diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-07-04 16:58:54 +0800 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-07-04 16:58:54 +0800 |
commit | 4ff68b8f1a9706aa2bb936ed541848343602517c (patch) | |
tree | 9b862790817becea49f98699a20e445a7344f382 | |
parent | 2ca1e8f7c391a2d8629aaea8d27b14c63cf7e17d (diff) | |
download | 2021-arduino-obd-4ff68b8f1a9706aa2bb936ed541848343602517c.tar.gz 2021-arduino-obd-4ff68b8f1a9706aa2bb936ed541848343602517c.tar.bz2 2021-arduino-obd-4ff68b8f1a9706aa2bb936ed541848343602517c.zip |
update MultiLCD library
-rw-r--r-- | libraries/MultiLCD/MultiLCD.cpp | 37 | ||||
-rw-r--r-- | libraries/MultiLCD/MultiLCD.h | 11 | ||||
-rw-r--r-- | libraries/MultiLCD/PCD8544.cpp | 19 |
3 files changed, 46 insertions, 21 deletions
diff --git a/libraries/MultiLCD/MultiLCD.cpp b/libraries/MultiLCD/MultiLCD.cpp index 1856a21..1865cc5 100644 --- a/libraries/MultiLCD/MultiLCD.cpp +++ b/libraries/MultiLCD/MultiLCD.cpp @@ -55,6 +55,14 @@ void LCD_ZTOLED::setCursor(byte column, byte line) size_t LCD_ZTOLED::write(uint8_t c) { + if (c == '\n') { + m_column = 0; + m_page += (m_font == FONT_SIZE_SMALL) ? 1 : 2; + return 0; + } else if (c == '\r') { + m_column = 0; + return 0; + } if (m_font == FONT_SIZE_SMALL) { if (c <= 0x20 || c >= 0x7f) { ScI2cMxFillArea(OLED_ADDRESS, m_column, m_column + 5, m_page, m_page, 0); @@ -72,6 +80,16 @@ size_t LCD_ZTOLED::write(uint8_t c) return 1; } +/* +void LCD_ZTOLED::print(const char* s) +{ + ScI2cMxDisplay8x16Str(OLED_ADDRESS, m_page, m_column, s); + m_column += (strlen(s) << 3); + m_page += (m_column >> 7) << 1; + m_column %= 0x7f; +} +*/ + void LCD_ZTOLED::writeDigit(byte n) { if (m_font == FONT_SIZE_SMALL) { @@ -166,6 +184,13 @@ void LCD_SSD1306::setCursor(byte column, byte line) size_t LCD_SSD1306::write(uint8_t c) { + if (c == '\n') { + setCursor(0, m_row + ((m_font == FONT_SIZE_SMALL) ? 1 : 2)); + return 1; + } else if (c == '\r') { + m_col = 0; + return 1; + } if (m_font == FONT_SIZE_SMALL) { Wire.beginTransmission(_i2caddr); Wire.write(0x40); @@ -181,7 +206,11 @@ size_t LCD_SSD1306::write(uint8_t c) } } Wire.endTransmission(); - m_col += 8; + m_col += 6; + if (m_col >= 128) { + m_col = 0; + m_row ++; + } } else { if (c > 0x20 && c < 0x7f) { c -= 0x21; @@ -231,6 +260,10 @@ size_t LCD_SSD1306::write(uint8_t c) Wire.endTransmission(); } m_col += 9; + if (m_col >= 128) { + m_col = 0; + m_row += 2; + } } return 1; } @@ -456,5 +489,7 @@ void LCD_SSD1306::clear(byte x, byte y, byte width, byte height) Wire.endTransmission(); } } + + setCursor(0, 0); TWBR = twbrbackup; } diff --git a/libraries/MultiLCD/MultiLCD.h b/libraries/MultiLCD/MultiLCD.h index 0809bf6..734ed70 100644 --- a/libraries/MultiLCD/MultiLCD.h +++ b/libraries/MultiLCD/MultiLCD.h @@ -28,7 +28,6 @@ public: virtual void backlight(bool on) {} virtual byte getLines() = 0; virtual byte getCols() = 0; - virtual void changeLine() {} virtual void clearLine(byte line) {} void draw(const PROGMEM byte* buffer, byte x, byte y, byte width, byte height) {} void printInt(uint16_t value, char padding = -1); @@ -53,11 +52,6 @@ public: setCursor(0, line); for (byte i = 14; i > 0; i--) write(' '); } - void changeLine() - { - column = 0; - line ++; - } void draw(const PROGMEM byte* buffer, byte x, byte y, byte width, byte height); private: void writeDigit(byte n); @@ -73,11 +67,6 @@ public: byte getLines() { return 4; } byte getCols() { return 16; } void setCursor(byte column, byte line); - void changeLine() - { - m_column = 0; - m_page += 2; - } size_t write(uint8_t c); //void print(const char* s); void writeDigit(byte n); diff --git a/libraries/MultiLCD/PCD8544.cpp b/libraries/MultiLCD/PCD8544.cpp index 9bd62c5..6b339fe 100644 --- a/libraries/MultiLCD/PCD8544.cpp +++ b/libraries/MultiLCD/PCD8544.cpp @@ -185,19 +185,20 @@ void PCD8544::createChar(unsigned char chr, const unsigned char *glyph) } -#if ARDUINO < 100 -void PCD8544::write(uint8_t chr) -#else size_t PCD8544::write(uint8_t chr) -#endif { // ASCII 7-bit only... - if (chr >= 0x80) { -#if ARDUINO < 100 - return; -#else + if (chr >= 0x7f) { + return 0; + } + + if (chr == '\n') { + column = 0; + line = (line + 1) % (PCD8544_HEIGHT/9 + 1); + return 0; + } else if (chr == '\r') { + column = 0; return 0; -#endif } const unsigned char *glyph; |