Allow the modem to host a serial display.
This commit is contained in:
parent
7503d314e0
commit
178e104d44
|
@ -125,6 +125,7 @@ LocalPort=20013
|
||||||
Debug=0
|
Debug=0
|
||||||
|
|
||||||
[TFT Serial]
|
[TFT Serial]
|
||||||
|
# Port=modem
|
||||||
Port=/dev/ttyAMA0
|
Port=/dev/ttyAMA0
|
||||||
Brightness=50
|
Brightness=50
|
||||||
|
|
||||||
|
@ -149,6 +150,7 @@ DisplayClock=1
|
||||||
UTC=0
|
UTC=0
|
||||||
|
|
||||||
[Nextion]
|
[Nextion]
|
||||||
|
# Port=modem
|
||||||
Port=/dev/ttyAMA0
|
Port=/dev/ttyAMA0
|
||||||
Brightness=50
|
Brightness=50
|
||||||
DisplayClock=1
|
DisplayClock=1
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MMDVMHost.h"
|
#include "MMDVMHost.h"
|
||||||
#include "Log.h"
|
#include "SerialController.h"
|
||||||
|
#include "ModemSerialPort.h"
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
#include "StopWatch.h"
|
#include "StopWatch.h"
|
||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
#include "P25Control.h"
|
#include "P25Control.h"
|
||||||
#include "Nextion.h"
|
#include "Nextion.h"
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
#if defined(HD44780)
|
#if defined(HD44780)
|
||||||
#include "HD44780.h"
|
#include "HD44780.h"
|
||||||
|
@ -974,7 +976,7 @@ void CMMDVMHost::readParams()
|
||||||
|
|
||||||
void CMMDVMHost::createDisplay()
|
void CMMDVMHost::createDisplay()
|
||||||
{
|
{
|
||||||
std::string type = m_conf.getDisplay();
|
std::string type = m_conf.getDisplay();
|
||||||
unsigned int dmrid = m_conf.getDMRId();
|
unsigned int dmrid = m_conf.getDMRId();
|
||||||
|
|
||||||
LogInfo("Display Parameters");
|
LogInfo("Display Parameters");
|
||||||
|
@ -987,7 +989,13 @@ void CMMDVMHost::createDisplay()
|
||||||
LogInfo(" Port: %s", port.c_str());
|
LogInfo(" Port: %s", port.c_str());
|
||||||
LogInfo(" Brightness: %u", brightness);
|
LogInfo(" Brightness: %u", brightness);
|
||||||
|
|
||||||
m_display = new CTFTSerial(m_callsign, dmrid, port, brightness);
|
ISerialPort* serial = NULL;
|
||||||
|
if (port == "modem")
|
||||||
|
serial = new CModemSerialPort(m_modem);
|
||||||
|
else
|
||||||
|
serial = new CSerialController(port, SERIAL_9600);
|
||||||
|
|
||||||
|
m_display = new CTFTSerial(m_callsign, dmrid, serial, brightness);
|
||||||
} else if (type == "Nextion") {
|
} else if (type == "Nextion") {
|
||||||
std::string port = m_conf.getNextionPort();
|
std::string port = m_conf.getNextionPort();
|
||||||
unsigned int brightness = m_conf.getNextionBrightness();
|
unsigned int brightness = m_conf.getNextionBrightness();
|
||||||
|
@ -1002,7 +1010,13 @@ void CMMDVMHost::createDisplay()
|
||||||
LogInfo(" Display UTC: %s", utc ? "yes" : "no");
|
LogInfo(" Display UTC: %s", utc ? "yes" : "no");
|
||||||
LogInfo(" Idle Brightness: %u", idleBrightness);
|
LogInfo(" Idle Brightness: %u", idleBrightness);
|
||||||
|
|
||||||
m_display = new CNextion(m_callsign, dmrid, port, brightness, displayClock, utc, idleBrightness);
|
ISerialPort* serial = NULL;
|
||||||
|
if (port == "modem")
|
||||||
|
serial = new CModemSerialPort(m_modem);
|
||||||
|
else
|
||||||
|
serial = new CSerialController(port, SERIAL_9600);
|
||||||
|
|
||||||
|
m_display = new CNextion(m_callsign, dmrid, serial, brightness, displayClock, utc, idleBrightness);
|
||||||
#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();
|
||||||
|
|
|
@ -180,6 +180,7 @@
|
||||||
<ClInclude Include="Log.h" />
|
<ClInclude Include="Log.h" />
|
||||||
<ClInclude Include="MMDVMHost.h" />
|
<ClInclude Include="MMDVMHost.h" />
|
||||||
<ClInclude Include="Modem.h" />
|
<ClInclude Include="Modem.h" />
|
||||||
|
<ClInclude Include="ModemSerialPort.h" />
|
||||||
<ClInclude Include="Nextion.h" />
|
<ClInclude Include="Nextion.h" />
|
||||||
<ClInclude Include="NullDisplay.h" />
|
<ClInclude Include="NullDisplay.h" />
|
||||||
<ClInclude Include="P25Audio.h" />
|
<ClInclude Include="P25Audio.h" />
|
||||||
|
@ -195,6 +196,7 @@
|
||||||
<ClInclude Include="RS129.h" />
|
<ClInclude Include="RS129.h" />
|
||||||
<ClInclude Include="RS241213.h" />
|
<ClInclude Include="RS241213.h" />
|
||||||
<ClInclude Include="SerialController.h" />
|
<ClInclude Include="SerialController.h" />
|
||||||
|
<ClInclude Include="SerialPort.h" />
|
||||||
<ClInclude Include="SHA256.h" />
|
<ClInclude Include="SHA256.h" />
|
||||||
<ClInclude Include="StopWatch.h" />
|
<ClInclude Include="StopWatch.h" />
|
||||||
<ClInclude Include="Sync.h" />
|
<ClInclude Include="Sync.h" />
|
||||||
|
@ -243,6 +245,7 @@
|
||||||
<ClCompile Include="Log.cpp" />
|
<ClCompile Include="Log.cpp" />
|
||||||
<ClCompile Include="MMDVMHost.cpp" />
|
<ClCompile Include="MMDVMHost.cpp" />
|
||||||
<ClCompile Include="Modem.cpp" />
|
<ClCompile Include="Modem.cpp" />
|
||||||
|
<ClCompile Include="ModemSerialPort.cpp" />
|
||||||
<ClCompile Include="Nextion.cpp" />
|
<ClCompile Include="Nextion.cpp" />
|
||||||
<ClCompile Include="NullDisplay.cpp" />
|
<ClCompile Include="NullDisplay.cpp" />
|
||||||
<ClCompile Include="P25Audio.cpp" />
|
<ClCompile Include="P25Audio.cpp" />
|
||||||
|
@ -256,6 +259,7 @@
|
||||||
<ClCompile Include="RS129.cpp" />
|
<ClCompile Include="RS129.cpp" />
|
||||||
<ClCompile Include="RS241213.cpp" />
|
<ClCompile Include="RS241213.cpp" />
|
||||||
<ClCompile Include="SerialController.cpp" />
|
<ClCompile Include="SerialController.cpp" />
|
||||||
|
<ClCompile Include="SerialPort.cpp" />
|
||||||
<ClCompile Include="SHA256.cpp" />
|
<ClCompile Include="SHA256.cpp" />
|
||||||
<ClCompile Include="StopWatch.cpp" />
|
<ClCompile Include="StopWatch.cpp" />
|
||||||
<ClCompile Include="Sync.cpp" />
|
<ClCompile Include="Sync.cpp" />
|
||||||
|
|
|
@ -203,6 +203,12 @@
|
||||||
<ClInclude Include="RS241213.h">
|
<ClInclude Include="RS241213.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="SerialPort.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ModemSerialPort.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="BPTC19696.cpp">
|
<ClCompile Include="BPTC19696.cpp">
|
||||||
|
@ -376,5 +382,11 @@
|
||||||
<ClCompile Include="RS241213.cpp">
|
<ClCompile Include="RS241213.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="SerialPort.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ModemSerialPort.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
6
Makefile
6
Makefile
|
@ -9,9 +9,9 @@ LDFLAGS = -g
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
||||||
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
||||||
Golay24128.o Hamming.o Log.o MMDVMHost.o Modem.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Utils.o \
|
Golay24128.o Hamming.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o \
|
||||||
QR1676.o RS129.o RS241213.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o YSFControl.o YSFConvolution.o \
|
P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o \
|
||||||
YSFFICH.o YSFNetwork.o YSFPayload.o
|
YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||||
|
|
||||||
all: MMDVMHost
|
all: MMDVMHost
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ LDFLAGS = -g -L/usr/local/lib
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
||||||
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
||||||
Golay24128.o Hamming.o HD44780.o Log.o MMDVMHost.o Modem.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \
|
Golay24128.o Hamming.o HD44780.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
|
||||||
P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o YSFControl.o \
|
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
|
||||||
YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||||
|
|
||||||
all: MMDVMHost
|
all: MMDVMHost
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ LDFLAGS = -g -L/usr/local/lib
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
||||||
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
||||||
Golay24128.o Hamming.o HD44780.o Log.o MMDVMHost.o Modem.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \
|
Golay24128.o Hamming.o HD44780.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
|
||||||
P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o YSFControl.o \
|
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
|
||||||
YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||||
|
|
||||||
all: MMDVMHost
|
all: MMDVMHost
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ LDFLAGS = -g -L/usr/local/lib
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
||||||
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
||||||
Golay24128.o Hamming.o OLED.o Log.o MMDVMHost.o Modem.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \
|
Golay24128.o Hamming.o OLED.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o \
|
||||||
P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o YSFControl.o \
|
P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o \
|
||||||
YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||||
|
|
||||||
all: MMDVMHost
|
all: MMDVMHost
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ LDFLAGS = -g -L/usr/local/lib
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
||||||
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
||||||
Golay24128.o Hamming.o HD44780.o Log.o MMDVMHost.o Modem.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \
|
Golay24128.o Hamming.o HD44780.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
|
||||||
P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o YSFControl.o \
|
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
|
||||||
YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||||
|
|
||||||
all: MMDVMHost
|
all: MMDVMHost
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ LDFLAGS = -g
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
||||||
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
||||||
Golay24128.o Hamming.o Log.o MMDVMHost.o Modem.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Utils.o \
|
Golay24128.o Hamming.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o \
|
||||||
QR1676.o RS129.o RS241213.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o YSFControl.o YSFConvolution.o \
|
P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o \
|
||||||
YSFFICH.o YSFNetwork.o YSFPayload.o
|
YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||||
|
|
||||||
all: MMDVMHost
|
all: MMDVMHost
|
||||||
|
|
||||||
|
|
30
Modem.cpp
30
Modem.cpp
|
@ -69,6 +69,8 @@ const unsigned char MMDVM_P25_LOST = 0x32U;
|
||||||
const unsigned char MMDVM_ACK = 0x70U;
|
const unsigned char MMDVM_ACK = 0x70U;
|
||||||
const unsigned char MMDVM_NAK = 0x7FU;
|
const unsigned char MMDVM_NAK = 0x7FU;
|
||||||
|
|
||||||
|
const unsigned char MMDVM_SERIAL = 0x80U;
|
||||||
|
|
||||||
const unsigned char MMDVM_DEBUG1 = 0xF1U;
|
const unsigned char MMDVM_DEBUG1 = 0xF1U;
|
||||||
const unsigned char MMDVM_DEBUG2 = 0xF2U;
|
const unsigned char MMDVM_DEBUG2 = 0xF2U;
|
||||||
const unsigned char MMDVM_DEBUG3 = 0xF3U;
|
const unsigned char MMDVM_DEBUG3 = 0xF3U;
|
||||||
|
@ -655,6 +657,15 @@ unsigned int CModem::readP25Data(unsigned char* data)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To be implemented later if needed
|
||||||
|
unsigned int CModem::readSerial(unsigned char* data, unsigned int length)
|
||||||
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
assert(length > 0U);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
|
||||||
bool CModem::hasDStarSpace() const
|
bool CModem::hasDStarSpace() const
|
||||||
{
|
{
|
||||||
unsigned int space = m_txDStarData.freeSpace() / (DSTAR_FRAME_LENGTH_BYTES + 4U);
|
unsigned int space = m_txDStarData.freeSpace() / (DSTAR_FRAME_LENGTH_BYTES + 4U);
|
||||||
|
@ -816,6 +827,24 @@ bool CModem::writeP25Data(const unsigned char* data, unsigned int length)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CModem::writeSerial(const unsigned char* data, unsigned int length)
|
||||||
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
assert(length > 0U);
|
||||||
|
|
||||||
|
unsigned char buffer[250U];
|
||||||
|
|
||||||
|
buffer[0U] = MMDVM_FRAME_START;
|
||||||
|
buffer[1U] = length + 3U;
|
||||||
|
buffer[2U] = MMDVM_SERIAL;
|
||||||
|
|
||||||
|
::memcpy(buffer + 3U, data, length);
|
||||||
|
|
||||||
|
int ret = m_serial.write(buffer, length + 3U);
|
||||||
|
|
||||||
|
return ret != int(length + 3U);
|
||||||
|
}
|
||||||
|
|
||||||
bool CModem::hasTX() const
|
bool CModem::hasTX() const
|
||||||
{
|
{
|
||||||
return m_tx;
|
return m_tx;
|
||||||
|
@ -1088,6 +1117,7 @@ RESP_TYPE_MMDVM CModem::getResponse()
|
||||||
case MMDVM_GET_VERSION:
|
case MMDVM_GET_VERSION:
|
||||||
case MMDVM_ACK:
|
case MMDVM_ACK:
|
||||||
case MMDVM_NAK:
|
case MMDVM_NAK:
|
||||||
|
case MMDVM_SERIAL:
|
||||||
case MMDVM_DEBUG1:
|
case MMDVM_DEBUG1:
|
||||||
case MMDVM_DEBUG2:
|
case MMDVM_DEBUG2:
|
||||||
case MMDVM_DEBUG3:
|
case MMDVM_DEBUG3:
|
||||||
|
|
4
Modem.h
4
Modem.h
|
@ -50,6 +50,8 @@ public:
|
||||||
unsigned int readYSFData(unsigned char* data);
|
unsigned int readYSFData(unsigned char* data);
|
||||||
unsigned int readP25Data(unsigned char* data);
|
unsigned int readP25Data(unsigned char* data);
|
||||||
|
|
||||||
|
unsigned int readSerial(unsigned char* data, unsigned int length);
|
||||||
|
|
||||||
bool hasDStarSpace() const;
|
bool hasDStarSpace() const;
|
||||||
bool hasDMRSpace1() const;
|
bool hasDMRSpace1() const;
|
||||||
bool hasDMRSpace2() const;
|
bool hasDMRSpace2() const;
|
||||||
|
@ -71,6 +73,8 @@ public:
|
||||||
bool writeDMRShortLC(const unsigned char* lc);
|
bool writeDMRShortLC(const unsigned char* lc);
|
||||||
bool writeDMRAbort(unsigned int slotNo);
|
bool writeDMRAbort(unsigned int slotNo);
|
||||||
|
|
||||||
|
bool writeSerial(const unsigned char* data, unsigned int length);
|
||||||
|
|
||||||
bool setMode(unsigned char mode);
|
bool setMode(unsigned char mode);
|
||||||
|
|
||||||
bool sendCWId(const std::string& callsign);
|
bool sendCWId(const std::string& callsign);
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ModemSerialPort.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
CModemSerialPort::CModemSerialPort(CModem* modem) :
|
||||||
|
m_modem(modem)
|
||||||
|
{
|
||||||
|
assert(modem != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
CModemSerialPort::~CModemSerialPort()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CModemSerialPort::open()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CModemSerialPort::write(const unsigned char* data, unsigned int length)
|
||||||
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
assert(length > 0U);
|
||||||
|
|
||||||
|
bool ret = m_modem->writeSerial(data, length);
|
||||||
|
|
||||||
|
return ret ? int(length) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CModemSerialPort::read(unsigned char* data, unsigned int length)
|
||||||
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
assert(length > 0U);
|
||||||
|
|
||||||
|
return m_modem->readSerial(data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModemSerialPort::close()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ModemSerialPort_H
|
||||||
|
#define ModemSerialPort_H
|
||||||
|
|
||||||
|
#include "SerialPort.h"
|
||||||
|
#include "Modem.h"
|
||||||
|
|
||||||
|
class CModemSerialPort : public ISerialPort {
|
||||||
|
public:
|
||||||
|
CModemSerialPort(CModem* modem);
|
||||||
|
virtual ~CModemSerialPort();
|
||||||
|
|
||||||
|
virtual bool open();
|
||||||
|
|
||||||
|
virtual int read(unsigned char* buffer, unsigned int length);
|
||||||
|
|
||||||
|
virtual int write(const unsigned char* buffer, unsigned int length);
|
||||||
|
|
||||||
|
virtual void close();
|
||||||
|
|
||||||
|
private:
|
||||||
|
CModem* m_modem;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
15
Nextion.cpp
15
Nextion.cpp
|
@ -25,11 +25,11 @@
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
|
||||||
CNextion::CNextion(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness) :
|
CNextion::CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness) :
|
||||||
CDisplay(),
|
CDisplay(),
|
||||||
m_callsign(callsign),
|
m_callsign(callsign),
|
||||||
m_dmrid(dmrid),
|
m_dmrid(dmrid),
|
||||||
m_serial(port, SERIAL_9600),
|
m_serial(serial),
|
||||||
m_brightness(brightness),
|
m_brightness(brightness),
|
||||||
m_mode(MODE_IDLE),
|
m_mode(MODE_IDLE),
|
||||||
m_displayClock(displayClock),
|
m_displayClock(displayClock),
|
||||||
|
@ -37,6 +37,7 @@ m_utc(utc),
|
||||||
m_idleBrightness(idleBrightness),
|
m_idleBrightness(idleBrightness),
|
||||||
m_clockDisplayTimer(1000U, 0U, 400U)
|
m_clockDisplayTimer(1000U, 0U, 400U)
|
||||||
{
|
{
|
||||||
|
assert(serial != NULL);
|
||||||
assert(brightness >= 0U && brightness <= 100U);
|
assert(brightness >= 0U && brightness <= 100U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +47,10 @@ CNextion::~CNextion()
|
||||||
|
|
||||||
bool CNextion::open()
|
bool CNextion::open()
|
||||||
{
|
{
|
||||||
bool ret = m_serial.open();
|
bool ret = m_serial->open();
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
LogError("Cannot open the port for the Nextion display");
|
LogError("Cannot open the port for the Nextion display");
|
||||||
|
delete m_serial;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,13 +304,14 @@ void CNextion::clockInt(unsigned int ms)
|
||||||
|
|
||||||
void CNextion::close()
|
void CNextion::close()
|
||||||
{
|
{
|
||||||
m_serial.close();
|
m_serial->close();
|
||||||
|
delete m_serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNextion::sendCommand(const char* command)
|
void CNextion::sendCommand(const char* command)
|
||||||
{
|
{
|
||||||
assert(command != NULL);
|
assert(command != NULL);
|
||||||
|
|
||||||
m_serial.write((unsigned char*)command, ::strlen(command));
|
m_serial->write((unsigned char*)command, ::strlen(command));
|
||||||
m_serial.write((unsigned char*)"\xFF\xFF\xFF", 3U);
|
m_serial->write((unsigned char*)"\xFF\xFF\xFF", 3U);
|
||||||
}
|
}
|
||||||
|
|
22
Nextion.h
22
Nextion.h
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
#include "SerialController.h"
|
#include "SerialPort.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -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, unsigned int idleBrightness);
|
CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness);
|
||||||
virtual ~CNextion();
|
virtual ~CNextion();
|
||||||
|
|
||||||
virtual bool open();
|
virtual bool open();
|
||||||
|
@ -59,15 +59,15 @@ protected:
|
||||||
virtual void clockInt(unsigned int ms);
|
virtual void clockInt(unsigned int ms);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_callsign;
|
std::string m_callsign;
|
||||||
unsigned int m_dmrid;
|
unsigned int m_dmrid;
|
||||||
CSerialController m_serial;
|
ISerialPort* m_serial;
|
||||||
unsigned int m_brightness;
|
unsigned int m_brightness;
|
||||||
unsigned char m_mode;
|
unsigned char m_mode;
|
||||||
bool m_displayClock;
|
bool m_displayClock;
|
||||||
bool m_utc;
|
bool m_utc;
|
||||||
unsigned int m_idleBrightness;
|
unsigned int m_idleBrightness;
|
||||||
CTimer m_clockDisplayTimer;
|
CTimer m_clockDisplayTimer;
|
||||||
|
|
||||||
void sendCommand(const char* command);
|
void sendCommand(const char* command);
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#ifndef SerialController_H
|
#ifndef SerialController_H
|
||||||
#define SerialController_H
|
#define SerialController_H
|
||||||
|
|
||||||
|
#include "SerialPort.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
@ -38,17 +40,18 @@ enum SERIAL_SPEED {
|
||||||
SERIAL_230400 = 230400
|
SERIAL_230400 = 230400
|
||||||
};
|
};
|
||||||
|
|
||||||
class CSerialController {
|
class CSerialController : public ISerialPort {
|
||||||
public:
|
public:
|
||||||
CSerialController(const std::string& device, SERIAL_SPEED speed, bool assertRTS = false);
|
CSerialController(const std::string& device, SERIAL_SPEED speed, bool assertRTS = false);
|
||||||
~CSerialController();
|
virtual ~CSerialController();
|
||||||
|
|
||||||
bool open();
|
virtual bool open();
|
||||||
|
|
||||||
int read(unsigned char* buffer, unsigned int length);
|
virtual int read(unsigned char* buffer, unsigned int length);
|
||||||
int write(const unsigned char* buffer, unsigned int length);
|
|
||||||
|
|
||||||
void close();
|
virtual int write(const unsigned char* buffer, unsigned int length);
|
||||||
|
|
||||||
|
virtual void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_device;
|
std::string m_device;
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SerialPort.h"
|
||||||
|
|
||||||
|
ISerialPort::~ISerialPort()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SerialPort_H
|
||||||
|
#define SerialPort_H
|
||||||
|
|
||||||
|
class ISerialPort {
|
||||||
|
public:
|
||||||
|
virtual ~ISerialPort() = 0;
|
||||||
|
|
||||||
|
virtual bool open() = 0;
|
||||||
|
|
||||||
|
virtual int read(unsigned char* buffer, unsigned int length) = 0;
|
||||||
|
|
||||||
|
virtual int write(const unsigned char* buffer, unsigned int length) = 0;
|
||||||
|
|
||||||
|
virtual void close() = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
111
TFTSerial.cpp
111
TFTSerial.cpp
|
@ -44,14 +44,15 @@ const unsigned char FONT_LARGE = 3U;
|
||||||
// x = 0 to 159, y = 0 to 127 - Landscape
|
// x = 0 to 159, y = 0 to 127 - Landscape
|
||||||
// x = 0 to 127, y = 0 to 159 - Portrait
|
// x = 0 to 127, y = 0 to 159 - Portrait
|
||||||
|
|
||||||
CTFTSerial::CTFTSerial(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness) :
|
CTFTSerial::CTFTSerial(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness) :
|
||||||
CDisplay(),
|
CDisplay(),
|
||||||
m_callsign(callsign),
|
m_callsign(callsign),
|
||||||
m_dmrid(dmrid),
|
m_dmrid(dmrid),
|
||||||
m_serial(port, SERIAL_9600),
|
m_serial(serial),
|
||||||
m_brightness(brightness),
|
m_brightness(brightness),
|
||||||
m_mode(MODE_IDLE)
|
m_mode(MODE_IDLE)
|
||||||
{
|
{
|
||||||
|
assert(serial != NULL);
|
||||||
assert(brightness >= 0U && brightness <= 100U);
|
assert(brightness >= 0U && brightness <= 100U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +62,10 @@ CTFTSerial::~CTFTSerial()
|
||||||
|
|
||||||
bool CTFTSerial::open()
|
bool CTFTSerial::open()
|
||||||
{
|
{
|
||||||
bool ret = m_serial.open();
|
bool ret = m_serial->open();
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
LogError("Cannot open the port for the TFT Serial");
|
LogError("Cannot open the port for the TFT Serial");
|
||||||
|
delete m_serial;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,131 +370,132 @@ void CTFTSerial::clearCWInt()
|
||||||
|
|
||||||
void CTFTSerial::close()
|
void CTFTSerial::close()
|
||||||
{
|
{
|
||||||
m_serial.close();
|
m_serial->close();
|
||||||
|
delete m_serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::clearScreen()
|
void CTFTSerial::clearScreen()
|
||||||
{
|
{
|
||||||
m_serial.write((unsigned char*)"\x1B\x00\xFF", 3U);
|
m_serial->write((unsigned char*)"\x1B\x00\xFF", 3U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::setForeground(unsigned char colour)
|
void CTFTSerial::setForeground(unsigned char colour)
|
||||||
{
|
{
|
||||||
assert(colour >= 0U && colour <= 7U);
|
assert(colour >= 0U && colour <= 7U);
|
||||||
|
|
||||||
m_serial.write((unsigned char*)"\x1B\x01", 2U);
|
m_serial->write((unsigned char*)"\x1B\x01", 2U);
|
||||||
m_serial.write(&colour, 1U);
|
m_serial->write(&colour, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::setBackground(unsigned char colour)
|
void CTFTSerial::setBackground(unsigned char colour)
|
||||||
{
|
{
|
||||||
assert(colour >= 0U && colour <= 7U);
|
assert(colour >= 0U && colour <= 7U);
|
||||||
|
|
||||||
m_serial.write((unsigned char*)"\x1B\x02", 2U);
|
m_serial->write((unsigned char*)"\x1B\x02", 2U);
|
||||||
m_serial.write(&colour, 1U);
|
m_serial->write(&colour, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::setRotation(unsigned char rotation)
|
void CTFTSerial::setRotation(unsigned char rotation)
|
||||||
{
|
{
|
||||||
assert(rotation >= 0U && rotation <= 3U);
|
assert(rotation >= 0U && rotation <= 3U);
|
||||||
|
|
||||||
m_serial.write((unsigned char*)"\x1B\x03", 2U);
|
m_serial->write((unsigned char*)"\x1B\x03", 2U);
|
||||||
m_serial.write(&rotation, 1U);
|
m_serial->write(&rotation, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::setFontSize(unsigned char size)
|
void CTFTSerial::setFontSize(unsigned char size)
|
||||||
{
|
{
|
||||||
assert(size >= 1U && size <= 3U);
|
assert(size >= 1U && size <= 3U);
|
||||||
|
|
||||||
m_serial.write((unsigned char*)"\x1B\x04", 2U);
|
m_serial->write((unsigned char*)"\x1B\x04", 2U);
|
||||||
m_serial.write(&size, 1U);
|
m_serial->write(&size, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::gotoBegOfLine()
|
void CTFTSerial::gotoBegOfLine()
|
||||||
{
|
{
|
||||||
m_serial.write((unsigned char*)"\x1B\x05\xFF", 3U);
|
m_serial->write((unsigned char*)"\x1B\x05\xFF", 3U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::gotoPosText(unsigned char x, unsigned char y)
|
void CTFTSerial::gotoPosText(unsigned char x, unsigned char y)
|
||||||
{
|
{
|
||||||
m_serial.write((unsigned char*)"\x1B\x06", 2U);
|
m_serial->write((unsigned char*)"\x1B\x06", 2U);
|
||||||
m_serial.write(&x, 1U);
|
m_serial->write(&x, 1U);
|
||||||
m_serial.write(&y, 1U);
|
m_serial->write(&y, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::gotoPosPixel(unsigned char x, unsigned char y)
|
void CTFTSerial::gotoPosPixel(unsigned char x, unsigned char y)
|
||||||
{
|
{
|
||||||
m_serial.write((unsigned char*)"\x1B\x07", 2U);
|
m_serial->write((unsigned char*)"\x1B\x07", 2U);
|
||||||
m_serial.write(&x, 1U);
|
m_serial->write(&x, 1U);
|
||||||
m_serial.write(&y, 1U);
|
m_serial->write(&y, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::drawLine(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2)
|
void CTFTSerial::drawLine(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2)
|
||||||
{
|
{
|
||||||
m_serial.write((unsigned char*)"\x1B\x08", 2U);
|
m_serial->write((unsigned char*)"\x1B\x08", 2U);
|
||||||
m_serial.write(&x1, 1U);
|
m_serial->write(&x1, 1U);
|
||||||
m_serial.write(&y1, 1U);
|
m_serial->write(&y1, 1U);
|
||||||
m_serial.write(&x2, 1U);
|
m_serial->write(&x2, 1U);
|
||||||
m_serial.write(&y2, 1U);
|
m_serial->write(&y2, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::drawBox(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, bool filled)
|
void CTFTSerial::drawBox(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, bool filled)
|
||||||
{
|
{
|
||||||
if (filled)
|
if (filled)
|
||||||
m_serial.write((unsigned char*)"\x1B\x0A", 2U);
|
m_serial->write((unsigned char*)"\x1B\x0A", 2U);
|
||||||
else
|
else
|
||||||
m_serial.write((unsigned char*)"\x1B\x09", 2U);
|
m_serial->write((unsigned char*)"\x1B\x09", 2U);
|
||||||
|
|
||||||
m_serial.write(&x1, 1U);
|
m_serial->write(&x1, 1U);
|
||||||
m_serial.write(&y1, 1U);
|
m_serial->write(&y1, 1U);
|
||||||
m_serial.write(&x2, 1U);
|
m_serial->write(&x2, 1U);
|
||||||
m_serial.write(&y2, 1U);
|
m_serial->write(&y2, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::drawCircle(unsigned char x, unsigned char y, unsigned char radius, bool filled)
|
void CTFTSerial::drawCircle(unsigned char x, unsigned char y, unsigned char radius, bool filled)
|
||||||
{
|
{
|
||||||
if (filled)
|
if (filled)
|
||||||
m_serial.write((unsigned char*)"\x1B\x0C", 2U);
|
m_serial->write((unsigned char*)"\x1B\x0C", 2U);
|
||||||
else
|
else
|
||||||
m_serial.write((unsigned char*)"\x1B\x0B", 2U);
|
m_serial->write((unsigned char*)"\x1B\x0B", 2U);
|
||||||
|
|
||||||
m_serial.write(&x, 1U);
|
m_serial->write(&x, 1U);
|
||||||
m_serial.write(&y, 1U);
|
m_serial->write(&y, 1U);
|
||||||
m_serial.write(&radius, 1U);
|
m_serial->write(&radius, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::displayBitmap(unsigned char x, unsigned char y, const char* filename)
|
void CTFTSerial::displayBitmap(unsigned char x, unsigned char y, const char* filename)
|
||||||
{
|
{
|
||||||
assert(filename != NULL);
|
assert(filename != NULL);
|
||||||
|
|
||||||
m_serial.write((unsigned char*)"\x1B\x0D", 2U);
|
m_serial->write((unsigned char*)"\x1B\x0D", 2U);
|
||||||
m_serial.write(&x, 1U);
|
m_serial->write(&x, 1U);
|
||||||
m_serial.write(&y, 1U);
|
m_serial->write(&y, 1U);
|
||||||
m_serial.write((unsigned char*)filename, ::strlen(filename));
|
m_serial->write((unsigned char*)filename, ::strlen(filename));
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::setBrightness(unsigned char brightness)
|
void CTFTSerial::setBrightness(unsigned char brightness)
|
||||||
{
|
{
|
||||||
assert(brightness >= 0U && brightness <= 100U);
|
assert(brightness >= 0U && brightness <= 100U);
|
||||||
|
|
||||||
m_serial.write((unsigned char*)"\x1B\x0E", 2U);
|
m_serial->write((unsigned char*)"\x1B\x0E", 2U);
|
||||||
m_serial.write(&brightness, 1U);
|
m_serial->write(&brightness, 1U);
|
||||||
m_serial.write((unsigned char*)"\xFF", 1U);
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::displayText(const char* text)
|
void CTFTSerial::displayText(const char* text)
|
||||||
{
|
{
|
||||||
assert(text != NULL);
|
assert(text != NULL);
|
||||||
|
|
||||||
m_serial.write((unsigned char*)text, ::strlen(text));
|
m_serial->write((unsigned char*)text, ::strlen(text));
|
||||||
}
|
}
|
||||||
|
|
14
TFTSerial.h
14
TFTSerial.h
|
@ -21,14 +21,14 @@
|
||||||
|
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
#include "SerialController.h"
|
#include "SerialPort.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class CTFTSerial : public CDisplay
|
class CTFTSerial : public CDisplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CTFTSerial(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness);
|
CTFTSerial(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness);
|
||||||
virtual ~CTFTSerial();
|
virtual ~CTFTSerial();
|
||||||
|
|
||||||
virtual bool open();
|
virtual bool open();
|
||||||
|
@ -56,11 +56,11 @@ protected:
|
||||||
virtual void clearCWInt();
|
virtual void clearCWInt();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_callsign;
|
std::string m_callsign;
|
||||||
unsigned int m_dmrid;
|
unsigned int m_dmrid;
|
||||||
CSerialController m_serial;
|
ISerialPort* m_serial;
|
||||||
unsigned int m_brightness;
|
unsigned int m_brightness;
|
||||||
unsigned char m_mode;
|
unsigned char m_mode;
|
||||||
|
|
||||||
void clearScreen();
|
void clearScreen();
|
||||||
void setBackground(unsigned char colour);
|
void setBackground(unsigned char colour);
|
||||||
|
|
Loading…
Reference in New Issue