mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Use ledcWrite instead of analogWrite on ESP32
This commit is contained in:
parent
6eaf52f9b0
commit
ba2ef55312
@ -459,7 +459,20 @@ static inline bool gpio_set_analog_value(hasp_gpio_config_t* gpio)
|
||||
ledcWrite(gpio->channel, val); // 12 bits
|
||||
return true; // sent
|
||||
|
||||
#elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||
#elif defined(ARDUINO_ARCH_ESP32)
|
||||
|
||||
if(gpio->max == 255)
|
||||
val = SCALE_8BIT_TO_10BIT(gpio->val);
|
||||
else if(gpio->max == 4095)
|
||||
val = gpio->val >> 2;
|
||||
|
||||
if(!gpio->power) val = 0;
|
||||
if(gpio->inverted) val = 1023 - val;
|
||||
|
||||
ledcWrite(gpio->channel, val); // 10 bits
|
||||
return true; // sent
|
||||
|
||||
#elif defined(ARDUINO_ARCH_ESP8266)
|
||||
|
||||
if(gpio->max == 255)
|
||||
val = SCALE_8BIT_TO_10BIT(gpio->val);
|
||||
|
Loading…
x
Reference in New Issue
Block a user