mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-05-01 13:11:02 +00:00
Recover from display sleep, use LCD sleep function.
This commit is contained in:
parent
894d4b955c
commit
b801366e4e
@ -86,6 +86,19 @@ void EventDispatcher::request_stop() {
|
|||||||
is_running = false;
|
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() {
|
eventmask_t EventDispatcher::wait() {
|
||||||
return chEvtWaitAny(ALL_EVENTS);
|
return chEvtWaitAny(ALL_EVENTS);
|
||||||
}
|
}
|
||||||
@ -99,15 +112,15 @@ void EventDispatcher::dispatch(const eventmask_t events) {
|
|||||||
handle_rtc_tick();
|
handle_rtc_tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( events & EVT_MASK_SWITCHES ) {
|
||||||
|
handle_switches();
|
||||||
|
}
|
||||||
|
|
||||||
if( !display_sleep ) {
|
if( !display_sleep ) {
|
||||||
if( events & EVT_MASK_LCD_FRAME_SYNC ) {
|
if( events & EVT_MASK_LCD_FRAME_SYNC ) {
|
||||||
handle_lcd_frame_sync();
|
handle_lcd_frame_sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( events & EVT_MASK_SWITCHES ) {
|
|
||||||
handle_switches();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( events & EVT_MASK_ENCODER ) {
|
if( events & EVT_MASK_ENCODER ) {
|
||||||
handle_encoder();
|
handle_encoder();
|
||||||
}
|
}
|
||||||
@ -181,6 +194,15 @@ void EventDispatcher::handle_lcd_frame_sync() {
|
|||||||
|
|
||||||
void EventDispatcher::handle_switches() {
|
void EventDispatcher::handle_switches() {
|
||||||
const auto switches_state = get_switches_state();
|
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<switches_state.size(); i++) {
|
for(size_t i=0; i<switches_state.size(); i++) {
|
||||||
// TODO: Ignore multiple keys at the same time?
|
// TODO: Ignore multiple keys at the same time?
|
||||||
if( switches_state[i] ) {
|
if( switches_state[i] ) {
|
||||||
|
@ -55,10 +55,7 @@ public:
|
|||||||
void run();
|
void run();
|
||||||
void request_stop();
|
void request_stop();
|
||||||
|
|
||||||
void set_display_sleep(bool new_value) {
|
void set_display_sleep(const bool sleep);
|
||||||
portapack::io.lcd_backlight(false);
|
|
||||||
display_sleep = new_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline void events_flag(const eventmask_t events) {
|
static inline void events_flag(const eventmask_t events) {
|
||||||
if( thread_event_loop ) {
|
if( thread_event_loop ) {
|
||||||
|
@ -41,6 +41,20 @@ void lcd_reset() {
|
|||||||
chThdSleepMilliseconds(120);
|
chThdSleepMilliseconds(120);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcd_sleep_in() {
|
||||||
|
io.lcd_data_write_command_and_data(0x10, {});
|
||||||
|
chThdSleepMilliseconds(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_sleep_out() {
|
||||||
|
io.lcd_data_write_command_and_data(0x11, {});
|
||||||
|
chThdSleepMilliseconds(120);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_display_on() {
|
||||||
|
io.lcd_data_write_command_and_data(0x29, {});
|
||||||
|
}
|
||||||
|
|
||||||
void lcd_init() {
|
void lcd_init() {
|
||||||
// LCDs are configured for IM[2:0] = 001
|
// LCDs are configured for IM[2:0] = 001
|
||||||
// 8080-I system, 16-bit parallel bus
|
// 8080-I system, 16-bit parallel bus
|
||||||
@ -147,12 +161,8 @@ void lcd_init() {
|
|||||||
0x47, 0x04, 0x0C, 0x0B, 0x29, 0x2F, 0x05
|
0x47, 0x04, 0x0C, 0x0B, 0x29, 0x2F, 0x05
|
||||||
});
|
});
|
||||||
|
|
||||||
// Exit Sleep
|
lcd_sleep_out();
|
||||||
io.lcd_data_write_command_and_data(0x11, {});
|
lcd_display_on();
|
||||||
chThdSleepMilliseconds(120);
|
|
||||||
|
|
||||||
// Display on
|
|
||||||
io.lcd_data_write_command_and_data(0x29, {});
|
|
||||||
|
|
||||||
// Turn on Tearing Effect Line (TE) output signal.
|
// Turn on Tearing Effect Line (TE) output signal.
|
||||||
io.lcd_data_write_command_and_data(0x35, { 0b00000000 });
|
io.lcd_data_write_command_and_data(0x35, { 0b00000000 });
|
||||||
@ -230,6 +240,14 @@ void ILI9341::shutdown() {
|
|||||||
lcd_reset();
|
lcd_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ILI9341::sleep() {
|
||||||
|
lcd_sleep_in();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ILI9341::wake() {
|
||||||
|
lcd_sleep_out();
|
||||||
|
}
|
||||||
|
|
||||||
void ILI9341::fill_rectangle(ui::Rect r, const ui::Color c) {
|
void ILI9341::fill_rectangle(ui::Rect r, const ui::Color c) {
|
||||||
const auto r_clipped = r.intersect(screen_rect());
|
const auto r_clipped = r.intersect(screen_rect());
|
||||||
if( !r_clipped.is_empty() ) {
|
if( !r_clipped.is_empty() ) {
|
||||||
|
@ -44,6 +44,9 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
void sleep();
|
||||||
|
void wake();
|
||||||
|
|
||||||
void fill_rectangle(ui::Rect r, const ui::Color c);
|
void fill_rectangle(ui::Rect r, const ui::Color c);
|
||||||
void fill_circle(
|
void fill_circle(
|
||||||
const ui::Point center,
|
const ui::Point center,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user