Merge branch 'adafruit:main' into board-pykey87

This commit is contained in:
Pierre Constantineau 2021-11-22 17:11:36 -06:00 committed by GitHub
commit 401f1fadaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 438 additions and 281 deletions

@ -1 +1 @@
Subproject commit ee411d34dfa2fb70a35aa99945eca77f16456619
Subproject commit c55da0dee66302d2fa8ed31623d047c307f409b2

@ -1 +1 @@
Subproject commit 9ae0e7f870c0dd508d8a27c179b5d63b47567f85
Subproject commit 781f46b73f71817b709d2e279fc188a7c1e69423

@ -1 +1 @@
Subproject commit a8f3cbc1a94b8a5d25f80101f519025a162dbb80
Subproject commit c24a5310bc259cd9d93b1f42468e07f41d4b0e56

@ -1 +1 @@
Subproject commit 5aceeae814effae4eb950f1078c194b11401faa7
Subproject commit 169715b3444c614e55827ccf79b35b2b5e11f1d2

@ -1 +1 @@
Subproject commit e0fecb6c73f11c31cfc2a9c0e9ce9805b8fb1cf1
Subproject commit 2017afdfb43d3d9c5a73f8e85e951a583b18206a

@ -1 +1 @@
Subproject commit 66adc454f5c9cc66b9e38777a61c58bc82a04090
Subproject commit 8d09b29a1a92499dbbd10dd832f27db71057af5f

@ -1 +1 @@
Subproject commit c8483fe4909fba9b4ecfce7092918a038cc087a0
Subproject commit 8a6ab89b7d19f45a20b3f794cf900e23c9a8453b

@ -1 +1 @@
Subproject commit 5b017df35b6a4cb4b7a30d0ac5d4595583ea461d
Subproject commit 92a6ce1da70c0c4f69ef34fc0d7ec7155cc2441f

@ -1 +1 @@
Subproject commit 99bf9e741dccd1271317e782eed49cbf42a4efae
Subproject commit 313c17cbb590ef8d505845369eb3b78c25c97fae

@ -1 +1 @@
Subproject commit 99a296fb3bdf2743f9b5f487649d7721c8f83c24
Subproject commit ca141954c0b39cc0343c63bedb64c02f307159b9

@ -1 +1 @@
Subproject commit 931b7de8daf3fa1e9cee0548b80de3ddbc20081f
Subproject commit e07090117766d4a9ea2de07cd6f5418990cc598b

@ -1 +1 @@
Subproject commit b96b0debef16c41c35a8579ccbbb1779ca1eaf0c
Subproject commit e25c1801c5428598f543873bb846851b78efb329

@ -1 +1 @@
Subproject commit 27b6d39384249cc9050d5d87982e88f1323e3098
Subproject commit 68744ede79c992a3df8322c21a1468c5ccaef2ee

@ -1 +1 @@
Subproject commit 1cb554987df86b008e5a0feaa56f0a24d806bf28
Subproject commit d79dd180cf6062e97d6a12cbc8dc7fdbedcc752b

@ -1 +1 @@
Subproject commit 8132539c48397e01cabd8317f069e4bb8b3ab065
Subproject commit 2ca37f927b3ee3aad379c2991f36b3ef1be0203d

@ -1 +1 @@
Subproject commit ea7bd9a8b14be7dfd09abb2d776170ee10ab5da7
Subproject commit ed41dd44605110f1d1411ed694ec2b5676dd8d9c

@ -1 +1 @@
Subproject commit cf564ad0defb0bc98a41f195c5b20d1aa88641ed
Subproject commit daff8cdca78637915bea2f3a120cc84578516195

@ -1 +1 @@
Subproject commit fa2cb2c7770f67fa16053fe5375b1a9ad3a3d0a5
Subproject commit 9873446ebde5779c03c2bd4e3e544a801fb27bd5

@ -1 +1 @@
Subproject commit 0f5651650c11a24e531e5dd1eadfc5654d84a478
Subproject commit 1127e3f7bcefa9fddb5b7f30533ecc6c58b420ea

