Upgrade the TFT Serial display driver and displayed information.
This commit is contained in:
parent
3f6189c103
commit
360ca91de0
11 changed files with 182 additions and 58 deletions
10
Conf.cpp
10
Conf.cpp
|
@ -91,7 +91,8 @@ m_fusionNetworkEnabled(false),
|
||||||
m_fusionNetworkAddress(),
|
m_fusionNetworkAddress(),
|
||||||
m_fusionNetworkPort(0U),
|
m_fusionNetworkPort(0U),
|
||||||
m_fusionNetworkDebug(false),
|
m_fusionNetworkDebug(false),
|
||||||
m_tftSerialPort()
|
m_tftSerialPort(),
|
||||||
|
m_tftSerialBrightness(50U)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +260,8 @@ bool CConf::read()
|
||||||
} else if (section == SECTION_TFTSERIAL) {
|
} else if (section == SECTION_TFTSERIAL) {
|
||||||
if (::strcmp(key, "Port") == 0)
|
if (::strcmp(key, "Port") == 0)
|
||||||
m_tftSerialPort = value;
|
m_tftSerialPort = value;
|
||||||
|
else if (::strcmp(key, "Brightness") == 0)
|
||||||
|
m_tftSerialBrightness = (unsigned int)::atoi(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,3 +519,8 @@ std::string CConf::getTFTSerialPort() const
|
||||||
{
|
{
|
||||||
return m_tftSerialPort;
|
return m_tftSerialPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int CConf::getTFTSerialBrightness() const
|
||||||
|
{
|
||||||
|
return m_tftSerialBrightness;
|
||||||
|
}
|
||||||
|
|
2
Conf.h
2
Conf.h
|
@ -100,6 +100,7 @@ public:
|
||||||
|
|
||||||
// The TFTSERIAL section
|
// The TFTSERIAL section
|
||||||
std::string getTFTSerialPort() const;
|
std::string getTFTSerialPort() const;
|
||||||
|
unsigned int getTFTSerialBrightness() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_file;
|
std::string m_file;
|
||||||
|
@ -163,6 +164,7 @@ private:
|
||||||
bool m_fusionNetworkDebug;
|
bool m_fusionNetworkDebug;
|
||||||
|
|
||||||
std::string m_tftSerialPort;
|
std::string m_tftSerialPort;
|
||||||
|
unsigned int m_tftSerialBrightness;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
12
DMRSlot.cpp
12
DMRSlot.cpp
|
@ -144,7 +144,7 @@ void CDMRSlot::writeModem(unsigned char *data)
|
||||||
|
|
||||||
setShortLC(m_slotNo, m_lc->getDstId(), m_lc->getFLCO(), true);
|
setShortLC(m_slotNo, m_lc->getDstId(), m_lc->getFLCO(), true);
|
||||||
|
|
||||||
m_display->writeDMR(m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP, m_lc->getDstId());
|
m_display->writeDMR(m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP, m_lc->getDstId(), "RV");
|
||||||
|
|
||||||
LogMessage("DMR Slot %u, received RF voice header from %u to %s%u", m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP ? "TG " : "", m_lc->getDstId());
|
LogMessage("DMR Slot %u, received RF voice header from %u to %s%u", m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP ? "TG " : "", m_lc->getDstId());
|
||||||
} else if (dataType == DT_VOICE_PI_HEADER) {
|
} else if (dataType == DT_VOICE_PI_HEADER) {
|
||||||
|
@ -236,7 +236,7 @@ void CDMRSlot::writeModem(unsigned char *data)
|
||||||
|
|
||||||
setShortLC(m_slotNo, m_lc->getDstId(), gi ? FLCO_GROUP : FLCO_USER_USER, false);
|
setShortLC(m_slotNo, m_lc->getDstId(), gi ? FLCO_GROUP : FLCO_USER_USER, false);
|
||||||
|
|
||||||
m_display->writeDMR(m_slotNo, srcId, gi, dstId);
|
m_display->writeDMR(m_slotNo, srcId, gi, dstId, "RD");
|
||||||
|
|
||||||
LogMessage("DMR Slot %u, received RF data header from %u to %s%u, %u blocks", m_slotNo, srcId, gi ? "TG ": "", dstId, m_frames);
|
LogMessage("DMR Slot %u, received RF data header from %u to %s%u, %u blocks", m_slotNo, srcId, gi ? "TG ": "", dstId, m_frames);
|
||||||
} else if (dataType == DT_CSBK) {
|
} else if (dataType == DT_CSBK) {
|
||||||
|
@ -416,7 +416,7 @@ void CDMRSlot::writeModem(unsigned char *data)
|
||||||
|
|
||||||
setShortLC(m_slotNo, m_lc->getDstId(), m_lc->getFLCO(), true);
|
setShortLC(m_slotNo, m_lc->getDstId(), m_lc->getFLCO(), true);
|
||||||
|
|
||||||
m_display->writeDMR(m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP, m_lc->getDstId());
|
m_display->writeDMR(m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP, m_lc->getDstId(), "RV");
|
||||||
|
|
||||||
LogMessage("DMR Slot %u, received RF late entry from %u to %s%u", m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP ? "TG " : "", m_lc->getDstId());
|
LogMessage("DMR Slot %u, received RF late entry from %u to %s%u", m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP ? "TG " : "", m_lc->getDstId());
|
||||||
}
|
}
|
||||||
|
@ -540,7 +540,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
|
|
||||||
setShortLC(m_slotNo, m_lc->getDstId(), m_lc->getFLCO(), true);
|
setShortLC(m_slotNo, m_lc->getDstId(), m_lc->getFLCO(), true);
|
||||||
|
|
||||||
m_display->writeDMR(m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP, m_lc->getDstId());
|
m_display->writeDMR(m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP, m_lc->getDstId(), "NV");
|
||||||
|
|
||||||
#if defined(DUMP_DMR)
|
#if defined(DUMP_DMR)
|
||||||
openFile();
|
openFile();
|
||||||
|
@ -639,7 +639,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
|
|
||||||
setShortLC(m_slotNo, dmrData.getDstId(), gi ? FLCO_GROUP : FLCO_USER_USER, false);
|
setShortLC(m_slotNo, dmrData.getDstId(), gi ? FLCO_GROUP : FLCO_USER_USER, false);
|
||||||
|
|
||||||
m_display->writeDMR(m_slotNo, dmrData.getSrcId(), gi, dmrData.getDstId());
|
m_display->writeDMR(m_slotNo, dmrData.getSrcId(), gi, dmrData.getDstId(), "ND");
|
||||||
|
|
||||||
LogMessage("DMR Slot %u, received network data header from %u to %s%u, %u blocks", m_slotNo, dmrData.getSrcId(), gi ? "TG ": "", dmrData.getDstId(), m_frames);
|
LogMessage("DMR Slot %u, received network data header from %u to %s%u, %u blocks", m_slotNo, dmrData.getSrcId(), gi ? "TG ": "", dmrData.getDstId(), m_frames);
|
||||||
} else if (dataType == DT_VOICE_SYNC) {
|
} else if (dataType == DT_VOICE_SYNC) {
|
||||||
|
@ -664,7 +664,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
|
|
||||||
setShortLC(m_slotNo, m_lc->getDstId(), m_lc->getFLCO(), true);
|
setShortLC(m_slotNo, m_lc->getDstId(), m_lc->getFLCO(), true);
|
||||||
|
|
||||||
m_display->writeDMR(m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP, m_lc->getDstId());
|
m_display->writeDMR(m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP, m_lc->getDstId(), "NV");
|
||||||
|
|
||||||
LogMessage("DMR Slot %u, received network late entry from %u to %s%u", m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP ? "TG " : "", m_lc->getDstId());
|
LogMessage("DMR Slot %u, received network late entry from %u to %s%u", m_slotNo, m_lc->getSrcId(), m_lc->getFLCO() == FLCO_GROUP ? "TG " : "", m_lc->getDstId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ bool CDStarControl::writeModem(unsigned char *data)
|
||||||
|
|
||||||
m_state = RS_RELAYING_RF_AUDIO;
|
m_state = RS_RELAYING_RF_AUDIO;
|
||||||
|
|
||||||
m_display->writeDStar(std::string((char*)my1, 8U), std::string((char*)my2, 4U));
|
m_display->writeDStar((char*)my1, (char*)my2, (char*)your);
|
||||||
|
|
||||||
LogMessage("D-Star, received RF header from %8.8s/%4.4s to %8.8s", my1, my2, your);
|
LogMessage("D-Star, received RF header from %8.8s/%4.4s to %8.8s", my1, my2, your);
|
||||||
} else if (m_state == RS_RELAYING_NETWORK_AUDIO) {
|
} else if (m_state == RS_RELAYING_NETWORK_AUDIO) {
|
||||||
|
@ -351,7 +351,7 @@ bool CDStarControl::writeModem(unsigned char *data)
|
||||||
|
|
||||||
m_state = RS_RELAYING_RF_AUDIO;
|
m_state = RS_RELAYING_RF_AUDIO;
|
||||||
|
|
||||||
m_display->writeDStar(std::string((char*)my1, 8U), std::string((char*)my2, 4U));
|
m_display->writeDStar((char*)my1, (char*)my2, (char*)your);
|
||||||
|
|
||||||
LogMessage("D-Star, received RF late entry from %8.8s/%4.4s to %8.8s", my1, my2, your);
|
LogMessage("D-Star, received RF late entry from %8.8s/%4.4s to %8.8s", my1, my2, your);
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,7 @@ void CDStarControl::writeNetwork()
|
||||||
#endif
|
#endif
|
||||||
m_state = RS_RELAYING_NETWORK_AUDIO;
|
m_state = RS_RELAYING_NETWORK_AUDIO;
|
||||||
|
|
||||||
m_display->writeDStar(std::string((char*)my1, 8U), std::string((char*)my2, 4U));
|
m_display->writeDStar((char*)my1, (char*)my2, (char*)your);
|
||||||
|
|
||||||
LogMessage("D-Star, received network header from %8.8s/%4.4s to %8.8s", my1, my2, your);
|
LogMessage("D-Star, received network header from %8.8s/%4.4s to %8.8s", my1, my2, your);
|
||||||
} else if (type == TAG_EOT) {
|
} else if (type == TAG_EOT) {
|
||||||
|
|
|
@ -31,11 +31,11 @@ public:
|
||||||
virtual void setIdle() = 0;
|
virtual void setIdle() = 0;
|
||||||
|
|
||||||
virtual void setDStar() = 0;
|
virtual void setDStar() = 0;
|
||||||
virtual void writeDStar(const std::string& call1, const std::string& call2) = 0;
|
virtual void writeDStar(const char* my1, const char* my2, const char* your) = 0;
|
||||||
virtual void clearDStar() = 0;
|
virtual void clearDStar() = 0;
|
||||||
|
|
||||||
virtual void setDMR() = 0;
|
virtual void setDMR() = 0;
|
||||||
virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId) = 0;
|
virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId, const char* type) = 0;
|
||||||
virtual void clearDMR(unsigned int slotNo) = 0;
|
virtual void clearDMR(unsigned int slotNo) = 0;
|
||||||
|
|
||||||
virtual void setFusion() = 0;
|
virtual void setFusion() = 0;
|
||||||
|
|
|
@ -71,3 +71,4 @@ Debug=1
|
||||||
|
|
||||||
[TFT Serial]
|
[TFT Serial]
|
||||||
Port=/dev/ttyAMA0
|
Port=/dev/ttyAMA0
|
||||||
|
Brightness=50
|
||||||
|
|
|
@ -515,10 +515,12 @@ void CMMDVMHost::createDisplay()
|
||||||
|
|
||||||
if (type == "TFT Serial") {
|
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(" Port: %s", port.c_str());
|
||||||
|
LogInfo(" Brightness: %s", brightness);
|
||||||
|
|
||||||
m_display = new CTFTSerial(port);
|
m_display = new CTFTSerial(port, brightness);
|
||||||
} else {
|
} else {
|
||||||
m_display = new CNullDisplay;
|
m_display = new CNullDisplay;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ void CNullDisplay::setDStar()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNullDisplay::writeDStar(const std::string& call1, const std::string& call2)
|
void CNullDisplay::writeDStar(const char* my1, const char* my2, const char* your)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ void CNullDisplay::setDMR()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNullDisplay::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, unsigned int dstId)
|
void CNullDisplay::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, unsigned int dstId, const char* type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,11 @@ public:
|
||||||
virtual void setIdle();
|
virtual void setIdle();
|
||||||
|
|
||||||
virtual void setDStar();
|
virtual void setDStar();
|
||||||
virtual void writeDStar(const std::string& call1, const std::string& call2);
|
virtual void writeDStar(const char* my1, const char* my2, const char* your);
|
||||||
virtual void clearDStar();
|
virtual void clearDStar();
|
||||||
|
|
||||||
virtual void setDMR();
|
virtual void setDMR();
|
||||||
virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId);
|
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 clearDMR(unsigned int slotNo);
|
||||||
|
|
||||||
virtual void setFusion();
|
virtual void setFusion();
|
||||||
|
|
172
TFTSerial.cpp
172
TFTSerial.cpp
|
@ -19,11 +19,15 @@
|
||||||
#include "TFTSerial.h"
|
#include "TFTSerial.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
CTFTSerial::CTFTSerial(const std::string& port) :
|
CTFTSerial::CTFTSerial(const std::string& port, unsigned int brightness) :
|
||||||
m_serial(port, SERIAL_9600)
|
m_serial(port, SERIAL_9600),
|
||||||
|
m_brightness(brightness)
|
||||||
{
|
{
|
||||||
|
assert(brightness >= 0U && brightness <= 100U);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTFTSerial::~CTFTSerial()
|
CTFTSerial::~CTFTSerial()
|
||||||
|
@ -38,11 +42,17 @@ bool CTFTSerial::open()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setRotation(3U);
|
||||||
|
|
||||||
|
setFontSize(1U);
|
||||||
|
|
||||||
|
setBrightness(m_brightness);
|
||||||
|
|
||||||
// Set background white
|
// Set background white
|
||||||
m_serial.write((unsigned char*)"\x1B\x02\x07\xFF", 4U);
|
setBackground(7U);
|
||||||
|
|
||||||
// Set foreground black
|
// Set foreground black
|
||||||
m_serial.write((unsigned char*)"\x1B\x01\x00\xFF", 4U);
|
setForeground(0U);
|
||||||
|
|
||||||
setIdle();
|
setIdle();
|
||||||
|
|
||||||
|
@ -55,10 +65,10 @@ void CTFTSerial::setIdle()
|
||||||
clearScreen();
|
clearScreen();
|
||||||
|
|
||||||
// Draw MMDVM logo
|
// Draw MMDVM logo
|
||||||
writeImage(0U, 0U, "MMDVM_sm.bmp");
|
displayImage(0U, 0U, "MMDVM_sm.bmp");
|
||||||
|
|
||||||
// Draw all mode insignias
|
// Draw all mode insignias
|
||||||
writeImage(0U, 30U, "ALL_sm.bmp");
|
displayImage(0U, 30U, "ALL_sm.bmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::setDStar()
|
void CTFTSerial::setDStar()
|
||||||
|
@ -67,31 +77,35 @@ void CTFTSerial::setDStar()
|
||||||
clearScreen();
|
clearScreen();
|
||||||
|
|
||||||
// Draw MMDVM logo
|
// Draw MMDVM logo
|
||||||
writeImage(0U, 0U, "MMDVM_sm.bmp");
|
displayImage(0U, 0U, "MMDVM_sm.bmp");
|
||||||
|
|
||||||
// Draw D-Star insignia
|
// Draw D-Star insignia
|
||||||
writeImage(0U, 30U, "DStar_sm.bmp");
|
displayImage(0U, 30U, "DStar_sm.bmp");
|
||||||
|
|
||||||
writeText(0U, 8U, "Listening");
|
displayText(0U, 8U, "Listening");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::writeDStar(const std::string& call1, const std::string& call2)
|
void CTFTSerial::writeDStar(const char* my1, const char* my2, const char* your)
|
||||||
{
|
{
|
||||||
char text[20U];
|
assert(my1 != NULL);
|
||||||
::sprintf(text, "%s/%s", call1.c_str(), call2.c_str());
|
assert(my2 != NULL);
|
||||||
|
assert(your != NULL);
|
||||||
|
|
||||||
writeText(0U, 8U, text);
|
char text[20U];
|
||||||
|
::sprintf(text, "%8.8s/%4.4s -> %8.8s", my1, my2, your);
|
||||||
|
|
||||||
|
displayText(0U, 8U, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::clearDStar()
|
void CTFTSerial::clearDStar()
|
||||||
{
|
{
|
||||||
// Draw MMDVM logo
|
// Draw MMDVM logo
|
||||||
writeImage(0U, 0U, "MMDVM_sm.bmp");
|
displayImage(0U, 0U, "MMDVM_sm.bmp");
|
||||||
|
|
||||||
// Draw D-Star insignia
|
// Draw D-Star insignia
|
||||||
writeImage(0U, 30U, "DStar_sm.bmp");
|
displayImage(0U, 30U, "DStar_sm.bmp");
|
||||||
|
|
||||||
writeText(0U, 8U, "Listening");
|
displayText(0U, 8U, "Listening");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::setDMR()
|
void CTFTSerial::setDMR()
|
||||||
|
@ -100,32 +114,34 @@ void CTFTSerial::setDMR()
|
||||||
clearScreen();
|
clearScreen();
|
||||||
|
|
||||||
// Draw MMDVM logo
|
// Draw MMDVM logo
|
||||||
writeImage(0U, 0U, "MMDVM_sm.bmp");
|
displayImage(0U, 0U, "MMDVM_sm.bmp");
|
||||||
|
|
||||||
// Draw DMR insignia
|
// Draw DMR insignia
|
||||||
writeImage(0U, 30U, "DMR_sm.bmp");
|
displayImage(0U, 30U, "DMR_sm.bmp");
|
||||||
|
|
||||||
writeText(0U, 8U, "1: Listening");
|
displayText(0U, 8U, "1: Listening");
|
||||||
writeText(0U, 9U, "2: Listening");
|
displayText(0U, 9U, "2: Listening");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, unsigned int dstId)
|
void CTFTSerial::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, unsigned int dstId, const char* type)
|
||||||
{
|
{
|
||||||
|
assert(type != NULL);
|
||||||
|
|
||||||
char text[20U];
|
char text[20U];
|
||||||
::sprintf(text, "%u: %u %s%u", slotNo, srcId, group ? "TG " : "", dstId);
|
::sprintf(text, "%u: %s %u -> %s%u", slotNo, type, srcId, group ? "TG" : "", dstId);
|
||||||
|
|
||||||
if (slotNo == 1U)
|
if (slotNo == 1U)
|
||||||
writeText(0U, 8U, text);
|
displayText(0U, 8U, text);
|
||||||
else
|
else
|
||||||
writeText(0U, 9U, text);
|
displayText(0U, 9U, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::clearDMR(unsigned int slotNo)
|
void CTFTSerial::clearDMR(unsigned int slotNo)
|
||||||
{
|
{
|
||||||
if (slotNo == 1U)
|
if (slotNo == 1U)
|
||||||
writeText(0U, 8U, "1: Listening");
|
displayText(0U, 8U, "1: Listening");
|
||||||
else
|
else
|
||||||
writeText(0U, 9U, "2: Listening");
|
displayText(0U, 9U, "2: Listening");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::setFusion()
|
void CTFTSerial::setFusion()
|
||||||
|
@ -134,12 +150,12 @@ void CTFTSerial::setFusion()
|
||||||
clearScreen();
|
clearScreen();
|
||||||
|
|
||||||
// Draw MMDVM logo
|
// Draw MMDVM logo
|
||||||
writeImage(0U, 0U, "MMDVM_sm.bmp");
|
displayImage(0U, 0U, "MMDVM_sm.bmp");
|
||||||
|
|
||||||
// Draw the System Fusion insignia
|
// Draw the System Fusion insignia
|
||||||
writeImage(0U, 30U, "YSF_sm.bmp");
|
displayImage(0U, 30U, "YSF_sm.bmp");
|
||||||
|
|
||||||
writeText(0U, 8U, "Listening");
|
displayText(0U, 8U, "Listening");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::writeFusion(const std::string& callsign)
|
void CTFTSerial::writeFusion(const std::string& callsign)
|
||||||
|
@ -147,18 +163,18 @@ void CTFTSerial::writeFusion(const std::string& callsign)
|
||||||
char text[20U];
|
char text[20U];
|
||||||
::sprintf(text, "%s", callsign.c_str());
|
::sprintf(text, "%s", callsign.c_str());
|
||||||
|
|
||||||
writeText(0U, 8U, text);
|
displayText(0U, 8U, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::clearFusion()
|
void CTFTSerial::clearFusion()
|
||||||
{
|
{
|
||||||
// Draw MMDVM logo
|
// Draw MMDVM logo
|
||||||
writeImage(0U, 0U, "MMDVM_sm.bmp");
|
displayImage(0U, 0U, "MMDVM_sm.bmp");
|
||||||
|
|
||||||
// Draw the System Fusion insignia
|
// Draw the System Fusion insignia
|
||||||
writeImage(0U, 30U, "YSF_sm.bmp");
|
displayImage(0U, 30U, "YSF_sm.bmp");
|
||||||
|
|
||||||
writeText(0U, 8U, "Listening");
|
displayText(0U, 8U, "Listening");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::close()
|
void CTFTSerial::close()
|
||||||
|
@ -171,8 +187,46 @@ void CTFTSerial::clearScreen()
|
||||||
m_serial.write((unsigned char*)"\x1B\x00\xFF", 3U);
|
m_serial.write((unsigned char*)"\x1B\x00\xFF", 3U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::writeText(unsigned char x, unsigned char y, const char* text)
|
void CTFTSerial::setForeground(unsigned char colour)
|
||||||
{
|
{
|
||||||
|
assert(colour >= 0U && colour <= 7U);
|
||||||
|
|
||||||
|
m_serial.write((unsigned char*)"\x1B\x01", 2U);
|
||||||
|
m_serial.write(&colour, 1U);
|
||||||
|
m_serial.write((unsigned char*)"\xFF", 1U);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTFTSerial::setBackground(unsigned char colour)
|
||||||
|
{
|
||||||
|
assert(colour >= 0U && colour <= 7U);
|
||||||
|
|
||||||
|
m_serial.write((unsigned char*)"\x1B\x02", 2U);
|
||||||
|
m_serial.write(&colour, 1U);
|
||||||
|
m_serial.write((unsigned char*)"\xFF", 1U);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTFTSerial::setRotation(unsigned char rotation)
|
||||||
|
{
|
||||||
|
assert(rotation >= 0U && rotation <= 3U);
|
||||||
|
|
||||||
|
m_serial.write((unsigned char*)"\x1B\x03", 2U);
|
||||||
|
m_serial.write(&rotation, 1U);
|
||||||
|
m_serial.write((unsigned char*)"\xFF", 1U);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTFTSerial::setFontSize(unsigned char size)
|
||||||
|
{
|
||||||
|
assert(size >= 0U && size <= 2U);
|
||||||
|
|
||||||
|
m_serial.write((unsigned char*)"\x1B\x04", 2U);
|
||||||
|
m_serial.write(&size, 1U);
|
||||||
|
m_serial.write((unsigned char*)"\xFF", 1U);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTFTSerial::displayText(unsigned char x, unsigned char y, const char* text)
|
||||||
|
{
|
||||||
|
assert(text != NULL);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -180,11 +234,59 @@ void CTFTSerial::writeText(unsigned char x, unsigned char y, const char* text)
|
||||||
m_serial.write((unsigned char*)text, ::strlen(text));
|
m_serial.write((unsigned char*)text, ::strlen(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTFTSerial::writeImage(unsigned char x, unsigned char y, const char* filename)
|
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(&x1, 1U);
|
||||||
|
m_serial.write(&y1, 1U);
|
||||||
|
m_serial.write(&x2, 1U);
|
||||||
|
m_serial.write(&y2, 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)
|
||||||
|
{
|
||||||
|
if (filled)
|
||||||
|
m_serial.write((unsigned char*)"\x1B\x0A", 2U);
|
||||||
|
else
|
||||||
|
m_serial.write((unsigned char*)"\x1B\x09", 2U);
|
||||||
|
|
||||||
|
m_serial.write(&x1, 1U);
|
||||||
|
m_serial.write(&y1, 1U);
|
||||||
|
m_serial.write(&x2, 1U);
|
||||||
|
m_serial.write(&y2, 1U);
|
||||||
|
m_serial.write((unsigned char*)"\xFF", 1U);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTFTSerial::drawCircle(unsigned char x, unsigned char y, unsigned char radius, bool filled)
|
||||||
|
{
|
||||||
|
if (filled)
|
||||||
|
m_serial.write((unsigned char*)"\x1B\x0C", 2U);
|
||||||
|
else
|
||||||
|
m_serial.write((unsigned char*)"\x1B\x0B", 2U);
|
||||||
|
|
||||||
|
m_serial.write(&x, 1U);
|
||||||
|
m_serial.write(&y, 1U);
|
||||||
|
m_serial.write(&radius, 1U);
|
||||||
|
m_serial.write((unsigned char*)"\xFF", 1U);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTFTSerial::displayImage(unsigned char x, unsigned char y, const char* filename)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
assert(brightness >= 0U && brightness <= 100U);
|
||||||
|
|
||||||
|
m_serial.write((unsigned char*)"\x1B\x0E", 2U);
|
||||||
|
m_serial.write(&brightness, 1U);
|
||||||
|
m_serial.write((unsigned char*)"\xFF", 1U);
|
||||||
|
}
|
||||||
|
|
19
TFTSerial.h
19
TFTSerial.h
|
@ -27,7 +27,7 @@
|
||||||
class CTFTSerial : public IDisplay
|
class CTFTSerial : public IDisplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CTFTSerial(const std::string& port);
|
CTFTSerial(const std::string& port, unsigned int brightness);
|
||||||
virtual ~CTFTSerial();
|
virtual ~CTFTSerial();
|
||||||
|
|
||||||
virtual bool open();
|
virtual bool open();
|
||||||
|
@ -35,11 +35,11 @@ public:
|
||||||
virtual void setIdle();
|
virtual void setIdle();
|
||||||
|
|
||||||
virtual void setDStar();
|
virtual void setDStar();
|
||||||
virtual void writeDStar(const std::string& call1, const std::string& call2);
|
virtual void writeDStar(const char* my1, const char* my2, const char* your);
|
||||||
virtual void clearDStar();
|
virtual void clearDStar();
|
||||||
|
|
||||||
virtual void setDMR();
|
virtual void setDMR();
|
||||||
virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId);
|
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 clearDMR(unsigned int slotNo);
|
||||||
|
|
||||||
virtual void setFusion();
|
virtual void setFusion();
|
||||||
|
@ -50,10 +50,19 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSerialController m_serial;
|
CSerialController m_serial;
|
||||||
|
unsigned int m_brightness;
|
||||||
|
|
||||||
void clearScreen();
|
void clearScreen();
|
||||||
void writeText(unsigned char x, unsigned char y, const char* text);
|
void setBackground(unsigned char colour);
|
||||||
void writeImage(unsigned char x, unsigned char y, const char* filename);
|
void setForeground(unsigned char colour);
|
||||||
|
void setRotation(unsigned char rotation);
|
||||||
|
void setFontSize(unsigned char size);
|
||||||
|
void displayText(unsigned char x, unsigned char y, const char* text);
|
||||||
|
void drawLine(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2);
|
||||||
|
void drawBox(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, bool filled);
|
||||||
|
void drawCircle(unsigned char x, unsigned char y, unsigned char radius, bool filled);
|
||||||
|
void displayImage(unsigned char x, unsigned char y, const char* filename);
|
||||||
|
void setBrightness(unsigned char brightness);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue