Ken Van Hoeylandt 50c0a14a93
New kernel drivers and more (#560)
- 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
2026-07-12 00:29:12 +02:00

261 lines
8.5 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>
/**
* @brief Pixel color formats supported by display panel drivers.
*/
enum DisplayColorFormat {
DISPLAY_COLOR_FORMAT_MONOCHROME = 0x0, // 1 bpp
DISPLAY_COLOR_FORMAT_BGR565 = 0x1,
DISPLAY_COLOR_FORMAT_BGR565_SWAPPED = 0x2,
DISPLAY_COLOR_FORMAT_RGB565 = 0x3,
DISPLAY_COLOR_FORMAT_RGB565_SWAPPED = 0x4,
DISPLAY_COLOR_FORMAT_RGB888 = 0x5,
};
/**
* @brief API for display panel drivers.
*/
struct DisplayApi {
/**
* @brief Performs a hardware reset of the panel (e.g. toggling a reset GPIO).
* @param[in] device the display device
* @retval ERROR_NONE when the operation was successful
*/
error_t (*reset)(struct Device* device);
/**
* @brief Sends the panel's initialization command sequence. Call after reset().
* @param[in] device the display device
* @retval ERROR_NONE when the operation was successful
*/
error_t (*init)(struct Device* device);
/**
* @brief Draws pixel data into the given rectangle.
* @param[in] device the display device
* @param[in] x_start left edge (inclusive)
* @param[in] y_start top edge (inclusive)
* @param[in] x_end right edge (exclusive)
* @param[in] y_end bottom edge (exclusive)
* @param[in] color_data pixel data in the panel's configured color format
* @retval ERROR_NONE when the operation was successful
*/
error_t (*draw_bitmap)(struct Device* device, int32_t x_start, int32_t y_start, int32_t x_end, int32_t y_end, const void* color_data);
/**
* @brief Mirrors the image along the X and/or Y axis.
* @param[in] device the display device
* @retval ERROR_NONE when the operation was successful
*/
error_t (*mirror)(struct Device* device, bool x_axis, bool y_axis);
/**
* @brief Swaps the X and Y axes (rotates the coordinate system).
* @param[in] device the display device
* @retval ERROR_NONE when the operation was successful
*/
error_t (*swap_xy)(struct Device* device, bool swap_axes);
/**
* @brief Gets whether the X and Y axes are currently swapped.
* @param[in] device the display device
* @return true if swapped
*/
bool (*get_swap_xy)(struct Device* device);
/**
* @brief Gets whether the X axis is currently mirrored.
* @param[in] device the display device
* @return true if mirrored
*/
bool (*get_mirror_x)(struct Device* device);
/**
* @brief Gets whether the Y axis is currently mirrored.
* @param[in] device the display device
* @return true if mirrored
*/
bool (*get_mirror_y)(struct Device* device);
/**
* @brief Sets a coordinate offset applied to all draw operations.
* @param[in] device the display device
* @retval ERROR_NONE when the operation was successful
*/
error_t (*set_gap)(struct Device* device, int32_t x_gap, int32_t y_gap);
/**
* @brief Inverts the panel's color output.
* @param[in] device the display device
* @retval ERROR_NONE when the operation was successful
*/
error_t (*invert_color)(struct Device* device, bool invert_color_data);
/**
* @brief Turns the panel's display output on or off.
* @param[in] device the display device
* @retval ERROR_NONE when the operation was successful
*/
error_t (*disp_on_off)(struct Device* device, bool on_off);
/**
* @brief Puts the panel into or out of its low-power sleep mode.
* @param[in] device the display device
* @retval ERROR_NONE when the operation was successful
*/
error_t (*disp_sleep)(struct Device* device, bool sleep);
/**
* @brief Gets the panel's pixel color format.
* @param[in] device the display device
* @return the color format
*/
enum DisplayColorFormat (*get_color_format)(struct Device* device);
/**
* @brief Gets the panel's horizontal resolution in pixels.
* @param[in] device the display device
* @return the horizontal resolution
*/
uint16_t (*get_resolution_x)(struct Device* device);
/**
* @brief Gets the panel's vertical resolution in pixels.
* @param[in] device the display device
* @return the vertical resolution
*/
uint16_t (*get_resolution_y)(struct Device* device);
/**
* @brief Gets a pointer to one of the panel's frame buffers, for panels that expose direct frame buffer access.
* @param[in] device the display device
* @param[in] index the frame buffer index (see get_frame_buffer_count())
* @param[out] out_buffer the buffer pointer
*/
void (*get_frame_buffer)(struct Device* device, uint8_t index, void** out_buffer);
/**
* @brief Gets the number of frame buffers exposed by the panel via get_frame_buffer(). 0 when unsupported.
* @param[in] device the display device
* @return the frame buffer count
*/
uint8_t (*get_frame_buffer_count)(struct Device* device);
/**
* @brief Gets the backlight device associated with this display, if any.
* @param[in] device the display device
* @param[out] backlight the associated backlight device
* @retval ERROR_NONE when a backlight is available and *backlight was set
* @retval ERROR_NOT_SUPPORTED when this display has no associated backlight
*/
error_t (*get_backlight)(struct Device* device, struct Device** backlight);
};
/**
* @brief Performs a hardware reset of the panel using the specified display.
*/
error_t display_reset(struct Device* device);
/**
* @brief Sends the panel's initialization command sequence using the specified display.
*/
error_t display_init(struct Device* device);
/**
* @brief Draws pixel data into the given rectangle using the specified display.
*/
error_t display_draw_bitmap(struct Device* device, int32_t x_start, int32_t y_start, int32_t x_end, int32_t y_end, const void* color_data);
/**
* @brief Mirrors the image along the X and/or Y axis using the specified display.
*/
error_t display_mirror(struct Device* device, bool x_axis, bool y_axis);
/**
* @brief Swaps the X and Y axes using the specified display.
*/
error_t display_swap_xy(struct Device* device, bool swap_axes);
/**
* @brief Gets whether the X and Y axes are currently swapped using the specified display.
*/
bool display_get_swap_xy(struct Device* device);
/**
* @brief Gets whether the X axis is currently mirrored using the specified display.
*/
bool display_get_mirror_x(struct Device* device);
/**
* @brief Gets whether the Y axis is currently mirrored using the specified display.
*/
bool display_get_mirror_y(struct Device* device);
/**
* @brief Sets a coordinate offset applied to all draw operations using the specified display.
*/
error_t display_set_gap(struct Device* device, int32_t x_gap, int32_t y_gap);
/**
* @brief Inverts the panel's color output using the specified display.
*/
error_t display_invert_color(struct Device* device, bool invert_color_data);
/**
* @brief Turns the panel's display output on or off using the specified display.
*/
error_t display_disp_on_off(struct Device* device, bool on_off);
/**
* @brief Puts the panel into or out of its low-power sleep mode using the specified display.
*/
error_t display_disp_sleep(struct Device* device, bool sleep);
/**
* @brief Gets the pixel color format using the specified display.
*/
enum DisplayColorFormat display_get_color_format(struct Device* device);
/**
* @brief Gets the horizontal resolution in pixels using the specified display.
*/
uint16_t display_get_resolution_x(struct Device* device);
/**
* @brief Gets the vertical resolution in pixels using the specified display.
*/
uint16_t display_get_resolution_y(struct Device* device);
/**
* @brief Gets a pointer to one of the panel's frame buffers using the specified display.
*/
void display_get_frame_buffer(struct Device* device, uint8_t index, void** out_buffer);
/**
* @brief Gets the number of frame buffers exposed by the panel using the specified display.
*/
uint8_t display_get_frame_buffer_count(struct Device* device);
/**
* @brief Gets the backlight device associated with the specified display, if any.
* @retval ERROR_NONE when a backlight is available and *backlight was set
* @retval ERROR_NOT_SUPPORTED when the display has no associated backlight
*/
error_t display_get_backlight(struct Device* device, struct Device** backlight);
extern const struct DeviceType DISPLAY_TYPE;
#ifdef __cplusplus
}
#endif