From 00a659f3ee90096cd394927735b42d1a3c9e8059 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 2 May 2018 12:15:31 +1000 Subject: [PATCH] stm32/dac: Implement printing of a DAC object. --- ports/stm32/dac.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ports/stm32/dac.c b/ports/stm32/dac.c index 7a72a2106b..0c9e0ae0cf 100644 --- a/ports/stm32/dac.c +++ b/ports/stm32/dac.c @@ -152,6 +152,13 @@ typedef struct _pyb_dac_obj_t { uint8_t outbuf_waveform; } pyb_dac_obj_t; +STATIC void pyb_dac_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + pyb_dac_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "DAC(%u, bits=%u)", + self->dac_channel == DAC_CHANNEL_1 ? 1 : 2, + self->bits); +} + STATIC mp_obj_t pyb_dac_init_helper(pyb_dac_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { static const mp_arg_t allowed_args[] = { { MP_QSTR_bits, MP_ARG_INT, {.u_int = 8} }, @@ -529,6 +536,7 @@ STATIC MP_DEFINE_CONST_DICT(pyb_dac_locals_dict, pyb_dac_locals_dict_table); const mp_obj_type_t pyb_dac_type = { { &mp_type_type }, .name = MP_QSTR_DAC, + .print = pyb_dac_print, .make_new = pyb_dac_make_new, .locals_dict = (mp_obj_dict_t*)&pyb_dac_locals_dict, };