aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
parentf22c5c17b6fe069bec1241262a1c27eb89d3d3af (diff)
downloadfirmware-957070a6b5886719557b6880afa7e3716548c18a.tar.gz
firmware-957070a6b5886719557b6880afa7e3716548c18a.tar.bz2
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')
-rw-r--r--drivers/oled/oled_driver.c40
-rw-r--r--drivers/oled/oled_driver.h8
2 files changed, 42 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;
bool oled_scrolling = false;
uint8_t oled_rotation = 0;
uint8_t oled_rotation_width = 0;
-#if !defined(OLED_DISABLE_TIMEOUT)
- uint16_t oled_last_activity;
+#if OLED_TIMEOUT > 0
+ uint32_t oled_timeout;
+#endif
+#if OLED_SCROLL_TIMEOUT > 0
+ uint32_t oled_scroll_timeout;
#endif
// Internal variables to reduce math instructions
@@ -209,6 +212,13 @@ bool oled_init(uint8_t rotation) {
return false;
}
+#if OLED_TIMEOUT > 0
+ oled_timeout = timer_read32() + OLED_TIMEOUT;
+#endif
+#if OLED_SCROLL_TIMEOUT > 0
+ oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
+#endif
+
oled_clear();
oled_initialized = true;
oled_active = true;
@@ -457,8 +467,8 @@ void oled_write_ln_P(const char *data, bool invert) {
#endif // defined(__AVR__)
bool oled_on(void) {
-#if !defined(OLED_DISABLE_TIMEOUT)
- oled_last_activity = timer_read();
+#if OLED_TIMEOUT > 0
+ oled_timeout = timer_read32() + OLED_TIMEOUT;
#endif
static const uint8_t PROGMEM display_on[] = { I2C_CMD, DISPLAY_ON };
@@ -522,6 +532,7 @@ bool oled_scroll_off(void) {
return oled_scrolling;
}
oled_scrolling = false;
+ oled_dirty = -1;
}
return !oled_scrolling;
}
@@ -549,15 +560,32 @@ void oled_task(void) {
oled_task_user();
+#if OLED_SCROLL_TIMEOUT > 0
+ if (oled_dirty && oled_scrolling) {
+ oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
+ oled_scroll_off();
+ }
+#endif
+
// Smart render system, no need to check for dirty
oled_render();
// Display timeout check
-#if !defined(OLED_DISABLE_TIMEOUT)
- if (oled_active && timer_elapsed(oled_last_activity) > OLED_TIMEOUT) {
+#if OLED_TIMEOUT > 0
+ if (oled_active && timer_expired32(timer_read32(), oled_timeout)) {
oled_off();
}
#endif
+
+#if OLED_SCROLL_TIMEOUT > 0
+ if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) {
+#ifdef OLED_SCROLL_TIMEOUT_RIGHT
+ oled_scroll_right();
+#else
+ oled_scroll_left();
+#endif
+ }
+#endif
}
__attribute__((weak))
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 03dda2e64..4f6254c98 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -138,6 +138,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define OLED_FONT_HEIGHT 8
#endif
+#if !defined(OLED_TIMEOUT)
+ #if defined(OLED_DISABLE_TIMEOUT)
+ #define OLED_TIMEOUT 0
+ #else
+ #define OLED_TIMEOUT 60000
+ #endif
+#endif
+
// OLED Rotation enum values are flags
typedef enum {
OLED_ROTATION_0 = 0,