summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'libraries')
-rw-r--r--libraries/MultiLCD/MultiLCD.h54
-rw-r--r--libraries/MultiLCD/PCD8544.cpp21
-rw-r--r--libraries/MultiLCD/PCD8544.h5
3 files changed, 60 insertions, 20 deletions
diff --git a/libraries/MultiLCD/MultiLCD.h b/libraries/MultiLCD/MultiLCD.h
index 35016aa..5a8f7e3 100644
--- a/libraries/MultiLCD/MultiLCD.h
+++ b/libraries/MultiLCD/MultiLCD.h
@@ -3,26 +3,51 @@ extern const PROGMEM unsigned char font5x8[][5];
#include "PCD8544.h"
-class LCD_PCD8544 : public PCD8544 {
+class LCD_Common
+{
public:
+ virtual void backlight(bool on) {}
+ virtual byte getLines() = 0;
+ virtual byte getCols() = 0;
+ virtual void changeLine() {}
+};
+
+class LCD_PCD8544 : public LCD_Common, public PCD8544
+{
+public:
+ byte getLines() { return 6; }
+ byte getCols() { return 14; }
void printLarge(const char* s);
void backlight(bool on)
{
pinMode(7, OUTPUT);
digitalWrite(7, on ? HIGH : LOW);
}
+ void clearLine(byte line)
+ {
+ setCursor(0, line);
+ for (byte i = 14; i > 0; i--) write(' ');
+ }
};
#include "ZtLib.h"
#define OLED_ADDRESS 0x27
-class LCD_OLED : public ZtLib {
+class LCD_OLED : public LCD_Common, public ZtLib
+{
public:
- void setCursor(unsigned char column, unsigned char line)
+ byte getLines() { return 4; }
+ byte getCols() { return 16; }
+ void setCursor(byte column, byte line)
{
m_column = column << 3;
- m_line = line == -1 ? m_line + 2 : (line << 1);
+ m_line = line << 1;
+ }
+ void changeLine()
+ {
+ m_column = 0;
+ m_line += 2;
}
void write(char c);
void print(const char* s);
@@ -30,15 +55,30 @@ public:
void clear();
void begin();
void backlight(bool on) {}
+ void clearLine(byte line)
+ {
+ setCursor(0, line);
+ for (byte i = 16; i > 0; i--) write(' ');
+ }
private:
unsigned char m_column;
unsigned char m_line;
};
#include "LCD4Bit_mod.h"
-class LCD_1602 : public LCD4Bit_mod {
+class LCD_1602 : public LCD_Common, public LCD4Bit_mod
+{
public:
- void printLarge(const char* s) { print(s); }
- void backlight(bool on) {}
+ byte getLines() { return 2; }
+ byte getCols() { return 16; }
+ void printLarge(const char* s)
+ {
+ print(s);
+ }
+ void clearLine(byte line)
+ {
+ setCursor(0, line);
+ for (byte i = 16; i > 0; i--) write(' ');
+ }
};
diff --git a/libraries/MultiLCD/PCD8544.cpp b/libraries/MultiLCD/PCD8544.cpp
index 9c85662..a54bfc8 100644
--- a/libraries/MultiLCD/PCD8544.cpp
+++ b/libraries/MultiLCD/PCD8544.cpp
@@ -25,12 +25,7 @@
#include "PCD8544.h"
-#if ARDUINO < 100
-#include <WProgram.h>
-#else
#include <Arduino.h>
-#endif
-
#include <avr/pgmspace.h>
@@ -77,7 +72,7 @@ void PCD8544::begin(unsigned char width, unsigned char height, unsigned char mod
digitalWrite(this->pin_reset, HIGH);
digitalWrite(this->pin_sce, HIGH);
digitalWrite(this->pin_reset, LOW);
- delay(100);
+ delay(100);
digitalWrite(this->pin_reset, HIGH);
// Set the LCD parameters...
@@ -171,11 +166,11 @@ void PCD8544::home()
void PCD8544::setCursor(unsigned char column, unsigned char line)
{
- this->column = (column % this->width);
+ this->column = (column * 6 % this->width);
this->line = (line % (this->height/9 + 1));
this->send(PCD8544_CMD, 0x80 | this->column);
- this->send(PCD8544_CMD, 0x40 | this->line);
+ this->send(PCD8544_CMD, 0x40 | this->line);
}
@@ -185,7 +180,7 @@ void PCD8544::createChar(unsigned char chr, const unsigned char *glyph)
if (chr >= ' ') {
return;
}
-
+
this->custom[chr] = glyph;
}
@@ -278,7 +273,7 @@ void PCD8544::drawColumn(unsigned char lines, unsigned char value)
// Find the line where "value" resides...
unsigned char mark = (lines*8 - 1 - value)/8;
-
+
// Clear the lines above the mark...
for (unsigned char line = 0; line < mark; line++) {
this->setCursor(scolumn, sline + line);
@@ -299,16 +294,16 @@ void PCD8544::drawColumn(unsigned char lines, unsigned char value)
this->setCursor(scolumn, sline + line);
this->send(PCD8544_DATA, 0xff);
}
-
+
// Leave the cursor in a consistent position...
- this->setCursor(scolumn + 1, sline);
+ this->setCursor(scolumn + 1, sline);
}
void PCD8544::send(unsigned char type, unsigned char data)
{
digitalWrite(this->pin_dc, type);
-
+
digitalWrite(this->pin_sce, LOW);
shiftOut(this->pin_sdin, this->pin_sclk, MSBFIRST, data);
digitalWrite(this->pin_sce, HIGH);
diff --git a/libraries/MultiLCD/PCD8544.h b/libraries/MultiLCD/PCD8544.h
index 927ec47..c6e8d43 100644
--- a/libraries/MultiLCD/PCD8544.h
+++ b/libraries/MultiLCD/PCD8544.h
@@ -88,6 +88,11 @@ class PCD8544: public Print {
// Draw a chart element at the current cursor position...
void drawColumn(unsigned char lines, unsigned char value);
+ void changeLine()
+ {
+ column = 0;
+ line ++;
+ }
protected:
// Current cursor position...
unsigned char column;