feat: 实现设置页面及其功能

This commit is contained in:
2026-07-05 20:52:04 +08:00
parent 9a355e540c
commit 6a6ee41a07
15 changed files with 676 additions and 11 deletions
+9
View File
@@ -9,6 +9,15 @@
#define BOARD_LCD_PIXEL_CLOCK_HZ (20 * 1000 * 1000)
#define BOARD_LCD_H_RES 170
#define BOARD_LCD_V_RES 320
/* LVGL logical resolution after 90° rotation (landscape) */
#define BOARD_LCD_LOGIC_H_RES 320
#define BOARD_LCD_LOGIC_V_RES 170
/* Touch IC → physical panel alignment (not LVGL logical rotation) */
#define BOARD_TOUCH_SWAP_XY 0
#define BOARD_TOUCH_MIRROR_X 0
#define BOARD_TOUCH_MIRROR_Y 0
#define BOARD_LCD_PANEL_H_RES 240
#define BOARD_LCD_GAP_X ((BOARD_LCD_PANEL_H_RES - BOARD_LCD_H_RES) / 2)
#define BOARD_LCD_GAP_Y 0
+34 -6
View File
@@ -2,6 +2,7 @@
#include "board_config.h"
#include "draw/sw/lv_draw_sw.h"
#include "driver/spi_master.h"
#include "esp_lcd_panel_ops.h"
#include "esp_log.h"
@@ -31,14 +32,40 @@ static bool notify_flush_ready(esp_lcd_panel_io_handle_t panel_io,
static void flush_cb(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map)
{
esp_lcd_panel_handle_t panel_handle = lv_display_get_user_data(disp);
int offsetx1 = area->x1;
int offsetx2 = area->x2;
int offsety1 = area->y1;
int offsety2 = area->y2;
lv_draw_sw_rgb565_swap(px_map,
const lv_area_t *draw_area = area;
uint8_t *draw_buf = px_map;
static uint8_t rotated_buf[BOARD_LCD_H_RES * BOARD_LVGL_DRAW_BUF_LINES *
sizeof(lv_color16_t)];
lv_display_rotation_t rotation = lv_display_get_rotation(disp);
lv_area_t rotated_area;
if (rotation != LV_DISPLAY_ROTATION_0) {
lv_color_format_t cf = lv_display_get_color_format(disp);
rotated_area = *area;
lv_display_rotate_area(disp, &rotated_area);
int32_t src_w = lv_area_get_width(area);
int32_t src_h = lv_area_get_height(area);
uint32_t src_stride = lv_draw_buf_width_to_stride(src_w, cf);
uint32_t dest_stride =
lv_draw_buf_width_to_stride(lv_area_get_width(&rotated_area), cf);
lv_draw_sw_rotate(px_map, rotated_buf, src_w, src_h, src_stride,
dest_stride, rotation, cf);
draw_area = &rotated_area;
draw_buf = rotated_buf;
}
int offsetx1 = draw_area->x1;
int offsetx2 = draw_area->x2;
int offsety1 = draw_area->y1;
int offsety2 = draw_area->y2;
lv_draw_sw_rgb565_swap(draw_buf,
(offsetx2 + 1 - offsetx1) * (offsety2 + 1 - offsety1));
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1,
offsety2 + 1, px_map);
offsety2 + 1, draw_buf);
}
static void increase_lvgl_tick(void *arg)
@@ -80,6 +107,7 @@ lv_display_t *lvgl_port_init(esp_lcd_panel_io_handle_t io_handle,
lv_display_t *display =
lv_display_create(BOARD_LCD_H_RES, BOARD_LCD_V_RES);
lv_display_set_rotation(display, LV_DISPLAY_ROTATION_270);
size_t draw_buffer_sz = BOARD_LCD_H_RES * BOARD_LVGL_DRAW_BUF_LINES *
sizeof(lv_color16_t);
+3 -3
View File
@@ -86,9 +86,9 @@ esp_err_t touch_init(lv_display_t *display)
.interrupt = 0,
},
.flags = {
.swap_xy = 0,
.mirror_x = 0,
.mirror_y = 0,
.swap_xy = BOARD_TOUCH_SWAP_XY,
.mirror_x = BOARD_TOUCH_MIRROR_X,
.mirror_y = BOARD_TOUCH_MIRROR_Y,
},
.interrupt_callback = touch_isr_cb,
};