Show battery value or percent
This commit is contained in:
+91
-2
@@ -108,6 +108,8 @@ byte bandFM;
|
||||
byte bandforbidden;
|
||||
byte battery;
|
||||
byte batteryold;
|
||||
byte batteryoptions;
|
||||
byte batteryoptionsold;
|
||||
byte BWset;
|
||||
#ifdef CHINA_PORTABLE
|
||||
byte hardwaremodel = PORTABLE_ILI9341;
|
||||
@@ -220,6 +222,10 @@ int16_t SStatus;
|
||||
int8_t LevelOffset;
|
||||
int8_t LowLevelSet;
|
||||
int8_t VolSet;
|
||||
int vref = 1056;
|
||||
float batteryV;
|
||||
float batteryVold;
|
||||
float batteryPold;
|
||||
IPAddress remoteip;
|
||||
String afstringold;
|
||||
String cryptedpassword;
|
||||
@@ -383,6 +389,7 @@ void setup() {
|
||||
unit = EEPROM.readByte(EE_BYTE_UNIT);
|
||||
af = EEPROM.readByte(EE_BYTE_AF);
|
||||
StereoToggle = EEPROM.readByte(EE_BYTE_STEREO);
|
||||
batteryoptions = EEPROM.readByte(EE_BYTE_BATTERY_OPTIONS);
|
||||
|
||||
LWLowEdgeSet = FREQ_LW_LOW_EDGE_MIN; // later will read from flash
|
||||
LWHighEdgeSet = FREQ_LW_HIGH_EDGE_MAX; // later will read from flash
|
||||
@@ -1816,6 +1823,7 @@ void ModeButtonPress() {
|
||||
EEPROM.writeByte(EE_BYTE_UNIT, unit);
|
||||
EEPROM.writeByte(EE_BYTE_AF, af);
|
||||
EEPROM.writeByte(EE_BYTE_STEREO, StereoToggle);
|
||||
EEPROM.writeByte(EE_BYTE_BATTERY_OPTIONS, batteryoptions);
|
||||
EEPROM.commit();
|
||||
Serial.end();
|
||||
if (wifi) remoteip = IPAddress (WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient);
|
||||
@@ -2278,8 +2286,19 @@ void ButtonPress() {
|
||||
}
|
||||
hardwaremodelold = hardwaremodel;
|
||||
break;
|
||||
|
||||
case 50:
|
||||
tftPrint(0, myLanguage[language][173], 155, 78, ActiveColor, ActiveColorSmooth, FONT28);
|
||||
switch (batteryoptions) {
|
||||
case BATTERY_NONE: tftPrint(0, myLanguage[language][30], 155, 118, PrimaryColor, PrimaryColorSmooth, FONT28); break;
|
||||
case BATTERY_VALUE: tftPrint(0, myLanguage[language][174], 155, 118, PrimaryColor, PrimaryColorSmooth, FONT28); break;
|
||||
case BATTERY_PERCENT: tftPrint(0, myLanguage[language][175], 155, 118, PrimaryColor, PrimaryColorSmooth, FONT28); break;
|
||||
}
|
||||
batteryoptionsold = batteryoptions;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
if (menupage == 2 && menuoption == 190 && wifi == true) {
|
||||
@@ -2707,6 +2726,25 @@ void KeyUp() {
|
||||
}
|
||||
hardwaremodelold = hardwaremodel;
|
||||
break;
|
||||
|
||||
case 50:
|
||||
switch (batteryoptionsold) {
|
||||
case BATTERY_NONE: tftPrint(0, myLanguage[language][30], 155, 118, BackgroundColor, BackgroundColor, FONT28); break;
|
||||
case BATTERY_VALUE: tftPrint(0, myLanguage[language][174], 155, 118, BackgroundColor, BackgroundColor, FONT28); break;
|
||||
case BATTERY_PERCENT: tftPrint(0, myLanguage[language][175], 155, 118, BackgroundColor, BackgroundColor, FONT28); break;
|
||||
}
|
||||
|
||||
batteryoptions++;
|
||||
if (batteryoptions > RADIO_BATTERY_CNT - 1) batteryoptions = 0;
|
||||
|
||||
switch (batteryoptions) {
|
||||
case BATTERY_NONE: tftPrint(0, myLanguage[language][30], 155, 118, PrimaryColor, PrimaryColorSmooth, FONT28); break;
|
||||
case BATTERY_VALUE: tftPrint(0, myLanguage[language][174], 155, 118, PrimaryColor, PrimaryColorSmooth, FONT28); break;
|
||||
case BATTERY_PERCENT: tftPrint(0, myLanguage[language][175], 155, 118, PrimaryColor, PrimaryColorSmooth, FONT28); break;
|
||||
}
|
||||
batteryoptionsold = batteryoptions;
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3125,6 +3163,24 @@ void KeyDown() {
|
||||
}
|
||||
hardwaremodelold = hardwaremodel;
|
||||
break;
|
||||
|
||||
case 50:
|
||||
switch (batteryoptionsold) {
|
||||
case BATTERY_NONE: tftPrint(0, myLanguage[language][30], 155, 118, BackgroundColor, BackgroundColor, FONT28); break;
|
||||
case BATTERY_VALUE: tftPrint(0, myLanguage[language][174], 155, 118, BackgroundColor, BackgroundColor, FONT28); break;
|
||||
case BATTERY_PERCENT: tftPrint(0, myLanguage[language][175], 155, 118, BackgroundColor, BackgroundColor, FONT28); break;
|
||||
}
|
||||
|
||||
batteryoptions--;
|
||||
if (batteryoptions > RADIO_BATTERY_CNT - 1) batteryoptions = RADIO_BATTERY_CNT - 1;
|
||||
|
||||
switch (batteryoptions) {
|
||||
case BATTERY_NONE: tftPrint(0, myLanguage[language][30], 155, 118, PrimaryColor, PrimaryColorSmooth, FONT28); break;
|
||||
case BATTERY_VALUE: tftPrint(0, myLanguage[language][174], 155, 118, PrimaryColor, PrimaryColorSmooth, FONT28); break;
|
||||
case BATTERY_PERCENT: tftPrint(0, myLanguage[language][175], 155, 118, PrimaryColor, PrimaryColorSmooth, FONT28); break;
|
||||
}
|
||||
batteryoptionsold = batteryoptions;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3873,12 +3929,18 @@ void BuildMenu() {
|
||||
|
||||
case 5:
|
||||
tftPrint(-1, myLanguage[language][108], 14, 36, ActiveColor, ActiveColorSmooth, FONT16);
|
||||
tftPrint(-1, myLanguage[language][173], 14, 56, ActiveColor, ActiveColorSmooth, FONT16);
|
||||
|
||||
switch (hardwaremodel) {
|
||||
case BASE_ILI9341: tftPrint(1, myLanguage[language][109], 305, 36, PrimaryColor, PrimaryColorSmooth, FONT16); break;
|
||||
case PORTABLE_ILI9341: tftPrint(1, myLanguage[language][110 ], 305, 36, PrimaryColor, PrimaryColorSmooth, FONT16); break;
|
||||
case PORTABLE_TOUCH_ILI9341: tftPrint(1, myLanguage[language][111], 305, 36, PrimaryColor, PrimaryColorSmooth, FONT16); break;
|
||||
}
|
||||
switch (batteryoptions) {
|
||||
case BATTERY_NONE: tftPrint(1, myLanguage[language][30], 305, 56, PrimaryColor, PrimaryColorSmooth, FONT16); break;
|
||||
case BATTERY_VALUE: tftPrint(1, myLanguage[language][174], 305, 56, PrimaryColor, PrimaryColorSmooth, FONT16); break;
|
||||
case BATTERY_PERCENT: tftPrint(1, myLanguage[language][175], 305, 56, PrimaryColor, PrimaryColorSmooth, FONT16); break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -4166,7 +4228,7 @@ void BuildDisplay() {
|
||||
}
|
||||
}
|
||||
if (showsquelch) tftPrint(-1, "SQ:", 212, 145, ActiveColor, ActiveColorSmooth, FONT16);
|
||||
tftPrint(1, "C/N", 265, 163, ActiveColor, ActiveColorSmooth, FONT16);
|
||||
tftPrint(1, "C/N", 270, 163, ActiveColor, ActiveColorSmooth, FONT16);
|
||||
tftPrint(-1, "dB", 300, 163, ActiveColor, ActiveColorSmooth, FONT16);
|
||||
if (region == 0) tftPrint(-1, "PI:", 216, 193, ActiveColor, ActiveColorSmooth, FONT16);
|
||||
if (region == 1) tftPrint(-1, "ID:", 216, 193, ActiveColor, ActiveColorSmooth, FONT16);
|
||||
@@ -4999,7 +5061,9 @@ void ShowBattery() {
|
||||
return;
|
||||
}
|
||||
|
||||
battery = map(constrain(analogRead(BATTERY_PIN), BAT_LEVEL_EMPTY, BAT_LEVEL_FULL), BAT_LEVEL_EMPTY, BAT_LEVEL_FULL, 0, BAT_LEVEL_STAGE);
|
||||
uint16_t v = analogRead(BATTERY_PIN);
|
||||
|
||||
battery = map(constrain(v, BAT_LEVEL_EMPTY, BAT_LEVEL_FULL), BAT_LEVEL_EMPTY, BAT_LEVEL_FULL, 0, BAT_LEVEL_STAGE);
|
||||
if (batteryold != battery) {
|
||||
if (batterydetect) {
|
||||
if (battery == 0) {
|
||||
@@ -5020,6 +5084,30 @@ void ShowBattery() {
|
||||
}
|
||||
batteryold = battery;
|
||||
}
|
||||
|
||||
if (batteryoptions > BATTERY_NONE) {
|
||||
batteryV = ((float)v / 4095.0) * 2.0 * 3.3 * (vref / 1000.0);
|
||||
if (batteryoptions == BATTERY_VALUE){
|
||||
if (batteryV < BATTERY_LOW_VALUE) return;
|
||||
|
||||
tftPrint(-1, String(batteryVold,1), 213, 163, BackgroundColor, BackgroundColor, FONT16);
|
||||
|
||||
tftPrint(-1, String(batteryV,1), 213, 163, PrimaryColor, PrimaryColorSmooth, FONT16);
|
||||
tftPrint(-1, "V", 232, 163, PrimaryColor, PrimaryColorSmooth, FONT16);
|
||||
batteryVold = batteryV;
|
||||
} else if (batteryoptions == BATTERY_PERCENT) {
|
||||
float vPer = 0.0;
|
||||
vPer = (batteryPold - BATTERY_LOW_VALUE)/(BATTERY_FULL_VALUE - BATTERY_LOW_VALUE);
|
||||
if (vPer >= 1) vPer = 1;
|
||||
tftPrint(-1, String(vPer * 100, 0), 213, 163, BackgroundColor, BackgroundColor, FONT16);
|
||||
|
||||
vPer = (batteryV - BATTERY_LOW_VALUE)/(BATTERY_FULL_VALUE - BATTERY_LOW_VALUE);
|
||||
if (vPer >= 1) vPer = 1;
|
||||
tftPrint(-1, String(vPer * 100, 0), 213, 163, PrimaryColor, PrimaryColorSmooth, FONT16);
|
||||
tftPrint(-1, "%", 230, 163, PrimaryColor, PrimaryColorSmooth, FONT16);
|
||||
batteryPold = batteryV;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Communication() {
|
||||
@@ -6168,6 +6256,7 @@ void DefaultSettings(byte userhardwaremodel) {
|
||||
EEPROM.writeByte(EE_BYTE_UNIT, 0);
|
||||
EEPROM.writeByte(EE_BYTE_AF, 0);
|
||||
EEPROM.writeByte(EE_BYTE_STEREO, 1);
|
||||
EEPROM.writeByte(EE_BYTE_BATTERY_OPTIONS, BATTERY_VALUE);
|
||||
EEPROM.commit();
|
||||
}
|
||||
|
||||
|
||||
+3740
-3656
File diff suppressed because it is too large
Load Diff
+9873
-9652
File diff suppressed because it is too large
Load Diff
@@ -42,6 +42,11 @@ enum RADIO_HARDWARE_MODEL {
|
||||
RADIO_HARDWARE_CNT
|
||||
};
|
||||
|
||||
enum RADIO_BATTERY_SELECTION {
|
||||
BATTERY_NONE = 0, BATTERY_VALUE, BATTERY_PERCENT,
|
||||
RADIO_BATTERY_CNT
|
||||
};
|
||||
|
||||
static const char* const PTY_EU[] {
|
||||
"None",
|
||||
"News",
|
||||
|
||||
+7
-2
@@ -19,6 +19,10 @@
|
||||
#define BAT_LEVEL_WARN 1700
|
||||
#define BAT_LEVEL_FULL 2270
|
||||
#define BAT_LEVEL_STAGE 4
|
||||
#define BATTERY_WARN_VALUE 3.68
|
||||
#define BATTERY_LOW_VALUE 3.0
|
||||
#define BATTERY_FULL_VALUE 4.2
|
||||
|
||||
|
||||
#define LANGUAGE_CHS 14
|
||||
|
||||
@@ -97,9 +101,9 @@
|
||||
|
||||
// EEPROM index defines
|
||||
#define EE_PRESETS_CNT 30
|
||||
#define EE_CHECKBYTE_VALUE 36 // 0 ~ 255,add new entry, change for new value
|
||||
#define EE_CHECKBYTE_VALUE 32 // 0 ~ 255,add new entry, change for new value
|
||||
|
||||
#define EE_TOTAL_CNT 273
|
||||
#define EE_TOTAL_CNT 274
|
||||
#define EE_UINT16_FREQUENCY_FM 0
|
||||
#define EE_BYTE_VOLSET 4
|
||||
#define EE_BYTE_STEREO 5
|
||||
@@ -164,6 +168,7 @@
|
||||
#define EE_BYTE_UNIT 267
|
||||
#define EE_BYTE_AF 268
|
||||
#define EE_UINT16_FREQUENCY_OIRT 269
|
||||
#define EE_BYTE_BATTERY_OPTIONS 273
|
||||
// End of EEPROM index defines
|
||||
|
||||
static const char* const unitString[] = {"dBμV", "dBf", "dBm"};
|
||||
|
||||
+68
-17
@@ -1,6 +1,6 @@
|
||||
// [number of languages][number of texts][max. length of text]
|
||||
|
||||
static const char* const myLanguage[16][173] = {
|
||||
static const char* const myLanguage[16][176] = {
|
||||
{ "English", // English
|
||||
"Rotary direction changed", // 1
|
||||
"Please release button", // 2
|
||||
@@ -173,7 +173,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Nederlands", // Dutch
|
||||
@@ -348,7 +351,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Polski", // Polish
|
||||
@@ -523,7 +529,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Hrvatski", // Croatian
|
||||
@@ -698,7 +707,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Ελληνικά", // Greek
|
||||
@@ -873,7 +885,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Μανταρινί", // 170
|
||||
"Ωκεανός", // 171
|
||||
"Ινδικό" // 172
|
||||
"Ινδικό", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Romana", // Romanian
|
||||
@@ -1048,7 +1063,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Deutsch", // German
|
||||
@@ -1223,7 +1241,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Czech", // Czech
|
||||
@@ -1398,7 +1419,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Slovak", // Slovak
|
||||
@@ -1573,7 +1597,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Français", // French
|
||||
@@ -1748,7 +1775,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Mandarine", // 170
|
||||
"Océan", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Български", // Bulgarian
|
||||
@@ -1923,7 +1953,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Русский", // Russian
|
||||
@@ -2098,7 +2131,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Мандариновый", // 170
|
||||
"Океан", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Українська", // Ukranian
|
||||
@@ -2273,7 +2309,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Мандариновий", // 170
|
||||
"Океан", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Italiano", // Italian
|
||||
@@ -2448,7 +2487,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo" // 172
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
},
|
||||
|
||||
{ "Simplified Chinese", // Simplified Chinese
|
||||
@@ -2623,7 +2665,10 @@ static const char* const myLanguage[16][173] = {
|
||||
" ", // 169
|
||||
"桔红", // 170
|
||||
"海之蓝", // 171
|
||||
"Indigo" // 172
|
||||
"靛青", // 172
|
||||
"显示电池", // 173
|
||||
"电压值", // 174
|
||||
"电池百分比" // 175
|
||||
},
|
||||
|
||||
{ "Norsk", // Norwegian
|
||||
@@ -2795,7 +2840,13 @@ static const char* const myLanguage[16][173] = {
|
||||
"Identifikator", // 166
|
||||
"Kjøp", // 167
|
||||
"Få data", // 168
|
||||
"" // 169
|
||||
" ", // 169
|
||||
"Tangerine", // 170
|
||||
"Ocean", // 171
|
||||
"Indigo", // 172
|
||||
"Battery options", // 173
|
||||
"Show battery value", // 174
|
||||
"Show battery percent" // 175
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user