From c17f147be95e7490e5207c747add2da1cc8b167f Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 6 Feb 2019 12:13:17 -0800 Subject: A variety of displayio improvements This changes a number of things in displayio: * Introduces BuiltinFont and Glyph so the built in font can be used by libraries. For boards with a font it is available as board.TERMINAL_FONT. Fixes #1172 * Remove _load_row from Bitmap in favor of bitmap[] access. Index can be x/y tuple or overall index. Fixes #1191 * Add width and height properties to Bitmap. * Add insert and [] access to Group. Fixes #1518 * Add index param to pop on Group. * Terminal no longer takes unicode character info. It takes a BuiltinFont instead. * Fix Terminal's handling of [###D vt100 commands used when up arrowing into repl history. * Add x and y positions to Group plus scale as well. * Add bitmap accessor for BuiltinFont --- shared-bindings/pulseio/PulseIn.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'shared-bindings/pulseio') diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index d30abf28f..426ac4384 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -257,7 +257,7 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } -//| .. method:: __get__(index) +//| .. method:: __getitem__(index) //| //| Returns the value at the given index or values in slice. //| @@ -277,12 +277,7 @@ STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t va if (MP_OBJ_IS_TYPE(index_obj, &mp_type_slice)) { mp_raise_NotImplementedError(translate("Slices not supported")); } else { - uint16_t index = 0; - if (MP_OBJ_IS_SMALL_INT(index_obj)) { - index = MP_OBJ_SMALL_INT_VALUE(index_obj); - } else { - mp_raise_TypeError(translate("index must be int")); - } + size_t index = mp_get_index(&pulseio_pulsein_type, common_hal_pulseio_pulsein_get_len(self), index_obj, false); if (value == MP_OBJ_SENTINEL) { // load return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pulsein_get_item(self, index)); -- cgit v1.2.3