Skip to content

Commit

Permalink
rp2: Fix the display of timer properties.
Browse files Browse the repository at this point in the history
Showing the period as either ms for periods > 1 Minute, or µs if
smaller.

Signed-off-by: robert-hh <robert@hammelrath.com>
  • Loading branch information
robert-hh committed Sep 1, 2023
1 parent 607548f commit a36e662
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ports/rp2/machine_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ STATIC int64_t alarm_callback(alarm_id_t id, void *user_data) {
STATIC void machine_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_timer_obj_t *self = MP_OBJ_TO_PTR(self_in);
qstr mode = self->mode == TIMER_MODE_ONE_SHOT ? MP_QSTR_ONE_SHOT : MP_QSTR_PERIODIC;
mp_printf(print, "Timer(mode=%q, period=%u, tick_hz=1000000)", mode, self->delta_us);
mp_printf(print, "Timer(mode=%q, tick_hz=", mode);
if (self->delta_us < 60000000) {
mp_printf(print, "1000000, period=%u)", (uint32_t)self->delta_us);
} else {
mp_printf(print, "1000, period=%u)", (uint32_t)(self->delta_us / 1000));
}
}

STATIC mp_obj_t machine_timer_init_helper(machine_timer_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
Expand Down

0 comments on commit a36e662

Please sign in to comment.