Battery Info for Cardputer and PT-BR adjust

This commit is contained in:
Mmatuda 2024-01-14 03:47:46 -03:00
parent c0e247885d
commit b3329f1619
3 changed files with 66 additions and 12 deletions

View File

@ -89,7 +89,7 @@
#define TXT_RIGHT "Direita" #define TXT_RIGHT "Direita"
#define TXT_LEFT "Esquerda" #define TXT_LEFT "Esquerda"
#define TXT_BATT "Bateria: " #define TXT_BATT "Bateria: "
#define TXT_EXIT "Pressione qualquer botao para sair" #define TXT_EXIT "Pressione qualquer botao para sair"
#define TXT_RG_AMERICAS "Regiao:\nAmericas / Asia\n" #define TXT_RG_AMERICAS "Regiao:\nAmericas / Asia\n"
#define TXT_RG_EMEA "Regiao: EMEA" #define TXT_RG_EMEA "Regiao: EMEA"
#define TXT_SEL_GO_PAUSE "Ok: Iniciar/Parar" #define TXT_SEL_GO_PAUSE "Ok: Iniciar/Parar"
@ -127,7 +127,7 @@
#define TXT_WF_CRYPT "Cripto: %s\n" #define TXT_WF_CRYPT "Cripto: %s\n"
#define TXT_SEL_BACK "\nProx: Voltar\n" #define TXT_SEL_BACK "\nProx: Voltar\n"
#define TXT_HOLD_CLONE "Segurar Ok: Clonar\n" #define TXT_HOLD_CLONE "Segurar Ok: Clonar\n"
#define TXT_WF_SCN "WiFi Scanner" #define TXT_WF_SCN "Escanear \n Wifi"
#define TXT_WF_SCNING "Escaneando..." #define TXT_WF_SCNING "Escaneando..."
#define TXT_INST_NXT "Prox: Seta v" #define TXT_INST_NXT "Prox: Seta v"
#define TXT_INST_PRV "Anterior: Seta ^" #define TXT_INST_PRV "Anterior: Seta ^"

View File

