diff options
Diffstat (limited to 'shared-bindings')
| -rw-r--r-- | shared-bindings/displayio/Display.c | 3 | ||||
| -rw-r--r-- | shared-bindings/displayio/Display.h | 2 | ||||
| -rw-r--r-- | shared-bindings/pulseio/PWMOut.c | 11 | ||||
| -rw-r--r-- | shared-bindings/pulseio/PWMOut.h | 14 |
4 files changed, 26 insertions, 4 deletions
diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 1838228af..398bca166 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -119,10 +119,11 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a mp_raise_RuntimeError(translate("Too many displays")); } self->base.type = &displayio_display_type; + // TODO(tannewt): Support backlight pin. common_hal_displayio_display_construct(self, display_bus, args[ARG_width].u_int, args[ARG_height].u_int, args[ARG_colstart].u_int, args[ARG_rowstart].u_int, args[ARG_color_depth].u_int, args[ARG_set_column_command].u_int, args[ARG_set_row_command].u_int, - args[ARG_write_ram_command].u_int, bufinfo.buf, bufinfo.len); + args[ARG_write_ram_command].u_int, bufinfo.buf, bufinfo.len, NULL); return self; } diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index 4cec66058..181afc941 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -40,7 +40,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t color_depth, uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command, - uint8_t* init_sequence, uint16_t init_sequence_len); + uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin); int32_t common_hal_displayio_display_wait_for_frame(displayio_display_obj_t* self); 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); } diff --git a/shared-bindings/pulseio/PWMOut.h b/shared-bindings/pulseio/PWMOut.h index 0b630816b..c01e0c926 100644 --- a/shared-bindings/pulseio/PWMOut.h +++ b/shared-bindings/pulseio/PWMOut.h @@ -32,7 +32,15 @@ extern const mp_obj_type_t pulseio_pwmout_type; -extern void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, +typedef enum { + PWMOUT_OK, + PWMOUT_INVALID_PIN, + PWMOUT_INVALID_FREQUENCY, + PWMOUT_ALL_TIMERS_ON_PIN_IN_USE, + PWMOUT_ALL_TIMERS_IN_USE +} pwmout_result_t; + +extern pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, const mcu_pin_obj_t* pin, uint16_t duty, uint32_t frequency, bool variable_frequency); extern void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self); @@ -43,4 +51,8 @@ extern void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, extern uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self); extern bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self); +// This is used by the supervisor to claim PWMOut devices indefinitely. +extern void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self); +extern void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PWMOUT_H |
