fix gppwm on-off mode (#1406)

* fix

* put it back

* do it with PWM instead

* comments

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2020-05-09 06:25:45 -07:00 committed by GitHub
parent 1a55d40863
commit 96a800acb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -75,13 +75,14 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
warning(CUSTOM_PWM_DUTY_TOO_HIGH, "%s duty %.2f", name, dutyCycle);
dutyCycle = 1;
}
if (dutyCycle == 0.0f && stateChangeCallback != NULL) {
/**
* set the pin low just to be super sure
* this custom handling of zero value comes from CJ125 heater code
* TODO: is this really needed? cover by unit test?
*/
// Handle zero and full duty cycle. This will cause the PWM output to behave like a plain digital output.
if (dutyCycle == 0.0f && stateChangeCallback) {
// Manually fire falling edge
stateChangeCallback(0, arg);
} else if (dutyCycle == 1.0f && stateChangeCallback) {
// Manually fire rising edge
stateChangeCallback(1, arg);
}
if (dutyCycle < ZERO_PWM_THRESHOLD) {