diff --git a/include/TEF6686.h b/include/TEF6686.h index a39c0e8..05a6e28 100644 --- a/include/TEF6686.h +++ b/include/TEF6686.h @@ -104,10 +104,10 @@ static const char* const ECCtext[] { "Kingdom of Morroco", // 2 "Republica Moldova", // 3 "People's Democratic Republic of Algeria", // 4 - "Κυπριακή Δημοκρατία / (Republic of Cyprus)", // 5 + "Κυπριακή Δημοκρατία [Republic of Cyprus]", // 5 "Česká republika", // 6 "Ireland", // 7 - "Eesti Vabariik / (Republic of Estonia)", // 8 + "Eesti Vabariik [Republic of Estonia]", // 8 "Principat d'Andorra", // 9 "Repubblica di San Marino", // 10 "Rzeczpospolita Polska", // 11 @@ -118,17 +118,17 @@ static const char* const ECCtext[] { "The former Yugoslav Republic of Macedonia", // 16 "Repubblica Italiana", // 17 "Hashemite Kingdom of Jordan", // 18 - "Slovenská republika", // 19 - "Koninkrijk België / Royaume de Belgique", // 20 - "Suomen tasavalta / (Republic of Finland)", // 21 + "Slovenská republika [Republic of Slovakia]", // 19 + "Koninkrijk België / Royaume de Belgique [Kingdom of Belgium]", // 20 + "Suomen tasavalta [Republic of Finland]", // 21 "Syrian Arab Republic", // 22 - "Republic of Serbia", // 23 - "Україна / (Ukraine)", // 24 - "Российская Федерация / (Russian Federation)", // 25 - "Groussherzogtum Lëtzebuerg / (Grand Duchy of Luxembourg)", // 26 + "Републике Србије [Republic of Serbia]", // 23 + "Україна [Ukraine]", // 24 + "Российская Федерация [Russian Federation]", // 25 + "Groussherzogtum Lëtzebuerg [Grand Duchy of Luxembourg]", // 26 "Republic of Tunisia", // 27 "State of Palestine", // 28 - "Република България / (Republic of Bulgaria)", // 29 + "Република България [Republic of Bulgaria]", // 29 "Republic of Portugal (Madeira)", // 30 "Koninkrijk der Nederlanden", // 31 "Republic of Portugal", // 32 @@ -146,13 +146,13 @@ static const char* const ECCtext[] { "Principality of Monaco", // 44 "Republic of Malta", // 45 "United Kingdom of Great Britain and Northern Ireland", // 46 - "Lietuvos Respublika / (Republic of Lithuania)", // 47 - "Republika Hrvatska / (Republic of Croatia)", // 48 + "Lietuvos Respublika [Republic of Lithuania]", // 47 + "Republika Hrvatska [Republic of Croatia]", // 48 "Libya", // 49 "Kingdom of Spain (Canary Islands)", // 50 "România", // 51 - "Reino de España / (Kingdom of Spain)", // 52 - "Konungariket Sverige / (Kingdom of Sweden)", // 53 + "Reino de España [Kingdom of Spain]", // 52 + "Konungariket Sverige [Kingdom of Sweden]", // 53 "Arab Republic of Egypt", // 54 "République de France", // 55 "Kongeriket Norge", // 56 @@ -239,7 +239,7 @@ static const char* const ECCtext[] { "República Federativa do Brasil", // 137 "Canada", // 138 "United Kingdom of Great Britain and Northern Ireland (Cayman Islands)", // 139 - "Republic of Chile", // 140 + "República de Chile", // 140 "Republic of Colombia", // 141 "Republic of Costa Rica", // 142 "Republic of Cuba", // 143 @@ -250,20 +250,20 @@ static const char* const ECCtext[] { "United Kingdom of Great Britain and Northern Ireland (Falkland Islands)", // 148 "Kingdom of Denmark (Greenland, NOT USA)", // 149 "Grenada", // 150 - "Republic of France (Guadeloupe)", // 151 + "République française (Guadeloupe)", // 151 "Republic of Guatemala", // 152 "Republic of Guyana", // 153 "Republic of Haiti", // 154 "Republic of Honduras", // 155 "Jamaica", // 156 - "Republic of France (Martinique)", // 157 + "République française (Martinique)", // 157 "Estados Unidos Mexicanos", // 158 "United Kingdom of Great Britain and Northern Ireland (Montserrat)", // 159 - "Netherlands Antilles (does not exist)", // 160 + "Netherlands Antilles", // 160 "Republic of Nicaragua", // 161 "Republic of Panama", // 162 - "Republic of Paraguay", // 163 - "Republic of Peru", // 164 + "República del Paraguay", // 163 + "República del Perú", // 164 "United States of America (Puerto Rico)", // 165 "Saint Kitts and Nevis", // 166 "Saint Lucia", // 167 @@ -289,9 +289,9 @@ static const char* const ECCtext[] { "Kingdom of Bhutan", // 187 "Negara Brunei Darussalam", // 188 "Kingdom of Cambodia", // 189 - "People's Republic of China", // 190 + "中华人民共和国 [PRC]", // 190 "Republic of Fiji", // 191 - "People's Republic of China (Hong Kong)", // 192 + "中华人民共和国(香港 [PRC, HK]", // 192 "Republic of India", // 193 "Republic of Indonesia", // 194 "Islamic Republic of Iran", // 195 @@ -300,7 +300,7 @@ static const char* const ECCtext[] { "Democratic People's Republic of Korea (North Korea)", // 198 "Republic of Korea (South Korea)", // 199 "Lao People's Democratic Republic", // 200 - "People's Republic of China (Macao)", // 201 + "中华人民共和国(澳门) [PRC, M]", // 201 "Malaysia", // 202 "Republic of Maldives", // 203 "United States of America (Marshall Islands)", // 204 @@ -324,7 +324,7 @@ static const char* const ECCtext[] { "Commonwealth of the Bahamas", // 222 "United Kingdom of Great Britain and Northern Ireland (Bermuda) / Federative Republic of Brazil", // 223 "Federative Republic of Brazil / Republic of Ecuador", // 224 - "Netherlands Antilles (does not exist) / Federative Republic of Brazil", // 225 + "Netherlands Antilles / Federative Republic of Brazil", // 225 "United States of America", // 226 "People's Republic of Bangladesh", // 227 "Rzeczpospolita Zachodniej Polski" // 228 - doesn't exist, YET, we don't want a fucking pimp for president here diff --git a/include/comms.h b/include/comms.h index 49bd385..aef0584 100644 --- a/include/comms.h +++ b/include/comms.h @@ -3,36 +3,18 @@ #include "globals.h" #include "nonvolatile.h" #include +#include "main.h" void Communication(); void XDRGTKRoutine(); void passwordcrypt(); void tryWiFi(); -extern void DataPrint(String string); -extern void ShowFreq(int mode); -extern void SelectBand(); -extern void doBW(); extern void BuildDisplay(); extern void BuildAdvancedRDS(); -extern void ModeButtonPress(); -extern void Seek(bool mode); -extern void doStereoToggle(); -extern void MuteScreen(bool setting); -extern void updateiMS(); -extern void updateEQ(); -extern void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize); -extern void showAutoSquelch(bool mode); -extern void ShowStepSize(); -extern void startFMDXScan(); -extern void cancelDXScan(); extern void printLogbookCSV(); extern void NTPupdate(); extern void handleRoot(); extern void handleDownloadCSV(); extern void handleLogo(); extern void Infoboxprint(const char* input); -extern void TuneUp(); -extern void TuneDown(); -extern void ShowTuneMode(); -extern const char* textUI(uint16_t number); diff --git a/include/gui.h b/include/gui.h index 9fedf8a..99e9d6f 100644 --- a/include/gui.h +++ b/include/gui.h @@ -3,6 +3,7 @@ #include "globals.h" #include "utils.h" #include "menugraphics.h" +#include "main.h" static const char* const unitString[] = {"dBμV", "dBf", "dBm"}; static const char* const FreqFont[] = {"Classic", "Roubenstil", "Motoya", "Aura2", "Comic", "Modern"}; @@ -25,27 +26,10 @@ String shortLine(String text); void showMenuOpenTouchButtons(); void showBWSelector(); -extern void ShowFreq(int mode); extern void ShowBandSelectionFM(bool notglanceview, bool normaldisplay); extern void ShowBandSelectionAM(bool notglanceview, bool normaldisplay); extern void ScreensaverTimerSet(byte value); -extern void ShowMemoryPos(); -extern void ShowTuneMode(); -extern void updateBW(); -extern void ShowStepSize(); -extern void updateiMS(); -extern void updateEQ(); extern void doTheme(); extern void tryWiFi(); -extern void TuneUp(); -extern void endMenu(); -extern void startFMDXScan(); -extern void DoMemoryPosTune(); -extern void UpdateFonts(); -extern void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize); -extern void setAutoSpeedSPI(); -extern void showAutoSquelch(bool mode); -extern uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, uint8_t stopmem, bool rdsonly, uint8_t doublepi); extern void ClearMemoryRange(uint8_t start, uint8_t stop); -extern bool handleCreateNewLogbook(); -extern const char* textUI(uint16_t number); \ No newline at end of file +extern bool handleCreateNewLogbook(); \ No newline at end of file diff --git a/include/logbook.h b/include/logbook.h index b2d2170..5f60a79 100644 --- a/include/logbook.h +++ b/include/logbook.h @@ -6,6 +6,7 @@ using fs::FS; #include #include "globals.h" #include "rtc.hpp" +#include "main.h" void handleRoot(); void handleDownloadCSV(); @@ -16,6 +17,4 @@ bool isDST(time_t t); void handleLogo(); void printLogbookCSV(); void sendUDPlog(); -IPAddress makeBroadcastAddress(IPAddress ip); - -extern const char* textUI(uint16_t number); +IPAddress makeBroadcastAddress(IPAddress ip); \ No newline at end of file diff --git a/include/main.h b/include/main.h new file mode 100644 index 0000000..fd1bb56 --- /dev/null +++ b/include/main.h @@ -0,0 +1,33 @@ +#pragma once +#include +#include + +void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize); +void tftPrint16(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, bool force_font = true, bool font = false); +void tftReplace(int8_t offset, const String & textold, const String & text, int16_t x, int16_t y, int color, int smoothcolor, int background, uint8_t fontsize); +const char* textUI(uint16_t number); +uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, uint8_t stopmem, bool rdsonly, uint8_t doublepi); +void showAutoSquelch(bool mode); +void UpdateFonts(); +void setAutoSpeedSPI(); +void DoMemoryPosTune(); +void startFMDXScan(); +void endMenu(); +void TuneUp(); +void ShowStepSize(); +void ShowFreq(int mode); +void ShowMemoryPos(); +void TuneDown(); +void ShowTuneMode(); +void SelectBand(); +void doBW(); +void ModeButtonPress(); +void updateEQ(); +void updateiMS(); +void Seek(bool mode); +void MuteScreen(bool setting); +void cancelDXScan(); +void doStereoToggle(); +void updateBW(); +void ShowRDSLogo(bool RDSstatus); +void DataPrint(String string); diff --git a/include/rds.h b/include/rds.h index 98a3f79..85754fc 100644 --- a/include/rds.h +++ b/include/rds.h @@ -9,6 +9,7 @@ #include "globals.h" #include "NTPupdate.h" #include "rtc.hpp" +#include "main.h" void ShowAdvancedRDS(); void readRds(); @@ -22,9 +23,4 @@ void showCT(); void ShowErrors(); void ShowRDSStatistics(); -extern void ShowRDSLogo(bool RDSstatus); -extern void DataPrint(String string); -extern void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize); -extern void tftReplace(int8_t offset, const String & textold, const String & text, int16_t x, int16_t y, int color, int smoothcolor, int background, uint8_t fontsize); extern bool isDST(time_t t); -extern const char* textUI(uint16_t number); diff --git a/include/scrolling_text.h b/include/scrolling_text.h index 156b7a2..ee96810 100644 --- a/include/scrolling_text.h +++ b/include/scrolling_text.h @@ -13,7 +13,7 @@ private: unsigned long lastTick; unsigned long holdTick; bool isScrolling; - std::function postDrawCallback; + std::function postDrawCallback; int usedH; bool hold; int xOffset; @@ -26,17 +26,17 @@ public: ScrollingTextDisplay(TFT_eSprite* spr, int y, int maxW, int x = 35, int inuseH = -1 ) : sprite(spr), yPos(y), maxWidth(maxW), xPos(0), textWidth(0), lastTick(0), holdTick(0), isScrolling(false), postDrawCallback(nullptr), usedH(inuseH), hold(false), xOffset(x) {} - void setPostDrawCallback(std::function callback) { + void setPostDrawCallback(std::function callback) { postDrawCallback = callback; } - void update(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth, uint16_t backgroundColor) { + void update(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth, uint16_t backgroundColor, uint8_t font = 255) { textWidth = sprite->textWidth(text); if(textWidth < maxWidth) { xPos = 0; isScrolling = false; - drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth, backgroundColor); + drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth, backgroundColor, font); } else { if(!isScrolling) holdTick = millis(); isScrolling = true; @@ -54,7 +54,7 @@ public: holdTick = millis(); } - drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth, backgroundColor); + drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth, backgroundColor, font); lastTick = millis(); } } @@ -75,7 +75,9 @@ public: } private: - void drawText(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth, uint16_t backgroundColor) { + void drawText(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth, uint16_t backgroundColor, uint8_t font) { + if(font > FONT_COUNT) font = sprite->textfont; + if(usedH > 0) { sprite->fillSprite(TFT_TRANSPARENT); sprite->fillRect(0, 0, maxWidth, usedH, backgroundColor); @@ -85,8 +87,8 @@ private: if(status) sprite->setTextColor(activeColor, activeSmooth, false); else sprite->setTextColor(dropoutColor, dropoutSmooth, false); - sprite->drawString(text, xPos, 0); - if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0); + sprite->drawString(text, xPos, 0, font); + if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0, font); sprite->resetViewport(); } else { @@ -95,11 +97,11 @@ private: if(status) sprite->setTextColor(activeColor, activeSmooth, false); else sprite->setTextColor(dropoutColor, dropoutSmooth, false); - sprite->drawString(text, xPos, 0); - if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0); + sprite->drawString(text, xPos, 0, font); + if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0, font); } - if(postDrawCallback) postDrawCallback(sprite, false); + if(postDrawCallback) postDrawCallback(sprite); if(yPos != 0) sprite->pushSprite(xOffset, yPos, TFT_TRANSPARENT); } }; \ No newline at end of file diff --git a/lib/TFT_eSPI/TFT_eSPI.cpp b/lib/TFT_eSPI/TFT_eSPI.cpp index be5ea0b..23e8fcd 100644 --- a/lib/TFT_eSPI/TFT_eSPI.cpp +++ b/lib/TFT_eSPI/TFT_eSPI.cpp @@ -2521,11 +2521,10 @@ int16_t TFT_eSPI::drawFloat(float floatNumber, uint8_t dp, int32_t poX, int32_t } void TFT_eSPI::setTextFont(uint8_t f) { - textfont = (f > 7) ? 1 : f; // Don't allow font > 7 + textfont = (f > FONT_COUNT) ? 1 : f; // Don't allow font > 7 } -void TFT_eSPI::loadFont(const uint8_t array[], uint8_t font) -{ +void TFT_eSPI::loadFont(const uint8_t array[], uint8_t font) { if (array == nullptr) return; fontPtr = (uint8_t*)array; unloadFont(font); @@ -2593,45 +2592,50 @@ void TFT_eSPI::loadMetrics(uint8_t font) gFonts[font].spaceWidth = (gFonts[font].ascent + gFonts[font].descent) * 2/7; // Guess at space width } -void TFT_eSPI::unloadFont(uint8_t font) -{ +void TFT_eSPI::unloadFont(uint8_t font) { + if (!fontOwned[font]) { + gUnicode[font] = NULL; + gHeight[font] = NULL; + gWidth[font] = NULL; + gxAdvance[font] = NULL; + gdY[font] = NULL; + gdX[font] = NULL; + gBitmap[font] = NULL; + gFonts[font].gArray = nullptr; + return; + } + if (gUnicode[font]) { free(gUnicode[font]); gUnicode[font] = NULL; } - if (gHeight[font]) - { + if (gHeight[font]) { free(gHeight[font]); gHeight[font] = NULL; } - if (gWidth[font]) - { + if (gWidth[font]) { free(gWidth[font]); gWidth[font] = NULL; } - if (gxAdvance[font]) - { + if (gxAdvance[font]) { free(gxAdvance[font]); gxAdvance[font] = NULL; } - if (gdY[font]) - { + if (gdY[font]) { free(gdY[font]); gdY[font] = NULL; } - if (gdX[font]) - { + if (gdX[font]) { free(gdX[font]); gdX[font] = NULL; } - if (gBitmap[font]) - { + if (gBitmap[font]) { free(gBitmap[font]); gBitmap[font] = NULL; } @@ -3079,7 +3083,7 @@ TFT_eSprite::TFT_eSprite(TFT_eSPI *tft) { _iwidth = 0; // Initialise width and height to 0 (it does not exist yet) _iheight = 0; _bpp = 16; - _swapBytes = true; // Do not swap pushImage colour bytes by default + _swapBytes = true; _created = false; _vpOoB = true; @@ -3306,8 +3310,7 @@ void TFT_eSprite::deleteSprite() { } } -void TFT_eSprite::pushSprite(int32_t x, int32_t y) -{ +void TFT_eSprite::pushSprite(int32_t x, int32_t y) { if (!_created) return; if (_bpp == 16) { @@ -4335,4 +4338,20 @@ void TFT_eSprite::drawGlyph(uint16_t code, uint16_t font) { } bg_cursor_x = cursor_x; last_cursor_x = cursor_x; -} \ No newline at end of file +} + + void TFT_eSprite::copyFontFromTFT(uint8_t source, uint8_t destination) { + unloadFont(destination); // Make sure there is nothing there + + gUnicode[destination] = _tft->gUnicode[source]; + gHeight[destination] = _tft->gHeight[source]; + gWidth[destination] = _tft->gWidth[source]; + gxAdvance[destination] = _tft->gxAdvance[source]; + gdY[destination] = _tft->gdY[source]; + gdX[destination] = _tft->gdX[source]; + gBitmap[destination] = _tft->gBitmap[source]; + + memcpy(&gFonts[destination], &_tft->gFonts[source], sizeof(fontMetrics)); + + fontOwned[destination] = false; + } \ No newline at end of file diff --git a/lib/TFT_eSPI/TFT_eSPI.h b/lib/TFT_eSPI/TFT_eSPI.h index 5abc384..101c227 100644 --- a/lib/TFT_eSPI/TFT_eSPI.h +++ b/lib/TFT_eSPI/TFT_eSPI.h @@ -1,5 +1,7 @@ #pragma once +#define FONT_COUNT 7 + #include #define SPI_FREQUENCY 7500000 @@ -398,7 +400,7 @@ class TFT_eSPI { friend class TFT_eSprite; uint16_t maxDescent; // Maximum descent found in font } fontMetrics; - fontMetrics gFonts[7] = { + fontMetrics gFonts[FONT_COUNT] = { { nullptr, 0, 0, 0, 0, 0, 0, 0 }, { nullptr, 0, 0, 0, 0, 0, 0, 0 }, { nullptr, 0, 0, 0, 0, 0, 0, 0 }, @@ -409,13 +411,15 @@ class TFT_eSPI { friend class TFT_eSprite; }; // These are for the metrics for each individual glyph (so we don't need to seek this in file and waste time) - uint16_t* gUnicode[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //UTF-16 code, the codes are searched so do not need to be sequential - uint8_t* gHeight[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //cheight - uint8_t* gWidth[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //cwidth - uint8_t* gxAdvance[7] = {NULL, NULL, NULL, NULL, NULL, NULL}; //setWidth - int16_t* gdY[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //topExtent - int8_t* gdX[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //leftExtent - uint32_t* gBitmap[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //file pointer to greyscale bitmap + uint16_t* gUnicode[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //UTF-16 code, the codes are searched so do not need to be sequential + uint8_t* gHeight[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //cheight + uint8_t* gWidth[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //cwidth + uint8_t* gxAdvance[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL}; //setWidth + int16_t* gdY[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //topExtent + int8_t* gdX[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //leftExtent + uint32_t* gBitmap[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //file pointer to greyscale bitmap + + bool fontOwned[FONT_COUNT] = {false}; uint8_t getTouchRaw(uint16_t *x, uint16_t *y); uint16_t getTouchRawZ(); @@ -539,6 +543,7 @@ class TFT_eSprite : public TFT_eSPI { int16_t width(), height(); void drawGlyph(uint16_t code, uint16_t font); + void copyFontFromTFT(uint8_t source, uint8_t destination); private: diff --git a/src/gui.cpp b/src/gui.cpp index aeea073..5cffbbe 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -480,11 +480,10 @@ void BuildRDSStatScreen() { // Only build screen if not already active if (!rdsstatscreen) { // Set page flags - afscreen = false; - advancedRDS = false; + afscreen = false; + advancedRDS = false; rdsstatscreen = true; - // --- Draw frame and static lines --- tft.fillScreen(BackgroundColor); tft.drawRect(0, 0, 320, 240, FrameColor); tft.drawLine(0, 30, 320, 30, FrameColor); @@ -499,22 +498,18 @@ void BuildRDSStatScreen() { tft.drawLine(160, 50, 160, 218, FrameColor); tft.drawLine(240, 50, 240, 218, FrameColor); - // --- Column headers --- - tftPrint(ALEFT, "kHz", 205, 4, ActiveColor, ActiveColorSmooth, 28); + tftPrint(ALEFT, "kHz", 205, 4, ActiveColor, ActiveColorSmooth, 28); // 28, not 16 can't force latin font - // --- Labels above packet columns --- - tftPrint(ALEFT, "ERRORS", 3, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "A:", 66, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "B:", 104, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "C:", 142, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "D:", 180, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "BER", 250, 34, ActiveColor, ActiveColorSmooth, 16); + tftPrint16(ALEFT, "ERRORS", 3, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "A:", 66, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "B:", 104, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "C:", 142, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "D:", 180, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "BER", 250, 34, ActiveColor, ActiveColorSmooth); - // --- Group labels setup --- const uint16_t xcol[4] = {10, 90, 170, 250}; // column X positions const uint16_t rowY[8] = {56, 76, 96, 116, 136, 156, 176, 196}; // row Y positions - // Labels for each group (A/B) const char* const groups[16][2] = { {"0A", "0B"}, {"1A", "1B"}, {"2A", "2B"}, {"3A", "3B"}, {"4A", "4B"}, {"5A", "5B"}, {"6A", "6B"}, {"7A", "7B"}, @@ -526,8 +521,8 @@ void BuildRDSStatScreen() { for (uint8_t col = 0; col < 4; col++) { // 4 columns for (uint8_t row = 0; row < 4; row++) { // 4 groups per column uint8_t g = col * 4 + row; // group index 0..15 - tftPrint(ALEFT, groups[g][0], xcol[col], rowY[row * 2], ActiveColor, ActiveColorSmooth, 16); // A - tftPrint(ALEFT, groups[g][1], xcol[col], rowY[row * 2 + 1], ActiveColor, ActiveColorSmooth, 16); // B + tftPrint16(ALEFT, groups[g][0], xcol[col], rowY[row * 2], ActiveColor, ActiveColorSmooth); // A + tftPrint16(ALEFT, groups[g][1], xcol[col], rowY[row * 2 + 1], ActiveColor, ActiveColorSmooth); // B } } @@ -535,8 +530,8 @@ void BuildRDSStatScreen() { const uint16_t pctX[4] = {70, 150, 230, 310}; for (uint8_t c = 0; c < 4; c++) { for (uint8_t y = 56; y < 216; y += 20) { - tftPrint(ARIGHT, "0.0", pctX[c] - 10, y, GreyoutColor, BackgroundColor, 16); // placeholder value - tftPrint(ACENTER, "%", pctX[c], y, GreyoutColor, BackgroundColor, 16); + tftPrint16(ARIGHT, "0.0", pctX[c] - 10, y, GreyoutColor, BackgroundColor); // placeholder value + tftPrint16(ACENTER, "%", pctX[c], y, GreyoutColor, BackgroundColor); } } @@ -2901,30 +2896,29 @@ void BuildAdvancedRDS() { tft.drawLine(210, 30, 210, 193, FrameColor); tft.drawLine(248, 30, 248, 0, FrameColor); - tftPrint(ALEFT, "ERRORS", 3, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ARIGHT, "MHz", 310, 35, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ARIGHT, unitString[unit], 310, 51, ActiveColor, ActiveColorSmooth, 16); - if (radio.rds.region == 0) { - tftPrint(ALEFT, "PI", 216, 81, ActiveColor, ActiveColorSmooth, 16); - } else { - tftPrint(ALEFT, "PI", 216, 72, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "ID", 216, 89, ActiveColor, ActiveColorSmooth, 16); + tftPrint16(ALEFT, "ERRORS", 3, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ARIGHT, "MHz", 310, 35, ActiveColor, ActiveColorSmooth); + tftPrint16(ARIGHT, unitString[unit], 310, 51, ActiveColor, ActiveColorSmooth); + if (radio.rds.region == 0) tftPrint16(ALEFT, "PI", 216, 81, ActiveColor, ActiveColorSmooth); + else { + tftPrint16(ALEFT, "PI", 216, 72, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "ID", 216, 89, ActiveColor, ActiveColorSmooth); } - tftPrint(ALEFT, "PS", 3, 81, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "PTY", 3, 109, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "RT+", 3, 147, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "EON", 3, 174, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "ECC", 3, 199, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "RT", 3, 222, ActiveColor, ActiveColorSmooth, 16); + tftPrint16(ALEFT, "PS", 3, 81, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "PTY", 3, 109, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "RT+", 3, 147, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "EON", 3, 174, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "ECC", 3, 199, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "RT", 3, 222, ActiveColor, ActiveColorSmooth); - tftPrint(ALEFT, "A:", 66, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "B:", 104, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "C:", 142, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "D:", 180, 34, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ARIGHT, "Dynamic PTY", 300, 130, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ARIGHT, "Artificial head", 300, 145, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ARIGHT, "Compressed", 300, 160, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ARIGHT, "Has stereo", 300, 175, ActiveColor, ActiveColorSmooth, 16); + tftPrint16(ALEFT, "A:", 66, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "B:", 104, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "C:", 142, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "D:", 180, 34, ActiveColor, ActiveColorSmooth); + tftPrint16(ARIGHT, "Dynamic PTY", 300, 130, ActiveColor, ActiveColorSmooth); + tftPrint16(ARIGHT, "Artificial head", 300, 145, ActiveColor, ActiveColorSmooth); + tftPrint16(ARIGHT, "Compressed", 300, 160, ActiveColor, ActiveColorSmooth); + tftPrint16(ARIGHT, "Has stereo", 300, 175, ActiveColor, ActiveColorSmooth); tft.fillCircle(86, 41, 5, SignificantColor); tft.fillCircle(124, 41, 5, SignificantColor); @@ -2946,13 +2940,13 @@ void BuildAdvancedRDS() { if (!StereoToggle) tft.drawBitmap(38, 5, Mono, 22, 22, SecondaryColor); else tft.drawBitmap(32, 5, Stereo, 32, 22, GreyoutColor); - tftPrint(ALEFT, "TP", 2, 51, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "TA", 24, 51, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "AF", 50, 51, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "-B", 68, 51, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "TMC", 88, 51, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "RT+", 123, 51, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "EON", 153, 51, GreyoutColor, BackgroundColor, 16); + tftPrint16(ALEFT, "TP", 2, 51, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "TA", 24, 51, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "AF", 50, 51, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "-B", 68, 51, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "TMC", 88, 51, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "RT+", 123, 51, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "EON", 153, 51, GreyoutColor, BackgroundColor); RDSstatusold = !RDSstatusold; ShowFreq(0); diff --git a/src/main.cpp b/src/main.cpp index 693b03b..6edf548 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ using fs::FS; #include "nonvolatile.h" #include "utils.h" #include "system_console.h" +#include "main.h" #pragma endregion Console console(&tft); @@ -261,8 +262,8 @@ void updateSWMIBand() { inline void updateCodetect() { if (band > BAND_GAP) { - if (WAM) tftPrint(ALEFT, "CO", 50, 61, PrimaryColor, PrimaryColorSmooth, 16); - else tftPrint(ALEFT, "CO", 50, 61, BackgroundColor, BackgroundColor, 16); + if (WAM) tftPrint16(ALEFT, "CO", 50, 61, PrimaryColor, PrimaryColorSmooth); + else tftPrint16(ALEFT, "CO", 50, 61, BackgroundColor, BackgroundColor); } } @@ -718,13 +719,13 @@ void updateBW() { if (BWset == 0) { if (!BWtune && !screenmute && !advancedRDS && !afscreen && !rdsstatscreen) { tft.fillRoundRect(248, 36, 69, 18, 2, SecondaryColor); - tftPrint(ACENTER, "AUTO BW", 282, 38, BackgroundColor, SecondaryColor, 16); + tftPrint16(ACENTER, "AUTO BW", 282, 38, BackgroundColor, SecondaryColor); } radio.setFMABandw(); } else { if (!BWtune && !screenmute && !advancedRDS && !afscreen && !rdsstatscreen) { tft.fillRoundRect(248, 36, 69, 18, 2, GreyoutColor); - tftPrint(ACENTER, "AUTO BW", 282, 38, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "AUTO BW", 282, 38, BackgroundColor, GreyoutColor); } } } @@ -734,13 +735,13 @@ void updateiMS() { if (iMSset == 0) { if (!screenmute && !advancedRDS && !afscreen && !rdsstatscreen && !BWtune) { tft.fillRoundRect(249, 57, 30, 18, 2, SecondaryColor); - tftPrint(ACENTER, "iMS", 265, 59, BackgroundColor, SecondaryColor, 16); + tftPrint16(ACENTER, "iMS", 265, 59, BackgroundColor, SecondaryColor); } radio.setiMS(1); } else { if (!screenmute && !advancedRDS && !afscreen && !rdsstatscreen && !BWtune) { tft.fillRoundRect(249, 57, 30, 18, 2, GreyoutColor); - tftPrint(ACENTER, "iMS", 265, 59, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "iMS", 265, 59, BackgroundColor, GreyoutColor); } radio.setiMS(0); } @@ -752,13 +753,13 @@ void updateEQ() { if (EQset == 0) { if (!screenmute && !advancedRDS && !afscreen && !rdsstatscreen && !BWtune) { tft.fillRoundRect(287, 57, 30, 18, 2, SecondaryColor); - tftPrint(ACENTER, "EQ", 301, 59, BackgroundColor, SecondaryColor, 16); + tftPrint16(ACENTER, "EQ", 301, 59, BackgroundColor, SecondaryColor); } radio.setEQ(1); } else { if (!screenmute && !advancedRDS && !afscreen && !rdsstatscreen && !BWtune) { tft.fillRoundRect(287, 57, 30, 18, 2, GreyoutColor); - tftPrint(ACENTER, "EQ", 301, 59, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "EQ", 301, 59, BackgroundColor, GreyoutColor); } radio.setEQ(0); } @@ -1149,7 +1150,7 @@ void cancelDXScan() { if (!flashing) { tft.fillRoundRect(2, 80, 40, 18, 2, SecondaryColor); - tftPrint(ACENTER, "MEM", 22, 82, BackgroundColor, SecondaryColor, 16); + tftPrint16(ACENTER, "MEM", 22, 82, BackgroundColor, SecondaryColor); } SQ = false; @@ -1379,7 +1380,11 @@ void setup() { tft.init(); - tft.loadFont(FONT48, 2); + tft.loadFont(FONT16_CHS, 0); + tft.loadFont(FONT48, 1); + tft.loadFont(FONT16, 2); + tft.loadFont(FONT28, 3); + tft.loadFont(FONT28_CHS, 4); doTheme(); @@ -1413,13 +1418,13 @@ void setup() { FrequencySprite.loadFont(FREQFONT5, 5); GeneralTextSprite.createSprite(308, 28); - GeneralTextSprite.loadFont(FONT48, 2); + GeneralTextSprite.copyFontFromTFT(2, 2); PSSprite.createSprite(150, 32); - PSSprite.loadFont(FONT16, 0); - PSSprite.loadFont(FONT16_CHS, 1); - PSSprite.loadFont(FONT28, 2); - PSSprite.loadFont(FONT28_CHS, 3); + PSSprite.copyFontFromTFT(2, 0); + PSSprite.copyFontFromTFT(0, 1); + PSSprite.copyFontFromTFT(3, 2); + PSSprite.copyFontFromTFT(4, 3); SquelchSprite.createSprite(27, 19); @@ -1428,7 +1433,7 @@ void setup() { OneBigLineSprite.createSprite(270, 30); SignalSprite.createSprite(80, 48); - SignalSprite.loadFont(FONT28, 0); + SignalSprite.copyFontFromTFT(4, 0); SignalSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); UpdateFonts(); @@ -1549,11 +1554,11 @@ void setup() { SelectBand(); if (tunemode == TUNE_MEM) DoMemoryPosTune(); - eccDisplay.setPostDrawCallback([&](TFT_eSprite* sprite, bool scrolling) { + eccDisplay.setPostDrawCallback([&](TFT_eSprite* sprite) { sprite->fillRect(275, 0, 10, 19, BackgroundColor); sprite->drawLine(284, 0, 284, 19, FrameColor); }); - rtDisplay.setPostDrawCallback([&](TFT_eSprite* sprite, bool scrolling) { + rtDisplay.setPostDrawCallback([&](TFT_eSprite* sprite) { sprite->fillRect(275, 0, 10, 19, BackgroundColor); sprite->drawLine(284, 0, 284, 19, FrameColor); if(radio.rds.hasRT) { @@ -1678,10 +1683,10 @@ void loop() { flashing = !flashing; if (flashing) { tft.fillRoundRect(2, 80, 40, 18, 2, SecondaryColor); - tftPrint(ACENTER, "MEM", 22, 82, BackgroundColor, SecondaryColor, 16); + tftPrint16(ACENTER, "MEM", 22, 82, BackgroundColor, SecondaryColor); } else { tft.fillRoundRect(2, 80, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "MEM", 22, 82, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "MEM", 22, 82, BackgroundColor, GreyoutColor); } flashingtimer = millis(); } @@ -1825,12 +1830,12 @@ void loop() { if ((SStatus / 10 > LowLevelSet) && !LowLevelInit && !BWtune && !menu && band < BAND_GAP) { if (!screenmute && !advancedRDS && !rdsstatscreen && !afscreen) { if (showaudio) { - tftPrint(ALEFT, "10", 24, 144, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "30", 54, 144, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "50", 84, 144, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "70", 114, 144, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "100", 160, 144, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ACENTER, "A", 7, 128, ActiveColor, ActiveColorSmooth, 16); + tftPrint16(ALEFT, "10", 24, 144, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "30", 54, 144, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "50", 84, 144, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "70", 114, 144, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "100", 160, 144, ActiveColor, ActiveColorSmooth); + tftPrint16(ACENTER, "A", 7, 128, ActiveColor, ActiveColorSmooth); for (byte segments = 0; segments < 93; segments++) { if (segments > 54) { if (((segments - 53) % 10) == 0) tft.fillRect(22 + (2 * segments), 141, 2, 2, BarSignificantColor); @@ -1839,14 +1844,14 @@ void loop() { } } } - if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16); + if (radio.rds.region == 0) tftPrint16(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth); else { - tftPrint(ALEFT, "PI", 212, 184, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "ID", 212, 201, ActiveColor, ActiveColorSmooth, 16); + tftPrint16(ALEFT, "PI", 212, 184, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "ID", 212, 201, ActiveColor, ActiveColorSmooth); } - tftPrint(ALEFT, "PS", 3, 193, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "RT", 3, 221, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "PTY", 3, 163, ActiveColor, ActiveColorSmooth, 16); + tftPrint16(ALEFT, "PS", 3, 193, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "RT", 3, 221, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "PTY", 3, 163, ActiveColor, ActiveColorSmooth); if (!showaudio) tft.drawLine(16, 143, 189, 143, GreyoutColor); else tft.drawLine(16, 143, 189, 143, ActiveColor); } LowLevelInit = true; @@ -1856,12 +1861,12 @@ void loop() { if (LowLevelInit && !BWtune && !menu) { if (!screenmute && !rdsstatscreen && !afscreen && !advancedRDS) { if(showaudio) { - tftPrint(ALEFT, "10", 24, 144, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "30", 54, 144, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "50", 84, 144, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "70", 114, 144, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "100", 160, 144, GreyoutColor, BackgroundColor, 16); - tftPrint(ACENTER, "A", 7, 128, GreyoutColor, BackgroundColor, 16); + tftPrint16(ALEFT, "10", 24, 144, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "30", 54, 144, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "50", 84, 144, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "70", 114, 144, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "100", 160, 144, GreyoutColor, BackgroundColor); + tftPrint16(ACENTER, "A", 7, 128, GreyoutColor, BackgroundColor); tft.fillRect(16, 133, 174, 6, GreyoutColor); for (byte segments = 0; segments < 93; segments++) { if (segments > 54) { @@ -1871,14 +1876,14 @@ void loop() { } } } - if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, GreyoutColor, BackgroundColor, 16); + if (radio.rds.region == 0) tftPrint16(ALEFT, "PI", 212, 193, GreyoutColor, BackgroundColor); else { - tftPrint(ALEFT, "PI", 212, 184, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "ID", 212, 201, GreyoutColor, BackgroundColor, 16); + tftPrint16(ALEFT, "PI", 212, 184, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "ID", 212, 201, GreyoutColor, BackgroundColor); } - tftPrint(ALEFT, "PS", 3, 193, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "RT", 3, 221, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "PTY", 3, 163, GreyoutColor, BackgroundColor, 16); + tftPrint16(ALEFT, "PS", 3, 193, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "RT", 3, 221, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "PTY", 3, 163, GreyoutColor, BackgroundColor); tft.drawLine(16, 143, 189, 143, GreyoutColor); tft.drawBitmap(68, 5, RDSLogo, 35, 22, GreyoutColor); } @@ -2356,20 +2361,20 @@ void SelectBand() { radio.setAMCoChannel(amcodect, amcodectcount); doBW(); if (!screenmute) { - if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, GreyoutColor, BackgroundColor, 16); + if (radio.rds.region == 0) tftPrint16(ALEFT, "PI", 212, 193, GreyoutColor, BackgroundColor); else { - tftPrint(ALEFT, "PI", 212, 184, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "ID", 212, 201, GreyoutColor, BackgroundColor, 16); + tftPrint16(ALEFT, "PI", 212, 184, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "ID", 212, 201, GreyoutColor, BackgroundColor); } - tftPrint(ALEFT, "PS", 3, 193, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "RT", 3, 221, GreyoutColor, BackgroundColor, 16); - tftPrint(ALEFT, "PTY", 3, 163, GreyoutColor, BackgroundColor, 16); + tftPrint16(ALEFT, "PS", 3, 193, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "RT", 3, 221, GreyoutColor, BackgroundColor); + tftPrint16(ALEFT, "PTY", 3, 163, GreyoutColor, BackgroundColor); tft.drawBitmap(68, 5, RDSLogo, 35, 22, GreyoutColor); tft.fillRoundRect(249, 57, 30, 18, 2, GreyoutColor); - tftPrint(ACENTER, "iMS", 265, 59, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "iMS", 265, 59, BackgroundColor, GreyoutColor); tft.fillRoundRect(287, 57, 30, 18, 2, GreyoutColor); - tftPrint(ACENTER, "EQ", 301, 59, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "EQ", 301, 59, BackgroundColor, GreyoutColor); tftReplace(ALEFT, "MHz", "kHz", 258, 76, ActiveColor, ActiveColorSmooth, BackgroundColor, 28); } } else { @@ -2385,14 +2390,14 @@ void SelectBand() { freqold = frequency_AM; if (!externaltune && tunemode != TUNE_MEM) CheckBandForbiddenFM(); doBW(); - if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16); + if (radio.rds.region == 0) tftPrint16(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth); else { - tftPrint(ALEFT, "PI", 212, 184, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "ID", 212, 201, ActiveColor, ActiveColorSmooth, 16); + tftPrint16(ALEFT, "PI", 212, 184, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "ID", 212, 201, ActiveColor, ActiveColorSmooth); } - tftPrint(ALEFT, "PS", 3, 193, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "RT", 3, 221, ActiveColor, ActiveColorSmooth, 16); - tftPrint(ALEFT, "PTY", 3, 163, ActiveColor, ActiveColorSmooth, 16); + tftPrint16(ALEFT, "PS", 3, 193, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "RT", 3, 221, ActiveColor, ActiveColorSmooth); + tftPrint16(ALEFT, "PTY", 3, 163, ActiveColor, ActiveColorSmooth); tftReplace(ALEFT, "kHz", "MHz", 258, 76, ActiveColor, ActiveColorSmooth, BackgroundColor, 28); } @@ -2625,8 +2630,8 @@ void ButtonPress() { EEPROM.writeByte(EE_BYTE_BANDAUTOSW, nowToggleSWMIBand); EEPROM.commit(); if (!screenmute) { - tftPrint(ACENTER, "AUTO", 22, 60, BackgroundColor, BackgroundColor, 16); - tftPrint(ACENTER, "BAND", 22, 60, BackgroundColor, BackgroundColor, 16); + tftPrint16(ACENTER, "AUTO", 22, 60, BackgroundColor, BackgroundColor); + tftPrint16(ACENTER, "BAND", 22, 60, BackgroundColor, BackgroundColor); } doTuneMode(); ShowTuneMode(); @@ -2820,8 +2825,8 @@ void ShowMemoryPos() { else tftReplace(ALEFT, String(memoryposold + 1), String(memorypos + 1), 50, 32, memposcolor, memposcolorsmooth, BackgroundColor, 16); memoryposold = memorypos; } else { - if (advancedRDS) tftPrint(ALEFT, String(memorypos + 1), 215, 36, BackgroundColor, BackgroundColor, 16); - else tftPrint(ALEFT, String(memorypos + 1), 50, 32, BackgroundColor, BackgroundColor, 16); + if (advancedRDS) tftPrint16(ALEFT, String(memorypos + 1), 215, 36, BackgroundColor, BackgroundColor); + else tftPrint16(ALEFT, String(memorypos + 1), 50, 32, BackgroundColor, BackgroundColor); } } @@ -3029,12 +3034,12 @@ void ShowSignalLevel() { SNRupdatetimer = millis(); if (!advancedRDS) { if (CN > (CNold + 1) || CN < (CNold - 1)) { - if (CNold == 0) tftPrint(ARIGHT, "--", 234, 165, BackgroundColor, BackgroundColor, 16); else tftPrint(ARIGHT, String(CNold), 234, 165, BackgroundColor, BackgroundColor, 16); + if (CNold == 0) tftPrint16(ARIGHT, "--", 234, 165, BackgroundColor, BackgroundColor); else tftPrint16(ARIGHT, String(CNold), 234, 165, BackgroundColor, BackgroundColor); if (tuned) { - if (CN == 0) tftPrint(ARIGHT, "--", 234, 165, PrimaryColor, PrimaryColorSmooth, 16); else tftPrint(ARIGHT, String(CN), 234, 165, PrimaryColor, PrimaryColorSmooth, 16); + if (CN == 0) tftPrint16(ARIGHT, "--", 234, 165, PrimaryColor, PrimaryColorSmooth); else tftPrint16(ARIGHT, String(CN), 234, 165, PrimaryColor, PrimaryColorSmooth); CNold = CN; } else { - tftPrint(ARIGHT, "--", 234, 165, PrimaryColor, PrimaryColorSmooth, 16); + tftPrint16(ARIGHT, "--", 234, 165, PrimaryColor, PrimaryColorSmooth); CNold = 0; } } @@ -3475,67 +3480,67 @@ void ShowTuneMode() { switch (tunemode) { case TUNE_MAN: if (band == BAND_SW && nowToggleSWMIBand) { - tftPrint(ACENTER, "AUTO", 22, 60, GreyoutColor, GreyoutColor, 16); + tftPrint16(ACENTER, "AUTO", 22, 60, GreyoutColor, GreyoutColor); tft.fillRoundRect(2, 58, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "BAND", 22, 60, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "BAND", 22, 60, BackgroundColor, GreyoutColor); } else { - tftPrint(ACENTER, "BAND", 22, 60, GreyoutColor, GreyoutColor, 16); + tftPrint16(ACENTER, "BAND", 22, 60, GreyoutColor, GreyoutColor); tft.fillRoundRect(2, 58, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "AUTO", 22, 60, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "AUTO", 22, 60, BackgroundColor, GreyoutColor); } tft.fillRoundRect(2, 36, 40, 18, 2, SecondaryColor); - tftPrint(ACENTER, "MAN", 22, 38, BackgroundColor, SecondaryColor, 16); + tftPrint16(ACENTER, "MAN", 22, 38, BackgroundColor, SecondaryColor); tft.fillRoundRect(2, 80, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "MEM", 22, 82, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "MEM", 22, 82, BackgroundColor, GreyoutColor); break; case TUNE_AUTO: tft.fillRoundRect(2, 58, 40, 18, 2, SecondaryColor); - tftPrint(ACENTER, "AUTO", 22, 60, BackgroundColor, SecondaryColor, 16); + tftPrint16(ACENTER, "AUTO", 22, 60, BackgroundColor, SecondaryColor); tft.fillRoundRect(2, 36, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "MAN", 22, 38, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "MAN", 22, 38, BackgroundColor, GreyoutColor); tft.fillRoundRect(2, 80, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "MEM", 22, 82, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "MEM", 22, 82, BackgroundColor, GreyoutColor); break; case TUNE_MEM: if (band == BAND_SW && nowToggleSWMIBand) { - tftPrint(ACENTER, "AUTO", 22, 60, GreyoutColor, GreyoutColor, 16); + tftPrint16(ACENTER, "AUTO", 22, 60, GreyoutColor, GreyoutColor); tft.fillRoundRect(2, 58, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "BAND", 22, 60, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "BAND", 22, 60, BackgroundColor, GreyoutColor); } else { - tftPrint(ACENTER, "BAND", 22, 60, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "BAND", 22, 60, BackgroundColor, GreyoutColor); tft.fillRoundRect(2, 58, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "AUTO", 22, 60, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "AUTO", 22, 60, BackgroundColor, GreyoutColor); } tft.fillRoundRect(2, 36, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "MAN", 22, 38, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "MAN", 22, 38, BackgroundColor, GreyoutColor); if (memorystore) { tft.fillRoundRect(2, 80, 40, 18, 2, SignificantColor); - tftPrint(ACENTER, "MEM", 22, 82, BackgroundColor, SignificantColor, 16); + tftPrint16(ACENTER, "MEM", 22, 82, BackgroundColor, SignificantColor); } else { tft.fillRoundRect(2, 80, 40, 18, 2, SecondaryColor); - tftPrint(ACENTER, "MEM", 22, 82, BackgroundColor, SecondaryColor, 16); + tftPrint16(ACENTER, "MEM", 22, 82, BackgroundColor, SecondaryColor); } break; case TUNE_MI_BAND: tft.fillRoundRect(2, 58, 40, 18, 2, SecondaryColor); - tftPrint(ACENTER, "BAND", 22, 60, BackgroundColor, SecondaryColor, 16); + tftPrint16(ACENTER, "BAND", 22, 60, BackgroundColor, SecondaryColor); tft.fillRoundRect(2, 36, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "MAN", 22, 38, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "MAN", 22, 38, BackgroundColor, GreyoutColor); tft.fillRoundRect(2, 80, 40, 18, 2, GreyoutColor); - tftPrint(ACENTER, "MEM", 22, 82, BackgroundColor, GreyoutColor, 16); + tftPrint16(ACENTER, "MEM", 22, 82, BackgroundColor, GreyoutColor); break; } } @@ -3841,9 +3846,9 @@ void read_encoder() { } void tftReplace(int8_t offset, const String & textold, const String & text, int16_t x, int16_t y, int color, int smoothcolor, int background, uint8_t fontsize) { - uint8_t selectedFont = 0; - if (fontsize == 28) selectedFont = 1; - else if (fontsize == 48) selectedFont = 2; + uint8_t selectedFont = 0 ? (language == LANGUAGE_CHS) : 2; + if(fontsize == 28) selectedFont = (language == LANGUAGE_CHS) ? 4 : 3; + else if(fontsize == 48) selectedFont = 1; switch (offset) { case -1: tft.setTextDatum(TL_DATUM); break; @@ -3862,11 +3867,29 @@ void tftReplace(int8_t offset, const String & textold, const String & text, int1 } void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize) { - uint8_t selectedFont = 0; - if (fontsize == 28) selectedFont = 1; - else if (fontsize == 48) selectedFont = 2; + uint8_t selectedFont = (language == LANGUAGE_CHS) ? 0 : 2; + if (fontsize == 28) selectedFont = (language == LANGUAGE_CHS) ? 4 : 3; + else if (fontsize == 48) selectedFont = 1; - tft.setTextColor(color, smoothcolor, (fontsize == 52 ? true : false)); + tft.setTextColor(color, smoothcolor); + + switch (offset) { + case -1: tft.setTextDatum(TL_DATUM); break; + case 0: tft.setTextDatum(TC_DATUM); break; + case 1: tft.setTextDatum(TR_DATUM); break; + } + + String modifiedText = text; + modifiedText.replace("\n", " "); + + tft.drawString(modifiedText, x, y, selectedFont); +} + +void tftPrint16(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, bool force_font, bool font) { + uint8_t selectedFont = (language == LANGUAGE_CHS) ? 0 : 2; + if(force_font) selectedFont = 0 ? font : 2; + + tft.setTextColor(color, smoothcolor); switch (offset) { case -1: tft.setTextDatum(TL_DATUM); break; @@ -3881,26 +3904,30 @@ void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int colo } void UpdateFonts() { + // This is at setup: + // tft.loadFont(FONT48, 1); + + // tft.loadFont(FONT16_CHS, 0); + // tft.loadFont(FONT16, 2); + // tft.loadFont(FONT28, 3); + // tft.loadFont(FONT28_CHS, 4); + if (language == LANGUAGE_CHS) { if (menu) PSSprite.setTextFont(1); else PSSprite.setTextFont(3); - OneBigLineSprite.loadFont(FONT28_CHS, 0); - FullLineSprite.loadFont(FONT16_CHS, 0); - GeneralTextSprite.loadFont(FONT16_CHS, 0); - GeneralTextSprite.loadFont(FONT28_CHS, 1); - FrequencySprite.loadFont(FONT16_CHS, 6); - tft.loadFont(FONT16_CHS, 0); - tft.loadFont(FONT28_CHS, 1); - SquelchSprite.loadFont(FONT16, 0); + OneBigLineSprite.copyFontFromTFT(4, 0); + FullLineSprite.copyFontFromTFT(0, 0); + GeneralTextSprite.copyFontFromTFT(0, 0); + GeneralTextSprite.copyFontFromTFT(4, 1); + FrequencySprite.copyFontFromTFT(0, 6); + SquelchSprite.copyFontFromTFT(0, 0); } else { if (menu) PSSprite.setTextFont(0); else PSSprite.setTextFont(2); - OneBigLineSprite.loadFont(FONT28, 0); - FullLineSprite.loadFont(FONT16, 0); - GeneralTextSprite.loadFont(FONT16, 0); - GeneralTextSprite.loadFont(FONT28, 1); - FrequencySprite.loadFont(FONT16, 6); - tft.loadFont(FONT16, 0); - tft.loadFont(FONT28, 1); - SquelchSprite.loadFont(FONT16_CHS, 0); + OneBigLineSprite.copyFontFromTFT(3, 0); + FullLineSprite.copyFontFromTFT(2, 0); + GeneralTextSprite.copyFontFromTFT(2, 0); + GeneralTextSprite.copyFontFromTFT(3, 1); + FrequencySprite.copyFontFromTFT(2, 6); + SquelchSprite.copyFontFromTFT(2, 0); } } diff --git a/src/rds.cpp b/src/rds.cpp index fa247d1..73c4393 100644 --- a/src/rds.cpp +++ b/src/rds.cpp @@ -36,17 +36,17 @@ void ShowAdvancedRDS() { if (radio.rds.PTYN.changed(0) || rdsreset) { if (!screenmute) { if (radio.rds.PTYN.getPrev() != "PTYN N/A" || radio.rds.hasPTYN) { - tftPrint(ALEFT, "PTYN N/A", 216, 109, BackgroundColor, BackgroundColor, 16); - tftPrint(ALEFT, radio.rds.PTYN.getPrev(), 216, 109, BackgroundColor, BackgroundColor, 16); + tftPrint16(ALEFT, "PTYN N/A", 216, 109, BackgroundColor, BackgroundColor); + tftPrint16(ALEFT, radio.rds.PTYN.getPrev(), 216, 109, BackgroundColor, BackgroundColor); } if (!radio.rds.hasPTYN) radio.rds.PTYN = "PTYN N/A"; - tftPrint(ALEFT, String(radio.rds.PTYN), 216, 109, RDSColor, RDSColorSmooth, 16); + tftPrint16(ALEFT, String(radio.rds.PTYN), 216, 109, RDSColor, RDSColorSmooth); // PTYN is UCS-2, meaning no chinese characters. Americans... } } if (hasafold != radio.rds.hasAF) { if (!screenmute) { - if (radio.rds.hasAF) tftPrint(ALEFT, "AF", 50, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "AF", 50, 51, GreyoutColor, BackgroundColor, 16); + if (radio.rds.hasAF) tftPrint16(ALEFT, "AF", 50, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "AF", 50, 51, GreyoutColor, BackgroundColor); } hasafold = radio.rds.hasAF; } @@ -64,13 +64,19 @@ void ShowAdvancedRDS() { Udp.endPacket(); } } - if(!screenmute) eccDisplay.update(ECCString, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor); + if(!screenmute) { + uint8_t font = 0; + if(radio.rds.ECC.get() == 190) font = 1; + else if(radio.rds.ECC.get() == 192) font = 1; + else if(radio.rds.ECC.get() == 201) font = 1; + eccDisplay.update(ECCString, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, font); + } String eonstring; if (radio.eon_counter > 0) for (byte i = 0; i < radio.eon_counter; i++) eonstring += String(radio.eon[i].picode) + (radio.eon[i].ps.length() > 0 ? String(": " + String(radio.eon[i].ps)) : "") + (radio.eon[i].mappedfreq > 0 ? String(" " + String(radio.eon[i].mappedfreq / 100) + "." + String((radio.eon[i].mappedfreq % 100) / 10)) : "") + (radio.eon[i].mappedfreq2 > 0 ? String(" / " + String(radio.eon[i].mappedfreq2 / 100) + "." + String((radio.eon[i].mappedfreq2 % 100) / 10)) : "") + (radio.eon[i].mappedfreq3 > 0 ? String(" / " + String(radio.eon[i].mappedfreq3 / 100) + "." + String((radio.eon[i].mappedfreq3 % 100) / 10)) : "") + (i == radio.eon_counter - 1 ? "" : " | "); else eonstring = textUI(85); if (radio.rds.hasEON.changed(0)) { if (!screenmute) { - if (radio.eon_counter > 0) tftPrint(ALEFT, "EON", 153, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "EON", 153, 51, GreyoutColor, BackgroundColor, 16); + if (radio.eon_counter > 0) tftPrint16(ALEFT, "EON", 153, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "EON", 153, 51, GreyoutColor, BackgroundColor); } } @@ -80,23 +86,23 @@ void ShowAdvancedRDS() { if (radio.rds.hasRTplus) rtplusstring = (radio.rds.rdsplusTag1 != 169 ? String(textUI(radio.rds.rdsplusTag1)) + ": " + String(radio.rds.RTContent1) : "") + (radio.rds.rdsplusTag2 != 169 ? " - " + String(textUI(radio.rds.rdsplusTag2)) + ": " + String(radio.rds.RTContent2) : ""); else rtplusstring = textUI(86); if (radio.rds.hasRTplus.changed(0)) { if (!screenmute) { - if (radio.rds.hasRTplus) tftPrint(ALEFT, "RT+", 123, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "RT+", 123, 51, GreyoutColor, BackgroundColor, 16); + if (radio.rds.hasRTplus) tftPrint16(ALEFT, "RT+", 123, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "RT+", 123, 51, GreyoutColor, BackgroundColor); } } if(!screenmute) rtplusDisplay.update(rtplusstring, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor); if (radio.rds.TP.changed(0) && !screenmute) { - if (radio.rds.TP) tftPrint(ALEFT, "TP", 2, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "TP", 2, 51, GreyoutColor, BackgroundColor, 16); + if (radio.rds.TP) tftPrint16(ALEFT, "TP", 2, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "TP", 2, 51, GreyoutColor, BackgroundColor); } if (radio.rds.TA.changed(0) && !screenmute) { - if (radio.rds.TA) tftPrint(ALEFT, "TA", 24, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "TA", 24, 51, GreyoutColor, BackgroundColor, 16); + if (radio.rds.TA) tftPrint16(ALEFT, "TA", 24, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "TA", 24, 51, GreyoutColor, BackgroundColor); } if (afmethodBold != radio.afmethodB || rdsreset) { if (!screenmute) { - if (radio.afmethodB) tftPrint(ALEFT, "-B", 68, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "-B", 68, 51, GreyoutColor, BackgroundColor, 16); + if (radio.afmethodB) tftPrint16(ALEFT, "-B", 68, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "-B", 68, 51, GreyoutColor, BackgroundColor); } afmethodBold = radio.afmethodB; } @@ -109,7 +115,7 @@ void ShowAdvancedRDS() { if (radio.rds.hasTMC.changed(0)) { if (!screenmute) { - if (radio.rds.hasTMC) tftPrint(ALEFT, "TMC", 88, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "TMC", 88, 51, GreyoutColor, BackgroundColor, 16); + if (radio.rds.hasTMC) tftPrint16(ALEFT, "TMC", 88, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "TMC", 88, 51, GreyoutColor, BackgroundColor); } } @@ -152,7 +158,7 @@ void readRds() { else { tftPrint(ALEFT, PIold, 240, advancedRDS ? 72 : 184, RDSDropoutColor, RDSDropoutColorSmooth, 16); tftPrint(ALEFT, stationIDold, 240, advancedRDS ? 89 : 201, RDSDropoutColor, RDSDropoutColorSmooth, 16); - tftPrint( 1, stationStateold, 318, advancedRDS ? 89 : 201, RDSDropoutColor, RDSDropoutColorSmooth, 16); + tftPrint(1, stationStateold, 318, advancedRDS ? 89 : 201, RDSDropoutColor, RDSDropoutColorSmooth, 16); } if (!radio.rds.hasLongPS) { @@ -558,11 +564,11 @@ void ShowAFEON() { if (radio.eon_counter > 9) { if (!afpage) { afpage = true; - tftPrint(ARIGHT, String(afpagenr) + "/2", 315, 201, BackgroundColor, BackgroundColor, 16); + tftPrint16(ARIGHT, String(afpagenr) + "/2", 315, 201, BackgroundColor, BackgroundColor); } } - if (afpage) tftPrint(ARIGHT, String(afpagenr) + "/3", 315, 201, ActiveColor, ActiveColorSmooth, 16); else tftPrint(ARIGHT, String(afpagenr) + "/2", 315, 201, ActiveColor, ActiveColorSmooth, 16); + if (afpage) tftPrint16(ARIGHT, String(afpagenr) + "/3", 315, 201, ActiveColor, ActiveColorSmooth); else tftPrint16(ARIGHT, String(afpagenr) + "/2", 315, 201, ActiveColor, ActiveColorSmooth); if (radio.rds.hasAF && afpagenr == 1) { if (!hasafold) {