@ -1 +1 @@
Subproject commit a9ef35bae580b6a0d99a425856fcc863ad58a54d
Subproject commit 88e5ae51427aa690de129c157223e93bf936ac41

@ -1 +1 @@
Subproject commit 0f4661c45a578d816323b5ad0f432aff73b5522f
Subproject commit 9ca3bf00c6a2dd1de2d315a3b952a381d720aa7d

@ -1 +1 @@
Subproject commit 6b5e5699d205d26d08a50580c6e3094c1d445b8b
Subproject commit e4f7cd083dea8eb103954e7703bbb487491b433f

@ -1 +1 @@
Subproject commit 161b39148ebd79f051630737e34e0cbd6d838a59
Subproject commit 70ef86dc1a42138efcab01945d5a421e45f2408e

@ -1 +1 @@
Subproject commit 4490961b28a129d2f6435c73d2bd65d2b042224c
Subproject commit 379209dd7e4374c262b84256778d7895693e7fb6

@ -1 +1 @@
Subproject commit a0892d1822937fe89146dec68604b3e924d5c51e
Subproject commit 79678c6adb2252de8fed6273604bc6ac676132a5

@ -1 +1 @@
Subproject commit 03f54421a050bbfda71e1c98986ddecc3862431a
Subproject commit 900b28cbae008e3253c4c40496e49faea9fb7034

@ -1 +1 @@
Subproject commit 63f795518c79821fa1f60c4978b59c8bbd16ad1c
Subproject commit b7a76420d1dec119f8744aa7c0ea500e235561d1

@ -1 +1 @@
Subproject commit 460e971e32ea53176b39ec093ae98fdac0d39d86
Subproject commit c5b480434de8fa56d8ba978a57cd3919fdc9da2a

@ -1 +1 @@
Subproject commit 9b53bebc520d70f89d44fc989fc493d5036df925
Subproject commit ca56187fe7af315130808191b004432fdfdc1b09

@ -1 +1 @@
Subproject commit 5f382650e62e05cc72a67dbedce13d706d699621
Subproject commit 5b699a609197fb42aa059788c7c824c346d57c4e

@ -1 +1 @@
Subproject commit da67fd3046c85eae0a3e417074bc681befa39218
Subproject commit d4ac6ce3eea2c87781fa2df4e431d9440c610fad

@ -1 +1 @@
Subproject commit 4ab8a0fc00795121d81f7e609bb7a03973725f10
Subproject commit 0450119e163df782930a887022e197d6d25ca666

View File

