Fix OLED timeout on satisfaction75 after migration from QWIIC (#14780)
The custom OLED_OFF mode implemented on satisfaction75 is incompatible with the OLED_TIMEOUT feature (the OLED_TIMEOUT code assumes that any key or encoder action should turn the OLED display on, and does not provide any way to disable that behavior). To keep the OLED_OFF mode functioning as before while still having a working OLED idle timeout, a custom implementation of the OLED idle timeout code is added.
This commit is contained in:
parent
0ea72af8b7
commit
2d3bd7cfcf
4 changed files with 87 additions and 8 deletions
|
@ -8,7 +8,7 @@ void draw_clock(void);
|
|||
__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_0; }
|
||||
|
||||
__attribute__((weak)) void oled_task_user(void) {
|
||||
if (!is_oled_on()) {
|
||||
if (!oled_task_needs_to_repaint()) {
|
||||
return;
|
||||
}
|
||||
oled_clear();
|
||||
|
@ -27,6 +27,70 @@ __attribute__((weak)) void oled_task_user(void) {
|
|||
}
|
||||
}
|
||||
|
||||
// Request a repaint of the OLED image without resetting the OLED sleep timer.
|
||||
// Used for things like clock updates that should not keep the OLED turned on
|
||||
// if there is no other activity.
|
||||
void oled_request_repaint(void) {
|
||||
if (is_oled_on()) {
|
||||
oled_repaint_requested = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Request a repaint of the OLED image and reset the OLED sleep timer.
|
||||
// Needs to be called after any activity that should keep the OLED turned on.
|
||||
void oled_request_wakeup(void) {
|
||||
oled_wakeup_requested = true;
|
||||
}
|
||||
|
||||
// Check whether oled_task_user() needs to repaint the OLED image. This
|
||||
// function should be called at the start of oled_task_user(); it also handles
|
||||
// the OLED sleep timer and the OLED_OFF mode.
|
||||
bool oled_task_needs_to_repaint(void) {
|
||||
// In the OLED_OFF mode the OLED is kept turned off; any wakeup requests
|
||||
// are ignored.
|
||||
if ((oled_mode == OLED_OFF) && !clock_set_mode) {
|
||||
oled_wakeup_requested = false;
|
||||
oled_repaint_requested = false;
|
||||
oled_off();
|
||||
return false;
|
||||
}
|
||||
|
||||
// If OLED wakeup was requested, reset the sleep timer and do a repaint.
|
||||
if (oled_wakeup_requested) {
|
||||
oled_wakeup_requested = false;
|
||||
oled_repaint_requested = false;
|
||||
oled_sleep_timer = timer_read32() + CUSTOM_OLED_TIMEOUT;
|
||||
oled_on();
|
||||
return true;
|
||||
}
|
||||
|
||||
// If OLED repaint was requested, just do a repaint without touching the
|
||||
// sleep timer.
|
||||
if (oled_repaint_requested) {
|
||||
oled_repaint_requested = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the OLED is currently off, skip the repaint (which would turn the
|
||||
// OLED on if the image is changed in any way).
|
||||
if (!is_oled_on()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sleep timer has expired while the OLED was on, turn the OLED off.
|
||||
if (timer_expired32(timer_read32(), oled_sleep_timer)) {
|
||||
oled_off();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Always perform a repaint if the OLED is currently on. (This can
|
||||
// potentially be optimized to avoid unneeded repaints if all possible
|
||||
// state changes are covered by oled_request_repaint() or
|
||||
// oled_request_wakeup(), but then any missed calls to these functions
|
||||
// would result in displaying a stale image.)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void draw_line_h(uint8_t x, uint8_t y, uint8_t len) {
|
||||
for (uint8_t i = 0; i < len; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue