Further changes to HD44780 support on the Pi.

This commit is contained in:
Jonathan Naylor
2016-03-15 07:12:52 +00:00
parent 070bf2bff4
commit c698cfb887
5 changed files with 79 additions and 32 deletions

View File

@@ -427,7 +427,7 @@ bool CDMRIPSC::writeAuthorisation()
bool CDMRIPSC::writeConfig()
{
char* software = "MMDVM";
const char* software = "MMDVM";
char slots = '0';
if (m_duplex) {
if (m_slot1 && m_slot2)

View File

@@ -16,8 +16,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if defined(RASPBERRY_PI)
#include "HD44780.h"
#include "Log.h"
@@ -27,6 +25,8 @@
#include <cstdio>
#include <cassert>
const char* LISTENING = "Listening ";
CHD44780::CHD44780(unsigned int rows, unsigned int cols) :
m_rows(rows),
m_cols(cols),
@@ -83,52 +83,75 @@ void CHD44780::setDStar()
::lcdPuts(m_fd, "D-Star");
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Listening");
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
}
void CHD44780::writeDStar(const char* my1, const char* my2, const char* your)
{
char buffer[40U];
::sprintf(buffer, "%s/%s > %s", my1, my2, your);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%s/%s > %s", my1, my2, your);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
}
void CHD44780::clearDStar()
{
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Listening ");
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
}
void CHD44780::setDMR()
{
::lcdClear(m_fd);
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "1 DMR Listening");
int row = 0;
if (m_rows > 2U) {
::lcdPosition(m_fd, 0, row);
::lcdPuts(m_fd, "DMR");
row++;
}
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "2 DMR Listening");
::lcdPosition(m_fd, 0, row);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
row++;
::lcdPosition(m_fd, 0, row);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
}
void CHD44780::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, unsigned int dstId, const char* type)
{
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %s %u > %s%u", type, srcId, group ? "TG" : "", dstId);
}
else {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %s %u > %s%u", type, srcId, group ? "TG" : "", dstId);
char buffer[40U];
if (m_cols > 16U)
::sprintf(buffer, "%s %u > %s%u", type, srcId, group ? "TG" : "", dstId);
else
::sprintf(buffer, "%u > %s%u", srcId, group ? "TG" : "", dstId);
::lcdPosition(m_fd, 0, m_rows > 2U ? 1 : 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer);
} else {
char buffer[40U];
if (m_cols > 16U)
::sprintf(buffer, "%s %u > %s%u", type, srcId, group ? "TG" : "", dstId);
else
::sprintf(buffer, "%u > %s%u", srcId, group ? "TG" : "", dstId);
::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
}
}
void CHD44780::clearDMR(unsigned int slotNo)
{
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "1 Listening ");
::lcdPosition(m_fd, 0, m_rows > 2U ? 1 : 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
} else {
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "2 Listening ");
::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
}
}
@@ -140,23 +163,24 @@ void CHD44780::setFusion()
::lcdPuts(m_fd, "System Fusion");
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Listening");
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
}
void CHD44780::writeFusion(const char* source, const char* dest)
{
char buffer[40U];
::sprintf(buffer, "%s > %s", source, dest);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%s > %s", source, dest);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
}
void CHD44780::clearFusion()
{
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Listening ");
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
}
void CHD44780::close()
{
}
#endif

View File

@@ -19,8 +19,6 @@
#if !defined(HD44780_H)
#define HD44780_H
#if defined(RASPBERRY_PI)
#include "Display.h"
#include <string>
@@ -58,5 +56,3 @@ private:
};
#endif
#endif

View File

@@ -1,3 +1,5 @@
# This makefile is for all platforms, but doesn't include support for the HD44780 display on the Raspberry Pi.
CC = gcc
CXX = g++
CFLAGS = -g -O3 -Wall -std=c++0x
@@ -6,9 +8,9 @@ LDFLAGS = -g
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 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 \
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
DMRSlot.o DMRSlotType.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o Golay24128.o Hamming.o Log.o MMDVMHost.o Modem.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

25
Makefile.Pi Normal file
View File

@@ -0,0 +1,25 @@
# This makefile is for use with the Raspberry Pi when using an HD44780 compatible display. The wiringpi library is needed.
CC = gcc
CXX = g++
CFLAGS = -g -O3 -Wall -std=c++0x -DRASPBERRY_PI -I/usr/local/include
LIBS = -lwiringPi
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 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 \
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 *~