mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-08-20 17:05:06 +00:00
Compare commits
3 Commits
b3c6be7291
...
67d9f817ba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67d9f817ba | ||
|
|
27c9637209 | ||
|
|
5b728956c5 |
@ -89,7 +89,7 @@
|
||||
aw9523_sdcard_switch {
|
||||
compatible = "gpio-hog";
|
||||
pin = <&aw9523b 4 GPIO_FLAG_NONE>;
|
||||
mode = <GPIO_HOG_MODE_OUTPUT_HIGH>;
|
||||
mode = <GPIO_HOG_MODE_INPUT>;
|
||||
};
|
||||
|
||||
aw9523_boost_enable {
|
||||
|
||||
@ -324,6 +324,21 @@ static error_t ili9341_set_gap(Device* device, int32_t x_gap, int32_t y_gap) {
|
||||
return esp_lcd_panel_set_gap(internal->panel_handle, x_gap, y_gap) == ESP_OK ? ERROR_NONE : ERROR_RESOURCE;
|
||||
}
|
||||
|
||||
// Reads the devicetree-configured baseline, not live hardware state - see DisplayApi::get_gap_x().
|
||||
// Must match what start() actually programmed into the panel (physical CASET/RASET-space, swapped
|
||||
// when swap_xy is set) - lvgl_display.c treats this as the LV_DISPLAY_ROTATION_0 baseline and
|
||||
// re-applies it verbatim, so returning the raw unswapped config here would silently clobber
|
||||
// start()'s gap back to the wrong axes as soon as a display is bound.
|
||||
static int32_t ili9341_get_gap_x(Device* device) {
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_y : config->gap_x;
|
||||
}
|
||||
|
||||
static int32_t ili9341_get_gap_y(Device* device) {
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_x : config->gap_y;
|
||||
}
|
||||
|
||||
static error_t ili9341_invert_color(Device* device, bool invert_color_data) {
|
||||
auto* internal = static_cast<Ili9341Internal*>(device_get_driver_data(device));
|
||||
return esp_lcd_panel_invert_color(internal->panel_handle, invert_color_data) == ESP_OK ? ERROR_NONE : ERROR_RESOURCE;
|
||||
@ -392,6 +407,8 @@ static const DisplayApi ili9341_display_api = {
|
||||
.get_mirror_x = ili9341_get_mirror_x,
|
||||
.get_mirror_y = ili9341_get_mirror_y,
|
||||
.set_gap = ili9341_set_gap,
|
||||
.get_gap_x = ili9341_get_gap_x,
|
||||
.get_gap_y = ili9341_get_gap_y,
|
||||
.invert_color = ili9341_invert_color,
|
||||
.disp_on_off = ili9341_disp_on_off,
|
||||
.disp_sleep = ili9341_disp_sleep,
|
||||
|
||||
@ -246,6 +246,21 @@ static error_t ili9488_set_gap(Device* device, int32_t x_gap, int32_t y_gap) {
|
||||
return esp_lcd_panel_set_gap(internal->panel_handle, x_gap, y_gap) == ESP_OK ? ERROR_NONE : ERROR_RESOURCE;
|
||||
}
|
||||
|
||||
// Reads the devicetree-configured baseline, not live hardware state - see DisplayApi::get_gap_x().
|
||||
// Must match what start() actually programmed into the panel (physical CASET/RASET-space, swapped
|
||||
// when swap_xy is set) - lvgl_display.c treats this as the LV_DISPLAY_ROTATION_0 baseline and
|
||||
// re-applies it verbatim, so returning the raw unswapped config here would silently clobber
|
||||
// start()'s gap back to the wrong axes as soon as a display is bound.
|
||||
static int32_t ili9488_get_gap_x(Device* device) {
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_y : config->gap_x;
|
||||
}
|
||||
|
||||
static int32_t ili9488_get_gap_y(Device* device) {
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_x : config->gap_y;
|
||||
}
|
||||
|
||||
static error_t ili9488_invert_color(Device* device, bool invert_color_data) {
|
||||
auto* internal = static_cast<Ili9488Internal*>(device_get_driver_data(device));
|
||||
return esp_lcd_panel_invert_color(internal->panel_handle, invert_color_data) == ESP_OK ? ERROR_NONE : ERROR_RESOURCE;
|
||||
@ -311,6 +326,8 @@ static const DisplayApi ili9488_display_api = {
|
||||
.get_mirror_x = ili9488_get_mirror_x,
|
||||
.get_mirror_y = ili9488_get_mirror_y,
|
||||
.set_gap = ili9488_set_gap,
|
||||
.get_gap_x = ili9488_get_gap_x,
|
||||
.get_gap_y = ili9488_get_gap_y,
|
||||
.invert_color = ili9488_invert_color,
|
||||
.disp_on_off = ili9488_disp_on_off,
|
||||
.disp_sleep = ili9488_disp_sleep,
|
||||
|
||||
@ -24,6 +24,7 @@ static constexpr uint8_t REG_FIFO_EN = 0x23; // FIFO enable
|
||||
static constexpr uint8_t REG_WHO_AM_I = 0x75; // chip ID — expect 0x19
|
||||
|
||||
static constexpr uint8_t WHO_AM_I_VALUE = 0x19;
|
||||
static constexpr uint8_t WHO_AM_I_ATTEMPTS = 5;
|
||||
|
||||
// Configuration values
|
||||
// GYRO_CONFIG: FS_SEL=3 (±2000°/s), FCHOICE_B=00 → 0x18
|
||||
@ -54,10 +55,16 @@ static error_t start(Device* device) {
|
||||
|
||||
auto address = GET_CONFIG(device)->address;
|
||||
|
||||
// Verify chip ID
|
||||
// Verify chip ID: it might take more than 1 attempt at power up (on M5Stack Core2)
|
||||
uint8_t who_am_i = 0;
|
||||
if (i2c_controller_register8_get(i2c_controller, address, REG_WHO_AM_I, &who_am_i, I2C_TIMEOUT_TICKS) != ERROR_NONE
|
||||
|| who_am_i != WHO_AM_I_VALUE) {
|
||||
for (int i = 0; i < WHO_AM_I_ATTEMPTS; i++) {
|
||||
if (i2c_controller_register8_get(i2c_controller, address, REG_WHO_AM_I, &who_am_i, I2C_TIMEOUT_TICKS) == ERROR_NONE) {
|
||||
break;
|
||||
}
|
||||
vTaskDelay(10);
|
||||
}
|
||||
|
||||
if (who_am_i != WHO_AM_I_VALUE) {
|
||||
LOG_E(TAG, "WHO_AM_I mismatch: got 0x%02X, expected 0x%02X", who_am_i, WHO_AM_I_VALUE);
|
||||
return ERROR_RESOURCE;
|
||||
}
|
||||
|
||||
@ -138,11 +138,13 @@ static error_t start(Device* device) {
|
||||
esp_lcd_panel_init(internal->panel_handle) == ESP_OK &&
|
||||
(!config->invert_color || esp_lcd_panel_invert_color(internal->panel_handle, true) == ESP_OK);
|
||||
|
||||
// set_gap() just stores x_gap/y_gap and adds them as raw offsets wherever draw_bitmap()'s
|
||||
// (already logical, post-swap) x/y land - independent of swap_xy/mirror state (confirmed via
|
||||
// ESP-IDF's esp_lcd_panel_st7789.c, same pattern), so gap_x/gap_y are passed through unswapped.
|
||||
// set_gap()'s x/y map straight to the physical CASET/RASET column/row registers, not to
|
||||
// draw_bitmap()'s logical (post-swap) x/y - swap_xy transposes which physical axis those
|
||||
// registers address, so the configured gaps must swap with it too
|
||||
int32_t gap_x = config->swap_xy ? config->gap_y : config->gap_x;
|
||||
int32_t gap_y = config->swap_xy ? config->gap_x : config->gap_y;
|
||||
if (ok) {
|
||||
ok = (config->gap_x == 0 && config->gap_y == 0) || esp_lcd_panel_set_gap(internal->panel_handle, config->gap_x, config->gap_y) == ESP_OK;
|
||||
ok = (gap_x == 0 && gap_y == 0) || esp_lcd_panel_set_gap(internal->panel_handle, gap_x, gap_y) == ESP_OK;
|
||||
}
|
||||
ok = ok && (!config->swap_xy || esp_lcd_panel_swap_xy(internal->panel_handle, true) == ESP_OK);
|
||||
ok = ok && ((!config->mirror_x && !config->mirror_y) || esp_lcd_panel_mirror(internal->panel_handle, config->mirror_x, config->mirror_y) == ESP_OK);
|
||||
@ -252,12 +254,18 @@ static error_t st7735_set_gap(Device* device, int32_t x_gap, int32_t y_gap) {
|
||||
}
|
||||
|
||||
// Reads the devicetree-configured baseline, not live hardware state - see DisplayApi::get_gap_x().
|
||||
// Must match what start() actually programmed into the panel (physical CASET/RASET-space, swapped
|
||||
// when swap_xy is set) - lvgl_display.c treats this as the LV_DISPLAY_ROTATION_0 baseline and
|
||||
// re-applies it verbatim, so returning the raw unswapped config here would silently clobber
|
||||
// start()'s gap back to the wrong axes as soon as a display is bound.
|
||||
static int32_t st7735_get_gap_x(Device* device) {
|
||||
return GET_CONFIG(device)->gap_x;
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_y : config->gap_x;
|
||||
}
|
||||
|
||||
static int32_t st7735_get_gap_y(Device* device) {
|
||||
return GET_CONFIG(device)->gap_y;
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_x : config->gap_y;
|
||||
}
|
||||
|
||||
static error_t st7735_invert_color(Device* device, bool invert_color_data) {
|
||||
|
||||
@ -275,6 +275,21 @@ static bool st7789_i8080_get_mirror_y(Device* device) {
|
||||
return GET_CONFIG(device)->mirror_y;
|
||||
}
|
||||
|
||||
// Reads the devicetree-configured baseline, not live hardware state - see DisplayApi::get_gap_x().
|
||||
// Must match what start() actually programmed into the panel (physical CASET/RASET-space, swapped
|
||||
// when swap_xy is set) - lvgl_display.c treats this as the LV_DISPLAY_ROTATION_0 baseline and
|
||||
// re-applies it verbatim, so returning the raw unswapped config here would silently clobber
|
||||
// start()'s gap back to the wrong axes as soon as a display is bound.
|
||||
static int32_t st7789_i8080_get_gap_x(Device* device) {
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_y : config->gap_x;
|
||||
}
|
||||
|
||||
static int32_t st7789_i8080_get_gap_y(Device* device) {
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_x : config->gap_y;
|
||||
}
|
||||
|
||||
static error_t st7789_i8080_set_gap(Device* device, int32_t x_gap, int32_t y_gap) {
|
||||
auto* internal = static_cast<St7789I8080Internal*>(device_get_driver_data(device));
|
||||
return esp_lcd_panel_set_gap(internal->panel_handle, x_gap, y_gap) == ESP_OK ? ERROR_NONE : ERROR_RESOURCE;
|
||||
@ -342,6 +357,8 @@ static const DisplayApi st7789_i8080_display_api = {
|
||||
.get_mirror_x = st7789_i8080_get_mirror_x,
|
||||
.get_mirror_y = st7789_i8080_get_mirror_y,
|
||||
.set_gap = st7789_i8080_set_gap,
|
||||
.get_gap_x = st7789_i8080_get_gap_x,
|
||||
.get_gap_y = st7789_i8080_get_gap_y,
|
||||
.invert_color = st7789_i8080_invert_color,
|
||||
.disp_on_off = st7789_i8080_disp_on_off,
|
||||
.disp_sleep = st7789_i8080_disp_sleep,
|
||||
|
||||
@ -138,11 +138,13 @@ static error_t start(Device* device) {
|
||||
esp_lcd_panel_init(internal->panel_handle) == ESP_OK &&
|
||||
(!config->invert_color || esp_lcd_panel_invert_color(internal->panel_handle, true) == ESP_OK);
|
||||
|
||||
// set_gap() just stores x_gap/y_gap and adds them as raw offsets wherever draw_bitmap()'s
|
||||
// (already logical, post-swap) x/y land - independent of swap_xy/mirror state (confirmed via
|
||||
// ESP-IDF's esp_lcd_panel_st7789.c), so gap_x/gap_y are passed through unswapped.
|
||||
// set_gap()'s x/y map straight to the physical CASET/RASET column/row registers, not to
|
||||
// draw_bitmap()'s logical (post-swap) x/y - swap_xy transposes which physical axis those
|
||||
// registers address, so the configured gaps must swap with it too.
|
||||
int32_t gap_x = config->swap_xy ? config->gap_y : config->gap_x;
|
||||
int32_t gap_y = config->swap_xy ? config->gap_x : config->gap_y;
|
||||
if (ok) {
|
||||
ok = (config->gap_x == 0 && config->gap_y == 0) || esp_lcd_panel_set_gap(internal->panel_handle, config->gap_x, config->gap_y) == ESP_OK;
|
||||
ok = (gap_x == 0 && gap_y == 0) || esp_lcd_panel_set_gap(internal->panel_handle, gap_x, gap_y) == ESP_OK;
|
||||
}
|
||||
ok = ok && (!config->swap_xy || esp_lcd_panel_swap_xy(internal->panel_handle, true) == ESP_OK);
|
||||
ok = ok && ((!config->mirror_x && !config->mirror_y) || esp_lcd_panel_mirror(internal->panel_handle, config->mirror_x, config->mirror_y) == ESP_OK);
|
||||
@ -252,12 +254,18 @@ static error_t st7789_set_gap(Device* device, int32_t x_gap, int32_t y_gap) {
|
||||
}
|
||||
|
||||
// Reads the devicetree-configured baseline, not live hardware state - see DisplayApi::get_gap_x().
|
||||
// Must match what start() actually programmed into the panel (physical CASET/RASET-space, swapped
|
||||
// when swap_xy is set) - lvgl_display.c treats this as the LV_DISPLAY_ROTATION_0 baseline and
|
||||
// re-applies it verbatim, so returning the raw unswapped config here would silently clobber
|
||||
// start()'s gap back to the wrong axes as soon as a display is bound.
|
||||
static int32_t st7789_get_gap_x(Device* device) {
|
||||
return GET_CONFIG(device)->gap_x;
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_y : config->gap_x;
|
||||
}
|
||||
|
||||
static int32_t st7789_get_gap_y(Device* device) {
|
||||
return GET_CONFIG(device)->gap_y;
|
||||
const auto* config = GET_CONFIG(device);
|
||||
return config->swap_xy ? config->gap_x : config->gap_y;
|
||||
}
|
||||
|
||||
static error_t st7789_invert_color(Device* device, bool invert_color_data) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user