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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
from cal import getEventsFromCal
from natDay import getNationalDay
from news import getHeadlines
from quote import getQuote
from weather import getHourlyForecast, getDetailedForecast
import datetime
from settings import modules, general, lineWidth
from time import sleep
from Adafruit_Thermal import *
from textwrap import fill
from ipqr import getQrCode
from PIL import Image
name = general["name"]
today = datetime.date.today().strftime("%A %m-%d-%Y")
printer = Adafruit_Thermal("/dev/ttyS0", 19200, timeout=5)
output = ["The Morning Paper:", f"Good Morning {name}, Today is {today}"]
mods = {
"quote": getQuote(),
"national day": getNationalDay(),
"Detailed": getDetailedForecast(),
"Hourly": getHourlyForecast(),
"calendar": getEventsFromCal(),
"news": getHeadlines()
}
def main():
for module in modules:
if modules[module]:
for line in mods[module]:
line = line.replace("\n", "")
printer.println(fill(line, lineWidth))
printer.feed(1)
def printSettingsPage():
printer.println("Settings")
try:
getQrCode()
qr = Image.open(r"ipqr.png")
printer.println(fill("Scan the QR Code below to access settings", lineWidth))
printer.printImage(qr)
except:
printer.println("No Network Connection")
printer.wake()
printer.setSize('M')
sleep(10)
for line in output:
printer.println(fill(line, lineWidth))
try:
main()
except:
sleep(30)
main()
printSettingsPage()
printer.feed(6)
printer.sleep()
|