Remove old HAL components and refactored GPS-related code (#583)
- Added generic GPS/GNSS support with device detection, configuration, and persistent settings. - Improved device and module lifecycle management. - Added flexible filesystem locking support for displays and storage. - Improved display-idle and keyboard backlight handling. - Updated architecture, driver, module, testing, and licensing documentation. - Removed old HAL device and related code.
This commit is contained in:
committed by
GitHub
parent
29e80cfd65
commit
2a2558b29a
@@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool tt_gps_has_coordinates();
|
||||
|
||||
bool tt_gps_get_coordinates(
|
||||
float* longitude,
|
||||
float* latitude,
|
||||
float* speed,
|
||||
float* course,
|
||||
int* day,
|
||||
int* month,
|
||||
int* year
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
DEVICE_TYPE_I2C,
|
||||
DEVICE_TYPE_DISPLAY,
|
||||
DEVICE_TYPE_TOUCH,
|
||||
DEVICE_TYPE_SDCARD,
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
DEVICE_TYPE_POWER,
|
||||
DEVICE_TYPE_GPS
|
||||
} TtDeviceType;
|
||||
|
||||
typedef uint32_t DeviceId;
|
||||
|
||||
/**
|
||||
* Find one or more devices of a certain type.
|
||||
* @param[in] type the type to look for
|
||||
* @param[inout] deviceIds the output ids, which should fit at least maxCount amount of devices
|
||||
* @param[out] count the resulting number of device ids that were returned
|
||||
* @param[in] maxCount the maximum number of items that the "deviceIds" output can contain (minimum value is 1)
|
||||
* @return true if one or more devices were found
|
||||
*/
|
||||
bool tt_hal_device_find(TtDeviceType type, DeviceId* deviceIds, uint16_t* count, uint16_t maxCount);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,100 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <tt_hal_device.h>
|
||||
#include <stdbool.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* DisplayDriverHandle;
|
||||
|
||||
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.
|
||||
* @param[in] displayId the identifier of the display device
|
||||
* @return true if the driver is supported.
|
||||
*/
|
||||
bool tt_hal_display_driver_supported(DeviceId displayId);
|
||||
|
||||
/**
|
||||
* Allocate a driver object for the specified displayId.
|
||||
* @warning check whether the driver is supported by calling tt_hal_display_driver_supported() first
|
||||
* @param[in] displayId the identifier of the display device
|
||||
* @return the driver handle
|
||||
*/
|
||||
DisplayDriverHandle tt_hal_display_driver_alloc(DeviceId displayId);
|
||||
|
||||
/**
|
||||
* Free the memory for the display driver.
|
||||
* @param[in] handle the display driver handle
|
||||
*/
|
||||
void tt_hal_display_driver_free(DisplayDriverHandle handle);
|
||||
|
||||
/**
|
||||
* Lock the display device. Call this function before doing any draw calls.
|
||||
* Certain display devices are on a shared bus (e.g. SPI) so they must run
|
||||
* mutually exclusive with other devices on the same bus (e.g. SD card)
|
||||
* @param[in] handle the display driver handle
|
||||
* @param[in] timeout the maximum amount of ticks to wait for getting a lock
|
||||
* @return true if the lock was acquired
|
||||
*/
|
||||
bool tt_hal_display_driver_lock(DisplayDriverHandle handle, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* Unlock the display device. Must be called exactly once after locking.
|
||||
* @param[in] handle the display driver handle
|
||||
*/
|
||||
void tt_hal_display_driver_unlock(DisplayDriverHandle handle);
|
||||
|
||||
/**
|
||||
* @param[in] handle the display driver handle
|
||||
* @return the native color format for this display
|
||||
*/
|
||||
ColorFormat tt_hal_display_driver_get_colorformat(DisplayDriverHandle handle);
|
||||
|
||||
/**
|
||||
* @param[in] handle the display driver handle
|
||||
* @return the horizontal resolution of the display
|
||||
*/
|
||||
uint16_t tt_hal_display_driver_get_pixel_width(DisplayDriverHandle handle);
|
||||
|
||||
/**
|
||||
* @param[in] handle the display driver handle
|
||||
* @return the vertical resolution of the display
|
||||
*/
|
||||
uint16_t tt_hal_display_driver_get_pixel_height(DisplayDriverHandle handle);
|
||||
|
||||
/**
|
||||
* Draw pixels on the screen. Make sure to call the lock function first and unlock afterwards.
|
||||
* Many draw calls can be done inbetween a single lock and unlock.
|
||||
* @param[in] handle the display driver handle
|
||||
* @param[in] xStart the starting x coordinate for rendering the pixel data
|
||||
* @param[in] yStart the starting y coordinate for rendering the pixel data
|
||||
* @param[in] xEnd the last x coordinate for rendering the pixel data (absolute pixel value, not relative to xStart!)
|
||||
* @param[in] yEnd the last y coordinate for rendering the pixel data (absolute pixel value, not relative to yStart!)
|
||||
* @param[in] pixelData a buffer of pixels. the data is placed as "RowRowRowRow". The size depends on the ColorFormat
|
||||
*/
|
||||
void tt_hal_display_driver_draw_bitmap(DisplayDriverHandle handle, int xStart, int yStart, int xEnd, int yEnd, const void* pixelData);
|
||||
|
||||
/**
|
||||
* Get direct pointers to the display's hardware frame buffer(s), if supported.
|
||||
* Only available for panels with direct CPU-addressable frame buffers (e.g. MIPI-DSI/DPI).
|
||||
* @param[in] handle the display driver handle
|
||||
* @param[out] outBuffers receives up to 2 frame buffer pointers
|
||||
* @return number of buffers written to outBuffers (0 if unsupported)
|
||||
*/
|
||||
uint8_t tt_hal_display_driver_get_frame_buffers(DisplayDriverHandle handle, void* outBuffers[2]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @deprecated NON-FUNCTIONAL - WILL BE REMOVED SOON */
|
||||
typedef unsigned int GpioPin;
|
||||
|
||||
/** @deprecated NON-FUNCTIONAL - WILL BE REMOVED SOON */
|
||||
#define GPIO_NO_PIN -1
|
||||
|
||||
/** @deprecated NON-FUNCTIONAL - WILL BE REMOVED SOON */
|
||||
bool tt_hal_gpio_get_level(GpioPin pin);
|
||||
|
||||
/** @deprecated NON-FUNCTIONAL - WILL BE REMOVED SOON */
|
||||
int tt_hal_gpio_get_pin_count();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,48 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "tt_hal_device.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* TouchDriverHandle;
|
||||
/**
|
||||
* Check if the touch driver interface is supported for this device.
|
||||
* @param[in] touchDeviceId the identifier of the touch device
|
||||
* @return true if the driver is supported.
|
||||
*/
|
||||
bool tt_hal_touch_driver_supported(DeviceId touchDeviceId);
|
||||
|
||||
/**
|
||||
* Allocate a driver object for the specified touchDeviceId.
|
||||
* @warning check whether the driver is supported by calling tt_hal_touch_driver_supported() first
|
||||
* @param[in] touchDeviceId the identifier of the touch device
|
||||
* @return the driver handle
|
||||
*/
|
||||
TouchDriverHandle tt_hal_touch_driver_alloc(DeviceId touchDeviceId);
|
||||
|
||||
/**
|
||||
* Free the memory for the touch driver.
|
||||
* @param[in] handle the touch driver handle
|
||||
*/
|
||||
void tt_hal_touch_driver_free(TouchDriverHandle handle);
|
||||
|
||||
/**
|
||||
* Get the coordinates for the currently touched points on the screen.
|
||||
*
|
||||
* @param[in] handle the touch driver handle
|
||||
* @param[in] x array of X coordinates
|
||||
* @param[in] y array of Y coordinates
|
||||
* @param[in] strength array of strengths (with the minimum size of maxPointCount) or NULL
|
||||
* @param[in] pointCount the number of points currently touched on the screen
|
||||
* @param[in] maxPointCount the maximum number of points that can be touched at once
|
||||
*
|
||||
* @return true when touched and coordinates are available
|
||||
*/
|
||||
bool tt_hal_touch_driver_get_touched_points(TouchDriverHandle handle, uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* pointCount, uint8_t maxPointCount);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,159 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* WARNING: THIS API IS NON-FUNCTIONAL AND DEPRECATED.
|
||||
* IT WILL BE REMOVED IN A FUTURE RELEASE ONCE OFFICIAL APPS ARE MIGRATED.
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file tt_hal_uart.h
|
||||
* @brief C HAL interface for UART devices used by Tactility C modules.
|
||||
*
|
||||
* This header exposes a minimal, C-compatible UART API that mirrors the higher-level
|
||||
* C++ UART interface (see Tactility/hal/uart).
|
||||
*
|
||||
* General notes:
|
||||
* - Start the UART before I/O using tt_hal_uart_start(); stop it with tt_hal_uart_stop().
|
||||
*/
|
||||
|
||||
typedef void* UartHandle; /**< Opaque handle to an underlying UART instance. */
|
||||
|
||||
/**
|
||||
* @brief Get the number of UART devices available on this platform.
|
||||
* @return Count of discoverable UARTs (0 if none).
|
||||
*/
|
||||
size_t tt_hal_uart_get_count();
|
||||
|
||||
/**
|
||||
* @brief Get the user-friendly name of a UART by index.
|
||||
* @param index Zero-based UART index in the range [0, tt_hal_uart_get_count()).
|
||||
* @param[out] name Destination buffer to receive a null-terminated name.
|
||||
* @param nameSizeLimit Size in bytes of the destination buffer. The name will be
|
||||
* truncated to fit and always null-terminated if the size
|
||||
* is greater than 0.
|
||||
* @return true if a name was written to the buffer; false if the index is out of range
|
||||
* or on other failure.
|
||||
*/
|
||||
bool tt_hal_uart_get_name(size_t index, char* name, size_t nameSizeLimit);
|
||||
|
||||
/**
|
||||
* @brief Allocate an opaque UART handle by index.
|
||||
*
|
||||
* Allocation does not start the hardware; call tt_hal_uart_start() to begin I/O.
|
||||
*
|
||||
* @param index Zero-based UART index.
|
||||
* @return A valid UartHandle on success; NULL on failure (e.g., invalid index or already in use).
|
||||
*/
|
||||
UartHandle tt_hal_uart_alloc(size_t index);
|
||||
|
||||
/**
|
||||
* @brief Release a previously allocated UART handle and any associated resources.
|
||||
* @param handle Handle returned by tt_hal_uart_alloc()
|
||||
*/
|
||||
void tt_hal_uart_free(UartHandle handle);
|
||||
|
||||
/**
|
||||
* @brief Start the UART so it can perform I/O.
|
||||
* @param handle A valid UART handle.
|
||||
* @return true on success; false on failure.
|
||||
*/
|
||||
bool tt_hal_uart_start(UartHandle handle);
|
||||
|
||||
/**
|
||||
* @brief Query whether the UART has been started.
|
||||
* @param handle A valid UART handle.
|
||||
* @return true if started; false otherwise.
|
||||
*/
|
||||
bool tt_hal_uart_is_started(UartHandle handle);
|
||||
|
||||
/**
|
||||
* @brief Stop the UART
|
||||
* @param handle A valid UART handle.
|
||||
* @return true on success; false on failure.
|
||||
*/
|
||||
bool tt_hal_uart_stop(UartHandle handle);
|
||||
|
||||
/**
|
||||
* @brief Read up to bufferSize bytes into buffer.
|
||||
*
|
||||
* This call may block up to timeout ticks waiting for data. It returns the actual
|
||||
* number of bytes placed into the buffer, which can be less than bufferSize if
|
||||
* fewer bytes became available before the timeout expired.
|
||||
*
|
||||
* @param handle A valid UART handle.
|
||||
* @param[out] buffer Destination buffer.
|
||||
* @param bufferSize Capacity of the destination buffer in bytes.
|
||||
* @param timeout Maximum time to wait in ticks. Use 0 for non-blocking; use TT_MAX_TICKS
|
||||
* to wait indefinitely.
|
||||
* @return The number of bytes read (0 on timeout with no data). Never exceeds bufferSize.
|
||||
*/
|
||||
size_t tt_hal_uart_read_bytes(UartHandle handle, char* buffer, size_t bufferSize, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Read a single byte.
|
||||
*
|
||||
* @param handle A valid UART handle.
|
||||
* @param[out] output Where to store the read byte.
|
||||
* @param timeout Maximum time to wait in ticks. Use 0 for non-blocking; use TT_MAX_TICKS
|
||||
* to wait indefinitely.
|
||||
* @return true if a byte was read and stored in output; false on timeout or failure.
|
||||
*/
|
||||
bool tt_hal_uart_read_byte(UartHandle handle, char* output, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Write up to bufferSize bytes from buffer.
|
||||
*
|
||||
* This call may block up to timeout ticks waiting for transmit queue space. It returns
|
||||
* the number of bytes accepted for transmission.
|
||||
*
|
||||
* @param handle A valid UART handle.
|
||||
* @param[in] buffer Source buffer containing bytes to write.
|
||||
* @param bufferSize Number of bytes to write from buffer.
|
||||
* @param timeout Maximum time to wait in ticks. Use 0 for non-blocking; use TT_MAX_TICKS
|
||||
* to wait indefinitely.
|
||||
* @return The number of bytes written (may be less than bufferSize on timeout).
|
||||
*/
|
||||
size_t tt_hal_uart_write_bytes(UartHandle handle, const char* buffer, size_t bufferSize, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Get the number of bytes currently available to read without blocking.
|
||||
* @param handle A valid UART handle.
|
||||
* @return The count of bytes available in the receive buffer.
|
||||
*/
|
||||
size_t tt_hal_uart_available(UartHandle handle);
|
||||
|
||||
/**
|
||||
* @brief Set the UART baud rate.
|
||||
* @param handle A valid UART handle.
|
||||
* @param baud_rate Desired baud rate in bits per second (e.g., 115200).
|
||||
* @return true on success; false if the rate is unsupported or on error.
|
||||
*/
|
||||
bool tt_hal_uart_set_baud_rate(UartHandle handle, size_t baud_rate);
|
||||
|
||||
/**
|
||||
* @brief Get the current UART baud rate.
|
||||
* @param handle A valid UART handle.
|
||||
* @return The configured baud rate in bits per second.
|
||||
*/
|
||||
uint32_t tt_hal_uart_get_baud_rate(UartHandle handle);
|
||||
|
||||
/**
|
||||
* @brief Flush the UART input (receive) buffer, discarding any unread data.
|
||||
* @param handle A valid UART handle.
|
||||
*/
|
||||
void tt_hal_uart_flush_input(UartHandle handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TT_LVGL_DEFAULT_LOCK_TIME 500 // 500 ticks = 500 ms
|
||||
|
||||
/** @return true if LVGL is started and active */
|
||||
bool tt_lvgl_is_started();
|
||||
|
||||
/** Start LVGL and related background services */
|
||||
void tt_lvgl_start();
|
||||
|
||||
/** Stop LVGL and related background services */
|
||||
void tt_lvgl_stop();
|
||||
|
||||
/** Lock the LVGL context. Call this before doing LVGL-related operations from a non-LVLG thread */
|
||||
bool tt_lvgl_lock(TickType_t timeout);
|
||||
|
||||
/** Unlock the LVGL context */
|
||||
void tt_lvgl_unlock();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
#include "tt_gps.h"
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
|
||||
using namespace tt::service;
|
||||
|
||||
extern "C" {
|
||||
|
||||
bool tt_gps_has_coordinates() {
|
||||
auto service = gps::findGpsService();
|
||||
return service != nullptr && service->hasCoordinates();
|
||||
}
|
||||
|
||||
bool tt_gps_get_coordinates(
|
||||
float* longitude,
|
||||
float* latitude,
|
||||
float* speed,
|
||||
float* course,
|
||||
int* day,
|
||||
int* month,
|
||||
int* year
|
||||
) {
|
||||
auto service = gps::findGpsService();
|
||||
|
||||
if (service == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
minmea_sentence_rmc rmc;
|
||||
|
||||
if (!service->getCoordinates(rmc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*longitude = minmea_tocoord(&rmc.longitude);
|
||||
*latitude = minmea_tocoord(&rmc.latitude);
|
||||
*speed = minmea_tocoord(&rmc.speed);
|
||||
*course = minmea_tocoord(&rmc.course);
|
||||
*day = rmc.date.day;
|
||||
*month = rmc.date.month;
|
||||
*year = rmc.date.year;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#include "tt_hal_device.h"
|
||||
|
||||
#include <tactility/check.h>
|
||||
|
||||
#include <tactility/hal/Device.h>
|
||||
|
||||
static tt::hal::Device::Type toTactilityDeviceType(TtDeviceType type) {
|
||||
switch (type) {
|
||||
case DEVICE_TYPE_I2C:
|
||||
return tt::hal::Device::Type::I2c;
|
||||
case DEVICE_TYPE_DISPLAY:
|
||||
return tt::hal::Device::Type::Display;
|
||||
case DEVICE_TYPE_TOUCH:
|
||||
return tt::hal::Device::Type::Touch;
|
||||
case DEVICE_TYPE_SDCARD:
|
||||
return tt::hal::Device::Type::SdCard;
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
return tt::hal::Device::Type::Keyboard;
|
||||
case DEVICE_TYPE_POWER:
|
||||
return tt::hal::Device::Type::Power;
|
||||
case DEVICE_TYPE_GPS:
|
||||
return tt::hal::Device::Type::Gps;
|
||||
default:
|
||||
check(false, "Device::Type not supported");
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
bool tt_hal_device_find(TtDeviceType type, DeviceId* deviceIds, uint16_t* count, uint16_t maxCount) {
|
||||
assert(maxCount > 0);
|
||||
|
||||
int16_t currentIndex = -1;
|
||||
uint16_t maxIndex = maxCount - 1;
|
||||
|
||||
findDevices<tt::hal::Device>(toTactilityDeviceType(type), [&](const auto& device) {
|
||||
currentIndex++;
|
||||
deviceIds[currentIndex] = device->getId();
|
||||
// Continue if there is storage capacity left
|
||||
return currentIndex < maxIndex;
|
||||
});
|
||||
|
||||
*count = currentIndex + 1;
|
||||
|
||||
return currentIndex >= 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
#include "tt_hal_display.h"
|
||||
|
||||
#include <tactility/check.h>
|
||||
|
||||
#include <tactility/hal/Device.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <Tactility/hal/display/DisplayDriver.h>
|
||||
|
||||
static ColorFormat toColorFormat(tt::hal::display::ColorFormat format) {
|
||||
switch (format) {
|
||||
case tt::hal::display::ColorFormat::Monochrome:
|
||||
return COLOR_FORMAT_MONOCHROME;
|
||||
case tt::hal::display::ColorFormat::BGR565:
|
||||
return COLOR_FORMAT_BGR565;
|
||||
case tt::hal::display::ColorFormat::BGR565Swapped:
|
||||
return COLOR_FORMAT_BGR565_SWAPPED;
|
||||
case tt::hal::display::ColorFormat::RGB565:
|
||||
return COLOR_FORMAT_RGB565;
|
||||
case tt::hal::display::ColorFormat::RGB565Swapped:
|
||||
return COLOR_FORMAT_RGB565_SWAPPED;
|
||||
case tt::hal::display::ColorFormat::RGB888:
|
||||
return COLOR_FORMAT_RGB888;
|
||||
default:
|
||||
check(false, "ColorFormat not supported");
|
||||
}
|
||||
}
|
||||
|
||||
struct DriverWrapper {
|
||||
std::shared_ptr<tt::hal::display::DisplayDriver> driver;
|
||||
DriverWrapper(std::shared_ptr<tt::hal::display::DisplayDriver> driver) : driver(driver) {}
|
||||
};
|
||||
|
||||
static std::shared_ptr<tt::hal::display::DisplayDevice> findValidDisplayDevice(tt::hal::Device::Id id) {
|
||||
auto device = tt::hal::findDevice(id);
|
||||
if (device == nullptr || device->getType() != tt::hal::Device::Type::Display) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(device);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
bool tt_hal_display_driver_supported(DeviceId id) {
|
||||
auto display = findValidDisplayDevice(id);
|
||||
return display != nullptr && display->supportsDisplayDriver();
|
||||
}
|
||||
|
||||
DisplayDriverHandle tt_hal_display_driver_alloc(DeviceId id) {
|
||||
auto display = findValidDisplayDevice(id);
|
||||
assert(display->supportsDisplayDriver());
|
||||
return new DriverWrapper(display->getDisplayDriver());
|
||||
}
|
||||
|
||||
void tt_hal_display_driver_free(DisplayDriverHandle handle) {
|
||||
auto wrapper = static_cast<DriverWrapper*>(handle);
|
||||
delete wrapper;
|
||||
}
|
||||
|
||||
bool tt_hal_display_driver_lock(DisplayDriverHandle handle, TickType_t timeout) {
|
||||
// TODO: re-implement with SPI lock
|
||||
return true;
|
||||
}
|
||||
|
||||
void tt_hal_display_driver_unlock(DisplayDriverHandle handle) {
|
||||
// TODO: re-implement with SPI lock
|
||||
}
|
||||
|
||||
ColorFormat tt_hal_display_driver_get_colorformat(DisplayDriverHandle handle) {
|
||||
auto wrapper = static_cast<DriverWrapper*>(handle);
|
||||
return toColorFormat(wrapper->driver->getColorFormat());
|
||||
}
|
||||
|
||||
uint16_t tt_hal_display_driver_get_pixel_width(DisplayDriverHandle handle) {
|
||||
auto wrapper = static_cast<DriverWrapper*>(handle);
|
||||
return wrapper->driver->getPixelWidth();
|
||||
}
|
||||
|
||||
uint16_t tt_hal_display_driver_get_pixel_height(DisplayDriverHandle handle) {
|
||||
auto wrapper = static_cast<DriverWrapper*>(handle);
|
||||
return wrapper->driver->getPixelHeight();
|
||||
}
|
||||
|
||||
void tt_hal_display_driver_draw_bitmap(DisplayDriverHandle handle, int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) {
|
||||
auto wrapper = static_cast<DriverWrapper*>(handle);
|
||||
wrapper->driver->drawBitmap(xStart, yStart, xEnd, yEnd, pixelData);
|
||||
}
|
||||
|
||||
uint8_t tt_hal_display_driver_get_frame_buffers(DisplayDriverHandle handle, void* outBuffers[2]) {
|
||||
auto wrapper = static_cast<DriverWrapper*>(handle);
|
||||
return wrapper->driver->getFrameBuffers(outBuffers);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#include "tt_hal_touch.h"
|
||||
|
||||
#include <tactility/hal/Device.h>
|
||||
#include "Tactility/hal/touch/TouchDevice.h"
|
||||
#include "Tactility/hal/touch/TouchDriver.h"
|
||||
|
||||
struct DriverWrapper {
|
||||
std::shared_ptr<tt::hal::touch::TouchDriver> driver;
|
||||
DriverWrapper(std::shared_ptr<tt::hal::touch::TouchDriver> driver) : driver(driver) {}
|
||||
};
|
||||
|
||||
static std::shared_ptr<tt::hal::touch::TouchDevice> findValidTouchDevice(tt::hal::Device::Id id) {
|
||||
auto device = tt::hal::findDevice(id);
|
||||
if (device == nullptr || device->getType() != tt::hal::Device::Type::Touch) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(device);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
bool tt_hal_touch_driver_supported(DeviceId id) {
|
||||
auto touch = findValidTouchDevice(id);
|
||||
return touch != nullptr && touch->supportsTouchDriver();
|
||||
}
|
||||
|
||||
TouchDriverHandle tt_hal_touch_driver_alloc(DeviceId id) {
|
||||
auto touch = findValidTouchDevice(id);
|
||||
assert(touch->supportsTouchDriver());
|
||||
return new DriverWrapper(touch->getTouchDriver());
|
||||
}
|
||||
|
||||
void tt_hal_touch_driver_free(TouchDriverHandle handle) {
|
||||
DriverWrapper* wrapper = static_cast<DriverWrapper*>(handle);
|
||||
delete wrapper;
|
||||
}
|
||||
|
||||
bool tt_hal_touch_driver_get_touched_points(TouchDriverHandle handle, uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* pointCount, uint8_t maxPointCount) {
|
||||
DriverWrapper* wrapper = static_cast<DriverWrapper*>(handle);
|
||||
return wrapper->driver->getTouchedPoints(x, y, strength, pointCount, maxPointCount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
#include "tt_hal_uart.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
extern "C" {
|
||||
|
||||
size_t tt_hal_uart_get_count() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tt_hal_uart_get_name(size_t index, char* name, size_t nameSizeLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UartHandle tt_hal_uart_alloc(size_t index) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void tt_hal_uart_free(UartHandle handle) {
|
||||
}
|
||||
|
||||
bool tt_hal_uart_start(UartHandle handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool tt_hal_uart_is_started(UartHandle handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool tt_hal_uart_stop(UartHandle handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t tt_hal_uart_read_bytes(UartHandle handle, char* buffer, size_t bufferSize, TickType_t timeout) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tt_hal_uart_read_byte(UartHandle handle, char* output, TickType_t timeout) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t tt_hal_uart_write_bytes(UartHandle handle, const char* buffer, size_t bufferSize, TickType_t timeout) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t tt_hal_uart_available(UartHandle handle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tt_hal_uart_set_baud_rate(UartHandle handle, size_t baud_rate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t tt_hal_uart_get_baud_rate(UartHandle handle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tt_hal_uart_flush_input(UartHandle handle) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,13 +5,7 @@
|
||||
#include "tt_app_fileselection.h"
|
||||
#include "tt_app_selectiondialog.h"
|
||||
#include "tt_bundle.h"
|
||||
#include "tt_gps.h"
|
||||
#include "tt_hal_device.h"
|
||||
#include "tt_hal_display.h"
|
||||
#include "tt_hal_touch.h"
|
||||
#include "tt_hal_uart.h"
|
||||
#include <tt_lock.h>
|
||||
#include "tt_lvgl.h"
|
||||
#include "tt_lvgl_keyboard.h"
|
||||
#include "tt_lvgl_spinner.h"
|
||||
#include "tt_lvgl_toolbar.h"
|
||||
@@ -299,42 +293,6 @@ const esp_elfsym main_symbols[] {
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_put_bool),
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_put_int32),
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_put_string),
|
||||
ESP_ELFSYM_EXPORT(tt_gps_has_coordinates),
|
||||
ESP_ELFSYM_EXPORT(tt_gps_get_coordinates),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_device_find),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_alloc),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_draw_bitmap),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_free),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_get_colorformat),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_get_pixel_height),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_get_pixel_width),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_lock),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_unlock),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_supported),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_display_driver_get_frame_buffers),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_supported),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_alloc),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_free),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_get_touched_points),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_get_count),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_get_name),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_alloc),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_free),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_start),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_is_started),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_stop),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_read_bytes),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_read_byte),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_write_bytes),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_available),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_set_baud_rate),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_get_baud_rate),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_uart_flush_input),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_is_started),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_lock),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_unlock),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_start),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_stop),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_show),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_hide),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_is_enabled),
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include <Tactility/lvgl/Lvgl.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
bool tt_lvgl_is_started() {
|
||||
return tt::lvgl::isStarted();
|
||||
}
|
||||
|
||||
void tt_lvgl_start() {
|
||||
tt::lvgl::start();
|
||||
}
|
||||
|
||||
void tt_lvgl_stop() {
|
||||
tt::lvgl::stop();
|
||||
}
|
||||
|
||||
bool tt_lvgl_lock(TickType_t timeout) {
|
||||
return tt::lvgl::getSyncLock()->lock(timeout);
|
||||
}
|
||||
|
||||
void tt_lvgl_unlock() {
|
||||
tt::lvgl::getSyncLock()->unlock();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user