Minor improvements + Bugfixes
Fixed a bug where the update interval would be calculated incorrectly. The display will now update as specified in the settings file. Instead of importing a single driver file, this module will automatically import the driver file for the specified E-Paper (in the settings file). This means that even though more E-Papers are now supported, the code will not become too complex. Calibration has been omitted for now to test if the E-Paper shows signs of ghosting.
This commit is contained in:
parent
6400643039
commit
5d714665a4
@ -1,28 +1,27 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Main script of Inky-Calendar software.
|
v1.7.1
|
||||||
|
|
||||||
|
Main file of Inky-Calendar software. Creates dynamic images for each section,
|
||||||
|
assembles them and sends it to the E-Paper
|
||||||
|
|
||||||
Copyright by aceisace
|
Copyright by aceisace
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from configuration import *
|
|
||||||
from settings import *
|
|
||||||
import arrow
|
import arrow
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import gc
|
import gc
|
||||||
import inkycal_drivers as drivers
|
|
||||||
|
|
||||||
import inkycal_rss as rss
|
import inkycal_rss as rss
|
||||||
import inkycal_weather as weather
|
import inkycal_weather as weather
|
||||||
import inkycal_calendar as calendar
|
import inkycal_calendar as calendar
|
||||||
import inkycal_agenda as agenda
|
import inkycal_agenda as agenda
|
||||||
|
|
||||||
|
from configuration import *
|
||||||
|
import importlib
|
||||||
|
driver = importlib.import_module('drivers.'+model)
|
||||||
|
|
||||||
display = drivers.EPD()
|
"""Remove previously generated images"""
|
||||||
skip_calibration = False
|
|
||||||
|
|
||||||
"""Perepare for execution of main programm"""
|
|
||||||
calibration_countdown = 'initial'
|
|
||||||
image_cleanup()
|
image_cleanup()
|
||||||
|
|
||||||
"""Check time and calibrate display if time """
|
"""Check time and calibrate display if time """
|
||||||
@ -36,26 +35,6 @@ while True:
|
|||||||
'D MMM YYYY'), now.format('HH:mm')))
|
'D MMM YYYY'), now.format('HH:mm')))
|
||||||
print('-----------Main programm started now----------')
|
print('-----------Main programm started now----------')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""------------------Calibration check----------------"""
|
|
||||||
if skip_calibration != True:
|
|
||||||
print('Calibration..', end = ' ')
|
|
||||||
if now.hour in calibration_hours:
|
|
||||||
if calibration_countdown == 'initial':
|
|
||||||
print('required. Performing calibration now.')
|
|
||||||
calibration_countdown = 0
|
|
||||||
display.calibrate_display(3)
|
|
||||||
else:
|
|
||||||
if calibration_countdown % (60 // int(update_interval)) == 0:
|
|
||||||
display.calibrate_display(3)
|
|
||||||
calibration_countdown = 0
|
|
||||||
else:
|
|
||||||
print('not required. Continuing...')
|
|
||||||
else:
|
|
||||||
print('Calibration skipped!. Please note that not calibrating e-paper',
|
|
||||||
'displays causes ghosting')
|
|
||||||
|
|
||||||
"""----------------Generating and assembling images------"""
|
"""----------------Generating and assembling images------"""
|
||||||
if top_section == 'Weather':
|
if top_section == 'Weather':
|
||||||
try:
|
try:
|
||||||
@ -92,26 +71,41 @@ while True:
|
|||||||
image.save(image_path + 'canvas.png')
|
image.save(image_path + 'canvas.png')
|
||||||
|
|
||||||
"""---------Refreshing E-Paper with newly created image-----------"""
|
"""---------Refreshing E-Paper with newly created image-----------"""
|
||||||
display.show_image(image, reduce_colours= True)
|
epaper = driver.EPD()
|
||||||
|
print('Initialising E-Paper...', end = '')
|
||||||
|
epaper.init()
|
||||||
|
print('Done')
|
||||||
|
|
||||||
|
if three_colour_support == True:
|
||||||
|
print('Sending image data and refreshing display...', end='')
|
||||||
|
black_im, red_im = split_colours(image)
|
||||||
|
epaper.display(epaper.getbuffer(black_im), epaper.getbuffer(red_im))
|
||||||
|
print('Done')
|
||||||
|
else:
|
||||||
|
print('Sending image data and refreshing display...', end='')
|
||||||
|
epaper.display(epaper.getbuffer(image.convert('1', dither=True)))
|
||||||
|
print('Done')
|
||||||
|
|
||||||
|
print('Sending E-Paper to deep sleep...', end = '')
|
||||||
|
epaper.sleep()
|
||||||
|
print('Done')
|
||||||
|
|
||||||
"""--------------Post processing after main loop-----------------"""
|
"""--------------Post processing after main loop-----------------"""
|
||||||
"""Collect some garbage to free up some resources"""
|
"""Collect some garbage to free up some resources"""
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
"""Adjust calibration countdowns"""
|
|
||||||
if calibration_countdown == 'initial':
|
|
||||||
calibration_countdown = 0
|
|
||||||
calibration_countdown += 1
|
|
||||||
|
|
||||||
"""Calculate duration until next display refresh"""
|
"""Calculate duration until next display refresh"""
|
||||||
for _ in range(1):
|
for _ in range(1):
|
||||||
update_timings = [(60 - int(update_interval)*updates) for updates in
|
update_timings = [(60 - int(update_interval)*updates) for updates in
|
||||||
range(60//int(update_interval))]
|
range(60//int(update_interval))][::-1]
|
||||||
|
|
||||||
minutes = [i - now.minute for i in update_timings if i >= now.minute]
|
for _ in update_timings:
|
||||||
refresh_countdown = minutes[0]*60 + (60 - now.second)
|
if now.minute <= _:
|
||||||
|
minutes = _ - now.minute
|
||||||
|
break
|
||||||
|
|
||||||
print('{0} Minutes left until next refresh'.format(minutes[0]))
|
refresh_countdown = minutes*60 + (60 - now.second)
|
||||||
|
print('{0} Minutes left until next refresh'.format(minutes))
|
||||||
|
|
||||||
del update_timings, minutes, image
|
del update_timings, minutes, image
|
||||||
sleep(refresh_countdown)
|
sleep(refresh_countdown)
|
||||||
|
Loading…
Reference in New Issue
Block a user