@ -2178,7 +2178,7 @@ msgid "Stack size must be at least 256"
msgstr "Ukuran stack minimal harus 256"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2143,7 +2143,7 @@ msgid "Stack size must be at least 256"
msgstr ""
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2146,7 +2146,7 @@ msgid "Stack size must be at least 256"
msgstr ""
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2175,7 +2175,7 @@ msgid "Stack size must be at least 256"
msgstr "Die Stackgröße sollte mindestens 256 sein"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2143,7 +2143,7 @@ msgid "Stack size must be at least 256"
msgstr ""
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2167,7 +2167,7 @@ msgid "Stack size must be at least 256"
msgstr "Stack size must be at least 256"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2195,7 +2195,7 @@ msgid "Stack size must be at least 256"
msgstr "El tamaño de la pila debe ser de al menos 256"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2163,7 +2163,7 @@ msgid "Stack size must be at least 256"
msgstr "Ang laki ng stack ay dapat na hindi bababa sa 256"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2207,7 +2207,7 @@ msgid "Stack size must be at least 256"
msgstr "La pile doit être au moins de 256"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2143,7 +2143,7 @@ msgid "Stack size must be at least 256"
msgstr ""
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2182,7 +2182,7 @@ msgid "Stack size must be at least 256"
msgstr "La dimensione dello stack deve essere almeno 256"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2157,7 +2157,7 @@ msgid "Stack size must be at least 256"
msgstr "スタックサイズは少なくとも256以上でなければなりません"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2146,7 +2146,7 @@ msgid "Stack size must be at least 256"
msgstr ""
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2169,7 +2169,7 @@ msgid "Stack size must be at least 256"
msgstr "Stack grootte moet op zijn minst 256 zijn"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -2154,7 +2154,7 @@ msgid "Stack size must be at least 256"
msgstr "Stos musi mieć co najmniej 256 bajtów"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -6,7 +6,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
"PO-Revision-Date: 2021-11-15 18:21+0000\n"
"PO-Revision-Date: 2021-11-17 18:26+0000\n"
"Last-Translator: Wellington Terumi Uemura <wellingtonuemura@gmail.com>\n"
"Language-Team: \n"
"Language: pt_BR\n"
@ -1319,7 +1319,7 @@ msgstr "O pino DAC informado é inválido"
#: shared-bindings/wifi/Radio.c
msgid "Invalid MAC address"
msgstr ""
msgstr "Endereço MAC inválido"
#: shared-bindings/synthio/__init__.c
msgid "Invalid MIDI file"
@ -1396,7 +1396,7 @@ msgstr "O acesso da memória é inválido."
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Invalid multicast MAC address"
msgstr ""
msgstr "Endereço MAC multicast inválido"
#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c
msgid "Invalid number of bits"
@ -2200,7 +2200,7 @@ msgid "Stack size must be at least 256"
msgstr "O tamanho da pilha deve ser pelo menos 256"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
@ -4262,7 +4262,7 @@ msgstr "o source_bitmap deve ter o value_count de 8"
#: shared-bindings/wifi/Radio.c
msgid "ssid can't be more than 32 bytes"
msgstr ""
msgstr "O ssid não pode ter mais do que 32 bytes"
#: py/objstr.c
msgid "start/end indices"
@ -4627,6 +4627,9 @@ msgstr "zi deve ser de um tipo float"
msgid "zi must be of shape (n_section, 2)"
msgstr "zi deve estar na forma (n_section, 2)"
#~ msgid "Station must be started"
#~ msgstr "A estação deve ser iniciada"
#~ msgid "%q must <= %d"
#~ msgstr "o %q deve ser <= %d"

File diff suppressed because it is too large Load Diff

View File

@ -2175,8 +2175,8 @@ msgid "Stack size must be at least 256"
msgstr "Stackstorleken måste vara minst 256"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgstr "Stationen måste startas"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
msgid "Stereo left must be on PWM channel A"
@ -4584,6 +4584,9 @@ msgstr "zi måste vara av typ float"
msgid "zi must be of shape (n_section, 2)"
msgstr "zi måste vara i formen (n_section, 2)"
#~ msgid "Station must be started"
#~ msgstr "Stationen måste startas"
#~ msgid "%q must <= %d"
#~ msgstr "%q måste vara <=%d"

View File

@ -2185,7 +2185,7 @@ msgid "Stack size must be at least 256"
msgstr "Duīzhàn dàxiǎo bìxū zhìshǎo 256"
#: ports/espressif/common-hal/wifi/Radio.c
msgid "Station must be started"
msgid "Interface must be started"
msgstr ""
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

View File

@ -15,7 +15,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_I2C_POWER), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_I2C_POWER_INVERTED), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) },
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) },

View File

