simplyfy the font logic and also fix the bug where it loaded the chinese font for both chinese and latin
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ extern void TuneUp();
|
|||||||
extern void endMenu();
|
extern void endMenu();
|
||||||
extern void startFMDXScan();
|
extern void startFMDXScan();
|
||||||
extern void DoMemoryPosTune();
|
extern void DoMemoryPosTune();
|
||||||
extern void UpdateFonts(byte mode);
|
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 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 setAutoSpeedSPI();
|
||||||
extern void showAutoSquelch(bool mode);
|
extern void showAutoSquelch(bool mode);
|
||||||
|
|||||||
@@ -498,7 +498,6 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
|
|||||||
_fillbg = isDigits = textwrapY = false;
|
_fillbg = isDigits = textwrapY = false;
|
||||||
textwrapX = true;
|
textwrapX = true;
|
||||||
textdatum = TL_DATUM;
|
textdatum = TL_DATUM;
|
||||||
fontsloaded = 0;
|
|
||||||
|
|
||||||
_swapBytes = false;
|
_swapBytes = false;
|
||||||
|
|
||||||
@@ -507,17 +506,12 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
|
|||||||
lockTransaction = false;
|
lockTransaction = false;
|
||||||
|
|
||||||
_booted = true;
|
_booted = true;
|
||||||
_cp437 = false;
|
|
||||||
_utf8 = true;
|
|
||||||
|
|
||||||
addr_row = 0xFFFF;
|
addr_row = 0xFFFF;
|
||||||
addr_col = 0xFFFF;
|
addr_col = 0xFFFF;
|
||||||
|
|
||||||
_xPivot = 0;
|
_xPivot = 0;
|
||||||
_yPivot = 0;
|
_yPivot = 0;
|
||||||
|
|
||||||
fontsloaded = 0x0002; // Bit 1 set
|
|
||||||
fontsloaded |= 0x8000; // Bit 15 set
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFT_eSPI::initBus(void) {
|
void TFT_eSPI::initBus(void) {
|
||||||
@@ -2139,10 +2133,6 @@ int16_t TFT_eSPI::textWidth(const char *string, uint8_t font) {
|
|||||||
return str_width;
|
return str_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t TFT_eSPI::fontsLoaded() {
|
|
||||||
return fontsloaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t TFT_eSPI::fontHeight(uint8_t font) {
|
int16_t TFT_eSPI::fontHeight(uint8_t font) {
|
||||||
if (font > 8) return 0;
|
if (font > 8) return 0;
|
||||||
|
|
||||||
@@ -2948,8 +2938,6 @@ void TFT_eSPI::invertDisplay(bool i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t TFT_eSPI::decodeUTF8(uint8_t c) {
|
uint16_t TFT_eSPI::decodeUTF8(uint8_t c) {
|
||||||
if (!_utf8) return c;
|
|
||||||
|
|
||||||
if ((c & 0x80) == 0x00) {
|
if ((c & 0x80) == 0x00) {
|
||||||
decoderState = 0;
|
decoderState = 0;
|
||||||
return c;
|
return c;
|
||||||
@@ -2989,8 +2977,6 @@ uint16_t TFT_eSPI::decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining)
|
|||||||
{
|
{
|
||||||
uint16_t c = buf[(*index)++];
|
uint16_t c = buf[(*index)++];
|
||||||
|
|
||||||
if (!_utf8) return c;
|
|
||||||
|
|
||||||
if ((c & 0x80) == 0x00) return c;
|
if ((c & 0x80) == 0x00) return c;
|
||||||
|
|
||||||
if (((c & 0xE0) == 0xC0) && (remaining > 1))
|
if (((c & 0xE0) == 0xC0) && (remaining > 1))
|
||||||
|
|||||||
@@ -277,9 +277,6 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
// Used by Smooth font class to fetch a pixel colour for the anti-aliasing
|
// Used by Smooth font class to fetch a pixel colour for the anti-aliasing
|
||||||
void setCallback(getColorCallback getCol);
|
void setCallback(getColorCallback getCol);
|
||||||
|
|
||||||
uint16_t fontsLoaded(void); // Each bit in returned value represents a font type that is loaded - used for debug/error handling only
|
|
||||||
|
|
||||||
|
|
||||||
void spiwrite(uint8_t); // legacy support only
|
void spiwrite(uint8_t); // legacy support only
|
||||||
void writecommand(uint8_t c); // Send an 8-bit command, function resets DC/RS high ready for data
|
void writecommand(uint8_t c); // Send an 8-bit command, function resets DC/RS high ready for data
|
||||||
void writedata(uint8_t d); // Send data with DC/RS set high
|
void writedata(uint8_t d); // Send data with DC/RS set high
|
||||||
@@ -440,17 +437,12 @@ uint8_t spi_write_speed;
|
|||||||
int32_t bg_cursor_x;
|
int32_t bg_cursor_x;
|
||||||
int32_t last_cursor_x;
|
int32_t last_cursor_x;
|
||||||
|
|
||||||
uint32_t fontsloaded;
|
|
||||||
|
|
||||||
bool isDigits;
|
bool isDigits;
|
||||||
bool textwrapX, textwrapY;
|
bool textwrapX, textwrapY;
|
||||||
bool _swapBytes;
|
bool _swapBytes;
|
||||||
|
|
||||||
bool _booted;
|
bool _booted;
|
||||||
|
|
||||||
bool _cp437;
|
|
||||||
bool _utf8;
|
|
||||||
|
|
||||||
uint32_t _lastColor;
|
uint32_t _lastColor;
|
||||||
|
|
||||||
bool _fillbg;
|
bool _fillbg;
|
||||||
|
|||||||
+3
-5
@@ -3519,14 +3519,14 @@ void MenuUpDown(bool dir) {
|
|||||||
switch (menuoption) {
|
switch (menuoption) {
|
||||||
case ITEM1:
|
case ITEM1:
|
||||||
if (dir) {
|
if (dir) {
|
||||||
language ++;
|
language++;
|
||||||
if (language == language_totalnumber) language = 0;
|
if (language == language_totalnumber) language = 0;
|
||||||
} else {
|
} else {
|
||||||
language --;
|
language--;
|
||||||
if (language > language_totalnumber) language = language_totalnumber - 1;
|
if (language > language_totalnumber) language = language_totalnumber - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateFonts(0);
|
UpdateFonts();
|
||||||
OneBigLineSprite.drawString(textUI(0), 135, 0);
|
OneBigLineSprite.drawString(textUI(0), 135, 0);
|
||||||
OneBigLineSprite.pushSprite(24, 118);
|
OneBigLineSprite.pushSprite(24, 118);
|
||||||
break;
|
break;
|
||||||
@@ -5222,7 +5222,6 @@ void DoMenu() {
|
|||||||
tftPrint(ACENTER, "http://192.168.4.1", 155, 174, PrimaryColor, PrimaryColorSmooth, 16);
|
tftPrint(ACENTER, "http://192.168.4.1", 155, 174, PrimaryColor, PrimaryColorSmooth, 16);
|
||||||
char key [9];
|
char key [9];
|
||||||
XDRGTK_key.toCharArray(key, 9);
|
XDRGTK_key.toCharArray(key, 9);
|
||||||
UpdateFonts(1);
|
|
||||||
if (wifi) {
|
if (wifi) {
|
||||||
wifi = false;
|
wifi = false;
|
||||||
tryWiFi();
|
tryWiFi();
|
||||||
@@ -5238,7 +5237,6 @@ void DoMenu() {
|
|||||||
XDRGTK_key = XDRGTK_key_input.getValue();
|
XDRGTK_key = XDRGTK_key_input.getValue();
|
||||||
EEPROM.writeString(EE_STRING_XDRGTK_KEY, XDRGTK_key);
|
EEPROM.writeString(EE_STRING_XDRGTK_KEY, XDRGTK_key);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
UpdateFonts(0);
|
|
||||||
wifi = true;
|
wifi = true;
|
||||||
tryWiFi();
|
tryWiFi();
|
||||||
delay(2000);
|
delay(2000);
|
||||||
|
|||||||
+14
-18
@@ -1315,19 +1315,19 @@ void setup() {
|
|||||||
FullLineSprite.createSprite(308, 19);
|
FullLineSprite.createSprite(308, 19);
|
||||||
FullLineSprite.setSwapBytes(true);
|
FullLineSprite.setSwapBytes(true);
|
||||||
FullLineSprite.loadFont(FONT16, 0);
|
FullLineSprite.loadFont(FONT16, 0);
|
||||||
FullLineSprite.loadFont(FONT16_CHS, 0);
|
FullLineSprite.loadFont(FONT16_CHS, 1);
|
||||||
|
|
||||||
OneBigLineSprite.createSprite(270, 30);
|
OneBigLineSprite.createSprite(270, 30);
|
||||||
OneBigLineSprite.setSwapBytes(true);
|
OneBigLineSprite.setSwapBytes(true);
|
||||||
OneBigLineSprite.loadFont(FONT28, 0);
|
OneBigLineSprite.loadFont(FONT28, 0);
|
||||||
OneBigLineSprite.loadFont(FONT28_CHS, 0);
|
OneBigLineSprite.loadFont(FONT28_CHS, 1);
|
||||||
|
|
||||||
SignalSprite.createSprite(80, 48);
|
SignalSprite.createSprite(80, 48);
|
||||||
SignalSprite.loadFont(FONT28, 0);
|
SignalSprite.loadFont(FONT28, 0);
|
||||||
SignalSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
|
SignalSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
|
||||||
SignalSprite.setSwapBytes(true);
|
SignalSprite.setSwapBytes(true);
|
||||||
|
|
||||||
UpdateFonts(0);
|
UpdateFonts();
|
||||||
|
|
||||||
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == HIGH) {
|
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == HIGH) {
|
||||||
if (rotarymode == 0) rotarymode = 1; else rotarymode = 0;
|
if (rotarymode == 0) rotarymode = 1; else rotarymode = 0;
|
||||||
@@ -3903,21 +3903,17 @@ void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int colo
|
|||||||
tft.drawString(modifiedText, x, y, selectedFont);
|
tft.drawString(modifiedText, x, y, selectedFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFonts(byte mode) {
|
void UpdateFonts() {
|
||||||
switch (mode) {
|
if (language == LANGUAGE_CHS) {
|
||||||
case 0:
|
if (menu) PSSprite.setTextFont(1); else PSSprite.setTextFont(3);
|
||||||
if (language == LANGUAGE_CHS) {
|
OneBigLineSprite.setTextFont(1);
|
||||||
if (menu) PSSprite.setTextFont(1); else PSSprite.setTextFont(3);
|
GeneralTextSprite.setTextFont(1);
|
||||||
OneBigLineSprite.setTextFont(1);
|
FullLineSprite.setTextFont(1);
|
||||||
GeneralTextSprite.setTextFont(1);
|
} else {
|
||||||
FullLineSprite.setTextFont(1);
|
if (menu) PSSprite.setTextFont(0); else PSSprite.setTextFont(2);
|
||||||
} else {
|
OneBigLineSprite.setTextFont(0);
|
||||||
if (menu) PSSprite.setTextFont(0); else PSSprite.setTextFont(2);
|
GeneralTextSprite.setTextFont(0);
|
||||||
OneBigLineSprite.setTextFont(0);
|
FullLineSprite.setTextFont(0);
|
||||||
GeneralTextSprite.setTextFont(0);
|
|
||||||
FullLineSprite.setTextFont(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user