summaryrefslogtreecommitdiff
path: root/drivers/oled
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2022-11-14 01:49:58 +0000
committerGitHub <noreply@github.com>2022-11-14 01:49:58 +0000
commit0719d68b205ecffd8f93dee07b7dd07d8bc8c615 (patch)
tree29acd55f8fad0092c12bb599de411978171459de /drivers/oled
parenta42ab90220ce01c2aebdebb09aa458f383d26892 (diff)
Add default limit to OLED dirty processing (#19068)
Diffstat (limited to 'drivers/oled')
-rw-r--r--drivers/oled/oled_driver.h4
-rw-r--r--drivers/oled/ssd1306_sh1106.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index e9b8c5b4e8..291049e36b 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -170,6 +170,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
170# define OLED_UPDATE_INTERVAL 50 170# define OLED_UPDATE_INTERVAL 50
171#endif 171#endif
172 172
173#if !defined(OLED_UPDATE_PROCESS_LIMIT)
174# define OLED_UPDATE_PROCESS_LIMIT 1
175#endif
176
173typedef struct __attribute__((__packed__)) { 177typedef struct __attribute__((__packed__)) {
174 uint8_t *current_element; 178 uint8_t *current_element;
175 uint16_t remaining_element_count; 179 uint16_t remaining_element_count;
diff --git a/drivers/oled/ssd1306_sh1106.c b/drivers/oled/ssd1306_sh1106.c
index 9fc8c2d2ad..342920572e 100644
--- a/drivers/oled/ssd1306_sh1106.c
+++ b/drivers/oled/ssd1306_sh1106.c
@@ -300,8 +300,9 @@ void oled_render(void) {
300 // Turn on display if it is off 300 // Turn on display if it is off
301 oled_on(); 301 oled_on();
302 302
303 uint8_t update_start = 0; 303 uint8_t update_start = 0;
304 while (oled_dirty) { // render all dirty blocks 304 uint8_t num_processed = 0;
305 while (oled_dirty && num_processed++ < OLED_UPDATE_PROCESS_LIMIT) { // render all dirty blocks (up to the configured limit)
305 // Find next dirty block 306 // Find next dirty block
306 while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) { 307 while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) {
307 ++update_start; 308 ++update_start;