Skip to content

Commit

Permalink
refactor main script and add IR menu
Browse files Browse the repository at this point in the history
  • Loading branch information
rennancockles committed Jul 24, 2024
1 parent 002024e commit 58e4756
Show file tree
Hide file tree
Showing 9 changed files with 737 additions and 604 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
Bruce3_Cardputer.bin
Bruce3_cplus1_1.bin
Bruce3_cplus2.bin
Bruce3_*.bin
_*.sh
9 changes: 6 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
~/.local/bin/esptool.py --chip esp32s3 merge_bin --output Bruce3_Cardputer.bin 0x0 .pio/build/m5stack-cardputer/bootloader.bin 0x8000 .pio/build/m5stack-cardputer/partitions.bin 0x10000 .pio/build/m5stack-cardputer/firmware.bin
~/.local/bin/esptool.py --chip esp32 merge_bin --output Bruce3_cplus2.bin 0x1000 .pio/build/m5stack-cplus2/bootloader.bin 0x8000 .pio/build/m5stack-cplus2/partitions.bin 0x10000 .pio/build/m5stack-cplus2/firmware.bin
~/.local/bin/esptool.py --chip esp32 merge_bin --output Bruce3_cplus1_1.bin 0x1000 .pio/build/m5stack-cplus1_1/bootloader.bin 0x8000 .pio/build/m5stack-cplus1_1/partitions.bin 0x10000 .pio/build/m5stack-cplus1_1/firmware.bin
ESPTOOL_PATH="$HOME/.local/bin"
ESPTOOL=$([[ -f $ESPTOOL_PATH/esptool.py ]] && echo "$ESPTOOL_PATH/esptool.py" || echo "$ESPTOOL_PATH/esptool")

$ESPTOOL --chip esp32s3 merge_bin --output Bruce3_Cardputer.bin 0x0 .pio/build/m5stack-cardputer/bootloader.bin 0x8000 .pio/build/m5stack-cardputer/partitions.bin 0x10000 .pio/build/m5stack-cardputer/firmware.bin
$ESPTOOL --chip esp32 merge_bin --output Bruce3_cplus2.bin 0x1000 .pio/build/m5stack-cplus2/bootloader.bin 0x8000 .pio/build/m5stack-cplus2/partitions.bin 0x10000 .pio/build/m5stack-cplus2/firmware.bin
$ESPTOOL --chip esp32 merge_bin --output Bruce3_cplus1_1.bin 0x1000 .pio/build/m5stack-cplus1_1/bootloader.bin 0x8000 .pio/build/m5stack-cplus1_1/partitions.bin 0x10000 .pio/build/m5stack-cplus1_1/firmware.bin
59 changes: 10 additions & 49 deletions src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,55 +244,6 @@ void drawMainBorder() {
drawBatteryStatus();
}

/***************************************************************************************
** Function name: drawMainMenu
** Description: Função para desenhar e mostrar o menu principal
***************************************************************************************/
void drawMainMenu(int index) {
const int border = 10;
const uint16_t colors[6] = {
static_cast<uint16_t>(FGCOLOR),
static_cast<uint16_t>(FGCOLOR),
static_cast<uint16_t>(FGCOLOR),
static_cast<uint16_t>(sdcardMounted ? FGCOLOR : TFT_DARKGREY),
static_cast<uint16_t>(FGCOLOR),
static_cast<uint16_t>(FGCOLOR)
};

const char* texts[6] = { "WiFi", "BLE", "RF", "RFID", "Others", "Config" };

drawMainBorder();
tft.setTextSize(FG);

switch(index) {
case 0:
drawWifi(80,27);
break;
case 1:
drawBLE(80,27);
break;
case 2:
drawRf(80,27);
break;
case 3:
drawRfid(80,27);
break;
case 4:
drawOther(80,27);
break;
case 5:
drawCfg(80,27);
break;
}
tft.setTextSize(FM);
tft.drawCentreString(texts[index],tft.width()/2, tft.height()-(LH*FM+10), SMOOTH_FONT);
tft.setTextSize(FG);
tft.drawChar('<',10,tft.height()/2+10);
tft.drawChar('>',tft.width()-(LW*FG+10),tft.height()/2+10);


}


