Support for HD44780 via PCF8574
This commit is contained in:
parent
084e39c1de
commit
04b297de20
34
HD44780.cpp
34
HD44780.cpp
|
@ -206,6 +206,10 @@ bool CHD44780::open()
|
||||||
adafruitLCDSetup();
|
adafruitLCDSetup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PCF8574_DISPLAY
|
||||||
|
pcf8574LCDSetup();
|
||||||
|
#endif
|
||||||
|
|
||||||
m_fd = ::lcdInit(m_rows, m_cols, 4, m_rb, m_strb, m_d0, m_d1, m_d2, m_d3, 0, 0, 0, 0);
|
m_fd = ::lcdInit(m_rows, m_cols, 4, m_rb, m_strb, m_d0, m_d1, m_d2, m_d3, 0, 0, 0, 0);
|
||||||
if (m_fd == -1) {
|
if (m_fd == -1) {
|
||||||
LogError("Unable to open the HD44780");
|
LogError("Unable to open the HD44780");
|
||||||
|
@ -296,6 +300,36 @@ void CHD44780::adafruitLCDColour(ADAFRUIT_COLOUR colour)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PCF8574_DISPLAY
|
||||||
|
void CHD44780::pcf8574LCDSetup()
|
||||||
|
{
|
||||||
|
// Initalize PFC8574
|
||||||
|
::pcf8574Setup(AF_BASE, PCF8574);
|
||||||
|
|
||||||
|
// Initialise LCD
|
||||||
|
m_fd = ::lcdInit(m_rows, m_cols, 4, AF_RS, AF_E, AF_D1, AF_D2, AF_D3, AF_D4, 0, 0, 0, 0);
|
||||||
|
if (m_fd == -1) {
|
||||||
|
LogError("Unable to open the HD44780 via I2C");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_rb = AF_RS;
|
||||||
|
m_strb = AF_E;
|
||||||
|
m_d0 = AF_D1;
|
||||||
|
m_d1 = AF_D2;
|
||||||
|
m_d2 = AF_D3;
|
||||||
|
m_d3 = AF_D4;
|
||||||
|
|
||||||
|
// Turn on backlight
|
||||||
|
::pinMode (AF_BL, OUTPUT);
|
||||||
|
::digitalWrite (AF_BL, 1);
|
||||||
|
|
||||||
|
// Set LCD to write mode.
|
||||||
|
::pinMode (AF_RW, OUTPUT);
|
||||||
|
::digitalWrite (AF_RW, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void CHD44780::setIdleInt()
|
void CHD44780::setIdleInt()
|
||||||
{
|
{
|
||||||
m_dmrScrollTimer1.stop(); // Stop the scroll timer on slot 1
|
m_dmrScrollTimer1.stop(); // Stop the scroll timer on slot 1
|
||||||
|
|
19
HD44780.h
19
HD44780.h
|
@ -26,6 +26,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <mcp23017.h>
|
#include <mcp23017.h>
|
||||||
|
#include <pcf8574.h>
|
||||||
|
|
||||||
enum ADAFRUIT_COLOUR {
|
enum ADAFRUIT_COLOUR {
|
||||||
AC_OFF,
|
AC_OFF,
|
||||||
|
@ -50,6 +51,20 @@ enum ADAFRUIT_COLOUR {
|
||||||
#define MCP23017 0x20
|
#define MCP23017 0x20
|
||||||
#endif
|
#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 PCF8547 0x27
|
||||||
|
#endif
|
||||||
|
|
||||||
class CHD44780 : public CDisplay
|
class CHD44780 : public CDisplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -105,6 +120,10 @@ private:
|
||||||
void adafruitLCDSetup();
|
void adafruitLCDSetup();
|
||||||
void adafruitLCDColour(ADAFRUIT_COLOUR colour);
|
void adafruitLCDColour(ADAFRUIT_COLOUR colour);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PCF8574_DISPLAY
|
||||||
|
void pcf8574LCDSetup();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
24
Makefile.Pi.PCF8574
Normal file
24
Makefile.Pi.PCF8574
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
+# This makefile is for use with the Raspberry Pi when using an HD44780 compatible display. The wiringpi library is needed.
|
||||||
|
+# Support for the HD44780 connected via a PCF8574 8-bit GPIO expander IC
|
||||||
|
+CC = gcc
|
||||||
|
+CXX = g++
|
||||||
|
+CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include
|
||||||
|
+LIBS = -lwiringPi -lwiringPiDev -lpthread
|
||||||
|
+LDFLAGS = -g -L/usr/local/lib
|
||||||
|
+
|
||||||
|
+OBJECTS = \
|
||||||
|
+ AMBEFEC.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRIPSC.o DMRLookup.o DMRLC.o \
|
||||||
|
+ DMRShortLC.o DMRSlot.o DMRSlotType.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o Log.o MMDVMHost.o \
|
||||||
|
+ Modem.o Nextion.o NullDisplay.o QR1676.o RS129.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o YSFControl.o \
|
||||||
|
+ YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||||
|
+
|
||||||
|
+all: MMDVMHost
|
||||||
|
+
|
||||||
|
+MMDVMHost: $(OBJECTS)
|
||||||
|
+ $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost
|
||||||
|
+
|
||||||
|
+%.o: %.cpp
|
||||||
|
+ $(CXX) $(CFLAGS) -c -o $@ $<
|
||||||
|
+
|
||||||
|
+clean:
|
||||||
|
+ $(RM) MMDVMHost *.o *.d *.bak *~
|
Loading…
Reference in a new issue