diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-08-21 13:27:39 +0800 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-08-21 13:27:39 +0800 |
commit | df4f9660834d1b7c64466812c5ede06de2eb1d45 (patch) | |
tree | f766052d618024f218a67c42982fb3545c50bdf2 /obdlogger | |
parent | 7d26dc0589f19815522d02b4a86a99a919272d92 (diff) | |
download | 2021-arduino-obd-df4f9660834d1b7c64466812c5ede06de2eb1d45.tar.gz 2021-arduino-obd-df4f9660834d1b7c64466812c5ede06de2eb1d45.tar.bz2 2021-arduino-obd-df4f9660834d1b7c64466812c5ede06de2eb1d45.zip |
update MicroLCD library
Diffstat (limited to 'obdlogger')
-rw-r--r-- | obdlogger/MicroLCD.cpp | 119 | ||||
-rw-r--r-- | obdlogger/MicroLCD.h | 7 |
2 files changed, 60 insertions, 66 deletions
diff --git a/obdlogger/MicroLCD.cpp b/obdlogger/MicroLCD.cpp index d632506..19a45fa 100644 --- a/obdlogger/MicroLCD.cpp +++ b/obdlogger/MicroLCD.cpp @@ -406,18 +406,17 @@ void LCD_SSD1306::writeDigit(byte n) } Wire.endTransmission(); m_col += 6; - } else if (m_font == FONT_SIZE_MEDIUM) { -#ifndef MEMORY_SAVING + } else if (m_font == FONT_SIZE_XLARGE) { if (n <= 9) { - n += '0' - 0x21; + byte i; ssd1306_command(0xB0 + m_row);//set page address ssd1306_command(m_col & 0xf);//set lower column address ssd1306_command(0x10 | (m_col >> 4));//set higher column address Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = 0; i <= 14; i += 2) { - byte d = pgm_read_byte_near(&font8x16_terminal[n][i]); + for (i = 0; i < 16; i ++) { + byte d = pgm_read_byte_near(&digits16x24[n][i * 3]); Wire.write(d); if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } @@ -429,8 +428,21 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = 1; i <= 15; i += 2) { - byte d = pgm_read_byte_near(&font8x16_terminal[n][i]); + for (i = 0; i < 16; i ++) { + byte d = pgm_read_byte_near(&digits16x24[n][i * 3 + 1]); + Wire.write(d); + if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); + } + Wire.endTransmission(); + + ssd1306_command(0xB0 + m_row + 2);//set page address + ssd1306_command(m_col & 0xf);//set lower column address + ssd1306_command(0x10 | (m_col >> 4));//set higher column address + + Wire.beginTransmission(_i2caddr); + Wire.write(0x40); + for (i = 0; i < 16; i ++) { + byte d = pgm_read_byte_near(&digits16x24[n][i * 3 + 2]); Wire.write(d); if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } @@ -442,7 +454,7 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 16 : 8; i > 0; i--) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { Wire.write(0); } Wire.endTransmission(); @@ -453,38 +465,35 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 16 : 8; i > 0; i--) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { Wire.write(0); } Wire.endTransmission(); - } - m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 17 : 9; -#else - Wire.beginTransmission(_i2caddr); - Wire.write(0x40); - if (n <= 9) { - for (byte i = 0; i < 8; i++) { - Wire.write(pgm_read_byte_near(&digits8x8[n][i])); - } - } else { - for (byte i = 0; i < 8; i++) { + + ssd1306_command(0xB0 + m_row + 2);//set page address + ssd1306_command(m_col & 0xf);//set lower column address + ssd1306_command(0x10 | (m_col >> 4));//set higher column address + + Wire.beginTransmission(_i2caddr); + Wire.write(0x40); + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { Wire.write(0); } + Wire.endTransmission(); } - Wire.endTransmission(); - m_col += 8; -#endif - } else if (m_font == FONT_SIZE_LARGE) { + m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16; +#ifndef MEMORY_SAVING + } else if (m_font == FONT_SIZE_MEDIUM) { if (n <= 9) { - byte i; + n += '0' - 0x21; ssd1306_command(0xB0 + m_row);//set page address ssd1306_command(m_col & 0xf);//set lower column address ssd1306_command(0x10 | (m_col >> 4));//set higher column address Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (i = 0; i < 16; i ++) { - byte d = pgm_read_byte_near(&digits16x16[n][i]); + for (byte i = 0; i <= 14; i += 2) { + byte d = pgm_read_byte_near(&font8x16_terminal[n][i]); Wire.write(d); if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } @@ -496,8 +505,8 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (; i < 32; i ++) { - byte d = pgm_read_byte_near(&digits16x16[n][i]); + for (byte i = 1; i <= 15; i += 2) { + byte d = pgm_read_byte_near(&font8x16_terminal[n][i]); Wire.write(d); if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } @@ -509,7 +518,7 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 16 : 8; i > 0; i--) { Wire.write(0); } Wire.endTransmission(); @@ -520,13 +529,13 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 16 : 8; i > 0; i--) { Wire.write(0); } Wire.endTransmission(); } - m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16; - } else if (m_font == FONT_SIZE_XLARGE) { + m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 17 : 9; + } else { if (n <= 9) { byte i; ssd1306_command(0xB0 + m_row);//set page address @@ -536,7 +545,7 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); for (i = 0; i < 16; i ++) { - byte d = pgm_read_byte_near(&digits16x24[n][i * 3]); + byte d = pgm_read_byte_near(&digits16x16[n][i]); Wire.write(d); if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } @@ -548,21 +557,8 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (i = 0; i < 16; i ++) { - byte d = pgm_read_byte_near(&digits16x24[n][i * 3 + 1]); - Wire.write(d); - if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); - } - Wire.endTransmission(); - - ssd1306_command(0xB0 + m_row + 2);//set page address - ssd1306_command(m_col & 0xf);//set lower column address - ssd1306_command(0x10 | (m_col >> 4));//set higher column address - - Wire.beginTransmission(_i2caddr); - Wire.write(0x40); - for (i = 0; i < 16; i ++) { - byte d = pgm_read_byte_near(&digits16x24[n][i * 3 + 2]); + for (; i < 32; i ++) { + byte d = pgm_read_byte_near(&digits16x16[n][i]); Wire.write(d); if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } @@ -589,19 +585,24 @@ void LCD_SSD1306::writeDigit(byte n) Wire.write(0); } Wire.endTransmission(); - - ssd1306_command(0xB0 + m_row + 2);//set page address - ssd1306_command(m_col & 0xf);//set lower column address - ssd1306_command(0x10 | (m_col >> 4));//set higher column address - - Wire.beginTransmission(_i2caddr); - Wire.write(0x40); - for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { + } + m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16; +#else + } else { + Wire.beginTransmission(_i2caddr); + Wire.write(0x40); + if (n <= 9) { + for (byte i = 0; i < 8; i++) { + Wire.write(pgm_read_byte_near(&digits8x8[n][i])); + } + } else { + for (byte i = 0; i < 8; i++) { Wire.write(0); } - Wire.endTransmission(); } - m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16; + Wire.endTransmission(); + m_col += 8; +#endif } TWBR = twbrbackup; } diff --git a/obdlogger/MicroLCD.h b/obdlogger/MicroLCD.h index 1206414..a22a2ce 100644 --- a/obdlogger/MicroLCD.h +++ b/obdlogger/MicroLCD.h @@ -21,13 +21,6 @@ typedef enum { #define FLAG_PIXEL_DOUBLE_V 4 #define FLAG_PIXEL_DOUBLE (FLAG_PIXEL_DOUBLE_H | FLAG_PIXEL_DOUBLE_V) -extern const PROGMEM unsigned char font5x8[][5]; -extern const PROGMEM unsigned char digits8x8[][8] ; -extern const PROGMEM unsigned char digits16x16[][32]; -extern const PROGMEM unsigned char digits16x24[][48]; -extern const PROGMEM unsigned char font8x16_doslike[][16]; -extern const PROGMEM unsigned char font8x16_terminal[][16]; - class LCD_Common { public: |