def __draw_meeting_display(panel_size, meeting_state): infologging.log_message('__draw_meeting_display: ' + str(meeting_state)) if meeting_state == 1: return Image.new("RGB", panel_size, 'Red') elif meeting_state == 0: return Image.new("RGB", panel_size, 'Green') return Image.new("RGB", panel_size, 'Yellow')
def init(): infologging.log_message('lcd.init') LCD = LCD_1in44.LCD() Lcd_ScanDir = LCD_1in44.SCAN_DIR_DFT #SCAN_DIR_DFT = D2U_L2R LCD.LCD_Init(Lcd_ScanDir) LCD.LCD_Clear() return LCD
def main(): infologging.log_message('main.main()') LCD = init() counter = 0 update_meeting_display(LCD, meeting_state) while (1): main_loop(LCD) time.sleep(0.34)
def init_gpio(): infologging.log_message('init_gpio') GPIO.setmode(GPIO.BCM) GPIO.cleanup() GPIO.setup(KEY_UP_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up GPIO.setup(KEY_DOWN_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up GPIO.setup(KEY_LEFT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up GPIO.setup(KEY_RIGHT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up GPIO.setup(KEY_PRESS_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up GPIO.setup(KEY1_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up GPIO.setup(KEY2_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up GPIO.setup(KEY3_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up
def get_train_times(source, dest): log.log_message('trains: Getting session') session = DarwinLdbSession(wsdl=apis.darwin_api_url, api_key=apis.darwin_api_key) log.log_message('trains: Getting train times: ' + source + ' -> ' + dest) result = session.get_station_board(source, destination_crs=dest) log.log_message('trains: Got times: ' + source + ' -> ' + dest) return result
def get_news(): log.log_message('news: Getting news') headlines = get_headlines() articleCount = headlines['totalResults'] result = [] log.log_message('news: Collating headlines') i = 0 while (i < articleCount): article = Article(headlines['articles'][i]) result.append(article) i += 1 log.log_message('news: Returning headlines') return result
def update_meeting_display(LCD, meeting_state): infologging.log_message('main.update_meeting_display: ' + str(meeting_state)) image = display.get_updated_display((128, 128), meeting_state) lcd.show_image(LCD, image)
def init(): infologging.log_message('main.init()') infologging.setup_logging() keypad.init_gpio() return lcd.init()
def show_image(LCD, image): infologging.log_message('lcd.show_image') LCD.LCD_ShowImage(image, 0, 0)
import sys sys.path.insert(1, './display') import display import epaper import infologging as log import time epaper.initialise() log.setup_logging() try: while True: log.log_message('Creating image') image = display.createImage() epaper.display_on_e_paper(image) log.log_message('Sleeping') time.sleep(300) except: log.logging.exception('Exception thrown')
def get_updated_display(panel_size, meeting_state): infologging.log_message('get_updated_display: ' + str(meeting_state)) return __draw_meeting_display(panel_size, meeting_state)
def createImage(): image = draw.create_display(settings.displaysize) try: log.log_message('Header') displayheader.display_header(image, settings.header_location, settings.header_size) except: log.log_message('Header failed?') try: log.log_message('Weather') displayweather.display_weather(image, settings.weather_location, settings.weather_size) except: log.log_message('Weather failed?') try: log.log_message('News') displaynews.display_news(image, settings.news_location, settings.news_size) except: log.log_message('News failed?') try: log.log_message('Trains') displaytrains.display_trains(image, settings.trains_location, settings.trains_size) except: log.log_message('Trains failed?') try: log.log_message('Heating') displayheating.display_heating(image, settings.heating_location, settings.heating_size) except: log.log_message('Heating failed?') print("display: returning image") return image