240a374148
- ST7735 SPI-Treiber für 0.96 Zoll Display (80x160 Pixel) - ASCII-Font 6x8 mit Text-Ausgabe - Frame-Counter (gross, rot) - SD-Speicher-Balken (grün/gelb/rot) - Frame-Scroller: rollende Liste der letzten 7 Frames - RSSI-Farbbalken (rot/gelb/grün) - Message-Type (B=BSM, C=CAM, D=DENM) - BSSID Hex + Kanal/RSSI - Display UI Task aktualisiert alle 2 Sekunden - Frame Writer sendet Frames an Scroller Queue - Channel Hopper aktualisiert g_v2x_channel_idx
91 lines
2.9 KiB
C
91 lines
2.9 KiB
C
/**
|
|
* Display UI Task — aktualisiert SD-Speicher und Frame-Counter
|
|
*
|
|
* Wird als FreeRTOS-Task gestartet und alle 2 Sekunden:
|
|
* - SD-Speicher % berechnen + Balken zeichnen
|
|
* - Frame-Counter groß anzeigen
|
|
* - Scroller aktualisieren
|
|
*/
|
|
|
|
#include "esp_log.h"
|
|
#include "v2x_display.h"
|
|
#include "esp_vfs_fat.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "stdio.h"
|
|
|
|
static const char *TAG = "v2x-ui";
|
|
|
|
/* SD-Speicher % berechnen */
|
|
static float get_sd_storage_percent(void)
|
|
{
|
|
FATFS *fs;
|
|
DWORD free_clusters;
|
|
|
|
esp_err_t ret = f_getfree(SD_CARD_MOUNT_POINT, &free_clusters, &fs);
|
|
if (ret != FR_OK) return 0.0f;
|
|
|
|
/* Gesamt-Cluster zählen */
|
|
uint32_t total = fs->n_fatent - 12; /* FAT32: Cluster ab 12 */
|
|
if (total == 0) return 0.0f;
|
|
|
|
return (float)(total - free_clusters) / total;
|
|
}
|
|
|
|
/* Frame-Counter als extern (wird vom Writer Task gesetzt) */
|
|
extern uint32_t g_v2x_frame_count;
|
|
|
|
/* Display UI Task */
|
|
void v2x_display_ui_task(void *pvParameters)
|
|
{
|
|
uint32_t last_count = 0;
|
|
|
|
ESP_LOGI(TAG, "Display UI Task gestartet");
|
|
|
|
while (1) {
|
|
/* --- Display löschen (schwarzer Hintergrund) --- */
|
|
v2x_display_clear(DISP_COLOR_BLACK);
|
|
|
|
/* --- SD-Speicher-Balken (Y=0, Höhe=8px) --- */
|
|
float sd_pct = get_sd_storage_percent();
|
|
v2x_display_storage_bar(0, 0, DISP_W, 8, sd_pct);
|
|
|
|
/* Text: "SD: ##%" */
|
|
char sd_label[16];
|
|
snprintf(sd_label, sizeof(sd_label), "SD: %3.0f%%", sd_pct * 100);
|
|
v2x_display_text(2, 9, sd_label, DISP_COLOR_WHITE, FONT_6x8);
|
|
|
|
/* --- Frame-Counter (groß, rot, Y=20) --- */
|
|
uint32_t current_count = g_v2x_frame_count;
|
|
if (current_count != last_count) {
|
|
v2x_display_frame_count(current_count, 28, DISP_W, 40);
|
|
last_count = current_count;
|
|
}
|
|
|
|
/* --- RSSI-Anzeige (Y=72) --- */
|
|
v2x_display_text(2, 72, "RSSI:", DISP_COLOR_YELLOW, FONT_6x8);
|
|
char rssi_label[20];
|
|
snprintf(rssi_label, sizeof(rssi_label), "Max: %3d dBm", g_v2x_max_rssi);
|
|
v2x_display_text(40, 72, rssi_label, DISP_COLOR_WHITE, FONT_6x8);
|
|
|
|
/* --- Scroller (Y=84) --- */
|
|
scroller_redraw();
|
|
|
|
/* --- Statistik-Balken (Y=132) --- */
|
|
v2x_display_text(2, 132, "CH:", DISP_COLOR_GREEN, FONT_6x8);
|
|
|
|
/* Kanal + Frequenz */
|
|
extern uint32_t g_v2x_current_freq;
|
|
extern int g_v2x_channel_idx;
|
|
char ch_info[20];
|
|
snprintf(ch_info, sizeof(ch_info), "CH:%d %.0fMHz",
|
|
g_v2x_channel_idx, g_v2x_current_freq / 1000.0f);
|
|
v2x_display_text(20, 132, ch_info, DISP_COLOR_CYAN, FONT_6x8);
|
|
|
|
/* BSSID-Farbcodes */
|
|
v2x_display_text(2, 148, "B=BSM C=CAM D=DENM", DISP_COLOR_GRAY, FONT_6x8);
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(2000));
|
|
}
|
|
}
|