forked from jarret/raspi-uart-waveshare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_show_image.py
executable file
·39 lines (33 loc) · 1.23 KB
/
test_show_image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
# Original: Copyright (c) 2019 Jarret Dyrbye
# Addded File Upload Capabilities giddyhup@github, 2021
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php
import time
import sys
from waveshare.epaper import EPaper
from waveshare.epaper import Handshake
from waveshare.epaper import RefreshAndUpdate
from waveshare.epaper import SetPallet
from waveshare.epaper import SetCurrentDisplayRotation
from waveshare.epaper import DisplayImage
from waveshare.epaper import SetStorageMode
def showImage(fname):
paper.send(SetStorageMode(b'\x01'))
paper.send(DisplayImage(0, 0, fname.encode()))
if __name__ == '__main__':
with EPaper() as paper:
try:
fname = sys.argv[1]
except:
print(f'Please supply a file to be displayed, e.g.\n'
f'{sys.argv[0]} TEST.JPG')
exit()
paper.send(Handshake())
time.sleep(2)
paper.send(SetPallet(SetPallet.BLACK, SetPallet.WHITE))
paper.send(SetCurrentDisplayRotation(SetCurrentDisplayRotation.FLIP))
showImage(fname)
time.sleep(10)
paper.send(RefreshAndUpdate())
time.sleep(10)