From b801366e4ef8a3d5d8920e5b8d1fa70f59a486f5 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 27 Jan 2016 21:03:34 -0800 Subject: [PATCH] Recover from display sleep, use LCD sleep function. --- firmware/application/event_m0.cpp | 30 ++++++++++++++++++++++++++---- firmware/application/event_m0.hpp | 5 +---- firmware/common/lcd_ili9341.cpp | 30 ++++++++++++++++++++++++------ firmware/common/lcd_ili9341.hpp | 3 +++ 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/firmware/application/event_m0.cpp b/firmware/application/event_m0.cpp index df694bb5d..dc5573979 100644 --- a/firmware/application/event_m0.cpp +++ b/firmware/application/event_m0.cpp @@ -86,6 +86,19 @@ void EventDispatcher::request_stop() { is_running = false; } +void EventDispatcher::set_display_sleep(const bool sleep) { + // TODO: Distribute display sleep message more broadly, shut down data generation + // on baseband side, since all that data is being discarded during sleep. + if( sleep ) { + portapack::io.lcd_backlight(false); + portapack::display.sleep(); + } else { + portapack::display.wake(); + portapack::io.lcd_backlight(true); + } + display_sleep = sleep; +}; + eventmask_t EventDispatcher::wait() { return chEvtWaitAny(ALL_EVENTS); } @@ -99,15 +112,15 @@ void EventDispatcher::dispatch(const eventmask_t events) { handle_rtc_tick(); } + if( events & EVT_MASK_SWITCHES ) { + handle_switches(); + } + if( !display_sleep ) { if( events & EVT_MASK_LCD_FRAME_SYNC ) { handle_lcd_frame_sync(); } - if( events & EVT_MASK_SWITCHES ) { - handle_switches(); - } - if( events & EVT_MASK_ENCODER ) { handle_encoder(); } @@ -181,6 +194,15 @@ void EventDispatcher::handle_lcd_frame_sync() { void EventDispatcher::handle_switches() { const auto switches_state = get_switches_state(); + + if( display_sleep ) { + // Swallow event, wake up display. + if( switches_state.any() ) { + set_display_sleep(false); + } + return; + } + for(size_t i=0; i