From 2d468c45a9ed5094f5a4f3a0313b40fb85576073 Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Mon, 19 Oct 2020 21:08:42 +0900 Subject: [PATCH] OLED display update interval support (#10388) * add OLED_UPDATE_INTERVAL_MS support * update docs/feature_oled_driver.md * Update docs/feature_oled_driver.md Co-authored-by: Joel Challis * Update drivers/oled/oled_driver.c * Update drivers/oled/oled_driver.c Co-authored-by: Joel Challis --- docs/feature_oled_driver.md | 1 + drivers/oled/oled_driver.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md index 9e33a321ce0d..f904a140ede6 100644 --- a/docs/feature_oled_driver.md +++ b/docs/feature_oled_driver.md @@ -149,6 +149,7 @@ void oled_task_user(void) { |`OLED_SCROLL_TIMEOUT_RIGHT`|*Not defined* |Scroll timeout direction is right when defined, left when undefined. | |`OLED_IC` |`OLED_IC_SSD1306`|Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. | |`OLED_COLUMN_OFFSET` |`0` |(SH1106 only.) Shift output to the right this many pixels.
Useful for 128x64 displays centered on a 132x64 SH1106 IC.| +|`OLED_UPDATE_INTERVAL` |`0` |Set the time interval for updating the OLED display in ms. This will improve the matrix scan rate. | ## 128x64 & Custom sized OLED Displays diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 0b24a987de52..123cd1e62904 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c @@ -118,6 +118,9 @@ uint32_t oled_timeout; #if OLED_SCROLL_TIMEOUT > 0 uint32_t oled_scroll_timeout; #endif +#if OLED_UPDATE_INTERVAL > 0 +uint16_t oled_update_timeout; +#endif // Internal variables to reduce math instructions @@ -635,6 +638,13 @@ void oled_task(void) { return; } +#if OLED_UPDATE_INTERVAL > 0 + if (timer_elapsed(oled_update_timeout) < OLED_UPDATE_INTERVAL) { + return; + } + oled_update_timeout = timer_read(); +#endif + oled_set_cursor(0, 0); oled_task_user();