2019-02-03 16:26:30 +01:00
|
|
|
#!/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
|
2019-02-28 15:17:43 +01:00
|
|
|
from Assets import datetime_locals
|
|
|
|
import locale
|
2019-02-26 22:09:19 +01:00
|
|
|
from DebugConsole import DebugConsole
|
2019-02-03 16:26:30 +01:00
|
|
|
from settings import *
|
2019-02-28 15:17:43 +01:00
|
|
|
from MonthOvPanel import MonthOvPanel
|
2019-03-08 17:46:10 +01:00
|
|
|
from DayListPanel import DayListPanel
|
2019-02-23 19:49:20 +01:00
|
|
|
import OwmForecasts
|
2019-02-26 22:09:19 +01:00
|
|
|
import IcalEvents
|
2019-03-04 20:10:36 +01:00
|
|
|
import RssParserPosts
|
2019-02-03 16:26:30 +01:00
|
|
|
|
2019-02-28 15:17:43 +01:00
|
|
|
locale.setlocale(locale.LC_ALL, datetime_locals[language])
|
|
|
|
debug = DebugConsole()
|
2019-02-25 21:57:22 +01:00
|
|
|
output_adapters = []
|
2019-02-20 20:56:10 +01:00
|
|
|
|
2019-02-25 21:57:22 +01:00
|
|
|
if render_to_file:
|
2019-02-20 20:56:10 +01:00
|
|
|
import ImageFileAdapter
|
|
|
|
epd = ImageFileAdapter.ImageFileAdapter()
|
2019-02-25 21:57:22 +01:00
|
|
|
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)
|
2019-02-03 16:26:30 +01:00
|
|
|
|
2019-03-08 17:46:10 +01:00
|
|
|
available_panels = {
|
|
|
|
"day-list" : DayListPanel,
|
|
|
|
"month-overview" : MonthOvPanel
|
|
|
|
}
|
|
|
|
|
2019-02-03 16:26:30 +01:00
|
|
|
"""Main loop starts from here"""
|
2019-02-23 19:49:20 +01:00
|
|
|
def main ():
|
2019-02-03 16:26:30 +01:00
|
|
|
while True:
|
|
|
|
|
|
|
|
time = datetime.now()
|
2019-02-20 20:56:10 +01:00
|
|
|
hour = int(time.strftime("%H"))
|
|
|
|
month = int(time.now().strftime('%m'))
|
2019-02-03 16:26:30 +01:00
|
|
|
year = int(time.now().strftime('%Y'))
|
|
|
|
|
|
|
|
for i in range(1):
|
2019-03-03 16:40:14 +01:00
|
|
|
debug.print_line('_________Starting new loop___________')
|
|
|
|
debug.print_line('Date: '+ time.strftime('%a %d %b %y') + ', time: ' + time.strftime('%H:%M') + '\n')
|
2019-02-03 16:26:30 +01:00
|
|
|
|
2019-02-25 21:57:22 +01:00
|
|
|
if hour in calibrate_hours:
|
2019-02-26 22:09:19 +01:00
|
|
|
for output in output_adapters:
|
|
|
|
output.calibrate()
|
2019-02-03 16:26:30 +01:00
|
|
|
|
2019-03-08 17:46:10 +01:00
|
|
|
if choosen_design in available_panels.keys():
|
|
|
|
design = available_panels[choosen_design]((epd.width, epd.height))
|
|
|
|
else:
|
|
|
|
raise ImportError("choosen_design must be valid (" + choosen_design + ")")
|
2019-02-03 16:26:30 +01:00
|
|
|
|
2019-03-04 20:22:40 +01:00
|
|
|
debug.print_line("Fetching weather information from open weather map")
|
2019-03-09 15:46:42 +01:00
|
|
|
owm = OwmForecasts.OwmForecasts(location, api_key)
|
|
|
|
design.add_weather(owm)
|
2019-02-28 15:17:43 +01:00
|
|
|
|
2019-03-06 22:15:53 +01:00
|
|
|
debug.print_line('Fetching events from your calendar')
|
|
|
|
events_cal = IcalEvents.IcalEvents(ical_urls)
|
|
|
|
design.add_calendar(events_cal)
|
2019-03-04 20:10:36 +01:00
|
|
|
|
|
|
|
debug.print_line('Fetching posts from your rss-feeds')
|
|
|
|
rss = RssParserPosts.RssParserPosts(rss_feeds)
|
|
|
|
design.add_rssfeed(rss)
|
2019-02-28 15:17:43 +01:00
|
|
|
|
2019-02-25 21:57:22 +01:00
|
|
|
for output in output_adapters:
|
2019-02-28 15:17:43 +01:00
|
|
|
output.render(design)
|
2019-02-03 16:26:30 +01:00
|
|
|
|
2019-03-03 16:40:14 +01:00
|
|
|
debug.print_line("=> Finished rendering" + "\n")
|
2019-02-26 22:09:19 +01:00
|
|
|
|
2019-02-03 16:26:30 +01:00
|
|
|
for i in range(1):
|
2019-02-23 19:49:20 +01:00
|
|
|
nexthour = ((60 - int(time.strftime("%M"))) * 60) - (int(time.strftime("%S")))
|
2019-02-03 16:26:30 +01:00
|
|
|
sleep(nexthour)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|