Migrate TactilityC and LVGL functionality (#588)
lvgl-module - Move and rename source and include files - Fix bug with missing lvgl unlock - New widgets: spinner, toolbar, sliderbox TactilityC - Removed tt_lock, tt_lvgl_\*
This commit is contained in:
committed by
GitHub
parent
cd2d9d6158
commit
b98a813f3c
@@ -0,0 +1,86 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configuration for binding a kernel DisplayApi device to an lv_display_t.
|
||||
*/
|
||||
struct LvglDisplayConfig {
|
||||
/**
|
||||
* Number of horizontal lines per draw buffer. 0 means the full vertical resolution.
|
||||
* Ignored when the device exposes its own frame buffer(s) (display_get_frame_buffer_count() > 0).
|
||||
*/
|
||||
uint16_t buffer_height;
|
||||
|
||||
/**
|
||||
* Allocates a second draw buffer for double buffering.
|
||||
* Ignored when the device exposes its own frame buffer(s).
|
||||
*/
|
||||
bool double_buffer;
|
||||
|
||||
/**
|
||||
* Rotate LVGL_rendered content in software instead of calling display_swap_xy()/display_mirror()
|
||||
* on the device. Use this for panels whose driver can't rotate in hardware (e.g. RGB/DPI panels).
|
||||
* Allocates one extra buffer sized like the primary draw buffer.
|
||||
*/
|
||||
bool sw_rotate;
|
||||
|
||||
/**
|
||||
* Endianness of the 2 bytes of each RGB565/BGR565 pixel sent to the panel. False (default)
|
||||
* keeps this little-endian CPU's native byte order (no-op). True swaps the 2 bytes of every
|
||||
* pixel (big-endian) in the flush callback, via lv_draw_sw_rgb565_swap() - for panels that
|
||||
* expect the opposite byte order over the bus. Ignored for color formats other than
|
||||
* RGB565/BGR565 (e.g. RGB888, MONOCHROME).
|
||||
*/
|
||||
bool swap_bytes;
|
||||
|
||||
/**
|
||||
* Forces LV_DISPLAY_RENDER_MODE_FULL with a full-resolution buffer, ignoring buffer_height,
|
||||
* and always flushes the entire display rather than per-tile dirty regions. Set this when the
|
||||
* device reports DISPLAY_CAPABILITY_REQUIRES_FULL_FRAME - see that capability's doc comment.
|
||||
* Ignored when the device exposes its own frame buffer(s) (already always-full-frame) or uses
|
||||
* the LV_COLOR_FORMAT_I1 path (already always-full-frame).
|
||||
*/
|
||||
bool force_full_frame;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Creates an lv_display_t bound to the given DISPLAY_TYPE device and registers a flush callback
|
||||
* that draws through the device's DisplayApi.
|
||||
*
|
||||
* The device's swap_xy/mirror_x/mirror_y state at the time of this call (via display_get_swap_xy() etc.)
|
||||
* is treated as the LV_DISPLAY_ROTATION_0 baseline; LVGL-driven rotation changes are applied relative to it.
|
||||
*
|
||||
* @warning Caller must hold the LVGL lock (see lvgl_lock() in lvgl_module.h) — call this from
|
||||
* LvglModuleConfig.on_start, or after calling lvgl_lock() explicitly.
|
||||
*
|
||||
* @param[in] device a device of type DISPLAY_TYPE
|
||||
* @param[in] config binding configuration
|
||||
* @param[out] out_display the created display, valid only when ERROR_NONE is returned
|
||||
* @retval ERROR_NONE on success
|
||||
* @retval ERROR_INVALID_ARGUMENT if device, config or out_display is NULL, or device is not of type DISPLAY_TYPE
|
||||
* @retval ERROR_NOT_SUPPORTED if the device's color format has no LVGL equivalent
|
||||
* @retval ERROR_OUT_OF_MEMORY if buffer or lv_display_t allocation failed
|
||||
*/
|
||||
error_t lvgl_display_add(struct Device* device, const struct LvglDisplayConfig* config, lv_display_t** out_display);
|
||||
|
||||
/**
|
||||
* @brief Removes a display previously created with lvgl_display_add(), freeing any buffers it owns.
|
||||
* @warning Caller must hold the LVGL lock.
|
||||
*/
|
||||
void lvgl_display_remove(lv_display_t* display);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Creates an lv_indev_t bound to the given KEYBOARD_TYPE device and registers a read callback
|
||||
* that polls the device through its KeyboardApi.
|
||||
*
|
||||
* @warning Caller must hold the LVGL lock (see lvgl_lock() in lvgl_module.h) — call this from
|
||||
* LvglModuleConfig.on_start, or after calling lvgl_lock() explicitly.
|
||||
*
|
||||
* @param[in] device a device of type KEYBOARD_TYPE
|
||||
* @param[in] display the display this indev should be associated with, or NULL to leave it unset
|
||||
* @param[out] out_indev the created indev, valid only when ERROR_NONE is returned
|
||||
* @retval ERROR_NONE on success
|
||||
* @retval ERROR_INVALID_ARGUMENT if device or out_indev is NULL, or device is not of type KEYBOARD_TYPE
|
||||
* @retval ERROR_OUT_OF_MEMORY if allocation failed
|
||||
*/
|
||||
error_t lvgl_keyboard_add(struct Device* device, lv_display_t* display, lv_indev_t** out_indev);
|
||||
|
||||
/**
|
||||
* @brief Removes an indev previously created with lvgl_keyboard_add().
|
||||
* @warning Caller must hold the LVGL lock.
|
||||
*/
|
||||
void lvgl_keyboard_remove(lv_indev_t* indev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/error.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Linear per-axis calibration range for raw pointer coordinates.
|
||||
*
|
||||
* Values are the raw (pre-calibration) coordinates that should map to the display's
|
||||
* [0, hor_res-1] / [0, ver_res-1] range. Corrects scale+offset error only; axis
|
||||
* swap/mirror is handled separately by PointerApi and applied by the driver before
|
||||
* lvgl_pointer_read_cb() sees the coordinates.
|
||||
*/
|
||||
struct LvglPointerCalibration {
|
||||
int32_t x_min;
|
||||
int32_t x_max;
|
||||
int32_t y_min;
|
||||
int32_t y_max;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Sets (or clears, when calibration is NULL) the calibration applied to raw coordinates
|
||||
* read from the device before they are written into LVGL indev data, on an indev previously
|
||||
* created with lvgl_pointer_add().
|
||||
*
|
||||
* @warning Caller must hold the LVGL lock (see lvgl_lock() in lvgl_module.h).
|
||||
*
|
||||
* @param[in] indev an indev previously created by lvgl_pointer_add()
|
||||
* @param[in] calibration the calibration range to apply, or NULL to clear/disable calibration
|
||||
* @retval ERROR_NONE on success
|
||||
* @retval ERROR_INVALID_ARGUMENT if indev is NULL, or calibration is non-NULL but invalid
|
||||
* (x_max <= x_min, y_max <= y_min, or either span smaller than the minimum allowed range)
|
||||
*/
|
||||
error_t lvgl_pointer_set_calibration(lv_indev_t* indev, const struct LvglPointerCalibration* calibration);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the calibration currently active on indev, if any.
|
||||
* @warning Caller must hold the LVGL lock.
|
||||
* @return true when a calibration is currently set on indev (out_calibration is filled), false otherwise
|
||||
*/
|
||||
bool lvgl_pointer_get_calibration(lv_indev_t* indev, struct LvglPointerCalibration* out_calibration);
|
||||
|
||||
/**
|
||||
* @brief Returns the first indev created by lvgl_pointer_add() that hasn't been removed yet.
|
||||
*
|
||||
* Unlike iterating LVGL's own indev list, this only ever returns an indev created by
|
||||
* lvgl_pointer_add() — safe to pass to lvgl_pointer_set_calibration()/lvgl_pointer_get_calibration()
|
||||
* without risking a foreign indev (e.g. one registered by the deprecated HAL layer) whose driver
|
||||
* data isn't a struct LvglPointerCtx*.
|
||||
*
|
||||
* @warning Caller must hold the LVGL lock.
|
||||
* @return the indev, or NULL if none is currently registered.
|
||||
*/
|
||||
lv_indev_t* lvgl_pointer_get_default(void);
|
||||
|
||||
/**
|
||||
* @brief Creates an lv_indev_t bound to the given POINTER_TYPE device and registers a read callback
|
||||
* that polls the device through its PointerApi.
|
||||
*
|
||||
* @warning Caller must hold the LVGL lock (see lvgl_lock() in lvgl_module.h) — call this from
|
||||
* LvglModuleConfig.on_start, or after calling lvgl_lock() explicitly.
|
||||
*
|
||||
* @param[in] device a device of type POINTER_TYPE
|
||||
* @param[in] display the display this indev should be associated with, or NULL to leave it unset
|
||||
* @param[out] out_indev the created indev, valid only when ERROR_NONE is returned
|
||||
* @retval ERROR_NONE on success
|
||||
* @retval ERROR_INVALID_ARGUMENT if device or out_indev is NULL, or device is not of type POINTER_TYPE
|
||||
* @retval ERROR_OUT_OF_MEMORY if allocation failed
|
||||
*/
|
||||
error_t lvgl_pointer_add(struct Device* device, lv_display_t* display, lv_indev_t** out_indev);
|
||||
|
||||
/**
|
||||
* @brief Removes an indev previously created with lvgl_pointer_add().
|
||||
* @warning Caller must hold the LVGL lock.
|
||||
*/
|
||||
void lvgl_pointer_remove(lv_indev_t* indev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user