/***************************************************************************************
** Function name: getBattery()
Expand Down Expand Up @@ -482,6 +433,16 @@ void drawRfid(int x, int y) {
tft.drawArc(15+x,65+y,38,35,180,270,FGCOLOR,BGCOLOR);
}

void drawIR(int x, int y) {
tft.fillRect(x,y,80,80,BGCOLOR);
tft.fillSmoothRoundRect(11+x,10+y,10,60,2,FGCOLOR,BGCOLOR);
tft.fillSmoothRoundRect(21+x,20+y,10,40,2,FGCOLOR,BGCOLOR);
tft.drawCircle(31+x,40+y,7,FGCOLOR);
tft.drawArc(31+x,40+y,18,15,220,320,FGCOLOR,BGCOLOR);
tft.drawArc(31+x,40+y,28,25,220,320,FGCOLOR,BGCOLOR);
tft.drawArc(31+x,40+y,38,35,220,320,FGCOLOR,BGCOLOR);
}

void drawOther(int x, int y) {
tft.fillRect(x,y,80,80,BGCOLOR);
tft.fillCircle(40+x,40+y,7,FGCOLOR);
Expand Down
711 changes: 356 additions & 355 deletions src/core/display.h

Large diffs are not rendered by default.

249 changes: 249 additions & 0 deletions src/core/main_menu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
#include "globals.h"
#include "display.h"
#include "sd_functions.h"
#include "settings.h"
#include "wg.h"
#include "wifi_common.h"

#include "modules/ble/ble_spam.h"
#include "modules/others/openhaystack.h"
#include "modules/others/tururururu.h"
#include "modules/others/TV-B-Gone.h"
#include "modules/others/webInterface.h"
#include "modules/rf/rf.h"
#include "modules/rfid/rfid.h"
#include "modules/rfid/tag_o_matic.h"
#include "modules/rfid/mfrc522_i2c.h"
#include "modules/wifi/clients.h"
#include "modules/wifi/dpwo.h"
#include "modules/wifi/evil_portal.h"
#include "modules/wifi/scan_hosts.h"
#include "modules/wifi/sniffer.h"
#include "modules/wifi/wifi_atks.h"

#ifdef CARDPUTER
#include "modules/others/bad_usb.h"
#include "modules/others/led_control.h"
#endif


/**********************************************************************
** Function: wifiOptions
** Wifi menu options
**********************************************************************/
void wifiOptions() {
if(!wifiConnected) {
options = {
{"Connect Wifi", [=]() { wifiConnectMenu(); }}, //wifi_common.h
{"WiFi AP", [=]() { wifiConnectMenu(true); }},//wifi_common.h
};
} else {
options = {
{"Disconnect", [=]() { wifiDisconnect(); }}, //wifi_common.h
};
}
options.push_back({"Wifi Atks", [=]() { wifi_atk_menu(); }});
#ifndef STICK_C_PLUS
options.push_back({"TelNET", [=]() { telnet_setup(); }});
options.push_back({"SSH", [=]() { ssh_setup(); }});
#endif
options.push_back({"Raw Sniffer", [=]() { sniffer_setup(); }});
options.push_back({"DPWO", [=]() { dpwo_setup(); }});
options.push_back({"Evil Portal", [=]() { startEvilPortal(); }});
options.push_back({"Scan Hosts", [=]() { local_scan_setup(); }});
#ifndef STICK_C_PLUS
options.push_back({"Wireguard", [=]() { wg_setup(); }});
#endif
options.push_back({"Main Menu", [=]() { backToMenu(); }});
delay(200);
loopOptions(options,false,true,"WiFi");
}


/**********************************************************************
** Function: bleOptions
** Bluetooth menu options
**********************************************************************/
void bleOptions() {
options = {
{"AppleJuice", [=]() { aj_adv(0); }},
{"SwiftPair", [=]() { aj_adv(1); }},
{"Samsung Spam", [=]() { aj_adv(2); }},
{"SourApple", [=]() { aj_adv(3); }},
{"Android Spam", [=]() { aj_adv(4); }},
{"BT Maelstrom", [=]() { aj_adv(5); }},
{"Main Menu", [=]() { backToMenu(); }},
};
delay(200);
loopOptions(options,false,true,"Bluetooth");
}


/**********************************************************************
** Function: rfOptions
** Radio frequency menu options
**********************************************************************/
void rfOptions(){
options = {
//{"Scan/copy", [=]() { displayRedStripe("Scan/Copy"); }},
//{"Replay", [=]() { displayRedStripe("Replay"); }},
{"Spectrum", [=]() { rf_spectrum(); }}, //@IncursioHack
{"Jammer Itmt", [=]() { rf_jammerIntermittent(); }}, //@IncursioHack
{"Jammer Full", [=]() { rf_jammerFull(); }}, //@IncursioHack
{"Main Menu", [=]() { backToMenu(); }},
};
delay(200);
loopOptions(options,false,true,"Radio Frequency");
}


