diff --git a/HD44780.cpp b/HD44780.cpp index d18284b..aabcea2 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -54,6 +54,10 @@ bool CHD44780::open() { ::wiringPiSetup(); +#ifdef ADAFRUIT_DISPLAY + adafruitLCDSetup(); +#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); if (m_fd == -1) { LogError("Unable to open the HD44780"); @@ -67,6 +71,22 @@ bool CHD44780::open() return true; } +#ifdef ADAFRUIT_DISPLAY +void CHD44780::adafruitLCDSetup() +{ + // The other control pins are initialised with lcdInit () + ::mcp23017Setup (AF_BASE, MCP23017); + + // Backlight LEDs, Only one color (RED) + pinMode (AF_RED, OUTPUT); + digitalWrite (AF_RED, LOW); // The colour outputs are inverted. + + // Control signals + pinMode (AF_RW, OUTPUT); + digitalWrite (AF_RW, LOW); +} +#endif + void CHD44780::setIdle() { ::lcdClear(m_fd); diff --git a/HD44780.h b/HD44780.h index 814b22a..acce49b 100644 --- a/HD44780.h +++ b/HD44780.h @@ -24,6 +24,16 @@ #include #include +#include + +// Defines for the Adafruit Pi LCD interface board +#ifdef ADAFRUIT_DISPLAY +#define AF_BASE 100 +#define AF_RED (AF_BASE + 6) +#define AF_RW (AF_BASE + 14) +#define MCP23017 0x20 +#endif + class CHD44780 : public IDisplay { public: @@ -61,6 +71,11 @@ private: unsigned int m_d3; int m_fd; bool m_dmr; + +#ifdef ADAFRUIT_DISPLAY + void adafruitLCDSetup(); +#endif + }; #endif diff --git a/MMDVM.ini b/MMDVM.ini index 850e9ea..a4486fa 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -85,7 +85,9 @@ Brightness=50 Rows=2 Columns=16 # rs, strb, d0, d1, d2, d3 -Pins=11,10,0,1,2,3 +# Pins=11,10,0,1,2,3 +# Adafruit i2c HD44780 +Pins=115,113,112,111,110,109 [Nextion] Port=/dev/ttyAMA0 diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit new file mode 100644 index 0000000..9433045 --- /dev/null +++ b/Makefile.Pi.Adafruit @@ -0,0 +1,25 @@ +# This makefile is for use with the Raspberry Pi when using an HD44780 compatible display. The wiringpi library is needed. +# Support for the Adafruit i2c 16 x 2 RGB LCD Pi Plate +CC = gcc +CXX = g++ +CFLAGS = -g -O3 -Wall -std=c++0x -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include +LIBS = -lwiringPi -lwiringPiDev +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 Timer.o Trellis.o UDPSocket.o Utils.o YSFControl.o \ + YSFConvolution.o YSFFICH.o YSFParrot.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 *~ +