From 8bf6652f42489881e469a7f542e81ef18ce25f5d Mon Sep 17 00:00:00 2001 From: Peter Jakobs Date: Wed, 30 Oct 2024 17:25:18 +0100 Subject: [PATCH] moved the implementation of 'getMaxDuty()' into the cpp file for all architectures. Before, for esp32c3, the function in header would always return 0. --- Sming/Arch/Esp32/Core/HardwarePWM.cpp | 5 +++++ Sming/Arch/Esp8266/Core/HardwarePWM.cpp | 5 +++++ Sming/Arch/Host/Core/HardwarePWM.cpp | 5 +++++ Sming/Arch/Rp2040/Core/HardwarePWM.cpp.todo | 5 +++++ Sming/Core/HardwarePWM.h | 5 +---- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Sming/Arch/Esp32/Core/HardwarePWM.cpp b/Sming/Arch/Esp32/Core/HardwarePWM.cpp index fcc387dc34..89d785acb3 100644 --- a/Sming/Arch/Esp32/Core/HardwarePWM.cpp +++ b/Sming/Arch/Esp32/Core/HardwarePWM.cpp @@ -223,6 +223,11 @@ uint32_t HardwarePWM::getDutyChan(uint8_t chan) return (chan == PWM_BAD_CHANNEL) ? 0 : ledc_get_duty(pinToGroup(chan), pinToChannel(chan)); } +uint32_t HardwarePWM::getMaxDuty() +{ + return maxduty; +} + bool HardwarePWM::setDutyChan(uint8_t chan, uint32_t duty, bool update) { if(chan == PWM_BAD_CHANNEL) { diff --git a/Sming/Arch/Esp8266/Core/HardwarePWM.cpp b/Sming/Arch/Esp8266/Core/HardwarePWM.cpp index 1483df469e..1eb9925b7f 100644 --- a/Sming/Arch/Esp8266/Core/HardwarePWM.cpp +++ b/Sming/Arch/Esp8266/Core/HardwarePWM.cpp @@ -125,6 +125,11 @@ uint32_t HardwarePWM::getPeriod() return pwm_get_period(); } +uint32_t getMaxDuty() +{ + return maxduty; +} + void HardwarePWM::setPeriod(uint32_t period) { maxduty = PERIOD_TO_MAX_DUTY(period); diff --git a/Sming/Arch/Host/Core/HardwarePWM.cpp b/Sming/Arch/Host/Core/HardwarePWM.cpp index cf5d2de430..6846f9dccf 100644 --- a/Sming/Arch/Host/Core/HardwarePWM.cpp +++ b/Sming/Arch/Host/Core/HardwarePWM.cpp @@ -46,6 +46,11 @@ bool HardwarePWM::setDutyChan(uint8_t chan, uint32_t duty, bool update) return false; } +uint32_t HardwarePWM::getMaxDuty() +{ + return 0; +} + uint32_t HardwarePWM::getPeriod() { return 0; diff --git a/Sming/Arch/Rp2040/Core/HardwarePWM.cpp.todo b/Sming/Arch/Rp2040/Core/HardwarePWM.cpp.todo index 6def2d36fd..2c71ef6f49 100644 --- a/Sming/Arch/Rp2040/Core/HardwarePWM.cpp.todo +++ b/Sming/Arch/Rp2040/Core/HardwarePWM.cpp.todo @@ -116,6 +116,11 @@ uint32 HardwarePWM::getPeriod() return pwm_get_period(); } +uint32_t HardwarePWM::getMaxDuty() +{ + return maxduty; +} + /* Function Name: setPeriod * Description: This function is used to set Period of PWM. * Period / frequency will remain same for all pins. diff --git a/Sming/Core/HardwarePWM.h b/Sming/Core/HardwarePWM.h index fe1d6d501d..9d529633ec 100644 --- a/Sming/Core/HardwarePWM.h +++ b/Sming/Core/HardwarePWM.h @@ -113,10 +113,7 @@ class HardwarePWM * @retval uint32_t Maximum permissible duty cycle * @note Attempt to set duty of a pin above this value will fail */ - uint32_t getMaxDuty() - { - return maxduty; - } + uint32_t getMaxDuty(); /** @brief This function is used to actually update the PWM. */