diff --git a/firmware/application/event_m0.cpp b/firmware/application/event_m0.cpp index 82f0e6bde..d32fa0d3a 100644 --- a/firmware/application/event_m0.cpp +++ b/firmware/application/event_m0.cpp @@ -124,12 +124,12 @@ void EventDispatcher::request_stop() { 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. + // on baseband side, since all that data is being discarded during sleep. -- DON'T TODO it, sincethe stealth mode want to send with screen off! if (sleep) { portapack::backlight()->off(); - portapack::display.sleep(); + portapack::display.sleep(false); // when called the hw_sleep = true, the irq wont fire, so the EVT_MASK_LCD_FRAME_SYNC won't set. } else { - portapack::display.wake(); + portapack::display.wake(true); // not important, command not affect if already hw waken up // Don't turn on backlight here. // Let frame sync handler turn on backlight after repaint. } @@ -180,12 +180,10 @@ void EventDispatcher::dispatch(const eventmask_t events) { /*if( events & EVT_MASK_LCD_FRAME_SYNC ) { blink_timer(); }*/ - + if (events & EVT_MASK_LCD_FRAME_SYNC) { + handle_lcd_frame_sync(!EventDispatcher::display_sleep); + } if (!EventDispatcher::display_sleep) { - if (events & EVT_MASK_LCD_FRAME_SYNC) { - handle_lcd_frame_sync(); - } - if (events & EVT_MASK_ENCODER) { handle_encoder(); } @@ -328,17 +326,16 @@ ui::Widget* EventDispatcher::getFocusedWidget() { return context.focus_manager().focus_widget(); } -void EventDispatcher::handle_lcd_frame_sync() { +void EventDispatcher::handle_lcd_frame_sync(bool screen_on) { bool waiting_for_frame = this->waiting_for_frame; - DisplayFrameSyncMessage message; + DisplayFrameSyncMessage message; // send framesync msg all the time, bc some apps relay on it message_map.send(&message); - - static_cast(top_widget)->paint_overlay(); - painter.paint_widget_tree(top_widget); - - portapack::backlight()->on(); - + if (screen_on) { // only draw when screen is on + static_cast(top_widget)->paint_overlay(); + painter.paint_widget_tree(top_widget); + portapack::backlight()->on(); + } if (waiting_for_frame) this->waiting_for_frame = false; } diff --git a/firmware/application/event_m0.hpp b/firmware/application/event_m0.hpp index f84ba1b46..94c1e6b97 100644 --- a/firmware/application/event_m0.hpp +++ b/firmware/application/event_m0.hpp @@ -133,7 +133,7 @@ class EventDispatcher { void on_keyboard_event(ui::KeyboardEvent event); // void blink_timer(); - void handle_lcd_frame_sync(); + void handle_lcd_frame_sync(bool screen_on); void handle_switches(); void handle_encoder(); void handle_touch(); diff --git a/firmware/common/lcd_ili9341.cpp b/firmware/common/lcd_ili9341.cpp index a353df4e0..1bdf2b6fb 100644 --- a/firmware/common/lcd_ili9341.cpp +++ b/firmware/common/lcd_ili9341.cpp @@ -77,13 +77,17 @@ void lcd_display_off() { io.lcd_data_write_command_and_data(0x28, {}); } -void lcd_sleep() { +void lcd_sleep(bool hw_sleep = true) { lcd_display_off(); - lcd_sleep_in(); + if (hw_sleep) { + lcd_sleep_in(); + } } -void lcd_wake() { - lcd_sleep_out(); +void lcd_wake(bool hw_sleep = true) { + if (hw_sleep) { + lcd_sleep_out(); + } lcd_display_on(); } @@ -394,12 +398,12 @@ void ILI9341::shutdown() { lcd_reset(); } -void ILI9341::sleep() { - lcd_sleep(); +void ILI9341::sleep(bool hw_sleep) { + lcd_sleep(hw_sleep); } -void ILI9341::wake() { - lcd_wake(); +void ILI9341::wake(bool hw_sleep) { + lcd_wake(hw_sleep); } void ILI9341::fill_rectangle(ui::Rect r, const ui::Color c) { diff --git a/firmware/common/lcd_ili9341.hpp b/firmware/common/lcd_ili9341.hpp index 9add72f41..9bbc425d9 100644 --- a/firmware/common/lcd_ili9341.hpp +++ b/firmware/common/lcd_ili9341.hpp @@ -48,8 +48,8 @@ class ILI9341 { void init(); void shutdown(); - void sleep(); - void wake(); + void sleep(bool hw_sleep = true); + void wake(bool hw_sleep = true); void fill_rectangle(ui::Rect r, const ui::Color c); void fill_rectangle_unrolled8(ui::Rect r, const ui::Color c);