Skip to content

Commit 06318cf

Browse files
committed
【修改】machine.pwm 模块添加 print 函数
Signed-off-by: chenyong <[email protected]>
1 parent 4c8c6ac commit 06318cf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

port/machine_pwm.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ typedef struct _machine_pwm_obj_t {
5454
uint32_t freq;
5555
} machine_pwm_obj_t;
5656

57+
STATIC void machine_pwm_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
58+
machine_pwm_obj_t *self = self_in;
59+
60+
mp_printf(print, "PWM(%p; ", self);
61+
62+
mp_printf(print, "id=%d, ", self->id);
63+
mp_printf(print, "channel=%d, ", self->channel);
64+
mp_printf(print, "freq=%d, ", self->freq);
65+
mp_printf(print, "duty=%d)", self->duty);
66+
}
67+
68+
5769
STATIC void error_check(bool status, const char *msg) {
5870
if (!status) {
5971
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, msg));
@@ -238,6 +250,7 @@ STATIC MP_DEFINE_CONST_DICT(machine_pwm_locals_dict,
238250
const mp_obj_type_t machine_pwm_type = {
239251
{ &mp_type_type },
240252
.name = MP_QSTR_PWM,
253+
.print = machine_pwm_print,
241254
.make_new = machine_pwm_make_new,
242255
.locals_dict = (mp_obj_dict_t *) &machine_pwm_locals_dict,
243256
};

0 commit comments

Comments
 (0)