aboutsummaryrefslogtreecommitdiff
path: root/drivers/oled/oled_driver.c
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2019-08-25 14:37:55 -0500
committerDrashna Jaelre <drashna@live.com>2019-08-25 12:37:55 -0700
commit957070a6b5886719557b6880afa7e3716548c18a (patch)
tree68adde454ad00f5c74538b0927f76b7db7afcb09 /drivers/oled/oled_driver.c
parentf22c5c17b6fe069bec1241262a1c27eb89d3d3af (diff)
downloadqmk_firmware-957070a6b5886719557b6880afa7e3716548c18a.tar.gz
qmk_firmware-957070a6b5886719557b6880afa7e3716548c18a.zip
Added OLED Display autoscroll during periods of OLED data inactivity (#6546)
* Added OLED Display autoscroll during periods of OLED data inactivity. * Fixing compile errors * Feedback from review
Diffstat (limited to 'drivers/oled/oled_driver.c')
-rw-r--r--drivers/oled/oled_driver.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index 2b3dd7ff2..3dad72add 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -114,8 +114,11 @@ bool oled_active = false;
114bool oled_scrolling = false; 114bool oled_scrolling = false;
115uint8_t oled_rotation = 0; 115uint8_t oled_rotation = 0;
116uint8_t oled_rotation_width = 0; 116uint8_t oled_rotation_width = 0;
117#if !defined(OLED_DISABLE_TIMEOUT) 117#if OLED_TIMEOUT > 0
118 uint16_t oled_last_activity; 118 uint32_t oled_timeout;
119#endif
120#if OLED_SCROLL_TIMEOUT > 0
121 uint32_t oled_scroll_timeout;
119#endif 122#endif
120 123
121// Internal variables to reduce math instructions 124// Internal variables to reduce math instructions
@@ -209,6 +212,13 @@ bool oled_init(uint8_t rotation) {
209 return false; 212 return false;
210 } 213 }
211 214
215#if OLED_TIMEOUT > 0
216 oled_timeout = timer_read32() + OLED_TIMEOUT;
217#endif
218#if OLED_SCROLL_TIMEOUT > 0
219 oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
220#endif
221
212 oled_clear(); 222 oled_clear();
213 oled_initialized = true; 223 oled_initialized = true;
214 oled_active = true; 224 oled_active = true;
@@ -457,8 +467,8 @@ void oled_write_ln_P(const char *data, bool invert) {
457#endif // defined(__AVR__) 467#endif // defined(__AVR__)
458 468
459bool oled_on(void) { 469bool oled_on(void) {
460#if !defined(OLED_DISABLE_TIMEOUT) 470#if OLED_TIMEOUT > 0
461 oled_last_activity = timer_read(); 471 oled_timeout = timer_read32() + OLED_TIMEOUT;
462#endif 472#endif
463 473
464 static const uint8_t PROGMEM display_on[] = { I2C_CMD, DISPLAY_ON }; 474 static const uint8_t PROGMEM display_on[] = { I2C_CMD, DISPLAY_ON };
@@ -522,6 +532,7 @@ bool oled_scroll_off(void) {
522 return oled_scrolling; 532 return oled_scrolling;
523 } 533 }
524 oled_scrolling = false; 534 oled_scrolling = false;
535 oled_dirty = -1;
525 } 536 }
526 return !oled_scrolling; 537 return !oled_scrolling;
527} 538}
@@ -549,15 +560,32 @@ void oled_task(void) {
549 560
550 oled_task_user(); 561 oled_task_user();
551 562
563#if OLED_SCROLL_TIMEOUT > 0
564 if (oled_dirty && oled_scrolling) {
565 oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
566 oled_scroll_off();
567 }
568#endif
569
552 // Smart render system, no need to check for dirty 570 // Smart render system, no need to check for dirty
553 oled_render(); 571 oled_render();
554 572
555 // Display timeout check 573 // Display timeout check
556#if !defined(OLED_DISABLE_TIMEOUT) 574#if OLED_TIMEOUT > 0
557 if (oled_active && timer_elapsed(oled_last_activity) > OLED_TIMEOUT) { 575 if (oled_active && timer_expired32(timer_read32(), oled_timeout)) {
558 oled_off(); 576 oled_off();
559 } 577 }
560#endif 578#endif
579
580#if OLED_SCROLL_TIMEOUT > 0
581 if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) {
582#ifdef OLED_SCROLL_TIMEOUT_RIGHT
583 oled_scroll_right();
584#else
585 oled_scroll_left();
586#endif
587 }
588#endif
561} 589}
562 590
563__attribute__((weak)) 591__attribute__((weak))