Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* https://www.reddit.com/r/olkb/comments/10m0zw8/qmk_timeout_image_on_oled_screens/
- * Code to enable a screensaver for an OLED display.
- * Code to actually animate the screensaver is not included here.
- */
- // config.h -------------------------------------------------------------------
- #define MINUTE_TO_MS 60000 // 60 seconds * 1000 milliseconds
- #ifdef OLED_ENABLE
- #define OLED_SCREENSAVER_TIMEOUT 1 * MINUTE_TO_MS // 1 minute of no activity to turn on OLED screensaver
- #define OLED_TIMEOUT 10 * MINUTE_TO_MS // 10 minutes of no activity to turn OLED off
- #endif
- // keymap.c ----------------------------------------------------------------
- #ifdef OLED_ENABLE
- bool oled_screensaver_active = false;
- bool oled_task_user(void) {
- // if oled is off, make sure screensaver is disabled, and do nothing else
- if (!is_oled_on()) {
- oled_screensaver_active = false;
- return true;
- }
- // if oled is on and it has been longer than OLED_SCREENSAVER_TIMEOUT since last matrix or encoder change, activate screensaver
- if (is_oled_on() && last_input_activity_elapsed() > OLED_SCREENSAVER_TIMEOUT) {
- oled_screensaver_active = true;
- }
- if (oled_screensaver_active) {
- // matrix rain animation code goes here
- // ...
- return true;
- }
- // normal oled display code goes here
- // ...
- return true;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement