summaryrefslogtreecommitdiff
path: root/libraries/MultiLCD
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2013-07-24 01:01:23 +0800
committerStanley Huang <stanleyhuangyc@gmail.com>2013-07-24 01:01:23 +0800
commit9dd48e5285ed65cae13ca8e9157e0503a8d58e88 (patch)
tree1ee1bf813c3f5c565dc23e6421caea4f46a1f4ec /libraries/MultiLCD
parent9e44fd48ee50e3cf39283f16c532e7089e8117dc (diff)
download2021-arduino-obd-9dd48e5285ed65cae13ca8e9157e0503a8d58e88.tar.gz
2021-arduino-obd-9dd48e5285ed65cae13ca8e9157e0503a8d58e88.tar.bz2
2021-arduino-obd-9dd48e5285ed65cae13ca8e9157e0503a8d58e88.zip
update MultiLCD library
Diffstat (limited to 'libraries/MultiLCD')
-rw-r--r--libraries/MultiLCD/ILI9325D.cpp6
-rw-r--r--libraries/MultiLCD/MultiLCD.cpp6
-rw-r--r--libraries/MultiLCD/MultiLCD.h8
3 files changed, 12 insertions, 8 deletions
diff --git a/libraries/MultiLCD/ILI9325D.cpp b/libraries/MultiLCD/ILI9325D.cpp
index eb5f10b..91ca5b2 100644
--- a/libraries/MultiLCD/ILI9325D.cpp
+++ b/libraries/MultiLCD/ILI9325D.cpp
@@ -301,7 +301,7 @@ void LCD_ILI9325D::clear(uint16_t x, uint16_t y, uint16_t width, uint16_t height
size_t LCD_ILI9325D::write(uint8_t c)
{
if (c == '\n') {
- m_x += 8;
+ m_x += (m_font + 1) << 3;
return 0;
} else if (c == '\r') {
SetXY(m_x, m_x + 7, m_y, 319);
@@ -317,7 +317,7 @@ size_t LCD_ILI9325D::write(uint8_t c)
SetXY(m_x, m_x + 7, m_y, m_y + 4);
m_y += 6;
if (m_y >= 320) {
- m_x += 8;
+ m_x += (m_font + 1) << 3;
m_y = 0;
if (m_x >= 240) {
m_x = 0;
@@ -339,7 +339,7 @@ size_t LCD_ILI9325D::write(uint8_t c)
SetXY(m_x, m_x + 15, m_y, m_y + 7);
m_y += 9;
if (m_y >= 320) {
- m_x += 8;
+ m_x += (m_font + 1) << 3;
m_y = 0;
if (m_x >= 240) {
m_x = 0;
diff --git a/libraries/MultiLCD/MultiLCD.cpp b/libraries/MultiLCD/MultiLCD.cpp
index 1865cc5..dfc3af7 100644
--- a/libraries/MultiLCD/MultiLCD.cpp
+++ b/libraries/MultiLCD/MultiLCD.cpp
@@ -18,7 +18,7 @@ void LCD_Common::printInt(unsigned int value, char padding)
den /= 10;
if (v == 0 && padding && den) {
if (padding >= i) {
- writeDigit(-1);
+ writeDigit((m_flags & FLAG_PAD_ZERO) ? 0 : -1);
}
continue;
}
@@ -36,7 +36,7 @@ void LCD_Common::printLong(unsigned long value, char padding)
den /= 10;
if (v == 0 && padding && den) {
if (padding >= i) {
- writeDigit(-1);
+ writeDigit((m_flags & FLAG_PAD_ZERO) ? 0 : -1);
}
continue;
}
@@ -273,10 +273,10 @@ void LCD_SSD1306::writeDigit(byte n)
uint8_t twbrbackup = TWBR;
TWBR = 18; // upgrade to 400KHz!
if (m_font == FONT_SIZE_SMALL) {
- n += '0' - 0x21;
Wire.beginTransmission(_i2caddr);
Wire.write(0x40);
if (n <= 9) {
+ n += '0' - 0x21;
for (byte i = 0; i < 5; i++) {
Wire.write(pgm_read_byte_near(&font5x8[n][i]));
}
diff --git a/libraries/MultiLCD/MultiLCD.h b/libraries/MultiLCD/MultiLCD.h
index 734ed70..648321c 100644
--- a/libraries/MultiLCD/MultiLCD.h
+++ b/libraries/MultiLCD/MultiLCD.h
@@ -12,6 +12,8 @@ typedef enum {
FONT_SIZE_XLARGE
} FONT_SIZE;
+#define FLAG_PAD_ZERO 1
+
extern const PROGMEM unsigned char font5x8[][5];
extern const PROGMEM unsigned char digits8x8[][8] ;
extern const PROGMEM unsigned char digits16x16[][32];
@@ -23,8 +25,9 @@ extern const PROGMEM unsigned char font8x16_terminal[][16];
class LCD_Common
{
public:
- LCD_Common():m_font(0) {}
+ LCD_Common():m_font(FONT_SIZE_SMALL),m_flags(0) {}
void setFont(FONT_SIZE size) { m_font = size; }
+ void setFlags(byte flags) { m_flags = flags; }
virtual void backlight(bool on) {}
virtual byte getLines() = 0;
virtual byte getCols() = 0;
@@ -35,6 +38,7 @@ public:
protected:
virtual void writeDigit(byte n) {}
byte m_font;
+ byte m_flags;
};
class LCD_PCD8544 : public LCD_Common, public PCD8544
@@ -121,7 +125,7 @@ private:
class LCD_ILI9325D : public LCD_Common, public Print
{
public:
- LCD_ILI9325D():m_lineHeight(10) {}
+ LCD_ILI9325D():m_lineHeight(10) { m_font = FONT_SIZE_MEDIUM; }
void setCursor(uint16_t column, uint16_t line)
{
m_y = column;