@ -112,6 +112,7 @@ mp_obj_t common_hal_wifi_radio_get_hostname(wifi_radio_obj_t *self) {
void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname) {
esp_netif_set_hostname(self->netif, hostname);
esp_netif_set_hostname(self->ap_netif, hostname);
}
mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) {
@ -122,7 +123,7 @@ mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) {
void common_hal_wifi_radio_set_mac_address(wifi_radio_obj_t *self, const uint8_t *mac) {
if (!self->sta_mode) {
mp_raise_RuntimeError(translate("Station must be started"));
mp_raise_RuntimeError(translate("Interface must be started"));
}
if ((mac[0] & 0b1) == 0b1) {
mp_raise_RuntimeError(translate("Invalid multicast MAC address"));
@ -136,6 +137,16 @@ mp_obj_t common_hal_wifi_radio_get_mac_address_ap(wifi_radio_obj_t *self) {
return mp_obj_new_bytes(mac, MAC_ADDRESS_LENGTH);
}
void common_hal_wifi_radio_set_mac_address_ap(wifi_radio_obj_t *self, const uint8_t *mac) {
if (!self->ap_mode) {
mp_raise_RuntimeError(translate("Interface must be started"));
}
if ((mac[0] & 0b1) == 0b1) {
mp_raise_RuntimeError(translate("Invalid multicast MAC address"));
}
esp_wifi_set_mac(ESP_IF_WIFI_AP, mac);
}
mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) {
if (self->current_scan != NULL) {
mp_raise_RuntimeError(translate("Already scanning for wifi networks"));

View File

@ -558,11 +558,10 @@ void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qs
if (self->traceback == NULL) {
self->traceback = &MP_STATE_VM(mp_emergency_traceback_obj);
}
// populate traceback object
*self->traceback = mp_const_empty_traceback_obj;
}
// populate traceback object
*self->traceback = mp_const_empty_traceback_obj;
// append the provided traceback info to traceback data
// if memory allocation fails (eg because gc is locked), just return
if (self->traceback->data == NULL) {

View File

@ -290,8 +290,8 @@ STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args,
displayio_bitmap_t *source1 = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_source_bitmap_1].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap_1)); // the first source bitmap
displayio_bitmap_t *source2 = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_source_bitmap_2].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap_2)); // the second source bitmap
mp_float_t factor1 = (args[ARG_factor_1].u_obj == mp_const_none) ? MICROPY_FLOAT_CONST(.5) : mp_obj_float_get(args[ARG_factor_1].u_obj);
mp_float_t factor2 = (args[ARG_factor_2].u_obj == mp_const_none) ? 1 - factor1 : mp_obj_float_get(args[ARG_factor_2].u_obj);
mp_float_t factor1 = (args[ARG_factor_1].u_obj == mp_const_none) ? MICROPY_FLOAT_CONST(.5) : mp_obj_get_float(args[ARG_factor_1].u_obj);
mp_float_t factor2 = (args[ARG_factor_2].u_obj == mp_const_none) ? 1 - factor1 : mp_obj_get_float(args[ARG_factor_2].u_obj);
displayio_colorspace_t colorspace = (displayio_colorspace_t)cp_enum_value(&displayio_colorspace_type, args[ARG_colorspace].u_obj);
@ -619,7 +619,7 @@ STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp
displayio_bitmap_t *bitmap = mp_arg_validate_type(args[ARG_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_bitmap);
pyb_file_obj_t *file = mp_arg_validate_type(args[ARG_file].u_obj, &mp_type_fileio, MP_QSTR_file);
mp_obj_t *file = args[ARG_file].u_obj;
int element_size = args[ARG_element_size].u_int;
if (element_size != 1 && element_size != 2 && element_size != 4) {

View File

@ -64,7 +64,7 @@ void common_hal_bitmaptools_draw_line(displayio_bitmap_t *destination,
int16_t x1, int16_t y1,
uint32_t value);
void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_word, bool swap_bytes, bool reverse_rows);
void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, mp_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_word, bool swap_bytes, bool reverse_rows);
void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int element_size, int x1, int y1, int x2, int y2, bool skip_specified, uint32_t skip_index);
void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bitmap_t *source_bitmap, displayio_colorspace_t colorspace, bitmaptools_dither_algorithm_t algorithm);

View File

