mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-21 10:16:34 +00:00
Fix for PWM moodlight crashes
This commit is contained in:
parent
476d268789
commit
7b067f7cc2
@ -185,7 +185,11 @@ void Esp32Device::set_backlight_pin(uint8_t pin)
|
||||
/* Setup Backlight Control Pin */
|
||||
if(pin < GPIO_NUM_MAX) {
|
||||
LOG_VERBOSE(TAG_GUI, F("Backlight : Pin %d"), pin);
|
||||
ledcSetup(BACKLIGHT_CHANNEL, 2000, 10);
|
||||
#ifndef ESP32S2
|
||||
ledcSetup(BACKLIGHT_CHANNEL, 20000, 12);
|
||||
#else
|
||||
ledcSetup(BACKLIGHT_CHANNEL, 20000, 10);
|
||||
#endif
|
||||
ledcAttachPin(pin, BACKLIGHT_CHANNEL);
|
||||
update_backlight();
|
||||
} else {
|
||||
@ -218,9 +222,15 @@ bool Esp32Device::get_backlight_power()
|
||||
void Esp32Device::update_backlight()
|
||||
{
|
||||
if(_backlight_pin < GPIO_NUM_MAX) {
|
||||
#ifndef ESP32S2
|
||||
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
|
||||
#else
|
||||
uint32_t duty = _backlight_power ? map(_backlight_level, 0, 255, 0, 1023) : 0;
|
||||
if(_backlight_invert) duty = 1023 - duty;
|
||||
ledcWrite(BACKLIGHT_CHANNEL, duty); // ledChannel and value
|
||||
#endif
|
||||
}
|
||||
|
||||
// haspTft.tft.writecommand(0x53); // Write CTRL Display
|
||||
|
Loading…
x
Reference in New Issue
Block a user