Clean up the recent HD44780 changes.
This commit is contained in:
parent
52de9f3970
commit
99b71a00b2
16
Conf.cpp
16
Conf.cpp
|
@ -105,17 +105,17 @@ m_fusionNetworkEnabled(false),
|
||||||
m_fusionNetworkAddress(),
|
m_fusionNetworkAddress(),
|
||||||
m_fusionNetworkPort(0U),
|
m_fusionNetworkPort(0U),
|
||||||
m_fusionNetworkDebug(false),
|
m_fusionNetworkDebug(false),
|
||||||
m_tftSerialPort(),
|
m_tftSerialPort("/dev/ttyAMA0"),
|
||||||
m_tftSerialBrightness(50U),
|
m_tftSerialBrightness(50U),
|
||||||
m_hd44780Rows(2U),
|
m_hd44780Rows(2U),
|
||||||
m_hd44780Columns(16U),
|
m_hd44780Columns(16U),
|
||||||
m_hd44780Pins(),
|
m_hd44780Pins(),
|
||||||
m_hd44780PWM(),
|
m_hd44780PWM(false),
|
||||||
m_hd44780PWMPin(),
|
m_hd44780PWMPin(),
|
||||||
m_hd44780PWMBright(),
|
m_hd44780PWMBright(),
|
||||||
m_hd44780PWMDim(),
|
m_hd44780PWMDim(),
|
||||||
m_nextionSize(),
|
m_nextionSize("2.4"),
|
||||||
m_nextionPort(),
|
m_nextionPort("/dev/ttyAMA0"),
|
||||||
m_nextionBrightness(50U)
|
m_nextionBrightness(50U)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -344,17 +344,14 @@ bool CConf::read()
|
||||||
m_hd44780Rows = (unsigned int)::atoi(value);
|
m_hd44780Rows = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "Columns") == 0)
|
else if (::strcmp(key, "Columns") == 0)
|
||||||
m_hd44780Columns = (unsigned int)::atoi(value);
|
m_hd44780Columns = (unsigned int)::atoi(value);
|
||||||
|
|
||||||
// WFV
|
|
||||||
else if (::strcmp(key, "PWM") == 0)
|
else if (::strcmp(key, "PWM") == 0)
|
||||||
m_hd44780PWM = (unsigned int)::atoi(value);
|
m_hd44780PWM = ::atoi(value) == 1;
|
||||||
else if (::strcmp(key, "PWMPin") == 0)
|
else if (::strcmp(key, "PWMPin") == 0)
|
||||||
m_hd44780PWMPin = (unsigned int)::atoi(value);
|
m_hd44780PWMPin = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "PWMBright") == 0)
|
else if (::strcmp(key, "PWMBright") == 0)
|
||||||
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, "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) {
|
||||||
|
@ -698,8 +695,7 @@ std::vector<unsigned int> CConf::getHD44780Pins() const
|
||||||
return m_hd44780Pins;
|
return m_hd44780Pins;
|
||||||
}
|
}
|
||||||
|
|
||||||
// WFV
|
bool CConf::getHD44780PWM() const
|
||||||
unsigned int CConf::getHD44780PWM() const
|
|
||||||
{
|
{
|
||||||
return m_hd44780PWM;
|
return m_hd44780PWM;
|
||||||
}
|
}
|
||||||
|
|
8
Conf.h
8
Conf.h
|
@ -117,9 +117,7 @@ public:
|
||||||
unsigned int getHD44780Rows() const;
|
unsigned int getHD44780Rows() const;
|
||||||
unsigned int getHD44780Columns() const;
|
unsigned int getHD44780Columns() const;
|
||||||
std::vector<unsigned int> getHD44780Pins() const;
|
std::vector<unsigned int> getHD44780Pins() const;
|
||||||
|
bool getHD44780PWM() const;
|
||||||
// WFV
|
|
||||||
unsigned int getHD44780PWM() const;
|
|
||||||
unsigned int getHD44780PWMPin() const;
|
unsigned int getHD44780PWMPin() const;
|
||||||
unsigned int getHD44780PWMBright() const;
|
unsigned int getHD44780PWMBright() const;
|
||||||
unsigned int getHD44780PWMDim() const;
|
unsigned int getHD44780PWMDim() const;
|
||||||
|
@ -206,9 +204,7 @@ private:
|
||||||
unsigned int m_hd44780Rows;
|
unsigned int m_hd44780Rows;
|
||||||
unsigned int m_hd44780Columns;
|
unsigned int m_hd44780Columns;
|
||||||
std::vector<unsigned int> m_hd44780Pins;
|
std::vector<unsigned int> m_hd44780Pins;
|
||||||
|
bool m_hd44780PWM;
|
||||||
//WFV
|
|
||||||
unsigned int m_hd44780PWM;
|
|
||||||
unsigned int m_hd44780PWMPin;
|
unsigned int m_hd44780PWMPin;
|
||||||
unsigned int m_hd44780PWMBright;
|
unsigned int m_hd44780PWMBright;
|
||||||
unsigned int m_hd44780PWMDim;
|
unsigned int m_hd44780PWMDim;
|
||||||
|
|
267
HD44780.cpp
267
HD44780.cpp
|
@ -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, unsigned int 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) :
|
||||||
m_rows(rows),
|
m_rows(rows),
|
||||||
m_cols(cols),
|
m_cols(cols),
|
||||||
m_callsign(callsign),
|
m_callsign(callsign),
|
||||||
|
@ -40,13 +40,10 @@ m_d0(pins.at(2U)),
|
||||||
m_d1(pins.at(3U)),
|
m_d1(pins.at(3U)),
|
||||||
m_d2(pins.at(4U)),
|
m_d2(pins.at(4U)),
|
||||||
m_d3(pins.at(5U)),
|
m_d3(pins.at(5U)),
|
||||||
|
m_pwm(pwm),
|
||||||
// WFV
|
m_pwmPin(pwmPin),
|
||||||
m_PWM(PWM),
|
m_pwmBright(pwmBright),
|
||||||
m_PWMPin(PWMPin),
|
m_pwmDim(pwmDim),
|
||||||
m_PWMBright(PWMBright),
|
|
||||||
m_PWMDim(PWMDim),
|
|
||||||
|
|
||||||
m_fd(-1),
|
m_fd(-1),
|
||||||
m_dmr(false)
|
m_dmr(false)
|
||||||
{
|
{
|
||||||
|
@ -62,15 +59,13 @@ bool CHD44780::open()
|
||||||
{
|
{
|
||||||
::wiringPiSetup();
|
::wiringPiSetup();
|
||||||
|
|
||||||
// WFV
|
if (m_pwm) {
|
||||||
if (m_PWM == 1U) {
|
if (m_pwmPin != 1U) {
|
||||||
if (m_PWMPin != 1U) {
|
::softPwmCreate(m_pwmPin, 0, 100);
|
||||||
::softPwmCreate(m_PWMPin, 0, 100);
|
::softPwmWrite(m_pwmPin, m_pwmDim);
|
||||||
::softPwmWrite(m_PWMPin, m_PWMDim);
|
} else {
|
||||||
}
|
::pinMode(m_pwmPin, PWM_OUTPUT);
|
||||||
else {
|
::pwmWrite(m_pwmPin, (m_pwmDim / 100) * 1024);
|
||||||
::pinMode(m_PWMPin, PWM_OUTPUT);
|
|
||||||
::pwmWrite(m_PWMPin, (m_PWMDim/100)*1024);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,72 +93,77 @@ void CHD44780::adafruitLCDSetup()
|
||||||
::mcp23017Setup(AF_BASE, MCP23017);
|
::mcp23017Setup(AF_BASE, MCP23017);
|
||||||
|
|
||||||
// Backlight LEDs
|
// Backlight LEDs
|
||||||
|
::pinMode(AF_RED, OUTPUT);
|
||||||
pinMode (AF_RED, OUTPUT);
|
::pinMode(AF_GREEN, OUTPUT);
|
||||||
pinMode (AF_GREEN, OUTPUT);
|
::pinMode(AF_BLUE, OUTPUT);
|
||||||
pinMode (AF_BLUE, OUTPUT);
|
|
||||||
|
|
||||||
|
|
||||||
// Control signals
|
// Control signals
|
||||||
pinMode (AF_RW, OUTPUT);
|
::pinMode(AF_RW, OUTPUT);
|
||||||
digitalWrite (AF_RW, LOW);
|
::digitalWrite(AF_RW, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CHD44780::adafruitLCDColour(ADAFRUIT_COLOUR colour)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LCDColor(int color)
|
|
||||||
{
|
{
|
||||||
//VERY SIMPLE COLOR FUNCTION
|
switch (colour) {
|
||||||
// By Giorgio
|
case AC_OFF:
|
||||||
//OFF
|
::digitalWrite(AF_RED, HIGH);
|
||||||
if (color==0){digitalWrite (AF_RED, HIGH);digitalWrite (AF_GREEN, HIGH);digitalWrite (AF_BLUE, HIGH);} // OFF
|
::digitalWrite(AF_GREEN, HIGH);
|
||||||
//BASIC
|
::digitalWrite(AF_BLUE, HIGH);
|
||||||
if (color==1){digitalWrite (AF_RED, LOW);digitalWrite (AF_GREEN, LOW);digitalWrite (AF_BLUE, LOW);} // WHITE
|
break;
|
||||||
if (color==2){digitalWrite (AF_RED, LOW);digitalWrite (AF_GREEN, HIGH);digitalWrite (AF_BLUE, HIGH);} // RED
|
case AC_WHITE:
|
||||||
if (color==3){digitalWrite (AF_RED, HIGH);digitalWrite (AF_GREEN, LOW);digitalWrite (AF_BLUE, HIGH);} // GREEN
|
::digitalWrite(AF_RED, LOW);
|
||||||
if (color==4){digitalWrite (AF_RED, HIGH);digitalWrite (AF_GREEN, HIGH);digitalWrite (AF_BLUE, LOW);} // BLUE
|
::digitalWrite(AF_GREEN, LOW);
|
||||||
//SPECIAL
|
::digitalWrite(AF_BLUE, LOW);
|
||||||
if (color==5){digitalWrite (AF_RED, LOW);digitalWrite (AF_GREEN, HIGH);digitalWrite (AF_BLUE, LOW);} // PURPLE
|
break;
|
||||||
if (color==6){digitalWrite (AF_RED, LOW);digitalWrite (AF_GREEN, LOW);digitalWrite (AF_BLUE, HIGH);} // YELLOW
|
case AC_RED:
|
||||||
if (color==7){digitalWrite (AF_RED, HIGH);digitalWrite (AF_GREEN, LOW);digitalWrite (AF_BLUE, LOW);} // ICE
|
::digitalWrite(AF_RED, LOW);
|
||||||
|
::digitalWrite(AF_GREEN, HIGH);
|
||||||
// USE WITH:
|
::digitalWrite(AF_BLUE, HIGH);
|
||||||
/*
|
break;
|
||||||
LCDColor(0); //OFF
|
case AC_GREEN:
|
||||||
LCDColor(1); //WHITE
|
::digitalWrite(AF_RED, HIGH);
|
||||||
LCDColor(2); //RED
|
::digitalWrite(AF_GREEN, LOW);
|
||||||
LCDColor(3); //GREEN
|
::digitalWrite(AF_BLUE, HIGH);
|
||||||
LCDColor(4); //BLUE
|
break;
|
||||||
LCDColor(5); //PURPLE
|
case AC_BLUE:
|
||||||
LCDColor(6); //YELLOW
|
::digitalWrite(AF_RED, HIGH);
|
||||||
LCDColor(7); //ICE
|
::digitalWrite(AF_GREEN, HIGH);
|
||||||
*/
|
::digitalWrite(AF_BLUE, LOW);
|
||||||
|
break;
|
||||||
|
case AC_PURPLE:
|
||||||
|
::digitalWrite(AF_RED, LOW);
|
||||||
|
::digitalWrite(AF_GREEN, HIGH);
|
||||||
|
::digitalWrite(AF_BLUE, LOW);
|
||||||
|
break;
|
||||||
|
case AC_YELLOW:
|
||||||
|
::digitalWrite(AF_RED, LOW);
|
||||||
|
::digitalWrite(AF_GREEN, LOW);
|
||||||
|
::digitalWrite(AF_BLUE, HIGH);
|
||||||
|
break;
|
||||||
|
case AC_ICE:
|
||||||
|
::digitalWrite(AF_RED, HIGH);
|
||||||
|
::digitalWrite(AF_GREEN, LOW);
|
||||||
|
::digitalWrite(AF_BLUE, LOW);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CHD44780::setIdle()
|
void CHD44780::setIdle()
|
||||||
{
|
{
|
||||||
::lcdClear(m_fd);
|
::lcdClear(m_fd);
|
||||||
|
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
LCDColor(1); //WHITE
|
adafruittLCDColour(AC_WHITE);
|
||||||
#endif
|
#endif
|
||||||
// WFV
|
|
||||||
if (m_PWM == 1U) {
|
if (m_pwm) {
|
||||||
if (m_PWMPin != 1U) {
|
if (m_pwmPin != 1U)
|
||||||
::softPwmWrite(m_PWMPin, m_PWMDim);
|
::softPwmWrite(m_pwmPin, m_pwmDim);
|
||||||
}
|
else
|
||||||
else {
|
::pwmWrite(m_pwmPin, (m_pwmDim / 100) * 1024);
|
||||||
::pwmWrite(m_PWMPin, (m_PWMDim/100)*1024);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::lcdPosition(m_fd, 0, 0);
|
::lcdPosition(m_fd, 0, 0);
|
||||||
|
@ -177,21 +177,19 @@ LCDColor(1); //WHITE
|
||||||
|
|
||||||
void CHD44780::setError(const char* text)
|
void CHD44780::setError(const char* text)
|
||||||
{
|
{
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
|
||||||
LCDColor(2); //RED
|
|
||||||
#endif
|
|
||||||
assert(text != NULL);
|
assert(text != NULL);
|
||||||
|
|
||||||
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
|
adafruitLCDColour(AC_RED);
|
||||||
|
#endif
|
||||||
|
|
||||||
::lcdClear(m_fd);
|
::lcdClear(m_fd);
|
||||||
|
|
||||||
// WFV
|
if (m_pwm) {
|
||||||
if (m_PWM == 1U) {
|
if (m_pwmPin != 1U)
|
||||||
if (m_PWMPin != 1U) {
|
::softPwmWrite(m_pwmPin, m_pwmBright);
|
||||||
::softPwmWrite(m_PWMPin, m_PWMBright);
|
else
|
||||||
}
|
::pwmWrite(m_pwmPin, (m_pwmBright / 100) * 1024);
|
||||||
else {
|
|
||||||
::pwmWrite(m_PWMPin, (m_PWMBright/100)*1024);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::lcdPosition(m_fd, 0, 0);
|
::lcdPosition(m_fd, 0, 0);
|
||||||
|
@ -206,18 +204,16 @@ LCDColor(2); //RED
|
||||||
void CHD44780::setLockout()
|
void CHD44780::setLockout()
|
||||||
{
|
{
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
LCDColor(2); //RED
|
adafruitLCDColour(AC_RED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
::lcdClear(m_fd);
|
::lcdClear(m_fd);
|
||||||
|
|
||||||
// WFV
|
if (m_pwm) {
|
||||||
if (m_PWM == 1U) {
|
if (m_pwmPin != 1U)
|
||||||
if (m_PWMPin != 1U) {
|
::softPwmWrite(m_pwmPin, m_pwmBright);
|
||||||
::softPwmWrite(m_PWMPin, m_PWMBright);
|
else
|
||||||
}
|
::pwmWrite(m_pwmPin, (m_pwmBright / 100) * 1024);
|
||||||
else {
|
|
||||||
::pwmWrite(m_PWMPin, (m_PWMBright/100)*1024);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::lcdPosition(m_fd, 0, 0);
|
::lcdPosition(m_fd, 0, 0);
|
||||||
|
@ -237,16 +233,17 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your, co
|
||||||
assert(type != NULL);
|
assert(type != NULL);
|
||||||
assert(reflector != NULL);
|
assert(reflector != NULL);
|
||||||
|
|
||||||
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
|
adafruitLCDColour(AC_RED);
|
||||||
|
#endif
|
||||||
|
|
||||||
::lcdClear(m_fd);
|
::lcdClear(m_fd);
|
||||||
|
|
||||||
// WFV
|
if (m_pwm) {
|
||||||
if (m_PWM == 1U) {
|
if (m_pwmPin != 1U)
|
||||||
if (m_PWMPin != 1U) {
|
::softPwmWrite(m_pwmPin, m_pwmBright);
|
||||||
::softPwmWrite(m_PWMPin, m_PWMBright);
|
else
|
||||||
}
|
::pwmWrite(m_pwmPin, (m_pwmBright / 100) * 1024);
|
||||||
else {
|
|
||||||
::pwmWrite(m_PWMPin, (m_PWMBright/100)*1024);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::lcdPosition(m_fd, 0, 0);
|
::lcdPosition(m_fd, 0, 0);
|
||||||
|
@ -263,11 +260,11 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your, co
|
||||||
::lcdPosition(m_fd, 0, 1);
|
::lcdPosition(m_fd, 0, 1);
|
||||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||||
|
|
||||||
if (strcmp(reflector, " ") == 0) {
|
if (strcmp(reflector, " ") == 0)
|
||||||
::sprintf(buffer, "%.8s", your);
|
::sprintf(buffer, "%.8s", your);
|
||||||
} else {
|
else
|
||||||
::sprintf(buffer, "%.8s<%.8s", your, reflector);
|
::sprintf(buffer, "%.8s<%.8s", your, reflector);
|
||||||
}
|
|
||||||
::lcdPosition(m_fd, 0, 2);
|
::lcdPosition(m_fd, 0, 2);
|
||||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||||
} else if (m_rows == 4U && m_cols == 20U) {
|
} else if (m_rows == 4U && m_cols == 20U) {
|
||||||
|
@ -276,20 +273,20 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your, co
|
||||||
::lcdPosition(m_fd, 0, 1);
|
::lcdPosition(m_fd, 0, 1);
|
||||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||||
|
|
||||||
if (strcmp(reflector, " ") == 0) {
|
if (strcmp(reflector, " ") == 0)
|
||||||
::sprintf(buffer, "%.8s", your);
|
::sprintf(buffer, "%.8s", your);
|
||||||
} else {
|
else
|
||||||
::sprintf(buffer, "%.8s <- %.8s", your, reflector);
|
::sprintf(buffer, "%.8s <- %.8s", your, reflector);
|
||||||
}
|
|
||||||
::lcdPosition(m_fd, 0, 2);
|
::lcdPosition(m_fd, 0, 2);
|
||||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||||
} else if (m_rows == 2 && m_cols == 40U) {
|
} else if (m_rows == 2 && m_cols == 40U) {
|
||||||
char buffer[40U];
|
char buffer[40U];
|
||||||
if (strcmp(reflector, " ") == 0) {
|
if (strcmp(reflector, " ") == 0)
|
||||||
::sprintf(buffer, "%s %.8s/%.4s > %.8s", type, my1, my2, your);
|
::sprintf(buffer, "%s %.8s/%.4s > %.8s", type, my1, my2, your);
|
||||||
} else {
|
else
|
||||||
::sprintf(buffer, "%s %.8s/%.4s > %.8s via %.8s", type, my1, my2, your, reflector);
|
::sprintf(buffer, "%s %.8s/%.4s > %.8s via %.8s", type, my1, my2, your, reflector);
|
||||||
}
|
|
||||||
::lcdPosition(m_fd, 0, 1);
|
::lcdPosition(m_fd, 0, 1);
|
||||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||||
}
|
}
|
||||||
|
@ -299,6 +296,9 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your, co
|
||||||
|
|
||||||
void CHD44780::clearDStar()
|
void CHD44780::clearDStar()
|
||||||
{
|
{
|
||||||
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
|
adafruitLCDColour(AC_ICE);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_rows == 2U && m_cols == 16U) {
|
if (m_rows == 2U && m_cols == 16U) {
|
||||||
::lcdPosition(m_fd, 0, 1);
|
::lcdPosition(m_fd, 0, 1);
|
||||||
|
@ -323,23 +323,20 @@ void CHD44780::clearDStar()
|
||||||
|
|
||||||
void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
|
void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
|
||||||
{
|
{
|
||||||
|
|
||||||
assert(type != NULL);
|
assert(type != NULL);
|
||||||
|
|
||||||
if (!m_dmr) {
|
if (!m_dmr) {
|
||||||
::lcdClear(m_fd);
|
::lcdClear(m_fd);
|
||||||
|
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
LCDColor(3); //GREEN
|
adafruitLCDColour(AC_GREEN);
|
||||||
#endif
|
#endif
|
||||||
// WFV
|
|
||||||
if (m_PWM == 1U) {
|
if (m_pwm) {
|
||||||
if (m_PWMPin != 1U) {
|
if (m_pwmPin != 1U)
|
||||||
::softPwmWrite(m_PWMPin, m_PWMBright);
|
::softPwmWrite(m_pwmPin, m_pwmBright);
|
||||||
}
|
else
|
||||||
else {
|
::pwmWrite(m_pwmPin, (m_pwmBright / 100) * 1024);
|
||||||
::pwmWrite(m_PWMPin, (m_PWMBright/100)*1024);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_rows == 2U && m_cols == 16U) {
|
if (m_rows == 2U && m_cols == 16U) {
|
||||||
|
@ -354,6 +351,7 @@ LCDColor(3); //GREEN
|
||||||
} 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);
|
||||||
::lcdPuts(m_fd, "DMR");
|
::lcdPuts(m_fd, "DMR");
|
||||||
|
|
||||||
if (slotNo == 1U) {
|
if (slotNo == 1U) {
|
||||||
::lcdPosition(m_fd, 0, 2);
|
::lcdPosition(m_fd, 0, 2);
|
||||||
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
|
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
|
||||||
|
@ -364,6 +362,7 @@ LCDColor(3); //GREEN
|
||||||
} else if (m_rows == 4U && m_cols == 20U) {
|
} else if (m_rows == 4U && m_cols == 20U) {
|
||||||
::lcdPosition(m_fd, 0, 0);
|
::lcdPosition(m_fd, 0, 0);
|
||||||
::lcdPuts(m_fd, "DMR");
|
::lcdPuts(m_fd, "DMR");
|
||||||
|
|
||||||
if (slotNo == 1U) {
|
if (slotNo == 1U) {
|
||||||
::lcdPosition(m_fd, 0, 2);
|
::lcdPosition(m_fd, 0, 2);
|
||||||
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
|
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
|
||||||
|
@ -383,9 +382,8 @@ LCDColor(3); //GREEN
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_rows == 2U && m_cols == 16U) {
|
if (m_rows == 2U && m_cols == 16U) {
|
||||||
|
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
LCDColor(2); //RED
|
adafruitLCDColour(AC_RED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char buffer[16U];
|
char buffer[16U];
|
||||||
|
@ -399,9 +397,8 @@ LCDColor(2); //RED
|
||||||
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
|
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
|
||||||
}
|
}
|
||||||
} else if (m_rows == 4U && m_cols == 16U) {
|
} else if (m_rows == 4U && m_cols == 16U) {
|
||||||
|
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
LCDColor(2); //RED
|
adafruitLCDColour(AC_RED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char buffer[16U];
|
char buffer[16U];
|
||||||
|
@ -415,9 +412,8 @@ LCDColor(2); //RED
|
||||||
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
|
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
|
||||||
}
|
}
|
||||||
} else if (m_rows == 4U && m_cols == 20U) {
|
} else if (m_rows == 4U && m_cols == 20U) {
|
||||||
|
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
LCDColor(2); //RED
|
adafruitLCDColour(AC_RED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char buffer[20U];
|
char buffer[20U];
|
||||||
|
@ -431,9 +427,8 @@ LCDColor(2); //RED
|
||||||
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
|
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
|
||||||
}
|
}
|
||||||
} else if (m_rows == 2U && m_cols == 40U) {
|
} else if (m_rows == 2U && m_cols == 40U) {
|
||||||
|
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
LCDColor(2); //RED
|
adafruitLCDColour(AC_RED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char buffer[40U];
|
char buffer[40U];
|
||||||
|
@ -453,9 +448,8 @@ LCDColor(2); //RED
|
||||||
|
|
||||||
void CHD44780::clearDMR(unsigned int slotNo)
|
void CHD44780::clearDMR(unsigned int slotNo)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
LCDColor(7); //ICE
|
adafruitLCDColour(AC_ICE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_rows == 2U && m_cols == 16U) {
|
if (m_rows == 2U && m_cols == 16U) {
|
||||||
|
@ -498,16 +492,17 @@ void CHD44780::writeFusion(const char* source, const char* dest)
|
||||||
assert(source != NULL);
|
assert(source != NULL);
|
||||||
assert(dest != NULL);
|
assert(dest != NULL);
|
||||||
|
|
||||||
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
|
adafruitLCDColour(AC_RED);
|
||||||
|
#endif
|
||||||
|
|
||||||
::lcdClear(m_fd);
|
::lcdClear(m_fd);
|
||||||
|
|
||||||
// WFV
|
if (m_pwm) {
|
||||||
if (m_PWM == 1U) {
|
if (m_pwmPin != 1U)
|
||||||
if (m_PWMPin != 1U) {
|
::softPwmWrite(m_pwmPin, m_pwmBright);
|
||||||
::softPwmWrite(m_PWMPin, m_PWMBright);
|
else
|
||||||
}
|
::pwmWrite(m_pwmPin, (m_pwmBright / 100) * 1024);
|
||||||
else {
|
|
||||||
::pwmWrite(m_PWMPin, (m_PWMBright/100)*1024);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::lcdPosition(m_fd, 0, 0);
|
::lcdPosition(m_fd, 0, 0);
|
||||||
|
@ -549,6 +544,10 @@ void CHD44780::writeFusion(const char* source, const char* dest)
|
||||||
|
|
||||||
void CHD44780::clearFusion()
|
void CHD44780::clearFusion()
|
||||||
{
|
{
|
||||||
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
|
adafruitLCDColour(AC_ICE);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_rows == 2U && m_cols == 16U) {
|
if (m_rows == 2U && m_cols == 16U) {
|
||||||
::lcdPosition(m_fd, 0, 1);
|
::lcdPosition(m_fd, 0, 1);
|
||||||
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
|
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
|
||||||
|
|
26
HD44780.h
26
HD44780.h
|
@ -26,6 +26,17 @@
|
||||||
|
|
||||||
#include <mcp23017.h>
|
#include <mcp23017.h>
|
||||||
|
|
||||||
|
enum ADAFRUIT_COLOUR {
|
||||||
|
AC_OFF,
|
||||||
|
AC_WHITE,
|
||||||
|
AC_RED,
|
||||||
|
AC_GREEN,
|
||||||
|
AC_BLUE,
|
||||||
|
AC_PURPLE,
|
||||||
|
AC_YELLOW,
|
||||||
|
AC_ICE
|
||||||
|
};
|
||||||
|
|
||||||
// Defines for the Adafruit Pi LCD interface board
|
// Defines for the Adafruit Pi LCD interface board
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
#define AF_BASE 100
|
#define AF_BASE 100
|
||||||
|
@ -40,7 +51,7 @@
|
||||||
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, unsigned int 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);
|
||||||
virtual ~CHD44780();
|
virtual ~CHD44780();
|
||||||
|
|
||||||
virtual bool open();
|
virtual bool open();
|
||||||
|
@ -72,20 +83,17 @@ private:
|
||||||
unsigned int m_d1;
|
unsigned int m_d1;
|
||||||
unsigned int m_d2;
|
unsigned int m_d2;
|
||||||
unsigned int m_d3;
|
unsigned int m_d3;
|
||||||
|
bool m_pwm;
|
||||||
// WFV
|
unsigned int m_pwmPin;
|
||||||
unsigned int m_PWM;
|
unsigned int m_pwmBright;
|
||||||
unsigned int m_PWMPin;
|
unsigned int m_pwmDim;
|
||||||
unsigned int m_PWMBright;
|
|
||||||
unsigned int m_PWMDim;
|
|
||||||
|
|
||||||
int m_fd;
|
int m_fd;
|
||||||
bool m_dmr;
|
bool m_dmr;
|
||||||
|
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
void adafruitLCDSetup();
|
void adafruitLCDSetup();
|
||||||
|
void adafruitLCDColour(ADAFRUIT_COLOUR colour);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -572,12 +572,6 @@ void CMMDVMHost::createDisplay()
|
||||||
std::string callsign = m_conf.getCallsign();
|
std::string callsign = m_conf.getCallsign();
|
||||||
unsigned int dmrid = m_conf.getDMRId();
|
unsigned int dmrid = m_conf.getDMRId();
|
||||||
|
|
||||||
// WFV
|
|
||||||
unsigned int PWM = m_conf.getHD44780PWM();
|
|
||||||
unsigned int PWMPin = m_conf.getHD44780PWMPin();
|
|
||||||
unsigned int PWMBright = m_conf.getHD44780PWMBright();
|
|
||||||
unsigned int PWMDim = m_conf.getHD44780PWMDim();
|
|
||||||
|
|
||||||
LogInfo("Display Parameters");
|
LogInfo("Display Parameters");
|
||||||
LogInfo(" Type: %s", type.c_str());
|
LogInfo(" Type: %s", type.c_str());
|
||||||
|
|
||||||
|
@ -604,21 +598,24 @@ void CMMDVMHost::createDisplay()
|
||||||
unsigned int rows = m_conf.getHD44780Rows();
|
unsigned int rows = m_conf.getHD44780Rows();
|
||||||
unsigned int columns = m_conf.getHD44780Columns();
|
unsigned int columns = m_conf.getHD44780Columns();
|
||||||
std::vector<unsigned int> pins = m_conf.getHD44780Pins();
|
std::vector<unsigned int> pins = m_conf.getHD44780Pins();
|
||||||
|
bool pwm = m_conf.getHD44780PWM();
|
||||||
|
unsigned int pwmPin = m_conf.getHD44780PWMPin();
|
||||||
|
unsigned int pwmBright = m_conf.getHD44780PWMBright();
|
||||||
|
unsigned int pwmDim = m_conf.getHD44780PWMDim();
|
||||||
|
|
||||||
if (pins.size() == 6U) {
|
if (pins.size() == 6U) {
|
||||||
LogInfo(" Rows: %u", rows);
|
LogInfo(" Rows: %u", rows);
|
||||||
LogInfo(" Columns: %u", columns);
|
LogInfo(" Columns: %u", columns);
|
||||||
LogInfo(" Pins: %u,%u,%u,%u,%u,%u", pins.at(0U), pins.at(1U), pins.at(2U), pins.at(3U), pins.at(4U), pins.at(5U));
|
LogInfo(" Pins: %u,%u,%u,%u,%u,%u", pins.at(0U), pins.at(1U), pins.at(2U), pins.at(3U), pins.at(4U), pins.at(5U));
|
||||||
|
|
||||||
// WFV
|
if (pwm) {
|
||||||
if (PWM == 1U) {
|
|
||||||
LogInfo("PWM Brightness Control Enabled");
|
LogInfo("PWM Brightness Control Enabled");
|
||||||
LogInfo(" PWM Pin: %u", PWMPin);
|
LogInfo(" PWM Pin: %u", pwmPin);
|
||||||
LogInfo(" PWM Bright: %u", PWMBright);
|
LogInfo(" PWM Bright: %u", pwmBright);
|
||||||
LogInfo(" PWM Dim: %u", PWMDim);
|
LogInfo(" PWM Dim: %u", pwmDim);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_display = new CHD44780(rows, columns, callsign, dmrid, pins, PWM, PWMPin, PWMBright, PWMDim);
|
m_display = new CHD44780(rows, columns, callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue