Skip to content

Commit

Permalink
BLE, checkEscPress, Boot
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorcelli committed May 15, 2024
1 parent 0fb40b6 commit 0f92c72
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 74 deletions.
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ build_flags =
-DWIDTH=240
-DHEIGHT=135
-DBACKLIGHT=27
-DMINBRIGHT=190
-DMINBRIGHT=80

-DLED=19
-DLED_ON=HIGH
Expand Down Expand Up @@ -174,7 +174,7 @@ build_flags =
-DWIDTH=240
-DHEIGHT=135
-DBACKLIGHT=38
-DMINBRIGHT=165
-DMINBRIGHT=80
-DMAX_MENU_SIZE=5

-DFP=1
Expand Down Expand Up @@ -287,7 +287,7 @@ build_flags =
-DLED_ON=HIGH
-DLED_OFF=LOW
-DBACKLIGHT=38
-DMINBRIGHT=165
-DMINBRIGHT=80
-DMAX_MENU_SIZE=5
-DUSER_SETUP_LOADED=1
-DST7789_2_DRIVER=1
Expand Down
10 changes: 3 additions & 7 deletions src/TV-B-Gone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,10 @@ void sendAllCodes()
displayRedStripe("Paused", TFT_WHITE, BGCOLOR);

while (!checkSelPress()){ // Se apertar Select denovo, continua
#ifndef CARDPUTER
if(checkPrevPress()) { // Cancela o TV-B-Gone
endingEarly = true;
break;
if(checkEscPress()) {
endingEarly= true;
break;
}
#else
if(Keyboard.isKeyPressed('`')) break;; // apertar ESC no Cardputer // Cancela o TV-B-Gone
#endif
}
while (checkSelPress()){
yield();
Expand Down
5 changes: 0 additions & 5 deletions src/ble_spam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,7 @@ void executeSourApple() {
NimBLEServer *pServer = NimBLEDevice::createServer();

pAdvertising = pServer->getAdvertising();
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_P9);
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P9);
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN ,ESP_PWR_LVL_P9);
delay(40);
//NimBLEAdvertisementData advertisementData = getOAdvertisementData();
NimBLEAdvertisementData advertisementData = GetUniversalAdvertisementData(Apple);
Expand All @@ -487,10 +485,7 @@ void executeSwiftpairSpam(EBLEPayloadType type) {
NimBLEDevice::init("");

NimBLEServer *pServer = NimBLEDevice::createServer();
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_P9);
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P9);
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN ,ESP_PWR_LVL_P9);

pAdvertising = pServer->getAdvertising();

//NimBLEAdvertisementData advertisementData = getSwiftAdvertisementData();
Expand Down
3 changes: 1 addition & 2 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ void loopOptions(const std::vector<std::pair<std::string, std::function<void()>>
}

