Skip to content

Commit

Permalink
Add default limit to OLED dirty processing (qmk#19068)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr authored and ramonimbao committed Nov 28, 2022
1 parent 1ab16bc commit dcef384
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions drivers/oled/oled_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# 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;
Expand Down
5 changes: 3 additions & 2 deletions drivers/oled/ssd1306_sh1106.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 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;
Expand Down

0 comments on commit dcef384

Please sign in to comment.