From c165d6f7e120a183ab8169f133590f84de4af7a0 Mon Sep 17 00:00:00 2001 From: Lucinhu <78008990+lucinhu@users.noreply.github.com> Date: Fri, 14 Mar 2025 23:40:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3sensecap-watcher?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8=20(#348)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sensecap-watcher/sensecap_watcher.cc | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/main/boards/sensecap-watcher/sensecap_watcher.cc b/main/boards/sensecap-watcher/sensecap_watcher.cc index 28b78409..88ef12cf 100644 --- a/main/boards/sensecap-watcher/sensecap_watcher.cc +++ b/main/boards/sensecap-watcher/sensecap_watcher.cc @@ -1,3 +1,5 @@ +#include "display/lv_display.h" +#include "misc/lv_event.h" #include "wifi_board.h" #include "sensecap_audio_codec.h" #include "display/lcd_display.h" @@ -205,7 +207,7 @@ private: esp_lcd_panel_init(panel_); esp_lcd_panel_mirror(panel_, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y); esp_lcd_panel_disp_on_off(panel_, true); - + display_ = new SpiLcdDisplay(panel_io_, panel_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, { @@ -213,6 +215,23 @@ private: .icon_font = &font_awesome_30_4, .emoji_font = font_emoji_64_init(), }); + + // 使每次刷新的行数是4的倍数,防止花屏 + lv_display_add_event_cb(lv_display_get_default(), [](lv_event_t *e) { + lv_area_t *area = (lv_area_t *)lv_event_get_param(e); + uint16_t x1 = area->x1; + uint16_t x2 = area->x2; + // round the start of area down to the nearest 4N number + area->x1 = (x1 >> 2) << 2; + // round the start of area down to the nearest 4N number + area->x1 = (x1 >> 2) << 2; + + // round the end of area up to the nearest 4M+3 number + area->x2 = ((x2 >> 2) << 2) + 3; + // round the end of area up to the nearest 4M+3 number + area->x2 = ((x2 >> 2) << 2) + 3; + }, LV_EVENT_INVALIDATE_AREA, NULL); + } // 物联网初始化,添加对 AI 可见设备