@ -114,6 +114,7 @@ String buildver="2.3.3";
#define SD_MISO_PIN 39 #define SD_MISO_PIN 39
#define SD_MOSI_PIN 14 #define SD_MOSI_PIN 14
#define SD_CS_PIN 12 #define SD_CS_PIN 12
#define VBAT_PIN 10
#endif #endif
// -=-=-=-=-=- LIST OF CURRENTLY DEFINED FEATURES -=-=-=-=-=- // -=-=-=-=-=- LIST OF CURRENTLY DEFINED FEATURES -=-=-=-=-=-
@ -462,6 +463,9 @@ MENU smenu[] = {
{ TXT_BACK, 1}, { TXT_BACK, 1},
#if defined(AXP) #if defined(AXP)
{ TXT_BATT_INFO, 6}, { TXT_BATT_INFO, 6},
#endif
#if defined(CARDPUTER)
{ TXT_BATT_INFO, 6},
#endif #endif
{ TXT_BRIGHT, 4}, { TXT_BRIGHT, 4},
#if defined(RTC) #if defined(RTC)
@ -606,6 +610,51 @@ int rotation = 1;
} }
#endif // AXP #endif // AXP
#if defined(CARDPUTER)
/// BATTERY INFO ///
int oldbattery=0;
void battery_drawmenu(int battery) {
DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 8, 1);
DISP.print(TXT_BATT);
DISP.print(battery);
DISP.println("%");
DISP.println(TXT_EXIT);
}
void battery_setup() { //
rstOverride = false;
pinMode(VBAT_PIN, INPUT);
int battery = ((((analogRead(VBAT_PIN)) - 1842) * 100) / 738); //
int bat_ = analogRead(VBAT_PIN);
Serial.println("Battery level:");
Serial.println(battery);
battery_drawmenu(battery);
delay(500); // Prevent switching after menu loads up
/*
Used minimum 3,0V and maximum 4,2V for battery. So it may show wrong values. Needs testing.
It only shows decent values when disconnected from charger, due to HW limitations.
Equation: Bat% = ((Vadc - 1842) / (2580 - 1842)) * 100. Where: 4,2V = 2580, 3,0V = 1842.
*/
}
void battery_loop() {
delay(300);
int battery = ((((analogRead(VBAT_PIN)) - 1842) * 100) / 738);
if (battery != oldbattery){
Serial.println("Battery level:");
Serial.println(battery);
battery_drawmenu(battery);
}
if (check_select_press()) {
rstOverride = false;
isSwitching = true;
current_proc = 1;
}
oldbattery = battery;
}
#endif // Cardputer
/// TV-B-GONE /// /// TV-B-GONE ///
void tvbgone_setup() { void tvbgone_setup() {
DISP.fillScreen(BGCOLOR); DISP.fillScreen(BGCOLOR);
@ -1500,14 +1549,14 @@ void wscan_result_loop(){
break ; break ;
} }
DISP.setTextSize(MEDIUM_TEXT); DISP.setTextSize(SMALL_TEXT);
if(WiFi.SSID(cursor).length() > 12){ if(WiFi.SSID(cursor).length() > 12){
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(TINY_TEXT);
} }
DISP.fillScreen(BGCOLOR); DISP.fillScreen(BGCOLOR);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println(WiFi.SSID(cursor)); DISP.println(WiFi.SSID(cursor));
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(TINY_TEXT);
DISP.printf(TXT_WF_CHANN, WiFi.channel(cursor)); DISP.printf(TXT_WF_CHANN, WiFi.channel(cursor));
DISP.printf(TXT_WF_CRYPT, encryptType); DISP.printf(TXT_WF_CRYPT, encryptType);
DISP.print("BSSID:\n" + WiFi.BSSIDstr(i)); DISP.print("BSSID:\n" + WiFi.BSSIDstr(i));
@ -1550,7 +1599,6 @@ void bootScreen(){
// Boot Screen // Boot Screen
DISP.drawBmp(NEMOMatrix, 97338); DISP.drawBmp(NEMOMatrix, 97338);
setupSongs(); setupSongs();
delay(3000);
DISP.fillScreen(BGCOLOR); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(BIG_TEXT); DISP.setTextSize(BIG_TEXT);
DISP.setCursor(40, 0); DISP.setCursor(40, 0);
@ -1563,6 +1611,7 @@ void bootScreen(){
DISP.println(TXT_INST_PRV); DISP.println(TXT_INST_PRV);
DISP.println(TXT_INST_SEL); DISP.println(TXT_INST_SEL);
DISP.println(TXT_INST_HOME); DISP.println(TXT_INST_HOME);
delay(1500);
DISP.println(TXT_INST_PRSS_KEY); DISP.println(TXT_INST_PRSS_KEY);
while(true){ while(true){
M5Cardputer.update(); M5Cardputer.update();
@ -1757,6 +1806,11 @@ void loop() {
battery_setup(); battery_setup();
break; break;
#endif #endif
#if defined(CARDPUTER)
case 6:
battery_setup();
break;
#endif
#if defined(ROTATION) #if defined(ROTATION)
case 7: case 7:
rmenu_setup(); rmenu_setup();
@ -1829,6 +1883,11 @@ void loop() {
battery_loop(); battery_loop();
break; break;
#endif #endif
#if defined(CARDPUTER)
case 6:
battery_loop();
break;
#endif
#if defined(ROTATION) #if defined(ROTATION)
case 7: case 7:
rmenu_loop(); rmenu_loop();

View File

@ -27,10 +27,7 @@
// change this to make the song slower or faster // change this to make the song slower or faster
int tempo = 200; int tempo = 200;
// change this to whichever pin you want to use // notes of the melody followed by the duration.
int buzzer = 11;
// notes of the moledy followed by the duration.
// a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on
// !!negative numbers are used to represent dotted notes, // !!negative numbers are used to represent dotted notes,
// so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!!
@ -40,7 +37,6 @@ int melody[] = {
// Score available at https://musescore.com/user/2123/scores/2145 // Score available at https://musescore.com/user/2123/scores/2145
// Theme by Koji Kondo // Theme by Koji Kondo
NOTE_E6,8, NOTE_E6,8, REST,8, NOTE_E6,8, REST,8, NOTE_C6,8, NOTE_E6,8, //WRITE YOUR MELODY HERE NOTE_E6,8, NOTE_E6,8, REST,8, NOTE_E6,8, REST,8, NOTE_C6,8, NOTE_E6,8, //WRITE YOUR MELODY HERE
NOTE_G6,4, REST,4, NOTE_G6,4, REST,4,
}; };
@ -81,6 +77,5 @@ void setupSongs() {
delay(noteDuration); delay(noteDuration);
#endif #endif
} }
} }