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
+53
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;