From cac3e8b3e35229979cc27cb1914efd1f5ffaf120 Mon Sep 17 00:00:00 2001 From: VasilyRakche Date: Fri, 15 Jul 2022 12:45:26 +0200 Subject: [PATCH 1/2] Get channel assigned to the pin with analogWrite --- cores/esp32/esp32-hal-ledc.c | 4 ++++ cores/esp32/esp32-hal.h | 1 + 2 files changed, 5 insertions(+) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index 44a3667333d..fe29cb718fa 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -226,3 +226,7 @@ void analogWrite(uint8_t pin, int value) { ledcWrite(pin_to_channel[pin] - 1, value); } } + +int8_t analogGetChannel(uint8_t pin) { + return pin_to_channel[pin] - 1; +} \ No newline at end of file diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index 9039d3544c8..59dca98cbb9 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -92,6 +92,7 @@ void yield(void); #include "esp32-hal-cpu.h" void analogWrite(uint8_t pin, int value); +int8_t analogGetChannel(uint8_t pin); //returns chip temperature in Celsius float temperatureRead(); From a6e328459793c3d33632e4da183b26e9d9f397ff Mon Sep 17 00:00:00 2001 From: VasilyRakche Date: Mon, 18 Jul 2022 15:45:35 +0200 Subject: [PATCH 2/2] Respect coding standard in LEDC source file --- cores/esp32/esp32-hal-ledc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index fe29cb718fa..4b5e136cbe6 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -229,4 +229,4 @@ void analogWrite(uint8_t pin, int value) { int8_t analogGetChannel(uint8_t pin) { return pin_to_channel[pin] - 1; -} \ No newline at end of file +}