@ -61,11 +61,11 @@
//| """Initialize camera."""
//| ...
//|
STATIC mp_obj_t camera_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) {
STATIC mp_obj_t camera_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
camera_obj_t *self = m_new_obj(camera_obj_t);
self->base.type = &camera_type;
// No arguments
mp_arg_check_num(n_args, kw_args, 0, 0, false);
mp_arg_check_num(n_args, n_kw, 0, 0, false);
common_hal_camera_construct(self);
return MP_OBJ_FROM_PTR(self);

View File

@ -149,23 +149,38 @@ const mp_obj_property_t wifi_radio_mac_address_obj = {
MP_ROM_NONE },
};
//| mac_address_ap: bytes
//| """MAC address of the wifi radio access point. (read-only)"""
//| mac_address_ap: ReadableBuffer
//| """MAC address for the AP. When the address is altered after interface is started
//| the changes would only be reflected once the interface restarts."""
//|
STATIC mp_obj_t wifi_radio_get_mac_address_ap(mp_obj_t self) {
STATIC mp_obj_t wifi_radio_get_mac_address_ap(mp_obj_t self_in) {
wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in);
return MP_OBJ_FROM_PTR(common_hal_wifi_radio_get_mac_address_ap(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_mac_address_ap_obj, wifi_radio_get_mac_address_ap);
STATIC mp_obj_t wifi_radio_set_mac_address_ap(mp_obj_t self_in, mp_obj_t mac_address_in) {
mp_buffer_info_t mac_address;
mp_get_buffer_raise(mac_address_in, &mac_address, MP_BUFFER_READ);
if (mac_address.len != MAC_ADDRESS_LENGTH) {
mp_raise_ValueError(translate("Invalid MAC address"));
}
wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_wifi_radio_set_mac_address_ap(self, mac_address.buf);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_mac_address_ap_obj, wifi_radio_set_mac_address_ap);
const mp_obj_property_t wifi_radio_mac_address_ap_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&wifi_radio_get_mac_address_ap_obj,
MP_ROM_NONE,
(mp_obj_t)&wifi_radio_set_mac_address_ap_obj,
MP_ROM_NONE },
};
//| def start_scanning_networks(self, *, start_channel: int = 1, stop_channel: int = 11) -> Iterable[Network]:
//| """Scans for available wifi networks over the given channel range. Make sure the channels are allowed in your country."""
//| ...

View File

@ -80,6 +80,7 @@ extern void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const cha
extern mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self);
extern void common_hal_wifi_radio_set_mac_address(wifi_radio_obj_t *self, const uint8_t *mac);
extern mp_obj_t common_hal_wifi_radio_get_mac_address_ap(wifi_radio_obj_t *self);
extern void common_hal_wifi_radio_set_mac_address_ap(wifi_radio_obj_t *self, const uint8_t *mac);
extern mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self);
extern void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self);

View File

