summaryrefslogtreecommitdiff
path: root/gpslogger/MicroLCD.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gpslogger/MicroLCD.cpp')
-rw-r--r--gpslogger/MicroLCD.cpp119
1 files changed, 60 insertions, 59 deletions
diff --git a/gpslogger/MicroLCD.cpp b/gpslogger/MicroLCD.cpp
index d632506..19a45fa 100644
--- a/gpslogger/MicroLCD.cpp
+++ b/gpslogger/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;
}