From 0de72941ce63636d4a6df7773b8666f11f988ce3 Mon Sep 17 00:00:00 2001 From: zvecr Date: Sun, 13 Nov 2022 21:00:41 +0000 Subject: [PATCH 1/3] Add default limit to OLED dirty processing --- drivers/oled/oled_driver.h | 4 ++++ drivers/oled/ssd1306_sh1106.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index e9b8c5b4e877..291049e36bd7 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h @@ -170,6 +170,10 @@ along with this program. If not, see . # define OLED_UPDATE_INTERVAL 50 #endif +#if !defined(OLED_UPDATE_PROCESS_LIMIT) +# define OLED_UPDATE_PROCESS_LIMIT 1 +#endif + typedef struct __attribute__((__packed__)) { uint8_t *current_element; uint16_t remaining_element_count; diff --git a/drivers/oled/ssd1306_sh1106.c b/drivers/oled/ssd1306_sh1106.c index 9fc8c2d2adf6..cff0c37d1b48 100644 --- a/drivers/oled/ssd1306_sh1106.c +++ b/drivers/oled/ssd1306_sh1106.c @@ -300,8 +300,9 @@ void oled_render(void) { // Turn on display if it is off oled_on(); - uint8_t update_start = 0; - while (oled_dirty) { // render all dirty blocks + uint8_t update_start = 0; + uint8_t oled_dirty_count = 0; + while (oled_dirty && oled_dirty_count++ < OLED_UPDATE_PROCESS_LIMIT) { // render all dirty blocks // Find next dirty block while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) { ++update_start; From bed1444e1ab0172874bda2b4aaeae20f9b35ebb7 Mon Sep 17 00:00:00 2001 From: zvecr Date: Sun, 13 Nov 2022 21:03:44 +0000 Subject: [PATCH 2/3] update comment --- drivers/oled/ssd1306_sh1106.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/oled/ssd1306_sh1106.c b/drivers/oled/ssd1306_sh1106.c index cff0c37d1b48..b23ffc2e8606 100644 --- a/drivers/oled/ssd1306_sh1106.c +++ b/drivers/oled/ssd1306_sh1106.c @@ -300,9 +300,9 @@ void oled_render(void) { // Turn on display if it is off oled_on(); - uint8_t update_start = 0; - uint8_t oled_dirty_count = 0; - while (oled_dirty && oled_dirty_count++ < OLED_UPDATE_PROCESS_LIMIT) { // render all dirty blocks + uint8_t update_start = 0; + uint8_t dirty_count = 0; + while (oled_dirty && dirty_count++ < OLED_UPDATE_PROCESS_LIMIT) { // render all dirty blocks (up to the configured limit) // Find next dirty block while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) { ++update_start; From 7ca689bbbda945c47a314d81078066a5bdc4d211 Mon Sep 17 00:00:00 2001 From: zvecr Date: Sun, 13 Nov 2022 22:36:42 +0000 Subject: [PATCH 3/3] rename var --- drivers/oled/ssd1306_sh1106.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/oled/ssd1306_sh1106.c b/drivers/oled/ssd1306_sh1106.c index b23ffc2e8606..342920572e3a 100644 --- a/drivers/oled/ssd1306_sh1106.c +++ b/drivers/oled/ssd1306_sh1106.c @@ -300,9 +300,9 @@ void oled_render(void) { // Turn on display if it is off oled_on(); - uint8_t update_start = 0; - uint8_t dirty_count = 0; - while (oled_dirty && dirty_count++ < OLED_UPDATE_PROCESS_LIMIT) { // render all dirty blocks (up to the configured limit) + uint8_t update_start = 0; + uint8_t num_processed = 0; + while (oled_dirty && num_processed++ < OLED_UPDATE_PROCESS_LIMIT) { // render all dirty blocks (up to the configured limit) // Find next dirty block while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) { ++update_start;