mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-20 22:45:44 +08:00
TFTSurenoo: add 240x320 panel support
to support 240x320 panel, add ScreenLayout property at [TFT Serial] section in MMDVM.ini ScreenLayout=0 160x128 (default) ScreenLayout=1 128x160 ScreenLayout=2 320x240 ScreenLayout=1 240x320 (landscape layout is recommended)
This commit is contained in:
8
Conf.cpp
8
Conf.cpp
@@ -308,6 +308,7 @@ m_ax25NetworkSpeed(9600U),
|
||||
m_ax25NetworkDebug(false),
|
||||
m_tftSerialPort("/dev/ttyAMA0"),
|
||||
m_tftSerialBrightness(50U),
|
||||
m_tftSerialScreenLayout(0U),
|
||||
m_hd44780Rows(2U),
|
||||
m_hd44780Columns(16U),
|
||||
m_hd44780Pins(),
|
||||
@@ -1073,6 +1074,8 @@ bool CConf::read()
|
||||
m_tftSerialPort = value;
|
||||
else if (::strcmp(key, "Brightness") == 0)
|
||||
m_tftSerialBrightness = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "ScreenLayout") == 0)
|
||||
m_tftSerialScreenLayout = (unsigned int)::atoi(value);
|
||||
} else if (section == SECTION_HD44780) {
|
||||
if (::strcmp(key, "Rows") == 0)
|
||||
m_hd44780Rows = (unsigned int)::atoi(value);
|
||||
@@ -2369,6 +2372,11 @@ unsigned int CConf::getTFTSerialBrightness() const
|
||||
return m_tftSerialBrightness;
|
||||
}
|
||||
|
||||
unsigned int CConf::getTFTSerialScreenLayout() const
|
||||
{
|
||||
return m_tftSerialScreenLayout;
|
||||
}
|
||||
|
||||
unsigned int CConf::getHD44780Rows() const
|
||||
{
|
||||
return m_hd44780Rows;
|
||||
|
||||
2
Conf.h
2
Conf.h
@@ -325,6 +325,7 @@ public:
|
||||
// The TFTSERIAL section
|
||||
std::string getTFTSerialPort() const;
|
||||
unsigned int getTFTSerialBrightness() const;
|
||||
unsigned int getTFTSerialScreenLayout() const;
|
||||
|
||||
// The HD44780 section
|
||||
unsigned int getHD44780Rows() const;
|
||||
@@ -642,6 +643,7 @@ private:
|
||||
|
||||
std::string m_tftSerialPort;
|
||||
unsigned int m_tftSerialBrightness;
|
||||
unsigned int m_tftSerialScreenLayout;
|
||||
|
||||
unsigned int m_hd44780Rows;
|
||||
unsigned int m_hd44780Columns;
|
||||
|
||||
@@ -553,9 +553,11 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CModem* modem)
|
||||
if (type == "TFT Surenoo") {
|
||||
std::string port = conf.getTFTSerialPort();
|
||||
unsigned int brightness = conf.getTFTSerialBrightness();
|
||||
unsigned int screenLayout = conf.getTFTSerialScreenLayout();
|
||||
|
||||
LogInfo(" Port: %s", port.c_str());
|
||||
LogInfo(" Brightness: %u", brightness);
|
||||
LogInfo(" Screen Layout: %u", screenLayout);
|
||||
|
||||
ISerialPort* serial = NULL;
|
||||
if (port == "modem")
|
||||
@@ -563,7 +565,7 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CModem* modem)
|
||||
else
|
||||
serial = new CUARTController(port, 115200U);
|
||||
|
||||
display = new CTFTSurenoo(conf.getCallsign(), dmrid, serial, brightness, conf.getDuplex());
|
||||
display = new CTFTSurenoo(conf.getCallsign(), dmrid, serial, brightness, conf.getDuplex(), screenLayout);
|
||||
} else if (type == "Nextion") {
|
||||
std::string port = conf.getNextionPort();
|
||||
unsigned int brightness = conf.getNextionBrightness();
|
||||
|
||||
@@ -314,6 +314,7 @@ Debug=0
|
||||
# Port=modem
|
||||
Port=/dev/ttyAMA0
|
||||
Brightness=50
|
||||
ScreenLayout=0
|
||||
|
||||
[HD44780]
|
||||
Rows=2
|
||||
|
||||
@@ -29,15 +29,33 @@
|
||||
* other Surenoo UART-LCD will be work, but display area is still 160x128
|
||||
* (tested with JC028-V03 240x320 module)
|
||||
*/
|
||||
|
||||
// x = 0 to 159, y = 0 to 127 - Landscape
|
||||
// x = 0 to 127, y = 0 to 159 - Portrait
|
||||
#define X_WIDTH 160
|
||||
#define Y_WIDTH 128
|
||||
struct layoutdef {
|
||||
int x_width;
|
||||
int y_width;
|
||||
int rotation;
|
||||
int mode_font_size;
|
||||
int status_font_size;
|
||||
int status_margin;
|
||||
};
|
||||
|
||||
#define ROTATION_PORTRAIT 0
|
||||
#define ROTATION_LANDSCAPE 1
|
||||
|
||||
#define FONT_SMALL 16 // 8x16
|
||||
#define FONT_MEDIUM 24 // 12x24
|
||||
#define FONT_LARGE 32 // 16x32
|
||||
|
||||
static const struct layoutdef Layout[] = {
|
||||
{160, 128, ROTATION_LANDSCAPE, FONT_MEDIUM, FONT_SMALL, 32},
|
||||
{128, 160, ROTATION_PORTRAIT, FONT_MEDIUM, FONT_SMALL, 32},
|
||||
{320, 240, ROTATION_LANDSCAPE, FONT_LARGE, FONT_MEDIUM, 48},
|
||||
{240, 320, ROTATION_PORTRAIT, FONT_LARGE, FONT_MEDIUM, 48},
|
||||
};
|
||||
|
||||
#define X_WIDTH Layout[m_screenLayout].x_width
|
||||
#define Y_WIDTH Layout[m_screenLayout].y_width
|
||||
#define ROTATION Layout[m_screenLayout].rotation
|
||||
|
||||
enum LcdColour {
|
||||
COLOUR_BLACK, COLOUR_RED, COLOUR_GREEN, COLOUR_BLUE,
|
||||
COLOUR_YELLOW, COLOUR_CYAN, COLOUR_MAGENTA, COLOUR_GREY,
|
||||
@@ -45,10 +63,6 @@ enum LcdColour {
|
||||
COLOUR_DARK_YELLOW, COLOUR_DARK_CYAN, COLOUR_DARK_MAGENTA, COLOUR_WHITE
|
||||
};
|
||||
|
||||
#define FONT_SMALL 16 // 8x16
|
||||
#define FONT_MEDIUM 24 // 12x24
|
||||
#define FONT_LARGE 32 // 16x32
|
||||
|
||||
#define INFO_COLOUR COLOUR_CYAN
|
||||
#define EXT_COLOUR COLOUR_DARK_GREEN
|
||||
#define BG_COLOUR COLOUR_BLACK
|
||||
@@ -56,10 +70,10 @@ enum LcdColour {
|
||||
#define MODE_COLOUR COLOUR_YELLOW
|
||||
|
||||
// MODE_FONT_SIZE should be equal or larger than STATUS_FONT_SIZE
|
||||
#define MODE_FONT_SIZE FONT_MEDIUM
|
||||
#define STATUS_FONT_SIZE FONT_SMALL
|
||||
#define MODE_FONT_SIZE Layout[m_screenLayout].mode_font_size
|
||||
#define STATUS_FONT_SIZE Layout[m_screenLayout].status_font_size
|
||||
|
||||
#define STATUS_MARGIN 32 // pixel
|
||||
#define STATUS_MARGIN Layout[m_screenLayout].status_margin
|
||||
|
||||
#define MODE_CHARS (X_WIDTH / (MODE_FONT_SIZE / 2))
|
||||
#define STATUS_CHARS (X_WIDTH / (STATUS_FONT_SIZE / 2))
|
||||
@@ -81,7 +95,7 @@ enum LcdColour {
|
||||
#define STR_P25 "P25"
|
||||
#define STR_YSF "SystemFusion"
|
||||
|
||||
CTFTSurenoo::CTFTSurenoo(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool duplex) :
|
||||
CTFTSurenoo::CTFTSurenoo(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool duplex, unsigned int screenLayout) :
|
||||
CDisplay(),
|
||||
m_callsign(callsign),
|
||||
m_dmrid(dmrid),
|
||||
@@ -92,7 +106,8 @@ m_duplex(duplex),
|
||||
//m_duplex(true), // uncomment to force duplex display for testing!
|
||||
m_refresh(false),
|
||||
m_refreshTimer(1000U, 0U, REFRESH_PERIOD),
|
||||
m_lineBuf(NULL)
|
||||
m_lineBuf(NULL),
|
||||
m_screenLayout(screenLayout)
|
||||
{
|
||||
assert(serial != NULL);
|
||||
assert(brightness >= 0U && brightness <= 255U);
|
||||
@@ -453,7 +468,7 @@ void CTFTSurenoo::refreshDisplay(void)
|
||||
m_serial->write((unsigned char*)m_temp, (unsigned int)::strlen(m_temp));
|
||||
|
||||
// config display
|
||||
setRotation(ROTATION_LANDSCAPE);
|
||||
setRotation(ROTATION);
|
||||
setBrightness(m_brightness);
|
||||
setBackground(BG_COLOUR);
|
||||
m_serial->write((unsigned char*)m_temp, (unsigned int)::strlen(m_temp));
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
class CTFTSurenoo : public CDisplay
|
||||
{
|
||||
public:
|
||||
CTFTSurenoo(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool duplex);
|
||||
CTFTSurenoo(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool duplex, unsigned int screenLayout);
|
||||
virtual ~CTFTSurenoo();
|
||||
|
||||
virtual bool open();
|
||||
@@ -83,6 +83,7 @@ private:
|
||||
CTimer m_refreshTimer;
|
||||
char* m_lineBuf;
|
||||
char m_temp[128];
|
||||
unsigned int m_screenLayout;
|
||||
|
||||
void setLineBuffer(char *buf, const char *text, int maxchar);
|
||||
void setModeLine(const char *text);
|
||||
|
||||
Reference in New Issue
Block a user