Merge remote-tracking branch 'adafruit/main' into add_pwmio

This commit is contained in:
Scott Shawcroft 2020-08-24 18:25:18 -07:00
commit 1527a3ce92
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
29 changed files with 212 additions and 68 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
"POT-Creation-Date: 2020-08-21 21:39-0500\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"
@ -1349,10 +1349,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
#: ports/stm/ref/pulseout-pre-timeralloc.c
msgid "PulseOut not supported on this chip"
msgstr ""
#: ports/stm/common-hal/os/__init__.c
msgid "RNG DeInit Error"
msgstr ""
@ -2879,6 +2875,14 @@ msgstr ""
msgid "ord() expected a character, but string of length %d found"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "out of range of source"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "out of range of target"
msgstr ""
#: py/objint_mpz.c
msgid "overflow converting long int to machine word"
msgstr ""
@ -3056,6 +3060,10 @@ msgstr ""
msgid "sosfilt requires iterable arguments"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "source palette too large"
msgstr ""
#: py/objstr.c
msgid "start/end indices"
msgstr ""

View File

@ -6,7 +6,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
"PO-Revision-Date: 2020-08-16 02:25+0000\n"
"PO-Revision-Date: 2020-08-21 18:19+0000\n"
"Last-Translator: Wellington Terumi Uemura <wellingtonuemura@gmail.com>\n"
"Language-Team: \n"
"Language: pt_BR\n"
@ -14,7 +14,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.2-dev\n"
"X-Generator: Weblate 4.2.1-dev\n"
#: main.c
msgid ""
@ -1375,6 +1375,8 @@ msgid ""
"Port does not accept pins or frequency. "
"Construct and pass a PWMOut Carrier instead"
msgstr ""
"A porta não aceita pinos ou frequência. "
"Em vez disso, Construa e encaminhe um PWMOut Carrier"
#: shared-bindings/_bleio/Adapter.c
msgid "Prefix buffer must be on the heap"

View File

@ -35,6 +35,6 @@ typedef struct {
mp_obj_base_t base;
} mcu_processor_obj_t;
const mp_obj_type_t mcu_processor_type;
extern const mp_obj_type_t mcu_processor_type;
#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H

View File

@ -39,8 +39,8 @@ static inline mp_uint_t mp_hal_ticks_ms(void) {
return supervisor_ticks_ms32();
}
// Number of bytes in receive buffer
volatile uint8_t usb_rx_count;
volatile bool mp_cdc_enabled;
extern volatile uint8_t usb_rx_count;
extern volatile bool mp_cdc_enabled;
int receive_usb(void);

View File

@ -27,18 +27,18 @@
#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H
#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H
LPI2C_Type *mcu_i2c_banks[2];
extern LPI2C_Type *mcu_i2c_banks[2];
extern const mcu_periph_obj_t mcu_i2c_sda_list[8];
extern const mcu_periph_obj_t mcu_i2c_scl_list[8];
LPSPI_Type *mcu_spi_banks[2];
extern LPSPI_Type *mcu_spi_banks[2];
extern const mcu_periph_obj_t mcu_spi_sck_list[4];
extern const mcu_periph_obj_t mcu_spi_mosi_list[4];
extern const mcu_periph_obj_t mcu_spi_miso_list[4];
LPUART_Type *mcu_uart_banks[4];
extern LPUART_Type *mcu_uart_banks[4];
extern const mcu_periph_obj_t mcu_uart_rx_list[9];
extern const mcu_periph_obj_t mcu_uart_tx_list[9];

View File

@ -28,18 +28,18 @@
#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H
#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H
LPI2C_Type *mcu_i2c_banks[4];
extern LPI2C_Type *mcu_i2c_banks[4];
extern const mcu_periph_obj_t mcu_i2c_sda_list[8];
extern const mcu_periph_obj_t mcu_i2c_scl_list[8];
LPSPI_Type *mcu_spi_banks[4];
extern LPSPI_Type *mcu_spi_banks[4];
extern const mcu_periph_obj_t mcu_spi_sck_list[8];
extern const mcu_periph_obj_t mcu_spi_mosi_list[8];
extern const mcu_periph_obj_t mcu_spi_miso_list[8];
LPUART_Type *mcu_uart_banks[8];
extern LPUART_Type *mcu_uart_banks[8];
extern const mcu_periph_obj_t mcu_uart_rx_list[16];
extern const mcu_periph_obj_t mcu_uart_tx_list[16];

View File

