From 605ff91efdeb3cd7e4948c0398c839a9ae06044a Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 11 Apr 2017 00:12:20 +0300 Subject: extmod/machine_signal: Support all Pin's arguments to the constructor. This implements the orginal idea is that Signal is a subclass of Pin, and thus can accept all the same argument as Pin, and additionally, "inverted" param. On the practical side, it allows to avoid many enclosed parenses for a typical declararion, e.g. for Zephyr: Signal(Pin(("GPIO_0", 1))). Of course, passing a Pin to Signal constructor is still supported and is the most generic form (e.g. Unix port will only support such form, as it doesn't have "builtin" Pins), what's introduces here is just practical readability optimization. "value" kwarg is treated as applying to a Signal (i.e. accounts for possible inversion). --- extmod/virtpin.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'extmod/virtpin.h') diff --git a/extmod/virtpin.h b/extmod/virtpin.h index 3821f9dec..041010350 100644 --- a/extmod/virtpin.h +++ b/extmod/virtpin.h @@ -38,3 +38,6 @@ typedef struct _mp_pin_p_t { int mp_virtual_pin_read(mp_obj_t pin); void mp_virtual_pin_write(mp_obj_t pin, int value); + +// If a port exposes a Pin object, it's constructor should be like this +mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); -- cgit v1.2.3