Skip to content

Commit ef1a484

Browse files
committed
shared-bindings: Correct PulseIn.resume to match docs. Fixes adafruit#125
1 parent c6d539a commit ef1a484

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

shared-bindings/pulseio/PulseIn.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,19 @@ MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_pause_obj, pulseio_pulsein_obj_pause);
154154
//|
155155
//| :param int trigger_duration: trigger pulse duration in microseconds
156156
//|
157-
STATIC mp_obj_t pulseio_pulsein_obj_resume(mp_obj_t self_in, mp_obj_t duration_obj) {
158-
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in);
159-
uint16_t trigger_duration = 0;
160-
if (MP_OBJ_IS_SMALL_INT(duration_obj)) {
161-
trigger_duration = MP_OBJ_SMALL_INT_VALUE(duration_obj);
162-
} else if (duration_obj != mp_const_none) {
163-
mp_raise_TypeError("trigger_duration must be int");
164-
}
157+
STATIC mp_obj_t pulseio_pulsein_obj_resume(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
158+
enum { ARG_trigger_duration };
159+
static const mp_arg_t allowed_args[] = {
160+
{ MP_QSTR_trigger_duration, MP_ARG_OBJ, {.u_int = 0} },
161+
};
162+
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
163+
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
164+
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
165165

166-
common_hal_pulseio_pulsein_resume(self, trigger_duration);
166+
common_hal_pulseio_pulsein_resume(self, args[ARG_trigger_duration].u_int);
167167
return mp_const_none;
168168
}
169-
MP_DEFINE_CONST_FUN_OBJ_2(pulseio_pulsein_resume_obj, pulseio_pulsein_obj_resume);
169+
MP_DEFINE_CONST_FUN_OBJ_KW(pulseio_pulsein_resume_obj, 1, pulseio_pulsein_obj_resume);
170170

171171
//| .. method:: clear()
172172
//|

0 commit comments

Comments
 (0)