@ -27,18 +27,18 @@
#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H
#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H
LPI2C_Type *mcu_i2c_banks[4];
extern LPI2C_Type *mcu_i2c_banks[4];
extern const mcu_periph_obj_t mcu_i2c_sda_list[9];
extern const mcu_periph_obj_t mcu_i2c_scl_list[9];
LPSPI_Type *mcu_spi_banks[4];
extern LPSPI_Type *mcu_spi_banks[4];
extern const mcu_periph_obj_t mcu_spi_sck_list[8];
extern const mcu_periph_obj_t mcu_spi_mosi_list[8];
extern const mcu_periph_obj_t mcu_spi_miso_list[8];
LPUART_Type *mcu_uart_banks[8];
extern LPUART_Type *mcu_uart_banks[8];
extern const mcu_periph_obj_t mcu_uart_rx_list[18];
extern const mcu_periph_obj_t mcu_uart_tx_list[18];

View File

@ -87,6 +87,8 @@ void check_sec_status(uint8_t sec_status) {
}
}
bool vm_used_ble;
// Turn off BLE on a reset or reload.
void bleio_reset() {
if (!common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) {

View File

@ -45,6 +45,6 @@ void check_gatt_status(uint16_t gatt_status);
void check_sec_status(uint8_t sec_status);
// Track if the user code modified the BLE state to know if we need to undo it on reload.
bool vm_used_ble;
extern bool vm_used_ble;
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H

View File

@ -96,7 +96,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
//if pin is same
if (l_tim->pin == pin) {
//check if the timer has a channel active, or is reserved by main timer system
if (reserved_tim[l_tim_index] != 0) {
if (l_tim_index < TIM_BANK_ARRAY_LEN && reserved_tim[l_tim_index] != 0) {
// Timer has already been reserved by an internal module
if (stm_peripherals_timer_is_reserved(mcu_tim_banks[l_tim_index])) {
tim_taken_internal = true;

View File

@ -38,8 +38,8 @@ static inline mp_uint_t mp_hal_ticks_ms(void) {
return supervisor_ticks_ms32();
}
// Number of bytes in receive buffer
volatile uint8_t usb_rx_count;
volatile bool mp_cdc_enabled;
extern volatile uint8_t usb_rx_count;
extern volatile bool mp_cdc_enabled;
int receive_usb(void);

View File

@ -51,7 +51,7 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[6];
//Timers
#define TIM_BANK_ARRAY_LEN 14
#define TIM_PIN_ARRAY_LEN 44
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F401XE_PERIPH_H

View File

@ -58,8 +58,8 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN];
//Timers
#define TIM_BANK_ARRAY_LEN 14
#define TIM_PIN_ARRAY_LEN 67
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
//SDIO
extern SDIO_TypeDef * mcu_sdio_banks[1];

View File

@ -51,7 +51,7 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[12];
//Timers
#define TIM_BANK_ARRAY_LEN 14
#define TIM_PIN_ARRAY_LEN 56
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F407XX_PERIPH_H

View File

@ -51,7 +51,7 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[7];
//Timers
#define TIM_BANK_ARRAY_LEN 14
#define TIM_PIN_ARRAY_LEN 44
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F411XE_PERIPH_H

View File

@ -52,7 +52,7 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[12];
//Timers
#define TIM_BANK_ARRAY_LEN 14
#define TIM_PIN_ARRAY_LEN 60
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F412ZX_PERIPH_H

View File

@ -31,28 +31,28 @@
//I2C
extern I2C_TypeDef * mcu_i2c_banks[4];
const mcu_periph_obj_t mcu_i2c_sda_list[10];
const mcu_periph_obj_t mcu_i2c_scl_list[10];
extern const mcu_periph_obj_t mcu_i2c_sda_list[10];
extern const mcu_periph_obj_t mcu_i2c_scl_list[10];
//SPI
extern SPI_TypeDef * mcu_spi_banks[6];
const mcu_periph_obj_t mcu_spi_sck_list[14];
const mcu_periph_obj_t mcu_spi_mosi_list[15];
const mcu_periph_obj_t mcu_spi_miso_list[12];
extern const mcu_periph_obj_t mcu_spi_sck_list[14];
extern const mcu_periph_obj_t mcu_spi_mosi_list[15];
extern const mcu_periph_obj_t mcu_spi_miso_list[12];
//UART
extern USART_TypeDef * mcu_uart_banks[MAX_UART];
extern bool mcu_uart_has_usart[MAX_UART];
const mcu_periph_obj_t mcu_uart_tx_list[15];
const mcu_periph_obj_t mcu_uart_rx_list[15];
extern const mcu_periph_obj_t mcu_uart_tx_list[15];
extern const mcu_periph_obj_t mcu_uart_rx_list[15];
//Timers
#define TIM_BANK_ARRAY_LEN 14
#define TIM_PIN_ARRAY_LEN 55
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F746XX_PERIPH_H

View File

@ -30,28 +30,28 @@
//I2C
extern I2C_TypeDef * mcu_i2c_banks[4];
const mcu_periph_obj_t mcu_i2c_sda_list[12];
const mcu_periph_obj_t mcu_i2c_scl_list[12];
extern const mcu_periph_obj_t mcu_i2c_sda_list[12];
extern const mcu_periph_obj_t mcu_i2c_scl_list[12];
//SPI
extern SPI_TypeDef * mcu_spi_banks[6];
const mcu_periph_obj_t mcu_spi_sck_list[18];
const mcu_periph_obj_t mcu_spi_mosi_list[18];
const mcu_periph_obj_t mcu_spi_miso_list[15];
extern const mcu_periph_obj_t mcu_spi_sck_list[18];
extern const mcu_periph_obj_t mcu_spi_mosi_list[18];
extern const mcu_periph_obj_t mcu_spi_miso_list[15];
//UART
extern USART_TypeDef * mcu_uart_banks[MAX_UART];
extern bool mcu_uart_has_usart[MAX_UART];
const mcu_periph_obj_t mcu_uart_tx_list[24];
const mcu_periph_obj_t mcu_uart_rx_list[25];
extern const mcu_periph_obj_t mcu_uart_tx_list[24];
extern const mcu_periph_obj_t mcu_uart_rx_list[25];
//Timers
#define TIM_BANK_ARRAY_LEN 14
#define TIM_PIN_ARRAY_LEN 55
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F767XX_PERIPH_H

View File

@ -30,26 +30,26 @@
//I2C
extern I2C_TypeDef * mcu_i2c_banks[4];
const mcu_periph_obj_t mcu_i2c_sda_list[12];
const mcu_periph_obj_t mcu_i2c_scl_list[12];
extern const mcu_periph_obj_t mcu_i2c_sda_list[12];
extern const mcu_periph_obj_t mcu_i2c_scl_list[12];
//SPI
extern SPI_TypeDef * mcu_spi_banks[6];
const mcu_periph_obj_t mcu_spi_sck_list[19];
const mcu_periph_obj_t mcu_spi_mosi_list[19];
const mcu_periph_obj_t mcu_spi_miso_list[16];
extern const mcu_periph_obj_t mcu_spi_sck_list[19];
extern const mcu_periph_obj_t mcu_spi_mosi_list[19];
extern const mcu_periph_obj_t mcu_spi_miso_list[16];
//UART
extern USART_TypeDef * mcu_uart_banks[MAX_UART];
extern bool mcu_uart_has_usart[MAX_UART];
const mcu_periph_obj_t mcu_uart_tx_list[25];
const mcu_periph_obj_t mcu_uart_rx_list[26];
extern const mcu_periph_obj_t mcu_uart_tx_list[25];
extern const mcu_periph_obj_t mcu_uart_rx_list[26];
//Timers
#define TIM_BANK_ARRAY_LEN 14
#define TIM_PIN_ARRAY_LEN 58
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32H743XX_PERIPH_H

View File

@ -177,13 +177,13 @@ void port_internal_flash_flush(void) {
EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3; // voltage range needs to be 2.7V to 3.6V
// get the sector information
uint32_t sector_size;
uint32_t sector_start_addr;
uint32_t sector_start_addr = 0xffffffff;
#if defined(STM32H7)
EraseInitStruct.Banks = get_bank(_cache_flash_addr);
#endif
EraseInitStruct.Sector = flash_get_sector_info(_cache_flash_addr, &sector_start_addr, &sector_size);
EraseInitStruct.NbSectors = 1;
if (sector_size > sizeof(_flash_cache)) {
if (sector_size > sizeof(_flash_cache) || sector_start_addr == 0xffffffff) {
reset_into_safe_mode(FLASH_WRITE_FAIL);
}

View File

@ -35,7 +35,7 @@
#include "py/objstr.h"
#include "shared-module/_bleio/Address.h"
const mp_obj_type_t bleio_adapter_type;
extern const mp_obj_type_t bleio_adapter_type;
extern bool common_hal_bleio_adapter_get_advertising(bleio_adapter_obj_t *self);
extern bool common_hal_bleio_adapter_get_enabled(bleio_adapter_obj_t *self);

View File

@ -34,7 +34,7 @@
#include "py/objtuple.h"
const mp_obj_type_t bleio_service_type;
extern const mp_obj_type_t bleio_service_type;
// Private version that doesn't allocate on the heap
extern uint32_t _common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary, mp_obj_list_t * characteristic_list);

View File

@ -172,7 +172,109 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val
return mp_const_none;
}
//| def fill(self, value: int) -> None:
//| def blit(self, x: int, y: int, source_bitmap: bitmap, *, x1: int, y1: int, x2: int, y2: int, skip_index: int) -> None:
//| """Inserts the source_bitmap region defined by rectangular boundaries
//| (x1,y1) and (x2,y2) into the bitmap at the specified (x,y) location.
//|
//| :param int x: Horizontal pixel location in bitmap where source_bitmap upper-left
//| corner will be placed
//| :param int y: Vertical pixel location in bitmap where source_bitmap upper-left
//| corner will be placed
//| :param bitmap source_bitmap: Source bitmap that contains the graphical region to be copied
//| :param int x1: Minimum x-value for rectangular bounding box to be copied from the source bitmap
//| :param int y1: Minimum y-value for rectangular bounding box to be copied from the source bitmap
//| :param int x2: Maximum x-value (exclusive) for rectangular bounding box to be copied from the source bitmap
//| :param int y2: Maximum y-value (exclusive) for rectangular bounding box to be copied from the source bitmap
//| :param int skip_index: bitmap palette index in the source that will not be copied,
//| set to None to copy all pixels"""
//| ...
//|
STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args){
enum {ARG_x, ARG_y, ARG_source, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_index};
static const mp_arg_t allowed_args[] = {
{MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT},
{MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT},
{MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ},
{MP_QSTR_x1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{MP_QSTR_y1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{MP_QSTR_x2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->width
{MP_QSTR_y2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->height
{MP_QSTR_skip_index, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj=mp_const_none} },
};
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);
displayio_bitmap_t *self = MP_OBJ_TO_PTR(pos_args[0]);
int16_t x = args[ARG_x].u_int;
int16_t y = args[ARG_y].u_int;
displayio_bitmap_t *source = MP_OBJ_TO_PTR(args[ARG_source].u_obj);
// ensure that the target bitmap (self) has at least as many `bits_per_value` as the source
if (self->bits_per_value < source->bits_per_value) {
mp_raise_ValueError(translate("source palette too large"));
}
int16_t x1 = args[ARG_x1].u_int;
int16_t y1 = args[ARG_y1].u_int;
int16_t x2, y2;
// if x2 or y2 is None, then set as the maximum size of the source bitmap
if ( args[ARG_x2].u_obj == mp_const_none ) {
x2 = source->width;
} else {
x2 = mp_obj_get_int(args[ARG_x2].u_obj);
}
//int16_t y2;
if ( args[ARG_y2].u_obj == mp_const_none ) {
y2 = source->height;
} else {
y2 = mp_obj_get_int(args[ARG_y2].u_obj);
}
// Check x,y are within self (target) bitmap boundary
if ( (x < 0) || (y < 0) || (x > self->width) || (y > self->height) ) {
mp_raise_ValueError(translate("out of range of target"));
}
// Check x1,y1,x2,y2 are within source bitmap boundary
if ( (x1 < 0) || (x1 > source->width) ||
(y1 < 0) || (y1 > source->height) ||
(x2 < 0) || (x2 > source->width) ||
(y2 < 0) || (y2 > source->height) ) {
mp_raise_ValueError(translate("out of range of source"));
}
// Ensure x1 < x2 and y1 < y2
if (x1 > x2) {
int16_t temp=x2;
x2=x1;
x1=temp;
}
if (y1 > y2) {
int16_t temp=y2;
y2=y1;
y1=temp;
}
uint32_t skip_index;
bool skip_index_none; // flag whether skip_value was None
if (args[ARG_skip_index].u_obj == mp_const_none ) {
skip_index = 0;
skip_index_none = true;
} else {
skip_index = mp_obj_get_int(args[ARG_skip_index].u_obj);
skip_index_none = false;
}
common_hal_displayio_bitmap_blit(self, x, y, source, x1, y1, x2, y2, skip_index, skip_index_none);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 4, displayio_bitmap_obj_blit);
// `displayio_bitmap_obj_blit` requires at least 4 arguments
//| def fill(self, value: Any) -> None:
//| """Fills the bitmap with the supplied palette index value."""
//| ...
//|
@ -192,6 +294,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_bitmap_fill_obj, displayio_bitmap_obj_fill);
STATIC const mp_rom_map_elem_t displayio_bitmap_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_bitmap_height_obj) },
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_bitmap_width_obj) },
{ MP_ROM_QSTR(MP_QSTR_blit), MP_ROM_PTR(&displayio_bitmap_blit_obj) },
{ MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&displayio_bitmap_fill_obj) },
};

