132 lines
4.1 KiB
C
132 lines
4.1 KiB
C
#ifndef V2X_DISPLAY_H
|
|
#define V2X_DISPLAY_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "esp_err.h"
|
|
|
|
/* === Display-Konstanten (T-Dongle-C5) === */
|
|
#define DISP_W 80
|
|
#define DISP_H 160
|
|
|
|
/* === GPIO-Pins (T-Dongle-C5) === */
|
|
#define DISP_GPIO_CS 10
|
|
#define DISP_GPIO_DC 3
|
|
#define DISP_GPIO_RST 1
|
|
#define DISP_GPIO_BL 0
|
|
#define DISP_GPIO_SDA 2
|
|
#define DISP_GPIO_SCK 6
|
|
|
|
/* === Farben (16-bit RGB565) === */
|
|
#define DISP_COLOR_BLACK 0x0000
|
|
#define DISP_COLOR_WHITE 0xFFFF
|
|
#define DISP_COLOR_RED 0xF800
|
|
#define DISP_COLOR_GREEN 0x07E0
|
|
#define DISP_COLOR_BLUE 0x001F
|
|
#define DISP_COLOR_YELLOW 0xFFE0
|
|
#define DISP_COLOR_CYAN 0x07FF
|
|
#define DISP_COLOR_MAGENTA 0xF81F
|
|
#define DISP_COLOR_GRAY 0x7BEF
|
|
|
|
/* === Font-Optionen === */
|
|
#define FONT_6x8 0
|
|
|
|
/* === Msg-Type Erkennung === */
|
|
typedef enum {
|
|
V2X_MSG_UNKNOWN = 0,
|
|
V2X_MSG_BSM = 1,
|
|
V2X_MSG_CAM = 2,
|
|
V2X_MSG_DENM = 3,
|
|
} v2x_msg_type_t;
|
|
|
|
/* === Frame-Info für Scroller === */
|
|
typedef struct {
|
|
uint8_t msg_type;
|
|
int8_t rssi;
|
|
uint8_t channel;
|
|
uint8_t bssid_last3[3];
|
|
} disp_frame_info_t;
|
|
|
|
/* === Frame-Info für SD === */
|
|
#define V2X_MAX_FRAME_LEN 512
|
|
|
|
typedef struct {
|
|
uint64_t timestamp_us;
|
|
uint8_t msg_type;
|
|
float frequency_mhz;
|
|
int8_t rssi_dbm;
|
|
int8_t noise_dbm;
|
|
uint8_t rate_index;
|
|
uint16_t frame_len;
|
|
uint8_t mac_addr[6];
|
|
uint8_t bssid[6];
|
|
uint8_t raw_data[V2X_MAX_FRAME_LEN];
|
|
uint16_t raw_len;
|
|
uint8_t channel; /* channel field for CSV output */
|
|
} v2x_frame_t;
|
|
|
|
/* === SD-Konstanten === */
|
|
#define SD_CARD_MOUNT_POINT "/sdcard"
|
|
#define SD_CSV_FILE "/sdcard/v2x_frames.csv"
|
|
#define SD_LOG_FILE "/sdcard/v2x_log.txt"
|
|
#define CSV_HEADER "timestamp_us,msg_type,channel,frequency_mhz,rssi_dbm,noise_dbm,rate_index,frame_len,mac_addr,bssid,raw_hex"
|
|
|
|
/* === Statistik === */
|
|
#define RAW_HEX_BUF 512
|
|
|
|
typedef struct {
|
|
uint64_t total_frames;
|
|
uint64_t bsm_count;
|
|
uint64_t cam_count;
|
|
uint64_t denm_count;
|
|
uint64_t unknown_count;
|
|
uint64_t sd_write_errors;
|
|
uint64_t start_timestamp_us;
|
|
} v2x_stats_t;
|
|
|
|
/* === Globale Display-Status-Variablen === */
|
|
extern bool g_disp_initialized;
|
|
extern void *g_disp_panel;
|
|
|
|
/* === Globale V2X-Status-Variablen (für UI) === */
|
|
extern uint32_t g_v2x_frame_count;
|
|
extern int8_t g_v2x_max_rssi;
|
|
extern uint32_t g_v2x_current_freq;
|
|
extern int g_v2x_channel_idx;
|
|
|
|
/* === Display-Primärfunktionen === */
|
|
esp_err_t v2x_display_init(void);
|
|
esp_err_t v2x_display_clear(uint16_t color);
|
|
esp_err_t v2x_display_rect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color, bool filled);
|
|
esp_err_t v2x_display_line(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
|
|
esp_err_t v2x_display_off(void);
|
|
|
|
/* === Display-Zeichnungsfunktionen === */
|
|
esp_err_t v2x_display_text(int16_t x, int16_t y, const char *text, uint16_t color, uint8_t font);
|
|
esp_err_t v2x_display_frame_count(uint32_t count);
|
|
esp_err_t v2x_display_storage_bar(int16_t x, int16_t y, int16_t w, int16_t h, float pct);
|
|
esp_err_t v2x_display_progress_bar(int16_t x, int16_t y, int16_t w, int16_t h, float progress,
|
|
uint16_t fg_color, uint16_t bg_color);
|
|
esp_err_t v2x_display_rssi_gauge(int8_t rssi);
|
|
esp_err_t v2x_display_render_frame_line(int16_t x, int16_t y, const disp_frame_info_t *info,
|
|
uint16_t bg_color);
|
|
|
|
/* === Scroller-Funktionen === */
|
|
void scroller_add_entry(uint8_t msg_type, int8_t rssi, uint8_t ch, const uint8_t *bssid);
|
|
void scroller_redraw(void);
|
|
void scroller_redraw_line(uint32_t entry_idx);
|
|
|
|
/* === SD-Funktionen === */
|
|
esp_err_t v2x_sd_init(void);
|
|
esp_err_t v2x_sd_write_frame(const v2x_frame_t *frame);
|
|
esp_err_t v2x_sd_dump_stats(void);
|
|
esp_err_t v2x_sd_reset_stats(void);
|
|
esp_err_t v2x_sd_log_write(const char *fmt, ...);
|
|
const v2x_stats_t* v2x_sd_get_stats(void);
|
|
void frame_to_csv_line(const v2x_frame_t *frame, char *out, size_t out_len);
|
|
|
|
/* === Display UI Task === */
|
|
void v2x_display_ui_task(void *pvParameters);
|
|
|
|
#endif /* V2X_DISPLAY_H */
|