MCPcopy Create free account
hub / github.com/PricelessToolkit/MailBoxGuard / drawLogBuffer

Method drawLogBuffer

Code/Arduino_libraries/SSD1306/OLEDDisplay.cpp:822–852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

820}
821
822void OLEDDisplay::drawLogBuffer(uint16_t xMove, uint16_t yMove) {
823 uint16_t lineHeight = pgm_read_byte(fontData + HEIGHT_POS);
824 // Always align left
825 setTextAlignment(TEXT_ALIGN_LEFT);
826
827 // State values
828 uint16_t length = 0;
829 uint16_t line = 0;
830 uint16_t lastPos = 0;
831
832 for (uint16_t i=0;i<this->logBufferFilled;i++){
833 // Everytime we have a \n print
834 if (this->logBuffer[i] == 10) {
835 length++;
836 // Draw string on line `line` from lastPos to length
837 // Passing 0 as the lenght because we are in TEXT_ALIGN_LEFT
838 drawStringInternal(xMove, yMove + (line++) * lineHeight, &this->logBuffer[lastPos], length, 0, false);
839 // Remember last pos
840 lastPos = i;
841 // Reset length
842 length = 0;
843 } else {
844 // Count chars until next linebreak
845 length++;
846 }
847 }
848 // Draw the remaining string
849 if (length > 0) {
850 drawStringInternal(xMove, yMove + line * lineHeight, &this->logBuffer[lastPos], length, 0, false);
851 }
852}
853
854uint16_t OLEDDisplay::getWidth(void) {
855 return displayWidth;

Callers

nothing calls this directly

Calls 1

pgm_read_byteFunction · 0.85

Tested by

no test coverage detected