View File

@ -40,6 +40,9 @@ uint16_t common_hal_displayio_bitmap_get_height(displayio_bitmap_t *self);
uint16_t common_hal_displayio_bitmap_get_width(displayio_bitmap_t *self);
uint32_t common_hal_displayio_bitmap_get_bits_per_value(displayio_bitmap_t *self);
void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y, uint32_t value);
void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16_t y, displayio_bitmap_t *source,
int16_t x1, int16_t y1, int16_t x2, int16_t y2,
uint32_t skip_index, bool skip_index_none);
uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y);
void common_hal_displayio_bitmap_fill(displayio_bitmap_t *bitmap, uint32_t value);

View File

@ -13,7 +13,7 @@ typedef enum {
POSITIONFIX_3D,
} gnss_positionfix_t;
const mp_obj_type_t gnss_positionfix_type;
extern const mp_obj_type_t gnss_positionfix_type;
gnss_positionfix_t gnss_positionfix_obj_to_type(mp_obj_t obj);
mp_obj_t gnss_positionfix_type_to_obj(gnss_positionfix_t mode);

View File

@ -16,7 +16,7 @@ typedef enum {
SATELLITESYSTEM_QZSS_L1S = (1U << 4),
} gnss_satellitesystem_t;
const mp_obj_type_t gnss_satellitesystem_type;
extern const mp_obj_type_t gnss_satellitesystem_type;
gnss_satellitesystem_t gnss_satellitesystem_obj_to_type(mp_obj_t obj);
mp_obj_t gnss_satellitesystem_type_to_obj(gnss_satellitesystem_t mode);

