Merge pull request #1940 from tannewt/dirty_area
Add partial display update support.
This commit is contained in:
commit
6be7cf7440
|
@ -1 +1 @@
|
|||
Subproject commit 6b3402965999d068316882d63fae3ab26006477c
|
||||
Subproject commit b9280af5142fc41639229544678e23b5cca07c3a
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -856,6 +856,10 @@ msgstr ""
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr "LHS dari keyword arg harus menjadi sebuah id"
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr ""
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 16:00-0300\n"
|
||||
"POT-Creation-Date: 2019-06-12 00:59-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -831,6 +831,10 @@ msgstr ""
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr ""
|
||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
|
||||
"Last-Translator: Pascal Deneaux\n"
|
||||
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
|
||||
|
@ -837,6 +837,10 @@ msgstr "Ungültige wave Datei"
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr "LHS des Schlüsselwortarguments muss eine id sein"
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr "Layer muss eine Group- oder TileGrid-Unterklasse sein."
|
||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -831,6 +831,10 @@ msgstr ""
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr ""
|
||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: @sommersoft, @MrCertainly\n"
|
||||
|
@ -835,6 +835,10 @@ msgstr ""
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr ""
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -866,6 +866,10 @@ msgstr "Archivo wave inválido"
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr "LHS del agumento por palabra clave deberia ser un identificador"
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr "Layer debe ser una subclase de Group o TileGrid."
|
||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
|
||||
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
|
||||
"Language-Team: fil\n"
|
||||
|
@ -861,6 +861,10 @@ msgstr "May hindi tama sa wave file"
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr "LHS ng keyword arg ay dapat na id"
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr ""
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: 0.1\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
|
||||
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
|
||||
"Language-Team: fr\n"
|
||||
|
@ -869,6 +869,10 @@ msgstr "Fichier WAVE invalide"
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr "La partie gauche de l'argument nommé doit être un identifiant"
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr "'Layer' doit être un 'Group' ou une sous-classe 'TileGrid'."
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
|
||||
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
|
||||
"Language-Team: \n"
|
||||
|
@ -863,6 +863,10 @@ msgstr "File wave non valido"
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr "Layer deve essere un Group o TileGrid subclass"
|
||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
|
||||
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
|
||||
"Language-Team: pl\n"
|
||||
|
@ -836,6 +836,10 @@ msgstr "Zły plik wave"
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr "Lewa strona argumentu nazwanego musi być nazwą"
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr "Layer musi dziedziczyć z Group albo TileGrid"
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -854,6 +854,10 @@ msgstr "Aqruivo de ondas inválido"
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr ""
|
||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: circuitpython-cn\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-22 15:56-0300\n"
|
||||
"POT-Creation-Date: 2019-06-11 14:59-0700\n"
|
||||
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
|
||||
"Last-Translator: hexthat\n"
|
||||
"Language-Team: Chinese Hanyu Pinyin\n"
|
||||
|
@ -837,6 +837,10 @@ msgstr "Wúxiào de làng làngcháo wénjiàn"
|
|||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr "Guānjiàn zì arg de LHS bìxū shì id"
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer already in a group."
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/displayio/Group.c
|
||||
msgid "Layer must be a Group or TileGrid subclass."
|
||||
msgstr "Layer bìxū shì Group huò TileGrid zi lèi."
|
||||
|
|
|
@ -101,7 +101,7 @@ endif
|
|||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -ggdb
|
||||
# You may want to disable -flto if it interferes with debugging.
|
||||
CFLAGS += -flto
|
||||
CFLAGS += -flto -flto-partition=none
|
||||
# You may want to enable these flags to make setting breakpoints easier.
|
||||
# CFLAGS += -fno-inline -fno-ipa-sra
|
||||
ifeq ($(CHIP_FAMILY), samd21)
|
||||
|
@ -122,8 +122,7 @@ else
|
|||
ifdef CFLAGS_INLINE_LIMIT
|
||||
CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT)
|
||||
endif
|
||||
|
||||
CFLAGS += -flto
|
||||
CFLAGS += -flto -flto-partition=none
|
||||
endif
|
||||
|
||||
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT)
|
||||
|
|
|
@ -13,3 +13,4 @@ EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C"
|
|||
LONGINT_IMPL = MPZ
|
||||
|
||||
CFLAGS_INLINE_LIMIT = 60
|
||||
SUPEROPT_GC = 0
|
||||
|
|
|
@ -13,3 +13,4 @@ EXTERNAL_FLASH_DEVICES = "W25Q16FW, GD25Q16C"
|
|||
LONGINT_IMPL = MPZ
|
||||
|
||||
CFLAGS_INLINE_LIMIT = 60
|
||||
SUPEROPT_GC = 0
|
||||
|
|
|
@ -13,3 +13,4 @@ EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C"
|
|||
LONGINT_IMPL = MPZ
|
||||
|
||||
CFLAGS_INLINE_LIMIT = 60
|
||||
SUPEROPT_GC = 0
|
||||
|
|
|
@ -87,8 +87,8 @@ void board_init(void) {
|
|||
display->base.type = &displayio_display_type;
|
||||
common_hal_displayio_display_construct(display,
|
||||
bus,
|
||||
160, // Width
|
||||
128, // Height
|
||||
160, // Width (after rotation)
|
||||
128, // Height (after rotation)
|
||||
0, // column start
|
||||
0, // row start
|
||||
270, // rotation
|
||||
|
|
|
@ -13,3 +13,4 @@ EXTERNAL_FLASH_DEVICES = "W25Q32FV"
|
|||
LONGINT_IMPL = MPZ
|
||||
|
||||
CFLAGS_INLINE_LIMIT = 60
|
||||
SUPEROPT_GC = 0
|
||||
|
|
|
@ -96,8 +96,9 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||
mp_raise_TypeError(translate("Row entry must be digitalio.DigitalInOut"));
|
||||
}
|
||||
digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(rows[i]);
|
||||
raise_error_if_deinited(
|
||||
common_hal_digitalio_digitalinout_deinited(pin));
|
||||
if (common_hal_digitalio_digitalinout_deinited(pin)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < cols_size; ++i) {
|
||||
|
@ -105,8 +106,9 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||
mp_raise_TypeError(translate("Column entry must be digitalio.DigitalInOut"));
|
||||
}
|
||||
digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(cols[i]);
|
||||
raise_error_if_deinited(
|
||||
common_hal_digitalio_digitalinout_deinited(pin));
|
||||
if (common_hal_digitalio_digitalinout_deinited(pin)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
if (!MP_OBJ_IS_TYPE(args[ARG_buttons].u_obj,
|
||||
|
@ -115,8 +117,9 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||
}
|
||||
digitalio_digitalinout_obj_t *buttons = MP_OBJ_TO_PTR(
|
||||
args[ARG_buttons].u_obj);
|
||||
raise_error_if_deinited(
|
||||
common_hal_digitalio_digitalinout_deinited(buttons));
|
||||
if (common_hal_digitalio_digitalinout_deinited(buttons)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
|
||||
pew_obj_t *pew = MP_STATE_VM(pew_singleton);
|
||||
if (!pew) {
|
||||
|
|
|
@ -86,6 +86,11 @@ STATIC mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_deinit_obj, analogio_analogin_deinit);
|
||||
|
||||
STATIC void check_for_deinit(analogio_analogin_obj_t *self) {
|
||||
if (common_hal_analogio_analogin_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -113,7 +118,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogin___exit___obj, 4, 4,
|
|||
//|
|
||||
STATIC mp_obj_t analogio_analogin_obj_get_value(mp_obj_t self_in) {
|
||||
analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_analogio_analogin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_analogio_analogin_get_value(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_get_value_obj, analogio_analogin_obj_get_value);
|
||||
|
@ -132,7 +137,7 @@ const mp_obj_property_t analogio_analogin_value_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) {
|
||||
analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_analogio_analogin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_float(common_hal_analogio_analogin_get_reference_voltage(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_get_reference_voltage_obj,
|
||||
|
|
|
@ -112,7 +112,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4
|
|||
//| resolution, the value is 16-bit.
|
||||
STATIC mp_obj_t analogio_analogout_obj_set_value(mp_obj_t self_in, mp_obj_t value) {
|
||||
analogio_analogout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_analogio_analogout_deinited(self));
|
||||
if (common_hal_analogio_analogout_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
uint32_t v = mp_obj_get_int(value);
|
||||
if (v >= (1 << 16)) {
|
||||
mp_raise_ValueError(translate("AnalogOut is only 16 bits. Value must be less than 65536."));
|
||||
|
|
|
@ -134,6 +134,11 @@ STATIC mp_obj_t audiobusio_i2sout_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_deinit_obj, audiobusio_i2sout_deinit);
|
||||
|
||||
STATIC void check_for_deinit(audiobusio_i2sout_obj_t *self) {
|
||||
if (common_hal_audiobusio_i2sout_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -169,7 +174,7 @@ STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_ar
|
|||
{ MP_QSTR_loop, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||
};
|
||||
audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_audiobusio_i2sout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
|
@ -186,7 +191,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audiobusio_i2sout_play_obj, 1, audiobusio_i2sout_obj_
|
|||
//|
|
||||
STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) {
|
||||
audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audiobusio_i2sout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
common_hal_audiobusio_i2sout_stop(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -198,7 +203,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_stop_obj, audiobusio_i2sout_obj_stop
|
|||
//|
|
||||
STATIC mp_obj_t audiobusio_i2sout_obj_get_playing(mp_obj_t self_in) {
|
||||
audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audiobusio_i2sout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_bool(common_hal_audiobusio_i2sout_get_playing(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_get_playing_obj, audiobusio_i2sout_obj_get_playing);
|
||||
|
@ -216,7 +221,7 @@ const mp_obj_property_t audiobusio_i2sout_playing_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) {
|
||||
audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audiobusio_i2sout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
if (!common_hal_audiobusio_i2sout_get_playing(self)) {
|
||||
mp_raise_RuntimeError(translate("Not playing"));
|
||||
|
@ -232,7 +237,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_pause_obj, audiobusio_i2sout_obj_pau
|
|||
//|
|
||||
STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) {
|
||||
audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audiobusio_i2sout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
if (common_hal_audiobusio_i2sout_get_paused(self)) {
|
||||
common_hal_audiobusio_i2sout_resume(self);
|
||||
|
@ -248,7 +253,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_resume_obj, audiobusio_i2sout_obj_re
|
|||
//|
|
||||
STATIC mp_obj_t audiobusio_i2sout_obj_get_paused(mp_obj_t self_in) {
|
||||
audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audiobusio_i2sout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_bool(common_hal_audiobusio_i2sout_get_paused(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_get_paused_obj, audiobusio_i2sout_obj_get_paused);
|
||||
|
|
|
@ -156,6 +156,11 @@ STATIC mp_obj_t audiobusio_pdmin_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_pdmin_deinit_obj, audiobusio_pdmin_deinit);
|
||||
|
||||
STATIC void check_for_deinit(audiobusio_pdmin_obj_t *self) {
|
||||
if (common_hal_audiobusio_pdmin_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -188,7 +193,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4,
|
|||
//|
|
||||
STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destination, mp_obj_t destination_length) {
|
||||
audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_obj);
|
||||
raise_error_if_deinited(common_hal_audiobusio_pdmin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
if (!MP_OBJ_IS_SMALL_INT(destination_length) || MP_OBJ_SMALL_INT_VALUE(destination_length) < 0) {
|
||||
mp_raise_TypeError(translate("destination_length must be an int >= 0"));
|
||||
}
|
||||
|
@ -223,7 +228,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(audiobusio_pdmin_record_obj, audiobusio_pdmin_obj_reco
|
|||
//|
|
||||
STATIC mp_obj_t audiobusio_pdmin_obj_get_sample_rate(mp_obj_t self_in) {
|
||||
audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audiobusio_pdmin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_audiobusio_pdmin_get_sample_rate(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_pdmin_get_sample_rate_obj, audiobusio_pdmin_obj_get_sample_rate);
|
||||
|
|
|
@ -133,6 +133,11 @@ STATIC mp_obj_t audioio_audioout_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_deinit_obj, audioio_audioout_deinit);
|
||||
|
||||
STATIC void check_for_deinit(audioio_audioout_obj_t *self) {
|
||||
if (common_hal_audioio_audioout_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -170,7 +175,7 @@ STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_arg
|
|||
{ MP_QSTR_loop, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||
};
|
||||
audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_audioio_audioout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
|
@ -187,7 +192,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audioio_audioout_play_obj, 1, audioio_audioout_obj_pl
|
|||
//|
|
||||
STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) {
|
||||
audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_audioout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
common_hal_audioio_audioout_stop(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -199,7 +204,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_stop_obj, audioio_audioout_obj_stop);
|
|||
//|
|
||||
STATIC mp_obj_t audioio_audioout_obj_get_playing(mp_obj_t self_in) {
|
||||
audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_audioout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_bool(common_hal_audioio_audioout_get_playing(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_get_playing_obj, audioio_audioout_obj_get_playing);
|
||||
|
@ -217,7 +222,7 @@ const mp_obj_property_t audioio_audioout_playing_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) {
|
||||
audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_audioout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
if (!common_hal_audioio_audioout_get_playing(self)) {
|
||||
mp_raise_RuntimeError(translate("Not playing"));
|
||||
|
@ -233,7 +238,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_pause_obj, audioio_audioout_obj_pause
|
|||
//|
|
||||
STATIC mp_obj_t audioio_audioout_obj_resume(mp_obj_t self_in) {
|
||||
audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_audioout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
if (common_hal_audioio_audioout_get_paused(self)) {
|
||||
common_hal_audioio_audioout_resume(self);
|
||||
|
@ -249,7 +254,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_resume_obj, audioio_audioout_obj_resu
|
|||
//|
|
||||
STATIC mp_obj_t audioio_audioout_obj_get_paused(mp_obj_t self_in) {
|
||||
audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_audioout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_bool(common_hal_audioio_audioout_get_paused(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_get_paused_obj, audioio_audioout_obj_get_paused);
|
||||
|
|
|
@ -121,6 +121,12 @@ STATIC mp_obj_t audioio_mixer_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audioio_mixer_deinit_obj, audioio_mixer_deinit);
|
||||
|
||||
STATIC void check_for_deinit(audioio_mixer_obj_t *self) {
|
||||
if (common_hal_audioio_mixer_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -157,7 +163,7 @@ STATIC mp_obj_t audioio_mixer_obj_play(size_t n_args, const mp_obj_t *pos_args,
|
|||
{ MP_QSTR_loop, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||
};
|
||||
audioio_mixer_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_audioio_mixer_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
|
@ -178,7 +184,7 @@ STATIC mp_obj_t audioio_mixer_obj_stop_voice(size_t n_args, const mp_obj_t *pos_
|
|||
{ MP_QSTR_voice, MP_ARG_INT, {.u_int = 0} },
|
||||
};
|
||||
audioio_mixer_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_audioio_mixer_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
|
@ -193,7 +199,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audioio_mixer_stop_voice_obj, 1, audioio_mixer_obj_st
|
|||
//|
|
||||
STATIC mp_obj_t audioio_mixer_obj_get_playing(mp_obj_t self_in) {
|
||||
audioio_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_mixer_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_bool(common_hal_audioio_mixer_get_playing(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audioio_mixer_get_playing_obj, audioio_mixer_obj_get_playing);
|
||||
|
@ -211,7 +217,7 @@ const mp_obj_property_t audioio_mixer_playing_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t audioio_mixer_obj_get_sample_rate(mp_obj_t self_in) {
|
||||
audioio_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_mixer_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_audioio_mixer_get_sample_rate(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audioio_mixer_get_sample_rate_obj, audioio_mixer_obj_get_sample_rate);
|
||||
|
|
|
@ -115,6 +115,12 @@ STATIC mp_obj_t audioio_rawsample_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audioio_rawsample_deinit_obj, audioio_rawsample_deinit);
|
||||
|
||||
STATIC void check_for_deinit(audioio_rawsample_obj_t *self) {
|
||||
if (common_hal_audioio_rawsample_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -142,14 +148,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_rawsample___exit___obj, 4, 4,
|
|||
//|
|
||||
STATIC mp_obj_t audioio_rawsample_obj_get_sample_rate(mp_obj_t self_in) {
|
||||
audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_rawsample_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_audioio_rawsample_get_sample_rate(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audioio_rawsample_get_sample_rate_obj, audioio_rawsample_obj_get_sample_rate);
|
||||
|
||||
STATIC mp_obj_t audioio_rawsample_obj_set_sample_rate(mp_obj_t self_in, mp_obj_t sample_rate) {
|
||||
audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_rawsample_deinited(self));
|
||||
check_for_deinit(self);
|
||||
common_hal_audioio_rawsample_set_sample_rate(self, mp_obj_get_int(sample_rate));
|
||||
return mp_const_none;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,12 @@ STATIC mp_obj_t audioio_wavefile_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audioio_wavefile_deinit_obj, audioio_wavefile_deinit);
|
||||
|
||||
STATIC void check_for_deinit(audioio_wavefile_obj_t *self) {
|
||||
if (common_hal_audioio_wavefile_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -118,14 +124,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_wavefile___exit___obj, 4, 4,
|
|||
//|
|
||||
STATIC mp_obj_t audioio_wavefile_obj_get_sample_rate(mp_obj_t self_in) {
|
||||
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_wavefile_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_audioio_wavefile_get_sample_rate(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audioio_wavefile_get_sample_rate_obj, audioio_wavefile_obj_get_sample_rate);
|
||||
|
||||
STATIC mp_obj_t audioio_wavefile_obj_set_sample_rate(mp_obj_t self_in, mp_obj_t sample_rate) {
|
||||
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_wavefile_deinited(self));
|
||||
check_for_deinit(self);
|
||||
common_hal_audioio_wavefile_set_sample_rate(self, mp_obj_get_int(sample_rate));
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -144,7 +150,7 @@ const mp_obj_property_t audioio_wavefile_sample_rate_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t audioio_wavefile_obj_get_bits_per_sample(mp_obj_t self_in) {
|
||||
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_wavefile_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_audioio_wavefile_get_bits_per_sample(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audioio_wavefile_get_bits_per_sample_obj, audioio_wavefile_obj_get_bits_per_sample);
|
||||
|
@ -162,7 +168,7 @@ const mp_obj_property_t audioio_wavefile_bits_per_sample_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t audioio_wavefile_obj_get_channel_count(mp_obj_t self_in) {
|
||||
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_audioio_wavefile_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_audioio_wavefile_get_channel_count(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(audioio_wavefile_get_channel_count_obj, audioio_wavefile_obj_get_channel_count);
|
||||
|
|
|
@ -69,7 +69,6 @@ STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||
const mcu_pin_obj_t* sda = MP_OBJ_TO_PTR(args[ARG_sda].u_obj);
|
||||
|
||||
bitbangio_i2c_obj_t *self = m_new_obj(bitbangio_i2c_obj_t);
|
||||
raise_error_if_deinited(shared_module_bitbangio_i2c_deinited(self));
|
||||
self->base.type = &bitbangio_i2c_type;
|
||||
shared_module_bitbangio_i2c_construct(self, scl, sda, args[ARG_frequency].u_int, args[ARG_timeout].u_int);
|
||||
return (mp_obj_t)self;
|
||||
|
@ -86,6 +85,12 @@ STATIC mp_obj_t bitbangio_i2c_obj_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_deinit_obj, bitbangio_i2c_obj_deinit);
|
||||
|
||||
STATIC void check_for_deinit(bitbangio_i2c_obj_t *self) {
|
||||
if (shared_module_bitbangio_i2c_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used in Context Managers.
|
||||
|
@ -118,7 +123,7 @@ static void check_lock(bitbangio_i2c_obj_t *self) {
|
|||
//|
|
||||
STATIC mp_obj_t bitbangio_i2c_scan(mp_obj_t self_in) {
|
||||
bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(shared_module_bitbangio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_obj_t list = mp_obj_new_list(0, NULL);
|
||||
// 7-bit addresses 0b0000xxx and 0b1111xxx are reserved
|
||||
|
@ -138,7 +143,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_scan_obj, bitbangio_i2c_scan);
|
|||
//|
|
||||
STATIC mp_obj_t bitbangio_i2c_obj_try_lock(mp_obj_t self_in) {
|
||||
bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(shared_module_bitbangio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_bool(shared_module_bitbangio_i2c_try_lock(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_try_lock_obj, bitbangio_i2c_obj_try_lock);
|
||||
|
@ -149,7 +154,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_try_lock_obj, bitbangio_i2c_obj_try_lock
|
|||
//|
|
||||
STATIC mp_obj_t bitbangio_i2c_obj_unlock(mp_obj_t self_in) {
|
||||
bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(shared_module_bitbangio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
shared_module_bitbangio_i2c_unlock(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -179,7 +184,7 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a
|
|||
{ MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} },
|
||||
};
|
||||
bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(shared_module_bitbangio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
check_lock(self);
|
||||
|
@ -232,7 +237,7 @@ STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, m
|
|||
{ MP_QSTR_stop, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
|
||||
};
|
||||
bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(shared_module_bitbangio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
|
|
@ -91,6 +91,12 @@ STATIC mp_obj_t bitbangio_onewire_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_deinit_obj, bitbangio_onewire_deinit);
|
||||
|
||||
STATIC void check_for_deinit(bitbangio_onewire_obj_t *self) {
|
||||
if (shared_module_bitbangio_onewire_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -115,7 +121,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_onewire___exit___obj, 4, 4,
|
|||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(shared_module_bitbangio_onewire_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(shared_module_bitbangio_onewire_reset(self));
|
||||
}
|
||||
|
@ -130,7 +136,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_reset_obj, bitbangio_onewire_obj_res
|
|||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(shared_module_bitbangio_onewire_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(shared_module_bitbangio_onewire_read_bit(self));
|
||||
}
|
||||
|
@ -142,7 +148,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_read_bit_obj, bitbangio_onewire_obj_
|
|||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(shared_module_bitbangio_onewire_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
shared_module_bitbangio_onewire_write_bit(self, mp_obj_is_true(bool_obj));
|
||||
return mp_const_none;
|
||||
|
|
|
@ -95,6 +95,12 @@ STATIC mp_obj_t bitbangio_spi_obj_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_deinit_obj, bitbangio_spi_obj_deinit);
|
||||
|
||||
STATIC void check_for_deinit(bitbangio_spi_obj_t *self) {
|
||||
if (shared_module_bitbangio_spi_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -139,7 +145,7 @@ STATIC mp_obj_t bitbangio_spi_configure(size_t n_args, const mp_obj_t *pos_args,
|
|||
{ MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} },
|
||||
};
|
||||
bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(shared_module_bitbangio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
@ -171,7 +177,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_configure_obj, 1, bitbangio_spi_configu
|
|||
//|
|
||||
STATIC mp_obj_t bitbangio_spi_obj_try_lock(mp_obj_t self_in) {
|
||||
bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(shared_module_bitbangio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_bool(shared_module_bitbangio_spi_try_lock(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_try_lock_obj, bitbangio_spi_obj_try_lock);
|
||||
|
@ -182,7 +188,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_try_lock_obj, bitbangio_spi_obj_try_lock
|
|||
//|
|
||||
STATIC mp_obj_t bitbangio_spi_obj_unlock(mp_obj_t self_in) {
|
||||
bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(shared_module_bitbangio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
shared_module_bitbangio_spi_unlock(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -196,7 +202,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_unlock_obj, bitbangio_spi_obj_unlock);
|
|||
// TODO(tannewt): Add support for start and end kwargs.
|
||||
STATIC mp_obj_t bitbangio_spi_write(mp_obj_t self_in, mp_obj_t wr_buf) {
|
||||
bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(shared_module_bitbangio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_buffer_info_t src;
|
||||
mp_get_buffer_raise(wr_buf, &src, MP_BUFFER_READ);
|
||||
if (src.len == 0) {
|
||||
|
@ -221,7 +227,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(bitbangio_spi_write_obj, bitbangio_spi_write);
|
|||
// TODO(tannewt): Add support for start and end kwargs.
|
||||
STATIC mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *args) {
|
||||
bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
raise_error_if_deinited(shared_module_bitbangio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE);
|
||||
if (bufinfo.len == 0) {
|
||||
|
@ -261,7 +267,7 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_
|
|||
{ MP_QSTR_in_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} },
|
||||
};
|
||||
bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(shared_module_bitbangio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
|
|
@ -92,6 +92,12 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type,
|
|||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
STATIC void check_for_deinit(bleio_characteristic_buffer_obj_t *self) {
|
||||
if (common_hal_bleio_characteristic_buffer_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
// These are standard stream methods. Code is in py/stream.c.
|
||||
//
|
||||
//| .. method:: read(nbytes=None)
|
||||
|
@ -122,7 +128,7 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type,
|
|||
// These three methods are used by the shared stream methods.
|
||||
STATIC mp_uint_t bleio_characteristic_buffer_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
|
||||
bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_bleio_characteristic_buffer_deinited(self));
|
||||
check_for_deinit(self);
|
||||
raise_error_if_not_connected(self);
|
||||
byte *buf = buf_in;
|
||||
|
||||
|
@ -141,7 +147,7 @@ STATIC mp_uint_t bleio_characteristic_buffer_write(mp_obj_t self_in, const void
|
|||
|
||||
STATIC mp_uint_t bleio_characteristic_buffer_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
||||
bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_bleio_characteristic_buffer_deinited(self));
|
||||
check_for_deinit(self);
|
||||
raise_error_if_not_connected(self);
|
||||
if (!common_hal_bleio_characteristic_buffer_connected(self)) {
|
||||
mp_raise_ValueError(translate("Not connected"));
|
||||
|
@ -170,7 +176,7 @@ STATIC mp_uint_t bleio_characteristic_buffer_ioctl(mp_obj_t self_in, mp_uint_t r
|
|||
//|
|
||||
STATIC mp_obj_t bleio_characteristic_buffer_obj_get_in_waiting(mp_obj_t self_in) {
|
||||
bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_bleio_characteristic_buffer_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_characteristic_buffer_rx_characters_available(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_buffer_get_in_waiting_obj, bleio_characteristic_buffer_obj_get_in_waiting);
|
||||
|
@ -188,7 +194,7 @@ const mp_obj_property_t bleio_characteristic_buffer_in_waiting_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t bleio_characteristic_buffer_obj_reset_input_buffer(mp_obj_t self_in) {
|
||||
bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_bleio_characteristic_buffer_deinited(self));
|
||||
check_for_deinit(self);
|
||||
common_hal_bleio_characteristic_buffer_clear_rx_buffer(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
|
|
@ -93,6 +93,12 @@ STATIC mp_obj_t busio_i2c_obj_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_deinit_obj, busio_i2c_obj_deinit);
|
||||
|
||||
STATIC void check_for_deinit(busio_i2c_obj_t *self) {
|
||||
if (common_hal_busio_i2c_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used in Context Managers.
|
||||
|
@ -128,7 +134,7 @@ static void check_lock(busio_i2c_obj_t *self) {
|
|||
//|
|
||||
STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) {
|
||||
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_obj_t list = mp_obj_new_list(0, NULL);
|
||||
// 7-bit addresses 0b0000xxx and 0b1111xxx are reserved
|
||||
|
@ -151,7 +157,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan);
|
|||
//|
|
||||
STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) {
|
||||
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_bool(common_hal_busio_i2c_try_lock(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock);
|
||||
|
@ -162,7 +168,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock);
|
|||
//|
|
||||
STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) {
|
||||
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
common_hal_busio_i2c_unlock(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -192,7 +198,7 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args,
|
|||
{ MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} },
|
||||
};
|
||||
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_busio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
@ -245,7 +251,7 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma
|
|||
{ MP_QSTR_stop, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
|
||||
};
|
||||
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_busio_i2c_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
|
|
@ -91,6 +91,12 @@ STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_deinit_obj, busio_onewire_deinit);
|
||||
|
||||
STATIC void check_for_deinit(busio_onewire_obj_t *self) {
|
||||
if (common_hal_busio_onewire_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -118,7 +124,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, bus
|
|||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_onewire_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(common_hal_busio_onewire_reset(self));
|
||||
}
|
||||
|
@ -133,7 +139,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset);
|
|||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_onewire_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(common_hal_busio_onewire_read_bit(self));
|
||||
}
|
||||
|
@ -145,7 +151,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit
|
|||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_onewire_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_busio_onewire_write_bit(self, mp_obj_is_true(bool_obj));
|
||||
return mp_const_none;
|
||||
|
|
|
@ -124,13 +124,19 @@ STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_spi_obj___exit___obj, 4, 4, busio_spi_obj___exit__);
|
||||
|
||||
static void check_lock(busio_spi_obj_t *self) {
|
||||
STATIC void check_lock(busio_spi_obj_t *self) {
|
||||
asm("");
|
||||
if (!common_hal_busio_spi_has_lock(self)) {
|
||||
mp_raise_RuntimeError(translate("Function requires lock"));
|
||||
}
|
||||
}
|
||||
|
||||
STATIC void check_for_deinit(busio_spi_obj_t *self) {
|
||||
if (common_hal_busio_spi_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: configure(*, baudrate=100000, polarity=0, phase=0, bits=8)
|
||||
//|
|
||||
//| Configures the SPI bus. The SPI object must be locked.
|
||||
|
@ -162,7 +168,7 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_
|
|||
{ MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} },
|
||||
};
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_busio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
@ -197,7 +203,6 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure);
|
|||
//|
|
||||
STATIC mp_obj_t busio_spi_obj_try_lock(mp_obj_t self_in) {
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_spi_deinited(self));
|
||||
return mp_obj_new_bool(common_hal_busio_spi_try_lock(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock);
|
||||
|
@ -208,7 +213,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock);
|
|||
//|
|
||||
STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) {
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
common_hal_busio_spi_unlock(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -231,7 +236,7 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
|||
{ MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} },
|
||||
};
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_busio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
@ -275,7 +280,7 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m
|
|||
{ MP_QSTR_write_value,MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
|
||||
};
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_busio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
@ -324,7 +329,7 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args
|
|||
{ MP_QSTR_in_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} },
|
||||
};
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_busio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
check_lock(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
@ -367,7 +372,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_read
|
|||
//|
|
||||
STATIC mp_obj_t busio_spi_obj_get_frequency(mp_obj_t self_in) {
|
||||
busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_spi_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_busio_spi_get_frequency(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_get_frequency_obj, busio_spi_obj_get_frequency);
|
||||
|
|
|
@ -137,6 +137,12 @@ STATIC mp_obj_t busio_uart_obj_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_deinit_obj, busio_uart_obj_deinit);
|
||||
|
||||
STATIC void check_for_deinit(busio_uart_obj_t *self) {
|
||||
if (common_hal_busio_uart_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -196,7 +202,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
|
|||
// These three methods are used by the shared stream methods.
|
||||
STATIC mp_uint_t busio_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_uart_deinited(self));
|
||||
check_for_deinit(self);
|
||||
byte *buf = buf_in;
|
||||
|
||||
// make sure we want at least 1 char
|
||||
|
@ -209,7 +215,7 @@ STATIC mp_uint_t busio_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size,
|
|||
|
||||
STATIC mp_uint_t busio_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_uart_deinited(self));
|
||||
check_for_deinit(self);
|
||||
const byte *buf = buf_in;
|
||||
|
||||
return common_hal_busio_uart_write(self, buf, size, errcode);
|
||||
|
@ -217,7 +223,7 @@ STATIC mp_uint_t busio_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_
|
|||
|
||||
STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_uart_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_uint_t ret;
|
||||
if (request == MP_IOCTL_POLL) {
|
||||
mp_uint_t flags = arg;
|
||||
|
@ -241,14 +247,14 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t
|
|||
//|
|
||||
STATIC mp_obj_t busio_uart_obj_get_baudrate(mp_obj_t self_in) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_uart_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_busio_uart_get_baudrate(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_get_baudrate_obj, busio_uart_obj_get_baudrate);
|
||||
|
||||
STATIC mp_obj_t busio_uart_obj_set_baudrate(mp_obj_t self_in, mp_obj_t baudrate) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_uart_deinited(self));
|
||||
check_for_deinit(self);
|
||||
common_hal_busio_uart_set_baudrate(self, mp_obj_get_int(baudrate));
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -268,7 +274,7 @@ const mp_obj_property_t busio_uart_baudrate_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t busio_uart_obj_get_in_waiting(mp_obj_t self_in) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_uart_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_busio_uart_rx_characters_available(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_get_in_waiting_obj, busio_uart_obj_get_in_waiting);
|
||||
|
@ -286,7 +292,7 @@ const mp_obj_property_t busio_uart_in_waiting_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) {
|
||||
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_busio_uart_deinited(self));
|
||||
check_for_deinit(self);
|
||||
common_hal_busio_uart_clear_rx_buffer(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,12 @@ STATIC mp_obj_t digitalio_digitalinout_obj___exit__(size_t n_args, const mp_obj_
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(digitalio_digitalinout_obj___exit___obj, 4, 4, digitalio_digitalinout_obj___exit__);
|
||||
|
||||
STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) {
|
||||
if (common_hal_digitalio_digitalinout_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//|
|
||||
//| .. method:: switch_to_output(value=False, drive_mode=digitalio.DriveMode.PUSH_PULL)
|
||||
//|
|
||||
|
@ -121,7 +127,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_
|
|||
{ MP_QSTR_drive_mode, MP_ARG_OBJ, {.u_rom_obj = &digitalio_drive_mode_push_pull_obj} },
|
||||
};
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
|
@ -158,7 +164,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o
|
|||
{ MP_QSTR_pull, MP_ARG_OBJ, {.u_rom_obj = mp_const_none} },
|
||||
};
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
|
@ -191,7 +197,7 @@ extern const digitalio_digitalio_direction_obj_t digitalio_digitalio_direction_o
|
|||
|
||||
STATIC mp_obj_t digitalio_digitalinout_obj_get_direction(mp_obj_t self_in) {
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
digitalio_direction_t direction = common_hal_digitalio_digitalinout_get_direction(self);
|
||||
if (direction == DIRECTION_INPUT) {
|
||||
return (mp_obj_t)&digitalio_direction_input_obj;
|
||||
|
@ -202,7 +208,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_get_direction_obj, digitalio_di
|
|||
|
||||
STATIC mp_obj_t digitalio_digitalinout_obj_set_direction(mp_obj_t self_in, mp_obj_t value) {
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
if (value == &digitalio_direction_input_obj) {
|
||||
common_hal_digitalio_digitalinout_switch_to_input(self, PULL_NONE);
|
||||
} else if (value == &digitalio_direction_output_obj) {
|
||||
|
@ -227,7 +233,7 @@ const mp_obj_property_t digitalio_digitalio_direction_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t digitalio_digitalinout_obj_get_value(mp_obj_t self_in) {
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
bool value = common_hal_digitalio_digitalinout_get_value(self);
|
||||
return mp_obj_new_bool(value);
|
||||
}
|
||||
|
@ -235,7 +241,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_get_value_obj, digitalio_digita
|
|||
|
||||
STATIC mp_obj_t digitalio_digitalinout_obj_set_value(mp_obj_t self_in, mp_obj_t value) {
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_INPUT) {
|
||||
mp_raise_AttributeError(translate("Cannot set value when direction is input."));
|
||||
return mp_const_none;
|
||||
|
@ -261,7 +267,7 @@ const mp_obj_property_t digitalio_digitalinout_value_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t digitalio_digitalinout_obj_get_drive_mode(mp_obj_t self_in) {
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_INPUT) {
|
||||
mp_raise_AttributeError(translate("Drive mode not used when direction is input."));
|
||||
return mp_const_none;
|
||||
|
@ -276,7 +282,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_get_drive_mode_obj, digitalio_d
|
|||
|
||||
STATIC mp_obj_t digitalio_digitalinout_obj_set_drive_mode(mp_obj_t self_in, mp_obj_t drive_mode) {
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_INPUT) {
|
||||
mp_raise_AttributeError(translate("Drive mode not used when direction is input."));
|
||||
return mp_const_none;
|
||||
|
@ -309,7 +315,7 @@ const mp_obj_property_t digitalio_digitalio_drive_mode_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t digitalio_digitalinout_obj_get_pull(mp_obj_t self_in) {
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_OUTPUT) {
|
||||
mp_raise_AttributeError(translate("Pull not used when direction is output."));
|
||||
return mp_const_none;
|
||||
|
@ -326,7 +332,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_get_pull_obj, digitalio_digital
|
|||
|
||||
STATIC mp_obj_t digitalio_digitalinout_obj_set_pull(mp_obj_t self_in, mp_obj_t pull_obj) {
|
||||
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_OUTPUT) {
|
||||
mp_raise_AttributeError(translate("Pull not used when direction is output."));
|
||||
return mp_const_none;
|
||||
|
@ -381,7 +387,6 @@ digitalio_digitalinout_obj_t *assert_digitalinout(mp_obj_t obj) {
|
|||
mp_raise_TypeError(translate("argument num/types mismatch"));
|
||||
}
|
||||
digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(obj);
|
||||
raise_error_if_deinited(
|
||||
common_hal_digitalio_digitalinout_deinited(pin));
|
||||
check_for_deinit(pin);
|
||||
return pin;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ bool displayio_display_frame_queued(displayio_display_obj_t* self);
|
|||
|
||||
bool displayio_display_refresh_queued(displayio_display_obj_t* self);
|
||||
void displayio_display_finish_refresh(displayio_display_obj_t* self);
|
||||
void displayio_display_send_pixels(displayio_display_obj_t* self, uint32_t* pixels, uint32_t length);
|
||||
void displayio_display_send_pixels(displayio_display_obj_t* self, uint8_t* pixels, uint32_t length);
|
||||
|
||||
bool common_hal_displayio_display_get_auto_brightness(displayio_display_obj_t* self);
|
||||
void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* self, bool auto_brightness);
|
||||
|
|
|
@ -196,6 +196,83 @@ const mp_obj_property_t displayio_tilegrid_y_obj = {
|
|||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| .. attribute:: flip_x
|
||||
//|
|
||||
//| If true, the left edge rendered will be the right edge of the right-most tile.
|
||||
//|
|
||||
STATIC mp_obj_t displayio_tilegrid_obj_get_flip_x(mp_obj_t self_in) {
|
||||
displayio_tilegrid_t *self = native_tilegrid(self_in);
|
||||
return mp_obj_new_bool(common_hal_displayio_tilegrid_get_flip_x(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_flip_x_obj, displayio_tilegrid_obj_get_flip_x);
|
||||
|
||||
STATIC mp_obj_t displayio_tilegrid_obj_set_flip_x(mp_obj_t self_in, mp_obj_t flip_x_obj) {
|
||||
displayio_tilegrid_t *self = native_tilegrid(self_in);
|
||||
|
||||
common_hal_displayio_tilegrid_set_flip_x(self, mp_obj_is_true(flip_x_obj));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_flip_x_obj, displayio_tilegrid_obj_set_flip_x);
|
||||
|
||||
const mp_obj_property_t displayio_tilegrid_flip_x_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = {(mp_obj_t)&displayio_tilegrid_get_flip_x_obj,
|
||||
(mp_obj_t)&displayio_tilegrid_set_flip_x_obj,
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| .. attribute:: flip_y
|
||||
//|
|
||||
//| If true, the top edge rendered will be the bottom edge of the bottom-most tile.
|
||||
//|
|
||||
STATIC mp_obj_t displayio_tilegrid_obj_get_flip_y(mp_obj_t self_in) {
|
||||
displayio_tilegrid_t *self = native_tilegrid(self_in);
|
||||
return mp_obj_new_bool(common_hal_displayio_tilegrid_get_flip_y(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_flip_y_obj, displayio_tilegrid_obj_get_flip_y);
|
||||
|
||||
STATIC mp_obj_t displayio_tilegrid_obj_set_flip_y(mp_obj_t self_in, mp_obj_t flip_y_obj) {
|
||||
displayio_tilegrid_t *self = native_tilegrid(self_in);
|
||||
|
||||
common_hal_displayio_tilegrid_set_flip_y(self, mp_obj_is_true(flip_y_obj));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_flip_y_obj, displayio_tilegrid_obj_set_flip_y);
|
||||
|
||||
const mp_obj_property_t displayio_tilegrid_flip_y_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = {(mp_obj_t)&displayio_tilegrid_get_flip_y_obj,
|
||||
(mp_obj_t)&displayio_tilegrid_set_flip_y_obj,
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
|
||||
//| .. attribute:: transpose_xy
|
||||
//|
|
||||
//| If true, the TileGrid's axis will be swapped. When combined with mirroring, any 90 degree
|
||||
//| rotation can be achieved along with the corresponding mirrored version.
|
||||
//|
|
||||
STATIC mp_obj_t displayio_tilegrid_obj_get_transpose_xy(mp_obj_t self_in) {
|
||||
displayio_tilegrid_t *self = native_tilegrid(self_in);
|
||||
return mp_obj_new_bool(common_hal_displayio_tilegrid_get_transpose_xy(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_transpose_xy_obj, displayio_tilegrid_obj_get_transpose_xy);
|
||||
|
||||
STATIC mp_obj_t displayio_tilegrid_obj_set_transpose_xy(mp_obj_t self_in, mp_obj_t transpose_xy_obj) {
|
||||
displayio_tilegrid_t *self = native_tilegrid(self_in);
|
||||
|
||||
common_hal_displayio_tilegrid_set_transpose_xy(self, mp_obj_is_true(transpose_xy_obj));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_transpose_xy_obj, displayio_tilegrid_obj_set_transpose_xy);
|
||||
|
||||
const mp_obj_property_t displayio_tilegrid_transpose_xy_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = {(mp_obj_t)&displayio_tilegrid_get_transpose_xy_obj,
|
||||
(mp_obj_t)&displayio_tilegrid_set_transpose_xy_obj,
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| .. attribute:: pixel_shader
|
||||
//|
|
||||
//| The pixel shader of the tilegrid.
|
||||
|
@ -292,6 +369,9 @@ STATIC const mp_rom_map_elem_t displayio_tilegrid_locals_dict_table[] = {
|
|||
// Properties
|
||||
{ MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&displayio_tilegrid_x_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_y), MP_ROM_PTR(&displayio_tilegrid_y_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_flip_x), MP_ROM_PTR(&displayio_tilegrid_flip_x_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_flip_y), MP_ROM_PTR(&displayio_tilegrid_flip_y_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_transpose_xy), MP_ROM_PTR(&displayio_tilegrid_transpose_xy_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_pixel_shader), MP_ROM_PTR(&displayio_tilegrid_pixel_shader_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(displayio_tilegrid_locals_dict, displayio_tilegrid_locals_dict_table);
|
||||
|
|
|
@ -42,6 +42,14 @@ void common_hal_displayio_tilegrid_set_y(displayio_tilegrid_t *self, mp_int_t y)
|
|||
mp_obj_t common_hal_displayio_tilegrid_get_pixel_shader(displayio_tilegrid_t *self);
|
||||
void common_hal_displayio_tilegrid_set_pixel_shader(displayio_tilegrid_t *self, mp_obj_t pixel_shader);
|
||||
|
||||
|
||||
bool common_hal_displayio_tilegrid_get_flip_x(displayio_tilegrid_t *self);
|
||||
void common_hal_displayio_tilegrid_set_flip_x(displayio_tilegrid_t *self, bool flip_x);
|
||||
bool common_hal_displayio_tilegrid_get_flip_y(displayio_tilegrid_t *self);
|
||||
void common_hal_displayio_tilegrid_set_flip_y(displayio_tilegrid_t *self, bool flip_y);
|
||||
bool common_hal_displayio_tilegrid_get_transpose_xy(displayio_tilegrid_t *self);
|
||||
void common_hal_displayio_tilegrid_set_transpose_xy(displayio_tilegrid_t *self, bool transpose_xy);
|
||||
|
||||
uint16_t common_hal_displayio_tilegrid_get_width(displayio_tilegrid_t *self);
|
||||
uint16_t common_hal_displayio_tilegrid_get_height(displayio_tilegrid_t *self);
|
||||
|
||||
|
|
|
@ -109,6 +109,12 @@ STATIC mp_obj_t frequencyio_frequencyin_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_deinit_obj, frequencyio_frequencyin_deinit);
|
||||
|
||||
STATIC void check_for_deinit(frequencyio_frequencyin_obj_t *self) {
|
||||
if (common_hal_frequencyio_frequencyin_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -133,7 +139,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(frequencyio_frequencyin___exit___obj,
|
|||
//|
|
||||
STATIC mp_obj_t frequencyio_frequencyin_obj_pause(mp_obj_t self_in) {
|
||||
frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_frequencyio_frequencyin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_frequencyio_frequencyin_pause(self);
|
||||
return mp_const_none;
|
||||
|
@ -146,7 +152,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_pause_obj, frequencyio_frequen
|
|||
//|
|
||||
STATIC mp_obj_t frequencyio_frequencyin_obj_resume(mp_obj_t self_in) {
|
||||
frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_frequencyio_frequencyin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_frequencyio_frequencyin_resume(self);
|
||||
return mp_const_none;
|
||||
|
@ -160,7 +166,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_resume_obj, frequencyio_freque
|
|||
|
||||
STATIC mp_obj_t frequencyio_frequencyin_obj_clear(mp_obj_t self_in) {
|
||||
frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_frequencyio_frequencyin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_frequencyio_frequencyin_clear(self);
|
||||
return mp_const_none;
|
||||
|
@ -178,7 +184,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_clear_obj, frequencyio_frequen
|
|||
//|
|
||||
STATIC mp_obj_t frequencyio_frequencyin_obj_get_capture_period(mp_obj_t self_in) {
|
||||
frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_frequencyio_frequencyin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_frequencyio_frequencyin_get_capture_period(self));
|
||||
}
|
||||
|
@ -186,7 +192,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequency_get_capture_period_obj, frequenc
|
|||
|
||||
STATIC mp_obj_t frequencyio_frequencyin_obj_set_capture_period(mp_obj_t self_in, mp_obj_t capture_period) {
|
||||
frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_frequencyio_frequencyin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_frequencyio_frequencyin_set_capture_period(self, mp_obj_get_int(capture_period));
|
||||
return mp_const_none;
|
||||
|
@ -206,7 +212,7 @@ const mp_obj_property_t frequencyio_frequencyin_capture_period_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t frequencyio_frequencyin_obj_get_value(mp_obj_t self_in) {
|
||||
frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_frequencyio_frequencyin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
//return MP_OBJ_NEW_SMALL_INT(common_hal_frequencyio_frequencyin_get_item(self));
|
||||
return mp_obj_new_int_from_float(common_hal_frequencyio_frequencyin_get_item(self));
|
||||
|
|
|
@ -150,7 +150,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(i2cslave_i2c_slave___exit___obj, 4, 4
|
|||
STATIC mp_obj_t i2cslave_i2c_slave_request(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
mp_check_self(MP_OBJ_IS_TYPE(pos_args[0], &i2cslave_i2c_slave_type));
|
||||
i2cslave_i2c_slave_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_i2cslave_i2c_slave_deinited(self));
|
||||
if(common_hal_i2cslave_i2c_slave_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
enum { ARG_timeout };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(-1)} },
|
||||
|
|
|
@ -103,6 +103,12 @@ STATIC mp_obj_t ps2io_ps2_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(ps2io_ps2_deinit_obj, ps2io_ps2_deinit);
|
||||
|
||||
STATIC void check_for_deinit(ps2io_ps2_obj_t *self) {
|
||||
if (common_hal_ps2io_ps2_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -128,7 +134,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ps2io_ps2___exit___obj, 4, 4, ps2io_p
|
|||
//|
|
||||
STATIC mp_obj_t ps2io_ps2_obj_popleft(mp_obj_t self_in) {
|
||||
ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_ps2io_ps2_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
int b = common_hal_ps2io_ps2_popleft(self);
|
||||
if (b < 0) {
|
||||
|
@ -153,7 +159,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(ps2io_ps2_popleft_obj, ps2io_ps2_obj_popleft);
|
|||
//|
|
||||
STATIC mp_obj_t ps2io_ps2_obj_sendcmd(mp_obj_t self_in, mp_obj_t ob) {
|
||||
ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_ps2io_ps2_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_int_t cmd = mp_obj_get_int(ob) & 0xff;
|
||||
int resp = common_hal_ps2io_ps2_sendcmd(self, cmd);
|
||||
if (resp < 0) {
|
||||
|
@ -195,7 +201,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(ps2io_ps2_sendcmd_obj, ps2io_ps2_obj_sendcmd);
|
|||
//|
|
||||
STATIC mp_obj_t ps2io_ps2_obj_clear_errors(mp_obj_t self_in) {
|
||||
ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_ps2io_ps2_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_ps2io_ps2_clear_errors(self));
|
||||
}
|
||||
|
@ -208,7 +214,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(ps2io_ps2_clear_errors_obj, ps2io_ps2_obj_clear_errors
|
|||
//|
|
||||
STATIC mp_obj_t ps2_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
|
||||
ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_ps2io_ps2_deinited(self));
|
||||
check_for_deinit(self);
|
||||
uint16_t len = common_hal_ps2io_ps2_get_len(self);
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len != 0);
|
||||
|
|
|
@ -133,6 +133,12 @@ STATIC mp_obj_t pulseio_pwmout_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pwmout_deinit_obj, pulseio_pwmout_deinit);
|
||||
|
||||
STATIC void check_for_deinit(pulseio_pwmout_obj_t *self) {
|
||||
if (common_hal_pulseio_pwmout_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -158,14 +164,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pwmout___exit___obj, 4, 4, pu
|
|||
//| be half high and then half low.
|
||||
STATIC mp_obj_t pulseio_pwmout_obj_get_duty_cycle(mp_obj_t self_in) {
|
||||
pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pwmout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pwmout_get_duty_cycle(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pwmout_get_duty_cycle_obj, pulseio_pwmout_obj_get_duty_cycle);
|
||||
|
||||
STATIC mp_obj_t pulseio_pwmout_obj_set_duty_cycle(mp_obj_t self_in, mp_obj_t duty_cycle) {
|
||||
pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pwmout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
mp_int_t duty = mp_obj_get_int(duty_cycle);
|
||||
if (duty < 0 || duty > 0xffff) {
|
||||
mp_raise_ValueError(translate("PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)"));
|
||||
|
@ -189,14 +195,14 @@ const mp_obj_property_t pulseio_pwmout_duty_cycle_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t pulseio_pwmout_obj_get_frequency(mp_obj_t self_in) {
|
||||
pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pwmout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pwmout_get_frequency(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pwmout_get_frequency_obj, pulseio_pwmout_obj_get_frequency);
|
||||
|
||||
STATIC mp_obj_t pulseio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t frequency) {
|
||||
pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pwmout_deinited(self));
|
||||
check_for_deinit(self);
|
||||
if (!common_hal_pulseio_pwmout_get_variable_frequency(self)) {
|
||||
mp_raise_AttributeError(translate(
|
||||
"PWM frequency not writable when variable_frequency is False on "
|
||||
|
|
|
@ -114,6 +114,12 @@ STATIC mp_obj_t pulseio_pulsein_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_deinit_obj, pulseio_pulsein_deinit);
|
||||
|
||||
STATIC void check_for_deinit(pulseio_pulsein_obj_t *self) {
|
||||
if (common_hal_pulseio_pulsein_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -138,7 +144,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulsein___exit___obj, 4, 4, p
|
|||
//|
|
||||
STATIC mp_obj_t pulseio_pulsein_obj_pause(mp_obj_t self_in) {
|
||||
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pulsein_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_pulseio_pulsein_pause(self);
|
||||
return mp_const_none;
|
||||
|
@ -162,7 +168,7 @@ STATIC mp_obj_t pulseio_pulsein_obj_resume(size_t n_args, const mp_obj_t *pos_ar
|
|||
{ MP_QSTR_trigger_duration, MP_ARG_INT, {.u_int = 0} },
|
||||
};
|
||||
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
raise_error_if_deinited(common_hal_pulseio_pulsein_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
@ -178,7 +184,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(pulseio_pulsein_resume_obj, 1, pulseio_pulsein_obj_re
|
|||
//|
|
||||
STATIC mp_obj_t pulseio_pulsein_obj_clear(mp_obj_t self_in) {
|
||||
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pulsein_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_pulseio_pulsein_clear(self);
|
||||
return mp_const_none;
|
||||
|
@ -191,7 +197,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_clear_obj, pulseio_pulsein_obj_clear);
|
|||
//|
|
||||
STATIC mp_obj_t pulseio_pulsein_obj_popleft(mp_obj_t self_in) {
|
||||
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pulsein_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pulsein_popleft(self));
|
||||
}
|
||||
|
@ -204,7 +210,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_popleft_obj, pulseio_pulsein_obj_pople
|
|||
//|
|
||||
STATIC mp_obj_t pulseio_pulsein_obj_get_maxlen(mp_obj_t self_in) {
|
||||
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pulsein_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pulsein_get_maxlen(self));
|
||||
}
|
||||
|
@ -224,7 +230,7 @@ const mp_obj_property_t pulseio_pulsein_maxlen_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t pulseio_pulsein_obj_get_paused(mp_obj_t self_in) {
|
||||
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pulsein_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(common_hal_pulseio_pulsein_get_paused(self));
|
||||
}
|
||||
|
@ -248,7 +254,7 @@ const mp_obj_property_t pulseio_pulsein_paused_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
|
||||
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pulsein_deinited(self));
|
||||
check_for_deinit(self);
|
||||
uint16_t len = common_hal_pulseio_pulsein_get_len(self);
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len != 0);
|
||||
|
@ -272,7 +278,7 @@ STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t va
|
|||
mp_raise_AttributeError(translate("Cannot delete values"));
|
||||
} else {
|
||||
pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pulsein_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
if (MP_OBJ_IS_TYPE(index_obj, &mp_type_slice)) {
|
||||
mp_raise_NotImplementedError(translate("Slices not supported"));
|
||||
|
|
|
@ -127,7 +127,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulseout___exit___obj, 4, 4,
|
|||
//|
|
||||
STATIC mp_obj_t pulseio_pulseout_obj_send(mp_obj_t self_in, mp_obj_t pulses) {
|
||||
pulseio_pulseout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_pulseio_pulseout_deinited(self));
|
||||
if (common_hal_pulseio_pulseout_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(pulses, &bufinfo, MP_BUFFER_READ);
|
||||
|
|
|
@ -100,6 +100,12 @@ STATIC mp_obj_t rotaryio_incrementalencoder_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(rotaryio_incrementalencoder_deinit_obj, rotaryio_incrementalencoder_deinit);
|
||||
|
||||
STATIC void check_for_deinit(rotaryio_incrementalencoder_obj_t *self) {
|
||||
if (common_hal_rotaryio_incrementalencoder_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -126,7 +132,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(rotaryio_incrementalencoder___exit___
|
|||
//|
|
||||
STATIC mp_obj_t rotaryio_incrementalencoder_obj_get_position(mp_obj_t self_in) {
|
||||
rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_rotaryio_incrementalencoder_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_int(common_hal_rotaryio_incrementalencoder_get_position(self));
|
||||
}
|
||||
|
@ -134,7 +140,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(rotaryio_incrementalencoder_get_position_obj, rotaryio
|
|||
|
||||
STATIC mp_obj_t rotaryio_incrementalencoder_obj_set_position(mp_obj_t self_in, mp_obj_t new_position) {
|
||||
rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_rotaryio_incrementalencoder_deinited(self));
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_rotaryio_incrementalencoder_set_position(self, mp_obj_get_int(new_position));
|
||||
return mp_const_none;
|
||||
|
|
|
@ -88,6 +88,12 @@ STATIC mp_obj_t touchio_touchin_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(touchio_touchin_deinit_obj, touchio_touchin_deinit);
|
||||
|
||||
STATIC void check_for_deinit(touchio_touchin_obj_t *self) {
|
||||
if (common_hal_touchio_touchin_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| .. method:: __enter__()
|
||||
//|
|
||||
//| No-op used by Context Managers.
|
||||
|
@ -114,7 +120,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(touchio_touchin___exit___obj, 4, 4, t
|
|||
//|
|
||||
STATIC mp_obj_t touchio_touchin_obj_get_value(mp_obj_t self_in) {
|
||||
touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_touchio_touchin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return mp_obj_new_bool(common_hal_touchio_touchin_get_value(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(touchio_touchin_get_value_obj, touchio_touchin_obj_get_value);
|
||||
|
@ -133,7 +139,7 @@ const mp_obj_property_t touchio_touchin_value_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t touchio_touchin_obj_get_raw_value(mp_obj_t self_in) {
|
||||
touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_touchio_touchin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_touchio_touchin_get_raw_value(self));
|
||||
}
|
||||
|
||||
|
@ -158,7 +164,7 @@ const mp_obj_property_t touchio_touchin_raw_value_obj = {
|
|||
//|
|
||||
STATIC mp_obj_t touchio_touchin_obj_get_threshold(mp_obj_t self_in) {
|
||||
touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_touchio_touchin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_touchio_touchin_get_threshold(self));
|
||||
}
|
||||
|
||||
|
@ -166,7 +172,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(touchio_touchin_get_threshold_obj, touchio_touchin_obj
|
|||
|
||||
STATIC mp_obj_t touchio_touchin_obj_set_threshold(mp_obj_t self_in, mp_obj_t threshold_obj) {
|
||||
touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_touchio_touchin_deinited(self));
|
||||
check_for_deinit(self);
|
||||
uint32_t new_threshold = mp_obj_get_int(threshold_obj);
|
||||
if (new_threshold < 0 || new_threshold > UINT16_MAX) {
|
||||
// I would use MP_STRINGIFY(UINT16_MAX), but that prints "0xffff" instead of 65536.
|
||||
|
|
|
@ -32,11 +32,9 @@
|
|||
#include "shared-bindings/util.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
// Check if pin is None. If so, deinit() has already been called on the object, so complain.
|
||||
void raise_error_if_deinited(bool deinited) {
|
||||
if (deinited) {
|
||||
mp_raise_ValueError(translate("Object has been deinitialized and can no longer be used. Create a new object."));
|
||||
}
|
||||
// If so, deinit() has already been called on the object, so complain.
|
||||
void raise_deinited_error(void) {
|
||||
mp_raise_ValueError(translate("Object has been deinitialized and can no longer be used. Create a new object."));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_UTIL_H
|
||||
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_UTIL_H
|
||||
|
||||
void raise_error_if_deinited(bool deinited);
|
||||
void raise_deinited_error(void);
|
||||
|
||||
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_UTIL_H
|
||||
|
|
|
@ -107,28 +107,26 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
|||
|
||||
supervisor_start_terminal(width, height);
|
||||
|
||||
// Set the group after initialization otherwise we may send pixels while we delay in
|
||||
// initialization.
|
||||
self->refresh = true;
|
||||
self->current_group = &circuitpython_splash;
|
||||
|
||||
self->width = width;
|
||||
self->height = height;
|
||||
rotation = rotation % 360;
|
||||
self->mirror_x = false;
|
||||
self->mirror_y = false;
|
||||
self->transpose_xy = false;
|
||||
self->transform.x = 0;
|
||||
self->transform.y = 0;
|
||||
self->transform.scale = 1;
|
||||
self->transform.mirror_x = false;
|
||||
self->transform.mirror_y = false;
|
||||
self->transform.transpose_xy = false;
|
||||
if (rotation == 0 || rotation == 180) {
|
||||
if (rotation == 180) {
|
||||
self->mirror_x = true;
|
||||
self->mirror_y = true;
|
||||
self->transform.mirror_x = true;
|
||||
self->transform.mirror_y = true;
|
||||
}
|
||||
} else {
|
||||
self->transpose_xy = true;
|
||||
if (rotation == 90) {
|
||||
self->mirror_y = true;
|
||||
self->transform.transpose_xy = true;
|
||||
if (rotation == 270) {
|
||||
self->transform.mirror_y = true;
|
||||
} else {
|
||||
self->mirror_x = true;
|
||||
self->transform.mirror_x = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,13 +146,52 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
self->area.x1 = 0;
|
||||
self->area.y1 = 0;
|
||||
self->area.next = NULL;
|
||||
|
||||
self->transform.dx = 1;
|
||||
self->transform.dy = 1;
|
||||
if (self->transform.transpose_xy) {
|
||||
self->area.x2 = height;
|
||||
self->area.y2 = width;
|
||||
if (self->transform.mirror_x) {
|
||||
self->transform.x = height;
|
||||
self->transform.dx = -1;
|
||||
}
|
||||
if (self->transform.mirror_y) {
|
||||
self->transform.y = width;
|
||||
self->transform.dy = -1;
|
||||
}
|
||||
} else {
|
||||
self->area.x2 = width;
|
||||
self->area.y2 = height;
|
||||
if (self->transform.mirror_x) {
|
||||
self->transform.x = width;
|
||||
self->transform.dx = -1;
|
||||
}
|
||||
if (self->transform.mirror_y) {
|
||||
self->transform.y = height;
|
||||
self->transform.dy = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the group after initialization otherwise we may send pixels while we delay in
|
||||
// initialization.
|
||||
common_hal_displayio_display_show(self, &circuitpython_splash);
|
||||
}
|
||||
|
||||
void common_hal_displayio_display_show(displayio_display_obj_t* self, displayio_group_t* root_group) {
|
||||
if (root_group == NULL) {
|
||||
root_group = &circuitpython_splash;
|
||||
}
|
||||
if (root_group == self->current_group) {
|
||||
return;
|
||||
}
|
||||
displayio_group_update_transform(root_group, &self->transform);
|
||||
self->current_group = root_group;
|
||||
self->full_refresh = true;
|
||||
common_hal_displayio_display_refresh_soon(self);
|
||||
}
|
||||
|
||||
|
@ -162,6 +199,15 @@ void common_hal_displayio_display_refresh_soon(displayio_display_obj_t* self) {
|
|||
self->refresh = true;
|
||||
}
|
||||
|
||||
const displayio_area_t* displayio_display_get_refresh_areas(displayio_display_obj_t *self) {
|
||||
if (self->full_refresh) {
|
||||
self->area.next = NULL;
|
||||
return &self->area;
|
||||
} else {
|
||||
return displayio_group_get_refresh_areas(self->current_group, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t common_hal_displayio_display_wait_for_frame(displayio_display_obj_t* self) {
|
||||
uint64_t last_refresh = self->last_refresh;
|
||||
// Don't try to refresh if we got an exception.
|
||||
|
@ -224,7 +270,6 @@ void displayio_display_end_transaction(displayio_display_obj_t* self) {
|
|||
}
|
||||
|
||||
void displayio_display_set_region_to_update(displayio_display_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||
|
||||
self->send(self->bus, true, &self->set_column_command, 1);
|
||||
bool isCommand = self->data_as_commands;
|
||||
if (self->single_byte_bounds) {
|
||||
|
@ -255,13 +300,16 @@ void displayio_display_set_region_to_update(displayio_display_obj_t* self, uint1
|
|||
}
|
||||
}
|
||||
|
||||
bool displayio_display_frame_queued(displayio_display_obj_t* self) {
|
||||
// Refresh at ~30 fps.
|
||||
return (ticks_ms - self->last_refresh) > 32;
|
||||
void displayio_display_start_refresh(displayio_display_obj_t* self) {
|
||||
self->last_refresh = ticks_ms;
|
||||
}
|
||||
|
||||
bool displayio_display_refresh_queued(displayio_display_obj_t* self) {
|
||||
return self->refresh || (self->current_group != NULL && displayio_group_needs_refresh(self->current_group));
|
||||
bool displayio_display_frame_queued(displayio_display_obj_t* self) {
|
||||
if (self->current_group == NULL) {
|
||||
return false;
|
||||
}
|
||||
// Refresh at ~60 fps.
|
||||
return (ticks_ms - self->last_refresh) > 16;
|
||||
}
|
||||
|
||||
void displayio_display_finish_refresh(displayio_display_obj_t* self) {
|
||||
|
@ -269,11 +317,12 @@ void displayio_display_finish_refresh(displayio_display_obj_t* self) {
|
|||
displayio_group_finish_refresh(self->current_group);
|
||||
}
|
||||
self->refresh = false;
|
||||
self->full_refresh = false;
|
||||
self->last_refresh = ticks_ms;
|
||||
}
|
||||
|
||||
void displayio_display_send_pixels(displayio_display_obj_t* self, uint32_t* pixels, uint32_t length) {
|
||||
self->send(self->bus, false, (uint8_t*) pixels, length * 4);
|
||||
void displayio_display_send_pixels(displayio_display_obj_t* self, uint8_t* pixels, uint32_t length) {
|
||||
self->send(self->bus, false, pixels, length);
|
||||
}
|
||||
|
||||
void displayio_display_update_backlight(displayio_display_obj_t* self) {
|
||||
|
@ -298,3 +347,11 @@ void release_display(displayio_display_obj_t* self) {
|
|||
common_hal_digitalio_digitalinout_deinit(&self->backlight_inout);
|
||||
}
|
||||
}
|
||||
|
||||
bool displayio_display_fill_area(displayio_display_obj_t *self, displayio_area_t* area, uint32_t* mask, uint32_t *buffer) {
|
||||
return displayio_group_fill_area(self->current_group, area, mask, buffer);
|
||||
}
|
||||
|
||||
bool displayio_display_clip_area(displayio_display_obj_t *self, const displayio_area_t* area, displayio_area_t* clipped) {
|
||||
return displayio_area_compute_overlap(&self->area, area, clipped);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "shared-bindings/displayio/Group.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
|
||||
#include "shared-module/displayio/area.h"
|
||||
|
||||
typedef bool (*display_bus_begin_transaction)(mp_obj_t bus);
|
||||
typedef void (*display_bus_send)(mp_obj_t bus, bool command, uint8_t *data, uint32_t data_length);
|
||||
typedef void (*display_bus_end_transaction)(mp_obj_t bus);
|
||||
|
@ -38,19 +40,8 @@ typedef void (*display_bus_end_transaction)(mp_obj_t bus);
|
|||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
mp_obj_t bus;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint16_t color_depth;
|
||||
uint8_t set_column_command;
|
||||
uint8_t set_row_command;
|
||||
uint8_t write_ram_command;
|
||||
displayio_group_t *current_group;
|
||||
bool refresh;
|
||||
uint64_t last_refresh;
|
||||
int16_t colstart;
|
||||
int16_t rowstart;
|
||||
bool single_byte_bounds;
|
||||
bool data_as_commands;
|
||||
display_bus_begin_transaction begin_transaction;
|
||||
display_bus_send send;
|
||||
display_bus_end_transaction end_transaction;
|
||||
|
@ -59,14 +50,29 @@ typedef struct {
|
|||
pulseio_pwmout_obj_t backlight_pwm;
|
||||
};
|
||||
uint64_t last_backlight_refresh;
|
||||
bool auto_brightness:1;
|
||||
bool updating_backlight:1;
|
||||
bool mirror_x;
|
||||
bool mirror_y;
|
||||
bool transpose_xy;
|
||||
displayio_buffer_transform_t transform;
|
||||
displayio_area_t area;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint16_t color_depth;
|
||||
int16_t colstart;
|
||||
int16_t rowstart;
|
||||
uint8_t set_column_command;
|
||||
uint8_t set_row_command;
|
||||
uint8_t write_ram_command;
|
||||
bool refresh;
|
||||
bool single_byte_bounds;
|
||||
bool data_as_commands;
|
||||
bool auto_brightness;
|
||||
bool updating_backlight;
|
||||
bool full_refresh; // New group means we need to refresh the whole display.
|
||||
} displayio_display_obj_t;
|
||||
|
||||
void displayio_display_start_refresh(displayio_display_obj_t* self);
|
||||
const displayio_area_t* displayio_display_get_refresh_areas(displayio_display_obj_t *self);
|
||||
bool displayio_display_fill_area(displayio_display_obj_t *self, displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
|
||||
void displayio_display_update_backlight(displayio_display_obj_t* self);
|
||||
bool displayio_display_clip_area(displayio_display_obj_t *self, const displayio_area_t* area, displayio_area_t* clipped);
|
||||
void release_display(displayio_display_obj_t* self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_DISPLAY_H
|
||||
|
|
|
@ -38,9 +38,85 @@ uint32_t common_hal_displayio_group_get_scale(displayio_group_t* self) {
|
|||
return self->scale;
|
||||
}
|
||||
|
||||
bool displayio_group_get_previous_area(displayio_group_t *self, displayio_area_t* area) {
|
||||
bool first = true;
|
||||
for (size_t i = 0; i < self->size; i++) {
|
||||
mp_obj_t layer = self->children[i].native;
|
||||
displayio_area_t layer_area;
|
||||
if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) {
|
||||
if (!displayio_tilegrid_get_previous_area(layer, &layer_area)) {
|
||||
continue;
|
||||
}
|
||||
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
|
||||
if (!displayio_group_get_previous_area(layer, &layer_area)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (first) {
|
||||
displayio_area_copy(&layer_area, area);
|
||||
first = false;
|
||||
} else {
|
||||
displayio_area_expand(area, &layer_area);
|
||||
}
|
||||
}
|
||||
if (self->item_removed) {
|
||||
if (first) {
|
||||
displayio_area_copy(&self->dirty_area, area);
|
||||
first = false;
|
||||
} else {
|
||||
displayio_area_expand(area, &self->dirty_area);
|
||||
}
|
||||
}
|
||||
return !first;
|
||||
}
|
||||
|
||||
static void _update_child_transforms(displayio_group_t* self) {
|
||||
if (!self->in_group) {
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < self->size; i++) {
|
||||
mp_obj_t layer = self->children[i].native;
|
||||
if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) {
|
||||
displayio_tilegrid_update_transform(layer, &self->absolute_transform);
|
||||
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
|
||||
displayio_group_update_transform(layer, &self->absolute_transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void displayio_group_update_transform(displayio_group_t *self,
|
||||
const displayio_buffer_transform_t* parent_transform) {
|
||||
self->in_group = parent_transform != NULL;
|
||||
if (self->in_group) {
|
||||
int16_t x = self->x;
|
||||
int16_t y = self->y;
|
||||
if (parent_transform->transpose_xy) {
|
||||
x = y;
|
||||
y = self->x;
|
||||
}
|
||||
self->absolute_transform.x = parent_transform->x + parent_transform->dx * x;
|
||||
self->absolute_transform.y = parent_transform->y + parent_transform->dy * y;
|
||||
self->absolute_transform.dx = parent_transform->dx * self->scale;
|
||||
self->absolute_transform.dy = parent_transform->dy * self->scale;
|
||||
self->absolute_transform.transpose_xy = parent_transform->transpose_xy;
|
||||
self->absolute_transform.mirror_x = parent_transform->mirror_x;
|
||||
self->absolute_transform.mirror_y = parent_transform->mirror_y;
|
||||
|
||||
self->absolute_transform.scale = parent_transform->scale * self->scale;
|
||||
}
|
||||
_update_child_transforms(self);
|
||||
}
|
||||
|
||||
void common_hal_displayio_group_set_scale(displayio_group_t* self, uint32_t scale) {
|
||||
self->needs_refresh = self->scale != scale;
|
||||
if (self->scale == scale) {
|
||||
return;
|
||||
}
|
||||
uint8_t parent_scale = self->absolute_transform.scale / self->scale;
|
||||
self->absolute_transform.dx = self->absolute_transform.dx / self->scale * scale;
|
||||
self->absolute_transform.dy = self->absolute_transform.dy / self->scale * scale;
|
||||
self->absolute_transform.scale = parent_scale * scale;
|
||||
self->scale = scale;
|
||||
_update_child_transforms(self);
|
||||
}
|
||||
|
||||
mp_int_t common_hal_displayio_group_get_x(displayio_group_t* self) {
|
||||
|
@ -48,8 +124,19 @@ mp_int_t common_hal_displayio_group_get_x(displayio_group_t* self) {
|
|||
}
|
||||
|
||||
void common_hal_displayio_group_set_x(displayio_group_t* self, mp_int_t x) {
|
||||
self->needs_refresh = self->x != x;
|
||||
if (self->x == x) {
|
||||
return;
|
||||
}
|
||||
if (self->absolute_transform.transpose_xy) {
|
||||
int16_t dy = self->absolute_transform.dy / self->scale;
|
||||
self->absolute_transform.y += dy * (x - self->x);
|
||||
} else {
|
||||
int16_t dx = self->absolute_transform.dx / self->scale;
|
||||
self->absolute_transform.x += dx * (x - self->x);
|
||||
}
|
||||
|
||||
self->x = x;
|
||||
_update_child_transforms(self);
|
||||
}
|
||||
|
||||
mp_int_t common_hal_displayio_group_get_y(displayio_group_t* self) {
|
||||
|
@ -57,21 +144,75 @@ mp_int_t common_hal_displayio_group_get_y(displayio_group_t* self) {
|
|||
}
|
||||
|
||||
void common_hal_displayio_group_set_y(displayio_group_t* self, mp_int_t y) {
|
||||
self->needs_refresh = self->y != y;
|
||||
if (self->y == y) {
|
||||
return;
|
||||
}
|
||||
if (self->absolute_transform.transpose_xy) {
|
||||
int8_t dx = self->absolute_transform.dx / self->scale;
|
||||
self->absolute_transform.x += dx * (y - self->y);
|
||||
} else {
|
||||
int8_t dy = self->absolute_transform.dy / self->scale;
|
||||
self->absolute_transform.y += dy * (y - self->y);
|
||||
}
|
||||
self->y = y;
|
||||
_update_child_transforms(self);
|
||||
}
|
||||
|
||||
static mp_obj_t _add_layer(displayio_group_t* self, mp_obj_t layer) {
|
||||
mp_obj_t native_layer = mp_instance_cast_to_native_base(layer, &displayio_group_type);
|
||||
if (native_layer == MP_OBJ_NULL) {
|
||||
native_layer = mp_instance_cast_to_native_base(layer, &displayio_tilegrid_type);
|
||||
if (native_layer == MP_OBJ_NULL) {
|
||||
mp_raise_ValueError(translate("Layer must be a Group or TileGrid subclass."));
|
||||
}
|
||||
displayio_tilegrid_t* tilegrid = native_layer;
|
||||
if (tilegrid->in_group) {
|
||||
mp_raise_ValueError(translate("Layer already in a group."));
|
||||
} else {
|
||||
tilegrid->in_group = true;
|
||||
}
|
||||
displayio_tilegrid_update_transform(tilegrid, &self->absolute_transform);
|
||||
} else {
|
||||
displayio_group_t* group = native_layer;
|
||||
if (group->in_group) {
|
||||
mp_raise_ValueError(translate("Layer already in a group."));
|
||||
} else {
|
||||
group->in_group = true;
|
||||
}
|
||||
displayio_group_update_transform(group, &self->absolute_transform);
|
||||
}
|
||||
return native_layer;
|
||||
}
|
||||
|
||||
static void _remove_layer(displayio_group_t* self, size_t index) {
|
||||
mp_obj_t layer = self->children[index].native;
|
||||
displayio_area_t layer_area;
|
||||
bool rendered_last_frame = false;
|
||||
if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) {
|
||||
displayio_tilegrid_t* tilegrid = layer;
|
||||
rendered_last_frame = displayio_tilegrid_get_previous_area(tilegrid, &layer_area);
|
||||
displayio_tilegrid_update_transform(tilegrid, NULL);
|
||||
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
|
||||
displayio_group_t* group = layer;
|
||||
rendered_last_frame = displayio_group_get_previous_area(group, &layer_area);
|
||||
displayio_group_update_transform(group, NULL);
|
||||
}
|
||||
if (!rendered_last_frame) {
|
||||
return;
|
||||
}
|
||||
if (!self->item_removed) {
|
||||
displayio_area_copy(&layer_area, &self->dirty_area);
|
||||
} else {
|
||||
displayio_area_expand(&self->dirty_area, &layer_area);
|
||||
}
|
||||
self->item_removed = true;
|
||||
}
|
||||
|
||||
void common_hal_displayio_group_insert(displayio_group_t* self, size_t index, mp_obj_t layer) {
|
||||
if (self->size == self->max_size) {
|
||||
mp_raise_RuntimeError(translate("Group full"));
|
||||
}
|
||||
mp_obj_t native_layer = mp_instance_cast_to_native_base(layer, &displayio_group_type);
|
||||
if (native_layer == MP_OBJ_NULL) {
|
||||
native_layer = mp_instance_cast_to_native_base(layer, &displayio_tilegrid_type);
|
||||
}
|
||||
if (native_layer == MP_OBJ_NULL) {
|
||||
mp_raise_ValueError(translate("Layer must be a Group or TileGrid subclass."));
|
||||
}
|
||||
mp_obj_t native_layer = _add_layer(self, layer);
|
||||
// Shift everything right.
|
||||
for (size_t i = self->size; i > index; i--) {
|
||||
self->children[i] = self->children[i - 1];
|
||||
|
@ -79,19 +220,19 @@ void common_hal_displayio_group_insert(displayio_group_t* self, size_t index, mp
|
|||
self->children[index].native = native_layer;
|
||||
self->children[index].original = layer;
|
||||
self->size++;
|
||||
self->needs_refresh = true;
|
||||
}
|
||||
|
||||
mp_obj_t common_hal_displayio_group_pop(displayio_group_t* self, size_t index) {
|
||||
self->size--;
|
||||
mp_obj_t item = self->children[index].original;
|
||||
_remove_layer(self, index);
|
||||
|
||||
// Shift everything left.
|
||||
for (size_t i = index; i < self->size; i++) {
|
||||
self->children[i] = self->children[i + 1];
|
||||
}
|
||||
self->children[self->size].native = NULL;
|
||||
self->children[self->size].original = NULL;
|
||||
self->needs_refresh = true;
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -113,16 +254,10 @@ mp_obj_t common_hal_displayio_group_get(displayio_group_t* self, size_t index) {
|
|||
}
|
||||
|
||||
void common_hal_displayio_group_set(displayio_group_t* self, size_t index, mp_obj_t layer) {
|
||||
mp_obj_t native_layer = mp_instance_cast_to_native_base(layer, &displayio_group_type);
|
||||
if (native_layer == MP_OBJ_NULL) {
|
||||
native_layer = mp_instance_cast_to_native_base(layer, &displayio_tilegrid_type);
|
||||
}
|
||||
if (native_layer == MP_OBJ_NULL) {
|
||||
mp_raise_ValueError(translate("Layer must be a Group or TileGrid subclass."));
|
||||
}
|
||||
mp_obj_t native_layer = _add_layer(self, layer);
|
||||
_remove_layer(self, index);
|
||||
self->children[index].native = native_layer;
|
||||
self->children[index].original = layer;
|
||||
self->needs_refresh = true;
|
||||
}
|
||||
|
||||
void displayio_group_construct(displayio_group_t* self, displayio_group_child_t* child_array, uint32_t max_size, uint32_t scale, mp_int_t x, mp_int_t y) {
|
||||
|
@ -130,57 +265,34 @@ void displayio_group_construct(displayio_group_t* self, displayio_group_child_t*
|
|||
self->y = y;
|
||||
self->children = child_array;
|
||||
self->max_size = max_size;
|
||||
self->needs_refresh = false;
|
||||
self->item_removed = false;
|
||||
self->scale = scale;
|
||||
self->in_group = false;
|
||||
}
|
||||
|
||||
bool displayio_group_get_area(displayio_group_t *self, displayio_buffer_transform_t* transform, displayio_area_t* area, uint32_t* mask, uint32_t* buffer) {
|
||||
displayio_area_shift(area, -self->x * transform->scale, -self->y * transform->scale);
|
||||
transform->scale *= self->scale;
|
||||
|
||||
bool displayio_group_fill_area(displayio_group_t *self, const displayio_area_t* area, uint32_t* mask, uint32_t* buffer) {
|
||||
// Track if any of the layers finishes filling in the given area. We can ignore any remaining
|
||||
// layers at that point.
|
||||
bool full_coverage = false;
|
||||
for (int32_t i = self->size - 1; i >= 0 ; i--) {
|
||||
mp_obj_t layer = self->children[i].native;
|
||||
if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) {
|
||||
if (displayio_tilegrid_get_area(layer, transform, area, mask, buffer)) {
|
||||
if (displayio_tilegrid_fill_area(layer, area, mask, buffer)) {
|
||||
full_coverage = true;
|
||||
break;
|
||||
}
|
||||
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
|
||||
if (displayio_group_get_area(layer, transform, area, mask, buffer)) {
|
||||
if (displayio_group_fill_area(layer, area, mask, buffer)) {
|
||||
full_coverage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
transform->scale /= self->scale;
|
||||
displayio_area_shift(area, self->x * transform->scale, self->y * transform->scale);
|
||||
return full_coverage;
|
||||
}
|
||||
|
||||
bool displayio_group_needs_refresh(displayio_group_t *self) {
|
||||
if (self->needs_refresh) {
|
||||
return true;
|
||||
}
|
||||
for (int32_t i = self->size - 1; i >= 0 ; i--) {
|
||||
mp_obj_t layer = self->children[i].native;
|
||||
if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) {
|
||||
if (displayio_tilegrid_needs_refresh(layer)) {
|
||||
return true;
|
||||
}
|
||||
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
|
||||
if (displayio_group_needs_refresh(layer)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void displayio_group_finish_refresh(displayio_group_t *self) {
|
||||
self->needs_refresh = false;
|
||||
self->item_removed = false;
|
||||
for (int32_t i = self->size - 1; i >= 0 ; i--) {
|
||||
mp_obj_t layer = self->children[i].native;
|
||||
if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) {
|
||||
|
@ -190,3 +302,21 @@ void displayio_group_finish_refresh(displayio_group_t *self) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
displayio_area_t* displayio_group_get_refresh_areas(displayio_group_t *self, displayio_area_t* tail) {
|
||||
if (self->item_removed) {
|
||||
self->dirty_area.next = tail;
|
||||
tail = &self->dirty_area;
|
||||
}
|
||||
|
||||
for (int32_t i = self->size - 1; i >= 0 ; i--) {
|
||||
mp_obj_t layer = self->children[i].native;
|
||||
if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) {
|
||||
tail = displayio_tilegrid_get_refresh_areas(layer, tail);
|
||||
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
|
||||
tail = displayio_group_get_refresh_areas(layer, tail);
|
||||
}
|
||||
}
|
||||
|
||||
return tail;
|
||||
}
|
||||
|
|
|
@ -40,18 +40,23 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
displayio_group_child_t* children;
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
uint16_t scale;
|
||||
uint16_t size;
|
||||
uint16_t max_size;
|
||||
displayio_group_child_t* children;
|
||||
bool needs_refresh;
|
||||
bool item_removed;
|
||||
bool in_group;
|
||||
displayio_buffer_transform_t absolute_transform;
|
||||
displayio_area_t dirty_area; // Catch all for changed area
|
||||
} displayio_group_t;
|
||||
|
||||
void displayio_group_construct(displayio_group_t* self, displayio_group_child_t* child_array, uint32_t max_size, uint32_t scale, mp_int_t x, mp_int_t y);
|
||||
bool displayio_group_get_area(displayio_group_t *group, displayio_buffer_transform_t* transform, displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
|
||||
bool displayio_group_needs_refresh(displayio_group_t *self);
|
||||
bool displayio_group_get_previous_area(displayio_group_t *group, displayio_area_t* area);
|
||||
bool displayio_group_fill_area(displayio_group_t *group, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
|
||||
void displayio_group_update_transform(displayio_group_t *group, const displayio_buffer_transform_t* parent_transform);
|
||||
void displayio_group_finish_refresh(displayio_group_t *self);
|
||||
displayio_area_t* displayio_group_get_refresh_areas(displayio_group_t *self, displayio_area_t* tail);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_GROUP_H
|
||||
|
|
|
@ -53,7 +53,11 @@ void common_hal_displayio_palette_set_color(displayio_palette_t* self, uint32_t
|
|||
uint32_t packed = r5 << 11 | g6 << 5 | b5;
|
||||
// swap bytes
|
||||
packed = __builtin_bswap16(packed);
|
||||
self->colors[palette_index / 2] = masked | packed << shift;
|
||||
uint32_t final_color = masked | packed << shift;
|
||||
if (self->colors[palette_index / 2] == final_color) {
|
||||
return;
|
||||
}
|
||||
self->colors[palette_index / 2] = final_color;
|
||||
self->needs_refresh = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,39 +56,123 @@ void common_hal_displayio_tilegrid_construct(displayio_tilegrid_t *self, mp_obj_
|
|||
self->bitmap_width_in_tiles = bitmap_width_in_tiles;
|
||||
self->width_in_tiles = width;
|
||||
self->height_in_tiles = height;
|
||||
self->area.x1 = x;
|
||||
self->area.y1 = y;
|
||||
self->area.x2 = x + width * tile_width;
|
||||
self->area.y2 = y + height * tile_height;
|
||||
self->x = x;
|
||||
self->y = y;
|
||||
self->pixel_width = width * tile_width;
|
||||
self->pixel_height = height * tile_height;
|
||||
self->tile_width = tile_width;
|
||||
self->tile_height = tile_height;
|
||||
self->bitmap = bitmap;
|
||||
self->pixel_shader = pixel_shader;
|
||||
self->in_group = false;
|
||||
self->first_draw = true;
|
||||
self->flip_x = false;
|
||||
self->flip_y = false;
|
||||
self->transpose_xy = false;
|
||||
}
|
||||
|
||||
bool displayio_tilegrid_get_previous_area(displayio_tilegrid_t *self, displayio_area_t* area) {
|
||||
if (self->first_draw) {
|
||||
return false;
|
||||
}
|
||||
displayio_area_copy(&self->previous_area, area);
|
||||
return true;
|
||||
}
|
||||
|
||||
void _update_current_x(displayio_tilegrid_t *self) {
|
||||
int16_t width;
|
||||
if (self->transpose_xy) {
|
||||
width = self->pixel_height;
|
||||
} else {
|
||||
width = self->pixel_width;
|
||||
}
|
||||
if (self->absolute_transform->transpose_xy) {
|
||||
self->current_area.y1 = self->absolute_transform->y + self->absolute_transform->dy * self->x;
|
||||
self->current_area.y2 = self->absolute_transform->y + self->absolute_transform->dy * (self->x + width);
|
||||
if (self->current_area.y2 < self->current_area.y1) {
|
||||
int16_t temp = self->current_area.y2;
|
||||
self->current_area.y2 = self->current_area.y1;
|
||||
self->current_area.y1 = temp;
|
||||
}
|
||||
} else {
|
||||
self->current_area.x1 = self->absolute_transform->x + self->absolute_transform->dx * self->x;
|
||||
self->current_area.x2 = self->absolute_transform->x + self->absolute_transform->dx * (self->x + width);
|
||||
if (self->current_area.x2 < self->current_area.x1) {
|
||||
int16_t temp = self->current_area.x2;
|
||||
self->current_area.x2 = self->current_area.x1;
|
||||
self->current_area.x1 = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _update_current_y(displayio_tilegrid_t *self) {
|
||||
int16_t height;
|
||||
if (self->transpose_xy) {
|
||||
height = self->pixel_width;
|
||||
} else {
|
||||
height = self->pixel_height;
|
||||
}
|
||||
if (self->absolute_transform->transpose_xy) {
|
||||
self->current_area.x1 = self->absolute_transform->x + self->absolute_transform->dx * self->y;
|
||||
self->current_area.x2 = self->absolute_transform->x + self->absolute_transform->dx * (self->y + height);
|
||||
if (self->current_area.x2 < self->current_area.x1) {
|
||||
int16_t temp = self->current_area.x2;
|
||||
self->current_area.x2 = self->current_area.x1;
|
||||
self->current_area.x1 = temp;
|
||||
}
|
||||
} else {
|
||||
self->current_area.y1 = self->absolute_transform->y + self->absolute_transform->dy * self->y;
|
||||
self->current_area.y2 = self->absolute_transform->y + self->absolute_transform->dy * (self->y + height);
|
||||
if (self->current_area.y2 < self->current_area.y1) {
|
||||
int16_t temp = self->current_area.y2;
|
||||
self->current_area.y2 = self->current_area.y1;
|
||||
self->current_area.y1 = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void displayio_tilegrid_update_transform(displayio_tilegrid_t *self,
|
||||
const displayio_buffer_transform_t* absolute_transform) {
|
||||
self->in_group = absolute_transform != NULL;
|
||||
self->absolute_transform = absolute_transform;
|
||||
if (absolute_transform != NULL) {
|
||||
self->moved = !self->first_draw;
|
||||
|
||||
_update_current_x(self);
|
||||
_update_current_y(self);
|
||||
} else {
|
||||
self->first_draw = true;
|
||||
}
|
||||
}
|
||||
|
||||
mp_int_t common_hal_displayio_tilegrid_get_x(displayio_tilegrid_t *self) {
|
||||
return self->area.x1;
|
||||
return self->x;
|
||||
}
|
||||
void common_hal_displayio_tilegrid_set_x(displayio_tilegrid_t *self, mp_int_t x) {
|
||||
if (self->area.x1 == x) {
|
||||
if (self->x == x) {
|
||||
return;
|
||||
}
|
||||
self->needs_refresh = true;
|
||||
self->area.x2 += (self->area.x1 - x);
|
||||
self->area.x1 = x;
|
||||
|
||||
self->moved = !self->first_draw;
|
||||
|
||||
self->x = x;
|
||||
if (self->absolute_transform != NULL) {
|
||||
_update_current_x(self);
|
||||
}
|
||||
}
|
||||
mp_int_t common_hal_displayio_tilegrid_get_y(displayio_tilegrid_t *self) {
|
||||
return self->area.y1;
|
||||
return self->y;
|
||||
}
|
||||
|
||||
void common_hal_displayio_tilegrid_set_y(displayio_tilegrid_t *self, mp_int_t y) {
|
||||
if (self->area.y1 == y) {
|
||||
if (self->y == y) {
|
||||
return;
|
||||
}
|
||||
self->needs_refresh = true;
|
||||
self->area.y2 += (self->area.y1 - y);
|
||||
self->area.y1 = y;
|
||||
self->moved = !self->first_draw;
|
||||
self->y = y;
|
||||
if (self->absolute_transform != NULL) {
|
||||
_update_current_y(self);
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_t common_hal_displayio_tilegrid_get_pixel_shader(displayio_tilegrid_t *self) {
|
||||
|
@ -97,10 +181,9 @@ mp_obj_t common_hal_displayio_tilegrid_get_pixel_shader(displayio_tilegrid_t *se
|
|||
|
||||
void common_hal_displayio_tilegrid_set_pixel_shader(displayio_tilegrid_t *self, mp_obj_t pixel_shader) {
|
||||
self->pixel_shader = pixel_shader;
|
||||
self->needs_refresh = true;
|
||||
self->full_change = true;
|
||||
}
|
||||
|
||||
|
||||
uint16_t common_hal_displayio_tilegrid_get_width(displayio_tilegrid_t *self) {
|
||||
return self->width_in_tiles;
|
||||
}
|
||||
|
@ -129,17 +212,77 @@ void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t
|
|||
return;
|
||||
}
|
||||
tiles[y * self->width_in_tiles + x] = tile_index;
|
||||
self->needs_refresh = true;
|
||||
displayio_area_t temp_area;
|
||||
displayio_area_t* tile_area;
|
||||
if (!self->partial_change) {
|
||||
tile_area = &self->dirty_area;
|
||||
} else {
|
||||
tile_area = &temp_area;
|
||||
}
|
||||
tile_area->x1 = x * self->tile_width;
|
||||
tile_area->x2 = tile_area->x1 + self->tile_width;
|
||||
tile_area->y1 = y * self->tile_height;
|
||||
tile_area->y2 = tile_area->y1 + self->tile_height;
|
||||
if (self->partial_change) {
|
||||
displayio_area_expand(&self->dirty_area, &temp_area);
|
||||
}
|
||||
|
||||
self->partial_change = true;
|
||||
}
|
||||
|
||||
bool common_hal_displayio_tilegrid_get_flip_x(displayio_tilegrid_t *self) {
|
||||
return self->flip_x;
|
||||
}
|
||||
|
||||
void common_hal_displayio_tilegrid_set_flip_x(displayio_tilegrid_t *self, bool flip_x) {
|
||||
if (self->flip_x == flip_x) {
|
||||
return;
|
||||
}
|
||||
self->flip_x = flip_x;
|
||||
self->full_change = true;
|
||||
}
|
||||
|
||||
bool common_hal_displayio_tilegrid_get_flip_y(displayio_tilegrid_t *self) {
|
||||
return self->flip_y;
|
||||
}
|
||||
|
||||
void common_hal_displayio_tilegrid_set_flip_y(displayio_tilegrid_t *self, bool flip_y) {
|
||||
if (self->flip_y == flip_y) {
|
||||
return;
|
||||
}
|
||||
self->flip_y = flip_y;
|
||||
self->full_change = true;
|
||||
}
|
||||
|
||||
bool common_hal_displayio_tilegrid_get_transpose_xy(displayio_tilegrid_t *self) {
|
||||
return self->transpose_xy;
|
||||
}
|
||||
|
||||
void common_hal_displayio_tilegrid_set_transpose_xy(displayio_tilegrid_t *self, bool transpose_xy) {
|
||||
if (self->transpose_xy == transpose_xy) {
|
||||
return;
|
||||
}
|
||||
self->transpose_xy = transpose_xy;
|
||||
|
||||
// Square TileGrids do not change dimensions when transposed.
|
||||
if (self->pixel_width == self->pixel_height) {
|
||||
self->full_change = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_update_current_x(self);
|
||||
_update_current_y(self);
|
||||
|
||||
self->moved = true;
|
||||
}
|
||||
|
||||
void common_hal_displayio_tilegrid_set_top_left(displayio_tilegrid_t *self, uint16_t x, uint16_t y) {
|
||||
self->top_left_x = x;
|
||||
self->top_left_y = y;
|
||||
self->needs_refresh = true;
|
||||
self->full_change = true;
|
||||
}
|
||||
|
||||
bool displayio_tilegrid_get_area(displayio_tilegrid_t *self, displayio_buffer_transform_t* transform, displayio_area_t* area, uint32_t* mask, uint32_t *buffer) {
|
||||
bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer) {
|
||||
// If no tiles are present we have no impact.
|
||||
uint8_t* tiles = self->tiles;
|
||||
if (self->inline_tiles) {
|
||||
|
@ -150,28 +293,28 @@ bool displayio_tilegrid_get_area(displayio_tilegrid_t *self, displayio_buffer_tr
|
|||
}
|
||||
|
||||
displayio_area_t overlap;
|
||||
displayio_area_t scaled_area = {
|
||||
.x1 = self->area.x1 * transform->scale,
|
||||
.y1 = self->area.y1 * transform->scale,
|
||||
.x2 = self->area.x2 * transform->scale,
|
||||
.y2 = self->area.y2 * transform->scale
|
||||
};
|
||||
if (!displayio_area_compute_overlap(area, &scaled_area, &overlap)) {
|
||||
if (!displayio_area_compute_overlap(area, &self->current_area, &overlap)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int16_t x_stride = 1;
|
||||
int16_t y_stride = displayio_area_width(area);
|
||||
if (transform->transpose_xy) {
|
||||
x_stride = displayio_area_height(area);
|
||||
y_stride = 1;
|
||||
|
||||
bool flip_x = self->flip_x;
|
||||
bool flip_y = self->flip_y;
|
||||
if (self->transpose_xy != self->absolute_transform->transpose_xy) {
|
||||
bool temp_flip = flip_x;
|
||||
flip_x = flip_y;
|
||||
flip_y = temp_flip;
|
||||
}
|
||||
|
||||
// How many pixels are outside of our area between us and the start of the row.
|
||||
uint16_t start = 0;
|
||||
if (transform->mirror_x) {
|
||||
if ((self->absolute_transform->dx < 0) != flip_x) {
|
||||
start += (area->x2 - area->x1 - 1) * x_stride;
|
||||
x_stride *= -1;
|
||||
}
|
||||
if (transform->mirror_y) {
|
||||
if ((self->absolute_transform->dy < 0) != flip_y) {
|
||||
start += (area->y2 - area->y1 - 1) * y_stride;
|
||||
y_stride *= -1;
|
||||
}
|
||||
|
@ -185,25 +328,49 @@ bool displayio_tilegrid_get_area(displayio_tilegrid_t *self, displayio_buffer_tr
|
|||
|
||||
// TODO(tannewt): Check to see if the pixel_shader has any transparency. If it doesn't then we
|
||||
// can either return full coverage or bulk update the mask.
|
||||
int16_t y = overlap.y1 - scaled_area.y1;
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
displayio_area_t transformed;
|
||||
displayio_area_transform_within(flip_x != (self->absolute_transform->dx < 0), flip_y != (self->absolute_transform->dy < 0), self->transpose_xy != self->absolute_transform->transpose_xy,
|
||||
&overlap,
|
||||
&self->current_area,
|
||||
&transformed);
|
||||
|
||||
int16_t start_x = (transformed.x1 - self->current_area.x1);
|
||||
int16_t end_x = (transformed.x2 - self->current_area.x1);
|
||||
int16_t start_y = (transformed.y1 - self->current_area.y1);
|
||||
int16_t end_y = (transformed.y2 - self->current_area.y1);
|
||||
|
||||
int16_t y_shift = 0;
|
||||
int16_t x_shift = 0;
|
||||
if ((self->absolute_transform->dx < 0) != flip_x) {
|
||||
x_shift = area->x2 - overlap.x2;
|
||||
} else {
|
||||
x_shift = overlap.x1 - area->x1;
|
||||
}
|
||||
int16_t x_shift = area->x1 - scaled_area.x1;
|
||||
int16_t y_shift = area->y1 - scaled_area.y1;
|
||||
for (; y < overlap.y2 - scaled_area.y1; y++) {
|
||||
int16_t x = overlap.x1 - scaled_area.x1;
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
int16_t row_start = start + (y - y_shift) * y_stride;
|
||||
int16_t local_y = y / transform->scale;
|
||||
for (; x < overlap.x2 - scaled_area.x1; x++) {
|
||||
if ((self->absolute_transform->dy < 0) != flip_y) {
|
||||
y_shift = area->y2 - overlap.y2;
|
||||
} else {
|
||||
y_shift = overlap.y1 - area->y1;
|
||||
}
|
||||
|
||||
// This untransposes x and y so it aligns with bitmap rows.
|
||||
if (self->transpose_xy != self->absolute_transform->transpose_xy) {
|
||||
int16_t temp_stride = x_stride;
|
||||
x_stride = y_stride;
|
||||
y_stride = temp_stride;
|
||||
int16_t temp_shift = x_shift;
|
||||
x_shift = y_shift;
|
||||
y_shift = temp_shift;
|
||||
}
|
||||
|
||||
for (int16_t y = start_y; y < end_y; y++) {
|
||||
int16_t row_start = start + (y - start_y + y_shift) * y_stride;
|
||||
int16_t local_y = y / self->absolute_transform->scale;
|
||||
for (int16_t x = start_x; x < end_x; x++) {
|
||||
// Compute the destination pixel in the buffer and mask based on the transformations.
|
||||
uint16_t offset = row_start + (x - x_shift) * x_stride;
|
||||
int16_t offset = row_start + (x - start_x + x_shift) * x_stride;
|
||||
|
||||
// This is super useful for debugging out range accesses. Uncomment to use.
|
||||
// if (offset < 0 || offset >= displayio_area_size(area)) {
|
||||
// if (offset < 0 || offset >= (int32_t) displayio_area_size(area)) {
|
||||
// asm("bkpt");
|
||||
// }
|
||||
|
||||
|
@ -211,7 +378,7 @@ bool displayio_tilegrid_get_area(displayio_tilegrid_t *self, displayio_buffer_tr
|
|||
if ((mask[offset / 32] & (1 << (offset % 32))) != 0) {
|
||||
continue;
|
||||
}
|
||||
int16_t local_x = x / transform->scale;
|
||||
int16_t local_x = x / self->absolute_transform->scale;
|
||||
uint16_t tile_location = ((local_y / self->tile_height + self->top_left_y) % self->height_in_tiles) * self->width_in_tiles + (local_x / self->tile_width + self->top_left_x) % self->width_in_tiles;
|
||||
uint8_t tile = tiles[tile_location];
|
||||
uint16_t tile_x = (tile % self->bitmap_width_in_tiles) * self->tile_width + local_x % self->tile_width;
|
||||
|
@ -252,20 +419,15 @@ bool displayio_tilegrid_get_area(displayio_tilegrid_t *self, displayio_buffer_tr
|
|||
return full_coverage;
|
||||
}
|
||||
|
||||
bool displayio_tilegrid_needs_refresh(displayio_tilegrid_t *self) {
|
||||
if (self->needs_refresh) {
|
||||
return true;
|
||||
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type)) {
|
||||
return displayio_palette_needs_refresh(self->pixel_shader);
|
||||
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type)) {
|
||||
return displayio_colorconverter_needs_refresh(self->pixel_shader);
|
||||
void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self) {
|
||||
if (self->moved || self->first_draw) {
|
||||
displayio_area_copy(&self->current_area, &self->previous_area);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self) {
|
||||
self->needs_refresh = false;
|
||||
self->moved = false;
|
||||
self->full_change = false;
|
||||
self->partial_change = false;
|
||||
self->first_draw = false;
|
||||
if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type)) {
|
||||
displayio_palette_finish_refresh(self->pixel_shader);
|
||||
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type)) {
|
||||
|
@ -274,3 +436,58 @@ void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self) {
|
|||
// TODO(tannewt): We could double buffer changes to position and move them over here.
|
||||
// That way they won't change during a refresh and tear.
|
||||
}
|
||||
|
||||
displayio_area_t* displayio_tilegrid_get_refresh_areas(displayio_tilegrid_t *self, displayio_area_t* tail) {
|
||||
if (self->moved && !self->first_draw) {
|
||||
displayio_area_union(&self->previous_area, &self->current_area, &self->dirty_area);
|
||||
if (displayio_area_size(&self->dirty_area) <= 2 * self->pixel_width * self->pixel_height) {
|
||||
self->dirty_area.next = tail;
|
||||
return &self->dirty_area;
|
||||
}
|
||||
self->previous_area.next = tail;
|
||||
self->current_area.next = &self->previous_area;
|
||||
return &self->current_area;
|
||||
}
|
||||
|
||||
// We must recheck if our sources require a refresh because needs_refresh may or may not have
|
||||
// been called.
|
||||
self->full_change = self->full_change ||
|
||||
(MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type) &&
|
||||
displayio_palette_needs_refresh(self->pixel_shader)) ||
|
||||
(MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type) &&
|
||||
displayio_colorconverter_needs_refresh(self->pixel_shader));
|
||||
if (self->full_change || self->first_draw) {
|
||||
self->current_area.next = tail;
|
||||
return &self->current_area;
|
||||
}
|
||||
|
||||
if (self->partial_change) {
|
||||
if (self->absolute_transform->transpose_xy) {
|
||||
int16_t x1 = self->dirty_area.x1;
|
||||
self->dirty_area.x1 = self->absolute_transform->x + self->absolute_transform->dx * (self->y + self->dirty_area.y1);
|
||||
self->dirty_area.y1 = self->absolute_transform->y + self->absolute_transform->dy * (self->x + x1);
|
||||
int16_t x2 = self->dirty_area.x2;
|
||||
self->dirty_area.x2 = self->absolute_transform->x + self->absolute_transform->dx * (self->y + self->dirty_area.y2);
|
||||
self->dirty_area.y2 = self->absolute_transform->y + self->absolute_transform->dy * (self->x + x2);
|
||||
} else {
|
||||
self->dirty_area.x1 = self->absolute_transform->x + self->absolute_transform->dx * (self->x + self->dirty_area.x1);
|
||||
self->dirty_area.y1 = self->absolute_transform->y + self->absolute_transform->dy * (self->y + self->dirty_area.y1);
|
||||
self->dirty_area.x2 = self->absolute_transform->x + self->absolute_transform->dx * (self->x + self->dirty_area.x2);
|
||||
self->dirty_area.y2 = self->absolute_transform->y + self->absolute_transform->dy * (self->y + self->dirty_area.y2);
|
||||
}
|
||||
if (self->dirty_area.y2 < self->dirty_area.y1) {
|
||||
int16_t temp = self->dirty_area.y2;
|
||||
self->dirty_area.y2 = self->dirty_area.y1;
|
||||
self->dirty_area.y1 = temp;
|
||||
}
|
||||
if (self->dirty_area.x2 < self->dirty_area.x1) {
|
||||
int16_t temp = self->dirty_area.x2;
|
||||
self->dirty_area.x2 = self->dirty_area.x1;
|
||||
self->dirty_area.x1 = temp;
|
||||
}
|
||||
|
||||
self->dirty_area.next = tail;
|
||||
return &self->dirty_area;
|
||||
}
|
||||
return tail;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,10 @@ typedef struct {
|
|||
mp_obj_base_t base;
|
||||
mp_obj_t bitmap;
|
||||
mp_obj_t pixel_shader;
|
||||
displayio_area_t area;
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
uint16_t pixel_width;
|
||||
uint16_t pixel_height;
|
||||
uint16_t bitmap_width_in_tiles;
|
||||
uint16_t width_in_tiles;
|
||||
uint16_t height_in_tiles;
|
||||
|
@ -46,12 +49,34 @@ typedef struct {
|
|||
uint16_t top_left_x;
|
||||
uint16_t top_left_y;
|
||||
uint8_t* tiles;
|
||||
bool needs_refresh;
|
||||
const displayio_buffer_transform_t* absolute_transform;
|
||||
displayio_area_t dirty_area; // Stored as a relative area until the refresh area is fetched.
|
||||
displayio_area_t previous_area; // Stored as an absolute area.
|
||||
displayio_area_t current_area; // Stored as an absolute area so it applies across frames.
|
||||
bool partial_change;
|
||||
bool full_change;
|
||||
bool first_draw;
|
||||
bool moved;
|
||||
bool inline_tiles;
|
||||
bool in_group;
|
||||
bool flip_x;
|
||||
bool flip_y;
|
||||
bool transpose_xy;
|
||||
} displayio_tilegrid_t;
|
||||
|
||||
bool displayio_tilegrid_get_area(displayio_tilegrid_t *self, displayio_buffer_transform_t* transform, displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
|
||||
bool displayio_tilegrid_needs_refresh(displayio_tilegrid_t *self);
|
||||
// Updating the screen is a three stage process.
|
||||
|
||||
// The first stage is used to determine i
|
||||
displayio_area_t* displayio_tilegrid_get_refresh_areas(displayio_tilegrid_t *self, displayio_area_t* tail);
|
||||
|
||||
// Area is always in absolute screen coordinates. Update transform is used to inform TileGrids how
|
||||
// they relate to it.
|
||||
bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
|
||||
void displayio_tilegrid_update_transform(displayio_tilegrid_t *group, const displayio_buffer_transform_t* parent_transform);
|
||||
|
||||
// Fills in area with the maximum bounds of all related pixels in the last rendered frame. Returns
|
||||
// false if the tilegrid wasn't rendered in the last frame.
|
||||
bool displayio_tilegrid_get_previous_area(displayio_tilegrid_t *self, displayio_area_t* area);
|
||||
void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_TILEGRID_H
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "shared-module/displayio/__init__.h"
|
||||
|
||||
#include "lib/utils/interrupt_char.h"
|
||||
|
@ -19,14 +20,83 @@
|
|||
|
||||
primary_display_t displays[CIRCUITPY_DISPLAY_LIMIT];
|
||||
|
||||
static inline void swap(int16_t* a, int16_t* b) {
|
||||
int16_t temp = *a;
|
||||
*a = *b;
|
||||
*b = temp;
|
||||
bool refresh_area(displayio_display_obj_t* display, const displayio_area_t* area) {
|
||||
uint16_t buffer_size = 512;
|
||||
|
||||
displayio_area_t clipped;
|
||||
// Clip the area to the display by overlapping the areas. If there is no overlap then we're done.
|
||||
if (!displayio_display_clip_area(display, area, &clipped)) {
|
||||
return true;
|
||||
}
|
||||
uint16_t subrectangles = 1;
|
||||
uint16_t rows_per_buffer = displayio_area_height(&clipped);
|
||||
if (displayio_area_size(area) > buffer_size) {
|
||||
rows_per_buffer = buffer_size / displayio_area_width(&clipped);
|
||||
subrectangles = displayio_area_height(&clipped) / rows_per_buffer;
|
||||
if (displayio_area_height(&clipped) % rows_per_buffer != 0) {
|
||||
subrectangles++;
|
||||
}
|
||||
buffer_size = rows_per_buffer * displayio_area_width(&clipped);
|
||||
}
|
||||
uint32_t buffer[buffer_size / 2];
|
||||
uint16_t remaining_rows = displayio_area_height(&clipped);
|
||||
|
||||
for (uint16_t j = 0; j < subrectangles; j++) {
|
||||
displayio_area_t subrectangle = {
|
||||
.x1 = clipped.x1,
|
||||
.y1 = clipped.y1 + rows_per_buffer * j,
|
||||
.x2 = clipped.x2,
|
||||
.y2 = clipped.y1 + rows_per_buffer * (j + 1)
|
||||
};
|
||||
if (remaining_rows < rows_per_buffer) {
|
||||
subrectangle.y2 = subrectangle.y1 + remaining_rows;
|
||||
}
|
||||
remaining_rows -= rows_per_buffer;
|
||||
|
||||
displayio_display_begin_transaction(display);
|
||||
displayio_display_set_region_to_update(display, subrectangle.x1, subrectangle.y1,
|
||||
subrectangle.x2, subrectangle.y2);
|
||||
displayio_display_end_transaction(display);
|
||||
|
||||
uint32_t mask[(buffer_size / 32) + 1];
|
||||
for (uint16_t k = 0; k < (buffer_size / 32) + 1; k++) {
|
||||
mask[k] = 0x00000000;
|
||||
}
|
||||
|
||||
bool full_coverage = displayio_display_fill_area(display, &subrectangle, mask, buffer);
|
||||
if (!full_coverage) {
|
||||
uint32_t index = 0;
|
||||
uint32_t current_mask = 0;
|
||||
for (int16_t y = subrectangle.y1; y < subrectangle.y2; y++) {
|
||||
for (int16_t x = subrectangle.x1; x < subrectangle.x2; x++) {
|
||||
if (index % 32 == 0) {
|
||||
current_mask = mask[index / 32];
|
||||
}
|
||||
if ((current_mask & (1 << (index % 32))) == 0) {
|
||||
((uint16_t*) buffer)[index] = 0x0000;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!displayio_display_begin_transaction(display)) {
|
||||
// Can't acquire display bus; skip the rest of the data. Try next display.
|
||||
return false;
|
||||
}
|
||||
displayio_display_send_pixels(display, (uint8_t*) buffer, displayio_area_size(&subrectangle) * sizeof(uint16_t));
|
||||
displayio_display_end_transaction(display);
|
||||
|
||||
// TODO(tannewt): Make refresh displays faster so we don't starve other
|
||||
// background tasks.
|
||||
usb_background();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for recursive calls to displayio_refresh_displays.
|
||||
bool refresh_displays_in_progress = false;
|
||||
uint32_t frame_count = 0;
|
||||
|
||||
void displayio_refresh_displays(void) {
|
||||
if (mp_hal_is_interrupted()) {
|
||||
|
@ -57,115 +127,19 @@ void displayio_refresh_displays(void) {
|
|||
// Too soon. Try next display.
|
||||
continue;
|
||||
}
|
||||
if (displayio_display_refresh_queued(display)) {
|
||||
if (!displayio_display_begin_transaction(display)) {
|
||||
// Can't acquire display bus; skip updating this display. Try next display.
|
||||
continue;
|
||||
}
|
||||
displayio_display_end_transaction(display);
|
||||
|
||||
displayio_area_t whole_screen = {
|
||||
.x1 = 0,
|
||||
.y1 = 0,
|
||||
.x2 = display->width,
|
||||
.y2 = display->height
|
||||
};
|
||||
if (display->transpose_xy) {
|
||||
swap(&whole_screen.x2, &whole_screen.y2);
|
||||
}
|
||||
|
||||
uint16_t buffer_size = 512;
|
||||
|
||||
uint16_t subrectangles = 1;
|
||||
uint16_t rows_per_buffer = displayio_area_height(&whole_screen);
|
||||
if (displayio_area_size(&whole_screen) > buffer_size) {
|
||||
rows_per_buffer = buffer_size / displayio_area_width(&whole_screen);
|
||||
subrectangles = displayio_area_height(&whole_screen) / rows_per_buffer;
|
||||
buffer_size = rows_per_buffer * displayio_area_width(&whole_screen);
|
||||
}
|
||||
uint32_t buffer[buffer_size / 2];
|
||||
|
||||
for (uint16_t j = 0; j < subrectangles; j++) {
|
||||
displayio_area_t subrectangle = {
|
||||
.x1 = 0,
|
||||
.y1 = rows_per_buffer * j,
|
||||
.x2 = displayio_area_width(&whole_screen),
|
||||
.y2 = rows_per_buffer * (j + 1)
|
||||
};
|
||||
|
||||
displayio_display_begin_transaction(display);
|
||||
displayio_display_set_region_to_update(display, subrectangle.x1, subrectangle.y1,
|
||||
subrectangle.x2, subrectangle.y2);
|
||||
displayio_display_end_transaction(display);
|
||||
|
||||
// Handle display mirroring and transpose.
|
||||
displayio_area_t transformed_subrectangle;
|
||||
displayio_buffer_transform_t transform;
|
||||
if (display->mirror_x) {
|
||||
uint16_t width = displayio_area_width(&whole_screen);
|
||||
transformed_subrectangle.x1 = width - subrectangle.x2;
|
||||
transformed_subrectangle.x2 = width - subrectangle.x1;
|
||||
} else {
|
||||
transformed_subrectangle.x1 = subrectangle.x1;
|
||||
transformed_subrectangle.x2 = subrectangle.x2;
|
||||
}
|
||||
if (display->mirror_y != display->transpose_xy) {
|
||||
uint16_t height = displayio_area_height(&whole_screen);
|
||||
transformed_subrectangle.y1 = height - subrectangle.y2;
|
||||
transformed_subrectangle.y2 = height - subrectangle.y1;
|
||||
} else {
|
||||
transformed_subrectangle.y1 = subrectangle.y1;
|
||||
transformed_subrectangle.y2 = subrectangle.y2;
|
||||
}
|
||||
transform.width = transformed_subrectangle.x2 - transformed_subrectangle.x1;
|
||||
transform.height = transformed_subrectangle.y2 - transformed_subrectangle.y1;
|
||||
if (display->transpose_xy) {
|
||||
int16_t y1 = transformed_subrectangle.y1;
|
||||
int16_t y2 = transformed_subrectangle.y2;
|
||||
transformed_subrectangle.y1 = transformed_subrectangle.x1;
|
||||
transformed_subrectangle.y2 = transformed_subrectangle.x2;
|
||||
transformed_subrectangle.x1 = y1;
|
||||
transformed_subrectangle.x2 = y2;
|
||||
}
|
||||
transform.transpose_xy = display->transpose_xy;
|
||||
transform.mirror_x = display->mirror_x;
|
||||
transform.mirror_y = display->mirror_y;
|
||||
transform.scale = 1;
|
||||
|
||||
uint32_t mask[(buffer_size / 32) + 1];
|
||||
for (uint16_t k = 0; k < (buffer_size / 32) + 1; k++) {
|
||||
mask[k] = 0x00000000;
|
||||
}
|
||||
bool full_coverage = displayio_group_get_area(display->current_group, &transform, &transformed_subrectangle, mask, buffer);
|
||||
if (!full_coverage) {
|
||||
uint32_t index = 0;
|
||||
uint32_t current_mask = 0;
|
||||
for (int16_t y = subrectangle.y1; y < subrectangle.y2; y++) {
|
||||
for (int16_t x = subrectangle.x1; x < subrectangle.x2; x++) {
|
||||
if (index % 32 == 0) {
|
||||
current_mask = mask[index / 32];
|
||||
}
|
||||
if ((current_mask & (1 << (index % 32))) == 0) {
|
||||
((uint16_t*) buffer)[index] = 0x0000;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!displayio_display_begin_transaction(display)) {
|
||||
// Can't acquire display bus; skip the rest of the data. Try next display.
|
||||
break;
|
||||
}
|
||||
displayio_display_send_pixels(display, buffer, buffer_size / 2);
|
||||
displayio_display_end_transaction(display);
|
||||
|
||||
// TODO(tannewt): Make refresh displays faster so we don't starve other
|
||||
// background tasks.
|
||||
usb_background();
|
||||
}
|
||||
if (!displayio_display_begin_transaction(display)) {
|
||||
// Can't acquire display bus; skip updating this display. Try next display.
|
||||
continue;
|
||||
}
|
||||
displayio_display_end_transaction(display);
|
||||
displayio_display_start_refresh(display);
|
||||
const displayio_area_t* current_area = displayio_display_get_refresh_areas(display);
|
||||
while (current_area != NULL) {
|
||||
refresh_area(display, current_area);
|
||||
current_area = current_area->next;
|
||||
}
|
||||
displayio_display_finish_refresh(display);
|
||||
frame_count++;
|
||||
}
|
||||
|
||||
// All done.
|
||||
|
@ -244,6 +218,35 @@ void displayio_gc_collect(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void displayio_area_expand(displayio_area_t* original, const displayio_area_t* addition) {
|
||||
if (addition->x1 < original->x1) {
|
||||
original->x1 = addition->x1;
|
||||
}
|
||||
if (addition->y1 < original->y1) {
|
||||
original->y1 = addition->y1;
|
||||
}
|
||||
if (addition->x2 > original->x2) {
|
||||
original->x2 = addition->x2;
|
||||
}
|
||||
if (addition->y2 > original->y2) {
|
||||
original->y2 = addition->y2;
|
||||
}
|
||||
}
|
||||
|
||||
void displayio_area_copy(const displayio_area_t* src, displayio_area_t* dst) {
|
||||
dst->x1 = src->x1;
|
||||
dst->y1 = src->y1;
|
||||
dst->x2 = src->x2;
|
||||
dst->y2 = src->y2;
|
||||
}
|
||||
|
||||
void displayio_area_scale(displayio_area_t* area, uint16_t scale) {
|
||||
area->x1 *= scale;
|
||||
area->y1 *= scale;
|
||||
area->x2 *= scale;
|
||||
area->y2 *= scale;
|
||||
}
|
||||
|
||||
void displayio_area_shift(displayio_area_t* area, int16_t dx, int16_t dy) {
|
||||
area->x1 += dx;
|
||||
area->y1 += dy;
|
||||
|
@ -262,7 +265,7 @@ bool displayio_area_compute_overlap(const displayio_area_t* a,
|
|||
if (b->x2 < overlap->x2) {
|
||||
overlap->x2 = b->x2;
|
||||
}
|
||||
if (overlap->x1 > overlap->x2) {
|
||||
if (overlap->x1 >= overlap->x2) {
|
||||
return false;
|
||||
}
|
||||
overlap->y1 = a->y1;
|
||||
|
@ -273,12 +276,34 @@ bool displayio_area_compute_overlap(const displayio_area_t* a,
|
|||
if (b->y2 < overlap->y2) {
|
||||
overlap->y2 = b->y2;
|
||||
}
|
||||
if (overlap->y1 > overlap->y2) {
|
||||
if (overlap->y1 >= overlap->y2) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayio_area_union(const displayio_area_t* a,
|
||||
const displayio_area_t* b,
|
||||
displayio_area_t* u) {
|
||||
u->x1 = a->x1;
|
||||
if (b->x1 < u->x1) {
|
||||
u->x1 = b->x1;
|
||||
}
|
||||
u->x2 = a->x2;
|
||||
if (b->x2 > u->x2) {
|
||||
u->x2 = b->x2;
|
||||
}
|
||||
|
||||
u->y1 = a->y1;
|
||||
if (b->y1 < u->y1) {
|
||||
u->y1 = b->y1;
|
||||
}
|
||||
u->y2 = a->y2;
|
||||
if (b->y2 > u->y2) {
|
||||
u->y2 = b->y2;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t displayio_area_width(const displayio_area_t* area) {
|
||||
return area->x2 - area->x1;
|
||||
}
|
||||
|
@ -297,3 +322,32 @@ bool displayio_area_equal(const displayio_area_t* a, const displayio_area_t* b)
|
|||
a->x2 == b->x2 &&
|
||||
a->y2 == b->y2;
|
||||
}
|
||||
|
||||
// Original and whole must be in the same coordinate space.
|
||||
void displayio_area_transform_within(bool mirror_x, bool mirror_y, bool transpose_xy,
|
||||
const displayio_area_t* original,
|
||||
const displayio_area_t* whole,
|
||||
displayio_area_t* transformed) {
|
||||
if (mirror_x) {
|
||||
transformed->x1 = whole->x1 + (whole->x2 - original->x2);
|
||||
transformed->x2 = whole->x2 - (original->x1 - whole->x1);
|
||||
} else {
|
||||
transformed->x1 = original->x1;
|
||||
transformed->x2 = original->x2;
|
||||
}
|
||||
if (mirror_y) {
|
||||
transformed->y1 = whole->y1 + (whole->y2 - original->y2);
|
||||
transformed->y2 = whole->y2 - (original->y1 - whole->y1);
|
||||
} else {
|
||||
transformed->y1 = original->y1;
|
||||
transformed->y2 = original->y2;
|
||||
}
|
||||
if (transpose_xy) {
|
||||
int16_t y1 = transformed->y1;
|
||||
int16_t y2 = transformed->y2;
|
||||
transformed->y1 = whole->y1 + (transformed->x1 - whole->x1);
|
||||
transformed->y2 = whole->y1 + (transformed->x2 - whole->x1);
|
||||
transformed->x2 = whole->x1 + (y2 - whole->y1);
|
||||
transformed->x1 = whole->x1 + (y1 - whole->y1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,23 +28,35 @@
|
|||
#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_AREA_H
|
||||
|
||||
// Implementations are in __init__.c
|
||||
typedef struct _displayio_area_t displayio_area_t;
|
||||
|
||||
typedef struct {
|
||||
struct _displayio_area_t {
|
||||
int16_t x1;
|
||||
int16_t y1;
|
||||
int16_t x2; // Second point is exclusive.
|
||||
int16_t y2;
|
||||
} displayio_area_t;
|
||||
const displayio_area_t* next; // Next area in the linked list.
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
int8_t dx;
|
||||
int8_t dy;
|
||||
uint8_t scale;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint8_t scale;
|
||||
bool mirror_x;
|
||||
bool mirror_y;
|
||||
bool transpose_xy;
|
||||
} displayio_buffer_transform_t;
|
||||
|
||||
void displayio_area_union(const displayio_area_t* a,
|
||||
const displayio_area_t* b,
|
||||
displayio_area_t* u);
|
||||
void displayio_area_expand(displayio_area_t* original, const displayio_area_t* addition);
|
||||
void displayio_area_copy(const displayio_area_t* src, displayio_area_t* dst);
|
||||
void displayio_area_scale(displayio_area_t* area, uint16_t scale);
|
||||
void displayio_area_shift(displayio_area_t* area, int16_t dx, int16_t dy);
|
||||
bool displayio_area_compute_overlap(const displayio_area_t* a,
|
||||
const displayio_area_t* b,
|
||||
|
@ -53,5 +65,9 @@ uint16_t displayio_area_width(const displayio_area_t* area);
|
|||
uint16_t displayio_area_height(const displayio_area_t* area);
|
||||
uint32_t displayio_area_size(const displayio_area_t* area);
|
||||
bool displayio_area_equal(const displayio_area_t* a, const displayio_area_t* b);
|
||||
void displayio_area_transform_within(bool mirror_x, bool mirror_y, bool transpose_xy,
|
||||
const displayio_area_t* original,
|
||||
const displayio_area_t* whole,
|
||||
displayio_area_t* transformed);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_AREA_H
|
||||
|
|
|
@ -50,6 +50,10 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
|
|||
}
|
||||
width_in_tiles = (width_px - blinka_bitmap.width * scale) / (grid->tile_width * scale);
|
||||
uint16_t height_in_tiles = height_px / (grid->tile_height * scale);
|
||||
uint16_t remaining_pixels = height_px % (grid->tile_height * scale);
|
||||
if (remaining_pixels > 0) {
|
||||
height_in_tiles += 1;
|
||||
}
|
||||
circuitpython_splash.scale = scale;
|
||||
|
||||
uint16_t total_tiles = width_in_tiles * height_in_tiles;
|
||||
|
@ -67,11 +71,13 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
|
|||
if (tiles == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (remaining_pixels > 0) {
|
||||
grid->y -= (grid->tile_height - remaining_pixels);
|
||||
}
|
||||
grid->width_in_tiles = width_in_tiles;
|
||||
grid->height_in_tiles = height_in_tiles;
|
||||
grid->area.x2 = grid->area.x1 + width_in_tiles * grid->tile_width;
|
||||
grid->area.y2 = grid->area.y1 + height_in_tiles * grid->tile_height;
|
||||
grid->pixel_width = width_in_tiles * grid->tile_width;
|
||||
grid->pixel_height = height_in_tiles * grid->tile_height;
|
||||
grid->tiles = tiles;
|
||||
|
||||
supervisor_terminal.cursor_x = 0;
|
||||
|
@ -157,12 +163,10 @@ displayio_tilegrid_t blinka_sprite = {
|
|||
.base = {.type = &displayio_tilegrid_type },
|
||||
.bitmap = &blinka_bitmap,
|
||||
.pixel_shader = &blinka_palette,
|
||||
.area = {
|
||||
.x1 = 0,
|
||||
.y1 = 0,
|
||||
.x2 = 16,
|
||||
.y2 = 16
|
||||
},
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.pixel_width = 16,
|
||||
.pixel_height = 16,
|
||||
.bitmap_width_in_tiles = 1,
|
||||
.width_in_tiles = 1,
|
||||
.height_in_tiles = 1,
|
||||
|
@ -171,8 +175,12 @@ displayio_tilegrid_t blinka_sprite = {
|
|||
.top_left_x = 16,
|
||||
.top_left_y = 16,
|
||||
.tiles = 0,
|
||||
.needs_refresh = false,
|
||||
.inline_tiles = true
|
||||
.partial_change = false,
|
||||
.full_change = false,
|
||||
.first_draw = true,
|
||||
.moved = false,
|
||||
.inline_tiles = true,
|
||||
.in_group = true
|
||||
};
|
||||
|
||||
displayio_group_child_t splash_children[2] = {
|
||||
|
@ -188,5 +196,5 @@ displayio_group_t circuitpython_splash = {
|
|||
.size = 2,
|
||||
.max_size = 2,
|
||||
.children = splash_children,
|
||||
.needs_refresh = true
|
||||
.item_removed = false
|
||||
};
|
||||
|
|
|
@ -120,20 +120,22 @@ displayio_tilegrid_t supervisor_terminal_text_grid = {{
|
|||
.base = {{ .type = &displayio_tilegrid_type }},
|
||||
.bitmap = (displayio_bitmap_t*) &supervisor_terminal_font_bitmap,
|
||||
.pixel_shader = &supervisor_terminal_color,
|
||||
.area = {{
|
||||
.x1 = 16,
|
||||
.y1 = 0,
|
||||
.x2 = {1} + 16,
|
||||
.y2 = {2},
|
||||
}},
|
||||
.x = 16,
|
||||
.y = 0,
|
||||
.pixel_width = {1},
|
||||
.pixel_height = {2},
|
||||
.bitmap_width_in_tiles = {0},
|
||||
.width_in_tiles = 1,
|
||||
.height_in_tiles = 1,
|
||||
.tile_width = {1},
|
||||
.tile_height = {2},
|
||||
.tiles = NULL,
|
||||
.needs_refresh = false,
|
||||
.inline_tiles = false
|
||||
.partial_change = false,
|
||||
.full_change = false,
|
||||
.first_draw = true,
|
||||
.moved = false,
|
||||
.inline_tiles = false,
|
||||
.in_group = true
|
||||
}};
|
||||
""".format(len(all_characters), tile_x, tile_y))
|
||||
|
||||
|
|
Loading…
Reference in New Issue