summaryrefslogtreecommitdiff
path: root/shared-bindings/pulseio/PWMOut.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-01-31 16:03:51 -0500
committerGitHub <noreply@github.com>2019-01-31 16:03:51 -0500
commit7c443fbef2b92bfdd382db9aeaddcdcecbc02cd0 (patch)
tree93c06f6ba863e234148555f41042b354286cb52e /shared-bindings/pulseio/PWMOut.c
parent63d456127b783efb376bd2b25598cc9e7f9dceb6 (diff)
parentd72cd5b2d6cbc95665c41a43d6d914e71ac58017 (diff)
Merge pull request #1510 from tannewt/terminalio
Add a terminal that shows by default on displays.
Diffstat (limited to 'shared-bindings/pulseio/PWMOut.c')
-rw-r--r--shared-bindings/pulseio/PWMOut.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/shared-bindings/pulseio/PWMOut.c b/shared-bindings/pulseio/PWMOut.c
index ed3acd804..bba5fe883 100644
--- a/shared-bindings/pulseio/PWMOut.c
+++ b/shared-bindings/pulseio/PWMOut.c
@@ -108,7 +108,16 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args
// create PWM object from the given pin
pulseio_pwmout_obj_t *self = m_new_obj(pulseio_pwmout_obj_t);
self->base.type = &pulseio_pwmout_type;
- common_hal_pulseio_pwmout_construct(self, pin, duty_cycle, frequency, variable_frequency);
+ pwmout_result_t result = common_hal_pulseio_pwmout_construct(self, pin, duty_cycle, frequency, variable_frequency);
+ if (result == PWMOUT_INVALID_PIN) {
+ mp_raise_ValueError(translate("Invalid pin"));
+ } else if (result == PWMOUT_INVALID_FREQUENCY) {
+ mp_raise_ValueError(translate("Invalid PWM frequency"));
+ } else if (result == PWMOUT_ALL_TIMERS_ON_PIN_IN_USE) {
+ mp_raise_ValueError(translate("All timers for this pin are in use"));
+ } else if (result == PWMOUT_ALL_TIMERS_IN_USE) {
+ mp_raise_RuntimeError(translate("All timers in use"));
+ }
return MP_OBJ_FROM_PTR(self);
}