Add headless mode

This commit is contained in:
Just Call Me Koko
2023-10-24 18:52:00 -04:00
parent 516b8b0c3f
commit 598eda99e3
6 changed files with 78 additions and 39 deletions

View File

@@ -25,7 +25,7 @@ void Display::RunSetup()
#endif
#ifdef MARAUDER_M5STICKC
tft.setRotation(3);
tft.setRotation(1);
#endif
tft.setCursor(0, 0);

View File

@@ -68,6 +68,7 @@ class Display
bool tteBar = false;
bool draw_tft = false;
bool exit_draw = false;
bool headless_mode = false;
uint8_t TOP_FIXED_AREA_2 = 48;
uint8_t print_delay_1, print_delay_2 = 10;

View File

@@ -18,6 +18,13 @@ MenuFunctions::MenuFunctions()
/* Interrupt driven periodic handler */
#ifdef HAS_ILI9341
uint8_t MenuFunctions::updateTouch(uint16_t *x, uint16_t *y, uint16_t threshold) {
if (!display_obj.headless_mode)
return display_obj.tft.getTouch(x, y, threshold);
else
return !display_obj.headless_mode;
}
void MenuFunctions::lv_tick_handler()
{
lv_tick_inc(LVGL_TICK_PERIOD);
@@ -456,7 +463,7 @@ void MenuFunctions::main(uint32_t currentTime)
// getTouch causes a 10ms delay which makes beacon spam less effective
#ifdef HAS_ILI9341
pressed = display_obj.tft.getTouch(&t_x, &t_y);
pressed = this->updateTouch(&t_x, &t_y);
#endif
@@ -643,50 +650,51 @@ void MenuFunctions::main(uint32_t currentTime)
#endif
#ifdef HAS_BUTTONS
#ifndef MARAUDER_M5STICKC
if (u_btn.justPressed()){
#if !(defined(MARAUDER_V6) || defined(MARAUDER_V6_1))
#ifndef MARAUDER_M5STICKC
if (u_btn.justPressed()){
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
(wifi_scan_obj.currentScanMode == OTA_UPDATE)) {
if (current_menu->selected > 0) {
current_menu->selected--;
this->buttonSelected(current_menu->selected);
if (!current_menu->list->get(current_menu->selected + 1).selected)
this->buttonNotSelected(current_menu->selected + 1);
}
}
else if ((wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EAPOL)) {
if (wifi_scan_obj.set_channel < 14)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel + 1);
}
}
#endif
if (d_btn.justPressed()){
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
(wifi_scan_obj.currentScanMode == OTA_UPDATE)) {
if (current_menu->selected > 0) {
current_menu->selected--;
if (current_menu->selected < current_menu->list->size() - 1) {
current_menu->selected++;
this->buttonSelected(current_menu->selected);
if (!current_menu->list->get(current_menu->selected + 1).selected)
this->buttonNotSelected(current_menu->selected + 1);
if (!current_menu->list->get(current_menu->selected - 1).selected)
this->buttonNotSelected(current_menu->selected - 1);
}
else {
current_menu->selected = 0;
this->buttonSelected(current_menu->selected);
if (!current_menu->list->get(current_menu->list->size() - 1).selected)
this->buttonNotSelected(current_menu->list->size() - 1);
}
}
else if ((wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EAPOL)) {
if (wifi_scan_obj.set_channel < 14)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel + 1);
if (wifi_scan_obj.set_channel > 1)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel - 1);
}
}
if(c_btn_press){
current_menu->list->get(current_menu->selected).callable();
}
#endif
if (d_btn.justPressed()){
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
(wifi_scan_obj.currentScanMode == OTA_UPDATE)) {
if (current_menu->selected < current_menu->list->size() - 1) {
current_menu->selected++;
this->buttonSelected(current_menu->selected);
if (!current_menu->list->get(current_menu->selected - 1).selected)
this->buttonNotSelected(current_menu->selected - 1);
}
else {
current_menu->selected = 0;
this->buttonSelected(current_menu->selected);
if (!current_menu->list->get(current_menu->list->size() - 1).selected)
this->buttonNotSelected(current_menu->list->size() - 1);
}
}
else if ((wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EAPOL)) {
if (wifi_scan_obj.set_channel > 1)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel - 1);
}
}
if(c_btn_press){
current_menu->list->get(current_menu->selected).callable();
}
#endif
}

View File

@@ -166,6 +166,8 @@ class MenuFunctions
void buttonSelected(uint8_t b);
void buttonNotSelected(uint8_t b);
uint8_t updateTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600);
public:
MenuFunctions();

View File

@@ -71,7 +71,8 @@
//#define FLIPPER_ZERO_HAT
#define HAS_BATTERY
#define HAS_BT
//#define HAS_BUTTONS
#define HAS_BT_REMOTE
#define HAS_BUTTONS
#define HAS_NEOPIXEL_LED
//#define HAS_PWR_MGMT
#define HAS_SCREEN
@@ -85,7 +86,7 @@
//#define FLIPPER_ZERO_HAT
#define HAS_BATTERY
#define HAS_BT
//#define HAS_BUTTONS
#define HAS_BUTTONS
#define HAS_NEOPIXEL_LED
//#define HAS_PWR_MGMT
#define HAS_SCREEN
@@ -205,6 +206,22 @@
#define U_BTN -1
#define R_BTN -1
#define D_BTN 39
#endif
#ifdef MARAUDER_V6
#define L_BTN -1
#define C_BTN 0
#define U_BTN -1
#define R_BTN -1
#define D_BTN -1
#endif
#ifdef MARAUDER_V6_1
#define L_BTN -1
#define C_BTN 0
#define U_BTN -1
#define R_BTN -1
#define D_BTN -1
#endif
#endif

View File

@@ -165,7 +165,7 @@ void setup()
axp192_obj.begin();
#endif
pinMode(FLASH_BUTTON, INPUT);
//pinMode(FLASH_BUTTON, INPUT);
#ifdef HAS_SCREEN
pinMode(TFT_BL, OUTPUT);
@@ -247,6 +247,17 @@ void setup()
#ifdef HAS_SCREEN
delay(2000);
// Do some stealth mode stuff
#ifdef HAS_BUTTONS
if (c_btn.justPressed()) {
display_obj.headless_mode = true;
backlightOff();
Serial.println("Headless Mode enabled");
}
#endif
display_obj.clearScreen();
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);