From 8dc5c2c37f23481864aff4a0316726ca143a1339 Mon Sep 17 00:00:00 2001 From: Peter Jakobs Date: Thu, 31 Oct 2024 10:02:25 +0100 Subject: [PATCH] improved checking for max channel number and made sure PWM_CHANNEL_NUM_MAX is set correctly --- Sming/Arch/Esp32/Core/HardwarePWM.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Sming/Arch/Esp32/Core/HardwarePWM.cpp b/Sming/Arch/Esp32/Core/HardwarePWM.cpp index 9a58e5aad1..d8a7a91986 100644 --- a/Sming/Arch/Esp32/Core/HardwarePWM.cpp +++ b/Sming/Arch/Esp32/Core/HardwarePWM.cpp @@ -140,11 +140,8 @@ uint32_t maxDuty(ledc_timer_bit_t bits) HardwarePWM::HardwarePWM(uint8_t* pins, uint8_t no_of_pins) : channel_count(no_of_pins) { - assert(no_of_pins <= SOC_LEDC_CHANNEL_NUM); - - if(no_of_pins == 0) { - return; - } + assert(no_of_pins > 0 && no_of_pins <= SOC_LEDC_CHANNEL_NUM); + no_of_pins = std::min(uint8_t(SOC_LEDC_CHANNEL_NUM), no_of_pins); periph_module_enable(PERIPH_LEDC_MODULE);