Add the HD4470 type display to Raspberry Pis.

This commit is contained in:
Jonathan Naylor 2016-03-14 22:58:09 +00:00
parent 3f61e9a287
commit 070bf2bff4
7 changed files with 277 additions and 8 deletions

View file

@ -37,7 +37,8 @@ enum SECTION {
SECTION_DSTAR_NETWORK,
SECTION_DMR_NETWORK,
SECTION_FUSION_NETWORK,
SECTION_TFTSERIAL
SECTION_TFTSERIAL,
SECTION_HD44780
};
CConf::CConf(const std::string& file) :
@ -93,7 +94,9 @@ m_fusionNetworkAddress(),
m_fusionNetworkPort(0U),
m_fusionNetworkDebug(false),
m_tftSerialPort(),
m_tftSerialBrightness(50U)
m_tftSerialBrightness(50U),
m_hd44780Rows(2U),
m_hd44780Columns(16U)
{
}
@ -137,9 +140,11 @@ bool CConf::read()
section = SECTION_DMR_NETWORK;
else if (::strncmp(buffer, "[System Fusion Network]", 23U) == 0)
section = SECTION_FUSION_NETWORK;
else if (::strncmp(buffer, "[TFT Serial]", 11U) == 0)
else if (::strncmp(buffer, "[TFT Serial]", 12U) == 0)
section = SECTION_TFTSERIAL;
else
else if (::strncmp(buffer, "[HD44780]", 9U) == 0)
section = SECTION_HD44780;
else
section = SECTION_NONE;
continue;
@ -265,6 +270,11 @@ bool CConf::read()
m_tftSerialPort = value;
else if (::strcmp(key, "Brightness") == 0)
m_tftSerialBrightness = (unsigned int)::atoi(value);
} else if (section == SECTION_HD44780) {
if (::strcmp(key, "Rows") == 0)
m_hd44780Rows = (unsigned int)::atoi(value);
else if (::strcmp(key, "Columns") == 0)
m_hd44780Columns = (unsigned int)::atoi(value);
}
}
@ -532,3 +542,13 @@ unsigned int CConf::getTFTSerialBrightness() const
{
return m_tftSerialBrightness;
}
unsigned int CConf::getHD44780Rows() const
{
return m_hd44780Rows;
}
unsigned int CConf::getHD44780Columns() const
{
return m_hd44780Columns;
}

7
Conf.h
View file

@ -103,6 +103,10 @@ public:
std::string getTFTSerialPort() const;
unsigned int getTFTSerialBrightness() const;
// The HD44780 section
unsigned int getHD44780Rows() const;
unsigned int getHD44780Columns() const;
private:
std::string m_file;
std::string m_callsign;
@ -167,6 +171,9 @@ private:
std::string m_tftSerialPort;
unsigned int m_tftSerialBrightness;
unsigned int m_hd44780Rows;
unsigned int m_hd44780Columns;
};
#endif

162
HD44780.cpp Normal file
View file

@ -0,0 +1,162 @@
/*
* Copyright (C) 2016 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if defined(RASPBERRY_PI)
#include "HD44780.h"
#include "Log.h"
#include <wiringPi.h>
#include <lcd.h>
#include <cstdio>
#include <cassert>
CHD44780::CHD44780(unsigned int rows, unsigned int cols) :
m_rows(rows),
m_cols(cols),
m_fd(-1)
{
}
CHD44780::~CHD44780()
{
}
bool CHD44780::open()
{
m_fd = ::lcdInit(m_rows, m_cols, 4, 11, 10, 0, 1, 2, 3, 0, 0, 0, 0);
if (m_fd == -1) {
LogError("Unable to open the HD44780");
return false;
}
::lcdDisplay(m_fd, 1);
::lcdCursor(m_fd, 0);
::lcdCursorBlink(m_fd, 0);
return true;
}
void CHD44780::setIdle()
{
::lcdClear(m_fd);
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "MMDVM");
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Idle");
}
void CHD44780::setLockout()
{
::lcdClear(m_fd);
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "MMDVM");
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Lockout");
}
void CHD44780::setDStar()
{
::lcdClear(m_fd);
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "D-Star");
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Listening");
}
void CHD44780::writeDStar(const char* my1, const char* my2, const char* your)
{
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%s/%s > %s", my1, my2, your);
}
void CHD44780::clearDStar()
{
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Listening ");
}
void CHD44780::setDMR()
{
::lcdClear(m_fd);
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "1 DMR Listening");
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "2 DMR 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);
}
}
void CHD44780::clearDMR(unsigned int slotNo)
{
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "1 Listening ");
} else {
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "2 Listening ");
}
}
void CHD44780::setFusion()
{
::lcdClear(m_fd);
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "System Fusion");
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Listening");
}
void CHD44780::writeFusion(const char* source, const char* dest)
{
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%s > %s", source, dest);
}
void CHD44780::clearFusion()
{
::lcdPosition(m_fd, 0, 1);
::lcdPuts(m_fd, "Listening ");
}
void CHD44780::close()
{
}
#endif

62
HD44780.h Normal file
View file

@ -0,0 +1,62 @@
/*
* Copyright (C) 2016 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(HD44780_H)
#define HD44780_H
#if defined(RASPBERRY_PI)
#include "Display.h"
#include <string>
class CHD44780 : public IDisplay
{
public:
CHD44780(unsigned int rows, unsigned int cols);
virtual ~CHD44780();
virtual bool open();
virtual void setIdle();
virtual void setLockout();
virtual void setDStar();
virtual void writeDStar(const char* my1, const char* my2, const char* your);
virtual void clearDStar();
virtual void setDMR();
virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId, const char* type);
virtual void clearDMR(unsigned int slotNo);
virtual void setFusion();
virtual void writeFusion(const char* source, const char* dest);
virtual void clearFusion();
virtual void close();
private:
unsigned int m_rows;
unsigned int m_cols;
int m_fd;
};
#endif
#endif

View file

@ -73,3 +73,7 @@ Debug=1
[TFT Serial]
Port=/dev/ttyAMA0
Brightness=50
[HD44780]
Rows=2
Columns=16

View file

@ -27,6 +27,10 @@
#include "NullDisplay.h"
#include "YSFControl.h"
#if defined(RASPBERRY_PI)
#include "HD44780.h"
#endif
#include <cstdio>
#if !defined(_WIN32) && !defined(_WIN64)
@ -539,13 +543,23 @@ void CMMDVMHost::createDisplay()
LogInfo(" Type: %s", type.c_str());
if (type == "TFT Serial") {
std::string port = m_conf.getTFTSerialPort();
std::string port = m_conf.getTFTSerialPort();
unsigned int brightness = m_conf.getTFTSerialBrightness();
LogInfo(" Port: %s", port.c_str());
LogInfo(" Brightness: %u", brightness);
m_display = new CTFTSerial(port, brightness);
#if defined(RASPBERRY_PI)
} else if (type == "HD44780") {
unsigned int rows = m_conf.getHD44780Rows();
unsigned int columns = m_conf.getHD44780Columns();
LogInfo(" Rows: %u", rows);
LogInfo(" Columns: %u", columns);
m_display = new CHD44780(rows, columns);
#endif
} else {
m_display = new CNullDisplay;
}

View file

@ -6,9 +6,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 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 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