From 2f038eddd1c4334e3d10b5f9bd90a6513adb3cbe Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Sat, 26 Jun 2021 19:19:06 +0200 Subject: [PATCH] Fix update_backlight --- src/dev/esp32/esp32.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/dev/esp32/esp32.cpp b/src/dev/esp32/esp32.cpp index d3f763ee..40520cd3 100644 --- a/src/dev/esp32/esp32.cpp +++ b/src/dev/esp32/esp32.cpp @@ -209,31 +209,31 @@ bool Esp32Device::get_backlight_power() void Esp32Device::update_backlight() { - // if(_backlight_pin < GPIO_NUM_MAX) { - // uint32_t duty = _backlight_power ? map(_backlight_level, 0, 255, 0, 4095) : 0; - // if(_backlight_invert) duty = 4095 - duty; - // ledcWrite(BACKLIGHT_CHANNEL, duty); // ledChannel and value - // } - - haspTft.tft.writecommand(0x53); // Write CTRL Display - if(_backlight_power) - haspTft.tft.writedata(0x24); // BL on, show image - else - haspTft.tft.writedata(0x20); // BL off, white screen + if(_backlight_pin < GPIO_NUM_MAX) { + uint32_t duty = _backlight_power ? map(_backlight_level, 0, 255, 0, 4095) : 0; + if(_backlight_invert) duty = 4095 - duty; + ledcWrite(BACKLIGHT_CHANNEL, duty); // ledChannel and value + } + // haspTft.tft.writecommand(0x53); // Write CTRL Display // if(_backlight_power) - // haspTft.tft.writecommand(0x29); // BL on, show image + // haspTft.tft.writedata(0x24); // BL on, show image // else - // haspTft.tft.writecommand(0x28); // BL off, white screen + // haspTft.tft.writedata(0x20); // BL off, white screen - // haspTft.tft.writecommand(0x55); // Write Content Adaptive Brightness Control and Color Enhancement - // haspTft.tft.writedata(0x0); // Off + // // if(_backlight_power) + // // haspTft.tft.writecommand(0x29); // BL on, show image + // // else + // // haspTft.tft.writecommand(0x28); // BL off, white screen - haspTft.tft.writecommand(0x5E); // minimum brightness - haspTft.tft.writedata(_backlight_level); // 0-255 + // // haspTft.tft.writecommand(0x55); // Write Content Adaptive Brightness Control and Color Enhancement + // // haspTft.tft.writedata(0x0); // Off - haspTft.tft.writecommand(0x51); // Write Display Brightness - haspTft.tft.writedata(_backlight_level); // 0-255 + // haspTft.tft.writecommand(0x5E); // minimum brightness + // haspTft.tft.writedata(_backlight_level); // 0-255 + + // haspTft.tft.writecommand(0x51); // Write Display Brightness + // haspTft.tft.writedata(_backlight_level); // 0-255 } size_t Esp32Device::get_free_max_block()