#ifdef CARDPUTER
Keyboard.update();
if(Keyboard.isKeyPressed('`')) break;
if(checkEscPress()) break;
#endif
}
delay(200);
Expand Down
51 changes: 33 additions & 18 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,25 @@ void setup() {
#endif

getBrightness();
sprite.createSprite(WIDTH-15,HEIGHT-15);
//Start Bootscreen timer
int i = millis();
while(millis()<i+5000) { // boot image lasts for 5 secs
initDisplay(millis()-i); // show boot screen
setBrightness(0,false);
sprite.createSprite(WIDTH, HEIGHT);
menu_op.createSprite(WIDTH, HEIGHT);
sprite.drawXBitmap(1,1,bits, bits_width, bits_height,TFT_BLACK,TFT_WHITE);
menu_op.drawXBitmap(1,1,bits, bits_width, bits_height,TFT_BLACK,TFT_RED);
sprite.pushSprite(0,0);
while(millis()<i+10000) { // boot image lasts for 5 secs
if(millis()-i<4000) {
setBrightness((millis()-i)/40);
}
if((millis()-i>2000) && (millis()-i)<2500) tft.fillScreen(TFT_BLACK);
if((millis()-i>2500) && (millis()-i)<2700) sprite.pushSprite(0,0);
if((millis()-i>2700) && (millis()-i)<2900) tft.fillScreen(TFT_BLACK);
if((millis()-i>3100) && (millis()-i)<3300) sprite.pushSprite(0,0);
if((millis()-i>3300) && (millis()-i)<3700) tft.fillScreen(TFT_BLACK);
if((millis()-i>3700)) menu_op.pushSprite(0,0);


#if defined (CARDPUTER) // If any key is pressed, it'll jump the boot screen
Keyboard.update();
Expand All @@ -121,6 +135,10 @@ void setup() {

// If M5 or Enter button is pressed, continue from here
Program:
sprite.deleteSprite();
menu_op.deleteSprite();
sprite.createSprite(WIDTH-15,HEIGHT-15);
getBrightness();
delay(200);

}
Expand Down Expand Up @@ -171,7 +189,7 @@ void loop() {
};
} else {
options = {
{"Disconnect Wifi", [=]() { wifiDisconnect(); }}, //wifi_common.h
{"Disconnect", [=]() { wifiDisconnect(); }}, //wifi_common.h
};
}
options.push_back({"Wifi Atks", [=]() { wifi_atk_menu(); }});
Expand All @@ -181,11 +199,10 @@ void loop() {
options.push_back({"DPWO-ESP32", [=]() { dpwo_setup(); }});
options.push_back({"Evil Portal", [=]() { startEvilPortal(); }});
options.push_back({"ARP Scan", [=]() { local_scan_setup(); }});
options.push_back({"Wireguard Tun", [=]() { wg_setup(); }});
options.push_back({"Wireguard", [=]() { wg_setup(); }});
options.push_back({"Main Menu", [=]() { backToMenu(); }});
delay(200);
loopOptions(options,false,true,"WiFi");
// delay(1000); // remover depois, está aqui só por causa do "displayRedStripe"
break;
case 1: // BLE
options = {
Expand All @@ -199,7 +216,6 @@ void loop() {
};
delay(200);
loopOptions(options,false,true,"Bluetooth");
delay(1000); // remover depois, está aqui só por causa do "displayRedStripe"
break;
case 2: // RF
options = {
Expand All @@ -215,35 +231,33 @@ void loop() {
case 3: // RFID
options = {
{"Scan/copy", [=]() { rfid_setup(); }}, //@IncursioHack
{"Replay", [=]() { displayRedStripe("Replay"); }},
//{"Replay", [=]() { displayRedStripe("Replay"); }},
{"Main Menu", [=]() { backToMenu(); }},
};
delay(200);
loopOptions(options,false,true,"RFID");
//delay(1000); // remover depois, está aqui só por causa do "displayRedStripe"
break;
case 4: //Other
options = {
{"TV-B-Gone", [=]() { StartTvBGone(); }},
{"SD Card", [=]() { loopSD(); }},
{"WebUI", [=]() { loopOptionsWebUi(); }},
{"TV-B-Gone", [=]() { StartTvBGone(); }},
{"SD Card", [=]() { loopSD(); }},
{"WebUI", [=]() { loopOptionsWebUi(); }},
{"Megalodon", [=]() { shark_setup(); }},
};
if(sdcardMounted) options.push_back({"Custom IR", [=]() { otherIRcodes(); }});
#ifdef CARDPUTER
options.push_back({"BadUSB", [=]() { usb_setup(); }});
options.push_back({"LED Control", [=]() { ledrgb_setup(); }}); //IncursioHack
options.push_back({"LED FLash", [=]() { ledrgb_flash(); }}); // IncursioHack
options.push_back({"BadUSB", [=]() { usb_setup(); }});
options.push_back({"LED Control", [=]() { ledrgb_setup(); }}); //IncursioHack
options.push_back({"LED FLash", [=]() { ledrgb_flash(); }}); // IncursioHack
#endif
options.push_back({"Openhaystack", [=]() { openhaystack_setup(); }});
options.push_back({"Openhaystack", [=]() { openhaystack_setup(); }});
options.push_back({"Main Menu", [=]() { backToMenu(); }});
delay(200);
loopOptions(options,false,true,"Others");
delay(1000); // remover depois, está aqui só por causa do "displayRedStripe"
break;
case 5: //Config
options = {
{"Brightness", [=]() { setBrightnessMenu(); }}, //settings.h
{"Brightness", [=]() { setBrightnessMenu(); }}, //settings.h
{"Orientation", [=]() { gsetRotation(true); }}, //settings.h
{"Main Menu", [=]() { backToMenu(); }},
{"Restart", [=]() { ESP.restart(); }},
Expand All @@ -257,3 +271,4 @@ void loop() {
}
}
}

8 changes: 3 additions & 5 deletions src/mykeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ bool checkEscPress(){
Keyboard.update();
if(Keyboard.isKeyPressed('`'))
#endif
{
{
returnToMenu=true;


return true;
}
else { return false; }
}
else { return false; }
}

#ifndef STICK_C
Expand Down
10 changes: 1 addition & 9 deletions src/rfid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,10 @@ void rfid_loop() {
}
}
// Checks para sair do while
#ifndef CARDPUTER
if(checkPrevPress()) { // Apertar o botão power dos sticks
if(checkEscPress()) {
tft.fillScreen(BGCOLOR);
goto Exit;
}
#else
Keyboard.update();
if(Keyboard.isKeyPressed('`')) {
tft.fillScreen(BGCOLOR);
goto Exit;
} // apertar ESC no Cardputer
#endif

}
Exit:
Expand Down
3 changes: 1 addition & 2 deletions src/sd_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ String loopSD(bool filePicker) {
}

#ifdef CARDPUTER
Keyboard.update();
if(Keyboard.isKeyPressed('`')) break;
if(checkEscPress()) break;
#endif
}
return result;
Expand Down
14 changes: 3 additions & 11 deletions src/tururururu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,10 @@ void shark_loop() {
score++;
}

#ifndef CARDPUTER
if(checkPrevPress()) { // Apertar o botão power dos sticks
returnToMenu=true;
goto Exit;
if(checkEscPress()) {
returnToMenu=true;
goto Exit;
}
#else
Keyboard.update();
if(Keyboard.isKeyPressed('`')) {
returnToMenu=true;
goto Exit;
} // apertar ESC no Cardputer
#endif
}

Exit:
Expand Down
15 changes: 3 additions & 12 deletions src/wifi_atks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,14 @@ void target_atk(String tssid,String mac, uint8_t channel) {
while(checkSelPress()) { delay(50); } // timeless debounce
// wait to restart or kick out of the function
while(!checkSelPress()) {
#ifndef CARDPUTER
if(checkPrevPress()) break; // Apertar o botão power dos sticks
#else
Keyboard.update();
if(Keyboard.isKeyPressed('`')) break; // Apertar o ESC do cardputer
#endif
if(checkEscPress()) break;
}
while(checkSelPress()) { delay(50); } // timeless debounce
redraw=true;
}
// Checks para sair do while
#ifndef CARDPUTER
if(checkPrevPress()) break; // Apertar o botão power dos sticks
#else
Keyboard.update();
if(Keyboard.isKeyPressed('`')) break; // Apertar o ESC do cardputer
#endif
if(checkEscPress()) break;

}
wifiDisconnect();
returnToMenu=true;
Expand Down

0 comments on commit 0f92c72

Please sign in to comment.