From 3efef0cf200f5f6cf5c94e98726f8534a4cdbd46 Mon Sep 17 00:00:00 2001 From: Terrence Date: Sat, 22 Mar 2025 06:00:22 +0800 Subject: [PATCH] fixbug: display spi error when setting brightness --- .../esp32-s3-touch-amoled-1.8.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main/boards/esp32-s3-touch-amoled-1.8/esp32-s3-touch-amoled-1.8.cc b/main/boards/esp32-s3-touch-amoled-1.8/esp32-s3-touch-amoled-1.8.cc index 584b3cbc..7e0a595a 100644 --- a/main/boards/esp32-s3-touch-amoled-1.8/esp32-s3-touch-amoled-1.8.cc +++ b/main/boards/esp32-s3-touch-amoled-1.8/esp32-s3-touch-amoled-1.8.cc @@ -38,6 +38,9 @@ public: WriteReg(0x90, 0x00); WriteReg(0x91, 0x00); + // Set DC1 to 3.3V + WriteReg(0x82, (3300 - 1500) / 100); + // Set ALDO1 to 3.3V WriteReg(0x92, (3300 - 500) / 100); @@ -64,8 +67,7 @@ static const sh8601_lcd_init_cmd_t vendor_specific_init[] = { {0x2A, (uint8_t[]){0x00, 0x00, 0x01, 0x6F}, 4, 0}, {0x2B, (uint8_t[]){0x00, 0x00, 0x01, 0xBF}, 4, 0}, {0x51, (uint8_t[]){0x00}, 1, 10}, - {0x29, (uint8_t[]){0x00}, 0, 10}, - {0x51, (uint8_t[]){0xFF}, 1, 0}, + {0x29, (uint8_t[]){0x00}, 0, 10} }; // 在waveshare_amoled_1_8类之前添加新的显示类 @@ -101,6 +103,8 @@ protected: esp_lcd_panel_io_handle_t panel_io_; virtual void SetBrightnessImpl(uint8_t brightness) override { + auto display = Board::GetInstance().GetDisplay(); + DisplayLockGuard lock(display); uint8_t data[1] = {((uint8_t)((255 * brightness) / 100))}; int lcd_cmd = 0x51; lcd_cmd &= 0xff; @@ -127,7 +131,7 @@ private: auto display = GetDisplay(); display->SetChatMessage("system", ""); display->SetEmotion("sleepy"); - GetBacklight()->SetBrightness(10); + GetBacklight()->SetBrightness(20); }); power_save_timer_->OnExitSleepMode([this]() { auto display = GetDisplay();