Add removeAllPins to HwPWM instance

Given that no function exists to enumerate added pins, this allows for the HwPWM instance to be completely reset.
This commit is contained in:
James Gartrell committed 2023-02-16 09:30:49 -08:00
1 parent 0ea975e6e3
commit a95d23e03a
2 files changed
+12

No files matched your search

+9
View File
@@ -205,6 +205,15 @@ bool HardwarePWM::removePin(uint8_t pin)
return true;
}
bool HardwarePWM::removeAllPins(void)
{
for(int ch=0; ch<MAX_CHANNELS; ch++)
{
_set_psel(ch, 0xFFFFFFFFUL);
}
return true;
}
bool HardwarePWM::writeChannel(uint8_t ch, uint16_t value, bool inverted)
{
VERIFY( ch < MAX_CHANNELS );
+3
View File
@@ -94,6 +94,9 @@ class HardwarePWM
// Remove a pin from PWM module
bool removePin (uint8_t pin);
// Remove all pins from PWM module
bool removeAllPins (void);
// Get the mapped channel of a pin
int pin2channel(uint8_t pin) const
{