Skip to content

extmod/machine_signal: Add signal_print() as repr() function. #12291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions extmod/machine_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t
return MP_OBJ_FROM_PTR(o);
}

STATIC void signal_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_signal_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "Signal(");
mp_obj_print_helper(print, self->pin, PRINT_STR);
if (self->invert) {
mp_printf(print, ", invert=True");
}
mp_printf(print, ")");
}

STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
(void)errcode;
machine_signal_t *self = MP_OBJ_TO_PTR(self_in);
Expand Down Expand Up @@ -176,6 +186,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
MP_QSTR_Signal,
MP_TYPE_FLAG_NONE,
make_new, signal_make_new,
print, signal_print,
call, signal_call,
protocol, &signal_pin_p,
locals_dict, &signal_locals_dict
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy