summaryrefslogtreecommitdiff
path: root/obdlogger/MicroLCD.cpp
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2013-11-07 22:29:31 +1100
committerStanley Huang <stanleyhuangyc@gmail.com>2013-11-07 22:29:31 +1100
commit91c65f3d117d942b1b4f8fd4bcc77683c3ef71c8 (patch)
tree33b1b866f95b6df03f800dc30812c285038debca /obdlogger/MicroLCD.cpp
parentcabaa89f83d4e6124728f005c50fb0da8cbd0935 (diff)
download2021-arduino-obd-91c65f3d117d942b1b4f8fd4bcc77683c3ef71c8.tar.gz
2021-arduino-obd-91c65f3d117d942b1b4f8fd4bcc77683c3ef71c8.tar.bz2
2021-arduino-obd-91c65f3d117d942b1b4f8fd4bcc77683c3ef71c8.zip
update OBD logger,
config.h added for storing configurations default in acceleration timing mode
Diffstat (limited to 'obdlogger/MicroLCD.cpp')
-rw-r--r--obdlogger/MicroLCD.cpp109
1 files changed, 21 insertions, 88 deletions
diff --git a/obdlogger/MicroLCD.cpp b/obdlogger/MicroLCD.cpp
index da1cdc2..691b643 100644
--- a/obdlogger/MicroLCD.cpp
+++ b/obdlogger/MicroLCD.cpp
@@ -406,7 +406,9 @@ void LCD_SSD1306::writeDigit(byte n)
}
Wire.endTransmission();
m_col += 6;
- } else if (m_font == FONT_SIZE_XLARGE) {
+ } else if (m_font == FONT_SIZE_MEDIUM) {
+ write(n <= 9 ? ('0' + n) : ' ');
+ } else if (m_font == FONT_SIZE_LARGE) {
if (n <= 9) {
byte i;
ssd1306_command(0xB0 + m_row);//set page address
@@ -416,7 +418,7 @@ void LCD_SSD1306::writeDigit(byte n)
Wire.beginTransmission(_i2caddr);
Wire.write(0x40);
for (i = 0; i < 16; i ++) {
- byte d = pgm_read_byte(&digits16x24[n][i * 3]);
+ byte d = pgm_read_byte(&digits16x16[n][i]);
Wire.write(d);
if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d);
}
@@ -428,21 +430,8 @@ void LCD_SSD1306::writeDigit(byte n)
Wire.beginTransmission(_i2caddr);
Wire.write(0x40);
- for (i = 0; i < 16; i ++) {
- byte d = pgm_read_byte(&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(&digits16x24[n][i * 3 + 2]);
+ for (; i < 32; i ++) {
+ byte d = pgm_read_byte(&digits16x16[n][i]);
Wire.write(d);
if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d);
}
@@ -469,31 +458,19 @@ 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--) {
- Wire.write(0);
- }
- Wire.endTransmission();
}
m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16;
-#ifndef MEMORY_SAVING
- } else if (m_font == FONT_SIZE_MEDIUM) {
+ } 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(&font8x16_terminal[n][i]);
+ for (i = 0; i < 16; i ++) {
+ byte d = pgm_read_byte(&digits16x24[n][i * 3]);
Wire.write(d);
if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d);
}
@@ -505,66 +482,38 @@ 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(&font8x16_terminal[n][i]);
+ for (i = 0; i < 16; i ++) {
+ byte d = pgm_read_byte(&digits16x24[n][i * 3 + 1]);
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 {
- if (n <= 9) {
- byte i;
- ssd1306_command(0xB0 + m_row);//set page address
+ 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(&digits16x16[n][i]);
+ byte d = pgm_read_byte(&digits16x24[n][i * 3 + 2]);
Wire.write(d);
if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d);
}
Wire.endTransmission();
-
- ssd1306_command(0xB0 + m_row + 1);//set page address
+ } 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 (; i < 32; i ++) {
- byte d = pgm_read_byte(&digits16x16[n][i]);
- Wire.write(d);
- if (m_flags & FLAG_PIXEL_DOUBLE_H) Wire.write(d);
+ for (byte i = (m_flags & FLAG_PIXEL_DOUBLE_H) ? 32 : 16; i > 0; i--) {
+ Wire.write(0);
}
Wire.endTransmission();
- } else {
- ssd1306_command(0xB0 + m_row);//set page address
+
+ 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
@@ -575,7 +524,7 @@ void LCD_SSD1306::writeDigit(byte n)
}
Wire.endTransmission();
- ssd1306_command(0xB0 + m_row + 1);//set page address
+ 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
@@ -587,22 +536,6 @@ void LCD_SSD1306::writeDigit(byte n)
Wire.endTransmission();
}
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(&digits8x8[n][i]));
- }
- } else {
- for (byte i = 0; i < 8; i++) {
- Wire.write(0);
- }
- }
- Wire.endTransmission();
- m_col += 8;
-#endif
}
TWBR = twbrbackup;
}