diff options
Diffstat (limited to 'oled')
-rw-r--r-- | oled/ss_oled.c | 29 | ||||
-rw-r--r-- | oled/ss_oled.h | 2 |
2 files changed, 17 insertions, 14 deletions
diff --git a/oled/ss_oled.c b/oled/ss_oled.c index 3375bde..c29171f 100644 --- a/oled/ss_oled.c +++ b/oled/ss_oled.c @@ -1460,7 +1460,7 @@ void oledSetTextWrap(SSOLED *pOLED, int bWrap) // Draw a string of normal (8x8), small (6x8) or large (16x32) characters // At the given col+row // -int oledWriteString(SSOLED *pOLED, int iScroll, int x, int y, char *szMsg, int iSize, int bInvert, int bRender) +int oledWriteString(SSOLED *pOLED, int iScroll, int x, int y, const char *szMsg, int iSize, int bInvert, int bRender) { int i, iFontOff, iLen, iFontSkip; unsigned char c, *s, ucTemp[40]; @@ -1740,20 +1740,23 @@ unsigned char c, *s, ucTemp[40]; if (iScroll < 6) // if characters are visible { c = szMsg[i] - 32; - // we can't directly use the pointer to FLASH memory, so copy to a local buffer - ucTemp[0] = 0; - memcpy(&ucTemp[1], &ucSmallFont[(int)c*5], 5); - if (bInvert) InvertBytes(ucTemp, 6); - iLen = 6 - iFontSkip; - if (pOLED->iCursorX + iLen > pOLED->oled_x) // clip right edge - iLen = pOLED->oled_x - pOLED->iCursorX; - oledWriteDataBlock(pOLED, &ucTemp[iFontSkip], iLen, bRender); // write character pattern - // oledCachedWrite(ucTemp, 6); - pOLED->iCursorX += iLen; + if (szMsg[i] != '\n') { // Do not draw the new line char + // we can't directly use the pointer to FLASH memory, so copy to a local buffer + ucTemp[0] = 0; + memcpy(&ucTemp[1], &ucSmallFont[(int)c*5], 5); + if (bInvert) InvertBytes(ucTemp, 6); + iLen = 6 - iFontSkip; + if (pOLED->iCursorX + iLen > pOLED->oled_x) // clip right edge + iLen = pOLED->oled_x - pOLED->iCursorX; + oledWriteDataBlock(pOLED, &ucTemp[iFontSkip], iLen, bRender); // write character pattern + // oledCachedWrite(ucTemp, 6); + pOLED->iCursorX += iLen; + } iFontSkip = 0; - if (pOLED->iCursorX >= pOLED->oled_x-5 && pOLED->oled_wrap) // word wrap enabled? + + if ((pOLED->iCursorX >= pOLED->oled_x-5 && pOLED->oled_wrap) || szMsg[i] == '\n') // word wrap enabled? or newline char { - pOLED->iCursorX = 0; // start at the beginning of the next line + pOLED->iCursorX = x; // start at the beginning of the next line pOLED->iCursorY++; oledSetPosition(pOLED, pOLED->iCursorX, pOLED->iCursorY, bRender); } diff --git a/oled/ss_oled.h b/oled/ss_oled.h index fe6f399..78b68d4 100644 --- a/oled/ss_oled.h +++ b/oled/ss_oled.h @@ -129,7 +129,7 @@ void oledSetTextWrap(SSOLED *pOLED, int bWrap); // // Returns 0 for success, -1 for invalid parameter // -int oledWriteString(SSOLED *pOLED, int iScrollX, int x, int y, char *szMsg, int iSize, int bInvert, int bRender); +int oledWriteString(SSOLED *pOLED, int iScrollX, int x, int y, const char *szMsg, int iSize, int bInvert, int bRender); // // Fill the frame buffer with a byte pattern // e.g. all off (0x00) or all on (0xff) |