From e2ec39304c2e7404e566b223890c421ef9e1dfd0 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sat, 1 Nov 2025 09:38:32 +0100 Subject: [PATCH] Fixes for enums in TactilityC (#404) --- Documentation/ideas.md | 2 -- Tactility/Source/service/wifi/Wifi.cpp | 2 +- TactilityC/Include/tt_hal.h | 4 ++-- TactilityC/Include/tt_hal_device.h | 4 ++-- TactilityC/Include/tt_hal_display.h | 4 ++-- TactilityC/Include/tt_hal_gpio.h | 4 ++-- TactilityC/Include/tt_lock.h | 6 +++--- TactilityC/Include/tt_wifi.h | 12 ++++++------ 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Documentation/ideas.md b/Documentation/ideas.md index de6f1672..21a1ad23 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -2,8 +2,6 @@ ## Before release -- Issue with `enum DeviceType` when compiling from C (check all TactilityC enums!) -- Automate release process more - Elecrow Basic & Advance 3.5" memory issue: not enough memory for App Hub - App Hub crashes if you close it while an app is being installed - Fix glitches when installing app via App Hub with 4.3" Waveshare diff --git a/Tactility/Source/service/wifi/Wifi.cpp b/Tactility/Source/service/wifi/Wifi.cpp index b14ce3bf..e6f760c6 100644 --- a/Tactility/Source/service/wifi/Wifi.cpp +++ b/Tactility/Source/service/wifi/Wifi.cpp @@ -14,7 +14,7 @@ const char* radioStateToString(RadioState state) { case ConnectionActive: return TT_STRINGIFY(ConnectionActive); case OffPending: - return TT_STRINGIFY(OnPending); + return TT_STRINGIFY(OffPending); case Off: return TT_STRINGIFY(Off); } diff --git a/TactilityC/Include/tt_hal.h b/TactilityC/Include/tt_hal.h index 7d6f629a..d833a163 100644 --- a/TactilityC/Include/tt_hal.h +++ b/TactilityC/Include/tt_hal.h @@ -5,12 +5,12 @@ extern "C" { #endif /** Affects LVGL widget style */ -enum UiScale { +typedef enum { /** Ideal for very small non-touch screen devices (e.g. Waveshare S3 LCD 1.3") */ UiScaleSmallest, /** Nothing was changed in the LVGL UI/UX */ UiScaleDefault -}; +} UiScale; /** @return the UI scaling setting for this device. */ UiScale tt_hal_configuration_get_ui_scale(); diff --git a/TactilityC/Include/tt_hal_device.h b/TactilityC/Include/tt_hal_device.h index a1713682..5fcb0f29 100644 --- a/TactilityC/Include/tt_hal_device.h +++ b/TactilityC/Include/tt_hal_device.h @@ -7,7 +7,7 @@ extern "C" { #endif -enum DeviceType { +typedef enum { DEVICE_TYPE_I2C, DEVICE_TYPE_DISPLAY, DEVICE_TYPE_TOUCH, @@ -15,7 +15,7 @@ enum DeviceType { DEVICE_TYPE_KEYBOARD, DEVICE_TYPE_POWER, DEVICE_TYPE_GPS -}; +} DeviceType; typedef uint32_t DeviceId; diff --git a/TactilityC/Include/tt_hal_display.h b/TactilityC/Include/tt_hal_display.h index e19d1527..982221f3 100644 --- a/TactilityC/Include/tt_hal_display.h +++ b/TactilityC/Include/tt_hal_display.h @@ -10,14 +10,14 @@ extern "C" { typedef void* DisplayDriverHandle; -enum ColorFormat { +typedef enum { COLOR_FORMAT_MONOCHROME, // 1 bpp COLOR_FORMAT_BGR565, COLOR_FORMAT_BGR565_SWAPPED, COLOR_FORMAT_RGB565, COLOR_FORMAT_RGB565_SWAPPED, COLOR_FORMAT_RGB888 -}; +} ColorFormat; /** * Check if the display driver interface is supported for this device. diff --git a/TactilityC/Include/tt_hal_gpio.h b/TactilityC/Include/tt_hal_gpio.h index 9eeae31f..58230139 100644 --- a/TactilityC/Include/tt_hal_gpio.h +++ b/TactilityC/Include/tt_hal_gpio.h @@ -15,7 +15,7 @@ typedef unsigned int GpioPin; /** GPIO pin mode used by the HAL. * @warning The order must match tt::hal::gpio::Mode */ -enum GpioMode { +typedef enum { /** Pin is disabled (high-impedance). */ GpioModeDisable = 0, /** Pin configured as input only. */ @@ -28,7 +28,7 @@ enum GpioMode { GpioModeInputOutput, /** Pin configured for both input and output (open-drain). */ GpioModeInputOutputOpenDrain -}; +} GpioMode; /** Configure a single GPIO pin. * @param[in] pin GPIO number to configure. diff --git a/TactilityC/Include/tt_lock.h b/TactilityC/Include/tt_lock.h index 7708992d..38a2203b 100644 --- a/TactilityC/Include/tt_lock.h +++ b/TactilityC/Include/tt_lock.h @@ -10,17 +10,17 @@ extern "C" { /** A handle that represents a lock instance. A lock could be a Mutex or similar construct */ typedef void* LockHandle; -enum TtMutexType { +typedef enum { MutexTypeNormal, MutexTypeRecursive -}; +} TtMutexType; /** * Allocate a new mutex instance * @param[in] type specify if the mutex is either a normal one, or whether it can recursively (re)lock * @return the allocated lock handle */ -LockHandle tt_lock_alloc_mutex(enum TtMutexType type); +LockHandle tt_lock_alloc_mutex(TtMutexType type); /** * Allocate a lock for a file or folder. diff --git a/TactilityC/Include/tt_wifi.h b/TactilityC/Include/tt_wifi.h index 659fd750..4f8d2e68 100644 --- a/TactilityC/Include/tt_wifi.h +++ b/TactilityC/Include/tt_wifi.h @@ -12,12 +12,12 @@ extern "C" { /** Important: These values must map to tt::service::wifi::RadioState values exactly */ typedef enum { - WIFI_RADIO_STATE_ON_PENDING, - WIFI_RADIO_STATE_ON, - WIFI_RADIO_STATE_CONNECTION_PENDING, - WIFI_RADIO_STATE_CONNECTION_ACTIVE, - WIFI_RADIO_STATE_OFF_PENDING, - WIFI_RADIO_STATE_OFF, + WifiRadioStateOnPending, + WifiRadioStateOn, + WifiRadioStateConnectionPending, + WifiRadioStateConnectionActive, + WifiRadioStateOffPending, + WifiRadioStateOff, } WifiRadioState; /** @return the state of the WiFi radio */