Added battery+Wifi indicator

Can't test battery indicator. No portable device here ;-) Please feedback.
This commit is contained in:
Sjef Verhoeven PE5PVB
2023-06-17 20:07:48 +02:00
parent be09eb8907
commit 92e8210776
2 changed files with 154 additions and 36 deletions
+44 -14
View File
@@ -21,6 +21,7 @@
#define ROTARY_PIN_B 36 #define ROTARY_PIN_B 36
#define ROTARY_BUTTON 39 #define ROTARY_BUTTON 39
#define PIN_POT 35 #define PIN_POT 35
#define BATTERY_PIN 13
#define PWRBUTTON 4 #define PWRBUTTON 4
#define BWBUTTON 25 #define BWBUTTON 25
#define MODEBUTTON 26 #define MODEBUTTON 26
@@ -38,6 +39,10 @@ TFT_eSPI tft = TFT_eSPI(320, 240);
TFT_eSPI tft = TFT_eSPI(240, 320); TFT_eSPI tft = TFT_eSPI(240, 320);
#endif #endif
byte battery;
byte batteryold;
int rssi;
int rssiold = 200;
bool edgebeep; bool edgebeep;
bool RDSSPYUSB; bool RDSSPYUSB;
bool RDSSPYTCP; bool RDSSPYTCP;
@@ -67,7 +72,6 @@ bool store;
bool TPold; bool TPold;
bool TAold; bool TAold;
bool tuned; bool tuned;
bool USBstatus;
bool USBmode = 1; bool USBmode = 1;
bool XDRMute; bool XDRMute;
bool XDRGTKdata; bool XDRGTKdata;
@@ -614,12 +618,14 @@ void GetData() {
showRadioText(); showRadioText();
ShowStereoStatus(); ShowStereoStatus();
} }
ShowRSSI();
ShowBattery();
ShowOffset(); ShowOffset();
ShowSignalLevel(); ShowSignalLevel();
ShowBW(); ShowBW();
} }
} }
void PWRButtonPress() { void PWRButtonPress() {
if (menu == false) { if (menu == false) {
unsigned long counterold = millis(); unsigned long counterold = millis();
@@ -783,7 +789,7 @@ void ModeButtonPress() {
if (counter - counterold <= 1000) { if (counter - counterold <= 1000) {
doTuneMode(); doTuneMode();
} else { } else {
if (USBstatus == true && (XDRGTKUSB == true || XDRGTKTCP == true)) { if (XDRGTKUSB == true || XDRGTKTCP == true) {
ShowFreq(1); ShowFreq(1);
tft.setFreeFont(FONT14); tft.setFreeFont(FONT14);
tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -1122,6 +1128,8 @@ void ButtonPress() {
tft.drawCentreString(myLanguage[language][53], 155, 50, GFXFF); tft.drawCentreString(myLanguage[language][53], 155, 50, GFXFF);
tft.drawCentreString("ESP_" + String(ESP_getChipId()), 155, 90, GFXFF); tft.drawCentreString("ESP_" + String(ESP_getChipId()), 155, 90, GFXFF);
tft.drawCentreString(myLanguage[language][54], 155, 130, GFXFF); tft.drawCentreString(myLanguage[language][54], 155, 130, GFXFF);
tft.setFreeFont(FONT7);
tft.drawCentreString("http://192.168.4.1", 155, 170, GFXFF);
char key [9]; char key [9];
XDRGTK_key.toCharArray(key, 9); XDRGTK_key.toCharArray(key, 9);
WiFiConnectParam XDRGTK_key_text("Set XDRGTK Password: (max 8 characters)"); WiFiConnectParam XDRGTK_key_text("Set XDRGTK Password: (max 8 characters)");
@@ -2154,7 +2162,6 @@ void BuildDisplay() {
ShowFreq(0); ShowFreq(0);
ShowTuneMode(); ShowTuneMode();
updateBW(); updateBW();
ShowUSBstatus();
ShowStepSize(); ShowStepSize();
ShowMemoryPos(); ShowMemoryPos();
updateiMS(); updateiMS();
@@ -2162,6 +2169,8 @@ void BuildDisplay() {
Squelchold = -2; Squelchold = -2;
SStatusold = 2000; SStatusold = 2000;
SStatus = 100; SStatus = 100;
rssiold = 2000;
batteryold = 6;
rds_clockold = ""; rds_clockold = "";
strcpy(programTypePrevious, "0"); strcpy(programTypePrevious, "0");
strcpy(radioIdPrevious, "0"); strcpy(radioIdPrevious, "0");
@@ -2791,8 +2800,36 @@ void ShowTuneMode() {
} }
} }
void ShowUSBstatus() { void ShowRSSI() {
if (USBstatus == true) tft.drawBitmap(272, 6, USBLogo, 43, 21, TFT_SKYBLUE); else tft.drawBitmap(272, 6, USBLogo, 43, 21, TFT_GREYOUT); if (wifi) rssi = WiFi.RSSI(); else rssi = 0;
if (rssiold != rssi) {
rssiold = rssi;
if (rssi == 0) {
tft.drawBitmap(272, 4, WiFi4, 25, 25, TFT_GREYOUT);
} else if (rssi > -50 && rssi < 0) {
tft.drawBitmap(272, 4, WiFi4, 25, 25, TFT_SKYBLUE);
} else if (rssi > -60) {
tft.drawBitmap(272, 4, WiFi4, 25, 25, TFT_GREYOUT);
tft.drawBitmap(272, 4, WiFi3, 25, 25, TFT_SKYBLUE);
} else if (rssi > -70) {
tft.drawBitmap(272, 4, WiFi4, 25, 25, TFT_GREYOUT);
tft.drawBitmap(272, 4, WiFi2, 25, 25, TFT_SKYBLUE);
} else if (rssi < -70) {
tft.drawBitmap(272, 4, WiFi4, 25, 25, TFT_GREYOUT);
tft.drawBitmap(272, 4, WiFi1, 25, 25, TFT_SKYBLUE);
}
}
}
void ShowBattery() {
battery = map(constrain(analogRead(BATTERY_PIN), 1965, 2300), 1965, 2300, 0, 4);
if (batteryold != battery) {
tft.drawRect(300, 8, 12, 20, TFT_WHITE);
tft.fillRect(303, 4, 6, 4, TFT_WHITE);
tft.fillRect(302, 10, 8, 16, TFT_BLACK);
tft.fillRect(302, 26 - (battery * 4), 8, battery * 4, TFT_GREEN);
batteryold = battery;
}
} }
void Communication() { void Communication() {
@@ -2859,12 +2896,7 @@ void Communication() {
{ {
String data_str = Serial.readStringUntil('\n'); String data_str = Serial.readStringUntil('\n');
int data = data_str.toInt(); int data = data_str.toInt();
if (data_str.length() > 1 && data_str == ("*D*R?F")) if (data_str.length() > 1 && data_str == ("*D*R?F")) RDSSPYUSB = true;
{
USBstatus = true;
RDSSPYUSB = true;
ShowUSBstatus();
}
int symPos = data_str.indexOf("*F"); int symPos = data_str.indexOf("*F");
if (symPos >= 5) { if (symPos >= 5) {
String freq = data_str.substring(0, symPos); String freq = data_str.substring(0, symPos);
@@ -2894,9 +2926,7 @@ void Communication() {
SelectBand(); SelectBand();
} }
Serial.print("OK\nT" + String(frequency * 10) + "\n"); Serial.print("OK\nT" + String(frequency * 10) + "\n");
USBstatus = true;
XDRGTKUSB = true; XDRGTKUSB = true;
ShowUSBstatus();
if (menu == true) ModeButtonPress(); if (menu == true) ModeButtonPress();
if (Squelch != Squelchold) { if (Squelch != Squelchold) {
if (screenmute == false) { if (screenmute == false) {
+110 -22
View File
@@ -23,28 +23,116 @@ static const uint8_t RDSLogo[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}; };
static const uint8_t USBLogo[] PROGMEM = { static const uint8_t WiFi1[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0b, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xdf, 0xae, 0x5f, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00,
0x03, 0x87, 0x08, 0x06, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x07, 0x8f, 0x18, 0x03, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x2f, 0x0e, 0x00, 0xc2, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00,
0x3f, 0x0f, 0x10, 0xfe, 0x3c, 0x40, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x0e, 0x18, 0x1e, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x1e, 0x18, 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x0e, 0x3e, 0x06, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00,
0x7e, 0x1c, 0x13, 0xc4, 0x38, 0x40, 0x00, 0x00, 0x00, 0x00,
0xaf, 0x08, 0x21, 0xc4, 0x28, 0x40, 0x00, 0x00, 0x00, 0x00,
0x0f, 0x00, 0x60, 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
0x0f, 0x00, 0xf0, 0x08, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
0x07, 0xeb, 0xfe, 0xbe, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x00, 0x00,
0x00, 0x3c, 0x00, 0x00,
0x00, 0x1c, 0x00, 0x00,
0x00, 0x18, 0x00, 0x00
};
static const uint8_t WiFi2[] PROGMEM = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x00, 0x00,
0x00, 0xff, 0x00, 0x00,
0x01, 0xff, 0x80, 0x00,
0x03, 0xff, 0x80, 0x00,
0x03, 0xe7, 0x80, 0x00,
0x01, 0x83, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x00, 0x00,
0x00, 0x3c, 0x00, 0x00,
0x00, 0x3c, 0x00, 0x00,
0x00, 0x18, 0x00, 0x00
};
static const uint8_t WiFi3[] PROGMEM = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0x00, 0x00,
0x01, 0x80, 0xc0, 0x00,
0x02, 0x00, 0x20, 0x00,
0x04, 0x7e, 0x10, 0x00,
0x09, 0x80, 0x88, 0x00,
0x03, 0x00, 0x48, 0x00,
0x0c, 0x00, 0x20, 0x00,
0x04, 0x3e, 0x10, 0x00,
0x00, 0xc1, 0x00, 0x00,
0x01, 0x00, 0xc0, 0x00,
0x01, 0x36, 0x40, 0x00,
0x01, 0x43, 0x80, 0x00,
0x00, 0x80, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x1c, 0x00, 0x00,
0x00, 0x04, 0x00, 0x00,
0x00, 0x10, 0x00, 0x00,
0x00, 0x08, 0x00, 0x00
};
static const uint8_t WiFi4[] PROGMEM = {
0x00, 0xff, 0x80, 0x00,
0x03, 0xff, 0xe0, 0x00,
0x0f, 0xff, 0xf8, 0x00,
0x1f, 0xff, 0xfc, 0x00,
0x3f, 0xc1, 0xfe, 0x00,
0x7e, 0x00, 0x3f, 0x80,
0xfc, 0x00, 0x0f, 0x80,
0xf0, 0x7f, 0x07, 0x80,
0x61, 0xff, 0xc3, 0x80,
0x63, 0xff, 0xe1, 0x00,
0x07, 0xff, 0xf0, 0x00,
0x0f, 0xc0, 0xf8, 0x00,
0x0f, 0x00, 0x7c, 0x00,
0x0e, 0x00, 0x38, 0x00,
0x04, 0x3e, 0x08, 0x00,
0x00, 0x7f, 0x80, 0x00,
0x01, 0xff, 0xc0, 0x00,
0x01, 0xff, 0xc0, 0x00,
0x00, 0xe1, 0xc0, 0x00,
0x00, 0x80, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x1c, 0x00, 0x00,
0x00, 0x1e, 0x00, 0x00,
0x00, 0x1c, 0x00, 0x00,
0x00, 0x08, 0x00, 0x00
}; };
static const uint16_t pe5pvblogo[] PROGMEM = { static const uint16_t pe5pvblogo[] PROGMEM = {