/**********************************************************************
** Function: rfidOptions
** RFID menu options
**********************************************************************/
void rfidOptions(){
options = {
{"Tag-O-Matic", [=]() { TagOMatic(); }}, //@RennanCockles
{"Copy/Write", [=]() { rfid_setup(); }}, //@IncursioHack
{"Main Menu", [=]() { backToMenu(); }},
};
delay(200);
loopOptions(options,false,true,"RFID");
}


/**********************************************************************
** Function: irOptions
** Infrared menu options
**********************************************************************/
void irOptions(){
options = {
{"TV-B-Gone", [=]() { StartTvBGone(); }},
{"Custom IR", [=]() { otherIRcodes(); }},
{"Main Menu", [=]() { backToMenu(); }}
};
delay(200);
loopOptions(options,false,true,"Infrared");
}


/**********************************************************************
** Function: otherOptions
** Other menu options
**********************************************************************/
void otherOptions(){
options = {
{"SD Card", [=]() { loopSD(SD); }},
{"LittleFS", [=]() { loopSD(LittleFS); }},
{"WebUI", [=]() { loopOptionsWebUi(); }},
{"Megalodon", [=]() { shark_setup(); }},
#ifdef CARDPUTER
{"BadUSB", [=]() { usb_setup(); }},
{"LED Control", [=]() { ledrgb_setup(); }}, //IncursioHack
{"LED FLash", [=]() { ledrgb_flash(); }}, // IncursioHack
#endif
{"Openhaystack", [=]() { openhaystack_setup(); }},
{"Main Menu", [=]() { backToMenu(); }},
};
delay(200);
loopOptions(options,false,true,"Others");
}


/**********************************************************************
** Function: configOptions
** Config menu options
**********************************************************************/
void configOptions(){
options = {
{"Brightness", [=]() { setBrightnessMenu(); saveConfigs();}},
{"Dim Time", [=]() { setDimmerTimeMenu(); saveConfigs();}},
{"Clock", [=]() { setClock(); saveConfigs();}},
{"Orientation", [=]() { gsetRotation(true); saveConfigs();}},
{"UI Color", [=]() { setUIColor(); saveConfigs();}},
{"Ir TX Pin", [=]() { gsetIrTxPin(true); saveConfigs();}},
{"Ir RX Pin", [=]() { gsetIrRxPin(true); saveConfigs();}},
#ifndef CARDPUTER
{"RF TX Pin", [=]() { gsetRfTxPin(true); saveConfigs();}},
{"RF RX Pin", [=]() { gsetRfRxPin(true); saveConfigs();}},
#endif
{"Sleep", [=]() { setSleepMode(); }},
{"Restart", [=]() { ESP.restart(); }},
{"Main Menu", [=]() { backToMenu(); }},
};
delay(200);
loopOptions(options,false,true,"Config");
}


/**********************************************************************
** Function: getMainMenuOptions
** Description: Get main menu options
**********************************************************************/
void getMainMenuOptions(int index){
switch(index) {
case 0: // WiFi
wifiOptions();
break;
case 1: // BLE
bleOptions();
break;
case 2: // RF
rfOptions();
break;
case 3: // RFID
rfidOptions();
break;
case 4: //IR
irOptions();
break;
case 5: //Other
otherOptions();
break;
case 6: //Config
configOptions();
break;
}
}


/***************************************************************************************
** Function name: drawMainMenu
** Description: Função para desenhar e mostrar o menu principal
***************************************************************************************/
void drawMainMenu(int index) {
const char* texts[7] = { "WiFi", "BLE", "RF", "RFID", "IR", "Others", "Config" };

drawMainBorder();
tft.setTextSize(FG);

switch(index) {
case 0:
drawWifi(80,27);
break;
case 1:
drawBLE(80,27);
break;
case 2:
drawRf(80,27);
break;
case 3:
drawRfid(80,27);
break;
case 4:
drawIR(80,27);
break;
case 5:
drawOther(80,27);
break;
case 6:
drawCfg(80,27);
break;
}

tft.setTextSize(FM);
tft.drawCentreString(texts[index],tft.width()/2, tft.height()-(LH*FM+10), SMOOTH_FONT);
tft.setTextSize(FG);
tft.drawChar('<',10,tft.height()/2+10);
tft.drawChar('>',tft.width()-(LW*FG+10),tft.height()/2+10);
}
10 changes: 10 additions & 0 deletions src/core/main_menu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
void wifiOptions();
void bleOptions();
void rfOptions();
void rfidOptions();
void irOptions();
void otherOptions();
void configOptions();

void getMainMenuOptions(int index = 0);
void drawMainMenu(int index = 0);
Loading

0 comments on commit 58e4756

Please sign in to comment.