summaryrefslogtreecommitdiff
path: root/drivers/oled
diff options
context:
space:
mode:
authorChris Salch <emeraldd.chris@gmail.com>2023-09-14 03:20:03 -0500
committerGitHub <noreply@github.com>2023-09-14 01:20:03 -0700
commitd8e100ae3cc38a63889c5933cecc13b0a58f9277 (patch)
tree5b6b5ca25fea4713695e9f1f170709a0565ecedd /drivers/oled
parentb9d6bfe927c327dbfb197bb8e9e52ac2f07d7d48 (diff)
Allow force flush of oled display (#20953)
Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'drivers/oled')
-rw-r--r--drivers/oled/oled_driver.c4
-rw-r--r--drivers/oled/oled_driver.h20
2 files changed, 14 insertions, 10 deletions
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index 8ff6e0426c..ab04ff3d40 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -448,7 +448,7 @@ static void rotate_90(const uint8_t *src, uint8_t *dest) {
448 } 448 }
449} 449}
450 450
451void oled_render(void) { 451void oled_render_dirty(bool all) {
452 // Do we have work to do? 452 // Do we have work to do?
453 oled_dirty &= OLED_ALL_BLOCKS_MASK; 453 oled_dirty &= OLED_ALL_BLOCKS_MASK;
454 if (!oled_dirty || !oled_initialized || oled_scrolling) { 454 if (!oled_dirty || !oled_initialized || oled_scrolling) {
@@ -460,7 +460,7 @@ void oled_render(void) {
460 460
461 uint8_t update_start = 0; 461 uint8_t update_start = 0;
462 uint8_t num_processed = 0; 462 uint8_t num_processed = 0;
463 while (oled_dirty && num_processed++ < OLED_UPDATE_PROCESS_LIMIT) { // render all dirty blocks (up to the configured limit) 463 while (oled_dirty && (num_processed++ < OLED_UPDATE_PROCESS_LIMIT || all)) { // render all dirty blocks (up to the configured limit)
464 // Find next dirty block 464 // Find next dirty block
465 while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) { 465 while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) {
466 ++update_start; 466 ++update_start;
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 627a3da0ba..fba6633176 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -353,20 +353,24 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation);
353// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering 353// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering
354void oled_clear(void); 354void oled_clear(void);
355 355
356// Renders the dirty chunks of the buffer to oled display 356// Alias to oled_render_dirty to avoid a change in api.
357void oled_render(void); 357#define oled_render() oled_render_dirty(false)
358
359// Renders all dirty blocks to the display at one time or a subset depending on the value of
360// all.
361void oled_render_dirty(bool all);
358 362
359// Moves cursor to character position indicated by column and line, wraps if out of bounds 363// Moves cursor to character position indicated by column and line, wraps if out of bounds
360// Max column denoted by 'oled_max_chars()' and max lines by 'oled_max_lines()' functions 364// Max column denoted by 'oled_max_chars()' and max lines by 'oled_max_lines()' functions
361void oled_set_cursor(uint8_t col, uint8_t line); 365void oled_set_cursor(uint8_t col, uint8_t line);
362 366
363// Advances the cursor to the next page, writing ' ' if true 367// Advances the cursor to the next page, writing ' ' if true
364// Wraps to the begining when out of bounds 368// Wraps to the beginning when out of bounds
365void oled_advance_page(bool clearPageRemainder); 369void oled_advance_page(bool clearPageRemainder);
366 370
367// Moves the cursor forward 1 character length 371// Moves the cursor forward 1 character length
368// Advance page if there is not enough room for the next character 372// Advance page if there is not enough room for the next character
369// Wraps to the begining when out of bounds 373// Wraps to the beginning when out of bounds
370void oled_advance_char(void); 374void oled_advance_char(void);
371 375
372// Writes a single character to the buffer at current cursor position 376// Writes a single character to the buffer at current cursor position
@@ -433,10 +437,10 @@ bool oled_off(void);
433// not 437// not
434bool is_oled_on(void); 438bool is_oled_on(void);
435 439
436// Sets the brightness of the display 440// Sets the brightness level of the display
437uint8_t oled_set_brightness(uint8_t level); 441uint8_t oled_set_brightness(uint8_t level);
438 442
439// Gets the current brightness of the display 443// Gets the current brightness level of the display
440uint8_t oled_get_brightness(void); 444uint8_t oled_get_brightness(void);
441 445
442// Basically it's oled_render, but with timeout management and oled_task_user calling! 446// Basically it's oled_render, but with timeout management and oled_task_user calling!
@@ -458,12 +462,12 @@ void oled_scroll_set_area(uint8_t start_line, uint8_t end_line);
458// 0=2, 1=3, 2=4, 3=5, 4=25, 5=64, 6=128, 7=256 462// 0=2, 1=3, 2=4, 3=5, 4=25, 5=64, 6=128, 7=256
459void oled_scroll_set_speed(uint8_t speed); 463void oled_scroll_set_speed(uint8_t speed);
460 464
461// Scrolls the entire display right 465// Begin scrolling the entire display right
462// Returns true if the screen was scrolling or starts scrolling 466// Returns true if the screen was scrolling or starts scrolling
463// NOTE: display contents cannot be changed while scrolling 467// NOTE: display contents cannot be changed while scrolling
464bool oled_scroll_right(void); 468bool oled_scroll_right(void);
465 469
466// Scrolls the entire display left 470// Begin scrolling the entire display left
467// Returns true if the screen was scrolling or starts scrolling 471// Returns true if the screen was scrolling or starts scrolling
468// NOTE: display contents cannot be changed while scrolling 472// NOTE: display contents cannot be changed while scrolling
469bool oled_scroll_left(void); 473bool oled_scroll_left(void);