diff options
author | Ayke van Laethem <aykevanlaethem@gmail.com> | 2018-08-02 20:52:17 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-01-31 17:38:13 +1100 |
commit | e8678cd1c9e36f8a1175773b97ef2df5e5f8b673 (patch) | |
tree | 55bdd8d5ec04183c970bd9b87b033c1d6de441f5 | |
parent | 8faf17b93cfaee4f0150ee3a3086084f3340bcc6 (diff) |
nrf/pin: Print pull information in Pin.__str__.
-rw-r--r-- | ports/nrf/modules/machine/pin.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ports/nrf/modules/machine/pin.c b/ports/nrf/modules/machine/pin.c index 12bc9b0c6..8a16dc408 100644 --- a/ports/nrf/modules/machine/pin.c +++ b/ports/nrf/modules/machine/pin.c @@ -215,8 +215,22 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) { STATIC void pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { pin_obj_t *self = self_in; - mp_printf(print, "Pin(%d, mode=%s)", self->pin, - (nrf_gpio_pin_dir_get(self->pin) == NRF_GPIO_PIN_DIR_OUTPUT) ? "OUT" : "IN"); + char *pull = "PULL_DISABLED"; + switch (nrf_gpio_pin_pull_get(self->pin)) { + case NRF_GPIO_PIN_PULLUP: + pull = "PULL_UP"; + break; + case NRF_GPIO_PIN_PULLDOWN: + pull = "PULL_DOWN"; + break; + default: + break; + } + + mp_printf(print, "Pin(%d, mode=%s, pull=%s)", + self->pin, + (nrf_gpio_pin_dir_get(self->pin) == NRF_GPIO_PIN_DIR_OUTPUT) ? "OUT" : "IN", + pull); } STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *pin, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args); |