View File

@ -35,7 +35,7 @@ typedef enum {
WATCHDOGMODE_RESET,
} watchdog_watchdogmode_t;
const mp_obj_type_t watchdog_watchdogmode_type;
extern const mp_obj_type_t watchdog_watchdogmode_type;
watchdog_watchdogmode_t watchdog_watchdogmode_obj_to_type(mp_obj_t obj);
mp_obj_t watchdog_watchdogmode_type_to_obj(watchdog_watchdogmode_t mode);

View File

@ -105,6 +105,32 @@ uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *self, int16_t
return 0;
}
void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16_t y, displayio_bitmap_t *source,
int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t skip_index, bool skip_index_none) {
// Copy complete "source" bitmap into "self" bitmap at location x,y in the "self"
// Add a boolean to determine if all values are copied, or only if non-zero
// If skip_value is encountered in the source bitmap, it will not be copied.
// If skip_value is `None`, then all pixels are copied.
if (self->read_only) {
mp_raise_RuntimeError(translate("Read-only object"));
}
// simplest version - use internal functions for get/set pixels
for (int16_t i=0; i < (x2-x1) ; i++) {
if ( (x+i >= 0) && (x+i < self->width) ) {
for (int16_t j=0; j < (y2-y1) ; j++){
if ((y+j >= 0) && (y+j < self->height) ) {
uint32_t value = common_hal_displayio_bitmap_get_pixel(source, x1+i, y1+j);
if ( (skip_index_none) || (value != skip_index) ) { // write if skip_value_none is True
common_hal_displayio_bitmap_set_pixel(self, x+i, y+j, value);
}
}
}
}
}
}
void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *self, int16_t x, int16_t y, uint32_t value) {
if (self->read_only) {
mp_raise_RuntimeError(translate("Read-only object"));

View File

@ -394,8 +394,8 @@ primary_display_t *allocate_display_or_raise(void) {
}
primary_display_t *allocate_display_bus(void) {
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
mp_const_obj_t display_type = displays[i].display.base.type;
if (display_type == NULL || display_type == &mp_type_NoneType) {
mp_const_obj_t display_bus_type = displays[i].bus_base.type;
if (display_bus_type == NULL || display_bus_type == &mp_type_NoneType) {
return &displays[i];
}
}