mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-12 07:40:58 -08:00
Settings actually work
This commit is contained in:
@@ -1,41 +1,44 @@
|
||||
#ifndef Buffer_h
|
||||
#define Buffer_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "FS.h"
|
||||
//#include "SD_MMC.h"
|
||||
|
||||
#define BUF_SIZE 3 * 1024 // Had to reduce buffer size to save RAM. GG @spacehuhn
|
||||
#define SNAP_LEN 2324 // max len of each recieved packet
|
||||
|
||||
//extern bool useSD;
|
||||
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer();
|
||||
void open(fs::FS* fs, String fn = "");
|
||||
void close(fs::FS* fs);
|
||||
void addPacket(uint8_t* buf, uint32_t len);
|
||||
void save(fs::FS* fs);
|
||||
void forceSave(fs::FS* fs);
|
||||
private:
|
||||
void write(int32_t n);
|
||||
void write(uint32_t n);
|
||||
void write(uint16_t n);
|
||||
void write(uint8_t* buf, uint32_t len);
|
||||
|
||||
uint8_t* bufA;
|
||||
uint8_t* bufB;
|
||||
|
||||
uint32_t bufSizeA = 0;
|
||||
uint32_t bufSizeB = 0;
|
||||
|
||||
bool writing = false; // acceppting writes to buffer
|
||||
bool useA = true; // writing to bufA or bufB
|
||||
bool saving = false; // currently saving onto the SD card
|
||||
|
||||
String fileName = "/0.pcap";
|
||||
File file;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef Buffer_h
|
||||
#define Buffer_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "FS.h"
|
||||
#include "settings.h"
|
||||
//#include "SD_MMC.h"
|
||||
|
||||
#define BUF_SIZE 3 * 1024 // Had to reduce buffer size to save RAM. GG @spacehuhn
|
||||
#define SNAP_LEN 2324 // max len of each recieved packet
|
||||
|
||||
//extern bool useSD;
|
||||
|
||||
extern Settings settings_obj;
|
||||
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer();
|
||||
void open(fs::FS* fs, String fn = "");
|
||||
void close(fs::FS* fs);
|
||||
void addPacket(uint8_t* buf, uint32_t len);
|
||||
void save(fs::FS* fs);
|
||||
void forceSave(fs::FS* fs);
|
||||
private:
|
||||
void write(int32_t n);
|
||||
void write(uint32_t n);
|
||||
void write(uint16_t n);
|
||||
void write(uint8_t* buf, uint32_t len);
|
||||
|
||||
uint8_t* bufA;
|
||||
uint8_t* bufB;
|
||||
|
||||
uint32_t bufSizeA = 0;
|
||||
uint32_t bufSizeB = 0;
|
||||
|
||||
bool writing = false; // acceppting writes to buffer
|
||||
bool useA = true; // writing to bufA or bufB
|
||||
bool saving = false; // currently saving onto the SD card
|
||||
|
||||
String fileName = "/0.pcap";
|
||||
File file;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -131,7 +131,7 @@ class Display
|
||||
TFT_eSPI tft = TFT_eSPI();
|
||||
TFT_eSprite img = TFT_eSprite(&tft);
|
||||
TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
|
||||
const String PROGMEM version_number = "v0.9.4";
|
||||
const String PROGMEM version_number = "v0.9.5";
|
||||
|
||||
bool printing = false;
|
||||
bool loading = false;
|
||||
|
||||
@@ -1212,24 +1212,33 @@ String MenuFunctions::callSetting(String key) {
|
||||
}
|
||||
}
|
||||
|
||||
void MenuFunctions::displaySetting(String key) {
|
||||
void MenuFunctions::displaySetting(String key, Menu* menu, int index) {
|
||||
specSettingMenu.name = key;
|
||||
|
||||
bool setting_value = settings_obj.loadSetting<bool>(key);
|
||||
|
||||
// Make a local copy of menu node
|
||||
MenuNode node = menu->list->get(index);
|
||||
|
||||
display_obj.tft.setTextWrap(false);
|
||||
display_obj.tft.setFreeFont(NULL);
|
||||
display_obj.tft.setCursor(0, 100);
|
||||
display_obj.tft.setTextSize(1);
|
||||
|
||||
|
||||
// Set local copy value
|
||||
if (!setting_value) {
|
||||
display_obj.tft.setTextColor(TFT_RED);
|
||||
display_obj.tft.println(F("Setting disabled"));
|
||||
node.selected = false;
|
||||
}
|
||||
else {
|
||||
display_obj.tft.setTextColor(TFT_GREEN);
|
||||
display_obj.tft.println(F("Setting on"));
|
||||
node.selected = true;
|
||||
}
|
||||
|
||||
// Put local copy back into menu
|
||||
menu->list->set(index, node);
|
||||
|
||||
}
|
||||
|
||||
@@ -1598,7 +1607,7 @@ void MenuFunctions::RunSetup()
|
||||
settings_obj.toggleSetting(settings_obj.setting_index_to_name(i));
|
||||
changeMenu(&specSettingMenu);
|
||||
//this->callSetting(settings_obj.setting_index_to_name(i));
|
||||
this->displaySetting(settings_obj.setting_index_to_name(i));
|
||||
this->displaySetting(settings_obj.setting_index_to_name(i), &settingsMenu, i + 1);
|
||||
}, settings_obj.loadSetting<bool>(settings_obj.setting_index_to_name(i)));
|
||||
}
|
||||
|
||||
@@ -1771,10 +1780,10 @@ void MenuFunctions::displayCurrentMenu()
|
||||
//display_obj.key[i].drawButton2(current_menu->list->get(i).name);
|
||||
//display_obj.key[i].drawButton(ML_DATUM, BUTTON_PADDING, current_menu->list->get(i).name);
|
||||
//display_obj.key[i].drawButton(true);
|
||||
//if (!current_menu->list->get(i).selected)
|
||||
if (!current_menu->list->get(i).selected)
|
||||
display_obj.key[i].drawButton(false, current_menu->list->get(i).name);
|
||||
//else
|
||||
// display_obj.key[i].drawButton(true, current_menu->list->get(i).name);
|
||||
else
|
||||
display_obj.key[i].drawButton(true, current_menu->list->get(i).name);
|
||||
|
||||
if (current_menu->list->get(i).name != "Back")
|
||||
display_obj.tft.drawXBitmap(0,
|
||||
|
||||
@@ -182,7 +182,7 @@ class MenuFunctions
|
||||
void showMenuList(Menu* menu, int layer);
|
||||
String callSetting(String key);
|
||||
void runBoolSetting(String ley);
|
||||
void displaySetting(String key);
|
||||
void displaySetting(String key, Menu* menu, int index);
|
||||
|
||||
public:
|
||||
MenuFunctions();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user