Skip to content

Commit 041ba32

Browse files
seifemarcelstoer
authored andcommitted
drawStringInternal: exit loop early if possible
there's no use in drawing characters outside the display ;-)
1 parent 132da60 commit 041ba32

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/OLEDDisplay.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ void OLEDDisplay::drawStringInternal(int16_t xMove, int16_t yMove, char* text, u
582582
for (uint16_t j = 0; j < textLength; j++) {
583583
int16_t xPos = xMove + cursorX;
584584
int16_t yPos = yMove + cursorY;
585+
if (xPos > this->width())
586+
break; // no need to continue
585587

586588
uint8_t code = text[j];
587589
if (code >= firstChar) {

0 commit comments

Comments
 (0)