Fixes
This commit is contained in:
parent
3eb49b31af
commit
3a6e7cc5ec
@ -113,6 +113,7 @@ static void lcd_init(void)
|
||||
// Initialize panel first
|
||||
esp_lcd_panel_reset(panel_handle);
|
||||
esp_lcd_panel_init(panel_handle);
|
||||
esp_lcd_panel_swap_xy(panel_handle, true);
|
||||
esp_lcd_panel_disp_on_off(panel_handle, true);
|
||||
|
||||
// Now set up synchronization after panel is ready
|
||||
@ -147,10 +148,10 @@ static void touch_init(void)
|
||||
touch_io_cfg.scl_speed_hz = TOUCH_I2C_FREQ_HZ;
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_bus, &touch_io_cfg, &touch_io));
|
||||
|
||||
// GT911 Touch Controller
|
||||
// GT911 Touch Controller (with rotation for landscape)
|
||||
esp_lcd_touch_config_t touch_cfg = {
|
||||
.x_max = LCD_H_RES,
|
||||
.y_max = LCD_V_RES,
|
||||
.x_max = LCD_V_RES, // Swapped for landscape
|
||||
.y_max = LCD_H_RES,
|
||||
.rst_gpio_num = TOUCH_RST_GPIO,
|
||||
.int_gpio_num = TOUCH_INT_GPIO,
|
||||
.levels = {
|
||||
@ -158,8 +159,8 @@ static void touch_init(void)
|
||||
.interrupt = 0,
|
||||
},
|
||||
.flags = {
|
||||
.swap_xy = 0,
|
||||
.mirror_x = 0,
|
||||
.swap_xy = 1, // Swap X/Y for 90° rotation
|
||||
.mirror_x = 1, // Mirror X for correct orientation
|
||||
.mirror_y = 0,
|
||||
},
|
||||
};
|
||||
@ -197,6 +198,9 @@ static void lvgl_init(void)
|
||||
// Set color format to match panel (RGB888 = 24-bit)
|
||||
lv_display_set_color_format(display1, LV_COLOR_FORMAT_RGB888);
|
||||
|
||||
// Rotate to landscape
|
||||
lv_display_set_rotation(display1, LV_DISPLAY_ROTATION_90);
|
||||
|
||||
// Allocate buffers in PSRAM with proper alignment for DMA
|
||||
size_t buf_size = LCD_H_RES * 100 * 3; // 100 lines at a time, RGB888
|
||||
uint8_t *buf1 = heap_caps_aligned_alloc(64, buf_size,
|
||||
@ -223,28 +227,31 @@ static void lvgl_init(void)
|
||||
lv_display_set_default(display1);
|
||||
}
|
||||
|
||||
// ================= Button Callback ===================
|
||||
static void btn_event_cb(lv_event_t *e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if (code == LV_EVENT_CLICKED) {
|
||||
ESP_LOGI(TAG, "Button clicked!");
|
||||
}
|
||||
}
|
||||
|
||||
// ================= UI erstellen ===================
|
||||
static void create_ui(void)
|
||||
{
|
||||
// Button erstellen
|
||||
lv_obj_t *btn = lv_button_create(lv_screen_active());
|
||||
lv_obj_set_size(btn, 200, 80);
|
||||
lv_obj_center(btn);
|
||||
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL);
|
||||
// Tileview für Swipe-Pages
|
||||
lv_obj_t *tileview = lv_tileview_create(lv_screen_active());
|
||||
|
||||
// Label auf dem Button
|
||||
lv_obj_t *label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Klick mich!");
|
||||
lv_obj_center(label);
|
||||
// Seite 1 - Blau
|
||||
lv_obj_t *tile1 = lv_tileview_add_tile(tileview, 0, 0, LV_DIR_RIGHT);
|
||||
lv_obj_set_style_bg_color(tile1, lv_color_hex(0x2196F3), 0);
|
||||
|
||||
lv_obj_t *label1 = lv_label_create(tile1);
|
||||
lv_label_set_text(label1, "Seite 1\n\nSwipe nach links ->");
|
||||
lv_obj_set_style_text_color(label1, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_font(label1, &lv_font_montserrat_28, 0);
|
||||
lv_obj_center(label1);
|
||||
|
||||
// Seite 2 - Grün
|
||||
lv_obj_t *tile2 = lv_tileview_add_tile(tileview, 1, 0, LV_DIR_LEFT);
|
||||
lv_obj_set_style_bg_color(tile2, lv_color_hex(0x4CAF50), 0);
|
||||
|
||||
lv_obj_t *label2 = lv_label_create(tile2);
|
||||
lv_label_set_text(label2, "Seite 2\n\n<- Swipe nach rechts");
|
||||
lv_obj_set_style_text_color(label2, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_font(label2, &lv_font_montserrat_28, 0);
|
||||
lv_obj_center(label2);
|
||||
}
|
||||
|
||||
// ================= Main ===================
|
||||
|
||||
Loading…
Reference in New Issue
Block a user