From cb740690c3a1e5b916955140e19c8627ba407c0e Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Tue, 28 Jun 2016 18:21:04 +0100 Subject: [PATCH] Hardcode "pins" for Adafruit display as they shouldn't change PCF8574 "pins" already hardcoded. But variables now renamed to match MMDVMHost variables. Added other Adafruit defines (commented out for now) for possible future use. Tidyed up some comments. --- HD44780.cpp | 23 +++++++++++++++-------- HD44780.h | 47 ++++++++++++++++++++++++++++++++++------------- MMDVM.ini | 2 -- 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 7ac16c9..c900b33 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -249,6 +249,13 @@ void CHD44780::adafruitLCDSetup() // Control signals ::pinMode(AF_RW, OUTPUT); ::digitalWrite(AF_RW, LOW); + + m_rb = AF_RS; + m_strb = AF_E; + m_d0 = AF_D0; + m_d1 = AF_D1; + m_d2 = AF_D2; + m_d3 = AF_D3; } void CHD44780::adafruitLCDColour(ADAFRUIT_COLOUR colour) @@ -316,17 +323,17 @@ void CHD44780::pcf8574LCDSetup() m_rb = AF_RS; m_strb = AF_E; - m_d0 = AF_D1; - m_d1 = AF_D2; - m_d2 = AF_D3; - m_d3 = AF_D4; + m_d0 = AF_D0; + m_d1 = AF_D1; + m_d2 = AF_D2; + m_d3 = AF_D3; } #endif void CHD44780::setIdleInt() { - m_dmrScrollTimer1.stop(); // Stop the scroll timer on slot 1 - m_dmrScrollTimer2.stop(); // Stop the scroll timer on slot 2 + m_dmrScrollTimer1.stop(); // Stop the scroll timer on slot 1 + m_dmrScrollTimer2.stop(); // Stop the scroll timer on slot 2 m_clockDisplayTimer.start(); // Start the clock display in IDLE only ::lcdClear(m_fd); @@ -369,8 +376,8 @@ void CHD44780::setErrorInt(const char* text) #endif m_clockDisplayTimer.stop(); // Stop the clock display - m_dmrScrollTimer1.stop(); // Stop the scroll timer on slot 1 - m_dmrScrollTimer2.stop(); // Stop the scroll timer on slot 2 + m_dmrScrollTimer1.stop(); // Stop the scroll timer on slot 1 + m_dmrScrollTimer2.stop(); // Stop the scroll timer on slot 2 ::lcdClear(m_fd); if (m_pwm) { diff --git a/HD44780.h b/HD44780.h index 95b818e..ab8b3ae 100644 --- a/HD44780.h +++ b/HD44780.h @@ -42,26 +42,47 @@ enum ADAFRUIT_COLOUR { // Defines for the Adafruit Pi LCD interface board #ifdef ADAFRUIT_DISPLAY #define AF_BASE 100 -#define AF_RED (AF_BASE + 6) -#define AF_GREEN (AF_BASE + 7) -#define AF_BLUE (AF_BASE + 8) + +/* Not yet used defines (for possible future use) + * + * #define AF_SELECT (AF_BASE + 0) + * #define AF_RIGHT (AF_BASE + 1) + * #define AF_DOWN (AF_BASE + 2) + * #define AF_UP (AF_BASE + 3) + * #define AF_LEFT (AF_BASE + 4) + */ + +#define AF_RED (AF_BASE + 6) +#define AF_GREEN (AF_BASE + 7) +#define AF_BLUE (AF_BASE + 8) + +#define AF_D3 (AF_BASE + 9) +#define AF_D2 (AF_BASE + 10) +#define AF_D1 (AF_BASE + 11) +#define AF_D0 (AF_BASE + 12) +#define AF_E (AF_BASE + 13) #define AF_RW (AF_BASE + 14) -#define AF_ON LOW -#define AF_OFF HIGH +#define AF_RS (AF_BASE + 15) + +#define AF_ON LOW +#define AF_OFF HIGH + #define MCP23017 0x20 #endif // Define for HD44780 connected via a PCF8574 GPIO extender #ifdef PCF8574_DISPLAY #define AF_BASE 100 -#define AF_RS (AF_BASE + 0) -#define AF_RW (AF_BASE + 1) -#define AF_E (AF_BASE + 2) -#define AF_BL (AF_BASE + 3) -#define AF_D1 (AF_BASE + 4) -#define AF_D2 (AF_BASE + 5) -#define AF_D3 (AF_BASE + 6) -#define AF_D4 (AF_BASE + 7) + +#define AF_RS (AF_BASE + 0) +#define AF_RW (AF_BASE + 1) +#define AF_E (AF_BASE + 2) +#define AF_BL (AF_BASE + 3) +#define AF_D0 (AF_BASE + 4) +#define AF_D1 (AF_BASE + 5) +#define AF_D2 (AF_BASE + 6) +#define AF_D3 (AF_BASE + 7) + #define PCF8574 0x27 #endif diff --git a/MMDVM.ini b/MMDVM.ini index 518ee35..7492b7d 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -110,8 +110,6 @@ Columns=16 # rs, strb, d0, d1, d2, d3 # For basic HD44780 displays Pins=11,10,0,1,2,3 -# For Adafruit i2c HD44780 -# Pins=115,113,112,111,110,109 # PWM backlight PWM=0