Skip to content

Commit

Permalink
OLED display update interval support (#10388)
Browse files Browse the repository at this point in the history
* add OLED_UPDATE_INTERVAL_MS support

* update docs/feature_oled_driver.md

* Update docs/feature_oled_driver.md

Co-authored-by: Joel Challis <git@zvecr.com>

* Update drivers/oled/oled_driver.c

* Update drivers/oled/oled_driver.c

Co-authored-by: Joel Challis <git@zvecr.com>
  • Loading branch information
2 people authored and noroadsleft committed Oct 30, 2020
1 parent 94fea35 commit 12be012
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/feature_oled_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void oled_task_user(void) {
|`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.<br />Useful for 128x64 displays centered on a 132x64 SH1106 IC.|
|`OLED_BRIGHTNESS` |`255` |The default brightness level of the OLED, from 0 to 255. |
|`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

Expand Down
10 changes: 10 additions & 0 deletions drivers/oled/oled_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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

Expand Down Expand Up @@ -650,6 +653,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();
Expand Down

0 comments on commit 12be012

Please sign in to comment.