fix some bugs due to framesync not fired on stealth mode (#2834)

This commit is contained in:
Totoo 2025-10-18 13:13:51 +02:00 committed by GitHub
parent dafe3b7641
commit 200831ad67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 27 deletions

View file

@ -124,12 +124,12 @@ void EventDispatcher::request_stop() {
void EventDispatcher::set_display_sleep(const bool sleep) { void EventDispatcher::set_display_sleep(const bool sleep) {
// TODO: Distribute display sleep message more broadly, shut down data generation // 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) { if (sleep) {
portapack::backlight()->off(); 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 { } else {
portapack::display.wake(); portapack::display.wake(true); // not important, command not affect if already hw waken up
// Don't turn on backlight here. // Don't turn on backlight here.
// Let frame sync handler turn on backlight after repaint. // 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 ) { /*if( events & EVT_MASK_LCD_FRAME_SYNC ) {
blink_timer(); blink_timer();
}*/ }*/
if (!EventDispatcher::display_sleep) {
if (events & EVT_MASK_LCD_FRAME_SYNC) { if (events & EVT_MASK_LCD_FRAME_SYNC) {
handle_lcd_frame_sync(); handle_lcd_frame_sync(!EventDispatcher::display_sleep);
} }
if (!EventDispatcher::display_sleep) {
if (events & EVT_MASK_ENCODER) { if (events & EVT_MASK_ENCODER) {
handle_encoder(); handle_encoder();
} }
@ -328,17 +326,16 @@ ui::Widget* EventDispatcher::getFocusedWidget() {
return context.focus_manager().focus_widget(); 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; 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); message_map.send(&message);
if (screen_on) { // only draw when screen is on
static_cast<ui::SystemView*>(top_widget)->paint_overlay(); static_cast<ui::SystemView*>(top_widget)->paint_overlay();
painter.paint_widget_tree(top_widget); painter.paint_widget_tree(top_widget);
portapack::backlight()->on(); portapack::backlight()->on();
}
if (waiting_for_frame) if (waiting_for_frame)
this->waiting_for_frame = false; this->waiting_for_frame = false;
} }

View file

@ -133,7 +133,7 @@ class EventDispatcher {
void on_keyboard_event(ui::KeyboardEvent event); void on_keyboard_event(ui::KeyboardEvent event);
// void blink_timer(); // void blink_timer();
void handle_lcd_frame_sync(); void handle_lcd_frame_sync(bool screen_on);
void handle_switches(); void handle_switches();
void handle_encoder(); void handle_encoder();
void handle_touch(); void handle_touch();

View file

@ -77,13 +77,17 @@ void lcd_display_off() {
io.lcd_data_write_command_and_data(0x28, {}); io.lcd_data_write_command_and_data(0x28, {});
} }
void lcd_sleep() { void lcd_sleep(bool hw_sleep = true) {
lcd_display_off(); lcd_display_off();
if (hw_sleep) {
lcd_sleep_in(); lcd_sleep_in();
} }
}
void lcd_wake() { void lcd_wake(bool hw_sleep = true) {
if (hw_sleep) {
lcd_sleep_out(); lcd_sleep_out();
}
lcd_display_on(); lcd_display_on();
} }
@ -394,12 +398,12 @@ void ILI9341::shutdown() {
lcd_reset(); lcd_reset();
} }
void ILI9341::sleep() { void ILI9341::sleep(bool hw_sleep) {
lcd_sleep(); lcd_sleep(hw_sleep);
} }
void ILI9341::wake() { void ILI9341::wake(bool hw_sleep) {
lcd_wake(); lcd_wake(hw_sleep);
} }
void ILI9341::fill_rectangle(ui::Rect r, const ui::Color c) { void ILI9341::fill_rectangle(ui::Rect r, const ui::Color c) {

View file

@ -48,8 +48,8 @@ class ILI9341 {
void init(); void init();
void shutdown(); void shutdown();
void sleep(); void sleep(bool hw_sleep = true);
void wake(); void wake(bool hw_sleep = true);
void fill_rectangle(ui::Rect r, const ui::Color c); void fill_rectangle(ui::Rect r, const ui::Color c);
void fill_rectangle_unrolled8(ui::Rect r, const ui::Color c); void fill_rectangle_unrolled8(ui::Rect r, const ui::Color c);