Merge pull request #49 from g0wfv/develop

Better usage of display with DVMega
This commit is contained in:
Jonathan Naylor 2016-05-05 16:58:13 +01:00
commit 925f29a982
6 changed files with 67 additions and 21 deletions

View file

@ -115,6 +115,7 @@ m_hd44780PWM(false),
m_hd44780PWMPin(), m_hd44780PWMPin(),
m_hd44780PWMBright(), m_hd44780PWMBright(),
m_hd44780PWMDim(), m_hd44780PWMDim(),
m_hd44780DVMegaDisplay(false),
m_nextionSize("2.4"), m_nextionSize("2.4"),
m_nextionPort("/dev/ttyAMA0"), m_nextionPort("/dev/ttyAMA0"),
m_nextionBrightness(50U) m_nextionBrightness(50U)
@ -355,6 +356,8 @@ bool CConf::read()
m_hd44780PWMBright = (unsigned int)::atoi(value); m_hd44780PWMBright = (unsigned int)::atoi(value);
else if (::strcmp(key, "PWMDim") == 0) else if (::strcmp(key, "PWMDim") == 0)
m_hd44780PWMDim = (unsigned int)::atoi(value); m_hd44780PWMDim = (unsigned int)::atoi(value);
else if (::strcmp(key, "DVMegaDisplay") == 0)
m_hd44780DVMegaDisplay = ::atoi(value) == 1;
else if (::strcmp(key, "Pins") == 0) { else if (::strcmp(key, "Pins") == 0) {
char* p = ::strtok(value, ",\r\n"); char* p = ::strtok(value, ",\r\n");
while (p != NULL) { while (p != NULL) {
@ -723,6 +726,11 @@ unsigned int CConf::getHD44780PWMDim() const
return m_hd44780PWMDim; return m_hd44780PWMDim;
} }
bool CConf::getHD44780DVMegaDisplay() const
{
return m_hd44780DVMegaDisplay;
}
std::string CConf::getNextionSize() const std::string CConf::getNextionSize() const
{ {
return m_nextionSize; return m_nextionSize;

2
Conf.h
View file

@ -122,6 +122,7 @@ public:
unsigned int getHD44780PWMPin() const; unsigned int getHD44780PWMPin() const;
unsigned int getHD44780PWMBright() const; unsigned int getHD44780PWMBright() const;
unsigned int getHD44780PWMDim() const; unsigned int getHD44780PWMDim() const;
bool getHD44780DVMegaDisplay() const;
// The Nextion section // The Nextion section
std::string getNextionSize() const; std::string getNextionSize() const;
@ -210,6 +211,7 @@ private:
unsigned int m_hd44780PWMPin; unsigned int m_hd44780PWMPin;
unsigned int m_hd44780PWMBright; unsigned int m_hd44780PWMBright;
unsigned int m_hd44780PWMDim; unsigned int m_hd44780PWMDim;
bool m_hd44780DVMegaDisplay;
std::string m_nextionSize; std::string m_nextionSize;
std::string m_nextionPort; std::string m_nextionPort;

View file

@ -29,7 +29,7 @@
const char* LISTENING = "Listening "; const char* LISTENING = "Listening ";
CHD44780::CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim) : CHD44780::CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool dvmegaDisplay) :
m_rows(rows), m_rows(rows),
m_cols(cols), m_cols(cols),
m_callsign(callsign), m_callsign(callsign),
@ -44,6 +44,7 @@ m_pwm(pwm),
m_pwmPin(pwmPin), m_pwmPin(pwmPin),
m_pwmBright(pwmBright), m_pwmBright(pwmBright),
m_pwmDim(pwmDim), m_pwmDim(pwmDim),
m_dvmegaDisplay(dvmegaDisplay),
m_fd(-1), m_fd(-1),
m_dmr(false) m_dmr(false)
{ {
@ -340,13 +341,20 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group,
} }
if (m_rows == 2U && m_cols == 16U) { if (m_rows == 2U && m_cols == 16U) {
if (!m_dvmegaDisplay) {
if (slotNo == 1U) { if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
} else { } else {
::lcdPosition(m_fd, 0, 0); ::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
}
} else {
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "DMR ");
::lcdPosition(m_fd, 0, 1);
// ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
::lcdPrintf(m_fd, "%-16s", "Listening");
} }
} else if (m_rows == 4U && m_cols == 16U) { } else if (m_rows == 4U && m_cols == 16U) {
::lcdPosition(m_fd, 0, 0); ::lcdPosition(m_fd, 0, 0);
@ -387,15 +395,27 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group,
#endif #endif
char buffer[16U]; char buffer[16U];
if (!m_dvmegaDisplay) {
if (slotNo == 1U) { if (slotNo == 1U) {
::sprintf(buffer, "%s >%s%s", src.c_str(), group ? "TG" : "", dst.c_str()); ::sprintf(buffer, "%s > %s%s", src.c_str(), group ? "TG" : "", dst.c_str());
::lcdPosition(m_fd, 0, 0); ::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer);
} else { } else {
::sprintf(buffer, "%s >%s%s", src.c_str(), group ? "TG" : "", dst.c_str()); ::sprintf(buffer, "%s > %s%s", src.c_str(), group ? "TG" : "", dst.c_str());
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
} }
} else {
::sprintf(buffer, "From: %s", src.c_str());
::lcdPosition(m_fd, 0, 0);
// ::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
::lcdPrintf(m_fd, "%-16s", buffer);
::sprintf(buffer, "To : %s%s", group ? "TG" : "", dst.c_str());
::lcdPosition(m_fd, 0, 1);
// ::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
::lcdPrintf(m_fd, "%-16s", buffer);
}
} else if (m_rows == 4U && m_cols == 16U) { } else if (m_rows == 4U && m_cols == 16U) {
#ifdef ADAFRUIT_DISPLAY #ifdef ADAFRUIT_DISPLAY
adafruitLCDColour(AC_RED); adafruitLCDColour(AC_RED);
@ -403,11 +423,11 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group,
char buffer[16U]; char buffer[16U];
if (slotNo == 1U) { if (slotNo == 1U) {
::sprintf(buffer, "%s %s >%s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str());
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer);
} else { } else {
::sprintf(buffer, "%s %s >%s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str());
::lcdPosition(m_fd, 0, 2); ::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
} }
@ -453,6 +473,7 @@ void CHD44780::clearDMR(unsigned int slotNo)
#endif #endif
if (m_rows == 2U && m_cols == 16U) { if (m_rows == 2U && m_cols == 16U) {
if (!m_dvmegaDisplay) {
if (slotNo == 1U) { if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 0); ::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
@ -460,6 +481,13 @@ void CHD44780::clearDMR(unsigned int slotNo)
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
} }
} else {
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "DMR ");
::lcdPosition(m_fd, 0, 1);
// ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
::lcdPrintf(m_fd, "%-16s", "Listening");
}
} else if (m_rows == 4U && m_cols == 16U) { } else if (m_rows == 4U && m_cols == 16U) {
if (slotNo == 1U) { if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);

View file

@ -51,7 +51,7 @@ enum ADAFRUIT_COLOUR {
class CHD44780 : public IDisplay class CHD44780 : public IDisplay
{ {
public: public:
CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim); CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool dvmegaDisplay);
virtual ~CHD44780(); virtual ~CHD44780();
virtual bool open(); virtual bool open();
@ -87,6 +87,7 @@ private:
unsigned int m_pwmPin; unsigned int m_pwmPin;
unsigned int m_pwmBright; unsigned int m_pwmBright;
unsigned int m_pwmDim; unsigned int m_pwmDim;
bool m_dvmegaDisplay;
int m_fd; int m_fd;
bool m_dmr; bool m_dmr;

View file

@ -97,6 +97,9 @@ PWMDim=16
# Adafruit i2c HD44780 # Adafruit i2c HD44780
Pins=115,113,112,111,110,109 Pins=115,113,112,111,110,109
# Use redundant display real estate when connected to a DVMega
DVMegaDisplay=0
[Nextion] [Nextion]
Size=2.4 Size=2.4
Port=/dev/ttyAMA0 Port=/dev/ttyAMA0

View file

@ -691,6 +691,7 @@ void CMMDVMHost::createDisplay()
unsigned int pwmPin = m_conf.getHD44780PWMPin(); unsigned int pwmPin = m_conf.getHD44780PWMPin();
unsigned int pwmBright = m_conf.getHD44780PWMBright(); unsigned int pwmBright = m_conf.getHD44780PWMBright();
unsigned int pwmDim = m_conf.getHD44780PWMDim(); unsigned int pwmDim = m_conf.getHD44780PWMDim();
bool dvmegaDisplay = m_conf.getHD44780DVMegaDisplay();
if (pins.size() == 6U) { if (pins.size() == 6U) {
LogInfo(" Rows: %u", rows); LogInfo(" Rows: %u", rows);
@ -704,7 +705,10 @@ void CMMDVMHost::createDisplay()
LogInfo(" PWM Dim: %u", pwmDim); LogInfo(" PWM Dim: %u", pwmDim);
} }
m_display = new CHD44780(rows, columns, callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim); if (dvmegaDisplay)
LogInfo("Using DVMega display output on HD44780");
m_display = new CHD44780(rows, columns, callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim, dvmegaDisplay);
} }
#endif #endif
} else { } else {