diff --git a/localization.h b/localization.h new file mode 100644 index 0000000..d5015a0 --- /dev/null +++ b/localization.h @@ -0,0 +1,140 @@ +#if defined(LANGUAGE_EN_US) + #define TXT_BACK "Back" + #define TXT_CLOCK "Clock" + #define TXT_SETTINGS "Settings" + #define TXT_NEVER "Never" + #define TXT_SEC "seconds" + #define TXT_MIN "minutes" + #define TXT_AUTO_DIM "SET AUTO DIM TIME" + #define TXT_SET_BRIGHT "SET BRIGHTNESS" + #define TXT_BATT_INFO "Battery Info" + #define TXT_BRIGHT "Brightness" + #define TXT_SET_CLOCK "Set Clock" + #define TXT_ROTATION "Rotation" + #define TXT_ABOUT "About" + #define TXT_REBOOT "Reboot" + #define TXT_CLR_SETTINGS "Clear Settings" + #define TXT_CLRING_SETTINGS "Restoring Default\nSettings..." + #define TXT_RIGHT "Right" + #define TXT_LEFT "Left" + #define TXT_BATT "Battery: " + #define TXT_EXIT "Press any button to exit" + #define TXT_RG_AMERICAS "Region:\nAmericas / Asia\n" + #define TXT_RG_EMEA "Region: EMEA" + #define TXT_SEL_GO_PAUSE "Select: Go/Pause" + #define TXT_SEL_EXIT "Next: Exit" + #define TXT_TRIG_TV "triggered TVBG" + #define TXT_MN_AMERICA "Americas / Asia" + #define TXT_MN_EMEA "EU/MidEast/Africa" + #define TXT_REGION "Region" + #define TXT_FK_GP "Front Key: Go/Pause" + #define TXT_SET_HOUR "SET HOUR" + #define TXT_SET_MIN "SET MINUTE" + #define TXT_ADV "Advertising:\n" + #define TXT_SP_RND "Swift Pair Random" + #define TXT_SEL_EXIT2 "\n\nNext: Exit" + #define TXT_BT_SPAM "BT Spam" + #define TXT_SA_CRASH "SourApple Crash" + #define TXT_CMB_BT_SPAM " Combined BT Spam" + #define TXT_AD_SPAM "Android Spam" + #define TXT_AJ_TRANSF_NM "Transfer Number" + #define TXT_AJ_TV_COLOR "TV Color Balance" + #define TXT_STP_NW_PH "Setup New Phone" + #define TXT_SA_ADV "SourApple Advertisement: " + #define TXT_SP_ADV "SwiftPair Advertisement: '%s' - " + #define TXT_AD_SPAM_ADV "Android Spam Advertisement: " + #define TXT_AJ_ADV "AppleJuice Advertisement: " + #define TXT_WF_SP "WiFi Spam" + #define TXT_RND_SSID " - Random SSIDs\n" + #define TXT_WF_SCAN "Scan Wifi" + #define TXT_WF_SPAM_FUN "Spam Funny" + #define TXT_WF_SPAM_RR "Spam Rickroll" + #define TXT_WF_SPAM_RND "Spam Random" + #define TXT_WF_RESCAN "[RESCAN]" + #define TXT_WF_OPEN "Open" + #define TXT_WF_CHANN "Chan : %d\n" + #define TXT_WF_CRYPT "Crypt: %s\n" + #define TXT_SEL_BACK "\nNext: Back\n" + #define TXT_HOLD_CLONE "Hold Select: Clone\n" + #define TXT_WF_SCN "WiFi Scan" + #define TXT_WF_SCNING "Scanning..." + #define TXT_INST_NXT "Next: Down Arrow" + #define TXT_INST_PRV "Prev: Up Arrow" + #define TXT_INST_SEL "Sel : Enter or ->" + #define TXT_INST_HOME "Home: Esc or <- " + #define TXT_INST_PRSS_KEY " Press a key" + #define TXT_STK_NXT "Next: Side Button" + #define TXT_STK_SEL "Sel : M5 Button" + #define TXT_STK_HOME "Home: Power Button" + +#endif + +#if defined(LANGUAGE_PT_BR) + #define TXT_BACK "Voltar" + #define TXT_CLOCK "Relogio" + #define TXT_SETTINGS "Configuracoes" + #define TXT_NEVER "Nunca" + #define TXT_SEC "segundos" + #define TXT_MIN "minutos" + #define TXT_AUTO_DIM "AJUSTAR LUZ DE FUNDO" + #define TXT_SET_BRIGHT "BRILHO DA TELA" + #define TXT_BATT_INFO "Estado da Bateria" + #define TXT_BRIGHT "Brilho" + #define TXT_SET_CLOCK "Ajustar Relogio" + #define TXT_ROTATION "Rotacao" + #define TXT_ABOUT "Sobre" + #define TXT_REBOOT "Reiniciar M5" + #define TXT_CLR_SETTINGS "Resetar Ajustes" + #define TXT_CLRING_SETTINGS "Aplicando Ajustes\nPadrao..." + #define TXT_RIGHT "Direita" + #define TXT_LEFT "Esquerda" + #define TXT_BATT "Bateria: " + #define TXT_EXIT "Pressione qualquer botao para sair" + #define TXT_RG_AMERICAS "Regiao:\nAmericas / Asia\n" + #define TXT_RG_EMEA "Regiao: EMEA" + #define TXT_SEL_GO_PAUSE "Ok: Iniciar/Parar" + #define TXT_SEL_EXIT "Seta 'v' : Sair" + #define TXT_TRIG_TV "TVBG em funcionamento..." + #define TXT_MN_AMERICA "Americas/Asia" + #define TXT_MN_EMEA "EU/MidEast/Africa" + #define TXT_REGION "Regiao" + #define TXT_FK_GP "Botao Frontal:Iniciar/Pausar" + #define TXT_SET_HOUR "AJUSTAR HORA" + #define TXT_SET_MIN "AJUSTAR MINUTO" + #define TXT_ADV "Aviso:\n" + #define TXT_SP_RND "Swift Pair Aleatorio" + #define TXT_SEL_EXIT2 "\n\nProx: Sair" + #define TXT_BT_SPAM "Bluetooth Spam" + #define TXT_SA_CRASH "SourApple Crash" + #define TXT_CMB_BT_SPAM "BT Spam Combinado" + #define TXT_AD_SPAM "Android Spam" + #define TXT_AJ_TRANSF_NM "Transferir Numero" + #define TXT_AJ_TV_COLOR "Balanco de Cor TV" + #define TXT_STP_NW_PH "Novo Aparelho" + #define TXT_SA_ADV "Aviso SourApple: " + #define TXT_SP_ADV "Aviso SwiftPair: '%s' - " + #define TXT_AD_SPAM_ADV "Aviso Android Spam: " + #define TXT_AJ_ADV "Aviso AppleJuice: " + #define TXT_WF_SP "WiFi Spam" + #define TXT_RND_SSID " - SSIDs Aleatorios\n" + #define TXT_WF_SCAN "Escanear Wifi" + #define TXT_WF_SPAM_FUN "Spam Engracado" + #define TXT_WF_SPAM_RR "Spam Rickroll" + #define TXT_WF_SPAM_RND "Spam Aleatorio" + #define TXT_WF_RESCAN "[RESCANEAR]" + #define TXT_WF_OPEN "Aberto" + #define TXT_WF_CHANN "Canal: %d\n" + #define TXT_WF_CRYPT "Cripto: %s\n" + #define TXT_SEL_BACK "\nProx: Voltar\n" + #define TXT_HOLD_CLONE "Segurar Ok: Clonar\n" + #define TXT_WF_SCN "Escanear \n Wifi" + #define TXT_WF_SCNING "Escaneando..." + #define TXT_INST_NXT "Prox: Seta v" + #define TXT_INST_PRV "Anterior: Seta ^" + #define TXT_INST_SEL "Sel : Ok ou Seta >" + #define TXT_INST_HOME "Home: Esc ou Seta <" + #define TXT_INST_PRSS_KEY "Pressione uma tecla" + #define TXT_STK_NXT "Prox: Botao do Lado" + #define TXT_STK_SEL "Sel : Botao M5" + #define TXT_STK_HOME "Home: Botao Power" +#endif \ No newline at end of file diff --git a/m5stick-nemo.ino b/m5stick-nemo.ino index fc32c1d..fe6f846 100644 --- a/m5stick-nemo.ino +++ b/m5stick-nemo.ino @@ -13,8 +13,8 @@ String buildver="2.3.3"; #define FGCOLOR GREEN // -=-=- NEMO Portal Language -=- Thanks, @marivaaldo! -=-=- -#define LANGUAGE_EN_US -//#define LANGUAGE_PT_BR +//define LANGUAGE_EN_US +#define LANGUAGE_PT_BR #if defined(STICK_C_PLUS) #include @@ -118,6 +118,7 @@ String buildver="2.3.3"; #define SD_MISO_PIN 39 #define SD_MOSI_PIN 14 #define SD_CS_PIN 12 + #define VBAT_PIN 10 #endif // -=-=-=-=-=- LIST OF CURRENTLY DEFINED FEATURES -=-=-=-=-=- @@ -191,6 +192,8 @@ bool isSwitching = true; #include "sd.h" #include "portal.h" #include "NEMOMatrix.h" +#include "songs.h" +#include "localization.h" #include #include @@ -205,7 +208,7 @@ struct QRCODE { }; QRCODE qrcodes[] = { - { "Back", "" }, + { TXT_BACK, "" }, { "Rickroll", "https://youtu.be/dQw4w9WgXcQ"}, { "HackerTyper", "https://hackertyper.net/"}, { "ZomboCom", "https://html5zombo.com/"}, @@ -328,13 +331,13 @@ bool check_select_press(){ /// MAIN MENU /// MENU mmenu[] = { #if defined(RTC) - { "Clock", 0}, + { TXT_CLOCK, 0}, #endif { "TV-B-Gone", 13}, // We jump to the region menu first { "Bluetooth", 16}, { "WiFi", 12}, { "QR Codes", 18}, - { "Settings", 2}, + { TXT_SETTINGS, 2}, }; int mmenu_size = sizeof(mmenu) / sizeof(MENU); @@ -397,22 +400,22 @@ void screen_dim_proc() { /// Dimmer MENU /// MENU dmenu[] = { - { "Back", screen_dim_time}, - { "Never", 0}, - { "5 seconds", 5}, - { "10 seconds", 10}, - { "15 seconds", 15}, - { "30 seconds", 30}, - { "1 minute", 60}, - { "2 minutes", 120}, - { "4 minutes", 240}, + { TXT_BACK, screen_dim_time}, + { TXT_NEVER, 0}, + { ("5 " TXT_SEC), 5}, + { ("10 " TXT_SEC), 10}, + { ("15 " TXT_SEC), 15}, + { ("30 " TXT_SEC), 30}, + { ("60 " TXT_SEC), 60}, + { ("120 " TXT_MIN), 120}, + { ("240 " TXT_MIN), 240}, }; int dmenu_size = sizeof(dmenu) / sizeof(MENU); void dmenu_setup() { DISP.fillScreen(BGCOLOR); DISP.setCursor(0, 5, 1); - DISP.println("SET AUTO DIM TIME"); + DISP.println(String(TXT_AUTO_DIM)); delay(1000); cursor = 0; rstOverride = true; @@ -435,7 +438,7 @@ void dmenu_loop() { #endif DISP.fillScreen(BGCOLOR); DISP.setCursor(0, 5, 1); - DISP.println("SET BRIGHTNESS"); + DISP.println(String(TXT_SET_BRIGHT)); delay(1000); cursor = brightness / 10; number_drawmenu(11); @@ -461,24 +464,26 @@ void dmenu_loop() { /// SETTINGS MENU /// MENU smenu[] = { - { "Back", 1}, + { TXT_BACK, 1}, #if defined(AXP) - { "Battery Info", 6}, + { TXT_BATT_INFO, 6}, #endif - { "Brightness", 4}, +#if defined(CARDPUTER) + { TXT_BATT_INFO, 6}, +#endif + { TXT_BRIGHT, 4}, #if defined(RTC) - { "Set Clock", 3}, + { TXT_SET_CLOCK, 3}, #endif #if defined(ROTATION) - { "Rotation", 7}, + { XT_ROTATION, 7}, #endif - { "About", 10}, - { "Reboot", 98}, + { TXT_ABOUT, 10}, + { TXT_REBOOT, 98}, #if defined(USE_EEPROM) - { "Clear Settings", 99}, + { TXT_CLR_SETTINGS, 99}, #endif -}; -int smenu_size = sizeof(smenu) / sizeof (MENU); +};int smenu_size = sizeof(smenu) / sizeof (MENU); void smenu_setup() { cursor = 0; @@ -503,7 +508,7 @@ void clearSettings(){ DISP.println("M5-NEMO"); DISP.setTextColor(WHITE, BLUE); DISP.setTextSize(SMALL_TEXT); - DISP.println("Restoring Default\nSettings..."); + DISP.println(TXT_CLRING_SETTINGS); delay(5000); ESP.restart(); } @@ -532,9 +537,9 @@ int rotation = 1; #if defined(ROTATION) /// Rotation MENU /// MENU rmenu[] = { - { "Back", rotation}, - { "Right", 1}, - { "Left", 3}, + { TXT_BACK, rotation}, + { TXT_RIGHT, 1}, + { TXT_LEFT, 3}, }; int rmenu_size = sizeof(rmenu) / sizeof (MENU); @@ -573,7 +578,7 @@ int rotation = 1; DISP.setTextSize(SMALL_TEXT); DISP.fillScreen(BGCOLOR); DISP.setCursor(0, 8, 1); - DISP.print("Battery: "); + DISP.print(TXT_BATT); DISP.print(battery); DISP.println("%"); DISP.print("DeltaB: "); @@ -581,7 +586,7 @@ int rotation = 1; DISP.print("DeltaC: "); DISP.println(c); DISP.println(""); - DISP.println("Press any button to exit"); + DISP.println(TXT_EXIT); } void battery_setup() { rstOverride = false; @@ -609,6 +614,51 @@ int rotation = 1; } #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 /// void tvbgone_setup() { DISP.fillScreen(BGCOLOR); @@ -622,13 +672,13 @@ void tvbgone_setup() { delay_ten_us(5000); if(region == NA) { - DISP.print("Region:\nAmericas / Asia\n"); + DISP.print(TXT_RG_AMERICAS); } else { - DISP.println("Region: EMEA"); + DISP.println(TXT_RG_EMEA); } - DISP.println("Select: Go/Pause"); - DISP.println("Next: Exit"); + DISP.println(TXT_SEL_GO_PAUSE); + DISP.println(TXT_SEL_EXIT); delay(1000); } @@ -636,16 +686,16 @@ void tvbgone_loop() { if (check_select_press()) { delay(250); - Serial.println("triggered TVBG"); + Serial.println(TXT_TRIG_TV); sendAllCodes(); } } /// TVBG-Region MENU /// MENU tvbgmenu[] = { - { "Back", 3}, - { "Americas / Asia", 0}, - { "EU/MidEast/Africa", 1}, + { TXT_BACK, 3}, + { TXT_MN_AMERICA, 0}, + { TXT_MN_EMEA, 1}, }; int tvbgmenu_size = sizeof(tvbgmenu) / sizeof (MENU); @@ -655,7 +705,7 @@ void tvbgmenu_setup() { DISP.setCursor(5, 1); DISP.println("TV-B-Gone"); DISP.setTextSize(MEDIUM_TEXT); - DISP.println("Region"); + DISP.println(TXT_REGION); cursor = region % 2; rstOverride = true; delay(1000); @@ -711,7 +761,7 @@ void sendAllCodes() { DISP.setCursor(5, 1); DISP.println("TV-B-Gone"); DISP.setTextSize(SMALL_TEXT); - DISP.println("Front Key: Go/Pause"); + DISP.println(TXT_FK_GP); const uint8_t bitcompression = powerCode->bitcompression; code_ptr = 0; for (uint8_t k = 0; k < numpairs; k++) { @@ -766,8 +816,8 @@ void sendAllCodes() { DISP.setCursor(5, 1); DISP.println("TV-B-Gone"); DISP.setTextSize(SMALL_TEXT); - DISP.println("Select: Go/Pause"); - DISP.println("Next: Exit"); + DISP.println(TXT_SEL_GO_PAUSE); + DISP.println(TXT_SEL_EXIT); } /// CLOCK /// @@ -791,7 +841,7 @@ void sendAllCodes() { rstOverride = true; DISP.fillScreen(BGCOLOR); DISP.setCursor(0, 5, 1); - DISP.println("SET HOUR"); + DISP.println(TXT_SET_HOUR); delay(2000); } @@ -810,7 +860,7 @@ void sendAllCodes() { int hour = cursor; DISP.fillScreen(BGCOLOR); DISP.setCursor(0, 5, 1); - DISP.println("SET MINUTE"); + DISP.println(TXT_SET_MIN); delay(2000); cursor = M5.Rtc.Minute; number_drawmenu(60); @@ -841,11 +891,11 @@ void sendAllCodes() { /// Bluetooth Spamming /// /// BTSPAM MENU /// MENU btmenu[] = { - { "Back", 5}, + { TXT_BACK, 5}, { "AppleJuice", 0}, { "Swift Pair", 1}, { "Android Spam", 4}, - { "SourApple Crash", 2}, + { TXT_SA_CRASH, 2}, { "BT Maelstrom", 3}, }; int btmenu_size = sizeof(btmenu) / sizeof (MENU); @@ -873,9 +923,9 @@ void btmenu_loop() { DISP.fillScreen(BGCOLOR); DISP.setTextSize(MEDIUM_TEXT); DISP.setCursor(5, 1); - DISP.println("BT Spam"); + DISP.println(TXT_BT_SPAM); DISP.setTextSize(SMALL_TEXT); - DISP.print("Advertising:\n"); + DISP.print(TXT_ADV); switch(option) { case 0: @@ -889,32 +939,32 @@ void btmenu_loop() { current_proc = 9; // jump straight to appleJuice Advertisement rstOverride = false; isSwitching = true; - DISP.print("Swift Pair Random"); - DISP.print("\n\nNext: Exit"); + DISP.print(TXT_SP_RND); + DISP.print(TXT_SEL_EXIT2); break; case 2: sourApple = true; current_proc = 9; // jump straight to appleJuice Advertisement rstOverride = false; isSwitching = true; - DISP.print("SourApple Crash"); - DISP.print("\n\nNext: Exit"); + DISP.print(TXT_SA_CRASH); + DISP.print(TXT_SEL_EXIT2); break; case 3: rstOverride = false; isSwitching = true; current_proc = 17; // Maelstrom DISP.print("Bluetooth Maelstrom\n"); - DISP.print(" Combined BT Spam"); - DISP.print("\n\nNext: Exit"); + DISP.print(TXT_CMB_BT_SPAM); + DISP.print(TXT_SEL_EXIT2); break; case 4: androidPair = true; current_proc = 9; // jump straight to appleJuice Advertisement rstOverride = false; isSwitching = true; - DISP.print("Android Spam"); - DISP.print("\n\nNext: Exit"); + DISP.print(TXT_AD_SPAM); + DISP.print(TXT_SEL_EXIT2); break; case 5: @@ -928,9 +978,9 @@ void btmenu_loop() { } MENU ajmenu[] = { - { "Back", 29}, + { TXT_BACK, 29}, { "AirPods", 1}, - { "Transfer Number", 27}, + { TXT_AJ_TRANSF_NM, 27}, { "AirPods Pro", 2}, { "AirPods Max", 3}, { "AirPods G2", 4}, @@ -955,8 +1005,8 @@ MENU ajmenu[] = { { "AppleTV HomeKit", 23}, { "AppleTV Keyboard", 24}, { "AppleTV Network", 25}, - { "TV Color Balance", 26}, - { "Setup New Phone", 28}, + { TXT_AJ_TV_COLOR, 26}, + { TXT_STP_NW_PH, 28}, }; int ajmenu_size = sizeof(ajmenu) / sizeof (MENU); @@ -1085,9 +1135,9 @@ void aj_loop(){ DISP.setCursor(5, 1); DISP.println("AppleJuice"); DISP.setTextSize(SMALL_TEXT); - DISP.print("Advertising:\n"); + DISP.print(TXT_ADV); DISP.print(ajmenu[cursor].name); - DISP.print("\n\nNext: Exit"); + DISP.print(TXT_SEL_EXIT2); isSwitching = true; current_proc = 9; // Jump over to the AppleJuice BLE beacon loop } @@ -1113,7 +1163,7 @@ void aj_adv(){ // It allows the BLE beacon to run through the loop. BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); if (sourApple){ - Serial.print("SourApple Advertisement: "); + Serial.print(TXT_SA_ADV); // Some code borrowed from RapierXbox/ESP32-Sour-Apple // Original credits for algorithm ECTO-1A & WillyJL uint8_t packet[17]; @@ -1141,7 +1191,7 @@ void aj_adv(){ Serial.println(""); } else if (swiftPair) { const char* display_name = generateRandomName(); - Serial.printf("SwiftPair Advertisement: '%s' - ", display_name); + Serial.printf(TXT_SP_ADV, display_name); uint8_t display_name_len = strlen(display_name); uint8_t size = 7 + display_name_len; uint8_t* packet = (uint8_t*)malloc(size); @@ -1166,7 +1216,7 @@ void aj_adv(){ free(packet); free((void*)display_name); } else if (androidPair) { - Serial.print("Android Spam Advertisement: "); + Serial.print(TXT_AD_SPAM_ADV); uint8_t packet[14]; uint8_t i = 0; packet[i++] = 3; // Packet Length @@ -1191,7 +1241,7 @@ void aj_adv(){ } Serial.println(""); } else { - Serial.print("AppleJuice Advertisement: "); + Serial.print(TXT_AJ_ADV); if (deviceType >= 18){ oAdvertisementData.addData(std::string((char*)data, sizeof(AppleTVPair))); } else { @@ -1284,12 +1334,12 @@ void wifispam_setup() { DISP.fillScreen(BGCOLOR); DISP.setTextSize(BIG_TEXT); DISP.setCursor(5, 1); - DISP.println("WiFi Spam"); + DISP.println(TXT_WF_SP); delay(1000); DISP.setTextSize(TINY_TEXT); DISP.fillScreen(BGCOLOR); DISP.setCursor(0, 0); - DISP.print("WiFi Spam"); + DISP.print(TXT_WF_SP); int ct = 0; const char *str; switch(spamtype) { @@ -1304,7 +1354,7 @@ void wifispam_setup() { DISP.print(rickrollssids); break; case 3: - DISP.printf(" - Random SSIDs\n", ct); + DISP.printf(TXT_RND_SSID, ct); break; } DISP.setTextSize(SMALL_TEXT); @@ -1380,11 +1430,11 @@ void btmaelstrom_loop(){ /// WIFI MENU /// MENU wsmenu[] = { - { "Back", 5}, - { "Scan Wifi", 0}, - { "Spam Funny", 1}, - { "Spam Rickroll", 2}, - { "Spam Random", 3}, + { TXT_BACK, 5}, + { TXT_WF_SCAN, 0}, + { TXT_WF_SPAM_FUN, 1}, + { TXT_WF_SPAM_RR, 2}, + { TXT_WF_SPAM_RND, 3}, { "NEMO Portal", 4}, }; int wsmenu_size = sizeof(wsmenu) / sizeof (MENU); @@ -1451,9 +1501,9 @@ void wscan_drawmenu() { } } DISP.print((cursor == wifict) ? ">" : " "); - DISP.println("[RESCAN]"); + DISP.println(TXT_WF_RESCAN); DISP.print((cursor == wifict + 1) ? ">" : " "); - DISP.println("Back"); + DISP.println(String(TXT_BACK)); } void wscan_result_setup() { @@ -1499,23 +1549,23 @@ void wscan_result_loop(){ encryptType = "WPA/WPA2/PSK"; break ; case 0: - encryptType = "Open"; + encryptType = TXT_WF_OPEN; break ; } - DISP.setTextSize(MEDIUM_TEXT); + DISP.setTextSize(SMALL_TEXT); if(WiFi.SSID(cursor).length() > 12){ - DISP.setTextSize(SMALL_TEXT); + DISP.setTextSize(TINY_TEXT); } DISP.fillScreen(BGCOLOR); DISP.setCursor(5, 1); DISP.println(WiFi.SSID(cursor)); - DISP.setTextSize(SMALL_TEXT); - DISP.printf("Chan : %d\n", WiFi.channel(cursor)); - DISP.printf("Crypt: %s\n", encryptType); + DISP.setTextSize(TINY_TEXT); + DISP.printf(TXT_WF_CHANN, WiFi.channel(cursor)); + DISP.printf(TXT_WF_CRYPT, encryptType); DISP.print("BSSID:\n" + WiFi.BSSIDstr(i)); - DISP.printf("\nNext: Back\n"); - DISP.printf("Hold Select: Clone\n"); + DISP.printf(TXT_SEL_BACK); + DISP.printf(TXT_HOLD_CLONE); if(check_select_press()){ apSsidName=WiFi.SSID(cursor); isSwitching=true; @@ -1530,7 +1580,7 @@ void wscan_setup(){ DISP.fillScreen(BGCOLOR); DISP.setTextSize(BIG_TEXT); DISP.setCursor(5, 1); - DISP.println("WiFi Scan"); + DISP.println(TXT_WF_SCN); delay(2000); } @@ -1538,7 +1588,7 @@ void wscan_loop(){ DISP.fillScreen(BGCOLOR); DISP.setTextSize(MEDIUM_TEXT); DISP.setCursor(5, 1); - DISP.println("Scanning..."); + DISP.println(TXT_WF_SCNING); wifict = WiFi.scanNetworks(); DISP.fillScreen(BGCOLOR); DISP.setTextSize(SMALL_TEXT); @@ -1551,6 +1601,7 @@ void wscan_loop(){ void bootScreen(){ // Boot Screen + setupSongs(); #ifndef STICK_C BITMAP; delay(3000); @@ -1563,11 +1614,12 @@ void bootScreen(){ DISP.setTextSize(SMALL_TEXT); DISP.printf("%s-%s\n",buildver,platformName); #if defined(CARDPUTER) - DISP.println("Next: Down Arrow"); - DISP.println("Prev: Up Arrow"); - DISP.println("Sel : Enter or ->"); - DISP.println("Home: Esc or <- "); - DISP.println(" Press a key"); + DISP.println(TXT_INST_NXT); + DISP.println(TXT_INST_PRV); + DISP.println(TXT_INST_SEL); + DISP.println(TXT_INST_HOME); + delay(1500); + DISP.println(TXT_INST_PRSS_KEY); while(true){ M5Cardputer.update(); if (M5Cardputer.Keyboard.isChange()) { @@ -1577,9 +1629,9 @@ void bootScreen(){ } } #else - DISP.println("Next: Side Button"); - DISP.println("Sel : M5 Button"); - DISP.println("Home: Power Button"); + DISP.println(TXT_STK_NXT); + DISP.println(TXT_STK_SEL); + DISP.println(TXT_STK_HOME); delay(3000); #endif } @@ -1761,6 +1813,11 @@ void loop() { battery_setup(); break; #endif +#if defined(CARDPUTER) + case 6: + battery_setup(); + break; +#endif #if defined(ROTATION) case 7: rmenu_setup(); @@ -1833,6 +1890,11 @@ void loop() { battery_loop(); break; #endif +#if defined(CARDPUTER) + case 6: + battery_loop(); + break; +#endif #if defined(ROTATION) case 7: rmenu_loop(); diff --git a/portal.h b/portal.h index 00073d8..3319600 100644 --- a/portal.h +++ b/portal.h @@ -25,7 +25,7 @@ #define LOGIN_PASSWORD_PLACEHOLDER "Senha" #define LOGIN_MESSAGE "Por favor, faça login para navegar de forma segura." #define LOGIN_BUTTON "Avançar" -#define LOGIN_AFTER_MESSAGE "Por favor, aguarde alguns minutos. Em breve você poderá acessar a internet." +#define LOGIN_AFTER_MESSAGE "Fazendo login..." #endif int totalCapturedCredentials = 0; @@ -227,7 +227,7 @@ void setupWebServer() { delay(50); SPEAKER.mute(); #elif defined(CARDPUTER) - SPEAKER.tone(4000, 50); + //SPEAKER.tone(4000, 50); //Silent mode, just in case #endif DISP.print("Victim Login"); #if defined(M5LED) diff --git a/songs.h b/songs.h new file mode 100644 index 0000000..4408466 --- /dev/null +++ b/songs.h @@ -0,0 +1,81 @@ +/* + Adapted by Milton Matuda to work with M5-NEMO. + You cand find a list of #define for other octaves at Robson's Github. + IG: @35mmatuda | https://github.com/Mmatuda +*/ +/* + Super Mario Bros - Overworld theme + More songs available at https://github.com/robsoncouto/arduino-songs + + Robson Couto, 2019 +*/ + +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define REST 0 + +// change this to make the song slower or faster +int tempo = 200; + +// notes of the melody followed by the duration. +// a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on +// !!negative numbers are used to represent dotted notes, +// so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! +int melody[] = { + + // Super Mario Bros theme + // Score available at https://musescore.com/user/2123/scores/2145 + // 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_G6,4, REST,4, +}; + +// sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) +// there are two values per note (pitch and duration), so for each note there are four bytes +int notes = sizeof(melody) / sizeof(melody[0]) / 2; + +// this calculates the duration of a whole note in ms +int wholenote = (60000 * 4) / tempo; + +int divider = 0, noteDuration = 0; + +void setupSongs() { + // iterate over the notes of the melody. + // Remember, the array is twice the number of notes (notes + durations) + for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { + + // calculates the duration of each note + divider = melody[thisNote + 1]; + if (divider > 0) { + // regular note, just proceed + noteDuration = (wholenote) / divider; + } else if (divider < 0) { + // dotted notes are represented with negative durations!! + noteDuration = (wholenote) / abs(divider); + noteDuration *= 1.5; // increases the duration in half for dotted notes + } +#if defined(STICK_C_PLUS) + SPEAKER.tone(4000); + delay(noteDuration * 0.9); + delay(noteDuration) + SPEAKER.mute(); +#elif defined(CARDPUTER) + // we only play the note for 90% of the duration, leaving 10% as a pause + SPEAKER.tone(melody[thisNote], noteDuration * 0.9); + // Wait for the specief duration before playing the next note. + delay(noteDuration); +#endif + + } +}