@ -30,8 +30,9 @@
#include "shared-bindings/displayio/ColorConverter.h"
#include "shared-module/displayio/Bitmap.h"
#include "py/runtime.h"
#include "py/mperrno.h"
#include "py/runtime.h"
#include "py/stream.h"
#include <math.h>
#include <stdlib.h>
@ -513,9 +514,11 @@ void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int
displayio_bitmap_set_dirty_area(self, &area);
}
void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_element, bool swap_bytes, bool reverse_rows) {
void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, mp_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_element, bool swap_bytes, bool reverse_rows) {
uint32_t mask = (1 << common_hal_displayio_bitmap_get_bits_per_value(self)) - 1;
const mp_stream_p_t *file_proto = mp_get_stream_raise(file, MP_STREAM_OP_READ);
displayio_area_t a = {0, 0, self->width, self->height, NULL};
displayio_bitmap_set_dirty_area(self, &a);
@ -530,9 +533,14 @@ void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *f
uint8_t *rowdata8 = (uint8_t *)rowdata32;
const int y_draw = reverse_rows ? (self->height) - 1 - y : y;
UINT bytes_read = 0;
if (f_read(&file->fp, rowdata32, rowsize, &bytes_read) != FR_OK || bytes_read != rowsize) {
mp_raise_OSError(MP_EIO);
int error = 0;
mp_uint_t bytes_read = file_proto->read(file, rowdata32, rowsize, &error);
if (error) {
mp_raise_OSError(error);
}
if (bytes_read != rowsize) {
mp_raise_msg(&mp_type_EOFError, NULL);
}
if (swap_bytes) {

View File

@ -78,7 +78,7 @@ static void write_word(gifio_gifwriter_t *self, uint16_t value) {
void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *file, int width, int height, displayio_colorspace_t colorspace, bool loop, bool dither, bool own_file) {
self->file = file;
self->file_proto = mp_proto_get_or_throw(MP_QSTR_protocol_stream, file);
self->file_proto = mp_get_stream_raise(file, MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL);
if (self->file_proto->is_text) {
mp_raise_TypeError(translate("file must be a file opened in byte mode"));
}

View File

@ -0,0 +1,53 @@
import ulab.numpy as np
import displayio
import bitmaptools
try:
import struct
except:
import ustruct as struct
base_header = b"BMFX\x02\x00\x00\x00\x00\x00F\x00\x00\x008\x00\x00\x00@\x01\x00\x00\xf0\x00\x00\x00\x01\x00\x10\x00\x03\x00\x00\x00\x00X\x02\x00\xd7\r\x00\x00\xd7\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00\x00\xe0\x07\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00"
def writebmp16(filename, bitmap):
header = bytearray(base_header)
header[18:26] = struct.pack("<II", bitmap.width, bitmap.height)
with open(filename, "wb") as f:
f.write(header)
b = np.frombuffer(bitmap, dtype=np.uint16)
for i in range(bitmap.height):
j = (bitmap.height - i - 1) * bitmap.width
f.write(b[j : j + bitmap.width])
def loadbmp16(filename, width=320, height=240):
"""This specialized routine loads 16bpp uncompressed bmp files with a
70-byte header. It is not appropriate for generic bmp files."""
bitmap = displayio.Bitmap(width, height, 65536)
with open(filename, "rb") as f:
f.seek(70)
bitmaptools.readinto(
bitmap,
f,
bits_per_pixel=16,
element_size=2,
reverse_rows=True,
)
return bitmap
if __name__ == "__main__":
if "/" in __file__:
here = __file__.rsplit("/", 1)[0]
else:
here = "."
b = loadbmp16(here + "/minerva16.bmp")
print(b[0, 0])
print(b[160, 160])
for i, p in enumerate(sorted(set(memoryview(b)))):
print("%04x" % p, end="\n" if (i % 8) == 7 else " ")
if i % 8 != 7:
print()

View File

@ -0,0 +1,32 @@
import bitmaptools
import displayio
import _bmp16
if "/" in __file__:
here = __file__.rsplit("/", 1)[0]
else:
here = "."
c = displayio.Colorspace.BGR565
b1 = _bmp16.loadbmp16(here + "/minerva16.bmp")
b2 = _bmp16.loadbmp16(here + "/blinka16.bmp")
b3 = displayio.Bitmap(320, 240, 65536)
for i in (
0,
1 / 64,
3 / 64,
3 / 32,
3 / 16,
0.5,
1 - 3 / 16,
1 - 3 / 32,
1 - 3 / 64,
1 - 1 / 64,
1,
):
bitmaptools.alphablend(b3, b1, b2, c, i)
_bmp16.writebmp16(f"blend-{i:.2f}.bmp", b3)
bitmaptools.alphablend(b3, b1, b2, c, i, 0)
_bmp16.writebmp16(f"fade-{i:.2f}.bmp", b3)

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

View File

@ -0,0 +1,31 @@
import bitmaptools
import displayio
import _bmp16
if "/" in __file__:
here = __file__.rsplit("/", 1)[0]
else:
here = "."
c = displayio.Colorspace.BGR565
b1 = _bmp16.loadbmp16(here + "/minerva16.bmp")
b3 = displayio.Bitmap(320, 240, 65536)
for i in (
0,
1 / 64,
3 / 64,
3 / 32,
3 / 16,
0.5,
1 - 3 / 16,
1 - 3 / 32,
1 - 3 / 64,
1 - 1 / 64,
1,
):
bitmaptools.dither(b3, b1, c)
_bmp16.writebmp16(f"dither-atkinson.bmp", b3)
bitmaptools.dither(b3, b1, c, bitmaptools.DitherAlgorithm.FloydStenberg)
_bmp16.writebmp16(f"dither-floydstenberg.bmp", b3)

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB