Merge develop into main (#303)

- `DisplayDevice` improvements related `DisplayDriver`
- Replaced incorrect usage of `spiBusHandle` with `spiHostDevice` in all SPI display devices
- Disabled `DisplayDriver` support for RGB displays for now
- Updated `GraphicsDemo` project for the above changes
- TactilityC improvements:
  - created `tt_hal_device_find()`
  - created `tt_hal_display_*`
  - created `tt_hal_touch_*`
  - created `tt_lvgl_*`
  - export `tt_app_*` calls
This commit is contained in:
Ken Van Hoeylandt
2025-08-17 22:48:51 +02:00
committed by GitHub
parent d875ade8cb
commit fbaff8cbac
43 changed files with 1554 additions and 70 deletions
@@ -0,0 +1,35 @@
#pragma once
class Colors {
public:
static void rgb888ToRgb565(uint8_t red, uint8_t green, uint8_t blue, uint16_t* rgb565) {
uint16_t _rgb565 = (red >> 3);
_rgb565 = (_rgb565 << 6) | (green >> 2);
_rgb565 = (_rgb565 << 5) | (blue >> 3);
*rgb565 = _rgb565;
}
static void rgb888ToBgr565(uint8_t red, uint8_t green, uint8_t blue, uint16_t* bgr565) {
uint16_t _bgr565 = (blue >> 3);
_bgr565 = (_bgr565 << 6) | (green >> 2);
_bgr565 = (_bgr565 << 5) | (red >> 3);
*bgr565 = _bgr565;
}
static void rgb565ToRgb888(uint16_t rgb565, uint32_t* rgb888) {
uint32_t _rgb565 = rgb565;
uint8_t b = (_rgb565 >> 8) & 0xF8;
uint8_t g = (_rgb565 >> 3) & 0xFC;
uint8_t r = (_rgb565 << 3) & 0xF8;
uint8_t* r8p = reinterpret_cast<uint8_t*>(rgb888);
uint8_t* g8p = r8p + 1;
uint8_t* b8p = r8p + 2;
*r8p = r | ((r >> 3) & 0x7);
*g8p = g | ((g >> 2) & 0x3);
*b8p = b | ((b >> 3) & 0x7);
}
};
@@ -0,0 +1,48 @@
#pragma once
#include <cassert>
#include <tt_hal_display.h>
/**
* Wrapper for tt_hal_display_driver_*
*/
class DisplayDriver {
DisplayDriverHandle handle = nullptr;
public:
explicit DisplayDriver(DeviceId id) {
assert(tt_hal_display_driver_supported(id));
handle = tt_hal_display_driver_alloc(id);
assert(handle != nullptr);
}
~DisplayDriver() {
tt_hal_display_driver_free(handle);
}
bool lock(TickType timeout = MAX_TICKS) const {
return tt_hal_display_driver_lock(handle, timeout);
}
void unlock() const {
tt_hal_display_driver_unlock(handle);
}
uint16_t getWidth() const {
return tt_hal_display_driver_get_pixel_width(handle);
}
uint16_t getHeight() const {
return tt_hal_display_driver_get_pixel_height(handle);
}
ColorFormat getColorFormat() const {
return tt_hal_display_driver_get_colorformat(handle);
}
void drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) const {
tt_hal_display_driver_draw_bitmap(handle, xStart, yStart, xEnd, yEnd, pixelData);
}
};
@@ -0,0 +1,28 @@
#pragma once
#include <cassert>
#include <tt_hal_touch.h>
/**
* Wrapper for tt_hal_touch_driver_*
*/
class TouchDriver {
TouchDriverHandle handle = nullptr;
public:
explicit TouchDriver(DeviceId id) {
assert(tt_hal_touch_driver_supported(id));
handle = tt_hal_touch_driver_alloc(id);
assert(handle != nullptr);
}
~TouchDriver() {
tt_hal_touch_driver_free(handle);
}
bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* count, uint8_t maxCount) const {
return tt_hal_touch_driver_get_touched_points(handle, x, y, strength, count, maxCount);
}
};