Skip to content

Commit

Permalink
moved the implementation of 'getMaxDuty()' into the cpp file for all …
Browse files Browse the repository at this point in the history
…architectures. Before, for esp32c3, the function in header would always return 0.
  • Loading branch information
pljakobs committed Oct 30, 2024
1 parent 0447ab4 commit 8bf6652
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Sming/Arch/Esp32/Core/HardwarePWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions Sming/Arch/Esp8266/Core/HardwarePWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions Sming/Arch/Host/Core/HardwarePWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions Sming/Arch/Rp2040/Core/HardwarePWM.cpp.todo
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions Sming/Core/HardwarePWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 8bf6652

Please sign in to comment.