mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 23:45:49 +08:00
Merge pull request #107 from phl0/DimOnIdle
Dim Nextion Displays in idle state
This commit is contained in:
9
Conf.cpp
9
Conf.cpp
@@ -142,6 +142,8 @@ m_nextionBrightness(50U),
|
|||||||
m_nextionDisplayClock(false),
|
m_nextionDisplayClock(false),
|
||||||
m_nextionUTC(false),
|
m_nextionUTC(false),
|
||||||
m_nextionDateFormat("British"),
|
m_nextionDateFormat("British"),
|
||||||
|
m_nextionDimOnIdle(false),
|
||||||
|
|
||||||
m_oledType(3),
|
m_oledType(3),
|
||||||
m_oledBrightness(0),
|
m_oledBrightness(0),
|
||||||
m_oledInvert(0)
|
m_oledInvert(0)
|
||||||
@@ -472,6 +474,8 @@ bool CConf::read()
|
|||||||
m_nextionUTC = ::atoi(value) == 1;
|
m_nextionUTC = ::atoi(value) == 1;
|
||||||
else if (::strcmp(key, "DateFormat") == 0)
|
else if (::strcmp(key, "DateFormat") == 0)
|
||||||
m_nextionDateFormat = value;
|
m_nextionDateFormat = value;
|
||||||
|
else if (::strcmp(key, "DimOnIdle") == 0)
|
||||||
|
m_nextionDimOnIdle = ::atoi(value) == 1;
|
||||||
} else if (section == SECTION_OLED) {
|
} else if (section == SECTION_OLED) {
|
||||||
if (::strcmp(key, "Type") == 0)
|
if (::strcmp(key, "Type") == 0)
|
||||||
m_oledType = (unsigned char)::atoi(value);
|
m_oledType = (unsigned char)::atoi(value);
|
||||||
@@ -952,6 +956,11 @@ std::string CConf::getNextionDateFormat() const
|
|||||||
return m_nextionDateFormat;
|
return m_nextionDateFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CConf::getNextionDimOnIdle() const
|
||||||
|
{
|
||||||
|
return m_nextionDimOnIdle;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char CConf::getOLEDType() const
|
unsigned char CConf::getOLEDType() const
|
||||||
{
|
{
|
||||||
return m_oledType;
|
return m_oledType;
|
||||||
|
|||||||
2
Conf.h
2
Conf.h
@@ -151,6 +151,7 @@ public:
|
|||||||
bool getNextionDisplayClock() const;
|
bool getNextionDisplayClock() const;
|
||||||
bool getNextionUTC() const;
|
bool getNextionUTC() const;
|
||||||
std::string getNextionDateFormat() const;
|
std::string getNextionDateFormat() const;
|
||||||
|
bool getNextionDimOnIdle() const;
|
||||||
|
|
||||||
// The OLED section
|
// The OLED section
|
||||||
unsigned char getOLEDType() const;
|
unsigned char getOLEDType() const;
|
||||||
@@ -266,6 +267,7 @@ private:
|
|||||||
bool m_nextionDisplayClock;
|
bool m_nextionDisplayClock;
|
||||||
bool m_nextionUTC;
|
bool m_nextionUTC;
|
||||||
std::string m_nextionDateFormat;
|
std::string m_nextionDateFormat;
|
||||||
|
bool m_nextionDimOnIdle;
|
||||||
|
|
||||||
unsigned char m_oledType;
|
unsigned char m_oledType;
|
||||||
unsigned char m_oledBrightness;
|
unsigned char m_oledBrightness;
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ Brightness=50
|
|||||||
DisplayClock=1
|
DisplayClock=1
|
||||||
UTC=0
|
UTC=0
|
||||||
DateFormat=British
|
DateFormat=British
|
||||||
|
DimOnIdle=1
|
||||||
|
|
||||||
[OLED]
|
[OLED]
|
||||||
Type=3
|
Type=3
|
||||||
|
|||||||
@@ -861,6 +861,7 @@ void CMMDVMHost::createDisplay()
|
|||||||
bool displayClock = m_conf.getNextionDisplayClock();
|
bool displayClock = m_conf.getNextionDisplayClock();
|
||||||
bool utc = m_conf.getNextionUTC();
|
bool utc = m_conf.getNextionUTC();
|
||||||
std::string dateformat = m_conf.getNextionDateFormat();
|
std::string dateformat = m_conf.getNextionDateFormat();
|
||||||
|
bool dimOnIdle = m_conf.getNextionDimOnIdle();
|
||||||
|
|
||||||
LogInfo(" Port: %s", port.c_str());
|
LogInfo(" Port: %s", port.c_str());
|
||||||
LogInfo(" Brightness: %u", brightness);
|
LogInfo(" Brightness: %u", brightness);
|
||||||
@@ -868,7 +869,7 @@ void CMMDVMHost::createDisplay()
|
|||||||
if (displayClock)
|
if (displayClock)
|
||||||
LogInfo(" Display UTC: %s", utc ? "yes" : "no");
|
LogInfo(" Display UTC: %s", utc ? "yes" : "no");
|
||||||
|
|
||||||
m_display = new CNextion(m_callsign, dmrid, port, brightness, displayClock, utc, dateformat);
|
m_display = new CNextion(m_callsign, dmrid, port, brightness, displayClock, utc, dateformat, dimOnIdle);
|
||||||
#if defined(HD44780)
|
#if defined(HD44780)
|
||||||
} else if (type == "HD44780") {
|
} else if (type == "HD44780") {
|
||||||
unsigned int rows = m_conf.getHD44780Rows();
|
unsigned int rows = m_conf.getHD44780Rows();
|
||||||
|
|||||||
36
Nextion.cpp
36
Nextion.cpp
@@ -24,7 +24,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
CNextion::CNextion(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness, bool displayClock, bool utc, const std::string& dateformat) :
|
CNextion::CNextion(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness, bool displayClock, bool utc, const std::string& dateformat, bool dimOnIdle) :
|
||||||
CDisplay(),
|
CDisplay(),
|
||||||
m_callsign(callsign),
|
m_callsign(callsign),
|
||||||
m_dmrid(dmrid),
|
m_dmrid(dmrid),
|
||||||
@@ -34,6 +34,7 @@ m_mode(MODE_IDLE),
|
|||||||
m_displayClock(displayClock),
|
m_displayClock(displayClock),
|
||||||
m_utc(utc),
|
m_utc(utc),
|
||||||
m_dateformat(dateformat),
|
m_dateformat(dateformat),
|
||||||
|
m_dimOnIdle(dimOnIdle),
|
||||||
m_clockDisplayTimer(1000U, 0U, 400U)
|
m_clockDisplayTimer(1000U, 0U, 400U)
|
||||||
{
|
{
|
||||||
assert(brightness >= 0U && brightness <= 100U);
|
assert(brightness >= 0U && brightness <= 100U);
|
||||||
@@ -53,10 +54,6 @@ bool CNextion::open()
|
|||||||
|
|
||||||
sendCommand("bkcmd=0");
|
sendCommand("bkcmd=0");
|
||||||
|
|
||||||
char command[20U];
|
|
||||||
::sprintf(command, "dim=%u", m_brightness);
|
|
||||||
sendCommand(command);
|
|
||||||
|
|
||||||
setIdle();
|
setIdle();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -67,6 +64,14 @@ void CNextion::setIdleInt()
|
|||||||
sendCommand("page MMDVM");
|
sendCommand("page MMDVM");
|
||||||
|
|
||||||
char command[30];
|
char command[30];
|
||||||
|
|
||||||
|
if (m_dimOnIdle) {
|
||||||
|
::sprintf(command, "dim=%u", (m_brightness/4));
|
||||||
|
} else {
|
||||||
|
::sprintf(command, "dim=%u", m_brightness);
|
||||||
|
}
|
||||||
|
sendCommand(command);
|
||||||
|
|
||||||
::sprintf(command, "t0.txt=\"%-6s / %u\"", m_callsign.c_str(), m_dmrid);
|
::sprintf(command, "t0.txt=\"%-6s / %u\"", m_callsign.c_str(), m_dmrid);
|
||||||
|
|
||||||
sendCommand(command);
|
sendCommand(command);
|
||||||
@@ -84,6 +89,9 @@ void CNextion::setErrorInt(const char* text)
|
|||||||
sendCommand("page MMDVM");
|
sendCommand("page MMDVM");
|
||||||
|
|
||||||
char command[20];
|
char command[20];
|
||||||
|
::sprintf(command, "dim=%u", m_brightness);
|
||||||
|
sendCommand(command);
|
||||||
|
|
||||||
::sprintf(command, "t0.txt=\"%s\"", text);
|
::sprintf(command, "t0.txt=\"%s\"", text);
|
||||||
|
|
||||||
sendCommand(command);
|
sendCommand(command);
|
||||||
@@ -98,6 +106,10 @@ void CNextion::setLockoutInt()
|
|||||||
{
|
{
|
||||||
sendCommand("page MMDVM");
|
sendCommand("page MMDVM");
|
||||||
|
|
||||||
|
char command[20];
|
||||||
|
::sprintf(command, "dim=%u", m_brightness);
|
||||||
|
sendCommand(command);
|
||||||
|
|
||||||
sendCommand("t0.txt=\"LOCKOUT\"");
|
sendCommand("t0.txt=\"LOCKOUT\"");
|
||||||
|
|
||||||
m_clockDisplayTimer.stop();
|
m_clockDisplayTimer.stop();
|
||||||
@@ -117,6 +129,9 @@ void CNextion::writeDStarInt(const char* my1, const char* my2, const char* your,
|
|||||||
sendCommand("page DStar");
|
sendCommand("page DStar");
|
||||||
|
|
||||||
char text[30U];
|
char text[30U];
|
||||||
|
::sprintf(text, "dim=%u", m_brightness);
|
||||||
|
sendCommand(text);
|
||||||
|
|
||||||
::sprintf(text, "t0.txt=\"%s %.8s/%4.4s\"", type, my1, my2);
|
::sprintf(text, "t0.txt=\"%s %.8s/%4.4s\"", type, my1, my2);
|
||||||
sendCommand(text);
|
sendCommand(text);
|
||||||
|
|
||||||
@@ -153,17 +168,17 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||||||
sendCommand("t0.txt=\"1 Listening\"");
|
sendCommand("t0.txt=\"1 Listening\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slotNo == 1U) {
|
char text[30U];
|
||||||
char text[30U];
|
::sprintf(text, "dim=%u", m_brightness);
|
||||||
|
sendCommand(text);
|
||||||
|
|
||||||
|
if (slotNo == 1U) {
|
||||||
::sprintf(text, "t0.txt=\"1 %s %s\"", type, src.c_str());
|
::sprintf(text, "t0.txt=\"1 %s %s\"", type, src.c_str());
|
||||||
sendCommand(text);
|
sendCommand(text);
|
||||||
|
|
||||||
::sprintf(text, "t1.txt=\"%s%s\"", group ? "TG" : "", dst.c_str());
|
::sprintf(text, "t1.txt=\"%s%s\"", group ? "TG" : "", dst.c_str());
|
||||||
sendCommand(text);
|
sendCommand(text);
|
||||||
} else {
|
} else {
|
||||||
char text[30U];
|
|
||||||
|
|
||||||
::sprintf(text, "t2.txt=\"2 %s %s\"", type, src.c_str());
|
::sprintf(text, "t2.txt=\"2 %s %s\"", type, src.c_str());
|
||||||
sendCommand(text);
|
sendCommand(text);
|
||||||
|
|
||||||
@@ -198,6 +213,9 @@ void CNextion::writeFusionInt(const char* source, const char* dest, const char*
|
|||||||
sendCommand("page YSF");
|
sendCommand("page YSF");
|
||||||
|
|
||||||
char text[30U];
|
char text[30U];
|
||||||
|
::sprintf(text, "dim=%u", m_brightness);
|
||||||
|
sendCommand(text);
|
||||||
|
|
||||||
::sprintf(text, "t0.txt=\"%s %.10s\"", type, source);
|
::sprintf(text, "t0.txt=\"%s %.10s\"", type, source);
|
||||||
sendCommand(text);
|
sendCommand(text);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
class CNextion : public CDisplay
|
class CNextion : public CDisplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CNextion(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness, bool displayClock, bool utc, const std::string& dateformat);
|
CNextion(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness, bool displayClock, bool utc, const std::string& dateformat, bool dimOnIdle);
|
||||||
virtual ~CNextion();
|
virtual ~CNextion();
|
||||||
|
|
||||||
virtual bool open();
|
virtual bool open();
|
||||||
@@ -61,6 +61,7 @@ private:
|
|||||||
bool m_displayClock;
|
bool m_displayClock;
|
||||||
bool m_utc;
|
bool m_utc;
|
||||||
std::string m_dateformat;
|
std::string m_dateformat;
|
||||||
|
bool m_dimOnIdle;
|
||||||
CTimer m_clockDisplayTimer;
|
CTimer m_clockDisplayTimer;
|
||||||
|
|
||||||
void sendCommand(const char* command);
|
void sendCommand(const char* command);
|
||||||
|
|||||||
Reference in New Issue
Block a user