Add channel summary frontend

This commit is contained in:
Just Call Me Koko
2025-11-03 00:36:54 -05:00
parent 6331e43db1
commit 0b6dc40fa6
4 changed files with 107 additions and 18 deletions

View File

@@ -819,6 +819,15 @@ void MenuFunctions::main(uint32_t currentTime)
this->drawGraph(wifi_scan_obj._analyzer_values);
#endif
}
if (wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ACT) {
#ifdef HAS_SCREEN
this->setGraphScale(this->graphScaleCheckSmall(wifi_scan_obj.channel_activity));
this->drawGraphSmall(wifi_scan_obj.channel_activity);
#endif
}
}
}
@@ -4023,6 +4032,25 @@ float MenuFunctions::graphScaleCheck(const int16_t array[TFT_WIDTH]) {
return 1.0;
}
float MenuFunctions::graphScaleCheckSmall(const uint8_t array[CHAN_PER_PAGE]) {
int16_t maxValue = 0;
// Iterate through the array to find the highest value
for (int16_t i = 0; i < CHAN_PER_PAGE; i++) {
if (array[i] > maxValue) {
maxValue = array[i];
}
}
// If the highest value exceeds GRAPH_VERT_LIM, call calculateMultiplier
if (maxValue > GRAPH_VERT_LIM) {
return this->calculateGraphScale(maxValue);
}
// If the highest value does not exceed GRAPH_VERT_LIM, return 1.0
return 1.0;
}
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));
@@ -4031,6 +4059,31 @@ void MenuFunctions::drawMaxLine(int16_t value, uint16_t color) {
display_obj.tft.println((String)(value / BASE_MULTIPLIER));
}
void MenuFunctions::drawGraphSmall(uint8_t *values) {
int16_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);
#ifndef HAS_DUAL_BAND
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 - (values[targ_val] * this->_graph_scale), bar_width, values[targ_val] * this->_graph_scale, TFT_CYAN);
}
#else
#endif
this->drawMaxLine(maxValue, TFT_GREEN); // Draw max
}
void MenuFunctions::drawGraph(int16_t *values) {
int16_t maxValue = 0;
int total = 0;

View File

@@ -231,7 +231,13 @@ class MenuFunctions
void drawMaxLine(int16_t value, uint16_t color);
float calculateGraphScale(int16_t value);
float graphScaleCheck(const int16_t array[TFT_WIDTH]);
#ifndef HAS_DUAL_BAND
float graphScaleCheckSmall(const uint8_t array[MAX_CHANNEL]);
#else
float graphScaleCheckSmall(const uint8_t array[DUAL_BAND_CHANNELS]);
#endif
void drawGraph(int16_t *values);
void drawGraphSmall(uint8_t *values);
void renderGraphUI(uint8_t scan_mode = 0);
//void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = "");
void addNodes(Menu* menu, String name, uint8_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = "");

View File

@@ -2877,6 +2877,7 @@ void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color)
else if (scan_mode == WIFI_SCAN_CHAN_ACT) {
display_obj.tft.setTextColor(TFT_BLACK, color);
display_obj.tft.drawCentreString("Channel Summary", TFT_WIDTH / 2, 16, 2);
this->drawChannelLine();
}
else if (scan_mode == WIFI_SCAN_PACKET_RATE) {
display_obj.tft.drawCentreString("Packet Rate", TFT_WIDTH / 2, 16, 2);
@@ -8060,6 +8061,31 @@ void WiFiScan::signalAnalyzerLoop(uint32_t tick) {
#endif
}
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);
#else
#endif
Serial.println("Drawing channel line...");
#ifndef HAS_DUAL_BAND
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_BLACK, TFT_CYAN);
display_obj.tft.print((String)(i + (CHAN_PER_PAGE * (this->activity_page - 1))));
}
#else
#endif
#endif
}
void WiFiScan::channelActivityLoop(uint32_t tick) {
#ifdef HAS_SCREEN
/*if (tick - this->initTime >= BANNER_TIME) {
@@ -8072,6 +8098,15 @@ void WiFiScan::channelActivityLoop(uint32_t tick) {
}
}*/
if (tick - this->initTime >= BANNER_TIME * 50) {
initTime = millis();
Serial.println("--------------");
for (int i = (activity_page * CHAN_PER_PAGE) - CHAN_PER_PAGE; i < activity_page * CHAN_PER_PAGE; i++) {
Serial.println((String)(i+1) + ": " + (String)channel_activity[i]);
channel_activity[i] = 0;
}
}
#ifdef HAS_ILI9341
int8_t b = this->checkAnalyzerButtons(millis());
@@ -8081,12 +8116,12 @@ void WiFiScan::channelActivityLoop(uint32_t tick) {
return;
}
else if (b == 4) {
Serial.println("Down");
#ifndef HAS_DUAL_BAND
if (this->activity_page > 1) {
this->activity_page--;
display_obj.tftDrawChannelScaleButtons(set_channel, false);
display_obj.tftDrawExitScaleButtons(false);
this->drawChannelLine();
return;
}
#else
@@ -8094,6 +8129,7 @@ void WiFiScan::channelActivityLoop(uint32_t tick) {
this->activity_page--;
display_obj.tftDrawChannelScaleButtons(this->set_channel, false);
display_obj.tftDrawExitScaleButtons(false);
this->drawChannelLine();
return;
}
#endif
@@ -8101,12 +8137,12 @@ void WiFiScan::channelActivityLoop(uint32_t tick) {
// Channel + button pressed
else if (b == 5) {
Serial.println("Up");
#ifndef HAS_DUAL_BAND
if (this->activity_page < MAX_CHANNEL / CHAN_PER_PAGE) {
this->activity_page++;
display_obj.tftDrawChannelScaleButtons(set_channel, false);
display_obj.tftDrawExitScaleButtons(false);
this->drawChannelLine();
return;
}
#else
@@ -8114,6 +8150,7 @@ void WiFiScan::channelActivityLoop(uint32_t tick) {
this->activity_page++;
display_obj.tftDrawChannelScaleButtons(this->set_channel, false);
display_obj.tftDrawExitScaleButtons(false);
this->drawChannelLine();
return;
}
#endif
@@ -8756,14 +8793,6 @@ void WiFiScan::main(uint32_t currentTime)
chanActTime = millis();
this->channelHop(false, true);
}
if (currentTime - initTime >= 1000) {
initTime = millis();
Serial.println("--------------");
for (int i = (activity_page * CHAN_PER_PAGE) - CHAN_PER_PAGE; i < activity_page * CHAN_PER_PAGE; i++) {
Serial.println((String)(i+1) + ": " + (String)channel_activity[i]);
channel_activity[i] = 0;
}
}
}
else if ((currentScanMode == WIFI_SCAN_PACKET_RATE) ||
(currentScanMode == WIFI_SCAN_RAW_CAPTURE)) {

View File

@@ -240,14 +240,6 @@ class WiFiScan
struct mac_addr mac_history[mac_history_len];
#endif
#ifdef HAS_DUAL_BAND
uint8_t channel_activity[DUAL_BAND_CHANNELS] = {};
#else
uint8_t channel_activity[MAX_CHANNEL] = {};
#endif
uint8_t activity_page = 1;
uint32_t chanActTime = 0;
uint8_t ap_mac[6] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
@@ -527,6 +519,7 @@ class WiFiScan
NimBLEAdvertisementData GetUniversalAdvertisementData(EBLEPayloadType type);
#endif
void drawChannelLine();
void fullARP();
bool readARP(IPAddress targ_ip);
bool singleARP(IPAddress ip_addr);
@@ -629,6 +622,14 @@ class WiFiScan
bool save_pcap = false;
bool ep_deauth = false;
#ifdef HAS_DUAL_BAND
uint8_t channel_activity[DUAL_BAND_CHANNELS] = {};
#else
uint8_t channel_activity[MAX_CHANNEL] = {};
#endif
uint8_t activity_page = 1;
String analyzer_name_string = "";
uint8_t analyzer_frames_recvd = 0;