reworked String Handling of Enums
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
// -> 6.90µl / Pulse
|
||||
#define DEFAULT_PUMP_DOSE 7
|
||||
|
||||
// --- System status enum with sentinel ---
|
||||
typedef enum eSystem_Status
|
||||
{
|
||||
sysStat_Startup,
|
||||
@@ -76,7 +77,8 @@ typedef enum eSystem_Status
|
||||
sysStat_Wash,
|
||||
sysStat_Purge,
|
||||
sysStat_Error,
|
||||
sysStat_Shutdown
|
||||
sysStat_Shutdown,
|
||||
SYSSTAT_COUNT // <- sentinel (must be last)
|
||||
} tSystem_Status;
|
||||
|
||||
// Enum for different sources of speed input
|
||||
@@ -89,13 +91,10 @@ typedef enum SpeedSource_e
|
||||
SOURCE_GPS,
|
||||
SOURCE_CAN,
|
||||
SOURCE_OBD2_KLINE,
|
||||
SOURCE_OBD2_CAN
|
||||
SOURCE_OBD2_CAN,
|
||||
SPEEDSOURCE_COUNT // <- sentinel (must be last)
|
||||
} SpeedSource_t;
|
||||
|
||||
// String representation of SpeedSource enum
|
||||
extern const char *SpeedSourceString[];
|
||||
extern const size_t SpeedSourceString_Elements;
|
||||
|
||||
// Enum for GPS baud rates
|
||||
typedef enum GPSBaudRate_e
|
||||
{
|
||||
@@ -104,23 +103,29 @@ typedef enum GPSBaudRate_e
|
||||
BAUD_19200,
|
||||
BAUD_38400,
|
||||
BAUD_57600,
|
||||
BAUD_115200
|
||||
BAUD_115200,
|
||||
GPSBAUDRATE_COUNT // <- sentinel (must be last)
|
||||
} GPSBaudRate_t;
|
||||
|
||||
// String representation of GPSBaudRate enum
|
||||
extern const char *GPSBaudRateString[];
|
||||
extern const size_t GPSBaudRateString_Elements;
|
||||
|
||||
// Enum for CAN bus sources
|
||||
typedef enum CANSource_e
|
||||
{
|
||||
KTM_890_ADV_R_2021,
|
||||
KTM_1290_SD_R_2023
|
||||
KTM_1290_SD_R_2023,
|
||||
CANSOURCE_COUNT // <- sentinel (must be last)
|
||||
} CANSource_t;
|
||||
|
||||
// String representation of CANSource enum
|
||||
extern const char *CANSourceString[];
|
||||
extern const size_t CANSourceString_Elements;
|
||||
// String tables (kept internal to the module)
|
||||
extern const char * const SystemStatusString[SYSSTAT_COUNT];
|
||||
extern const char * const SpeedSourceString[SPEEDSOURCE_COUNT];
|
||||
extern const char * const GPSBaudRateString[GPSBAUDRATE_COUNT];
|
||||
extern const char * const CANSourceString[CANSOURCE_COUNT];
|
||||
|
||||
// Safe getters (centralized bounds check)
|
||||
const char* ToString(SpeedSource_t v);
|
||||
const char* ToString(GPSBaudRate_t v);
|
||||
const char* ToString(CANSource_t v);
|
||||
const char* ToString(tSystem_Status v);
|
||||
|
||||
#define STARTUP_DELAY 2500
|
||||
#define SHUTDOWN_DELAY_MS 2500
|
||||
|
Reference in New Issue
Block a user