Repository navigation
Expand file tree
/
Copy pathshowQuotes.py
More file actions
51 lines (42 loc) · 1.37 KB
/
Copy pathshowQuotes.py
File metadata and controls
51 lines (42 loc) · 1.37 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
import os
# libary
libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib')
if os.path.exists(libdir):
sys.path.append(libdir)
# import the rest of the modules
import logging
from datetime import date
from waveshare_epd import epd5in83
from PIL import Image
logging.basicConfig(level=logging.DEBUG)
def main():
try:
global epd; epd = epd5in83.EPD() #get the display
logging.info("init and clear")
epd.init() #init the display
epd.Clear()
#getting todays day of the year
dayOfYear = date.today().strftime('%j')
#drawing the quote and author to the screen
writeScreen(dayOfYear)
#exiting into sleep
logging.info("Goto Sleep...")
epd.sleep()
except IOError as e:
logging.info(e)
except KeyboardInterrupt:
logging.info("ctrl + c:")
epd5in83.epdconfig.module_exit()
exit()
def writeScreen(number_day: int):
#initiate the drawing of the black frame
image = Image.new('1', (epd.width, epd.height), 255)
image = Image.open(os.path.join("/home/justus/quotes/bmp/", str(number_day)+".bmp"))
#output to the display
logging.info("drawing to screen")
epd.display(epd.getbuffer(image))
if __name__ == '__main__':
main()