diff options
Diffstat (limited to 'libraries/MultiLCD/MultiLCD.cpp')
-rw-r--r-- | libraries/MultiLCD/MultiLCD.cpp | 140 |
1 files changed, 118 insertions, 22 deletions
diff --git a/libraries/MultiLCD/MultiLCD.cpp b/libraries/MultiLCD/MultiLCD.cpp index dfc3af7..5668065 100644 --- a/libraries/MultiLCD/MultiLCD.cpp +++ b/libraries/MultiLCD/MultiLCD.cpp @@ -191,26 +191,31 @@ size_t LCD_SSD1306::write(uint8_t c) m_col = 0; return 1; } +#ifndef MEMORY_SAVING if (m_font == FONT_SIZE_SMALL) { +#endif Wire.beginTransmission(_i2caddr); Wire.write(0x40); if (c > 0x20 && c < 0x7f) { c -= 0x21; for (byte i = 0; i < 5; i++) { - Wire.write(pgm_read_byte_near(&font5x8[c][i])); + byte d = pgm_read_byte_near(&font5x8[c][i]); + Wire.write(d); + if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } Wire.write(0); } else { - for (byte i = 0; i < 6; i++) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 11 : 6; i > 0; i--) { Wire.write(0); } } Wire.endTransmission(); - m_col += 6; + m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 11 : 6; if (m_col >= 128) { m_col = 0; m_row ++; } +#ifndef MEMORY_SAVING } else { if (c > 0x20 && c < 0x7f) { c -= 0x21; @@ -222,7 +227,9 @@ size_t LCD_SSD1306::write(uint8_t c) Wire.beginTransmission(_i2caddr); Wire.write(0x40); for (byte i = 0; i <= 14; i += 2) { - Wire.write(pgm_read_byte_near(&font8x16_terminal[c][i])); + byte d = pgm_read_byte_near(&font8x16_terminal[c][i]); + Wire.write(d); + if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } Wire.endTransmission(); @@ -233,7 +240,9 @@ size_t LCD_SSD1306::write(uint8_t c) Wire.beginTransmission(_i2caddr); Wire.write(0x40); for (byte i = 1; i <= 15; i += 2) { - Wire.write(pgm_read_byte_near(&font8x16_terminal[c][i])); + byte d = pgm_read_byte_near(&font8x16_terminal[c][i]); + Wire.write(d); + if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } Wire.endTransmission(); } else { @@ -243,7 +252,7 @@ size_t LCD_SSD1306::write(uint8_t c) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = 0; i < 8; i ++) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 16 : 8; i > 0; i--) { Wire.write(0); } Wire.endTransmission(); @@ -254,17 +263,18 @@ size_t LCD_SSD1306::write(uint8_t c) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = 0; i < 8; i ++) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 16 : 8; i > 0; i--) { Wire.write(0); } Wire.endTransmission(); } - m_col += 9; + m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 17 : 9; if (m_col >= 128) { m_col = 0; m_row += 2; } } +#endif return 1; } @@ -289,6 +299,59 @@ void LCD_SSD1306::writeDigit(byte n) Wire.endTransmission(); m_col += 6; } else if (m_font == FONT_SIZE_MEDIUM) { +#ifndef MEMORY_SAVING + if (n <= 9) { + 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 (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); + } + Wire.endTransmission(); + + ssd1306_command(0xB0 + m_row + 1);//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 = 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); + } + Wire.endTransmission(); + } else { + 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 = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 16 : 8; i > 0; i--) { + Wire.write(0); + } + Wire.endTransmission(); + + ssd1306_command(0xB0 + m_row + 1);//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) ? 16 : 8; 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) { @@ -302,17 +365,20 @@ void LCD_SSD1306::writeDigit(byte n) } Wire.endTransmission(); m_col += 8; +#endif } else if (m_font == FONT_SIZE_LARGE) { 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) { - Wire.write(pgm_read_byte_near(&font8x16_terminal[n][i])); + for (i = 0; i < 16; i ++) { + byte d = pgm_read_byte_near(&digits16x16[n][i]); + Wire.write(d); + if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } Wire.endTransmission(); @@ -322,8 +388,10 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = 1; i <= 15; i += 2) { - Wire.write(pgm_read_byte_near(&font8x16_terminal[n][i])); + 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); } Wire.endTransmission(); } else { @@ -333,7 +401,7 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = 0; i < 8; i++) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { Wire.write(0); } Wire.endTransmission(); @@ -344,12 +412,12 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = 0; i < 8; i++) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { Wire.write(0); } Wire.endTransmission(); } - m_col += 9; + m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16; } else if (m_font == FONT_SIZE_XLARGE) { if (n <= 9) { byte i; @@ -360,7 +428,9 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); for (i = 0; i < 16; i ++) { - Wire.write(pgm_read_byte_near(&digits16x16[n][i])); + byte d = pgm_read_byte_near(&digits16x24[n][i * 3]); + Wire.write(d); + if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d); } Wire.endTransmission(); @@ -370,8 +440,23 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (; i < 32; i ++) { - Wire.write(pgm_read_byte_near(&digits16x16[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); } Wire.endTransmission(); } else { @@ -381,7 +466,7 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = 0; i < 16; i++) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { Wire.write(0); } Wire.endTransmission(); @@ -392,12 +477,23 @@ void LCD_SSD1306::writeDigit(byte n) Wire.beginTransmission(_i2caddr); Wire.write(0x40); - for (byte i = 0; i < 16; i++) { + for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) { + 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--) { Wire.write(0); } Wire.endTransmission(); } - m_col += 16; + m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16; } TWBR = twbrbackup; } |