开机检查背光是否为0,如果为0则调为10 (#379)

* Update backlight.cc

* Update backlight.cc

---------

Co-authored-by: Xiaoxia <terrence@tenclass.com>
This commit is contained in:
Kevincoooool
2025-03-21 12:16:26 +08:00
committed by GitHub
parent 11c79bf086
commit 34ab004c38

View File

@@ -31,8 +31,16 @@ Backlight::~Backlight() {
void Backlight::RestoreBrightness() {
// Load brightness from settings
Settings settings("display");
SetBrightness(settings.GetInt("brightness", 75));
Settings settings("display");
int saved_brightness = settings.GetInt("brightness", 75);
// 检查亮度值是否为0或过小设置默认值
if (saved_brightness <= 0) {
ESP_LOGW(TAG, "Invalid brightness value (%d), setting to default", saved_brightness);
saved_brightness = 10; // 设置一个较低的默认值
}
SetBrightness(saved_brightness);
}
void Backlight::SetBrightness(uint8_t brightness, bool permanent) {