diff options
| author | Jacob McDonnell <jacob@simplelittledream.com> | 2022-09-27 13:06:14 -0400 |
|---|---|---|
| committer | Jacob McDonnell <jacob@simplelittledream.com> | 2022-09-27 13:06:14 -0400 |
| commit | 380b7f432f93b82edd23e5c7921cb77c3479fbd3 (patch) | |
| tree | 9989b2ad2ce58832862012101d17f8455c74cc10 /main.py | |
Initial Commit
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -0,0 +1,50 @@ +from cal import getEventsFromCal +from natDay import getNationalDay +from news import getHeadlines +from quote import getQuote +from weather import getForecast +import datetime +from settings import modules, general +from time import sleep +from Adafruit_Thermal import * +import textwrap + +name = general["name"] +today = datetime.date.today().strftime("%A %m-%d-%Y") +printer = Adafruit_Thermal("/dev/ttyS0", 19200, timeout=5) +lineWidth = 32 + +output = ["The Morning Paper:", f"Good Morning {name}, Today is {today}"] + +mods = { + "quote": getQuote(), + "national day": getNationalDay(), + "weather": getForecast(), + "calendar": getEventsFromCal(), + "news": getHeadlines() +} + + +def main(): + for module in modules: + if modules[module]: + for line in mods[module]: + line = line.replace("\n", "") + printer.println(textwrap.fill(line, lineWidth)) + printer.feed(1) + +printer.wake() +printer.setSize('M') +sleep(10) + + +for line in output: + printer.println(textwrap.fill(line, lineWidth)) +try: + main() +except: + sleep(30) + main() + +printer.feed(6) +printer.sleep() |
