50c0a14a93
- Added kernel base drivers for: display, pointer (touch, mouse, etc.), keyboard, adc, power supply and backlight - Implement new kernel driver modules: `st7789-module` and `gt911-module` - Implement ESP32 ADC "oneshot" kernel driver - Implement ESP32 backlight kernel driver with ledc API - Implemented `battery-sense` driver that allows for voltage measurement and creates a power supply child device - Updated github actions - Updated flash scripts - Fix for esp32 legacy driver conflict with ADC - Created separate `lilygo-tdeck` and `lilygo-tdeck-plus` devices - Created `lilygo-module` with LilyGO kernel drivers - Fix for intermittent errors in build related to code generation of `devicetree.c` - `lvgl-module` can now map kernel drivers onto LVGL devices - Created `KernelDisplayApp` as a mirror of `HalDisplayApp` (formerly `DisplayApp`) - Removed `struct` and `enum` prefix in a lot of kernel driver cpp source files - `lilygo-tdeck` and `lilygo-tdeck-plus` are now fully relying on kernel drivers and don't use any of the old HAL
152 lines
5.0 KiB
C
152 lines
5.0 KiB
C
// SPDX-License-Identifier: Apache-2.0
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <tactility/device.h>
|
|
#include <tactility/error.h>
|
|
#include <tactility/freertos/freertos.h>
|
|
|
|
/**
|
|
* @brief API for pointer controller drivers.
|
|
*/
|
|
struct PointerApi {
|
|
/**
|
|
* @brief Puts the pointer controller into its low-power sleep mode.
|
|
* @param[in] device the pointer device
|
|
* @retval ERROR_NONE when the operation was successful
|
|
*/
|
|
error_t (*enter_sleep)(struct Device* device);
|
|
|
|
/**
|
|
* @brief Wakes the pointer controller from sleep mode.
|
|
* @param[in] device the pointer device
|
|
* @retval ERROR_NONE when the operation was successful
|
|
*/
|
|
error_t (*exit_sleep)(struct Device* device);
|
|
|
|
/**
|
|
* @brief Performs a blocking read of the latest touch data from the controller into its internal state.
|
|
* Call this before get_touched_points().
|
|
* @param[in] device the pointer device
|
|
* @param[in] timeout the maximum time to wait for the operation to complete
|
|
* @retval ERROR_NONE when the read operation was successful
|
|
* @retval ERROR_TIMEOUT when the operation timed out
|
|
*/
|
|
error_t (*read_data)(struct Device* device, TickType_t timeout);
|
|
|
|
/**
|
|
* @brief Retrieves the coordinates most recently read by read_data().
|
|
* @param[in] device the pointer device
|
|
* @param[out] x array of X coordinates
|
|
* @param[out] y array of Y coordinates
|
|
* @param[out] strength optional array of touch strengths (nullable)
|
|
* @param[out] point_count the number of points currently touched
|
|
* @param[in] max_point_count the maximum number of points the arrays can hold
|
|
* @return true when touched and coordinates are available
|
|
*/
|
|
bool (*get_touched_points)(struct Device* device, uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* point_count, uint8_t max_point_count);
|
|
|
|
/**
|
|
* @brief Sets whether the X and Y axes should be swapped.
|
|
* @param[in] device the pointer device
|
|
* @retval ERROR_NONE when the operation was successful
|
|
*/
|
|
error_t (*set_swap_xy)(struct Device* device, bool swap);
|
|
|
|
/**
|
|
* @brief Gets whether the X and Y axes are swapped.
|
|
* @param[in] device the pointer device
|
|
* @retval ERROR_NONE when the operation was successful
|
|
*/
|
|
error_t (*get_swap_xy)(struct Device* device, bool* swap);
|
|
|
|
/**
|
|
* @brief Sets whether the X axis should be mirrored.
|
|
* @param[in] device the pointer device
|
|
* @retval ERROR_NONE when the operation was successful
|
|
*/
|
|
error_t (*set_mirror_x)(struct Device* device, bool mirror);
|
|
|
|
/**
|
|
* @brief Gets whether the X axis is mirrored.
|
|
* @param[in] device the pointer device
|
|
* @retval ERROR_NONE when the operation was successful
|
|
*/
|
|
error_t (*get_mirror_x)(struct Device* device, bool* mirror);
|
|
|
|
/**
|
|
* @brief Sets whether the Y axis should be mirrored.
|
|
* @param[in] device the pointer device
|
|
* @retval ERROR_NONE when the operation was successful
|
|
*/
|
|
error_t (*set_mirror_y)(struct Device* device, bool mirror);
|
|
|
|
/**
|
|
* @brief Gets whether the Y axis is mirrored.
|
|
* @param[in] device the pointer device
|
|
* @retval ERROR_NONE when the operation was successful
|
|
*/
|
|
error_t (*get_mirror_y)(struct Device* device, bool* mirror);
|
|
};
|
|
|
|
/**
|
|
* @brief Puts the pointer controller into its low-power sleep mode using the specified pointer device.
|
|
*/
|
|
error_t pointer_enter_sleep(struct Device* device);
|
|
|
|
/**
|
|
* @brief Wakes the pointer controller from sleep mode using the specified pointer device.
|
|
*/
|
|
error_t pointer_exit_sleep(struct Device* device);
|
|
|
|
/**
|
|
* @brief Performs a blocking read of the latest touch data using the specified pointer device.
|
|
*/
|
|
error_t pointer_read_data(struct Device* device, TickType_t timeout);
|
|
|
|
/**
|
|
* @brief Retrieves the coordinates most recently read using the specified pointer device.
|
|
*/
|
|
bool pointer_get_touched_points(struct Device* device, uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* point_count, uint8_t max_point_count);
|
|
|
|
/**
|
|
* @brief Sets whether the X and Y axes should be swapped using the specified pointer device.
|
|
*/
|
|
error_t pointer_set_swap_xy(struct Device* device, bool swap);
|
|
|
|
/**
|
|
* @brief Gets whether the X and Y axes are swapped using the specified pointer device.
|
|
*/
|
|
error_t pointer_get_swap_xy(struct Device* device, bool* swap);
|
|
|
|
/**
|
|
* @brief Sets whether the X axis should be mirrored using the specified pointer device.
|
|
*/
|
|
error_t pointer_set_mirror_x(struct Device* device, bool mirror);
|
|
|
|
/**
|
|
* @brief Gets whether the X axis is mirrored using the specified pointer device.
|
|
*/
|
|
error_t pointer_get_mirror_x(struct Device* device, bool* mirror);
|
|
|
|
/**
|
|
* @brief Sets whether the Y axis should be mirrored using the specified pointer device.
|
|
*/
|
|
error_t pointer_set_mirror_y(struct Device* device, bool mirror);
|
|
|
|
/**
|
|
* @brief Gets whether the Y axis is mirrored using the specified pointer device.
|
|
*/
|
|
error_t pointer_get_mirror_y(struct Device* device, bool* mirror);
|
|
|
|
extern const struct DeviceType POINTER_TYPE;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|