mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-05 20:40:25 -08:00
Adjust UI of channel summary graph
This commit is contained in:
@@ -4049,6 +4049,18 @@ void MenuFunctions::setGraphScale(float scale) {
|
||||
this->_graph_scale = scale;
|
||||
}
|
||||
|
||||
float MenuFunctions::calculateGraphScale(uint8_t value) {
|
||||
if ((value * this->_graph_scale < GRAPH_VERT_LIM) && (value * this->_graph_scale > GRAPH_VERT_LIM * 0.75)) {
|
||||
return this->_graph_scale; // No scaling needed if the value is within the limit
|
||||
}
|
||||
|
||||
if (value < GRAPH_VERT_LIM)
|
||||
return 1.0;
|
||||
|
||||
// Calculate the multiplier proportionally
|
||||
return (0.75 * GRAPH_VERT_LIM) / value;
|
||||
}
|
||||
|
||||
float MenuFunctions::calculateGraphScale(int16_t value) {
|
||||
if ((value * this->_graph_scale < GRAPH_VERT_LIM) && (value * this->_graph_scale > GRAPH_VERT_LIM * 0.75)) {
|
||||
return this->_graph_scale; // No scaling needed if the value is within the limit
|
||||
@@ -4081,10 +4093,10 @@ float MenuFunctions::graphScaleCheck(const int16_t array[TFT_WIDTH]) {
|
||||
}
|
||||
|
||||
float MenuFunctions::graphScaleCheckSmall(const uint8_t array[CHAN_PER_PAGE]) {
|
||||
int16_t maxValue = 0;
|
||||
uint8_t maxValue = 0;
|
||||
|
||||
// Iterate through the array to find the highest value
|
||||
for (int16_t i = 0; i < CHAN_PER_PAGE; i++) {
|
||||
for (uint8_t i = 0; i < CHAN_PER_PAGE; i++) {
|
||||
if (array[i] > maxValue) {
|
||||
maxValue = array[i];
|
||||
}
|
||||
@@ -4107,12 +4119,20 @@ void MenuFunctions::drawMaxLine(int16_t value, uint16_t color) {
|
||||
display_obj.tft.println((String)(value / BASE_MULTIPLIER));
|
||||
}
|
||||
|
||||
void MenuFunctions::drawMaxLine(uint8_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(color, TFT_BLACK);
|
||||
display_obj.tft.setTextSize(1);
|
||||
display_obj.tft.println((String)value);
|
||||
}
|
||||
|
||||
void MenuFunctions::drawGraphSmall(uint8_t *values) {
|
||||
int16_t maxValue = 0;
|
||||
uint8_t maxValue = 0;
|
||||
//(i + (CHAN_PER_PAGE * (this->activity_page - 1)))
|
||||
|
||||
int bar_width = TFT_WIDTH / (CHAN_PER_PAGE * 2);
|
||||
display_obj.tft.fillRect(0, TFT_HEIGHT / 2 + 1, TFT_WIDTH, (TFT_HEIGHT / 2) + 1, TFT_BLACK);
|
||||
//display_obj.tft.fillRect(0, TFT_HEIGHT / 2 + 1, TFT_WIDTH, (TFT_HEIGHT / 2) + 1, TFT_BLACK);
|
||||
|
||||
#ifndef HAS_DUAL_BAND
|
||||
for (int i = 1; i < CHAN_PER_PAGE + 1; i++) {
|
||||
@@ -4124,9 +4144,26 @@ void MenuFunctions::drawGraphSmall(uint8_t *values) {
|
||||
maxValue = values[targ_val];
|
||||
}
|
||||
|
||||
display_obj.tft.fillRect(x_coord, TFT_HEIGHT / 2 + 1, bar_width, TFT_HEIGHT / 2 + 1, TFT_BLACK);
|
||||
display_obj.tft.fillRect(x_coord, TFT_HEIGHT - (values[targ_val] * this->_graph_scale), bar_width, values[targ_val] * this->_graph_scale, TFT_CYAN);
|
||||
|
||||
display_obj.tft.drawLine(x_coord - 2, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2), x_coord - 2, TFT_HEIGHT, TFT_WHITE);
|
||||
}
|
||||
#else
|
||||
for (int i = 1; i < CHAN_PER_PAGE + 1; i++) {
|
||||
int targ_val = i + (CHAN_PER_PAGE * (wifi_scan_obj.activity_page - 1)) - 1;
|
||||
int x_mult = (i * 2) - 1;
|
||||
int x_coord = (TFT_WIDTH / (CHAN_PER_PAGE * 2)) * (x_mult - 1);
|
||||
|
||||
if (values[targ_val] > maxValue) {
|
||||
maxValue = values[targ_val];
|
||||
}
|
||||
|
||||
display_obj.tft.fillRect(x_coord, TFT_HEIGHT / 2 + 1, bar_width, TFT_HEIGHT / 2 + 1, TFT_BLACK);
|
||||
display_obj.tft.fillRect(x_coord, TFT_HEIGHT - (values[targ_val] * this->_graph_scale), bar_width, values[targ_val] * this->_graph_scale, TFT_CYAN);
|
||||
|
||||
display_obj.tft.drawLine(x_coord - 2, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2), x_coord - 2, TFT_HEIGHT, TFT_WHITE);
|
||||
}
|
||||
#endif
|
||||
|
||||
this->drawMaxLine(maxValue, TFT_GREEN); // Draw max
|
||||
@@ -4156,7 +4193,7 @@ void MenuFunctions::drawGraph(int16_t *values) {
|
||||
}
|
||||
|
||||
this->drawMaxLine(maxValue, TFT_GREEN); // Draw max
|
||||
this->drawMaxLine(total / TFT_WIDTH, TFT_ORANGE); // Draw average
|
||||
this->drawMaxLine((int16_t)(total / TFT_WIDTH), TFT_ORANGE); // Draw average
|
||||
}
|
||||
|
||||
void MenuFunctions::renderGraphUI(uint8_t scan_mode) {
|
||||
|
||||
@@ -229,7 +229,9 @@ class MenuFunctions
|
||||
uint16_t getColor(uint16_t color);
|
||||
void drawAvgLine(int16_t value);
|
||||
void drawMaxLine(int16_t value, uint16_t color);
|
||||
void drawMaxLine(uint8_t value, uint16_t color);
|
||||
float calculateGraphScale(int16_t value);
|
||||
float calculateGraphScale(uint8_t value);
|
||||
float graphScaleCheck(const int16_t array[TFT_WIDTH]);
|
||||
#ifndef HAS_DUAL_BAND
|
||||
float graphScaleCheckSmall(const uint8_t array[MAX_CHANNEL]);
|
||||
|
||||
@@ -7255,6 +7255,8 @@ void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
|
||||
else if (wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ACT) {
|
||||
#ifndef HAS_DUAL_BAND
|
||||
wifi_scan_obj.channel_activity[wifi_scan_obj.set_channel - 1] = wifi_scan_obj.channel_activity[wifi_scan_obj.set_channel - 1] + 1;
|
||||
#else
|
||||
wifi_scan_obj.channel_activity[wifi_scan_obj.dual_band_channel_index] = wifi_scan_obj.channel_activity[wifi_scan_obj.dual_band_channel_index] + 1;
|
||||
#endif
|
||||
}
|
||||
else if (wifi_scan_obj.currentScanMode == WIFI_SCAN_PACKET_RATE) {
|
||||
@@ -8070,7 +8072,7 @@ void WiFiScan::signalAnalyzerLoop(uint32_t tick) {
|
||||
void WiFiScan::drawChannelLine() {
|
||||
#ifdef HAS_SCREEN
|
||||
//#ifdef HAS_FULL_SCREEN
|
||||
display_obj.tft.fillRect(0, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2), TFT_WIDTH, (CHAR_WIDTH * 2) - 1, TFT_MAGENTA);
|
||||
display_obj.tft.fillRect(0, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2), TFT_WIDTH, (CHAR_WIDTH * 2) - 1, TFT_BLACK);
|
||||
//#else
|
||||
//#endif
|
||||
Serial.println("Drawing channel line...");
|
||||
@@ -8084,10 +8086,22 @@ void WiFiScan::drawChannelLine() {
|
||||
display_obj.tft.setTextSize(1);
|
||||
#endif
|
||||
display_obj.tft.setCursor(x_coord, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2));
|
||||
display_obj.tft.setTextColor(TFT_BLACK, TFT_CYAN);
|
||||
display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
display_obj.tft.print((String)(i + (CHAN_PER_PAGE * (this->activity_page - 1))));
|
||||
}
|
||||
#else
|
||||
for (int i = 1; i < CHAN_PER_PAGE + 1; i++) {
|
||||
int x_mult = (i * 2) - 1;
|
||||
int x_coord = (TFT_WIDTH / (CHAN_PER_PAGE * 2)) * (x_mult - 1);
|
||||
//#ifdef HAS_FULL_SCREEN
|
||||
// display_obj.tft.setTextSize(2);
|
||||
//#else
|
||||
display_obj.tft.setTextSize(1);
|
||||
//#endif
|
||||
display_obj.tft.setCursor(x_coord, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2));
|
||||
display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
display_obj.tft.print((String)this->dual_band_channels[(i + (CHAN_PER_PAGE * (this->activity_page - 1)) - 1)]);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -8108,7 +8122,11 @@ void WiFiScan::channelActivityLoop(uint32_t tick) {
|
||||
initTime = millis();
|
||||
Serial.println("--------------");
|
||||
for (int i = (activity_page * CHAN_PER_PAGE) - CHAN_PER_PAGE; i < activity_page * CHAN_PER_PAGE; i++) {
|
||||
#ifndef HAS_DUAL_BAND
|
||||
Serial.println((String)(i+1) + ": " + (String)channel_activity[i]);
|
||||
#else
|
||||
Serial.println((String)this->dual_band_channels[i] + ": " + (String)channel_activity[i]);
|
||||
#endif
|
||||
channel_activity[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,7 +738,7 @@
|
||||
#define TFT_HEIGHT 240
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 0
|
||||
|
||||
@@ -814,7 +814,7 @@
|
||||
#define TFT_HEIGHT 240
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 0
|
||||
|
||||
@@ -889,7 +889,7 @@
|
||||
#define TFT_HEIGHT 240
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 0
|
||||
|
||||
@@ -954,7 +954,7 @@
|
||||
|
||||
#define TFT_SHIELD
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 20
|
||||
|
||||
@@ -1023,7 +1023,7 @@
|
||||
#define TFT_DIY
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 20
|
||||
|
||||
@@ -1097,7 +1097,7 @@
|
||||
//#define TFT_SHIELD
|
||||
//#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 20
|
||||
|
||||
@@ -1166,7 +1166,7 @@
|
||||
#define TFT_HEIGHT 320
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 20
|
||||
|
||||
@@ -1236,7 +1236,7 @@
|
||||
#define TFT_HEIGHT 320
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 20
|
||||
|
||||
@@ -1308,7 +1308,7 @@
|
||||
|
||||
#define TFT_DIY
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 20
|
||||
|
||||
@@ -1379,7 +1379,7 @@
|
||||
|
||||
#define TFT_DIY
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 20
|
||||
|
||||
@@ -1448,7 +1448,7 @@
|
||||
#define TFT_HEIGHT 320
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define TFT_DIY
|
||||
|
||||
@@ -1519,7 +1519,7 @@
|
||||
#define TFT_HEIGHT 320
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define TFT_DIY
|
||||
|
||||
@@ -1590,7 +1590,7 @@
|
||||
#define TFT_HEIGHT 320
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define TFT_DIY
|
||||
#define KIT
|
||||
@@ -1670,7 +1670,7 @@
|
||||
#define TFT_HEIGHT 128
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 0
|
||||
|
||||
@@ -1745,7 +1745,7 @@
|
||||
#define TFT_HEIGHT 135
|
||||
#endif
|
||||
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2
|
||||
#define GRAPH_VERT_LIM TFT_HEIGHT/2 - 1
|
||||
|
||||
#define EXT_BUTTON_WIDTH 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user