TactilityC improvements (#359)

- Expose HAL Configuration's `UiScale`
- Updated docs
- Fix for `tt_timer_alloc()`
- Changed `enum class` to regular C `enum`
- Renamed enums (add prefix)
- Include `<stdbool.h>` where needed
This commit is contained in:
Ken Van Hoeylandt
2025-10-05 18:31:54 +02:00
committed by GitHub
parent 3802679de4
commit 15de4e20b8
16 changed files with 117 additions and 26 deletions
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include <stdio.h>
#include <stdbool.h>
#include "tt_app_manifest.h"
+2
View File
@@ -1,5 +1,7 @@
#pragma once
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
+20
View File
@@ -0,0 +1,20 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/** Affects LVGL widget style */
enum UiScale {
/** 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
};
/** @return the UI scaling setting for this device. */
UiScale tt_hal_configuration_get_ui_scale();
#ifdef __cplusplus
}
#endif
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
+2 -2
View File
@@ -1,8 +1,8 @@
#pragma once
#include <tt_kernel.h>
#include "tt_hal_device.h"
#include <tt_hal_device.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
+53 -10
View File
@@ -7,31 +7,74 @@
extern "C" {
#endif
/** Logical GPIO pin identifier used by the HAL. Typically maps to the SoC GPIO number. */
typedef unsigned int GpioPin;
/** Value indicating that no GPIO pin is used/applicable. */
#define GPIO_NO_PIN -1
/** @warning The order must match tt::hal::gpio::Mode */
enum class GpioMode {
Disable = 0,
Input,
Output,
OutputOpenDrain,
InputOutput,
InputOutputOpenDrain
/** GPIO pin mode used by the HAL.
* @warning The order must match tt::hal::gpio::Mode
*/
enum GpioMode {
/** Pin is disabled (high-impedance). */
GpioModeDisable = 0,
/** Pin configured as input only. */
GpioModeInput,
/** Pin configured as push-pull output only. */
GpioModeOutput,
/** Pin configured as open-drain output only. */
GpioModeOutputOpenDrain,
/** Pin configured for both input and output (push-pull). */
GpioModeInputOutput,
/** Pin configured for both input and output (open-drain). */
GpioModeInputOutputOpenDrain
};
/** Configure a single pin */
/** Configure a single GPIO pin.
* @param[in] pin GPIO number to configure.
* @param[in] mode Desired I/O mode for the pin.
* @param[in] pullUp Enable internal pull-up if true.
* @param[in] pullDown Enable internal pull-down if true.
* @return true on success, false if the pin is invalid or configuration failed.
*/
bool tt_hal_gpio_configure(GpioPin pin, GpioMode mode, bool pullUp, bool pullDown);
/** Configure a set of pins defined by their bit index */
/** Configure a set of GPIO pins in one call.
* The bit index of pin N is (1ULL << N).
* @param[in] pinBitMask Bit mask of pins to configure.
* @param[in] mode Desired I/O mode for the pins.
* @param[in] pullUp Enable internal pull-up on the selected pins if true.
* @param[in] pullDown Enable internal pull-down on the selected pins if true.
* @return true on success, false if any pin is invalid or configuration failed.
*/
bool tt_hal_gpio_configure_with_pin_bitmask(uint64_t pinBitMask, GpioMode mode, bool pullUp, bool pullDown);
/** Set the input/output mode for the specified pin.
* @param[in] pin The pin to configure.
* @param[in] mode The mode to set.
* @return true on success, false if the pin is invalid or mode not supported.
*/
bool tt_hal_gpio_set_mode(GpioPin pin, GpioMode mode);
/** Read the current logic level of a pin.
* The pin should be configured for input or input/output.
* @param[in] pin The pin to read.
* @return true if the level is high, false if low. If the pin is invalid, the
* behavior is implementation-defined and may return false.
*/
bool tt_hal_gpio_get_level(GpioPin pin);
/** Drive the output level of a pin.
* The pin should be configured for output or input/output.
* @param[in] pin The pin to drive.
* @param[in] level Output level to set (true = high, false = low).
* @return true on success, false if the pin is invalid or not configured as output.
*/
bool tt_hal_gpio_set_level(GpioPin pin, bool level);
/** Get the number of GPIO pins available on this platform.
* @return The count of valid GPIO pins.
*/
int tt_hal_gpio_get_pin_count();
#ifdef __cplusplus
+1
View File
@@ -3,6 +3,7 @@
#include <freertos/FreeRTOS.h>
#include <hal/i2c_types.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include "tt_hal_device.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include "tt_kernel.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
+2
View File
@@ -1,5 +1,7 @@
#pragma once
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include <freertos/FreeRTOS.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
+3 -3
View File
@@ -3,13 +3,13 @@
#include "tt_thread.h"
#include <freertos/FreeRTOS.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
/** The handle that represents a timer instance */
typedef void* TimerHandle;