@@ -116,9 +116,8 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
116116 bool begin (TwoWire &wirePort=Wire, uint8_t address=kNoAddressSet ){
117117
118118 // defaults for Arduino Print
119- _cursorX = 0 ;
120- _cursorY = 0 ;
121- _color = COLOR_WHITE;
119+ setCursor (0 ,0 );
120+ setColor (COLOR_WHITE);
122121
123122 _i2cBus.init (wirePort);
124123
@@ -582,7 +581,7 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
582581 void text (uint8_t x0, uint8_t y0, const char * text, uint8_t clr=COLOR_WHITE){
583582 _device.text (x0, y0, text, clr);
584583 }
585-
584+
586585 void text (uint8_t x0, uint8_t y0, String &text, uint8_t clr=COLOR_WHITE){
587586
588587 _device.text (x0, y0, text.c_str (), clr);
@@ -654,24 +653,30 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
654653 if (!pFont) // no Font?! No dice?
655654 return 0 ;
656655
656+
657657 switch (theChar){
658658 case ' \n ' : // Carriage return
659659 _cursorX = 0 ;
660660 _cursorY += pFont->height ;
661661 case ' \r ' : // Line feed - do nothing
662662 break ;
663663 default :
664- _device.text (_cursorX, _cursorY, (const char *)&theChar, _color);
665- _cursorX += pFont->width ;
664+
665+ char buffer[2 ]={theChar, ' \0 ' }; // text() needs a c string
666+ _device.text (_cursorX, _cursorY, buffer, _color);
667+
668+ _cursorX += pFont->width + 1 ;
669+
666670 if ( _cursorX > _device.get_width () - pFont->width ){ // overflow
667671 _cursorX = 0 ;
668672 _cursorY += pFont->height ;
669673
670674 }
671675 break ;
672676 }
673- if (_cursorY > _device.get_height ()) // check for overflow
674- _cursorY = pFont->height ;
677+ if (_cursorY >= _device.get_height ()) // check for overflow
678+ _cursorY = 0 ;
679+
675680 return 1 ;
676681 }
677682
0 commit comments