Skip to content

Commit

Permalink
Force CR/LF for Code Page 437 fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
greiman committed Jun 27, 2022
1 parent 822bb4e commit 241f8cc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SSD1306Ascii
version=1.3.2
version=1.3.3
author=Bill Greiman <[email protected]>
maintainer=Bill Greiman <[email protected]>
sentence=Text display on small momochrome OLED modules.
Expand Down
49 changes: 25 additions & 24 deletions src/SSD1306Ascii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,34 +305,35 @@ size_t SSD1306Ascii::write(uint8_t ch) {
uint8_t count = readFontByte(m_font + FONT_CHAR_COUNT);
const uint8_t* base = m_font + FONT_WIDTH_TABLE;

if (ch < first || ch >= (first + count)) {
if (ch == '\r') {
setCol(0);
return 1;
}
if (ch == '\n') {
setCol(0);
uint8_t fr = m_magFactor*nr;
if (ch == '\r') {
setCol(0);
return 1;
}
if (ch == '\n') {
setCol(0);
uint8_t fr = m_magFactor*nr;
#if INCLUDE_SCROLLING
uint8_t dr = displayRows();
uint8_t tmpRow = m_row + fr;
int8_t delta = tmpRow + fr - dr;
if (m_scrollMode == SCROLL_MODE_OFF || delta <= 0) {
setRow(tmpRow);
} else {
m_pageOffset = (m_pageOffset + delta) & 7;
m_row = dr - fr;
// Cursor will be positioned by clearToEOL.
clearToEOL();
if (m_scrollMode == SCROLL_MODE_AUTO) {
setStartLine(8*m_pageOffset);
}
uint8_t dr = displayRows();
uint8_t tmpRow = m_row + fr;
int8_t delta = tmpRow + fr - dr;
if (m_scrollMode == SCROLL_MODE_OFF || delta <= 0) {
setRow(tmpRow);
} else {
m_pageOffset = (m_pageOffset + delta) & 7;
m_row = dr - fr;
// Cursor will be positioned by clearToEOL.
clearToEOL();
if (m_scrollMode == SCROLL_MODE_AUTO) {
setStartLine(8*m_pageOffset);
}
}
#else // INCLUDE_SCROLLING
setRow(m_row + fr);
setRow(m_row + fr);
#endif // INCLUDE_SCROLLING
return 1;
}
return 1;
}
// Error if not in font.
if (ch < first || (first + count) <= ch) {
return 0;
}
ch -= first;
Expand Down
4 changes: 2 additions & 2 deletions src/SSD1306Ascii.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "fonts/allFonts.h"
//------------------------------------------------------------------------------
/** SSD1306Ascii version */
#define SDD1306_ASCII_VERSION 10302
#define SDD1306_ASCII_VERSION 10303
//------------------------------------------------------------------------------
// Configuration options.
/** Set Scrolling mode for newline.
Expand Down Expand Up @@ -443,7 +443,7 @@ class SSD1306Ascii : public Print {
* @brief Advance ticker by one pixel.
*
* @param[in,out] state Ticker state.
* @return Number of entries in text pointer queue.
* @return Number of entries in text pointer queue or -1 if an error occurs.
*/
int8_t tickerTick(TickerState* state);
/**
Expand Down
2 changes: 2 additions & 0 deletions src/fonts/Adafruit5x7.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

// standard ascii 5x7 font
// Restrict to 96 characters
#ifndef ADAFRUIT_ASCII96
#define ADAFRUIT_ASCII96 1
#endif // ADAFRUIT_ASCII96
GLCDFONTDECL(Adafruit5x7) = {
0x0, 0x0, // size of zero indicates fixed width font,
0x05, // width
Expand Down
6 changes: 3 additions & 3 deletions src/fonts/ZevvPeep8x16.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// STARTFONT 2.1
// FONT -zevv-peep-Medium-R-Normal--16-140-75-75-C-80-ISO8859-1
#ifndef font8x16_h
#define font8x16_h
#ifndef ZevvPeep8x16_h
#define ZevvPeep8x16_h

GLCDFONTDECL(ZevvPeep8x16) = {
0x0, 0x0, // size of zero indicates fixed width font,
Expand Down Expand Up @@ -106,4 +106,4 @@ GLCDFONTDECL(ZevvPeep8x16) = {
0X30,0X08,0X08,0X10,0X20,0X20,0X18,0X00,0X00,0X00,0X00,0X00,0X00,0X00, // '~'
0XFE,0XFE,0XFE,0XFE,0XFE,0XFE,0XFE,0X7F,0X7F,0X7F,0X7F,0X7F,0X7F,0X7F // del
};
#endif // font8x16_h
#endif // ZevvPeep8x16_h

0 comments on commit 241f8cc

Please sign in to comment.