mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-22 07:10:47 -08:00
Add more data to channel analyzer
This commit is contained in:
@@ -2617,7 +2617,7 @@ void MenuFunctions::setGraphScale(float scale) {
|
||||
this->_graph_scale = scale;
|
||||
}
|
||||
|
||||
float MenuFunctions::calculateGraphScale(uint8_t value) {
|
||||
float MenuFunctions::calculateGraphScale(int16_t value) {
|
||||
if (value < GRAPH_VERT_LIM) {
|
||||
return 1.0; // No scaling needed if the value is within the limit
|
||||
}
|
||||
@@ -2626,11 +2626,11 @@ float MenuFunctions::calculateGraphScale(uint8_t value) {
|
||||
return (0.5 * GRAPH_VERT_LIM) / value;
|
||||
}
|
||||
|
||||
float MenuFunctions::graphScaleCheck(const uint8_t array[TFT_WIDTH]) {
|
||||
uint8_t maxValue = 0;
|
||||
float MenuFunctions::graphScaleCheck(const int16_t array[TFT_WIDTH]) {
|
||||
int16_t maxValue = 0;
|
||||
|
||||
// Iterate through the array to find the highest value
|
||||
for (uint8_t i = 0; i < TFT_WIDTH; i++) {
|
||||
for (int16_t i = 0; i < TFT_WIDTH; i++) {
|
||||
if (array[i] > maxValue) {
|
||||
maxValue = array[i];
|
||||
}
|
||||
@@ -2645,31 +2645,53 @@ float MenuFunctions::graphScaleCheck(const uint8_t array[TFT_WIDTH]) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
void MenuFunctions::drawMaxLine(uint8_t value) {
|
||||
display_obj.tft.drawLine(0, TFT_HEIGHT - (value * this->_graph_scale), TFT_WIDTH, TFT_HEIGHT - (value * this->_graph_scale), TFT_GREEN);
|
||||
void MenuFunctions::drawMaxLine(int16_t value, uint16_t color) {
|
||||
display_obj.tft.drawLine(0, TFT_HEIGHT - (value * this->_graph_scale), TFT_WIDTH, TFT_HEIGHT - (value * this->_graph_scale), color);
|
||||
display_obj.tft.setCursor(0, TFT_HEIGHT - (value * this->_graph_scale));
|
||||
display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
display_obj.tft.setTextColor(color, TFT_BLACK);
|
||||
display_obj.tft.setTextSize(1);
|
||||
display_obj.tft.println((String)value);
|
||||
}
|
||||
|
||||
void MenuFunctions::drawGraph(uint8_t *values) {
|
||||
uint8_t maxValue = 0;
|
||||
for (int i = 0; i < TFT_WIDTH; i++) {
|
||||
if (values[i] > maxValue) {
|
||||
maxValue = values[i];
|
||||
void MenuFunctions::drawGraph(int16_t *values) {
|
||||
int16_t maxValue = 0;
|
||||
int total = 0;
|
||||
for (int i = TFT_WIDTH - 1; i >= 0; i--) {
|
||||
if (values[i] >= 0) {
|
||||
total = total + values[i];
|
||||
if (values[i] > maxValue) {
|
||||
maxValue = values[i];
|
||||
}
|
||||
display_obj.tft.drawLine(i, TFT_HEIGHT, i, TFT_HEIGHT - GRAPH_VERT_LIM, TFT_BLACK);
|
||||
display_obj.tft.drawLine(i, TFT_HEIGHT, i, TFT_HEIGHT - (values[i] * this->_graph_scale), TFT_CYAN);
|
||||
}
|
||||
else {
|
||||
int16_t ch_val = values[i] * -1;
|
||||
display_obj.tft.drawLine(i, TFT_HEIGHT, i, TFT_HEIGHT - GRAPH_VERT_LIM, TFT_BLACK);
|
||||
display_obj.tft.drawLine(i, TFT_HEIGHT, i, TFT_HEIGHT - GRAPH_VERT_LIM, TFT_RED);
|
||||
display_obj.tft.setCursor(i, TFT_HEIGHT - GRAPH_VERT_LIM);
|
||||
display_obj.tft.setTextColor(TFT_BLACK, TFT_RED);
|
||||
display_obj.tft.setTextSize(1);
|
||||
display_obj.tft.println((String)ch_val);
|
||||
}
|
||||
display_obj.tft.drawLine(i, TFT_HEIGHT, i, TFT_HEIGHT - GRAPH_VERT_LIM, TFT_BLACK);
|
||||
display_obj.tft.drawLine(i, TFT_HEIGHT, i, TFT_HEIGHT - (values[i] * this->_graph_scale), TFT_CYAN);
|
||||
}
|
||||
|
||||
this->drawMaxLine(maxValue);
|
||||
this->drawMaxLine(maxValue, TFT_GREEN); // Draw max
|
||||
this->drawMaxLine(total / TFT_WIDTH, TFT_ORANGE); // Draw average
|
||||
}
|
||||
|
||||
void MenuFunctions::renderGraphUI() {
|
||||
display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
display_obj.tft.drawCentreString("Frames/" + (String)BANNER_TIME + "ms", TFT_WIDTH / 2, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2), 2);
|
||||
display_obj.tft.drawCentreString("Frames/" + (String)BANNER_TIME + "ms", TFT_WIDTH / 2, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2), BANNER_TEXT_SIZE);
|
||||
display_obj.tft.drawLine(0, TFT_HEIGHT - GRAPH_VERT_LIM - 1, TFT_WIDTH, TFT_HEIGHT - GRAPH_VERT_LIM - 1, TFT_WHITE);
|
||||
display_obj.tft.setCursor(0, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 8));
|
||||
display_obj.tft.setTextSize(BANNER_TEXT_SIZE);
|
||||
display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
display_obj.tft.println("Max");
|
||||
display_obj.tft.setTextColor(TFT_ORANGE, TFT_BLACK);
|
||||
display_obj.tft.println("Average");
|
||||
display_obj.tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
display_obj.tft.println("Channel Marker");
|
||||
}
|
||||
|
||||
void MenuFunctions::buildButtons(Menu * menu, int starting_index, String button_name)
|
||||
|
||||
@@ -181,10 +181,11 @@ class MenuFunctions
|
||||
// Menu icons
|
||||
|
||||
|
||||
void drawMaxLine(uint8_t value);
|
||||
float calculateGraphScale(uint8_t value);
|
||||
float graphScaleCheck(const uint8_t array[TFT_WIDTH]);
|
||||
void drawGraph(uint8_t *values);
|
||||
void drawAvgLine(int16_t value);
|
||||
void drawMaxLine(int16_t value, uint16_t color);
|
||||
float calculateGraphScale(int16_t value);
|
||||
float graphScaleCheck(const int16_t array[TFT_WIDTH]);
|
||||
void drawGraph(int16_t *values);
|
||||
void renderGraphUI();
|
||||
void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = "");
|
||||
void battery(bool initial = false);
|
||||
|
||||
@@ -5242,6 +5242,8 @@ void WiFiScan::changeChannel(int chan) {
|
||||
this->set_channel = chan;
|
||||
esp_wifi_set_channel(this->set_channel, WIFI_SECOND_CHAN_NONE);
|
||||
delay(1);
|
||||
if (this->currentScanMode == WIFI_SCAN_CHAN_ANALYZER)
|
||||
this->addAnalyzerValue(this->set_channel * -1, -72, this->_analyzer_values, TFT_WIDTH);
|
||||
}
|
||||
|
||||
void WiFiScan::changeChannel()
|
||||
@@ -5268,7 +5270,7 @@ char* WiFiScan::stringToChar(String string) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
void WiFiScan::addAnalyzerValue(uint8_t value, int rssi_avg, uint8_t target_array[], int array_size) {
|
||||
void WiFiScan::addAnalyzerValue(int16_t value, int rssi_avg, int16_t target_array[], int array_size) {
|
||||
// Shift all elements up by one index
|
||||
for (int i = array_size - 1; i > 0; i--) {
|
||||
target_array[i] = target_array[i - 1];
|
||||
|
||||
@@ -177,7 +177,7 @@ class WiFiScan
|
||||
// Wardriver thanks to https://github.com/JosephHewitt
|
||||
struct mac_addr mac_history[mac_history_len];
|
||||
|
||||
uint8_t _analyzer_value = 0;
|
||||
int16_t _analyzer_value = 0;
|
||||
|
||||
// Settings
|
||||
uint mac_history_cursor = 0;
|
||||
@@ -308,7 +308,7 @@ class WiFiScan
|
||||
NimBLEAdvertisementData GetUniversalAdvertisementData(EBLEPayloadType type);
|
||||
#endif
|
||||
|
||||
void addAnalyzerValue(uint8_t value, int rssi_avg, uint8_t target_array[], int array_size);
|
||||
void addAnalyzerValue(int16_t value, int rssi_avg, int16_t target_array[], int array_size);
|
||||
bool seen_mac(unsigned char* mac);
|
||||
bool mac_cmp(struct mac_addr addr1, struct mac_addr addr2);
|
||||
void save_mac(unsigned char* mac);
|
||||
@@ -384,8 +384,8 @@ class WiFiScan
|
||||
String dst_mac = "ff:ff:ff:ff:ff:ff";
|
||||
byte src_mac[6] = {};
|
||||
|
||||
uint8_t _analyzer_values[TFT_WIDTH];
|
||||
uint8_t _temp_analyzer_values[TFT_WIDTH];
|
||||
int16_t _analyzer_values[TFT_WIDTH];
|
||||
int16_t _temp_analyzer_values[TFT_WIDTH];
|
||||
|
||||
String current_mini_kb_ssid = "";
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
//// BOARD TARGETS
|
||||
//#define MARAUDER_M5STICKC
|
||||
//#define MARAUDER_M5STICKCP2
|
||||
//#define MARAUDER_MINI
|
||||
#define MARAUDER_MINI
|
||||
//#define MARAUDER_V4
|
||||
//#define MARAUDER_V6
|
||||
//#define MARAUDER_V6_1
|
||||
#define MARAUDER_V7
|
||||
//#define MARAUDER_V7
|
||||
//#define MARAUDER_KIT
|
||||
//#define GENERIC_ESP32
|
||||
//#define MARAUDER_FLIPPER
|
||||
|
||||
Reference in New Issue
Block a user