adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino — Issue #1: line wrap in Print::print()
Author: wa5znu
Created: 2012-03-09 06:05:54+00:00
State: open

Adafruit_SSD1331::write and hence Print::print() obey \n but do not line-wrap at end of line or screen-wrap at bottom of screen.
Adafruit_SSD1331::drawString wraps at end of line, but does not obey \n or screen-wrap at bottom of screen.

This short change to write(c) makes print() obey \n and wrap both X and Y:

#if ARDUINO >= 100
size_t Adafruit_SSD1331::write(uint8_t c) {
#else
void Adafruit_SSD1331::write(uint8_t c) {
#endif
if (c == '\n') {
cursor_y += textsize*8;
cursor_x = 0;
if (cursor_y >= TFTHEIGHT) cursor_y = 0;
} else if (c == '\r') {
// skip em
} else {
drawChar(cursor_x, cursor_y, c, textcolor, textsize);
cursor_x += textsize*6;
if ((cursor_x+5) > TFTWIDTH) {
cursor_x = 0;
cursor_y += textsize*8;
if (cursor_y >= TFTHEIGHT) cursor_y = 0;
}
}
#if ARDUINO >= 100
return 1;
#endif
}