E-Paper-Calendar/Calendar/E-Paper.py

77 lines
2.4 KiB
Python
Raw Normal View History

#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
E-Paper Software (main script) for the 3-colour and 2-Colour E-Paper display
A full and detailed breakdown for this code can be found in the wiki.
If you have any questions, feel free to open an issue at Github.
Copyright by aceisace
"""
from datetime import datetime
from time import sleep
from Assets import datetime_locals
import locale
from DebugConsole import DebugConsole
from settings import *
from MonthOvPanel import MonthOvPanel
import OwmForecasts
import IcalEvents
locale.setlocale(locale.LC_ALL, datetime_locals[language])
debug = DebugConsole()
output_adapters = []
if render_to_file:
import ImageFileAdapter
epd = ImageFileAdapter.ImageFileAdapter()
output_adapters.append(epd)
if render_to_display:
if display_colours == "bwr":
import Epd7in5bAdapter
epd = Epd7in5bAdapter.Epd7in5bAdapter()
output_adapters.append(epd)
elif display_colours == "bw":
import Epd7in5Adapter
epd = Epd7in5Adapter.Epd7in5Adapter()
output_adapters.append(epd)
"""Main loop starts from here"""
def main ():
while True:
time = datetime.now()
hour = int(time.strftime("%H"))
month = int(time.now().strftime('%m'))
year = int(time.now().strftime('%Y'))
for i in range(1):
debug.print_line('_________Starting new loop___________')
debug.print_line('Date: '+ time.strftime('%a %d %b %y') + ', time: ' + time.strftime('%H:%M') + '\n')
if hour in calibrate_hours:
for output in output_adapters:
output.calibrate()
design = MonthOvPanel((epd.width, epd.height))
debug.print_line("Fetching weather information from open weather map'")
owm = OwmForecasts.OwmForecasts(api_key)
design.add_weather(OwmForecasts.OwmForecasts(api_key))
debug.print_line('Fetching events from your calendar')
2019-03-02 09:36:55 +01:00
events_cal = IcalEvents.IcalEvents(ical_urls)
design.add_calendar(events_cal)
for output in output_adapters:
output.render(design)
debug.print_line("=> Finished rendering" + "\n")
for i in range(1):
nexthour = ((60 - int(time.strftime("%M"))) * 60) - (int(time.strftime("%S")))
sleep(nexthour)
if __name__ == '__main__':
main()