Merge pull request #93 from burbankb/master
Allow HardwarePWM::addPin method to return true if _count == MAX_CHAN…
This commit is contained in:
1 file changed
+7
-1
@@ -78,7 +78,7 @@ void HardwarePWM::setClockDiv(uint8_t div)
|
||||
*/
|
||||
bool HardwarePWM::addPin(uint8_t pin)
|
||||
{
|
||||
VERIFY( isPinValid(pin) && (_count < MAX_CHANNELS) );
|
||||
VERIFY( isPinValid(pin) && (_count <= MAX_CHANNELS) );
|
||||
|
||||
// Check if pin is already configured
|
||||
for(uint8_t i=0; i<_count; i++)
|
||||
@@ -86,6 +86,12 @@ bool HardwarePWM::addPin(uint8_t pin)
|
||||
if (_pwm->PSEL.OUT[i] == pin) return true;
|
||||
}
|
||||
|
||||
if ((_count >= MAX_CHANNELS))
|
||||
{
|
||||
//Pin not already configured, but this HardwarePWM is full
|
||||
return false;
|
||||
}
|
||||
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, LOW);
|
||||
|
||||
|
||||
Reference in new issue
Block a user