diff --git a/Conf.cpp b/Conf.cpp index 83aa2c57..ca686dbb 100644 --- a/Conf.cpp +++ b/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; diff --git a/Conf.h b/Conf.h index 96f57739..2cd756b2 100644 --- a/Conf.h +++ b/Conf.h @@ -325,6 +325,7 @@ class CConf // 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 @@ class CConf std::string m_tftSerialPort; unsigned int m_tftSerialBrightness; + unsigned int m_tftSerialScreenLayout; unsigned int m_hd44780Rows; unsigned int m_hd44780Columns; diff --git a/Display.cpp b/Display.cpp index 718ed84f..9d20773f 100644 --- a/Display.cpp +++ b/Display.cpp @@ -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(); diff --git a/MMDVM.ini b/MMDVM.ini index 9693e382..7883cf48 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -314,6 +314,7 @@ Debug=0 # Port=modem Port=/dev/ttyAMA0 Brightness=50 +ScreenLayout=0 [HD44780] Rows=2 diff --git a/TFTSurenoo.cpp b/TFTSurenoo.cpp index ca627c32..7d8f5f75 100644 --- a/TFTSurenoo.cpp +++ b/TFTSurenoo.cpp @@ -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)); diff --git a/TFTSurenoo.h b/TFTSurenoo.h index 0a0a7e74..23e3d0f4 100644 --- a/TFTSurenoo.h +++ b/TFTSurenoo.h @@ -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 @@ class CTFTSurenoo : public CDisplay 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);