From 826837186c9668805b58edb4e57b68363aba0149 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Tue, 7 Apr 2020 18:17:25 -0700 Subject: [PATCH 001/216] adds standard (non-queued) SPI support to QSPI for external flash --- .github/workflows/build.yml | 1 + .../atmel-samd/boards/pycubed/mpconfigboard.h | 2 + ports/atmel-samd/boards/pycubed_mram/board.c | 61 ++++++++++ .../boards/pycubed_mram/mpconfigboard.h | 37 ++++++ .../boards/pycubed_mram/mpconfigboard.mk | 24 ++++ ports/atmel-samd/boards/pycubed_mram/pins.c | 55 +++++++++ ports/atmel-samd/supervisor/qspi_flash.c | 15 ++- .../shared/external_flash/common_commands.h | 1 + supervisor/shared/external_flash/devices.h | 17 +++ .../shared/external_flash/external_flash.c | 105 ++++++++++-------- 10 files changed, 272 insertions(+), 46 deletions(-) create mode 100644 ports/atmel-samd/boards/pycubed_mram/board.c create mode 100644 ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/pycubed_mram/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 455f83a21b..e2455f0cd7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -204,6 +204,7 @@ jobs: - "pybadge_airlift" - "pyboard_v11" - "pycubed" + - "pycubed_mram" - "pygamer" - "pygamer_advance" - "pyportal" diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.h b/ports/atmel-samd/boards/pycubed/mpconfigboard.h index 49a98e8d45..8d046c75bd 100644 --- a/ports/atmel-samd/boards/pycubed/mpconfigboard.h +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.h @@ -3,6 +3,7 @@ #define MICROPY_HW_MCU_NAME "samd51j19" #define CIRCUITPY_MCU_FAMILY samd51 +#define MICROPY_HW_LED_STATUS (&pin_PA16) #define MICROPY_HW_NEOPIXEL (&pin_PA21) #define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11) @@ -16,6 +17,7 @@ #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) +// External flash W25Q80DV #define EXTERNAL_FLASH_QSPI_DUAL #define BOARD_HAS_CRYSTAL 1 diff --git a/ports/atmel-samd/boards/pycubed_mram/board.c b/ports/atmel-samd/boards/pycubed_mram/board.c new file mode 100644 index 0000000000..31b0812094 --- /dev/null +++ b/ports/atmel-samd/boards/pycubed_mram/board.c @@ -0,0 +1,61 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#include + +#include "boards/board.h" +#include "py/mpconfig.h" +#include "shared-bindings/nvm/ByteArray.h" +#include "common-hal/microcontroller/Pin.h" +#include "hal/include/hal_gpio.h" +#include "shared-bindings/pulseio/PWMOut.h" + +nvm_bytearray_obj_t bootcnt = { + .base = { + .type = &nvm_bytearray_type + }, + .len = ( uint32_t) 8192, + .start_address = (uint8_t*) (0x00080000 - 8192) + }; + + +void board_init(void) { + pulseio_pwmout_obj_t pwm; + common_hal_pulseio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false); + common_hal_pulseio_pwmout_never_reset(&pwm); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + uint8_t value_out = 0; + common_hal_nvm_bytearray_get_bytes(&bootcnt,0,1,&value_out); + ++value_out; + common_hal_nvm_bytearray_set_bytes(&bootcnt,0,&value_out,1); +} \ No newline at end of file diff --git a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h new file mode 100644 index 0000000000..aca9e3c368 --- /dev/null +++ b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h @@ -0,0 +1,37 @@ + +#define MICROPY_HW_BOARD_NAME "PyCubedv04-MRAM" +#define MICROPY_HW_MCU_NAME "samd51j19" +#define CIRCUITPY_MCU_FAMILY samd51 + +#define MICROPY_HW_LED_STATUS (&pin_PA16) +#define MICROPY_HW_NEOPIXEL (&pin_PA21) + +#define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11) +#define MICROPY_PORT_B (PORT_PA21 | PORT_PB10 | PORT_PB11) +#define MICROPY_PORT_C (0) +#define MICROPY_PORT_D (0) + +// External flash MR2xH40 MRAM +#define EXTERNAL_FLASH_QSPI_SINGLE + +#define AUTORESET_DELAY_MS 500 + +#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_PB13) +#define DEFAULT_I2C_BUS_SDA (&pin_PB12) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA12) +#define DEFAULT_SPI_BUS_MISO (&pin_PA14) + +#define DEFAULT_UART_BUS_TX (&pin_PB02) +#define DEFAULT_UART_BUS_RX (&pin_PB03) + +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 + diff --git a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk new file mode 100644 index 0000000000..ef92b4db56 --- /dev/null +++ b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk @@ -0,0 +1,24 @@ +LD_FILE = boards/samd51x19-bootloader-external-flash.ld +USB_VID = 0x04D8 +USB_PID = 0xEC44 +USB_PRODUCT = "PyCubed" +USB_MANUFACTURER = "maholli" + +CHIP_VARIANT = SAMD51J19A +CHIP_FAMILY = samd51 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = MR2xH40 +LONGINT_IMPL = MPZ + +# Not needed. +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_GAMEPAD = 0 +CIRCUITPY_PS2IO = 0 + +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD \ No newline at end of file diff --git a/ports/atmel-samd/boards/pycubed_mram/pins.c b/ports/atmel-samd/boards/pycubed_mram/pins.c new file mode 100644 index 0000000000..4c97f58a80 --- /dev/null +++ b/ports/atmel-samd/boards/pycubed_mram/pins.c @@ -0,0 +1,55 @@ +#include "shared-bindings/board/__init__.h" +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_xSDCS), MP_ROM_PTR(&pin_PA27) }, + + { MP_ROM_QSTR(MP_QSTR_RELAY_A), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_BURN1), MP_ROM_PTR(&pin_PB31) }, + { MP_ROM_QSTR(MP_QSTR_BURN2), MP_ROM_PTR(&pin_PA15) }, + + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_L1PROG), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_AIN4), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_AIN5), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_CHRG), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_DAC0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_PA17), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_PA18), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_PA19), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_PA20), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_PA22), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_PB16), MP_ROM_PTR(&pin_PB16) }, + { MP_ROM_QSTR(MP_QSTR_PB17), MP_ROM_PTR(&pin_PB17) }, + { MP_ROM_QSTR(MP_QSTR_PB22), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_PB23), MP_ROM_PTR(&pin_PB23) }, + + { MP_ROM_QSTR(MP_QSTR_RF1_RST), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_RF1_CS), MP_ROM_PTR(&pin_PB30) }, + { MP_ROM_QSTR(MP_QSTR_RF1_IO0), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_RF1_IO4), MP_ROM_PTR(&pin_PB04) }, + + { MP_ROM_QSTR(MP_QSTR_RF2_RST), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_RF2_CS), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_RF2_IO1), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_RF2_BSY), MP_ROM_PTR(&pin_PB07) }, + + { MP_ROM_QSTR(MP_QSTR_EN_GPS), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB03) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB13) }, + + { MP_ROM_QSTR(MP_QSTR_WDT_WDI), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA21) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); \ No newline at end of file diff --git a/ports/atmel-samd/supervisor/qspi_flash.c b/ports/atmel-samd/supervisor/qspi_flash.c index eca47b1648..434446f67d 100644 --- a/ports/atmel-samd/supervisor/qspi_flash.c +++ b/ports/atmel-samd/supervisor/qspi_flash.c @@ -166,7 +166,10 @@ bool spi_flash_write_data(uint32_t address, uint8_t* data, uint32_t length) { bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t length) { samd_peripherals_disable_and_clear_cache(); - #ifdef EXTERNAL_FLASH_QSPI_DUAL + #ifdef EXTERNAL_FLASH_QSPI_SINGLE + QSPI->INSTRCTRL.bit.INSTR = CMD_READ_DATA; + uint32_t mode = QSPI_INSTRFRAME_WIDTH_SINGLE_BIT_SPI; + #elif defined EXTERNAL_FLASH_QSPI_DUAL QSPI->INSTRCTRL.bit.INSTR = CMD_DUAL_READ; uint32_t mode = QSPI_INSTRFRAME_WIDTH_DUAL_OUTPUT; #else @@ -174,6 +177,15 @@ bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t length) { uint32_t mode = QSPI_INSTRFRAME_WIDTH_QUAD_OUTPUT; #endif + #ifdef IS_MRAM + QSPI->INSTRFRAME.reg = mode | + QSPI_INSTRFRAME_ADDRLEN_24BITS | + QSPI_INSTRFRAME_TFRTYPE_READMEMORY | + QSPI_INSTRFRAME_INSTREN | + QSPI_INSTRFRAME_ADDREN | + QSPI_INSTRFRAME_DATAEN | + QSPI_INSTRFRAME_DUMMYLEN(0); + #else QSPI->INSTRFRAME.reg = mode | QSPI_INSTRFRAME_ADDRLEN_24BITS | QSPI_INSTRFRAME_TFRTYPE_READMEMORY | @@ -181,6 +193,7 @@ bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t length) { QSPI_INSTRFRAME_ADDREN | QSPI_INSTRFRAME_DATAEN | QSPI_INSTRFRAME_DUMMYLEN(8); + #endif memcpy(data, ((uint8_t *) QSPI_AHB) + address, length); // TODO(tannewt): Fix DMA and enable it. diff --git a/supervisor/shared/external_flash/common_commands.h b/supervisor/shared/external_flash/common_commands.h index cc0da21759..2eaa848331 100644 --- a/supervisor/shared/external_flash/common_commands.h +++ b/supervisor/shared/external_flash/common_commands.h @@ -43,5 +43,6 @@ #define CMD_QUAD_READ 0x6b #define CMD_ENABLE_RESET 0x66 #define CMD_RESET 0x99 +#define CMD_WAKE 0xab #endif // MICROPY_INCLUDED_ATMEL_SAMD_EXTERNAL_FLASH_COMMON_COMMANDS_H diff --git a/supervisor/shared/external_flash/devices.h b/supervisor/shared/external_flash/devices.h index fd9224f561..05e9e3c95c 100644 --- a/supervisor/shared/external_flash/devices.h +++ b/supervisor/shared/external_flash/devices.h @@ -426,6 +426,23 @@ typedef struct { .single_status_byte = false, \ } +// Everspin MRAM +#define MR2xH40 {\ + .total_size = (1 << 22), /* 4 MiB */ \ + .start_up_time_us = 10000, \ + .manufacturer_id = 0xef, /*no JDEC*/ \ + .memory_type = 0x40, /*no JDEC*/ \ + .capacity = 0x14, /*no JDEC*/ \ + .max_clock_speed_mhz = 40, \ + .quad_enable_bit_mask = 0x00, \ + .has_sector_protection = false, \ + .supports_fast_read = false, \ + .supports_qspi = false, \ + .supports_qspi_writes = false, \ + .write_status_register_split = false, \ + .single_status_byte = true, \ +} + // Settings for the Macronix MX25L1606 2MiB SPI flash. // Datasheet: #define MX25L1606 {\ diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 9d38c07d89..7f5496d3ac 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -27,7 +27,7 @@ #include #include - +#include "mpconfigboard.h" #include "supervisor/spi_flash_api.h" #include "supervisor/shared/external_flash/common_commands.h" #include "extmod/vfs.h" @@ -57,13 +57,18 @@ static supervisor_allocation* supervisor_cache = NULL; // Wait until both the write enable and write in progress bits have cleared. static bool wait_for_flash_ready(void) { - uint8_t read_status_response[1] = {0x00}; bool ok = true; // Both the write enable and write in progress bits should be low. - do { - ok = spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); - } while (ok && (read_status_response[0] & 0x3) != 0); - return ok; + #ifdef EXTERNAL_FLASH_QSPI_SINGLE + // For NVM without a ready bit in status register + return ok; + #else + uint8_t read_status_response[1] = {0x00}; + do { + ok = spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); + } while (ok && (read_status_response[0] & 0x3) != 0); + return ok; + #endif } // Turn on the write enable bit so we can program and erase the flash. @@ -91,16 +96,18 @@ static bool write_flash(uint32_t address, const uint8_t* data, uint32_t data_len } // Don't bother writing if the data is all 1s. Thats equivalent to the flash // state after an erase. - bool all_ones = true; - for (uint16_t i = 0; i < data_length; i++) { - if (data[i] != 0xff) { - all_ones = false; - break; + #ifndef EXTERNAL_FLASH_QSPI_SINGLE + bool all_ones = true; + for (uint16_t i = 0; i < data_length; i++) { + if (data[i] != 0xff) { + all_ones = false; + break; + } } - } - if (all_ones) { - return true; - } + if (all_ones) { + return true; + } + #endif for (uint32_t bytes_written = 0; bytes_written < data_length; @@ -191,41 +198,49 @@ void supervisor_flash_init(void) { spi_flash_init(); - // The response will be 0xff if the flash needs more time to start up. - uint8_t jedec_id_response[3] = {0xff, 0xff, 0xff}; - while (jedec_id_response[0] == 0xff) { - spi_flash_read_command(CMD_READ_JEDEC_ID, jedec_id_response, 3); - } - - for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { - const external_flash_device* possible_device = &possible_devices[i]; - if (jedec_id_response[0] == possible_device->manufacturer_id && - jedec_id_response[1] == possible_device->memory_type && - jedec_id_response[2] == possible_device->capacity) { +#ifdef EXTERNAL_FLASH_QSPI_SINGLE + // For NVM that don't have JEDEC response + spi_flash_command(CMD_WAKE); + for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { + const external_flash_device* possible_device = &possible_devices[i]; flash_device = possible_device; break; } - } +#else + // The response will be 0xff if the flash needs more time to start up. + uint8_t jedec_id_response[3] = {0xff, 0xff, 0xff}; + while (jedec_id_response[0] == 0xff) { + spi_flash_read_command(CMD_READ_JEDEC_ID, jedec_id_response, 3); + } - if (flash_device == NULL) { - return; - } - - // We don't know what state the flash is in so wait for any remaining writes and then reset. - uint8_t read_status_response[1] = {0x00}; - // The write in progress bit should be low. - do { - spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); - } while ((read_status_response[0] & 0x1) != 0); - // The suspended write/erase bit should be low. - do { - spi_flash_read_command(CMD_READ_STATUS2, read_status_response, 1); - } while ((read_status_response[0] & 0x80) != 0); - - - spi_flash_command(CMD_ENABLE_RESET); - spi_flash_command(CMD_RESET); + for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { + const external_flash_device* possible_device = &possible_devices[i]; + if (jedec_id_response[0] == possible_device->manufacturer_id && + jedec_id_response[1] == possible_device->memory_type && + jedec_id_response[2] == possible_device->capacity) { + flash_device = possible_device; + break; + } + } +#endif + if (flash_device == NULL) { + return; + } + // We don't know what state the flash is in so wait for any remaining writes and then reset. + uint8_t read_status_response[1] = {0x00}; + // The write in progress bit should be low. + do { + spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); + } while ((read_status_response[0] & 0x1) != 0); +#ifndef EXTERNAL_FLASH_QSPI_SINGLE + // The suspended write/erase bit should be low. + do { + spi_flash_read_command(CMD_READ_STATUS2, read_status_response, 1); + } while ((read_status_response[0] & 0x80) != 0); + spi_flash_command(CMD_ENABLE_RESET); + spi_flash_command(CMD_RESET); +#endif // Wait 30us for the reset common_hal_mcu_delay_us(30); From a53a26be70588685a300e4c693ab9f8db65b1212 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Tue, 7 Apr 2020 18:24:53 -0700 Subject: [PATCH 002/216] missed a debug flag --- ports/atmel-samd/Makefile | 2 +- ports/atmel-samd/supervisor/qspi_flash.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index f4886f96ef..4e34a3904d 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -53,7 +53,7 @@ include $(TOP)/supervisor/supervisor.mk # Include make rules and variables common across CircuitPython builds. include $(TOP)/py/circuitpy_defns.mk -CROSS_COMPILE = arm-none-eabi- +CROSS_COMPILE = ~/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- HAL_DIR=hal/$(MCU_SERIES) diff --git a/ports/atmel-samd/supervisor/qspi_flash.c b/ports/atmel-samd/supervisor/qspi_flash.c index 434446f67d..fc538f95f3 100644 --- a/ports/atmel-samd/supervisor/qspi_flash.c +++ b/ports/atmel-samd/supervisor/qspi_flash.c @@ -177,7 +177,7 @@ bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t length) { uint32_t mode = QSPI_INSTRFRAME_WIDTH_QUAD_OUTPUT; #endif - #ifdef IS_MRAM + #ifdef EXTERNAL_FLASH_QSPI_SINGLE QSPI->INSTRFRAME.reg = mode | QSPI_INSTRFRAME_ADDRLEN_24BITS | QSPI_INSTRFRAME_TFRTYPE_READMEMORY | From 181ecf4a9be1062601c5d07039efe1f592ed01e1 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Tue, 7 Apr 2020 21:54:46 -0700 Subject: [PATCH 003/216] fixing my goofy CROSS_COMPILE fix --- ports/atmel-samd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 4e34a3904d..f4886f96ef 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -53,7 +53,7 @@ include $(TOP)/supervisor/supervisor.mk # Include make rules and variables common across CircuitPython builds. include $(TOP)/py/circuitpy_defns.mk -CROSS_COMPILE = ~/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- +CROSS_COMPILE = arm-none-eabi- HAL_DIR=hal/$(MCU_SERIES) From a18b991ca90670758afadfe0e78ec97cf56bf5e3 Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 22 Apr 2020 15:22:34 -0400 Subject: [PATCH 004/216] Added pyi to SPI.c --- shared-bindings/busio/SPI.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 043c1089d5..e01e9e35e5 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -40,6 +40,19 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" +class SPI: + def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): ... + def deinit(self, ) -> Any: ... + def __enter__(self, ) -> Any: ... + def __exit__(self, ) -> Any: ... + def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: ... + def try_lock(self, ) -> Any: ... + def unlock(self, ) -> Any: ... + def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: ... + def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: ... + def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: ... + frequency: Any = ... + //| .. currentmodule:: busio //| //| :class:`SPI` -- a 3-4 wire serial protocol From 855c2033b59c8451bde30387e668ecfb206888b6 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 23 Apr 2020 15:35:20 -0400 Subject: [PATCH 005/216] Reogranized pyi in spi.c --- shared-bindings/busio/SPI.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index e01e9e35e5..db84ac97b5 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -40,18 +40,6 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -class SPI: - def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): ... - def deinit(self, ) -> Any: ... - def __enter__(self, ) -> Any: ... - def __exit__(self, ) -> Any: ... - def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: ... - def try_lock(self, ) -> Any: ... - def unlock(self, ) -> Any: ... - def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: ... - def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: ... - def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: ... - frequency: Any = ... //| .. currentmodule:: busio //| @@ -89,6 +77,8 @@ class SPI: //| :param ~microcontroller.Pin MOSI: the Master Out Slave In pin. //| :param ~microcontroller.Pin MISO: the Master In Slave Out pin. //| +// class SPI: +// def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): ... // TODO(tannewt): Support LSB SPI. STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -115,6 +105,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con //| //| Turn off the SPI bus. //| +// def deinit(self, ) -> Any: ... STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_spi_deinit(self); @@ -127,12 +118,14 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit); //| No-op used by Context Managers. //| // Provided by context manager helper. +// def __enter__(self, ) -> Any: ... //| .. method:: __exit__() //| //| Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info. //| +// def __exit__(self, ) -> Any: ... STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_spi_deinit(args[0]); @@ -176,6 +169,7 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) { //| Two SPI objects may be created, except on the Circuit Playground Bluefruit, //| which allows only one (to allow for an additional I2C object). //| +// def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: ... STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits }; static const mp_arg_t allowed_args[] = { @@ -218,6 +212,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure); //| :return: True when lock has been grabbed //| :rtype: bool //| +// def try_lock(self, ) -> Any: ... 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); return mp_obj_new_bool(common_hal_busio_spi_try_lock(self)); @@ -228,6 +223,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock); //| //| Releases the SPI lock. //| +// def unlock(self, ) -> Any: ... STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -245,6 +241,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); //| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` //| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` //| +// def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: ... STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -288,6 +285,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write); //| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` //| :param int write_value: Value to write while reading. (Usually ignored.) //| +// def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: ... STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; static const mp_arg_t allowed_args[] = { @@ -335,6 +333,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto); //| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` //| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)`` //| +// def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: ... STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { @@ -387,6 +386,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_read //| The actual SPI bus frequency. This may not match the frequency requested //| due to internal limitations. //| +// frequency: Any = ... 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); check_for_deinit(self); From 55bdee688fc021d8afb70b0868b20699c5f0519b Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 23 Apr 2020 16:14:17 -0400 Subject: [PATCH 006/216] Reorganized pyi again --- shared-bindings/busio/SPI.c | 229 +++++++++++++++++------------------- 1 file changed, 108 insertions(+), 121 deletions(-) diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index db84ac97b5..1ac9629f80 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -41,44 +41,44 @@ #include "supervisor/shared/translate.h" -//| .. currentmodule:: busio +//|class SPI: +//| """.. currentmodule:: busio //| -//| :class:`SPI` -- a 3-4 wire serial protocol -//| ----------------------------------------------- +//| `SPI` -- a 3-4 wire serial protocol +//| ----------------------------------------------- //| -//| SPI is a serial protocol that has exclusive pins for data in and out of the -//| master. It is typically faster than :py:class:`~busio.I2C` because a -//| separate pin is used to control the active slave rather than a transitted -//| address. This class only manages three of the four SPI lines: `!clock`, -//| `!MOSI`, `!MISO`. Its up to the client to manage the appropriate slave -//| select line. (This is common because multiple slaves can share the `!clock`, -//| `!MOSI` and `!MISO` lines and therefore the hardware.) +//| SPI is a serial protocol that has exclusive pins for data in and out of the +//| master. It is typically faster than :py:class:`~busio.I2C` because a +//| separate pin is used to control the active slave rather than a transitted +//| address. This class only manages three of the four SPI lines: `!clock`, +//| `!MOSI`, `!MISO`. Its up to the client to manage the appropriate slave +//| select line. (This is common because multiple slaves can share the `!clock`, +//| `!MOSI` and `!MISO` lines and therefore the hardware.)""" //| -//| .. class:: SPI(clock, MOSI=None, MISO=None) +//| def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): //| -//| Construct an SPI object on the given pins. +//| """Construct an SPI object on the given pins. //| -//| ..note:: The SPI peripherals allocated in order of desirability, if possible, -//| such as highest speed and not shared use first. For instance, on the nRF52840, -//| there is a single 32MHz SPI peripheral, and multiple 8MHz peripherals, -//| some of which may also be used for I2C. The 32MHz SPI peripheral is returned -//| first, then the exclusive 8MHz SPI peripheral, and finally the shared 8MHz -//| peripherals. +//| ..note:: The SPI peripherals allocated in order of desirability, if possible, +//| such as highest speed and not shared use first. For instance, on the nRF52840, +//| there is a single 32MHz SPI peripheral, and multiple 8MHz peripherals, +//| some of which may also be used for I2C. The 32MHz SPI peripheral is returned +//| first, then the exclusive 8MHz SPI peripheral, and finally the shared 8MHz +//| peripherals. //| -//| .. seealso:: Using this class directly requires careful lock management. -//| Instead, use :class:`~adafruit_bus_device.spi_device.SPIDevice` to -//| manage locks. +//| .. seealso:: Using this class directly requires careful lock management. +//| Instead, use :class:`~adafruit_bus_device.spi_device.SPIDevice` to +//| manage locks. //| -//| .. seealso:: Using this class to directly read registers requires manual -//| bit unpacking. Instead, use an existing driver or make one with -//| :ref:`Register ` data descriptors. +//| .. seealso:: Using this class to directly read registers requires manual +//| bit unpacking. Instead, use an existing driver or make one with +//| :ref:`Register ` data descriptors. //| -//| :param ~microcontroller.Pin clock: the pin to use for the clock. -//| :param ~microcontroller.Pin MOSI: the Master Out Slave In pin. -//| :param ~microcontroller.Pin MISO: the Master In Slave Out pin. -//| -// class SPI: -// def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): ... +//| :param ~microcontroller.Pin clock: the pin to use for the clock. +//| :param ~microcontroller.Pin MOSI: the Master Out Slave In pin. +//| :param ~microcontroller.Pin MISO: the Master In Slave Out pin.""" +//| ... + // TODO(tannewt): Support LSB SPI. STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -101,11 +101,9 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Turn off the SPI bus. -//| -// def deinit(self, ) -> Any: ... +//| def deinit(self, ) -> Any: +//| """Turn off the SPI bus.""" +//| ... STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_spi_deinit(self); @@ -113,19 +111,15 @@ STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit); -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| -// Provided by context manager helper. -// def __enter__(self, ) -> Any: ... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers. +//| Provided by context manager helper.""" +//| ... -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| -// def __exit__(self, ) -> Any: ... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_spi_deinit(args[0]); @@ -146,30 +140,29 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) { } } -//| .. method:: configure(*, baudrate=100000, polarity=0, phase=0, bits=8) +//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: +//| """Configures the SPI bus. The SPI object must be locked. //| -//| Configures the SPI bus. The SPI object must be locked. +//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower +//| due to the granularity of available clock settings. +//| Check the `frequency` attribute for the actual clock rate. +//| :param int polarity: the base state of the clock line (0 or 1) +//| :param int phase: the edge of the clock that data is captured. First (0) +//| or second (1). Rising or falling depends on clock polarity. +//| :param int bits: the number of bits per word //| -//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower -//| due to the granularity of available clock settings. -//| Check the `frequency` attribute for the actual clock rate. -//| :param int polarity: the base state of the clock line (0 or 1) -//| :param int phase: the edge of the clock that data is captured. First (0) -//| or second (1). Rising or falling depends on clock polarity. -//| :param int bits: the number of bits per word +//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that +//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is +//| within spec for the SAMD21. //| -//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that -//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is -//| within spec for the SAMD21. -//| -//| .. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz, -//| and 8MHz. -//| If you pick a a baudrate other than one of these, the nearest lower -//| baudrate will be chosen, with a minimum of 125kHz. -//| Two SPI objects may be created, except on the Circuit Playground Bluefruit, -//| which allows only one (to allow for an additional I2C object). -//| -// def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: ... +//| .. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz, +//| and 8MHz. +//| If you pick a a baudrate other than one of these, the nearest lower +//| baudrate will be chosen, with a minimum of 125kHz. +//| Two SPI objects may be created, except on the Circuit Playground Bluefruit, +//| which allows only one (to allow for an additional I2C object).""" +//| ... + STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits }; static const mp_arg_t allowed_args[] = { @@ -205,25 +198,23 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_ } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure); -//| .. method:: try_lock() +//| def try_lock(self, ) -> Any: +//| """Attempts to grab the SPI lock. Returns True on success. //| -//| Attempts to grab the SPI lock. Returns True on success. -//| -//| :return: True when lock has been grabbed -//| :rtype: bool -//| -// def try_lock(self, ) -> Any: ... +//| :return: True when lock has been grabbed +//| :rtype: bool""" +//| ... + 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); 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); -//| .. method:: unlock() -//| -//| Releases the SPI lock. -//| -// def unlock(self, ) -> Any: ... +//| def unlock(self, ) -> Any: +//| """Releases the SPI 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); check_for_deinit(self); @@ -232,16 +223,15 @@ STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); -//| .. method:: write(buffer, *, start=0, end=None) +//| def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: ... +//| """Write the data contained in ``buffer``. The SPI object must be locked. +//| If the buffer is empty, nothing happens. //| -//| Write the data contained in ``buffer``. The SPI object must be locked. -//| If the buffer is empty, nothing happens. -//| -//| :param bytearray buffer: Write out the data in this buffer -//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` -//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` -//| -// def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: ... +//| :param bytearray buffer: Write out the data in this buffer +//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` +//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" +//| ... + STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -274,18 +264,17 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write); -//| .. method:: readinto(buffer, *, start=0, end=None, write_value=0) +//| def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: +//| """Read into ``buffer`` while writing ``write_value`` for each byte read. +//| The SPI object must be locked. +//| If the number of bytes to read is 0, nothing happens. //| -//| Read into ``buffer`` while writing ``write_value`` for each byte read. -//| The SPI object must be locked. -//| If the number of bytes to read is 0, nothing happens. -//| -//| :param bytearray buffer: Read data into this buffer -//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` -//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` -//| :param int write_value: Value to write while reading. (Usually ignored.) -//| -// def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: ... +//| :param bytearray buffer: Read data into this buffer +//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` +//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` +//| :param int write_value: Value to write while reading. (Usually ignored.)""" +//| ... + STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; static const mp_arg_t allowed_args[] = { @@ -318,22 +307,21 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto); -//| .. method:: write_readinto(buffer_out, buffer_in, *, out_start=0, out_end=None, in_start=0, in_end=None) +//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: +//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. +//| The SPI object must be locked. +//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` +//| must be equal. +//| If buffer slice lengths are both 0, nothing happens. //| -//| Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. -//| The SPI object must be locked. -//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` -//| must be equal. -//| If buffer slice lengths are both 0, nothing happens. -//| -//| :param bytearray buffer_out: Write out the data in this buffer -//| :param bytearray buffer_in: Read data into this buffer -//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` -//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` -//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` -//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)`` -//| -// def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: ... +//| :param bytearray buffer_out: Write out the data in this buffer +//| :param bytearray buffer_in: Read data into this buffer +//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` +//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` +//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` +//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" +//| ... + STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { @@ -381,12 +369,11 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto); -//| .. attribute:: frequency -//| -//| The actual SPI bus frequency. This may not match the frequency requested -//| due to internal limitations. -//| -// frequency: Any = ... +//| frequency: Any = +//| """The actual SPI bus frequency. This may not match the frequency requested +//| due to internal limitations.""" +//| ... + 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); check_for_deinit(self); From 28430a9919c511330c4fb833469497a346ad2288 Mon Sep 17 00:00:00 2001 From: dherrada Date: Sat, 25 Apr 2020 15:07:58 -0400 Subject: [PATCH 007/216] Added inline pyi to I2C.c --- shared-bindings/busio/I2C.c | 191 +++++++++++++++++------------------- 1 file changed, 90 insertions(+), 101 deletions(-) diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index c89215acdb..0cd392f9a8 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -36,34 +36,33 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: busio +//|class I2C: +//| """.. currentmodule:: busio //| -//| :class:`I2C` --- Two wire serial protocol -//| ------------------------------------------ +//| :class:`I2C` --- Two wire serial protocol +//| ------------------------------------------""" +//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255): +//| """I2C is a two-wire protocol for communicating between devices. At the +//| physical level it consists of 2 wires: SCL and SDA, the clock and data +//| lines respectively. //| -//| .. class:: I2C(scl, sda, *, frequency=400000, timeout=255) +//| .. seealso:: Using this class directly requires careful lock management. +//| Instead, use :class:`~adafruit_bus_device.i2c_device.I2CDevice` to +//| manage locks. //| -//| I2C is a two-wire protocol for communicating between devices. At the -//| physical level it consists of 2 wires: SCL and SDA, the clock and data -//| lines respectively. +//| .. seealso:: Using this class to directly read registers requires manual +//| bit unpacking. Instead, use an existing driver or make one with +//| :ref:`Register ` data descriptors. //| -//| .. seealso:: Using this class directly requires careful lock management. -//| Instead, use :class:`~adafruit_bus_device.i2c_device.I2CDevice` to -//| manage locks. -//| -//| .. seealso:: Using this class to directly read registers requires manual -//| bit unpacking. Instead, use an existing driver or make one with -//| :ref:`Register ` data descriptors. -//| -//| :param ~microcontroller.Pin scl: The clock pin -//| :param ~microcontroller.Pin sda: The data pin -//| :param int frequency: The clock frequency in Hertz -//| :param int timeout: The maximum clock stretching timeut - (used only for bitbangio.I2C; ignored for busio.I2C) -//| -//| .. note:: On the nRF52840, only one I2C object may be created, -//| except on the Circuit Playground Bluefruit, which allows two, -//| one for the onboard accelerometer, and one for offboard use. +//| :param ~microcontroller.Pin scl: The clock pin +//| :param ~microcontroller.Pin sda: The data pin +//| :param int frequency: The clock frequency in Hertz +//| :param int timeout: The maximum clock stretching timeut - (used only for bitbangio.I2C; ignored for busio.I2C) //| +//| .. note:: On the nRF52840, only one I2C object may be created, +//| except on the Circuit Playground Bluefruit, which allows two, +//| one for the onboard accelerometer, and one for offboard use.""" +//| ... STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t); self->base.type = &busio_i2c_type; @@ -84,10 +83,9 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con return (mp_obj_t)self; } -//| .. method:: deinit() -//| -//| Releases control of the underlying hardware so other classes can use it. -//| +//| def deinit(self, ) -> Any: +//| """Releases control of the underlying hardware so other classes can use it.""" +//| ... STATIC mp_obj_t busio_i2c_obj_deinit(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_i2c_deinit(self); @@ -101,17 +99,15 @@ STATIC void check_for_deinit(busio_i2c_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used in Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used in Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware on context exit. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware on context exit. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_i2c_deinit(args[0]); @@ -126,14 +122,13 @@ static void check_lock(busio_i2c_obj_t *self) { } } -//| .. method:: scan() -//| -//| Scan all I2C addresses between 0x08 and 0x77 inclusive and return a -//| list of those that respond. -//| -//| :return: List of device ids on the I2C bus -//| :rtype: list +//| def scan(self, ) -> Any: +//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a +//| list of those that respond. //| +//| :return: List of device ids on the I2C bus +//| :rtype: list""" +//| ... STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -150,13 +145,11 @@ STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan); -//| .. method:: try_lock() -//| -//| Attempts to grab the I2C lock. Returns True on success. -//| -//| :return: True when lock has been grabbed -//| :rtype: bool -//| +//| def try_lock(self, ) -> Any: +//| """Attempts to grab the I2C lock. Returns True on success. +//| :return: True when lock has been grabbed +//| :rtype: bool""" +//| ... 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); check_for_deinit(self); @@ -164,10 +157,9 @@ STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock); -//| .. method:: unlock() -//| -//| Releases the I2C lock. -//| +//| def unlock(self, ) -> Any: +//| """Releases the I2C 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); check_for_deinit(self); @@ -176,21 +168,20 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); -//| .. method:: readfrom_into(address, buffer, *, start=0, end=None) +//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any: +//| """Read into ``buffer`` from the slave specified by ``address``. +//| The number of bytes read will be the length of ``buffer``. +//| At least one byte must be read. //| -//| Read into ``buffer`` from the slave specified by ``address``. -//| The number of bytes read will be the length of ``buffer``. -//| At least one byte must be read. -//| -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buf[start:end]`` will so it saves memory. -//| -//| :param int address: 7-bit device address -//| :param bytearray buffer: buffer to write into -//| :param int start: Index to start writing at -//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)`` +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buf[start:end]`` will so it saves memory. //| +//| :param int address: 7-bit device address +//| :param bytearray buffer: buffer to write into +//| :param int start: Index to start writing at +//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| ... // Shared arg parsing for readfrom_into and writeto_then_readfrom. STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; @@ -228,27 +219,26 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, } MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into); -//| .. method:: writeto(address, buffer, *, start=0, end=None, stop=True) +//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any: +//| """Write the bytes from ``buffer`` to the slave specified by ``address``. +//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be +//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and +//| repeated start before a read. //| -//| Write the bytes from ``buffer`` to the slave specified by ``address``. -//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be -//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and -//| repeated start before a read. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buffer[start:end]`` will so it saves memory. //| -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. -//| -//| Writing a buffer or slice of length zero is permitted, as it can be used -//| to poll for the existence of a device. -//| -//| :param int address: 7-bit device address -//| :param bytearray buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param bool stop: If true, output an I2C stop condition after the buffer is written. -//| Deprecated. Will be removed in 6.x and act as stop=True. +//| Writing a buffer or slice of length zero is permitted, as it can be used +//| to poll for the existence of a device. //| +//| :param int address: 7-bit device address +//| :param bytearray buffer: buffer containing the bytes to write +//| :param int start: Index to start writing from +//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)`` +//| :param bool stop: If true, output an I2C stop condition after the buffer is written. +//| Deprecated. Will be removed in 6.x and act as stop=True.""" +//| ... // Shared arg parsing for writeto and writeto_then_readfrom. STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) { // get the buffer to write the data from @@ -287,24 +277,23 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); -//| .. method:: writeto_then_readfrom(address, out_buffer, in_buffer, *, out_start=0, out_end=None, in_start=0, in_end=None) +//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any: +//| """Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop +//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and +//| ``in_buffer`` can be the same buffer because they are used sequentially. //| -//| Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop -//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and -//| ``in_buffer`` can be the same buffer because they are used sequentially. -//| -//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` -//| will so it saves memory. -//| -//| :param int address: 7-bit device address -//| :param bytearray out_buffer: buffer containing the bytes to write -//| :param bytearray in_buffer: buffer to write into -//| :param int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)`` +//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` +//| will so it saves memory. //| +//| :param int address: 7-bit device address +//| :param bytearray out_buffer: buffer containing the bytes to write +//| :param bytearray in_buffer: buffer to write into +//| :param int out_start: Index to start writing from +//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` +//| :param int in_start: Index to start writing at +//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| ... STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { From 7070fe1995f70e745699682bbc9776bb54a069a6 Mon Sep 17 00:00:00 2001 From: dherrada Date: Sat, 25 Apr 2020 15:25:31 -0400 Subject: [PATCH 008/216] Added inline pyi to UART.c --- shared-bindings/busio/UART.c | 177 +++++++++++++++++------------------ 1 file changed, 86 insertions(+), 91 deletions(-) diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index f231924d50..59c95528d9 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -40,33 +40,32 @@ #include "supervisor/shared/translate.h" -//| .. currentmodule:: busio + +//|class UART: +//| """.. currentmodule:: busio //| -//| :class:`UART` -- a bidirectional serial protocol -//| ================================================= +//| :class:`UART` -- a bidirectional serial protocol +//| =================================================""" +//| def __init__(self, tx: microcontroller.Pin, rx: microcontroller.Pin, *, baudrate: int = 9600, bits: int = 8, parity: Parity = None, stop: int = 1, timeout: float = 1, receiver_buffer_size: int = 64): +//| """A common bidirectional serial protocol that uses an an agreed upon speed +//| rather than a shared clock line. //| +//| :param ~microcontroller.Pin tx: the pin to transmit with, or ``None`` if this ``UART`` is receive-only. +//| :param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only. +//| :param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use. +//| :param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use. +//| :param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use. +//| :param bool rs485_invert: set to invert the sense of the rs485_dir pin. +//| :param int baudrate: the transmit and receive speed. +//| :param int bits: the number of bits per byte, 7, 8 or 9. +//| :param Parity parity: the parity used for error checking. +//| :param int stop: the number of stop bits, 1 or 2. +//| :param float timeout: the timeout in seconds to wait for the first character and between subsequent characters when reading. Raises ``ValueError`` if timeout >100 seconds. +//| :param int receiver_buffer_size: the character length of the read buffer (0 to disable). (When a character is 9 bits the buffer will be 2 * receiver_buffer_size bytes.) //| -//| .. class:: UART(tx, rx, *, baudrate=9600, bits=8, parity=None, stop=1, timeout=1, receiver_buffer_size=64) -//| -//| A common bidirectional serial protocol that uses an an agreed upon speed -//| rather than a shared clock line. -//| -//| :param ~microcontroller.Pin tx: the pin to transmit with, or ``None`` if this ``UART`` is receive-only. -//| :param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only. -//| :param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use. -//| :param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use. -//| :param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use. -//| :param bool rs485_invert: set to invert the sense of the rs485_dir pin. -//| :param int baudrate: the transmit and receive speed. -//| :param int bits: the number of bits per byte, 7, 8 or 9. -//| :param Parity parity: the parity used for error checking. -//| :param int stop: the number of stop bits, 1 or 2. -//| :param float timeout: the timeout in seconds to wait for the first character and between subsequent characters when reading. Raises ``ValueError`` if timeout >100 seconds. -//| :param int receiver_buffer_size: the character length of the read buffer (0 to disable). (When a character is 9 bits the buffer will be 2 * receiver_buffer_size bytes.) -//| -//| *New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. -//| The new upper limit on ``timeout`` is meant to catch mistaken use of milliseconds. -//| +//| *New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. +//| The new upper limit on ``timeout`` is meant to catch mistaken use of milliseconds.""" +//| ... typedef struct { mp_obj_base_t base; } busio_uart_parity_obj_t; @@ -144,10 +143,9 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co return (mp_obj_t)self; } -//| .. method:: deinit() -//| -//| Deinitialises the UART and releases any hardware resources for reuse. -//| +//| def deinit(self, ) -> Any: +//| """Deinitialises the UART and releases any hardware resources for reuse.""" +//| ... STATIC mp_obj_t busio_uart_obj_deinit(mp_obj_t self_in) { busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_uart_deinit(self); @@ -161,17 +159,15 @@ STATIC void check_for_deinit(busio_uart_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_uart_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_uart_deinit(args[0]); @@ -181,41 +177,46 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ // These are standard stream methods. Code is in py/stream.c. // -//| .. method:: read(nbytes=None) +//| def read(self, nbytes: Any = None) -> Any: +//| """Read characters. If ``nbytes`` is specified then read at most that many +//| bytes. Otherwise, read everything that arrives until the connection +//| times out. Providing the number of bytes expected is highly recommended +//| because it will be faster. //| -//| Read characters. If ``nbytes`` is specified then read at most that many -//| bytes. Otherwise, read everything that arrives until the connection -//| times out. Providing the number of bytes expected is highly recommended -//| because it will be faster. -//| -//| :return: Data read -//| :rtype: bytes or None -//| -//| .. method:: readinto(buf) -//| -//| Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. -//| -//| :return: number of bytes read and stored into ``buf`` -//| :rtype: int or None (on a non-blocking error) -//| -//| *New in CircuitPython 4.0:* No length parameter is permitted. +//| :return: Data read +//| :rtype: bytes or None""" +//| ... -//| .. method:: readline() +//| def readinto(self, buf: Any) -> Any: +//| """.. method:: readinto(buf) //| -//| Read a line, ending in a newline character. +//| Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. //| -//| :return: the line read -//| :rtype: int or None +//| :return: number of bytes read and stored into ``buf`` +//| :rtype: int or None (on a non-blocking error) //| -//| .. method:: write(buf) +//| *New in CircuitPython 4.0:* No length parameter is permitted.""" +//| ... + +//| def readline(self, ) -> Any: +//| """.. method:: readline() //| -//| Write the buffer of bytes to the bus. +//| Read a line, ending in a newline character. //| -//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. +//| :return: the line read +//| :rtype: int or None""" +//| ... + +//| def write(self, buf: Any) -> Any: +//| """.. method:: write(buf) //| -//| :return: the number of bytes written -//| :rtype: int or None +//| Write the buffer of bytes to the bus. //| +//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. +//| +//| :return: the number of bytes written +//| :rtype: int or None""" +//| ... // 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) { @@ -259,10 +260,9 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t return ret; } -//| .. attribute:: baudrate -//| -//| The current baudrate. -//| +//| baudrate: Any = +//| """The current baudrate.""" +//| ... 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); check_for_deinit(self); @@ -286,10 +286,9 @@ const mp_obj_property_t busio_uart_baudrate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: in_waiting -//| -//| The number of bytes in the input buffer, available to be read -//| +//| in_waiting: Any = +//| """The number of bytes in the input buffer, available to be read""" +//| ... 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); check_for_deinit(self); @@ -304,10 +303,9 @@ const mp_obj_property_t busio_uart_in_waiting_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: timeout -//| -//| The current timeout, in seconds (float). -//| +//| timeout: Any = +//| """The current timeout, in seconds (float).""" +//| ... STATIC mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) { busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -333,10 +331,9 @@ const mp_obj_property_t busio_uart_timeout_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: reset_input_buffer() -//| -//| Discard any unread characters in the input buffer. -//| +//| def reset_input_buffer(self, ) -> Any: +//| """Discard any unread characters in the input buffer.""" +//| ... 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); check_for_deinit(self); @@ -345,18 +342,16 @@ STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_obj_reset_input_buffer); -//| .. class:: busio.UART.Parity() -//| -//| Enum-like class to define the parity used to verify correct data transfer. -//| -//| .. data:: ODD -//| -//| Total number of ones should be odd. -//| -//| .. data:: EVEN -//| -//| Total number of ones should be even. -//| +//|class busio: +//| def __init__(self, ): +//| """Enum-like class to define the parity used to verify correct data transfer.""" +//| ODD: Any = +//| """Total number of ones should be odd.""" +//| ... +//| EVEN: Any = +//| """Total number of ones should be even.""" +//| ... +//| ... const mp_obj_type_t busio_uart_parity_type; const busio_uart_parity_obj_t busio_uart_parity_odd_obj = { From e7874277abc43d794f521d519f522cb068ab95ef Mon Sep 17 00:00:00 2001 From: dherrada Date: Sat, 25 Apr 2020 15:35:24 -0400 Subject: [PATCH 009/216] Fixed empty lines --- shared-bindings/busio/UART.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 59c95528d9..954cbdd20b 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -39,8 +39,6 @@ #include "py/stream.h" #include "supervisor/shared/translate.h" - - //|class UART: //| """.. currentmodule:: busio //| From 27e085ec360fd625210fe70bf71019b8019363b3 Mon Sep 17 00:00:00 2001 From: dherrada Date: Sat, 25 Apr 2020 15:36:16 -0400 Subject: [PATCH 010/216] Added pyi to OneWire.c --- shared-bindings/busio/OneWire.c | 92 ++++++++++++++++----------------- 1 file changed, 44 insertions(+), 48 deletions(-) diff --git a/shared-bindings/busio/OneWire.c b/shared-bindings/busio/OneWire.c index 022d6afcf4..dd4410d468 100644 --- a/shared-bindings/busio/OneWire.c +++ b/shared-bindings/busio/OneWire.c @@ -34,34 +34,36 @@ #include "shared-bindings/busio/OneWire.h" #include "shared-bindings/util.h" -//| .. currentmodule:: busio +//|class OneWire: +//| """.. currentmodule:: busio //| -//| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol -//| ================================================================= +//| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol +//| =================================================================""" //| -//| :class:`~busio.OneWire` implements the timing-sensitive foundation of the Maxim -//| (formerly Dallas Semi) OneWire protocol. +//| def __init__(self, pin: microcontroller.Pin): +//| """:class:`~busio.OneWire` implements the timing-sensitive foundation of the Maxim +//| (formerly Dallas Semi) OneWire protocol. //| -//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126 +//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126 //| -//| .. class:: OneWire(pin) +//| .. class:: OneWire(pin) //| -//| Create a OneWire object associated with the given pin. The object -//| implements the lowest level timing-sensitive bits of the protocol. +//| Create a OneWire object associated with the given pin. The object +//| implements the lowest level timing-sensitive bits of the protocol. //| -//| :param ~microcontroller.Pin pin: Pin connected to the OneWire bus +//| :param ~microcontroller.Pin pin: Pin connected to the OneWire bus //| -//| Read a short series of pulses:: +//| Read a short series of pulses:: //| -//| import busio -//| import board -//| -//| onewire = busio.OneWire(board.D7) -//| onewire.reset() -//| onewire.write_bit(True) -//| onewire.write_bit(False) -//| print(onewire.read_bit()) +//| import busio +//| import board //| +//| onewire = busio.OneWire(board.D7) +//| onewire.reset() +//| onewire.write_bit(True) +//| onewire.write_bit(False) +//| print(onewire.read_bit())""" +//| ... STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pin }; static const mp_arg_t allowed_args[] = { @@ -78,10 +80,9 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialize the OneWire bus and release any hardware resources for reuse. -//| +//| def deinit(self, ) -> Any: +//| """Deinitialize the OneWire bus and release any hardware resources for reuse.""" +//| ... STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_onewire_deinit(self); @@ -95,17 +96,15 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_onewire_deinit(args[0]); @@ -113,13 +112,12 @@ STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__); -//| .. method:: reset() -//| -//| Reset the OneWire bus and read presence -//| -//| :returns: False when at least one device is present -//| :rtype: bool +//| def reset(self, ) -> Any: +//| """Reset the OneWire bus and read presence //| +//| :returns: False when at least one device is present +//| :rtype: bool""" +//| ... STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -128,13 +126,12 @@ STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset); -//| .. method:: read_bit() -//| -//| Read in a bit -//| -//| :returns: bit state read -//| :rtype: bool +//| def read_bit(self, ) -> Any: +//| """Read in a bit //| +//| :returns: bit state read +//| :rtype: bool""" +//| ... 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); check_for_deinit(self); @@ -143,10 +140,9 @@ STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit); -//| .. method:: write_bit(value) -//| -//| Write out a bit based on value. -//| +//| def write_bit(self, value: Any) -> Any: +//| """Write out a bit based on value.""" +//| ... 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); check_for_deinit(self); From 8344fce9940c2c964663e541908069b03cbe14e5 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 27 Apr 2020 13:06:47 -0400 Subject: [PATCH 011/216] Added inline pyi to analogio --- shared-bindings/analogio/AnalogIn.c | 71 +++++++++++++--------------- shared-bindings/analogio/AnalogOut.c | 62 ++++++++++++------------ 2 files changed, 61 insertions(+), 72 deletions(-) diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index b4eeb2af1b..a8afe75bda 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -36,27 +36,25 @@ #include "shared-bindings/analogio/AnalogIn.h" #include "shared-bindings/util.h" -//| .. currentmodule:: analogio +//|class AnalogIn: +//| """:class:`AnalogIn` -- read analog voltage +//| ============================================ //| -//| :class:`AnalogIn` -- read analog voltage -//| ============================================ +//| Usage:: //| -//| Usage:: +//| import analogio +//| from board import * //| -//| import analogio -//| from board import * +//| adc = analogio.AnalogIn(A1) +//| val = adc.value""" //| -//| adc = analogio.AnalogIn(A1) -//| val = adc.value +//| def __init__(self, pin: microcontroller.Pin): //| - -//| .. class:: AnalogIn(pin) -//| -//| Use the AnalogIn on the given pin. The reference voltage varies by -//| platform so use ``reference_voltage`` to read the configured setting. -//| -//| :param ~microcontroller.Pin pin: the pin to read from +//| """Use the AnalogIn on the given pin. The reference voltage varies by +//| platform so use ``reference_voltage`` to read the configured setting. //| +//| :param ~microcontroller.Pin pin: the pin to read from""" +//| ... STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // check number of arguments @@ -72,10 +70,9 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Turn off the AnalogIn and release the pin for other use. -//| +//| def deinit(self, ) -> Any: +//| """Turn off the AnalogIn and release the pin for other use.""" +//| ... STATIC mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) { analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_analogio_analogin_deinit(self); @@ -88,17 +85,15 @@ STATIC void check_for_deinit(analogio_analogin_obj_t *self) { raise_deinited_error(); } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_analogio_analogin_deinit(args[0]); @@ -106,13 +101,12 @@ STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogin___exit___obj, 4, 4, analogio_analogin___exit__); -//| .. attribute:: value -//| -//| The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only) -//| -//| Even if the underlying analog to digital converter (ADC) is lower -//| resolution, the value is 16-bit. +//| value: Any = +//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only) //| +//| Even if the underlying analog to digital converter (ADC) is lower +//| resolution, the value is 16-bit.""" +//| ... 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); check_for_deinit(self); @@ -127,11 +121,10 @@ const mp_obj_property_t analogio_analogin_value_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: reference_voltage -//| -//| The maximum voltage measurable (also known as the reference voltage) as a -//| `float` in Volts. -//| +//| reference_voltage: Any = +//| """The maximum voltage measurable (also known as the reference voltage) as a +//| `float` in Volts.""" +//| ... 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); check_for_deinit(self); diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index 89cf147b26..1b5808e6c9 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -36,28 +36,27 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: analogio +//|class AnalogOut: +//| """.. currentmodule:: analogio //| -//| :class:`AnalogOut` -- output analog voltage -//| ============================================ +//| :class:`AnalogOut` -- output analog voltage +//| ============================================ //| -//| The AnalogOut is used to output analog values (a specific voltage). +//| The AnalogOut is used to output analog values (a specific voltage). //| -//| Example usage:: +//| Example usage:: //| -//| import analogio -//| from microcontroller import pin +//| import analogio +//| from microcontroller import pin //| -//| dac = analogio.AnalogOut(pin.PA02) # output on pin PA02 -//| dac.value = 32768 # makes PA02 1.65V +//| dac = analogio.AnalogOut(pin.PA02) # output on pin PA02 +//| dac.value = 32768 # makes PA02 1.65V""" +//| def __init__(self, pin: microcontroller.Pin): //| - -//| .. class:: AnalogOut(pin) -//| -//| Use the AnalogOut on the given pin. -//| -//| :param ~microcontroller.Pin pin: the pin to output to +//| """Use the AnalogOut on the given pin. //| +//| :param ~microcontroller.Pin pin: the pin to output to""" +//| ... STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // check arguments mp_arg_check_num(n_args, kw_args, 1, 1, false); @@ -71,10 +70,9 @@ STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Turn off the AnalogOut and release the pin for other use. -//| +//| def deinit(self, ) -> Any: +//| """Turn off the AnalogOut and release the pin for other use.""" +//| ... STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) { analogio_analogout_obj_t *self = self_in; @@ -84,17 +82,15 @@ STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogout_deinit); -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_analogio_analogout_deinit(args[0]); @@ -102,12 +98,12 @@ STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4, analogio_analogout___exit__); -//| .. attribute:: value +//| value: Any = +//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only) //| -//| The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only) -//| -//| Even if the underlying digital to analog converter (DAC) is lower -//| resolution, the value is 16-bit. +//| Even if the underlying digital to analog converter (DAC) is lower +//| 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); if (common_hal_analogio_analogout_deinited(self)) { From e96235d0cf7e6548982d1dde4ef69492dfc19cd2 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 27 Apr 2020 16:35:03 -0400 Subject: [PATCH 012/216] Added inline pyi to audiobusio --- shared-bindings/audiobusio/I2SOut.c | 162 +++++++++++++--------------- shared-bindings/audiobusio/PDMIn.c | 100 ++++++++--------- 2 files changed, 127 insertions(+), 135 deletions(-) diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index cd662acb56..cad17ad184 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -35,65 +35,64 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audiobusio +//|class I2SOut: +//| """.. currentmodule:: audiobusio //| -//| :class:`I2SOut` -- Output an I2S audio signal -//| ======================================================== +//| :class:`I2SOut` -- Output an I2S audio signal +//| ======================================================== //| -//| I2S is used to output an audio signal on an I2S bus. +//| I2S is used to output an audio signal on an I2S bus.""" +//| def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool): +//| """Create a I2SOut object associated with the given pins. //| -//| .. class:: I2SOut(bit_clock, word_select, data, *, left_justified) +//| :param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin +//| :param ~microcontroller.Pin word_select: The word select (or left/right clock) pin +//| :param ~microcontroller.Pin data: The data pin +//| :param bool left_justified: True when data bits are aligned with the word select clock. False +//| when they are shifted by one to match classic I2S protocol. //| -//| Create a I2SOut object associated with the given pins. +//| Simple 8ksps 440 Hz sine wave on `Metro M0 Express `_ +//| using `UDA1334 Breakout `_:: //| -//| :param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin -//| :param ~microcontroller.Pin word_select: The word select (or left/right clock) pin -//| :param ~microcontroller.Pin data: The data pin -//| :param bool left_justified: True when data bits are aligned with the word select clock. False -//| when they are shifted by one to match classic I2S protocol. +//| import audiobusio +//| import audiocore +//| import board +//| import array +//| import time +//| import math //| -//| Simple 8ksps 440 Hz sine wave on `Metro M0 Express `_ -//| using `UDA1334 Breakout `_:: +//| # Generate one period of sine wave. +//| length = 8000 // 440 +//| sine_wave = array.array("H", [0] * length) +//| for i in range(length): +//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//| import audiobusio -//| import audiocore -//| import board -//| import array -//| import time -//| import math +//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//| i2s = audiobusio.I2SOut(board.D1, board.D0, board.D9) +//| i2s.play(sine_wave, loop=True) +//| time.sleep(1) +//| i2s.stop() //| -//| # Generate one period of sine wave. -//| length = 8000 // 440 -//| sine_wave = array.array("H", [0] * length) -//| for i in range(length): -//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//| Playing a wave file from flash:: //| -//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) -//| i2s = audiobusio.I2SOut(board.D1, board.D0, board.D9) -//| i2s.play(sine_wave, loop=True) -//| time.sleep(1) -//| i2s.stop() -//| -//| Playing a wave file from flash:: -//| -//| import board -//| import audioio -//| import audiocore -//| import audiobusio -//| import digitalio +//| import board +//| import audioio +//| import audiocore +//| import audiobusio +//| import digitalio //| //| -//| f = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audiocore.WaveFile(f) +//| f = open("cplay-5.1-16bit-16khz.wav", "rb") +//| wav = audiocore.WaveFile(f) //| -//| a = audiobusio.I2SOut(board.D1, board.D0, board.D9) -//| -//| print("playing") -//| a.play(wav) -//| while a.playing: -//| pass -//| print("stopped") +//| a = audiobusio.I2SOut(board.D1, board.D0, board.D9) //| +//| print("playing") +//| a.play(wav) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_left_justified }; static const mp_arg_t allowed_args[] = { @@ -116,10 +115,9 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the I2SOut and releases any hardware resources for reuse. -//| +//| def deinit(self, ) -> Any: +//| """Deinitialises the I2SOut and releases any hardware resources for reuse.""" +//| ... STATIC mp_obj_t audiobusio_i2sout_deinit(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_i2sout_deinit(self); @@ -132,17 +130,15 @@ STATIC void check_for_deinit(audiobusio_i2sout_obj_t *self) { raise_deinited_error(); } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_i2sout_deinit(args[0]); @@ -151,15 +147,14 @@ STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *ar STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, audiobusio_i2sout_obj___exit__); -//| .. method:: play(sample, *, loop=False) +//| def play(self, sample: Any, *, loop: Any = False) -> Any: +//| """Plays the sample once when loop=False and continuously when loop=True. +//| Does not block. Use `playing` to block. //| -//| Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. -//| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. -//| -//| The sample itself should consist of 8 bit or 16 bit samples. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| +//| The sample itself should consist of 8 bit or 16 bit samples.""" +//| ... STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -178,10 +173,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_ar } MP_DEFINE_CONST_FUN_OBJ_KW(audiobusio_i2sout_play_obj, 1, audiobusio_i2sout_obj_play); -//| .. method:: stop() -//| -//| Stops playback. -//| +//| def stop(self, ) -> Any: +//| """Stops playback.""" +//| ... STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -190,10 +184,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_stop_obj, audiobusio_i2sout_obj_stop); -//| .. attribute:: playing -//| -//| True when the audio sample is being output. (read-only) -//| +//| playing: Any = +//| """True when the audio sample is being output. (read-only)""" +//| ... 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); check_for_deinit(self); @@ -208,10 +201,9 @@ const mp_obj_property_t audiobusio_i2sout_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: pause() -//| -//| Stops playback temporarily while remembering the position. Use `resume` to resume playback. -//| +//| def pause(self, ) -> Any: +//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" +//| ... STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -224,10 +216,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_pause_obj, audiobusio_i2sout_obj_pause); -//| .. method:: resume() -//| -//| Resumes sample playback after :py:func:`pause`. -//| +//| def resume(self, ) -> Any: +//| """Resumes sample playback after :py:func:`pause`.""" +//| ... STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -240,10 +231,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_resume_obj, audiobusio_i2sout_obj_resume); -//| .. attribute:: paused -//| -//| True when playback is paused. (read-only) -//| +//| paused: Any = +//| """True when playback is paused. (read-only)""" +//| ... 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); check_for_deinit(self); diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index fce6cf7a2e..b75545ba7b 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -36,32 +36,39 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audiobusio + + + + + + + +//|class PDMIn: +//| """.. currentmodule:: audiobusio //| -//| :class:`PDMIn` -- Record an input PDM audio stream -//| ======================================================== +//| :class:`PDMIn` -- Record an input PDM audio stream +//| ======================================================== //| -//| PDMIn can be used to record an input audio signal on a given set of pins. +//| PDMIn can be used to record an input audio signal on a given set of pins.""" //| -//| .. class:: PDMIn(clock_pin, data_pin, *, sample_rate=16000, bit_depth=8, mono=True, oversample=64, startup_delay=0.11) -//| -//| Create a PDMIn object associated with the given pins. This allows you to -//| record audio signals from the given pins. Individual ports may put further -//| restrictions on the recording parameters. The overall sample rate is -//| determined by `sample_rate` x ``oversample``, and the total must be 1MHz or -//| higher, so `sample_rate` must be a minimum of 16000. -//| -//| :param ~microcontroller.Pin clock_pin: The pin to output the clock to -//| :param ~microcontroller.Pin data_pin: The pin to read the data from -//| :param int sample_rate: Target sample_rate of the resulting samples. Check `sample_rate` for actual value. -//| Minimum sample_rate is about 16000 Hz. -//| :param int bit_depth: Final number of bits per sample. Must be divisible by 8 -//| :param bool mono: True when capturing a single channel of audio, captures two channels otherwise -//| :param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8 -//| :param float startup_delay: seconds to wait after starting microphone clock -//| to allow microphone to turn on. Most require only 0.01s; some require 0.1s. Longer is safer. -//| Must be in range 0.0-1.0 seconds. +//| def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11): +//| """Create a PDMIn object associated with the given pins. This allows you to +//| record audio signals from the given pins. Individual ports may put further +//| restrictions on the recording parameters. The overall sample rate is +//| determined by `sample_rate` x ``oversample``, and the total must be 1MHz or +//| higher, so `sample_rate` must be a minimum of 16000. //| +//| :param ~microcontroller.Pin clock_pin: The pin to output the clock to +//| :param ~microcontroller.Pin data_pin: The pin to read the data from +//| :param int sample_rate: Target sample_rate of the resulting samples. Check `sample_rate` for actual value. +//| Minimum sample_rate is about 16000 Hz. +//| :param int bit_depth: Final number of bits per sample. Must be divisible by 8 +//| :param bool mono: True when capturing a single channel of audio, captures two channels otherwise +//| :param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8 +//| :param float startup_delay: seconds to wait after starting microphone clock +//| to allow microphone to turn on. Most require only 0.01s; some require 0.1s. Longer is safer. +//| Must be in range 0.0-1.0 seconds.""" +//| ... //| Record 8-bit unsigned samples to buffer:: //| @@ -86,7 +93,7 @@ //| b.append(0) //| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: //| mic.record(b, len(b)) -//| +//| STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_clock_pin, ARG_data_pin, ARG_sample_rate, ARG_bit_depth, ARG_mono, ARG_oversample, ARG_startup_delay }; static const mp_arg_t allowed_args[] = { @@ -138,10 +145,9 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the PDMIn and releases any hardware resources for reuse. -//| +//| def deinit(self, ) -> Any: +//| """Deinitialises the PDMIn and releases any hardware resources for reuse.""" +//| ... STATIC mp_obj_t audiobusio_pdmin_deinit(mp_obj_t self_in) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_pdmin_deinit(self); @@ -154,16 +160,14 @@ STATIC void check_for_deinit(audiobusio_pdmin_obj_t *self) { raise_deinited_error(); } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context.""" +//| ... STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_pdmin_deinit(args[0]); @@ -172,18 +176,17 @@ STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *arg STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, audiobusio_pdmin_obj___exit__); -//| .. method:: record(destination, destination_length) -//| -//| Records destination_length bytes of samples to destination. This is +//| def record(self, destination: Any, destination_length: Any) -> Any: +//| """Records destination_length bytes of samples to destination. This is //| blocking. //| -//| An IOError may be raised when the destination is too slow to record the -//| audio at the given rate. For internal flash, writing all 1s to the file -//| before recording is recommended to speed up writes. -//| -//| :return: The number of samples recorded. If this is less than ``destination_length``, -//| some samples were missed due to processing time. +//| An IOError may be raised when the destination is too slow to record the +//| audio at the given rate. For internal flash, writing all 1s to the file +//| before recording is recommended to speed up writes. //| +//| :return: The number of samples recorded. If this is less than ``destination_length``, +//| some samples were missed due to processing time.""" +//| ... 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); check_for_deinit(self); @@ -214,11 +217,10 @@ STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destinat } MP_DEFINE_CONST_FUN_OBJ_3(audiobusio_pdmin_record_obj, audiobusio_pdmin_obj_record); -//| .. attribute:: sample_rate -//| -//| The actual sample_rate of the recording. This may not match the constructed -//| sample rate due to internal clock limitations. -//| +//| sample_rate: Any = +//| """The actual sample_rate of the recording. This may not match the constructed +//| sample rate due to internal clock limitations.""" +//| ... 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); check_for_deinit(self); From 088b5b1785c2acd772dfaf97ce09a3098fdca978 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 27 Apr 2020 16:49:12 -0400 Subject: [PATCH 013/216] Added inline pyi to audiocore --- shared-bindings/audiocore/RawSample.c | 98 ++++++++++++------------ shared-bindings/audiocore/WaveFile.c | 105 ++++++++++++-------------- 2 files changed, 96 insertions(+), 107 deletions(-) diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 96af58a4f3..b879b1b97f 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -35,45 +35,45 @@ #include "shared-bindings/audiocore/RawSample.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audiocore +//|class RawSample: +//| """.. currentmodule:: audiocore //| -//| :class:`RawSample` -- A raw audio sample buffer -//| ======================================================== +//| :class:`RawSample` -- A raw audio sample buffer +//| ======================================================== //| -//| An in-memory sound sample +//| An in-memory sound sample""" //| -//| .. class:: RawSample(buffer, *, channel_count=1, sample_rate=8000) +//| def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000): +//| """Create a RawSample based on the given buffer of signed values. If channel_count is more than +//| 1 then each channel's samples should alternate. In other words, for a two channel buffer, the +//| first sample will be for channel 1, the second sample will be for channel two, the third for +//| channel 1 and so on. //| -//| Create a RawSample based on the given buffer of signed values. If channel_count is more than -//| 1 then each channel's samples should alternate. In other words, for a two channel buffer, the -//| first sample will be for channel 1, the second sample will be for channel two, the third for -//| channel 1 and so on. +//| :param array.array buffer: An `array.array` with samples +//| :param int channel_count: The number of channels in the buffer +//| :param int sample_rate: The desired playback sample rate //| -//| :param array.array buffer: An `array.array` with samples -//| :param int channel_count: The number of channels in the buffer -//| :param int sample_rate: The desired playback sample rate +//| Simple 8ksps 440 Hz sin wave:: //| -//| Simple 8ksps 440 Hz sin wave:: +//| import audiocore +//| import audioio +//| import board +//| import array +//| import time +//| import math //| -//| import audiocore -//| import audioio -//| import board -//| import array -//| import time -//| import math -//| -//| # Generate one period of sine wav. -//| length = 8000 // 440 -//| sine_wave = array.array("h", [0] * length) -//| for i in range(length): -//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15)) -//| -//| dac = audioio.AudioOut(board.SPEAKER) -//| sine_wave = audiocore.RawSample(sine_wave) -//| dac.play(sine_wave, loop=True) -//| time.sleep(1) -//| dac.stop() +//| # Generate one period of sine wav. +//| length = 8000 // 440 +//| sine_wave = array.array("h", [0] * length) +//| for i in range(length): +//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15)) //| +//| dac = audioio.AudioOut(board.SPEAKER) +//| sine_wave = audiocore.RawSample(sine_wave) +//| dac.play(sine_wave, loop=True) +//| time.sleep(1) +//| dac.stop()""" +//| ... STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_channel_count, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -105,10 +105,9 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the AudioOut and releases any hardware resources for reuse. -//| +//| def deinit(self, ) -> Any: +//| """Deinitialises the AudioOut and releases any hardware resources for reuse.""" +//| ... STATIC mp_obj_t audioio_rawsample_deinit(mp_obj_t self_in) { audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_rawsample_deinit(self); @@ -122,17 +121,15 @@ STATIC void check_for_deinit(audioio_rawsample_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_rawsample_deinit(args[0]); @@ -140,13 +137,12 @@ STATIC mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *ar } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_rawsample___exit___obj, 4, 4, audioio_rawsample_obj___exit__); -//| .. attribute:: sample_rate -//| -//| 32 bit value that dictates how quickly samples are played in Hertz (cycles per second). -//| When the sample is looped, this can change the pitch output without changing the underlying -//| sample. This will not change the sample rate of any active playback. Call ``play`` again to -//| change it. -//| +//| sample_rate: Any = +//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second). +//| When the sample is looped, this can change the pitch output without changing the underlying +//| sample. This will not change the sample rate of any active playback. Call ``play`` again to +//| change it.""" +//| ... 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); check_for_deinit(self); diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 178d2a1393..f57e1f8779 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -33,44 +33,43 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audiocore +//|class WaveFile: +//| """.. currentmodule:: audiocore //| -//| :class:`WaveFile` -- Load a wave file for audio playback -//| ======================================================== +//| :class:`WaveFile` -- Load a wave file for audio playback +//| ======================================================== //| -//| A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must -//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating -//| an internal buffer. +//| A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must +//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating +//| an internal buffer.""" +//| def __init__(self, file: typing.BinaryIO, buffer: bytearray): +//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. //| -//| .. class:: WaveFile(file[, buffer]) -//| -//| Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. -//| -//| :param typing.BinaryIO file: Already opened wave file -//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally. +//| :param typing.BinaryIO file: Already opened wave file +//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally. //| //| -//| Playing a wave file from flash:: +//| Playing a wave file from flash:: //| -//| import board -//| import audiocore -//| import audioio -//| import digitalio +//| import board +//| import audiocore +//| import audioio +//| import digitalio //| -//| # Required for CircuitPlayground Express -//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//| speaker_enable.switch_to_output(value=True) +//| # Required for CircuitPlayground Express +//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//| speaker_enable.switch_to_output(value=True) //| -//| data = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audiocore.WaveFile(data) -//| a = audioio.AudioOut(board.A0) -//| -//| print("playing") -//| a.play(wav) -//| while a.playing: -//| pass -//| print("stopped") +//| data = open("cplay-5.1-16bit-16khz.wav", "rb") +//| wav = audiocore.WaveFile(data) +//| a = audioio.AudioOut(board.A0) //| +//| print("playing") +//| a.play(wav) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 2, false); @@ -93,10 +92,9 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the WaveFile and releases all memory resources for reuse. -//| +//| def deinit(self, ) -> Any: +//| """Deinitialises the WaveFile and releases all memory resources for reuse.""" +//| ... STATIC mp_obj_t audioio_wavefile_deinit(mp_obj_t self_in) { audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_wavefile_deinit(self); @@ -110,17 +108,15 @@ STATIC void check_for_deinit(audioio_wavefile_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_wavefile_deinit(args[0]); @@ -128,12 +124,11 @@ STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_wavefile___exit___obj, 4, 4, audioio_wavefile_obj___exit__); -//| .. attribute:: sample_rate -//| -//| 32 bit value that dictates how quickly samples are loaded into the DAC -//| in Hertz (cycles per second). When the sample is looped, this can change -//| the pitch output without changing the underlying sample. -//| +//| sample_rate: Any = +//| """32 bit value that dictates how quickly samples are loaded into the DAC +//| in Hertz (cycles per second). When the sample is looped, this can change +//| the pitch output without changing the underlying sample.""" +//| ... 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); check_for_deinit(self); @@ -156,10 +151,9 @@ const mp_obj_property_t audioio_wavefile_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: bits_per_sample -//| -//| Bits per sample. (read only) -//| +//| bits_per_sample: Any = +//| """Bits per sample. (read only)""" +//| ... 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); check_for_deinit(self); @@ -174,10 +168,9 @@ const mp_obj_property_t audioio_wavefile_bits_per_sample_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: channel_count -//| -//| Number of audio channels. (read only) -//| +//| channel_count: Any = +//| """Number of audio channels. (read only)""" +//| ... 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); check_for_deinit(self); From 1363e6e724124b6f51619113b2877da53195dd1e Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 27 Apr 2020 17:02:48 -0400 Subject: [PATCH 014/216] Added inline pyi to audiocore --- shared-bindings/audioio/AudioOut.c | 165 ++++++++++++++--------------- 1 file changed, 78 insertions(+), 87 deletions(-) diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index ea1efcdffb..8df923e6f1 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -36,64 +36,64 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audioio +//|class AudioOut: +//| """.. currentmodule:: audioio //| -//| :class:`AudioOut` -- Output an analog audio signal -//| ======================================================== +//| :class:`AudioOut` -- Output an analog audio signal +//| ======================================================== //| -//| AudioOut can be used to output an analog audio signal on a given pin. +//| AudioOut can be used to output an analog audio signal on a given pin.""" //| -//| .. class:: AudioOut(left_channel, *, right_channel=None, quiescent_value=0x8000) +//| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): +//| """Create a AudioOut object associated with the given pin(s). This allows you to +//| play audio signals out on the given pin(s). //| -//| Create a AudioOut object associated with the given pin(s). This allows you to -//| play audio signals out on the given pin(s). +//| :param ~microcontroller.Pin left_channel: The pin to output the left channel to +//| :param ~microcontroller.Pin right_channel: The pin to output the right channel to +//| :param int quiescent_value: The output value when no signal is present. Samples should start +//| and end with this value to prevent audible popping. //| -//| :param ~microcontroller.Pin left_channel: The pin to output the left channel to -//| :param ~microcontroller.Pin right_channel: The pin to output the right channel to -//| :param int quiescent_value: The output value when no signal is present. Samples should start -//| and end with this value to prevent audible popping. +//| Simple 8ksps 440 Hz sin wave:: //| -//| Simple 8ksps 440 Hz sin wave:: +//| import audiocore +//| import audioio +//| import board +//| import array +//| import time +//| import math //| -//| import audiocore -//| import audioio -//| import board -//| import array -//| import time -//| import math +//| # Generate one period of sine wav. +//| length = 8000 // 440 +//| sine_wave = array.array("H", [0] * length) +//| for i in range(length): +//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//| # Generate one period of sine wav. -//| length = 8000 // 440 -//| sine_wave = array.array("H", [0] * length) -//| for i in range(length): -//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//| dac = audioio.AudioOut(board.SPEAKER) +//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//| dac.play(sine_wave, loop=True) +//| time.sleep(1) +//| dac.stop() //| -//| dac = audioio.AudioOut(board.SPEAKER) -//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) -//| dac.play(sine_wave, loop=True) -//| time.sleep(1) -//| dac.stop() +//| Playing a wave file from flash:: //| -//| Playing a wave file from flash:: +//| import board +//| import audioio +//| import digitalio //| -//| import board -//| import audioio -//| import digitalio +//| # Required for CircuitPlayground Express +//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//| speaker_enable.switch_to_output(value=True) //| -//| # Required for CircuitPlayground Express -//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//| speaker_enable.switch_to_output(value=True) -//| -//| data = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audiocore.WaveFile(data) -//| a = audioio.AudioOut(board.A0) -//| -//| print("playing") -//| a.play(wav) -//| while a.playing: -//| pass -//| print("stopped") +//| data = open("cplay-5.1-16bit-16khz.wav", "rb") +//| wav = audiocore.WaveFile(data) +//| a = audioio.AudioOut(board.A0) //| +//| print("playing") +//| a.play(wav) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { @@ -115,10 +115,9 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the AudioOut and releases any hardware resources for reuse. -//| +//| def deinit(self, ) -> Any: +//| """Deinitialises the AudioOut and releases any hardware resources for reuse.""" +//| ... STATIC mp_obj_t audioio_audioout_deinit(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_audioout_deinit(self); @@ -131,17 +130,15 @@ STATIC void check_for_deinit(audioio_audioout_obj_t *self) { raise_deinited_error(); } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_audioout_deinit(args[0]); @@ -150,17 +147,16 @@ STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *arg STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, audioio_audioout_obj___exit__); -//| .. method:: play(sample, *, loop=False) +//| def play(self, sample: Any, *, loop: Any = False) -> Any: +//| """Plays the sample once when loop=False and continuously when loop=True. +//| Does not block. Use `playing` to block. //| -//| Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. -//| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. -//| -//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output -//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit -//| DAC that ignores the lowest 6 bits when playing 16 bit samples. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| +//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output +//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit +//| DAC that ignores the lowest 6 bits when playing 16 bit samples.""" +//| ... STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -179,10 +175,9 @@ STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_arg } MP_DEFINE_CONST_FUN_OBJ_KW(audioio_audioout_play_obj, 1, audioio_audioout_obj_play); -//| .. method:: stop() -//| -//| Stops playback and resets to the start of the sample. -//| +//| def stop(self, ) -> Any: +//| """Stops playback and resets to the start of the sample.""" +//| ... STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -191,10 +186,9 @@ STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_stop_obj, audioio_audioout_obj_stop); -//| .. attribute:: playing -//| -//| True when an audio sample is being output even if `paused`. (read-only) -//| +//| playing: Any = +//| """True when an audio sample is being output even if `paused`. (read-only)""" +//| ... 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); check_for_deinit(self); @@ -209,10 +203,9 @@ const mp_obj_property_t audioio_audioout_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: pause() -//| -//| Stops playback temporarily while remembering the position. Use `resume` to resume playback. -//| +//| def pause(self, ) -> Any: +//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" +//| ... STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -225,10 +218,9 @@ STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_pause_obj, audioio_audioout_obj_pause); -//| .. method:: resume() -//| -//| Resumes sample playback after :py:func:`pause`. -//| +//| def resume(self, ) -> Any: +//| """Resumes sample playback after :py:func:`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); check_for_deinit(self); @@ -241,10 +233,9 @@ STATIC mp_obj_t audioio_audioout_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_resume_obj, audioio_audioout_obj_resume); -//| .. attribute:: paused -//| -//| True when playback is paused. (read-only) -//| +//| paused: Any = +//| """True when playback is paused. (read-only)""" +//| ... 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); check_for_deinit(self); From 8330471068c4cba89802c2b0b9a91a60e656c12e Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 27 Apr 2020 17:20:40 -0400 Subject: [PATCH 015/216] Added inline pyi to audiomixer --- shared-bindings/audiomixer/Mixer.c | 141 +++++++++++------------- shared-bindings/audiomixer/MixerVoice.c | 49 ++++---- 2 files changed, 90 insertions(+), 100 deletions(-) diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 03ffb9373b..1949f2addd 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -38,50 +38,50 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audiomixer +//|class Mixer: +//| """.. currentmodule:: audiomixer //| -//| :class:`Mixer` -- Mixes one or more audio samples together -//| =========================================================== +//| :class:`Mixer` -- Mixes one or more audio samples together +//| =========================================================== //| -//| Mixer mixes multiple samples into one sample. +//| Mixer mixes multiple samples into one sample.""" //| -//| .. class:: Mixer(voice_count=2, buffer_size=1024, channel_count=2, bits_per_sample=16, samples_signed=True, sample_rate=8000) +//| def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000): +//| """Create a Mixer object that can mix multiple channels with the same sample rate. +//| Samples are accessed and controlled with the mixer's `audiomixer.MixerVoice` objects. //| -//| Create a Mixer object that can mix multiple channels with the same sample rate. -//| Samples are accessed and controlled with the mixer's `audiomixer.MixerVoice` objects. +//| :param int voice_count: The maximum number of voices to mix +//| :param int buffer_size: The total size in bytes of the buffers to mix into +//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo. +//| :param int bits_per_sample: The bits per sample of the samples being played +//| :param bool samples_signed: Samples are signed (True) or unsigned (False) +//| :param int sample_rate: The sample rate to be used for all samples //| -//| :param int voice_count: The maximum number of voices to mix -//| :param int buffer_size: The total size in bytes of the buffers to mix into -//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo. -//| :param int bits_per_sample: The bits per sample of the samples being played -//| :param bool samples_signed: Samples are signed (True) or unsigned (False) -//| :param int sample_rate: The sample rate to be used for all samples +//| Playing a wave file from flash:: //| -//| Playing a wave file from flash:: +//| import board +//| import audioio +//| import audiocore +//| import audiomixer +//| import digitalio //| -//| import board -//| import audioio -//| import audiocore -//| import audiomixer -//| import digitalio -//| -//| a = audioio.AudioOut(board.A0) -//| music = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) -//| drum = audiocore.WaveFile(open("drum.wav", "rb")) -//| mixer = audiomixer.Mixer(voice_count=2, sample_rate=16000, channel_count=1, -//| bits_per_sample=16, samples_signed=True) -//| -//| print("playing") -//| # Have AudioOut play our Mixer source -//| a.play(mixer) -//| # Play the first sample voice -//| mixer.voice[0].play(music) -//| while mixer.playing: -//| # Play the second sample voice -//| mixer.voice[1].play(drum) -//| time.sleep(1) -//| print("stopped") +//| a = audioio.AudioOut(board.A0) +//| music = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) +//| drum = audiocore.WaveFile(open("drum.wav", "rb")) +//| mixer = audiomixer.Mixer(voice_count=2, sample_rate=16000, channel_count=1, +//| bits_per_sample=16, samples_signed=True) //| +//| print("playing") +//| # Have AudioOut play our Mixer source +//| a.play(mixer) +//| # Play the first sample voice +//| mixer.voice[0].play(music) +//| while mixer.playing: +//| # Play the second sample voice +//| mixer.voice[1].play(drum) +//| time.sleep(1) +//| print("stopped")""" +//| ... STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice_count, ARG_buffer_size, ARG_channel_count, ARG_bits_per_sample, ARG_samples_signed, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -125,10 +125,9 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the Mixer and releases any hardware resources for reuse. -//| +//| def deinit(self, ) -> Any: +//| """Deinitialises the Mixer and releases any hardware resources for reuse.""" +//| ... STATIC mp_obj_t audiomixer_mixer_deinit(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiomixer_mixer_deinit(self); @@ -142,17 +141,15 @@ STATIC void check_for_deinit(audiomixer_mixer_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiomixer_mixer_deinit(args[0]); @@ -160,10 +157,9 @@ STATIC mp_obj_t audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomixer_mixer___exit___obj, 4, 4, audiomixer_mixer_obj___exit__); -//| .. attribute:: playing -//| -//| True when any voice is being output. (read-only) -//| +//| playing: Any = +//| """True when any voice is being output. (read-only)""" +//| ... STATIC mp_obj_t audiomixer_mixer_obj_get_playing(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -178,10 +174,9 @@ const mp_obj_property_t audiomixer_mixer_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: sample_rate -//| -//| 32 bit value that dictates how quickly samples are played in Hertz (cycles per second). -//| +//| sample_rate: Any = +//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second).""" +//| ... STATIC mp_obj_t audiomixer_mixer_obj_get_sample_rate(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -196,14 +191,14 @@ const mp_obj_property_t audiomixer_mixer_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: voice +//| voice: Any = +//| """A tuple of the mixer's `audiomixer.MixerVoice` object(s). //| -//| A tuple of the mixer's `audiomixer.MixerVoice` object(s). +//| .. code-block:: python //| -//| .. code-block:: python -//| -//| >>> mixer.voice -//| (,) +//| >>> mixer.voice +//| (,)""" +//| ... STATIC mp_obj_t audiomixer_mixer_obj_get_voice(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -218,15 +213,14 @@ const mp_obj_property_t audiomixer_mixer_voice_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: play(sample, *, voice=0, loop=False) +//| def play(self, sample: Any, *, voice: Any = 0, loop: Any = False) -> Any: +//| """Plays the sample once when loop=False and continuously when loop=True. +//| Does not block. Use `playing` to block. //| -//| Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. -//| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. -//| -//| The sample must match the Mixer's encoding settings given in the constructor. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| +//| The sample must match the Mixer's encoding settings given in the constructor.""" +//| ... STATIC mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_voice, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -251,10 +245,9 @@ STATIC mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_arg } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixer_play_obj, 1, audiomixer_mixer_obj_play); -//| .. method:: stop_voice(voice=0) -//| -//| Stops playback of the sample on the given voice. -//| +//| def stop_voice(self, voice: Any = 0) -> Any: +//| """Stops playback of the sample on the given voice.""" +//| ... STATIC mp_obj_t audiomixer_mixer_obj_stop_voice(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index 188f76f579..e6c750bafa 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -37,17 +37,18 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audiomixer +//|class MixerVoice: +//| """.. currentmodule:: audiomixer //| -//| :class:`MixerVoice` -- Voice objects used with Mixer -//| ===================================================== +//| :class:`MixerVoice` -- Voice objects used with Mixer +//| ===================================================== //| -//| Used to access and control samples with `audiomixer.Mixer`. +//| Used to access and control samples with `audiomixer.Mixer`.""" //| -//| .. class:: MixerVoice() -//| -//| MixerVoice instance object(s) created by `audiomixer.Mixer`. +//| def __init__(self, ): //| +//| """MixerVoice instance object(s) created by `audiomixer.Mixer`.""" +//| ... // TODO: support mono or stereo voices STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { audiomixer_mixervoice_obj_t *self = m_new_obj(audiomixer_mixervoice_obj_t); @@ -58,15 +59,14 @@ STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t return MP_OBJ_FROM_PTR(self); } -//| .. method:: play(sample, *, loop=False) +//| def play(self, sample: Any, *, loop: Any = False) -> Any: +//| """Plays the sample once when ``loop=False``, and continuously when ``loop=True``. +//| Does not block. Use `playing` to block. //| -//| Plays the sample once when ``loop=False``, and continuously when ``loop=True``. -//| Does not block. Use `playing` to block. -//| -//| Sample must be an `audiocore.WaveFile`, `audiomixer.Mixer` or `audiocore.RawSample`. -//| -//| The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor. +//| Sample must be an `audiocore.WaveFile`, `audiomixer.Mixer` or `audiocore.RawSample`. //| +//| The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor.""" +//| ... STATIC mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -83,10 +83,9 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *po } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_play_obj, 1, audiomixer_mixervoice_obj_play); -//| .. method:: stop() -//| -//| Stops playback of the sample on this voice. -//| +//| def stop(self, ) -> Any: +//| """Stops playback of the sample on this voice.""" +//| ... STATIC mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { @@ -102,10 +101,9 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *po } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_stop_obj, 1, audiomixer_mixervoice_obj_stop); -//| .. attribute:: level() -//| -//| The volume level of a voice, as a floating point number between 0 and 1. -//| +//| level(): Any = +//| """The volume level of a voice, as a floating point number between 0 and 1.""" +//| ... STATIC mp_obj_t audiomixer_mixervoice_obj_get_level(mp_obj_t self_in) { return mp_obj_new_float(common_hal_audiomixer_mixervoice_get_level(self_in)); } @@ -139,10 +137,9 @@ const mp_obj_property_t audiomixer_mixervoice_level_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: playing -//| -//| True when this voice is being output. (read-only) -//| +//| playing: Any = +//| """True when this voice is being output. (read-only)""" +//| ... STATIC mp_obj_t audiomixer_mixervoice_obj_get_playing(mp_obj_t self_in) { audiomixer_mixervoice_obj_t *self = MP_OBJ_TO_PTR(self_in); From 829da5c12732337cc72f2c089bc72cb437a02e0c Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 27 Apr 2020 17:29:50 -0400 Subject: [PATCH 016/216] Added inline pyi to audiomp3 --- shared-bindings/audiomp3/MP3Decoder.c | 113 ++++++++++++-------------- 1 file changed, 53 insertions(+), 60 deletions(-) diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 2240422127..0bb2c88292 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -34,42 +34,42 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audiomp3 +//|class MP3: +//| """.. currentmodule:: audiomp3 //| -//| :class:`MP3Decoder` -- Load a mp3 file for audio playback -//| ========================================================= +//| :class:`MP3Decoder` -- Load a mp3 file for audio playback +//| ========================================================= //| -//| An object that decodes MP3 files for playback on an audio device. +//| An object that decodes MP3 files for playback on an audio device.""" //| -//| .. class:: MP3(file[, buffer]) +//| def __init__(self, file: typing.BinaryIO, buffer: bytearray): +//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. //| -//| Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. -//| -//| :param typing.BinaryIO file: Already opened mp3 file -//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. +//| :param typing.BinaryIO file: Already opened mp3 file +//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. //| //| -//| Playing a mp3 file from flash:: +//| Playing a mp3 file from flash:: //| -//| import board -//| import audiomp3 -//| import audioio -//| import digitalio +//| import board +//| import audiomp3 +//| import audioio +//| import digitalio //| -//| # Required for CircuitPlayground Express -//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//| speaker_enable.switch_to_output(value=True) +//| # Required for CircuitPlayground Express +//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//| speaker_enable.switch_to_output(value=True) //| -//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb") -//| mp3 = audiomp3.MP3Decoder(data) -//| a = audioio.AudioOut(board.A0) -//| -//| print("playing") -//| a.play(mp3) -//| while a.playing: -//| pass -//| print("stopped") +//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb") +//| mp3 = audiomp3.MP3Decoder(data) +//| a = audioio.AudioOut(board.A0) //| +//| print("playing") +//| a.play(mp3) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 2, false); @@ -92,10 +92,9 @@ STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the MP3 and releases all memory resources for reuse. -//| +//| def deinit(self, ) -> Any: +//| """Deinitialises the MP3 and releases all memory resources for reuse.""" +//| ... STATIC mp_obj_t audiomp3_mp3file_deinit(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiomp3_mp3file_deinit(self); @@ -109,17 +108,16 @@ STATIC void check_for_deinit(audiomp3_mp3file_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. -//| +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: //| +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiomp3_mp3file_deinit(args[0]); @@ -127,10 +125,9 @@ STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__); -//| .. attribute:: file -//| -//| File to play back. -//| +//| file: Any = +//| """File to play back.""" +//| ... STATIC mp_obj_t audiomp3_mp3file_obj_get_file(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -158,12 +155,11 @@ const mp_obj_property_t audiomp3_mp3file_file_obj = { -//| .. attribute:: sample_rate -//| -//| 32 bit value that dictates how quickly samples are loaded into the DAC -//| in Hertz (cycles per second). When the sample is looped, this can change -//| the pitch output without changing the underlying sample. -//| +//| sample_rate: Any = +//| """32 bit value that dictates how quickly samples are loaded into the DAC +//| in Hertz (cycles per second). When the sample is looped, this can change +//| the pitch output without changing the underlying sample.""" +//| ... STATIC mp_obj_t audiomp3_mp3file_obj_get_sample_rate(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -186,10 +182,9 @@ const mp_obj_property_t audiomp3_mp3file_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: bits_per_sample -//| -//| Bits per sample. (read only) -//| +//| bits_per_sample: Any = +//| """Bits per sample. (read only)""" +//| ... STATIC mp_obj_t audiomp3_mp3file_obj_get_bits_per_sample(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -204,10 +199,9 @@ const mp_obj_property_t audiomp3_mp3file_bits_per_sample_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: channel_count -//| -//| Number of audio channels. (read only) -//| +//| channel_count: Any = +//| """Number of audio channels. (read only)""" +//| ... STATIC mp_obj_t audiomp3_mp3file_obj_get_channel_count(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -222,10 +216,9 @@ const mp_obj_property_t audiomp3_mp3file_channel_count_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: rms_level -//| -//| The RMS audio level of a recently played moment of audio. (read only) -//| +//| rms_level: Any = +//| """The RMS audio level of a recently played moment of audio. (read only)""" +//| ... STATIC mp_obj_t audiomp3_mp3file_obj_get_rms_level(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); From 46713482f49690f96e55f872c087d245b4ce0489 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 27 Apr 2020 14:36:14 -0700 Subject: [PATCH 017/216] Add verification script --- Makefile | 4 ++-- tools/extract_pyi.py | 46 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 tools/extract_pyi.py diff --git a/Makefile b/Makefile index 5e949cd40f..aa8fc26d1f 100644 --- a/Makefile +++ b/Makefile @@ -213,8 +213,8 @@ check-translate: locale/circuitpython.pot $(wildcard locale/*.po) $(PYTHON) tools/check_translations.py $^ stubs: - rst2pyi $(VALIDATE) shared-bindings/ $(STUBDIR) - python setup.py sdist + python tools/extract_pyi.py shared-bindings/ $(STUBDIR) + #python setup.py sdist update-frozen-libraries: @echo "Updating all frozen libraries to latest tagged version." diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py new file mode 100644 index 0000000000..c7f3e4604e --- /dev/null +++ b/tools/extract_pyi.py @@ -0,0 +1,46 @@ +import os +import sys +import astroid +import traceback + +top_level = sys.argv[1].strip("/") +stub_directory = sys.argv[2] + +if top_level.count("/") == 1: + top_level, module = top_level.split("/") + modules = [module] +else: + modules = os.listdir(top_level) + modules = sorted(modules) + +ok = 0 +total = 0 +for module in modules: + module_path = os.path.join(top_level, module) + if not os.path.isdir(module_path): + continue + pyi_lines = [] + for class_file in os.listdir(module_path): + class_path = os.path.join(module_path, class_file) + with open(class_path, "r") as f: + for line in f: + if line.startswith("//| "): + pyi_lines.append(line[4:]) + + stub_filename = os.path.join(stub_directory, module + ".pyi") + print(stub_filename) + stub_contents = "".join(pyi_lines) + with open(stub_filename, "w") as f: + f.write(stub_contents) + + # Validate that the module is a parseable stub. + total += 1 + try: + astroid.parse(stub_contents) + ok += 1 + except astroid.exceptions.AstroidSyntaxError as e: + e = e.__cause__ + traceback.print_exception(type(e), e, e.__traceback__) + print() + +print(f"{ok} ok out of {total}") From 6c4decd4e280d30c6b45ed74ac3e0c9b12194cd9 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Tue, 28 Apr 2020 11:51:07 -0700 Subject: [PATCH 018/216] decoupling chip specific functions from EXTERNAL_FLASH_QSPI_SINGLE --- ports/atmel-samd/Makefile | 2 +- .../boards/pycubed/mpconfigboard.mk | 3 +- .../boards/pycubed_mram/mpconfigboard.h | 6 +- .../boards/pycubed_mram/mpconfigboard.mk | 7 +- ports/atmel-samd/boards/pycubed_mram/pins.c | 8 +- ports/atmel-samd/supervisor/qspi_flash.c | 2 +- supervisor/shared/external_flash/devices.h | 36 +++--- .../shared/external_flash/external_flash.c | 122 +++++++++++------- 8 files changed, 107 insertions(+), 79 deletions(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 7a626dff71..d6b3a543ac 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -53,7 +53,7 @@ include $(TOP)/supervisor/supervisor.mk # Include make rules and variables common across CircuitPython builds. include $(TOP)/py/circuitpy_defns.mk -CROSS_COMPILE = arm-none-eabi- +CROSS_COMPILE = ~/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- HAL_DIR=hal/$(MCU_SERIES) diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk index adaeecb893..b7b8073ab9 100644 --- a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x04D8 USB_PID = 0xEC44 USB_PRODUCT = "PyCubed" @@ -12,6 +11,8 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = W25Q80DV LONGINT_IMPL = MPZ +CIRCUITPY_DRIVE_LABEL = "PYCUBED" + # Not needed. CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_DISPLAYIO = 0 diff --git a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h index aca9e3c368..e2a733025d 100644 --- a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h +++ b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h @@ -1,4 +1,3 @@ - #define MICROPY_HW_BOARD_NAME "PyCubedv04-MRAM" #define MICROPY_HW_MCU_NAME "samd51j19" #define CIRCUITPY_MCU_FAMILY samd51 @@ -11,8 +10,12 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) +#define SPI_FLASH_WP_PIN &pin_PA10 +#define SPI_FLASH_HOLD_PIN &pin_PA11 + // External flash MR2xH40 MRAM #define EXTERNAL_FLASH_QSPI_SINGLE +#define EXTERNAL_FLASH_NO_JEDEC #define AUTORESET_DELAY_MS 500 @@ -34,4 +37,3 @@ #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 - diff --git a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk index ef92b4db56..f49bb3fef0 100644 --- a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x04D8 USB_PID = 0xEC44 USB_PRODUCT = "PyCubed" @@ -12,13 +11,17 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = MR2xH40 LONGINT_IMPL = MPZ +CIRCUITPY_DRIVE_LABEL = "PYCUBED" + # Not needed. CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_GAMEPAD = 0 +CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_PS2IO = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD \ No newline at end of file +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD diff --git a/ports/atmel-samd/boards/pycubed_mram/pins.c b/ports/atmel-samd/boards/pycubed_mram/pins.c index 4c97f58a80..e494fb54bf 100644 --- a/ports/atmel-samd/boards/pycubed_mram/pins.c +++ b/ports/atmel-samd/boards/pycubed_mram/pins.c @@ -40,16 +40,16 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_EN_GPS), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB02) }, { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB03) }, - + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB12) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB13) }, { MP_ROM_QSTR(MP_QSTR_WDT_WDI), MP_ROM_PTR(&pin_PA23) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA21) }, - + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - + }; -MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); \ No newline at end of file +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/supervisor/qspi_flash.c b/ports/atmel-samd/supervisor/qspi_flash.c index fc538f95f3..aaed2a0eee 100644 --- a/ports/atmel-samd/supervisor/qspi_flash.c +++ b/ports/atmel-samd/supervisor/qspi_flash.c @@ -169,7 +169,7 @@ bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t length) { #ifdef EXTERNAL_FLASH_QSPI_SINGLE QSPI->INSTRCTRL.bit.INSTR = CMD_READ_DATA; uint32_t mode = QSPI_INSTRFRAME_WIDTH_SINGLE_BIT_SPI; - #elif defined EXTERNAL_FLASH_QSPI_DUAL + #elif defined(EXTERNAL_FLASH_QSPI_DUAL) QSPI->INSTRCTRL.bit.INSTR = CMD_DUAL_READ; uint32_t mode = QSPI_INSTRFRAME_WIDTH_DUAL_OUTPUT; #else diff --git a/supervisor/shared/external_flash/devices.h b/supervisor/shared/external_flash/devices.h index e148db9851..08e38ed912 100644 --- a/supervisor/shared/external_flash/devices.h +++ b/supervisor/shared/external_flash/devices.h @@ -64,6 +64,15 @@ typedef struct { // True when the status register is a single byte. This implies the Quad Enable bit is in the // first byte and the Read Status Register 2 command (0x35) is unsupported. bool single_status_byte: 1; + + // Does not support using a ready bit within the status register + bool no_ready_bit: 1; + + // Does not support the erase command (0x20) + bool no_erase_cmd: 1; + + // Device does not have a reset command + bool no_reset_cmd: 1; } external_flash_device; // Settings for the Adesto Tech AT25DF081A 1MiB SPI flash. It's on the SAMD21 @@ -426,14 +435,15 @@ typedef struct { .single_status_byte = false, \ } -// Everspin MRAM +// Settings for the Everspin MR20H40 / MR25H40 magnetic non-volatile RAM +// Datasheet: https://www.everspin.com/supportdocs/MR25H40CDFR #define MR2xH40 {\ .total_size = (1 << 22), /* 4 MiB */ \ .start_up_time_us = 10000, \ .manufacturer_id = 0xef, /*no JDEC*/ \ .memory_type = 0x40, /*no JDEC*/ \ .capacity = 0x14, /*no JDEC*/ \ - .max_clock_speed_mhz = 40, \ + .max_clock_speed_mhz = 10, \ .quad_enable_bit_mask = 0x00, \ .has_sector_protection = false, \ .supports_fast_read = false, \ @@ -441,6 +451,9 @@ typedef struct { .supports_qspi_writes = false, \ .write_status_register_split = false, \ .single_status_byte = true, \ + .no_ready_bit = true, \ + .no_erase_cmd = true, \ + .no_reset_cmd = true, \ } // Settings for the Macronix MX25L1606 2MiB SPI flash. @@ -498,25 +511,6 @@ typedef struct { .single_status_byte = true, \ } -// Settings for the Macronix MX25R1635F 8MiB SPI flash. -// Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7595/MX25R1635F,%20Wide%20Range,%2016Mb,%20v1.6.pdf -// In low power mode, quad operations can only run at 8 MHz. -#define MX25R1635F {\ - .total_size = (1 << 21), /* 2 MiB */ \ - .start_up_time_us = 800, \ - .manufacturer_id = 0xc2, \ - .memory_type = 0x28, \ - .capacity = 0x18, \ - .max_clock_speed_mhz = 33, /* 8 mhz for dual/quad */ \ - .quad_enable_bit_mask = 0x80, \ - .has_sector_protection = false, \ - .supports_fast_read = true, \ - .supports_qspi = true, \ - .supports_qspi_writes = true, \ - .write_status_register_split = false, \ - .single_status_byte = true, \ -} - // Settings for the Macronix MX25L51245G 64MiB SPI flash. // Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7437/MX25L51245G,%203V,%20512Mb,%20v1.6.pdf #define MX25L51245G {\ diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 7f5496d3ac..6c14da4107 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -59,16 +59,16 @@ static supervisor_allocation* supervisor_cache = NULL; static bool wait_for_flash_ready(void) { bool ok = true; // Both the write enable and write in progress bits should be low. - #ifdef EXTERNAL_FLASH_QSPI_SINGLE + if (flash_device->no_ready_bit){ // For NVM without a ready bit in status register return ok; - #else + } else { uint8_t read_status_response[1] = {0x00}; do { ok = spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); } while (ok && (read_status_response[0] & 0x3) != 0); return ok; - #endif + } } // Turn on the write enable bit so we can program and erase the flash. @@ -96,7 +96,8 @@ static bool write_flash(uint32_t address, const uint8_t* data, uint32_t data_len } // Don't bother writing if the data is all 1s. Thats equivalent to the flash // state after an erase. - #ifndef EXTERNAL_FLASH_QSPI_SINGLE + if (!flash_device->no_erase_cmd){ + // Only do this if the device has an erase command bool all_ones = true; for (uint16_t i = 0; i < data_length; i++) { if (data[i] != 0xff) { @@ -107,7 +108,7 @@ static bool write_flash(uint32_t address, const uint8_t* data, uint32_t data_len if (all_ones) { return true; } - #endif + } for (uint32_t bytes_written = 0; bytes_written < data_length; @@ -127,29 +128,34 @@ static bool write_flash(uint32_t address, const uint8_t* data, uint32_t data_len static bool page_erased(uint32_t sector_address) { // Check the first few bytes to catch the common case where there is data // without using a bunch of memory. - uint8_t short_buffer[4]; - if (read_flash(sector_address, short_buffer, 4)) { - for (uint16_t i = 0; i < 4; i++) { - if (short_buffer[i] != 0xff) { - return false; - } - } + if (flash_device->no_erase_cmd){ + // skip this if device doesn't have an erase command. + return true; } else { - return false; - } + uint8_t short_buffer[4]; + if (read_flash(sector_address, short_buffer, 4)) { + for (uint16_t i = 0; i < 4; i++) { + if (short_buffer[i] != 0xff) { + return false; + } + } + } else { + return false; + } - // Now check the full length. - uint8_t full_buffer[FILESYSTEM_BLOCK_SIZE]; - if (read_flash(sector_address, full_buffer, FILESYSTEM_BLOCK_SIZE)) { - for (uint16_t i = 0; i < FILESYSTEM_BLOCK_SIZE; i++) { - if (short_buffer[i] != 0xff) { - return false; + // Now check the full length. + uint8_t full_buffer[FILESYSTEM_BLOCK_SIZE]; + if (read_flash(sector_address, full_buffer, FILESYSTEM_BLOCK_SIZE)) { + for (uint16_t i = 0; i < FILESYSTEM_BLOCK_SIZE; i++) { + if (short_buffer[i] != 0xff) { + return false; + } } + } else { + return false; } - } else { - return false; + return true; } - return true; } // Erases the given sector. Make sure you copied all of the data out of it you @@ -157,12 +163,20 @@ static bool page_erased(uint32_t sector_address) { static bool erase_sector(uint32_t sector_address) { // Before we erase the sector we need to wait for any writes to finish and // and then enable the write again. - if (!wait_for_flash_ready() || !write_enable()) { - return false; + if (flash_device->no_erase_cmd){ + // skip this if device doesn't have an erase command. + return true; + } else { + if (!wait_for_flash_ready() || !write_enable()) { + return false; + } + if (flash_device->no_erase_cmd) { + return true; + } else { + spi_flash_sector_command(CMD_SECTOR_ERASE, sector_address); + return true; + } } - - spi_flash_sector_command(CMD_SECTOR_ERASE, sector_address); - return true; } // Sector is really 24 bits. @@ -198,20 +212,31 @@ void supervisor_flash_init(void) { spi_flash_init(); -#ifdef EXTERNAL_FLASH_QSPI_SINGLE - // For NVM that don't have JEDEC response - spi_flash_command(CMD_WAKE); - for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { - const external_flash_device* possible_device = &possible_devices[i]; +#ifdef EXTERNAL_FLASH_NO_JEDEC + // For NVM that don't have JEDEC response + spi_flash_command(CMD_WAKE); + for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { + const external_flash_device* possible_device = &possible_devices[i]; + flash_device = possible_device; + break; + } +#else + // The response will be 0xff if the flash needs more time to start up. + uint8_t jedec_id_response[3] = {0xff, 0xff, 0xff}; + while (jedec_id_response[0] == 0xff) { + spi_flash_read_command(CMD_READ_JEDEC_ID, jedec_id_response, 3); + } + + for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { + const external_flash_device* possible_device = &possible_devices[i]; + if (jedec_id_response[0] == possible_device->manufacturer_id && + jedec_id_response[1] == possible_device->memory_type && + jedec_id_response[2] == possible_device->capacity) { flash_device = possible_device; break; + } } -#else - // The response will be 0xff if the flash needs more time to start up. - uint8_t jedec_id_response[3] = {0xff, 0xff, 0xff}; - while (jedec_id_response[0] == 0xff) { - spi_flash_read_command(CMD_READ_JEDEC_ID, jedec_id_response, 3); - } +#endif for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { const external_flash_device* possible_device = &possible_devices[i]; @@ -227,20 +252,23 @@ void supervisor_flash_init(void) { return; } - // We don't know what state the flash is in so wait for any remaining writes and then reset. - uint8_t read_status_response[1] = {0x00}; - // The write in progress bit should be low. - do { - spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); - } while ((read_status_response[0] & 0x1) != 0); -#ifndef EXTERNAL_FLASH_QSPI_SINGLE + // We don't know what state the flash is in so wait for any remaining writes and then reset. + uint8_t read_status_response[1] = {0x00}; + // The write in progress bit should be low. + do { + spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); + } while ((read_status_response[0] & 0x1) != 0); + + if (!(flash_device->no_reset_cmd)){ // The suspended write/erase bit should be low. do { spi_flash_read_command(CMD_READ_STATUS2, read_status_response, 1); } while ((read_status_response[0] & 0x80) != 0); + } else { spi_flash_command(CMD_ENABLE_RESET); spi_flash_command(CMD_RESET); -#endif + } + // Wait 30us for the reset common_hal_mcu_delay_us(30); From b2de5a9df9f32349983d02d8e99c334151dc6119 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Tue, 28 Apr 2020 12:24:10 -0700 Subject: [PATCH 019/216] fixing my goofy gcc-arm local stuff --- ports/atmel-samd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index d6b3a543ac..7a626dff71 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -53,7 +53,7 @@ include $(TOP)/supervisor/supervisor.mk # Include make rules and variables common across CircuitPython builds. include $(TOP)/py/circuitpy_defns.mk -CROSS_COMPILE = ~/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- +CROSS_COMPILE = arm-none-eabi- HAL_DIR=hal/$(MCU_SERIES) From 724dcda3ec8319e961fb032e4bef2524c9bf6948 Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 28 Apr 2020 18:39:58 -0400 Subject: [PATCH 020/216] Fixed whitespace in busio --- shared-bindings/busio/I2C.c | 178 ++++++++++++++-------------- shared-bindings/busio/OneWire.c | 86 +++++++------- shared-bindings/busio/SPI.c | 198 ++++++++++++++++---------------- shared-bindings/busio/UART.c | 160 +++++++++++++------------- 4 files changed, 311 insertions(+), 311 deletions(-) diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 0cd392f9a8..8b71be085d 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -37,32 +37,32 @@ #include "supervisor/shared/translate.h" //|class I2C: -//| """.. currentmodule:: busio +//|""".. currentmodule:: busio //| -//| :class:`I2C` --- Two wire serial protocol -//| ------------------------------------------""" -//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255): -//| """I2C is a two-wire protocol for communicating between devices. At the -//| physical level it consists of 2 wires: SCL and SDA, the clock and data -//| lines respectively. +//|:class:`I2C` --- Two wire serial protocol +//|------------------------------------------""" +//|def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255): +//|"""I2C is a two-wire protocol for communicating between devices. At the +//|physical level it consists of 2 wires: SCL and SDA, the clock and data +//|lines respectively. //| -//| .. seealso:: Using this class directly requires careful lock management. -//| Instead, use :class:`~adafruit_bus_device.i2c_device.I2CDevice` to -//| manage locks. +//|.. seealso:: Using this class directly requires careful lock management. +//|Instead, use :class:`~adafruit_bus_device.i2c_device.I2CDevice` to +//|manage locks. //| -//| .. seealso:: Using this class to directly read registers requires manual -//| bit unpacking. Instead, use an existing driver or make one with -//| :ref:`Register ` data descriptors. +//|.. seealso:: Using this class to directly read registers requires manual +//|bit unpacking. Instead, use an existing driver or make one with +//|:ref:`Register ` data descriptors. //| -//| :param ~microcontroller.Pin scl: The clock pin -//| :param ~microcontroller.Pin sda: The data pin -//| :param int frequency: The clock frequency in Hertz -//| :param int timeout: The maximum clock stretching timeut - (used only for bitbangio.I2C; ignored for busio.I2C) +//|:param ~microcontroller.Pin scl: The clock pin +//|:param ~microcontroller.Pin sda: The data pin +//|:param int frequency: The clock frequency in Hertz +//|:param int timeout: The maximum clock stretching timeut - (used only for bitbangio.I2C; ignored for busio.I2C) //| -//| .. note:: On the nRF52840, only one I2C object may be created, -//| except on the Circuit Playground Bluefruit, which allows two, -//| one for the onboard accelerometer, and one for offboard use.""" -//| ... +//|.. note:: On the nRF52840, only one I2C object may be created, +//|except on the Circuit Playground Bluefruit, which allows two, +//|one for the onboard accelerometer, and one for offboard use.""" +//|... STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t); self->base.type = &busio_i2c_type; @@ -83,9 +83,9 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con return (mp_obj_t)self; } -//| def deinit(self, ) -> Any: -//| """Releases control of the underlying hardware so other classes can use it.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Releases control of the underlying hardware so other classes can use it.""" +//|... STATIC mp_obj_t busio_i2c_obj_deinit(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_i2c_deinit(self); @@ -99,15 +99,15 @@ STATIC void check_for_deinit(busio_i2c_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used in Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used in Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware on context exit. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware on context exit. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_i2c_deinit(args[0]); @@ -122,13 +122,13 @@ static void check_lock(busio_i2c_obj_t *self) { } } -//| def scan(self, ) -> Any: -//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a -//| list of those that respond. +//|def scan(self, ) -> Any: +//|"""Scan all I2C addresses between 0x08 and 0x77 inclusive and return a +//|list of those that respond. //| -//| :return: List of device ids on the I2C bus -//| :rtype: list""" -//| ... +//|:return: List of device ids on the I2C bus +//|:rtype: list""" +//|... STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -145,11 +145,11 @@ STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan); -//| def try_lock(self, ) -> Any: -//| """Attempts to grab the I2C lock. Returns True on success. -//| :return: True when lock has been grabbed -//| :rtype: bool""" -//| ... +//|def try_lock(self, ) -> Any: +//|"""Attempts to grab the I2C lock. Returns True on success. +//|:return: True when lock has been grabbed +//|:rtype: bool""" +//|... 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); check_for_deinit(self); @@ -157,9 +157,9 @@ STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock); -//| def unlock(self, ) -> Any: -//| """Releases the I2C lock.""" -//| ... +//|def unlock(self, ) -> Any: +//|"""Releases the I2C 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); check_for_deinit(self); @@ -168,20 +168,20 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); -//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any: -//| """Read into ``buffer`` from the slave specified by ``address``. -//| The number of bytes read will be the length of ``buffer``. -//| At least one byte must be read. +//|def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any: +//|"""Read into ``buffer`` from the slave specified by ``address``. +//|The number of bytes read will be the length of ``buffer``. +//|At least one byte must be read. //| -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buf[start:end]`` will so it saves memory. +//|If ``start`` or ``end`` is provided, then the buffer will be sliced +//|as if ``buffer[start:end]``. This will not cause an allocation like +//|``buf[start:end]`` will so it saves memory. //| -//| :param int address: 7-bit device address -//| :param bytearray buffer: buffer to write into -//| :param int start: Index to start writing at -//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" -//| ... +//|:param int address: 7-bit device address +//|:param bytearray buffer: buffer to write into +//|:param int start: Index to start writing at +//|:param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//|... // Shared arg parsing for readfrom_into and writeto_then_readfrom. STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; @@ -219,26 +219,26 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, } MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into); -//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any: -//| """Write the bytes from ``buffer`` to the slave specified by ``address``. -//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be -//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and -//| repeated start before a read. +//|def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any: +//|"""Write the bytes from ``buffer`` to the slave specified by ``address``. +//|Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be +//|removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and +//|repeated start before a read. //| -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. +//|If ``start`` or ``end`` is provided, then the buffer will be sliced +//|as if ``buffer[start:end]``. This will not cause an allocation like +//|``buffer[start:end]`` will so it saves memory. //| -//| Writing a buffer or slice of length zero is permitted, as it can be used -//| to poll for the existence of a device. +//|Writing a buffer or slice of length zero is permitted, as it can be used +//|to poll for the existence of a device. //| -//| :param int address: 7-bit device address -//| :param bytearray buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param bool stop: If true, output an I2C stop condition after the buffer is written. -//| Deprecated. Will be removed in 6.x and act as stop=True.""" -//| ... +//|:param int address: 7-bit device address +//|:param bytearray buffer: buffer containing the bytes to write +//|:param int start: Index to start writing from +//|:param int end: Index to read up to but not include. Defaults to ``len(buffer)`` +//|:param bool stop: If true, output an I2C stop condition after the buffer is written. +//|Deprecated. Will be removed in 6.x and act as stop=True.""" +//|... // Shared arg parsing for writeto and writeto_then_readfrom. STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) { // get the buffer to write the data from @@ -277,23 +277,23 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); -//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any: -//| """Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop -//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and -//| ``in_buffer`` can be the same buffer because they are used sequentially. +//|def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any: +//|"""Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop +//|bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and +//|``in_buffer`` can be the same buffer because they are used sequentially. //| -//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` -//| will so it saves memory. +//|If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced +//|as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` +//|will so it saves memory. //| -//| :param int address: 7-bit device address -//| :param bytearray out_buffer: buffer containing the bytes to write -//| :param bytearray in_buffer: buffer to write into -//| :param int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" -//| ... +//|:param int address: 7-bit device address +//|:param bytearray out_buffer: buffer containing the bytes to write +//|:param bytearray in_buffer: buffer to write into +//|:param int out_start: Index to start writing from +//|:param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` +//|:param int in_start: Index to start writing at +//|:param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//|... STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/busio/OneWire.c b/shared-bindings/busio/OneWire.c index dd4410d468..d6af32bd95 100644 --- a/shared-bindings/busio/OneWire.c +++ b/shared-bindings/busio/OneWire.c @@ -35,35 +35,35 @@ #include "shared-bindings/util.h" //|class OneWire: -//| """.. currentmodule:: busio +//|""".. currentmodule:: busio //| -//| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol -//| =================================================================""" +//|:class:`OneWire` -- Lowest-level of the Maxim OneWire protocol +//|=================================================================""" //| -//| def __init__(self, pin: microcontroller.Pin): -//| """:class:`~busio.OneWire` implements the timing-sensitive foundation of the Maxim -//| (formerly Dallas Semi) OneWire protocol. +//|__init__(self, pin: microcontroller.Pin): +//|""":class:`~busio.OneWire` implements the timing-sensitive foundation of the Maxim +//|(formerly Dallas Semi) OneWire protocol. //| -//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126 +//|Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126 //| -//| .. class:: OneWire(pin) +//|.. class:: OneWire(pin) //| -//| Create a OneWire object associated with the given pin. The object -//| implements the lowest level timing-sensitive bits of the protocol. +//|Create a OneWire object associated with the given pin. The object +//|implements the lowest level timing-sensitive bits of the protocol. //| -//| :param ~microcontroller.Pin pin: Pin connected to the OneWire bus +//|:param ~microcontroller.Pin pin: Pin connected to the OneWire bus //| -//| Read a short series of pulses:: +//|Read a short series of pulses:: //| -//| import busio -//| import board +//|import busio +//|import board //| -//| onewire = busio.OneWire(board.D7) -//| onewire.reset() -//| onewire.write_bit(True) -//| onewire.write_bit(False) -//| print(onewire.read_bit())""" -//| ... +//|onewire = busio.OneWire(board.D7) +//|onewire.reset() +//|onewire.write_bit(True) +//|onewire.write_bit(False) +//|print(onewire.read_bit())""" +//|... STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pin }; static const mp_arg_t allowed_args[] = { @@ -80,9 +80,9 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialize the OneWire bus and release any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialize the OneWire bus and release any hardware resources for reuse.""" +//|... STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_onewire_deinit(self); @@ -96,15 +96,15 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_onewire_deinit(args[0]); @@ -112,12 +112,12 @@ STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__); -//| def reset(self, ) -> Any: -//| """Reset the OneWire bus and read presence +//|def reset(self, ) -> Any: +//|"""Reset the OneWire bus and read presence //| -//| :returns: False when at least one device is present -//| :rtype: bool""" -//| ... +//|:returns: False when at least one device is present +//|:rtype: bool""" +//|... STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -126,12 +126,12 @@ STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset); -//| def read_bit(self, ) -> Any: -//| """Read in a bit +//|def read_bit(self, ) -> Any: +//|"""Read in a bit //| -//| :returns: bit state read -//| :rtype: bool""" -//| ... +//|:returns: bit state read +//|:rtype: bool""" +//|... 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); check_for_deinit(self); @@ -140,9 +140,9 @@ STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit); -//| def write_bit(self, value: Any) -> Any: -//| """Write out a bit based on value.""" -//| ... +//|def write_bit(self, value: Any) -> Any: +//|"""Write out a bit based on value.""" +//|... 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); check_for_deinit(self); diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 1ac9629f80..5643b0d04e 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -42,42 +42,42 @@ //|class SPI: -//| """.. currentmodule:: busio +//|""".. currentmodule:: busio //| -//| `SPI` -- a 3-4 wire serial protocol -//| ----------------------------------------------- +//|`SPI` -- a 3-4 wire serial protocol +//|----------------------------------------------- //| -//| SPI is a serial protocol that has exclusive pins for data in and out of the -//| master. It is typically faster than :py:class:`~busio.I2C` because a -//| separate pin is used to control the active slave rather than a transitted -//| address. This class only manages three of the four SPI lines: `!clock`, -//| `!MOSI`, `!MISO`. Its up to the client to manage the appropriate slave -//| select line. (This is common because multiple slaves can share the `!clock`, -//| `!MOSI` and `!MISO` lines and therefore the hardware.)""" +//|SPI is a serial protocol that has exclusive pins for data in and out of the +//|master. It is typically faster than :py:class:`~busio.I2C` because a +//|separate pin is used to control the active slave rather than a transitted +//|address. This class only manages three of the four SPI lines: `!clock`, +//|`!MOSI`, `!MISO`. Its up to the client to manage the appropriate slave +//|select line. (This is common because multiple slaves can share the `!clock`, +//|`!MOSI` and `!MISO` lines and therefore the hardware.)""" //| -//| def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): +//|def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): //| -//| """Construct an SPI object on the given pins. +//|"""Construct an SPI object on the given pins. //| -//| ..note:: The SPI peripherals allocated in order of desirability, if possible, -//| such as highest speed and not shared use first. For instance, on the nRF52840, -//| there is a single 32MHz SPI peripheral, and multiple 8MHz peripherals, -//| some of which may also be used for I2C. The 32MHz SPI peripheral is returned -//| first, then the exclusive 8MHz SPI peripheral, and finally the shared 8MHz -//| peripherals. +//|..note:: The SPI peripherals allocated in order of desirability, if possible, +//|such as highest speed and not shared use first. For instance, on the nRF52840, +//|there is a single 32MHz SPI peripheral, and multiple 8MHz peripherals, +//|some of which may also be used for I2C. The 32MHz SPI peripheral is returned +//|first, then the exclusive 8MHz SPI peripheral, and finally the shared 8MHz +//|peripherals. //| -//| .. seealso:: Using this class directly requires careful lock management. -//| Instead, use :class:`~adafruit_bus_device.spi_device.SPIDevice` to -//| manage locks. +//|.. seealso:: Using this class directly requires careful lock management. +//|Instead, use :class:`~adafruit_bus_device.spi_device.SPIDevice` to +//|manage locks. //| -//| .. seealso:: Using this class to directly read registers requires manual -//| bit unpacking. Instead, use an existing driver or make one with -//| :ref:`Register ` data descriptors. +//|.. seealso:: Using this class to directly read registers requires manual +//|bit unpacking. Instead, use an existing driver or make one with +//|:ref:`Register ` data descriptors. //| -//| :param ~microcontroller.Pin clock: the pin to use for the clock. -//| :param ~microcontroller.Pin MOSI: the Master Out Slave In pin. -//| :param ~microcontroller.Pin MISO: the Master In Slave Out pin.""" -//| ... +//|:param ~microcontroller.Pin clock: the pin to use for the clock. +//|:param ~microcontroller.Pin MOSI: the Master Out Slave In pin. +//|:param ~microcontroller.Pin MISO: the Master In Slave Out pin.""" +//|... // TODO(tannewt): Support LSB SPI. @@ -101,9 +101,9 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Turn off the SPI bus.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Turn off the SPI bus.""" +//|... STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_spi_deinit(self); @@ -111,15 +111,15 @@ STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit); -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers. -//| Provided by context manager helper.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers. +//|Provided by context manager helper.""" +//|... -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_spi_deinit(args[0]); @@ -140,28 +140,28 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) { } } -//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: -//| """Configures the SPI bus. The SPI object must be locked. +//|def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: +//|"""Configures the SPI bus. The SPI object must be locked. //| -//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower -//| due to the granularity of available clock settings. -//| Check the `frequency` attribute for the actual clock rate. -//| :param int polarity: the base state of the clock line (0 or 1) -//| :param int phase: the edge of the clock that data is captured. First (0) -//| or second (1). Rising or falling depends on clock polarity. -//| :param int bits: the number of bits per word +//|:param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower +//|due to the granularity of available clock settings. +//|Check the `frequency` attribute for the actual clock rate. +//|:param int polarity: the base state of the clock line (0 or 1) +//|:param int phase: the edge of the clock that data is captured. First (0) +//|or second (1). Rising or falling depends on clock polarity. +//|:param int bits: the number of bits per word //| -//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that -//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is -//| within spec for the SAMD21. +//|.. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that +//|speed is not guaranteed to work. 12 MHz is the next available lower speed, and is +//|within spec for the SAMD21. //| -//| .. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz, -//| and 8MHz. -//| If you pick a a baudrate other than one of these, the nearest lower -//| baudrate will be chosen, with a minimum of 125kHz. -//| Two SPI objects may be created, except on the Circuit Playground Bluefruit, -//| which allows only one (to allow for an additional I2C object).""" -//| ... +//|.. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz, +//|and 8MHz. +//|If you pick a a baudrate other than one of these, the nearest lower +//|baudrate will be chosen, with a minimum of 125kHz. +//|Two SPI objects may be created, except on the Circuit Playground Bluefruit, +//|which allows only one (to allow for an additional I2C object).""" +//|... STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits }; @@ -198,12 +198,12 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_ } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure); -//| def try_lock(self, ) -> Any: -//| """Attempts to grab the SPI lock. Returns True on success. +//|def try_lock(self, ) -> Any: +//|"""Attempts to grab the SPI lock. Returns True on success. //| -//| :return: True when lock has been grabbed -//| :rtype: bool""" -//| ... +//|:return: True when lock has been grabbed +//|:rtype: bool""" +//|... 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); @@ -211,9 +211,9 @@ STATIC mp_obj_t busio_spi_obj_try_lock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock); -//| def unlock(self, ) -> Any: -//| """Releases the SPI lock.""" -//| ... +//|unlock(self, ) -> Any: +//|"""Releases the SPI 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); @@ -223,14 +223,14 @@ STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); -//| def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: ... -//| """Write the data contained in ``buffer``. The SPI object must be locked. -//| If the buffer is empty, nothing happens. +//|def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: ... +//|"""Write the data contained in ``buffer``. The SPI object must be locked. +//|If the buffer is empty, nothing happens. //| -//| :param bytearray buffer: Write out the data in this buffer -//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` -//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" -//| ... +//|:param bytearray buffer: Write out the data in this buffer +//|:param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` +//|:param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" +//|... STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; @@ -264,16 +264,16 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write); -//| def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: -//| """Read into ``buffer`` while writing ``write_value`` for each byte read. -//| The SPI object must be locked. -//| If the number of bytes to read is 0, nothing happens. +//|def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: +//|"""Read into ``buffer`` while writing ``write_value`` for each byte read. +//|The SPI object must be locked. +//|If the number of bytes to read is 0, nothing happens. //| -//| :param bytearray buffer: Read data into this buffer -//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` -//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` -//| :param int write_value: Value to write while reading. (Usually ignored.)""" -//| ... +//|:param bytearray buffer: Read data into this buffer +//|:param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` +//|:param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` +//|:param int write_value: Value to write while reading. (Usually ignored.)""" +//|... STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; @@ -307,20 +307,20 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto); -//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: -//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. -//| The SPI object must be locked. -//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` -//| must be equal. -//| If buffer slice lengths are both 0, nothing happens. +//|def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: +//|"""Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. +//|The SPI object must be locked. +//|The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` +//|must be equal. +//|If buffer slice lengths are both 0, nothing happens. //| -//| :param bytearray buffer_out: Write out the data in this buffer -//| :param bytearray buffer_in: Read data into this buffer -//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` -//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` -//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` -//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" -//| ... +//|:param bytearray buffer_out: Write out the data in this buffer +//|:param bytearray buffer_in: Read data into this buffer +//|:param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` +//|:param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` +//|:param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` +//|:param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" +//|... STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; @@ -369,10 +369,10 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto); -//| frequency: Any = -//| """The actual SPI bus frequency. This may not match the frequency requested -//| due to internal limitations.""" -//| ... +//|frequency: Any = +//|"""The actual SPI bus frequency. This may not match the frequency requested +//|due to internal limitations.""" +//|... 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); diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 954cbdd20b..b89b331af4 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -40,30 +40,30 @@ #include "supervisor/shared/translate.h" //|class UART: -//| """.. currentmodule:: busio +//|""".. currentmodule:: busio //| -//| :class:`UART` -- a bidirectional serial protocol -//| =================================================""" -//| def __init__(self, tx: microcontroller.Pin, rx: microcontroller.Pin, *, baudrate: int = 9600, bits: int = 8, parity: Parity = None, stop: int = 1, timeout: float = 1, receiver_buffer_size: int = 64): -//| """A common bidirectional serial protocol that uses an an agreed upon speed -//| rather than a shared clock line. +//|:class:`UART` -- a bidirectional serial protocol +//|=================================================""" +//|def __init__(self, tx: microcontroller.Pin, rx: microcontroller.Pin, *, baudrate: int = 9600, bits: int = 8, parity: Parity = None, stop: int = 1, timeout: float = 1, receiver_buffer_size: int = 64): +//|"""A common bidirectional serial protocol that uses an an agreed upon speed +//|rather than a shared clock line. //| -//| :param ~microcontroller.Pin tx: the pin to transmit with, or ``None`` if this ``UART`` is receive-only. -//| :param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only. -//| :param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use. -//| :param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use. -//| :param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use. -//| :param bool rs485_invert: set to invert the sense of the rs485_dir pin. -//| :param int baudrate: the transmit and receive speed. -//| :param int bits: the number of bits per byte, 7, 8 or 9. -//| :param Parity parity: the parity used for error checking. -//| :param int stop: the number of stop bits, 1 or 2. -//| :param float timeout: the timeout in seconds to wait for the first character and between subsequent characters when reading. Raises ``ValueError`` if timeout >100 seconds. -//| :param int receiver_buffer_size: the character length of the read buffer (0 to disable). (When a character is 9 bits the buffer will be 2 * receiver_buffer_size bytes.) +//|:param ~microcontroller.Pin tx: the pin to transmit with, or ``None`` if this ``UART`` is receive-only. +//|:param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only. +//|:param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use. +//|:param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use. +//|:param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use. +//|:param bool rs485_invert: set to invert the sense of the rs485_dir pin. +//|:param int baudrate: the transmit and receive speed. +//|:param int bits: the number of bits per byte, 7, 8 or 9. +//|:param Parity parity: the parity used for error checking. +//|:param int stop: the number of stop bits, 1 or 2. +//|:param float timeout: the timeout in seconds to wait for the first character and between subsequent characters when reading. Raises ``ValueError`` if timeout >100 seconds. +//|:param int receiver_buffer_size: the character length of the read buffer (0 to disable). (When a character is 9 bits the buffer will be 2 * receiver_buffer_size bytes.) //| -//| *New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. -//| The new upper limit on ``timeout`` is meant to catch mistaken use of milliseconds.""" -//| ... +//|*New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. +//|The new upper limit on ``timeout`` is meant to catch mistaken use of milliseconds.""" +//|... typedef struct { mp_obj_base_t base; } busio_uart_parity_obj_t; @@ -141,9 +141,9 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co return (mp_obj_t)self; } -//| def deinit(self, ) -> Any: -//| """Deinitialises the UART and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the UART and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t busio_uart_obj_deinit(mp_obj_t self_in) { busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_uart_deinit(self); @@ -157,15 +157,15 @@ STATIC void check_for_deinit(busio_uart_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t busio_uart_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_uart_deinit(args[0]); @@ -175,46 +175,46 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ // These are standard stream methods. Code is in py/stream.c. // -//| def read(self, nbytes: Any = None) -> Any: -//| """Read characters. If ``nbytes`` is specified then read at most that many -//| bytes. Otherwise, read everything that arrives until the connection -//| times out. Providing the number of bytes expected is highly recommended -//| because it will be faster. +//|def read(self, nbytes: Any = None) -> Any: +//|"""Read characters. If ``nbytes`` is specified then read at most that many +//|bytes. Otherwise, read everything that arrives until the connection +//|times out. Providing the number of bytes expected is highly recommended +//|because it will be faster. //| -//| :return: Data read -//| :rtype: bytes or None""" -//| ... +//|:return: Data read +//|:rtype: bytes or None""" +//|... -//| def readinto(self, buf: Any) -> Any: -//| """.. method:: readinto(buf) +//|def readinto(self, buf: Any) -> Any: +//|""".. method:: readinto(buf) //| -//| Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. +//|Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. //| -//| :return: number of bytes read and stored into ``buf`` -//| :rtype: int or None (on a non-blocking error) +//|:return: number of bytes read and stored into ``buf`` +//|:rtype: int or None (on a non-blocking error) //| -//| *New in CircuitPython 4.0:* No length parameter is permitted.""" -//| ... +//|*New in CircuitPython 4.0:* No length parameter is permitted.""" +//|... -//| def readline(self, ) -> Any: -//| """.. method:: readline() +//|def readline(self, ) -> Any: +//|""".. method:: readline() //| -//| Read a line, ending in a newline character. +//|Read a line, ending in a newline character. //| -//| :return: the line read -//| :rtype: int or None""" -//| ... +//|:return: the line read +//|:rtype: int or None""" +//|... -//| def write(self, buf: Any) -> Any: -//| """.. method:: write(buf) +//|def write(self, buf: Any) -> Any: +//|""".. method:: write(buf) //| -//| Write the buffer of bytes to the bus. +//|Write the buffer of bytes to the bus. //| -//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. +//|*New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. //| -//| :return: the number of bytes written -//| :rtype: int or None""" -//| ... +//|:return: the number of bytes written +//|:rtype: int or None""" +//|... // 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) { @@ -258,9 +258,9 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t return ret; } -//| baudrate: Any = -//| """The current baudrate.""" -//| ... +//|baudrate: Any = +//|"""The current baudrate.""" +//|... 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); check_for_deinit(self); @@ -284,9 +284,9 @@ const mp_obj_property_t busio_uart_baudrate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| in_waiting: Any = -//| """The number of bytes in the input buffer, available to be read""" -//| ... +//|in_waiting: Any = +//|"""The number of bytes in the input buffer, available to be read""" +//|... 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); check_for_deinit(self); @@ -301,9 +301,9 @@ const mp_obj_property_t busio_uart_in_waiting_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| timeout: Any = -//| """The current timeout, in seconds (float).""" -//| ... +//|timeout: Any = +//|"""The current timeout, in seconds (float).""" +//|... STATIC mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) { busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -329,9 +329,9 @@ const mp_obj_property_t busio_uart_timeout_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def reset_input_buffer(self, ) -> Any: -//| """Discard any unread characters in the input buffer.""" -//| ... +//|def reset_input_buffer(self, ) -> Any: +//|"""Discard any unread characters in the input buffer.""" +//|... 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); check_for_deinit(self); @@ -341,15 +341,15 @@ STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_obj_reset_input_buffer); //|class busio: -//| def __init__(self, ): -//| """Enum-like class to define the parity used to verify correct data transfer.""" -//| ODD: Any = -//| """Total number of ones should be odd.""" -//| ... -//| EVEN: Any = -//| """Total number of ones should be even.""" -//| ... -//| ... +//|def __init__(self, ): +//|"""Enum-like class to define the parity used to verify correct data transfer.""" +//|ODD: Any = +//|"""Total number of ones should be odd.""" +//|... +//|EVEN: Any = +//|"""Total number of ones should be even.""" +//|... +//|... const mp_obj_type_t busio_uart_parity_type; const busio_uart_parity_obj_t busio_uart_parity_odd_obj = { From c3897d0add969e0280e445a80eff34c6a2681592 Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 28 Apr 2020 18:43:40 -0400 Subject: [PATCH 021/216] Fixed whitespace in analogio --- shared-bindings/analogio/AnalogIn.c | 62 ++++++++++++++-------------- shared-bindings/analogio/AnalogOut.c | 57 +++++++++++++------------ 2 files changed, 59 insertions(+), 60 deletions(-) diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index a8afe75bda..9b6ac086be 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -37,24 +37,24 @@ #include "shared-bindings/util.h" //|class AnalogIn: -//| """:class:`AnalogIn` -- read analog voltage -//| ============================================ +//|""":class:`AnalogIn` -- read analog voltage +//|============================================ //| -//| Usage:: +//|Usage:: //| -//| import analogio -//| from board import * +//|import analogio +//|from board import * //| -//| adc = analogio.AnalogIn(A1) -//| val = adc.value""" +//|adc = analogio.AnalogIn(A1) +//|val = adc.value""" //| -//| def __init__(self, pin: microcontroller.Pin): +//|def __init__(self, pin: microcontroller.Pin): //| -//| """Use the AnalogIn on the given pin. The reference voltage varies by -//| platform so use ``reference_voltage`` to read the configured setting. +//|"""Use the AnalogIn on the given pin. The reference voltage varies by +//|platform so use ``reference_voltage`` to read the configured setting. //| -//| :param ~microcontroller.Pin pin: the pin to read from""" -//| ... +//|:param ~microcontroller.Pin pin: the pin to read from""" +//|... STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // check number of arguments @@ -70,9 +70,9 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Turn off the AnalogIn and release the pin for other use.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Turn off the AnalogIn and release the pin for other use.""" +//|... STATIC mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) { analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_analogio_analogin_deinit(self); @@ -85,15 +85,15 @@ STATIC void check_for_deinit(analogio_analogin_obj_t *self) { raise_deinited_error(); } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_analogio_analogin_deinit(args[0]); @@ -101,12 +101,12 @@ STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogin___exit___obj, 4, 4, analogio_analogin___exit__); -//| value: Any = -//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only) +//|value: Any = +//|"""The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only) //| -//| Even if the underlying analog to digital converter (ADC) is lower -//| resolution, the value is 16-bit.""" -//| ... +//|Even if the underlying analog to digital converter (ADC) is lower +//|resolution, the value is 16-bit.""" +//|... 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); check_for_deinit(self); @@ -121,10 +121,10 @@ const mp_obj_property_t analogio_analogin_value_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| reference_voltage: Any = -//| """The maximum voltage measurable (also known as the reference voltage) as a -//| `float` in Volts.""" -//| ... +//|reference_voltage: Any = +//|"""The maximum voltage measurable (also known as the reference voltage) as a +//|`float` in Volts.""" +//|... 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); check_for_deinit(self); diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index 1b5808e6c9..2316682903 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -37,26 +37,25 @@ #include "supervisor/shared/translate.h" //|class AnalogOut: -//| """.. currentmodule:: analogio +//|""".. currentmodule:: analogio //| -//| :class:`AnalogOut` -- output analog voltage -//| ============================================ +//|:class:`AnalogOut` -- output analog voltage +//|============================================ //| -//| The AnalogOut is used to output analog values (a specific voltage). +//|The AnalogOut is used to output analog values (a specific voltage). //| -//| Example usage:: +//|Example usage:: //| -//| import analogio -//| from microcontroller import pin +//|import analogio +//|from microcontroller import pin //| -//| dac = analogio.AnalogOut(pin.PA02) # output on pin PA02 -//| dac.value = 32768 # makes PA02 1.65V""" -//| def __init__(self, pin: microcontroller.Pin): +//|dac = analogio.AnalogOut(pin.PA02) # output on pin PA02 +//|dac.value = 32768 # makes PA02 1.65V""" +//|def __init__(self, pin: microcontroller.Pin): +//|"""Use the AnalogOut on the given pin. //| -//| """Use the AnalogOut on the given pin. -//| -//| :param ~microcontroller.Pin pin: the pin to output to""" -//| ... +//|:param ~microcontroller.Pin pin: the pin to output to""" +//|... STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // check arguments mp_arg_check_num(n_args, kw_args, 1, 1, false); @@ -70,9 +69,9 @@ STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Turn off the AnalogOut and release the pin for other use.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Turn off the AnalogOut and release the pin for other use.""" +//|... STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) { analogio_analogout_obj_t *self = self_in; @@ -82,15 +81,15 @@ STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogout_deinit); -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_analogio_analogout_deinit(args[0]); @@ -98,12 +97,12 @@ STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4, analogio_analogout___exit__); -//| value: Any = -//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only) +//|value: Any = +//|"""The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only) //| -//| Even if the underlying digital to analog converter (DAC) is lower -//| resolution, the value is 16-bit.""" -//| ... +//|Even if the underlying digital to analog converter (DAC) is lower +//|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); if (common_hal_analogio_analogout_deinited(self)) { From aacca615988e29dd58b5083a0199f60f2f40a263 Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 28 Apr 2020 18:56:19 -0400 Subject: [PATCH 022/216] Fixed whitespace on audiocore --- shared-bindings/audiocore/RawSample.c | 92 ++++++++++++------------- shared-bindings/audiocore/WaveFile.c | 96 +++++++++++++-------------- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index b879b1b97f..fdedfe9598 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -36,44 +36,44 @@ #include "supervisor/shared/translate.h" //|class RawSample: -//| """.. currentmodule:: audiocore +//|""".. currentmodule:: audiocore //| -//| :class:`RawSample` -- A raw audio sample buffer -//| ======================================================== +//|:class:`RawSample` -- A raw audio sample buffer +//|======================================================== //| -//| An in-memory sound sample""" +//|An in-memory sound sample""" //| -//| def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000): -//| """Create a RawSample based on the given buffer of signed values. If channel_count is more than -//| 1 then each channel's samples should alternate. In other words, for a two channel buffer, the -//| first sample will be for channel 1, the second sample will be for channel two, the third for -//| channel 1 and so on. +//|def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000): +//|"""Create a RawSample based on the given buffer of signed values. If channel_count is more than +//|1 then each channel's samples should alternate. In other words, for a two channel buffer, the +//|first sample will be for channel 1, the second sample will be for channel two, the third for +//|channel 1 and so on. //| -//| :param array.array buffer: An `array.array` with samples -//| :param int channel_count: The number of channels in the buffer -//| :param int sample_rate: The desired playback sample rate +//|:param array.array buffer: An `array.array` with samples +//|:param int channel_count: The number of channels in the buffer +//|:param int sample_rate: The desired playback sample rate //| -//| Simple 8ksps 440 Hz sin wave:: +//|Simple 8ksps 440 Hz sin wave:: //| -//| import audiocore -//| import audioio -//| import board -//| import array -//| import time -//| import math +//|import audiocore +//|import audioio +//|import board +//|import array +//|import time +//|import math //| -//| # Generate one period of sine wav. -//| length = 8000 // 440 -//| sine_wave = array.array("h", [0] * length) -//| for i in range(length): -//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15)) +//|# Generate one period of sine wav. +//|length = 8000 // 440 +//|sine_wave = array.array("h", [0] * length) +//|for i in range(length): +//|sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15)) //| -//| dac = audioio.AudioOut(board.SPEAKER) -//| sine_wave = audiocore.RawSample(sine_wave) -//| dac.play(sine_wave, loop=True) -//| time.sleep(1) -//| dac.stop()""" -//| ... +//|dac = audioio.AudioOut(board.SPEAKER) +//|sine_wave = audiocore.RawSample(sine_wave) +//|dac.play(sine_wave, loop=True) +//|time.sleep(1) +//|dac.stop()""" +//|... STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_channel_count, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -105,9 +105,9 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the AudioOut and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the AudioOut and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t audioio_rawsample_deinit(mp_obj_t self_in) { audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_rawsample_deinit(self); @@ -121,15 +121,15 @@ STATIC void check_for_deinit(audioio_rawsample_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_rawsample_deinit(args[0]); @@ -137,12 +137,12 @@ STATIC mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *ar } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_rawsample___exit___obj, 4, 4, audioio_rawsample_obj___exit__); -//| sample_rate: Any = -//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second). -//| When the sample is looped, this can change the pitch output without changing the underlying -//| sample. This will not change the sample rate of any active playback. Call ``play`` again to -//| change it.""" -//| ... +//|sample_rate: Any = +//|"""32 bit value that dictates how quickly samples are played in Hertz (cycles per second). +//|When the sample is looped, this can change the pitch output without changing the underlying +//|sample. This will not change the sample rate of any active playback. Call ``play`` again to +//|change it.""" +//|... 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); check_for_deinit(self); diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index f57e1f8779..9116e71f0f 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -34,42 +34,42 @@ #include "supervisor/shared/translate.h" //|class WaveFile: -//| """.. currentmodule:: audiocore +//|""".. currentmodule:: audiocore //| -//| :class:`WaveFile` -- Load a wave file for audio playback -//| ======================================================== +//|:class:`WaveFile` -- Load a wave file for audio playback +//|======================================================== //| -//| A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must -//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating -//| an internal buffer.""" -//| def __init__(self, file: typing.BinaryIO, buffer: bytearray): -//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. +//|A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must +//|be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating +//|an internal buffer.""" +//|def __init__(self, file: typing.BinaryIO, buffer: bytearray): +//|"""Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. //| -//| :param typing.BinaryIO file: Already opened wave file -//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally. +//|:param typing.BinaryIO file: Already opened wave file +//|:param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally. //| //| -//| Playing a wave file from flash:: +//|Playing a wave file from flash:: //| -//| import board -//| import audiocore -//| import audioio -//| import digitalio +//|import board +//|import audiocore +//|import audioio +//|import digitalio //| -//| # Required for CircuitPlayground Express -//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//| speaker_enable.switch_to_output(value=True) +//|# Required for CircuitPlayground Express +//|speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//|speaker_enable.switch_to_output(value=True) //| -//| data = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audiocore.WaveFile(data) -//| a = audioio.AudioOut(board.A0) +//|data = open("cplay-5.1-16bit-16khz.wav", "rb") +//|wav = audiocore.WaveFile(data) +//|a = audioio.AudioOut(board.A0) //| -//| print("playing") -//| a.play(wav) -//| while a.playing: -//| pass -//| print("stopped")""" -//| ... +//|print("playing") +//|a.play(wav) +//|while a.playing: +//|pass +//|print("stopped")""" +//|... STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 2, false); @@ -92,9 +92,9 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the WaveFile and releases all memory resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the WaveFile and releases all memory resources for reuse.""" +//|... STATIC mp_obj_t audioio_wavefile_deinit(mp_obj_t self_in) { audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_wavefile_deinit(self); @@ -108,15 +108,15 @@ STATIC void check_for_deinit(audioio_wavefile_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_wavefile_deinit(args[0]); @@ -124,11 +124,11 @@ STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_wavefile___exit___obj, 4, 4, audioio_wavefile_obj___exit__); -//| sample_rate: Any = -//| """32 bit value that dictates how quickly samples are loaded into the DAC -//| in Hertz (cycles per second). When the sample is looped, this can change -//| the pitch output without changing the underlying sample.""" -//| ... +//|sample_rate: Any = +//|"""32 bit value that dictates how quickly samples are loaded into the DAC +//|in Hertz (cycles per second). When the sample is looped, this can change +//|the pitch output without changing the underlying sample.""" +//|... 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); check_for_deinit(self); @@ -151,9 +151,9 @@ const mp_obj_property_t audioio_wavefile_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| bits_per_sample: Any = -//| """Bits per sample. (read only)""" -//| ... +//|bits_per_sample: Any = +//|"""Bits per sample. (read only)""" +//|... 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); check_for_deinit(self); @@ -168,9 +168,9 @@ const mp_obj_property_t audioio_wavefile_bits_per_sample_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| channel_count: Any = -//| """Number of audio channels. (read only)""" -//| ... +//|channel_count: Any = +//|"""Number of audio channels. (read only)""" +//|... 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); check_for_deinit(self); From c7b721f4f19b561006d9d2e1c46d79d9f22bf4b0 Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 28 Apr 2020 19:22:03 -0400 Subject: [PATCH 023/216] Fixed some more whitespace --- shared-bindings/audiobusio/I2SOut.c | 150 +++++++++++------------ shared-bindings/audiobusio/PDMIn.c | 129 ++++++++++---------- shared-bindings/audioio/AudioOut.c | 154 ++++++++++++------------ shared-bindings/audiomixer/Mixer.c | 132 ++++++++++---------- shared-bindings/audiomixer/MixerVoice.c | 44 +++---- shared-bindings/audiomp3/MP3Decoder.c | 105 ++++++++-------- 6 files changed, 353 insertions(+), 361 deletions(-) diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index cad17ad184..765e0a12dc 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -36,63 +36,63 @@ #include "supervisor/shared/translate.h" //|class I2SOut: -//| """.. currentmodule:: audiobusio +//|""".. currentmodule:: audiobusio //| -//| :class:`I2SOut` -- Output an I2S audio signal -//| ======================================================== +//|:class:`I2SOut` -- Output an I2S audio signal +//|======================================================== //| -//| I2S is used to output an audio signal on an I2S bus.""" -//| def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool): -//| """Create a I2SOut object associated with the given pins. +//|I2S is used to output an audio signal on an I2S bus.""" +//|def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool): +//|"""Create a I2SOut object associated with the given pins. //| -//| :param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin -//| :param ~microcontroller.Pin word_select: The word select (or left/right clock) pin -//| :param ~microcontroller.Pin data: The data pin -//| :param bool left_justified: True when data bits are aligned with the word select clock. False -//| when they are shifted by one to match classic I2S protocol. +//|:param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin +//|:param ~microcontroller.Pin word_select: The word select (or left/right clock) pin +//|:param ~microcontroller.Pin data: The data pin +//|:param bool left_justified: True when data bits are aligned with the word select clock. False +//|when they are shifted by one to match classic I2S protocol. //| -//| Simple 8ksps 440 Hz sine wave on `Metro M0 Express `_ -//| using `UDA1334 Breakout `_:: +//|Simple 8ksps 440 Hz sine wave on `Metro M0 Express `_ +//|using `UDA1334 Breakout `_:: //| -//| import audiobusio -//| import audiocore -//| import board -//| import array -//| import time -//| import math +//|import audiobusio +//|import audiocore +//|import board +//|import array +//|import time +//|import math //| -//| # Generate one period of sine wave. -//| length = 8000 // 440 -//| sine_wave = array.array("H", [0] * length) -//| for i in range(length): -//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//|# Generate one period of sine wave. +//|length = 8000 // 440 +//|sine_wave = array.array("H", [0] * length) +//|for i in range(length): +//|sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) -//| i2s = audiobusio.I2SOut(board.D1, board.D0, board.D9) -//| i2s.play(sine_wave, loop=True) -//| time.sleep(1) -//| i2s.stop() +//|sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//|i2s = audiobusio.I2SOut(board.D1, board.D0, board.D9) +//|i2s.play(sine_wave, loop=True) +//|time.sleep(1) +//|i2s.stop() //| -//| Playing a wave file from flash:: +//|Playing a wave file from flash:: //| -//| import board -//| import audioio -//| import audiocore -//| import audiobusio -//| import digitalio +//|import board +//|import audioio +//|import audiocore +//|import audiobusio +//|import digitalio //| //| -//| f = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audiocore.WaveFile(f) +//|f = open("cplay-5.1-16bit-16khz.wav", "rb") +//|wav = audiocore.WaveFile(f) //| -//| a = audiobusio.I2SOut(board.D1, board.D0, board.D9) +//|a = audiobusio.I2SOut(board.D1, board.D0, board.D9) //| -//| print("playing") -//| a.play(wav) -//| while a.playing: -//| pass -//| print("stopped")""" -//| ... +//|print("playing") +//|a.play(wav) +//|while a.playing: +//|pass +//|print("stopped")""" +//|... STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_left_justified }; static const mp_arg_t allowed_args[] = { @@ -115,9 +115,9 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the I2SOut and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the I2SOut and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t audiobusio_i2sout_deinit(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_i2sout_deinit(self); @@ -130,15 +130,15 @@ STATIC void check_for_deinit(audiobusio_i2sout_obj_t *self) { raise_deinited_error(); } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_i2sout_deinit(args[0]); @@ -147,14 +147,14 @@ STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *ar STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, audiobusio_i2sout_obj___exit__); -//| def play(self, sample: Any, *, loop: Any = False) -> Any: -//| """Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. +//|def play(self, sample: Any, *, loop: Any = False) -> Any: +//|"""Plays the sample once when loop=False and continuously when loop=True. +//|Does not block. Use `playing` to block. //| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//|Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| -//| The sample itself should consist of 8 bit or 16 bit samples.""" -//| ... +//|The sample itself should consist of 8 bit or 16 bit samples.""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -173,9 +173,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_ar } MP_DEFINE_CONST_FUN_OBJ_KW(audiobusio_i2sout_play_obj, 1, audiobusio_i2sout_obj_play); -//| def stop(self, ) -> Any: -//| """Stops playback.""" -//| ... +//|def stop(self, ) -> Any: +//|"""Stops playback.""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -184,9 +184,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_stop_obj, audiobusio_i2sout_obj_stop); -//| playing: Any = -//| """True when the audio sample is being output. (read-only)""" -//| ... +//|playing: Any = +//|"""True when the audio sample is being output. (read-only)""" +//|... 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); check_for_deinit(self); @@ -201,9 +201,9 @@ const mp_obj_property_t audiobusio_i2sout_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def pause(self, ) -> Any: -//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" -//| ... +//|def pause(self, ) -> Any: +//|"""Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -216,9 +216,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_pause_obj, audiobusio_i2sout_obj_pause); -//| def resume(self, ) -> Any: -//| """Resumes sample playback after :py:func:`pause`.""" -//| ... +//|def resume(self, ) -> Any: +//|"""Resumes sample playback after :py:func:`pause`.""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -231,9 +231,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_resume_obj, audiobusio_i2sout_obj_resume); -//| paused: Any = -//| """True when playback is paused. (read-only)""" -//| ... +//|paused: Any = +//|"""True when playback is paused. (read-only)""" +//|... 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); check_for_deinit(self); diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index b75545ba7b..28ff9a4818 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -36,63 +36,56 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" - - - - - - - //|class PDMIn: -//| """.. currentmodule:: audiobusio +//|""".. currentmodule:: audiobusio //| -//| :class:`PDMIn` -- Record an input PDM audio stream -//| ======================================================== +//|:class:`PDMIn` -- Record an input PDM audio stream +//|======================================================== //| -//| PDMIn can be used to record an input audio signal on a given set of pins.""" +//|PDMIn can be used to record an input audio signal on a given set of pins.""" //| -//| def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11): -//| """Create a PDMIn object associated with the given pins. This allows you to -//| record audio signals from the given pins. Individual ports may put further -//| restrictions on the recording parameters. The overall sample rate is -//| determined by `sample_rate` x ``oversample``, and the total must be 1MHz or -//| higher, so `sample_rate` must be a minimum of 16000. +//|def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11): +//|"""Create a PDMIn object associated with the given pins. This allows you to +//|record audio signals from the given pins. Individual ports may put further +//|restrictions on the recording parameters. The overall sample rate is +//|determined by `sample_rate` x ``oversample``, and the total must be 1MHz or +//|higher, so `sample_rate` must be a minimum of 16000. //| -//| :param ~microcontroller.Pin clock_pin: The pin to output the clock to -//| :param ~microcontroller.Pin data_pin: The pin to read the data from -//| :param int sample_rate: Target sample_rate of the resulting samples. Check `sample_rate` for actual value. -//| Minimum sample_rate is about 16000 Hz. -//| :param int bit_depth: Final number of bits per sample. Must be divisible by 8 -//| :param bool mono: True when capturing a single channel of audio, captures two channels otherwise -//| :param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8 -//| :param float startup_delay: seconds to wait after starting microphone clock -//| to allow microphone to turn on. Most require only 0.01s; some require 0.1s. Longer is safer. -//| Must be in range 0.0-1.0 seconds.""" -//| ... +//|:param ~microcontroller.Pin clock_pin: The pin to output the clock to +//|:param ~microcontroller.Pin data_pin: The pin to read the data from +//|:param int sample_rate: Target sample_rate of the resulting samples. Check `sample_rate` for actual value. +//|Minimum sample_rate is about 16000 Hz. +//|:param int bit_depth: Final number of bits per sample. Must be divisible by 8 +//|:param bool mono: True when capturing a single channel of audio, captures two channels otherwise +//|:param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8 +//|:param float startup_delay: seconds to wait after starting microphone clock +//|to allow microphone to turn on. Most require only 0.01s; some require 0.1s. Longer is safer. +//|Must be in range 0.0-1.0 seconds.""" +//|... -//| Record 8-bit unsigned samples to buffer:: +//|Record 8-bit unsigned samples to buffer:: //| -//| import audiobusio -//| import board +//|import audiobusio +//|import board //| -//| # Prep a buffer to record into -//| b = bytearray(200) -//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000) as mic: -//| mic.record(b, len(b)) +//|# Prep a buffer to record into +//|b = bytearray(200) +//|with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000) as mic: +//|mic.record(b, len(b)) //| -//| Record 16-bit unsigned samples to buffer:: +//|Record 16-bit unsigned samples to buffer:: //| -//| import audiobusio -//| import board +//|import audiobusio +//|import board //| -//| # Prep a buffer to record into. The array interface doesn't allow for -//| # constructing with a set size so we append to it until we have the size -//| # we want. -//| b = array.array("H") -//| for i in range(200): -//| b.append(0) -//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: -//| mic.record(b, len(b)) +//|# Prep a buffer to record into. The array interface doesn't allow for +//|# constructing with a set size so we append to it until we have the size +//|# we want. +//|b = array.array("H") +//|for i in range(200): +//|b.append(0) +//|with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: +//|mic.record(b, len(b)) //| STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_clock_pin, ARG_data_pin, ARG_sample_rate, ARG_bit_depth, ARG_mono, ARG_oversample, ARG_startup_delay }; @@ -145,9 +138,9 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the PDMIn and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the PDMIn and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t audiobusio_pdmin_deinit(mp_obj_t self_in) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_pdmin_deinit(self); @@ -160,14 +153,14 @@ STATIC void check_for_deinit(audiobusio_pdmin_obj_t *self) { raise_deinited_error(); } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context.""" +//|... STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_pdmin_deinit(args[0]); @@ -176,17 +169,17 @@ STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *arg STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, audiobusio_pdmin_obj___exit__); -//| def record(self, destination: Any, destination_length: Any) -> Any: -//| """Records destination_length bytes of samples to destination. This is -//| blocking. +//|def record(self, destination: Any, destination_length: Any) -> Any: +//|"""Records destination_length bytes of samples to destination. This is +//|blocking. //| -//| An IOError may be raised when the destination is too slow to record the -//| audio at the given rate. For internal flash, writing all 1s to the file -//| before recording is recommended to speed up writes. +//|An IOError may be raised when the destination is too slow to record the +//|audio at the given rate. For internal flash, writing all 1s to the file +//|before recording is recommended to speed up writes. //| -//| :return: The number of samples recorded. If this is less than ``destination_length``, -//| some samples were missed due to processing time.""" -//| ... +//|:return: The number of samples recorded. If this is less than ``destination_length``, +//|some samples were missed due to processing time.""" +//|... 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); check_for_deinit(self); @@ -217,10 +210,10 @@ STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destinat } MP_DEFINE_CONST_FUN_OBJ_3(audiobusio_pdmin_record_obj, audiobusio_pdmin_obj_record); -//| sample_rate: Any = -//| """The actual sample_rate of the recording. This may not match the constructed -//| sample rate due to internal clock limitations.""" -//| ... +//|sample_rate: Any = +//|"""The actual sample_rate of the recording. This may not match the constructed +//|sample rate due to internal clock limitations.""" +//|... 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); check_for_deinit(self); diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 8df923e6f1..28c345d168 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -37,63 +37,63 @@ #include "supervisor/shared/translate.h" //|class AudioOut: -//| """.. currentmodule:: audioio +//|""".. currentmodule:: audioio //| -//| :class:`AudioOut` -- Output an analog audio signal -//| ======================================================== +//|:class:`AudioOut` -- Output an analog audio signal +//|======================================================== //| -//| AudioOut can be used to output an analog audio signal on a given pin.""" +//|AudioOut can be used to output an analog audio signal on a given pin.""" //| -//| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): -//| """Create a AudioOut object associated with the given pin(s). This allows you to -//| play audio signals out on the given pin(s). +//|def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): +//|"""Create a AudioOut object associated with the given pin(s). This allows you to +//|play audio signals out on the given pin(s). //| -//| :param ~microcontroller.Pin left_channel: The pin to output the left channel to -//| :param ~microcontroller.Pin right_channel: The pin to output the right channel to -//| :param int quiescent_value: The output value when no signal is present. Samples should start -//| and end with this value to prevent audible popping. +//|:param ~microcontroller.Pin left_channel: The pin to output the left channel to +//|:param ~microcontroller.Pin right_channel: The pin to output the right channel to +//|:param int quiescent_value: The output value when no signal is present. Samples should start +//|and end with this value to prevent audible popping. //| -//| Simple 8ksps 440 Hz sin wave:: +//|Simple 8ksps 440 Hz sin wave:: //| -//| import audiocore -//| import audioio -//| import board -//| import array -//| import time -//| import math +//|import audiocore +//|import audioio +//|import board +//|import array +//|import time +//|import math //| -//| # Generate one period of sine wav. -//| length = 8000 // 440 -//| sine_wave = array.array("H", [0] * length) -//| for i in range(length): -//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//|# Generate one period of sine wav. +//|length = 8000 // 440 +//|sine_wave = array.array("H", [0] * length) +//|for i in range(length): +//|sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//| dac = audioio.AudioOut(board.SPEAKER) -//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) -//| dac.play(sine_wave, loop=True) -//| time.sleep(1) -//| dac.stop() +//|dac = audioio.AudioOut(board.SPEAKER) +//|sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//|dac.play(sine_wave, loop=True) +//|time.sleep(1) +//|dac.stop() //| -//| Playing a wave file from flash:: +//|Playing a wave file from flash:: //| -//| import board -//| import audioio -//| import digitalio +//|import board +//|import audioio +//|import digitalio //| -//| # Required for CircuitPlayground Express -//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//| speaker_enable.switch_to_output(value=True) +//|# Required for CircuitPlayground Express +//|speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//|speaker_enable.switch_to_output(value=True) //| -//| data = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audiocore.WaveFile(data) -//| a = audioio.AudioOut(board.A0) +//|data = open("cplay-5.1-16bit-16khz.wav", "rb") +//|wav = audiocore.WaveFile(data) +//|a = audioio.AudioOut(board.A0) //| -//| print("playing") -//| a.play(wav) -//| while a.playing: -//| pass -//| print("stopped")""" -//| ... +//|print("playing") +//|a.play(wav) +//|while a.playing: +//|pass +//|print("stopped")""" +//|... STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { @@ -115,9 +115,9 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the AudioOut and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the AudioOut and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t audioio_audioout_deinit(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_audioout_deinit(self); @@ -130,15 +130,15 @@ STATIC void check_for_deinit(audioio_audioout_obj_t *self) { raise_deinited_error(); } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_audioout_deinit(args[0]); @@ -147,16 +147,16 @@ STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *arg STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, audioio_audioout_obj___exit__); -//| def play(self, sample: Any, *, loop: Any = False) -> Any: -//| """Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. +//|def play(self, sample: Any, *, loop: Any = False) -> Any: +//|"""Plays the sample once when loop=False and continuously when loop=True. +//|Does not block. Use `playing` to block. //| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//|Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| -//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output -//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit -//| DAC that ignores the lowest 6 bits when playing 16 bit samples.""" -//| ... +//|The sample itself should consist of 16 bit samples. Microcontrollers with a lower output +//|resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit +//|DAC that ignores the lowest 6 bits when playing 16 bit samples.""" +//|... STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -175,9 +175,9 @@ STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_arg } MP_DEFINE_CONST_FUN_OBJ_KW(audioio_audioout_play_obj, 1, audioio_audioout_obj_play); -//| def stop(self, ) -> Any: -//| """Stops playback and resets to the start of the sample.""" -//| ... +//|def stop(self, ) -> Any: +//|"""Stops playback and resets to the start of the sample.""" +//|... STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -186,9 +186,9 @@ STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_stop_obj, audioio_audioout_obj_stop); -//| playing: Any = -//| """True when an audio sample is being output even if `paused`. (read-only)""" -//| ... +//|playing: Any = +//|"""True when an audio sample is being output even if `paused`. (read-only)""" +//|... 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); check_for_deinit(self); @@ -203,9 +203,9 @@ const mp_obj_property_t audioio_audioout_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def pause(self, ) -> Any: -//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" -//| ... +//|def pause(self, ) -> Any: +//|"""Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" +//|... STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -218,9 +218,9 @@ STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_pause_obj, audioio_audioout_obj_pause); -//| def resume(self, ) -> Any: -//| """Resumes sample playback after :py:func:`pause`.""" -//| ... +//|def resume(self, ) -> Any: +//|"""Resumes sample playback after :py:func:`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); check_for_deinit(self); @@ -233,9 +233,9 @@ STATIC mp_obj_t audioio_audioout_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_resume_obj, audioio_audioout_obj_resume); -//| paused: Any = -//| """True when playback is paused. (read-only)""" -//| ... +//|paused: Any = +//|"""True when playback is paused. (read-only)""" +//|... 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); check_for_deinit(self); diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 1949f2addd..93b1d3635f 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -39,49 +39,49 @@ #include "supervisor/shared/translate.h" //|class Mixer: -//| """.. currentmodule:: audiomixer +//|""".. currentmodule:: audiomixer //| -//| :class:`Mixer` -- Mixes one or more audio samples together -//| =========================================================== +//|:class:`Mixer` -- Mixes one or more audio samples together +//|=========================================================== //| -//| Mixer mixes multiple samples into one sample.""" +//|Mixer mixes multiple samples into one sample.""" //| -//| def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000): -//| """Create a Mixer object that can mix multiple channels with the same sample rate. -//| Samples are accessed and controlled with the mixer's `audiomixer.MixerVoice` objects. +//|def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000): +//|"""Create a Mixer object that can mix multiple channels with the same sample rate. +//|Samples are accessed and controlled with the mixer's `audiomixer.MixerVoice` objects. //| -//| :param int voice_count: The maximum number of voices to mix -//| :param int buffer_size: The total size in bytes of the buffers to mix into -//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo. -//| :param int bits_per_sample: The bits per sample of the samples being played -//| :param bool samples_signed: Samples are signed (True) or unsigned (False) -//| :param int sample_rate: The sample rate to be used for all samples +//|:param int voice_count: The maximum number of voices to mix +//|:param int buffer_size: The total size in bytes of the buffers to mix into +//|:param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo. +//|:param int bits_per_sample: The bits per sample of the samples being played +//|:param bool samples_signed: Samples are signed (True) or unsigned (False) +//|:param int sample_rate: The sample rate to be used for all samples //| -//| Playing a wave file from flash:: +//|Playing a wave file from flash:: //| -//| import board -//| import audioio -//| import audiocore -//| import audiomixer -//| import digitalio +//|import board +//|import audioio +//|import audiocore +//|import audiomixer +//|import digitalio //| -//| a = audioio.AudioOut(board.A0) -//| music = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) -//| drum = audiocore.WaveFile(open("drum.wav", "rb")) -//| mixer = audiomixer.Mixer(voice_count=2, sample_rate=16000, channel_count=1, -//| bits_per_sample=16, samples_signed=True) +//|a = audioio.AudioOut(board.A0) +//|music = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) +//|drum = audiocore.WaveFile(open("drum.wav", "rb")) +//|mixer = audiomixer.Mixer(voice_count=2, sample_rate=16000, channel_count=1, +//|bits_per_sample=16, samples_signed=True) //| -//| print("playing") -//| # Have AudioOut play our Mixer source -//| a.play(mixer) -//| # Play the first sample voice -//| mixer.voice[0].play(music) -//| while mixer.playing: -//| # Play the second sample voice -//| mixer.voice[1].play(drum) -//| time.sleep(1) -//| print("stopped")""" -//| ... +//|print("playing") +//|# Have AudioOut play our Mixer source +//|a.play(mixer) +//|# Play the first sample voice +//|mixer.voice[0].play(music) +//|while mixer.playing: +//|# Play the second sample voice +//|mixer.voice[1].play(drum) +//|time.sleep(1) +//|print("stopped")""" +//|... STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice_count, ARG_buffer_size, ARG_channel_count, ARG_bits_per_sample, ARG_samples_signed, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -125,9 +125,9 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the Mixer and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the Mixer and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t audiomixer_mixer_deinit(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiomixer_mixer_deinit(self); @@ -141,15 +141,15 @@ STATIC void check_for_deinit(audiomixer_mixer_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiomixer_mixer_deinit(args[0]); @@ -157,9 +157,9 @@ STATIC mp_obj_t audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomixer_mixer___exit___obj, 4, 4, audiomixer_mixer_obj___exit__); -//| playing: Any = -//| """True when any voice is being output. (read-only)""" -//| ... +//|playing: Any = +//|"""True when any voice is being output. (read-only)""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_get_playing(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -174,9 +174,9 @@ const mp_obj_property_t audiomixer_mixer_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| sample_rate: Any = -//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second).""" -//| ... +//|sample_rate: Any = +//|"""32 bit value that dictates how quickly samples are played in Hertz (cycles per second).""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_get_sample_rate(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -191,14 +191,14 @@ const mp_obj_property_t audiomixer_mixer_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| voice: Any = -//| """A tuple of the mixer's `audiomixer.MixerVoice` object(s). +//|voice: Any = +//|"""A tuple of the mixer's `audiomixer.MixerVoice` object(s). //| -//| .. code-block:: python +//|.. code-block:: python //| -//| >>> mixer.voice -//| (,)""" -//| ... +//|>>> mixer.voice +//|(,)""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_get_voice(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -213,14 +213,14 @@ const mp_obj_property_t audiomixer_mixer_voice_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def play(self, sample: Any, *, voice: Any = 0, loop: Any = False) -> Any: -//| """Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. +//|def play(self, sample: Any, *, voice: Any = 0, loop: Any = False) -> Any: +//|"""Plays the sample once when loop=False and continuously when loop=True. +//|Does not block. Use `playing` to block. //| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//|Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| -//| The sample must match the Mixer's encoding settings given in the constructor.""" -//| ... +//|The sample must match the Mixer's encoding settings given in the constructor.""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_voice, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -245,9 +245,9 @@ STATIC mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_arg } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixer_play_obj, 1, audiomixer_mixer_obj_play); -//| def stop_voice(self, voice: Any = 0) -> Any: -//| """Stops playback of the sample on the given voice.""" -//| ... +//|def stop_voice(self, voice: Any = 0) -> Any: +//|"""Stops playback of the sample on the given voice.""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_stop_voice(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index e6c750bafa..299600dd14 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -38,17 +38,17 @@ #include "supervisor/shared/translate.h" //|class MixerVoice: -//| """.. currentmodule:: audiomixer +//|""".. currentmodule:: audiomixer //| -//| :class:`MixerVoice` -- Voice objects used with Mixer -//| ===================================================== +//|:class:`MixerVoice` -- Voice objects used with Mixer +//|===================================================== //| -//| Used to access and control samples with `audiomixer.Mixer`.""" +//|Used to access and control samples with `audiomixer.Mixer`.""" //| -//| def __init__(self, ): +//|def __init__(self, ): //| -//| """MixerVoice instance object(s) created by `audiomixer.Mixer`.""" -//| ... +//|"""MixerVoice instance object(s) created by `audiomixer.Mixer`.""" +//|... // TODO: support mono or stereo voices STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { audiomixer_mixervoice_obj_t *self = m_new_obj(audiomixer_mixervoice_obj_t); @@ -59,14 +59,14 @@ STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t return MP_OBJ_FROM_PTR(self); } -//| def play(self, sample: Any, *, loop: Any = False) -> Any: -//| """Plays the sample once when ``loop=False``, and continuously when ``loop=True``. -//| Does not block. Use `playing` to block. +//|def play(self, sample: Any, *, loop: Any = False) -> Any: +//|"""Plays the sample once when ``loop=False``, and continuously when ``loop=True``. +//|Does not block. Use `playing` to block. //| -//| Sample must be an `audiocore.WaveFile`, `audiomixer.Mixer` or `audiocore.RawSample`. +//|Sample must be an `audiocore.WaveFile`, `audiomixer.Mixer` or `audiocore.RawSample`. //| -//| The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor.""" -//| ... +//|The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor.""" +//|... STATIC mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -83,9 +83,9 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *po } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_play_obj, 1, audiomixer_mixervoice_obj_play); -//| def stop(self, ) -> Any: -//| """Stops playback of the sample on this voice.""" -//| ... +//|def stop(self, ) -> Any: +//|"""Stops playback of the sample on this voice.""" +//|... STATIC mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { @@ -101,9 +101,9 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *po } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_stop_obj, 1, audiomixer_mixervoice_obj_stop); -//| level(): Any = -//| """The volume level of a voice, as a floating point number between 0 and 1.""" -//| ... +//|level(): Any = +//|"""The volume level of a voice, as a floating point number between 0 and 1.""" +//|... STATIC mp_obj_t audiomixer_mixervoice_obj_get_level(mp_obj_t self_in) { return mp_obj_new_float(common_hal_audiomixer_mixervoice_get_level(self_in)); } @@ -137,9 +137,9 @@ const mp_obj_property_t audiomixer_mixervoice_level_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| playing: Any = -//| """True when this voice is being output. (read-only)""" -//| ... +//|playing: Any = +//|"""True when this voice is being output. (read-only)""" +//|... STATIC mp_obj_t audiomixer_mixervoice_obj_get_playing(mp_obj_t self_in) { audiomixer_mixervoice_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 0bb2c88292..7c011b65f3 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -35,41 +35,41 @@ #include "supervisor/shared/translate.h" //|class MP3: -//| """.. currentmodule:: audiomp3 +//|""".. currentmodule:: audiomp3 //| -//| :class:`MP3Decoder` -- Load a mp3 file for audio playback -//| ========================================================= +//|:class:`MP3Decoder` -- Load a mp3 file for audio playback +//|========================================================= //| -//| An object that decodes MP3 files for playback on an audio device.""" +//|An object that decodes MP3 files for playback on an audio device.""" //| -//| def __init__(self, file: typing.BinaryIO, buffer: bytearray): -//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. +//|def __init__(self, file: typing.BinaryIO, buffer: bytearray): +//|"""Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. //| -//| :param typing.BinaryIO file: Already opened mp3 file -//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. +//|:param typing.BinaryIO file: Already opened mp3 file +//|:param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. //| //| -//| Playing a mp3 file from flash:: +//|Playing a mp3 file from flash:: //| -//| import board -//| import audiomp3 -//| import audioio -//| import digitalio +//|import board +//|import audiomp3 +//|import audioio +//|import digitalio //| -//| # Required for CircuitPlayground Express -//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//| speaker_enable.switch_to_output(value=True) +//|# Required for CircuitPlayground Express +//|speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//|speaker_enable.switch_to_output(value=True) //| -//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb") -//| mp3 = audiomp3.MP3Decoder(data) -//| a = audioio.AudioOut(board.A0) +//|data = open("cplay-16bit-16khz-64kbps.mp3", "rb") +//|mp3 = audiomp3.MP3Decoder(data) +//|a = audioio.AudioOut(board.A0) //| -//| print("playing") -//| a.play(mp3) -//| while a.playing: -//| pass -//| print("stopped")""" -//| ... +//|print("playing") +//|a.play(mp3) +//|while a.playing: +//|pass +//|print("stopped")""" +//|... STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 2, false); @@ -92,9 +92,9 @@ STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the MP3 and releases all memory resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the MP3 and releases all memory resources for reuse.""" +//|... STATIC mp_obj_t audiomp3_mp3file_deinit(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiomp3_mp3file_deinit(self); @@ -108,16 +108,15 @@ STATIC void check_for_deinit(audiomp3_mp3file_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context. See +//|:ref:`lifetime-and-contextmanagers` for more info.""" +//|... STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiomp3_mp3file_deinit(args[0]); @@ -125,9 +124,9 @@ STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__); -//| file: Any = -//| """File to play back.""" -//| ... +//|file: Any = +//|"""File to play back.""" +//|... STATIC mp_obj_t audiomp3_mp3file_obj_get_file(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -155,11 +154,11 @@ const mp_obj_property_t audiomp3_mp3file_file_obj = { -//| sample_rate: Any = -//| """32 bit value that dictates how quickly samples are loaded into the DAC -//| in Hertz (cycles per second). When the sample is looped, this can change -//| the pitch output without changing the underlying sample.""" -//| ... +//|sample_rate: Any = +//|"""32 bit value that dictates how quickly samples are loaded into the DAC +//|in Hertz (cycles per second). When the sample is looped, this can change +//|the pitch output without changing the underlying sample.""" +//|... STATIC mp_obj_t audiomp3_mp3file_obj_get_sample_rate(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -182,9 +181,9 @@ const mp_obj_property_t audiomp3_mp3file_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| bits_per_sample: Any = -//| """Bits per sample. (read only)""" -//| ... +//|bits_per_sample: Any = +//|"""Bits per sample. (read only)""" +//|... STATIC mp_obj_t audiomp3_mp3file_obj_get_bits_per_sample(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -199,9 +198,9 @@ const mp_obj_property_t audiomp3_mp3file_bits_per_sample_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| channel_count: Any = -//| """Number of audio channels. (read only)""" -//| ... +//|channel_count: Any = +//|"""Number of audio channels. (read only)""" +//|... STATIC mp_obj_t audiomp3_mp3file_obj_get_channel_count(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -216,9 +215,9 @@ const mp_obj_property_t audiomp3_mp3file_channel_count_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| rms_level: Any = -//| """The RMS audio level of a recently played moment of audio. (read only)""" -//| ... +//|rms_level: Any = +//|"""The RMS audio level of a recently played moment of audio. (read only)""" +//|... STATIC mp_obj_t audiomp3_mp3file_obj_get_rms_level(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); From cc290c50c677e16ccdddae74ab0861c9101727fc Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Tue, 28 Apr 2020 18:15:38 -0700 Subject: [PATCH 024/216] fixing diff error --- supervisor/shared/external_flash/external_flash.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 6c14da4107..ce47929757 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -226,18 +226,6 @@ void supervisor_flash_init(void) { while (jedec_id_response[0] == 0xff) { spi_flash_read_command(CMD_READ_JEDEC_ID, jedec_id_response, 3); } - - for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { - const external_flash_device* possible_device = &possible_devices[i]; - if (jedec_id_response[0] == possible_device->manufacturer_id && - jedec_id_response[1] == possible_device->memory_type && - jedec_id_response[2] == possible_device->capacity) { - flash_device = possible_device; - break; - } - } -#endif - for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { const external_flash_device* possible_device = &possible_devices[i]; if (jedec_id_response[0] == possible_device->manufacturer_id && From 8c77252adf4b78a2a4fe5d138e470fb70ae7233b Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 29 Apr 2020 10:29:12 -0700 Subject: [PATCH 025/216] Better handle //| and do __init__.c first. --- tools/extract_pyi.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index c7f3e4604e..de783eb270 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -20,12 +20,22 @@ for module in modules: if not os.path.isdir(module_path): continue pyi_lines = [] - for class_file in os.listdir(module_path): + classes = os.listdir(module_path) + classes = [x for x in sorted(classes) if x.endswith(".c")] + if classes[-1] == "__init__.c": + classes.insert(0, classes.pop()) + for class_file in classes: class_path = os.path.join(module_path, class_file) with open(class_path, "r") as f: for line in f: - if line.startswith("//| "): - pyi_lines.append(line[4:]) + if line.startswith("//|"): + if line[3] == " ": + line = line[4:] + elif line[3] == "\n": + line = line[3:] + else: + continue + pyi_lines.append(line) stub_filename = os.path.join(stub_directory, module + ".pyi") print(stub_filename) From 93d1e53c66f73b6a2d85398dba7924472f1f053d Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 29 Apr 2020 14:19:04 -0400 Subject: [PATCH 026/216] Hopefully fixed whitespace issues --- shared-bindings/busio/SPI.c | 200 +++++++++++++++---------------- shared-bindings/busio/__init__.c | 4 +- 2 files changed, 102 insertions(+), 102 deletions(-) diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 5643b0d04e..9644f4eb5d 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -41,43 +41,43 @@ #include "supervisor/shared/translate.h" -//|class SPI: -//|""".. currentmodule:: busio +//| class SPI: +//| """.. currentmodule:: busio //| -//|`SPI` -- a 3-4 wire serial protocol -//|----------------------------------------------- +//| `SPI` -- a 3-4 wire serial protocol +//| ----------------------------------------------- //| -//|SPI is a serial protocol that has exclusive pins for data in and out of the -//|master. It is typically faster than :py:class:`~busio.I2C` because a -//|separate pin is used to control the active slave rather than a transitted -//|address. This class only manages three of the four SPI lines: `!clock`, -//|`!MOSI`, `!MISO`. Its up to the client to manage the appropriate slave -//|select line. (This is common because multiple slaves can share the `!clock`, -//|`!MOSI` and `!MISO` lines and therefore the hardware.)""" +//| SPI is a serial protocol that has exclusive pins for data in and out of the +//| master. It is typically faster than :py:class:`~busio.I2C` because a +//| separate pin is used to control the active slave rather than a transitted +//| address. This class only manages three of the four SPI lines: `!clock`, +//| `!MOSI`, `!MISO`. Its up to the client to manage the appropriate slave +//| select line. (This is common because multiple slaves can share the `!clock`, +//| `!MOSI` and `!MISO` lines and therefore the hardware.)""" //| -//|def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): +//| def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): //| -//|"""Construct an SPI object on the given pins. +//| """Construct an SPI object on the given pins. //| -//|..note:: The SPI peripherals allocated in order of desirability, if possible, -//|such as highest speed and not shared use first. For instance, on the nRF52840, -//|there is a single 32MHz SPI peripheral, and multiple 8MHz peripherals, -//|some of which may also be used for I2C. The 32MHz SPI peripheral is returned -//|first, then the exclusive 8MHz SPI peripheral, and finally the shared 8MHz -//|peripherals. +//| ..note:: The SPI peripherals allocated in order of desirability, if possible, +//| such as highest speed and not shared use first. For instance, on the nRF52840, +//| there is a single 32MHz SPI peripheral, and multiple 8MHz peripherals, +//| some of which may also be used for I2C. The 32MHz SPI peripheral is returned +//| first, then the exclusive 8MHz SPI peripheral, and finally the shared 8MHz +//| peripherals. //| -//|.. seealso:: Using this class directly requires careful lock management. -//|Instead, use :class:`~adafruit_bus_device.spi_device.SPIDevice` to -//|manage locks. +//| .. seealso:: Using this class directly requires careful lock management. +//| Instead, use :class:`~adafruit_bus_device.spi_device.SPIDevice` to +//| manage locks. //| -//|.. seealso:: Using this class to directly read registers requires manual -//|bit unpacking. Instead, use an existing driver or make one with -//|:ref:`Register ` data descriptors. +//| .. seealso:: Using this class to directly read registers requires manual +//| bit unpacking. Instead, use an existing driver or make one with +//| :ref:`Register ` data descriptors. //| -//|:param ~microcontroller.Pin clock: the pin to use for the clock. -//|:param ~microcontroller.Pin MOSI: the Master Out Slave In pin. -//|:param ~microcontroller.Pin MISO: the Master In Slave Out pin.""" -//|... +//| :param ~microcontroller.Pin clock: the pin to use for the clock. +//| :param ~microcontroller.Pin MOSI: the Master Out Slave In pin. +//| :param ~microcontroller.Pin MISO: the Master In Slave Out pin.""" +//| ... // TODO(tannewt): Support LSB SPI. @@ -101,9 +101,9 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Turn off the SPI bus.""" -//|... +//| def deinit(self, ) -> Any: +//| """Turn off the SPI bus.""" +//| ... STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_spi_deinit(self); @@ -111,15 +111,15 @@ STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit); -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers. -//|Provided by context manager helper.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers. +//| Provided by context manager helper.""" +//| ... -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_spi_deinit(args[0]); @@ -140,28 +140,28 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) { } } -//|def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: -//|"""Configures the SPI bus. The SPI object must be locked. +//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: +//| """Configures the SPI bus. The SPI object must be locked. //| -//|:param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower -//|due to the granularity of available clock settings. -//|Check the `frequency` attribute for the actual clock rate. -//|:param int polarity: the base state of the clock line (0 or 1) -//|:param int phase: the edge of the clock that data is captured. First (0) -//|or second (1). Rising or falling depends on clock polarity. -//|:param int bits: the number of bits per word +//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower +//| due to the granularity of available clock settings. +//| Check the `frequency` attribute for the actual clock rate. +//| :param int polarity: the base state of the clock line (0 or 1) +//| :param int phase: the edge of the clock that data is captured. First (0) +//| or second (1). Rising or falling depends on clock polarity. +//| :param int bits: the number of bits per word //| -//|.. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that -//|speed is not guaranteed to work. 12 MHz is the next available lower speed, and is -//|within spec for the SAMD21. +//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that +//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is +//| within spec for the SAMD21. //| -//|.. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz, -//|and 8MHz. -//|If you pick a a baudrate other than one of these, the nearest lower -//|baudrate will be chosen, with a minimum of 125kHz. -//|Two SPI objects may be created, except on the Circuit Playground Bluefruit, -//|which allows only one (to allow for an additional I2C object).""" -//|... +//| .. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz, +//| and 8MHz. +//| If you pick a a baudrate other than one of these, the nearest lower +//| baudrate will be chosen, with a minimum of 125kHz. +//| Two SPI objects may be created, except on the Circuit Playground Bluefruit, +//| which allows only one (to allow for an additional I2C object).""" +//| ... STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits }; @@ -198,12 +198,12 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_ } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure); -//|def try_lock(self, ) -> Any: -//|"""Attempts to grab the SPI lock. Returns True on success. +//| def try_lock(self, ) -> Any: +//| """Attempts to grab the SPI lock. Returns True on success. //| -//|:return: True when lock has been grabbed -//|:rtype: bool""" -//|... +//| :return: True when lock has been grabbed +//| :rtype: bool""" +//| ... 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); @@ -211,9 +211,9 @@ STATIC mp_obj_t busio_spi_obj_try_lock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock); -//|unlock(self, ) -> Any: -//|"""Releases the SPI lock.""" -//|... +//| def unlock(self, ) -> Any: +//| """Releases the SPI 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); @@ -223,14 +223,14 @@ STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); -//|def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: ... -//|"""Write the data contained in ``buffer``. The SPI object must be locked. -//|If the buffer is empty, nothing happens. +//| def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: +//| """Write the data contained in ``buffer``. The SPI object must be locked. +//| If the buffer is empty, nothing happens. //| -//|:param bytearray buffer: Write out the data in this buffer -//|:param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` -//|:param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" -//|... +//| :param bytearray buffer: Write out the data in this buffer +//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` +//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" +//| ... STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; @@ -264,16 +264,16 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write); -//|def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: -//|"""Read into ``buffer`` while writing ``write_value`` for each byte read. -//|The SPI object must be locked. -//|If the number of bytes to read is 0, nothing happens. +//| def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: +//| """Read into ``buffer`` while writing ``write_value`` for each byte read. +//| The SPI object must be locked. +//| If the number of bytes to read is 0, nothing happens. //| -//|:param bytearray buffer: Read data into this buffer -//|:param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` -//|:param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` -//|:param int write_value: Value to write while reading. (Usually ignored.)""" -//|... +//| :param bytearray buffer: Read data into this buffer +//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` +//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` +//| :param int write_value: Value to write while reading. (Usually ignored.)""" +//| ... STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; @@ -307,20 +307,20 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto); -//|def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: -//|"""Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. -//|The SPI object must be locked. -//|The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` -//|must be equal. -//|If buffer slice lengths are both 0, nothing happens. +//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: +//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. +//| The SPI object must be locked. +//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` +//| must be equal. +//| If buffer slice lengths are both 0, nothing happens. //| -//|:param bytearray buffer_out: Write out the data in this buffer -//|:param bytearray buffer_in: Read data into this buffer -//|:param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` -//|:param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` -//|:param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` -//|:param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" -//|... +//| :param bytearray buffer_out: Write out the data in this buffer +//| :param bytearray buffer_in: Read data into this buffer +//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` +//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` +//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` +//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" +//| ... STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; @@ -369,10 +369,10 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto); -//|frequency: Any = -//|"""The actual SPI bus frequency. This may not match the frequency requested -//|due to internal limitations.""" -//|... +//| frequency: Any = ... +//| """The actual SPI bus frequency. This may not match the frequency requested +//| due to internal limitations.""" +//| 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); diff --git a/shared-bindings/busio/__init__.c b/shared-bindings/busio/__init__.c index ff2933dc6d..212b3218c1 100644 --- a/shared-bindings/busio/__init__.c +++ b/shared-bindings/busio/__init__.c @@ -38,7 +38,7 @@ #include "py/runtime.h" -//| :mod:`busio` --- Hardware accelerated behavior +//| """:mod:`busio` --- Hardware accelerated behavior //| ================================================= //| //| .. module:: busio @@ -81,7 +81,7 @@ //| This example will initialize the the device, run //| :py:meth:`~busio.I2C.scan` and then :py:meth:`~busio.I2C.deinit` the //| hardware. The last step is optional because CircuitPython automatically -//| resets hardware after a program finishes. +//| resets hardware after a program finishes.""" //| STATIC const mp_rom_map_elem_t busio_module_globals_table[] = { From deccdcc1d668a9e65036872aa0a3064ae9ec959c Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 29 Apr 2020 15:20:05 -0400 Subject: [PATCH 027/216] Did the same for the rest of busio --- shared-bindings/busio/I2C.c | 184 ++++++++++++++++---------------- shared-bindings/busio/OneWire.c | 87 ++++++++------- shared-bindings/busio/UART.c | 164 ++++++++++++++-------------- 3 files changed, 216 insertions(+), 219 deletions(-) diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 8b71be085d..31dd9a7bf6 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -36,33 +36,35 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//|class I2C: -//|""".. currentmodule:: busio +//| class I2C: +//| """.. currentmodule:: busio //| -//|:class:`I2C` --- Two wire serial protocol -//|------------------------------------------""" -//|def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255): -//|"""I2C is a two-wire protocol for communicating between devices. At the -//|physical level it consists of 2 wires: SCL and SDA, the clock and data -//|lines respectively. +//| :class:`I2C` --- Two wire serial protocol +//| ------------------------------------------""" //| -//|.. seealso:: Using this class directly requires careful lock management. -//|Instead, use :class:`~adafruit_bus_device.i2c_device.I2CDevice` to -//|manage locks. +//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255): //| -//|.. seealso:: Using this class to directly read registers requires manual -//|bit unpacking. Instead, use an existing driver or make one with -//|:ref:`Register ` data descriptors. +//| """I2C is a two-wire protocol for communicating between devices. At the +//| physical level it consists of 2 wires: SCL and SDA, the clock and data +//| lines respectively. //| -//|:param ~microcontroller.Pin scl: The clock pin -//|:param ~microcontroller.Pin sda: The data pin -//|:param int frequency: The clock frequency in Hertz -//|:param int timeout: The maximum clock stretching timeut - (used only for bitbangio.I2C; ignored for busio.I2C) +//| .. seealso:: Using this class directly requires careful lock management. +//| Instead, use :class:`~adafruit_bus_device.i2c_device.I2CDevice` to +//| manage locks. //| -//|.. note:: On the nRF52840, only one I2C object may be created, -//|except on the Circuit Playground Bluefruit, which allows two, -//|one for the onboard accelerometer, and one for offboard use.""" -//|... +//| .. seealso:: Using this class to directly read registers requires manual +//| bit unpacking. Instead, use an existing driver or make one with +//| :ref:`Register ` data descriptors. +//| +//| :param ~microcontroller.Pin scl: The clock pin +//| :param ~microcontroller.Pin sda: The data pin +//| :param int frequency: The clock frequency in Hertz +//| :param int timeout: The maximum clock stretching timeut - (used only for bitbangio.I2C; ignored for busio.I2C) +//| +//| .. note:: On the nRF52840, only one I2C object may be created, +//| except on the Circuit Playground Bluefruit, which allows two, +//| one for the onboard accelerometer, and one for offboard use.""" +//| ... STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t); self->base.type = &busio_i2c_type; @@ -83,9 +85,9 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con return (mp_obj_t)self; } -//|def deinit(self, ) -> Any: -//|"""Releases control of the underlying hardware so other classes can use it.""" -//|... +//| def deinit(self, ) -> Any: +//| """Releases control of the underlying hardware so other classes can use it.""" +//| ... STATIC mp_obj_t busio_i2c_obj_deinit(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_i2c_deinit(self); @@ -99,15 +101,15 @@ STATIC void check_for_deinit(busio_i2c_obj_t *self) { } } -//|def __enter__(self, ) -> Any: -//|"""No-op used in Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used in Context Managers.""" +//| ... // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware on context exit. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware on context exit. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_i2c_deinit(args[0]); @@ -122,13 +124,14 @@ static void check_lock(busio_i2c_obj_t *self) { } } -//|def scan(self, ) -> Any: -//|"""Scan all I2C addresses between 0x08 and 0x77 inclusive and return a -//|list of those that respond. +//| def scan(self, ) -> Any: //| -//|:return: List of device ids on the I2C bus -//|:rtype: list""" -//|... +//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a +//| list of those that respond. +//| +//| :return: List of device ids on the I2C bus +//| :rtype: list""" +//| ... STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -145,11 +148,12 @@ STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan); -//|def try_lock(self, ) -> Any: -//|"""Attempts to grab the I2C lock. Returns True on success. -//|:return: True when lock has been grabbed -//|:rtype: bool""" -//|... +//| def try_lock(self, ) -> Any: +//| """Attempts to grab the I2C lock. Returns True on success. +//| +//| :return: True when lock has been grabbed +//| :rtype: bool""" +//| ... 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); check_for_deinit(self); @@ -157,9 +161,9 @@ STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock); -//|def unlock(self, ) -> Any: -//|"""Releases the I2C lock.""" -//|... +//| def unlock(self, ) -> Any: +//| """Releases the I2C 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); check_for_deinit(self); @@ -168,20 +172,20 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); -//|def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any: -//|"""Read into ``buffer`` from the slave specified by ``address``. -//|The number of bytes read will be the length of ``buffer``. -//|At least one byte must be read. +//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any: +//| """Read into ``buffer`` from the slave specified by ``address``. +//| The number of bytes read will be the length of ``buffer``. +//| At least one byte must be read. //| -//|If ``start`` or ``end`` is provided, then the buffer will be sliced -//|as if ``buffer[start:end]``. This will not cause an allocation like -//|``buf[start:end]`` will so it saves memory. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buf[start:end]`` will so it saves memory. //| -//|:param int address: 7-bit device address -//|:param bytearray buffer: buffer to write into -//|:param int start: Index to start writing at -//|:param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" -//|... +//| :param int address: 7-bit device address +//| :param bytearray buffer: buffer to write into +//| :param int start: Index to start writing at +//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| ... // Shared arg parsing for readfrom_into and writeto_then_readfrom. STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; @@ -219,26 +223,26 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, } MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into); -//|def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any: -//|"""Write the bytes from ``buffer`` to the slave specified by ``address``. -//|Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be -//|removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and -//|repeated start before a read. +//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any: +//| """Write the bytes from ``buffer`` to the slave specified by ``address``. +//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be +//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and +//| repeated start before a read. //| -//|If ``start`` or ``end`` is provided, then the buffer will be sliced -//|as if ``buffer[start:end]``. This will not cause an allocation like -//|``buffer[start:end]`` will so it saves memory. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buffer[start:end]`` will so it saves memory. //| -//|Writing a buffer or slice of length zero is permitted, as it can be used -//|to poll for the existence of a device. +//| Writing a buffer or slice of length zero is permitted, as it can be used +//| to poll for the existence of a device. //| -//|:param int address: 7-bit device address -//|:param bytearray buffer: buffer containing the bytes to write -//|:param int start: Index to start writing from -//|:param int end: Index to read up to but not include. Defaults to ``len(buffer)`` -//|:param bool stop: If true, output an I2C stop condition after the buffer is written. -//|Deprecated. Will be removed in 6.x and act as stop=True.""" -//|... +//| :param int address: 7-bit device address +//| :param bytearray buffer: buffer containing the bytes to write +//| :param int start: Index to start writing from +//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)`` +//| :param bool stop: If true, output an I2C stop condition after the buffer is written. +//| Deprecated. Will be removed in 6.x and act as stop=True.""" +//| ... // Shared arg parsing for writeto and writeto_then_readfrom. STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) { // get the buffer to write the data from @@ -277,23 +281,23 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); -//|def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any: -//|"""Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop -//|bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and -//|``in_buffer`` can be the same buffer because they are used sequentially. +//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any: +//| """Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop +//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and +//| ``in_buffer`` can be the same buffer because they are used sequentially. //| -//|If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced -//|as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` -//|will so it saves memory. +//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` +//| will so it saves memory. //| -//|:param int address: 7-bit device address -//|:param bytearray out_buffer: buffer containing the bytes to write -//|:param bytearray in_buffer: buffer to write into -//|:param int out_start: Index to start writing from -//|:param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` -//|:param int in_start: Index to start writing at -//|:param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" -//|... +//| :param int address: 7-bit device address +//| :param bytearray out_buffer: buffer containing the bytes to write +//| :param bytearray in_buffer: buffer to write into +//| :param int out_start: Index to start writing from +//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` +//| :param int in_start: Index to start writing at +//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| ... STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/busio/OneWire.c b/shared-bindings/busio/OneWire.c index d6af32bd95..09a76decc8 100644 --- a/shared-bindings/busio/OneWire.c +++ b/shared-bindings/busio/OneWire.c @@ -34,36 +34,35 @@ #include "shared-bindings/busio/OneWire.h" #include "shared-bindings/util.h" -//|class OneWire: -//|""".. currentmodule:: busio +//| class OneWire: +//| """.. currentmodule:: busio //| -//|:class:`OneWire` -- Lowest-level of the Maxim OneWire protocol -//|=================================================================""" +//| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol +//| =================================================================""" //| -//|__init__(self, pin: microcontroller.Pin): -//|""":class:`~busio.OneWire` implements the timing-sensitive foundation of the Maxim -//|(formerly Dallas Semi) OneWire protocol. +//| def __init__(self, pin: microcontroller.Pin): +//| """(formerly Dallas Semi) OneWire protocol. //| -//|Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126 +//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126 //| -//|.. class:: OneWire(pin) +//| .. class:: OneWire(pin) //| -//|Create a OneWire object associated with the given pin. The object -//|implements the lowest level timing-sensitive bits of the protocol. +//| Create a OneWire object associated with the given pin. The object +//| implements the lowest level timing-sensitive bits of the protocol. //| -//|:param ~microcontroller.Pin pin: Pin connected to the OneWire bus +//| :param ~microcontroller.Pin pin: Pin connected to the OneWire bus //| -//|Read a short series of pulses:: +//| Read a short series of pulses:: //| -//|import busio -//|import board +//| import busio +//| import board //| -//|onewire = busio.OneWire(board.D7) -//|onewire.reset() -//|onewire.write_bit(True) -//|onewire.write_bit(False) -//|print(onewire.read_bit())""" -//|... +//| onewire = busio.OneWire(board.D7) +//| onewire.reset() +//| onewire.write_bit(True) +//| onewire.write_bit(False) +//| print(onewire.read_bit())""" +//| ... STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pin }; static const mp_arg_t allowed_args[] = { @@ -80,9 +79,9 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Deinitialize the OneWire bus and release any hardware resources for reuse.""" -//|... +//| def deinit(self, ) -> Any: +//| """Deinitialize the OneWire bus and release any hardware resources for reuse.""" +//| ... STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_onewire_deinit(self); @@ -96,15 +95,15 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) { } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_onewire_deinit(args[0]); @@ -112,12 +111,12 @@ STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__); -//|def reset(self, ) -> Any: -//|"""Reset the OneWire bus and read presence +//| def reset(self, ) -> Any: +//| """Reset the OneWire bus and read presence //| -//|:returns: False when at least one device is present -//|:rtype: bool""" -//|... +//| :returns: False when at least one device is present +//| :rtype: bool""" +//| ... STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -126,12 +125,12 @@ STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset); -//|def read_bit(self, ) -> Any: -//|"""Read in a bit +//| def read_bit(self, ) -> Any: +//| """Read in a bit //| -//|:returns: bit state read -//|:rtype: bool""" -//|... +//| :returns: bit state read +//| :rtype: bool""" +//| ... 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); check_for_deinit(self); @@ -140,9 +139,9 @@ STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit); -//|def write_bit(self, value: Any) -> Any: -//|"""Write out a bit based on value.""" -//|... +//| def write_bit(self, value: Any) -> Any: +//| """Write out a bit based on value.""" +//| ... 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); check_for_deinit(self); diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index b89b331af4..e5d123ce71 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -39,31 +39,31 @@ #include "py/stream.h" #include "supervisor/shared/translate.h" -//|class UART: -//|""".. currentmodule:: busio +//| class UART: +//| """.. currentmodule:: busio //| -//|:class:`UART` -- a bidirectional serial protocol -//|=================================================""" -//|def __init__(self, tx: microcontroller.Pin, rx: microcontroller.Pin, *, baudrate: int = 9600, bits: int = 8, parity: Parity = None, stop: int = 1, timeout: float = 1, receiver_buffer_size: int = 64): -//|"""A common bidirectional serial protocol that uses an an agreed upon speed -//|rather than a shared clock line. +//| :class:`UART` -- a bidirectional serial protocol +//| =================================================""" +//| def __init__(self, tx: microcontroller.Pin, rx: microcontroller.Pin, *, baudrate: int = 9600, bits: int = 8, parity: Parity = None, stop: int = 1, timeout: float = 1, receiver_buffer_size: int = 64): +//| """A common bidirectional serial protocol that uses an an agreed upon speed +//| rather than a shared clock line. //| -//|:param ~microcontroller.Pin tx: the pin to transmit with, or ``None`` if this ``UART`` is receive-only. -//|:param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only. -//|:param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use. -//|:param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use. -//|:param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use. -//|:param bool rs485_invert: set to invert the sense of the rs485_dir pin. -//|:param int baudrate: the transmit and receive speed. -//|:param int bits: the number of bits per byte, 7, 8 or 9. -//|:param Parity parity: the parity used for error checking. -//|:param int stop: the number of stop bits, 1 or 2. -//|:param float timeout: the timeout in seconds to wait for the first character and between subsequent characters when reading. Raises ``ValueError`` if timeout >100 seconds. -//|:param int receiver_buffer_size: the character length of the read buffer (0 to disable). (When a character is 9 bits the buffer will be 2 * receiver_buffer_size bytes.) +//| :param ~microcontroller.Pin tx: the pin to transmit with, or ``None`` if this ``UART`` is receive-only. +//| :param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only. +//| :param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use. +//| :param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use. +//| :param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use. +//| :param bool rs485_invert: set to invert the sense of the rs485_dir pin. +//| :param int baudrate: the transmit and receive speed. +//| :param int bits: the number of bits per byte, 7, 8 or 9. +//| :param Parity parity: the parity used for error checking. +//| :param int stop: the number of stop bits, 1 or 2. +//| :param float timeout: the timeout in seconds to wait for the first character and between subsequent characters when reading. Raises ``ValueError`` if timeout >100 seconds. +//| :param int receiver_buffer_size: the character length of the read buffer (0 to disable). (When a character is 9 bits the buffer will be 2 * receiver_buffer_size bytes.) //| -//|*New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. -//|The new upper limit on ``timeout`` is meant to catch mistaken use of milliseconds.""" -//|... +//| *New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. +//| The new upper limit on ``timeout`` is meant to catch mistaken use of milliseconds.""" +//| ... typedef struct { mp_obj_base_t base; } busio_uart_parity_obj_t; @@ -141,9 +141,9 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co return (mp_obj_t)self; } -//|def deinit(self, ) -> Any: -//|"""Deinitialises the UART and releases any hardware resources for reuse.""" -//|... +//| def deinit(self, ) -> Any: +//| """Deinitialises the UART and releases any hardware resources for reuse.""" +//| ... STATIC mp_obj_t busio_uart_obj_deinit(mp_obj_t self_in) { busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_uart_deinit(self); @@ -157,15 +157,15 @@ STATIC void check_for_deinit(busio_uart_obj_t *self) { } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_uart_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_uart_deinit(args[0]); @@ -175,46 +175,40 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ // These are standard stream methods. Code is in py/stream.c. // -//|def read(self, nbytes: Any = None) -> Any: -//|"""Read characters. If ``nbytes`` is specified then read at most that many -//|bytes. Otherwise, read everything that arrives until the connection -//|times out. Providing the number of bytes expected is highly recommended -//|because it will be faster. +//| def read(self, nbytes: Any = None) -> Any: +//| """Read characters. If ``nbytes`` is specified then read at most that many +//| bytes. Otherwise, read everything that arrives until the connection +//| times out. Providing the number of bytes expected is highly recommended +//| because it will be faster. //| -//|:return: Data read -//|:rtype: bytes or None""" -//|... +//| :return: Data read +//| :rtype: bytes or None""" +//| ... -//|def readinto(self, buf: Any) -> Any: -//|""".. method:: readinto(buf) +//| def readinto(self, buf: Any) -> Any: +//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. //| -//|Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. +//| :return: number of bytes read and stored into ``buf`` +//| :rtype: int or None (on a non-blocking error) //| -//|:return: number of bytes read and stored into ``buf`` -//|:rtype: int or None (on a non-blocking error) -//| -//|*New in CircuitPython 4.0:* No length parameter is permitted.""" -//|... +//| *New in CircuitPython 4.0:* No length parameter is permitted.""" +//| ... -//|def readline(self, ) -> Any: -//|""".. method:: readline() +//| def readline(self, ) -> Any: +//| """Read a line, ending in a newline character. //| -//|Read a line, ending in a newline character. -//| -//|:return: the line read -//|:rtype: int or None""" -//|... +//| :return: the line read +//| :rtype: int or None""" +//| ... -//|def write(self, buf: Any) -> Any: -//|""".. method:: write(buf) +//| def write(self, buf: Any) -> Any: +//| """Write the buffer of bytes to the bus. //| -//|Write the buffer of bytes to the bus. +//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. //| -//|*New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. -//| -//|:return: the number of bytes written -//|:rtype: int or None""" -//|... +//| :return: the number of bytes written +//| :rtype: int or None""" +//| ... // 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) { @@ -258,9 +252,9 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t return ret; } -//|baudrate: Any = -//|"""The current baudrate.""" -//|... +//| baudrate: Any = ... +//| """The current baudrate.""" +//| 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); check_for_deinit(self); @@ -284,9 +278,9 @@ const mp_obj_property_t busio_uart_baudrate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|in_waiting: Any = -//|"""The number of bytes in the input buffer, available to be read""" -//|... +//| in_waiting: Any = ... +//| """The number of bytes in the input buffer, available to be read""" +//| 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); check_for_deinit(self); @@ -301,9 +295,9 @@ const mp_obj_property_t busio_uart_in_waiting_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|timeout: Any = -//|"""The current timeout, in seconds (float).""" -//|... +//| timeout: Any = ... +//| """The current timeout, in seconds (float).""" +//| STATIC mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) { busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -329,9 +323,9 @@ const mp_obj_property_t busio_uart_timeout_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|def reset_input_buffer(self, ) -> Any: -//|"""Discard any unread characters in the input buffer.""" -//|... +//| def reset_input_buffer(self, ) -> Any: ... +//| """Discard any unread characters in the input buffer.""" +//| 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); check_for_deinit(self); @@ -340,16 +334,16 @@ STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_obj_reset_input_buffer); -//|class busio: -//|def __init__(self, ): -//|"""Enum-like class to define the parity used to verify correct data transfer.""" -//|ODD: Any = -//|"""Total number of ones should be odd.""" -//|... -//|EVEN: Any = -//|"""Total number of ones should be even.""" -//|... -//|... +//| class busio: +//| """Enum-like class to define the parity used to verify correct data transfer.""" +//| +//| def __init__(self, ): +//| ODD: Any = ... +//| """Total number of ones should be odd.""" +//| +//| EVEN: Any = ... +//| """Total number of ones should be even.""" +//| ... const mp_obj_type_t busio_uart_parity_type; const busio_uart_parity_obj_t busio_uart_parity_odd_obj = { From 093461e81670d8ad635d8f893a44426a46b9779c Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 29 Apr 2020 15:45:19 -0400 Subject: [PATCH 028/216] Fixed indentation --- shared-bindings/busio/I2C.c | 136 +++++++++++++++---------------- shared-bindings/busio/OneWire.c | 46 +++++------ shared-bindings/busio/SPI.c | 140 ++++++++++++++++---------------- shared-bindings/busio/UART.c | 88 ++++++++++---------- 4 files changed, 205 insertions(+), 205 deletions(-) diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 31dd9a7bf6..98ccbb5127 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -85,9 +85,9 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con return (mp_obj_t)self; } -//| def deinit(self, ) -> Any: -//| """Releases control of the underlying hardware so other classes can use it.""" -//| ... +//| def deinit(self, ) -> Any: +//| """Releases control of the underlying hardware so other classes can use it.""" +//| ... STATIC mp_obj_t busio_i2c_obj_deinit(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_i2c_deinit(self); @@ -101,15 +101,15 @@ STATIC void check_for_deinit(busio_i2c_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used in Context Managers.""" -//| ... +//| def __enter__(self, ) -> Any: +//| """No-op used in Context Managers.""" +//| ... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware on context exit. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware on context exit. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_i2c_deinit(args[0]); @@ -124,14 +124,14 @@ static void check_lock(busio_i2c_obj_t *self) { } } -//| def scan(self, ) -> Any: +//| def scan(self, ) -> Any: //| -//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a -//| list of those that respond. +//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a +//| list of those that respond. //| -//| :return: List of device ids on the I2C bus -//| :rtype: list""" -//| ... +//| :return: List of device ids on the I2C bus +//| :rtype: list""" +//| ... STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -148,12 +148,12 @@ STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan); -//| def try_lock(self, ) -> Any: -//| """Attempts to grab the I2C lock. Returns True on success. +//| def try_lock(self, ) -> Any: +//| """Attempts to grab the I2C lock. Returns True on success. //| -//| :return: True when lock has been grabbed -//| :rtype: bool""" -//| ... +//| :return: True when lock has been grabbed +//| :rtype: bool""" +//| ... 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); check_for_deinit(self); @@ -161,9 +161,9 @@ STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock); -//| def unlock(self, ) -> Any: -//| """Releases the I2C lock.""" -//| ... +//| def unlock(self, ) -> Any: +//| """Releases the I2C 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); check_for_deinit(self); @@ -172,20 +172,20 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); -//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any: -//| """Read into ``buffer`` from the slave specified by ``address``. -//| The number of bytes read will be the length of ``buffer``. -//| At least one byte must be read. +//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any: +//| """Read into ``buffer`` from the slave specified by ``address``. +//| The number of bytes read will be the length of ``buffer``. +//| At least one byte must be read. //| -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buf[start:end]`` will so it saves memory. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buf[start:end]`` will so it saves memory. //| -//| :param int address: 7-bit device address -//| :param bytearray buffer: buffer to write into -//| :param int start: Index to start writing at -//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" -//| ... +//| :param int address: 7-bit device address +//| :param bytearray buffer: buffer to write into +//| :param int start: Index to start writing at +//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| ... // Shared arg parsing for readfrom_into and writeto_then_readfrom. STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; @@ -223,26 +223,26 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, } MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into); -//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any: -//| """Write the bytes from ``buffer`` to the slave specified by ``address``. -//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be -//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and -//| repeated start before a read. +//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any: +//| """Write the bytes from ``buffer`` to the slave specified by ``address``. +//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be +//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and +//| repeated start before a read. //| -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buffer[start:end]`` will so it saves memory. //| -//| Writing a buffer or slice of length zero is permitted, as it can be used -//| to poll for the existence of a device. +//| Writing a buffer or slice of length zero is permitted, as it can be used +//| to poll for the existence of a device. //| -//| :param int address: 7-bit device address -//| :param bytearray buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param bool stop: If true, output an I2C stop condition after the buffer is written. -//| Deprecated. Will be removed in 6.x and act as stop=True.""" -//| ... +//| :param int address: 7-bit device address +//| :param bytearray buffer: buffer containing the bytes to write +//| :param int start: Index to start writing from +//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)`` +//| :param bool stop: If true, output an I2C stop condition after the buffer is written. +//| Deprecated. Will be removed in 6.x and act as stop=True.""" +//| ... // Shared arg parsing for writeto and writeto_then_readfrom. STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) { // get the buffer to write the data from @@ -281,23 +281,23 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); -//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any: -//| """Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop -//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and -//| ``in_buffer`` can be the same buffer because they are used sequentially. +//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any: +//| """Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop +//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and +//| ``in_buffer`` can be the same buffer because they are used sequentially. //| -//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` -//| will so it saves memory. +//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` +//| will so it saves memory. //| -//| :param int address: 7-bit device address -//| :param bytearray out_buffer: buffer containing the bytes to write -//| :param bytearray in_buffer: buffer to write into -//| :param int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" -//| ... +//| :param int address: 7-bit device address +//| :param bytearray out_buffer: buffer containing the bytes to write +//| :param bytearray in_buffer: buffer to write into +//| :param int out_start: Index to start writing from +//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` +//| :param int in_start: Index to start writing at +//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| ... STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/busio/OneWire.c b/shared-bindings/busio/OneWire.c index 09a76decc8..e44c876c57 100644 --- a/shared-bindings/busio/OneWire.c +++ b/shared-bindings/busio/OneWire.c @@ -79,9 +79,9 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialize the OneWire bus and release any hardware resources for reuse.""" -//| ... +//| def deinit(self, ) -> Any: +//| """Deinitialize the OneWire bus and release any hardware resources for reuse.""" +//| ... STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_onewire_deinit(self); @@ -95,15 +95,15 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_onewire_deinit(args[0]); @@ -111,12 +111,12 @@ STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__); -//| def reset(self, ) -> Any: -//| """Reset the OneWire bus and read presence +//| def reset(self, ) -> Any: +//| """Reset the OneWire bus and read presence //| -//| :returns: False when at least one device is present -//| :rtype: bool""" -//| ... +//| :returns: False when at least one device is present +//| :rtype: bool""" +//| ... STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -125,12 +125,12 @@ STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset); -//| def read_bit(self, ) -> Any: -//| """Read in a bit +//| def read_bit(self, ) -> Any: +//| """Read in a bit //| -//| :returns: bit state read -//| :rtype: bool""" -//| ... +//| :returns: bit state read +//| :rtype: bool""" +//| ... 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); check_for_deinit(self); @@ -139,9 +139,9 @@ STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit); -//| def write_bit(self, value: Any) -> Any: -//| """Write out a bit based on value.""" -//| ... +//| def write_bit(self, value: Any) -> Any: +//| """Write out a bit based on value.""" +//| ... 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); check_for_deinit(self); diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 9644f4eb5d..93588d0879 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -101,9 +101,9 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Turn off the SPI bus.""" -//| ... +//| def deinit(self, ) -> Any: +//| """Turn off the SPI bus.""" +//| ... STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_spi_deinit(self); @@ -111,15 +111,15 @@ STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit); -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers. -//| Provided by context manager helper.""" -//| ... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers. +//| Provided by context manager helper.""" +//| ... -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_spi_deinit(args[0]); @@ -140,28 +140,28 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) { } } -//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: -//| """Configures the SPI bus. The SPI object must be locked. +//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: +//| """Configures the SPI bus. The SPI object must be locked. //| -//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower -//| due to the granularity of available clock settings. -//| Check the `frequency` attribute for the actual clock rate. -//| :param int polarity: the base state of the clock line (0 or 1) -//| :param int phase: the edge of the clock that data is captured. First (0) -//| or second (1). Rising or falling depends on clock polarity. -//| :param int bits: the number of bits per word +//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower +//| due to the granularity of available clock settings. +//| Check the `frequency` attribute for the actual clock rate. +//| :param int polarity: the base state of the clock line (0 or 1) +//| :param int phase: the edge of the clock that data is captured. First (0) +//| or second (1). Rising or falling depends on clock polarity. +//| :param int bits: the number of bits per word //| -//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that -//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is -//| within spec for the SAMD21. +//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that +//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is +//| within spec for the SAMD21. //| -//| .. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz, -//| and 8MHz. -//| If you pick a a baudrate other than one of these, the nearest lower -//| baudrate will be chosen, with a minimum of 125kHz. -//| Two SPI objects may be created, except on the Circuit Playground Bluefruit, -//| which allows only one (to allow for an additional I2C object).""" -//| ... +//| .. note:: On the nRF52840, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz, +//| and 8MHz. +//| If you pick a a baudrate other than one of these, the nearest lower +//| baudrate will be chosen, with a minimum of 125kHz. +//| Two SPI objects may be created, except on the Circuit Playground Bluefruit, +//| which allows only one (to allow for an additional I2C object).""" +//| ... STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits }; @@ -198,12 +198,12 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_ } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure); -//| def try_lock(self, ) -> Any: -//| """Attempts to grab the SPI lock. Returns True on success. +//| def try_lock(self, ) -> Any: +//| """Attempts to grab the SPI lock. Returns True on success. //| -//| :return: True when lock has been grabbed -//| :rtype: bool""" -//| ... +//| :return: True when lock has been grabbed +//| :rtype: bool""" +//| ... 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); @@ -211,9 +211,9 @@ STATIC mp_obj_t busio_spi_obj_try_lock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock); -//| def unlock(self, ) -> Any: -//| """Releases the SPI lock.""" -//| ... +//| def unlock(self, ) -> Any: +//| """Releases the SPI 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); @@ -223,14 +223,14 @@ STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); -//| def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: -//| """Write the data contained in ``buffer``. The SPI object must be locked. -//| If the buffer is empty, nothing happens. +//| def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any: +//| """Write the data contained in ``buffer``. The SPI object must be locked. +//| If the buffer is empty, nothing happens. //| -//| :param bytearray buffer: Write out the data in this buffer -//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` -//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" -//| ... +//| :param bytearray buffer: Write out the data in this buffer +//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` +//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" +//| ... STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; @@ -264,16 +264,16 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write); -//| def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: -//| """Read into ``buffer`` while writing ``write_value`` for each byte read. -//| The SPI object must be locked. -//| If the number of bytes to read is 0, nothing happens. +//| def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any: +//| """Read into ``buffer`` while writing ``write_value`` for each byte read. +//| The SPI object must be locked. +//| If the number of bytes to read is 0, nothing happens. //| -//| :param bytearray buffer: Read data into this buffer -//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` -//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` -//| :param int write_value: Value to write while reading. (Usually ignored.)""" -//| ... +//| :param bytearray buffer: Read data into this buffer +//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` +//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` +//| :param int write_value: Value to write while reading. (Usually ignored.)""" +//| ... STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; @@ -307,20 +307,20 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto); -//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: -//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. -//| The SPI object must be locked. -//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` -//| must be equal. -//| If buffer slice lengths are both 0, nothing happens. +//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: +//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. +//| The SPI object must be locked. +//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` +//| must be equal. +//| If buffer slice lengths are both 0, nothing happens. //| -//| :param bytearray buffer_out: Write out the data in this buffer -//| :param bytearray buffer_in: Read data into this buffer -//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` -//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` -//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` -//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" -//| ... +//| :param bytearray buffer_out: Write out the data in this buffer +//| :param bytearray buffer_in: Read data into this buffer +//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` +//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` +//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` +//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" +//| ... STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; @@ -369,9 +369,9 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args } MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto); -//| frequency: Any = ... -//| """The actual SPI bus frequency. This may not match the frequency requested -//| due to internal limitations.""" +//| frequency: Any = ... +//| """The actual SPI bus frequency. This may not match the frequency requested +//| due to internal limitations.""" //| STATIC mp_obj_t busio_spi_obj_get_frequency(mp_obj_t self_in) { diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index e5d123ce71..7c5c6ec2bc 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -141,9 +141,9 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co return (mp_obj_t)self; } -//| def deinit(self, ) -> Any: -//| """Deinitialises the UART and releases any hardware resources for reuse.""" -//| ... +//| def deinit(self, ) -> Any: +//| """Deinitialises the UART and releases any hardware resources for reuse.""" +//| ... STATIC mp_obj_t busio_uart_obj_deinit(mp_obj_t self_in) { busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_uart_deinit(self); @@ -157,15 +157,15 @@ STATIC void check_for_deinit(busio_uart_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t busio_uart_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_uart_deinit(args[0]); @@ -175,40 +175,40 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ // These are standard stream methods. Code is in py/stream.c. // -//| def read(self, nbytes: Any = None) -> Any: -//| """Read characters. If ``nbytes`` is specified then read at most that many -//| bytes. Otherwise, read everything that arrives until the connection -//| times out. Providing the number of bytes expected is highly recommended -//| because it will be faster. +//| def read(self, nbytes: Any = None) -> Any: +//| """Read characters. If ``nbytes`` is specified then read at most that many +//| bytes. Otherwise, read everything that arrives until the connection +//| times out. Providing the number of bytes expected is highly recommended +//| because it will be faster. //| -//| :return: Data read -//| :rtype: bytes or None""" -//| ... +//| :return: Data read +//| :rtype: bytes or None""" +//| ... -//| def readinto(self, buf: Any) -> Any: -//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. +//| def readinto(self, buf: Any) -> Any: +//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. //| -//| :return: number of bytes read and stored into ``buf`` -//| :rtype: int or None (on a non-blocking error) +//| :return: number of bytes read and stored into ``buf`` +//| :rtype: int or None (on a non-blocking error) //| -//| *New in CircuitPython 4.0:* No length parameter is permitted.""" -//| ... +//| *New in CircuitPython 4.0:* No length parameter is permitted.""" +//| ... -//| def readline(self, ) -> Any: -//| """Read a line, ending in a newline character. +//| def readline(self, ) -> Any: +//| """Read a line, ending in a newline character. //| -//| :return: the line read -//| :rtype: int or None""" -//| ... +//| :return: the line read +//| :rtype: int or None""" +//| ... -//| def write(self, buf: Any) -> Any: -//| """Write the buffer of bytes to the bus. +//| def write(self, buf: Any) -> Any: +//| """Write the buffer of bytes to the bus. //| -//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. +//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string. //| -//| :return: the number of bytes written -//| :rtype: int or None""" -//| ... +//| :return: the number of bytes written +//| :rtype: int or None""" +//| ... // 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) { @@ -252,8 +252,8 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t return ret; } -//| baudrate: Any = ... -//| """The current baudrate.""" +//| baudrate: Any = ... +//| """The current baudrate.""" //| 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); @@ -278,8 +278,8 @@ const mp_obj_property_t busio_uart_baudrate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| in_waiting: Any = ... -//| """The number of bytes in the input buffer, available to be read""" +//| in_waiting: Any = ... +//| """The number of bytes in the input buffer, available to be read""" //| 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); @@ -295,8 +295,8 @@ const mp_obj_property_t busio_uart_in_waiting_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| timeout: Any = ... -//| """The current timeout, in seconds (float).""" +//| timeout: Any = ... +//| """The current timeout, in seconds (float).""" //| STATIC mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) { busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -323,8 +323,8 @@ const mp_obj_property_t busio_uart_timeout_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def reset_input_buffer(self, ) -> Any: ... -//| """Discard any unread characters in the input buffer.""" +//| def reset_input_buffer(self, ) -> Any: ... +//| """Discard any unread characters in the input buffer.""" //| 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); @@ -334,7 +334,7 @@ STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_obj_reset_input_buffer); -//| class busio: +//| class Parity: //| """Enum-like class to define the parity used to verify correct data transfer.""" //| //| def __init__(self, ): From a2a32fea1acc4caefb6c4142b547d8a09b2ba761 Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 29 Apr 2020 15:55:06 -0400 Subject: [PATCH 029/216] Added newlines after every ellipsis --- shared-bindings/busio/I2C.c | 10 ++++++++++ shared-bindings/busio/OneWire.c | 7 +++++++ shared-bindings/busio/SPI.c | 10 ++++++++++ shared-bindings/busio/UART.c | 9 +++++++++ 4 files changed, 36 insertions(+) diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 98ccbb5127..8ae3658eee 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -65,6 +65,7 @@ //| except on the Circuit Playground Bluefruit, which allows two, //| one for the onboard accelerometer, and one for offboard use.""" //| ... +//| STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t); self->base.type = &busio_i2c_type; @@ -88,6 +89,7 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con //| def deinit(self, ) -> Any: //| """Releases control of the underlying hardware so other classes can use it.""" //| ... +//| STATIC mp_obj_t busio_i2c_obj_deinit(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_i2c_deinit(self); @@ -104,12 +106,14 @@ STATIC void check_for_deinit(busio_i2c_obj_t *self) { //| def __enter__(self, ) -> Any: //| """No-op used in Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self, ) -> Any: //| """Automatically deinitializes the hardware on context exit. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| STATIC mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_i2c_deinit(args[0]); @@ -132,6 +136,7 @@ static void check_lock(busio_i2c_obj_t *self) { //| :return: List of device ids on the I2C bus //| :rtype: list""" //| ... +//| STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -154,6 +159,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan); //| :return: True when lock has been grabbed //| :rtype: bool""" //| ... +//| 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); check_for_deinit(self); @@ -164,6 +170,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock); //| def unlock(self, ) -> Any: //| """Releases the I2C 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); check_for_deinit(self); @@ -186,6 +193,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); //| :param int start: Index to start writing at //| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" //| ... +//| // Shared arg parsing for readfrom_into and writeto_then_readfrom. STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; @@ -243,6 +251,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_in //| :param bool stop: If true, output an I2C stop condition after the buffer is written. //| Deprecated. Will be removed in 6.x and act as stop=True.""" //| ... +//| // Shared arg parsing for writeto and writeto_then_readfrom. STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) { // get the buffer to write the data from @@ -298,6 +307,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); //| :param int in_start: Index to start writing at //| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" //| ... +//| STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/busio/OneWire.c b/shared-bindings/busio/OneWire.c index e44c876c57..556e567efc 100644 --- a/shared-bindings/busio/OneWire.c +++ b/shared-bindings/busio/OneWire.c @@ -63,6 +63,7 @@ //| onewire.write_bit(False) //| print(onewire.read_bit())""" //| ... +//| STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pin }; static const mp_arg_t allowed_args[] = { @@ -82,6 +83,7 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, //| def deinit(self, ) -> Any: //| """Deinitialize the OneWire bus and release any hardware resources for reuse.""" //| ... +//| STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_onewire_deinit(self); @@ -98,12 +100,14 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) { //| def __enter__(self, ) -> Any: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self, ) -> Any: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_onewire_deinit(args[0]); @@ -117,6 +121,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, bus //| :returns: False when at least one device is present //| :rtype: bool""" //| ... +//| STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) { busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -131,6 +136,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset); //| :returns: bit state read //| :rtype: bool""" //| ... +//| 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); check_for_deinit(self); @@ -142,6 +148,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit //| def write_bit(self, value: Any) -> Any: //| """Write out a bit based on value.""" //| ... +//| 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); check_for_deinit(self); diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 93588d0879..5b1881702c 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -78,6 +78,7 @@ //| :param ~microcontroller.Pin MOSI: the Master Out Slave In pin. //| :param ~microcontroller.Pin MISO: the Master In Slave Out pin.""" //| ... +//| // TODO(tannewt): Support LSB SPI. @@ -104,6 +105,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con //| def deinit(self, ) -> Any: //| """Turn off the SPI bus.""" //| ... +//| STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_spi_deinit(self); @@ -115,11 +117,13 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit); //| """No-op used by Context Managers. //| Provided by context manager helper.""" //| ... +//| //| def __exit__(self, ) -> Any: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_spi_deinit(args[0]); @@ -162,6 +166,7 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) { //| Two SPI objects may be created, except on the Circuit Playground Bluefruit, //| which allows only one (to allow for an additional I2C object).""" //| ... +//| STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits }; @@ -204,6 +209,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure); //| :return: True when lock has been grabbed //| :rtype: bool""" //| ... +//| 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); @@ -214,6 +220,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock); //| def unlock(self, ) -> Any: //| """Releases the SPI 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); @@ -231,6 +238,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); //| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` //| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" //| ... +//| STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; @@ -274,6 +282,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write); //| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` //| :param int write_value: Value to write while reading. (Usually ignored.)""" //| ... +//| STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; @@ -321,6 +330,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto); //| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` //| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" //| ... +//| STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 7c5c6ec2bc..6a3d542e1c 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -64,6 +64,7 @@ //| *New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. //| The new upper limit on ``timeout`` is meant to catch mistaken use of milliseconds.""" //| ... +//| typedef struct { mp_obj_base_t base; } busio_uart_parity_obj_t; @@ -144,6 +145,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co //| def deinit(self, ) -> Any: //| """Deinitialises the UART and releases any hardware resources for reuse.""" //| ... +//| STATIC mp_obj_t busio_uart_obj_deinit(mp_obj_t self_in) { busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_uart_deinit(self); @@ -160,12 +162,14 @@ STATIC void check_for_deinit(busio_uart_obj_t *self) { //| def __enter__(self, ) -> Any: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self, ) -> Any: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| STATIC mp_obj_t busio_uart_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_uart_deinit(args[0]); @@ -184,6 +188,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ //| :return: Data read //| :rtype: bytes or None""" //| ... +//| //| def readinto(self, buf: Any) -> Any: //| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. @@ -193,6 +198,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ //| //| *New in CircuitPython 4.0:* No length parameter is permitted.""" //| ... +//| //| def readline(self, ) -> Any: //| """Read a line, ending in a newline character. @@ -200,6 +206,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ //| :return: the line read //| :rtype: int or None""" //| ... +//| //| def write(self, buf: Any) -> Any: //| """Write the buffer of bytes to the bus. @@ -209,6 +216,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ //| :return: the number of bytes written //| :rtype: int or None""" //| ... +//| // 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) { @@ -344,6 +352,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_o //| EVEN: Any = ... //| """Total number of ones should be even.""" //| ... +//| const mp_obj_type_t busio_uart_parity_type; const busio_uart_parity_obj_t busio_uart_parity_odd_obj = { From 7ff9b9bc80b3dafd4b263bc8854e4582a21664c2 Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 29 Apr 2020 17:36:28 -0400 Subject: [PATCH 030/216] Did first 3 --- shared-bindings/analogio/AnalogIn.c | 70 ++++++----- shared-bindings/analogio/AnalogOut.c | 63 +++++----- shared-bindings/analogio/__init__.c | 4 +- shared-bindings/audiobusio/I2SOut.c | 161 ++++++++++++++------------ shared-bindings/audiobusio/PDMIn.c | 131 +++++++++++---------- shared-bindings/audiobusio/__init__.c | 4 +- shared-bindings/audiocore/RawSample.c | 104 +++++++++-------- shared-bindings/audiocore/WaveFile.c | 103 ++++++++-------- shared-bindings/audiocore/__init__.c | 4 +- 9 files changed, 341 insertions(+), 303 deletions(-) diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index 9b6ac086be..2fb5051ebe 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -36,25 +36,28 @@ #include "shared-bindings/analogio/AnalogIn.h" #include "shared-bindings/util.h" -//|class AnalogIn: -//|""":class:`AnalogIn` -- read analog voltage -//|============================================ +//| class AnalogIn: +//| """.. currentmodule:: analogio //| -//|Usage:: +//| :class:`AnalogIn` -- read analog voltage +//| ============================================ //| -//|import analogio -//|from board import * +//| Usage:: //| -//|adc = analogio.AnalogIn(A1) -//|val = adc.value""" +//| import analogio +//| from board import * //| -//|def __init__(self, pin: microcontroller.Pin): +//| adc = analogio.AnalogIn(A1) +//| val = adc.value""" //| -//|"""Use the AnalogIn on the given pin. The reference voltage varies by -//|platform so use ``reference_voltage`` to read the configured setting. + +//| def __init__(self, pin: microcontroller.Pin): +//| """Use the AnalogIn on the given pin. The reference voltage varies by +//| platform so use ``reference_voltage`` to read the configured setting. +//| +//| :param ~microcontroller.Pin pin: the pin to read from""" +//| ... //| -//|:param ~microcontroller.Pin pin: the pin to read from""" -//|... STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // check number of arguments @@ -70,9 +73,10 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Turn off the AnalogIn and release the pin for other use.""" -//|... +//| def deinit(self, ) -> Any: +//| """Turn off the AnalogIn and release the pin for other use.""" +//| ... +//| STATIC mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) { analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_analogio_analogin_deinit(self); @@ -85,15 +89,17 @@ STATIC void check_for_deinit(analogio_analogin_obj_t *self) { raise_deinited_error(); } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... +//| // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_analogio_analogin_deinit(args[0]); @@ -101,12 +107,12 @@ STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogin___exit___obj, 4, 4, analogio_analogin___exit__); -//|value: Any = -//|"""The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only) +//| value: Any = ... +//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only) +//| +//| Even if the underlying analog to digital converter (ADC) is lower +//| resolution, the value is 16-bit.""" //| -//|Even if the underlying analog to digital converter (ADC) is lower -//|resolution, the value is 16-bit.""" -//|... 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); check_for_deinit(self); @@ -121,10 +127,10 @@ const mp_obj_property_t analogio_analogin_value_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|reference_voltage: Any = -//|"""The maximum voltage measurable (also known as the reference voltage) as a -//|`float` in Volts.""" -//|... +//| reference_voltage: Any = ... +//| """The maximum voltage measurable (also known as the reference voltage) as a +//| `float` in Volts.""" +//| 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); check_for_deinit(self); diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index 2316682903..9064bb5dce 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -36,26 +36,28 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//|class AnalogOut: -//|""".. currentmodule:: analogio +//| class AnalogOut: +//| """.. currentmodule:: analogio //| -//|:class:`AnalogOut` -- output analog voltage -//|============================================ +//| :class:`AnalogOut` -- output analog voltage +//| ============================================ //| -//|The AnalogOut is used to output analog values (a specific voltage). +//| The AnalogOut is used to output analog values (a specific voltage). //| -//|Example usage:: +//| Example usage:: //| -//|import analogio -//|from microcontroller import pin +//| import analogio +//| from microcontroller import pin //| -//|dac = analogio.AnalogOut(pin.PA02) # output on pin PA02 -//|dac.value = 32768 # makes PA02 1.65V""" -//|def __init__(self, pin: microcontroller.Pin): -//|"""Use the AnalogOut on the given pin. +//| dac = analogio.AnalogOut(pin.PA02) # output on pin PA02 +//| dac.value = 32768 # makes PA02 1.65V""" +//| +//| def __init__(self, pin: microcontroller.Pin): +//| """Use the AnalogOut on the given pin. +//| +//| :param ~microcontroller.Pin pin: the pin to output to""" +//| ... //| -//|:param ~microcontroller.Pin pin: the pin to output to""" -//|... STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // check arguments mp_arg_check_num(n_args, kw_args, 1, 1, false); @@ -69,9 +71,10 @@ STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Turn off the AnalogOut and release the pin for other use.""" -//|... +//| def deinit(self, ) -> Any: +//| """Turn off the AnalogOut and release the pin for other use.""" +//| ... +//| STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) { analogio_analogout_obj_t *self = self_in; @@ -81,15 +84,17 @@ STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogout_deinit); -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... +//| // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_analogio_analogout_deinit(args[0]); @@ -97,12 +102,12 @@ STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4, analogio_analogout___exit__); -//|value: Any = -//|"""The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only) +//| value: Any = ... +//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only) +//| +//| Even if the underlying digital to analog converter (DAC) is lower +//| resolution, the value is 16-bit.""" //| -//|Even if the underlying digital to analog converter (DAC) is lower -//|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); if (common_hal_analogio_analogout_deinited(self)) { diff --git a/shared-bindings/analogio/__init__.c b/shared-bindings/analogio/__init__.c index b468bcde0c..79627f16aa 100644 --- a/shared-bindings/analogio/__init__.c +++ b/shared-bindings/analogio/__init__.c @@ -34,7 +34,7 @@ #include "shared-bindings/analogio/AnalogIn.h" #include "shared-bindings/analogio/AnalogOut.h" -//| :mod:`analogio` --- Analog hardware support +//| """:mod:`analogio` --- Analog hardware support //| ================================================= //| //| .. module:: analogio @@ -70,7 +70,7 @@ //| This example will initialize the the device, read //| :py:data:`~analogio.AnalogIn.value` and then //| :py:meth:`~analogio.AnalogIn.deinit` the hardware. The last step is optional -//| because CircuitPython will do it automatically after the program finishes. +//| because CircuitPython will do it automatically after the program finishes.""" //| STATIC const mp_rom_map_elem_t analogio_module_globals_table[] = { diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 765e0a12dc..724a65a347 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -35,64 +35,66 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//|class I2SOut: -//|""".. currentmodule:: audiobusio +//| class I2SOut: +//| """.. currentmodule:: audiobusio //| -//|:class:`I2SOut` -- Output an I2S audio signal -//|======================================================== +//| :class:`I2SOut` -- Output an I2S audio signal +//| ======================================================== //| -//|I2S is used to output an audio signal on an I2S bus.""" -//|def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool): -//|"""Create a I2SOut object associated with the given pins. +//| I2S is used to output an audio signal on an I2S bus.""" //| -//|:param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin -//|:param ~microcontroller.Pin word_select: The word select (or left/right clock) pin -//|:param ~microcontroller.Pin data: The data pin -//|:param bool left_justified: True when data bits are aligned with the word select clock. False -//|when they are shifted by one to match classic I2S protocol. +//| def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool): +//| """Create a I2SOut object associated with the given pins. //| -//|Simple 8ksps 440 Hz sine wave on `Metro M0 Express `_ -//|using `UDA1334 Breakout `_:: +//| :param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin +//| :param ~microcontroller.Pin word_select: The word select (or left/right clock) pin +//| :param ~microcontroller.Pin data: The data pin +//| :param bool left_justified: True when data bits are aligned with the word select clock. False +//| when they are shifted by one to match classic I2S protocol. //| -//|import audiobusio -//|import audiocore -//|import board -//|import array -//|import time -//|import math +//| Simple 8ksps 440 Hz sine wave on `Metro M0 Express `_ +//| using `UDA1334 Breakout `_:: //| -//|# Generate one period of sine wave. -//|length = 8000 // 440 -//|sine_wave = array.array("H", [0] * length) -//|for i in range(length): -//|sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//| import audiobusio +//| import audiocore +//| import board +//| import array +//| import time +//| import math //| -//|sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) -//|i2s = audiobusio.I2SOut(board.D1, board.D0, board.D9) -//|i2s.play(sine_wave, loop=True) -//|time.sleep(1) -//|i2s.stop() +//| # Generate one period of sine wave. +//| length = 8000 // 440 +//| sine_wave = array.array("H", [0] * length) +//| for i in range(length): +//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//|Playing a wave file from flash:: +//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//| i2s = audiobusio.I2SOut(board.D1, board.D0, board.D9) +//| i2s.play(sine_wave, loop=True) +//| time.sleep(1) +//| i2s.stop() //| -//|import board -//|import audioio -//|import audiocore -//|import audiobusio -//|import digitalio +//| Playing a wave file from flash:: +//| +//| import board +//| import audioio +//| import audiocore +//| import audiobusio +//| import digitalio //| //| -//|f = open("cplay-5.1-16bit-16khz.wav", "rb") -//|wav = audiocore.WaveFile(f) +//| f = open("cplay-5.1-16bit-16khz.wav", "rb") +//| wav = audiocore.WaveFile(f) //| -//|a = audiobusio.I2SOut(board.D1, board.D0, board.D9) +//| a = audiobusio.I2SOut(board.D1, board.D0, board.D9) +//| +//| print("playing") +//| a.play(wav) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... //| -//|print("playing") -//|a.play(wav) -//|while a.playing: -//|pass -//|print("stopped")""" -//|... STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_left_justified }; static const mp_arg_t allowed_args[] = { @@ -115,9 +117,10 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Deinitialises the I2SOut and releases any hardware resources for reuse.""" -//|... +//| def deinit(self, ) -> Any: +//| """Deinitialises the I2SOut and releases any hardware resources for reuse.""" +//| ... +//| STATIC mp_obj_t audiobusio_i2sout_deinit(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_i2sout_deinit(self); @@ -130,15 +133,17 @@ STATIC void check_for_deinit(audiobusio_i2sout_obj_t *self) { raise_deinited_error(); } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... +//| // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_i2sout_deinit(args[0]); @@ -147,14 +152,15 @@ STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *ar STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, audiobusio_i2sout_obj___exit__); -//|def play(self, sample: Any, *, loop: Any = False) -> Any: -//|"""Plays the sample once when loop=False and continuously when loop=True. -//|Does not block. Use `playing` to block. +//| def play(self, sample: Any, *, loop: Any = False) -> Any: +//| """Plays the sample once when loop=False and continuously when loop=True. +//| Does not block. Use `playing` to block. //| -//|Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//| +//| The sample itself should consist of 8 bit or 16 bit samples.""" +//| ... //| -//|The sample itself should consist of 8 bit or 16 bit samples.""" -//|... STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -173,9 +179,10 @@ STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_ar } MP_DEFINE_CONST_FUN_OBJ_KW(audiobusio_i2sout_play_obj, 1, audiobusio_i2sout_obj_play); -//|def stop(self, ) -> Any: -//|"""Stops playback.""" -//|... +//| def stop(self, ) -> Any: +//| """Stops playback.""" +//| ... +//| STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -184,9 +191,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_stop_obj, audiobusio_i2sout_obj_stop); -//|playing: Any = -//|"""True when the audio sample is being output. (read-only)""" -//|... +//| playing: Any = ... +//| """True when the audio sample is being output. (read-only)""" +//| 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); check_for_deinit(self); @@ -201,9 +208,10 @@ const mp_obj_property_t audiobusio_i2sout_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|def pause(self, ) -> Any: -//|"""Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" -//|... +//| def pause(self, ) -> Any: +//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" +//| ... +//| STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -216,9 +224,10 @@ STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_pause_obj, audiobusio_i2sout_obj_pause); -//|def resume(self, ) -> Any: -//|"""Resumes sample playback after :py:func:`pause`.""" -//|... +//| def resume(self, ) -> Any: +//| """Resumes sample playback after :py:func:`pause`.""" +//| ... +//| STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -231,9 +240,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_resume_obj, audiobusio_i2sout_obj_resume); -//|paused: Any = -//|"""True when playback is paused. (read-only)""" -//|... +//| paused: Any = ... +//| """True when playback is paused. (read-only)""" +//| 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); check_for_deinit(self); diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 28ff9a4818..6cc834724b 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -36,57 +36,58 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//|class PDMIn: -//|""".. currentmodule:: audiobusio +//| class PDMIn: +//| """.. currentmodule:: audiobusio //| -//|:class:`PDMIn` -- Record an input PDM audio stream -//|======================================================== +//| :class:`PDMIn` -- Record an input PDM audio stream +//| ======================================================== //| -//|PDMIn can be used to record an input audio signal on a given set of pins.""" +//| PDMIn can be used to record an input audio signal on a given set of pins.""" //| -//|def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11): -//|"""Create a PDMIn object associated with the given pins. This allows you to -//|record audio signals from the given pins. Individual ports may put further -//|restrictions on the recording parameters. The overall sample rate is -//|determined by `sample_rate` x ``oversample``, and the total must be 1MHz or -//|higher, so `sample_rate` must be a minimum of 16000. +//| def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11): +//| """Create a PDMIn object associated with the given pins. This allows you to +//| record audio signals from the given pins. Individual ports may put further +//| restrictions on the recording parameters. The overall sample rate is +//| determined by `sample_rate` x ``oversample``, and the total must be 1MHz or +//| higher, so `sample_rate` must be a minimum of 16000. +//| +//| :param ~microcontroller.Pin clock_pin: The pin to output the clock to +//| :param ~microcontroller.Pin data_pin: The pin to read the data from +//| :param int sample_rate: Target sample_rate of the resulting samples. Check `sample_rate` for actual value. +//| Minimum sample_rate is about 16000 Hz. +//| :param int bit_depth: Final number of bits per sample. Must be divisible by 8 +//| :param bool mono: True when capturing a single channel of audio, captures two channels otherwise +//| :param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8 +//| :param float startup_delay: seconds to wait after starting microphone clock +//| to allow microphone to turn on. Most require only 0.01s; some require 0.1s. Longer is safer. +//| Must be in range 0.0-1.0 seconds.""" //| -//|:param ~microcontroller.Pin clock_pin: The pin to output the clock to -//|:param ~microcontroller.Pin data_pin: The pin to read the data from -//|:param int sample_rate: Target sample_rate of the resulting samples. Check `sample_rate` for actual value. -//|Minimum sample_rate is about 16000 Hz. -//|:param int bit_depth: Final number of bits per sample. Must be divisible by 8 -//|:param bool mono: True when capturing a single channel of audio, captures two channels otherwise -//|:param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8 -//|:param float startup_delay: seconds to wait after starting microphone clock -//|to allow microphone to turn on. Most require only 0.01s; some require 0.1s. Longer is safer. -//|Must be in range 0.0-1.0 seconds.""" -//|... -//|Record 8-bit unsigned samples to buffer:: +//| """Record 8-bit unsigned samples to buffer:: //| -//|import audiobusio -//|import board +//| import audiobusio +//| import board //| -//|# Prep a buffer to record into -//|b = bytearray(200) -//|with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000) as mic: -//|mic.record(b, len(b)) +//| # Prep a buffer to record into +//| b = bytearray(200) +//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000) as mic: +//| mic.record(b, len(b)) //| -//|Record 16-bit unsigned samples to buffer:: +//| Record 16-bit unsigned samples to buffer:: //| -//|import audiobusio -//|import board +//| import audiobusio +//| import board +//| +//| # Prep a buffer to record into. The array interface doesn't allow for +//| # constructing with a set size so we append to it until we have the size +//| # we want. +//| b = array.array("H") +//| for i in range(200): +//| b.append(0) +//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: +//| mic.record(b, len(b))""" +//| ... //| -//|# Prep a buffer to record into. The array interface doesn't allow for -//|# constructing with a set size so we append to it until we have the size -//|# we want. -//|b = array.array("H") -//|for i in range(200): -//|b.append(0) -//|with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: -//|mic.record(b, len(b)) -//| STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_clock_pin, ARG_data_pin, ARG_sample_rate, ARG_bit_depth, ARG_mono, ARG_oversample, ARG_startup_delay }; static const mp_arg_t allowed_args[] = { @@ -138,9 +139,10 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Deinitialises the PDMIn and releases any hardware resources for reuse.""" -//|... +//| def deinit(self, ) -> Any: +//| """Deinitialises the PDMIn and releases any hardware resources for reuse.""" +//| ... +//| STATIC mp_obj_t audiobusio_pdmin_deinit(mp_obj_t self_in) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_pdmin_deinit(self); @@ -153,14 +155,16 @@ STATIC void check_for_deinit(audiobusio_pdmin_obj_t *self) { raise_deinited_error(); } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... +//| // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context.""" +//| ... +//| STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_pdmin_deinit(args[0]); @@ -169,17 +173,18 @@ STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *arg STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, audiobusio_pdmin_obj___exit__); -//|def record(self, destination: Any, destination_length: Any) -> Any: -//|"""Records destination_length bytes of samples to destination. This is -//|blocking. +//| def record(self, destination: Any, destination_length: Any) -> Any: +//| """Records destination_length bytes of samples to destination. This is +//| blocking. //| -//|An IOError may be raised when the destination is too slow to record the -//|audio at the given rate. For internal flash, writing all 1s to the file -//|before recording is recommended to speed up writes. +//| An IOError may be raised when the destination is too slow to record the +//| audio at the given rate. For internal flash, writing all 1s to the file +//| before recording is recommended to speed up writes. +//| +//| :return: The number of samples recorded. If this is less than ``destination_length``, +//| some samples were missed due to processing time.""" +//| ... //| -//|:return: The number of samples recorded. If this is less than ``destination_length``, -//|some samples were missed due to processing time.""" -//|... 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); check_for_deinit(self); @@ -210,10 +215,10 @@ STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destinat } MP_DEFINE_CONST_FUN_OBJ_3(audiobusio_pdmin_record_obj, audiobusio_pdmin_obj_record); -//|sample_rate: Any = -//|"""The actual sample_rate of the recording. This may not match the constructed -//|sample rate due to internal clock limitations.""" -//|... +//| sample_rate: Any = ... +//| """The actual sample_rate of the recording. This may not match the constructed +//| sample rate due to internal clock limitations.""" +//| 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); check_for_deinit(self); diff --git a/shared-bindings/audiobusio/__init__.c b/shared-bindings/audiobusio/__init__.c index f7e3a07668..c5c3873619 100644 --- a/shared-bindings/audiobusio/__init__.c +++ b/shared-bindings/audiobusio/__init__.c @@ -34,7 +34,7 @@ #include "shared-bindings/audiobusio/I2SOut.h" #include "shared-bindings/audiobusio/PDMIn.h" -//| :mod:`audiobusio` --- Support for audio input and output over digital bus +//| """:mod:`audiobusio` --- Support for audio input and output over digital bus //| ========================================================================= //| //| .. module:: audiobusio @@ -56,7 +56,7 @@ //| //| All libraries change hardware state and should be deinitialized when they //| are no longer needed. To do so, either call :py:meth:`!deinit` or use a -//| context manager. +//| context manager.""" //| STATIC const mp_rom_map_elem_t audiobusio_module_globals_table[] = { diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index fdedfe9598..6091fbfc00 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -35,45 +35,52 @@ #include "shared-bindings/audiocore/RawSample.h" #include "supervisor/shared/translate.h" -//|class RawSample: -//|""".. currentmodule:: audiocore + + + + + + +//| class RawSample: +//| """.. currentmodule:: audiocore //| -//|:class:`RawSample` -- A raw audio sample buffer -//|======================================================== +//| :class:`RawSample` -- A raw audio sample buffer +//| ======================================================== //| -//|An in-memory sound sample""" +//| An in-memory sound sample""" //| -//|def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000): -//|"""Create a RawSample based on the given buffer of signed values. If channel_count is more than -//|1 then each channel's samples should alternate. In other words, for a two channel buffer, the -//|first sample will be for channel 1, the second sample will be for channel two, the third for -//|channel 1 and so on. +//| def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000): +//| """Create a RawSample based on the given buffer of signed values. If channel_count is more than +//| 1 then each channel's samples should alternate. In other words, for a two channel buffer, the +//| first sample will be for channel 1, the second sample will be for channel two, the third for +//| channel 1 and so on. //| -//|:param array.array buffer: An `array.array` with samples -//|:param int channel_count: The number of channels in the buffer -//|:param int sample_rate: The desired playback sample rate +//| :param array.array buffer: An `array.array` with samples +//| :param int channel_count: The number of channels in the buffer +//| :param int sample_rate: The desired playback sample rate //| -//|Simple 8ksps 440 Hz sin wave:: +//| Simple 8ksps 440 Hz sin wave:: //| -//|import audiocore -//|import audioio -//|import board -//|import array -//|import time -//|import math +//| import audiocore +//| import audioio +//| import board +//| import array +//| import time +//| import math //| -//|# Generate one period of sine wav. -//|length = 8000 // 440 -//|sine_wave = array.array("h", [0] * length) -//|for i in range(length): -//|sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15)) +//| # Generate one period of sine wav. +//| length = 8000 // 440 +//| sine_wave = array.array("h", [0] * length) +//| for i in range(length): +//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15)) +//| +//| dac = audioio.AudioOut(board.SPEAKER) +//| sine_wave = audiocore.RawSample(sine_wave) +//| dac.play(sine_wave, loop=True) +//| time.sleep(1) +//| dac.stop()""" +//| ... //| -//|dac = audioio.AudioOut(board.SPEAKER) -//|sine_wave = audiocore.RawSample(sine_wave) -//|dac.play(sine_wave, loop=True) -//|time.sleep(1) -//|dac.stop()""" -//|... STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_channel_count, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -105,9 +112,10 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Deinitialises the AudioOut and releases any hardware resources for reuse.""" -//|... +//| def deinit(self, ) -> Any: +//| """Deinitialises the AudioOut and releases any hardware resources for reuse.""" +//| ... +//| STATIC mp_obj_t audioio_rawsample_deinit(mp_obj_t self_in) { audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_rawsample_deinit(self); @@ -121,15 +129,17 @@ STATIC void check_for_deinit(audioio_rawsample_obj_t *self) { } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... +//| // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| STATIC mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_rawsample_deinit(args[0]); @@ -137,12 +147,12 @@ STATIC mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *ar } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_rawsample___exit___obj, 4, 4, audioio_rawsample_obj___exit__); -//|sample_rate: Any = -//|"""32 bit value that dictates how quickly samples are played in Hertz (cycles per second). -//|When the sample is looped, this can change the pitch output without changing the underlying -//|sample. This will not change the sample rate of any active playback. Call ``play`` again to -//|change it.""" -//|... +//| sample_rate: Any = ... +//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second). +//| When the sample is looped, this can change the pitch output without changing the underlying +//| sample. This will not change the sample rate of any active playback. Call ``play`` again to +//| change it.""" +//| 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); check_for_deinit(self); diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 9116e71f0f..65b42fb6c4 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -33,43 +33,45 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//|class WaveFile: -//|""".. currentmodule:: audiocore +//| class WaveFile: +//| """.. currentmodule:: audiocore //| -//|:class:`WaveFile` -- Load a wave file for audio playback -//|======================================================== +//| :class:`WaveFile` -- Load a wave file for audio playback +//| ======================================================== //| -//|A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must -//|be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating -//|an internal buffer.""" -//|def __init__(self, file: typing.BinaryIO, buffer: bytearray): -//|"""Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. +//| A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must +//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating +//| an internal buffer.""" //| -//|:param typing.BinaryIO file: Already opened wave file -//|:param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally. +//| def __init__(self, file: typing.BinaryIO, buffer: bytearray): +//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. +//| +//| :param typing.BinaryIO file: Already opened wave file +//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally. //| //| -//|Playing a wave file from flash:: +//| Playing a wave file from flash:: //| -//|import board -//|import audiocore -//|import audioio -//|import digitalio +//| import board +//| import audiocore +//| import audioio +//| import digitalio //| -//|# Required for CircuitPlayground Express -//|speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//|speaker_enable.switch_to_output(value=True) +//| # Required for CircuitPlayground Express +//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//| speaker_enable.switch_to_output(value=True) //| -//|data = open("cplay-5.1-16bit-16khz.wav", "rb") -//|wav = audiocore.WaveFile(data) -//|a = audioio.AudioOut(board.A0) +//| data = open("cplay-5.1-16bit-16khz.wav", "rb") +//| wav = audiocore.WaveFile(data) +//| a = audioio.AudioOut(board.A0) +//| +//| print("playing") +//| a.play(wav) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... //| -//|print("playing") -//|a.play(wav) -//|while a.playing: -//|pass -//|print("stopped")""" -//|... STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 2, false); @@ -92,9 +94,9 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Deinitialises the WaveFile and releases all memory resources for reuse.""" -//|... +//| def deinit(self, ) -> Any: +//| """Deinitialises the WaveFile and releases all memory resources for reuse.""" +//| ... STATIC mp_obj_t audioio_wavefile_deinit(mp_obj_t self_in) { audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_wavefile_deinit(self); @@ -108,15 +110,17 @@ STATIC void check_for_deinit(audioio_wavefile_obj_t *self) { } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... +//| // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_wavefile_deinit(args[0]); @@ -124,11 +128,11 @@ STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_wavefile___exit___obj, 4, 4, audioio_wavefile_obj___exit__); -//|sample_rate: Any = -//|"""32 bit value that dictates how quickly samples are loaded into the DAC -//|in Hertz (cycles per second). When the sample is looped, this can change -//|the pitch output without changing the underlying sample.""" -//|... +//| sample_rate: Any = ... +//| """32 bit value that dictates how quickly samples are loaded into the DAC +//| in Hertz (cycles per second). When the sample is looped, this can change +//| the pitch output without changing the underlying sample.""" +//| 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); check_for_deinit(self); @@ -151,9 +155,9 @@ const mp_obj_property_t audioio_wavefile_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|bits_per_sample: Any = -//|"""Bits per sample. (read only)""" -//|... +//| bits_per_sample: Any = ... +//| """Bits per sample. (read only)""" +//| 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); check_for_deinit(self); @@ -167,10 +171,9 @@ const mp_obj_property_t audioio_wavefile_bits_per_sample_obj = { (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj}, }; - -//|channel_count: Any = -//|"""Number of audio channels. (read only)""" -//|... +//| channel_count: Any = ... +//| """Number of audio channels. (read only)""" +//| 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); check_for_deinit(self); diff --git a/shared-bindings/audiocore/__init__.c b/shared-bindings/audiocore/__init__.c index cf05112cb7..38f91d8eeb 100644 --- a/shared-bindings/audiocore/__init__.c +++ b/shared-bindings/audiocore/__init__.c @@ -35,7 +35,7 @@ #include "shared-bindings/audiocore/WaveFile.h" //#include "shared-bindings/audiomixer/Mixer.h" -//| :mod:`audiocore` --- Support for audio samples and mixer +//| """:mod:`audiocore` --- Support for audio samples and mixer //| ======================================================== //| //| .. module:: audiocore @@ -50,7 +50,7 @@ //| :maxdepth: 3 //| //| RawSample -//| WaveFile +//| WaveFile""" //| STATIC const mp_rom_map_elem_t audiocore_module_globals_table[] = { From 4393a88fb6e577fb9ea86d0ad0096f377e12e4cd Mon Sep 17 00:00:00 2001 From: Yihui Xiong Date: Thu, 30 Apr 2020 07:38:20 +0000 Subject: [PATCH 031/216] add nRF52840 based Makerdiary Pitaya Go --- ports/nrf/boards/pitaya_go/README.md | 40 +++++++++++++ ports/nrf/boards/pitaya_go/board.c | 38 ++++++++++++ ports/nrf/boards/pitaya_go/mpconfigboard.h | 43 ++++++++++++++ ports/nrf/boards/pitaya_go/mpconfigboard.mk | 10 ++++ ports/nrf/boards/pitaya_go/pins.c | 64 +++++++++++++++++++++ 5 files changed, 195 insertions(+) create mode 100644 ports/nrf/boards/pitaya_go/README.md create mode 100644 ports/nrf/boards/pitaya_go/board.c create mode 100644 ports/nrf/boards/pitaya_go/mpconfigboard.h create mode 100644 ports/nrf/boards/pitaya_go/mpconfigboard.mk create mode 100644 ports/nrf/boards/pitaya_go/pins.c diff --git a/ports/nrf/boards/pitaya_go/README.md b/ports/nrf/boards/pitaya_go/README.md new file mode 100644 index 0000000000..a58b752892 --- /dev/null +++ b/ports/nrf/boards/pitaya_go/README.md @@ -0,0 +1,40 @@ +# Makerdiary Pitaya Go + +>Pitaya Go is a compact and versatile development platform for IoT solutions, +combining the Nordic's high-end multiprotocol SoC nRF52840 and the Microchip's +extreme low power Wi-Fi® network controller ATWINC1500B. It offers a complete +solution for wireless connectivity with IEEE 802.11 b/g/n, Bluetooth 5, Thread +and Zigbee, that is specifically designed for the IoT. +Pitaya Go features a Battery Charger with power path management, 64Mbit ultra +low power QSPI Flash memory, additional NFC-A Tag PCB Antenna, user +programmable RGB LED and Buttons, reversible USB-C Connector and easily +expandable Header Sockets. All these features above make this board an ideal +choice for the next IoT project. + +from [Makerdiary](https://store.makerdiary.com/products/pitaya-go) + + +## Installing CircuitPython submodules + +Before you can build, you will need to run the following commands once, which +will install the submodules that are part of the CircuitPython ecosystem, and +build the `mpy-cross` tool: + +``` +$ cd circuitpython +$ git submodule update --init +$ make -C mpy-cross +``` + + +## Building +```sh +$ cd ports/nrf +$ make BOARD=pitaya_go SD=s140 -V=1 -j4 +``` + +# Flashing CircuitPython + +The Pitaya Go has a pre-programmed bootloader which can be used to program the +Pitaya Go. Follow [the guide - How to Program Pitaya Go](https://wiki.makerdiary.com/pitaya-go/programming/) +to flash the CircuitPython firmware. diff --git a/ports/nrf/boards/pitaya_go/board.c b/ports/nrf/boards/pitaya_go/board.c new file mode 100644 index 0000000000..4421970eef --- /dev/null +++ b/ports/nrf/boards/pitaya_go/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/nrf/boards/pitaya_go/mpconfigboard.h b/ports/nrf/boards/pitaya_go/mpconfigboard.h new file mode 100644 index 0000000000..7f9eff7164 --- /dev/null +++ b/ports/nrf/boards/pitaya_go/mpconfigboard.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2020 Yihui Xiong + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "nrfx/hal/nrf_gpio.h" + +#define MAKERDIARYPITAYAGO + +#define MICROPY_HW_BOARD_NAME "Makerdiary Pitaya Go" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(1, 6) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(1, 1) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 5) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(1, 2) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 4) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(1, 3) + +#define BOARD_HAS_CRYSTAL 1 diff --git a/ports/nrf/boards/pitaya_go/mpconfigboard.mk b/ports/nrf/boards/pitaya_go/mpconfigboard.mk new file mode 100644 index 0000000000..e3b273f966 --- /dev/null +++ b/ports/nrf/boards/pitaya_go/mpconfigboard.mk @@ -0,0 +1,10 @@ +USB_VID = 0x239A +USB_PID = 0x802A +USB_PRODUCT = "Pitaya Go" +USB_MANUFACTURER = "Makerdiary" + +MCU_CHIP = nrf52840 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = "MX25R6435F" diff --git a/ports/nrf/boards/pitaya_go/pins.c b/ports/nrf/boards/pitaya_go/pins.c new file mode 100644 index 0000000000..92411581bc --- /dev/null +++ b/ports/nrf/boards/pitaya_go/pins.c @@ -0,0 +1,64 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_AIN0), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_AIN1), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_AIN2), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_AIN3), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_AIN4), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_AIN5), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_AIN6), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_AIN7), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_VDIV), MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_NFC1), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) }, + + { MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_P8), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_P9), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_P10), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_P11), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_P12), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_P13), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_P14), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_P15), MP_ROM_PTR(&pin_P0_15) }, + { MP_ROM_QSTR(MP_QSTR_P16), MP_ROM_PTR(&pin_P0_16) }, + { MP_ROM_QSTR(MP_QSTR_P17), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_P18), MP_ROM_PTR(&pin_P0_18) }, + { MP_ROM_QSTR(MP_QSTR_P19), MP_ROM_PTR(&pin_P0_19) }, + { MP_ROM_QSTR(MP_QSTR_P20), MP_ROM_PTR(&pin_P0_20) }, + { MP_ROM_QSTR(MP_QSTR_P21), MP_ROM_PTR(&pin_P0_21) }, + { MP_ROM_QSTR(MP_QSTR_P22), MP_ROM_PTR(&pin_P0_22) }, + { MP_ROM_QSTR(MP_QSTR_P23), MP_ROM_PTR(&pin_P0_23) }, + { MP_ROM_QSTR(MP_QSTR_P24), MP_ROM_PTR(&pin_P0_24) }, + { MP_ROM_QSTR(MP_QSTR_P25), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_P26), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_P27), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_P28), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_P29), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_P30), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_P31), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P1_04) }, + { MP_ROM_QSTR(MP_QSTR_CSN), MP_ROM_PTR(&pin_P1_03) }, + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_P1_06) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_P1_01) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_P1_05) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_P1_02) }, + + { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_P0_12) }, + + { MP_ROM_QSTR(MP_QSTR_USR_BTN), MP_ROM_PTR(&pin_P1_00) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 14f6f082ad8b4c2b83b789b5b77f74e99f72b69b Mon Sep 17 00:00:00 2001 From: Yihui Xiong Date: Thu, 30 Apr 2020 14:31:06 +0000 Subject: [PATCH 032/216] add pitaya_go --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b1211cda1..3fc0ea411d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -214,6 +214,7 @@ jobs: - "pewpew10" - "pewpew_m4" - "pirkey_m0" + - "pitaya_go" - "pyb_nano_v2" - "pybadge" - "pybadge_airlift" From d65e85104431b354737d11b5ec9a29387d390cfd Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 30 Apr 2020 13:06:09 -0400 Subject: [PATCH 033/216] Did audioio, audiomixer, audiomp3 --- shared-bindings/audioio/AudioOut.c | 164 +++++++++++++----------- shared-bindings/audioio/__init__.c | 4 +- shared-bindings/audiomixer/Mixer.c | 139 ++++++++++---------- shared-bindings/audiomixer/MixerVoice.c | 48 +++---- shared-bindings/audiomixer/__init__.c | 4 +- shared-bindings/audiomp3/MP3Decoder.c | 111 ++++++++-------- shared-bindings/audiomp3/__init__.c | 4 +- 7 files changed, 247 insertions(+), 227 deletions(-) diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 28c345d168..84e5e44227 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -36,64 +36,65 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//|class AudioOut: -//|""".. currentmodule:: audioio +//| class AudioOut: +//| """.. currentmodule:: audioio //| -//|:class:`AudioOut` -- Output an analog audio signal -//|======================================================== +//| :class:`AudioOut` -- Output an analog audio signal +//| ======================================================== //| -//|AudioOut can be used to output an analog audio signal on a given pin.""" +//| AudioOut can be used to output an analog audio signal on a given pin.""" //| -//|def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): -//|"""Create a AudioOut object associated with the given pin(s). This allows you to -//|play audio signals out on the given pin(s). +//| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): +//| """Create a AudioOut object associated with the given pin(s). This allows you to +//| play audio signals out on the given pin(s). //| -//|:param ~microcontroller.Pin left_channel: The pin to output the left channel to -//|:param ~microcontroller.Pin right_channel: The pin to output the right channel to -//|:param int quiescent_value: The output value when no signal is present. Samples should start -//|and end with this value to prevent audible popping. +//| :param ~microcontroller.Pin left_channel: The pin to output the left channel to +//| :param ~microcontroller.Pin right_channel: The pin to output the right channel to +//| :param int quiescent_value: The output value when no signal is present. Samples should start +//| and end with this value to prevent audible popping. //| -//|Simple 8ksps 440 Hz sin wave:: +//| Simple 8ksps 440 Hz sin wave:: //| -//|import audiocore -//|import audioio -//|import board -//|import array -//|import time -//|import math +//| import audiocore +//| import audioio +//| import board +//| import array +//| import time +//| import math //| -//|# Generate one period of sine wav. -//|length = 8000 // 440 -//|sine_wave = array.array("H", [0] * length) -//|for i in range(length): -//|sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//| # Generate one period of sine wav. +//| length = 8000 // 440 +//| sine_wave = array.array("H", [0] * length) +//| for i in range(length): +//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//|dac = audioio.AudioOut(board.SPEAKER) -//|sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) -//|dac.play(sine_wave, loop=True) -//|time.sleep(1) -//|dac.stop() +//| dac = audioio.AudioOut(board.SPEAKER) +//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//| dac.play(sine_wave, loop=True) +//| time.sleep(1) +//| dac.stop() //| -//|Playing a wave file from flash:: +//| Playing a wave file from flash:: //| -//|import board -//|import audioio -//|import digitalio +//| import board +//| import audioio +//| import digitalio //| -//|# Required for CircuitPlayground Express -//|speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//|speaker_enable.switch_to_output(value=True) +//| # Required for CircuitPlayground Express +//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//| speaker_enable.switch_to_output(value=True) //| -//|data = open("cplay-5.1-16bit-16khz.wav", "rb") -//|wav = audiocore.WaveFile(data) -//|a = audioio.AudioOut(board.A0) +//| data = open("cplay-5.1-16bit-16khz.wav", "rb") +//| wav = audiocore.WaveFile(data) +//| a = audioio.AudioOut(board.A0) +//| +//| print("playing") +//| a.play(wav) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... //| -//|print("playing") -//|a.play(wav) -//|while a.playing: -//|pass -//|print("stopped")""" -//|... STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { @@ -115,9 +116,10 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Deinitialises the AudioOut and releases any hardware resources for reuse.""" -//|... +//| def deinit(self, ) -> Any: +//| """Deinitialises the AudioOut and releases any hardware resources for reuse.""" +//| ... +//| STATIC mp_obj_t audioio_audioout_deinit(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_audioout_deinit(self); @@ -130,15 +132,17 @@ STATIC void check_for_deinit(audioio_audioout_obj_t *self) { raise_deinited_error(); } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... +//| // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_audioout_deinit(args[0]); @@ -147,16 +151,17 @@ STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *arg STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, audioio_audioout_obj___exit__); -//|def play(self, sample: Any, *, loop: Any = False) -> Any: -//|"""Plays the sample once when loop=False and continuously when loop=True. -//|Does not block. Use `playing` to block. +//| def play(self, sample: Any, *, loop: Any = False) -> Any: +//| """Plays the sample once when loop=False and continuously when loop=True. +//| Does not block. Use `playing` to block. //| -//|Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//| +//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output +//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit +//| DAC that ignores the lowest 6 bits when playing 16 bit samples.""" +//| ... //| -//|The sample itself should consist of 16 bit samples. Microcontrollers with a lower output -//|resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit -//|DAC that ignores the lowest 6 bits when playing 16 bit samples.""" -//|... STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -175,9 +180,10 @@ STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_arg } MP_DEFINE_CONST_FUN_OBJ_KW(audioio_audioout_play_obj, 1, audioio_audioout_obj_play); -//|def stop(self, ) -> Any: -//|"""Stops playback and resets to the start of the sample.""" -//|... +//| def stop(self, ) -> Any: +//| """Stops playback and resets to the start of the sample.""" +//| ... +//| STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -186,9 +192,9 @@ STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_stop_obj, audioio_audioout_obj_stop); -//|playing: Any = -//|"""True when an audio sample is being output even if `paused`. (read-only)""" -//|... +//| playing: Any = ... +//| """True when an audio sample is being output even if `paused`. (read-only)""" +//| 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); check_for_deinit(self); @@ -203,9 +209,10 @@ const mp_obj_property_t audioio_audioout_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|def pause(self, ) -> Any: -//|"""Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" -//|... +//| def pause(self, ) -> Any: +//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" +//| ... +//| STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -218,9 +225,10 @@ STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_pause_obj, audioio_audioout_obj_pause); -//|def resume(self, ) -> Any: -//|"""Resumes sample playback after :py:func:`pause`.""" -//|... +//| def resume(self, ) -> Any: +//| """Resumes sample playback after :py:func:`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); check_for_deinit(self); @@ -233,9 +241,9 @@ STATIC mp_obj_t audioio_audioout_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_resume_obj, audioio_audioout_obj_resume); -//|paused: Any = -//|"""True when playback is paused. (read-only)""" -//|... +//| paused: Any = ... +//| """True when playback is paused. (read-only)""" +//| 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); check_for_deinit(self); diff --git a/shared-bindings/audioio/__init__.c b/shared-bindings/audioio/__init__.c index 02a5fe1eee..bc2e26cfce 100644 --- a/shared-bindings/audioio/__init__.c +++ b/shared-bindings/audioio/__init__.c @@ -42,7 +42,7 @@ #include "shared-bindings/audiomixer/Mixer.h" #endif -//| :mod:`audioio` --- Support for audio input and output +//| """:mod:`audioio` --- Support for audio input and output //| ====================================================== //| //| .. module:: audioio @@ -68,7 +68,7 @@ //| //| For compatibility with CircuitPython 4.x, some builds allow the items in //| `audiocore` to be imported from `audioio`. This will be removed for all -//| boards in a future build of CircuitPython. +//| boards in a future build of CircuitPython.""" //| STATIC const mp_rom_map_elem_t audioio_module_globals_table[] = { diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 93b1d3635f..966581d454 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -38,50 +38,51 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//|class Mixer: -//|""".. currentmodule:: audiomixer +//| class Mixer: +//| """.. currentmodule:: audiomixer //| -//|:class:`Mixer` -- Mixes one or more audio samples together -//|=========================================================== +//| :class:`Mixer` -- Mixes one or more audio samples together +//| =========================================================== //| -//|Mixer mixes multiple samples into one sample.""" +//| Mixer mixes multiple samples into one sample.""" //| -//|def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000): -//|"""Create a Mixer object that can mix multiple channels with the same sample rate. -//|Samples are accessed and controlled with the mixer's `audiomixer.MixerVoice` objects. +//| def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000): +//| """Create a Mixer object that can mix multiple channels with the same sample rate. +//| Samples are accessed and controlled with the mixer's `audiomixer.MixerVoice` objects. //| -//|:param int voice_count: The maximum number of voices to mix -//|:param int buffer_size: The total size in bytes of the buffers to mix into -//|:param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo. -//|:param int bits_per_sample: The bits per sample of the samples being played -//|:param bool samples_signed: Samples are signed (True) or unsigned (False) -//|:param int sample_rate: The sample rate to be used for all samples +//| :param int voice_count: The maximum number of voices to mix +//| :param int buffer_size: The total size in bytes of the buffers to mix into +//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo. +//| :param int bits_per_sample: The bits per sample of the samples being played +//| :param bool samples_signed: Samples are signed (True) or unsigned (False) +//| :param int sample_rate: The sample rate to be used for all samples //| -//|Playing a wave file from flash:: +//| Playing a wave file from flash:: //| -//|import board -//|import audioio -//|import audiocore -//|import audiomixer -//|import digitalio +//| import board +//| import audioio +//| import audiocore +//| import audiomixer +//| import digitalio //| -//|a = audioio.AudioOut(board.A0) -//|music = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) -//|drum = audiocore.WaveFile(open("drum.wav", "rb")) -//|mixer = audiomixer.Mixer(voice_count=2, sample_rate=16000, channel_count=1, -//|bits_per_sample=16, samples_signed=True) +//| a = audioio.AudioOut(board.A0) +//| music = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) +//| drum = audiocore.WaveFile(open("drum.wav", "rb")) +//| mixer = audiomixer.Mixer(voice_count=2, sample_rate=16000, channel_count=1, +//| bits_per_sample=16, samples_signed=True) +//| +//| print("playing") +//| # Have AudioOut play our Mixer source +//| a.play(mixer) +//| # Play the first sample voice +//| mixer.voice[0].play(music) +//| while mixer.playing: +//| # Play the second sample voice +//| mixer.voice[1].play(drum) +//| time.sleep(1) +//| print("stopped")""" +//| ... //| -//|print("playing") -//|# Have AudioOut play our Mixer source -//|a.play(mixer) -//|# Play the first sample voice -//|mixer.voice[0].play(music) -//|while mixer.playing: -//|# Play the second sample voice -//|mixer.voice[1].play(drum) -//|time.sleep(1) -//|print("stopped")""" -//|... STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice_count, ARG_buffer_size, ARG_channel_count, ARG_bits_per_sample, ARG_samples_signed, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -125,9 +126,10 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Deinitialises the Mixer and releases any hardware resources for reuse.""" -//|... +//| def deinit(self, ) -> Any: +//| """Deinitialises the Mixer and releases any hardware resources for reuse.""" +//| ... +//| STATIC mp_obj_t audiomixer_mixer_deinit(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiomixer_mixer_deinit(self); @@ -141,15 +143,17 @@ STATIC void check_for_deinit(audiomixer_mixer_obj_t *self) { } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... +//| // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| STATIC mp_obj_t audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiomixer_mixer_deinit(args[0]); @@ -157,9 +161,9 @@ STATIC mp_obj_t audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomixer_mixer___exit___obj, 4, 4, audiomixer_mixer_obj___exit__); -//|playing: Any = -//|"""True when any voice is being output. (read-only)""" -//|... +//| playing: Any = ... +//| """True when any voice is being output. (read-only)""" +//| STATIC mp_obj_t audiomixer_mixer_obj_get_playing(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -174,9 +178,9 @@ const mp_obj_property_t audiomixer_mixer_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|sample_rate: Any = -//|"""32 bit value that dictates how quickly samples are played in Hertz (cycles per second).""" -//|... +//| sample_rate: Any = ... +//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second).""" +//| STATIC mp_obj_t audiomixer_mixer_obj_get_sample_rate(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -191,14 +195,13 @@ const mp_obj_property_t audiomixer_mixer_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|voice: Any = -//|"""A tuple of the mixer's `audiomixer.MixerVoice` object(s). +//| voice: Any = ... +//| """A tuple of the mixer's `audiomixer.MixerVoice` object(s). //| -//|.. code-block:: python +//| .. code-block:: python //| -//|>>> mixer.voice -//|(,)""" -//|... +//| >>> mixer.voice +//| (,)""" STATIC mp_obj_t audiomixer_mixer_obj_get_voice(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -213,14 +216,15 @@ const mp_obj_property_t audiomixer_mixer_voice_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|def play(self, sample: Any, *, voice: Any = 0, loop: Any = False) -> Any: -//|"""Plays the sample once when loop=False and continuously when loop=True. -//|Does not block. Use `playing` to block. +//| def play(self, sample: Any, *, voice: Any = 0, loop: Any = False) -> Any: +//| """Plays the sample once when loop=False and continuously when loop=True. +//| Does not block. Use `playing` to block. //| -//|Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//| +//| The sample must match the Mixer's encoding settings given in the constructor.""" +//| ... //| -//|The sample must match the Mixer's encoding settings given in the constructor.""" -//|... STATIC mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_voice, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -245,9 +249,10 @@ STATIC mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_arg } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixer_play_obj, 1, audiomixer_mixer_obj_play); -//|def stop_voice(self, voice: Any = 0) -> Any: -//|"""Stops playback of the sample on the given voice.""" -//|... +//| def stop_voice(self, voice: Any = 0) -> Any: +//| """Stops playback of the sample on the given voice.""" +//| ... +//| STATIC mp_obj_t audiomixer_mixer_obj_stop_voice(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index 299600dd14..257d9507b9 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -37,18 +37,18 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//|class MixerVoice: -//|""".. currentmodule:: audiomixer +//| class MixerVoice: +//| """.. currentmodule:: audiomixer //| -//|:class:`MixerVoice` -- Voice objects used with Mixer -//|===================================================== +//| :class:`MixerVoice` -- Voice objects used with Mixer +//| ===================================================== //| -//|Used to access and control samples with `audiomixer.Mixer`.""" +//| Used to access and control samples with `audiomixer.Mixer`.""" //| -//|def __init__(self, ): +//| def __init__(self, ): +//| """MixerVoice instance object(s) created by `audiomixer.Mixer`.""" +//| ... //| -//|"""MixerVoice instance object(s) created by `audiomixer.Mixer`.""" -//|... // TODO: support mono or stereo voices STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { audiomixer_mixervoice_obj_t *self = m_new_obj(audiomixer_mixervoice_obj_t); @@ -59,14 +59,15 @@ STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t return MP_OBJ_FROM_PTR(self); } -//|def play(self, sample: Any, *, loop: Any = False) -> Any: -//|"""Plays the sample once when ``loop=False``, and continuously when ``loop=True``. -//|Does not block. Use `playing` to block. +//| def play(self, sample: Any, *, loop: Any = False) -> Any: +//| """Plays the sample once when ``loop=False``, and continuously when ``loop=True``. +//| Does not block. Use `playing` to block. //| -//|Sample must be an `audiocore.WaveFile`, `audiomixer.Mixer` or `audiocore.RawSample`. +//| Sample must be an `audiocore.WaveFile`, `audiomixer.Mixer` or `audiocore.RawSample`. +//| +//| The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor.""" +//| ... //| -//|The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor.""" -//|... STATIC mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -83,9 +84,10 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *po } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_play_obj, 1, audiomixer_mixervoice_obj_play); -//|def stop(self, ) -> Any: -//|"""Stops playback of the sample on this voice.""" -//|... +//| def stop(self, ) -> Any: +//| """Stops playback of the sample on this voice.""" +//| ... +//| STATIC mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { @@ -101,9 +103,9 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *po } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_stop_obj, 1, audiomixer_mixervoice_obj_stop); -//|level(): Any = -//|"""The volume level of a voice, as a floating point number between 0 and 1.""" -//|... +//| level: Any = ... +//| """The volume level of a voice, as a floating point number between 0 and 1.""" +//| STATIC mp_obj_t audiomixer_mixervoice_obj_get_level(mp_obj_t self_in) { return mp_obj_new_float(common_hal_audiomixer_mixervoice_get_level(self_in)); } @@ -137,9 +139,9 @@ const mp_obj_property_t audiomixer_mixervoice_level_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|playing: Any = -//|"""True when this voice is being output. (read-only)""" -//|... +//| playing: Any = ... +//| """True when this voice is being output. (read-only)""" +//| STATIC mp_obj_t audiomixer_mixervoice_obj_get_playing(mp_obj_t self_in) { audiomixer_mixervoice_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/audiomixer/__init__.c b/shared-bindings/audiomixer/__init__.c index 79bab440e5..c90a4a0e65 100644 --- a/shared-bindings/audiomixer/__init__.c +++ b/shared-bindings/audiomixer/__init__.c @@ -32,7 +32,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiomixer/Mixer.h" -//| :mod:`audiomixer` --- Support for audio mixer +//| """:mod:`audiomixer` --- Support for audio mixer //| ======================================================== //| //| .. module:: audiomixer @@ -46,7 +46,7 @@ //| :maxdepth: 3 //| //| Mixer -//| MixerVoice +//| MixerVoice""" //| STATIC const mp_rom_map_elem_t audiomixer_module_globals_table[] = { diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 7c011b65f3..d9c85bbf63 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -34,42 +34,44 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//|class MP3: -//|""".. currentmodule:: audiomp3 +//| class MP3: +//| """.. currentmodule:: audiomp3 //| -//|:class:`MP3Decoder` -- Load a mp3 file for audio playback -//|========================================================= +//| :class:`MP3Decoder` -- Load a mp3 file for audio playback +//| ========================================================= //| -//|An object that decodes MP3 files for playback on an audio device.""" +//| An object that decodes MP3 files for playback on an audio device.""" //| -//|def __init__(self, file: typing.BinaryIO, buffer: bytearray): -//|"""Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. +//| def __init__(self, file: typing.BinaryIO, buffer: bytearray): //| -//|:param typing.BinaryIO file: Already opened mp3 file -//|:param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. +//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. +//| +//| :param typing.BinaryIO file: Already opened mp3 file +//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. //| //| -//|Playing a mp3 file from flash:: +//| Playing a mp3 file from flash:: //| -//|import board -//|import audiomp3 -//|import audioio -//|import digitalio +//| import board +//| import audiomp3 +//| import audioio +//| import digitalio //| -//|# Required for CircuitPlayground Express -//|speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//|speaker_enable.switch_to_output(value=True) +//| # Required for CircuitPlayground Express +//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//| speaker_enable.switch_to_output(value=True) //| -//|data = open("cplay-16bit-16khz-64kbps.mp3", "rb") -//|mp3 = audiomp3.MP3Decoder(data) -//|a = audioio.AudioOut(board.A0) +//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb") +//| mp3 = audiomp3.MP3Decoder(data) +//| a = audioio.AudioOut(board.A0) +//| +//| print("playing") +//| a.play(mp3) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... //| -//|print("playing") -//|a.play(mp3) -//|while a.playing: -//|pass -//|print("stopped")""" -//|... STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 2, false); @@ -92,9 +94,10 @@ STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//|def deinit(self, ) -> Any: -//|"""Deinitialises the MP3 and releases all memory resources for reuse.""" -//|... +//| def deinit(self, ) -> Any: +//| """Deinitialises the MP3 and releases all memory resources for reuse.""" +//| ... +//| STATIC mp_obj_t audiomp3_mp3file_deinit(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiomp3_mp3file_deinit(self); @@ -108,15 +111,17 @@ STATIC void check_for_deinit(audiomp3_mp3file_obj_t *self) { } } -//|def __enter__(self, ) -> Any: -//|"""No-op used by Context Managers.""" -//|... +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... +//| // Provided by context manager helper. -//|def __exit__(self, ) -> Any: -//|"""Automatically deinitializes the hardware when exiting a context. See -//|:ref:`lifetime-and-contextmanagers` for more info.""" -//|... +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiomp3_mp3file_deinit(args[0]); @@ -124,9 +129,9 @@ STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__); -//|file: Any = -//|"""File to play back.""" -//|... +//| file: Any = ... +//| """File to play back.""" +//| STATIC mp_obj_t audiomp3_mp3file_obj_get_file(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -154,11 +159,11 @@ const mp_obj_property_t audiomp3_mp3file_file_obj = { -//|sample_rate: Any = -//|"""32 bit value that dictates how quickly samples are loaded into the DAC -//|in Hertz (cycles per second). When the sample is looped, this can change -//|the pitch output without changing the underlying sample.""" -//|... +//| sample_rate: Any = ... +//| """32 bit value that dictates how quickly samples are loaded into the DAC +//| in Hertz (cycles per second). When the sample is looped, this can change +//| the pitch output without changing the underlying sample.""" +//| STATIC mp_obj_t audiomp3_mp3file_obj_get_sample_rate(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -181,9 +186,9 @@ const mp_obj_property_t audiomp3_mp3file_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|bits_per_sample: Any = -//|"""Bits per sample. (read only)""" -//|... +//| bits_per_sample: Any = ... +//| """Bits per sample. (read only)""" +//| STATIC mp_obj_t audiomp3_mp3file_obj_get_bits_per_sample(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -198,9 +203,9 @@ const mp_obj_property_t audiomp3_mp3file_bits_per_sample_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|channel_count: Any = -//|"""Number of audio channels. (read only)""" -//|... +//| channel_count: Any = ... +//| """Number of audio channels. (read only)""" +//| STATIC mp_obj_t audiomp3_mp3file_obj_get_channel_count(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -215,9 +220,9 @@ const mp_obj_property_t audiomp3_mp3file_channel_count_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//|rms_level: Any = -//|"""The RMS audio level of a recently played moment of audio. (read only)""" -//|... +//| rms_level: Any = ... +//| """The RMS audio level of a recently played moment of audio. (read only)""" +//| STATIC mp_obj_t audiomp3_mp3file_obj_get_rms_level(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiomp3/__init__.c b/shared-bindings/audiomp3/__init__.c index fb2187669c..50b29da529 100644 --- a/shared-bindings/audiomp3/__init__.c +++ b/shared-bindings/audiomp3/__init__.c @@ -31,7 +31,7 @@ #include "shared-bindings/audiomp3/MP3Decoder.h" -//| :mod:`audiomp3` --- Support for MP3-compressed audio files +//| """:mod:`audiomp3` --- Support for MP3-compressed audio files //| ========================================================== //| //| .. module:: audiomp3 @@ -44,7 +44,7 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| MP3Decoder +//| MP3Decoder""" //| STATIC const mp_rom_map_elem_t audiomp3_module_globals_table[] = { From 7dd3ddc06b428a10ada5700bb68002c325ed79c2 Mon Sep 17 00:00:00 2001 From: Yihui Xiong Date: Fri, 1 May 2020 06:03:19 +0000 Subject: [PATCH 034/216] use Nordic's VID which seems to be allowed https://devzone.nordicsemi.com/f/nordic-q-a/50638/usb-pid-for-nrf52840 --- ports/nrf/boards/pitaya_go/mpconfigboard.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/nrf/boards/pitaya_go/mpconfigboard.mk b/ports/nrf/boards/pitaya_go/mpconfigboard.mk index e3b273f966..247ddd8ac5 100644 --- a/ports/nrf/boards/pitaya_go/mpconfigboard.mk +++ b/ports/nrf/boards/pitaya_go/mpconfigboard.mk @@ -1,5 +1,6 @@ -USB_VID = 0x239A -USB_PID = 0x802A +# Using Nordic's VID - https://devzone.nordicsemi.com/f/nordic-q-a/50638/usb-pid-for-nrf52840 +USB_VID = 0x1915 +USB_PID = 0xb001 USB_PRODUCT = "Pitaya Go" USB_MANUFACTURER = "Makerdiary" From 0e465e63b98c3825298219e2144a145208aaff7f Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 1 May 2020 18:23:27 -0400 Subject: [PATCH 035/216] Did audiopwmio, bitbangio, and _bleio --- shared-bindings/_bleio/Adapter.c | 151 ++++++++--------- shared-bindings/_bleio/Address.c | 71 ++++---- shared-bindings/_bleio/Attribute.c | 58 +++---- shared-bindings/_bleio/Characteristic.c | 134 +++++++-------- shared-bindings/_bleio/CharacteristicBuffer.c | 81 ++++----- shared-bindings/_bleio/Connection.c | 105 ++++++------ shared-bindings/_bleio/Descriptor.c | 72 ++++---- shared-bindings/_bleio/PacketBuffer.c | 73 ++++---- shared-bindings/_bleio/ScanEntry.c | 54 +++--- shared-bindings/_bleio/ScanResults.c | 31 ++-- shared-bindings/_bleio/Service.c | 51 +++--- shared-bindings/_bleio/UUID.c | 67 ++++---- shared-bindings/_bleio/__init__.c | 38 +++-- shared-bindings/audiopwmio/PWMAudioOut.c | 160 +++++++++--------- shared-bindings/audiopwmio/__init__.c | 4 +- shared-bindings/bitbangio/I2C.c | 152 ++++++++--------- shared-bindings/bitbangio/OneWire.c | 80 ++++----- shared-bindings/bitbangio/SPI.c | 127 +++++++------- shared-bindings/bitbangio/__init__.c | 4 +- 19 files changed, 738 insertions(+), 775 deletions(-) diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 921667f0fb..6fb5c323d7 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -47,35 +47,35 @@ #define INTERVAL_MAX_STRING "40.959375" #define WINDOW_DEFAULT (0.1f) -//| .. currentmodule:: _bleio +//| class Adapter: +//| """.. currentmodule:: _bleio //| -//| :class:`Adapter` --- BLE adapter -//| ---------------------------------------------------- +//| :class:`Adapter` --- BLE adapter +//| ---------------------------------------------------- //| -//| The Adapter manages the discovery and connection to other nearby Bluetooth Low Energy devices. -//| This part of the Bluetooth Low Energy Specification is known as Generic Access Profile (GAP). +//| The Adapter manages the discovery and connection to other nearby Bluetooth Low Energy devices. +//| This part of the Bluetooth Low Energy Specification is known as Generic Access Profile (GAP). //| -//| Discovery of other devices happens during a scanning process that listens for small packets of -//| information, known as advertisements, that are broadcast unencrypted. The advertising packets -//| have two different uses. The first is to broadcast a small piece of data to anyone who cares and -//| and nothing more. These are known as Beacons. The second class of advertisement is to promote -//| additional functionality available after the devices establish a connection. For example, a -//| BLE keyboard may advertise that it can provide key information, but not what the key info is. +//| Discovery of other devices happens during a scanning process that listens for small packets of +//| information, known as advertisements, that are broadcast unencrypted. The advertising packets +//| have two different uses. The first is to broadcast a small piece of data to anyone who cares and +//| and nothing more. These are known as Beacons. The second class of advertisement is to promote +//| additional functionality available after the devices establish a connection. For example, a +//| BLE keyboard may advertise that it can provide key information, but not what the key info is. //| -//| The built-in BLE adapter can do both parts of this process: it can scan for other device -//| advertisements and it can advertise its own data. Furthermore, Adapters can accept incoming -//| connections and also initiate connections. +//| The built-in BLE adapter can do both parts of this process: it can scan for other device +//| advertisements and it can advertise its own data. Furthermore, Adapters can accept incoming +//| connections and also initiate connections.""" //| -//| .. class:: Adapter() -//| -//| You cannot create an instance of `_bleio.Adapter`. -//| Use `_bleio.adapter` to access the sole instance available. +//| def __init__(self, ): +//| """You cannot create an instance of `_bleio.Adapter`. +//| Use `_bleio.adapter` to access the sole instance available.""" +//| ... //| -//| .. attribute:: enabled -//| -//| State of the BLE adapter. +//| enabled: Any = ... +//| """State of the BLE adapter.""" //| STATIC mp_obj_t bleio_adapter_get_enabled(mp_obj_t self) { return mp_obj_new_bool(common_hal_bleio_adapter_get_enabled(self)); @@ -98,9 +98,8 @@ const mp_obj_property_t bleio_adapter_enabled_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: address -//| -//| MAC address of the BLE adapter. (read-only) +//| address: Any = ... +//| """MAC address of the BLE adapter. (read-only)""" //| STATIC mp_obj_t bleio_adapter_get_address(mp_obj_t self) { return MP_OBJ_FROM_PTR(common_hal_bleio_adapter_get_address(self)); @@ -115,11 +114,10 @@ const mp_obj_property_t bleio_adapter_address_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: name -//| -//| name of the BLE adapter used once connected. -//| The name is "CIRCUITPY" + the last four hex digits of ``adapter.address``, -//| to make it easy to distinguish multiple CircuitPython boards. +//| name: Any = ... +//| """name of the BLE adapter used once connected. +//| The name is "CIRCUITPY" + the last four hex digits of ``adapter.address``, +//| to make it easy to distinguish multiple CircuitPython boards.""" //| STATIC mp_obj_t bleio_adapter_get_name(mp_obj_t self) { return MP_OBJ_FROM_PTR(common_hal_bleio_adapter_get_name(self)); @@ -140,18 +138,18 @@ const mp_obj_property_t bleio_adapter_name_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. method:: start_advertising(data, *, scan_response=None, connectable=True, interval=0.1) +//| def start_advertising(self, data: buf, *, scan_response: buf = None, connectable: bool = True, interval: float = 0.1) -> Any: +//| """Starts advertising until `stop_advertising` is called or if connectable, another device +//| connects to us. //| -//| Starts advertising until `stop_advertising` is called or if connectable, another device -//| connects to us. +//| .. warning: If data is longer than 31 bytes, then this will automatically advertise as an +//| extended advertisement that older BLE 4.x clients won't be able to scan for. //| -//| .. warning: If data is longer than 31 bytes, then this will automatically advertise as an -//| extended advertisement that older BLE 4.x clients won't be able to scan for. -//| -//| :param buf data: advertising data packet bytes -//| :param buf scan_response: scan response data packet bytes. ``None`` if no scan response is needed. -//| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral. -//| :param float interval: advertising interval, in seconds +//| :param buf data: advertising data packet bytes +//| :param buf scan_response: scan response data packet bytes. ``None`` if no scan response is needed. +//| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral. +//| :param float interval: advertising interval, in seconds""" +//| ... //| STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -198,9 +196,10 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 2, bleio_adapter_start_advertising); -//| .. method:: stop_advertising() +//| def stop_advertising(self, ) -> Any: +//| """Stop sending advertising packets.""" +//| ... //| -//| Stop sending advertising packets. STATIC mp_obj_t bleio_adapter_stop_advertising(mp_obj_t self_in) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -210,25 +209,25 @@ STATIC mp_obj_t bleio_adapter_stop_advertising(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_advertising_obj, bleio_adapter_stop_advertising); -//| .. method:: start_scan(prefixes=b"", \*, buffer_size=512, extended=False, timeout=None, interval=0.1, window=0.1, minimum_rssi=-80, active=True) +//| def start_scan(self, prefixes: sequence = b"", *, buffer_size: int = 512, extended: bool = False, timeout: float = None, interval: float = 0.1, window: float = 0.1, minimum_rssi: int = -80, active: bool = True) -> Any: +//| """Starts a BLE scan and returns an iterator of results. Advertisements and scan responses are +//| filtered and returned separately. //| -//| Starts a BLE scan and returns an iterator of results. Advertisements and scan responses are -//| filtered and returned separately. -//| -//| :param sequence prefixes: Sequence of byte string prefixes to filter advertising packets -//| with. A packet without an advertising structure that matches one of the prefixes is -//| ignored. Format is one byte for length (n) and n bytes of prefix and can be repeated. -//| :param int buffer_size: the maximum number of advertising bytes to buffer. -//| :param bool extended: When True, support extended advertising packets. Increasing buffer_size is recommended when this is set. -//| :param float timeout: the scan timeout in seconds. If None, will scan until `stop_scan` is called. -//| :param float interval: the interval (in seconds) between the start of two consecutive scan windows -//| Must be in the range 0.0025 - 40.959375 seconds. -//| :param float window: the duration (in seconds) to scan a single BLE channel. -//| window must be <= interval. -//| :param int minimum_rssi: the minimum rssi of entries to return. -//| :param bool active: retrieve scan responses for scannable advertisements. -//| :returns: an iterable of `_bleio.ScanEntry` objects -//| :rtype: iterable +//| :param sequence prefixes: Sequence of byte string prefixes to filter advertising packets +//| with. A packet without an advertising structure that matches one of the prefixes is +//| ignored. Format is one byte for length (n) and n bytes of prefix and can be repeated. +//| :param int buffer_size: the maximum number of advertising bytes to buffer. +//| :param bool extended: When True, support extended advertising packets. Increasing buffer_size is recommended when this is set. +//| :param float timeout: the scan timeout in seconds. If None, will scan until `stop_scan` is called. +//| :param float interval: the interval (in seconds) between the start of two consecutive scan windows +//| Must be in the range 0.0025 - 40.959375 seconds. +//| :param float window: the duration (in seconds) to scan a single BLE channel. +//| window must be <= interval. +//| :param int minimum_rssi: the minimum rssi of entries to return. +//| :param bool active: retrieve scan responses for scannable advertisements. +//| :returns: an iterable of `_bleio.ScanEntry` objects +//| :rtype: iterable""" +//| ... //| STATIC mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_prefixes, ARG_buffer_size, ARG_extended, ARG_timeout, ARG_interval, ARG_window, ARG_minimum_rssi, ARG_active }; @@ -283,9 +282,10 @@ STATIC mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_scan_obj, 1, bleio_adapter_start_scan); -//| .. method:: stop_scan() +//| def stop_scan(self, ) -> Any: +//| """Stop the current scan.""" +//| ... //| -//| Stop the current scan. STATIC mp_obj_t bleio_adapter_stop_scan(mp_obj_t self_in) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -295,10 +295,9 @@ STATIC mp_obj_t bleio_adapter_stop_scan(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_scan_obj, bleio_adapter_stop_scan); -//| .. attribute:: connected -//| -//| True when the adapter is connected to another device regardless of who initiated the -//| connection. (read-only) +//| connected: Any = ... +//| """True when the adapter is connected to another device regardless of who initiated the +//| connection. (read-only)""" //| STATIC mp_obj_t bleio_adapter_get_connected(mp_obj_t self) { return mp_obj_new_bool(common_hal_bleio_adapter_get_connected(self)); @@ -313,10 +312,9 @@ const mp_obj_property_t bleio_adapter_connected_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: connections -//| -//| Tuple of active connections including those initiated through -//| :py:meth:`_bleio.Adapter.connect`. (read-only) +//| connections: Any = ... +//| """Tuple of active connections including those initiated through +//| :py:meth:`_bleio.Adapter.connect`. (read-only)""" //| STATIC mp_obj_t bleio_adapter_get_connections(mp_obj_t self) { return common_hal_bleio_adapter_get_connections(self); @@ -330,12 +328,12 @@ const mp_obj_property_t bleio_adapter_connections_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. method:: connect(address, *, timeout) +//| def connect(self, address: Address, *, timeout: float/int) -> Any: +//| """Attempts a connection to the device with the given address. //| -//| Attempts a connection to the device with the given address. -//| -//| :param Address address: The address of the peripheral to connect to -//| :param float/int timeout: Try to connect for timeout seconds. +//| :param Address address: The address of the peripheral to connect to +//| :param float/int timeout: Try to connect for timeout seconds.""" +//| ... //| STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -360,9 +358,10 @@ STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 2, bleio_adapter_connect); -//| .. method:: erase_bonding() +//| def erase_bonding(self, ) -> Any: +//| """Erase all bonding information stored in flash memory.""" +//| ... //| -//| Erase all bonding information stored in flash memory. STATIC mp_obj_t bleio_adapter_erase_bonding(mp_obj_t self_in) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index c31eb604b1..2071bd3b24 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -34,22 +34,23 @@ #include "shared-bindings/_bleio/Address.h" #include "shared-module/_bleio/Address.h" -//| .. currentmodule:: _bleio +//| class Address: +//| """.. currentmodule:: _bleio //| -//| :class:`Address` -- BLE address -//| ========================================================= +//| :class:`Address` -- BLE address +//| ========================================================= //| -//| Encapsulates the address of a BLE device. +//| Encapsulates the address of a BLE device.""" //| -//| .. class:: Address(address, address_type) +//| def __init__(self, address: buf, address_type: Any): +//| """Create a new Address object encapsulating the address value. +//| The value itself can be one of: //| -//| Create a new Address object encapsulating the address value. -//| The value itself can be one of: -//| -//| :param buf address: The address value to encapsulate. A buffer object (bytearray, bytes) of 6 bytes. -//| :param int address_type: one of the integer values: `PUBLIC`, `RANDOM_STATIC`, -//| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`. +//| :param buf address: The address value to encapsulate. A buffer object (bytearray, bytes) of 6 bytes. +//| :param int address_type: one of the integer values: `PUBLIC`, `RANDOM_STATIC`, +//| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`.""" +//| ... //| STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_address_type }; @@ -81,9 +82,8 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(self); } -//| .. attribute:: address_bytes -//| -//| The bytes that make up the device address (read-only). +//| address_bytes: Any = ... +//| """The bytes that make up the device address (read-only). //| //| Note that the ``bytes`` object returned is in little-endian order: //| The least significant byte is ``address_bytes[0]``. So the address will @@ -97,7 +97,7 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, //| >>> _bleio.adapter.address //|
//| >>> _bleio.adapter.address.address_bytes -//| b'5\xa8\xed\xf5\x1d\xc8' +//| b'5\xa8\xed\xf5\x1d\xc8'""" //| STATIC mp_obj_t bleio_address_get_address_bytes(mp_obj_t self_in) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -113,12 +113,11 @@ const mp_obj_property_t bleio_address_address_bytes_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: type -//| -//| The address type (read-only). +//| type: Any = ... +//| """The address type (read-only). //| //| One of the integer values: `PUBLIC`, `RANDOM_STATIC`, `RANDOM_PRIVATE_RESOLVABLE`, -//| or `RANDOM_PRIVATE_NON_RESOLVABLE`. +//| or `RANDOM_PRIVATE_NON_RESOLVABLE`.""" //| STATIC mp_obj_t bleio_address_get_type(mp_obj_t self_in) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -134,9 +133,9 @@ const mp_obj_property_t bleio_address_type_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: __eq__(other) -//| -//| Two Address objects are equal if their addresses and address types are equal. +//| def __eq__(self, other: Any) -> Any: +//| """Two Address objects are equal if their addresses and address types are equal.""" +//| ... //| STATIC mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { switch (op) { @@ -160,9 +159,9 @@ STATIC mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_o } } -//| .. method:: __hash__() -//| -//| Returns a hash for the Address data. +//| def __hash__(self, ) -> Any: +//| """Returns a hash for the Address data.""" +//| ... //| STATIC mp_obj_t bleio_address_unary_op(mp_unary_op_t op, mp_obj_t self_in) { switch (op) { @@ -193,22 +192,18 @@ STATIC void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_pr buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]); } -//| .. data:: PUBLIC +//| PUBLIC: Any = ... +//| """A publicly known address, with a company ID (high 24 bits)and company-assigned part (low 24 bits).""" //| -//| A publicly known address, with a company ID (high 24 bits)and company-assigned part (low 24 bits). +//| RANDOM_STATIC: Any = ... +//| """A randomly generated address that does not change often. It may never change or may change after +//| a power cycle.""" //| -//| .. data:: RANDOM_STATIC +//| RANDOM_PRIVATE_RESOLVABLE: Any = ... +//| """An address that is usable when the peer knows the other device's secret Identity Resolving Key (IRK).""" //| -//| A randomly generated address that does not change often. It may never change or may change after -//| a power cycle. -//| -//| .. data:: RANDOM_PRIVATE_RESOLVABLE -//| -//| An address that is usable when the peer knows the other device's secret Identity Resolving Key (IRK). -//| -//| .. data:: RANDOM_PRIVATE_NON_RESOLVABLE -//| -//| A randomly generated address that changes on every connection. +//| RANDOM_PRIVATE_NON_RESOLVABLE: Any = ... +//| """A randomly generated address that changes on every connection.""" //| STATIC const mp_rom_map_elem_t bleio_address_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_address_bytes), MP_ROM_PTR(&bleio_address_address_bytes_obj) }, diff --git a/shared-bindings/_bleio/Attribute.c b/shared-bindings/_bleio/Attribute.c index 2d8b15b9f4..72fd13d1cc 100644 --- a/shared-bindings/_bleio/Attribute.c +++ b/shared-bindings/_bleio/Attribute.c @@ -29,52 +29,44 @@ #include "shared-bindings/_bleio/Characteristic.h" #include "shared-bindings/_bleio/UUID.h" -// - -//| .. currentmodule:: _bleio +//| class Attribute: +//| """.. currentmodule:: _bleio //| -//| :class:`Attribute` -- BLE Attribute -//| ========================================================= +//| :class:`Attribute` -- BLE Attribute +//| ========================================================= //| -//| Definitions associated with all BLE attributes: characteristics, descriptors, etc. -//| :py:class:`~_bleio.Attribute` is, notionally, a superclass of -//| :py:class:`~Characteristic` and :py:class:`~Descriptor`, -//| but is not defined as a Python superclass of those classes. +//| Definitions associated with all BLE attributes: characteristics, descriptors, etc. +//| :py:class:`~_bleio.Attribute` is, notionally, a superclass of +//| :py:class:`~Characteristic` and :py:class:`~Descriptor`, +//| but is not defined as a Python superclass of those classes.""" //| -//| .. class:: Attribute() -//| -//| You cannot create an instance of :py:class:`~_bleio.Attribute`. +//| def __init__(self, ): +//| """You cannot create an instance of :py:class:`~_bleio.Attribute`.""" +//| ... //| STATIC const mp_rom_map_elem_t bleio_attribute_locals_dict_table[] = { -//| .. data:: NO_ACCESS +//| NO_ACCESS: Any = ... +//| """security mode: access not allowed""" //| -//| security mode: access not allowed +//| OPEN: Any = ... +//| """security_mode: no security (link is not encrypted)""" //| -//| .. data:: OPEN +//| ENCRYPT_NO_MITM: Any = ... +//| """security_mode: unauthenticated encryption, without man-in-the-middle protection""" //| -//| security_mode: no security (link is not encrypted) +//| ENCRYPT_WITH_MITM: Any = ... +//| """security_mode: authenticated encryption, with man-in-the-middle protection""" //| -//| .. data:: ENCRYPT_NO_MITM +//| LESC_ENCRYPT_WITH_MITM: Any = ... +//| """security_mode: LESC encryption, with man-in-the-middle protection""" //| -//| security_mode: unauthenticated encryption, without man-in-the-middle protection +//| SIGNED_NO_MITM: Any = ... +//| """security_mode: unauthenticated data signing, without man-in-the-middle protection""" //| -//| .. data:: ENCRYPT_WITH_MITM -//| -//| security_mode: authenticated encryption, with man-in-the-middle protection -//| -//| .. data:: LESC_ENCRYPT_WITH_MITM -//| -//| security_mode: LESC encryption, with man-in-the-middle protection -//| -//| .. data:: SIGNED_NO_MITM -//| -//| security_mode: unauthenticated data signing, without man-in-the-middle protection -//| -//| .. data:: SIGNED_WITH_MITM -//| -//| security_mode: authenticated data signing, without man-in-the-middle protection +//| SIGNED_WITH_MITM: Any = ... +//| """security_mode: authenticated data signing, without man-in-the-middle protection""" //| { MP_ROM_QSTR(MP_QSTR_NO_ACCESS), MP_ROM_INT(SECURITY_MODE_NO_ACCESS) }, { MP_ROM_QSTR(MP_QSTR_OPEN), MP_ROM_INT(SECURITY_MODE_OPEN) }, diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index e55191f7ce..f8f18d0bd6 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -33,45 +33,46 @@ #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" -//| .. currentmodule:: _bleio +//| class Characteristic: +//| """.. currentmodule:: _bleio //| -//| :class:`Characteristic` -- BLE service characteristic -//| ========================================================= +//| :class:`Characteristic` -- BLE service characteristic +//| ========================================================= //| -//| Stores information about a BLE service characteristic and allows reading -//| and writing of the characteristic's value. +//| Stores information about a BLE service characteristic and allows reading +//| and writing of the characteristic's value.""" //| -//| .. class:: Characteristic -//| -//| There is no regular constructor for a Characteristic. A new local Characteristic can be created -//| and attached to a Service by calling `add_to_service()`. -//| Remote Characteristic objects are created by `Connection.discover_remote_services()` -//| as part of remote Services. +//| def __init__(self, ): +//| """There is no regular constructor for a Characteristic. A new local Characteristic can be created +//| and attached to a Service by calling `add_to_service()`. +//| Remote Characteristic objects are created by `Connection.discover_remote_services()` +//| as part of remote Services.""" +//| ... //| -//| .. method:: add_to_service(service, uuid, *, properties=0, read_perm=Attribute.OPEN, write_perm=Attribute.OPEN, max_length=20, fixed_length=False, initial_value=None) +//| def add_to_service(self, service: Service, uuid: UUID, *, properties: int = 0, read_perm: int = Attribute.OPEN, write_perm: int = Attribute.OPEN, max_length: int = 20, fixed_length: bool = False, initial_value: buf = None) -> Any: +//| """Create a new Characteristic object, and add it to this Service. //| -//| Create a new Characteristic object, and add it to this Service. +//| :param Service service: The service that will provide this characteristic +//| :param UUID uuid: The uuid of the characteristic +//| :param int properties: The properties of the characteristic, +//| specified as a bitmask of these values bitwise-or'd together: +//| `BROADCAST`, `INDICATE`, `NOTIFY`, `READ`, `WRITE`, `WRITE_NO_RESPONSE`. +//| :param int read_perm: Specifies whether the characteristic can be read by a client, and if so, which +//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`, +//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`, +//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`. +//| :param int write_perm: Specifies whether the characteristic can be written by a client, and if so, which +//| security mode is required. Values allowed are the same as ``read_perm``. +//| :param int max_length: Maximum length in bytes of the characteristic value. The maximum allowed is +//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum +//| number of data bytes that fit in a single BLE 4.x ATT packet. +//| :param bool fixed_length: True if the characteristic value is of fixed length. +//| :param buf initial_value: The initial value for this characteristic. If not given, will be +//| filled with zeros. //| -//| :param Service service: The service that will provide this characteristic -//| :param UUID uuid: The uuid of the characteristic -//| :param int properties: The properties of the characteristic, -//| specified as a bitmask of these values bitwise-or'd together: -//| `BROADCAST`, `INDICATE`, `NOTIFY`, `READ`, `WRITE`, `WRITE_NO_RESPONSE`. -//| :param int read_perm: Specifies whether the characteristic can be read by a client, and if so, which -//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`, -//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`, -//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`. -//| :param int write_perm: Specifies whether the characteristic can be written by a client, and if so, which -//| security mode is required. Values allowed are the same as ``read_perm``. -//| :param int max_length: Maximum length in bytes of the characteristic value. The maximum allowed is -//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum -//| number of data bytes that fit in a single BLE 4.x ATT packet. -//| :param bool fixed_length: True if the characteristic value is of fixed length. -//| :param buf initial_value: The initial value for this characteristic. If not given, will be -//| filled with zeros. -//| -//| :return: the new Characteristic. +//| :return: the new Characteristic.""" +//| ... //| STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { // class is arg[0], which we can ignore. @@ -145,11 +146,10 @@ STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_characteristic_add_to_service_obj, -//| .. attribute:: properties -//| -//| An int bitmask representing which properties are set, specified as bitwise or'ing of +//| properties: Any = ... +//| """An int bitmask representing which properties are set, specified as bitwise or'ing of //| of these possible values. -//| `BROADCAST`, `INDICATE`, `NOTIFY`, `READ`, `WRITE`, `WRITE_NO_RESPONSE`. +//| `BROADCAST`, `INDICATE`, `NOTIFY`, `READ`, `WRITE`, `WRITE_NO_RESPONSE`.""" //| STATIC mp_obj_t bleio_characteristic_get_properties(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -165,11 +165,10 @@ const mp_obj_property_t bleio_characteristic_properties_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: uuid +//| uuid: Any = ... +//| """The UUID of this characteristic. (read-only) //| -//| The UUID of this characteristic. (read-only) -//| -//| Will be ``None`` if the 128-bit UUID for this characteristic is not known. +//| Will be ``None`` if the 128-bit UUID for this characteristic is not known.""" //| STATIC mp_obj_t bleio_characteristic_get_uuid(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -186,9 +185,8 @@ const mp_obj_property_t bleio_characteristic_uuid_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: value -//| -//| The value of this characteristic. +//| value: Any = ... +//| """The value of this characteristic.""" //| STATIC mp_obj_t bleio_characteristic_get_value(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -218,9 +216,8 @@ const mp_obj_property_t bleio_characteristic_value_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: descriptors -//| -//| A tuple of :py:class:`Descriptor` that describe this characteristic. (read-only) +//| descriptors: Any = ... +//| """A tuple of :py:class:`Descriptor` that describe this characteristic. (read-only)""" //| STATIC mp_obj_t bleio_characteristic_get_descriptors(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -249,9 +246,8 @@ const mp_obj_property_t bleio_characteristic_descriptors_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: service (read-only) -//| -//| The Service this Characteristic is a part of. +//| service: Any = ... +//| """The Service this Characteristic is a part of.""" //| STATIC mp_obj_t bleio_characteristic_get_service(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -267,12 +263,12 @@ const mp_obj_property_t bleio_characteristic_service_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. method:: set_cccd(*, notify=False, indicate=False) +//| def set_cccd(self, *, notify: bool = False, indicate: float = False) -> Any: +//| """Set the remote characteristic's CCCD to enable or disable notification and indication. //| -//| Set the remote characteristic's CCCD to enable or disable notification and indication. -//| -//| :param bool notify: True if Characteristic should receive notifications of remote writes -//| :param float indicate: True if Characteristic should receive indications of remote writes +//| :param bool notify: True if Characteristic should receive notifications of remote writes +//| :param float indicate: True if Characteristic should receive indications of remote writes""" +//| ... //| STATIC mp_obj_t bleio_characteristic_set_cccd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -300,29 +296,23 @@ STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_set_cccd), MP_ROM_PTR(&bleio_characteristic_set_cccd_obj) }, // Bitmask constants to represent properties -//| .. data:: BROADCAST +//| BROADCAST: Any = ... +//| """property: allowed in advertising packets""" //| -//| property: allowed in advertising packets +//| INDICATE: Any = ... +//| """property: server will indicate to the client when the value is set and wait for a response""" //| -//| .. data:: INDICATE +//| NOTIFY: Any = ... +//| """property: server will notify the client when the value is set""" //| -//| property: server will indicate to the client when the value is set and wait for a response +//| READ: Any = ... +//| """property: clients may read this characteristic""" //| -//| .. data:: NOTIFY +//| WRITE: Any = ... +//| """property: clients may write this characteristic; a response will be sent back""" //| -//| property: server will notify the client when the value is set -//| -//| .. data:: READ -//| -//| property: clients may read this characteristic -//| -//| .. data:: WRITE -//| -//| property: clients may write this characteristic; a response will be sent back -//| -//| .. data:: WRITE_NO_RESPONSE -//| -//| property: clients may write this characteristic; no response will be sent back +//| WRITE_NO_RESPONSE: Any = ... +//| """property: clients may write this characteristic; no response will be sent back""" //| { MP_ROM_QSTR(MP_QSTR_BROADCAST), MP_ROM_INT(CHAR_PROP_BROADCAST) }, { MP_ROM_QSTR(MP_QSTR_INDICATE), MP_ROM_INT(CHAR_PROP_INDICATE) }, diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index fc95d0d503..f38f650d91 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -41,24 +41,26 @@ STATIC void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self } } -//| .. currentmodule:: _bleio +//| class CharacteristicBuffer: +//| """.. currentmodule:: _bleio //| -//| :class:`CharacteristicBuffer` -- BLE Service incoming values buffer. -//| ===================================================================== +//| :class:`CharacteristicBuffer` -- BLE Service incoming values buffer. +//| ===================================================================== //| -//| Accumulates a Characteristic's incoming values in a FIFO buffer. +//| Accumulates a Characteristic's incoming values in a FIFO buffer.""" //| -//| .. class:: CharacteristicBuffer(characteristic, *, timeout=1, buffer_size=64) +//| def __init__(self, characteristic: Characteristic, *, timeout: int = 1, buffer_size: int = 64): //| -//| Monitor the given Characteristic. Each time a new value is written to the Characteristic -//| add the newly-written bytes to a FIFO buffer. +//| """Monitor the given Characteristic. Each time a new value is written to the Characteristic +//| add the newly-written bytes to a FIFO buffer. //| -//| :param Characteristic characteristic: The Characteristic to monitor. -//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic -//| in a remote Service that a Central has connected to. -//| :param int timeout: the timeout in seconds to wait for the first character and between subsequent characters. -//| :param int buffer_size: Size of ring buffer that stores incoming data coming from client. -//| Must be >= 1. +//| :param Characteristic characteristic: The Characteristic to monitor. +//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic +//| in a remote Service that a Central has connected to. +//| :param int timeout: the timeout in seconds to wait for the first character and between subsequent characters. +//| :param int buffer_size: Size of ring buffer that stores incoming data coming from client. +//| Must be >= 1.""" +//| ... //| STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_characteristic, ARG_timeout, ARG_buffer_size, }; @@ -103,29 +105,29 @@ STATIC void check_for_deinit(bleio_characteristic_buffer_obj_t *self) { // These are standard stream methods. Code is in py/stream.c. // -//| .. method:: read(nbytes=None) +//| def read(self, nbytes: Any = None) -> Any: +//| """Read characters. If ``nbytes`` is specified then read at most that many +//| bytes. Otherwise, read everything that arrives until the connection +//| times out. Providing the number of bytes expected is highly recommended +//| because it will be faster. //| -//| Read characters. If ``nbytes`` is specified then read at most that many -//| bytes. Otherwise, read everything that arrives until the connection -//| times out. Providing the number of bytes expected is highly recommended -//| because it will be faster. +//| :return: Data read +//| :rtype: bytes or None""" +//| ... //| -//| :return: Data read -//| :rtype: bytes or None +//| def readinto(self, buf: Any) -> Any: +//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. //| -//| .. method:: readinto(buf) +//| :return: number of bytes read and stored into ``buf`` +//| :rtype: int or None (on a non-blocking error)""" +//| ... //| -//| Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. +//| def readline(self, ) -> Any: +//| """Read a line, ending in a newline character. //| -//| :return: number of bytes read and stored into ``buf`` -//| :rtype: int or None (on a non-blocking error) -//| -//| .. method:: readline() -//| -//| Read a line, ending in a newline character. -//| -//| :return: the line read -//| :rtype: int or None +//| :return: the line read +//| :rtype: int or None""" +//| ... //| // These three methods are used by the shared stream methods. @@ -170,9 +172,8 @@ STATIC mp_uint_t bleio_characteristic_buffer_ioctl(mp_obj_t self_in, mp_uint_t r return ret; } -//| .. attribute:: in_waiting -//| -//| The number of bytes in the input buffer, available to be read +//| in_waiting: Any = ... +//| """The number of bytes in the input buffer, available to be read""" //| 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); @@ -188,9 +189,9 @@ const mp_obj_property_t bleio_characteristic_buffer_in_waiting_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: reset_input_buffer() -//| -//| Discard any unread characters in the input buffer. +//| def reset_input_buffer(self, ) -> Any: +//| """Discard any unread characters in the input buffer.""" +//| ... //| 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); @@ -200,9 +201,9 @@ STATIC mp_obj_t bleio_characteristic_buffer_obj_reset_input_buffer(mp_obj_t self } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_buffer_reset_input_buffer_obj, bleio_characteristic_buffer_obj_reset_input_buffer); -//| .. method:: deinit() -//| -//| Disable permanently. +//| def deinit(self, ) -> Any: +//| """Disable permanently.""" +//| ... //| STATIC mp_obj_t bleio_characteristic_buffer_deinit(mp_obj_t self_in) { bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index c157af3652..2165f12b8e 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -42,28 +42,29 @@ #include "shared-bindings/_bleio/Characteristic.h" #include "shared-bindings/_bleio/Service.h" -//| .. currentmodule:: _bleio +//| class Connection: +//| """.. currentmodule:: _bleio //| -//| :class:`Connection` -- A BLE connection -//| ========================================================= +//| :class:`Connection` -- A BLE connection +//| ========================================================= //| -//| A BLE connection to another device. Used to discover and interact with services on the other -//| device. +//| A BLE connection to another device. Used to discover and interact with services on the other +//| device. //| -//| Usage:: +//| Usage:: //| -//| import _bleio +//| import _bleio //| -//| my_entry = None -//| for entry in _bleio.adapter.scan(2.5): -//| if entry.name is not None and entry.name == 'InterestingPeripheral': -//| my_entry = entry -//| break +//| my_entry = None +//| for entry in _bleio.adapter.scan(2.5): +//| if entry.name is not None and entry.name == 'InterestingPeripheral': +//| my_entry = entry +//| break //| -//| if not my_entry: -//| raise Exception("'InterestingPeripheral' not found") +//| if not my_entry: +//| raise Exception("'InterestingPeripheral' not found") //| -//| connection = _bleio.adapter.connect(my_entry.address, timeout=10) +//| connection = _bleio.adapter.connect(my_entry.address, timeout=10)""" //| void bleio_connection_ensure_connected(bleio_connection_obj_t *self) { @@ -72,15 +73,15 @@ void bleio_connection_ensure_connected(bleio_connection_obj_t *self) { } } -//| .. class:: Connection() +//| def __init__(self, ): +//| """Connections cannot be made directly. Instead, to initiate a connection use `Adapter.connect`. +//| Connections may also be made when another device initiates a connection. To use a Connection +//| created by a peer, read the `Adapter.connections` property. +//| ... //| -//| Connections cannot be made directly. Instead, to initiate a connection use `Adapter.connect`. -//| Connections may also be made when another device initiates a connection. To use a Connection -//| created by a peer, read the `Adapter.connections` property. -//| -//| .. method:: disconnect() -//| -//| Disconnects from the remote peripheral. Does nothing if already disconnected. +//| def disconnect(self, ) -> Any: +//| ""Disconnects from the remote peripheral. Does nothing if already disconnected.""" +//| ... //| STATIC mp_obj_t bleio_connection_disconnect(mp_obj_t self_in) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -91,9 +92,9 @@ STATIC mp_obj_t bleio_connection_disconnect(mp_obj_t self_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_disconnect_obj, bleio_connection_disconnect); -//| .. method:: pair(*, bond=True) -//| -//| Pair to the peer to improve security. +//| def pair(self, *, bond: Any = True) -> Any: +//| """Pair to the peer to improve security.""" +//| ... //| STATIC mp_obj_t bleio_connection_pair(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -113,29 +114,29 @@ STATIC mp_obj_t bleio_connection_pair(mp_uint_t n_args, const mp_obj_t *pos_args } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_connection_pair_obj, 1, bleio_connection_pair); -//| .. method:: discover_remote_services(service_uuids_whitelist=None) +//| def discover_remote_services(self, service_uuids_whitelist: iterable = None) -> Any: +//| """Do BLE discovery for all services or for the given service UUIDS, +//| to find their handles and characteristics, and return the discovered services. +//| `Connection.connected` must be True. //| -//| Do BLE discovery for all services or for the given service UUIDS, -//| to find their handles and characteristics, and return the discovered services. -//| `Connection.connected` must be True. +//| :param iterable service_uuids_whitelist: //| -//| :param iterable service_uuids_whitelist: +//| an iterable of :py:class:~`UUID` objects for the services provided by the peripheral +//| that you want to use. //| -//| an iterable of :py:class:~`UUID` objects for the services provided by the peripheral -//| that you want to use. +//| The peripheral may provide more services, but services not listed are ignored +//| and will not be returned. //| -//| The peripheral may provide more services, but services not listed are ignored -//| and will not be returned. +//| If service_uuids_whitelist is None, then all services will undergo discovery, which can be +//| slow. //| -//| If service_uuids_whitelist is None, then all services will undergo discovery, which can be -//| slow. +//| If the service UUID is 128-bit, or its characteristic UUID's are 128-bit, you +//| you must have already created a :py:class:~`UUID` object for that UUID in order for the +//| service or characteristic to be discovered. Creating the UUID causes the UUID to be +//| registered for use. (This restriction may be lifted in the future.) //| -//| If the service UUID is 128-bit, or its characteristic UUID's are 128-bit, you -//| you must have already created a :py:class:~`UUID` object for that UUID in order for the -//| service or characteristic to be discovered. Creating the UUID causes the UUID to be -//| registered for use. (This restriction may be lifted in the future.) -//| -//| :return: A tuple of `_bleio.Service` objects provided by the remote peripheral. +//| :return: A tuple of `_bleio.Service` objects provided by the remote peripheral.""" +//| ... //| STATIC mp_obj_t bleio_connection_discover_remote_services(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -156,9 +157,8 @@ STATIC mp_obj_t bleio_connection_discover_remote_services(mp_uint_t n_args, cons } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_connection_discover_remote_services_obj, 1, bleio_connection_discover_remote_services); -//| .. attribute:: connected -//| -//| True if connected to the remote peer. +//| connected: Any = ... +//| """True if connected to the remote peer.""" //| STATIC mp_obj_t bleio_connection_get_connected(mp_obj_t self_in) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -175,9 +175,8 @@ const mp_obj_property_t bleio_connection_connected_obj = { }; -//| .. attribute:: paired -//| -//| True if paired to the remote peer. +//| paired: Any = ... +//| """True if paired to the remote peer.""" //| STATIC mp_obj_t bleio_connection_get_paired(mp_obj_t self_in) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -194,17 +193,15 @@ const mp_obj_property_t bleio_connection_paired_obj = { }; -//| .. attribute:: connection_interval -//| -//| Time between transmissions in milliseconds. Will be multiple of 1.25ms. Lower numbers +//| connection_interval: Any = ... +//| """Time between transmissions in milliseconds. Will be multiple of 1.25ms. Lower numbers //| increase speed and decrease latency but increase power consumption. //| //| When setting connection_interval, the peer may reject the new interval and //| `connection_interval` will then remain the same. //| //| Apple has additional guidelines that dictate should be a multiple of 15ms except if HID is -//| available. When HID is available Apple devices may accept 11.25ms intervals. -//| +//| available. When HID is available Apple devices may accept 11.25ms intervals.""" //| STATIC mp_obj_t bleio_connection_get_connection_interval(mp_obj_t self_in) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index f7b6b5bbf1..00b3bacf51 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -33,41 +33,42 @@ #include "shared-bindings/_bleio/Descriptor.h" #include "shared-bindings/_bleio/UUID.h" -//| .. currentmodule:: _bleio +//| class Descriptor: +//| """.. currentmodule:: _bleio //| -//| :class:`Descriptor` -- BLE descriptor -//| ========================================================= +//| :class:`Descriptor` -- BLE descriptor +//| ========================================================= //| -//| Stores information about a BLE descriptor. -//| Descriptors are attached to BLE characteristics and provide contextual -//| information about the characteristic. +//| Stores information about a BLE descriptor. +//| Descriptors are attached to BLE characteristics and provide contextual +//| information about the characteristic.""" //| -//| .. class:: Descriptor +//| def __init__(self, ): +//| """There is no regular constructor for a Descriptor. A new local Descriptor can be created +//| and attached to a Characteristic by calling `add_to_characteristic()`. +//| Remote Descriptor objects are created by `Connection.discover_remote_services()` +//| as part of remote Characteristics in the remote Services that are discovered. //| -//| There is no regular constructor for a Descriptor. A new local Descriptor can be created -//| and attached to a Characteristic by calling `add_to_characteristic()`. -//| Remote Descriptor objects are created by `Connection.discover_remote_services()` -//| as part of remote Characteristics in the remote Services that are discovered. +//| .. classmethod:: add_to_characteristic(characteristic, uuid, *, read_perm=`Attribute.OPEN`, write_perm=`Attribute.OPEN`, max_length=20, fixed_length=False, initial_value=b'') //| -//| .. classmethod:: add_to_characteristic(characteristic, uuid, *, read_perm=`Attribute.OPEN`, write_perm=`Attribute.OPEN`, max_length=20, fixed_length=False, initial_value=b'') +//| Create a new Descriptor object, and add it to this Service. //| -//| Create a new Descriptor object, and add it to this Service. +//| :param Characteristic characteristic: The characteristic that will hold this descriptor +//| :param UUID uuid: The uuid of the descriptor +//| :param int read_perm: Specifies whether the descriptor can be read by a client, and if so, which +//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`, +//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`, +//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`. +//| :param int write_perm: Specifies whether the descriptor can be written by a client, and if so, which +//| security mode is required. Values allowed are the same as ``read_perm``. +//| :param int max_length: Maximum length in bytes of the descriptor value. The maximum allowed is +//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum +//| number of data bytes that fit in a single BLE 4.x ATT packet. +//| :param bool fixed_length: True if the descriptor value is of fixed length. +//| :param buf initial_value: The initial value for this descriptor. //| -//| :param Characteristic characteristic: The characteristic that will hold this descriptor -//| :param UUID uuid: The uuid of the descriptor -//| :param int read_perm: Specifies whether the descriptor can be read by a client, and if so, which -//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`, -//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`, -//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`. -//| :param int write_perm: Specifies whether the descriptor can be written by a client, and if so, which -//| security mode is required. Values allowed are the same as ``read_perm``. -//| :param int max_length: Maximum length in bytes of the descriptor value. The maximum allowed is -//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum -//| number of data bytes that fit in a single BLE 4.x ATT packet. -//| :param bool fixed_length: True if the descriptor value is of fixed length. -//| :param buf initial_value: The initial value for this descriptor. -//| -//| :return: the new Descriptor. +//| :return: the new Descriptor.""" +//| ... //| STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { // class is arg[0], which we can ignore. @@ -135,9 +136,8 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_descriptor_add_to_characteristic_fun_obj, 3, bleio_descriptor_add_to_characteristic); STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_descriptor_add_to_characteristic_obj, MP_ROM_PTR(&bleio_descriptor_add_to_characteristic_fun_obj)); -//| .. attribute:: uuid -//| -//| The descriptor uuid. (read-only) +//| uuid: Any = ... +//| """The descriptor uuid. (read-only)""" //| STATIC mp_obj_t bleio_descriptor_get_uuid(mp_obj_t self_in) { bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -154,9 +154,8 @@ const mp_obj_property_t bleio_descriptor_uuid_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: characteristic (read-only) -//| -//| The Characteristic this Descriptor is a part of. +//| characteristic: Any = ... +//| """The Characteristic this Descriptor is a part of.""" //| STATIC mp_obj_t bleio_descriptor_get_characteristic(mp_obj_t self_in) { bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -172,9 +171,8 @@ const mp_obj_property_t bleio_descriptor_characteristic_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: value -//| -//| The value of this descriptor. +//| value: Any = ... +//| """The value of this descriptor.""" //| STATIC mp_obj_t bleio_descriptor_get_value(mp_obj_t self_in) { bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index 9e3666044a..14efa022b3 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -35,29 +35,30 @@ #include "shared-bindings/_bleio/UUID.h" #include "shared-bindings/util.h" -//| .. currentmodule:: _bleio +//| class PacketBuffer: +//| """.. currentmodule:: _bleio //| -//| :class:`PacketBuffer` -- Packet-oriented characteristic usage. -//| ===================================================================== +//| :class:`PacketBuffer` -- Packet-oriented characteristic usage. +//| ===================================================================== //| -//| Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware -//| outgoing writes. A packet's size is either the characteristic length or the maximum transmission -//| unit (MTU), whichever is smaller. The MTU can change so check `packet_size` before creating a -//| buffer to store data. +//| Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware +//| outgoing writes. A packet's size is either the characteristic length or the maximum transmission +//| unit (MTU), whichever is smaller. The MTU can change so check `packet_size` before creating a +//| buffer to store data. //| -//| When we're the server, we ignore all connections besides the first to subscribe to -//| notifications. +//| When we're the server, we ignore all connections besides the first to subscribe to +//| notifications.""" //| -//| .. class:: PacketBuffer(characteristic, *, buffer_size) +//| def __init__(self, characteristic: Characteristic, *, buffer_size: int): +//| """Monitor the given Characteristic. Each time a new value is written to the Characteristic +//| add the newly-written bytes to a FIFO buffer. //| -//| Monitor the given Characteristic. Each time a new value is written to the Characteristic -//| add the newly-written bytes to a FIFO buffer. -//| -//| :param Characteristic characteristic: The Characteristic to monitor. -//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic -//| in a remote Service that a Central has connected to. -//| :param int buffer_size: Size of ring buffer (in packets of the Characteristic's maximum -//| length) that stores incoming packets coming from the peer. +//| :param Characteristic characteristic: The Characteristic to monitor. +//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic +//| in a remote Service that a Central has connected to. +//| :param int buffer_size: Size of ring buffer (in packets of the Characteristic's maximum +//| length) that stores incoming packets coming from the peer.""" +//| ... //| STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_characteristic, ARG_buffer_size }; @@ -94,13 +95,13 @@ STATIC void check_for_deinit(bleio_packet_buffer_obj_t *self) { } } -//| .. method:: readinto(buf) +//| def readinto(self, buf: Any) -> Any: +//| """Reads a single BLE packet into the ``buf``. Raises an exception if the next packet is longer +//| than the given buffer. Use `packet_size` to read the maximum length of a single packet. //| -//| Reads a single BLE packet into the ``buf``. Raises an exception if the next packet is longer -//| than the given buffer. Use `packet_size` to read the maximum length of a single packet. -//| -//| :return: number of bytes read and stored into ``buf`` -//| :rtype: int +//| :return: number of bytes read and stored into ``buf`` +//| :rtype: int""" +//| ... //| STATIC mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_obj) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -118,12 +119,12 @@ STATIC mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_o } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_packet_buffer_readinto_obj, bleio_packet_buffer_readinto); -//| .. method:: write(data, *, header=None) +//| def write(self, data: Any, *, header: Any = None) -> Any: +//| """Writes all bytes from data into the same outgoing packet. The bytes from header are included +//| before data when the pending packet is currently empty. //| -//| Writes all bytes from data into the same outgoing packet. The bytes from header are included -//| before data when the pending packet is currently empty. -//| -//| This does not block until the data is sent. It only blocks until the data is pending. +//| This does not block until the data is sent. It only blocks until the data is pending.""" +//| ... //| // TODO: Add a kwarg `merge=False` to dictate whether subsequent writes are merged into a pending // one. @@ -155,10 +156,9 @@ STATIC mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_ } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_packet_buffer_write_obj, 1, bleio_packet_buffer_write); -//| .. method:: deinit() -//| -//| Disable permanently. -//| +//| def deinit(self, ) -> Any: +//| """Disable permanently.""" +//| ... STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_bleio_packet_buffer_deinit(self); @@ -166,10 +166,9 @@ STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_deinit_obj, bleio_packet_buffer_deinit); -//| .. attribute:: packet_size -//| -//| Maximum size of each packet in bytes. This is the minimum of the Characteristic length and -//| the negotiated Maximum Transfer Unit (MTU). +//| packet_size: Any = ... +//| """Maximum size of each packet in bytes. This is the minimum of the Characteristic length and +//| the negotiated Maximum Transfer Unit (MTU).""" //| STATIC mp_obj_t bleio_packet_buffer_get_packet_size(mp_obj_t self_in) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c index d03cd6fb55..a92b247be3 100644 --- a/shared-bindings/_bleio/ScanEntry.c +++ b/shared-bindings/_bleio/ScanEntry.c @@ -35,25 +35,26 @@ #include "shared-bindings/_bleio/UUID.h" #include "shared-module/_bleio/ScanEntry.h" -//| .. currentmodule:: _bleio +//| class ScanEntry: +//| """.. currentmodule:: _bleio //| -//| :class:`ScanEntry` -- BLE scan data -//| ========================================================= +//| :class:`ScanEntry` -- BLE scan data +//| ========================================================= //| -//| Encapsulates information about a device that was received during scanning. It can be -//| advertisement or scan response data. This object may only be created by a `_bleio.ScanResults`: -//| it has no user-visible constructor. +//| Encapsulates information about a device that was received during scanning. It can be +//| advertisement or scan response data. This object may only be created by a `_bleio.ScanResults`: +//| it has no user-visible constructor.""" //| -//| .. class:: ScanEntry() +//| def __init__(self, ): +//| """Cannot be instantiated directly. Use `_bleio.Adapter.start_scan`.""" +//| ... //| -//| Cannot be instantiated directly. Use `_bleio.Adapter.start_scan`. -//| -//| .. method:: matches(prefixes, *, all=True) -//| -//| Returns True if the ScanEntry matches all prefixes when ``all`` is True. This is stricter -//| than the scan filtering which accepts any advertisements that match any of the prefixes -//| where all is False. +//| def matches(self, prefixes: Any, *, all: Any = True) -> Any: +//| """Returns True if the ScanEntry matches all prefixes when ``all`` is True. This is stricter +//| than the scan filtering which accepts any advertisements that match any of the prefixes +//| where all is False.""" +//| ... //| STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -74,9 +75,8 @@ STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_ar } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 2, bleio_scanentry_matches); -//| .. attribute:: address -//| -//| The address of the device (read-only), of type `_bleio.Address`. +//| address: Any = ... +//| """The address of the device (read-only), of type `_bleio.Address`.""" //| STATIC mp_obj_t bleio_scanentry_get_address(mp_obj_t self_in) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -91,9 +91,8 @@ const mp_obj_property_t bleio_scanentry_address_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: advertisement_bytes -//| -//| All the advertisement data present in the packet, returned as a ``bytes`` object. (read-only) +//| advertisement_bytes: Any = ... +//| """All the advertisement data present in the packet, returned as a ``bytes`` object. (read-only)""" //| STATIC mp_obj_t scanentry_get_advertisement_bytes(mp_obj_t self_in) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -108,9 +107,8 @@ const mp_obj_property_t bleio_scanentry_advertisement_bytes_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: rssi -//| -//| The signal strength of the device at the time of the scan, in integer dBm. (read-only) +//| rssi: Any = ... +//| """The signal strength of the device at the time of the scan, in integer dBm. (read-only)""" //| STATIC mp_obj_t scanentry_get_rssi(mp_obj_t self_in) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -125,9 +123,8 @@ const mp_obj_property_t bleio_scanentry_rssi_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: connectable -//| -//| True if the device can be connected to. (read-only) +//| connectable: Any = ... +//| """True if the device can be connected to. (read-only)""" //| STATIC mp_obj_t scanentry_get_connectable(mp_obj_t self_in) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -142,9 +139,8 @@ const mp_obj_property_t bleio_scanentry_connectable_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: scan_response -//| -//| True if the entry was a scan response. (read-only) +//| scan_response: Any = ... +//| """True if the entry was a scan response. (read-only)""" //| STATIC mp_obj_t scanentry_get_scan_response(mp_obj_t self_in) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/ScanResults.c b/shared-bindings/_bleio/ScanResults.c index dcece3d5d4..4b274fc682 100644 --- a/shared-bindings/_bleio/ScanResults.c +++ b/shared-bindings/_bleio/ScanResults.c @@ -32,13 +32,14 @@ #include "py/runtime.h" #include "shared-bindings/_bleio/ScanResults.h" -//| .. currentmodule:: _bleio +//| class ScanResults: +//| """.. currentmodule:: _bleio //| -//| :class:`ScanResults` -- An Iterator over BLE scanning results -//| =============================================================== +//| :class:`ScanResults` -- An Iterator over BLE scanning results +//| =============================================================== //| -//| Iterates over advertising data received while scanning. This object is always created -//| by a `_bleio.Adapter`: it has no user-visible constructor. +//| Iterates over advertising data received while scanning. This object is always created +//| by a `_bleio.Adapter`: it has no user-visible constructor.""" //| STATIC mp_obj_t scanresults_iternext(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &bleio_scanresults_type)); @@ -50,18 +51,18 @@ STATIC mp_obj_t scanresults_iternext(mp_obj_t self_in) { return MP_OBJ_STOP_ITERATION; } -//| .. class:: ScanResults() +//| def __init__(self, ): +//| """Cannot be instantiated directly. Use `_bleio.Adapter.start_scan`.""" +//| ... //| -//| Cannot be instantiated directly. Use `_bleio.Adapter.start_scan`. +//| def __iter__(self, ) -> Any: +//| """Returns itself since it is the iterator.""" +//| ... //| -//| .. method:: __iter__() -//| -//| Returns itself since it is the iterator. -//| -//| .. method:: __next__() -//| -//| Returns the next `_bleio.ScanEntry`. Blocks if none have been received and scanning is still -//| active. Raises `StopIteration` if scanning is finished and no other results are available. +//| def __next__(self, ) -> Any: +//| """Returns the next `_bleio.ScanEntry`. Blocks if none have been received and scanning is still +//| active. Raises `StopIteration` if scanning is finished and no other results are available.""" +//| ... //| const mp_obj_type_t bleio_scanresults_type = { diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index bc242bc364..3526ce1899 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -32,25 +32,26 @@ #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" -//| .. currentmodule:: _bleio +//| class Service: +//| """.. currentmodule:: _bleio //| -//| :class:`Service` -- BLE GATT Service -//| ========================================================= +//| :class:`Service` -- BLE GATT Service +//| ========================================================= //| -//| Stores information about a BLE service and its characteristics. +//| Stores information about a BLE service and its characteristics.""" //| -//| .. class:: Service(uuid, *, secondary=False) +//| def __init__(self, uuid: UUID, *, secondary: bool = False): +//| """Create a new Service identified by the specified UUID. It can be accessed by all +//| connections. This is known as a Service server. Client Service objects are created via +//| `Connection.discover_remote_services`. //| -//| Create a new Service identified by the specified UUID. It can be accessed by all -//| connections. This is known as a Service server. Client Service objects are created via -//| `Connection.discover_remote_services`. +//| To mark the Service as secondary, pass `True` as :py:data:`secondary`. //| -//| To mark the Service as secondary, pass `True` as :py:data:`secondary`. +//| :param UUID uuid: The uuid of the service +//| :param bool secondary: If the service is a secondary one //| -//| :param UUID uuid: The uuid of the service -//| :param bool secondary: If the service is a secondary one -// -//| :return: the new Service +//| :return: the new Service""" +//| ... //| STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_uuid, ARG_secondary }; @@ -77,10 +78,9 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(service); } -//| .. attribute:: characteristics -//| -//| A tuple of :py:class:`Characteristic` designating the characteristics that are offered by -//| this service. (read-only) +//| characteristics: Any = ... +//| """A tuple of :py:class:`Characteristic` designating the characteristics that are offered by +//| this service. (read-only)""" //| STATIC mp_obj_t bleio_service_get_characteristics(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -97,9 +97,8 @@ const mp_obj_property_t bleio_service_characteristics_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: remote -//| -//| True if this is a service provided by a remote device. (read-only) +//| remote: Any = ... +//| """True if this is a service provided by a remote device. (read-only)""" //| STATIC mp_obj_t bleio_service_get_remote(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -115,9 +114,8 @@ const mp_obj_property_t bleio_service_remote_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: secondary -//| -//| True if this is a secondary service. (read-only) +//| secondary: Any = ... +//| """True if this is a secondary service. (read-only)""" //| STATIC mp_obj_t bleio_service_get_secondary(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -133,11 +131,10 @@ const mp_obj_property_t bleio_service_secondary_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: uuid +//| uuid: Any = ... +//| """The UUID of this service. (read-only) //| -//| The UUID of this service. (read-only) -//| -//| Will be ``None`` if the 128-bit UUID for this service is not known. +//| Will be ``None`` if the 128-bit UUID for this service is not known.""" //| STATIC mp_obj_t bleio_service_get_uuid(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index dd34159022..d4b0f84cad 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -33,28 +33,28 @@ #include "py/runtime.h" #include "shared-bindings/_bleio/UUID.h" -//| .. currentmodule:: _bleio +//| class UUID: +//| """.. currentmodule:: _bleio //| -//| :class:`UUID` -- BLE UUID -//| ========================================================= +//| :class:`UUID` -- BLE UUID +//| ========================================================= //| -//| A 16-bit or 128-bit UUID. Can be used for services, characteristics, descriptors and more. +//| A 16-bit or 128-bit UUID. Can be used for services, characteristics, descriptors and more.""" //| - -//| .. class:: UUID(value) +//| def __init__(self, value: Any): +//| """Create a new UUID or UUID object encapsulating the uuid value. +//| The value can be one of: //| -//| Create a new UUID or UUID object encapsulating the uuid value. -//| The value can be one of: +//| - an `int` value in range 0 to 0xFFFF (Bluetooth SIG 16-bit UUID) +//| - a buffer object (bytearray, bytes) of 16 bytes in little-endian order (128-bit UUID) +//| - a string of hex digits of the form 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' //| -//| - an `int` value in range 0 to 0xFFFF (Bluetooth SIG 16-bit UUID) -//| - a buffer object (bytearray, bytes) of 16 bytes in little-endian order (128-bit UUID) -//| - a string of hex digits of the form 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' +//| Creating a 128-bit UUID registers the UUID with the onboard BLE software, and provides a +//| temporary 16-bit UUID that can be used in place of the full 128-bit UUID. //| -//| Creating a 128-bit UUID registers the UUID with the onboard BLE software, and provides a -//| temporary 16-bit UUID that can be used in place of the full 128-bit UUID. -//| -//| :param value: The uuid value to encapsulate -//| :type value: int or typing.ByteString +//| :param value: The uuid value to encapsulate +//| :type value: int or typing.ByteString""" +//| ... //| STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 1, false); @@ -125,11 +125,10 @@ STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, co return MP_OBJ_FROM_PTR(self); } -//| .. attribute:: uuid16 +//| uuid16: Any = ... +//| """The 16-bit part of the UUID. (read-only) //| -//| The 16-bit part of the UUID. (read-only) -//| -//| :type: int +//| :type: int""" //| STATIC mp_obj_t bleio_uuid_get_uuid16(mp_obj_t self_in) { bleio_uuid_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -145,12 +144,11 @@ const mp_obj_property_t bleio_uuid_uuid16_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: uuid128 -//| -//| The 128-bit value of the UUID +//| uuid128: Any = ... +//| """The 128-bit value of the UUID //| Raises AttributeError if this is a 16-bit UUID. (read-only) //| -//| :type: bytes +//| :type: bytes""" //| STATIC mp_obj_t bleio_uuid_get_uuid128(mp_obj_t self_in) { bleio_uuid_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -172,12 +170,11 @@ const mp_obj_property_t bleio_uuid_uuid128_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: size -//| -//| 128 if this UUID represents a 128-bit vendor-specific UUID. 16 if this UUID represents a +//| size: Any = ... +//| """128 if this UUID represents a 128-bit vendor-specific UUID. 16 if this UUID represents a //| 16-bit Bluetooth SIG assigned UUID. (read-only) 32-bit UUIDs are not currently supported. //| -//| :type: int +//| :type: int""" //| STATIC mp_obj_t bleio_uuid_get_size(mp_obj_t self_in) { bleio_uuid_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -194,9 +191,9 @@ const mp_obj_property_t bleio_uuid_size_obj = { }; -//| .. method:: pack_into(buffer, offset=0) -//| -//| Packs the UUID into the given buffer at the given offset. +//| def pack_into(self, buffer: Any, offset: Any = 0) -> Any: +//| """Packs the UUID into the given buffer at the given offset.""" +//| ... //| STATIC mp_obj_t bleio_uuid_pack_into(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_uuid_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -256,11 +253,9 @@ STATIC mp_obj_t bleio_uuid_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } -//| - -//| .. method:: __eq__(other) -//| -//| Two UUID objects are equal if their values match and they are both 128-bit or both 16-bit. +//| def __eq__(self, other: Any) -> Any: +//| """Two UUID objects are equal if their values match and they are both 128-bit or both 16-bit.""" +//| ... //| STATIC mp_obj_t bleio_uuid_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { switch (op) { diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c index dd401398c5..da7bfdd816 100644 --- a/shared-bindings/_bleio/__init__.c +++ b/shared-bindings/_bleio/__init__.c @@ -41,7 +41,7 @@ #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" -//| :mod:`_bleio` --- Bluetooth Low Energy (BLE) communication +//| """:mod:`_bleio` --- Bluetooth Low Energy (BLE) communication //| ================================================================ //| //| .. module:: _bleio @@ -79,13 +79,14 @@ //| .. attribute:: adapter //| //| BLE Adapter used to manage device discovery and connections. -//| This object is the sole instance of `_bleio.Adapter`. +//| This object is the sole instance of `_bleio.Adapter`.""" //| -//| .. class:: BluetoothError(Exception) -//| -//| Catch all exception for Bluetooth related errors. -//| + +//| class BluetoothError: +//| def __init__(self, Exception: Any): +//| """Catch all exception for Bluetooth related errors.""" +//| ... MP_DEFINE_BLEIO_EXCEPTION(BluetoothError, Exception) NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t* fmt, ...) { @@ -95,10 +96,10 @@ NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t* fmt, ...) va_end(argptr); nlr_raise(exception); } - -//| .. class:: ConnectionError(BluetoothError) -//| -//| Raised when a connection is unavailable. +//| class ConnectionError: +//| def __init__(self, BluetoothError: Any): +//| """Raised when a connection is unavailable.""" +//| ... //| MP_DEFINE_BLEIO_EXCEPTION(ConnectionError, bleio_BluetoothError) NORETURN void mp_raise_bleio_ConnectionError(const compressed_string_t* fmt, ...) { @@ -109,19 +110,20 @@ NORETURN void mp_raise_bleio_ConnectionError(const compressed_string_t* fmt, ... nlr_raise(exception); } -//| .. class:: RoleError(BluetoothError) -//| -//| Raised when a resource is used as the mismatched role. For example, if a local CCCD is -//| attempted to be set but they can only be set when remote. +//| class RoleError: +//| def __init__(self, BluetoothError: Any): +//| """Raised when a resource is used as the mismatched role. For example, if a local CCCD is +//| attempted to be set but they can only be set when remote.""" +//| ... //| MP_DEFINE_BLEIO_EXCEPTION(RoleError, bleio_BluetoothError) NORETURN void mp_raise_bleio_RoleError(const compressed_string_t* msg) { mp_raise_msg(&mp_type_bleio_RoleError, msg); } - -//| .. class:: SecurityError(BluetoothError) -//| -//| Raised when a security related error occurs. +//| class SecurityError: +//| def __init__(self, BluetoothError: Any): +//| """Raised when a security related error occurs.""" +//| ... //| MP_DEFINE_BLEIO_EXCEPTION(SecurityError, bleio_BluetoothError) NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t* fmt, ...) { diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index 9fa2b1578e..17f82e3f64 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -36,66 +36,67 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audiopwmio +//| class PWMAudioOut: +//| """.. currentmodule:: audiopwmio //| -//| :class:`PWMAudioOut` -- Output an analog audio signal -//| ======================================================== +//| :class:`PWMAudioOut` -- Output an analog audio signal +//| ======================================================== //| -//| AudioOut can be used to output an analog audio signal on a given pin. +//| AudioOut can be used to output an analog audio signal on a given pin.""" //| -//| .. class:: PWMAudioOut(left_channel, *, right_channel=None, quiescent_value=0x8000) +//| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): +//| """Create a PWMAudioOut object associated with the given pin(s). This allows you to +//| play audio signals out on the given pin(s). In contrast to mod:`audioio`, +//| the pin(s) specified are digital pins, and are driven with a device-dependent PWM +//| signal. //| -//| Create a PWMAudioOut object associated with the given pin(s). This allows you to -//| play audio signals out on the given pin(s). In contrast to mod:`audioio`, -//| the pin(s) specified are digital pins, and are driven with a device-dependent PWM -//| signal. +//| :param ~microcontroller.Pin left_channel: The pin to output the left channel to +//| :param ~microcontroller.Pin right_channel: The pin to output the right channel to +//| :param int quiescent_value: The output value when no signal is present. Samples should start +//| and end with this value to prevent audible popping. //| -//| :param ~microcontroller.Pin left_channel: The pin to output the left channel to -//| :param ~microcontroller.Pin right_channel: The pin to output the right channel to -//| :param int quiescent_value: The output value when no signal is present. Samples should start -//| and end with this value to prevent audible popping. +//| Simple 8ksps 440 Hz sin wave:: //| -//| Simple 8ksps 440 Hz sin wave:: +//| import audiocore +//| import audiopwmio +//| import board +//| import array +//| import time +//| import math //| -//| import audiocore -//| import audiopwmio -//| import board -//| import array -//| import time -//| import math +//| # Generate one period of sine wav. +//| length = 8000 // 440 +//| sine_wave = array.array("H", [0] * length) +//| for i in range(length): +//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//| # Generate one period of sine wav. -//| length = 8000 // 440 -//| sine_wave = array.array("H", [0] * length) -//| for i in range(length): -//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//| dac = audiopwmio.PWMAudioOut(board.SPEAKER) +//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//| dac.play(sine_wave, loop=True) +//| time.sleep(1) +//| dac.stop() //| -//| dac = audiopwmio.PWMAudioOut(board.SPEAKER) -//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) -//| dac.play(sine_wave, loop=True) -//| time.sleep(1) -//| dac.stop() +//| Playing a wave file from flash:: //| -//| Playing a wave file from flash:: +//| import board +//| import audiocore +//| import audiopwmio +//| import digitalio //| -//| import board -//| import audiocore -//| import audiopwmio -//| import digitalio +//| # Required for CircuitPlayground Express +//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//| speaker_enable.switch_to_output(value=True) //| -//| # Required for CircuitPlayground Express -//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//| speaker_enable.switch_to_output(value=True) +//| data = open("cplay-5.1-16bit-16khz.wav", "rb") +//| wav = audiocore.WaveFile(data) +//| a = audiopwmio.PWMAudioOut(board.SPEAKER) //| -//| data = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audiocore.WaveFile(data) -//| a = audiopwmio.PWMAudioOut(board.SPEAKER) -//| -//| print("playing") -//| a.play(wav) -//| while a.playing: -//| pass -//| print("stopped") +//| print("playing") +//| a.play(wav) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... //| STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; @@ -118,9 +119,9 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_ return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the PWMAudioOut and releases any hardware resources for reuse. +//| def deinit(self, ) -> Any: +//| """Deinitialises the PWMAudioOut and releases any hardware resources for reuse.""" +//| ... //| STATIC mp_obj_t audiopwmio_pwmaudioout_deinit(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -134,17 +135,16 @@ STATIC void check_for_deinit(audiopwmio_pwmaudioout_obj_t *self) { raise_deinited_error(); } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... STATIC mp_obj_t audiopwmio_pwmaudioout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiopwmio_pwmaudioout_deinit(args[0]); @@ -153,16 +153,16 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj___exit__(size_t n_args, const mp_obj_ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_pwmaudioout___exit___obj, 4, 4, audiopwmio_pwmaudioout_obj___exit__); -//| .. method:: play(sample, *, loop=False) +//| def play(self, sample: Any, *, loop: Any = False) -> Any: +//| """Plays the sample once when loop=False and continuously when loop=True. +//| Does not block. Use `playing` to block. //| -//| Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. -//| -//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output -//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit -//| DAC that ignores the lowest 6 bits when playing 16 bit samples. +//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output +//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit +//| DAC that ignores the lowest 6 bits when playing 16 bit samples.""" +//| ... //| STATIC mp_obj_t audiopwmio_pwmaudioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; @@ -182,9 +182,9 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_play(size_t n_args, const mp_obj_t *p } MP_DEFINE_CONST_FUN_OBJ_KW(audiopwmio_pwmaudioout_play_obj, 1, audiopwmio_pwmaudioout_obj_play); -//| .. method:: stop() -//| -//| Stops playback and resets to the start of the sample. +//| def stop(self, ) -> Any: +//| """Stops playback and resets to the start of the sample.""" +//| ... //| STATIC mp_obj_t audiopwmio_pwmaudioout_obj_stop(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -194,9 +194,8 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_stop(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_stop_obj, audiopwmio_pwmaudioout_obj_stop); -//| .. attribute:: playing -//| -//| True when an audio sample is being output even if `paused`. (read-only) +//| playing: Any = ... +//| """True when an audio sample is being output even if `paused`. (read-only)""" //| STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_playing(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -212,9 +211,9 @@ const mp_obj_property_t audiopwmio_pwmaudioout_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: pause() -//| -//| Stops playback temporarily while remembering the position. Use `resume` to resume playback. +//| def pause(self, ) -> Any: +//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" +//| ... //| STATIC mp_obj_t audiopwmio_pwmaudioout_obj_pause(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -228,9 +227,9 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_pause_obj, audiopwmio_pwmaudioout_obj_pause); -//| .. method:: resume() -//| -//| Resumes sample playback after :py:func:`pause`. +//| def resume(self, ) -> Any: +//| """Resumes sample playback after :py:func:`pause`.""" +//| ... //| STATIC mp_obj_t audiopwmio_pwmaudioout_obj_resume(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -244,9 +243,8 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_resume_obj, audiopwmio_pwmaudioout_obj_resume); -//| .. attribute:: paused -//| -//| True when playback is paused. (read-only) +//| paused: Any = ... +//| """True when playback is paused. (read-only)""" //| STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_paused(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/audiopwmio/__init__.c b/shared-bindings/audiopwmio/__init__.c index 8a2b202b36..74d22b45ec 100644 --- a/shared-bindings/audiopwmio/__init__.c +++ b/shared-bindings/audiopwmio/__init__.c @@ -33,7 +33,7 @@ #include "shared-bindings/audiopwmio/__init__.h" #include "shared-bindings/audiopwmio/PWMAudioOut.h" -//| :mod:`audiopwmio` --- Support for audio input and output +//| """:mod:`audiopwmio` --- Support for audio input and output //| ======================================================== //| //| .. module:: audiopwmio @@ -55,7 +55,7 @@ //| :ref:`lifetime-and-contextmanagers` for more info. //| //| Since CircuitPython 5, `Mixer`, `RawSample` and `WaveFile` are moved -//| to :mod:`audiocore`. +//| to :mod:`audiocore`.""" //| STATIC const mp_rom_map_elem_t audiopwmio_module_globals_table[] = { diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index 3c4f137771..a682e050e1 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -37,21 +37,22 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: bitbangio +//| class I2C: +//| """.. currentmodule:: bitbangio //| -//| :class:`I2C` --- Two wire serial protocol -//| ------------------------------------------ +//| :class:`I2C` --- Two wire serial protocol +//| ------------------------------------------""" //| -//| .. class:: I2C(scl, sda, *, frequency=400000, timeout) +//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int): +//| """I2C is a two-wire protocol for communicating between devices. At the +//| physical level it consists of 2 wires: SCL and SDA, the clock and data +//| lines respectively. //| -//| I2C is a two-wire protocol for communicating between devices. At the -//| physical level it consists of 2 wires: SCL and SDA, the clock and data -//| lines respectively. -//| -//| :param ~microcontroller.Pin scl: The clock pin -//| :param ~microcontroller.Pin sda: The data pin -//| :param int frequency: The clock frequency of the bus -//| :param int timeout: The maximum clock stretching timeout in microseconds +//| :param ~microcontroller.Pin scl: The clock pin +//| :param ~microcontroller.Pin sda: The data pin +//| :param int frequency: The clock frequency of the bus +//| :param int timeout: The maximum clock stretching timeout in microseconds""" +//| ... //| STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_scl, ARG_sda, ARG_frequency, ARG_timeout }; @@ -73,9 +74,9 @@ STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, return (mp_obj_t)self; } -//| .. method:: deinit() -//| -//| Releases control of the underlying hardware so other classes can use it. +//| def deinit(self, ) -> Any: +//| """Releases control of the underlying hardware so other classes can use it.""" +//| ... //| STATIC mp_obj_t bitbangio_i2c_obj_deinit(mp_obj_t self_in) { bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -90,16 +91,16 @@ STATIC void check_for_deinit(bitbangio_i2c_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used in Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used in Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware on context exit. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware on context exit. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t bitbangio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -114,11 +115,11 @@ static void check_lock(bitbangio_i2c_obj_t *self) { } } -//| .. method:: scan() -//| -//| Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of -//| those that respond. A device responds if it pulls the SDA line low after -//| its address (including a read bit) is sent on the bus. +//| def scan(self, ) -> Any: +//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of +//| those that respond. A device responds if it pulls the SDA line low after +//| its address (including a read bit) is sent on the bus.""" +//| ... //| STATIC mp_obj_t bitbangio_i2c_scan(mp_obj_t self_in) { bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -136,9 +137,9 @@ STATIC mp_obj_t bitbangio_i2c_scan(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_scan_obj, bitbangio_i2c_scan); -//| .. method:: try_lock() -//| -//| Attempts to grab the I2C lock. Returns True on success. +//| def try_lock(self, ) -> Any: +//| """Attempts to grab the I2C lock. Returns True on success.""" +//| ... //| 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); @@ -147,9 +148,9 @@ STATIC mp_obj_t bitbangio_i2c_obj_try_lock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_try_lock_obj, bitbangio_i2c_obj_try_lock); -//| .. method:: unlock() -//| -//| Releases the I2C lock. +//| def unlock(self, ) -> Any: +//| """Releases the I2C 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); @@ -159,20 +160,20 @@ STATIC mp_obj_t bitbangio_i2c_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock); -//| .. method:: readfrom_into(address, buffer, *, start=0, end=None) +//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any: +//| """Read into ``buffer`` from the slave specified by ``address``. +//| The number of bytes read will be the length of ``buffer``. +//| At least one byte must be read. //| -//| Read into ``buffer`` from the slave specified by ``address``. -//| The number of bytes read will be the length of ``buffer``. -//| At least one byte must be read. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buf[start:end]`` will so it saves memory. //| -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buf[start:end]`` will so it saves memory. -//| -//| :param int address: 7-bit device address -//| :param bytearray buffer: buffer to write into -//| :param int start: Index to start writing at -//| :param int end: Index to write up to but not include +//| :param int address: 7-bit device address +//| :param bytearray buffer: buffer to write into +//| :param int start: Index to start writing at +//| :param int end: Index to write up to but not include""" +//| ... //| // Shared arg parsing for readfrom_into and writeto_then_readfrom. STATIC void readfrom(bitbangio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) { @@ -211,25 +212,25 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a } MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_readfrom_into); -//| .. method:: writeto(address, buffer, *, start=0, end=None, stop=True) +//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any: +//| """Write the bytes from ``buffer`` to the slave specified by ``address`` and then transmits a +//| stop bit. Use `writeto_then_readfrom` when needing a write, no stop and repeated start +//| before a read. //| -//| Write the bytes from ``buffer`` to the slave specified by ``address`` and then transmits a -//| stop bit. Use `writeto_then_readfrom` when needing a write, no stop and repeated start -//| before a read. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buffer[start:end]`` will so it saves memory. //| -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. +//| Writing a buffer or slice of length zero is permitted, as it can be used +//| to poll for the existence of a device. //| -//| Writing a buffer or slice of length zero is permitted, as it can be used -//| to poll for the existence of a device. -//| -//| :param int address: 7-bit device address -//| :param bytearray buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include -//| :param bool stop: If true, output an I2C stop condition after the buffer is written. -//| Deprecated. Will be removed in 6.x and act as stop=True. +//| :param int address: 7-bit device address +//| :param bytearray buffer: buffer containing the bytes to write +//| :param int start: Index to start writing from +//| :param int end: Index to read up to but not include +//| :param bool stop: If true, output an I2C stop condition after the buffer is written. +//| Deprecated. Will be removed in 6.x and act as stop=True.""" +//| ... //| // Shared arg parsing for writeto and writeto_then_readfrom. STATIC void writeto(bitbangio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) { @@ -271,23 +272,22 @@ STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, m STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_writeto); -//| .. method:: writeto_then_readfrom(address, out_buffer, in_buffer, *, out_start=0, out_end=None, in_start=0, in_end=None) +//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any: +//| """Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop +//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and +//| ``in_buffer`` can be the same buffer because they are used sequentially. //| -//| Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop -//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and -//| ``in_buffer`` can be the same buffer because they are used sequentially. +//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` +//| will so it saves memory. //| -//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` -//| will so it saves memory. -//| -//| :param int address: 7-bit device address -//| :param bytearray out_buffer: buffer containing the bytes to write -//| :param bytearray in_buffer: buffer to write into -//| :param int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)`` +//| :param int address: 7-bit device address +//| :param bytearray out_buffer: buffer containing the bytes to write +//| :param bytearray in_buffer: buffer to write into +//| :param int out_start: Index to start writing from +//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` +//| :param int in_start: Index to start writing at +//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" //| STATIC mp_obj_t bitbangio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; diff --git a/shared-bindings/bitbangio/OneWire.c b/shared-bindings/bitbangio/OneWire.c index 95bbd0679c..1c9405bd8d 100644 --- a/shared-bindings/bitbangio/OneWire.c +++ b/shared-bindings/bitbangio/OneWire.c @@ -34,33 +34,35 @@ #include "shared-bindings/bitbangio/OneWire.h" #include "shared-bindings/util.h" -//| .. currentmodule:: bitbangio +//| class OneWire: +//| """.. currentmodule:: bitbangio //| -//| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol -//| =============================================================== +//| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol +//| =============================================================== //| -//| :class:`~bitbangio.OneWire` implements the timing-sensitive foundation of -//| the Maxim (formerly Dallas Semi) OneWire protocol. +//| :class:`~bitbangio.OneWire` implements the timing-sensitive foundation of +//| the Maxim (formerly Dallas Semi) OneWire protocol. //| -//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126 +//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126""" //| -//| .. class:: OneWire(pin) +//| def __init__(self, pin: microcontroller.Pin): //| -//| Create a OneWire object associated with the given pin. The object -//| implements the lowest level timing-sensitive bits of the protocol. +//| """Create a OneWire object associated with the given pin. The object +//| implements the lowest level timing-sensitive bits of the protocol. //| -//| :param ~microcontroller.Pin pin: Pin to read pulses from. +//| :param ~microcontroller.Pin pin: Pin to read pulses from. //| -//| Read a short series of pulses:: +//| Read a short series of pulses:: //| -//| import bitbangio -//| import board +//| import bitbangio +//| import board //| -//| onewire = bitbangio.OneWire(board.D7) -//| onewire.reset() -//| onewire.write_bit(True) -//| onewire.write_bit(False) -//| print(onewire.read_bit()) +//| onewire = bitbangio.OneWire(board.D7) +//| onewire.reset() +//| onewire.write_bit(True) +//| onewire.write_bit(False) +//| print(onewire.read_bit())""" +//| ... //| STATIC mp_obj_t bitbangio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pin }; @@ -79,9 +81,9 @@ STATIC mp_obj_t bitbangio_onewire_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialize the OneWire bus and release any hardware resources for reuse. +//| def deinit(self, ) -> Any: +//| """Deinitialize the OneWire bus and release any hardware resources for reuse.""" +//| ... //| STATIC mp_obj_t bitbangio_onewire_deinit(mp_obj_t self_in) { bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -96,16 +98,16 @@ STATIC void check_for_deinit(bitbangio_onewire_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t bitbangio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -114,9 +116,9 @@ STATIC mp_obj_t bitbangio_onewire_obj___exit__(size_t n_args, const mp_obj_t *ar } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_onewire___exit___obj, 4, 4, bitbangio_onewire_obj___exit__); -//| .. method:: reset() -//| -//| Reset the OneWire bus +//| def reset(self, ) -> Any: +//| """Reset the OneWire bus""" +//| ... //| STATIC mp_obj_t bitbangio_onewire_obj_reset(mp_obj_t self_in) { bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -126,12 +128,12 @@ STATIC mp_obj_t bitbangio_onewire_obj_reset(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_reset_obj, bitbangio_onewire_obj_reset); -//| .. method:: read_bit() +//| def read_bit(self, ) -> Any: +//| """Read in a bit //| -//| Read in a bit -//| -//| :returns: bit state read -//| :rtype: bool +//| :returns: bit state read +//| :rtype: bool""" +//| ... //| 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); @@ -141,9 +143,9 @@ STATIC mp_obj_t bitbangio_onewire_obj_read_bit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_read_bit_obj, bitbangio_onewire_obj_read_bit); -//| .. method:: write_bit(value) -//| -//| Write out a bit based on value. +//| def write_bit(self, value: Any) -> Any: +//| """Write out a bit based on value.""" +//| ... //| 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); diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index b1a94c1841..38e0926e8d 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -39,26 +39,27 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: bitbangio +//| class SPI: +//| """.. currentmodule:: bitbangio //| -//| :class:`SPI` -- a 3-4 wire serial protocol -//| ----------------------------------------------- +//| :class:`SPI` -- a 3-4 wire serial protocol +//| ----------------------------------------------- //| -//| SPI is a serial protocol that has exclusive pins for data in and out of the -//| master. It is typically faster than :py:class:`~bitbangio.I2C` because a -//| separate pin is used to control the active slave rather than a transmitted -//| address. This class only manages three of the four SPI lines: `!clock`, -//| `!MOSI`, `!MISO`. Its up to the client to manage the appropriate slave -//| select line. (This is common because multiple slaves can share the `!clock`, -//| `!MOSI` and `!MISO` lines and therefore the hardware.) +//| SPI is a serial protocol that has exclusive pins for data in and out of the +//| master. It is typically faster than :py:class:`~bitbangio.I2C` because a +//| separate pin is used to control the active slave rather than a transmitted +//| address. This class only manages three of the four SPI lines: `!clock`, +//| `!MOSI`, `!MISO`. Its up to the client to manage the appropriate slave +//| select line. (This is common because multiple slaves can share the `!clock`, +//| `!MOSI` and `!MISO` lines and therefore the hardware.)""" //| -//| .. class:: SPI(clock, MOSI=None, MISO=None) +//| def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None): +//| """Construct an SPI object on the given pins. //| -//| Construct an SPI object on the given pins. -//| -//| :param ~microcontroller.Pin clock: the pin to use for the clock. -//| :param ~microcontroller.Pin MOSI: the Master Out Slave In pin. -//| :param ~microcontroller.Pin MISO: the Master In Slave Out pin. +//| :param ~microcontroller.Pin clock: the pin to use for the clock. +//| :param ~microcontroller.Pin MOSI: the Master Out Slave In pin. +//| :param ~microcontroller.Pin MISO: the Master In Slave Out pin.""" +//| ... //| // TODO(tannewt): Support LSB SPI. @@ -82,9 +83,9 @@ STATIC mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args, return (mp_obj_t)self; } -//| .. method:: deinit() -//| -//| Turn off the SPI bus. +//| def deinit(self, ) -> Any: +//| """Turn off the SPI bus.""" +//| ... //| STATIC mp_obj_t bitbangio_spi_obj_deinit(mp_obj_t self_in) { bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -99,16 +100,16 @@ STATIC void check_for_deinit(bitbangio_spi_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t bitbangio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -124,15 +125,15 @@ static void check_lock(bitbangio_spi_obj_t *self) { } } -//| .. method:: configure(*, baudrate=100000, polarity=0, phase=0, bits=8) +//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: +//| """Configures the SPI bus. Only valid when locked. //| -//| Configures the SPI bus. Only valid when locked. -//| -//| :param int baudrate: the clock rate in Hertz -//| :param int polarity: the base state of the clock line (0 or 1) -//| :param int phase: the edge of the clock that data is captured. First (0) -//| or second (1). Rising or falling depends on clock polarity. -//| :param int bits: the number of bits per word +//| :param int baudrate: the clock rate in Hertz +//| :param int polarity: the base state of the clock line (0 or 1) +//| :param int phase: the edge of the clock that data is captured. First (0) +//| or second (1). Rising or falling depends on clock polarity. +//| :param int bits: the number of bits per word""" +//| ... //| STATIC mp_obj_t bitbangio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits }; @@ -166,12 +167,12 @@ STATIC mp_obj_t bitbangio_spi_configure(size_t n_args, const mp_obj_t *pos_args, } MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_configure_obj, 1, bitbangio_spi_configure); -//| .. method:: try_lock() +//| def try_lock(self, ) -> Any: +//| """Attempts to grab the SPI lock. Returns True on success. //| -//| Attempts to grab the SPI lock. Returns True on success. -//| -//| :return: True when lock has been grabbed -//| :rtype: bool +//| :return: True when lock has been grabbed +//| :rtype: bool""" +//| ... //| 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); @@ -180,9 +181,9 @@ STATIC mp_obj_t bitbangio_spi_obj_try_lock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_try_lock_obj, bitbangio_spi_obj_try_lock); -//| .. method:: unlock() -//| -//| Releases the SPI lock. +//| def unlock(self, ) -> Any: +//| """Releases the SPI 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); @@ -192,10 +193,10 @@ STATIC mp_obj_t bitbangio_spi_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_unlock_obj, bitbangio_spi_obj_unlock); -//| .. method:: write(buf) -//| -//| Write the data contained in ``buf``. Requires the SPI being locked. -//| If the buffer is empty, nothing happens. +//| def write(self, buf: Any) -> Any: +//| """Write the data contained in ``buf``. Requires the SPI being locked. +//| If the buffer is empty, nothing happens.""" +//| ... //| // 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) { @@ -216,11 +217,11 @@ STATIC mp_obj_t bitbangio_spi_write(mp_obj_t self_in, mp_obj_t wr_buf) { MP_DEFINE_CONST_FUN_OBJ_2(bitbangio_spi_write_obj, bitbangio_spi_write); -//| .. method:: readinto(buf) -//| -//| Read into the buffer specified by ``buf`` while writing zeroes. -//| Requires the SPI being locked. -//| If the number of bytes to read is 0, nothing happens. +//| def readinto(self, buf: Any) -> Any: +//| """Read into the buffer specified by ``buf`` while writing zeroes. +//| Requires the SPI being locked. +//| If the number of bytes to read is 0, nothing happens.""" +//| ... //| // 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) { @@ -240,19 +241,19 @@ STATIC mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *args) { } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_spi_readinto_obj, 2, 2, bitbangio_spi_readinto); -//| .. method:: write_readinto(buffer_out, buffer_in, *, out_start=0, out_end=None, in_start=0, in_end=None) +//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any: +//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. +//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` +//| must be equal. +//| If buffer slice lengths are both 0, nothing happens. //| -//| Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. -//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` -//| must be equal. -//| If buffer slice lengths are both 0, nothing happens. -//| -//| :param bytearray buffer_out: Write out the data in this buffer -//| :param bytearray buffer_in: Read data into this buffer -//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` -//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` -//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` -//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)`` +//| :param bytearray buffer_out: Write out the data in this buffer +//| :param bytearray buffer_in: Read data into this buffer +//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` +//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` +//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` +//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" +//| ... //| STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; diff --git a/shared-bindings/bitbangio/__init__.c b/shared-bindings/bitbangio/__init__.c index 3123fb199a..e9600a7e66 100644 --- a/shared-bindings/bitbangio/__init__.c +++ b/shared-bindings/bitbangio/__init__.c @@ -40,7 +40,7 @@ #include "py/runtime.h" -//| :mod:`bitbangio` --- Digital protocols implemented by the CPU +//| """:mod:`bitbangio` --- Digital protocols implemented by the CPU //| ============================================================= //| //| .. module:: bitbangio @@ -81,7 +81,7 @@ //| This example will initialize the the device, run //| :py:meth:`~bitbangio.I2C.scan` and then :py:meth:`~bitbangio.I2C.deinit` the //| hardware. The last step is optional because CircuitPython automatically -//| resets hardware after a program finishes. +//| resets hardware after a program finishes.""" //| STATIC const mp_rom_map_elem_t bitbangio_module_globals_table[] = { From 602eabe668f9218e9e75d44e7153ae73b928a465 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 4 May 2020 17:18:53 -0400 Subject: [PATCH 036/216] Squeeze hallowing_m0_express build slightly ko build is a little too big. --- ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk index af4a5a2932..875d23f9b7 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk @@ -20,7 +20,7 @@ CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 -CFLAGS_INLINE_LIMIT = 60 +CFLAGS_INLINE_LIMIT = 55 SUPEROPT_GC = 0 # Include these Python libraries in firmware. From bfa5cd9c13e308df5462653a53fe99eeb0543bc3 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Tue, 5 May 2020 15:23:38 +1000 Subject: [PATCH 037/216] refactor countio based on feedback --- locale/ID.po | 7 +- locale/circuitpython.pot | 7 +- locale/de_DE.po | 7 +- locale/en_US.po | 7 +- locale/en_x_pirate.po | 7 +- locale/es.po | 7 +- locale/fil.po | 7 +- locale/fr.po | 7 +- locale/it_IT.po | 7 +- locale/ko.po | 7 +- locale/pl.po | 7 +- locale/pt_BR.po | 7 +- locale/zh_Latn_pinyin.po | 7 +- ports/atmel-samd/common-hal/countio/Counter.c | 83 ++++++++++ ports/atmel-samd/common-hal/countio/Counter.h | 19 +++ .../atmel-samd/common-hal/countio/__init__.c | 1 + ports/atmel-samd/eic_handler.c | 7 + ports/atmel-samd/eic_handler.h | 1 + ports/cxd56/mpconfigport.mk | 2 +- ports/litex/mpconfigport.mk | 2 +- ports/mimxrt10xx/mpconfigport.mk | 2 +- ports/nrf/mpconfigport.mk | 2 + ports/stm/mpconfigport.mk | 3 + py/circuitpy_defns.mk | 5 + py/circuitpy_mpconfig.h | 8 + py/circuitpy_mpconfig.mk | 11 ++ shared-bindings/countio/Counter.c | 152 ++++++++++++++++++ shared-bindings/countio/Counter.h | 18 +++ shared-bindings/countio/__init__.c | 48 ++++++ shared-bindings/countio/__init__.h | 9 ++ 30 files changed, 448 insertions(+), 16 deletions(-) create mode 100644 ports/atmel-samd/common-hal/countio/Counter.c create mode 100644 ports/atmel-samd/common-hal/countio/Counter.h create mode 100644 ports/atmel-samd/common-hal/countio/__init__.c create mode 100644 shared-bindings/countio/Counter.c create mode 100644 shared-bindings/countio/Counter.h create mode 100644 shared-bindings/countio/__init__.c create mode 100644 shared-bindings/countio/__init__.h diff --git a/locale/ID.po b/locale/ID.po index ac10df5bf8..e303c7ca56 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -245,6 +245,7 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "Sebuah channel hardware interrupt sedang digunakan" @@ -1209,6 +1210,10 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "Pin tidak mempunya kemampuan untuk ADC (Analog Digital Converter)" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 4b18bfd478..aa82bfe29c 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -244,6 +244,7 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "" @@ -1197,6 +1198,10 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 6cf4b7d479..f7ef9bfeb8 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -246,6 +246,7 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "3-arg pow() wird nicht unterstützt" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "Ein Hardware Interrupt Kanal wird schon benutzt" @@ -1212,6 +1213,10 @@ msgstr "Zugang verweigert" msgid "Pin does not have ADC capabilities" msgstr "Pin hat keine ADC Funktionalität" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index 428a9c4754..c72e6d0c98 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -244,6 +244,7 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "" @@ -1197,6 +1198,10 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index aacc176f5c..1c523bb61e 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -246,6 +246,7 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "Avast! A hardware interrupt channel be used already" @@ -1201,6 +1202,10 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "Belay that! Th' Pin be not ADC capable" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/es.po b/locale/es.po index db60c9d37a..fe5086a99a 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -246,6 +246,7 @@ msgstr "0.0 a una potencia compleja" msgid "3-arg pow() not supported" msgstr "pow() con 3 argumentos no soportado" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "El canal EXTINT ya está siendo utilizado" @@ -1211,6 +1212,10 @@ msgstr "Permiso denegado" msgid "Pin does not have ADC capabilities" msgstr "Pin no tiene capacidad ADC" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/fil.po b/locale/fil.po index 6d577823fa..f1178c8cad 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -247,6 +247,7 @@ msgstr "0.0 para sa complex power" msgid "3-arg pow() not supported" msgstr "3-arg pow() hindi suportado" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "Isang channel ng hardware interrupt ay ginagamit na" @@ -1217,6 +1218,10 @@ msgstr "Walang pahintulot" msgid "Pin does not have ADC capabilities" msgstr "Ang pin ay walang kakayahan sa ADC" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 4d07eda19b..ab12be1b6e 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -248,6 +248,7 @@ msgstr "0.0 à une puissance complexe" msgid "3-arg pow() not supported" msgstr "pow() non supporté avec 3 arguments" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "Un canal d'interruptions matérielles est déjà utilisé" @@ -1231,6 +1232,10 @@ msgstr "Permission refusée" msgid "Pin does not have ADC capabilities" msgstr "La broche ne peut être utilisée pour l'ADC" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 0c0825e5ec..826b378891 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -246,6 +246,7 @@ msgstr "0.0 elevato alla potenza di un numero complesso" msgid "3-arg pow() not supported" msgstr "pow() con tre argmomenti non supportata" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "Un canale di interrupt hardware è già in uso" @@ -1226,6 +1227,10 @@ msgstr "Permesso negato" msgid "Pin does not have ADC capabilities" msgstr "Il pin non ha capacità di ADC" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 3e3ac1cf60..f6bff27cec 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -246,6 +246,7 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "" @@ -1201,6 +1202,10 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 8cc3c30b7a..fa19bfc194 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -245,6 +245,7 @@ msgstr "0.0 do potęgi zespolonej" msgid "3-arg pow() not supported" msgstr "3-argumentowy pow() jest niewspierany" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "Kanał przerwań sprzętowych w użyciu" @@ -1202,6 +1203,10 @@ msgstr "Odmowa dostępu" msgid "Pin does not have ADC capabilities" msgstr "Nóżka nie obsługuje ADC" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index d833169c0f..bf56405c64 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -246,6 +246,7 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "Um canal de interrupção de hardware já está em uso" @@ -1212,6 +1213,10 @@ msgstr "Permissão negada" msgid "Pin does not have ADC capabilities" msgstr "O pino não tem recursos de ADC" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index e7d6df02fa..52337cdb43 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 14:57+1000\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -251,6 +251,7 @@ msgstr "0.0 dào fùzá diànyuán" msgid "3-arg pow() not supported" msgstr "bù zhīchí 3-arg pow ()" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "Yìngjiàn zhōngduàn tōngdào yǐ zài shǐyòng zhōng" @@ -1216,6 +1217,10 @@ msgstr "Quánxiàn bèi jùjué" msgid "Pin does not have ADC capabilities" msgstr "Pin méiyǒu ADC nénglì" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" diff --git a/ports/atmel-samd/common-hal/countio/Counter.c b/ports/atmel-samd/common-hal/countio/Counter.c new file mode 100644 index 0000000000..db5b325b8f --- /dev/null +++ b/ports/atmel-samd/common-hal/countio/Counter.c @@ -0,0 +1,83 @@ + +#include "common-hal/countio/Counter.h" + +#include "atmel_start_pins.h" + +#include "eic_handler.h" +#include "samd/external_interrupts.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + +void common_hal_countio_counter_construct(countio_counter_obj_t* self, + const mcu_pin_obj_t* pin_a) { + if (!pin_a->has_extint) { + mp_raise_RuntimeError(translate("Pin must support hardware interrupts")); + } + + + if (eic_get_enable()) { + if (!eic_channel_free(pin_a->extint_channel)) { + mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); + } + } else { + turn_on_external_interrupt_controller(); + } + + // These default settings apply when the EIC isn't yet enabled. + self->eic_channel_a = pin_a->extint_channel; + + self->pin_a = pin_a->number; + + gpio_set_pin_function(self->pin_a, GPIO_PIN_FUNCTION_A); + gpio_set_pin_pull_mode(self->pin_a, GPIO_PULL_UP); + + set_eic_channel_data(self->eic_channel_a, (void*) self); + + self->count = 0; + + + claim_pin(pin_a); + + + set_eic_handler(self->eic_channel_a, EIC_HANDLER_COUNTER); + turn_on_eic_channel(self->eic_channel_a, EIC_CONFIG_SENSE0_FALL_Val); + +} + +bool common_hal_countio_counter_deinited(countio_counter_obj_t* self) { + return self->pin_a == NO_PIN; +} + +void common_hal_countio_counter_deinit(countio_counter_obj_t* self) { + if (common_hal_countio_counter_deinited(self)) { + return; + } + + set_eic_handler(self->eic_channel_a, EIC_HANDLER_NO_INTERRUPT); + turn_off_eic_channel(self->eic_channel_a); + + + reset_pin_number(self->pin_a); + self->pin_a = NO_PIN; + +} + +mp_int_t common_hal_countio_counter_get_count(countio_counter_obj_t* self) { + return self->count; +} + +void common_hal_countio_counter_set_count(countio_counter_obj_t* self, + mp_int_t new_count) { + self->count = new_count; +} + +void common_hal_countio_counter_reset(countio_counter_obj_t* self){ + self->count = 0; +} + +void counter_interrupt_handler(uint8_t channel) { + countio_counter_obj_t* self = get_eic_channel_data(channel); + + self->count += 1; + +} diff --git a/ports/atmel-samd/common-hal/countio/Counter.h b/ports/atmel-samd/common-hal/countio/Counter.h new file mode 100644 index 0000000000..724c734152 --- /dev/null +++ b/ports/atmel-samd/common-hal/countio/Counter.h @@ -0,0 +1,19 @@ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_COUNTIO_COUNTER_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_COUNTIO_COUNTER_H + +#include "common-hal/microcontroller/Pin.h" + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + uint8_t pin_a; + uint8_t eic_channel_a:4; + mp_int_t count; +} countio_counter_obj_t; + + +void counter_interrupt_handler(uint8_t channel); + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_COUNTIO_COUNT_H diff --git a/ports/atmel-samd/common-hal/countio/__init__.c b/ports/atmel-samd/common-hal/countio/__init__.c new file mode 100644 index 0000000000..b95b20d153 --- /dev/null +++ b/ports/atmel-samd/common-hal/countio/__init__.c @@ -0,0 +1 @@ +//No countio module functions diff --git a/ports/atmel-samd/eic_handler.c b/ports/atmel-samd/eic_handler.c index 30ecaa7cae..7f26bdefbf 100644 --- a/ports/atmel-samd/eic_handler.c +++ b/ports/atmel-samd/eic_handler.c @@ -27,6 +27,7 @@ #include "common-hal/pulseio/PulseIn.h" #include "common-hal/ps2io/Ps2.h" #include "common-hal/rotaryio/IncrementalEncoder.h" +#include "common-hal/countio/Counter.h" #include "shared-bindings/microcontroller/__init__.h" //#include "samd/external_interrupts.h" #include "eic_handler.h" @@ -59,6 +60,12 @@ void shared_eic_handler(uint8_t channel) { break; #endif +#if CIRCUITPY_COUNTIO + case EIC_HANDLER_COUNTER: + counter_interrupt_handler(channel); + break; +#endif + default: break; } diff --git a/ports/atmel-samd/eic_handler.h b/ports/atmel-samd/eic_handler.h index 71b0fce678..08da7ea34d 100644 --- a/ports/atmel-samd/eic_handler.h +++ b/ports/atmel-samd/eic_handler.h @@ -30,6 +30,7 @@ #define EIC_HANDLER_PULSEIN 0x1 #define EIC_HANDLER_INCREMENTAL_ENCODER 0x2 #define EIC_HANDLER_PS2 0x3 +#define EIC_HANDLER_COUNTER 0x04 void set_eic_handler(uint8_t channel, uint8_t eic_handler); void shared_eic_handler(uint8_t channel); diff --git a/ports/cxd56/mpconfigport.mk b/ports/cxd56/mpconfigport.mk index ad3d0e72df..8aeae1de56 100644 --- a/ports/cxd56/mpconfigport.mk +++ b/ports/cxd56/mpconfigport.mk @@ -18,5 +18,5 @@ CIRCUITPY_NEOPIXEL_WRITE = 0 CIRCUITPY_NVM = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FREQUENCYIO = 0 - +CIRCUITPY_COUNTIO = 0 INTERNAL_LIBM = 1 diff --git a/ports/litex/mpconfigport.mk b/ports/litex/mpconfigport.mk index 0a82f41619..004930ba70 100644 --- a/ports/litex/mpconfigport.mk +++ b/ports/litex/mpconfigport.mk @@ -25,7 +25,7 @@ CIRCUITPY_NVM = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 - +CIRCUITPY_COUNTIO = 0 # Enable USB support CIRCUITPY_USB_HID = 1 CIRCUITPY_USB_MIDI = 1 diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index 5881ac3020..e9e554142c 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -26,5 +26,5 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_NVM = 0 CIRCUITPY_ROTARYIO = 0 - +CIRCUITPY_COUNTIO = 0 LONGINT_IMPL = MPZ diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 410d3750e5..7939a175bd 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -54,6 +54,8 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_RGBMATRIX ?= 1 CIRCUITPY_FRAMEBUFFERIO ?= 1 +CIRCUITPY_COUNTIO = 0 + # nRF52840-specific ifeq ($(MCU_CHIP),nrf52840) diff --git a/ports/stm/mpconfigport.mk b/ports/stm/mpconfigport.mk index 5ef1e8e7b7..ee8b2e1601 100644 --- a/ports/stm/mpconfigport.mk +++ b/ports/stm/mpconfigport.mk @@ -8,6 +8,7 @@ ifeq ($(MCU_SERIES),F4) CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_ROTARYIO = 0 + CIRCUITPY_COUNTIO = 0 CIRCUITPY_RTC = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 @@ -26,6 +27,7 @@ ifeq ($(MCU_SERIES),H7) CIRCUITPY_NVM = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOIO = 0 + CIRCUITPY_COUNTIO = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 CIRCUITPY_FREQUENCYIO = 0 @@ -46,6 +48,7 @@ ifeq ($(MCU_SERIES),F7) CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_ROTARYIO = 0 + CIRCUITPY_COUNTIO = 0 CIRCUITPY_RTC = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index ec8e6c3e98..a253f2fa82 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -136,6 +136,9 @@ endif ifeq ($(CIRCUITPY_BUSIO),1) SRC_PATTERNS += busio/% bitbangio/OneWire.% endif +ifeq ($(CIRCUITPY_COUNTIO),1) +SRC_PATTERNS += countio/% +endif ifeq ($(CIRCUITPY_DIGITALIO),1) SRC_PATTERNS += digitalio/% endif @@ -263,6 +266,8 @@ SRC_COMMON_HAL_ALL = \ busio/SPI.c \ busio/UART.c \ busio/__init__.c \ + countio/Counter.c \ + countio/__init__.c \ digitalio/DigitalInOut.c \ digitalio/__init__.c \ displayio/ParallelBus.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 29a4d524ca..a3ab4da941 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -314,6 +314,13 @@ extern const struct _mp_obj_module_t busio_module; #define BUSIO_MODULE #endif +#if CIRCUITPY_COUNTIO +extern const struct _mp_obj_module_t countio_module; +#define COUNTIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_countio), (mp_obj_t)&countio_module }, +#else +#define COUNTIO_MODULE +#endif + #if CIRCUITPY_DIGITALIO extern const struct _mp_obj_module_t digitalio_module; #define DIGITALIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module }, @@ -630,6 +637,7 @@ extern const struct _mp_obj_module_t ustack_module; BLEIO_MODULE \ BOARD_MODULE \ BUSIO_MODULE \ + COUNTIO_MODULE \ DIGITALIO_MODULE \ DISPLAYIO_MODULE \ FONTIO_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 30ab720d70..7ef87a7ea2 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -109,6 +109,12 @@ CIRCUITPY_DIGITALIO = 1 endif CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) +ifndef CIRCUITPY_COUNTIO +CIRCUITPY_COUNTIO = 1 +endif +CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) + + ifndef CIRCUITPY_DISPLAYIO CIRCUITPY_DISPLAYIO = $(CIRCUITPY_FULL_BUILD) endif @@ -207,6 +213,11 @@ CIRCUITPY_ROTARYIO = 1 endif CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO) +ifndef CIRCUITPY_COUNTIO +CIRCUITPY_COUNTIO = 1 +endif +CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) + ifndef CIRCUITPY_RTC CIRCUITPY_RTC = 1 endif diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c new file mode 100644 index 0000000000..c10294199a --- /dev/null +++ b/shared-bindings/countio/Counter.c @@ -0,0 +1,152 @@ + +#include + +#include "lib/utils/context_manager_helpers.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "py/runtime0.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/countio/Counter.h" +#include "shared-bindings/util.h" + +//| .. currentmodule:: countio +//| +//| :class:`Counter` -- Track the count of edge transistions (pulses) on a given pin +//| ==================================================================================== +//| +//| Counter will keep track of the number of edge transistions (pulses) on a given pin +//| +//| .. class:: Counter(pin_a) +//| +//| Create an Counter object associated with the given pin. It tracks the number of +//| pulses relative when the object is contructed. +//| +//| :param ~microcontroller.Pin pin_a: Pin to read pulses from. +//| +//| +//| For example:: +//| +//| import countio +//| import time +//| from board import * +//| +//| pin_counter = countio.Counter(board.D1) +//| +//| while True: +//| count = pin_counter.count +//| if count == None 10: +//| pin_counter.reset() +//| print(pin_counter.count) +//| +STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_pin_a }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_pin_a, MP_ARG_REQUIRED | MP_ARG_OBJ } + + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + const mcu_pin_obj_t* pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj); + + + countio_counter_obj_t *self = m_new_obj(countio_counter_obj_t); + self->base.type = &countio_counter_type; + + common_hal_countio_counter_construct(self, pin_a); + + return MP_OBJ_FROM_PTR(self); +} + +//| .. method:: deinit() +//| +//| Deinitializes the Counter and releases any hardware resources for reuse. +//| +STATIC mp_obj_t countio_counter_deinit(mp_obj_t self_in) { + countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_countio_counter_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_deinit_obj, countio_counter_deinit); + +STATIC void check_for_deinit(countio_counter_obj_t *self) { + if (common_hal_countio_counter_deinited(self)) { + raise_deinited_error(); + } +} + +//| .. method:: __enter__() +//| +//| No-op used by Context Managers. +//| +// Provided by context manager helper. + +//| .. method:: __exit__() +//| +//| Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info. +//| +STATIC mp_obj_t countio_counter_obj___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + common_hal_countio_counter_deinit(args[0]); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(countio_counter___exit___obj, 4, 4, countio_counter_obj___exit__); + + +//| .. attribute:: count +//| +//| The current count in terms of pulses. +//| +//| +STATIC mp_obj_t countio_counter_obj_get_count(mp_obj_t self_in) { + countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + + return mp_obj_new_int(common_hal_countio_counter_get_count(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_get_count_obj, countio_counter_obj_get_count); + +STATIC mp_obj_t countio_counter_obj_set_count(mp_obj_t self_in, mp_obj_t new_count) { + countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + + common_hal_countio_counter_set_count(self, mp_obj_get_int(new_count)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(countio_counter_set_count_obj, countio_counter_obj_set_count); + +const mp_obj_property_t countio_counter_count_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&countio_counter_get_count_obj, + (mp_obj_t)&countio_counter_set_count_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in){ + countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + //set the position to zero for reset + common_hal_countio_counter_reset(self); + return mp_const_none; +} + + +MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_reset_obj, countio_counter_reset); + +STATIC const mp_rom_map_elem_t countio_counter_locals_dict_table[] = { + // Methods + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&countio_counter_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&countio_counter___exit___obj) }, + { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&countio_counter_count_obj) }, + { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&countio_counter_reset_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(countio_counter_locals_dict, countio_counter_locals_dict_table); + +const mp_obj_type_t countio_counter_type = { + { &mp_type_type }, + .name = MP_QSTR_Counter, + .make_new = countio_counter_make_new, + .locals_dict = (mp_obj_dict_t*)&countio_counter_locals_dict, +}; diff --git a/shared-bindings/countio/Counter.h b/shared-bindings/countio/Counter.h new file mode 100644 index 0000000000..15adbbe2ac --- /dev/null +++ b/shared-bindings/countio/Counter.h @@ -0,0 +1,18 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_COUNTER_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_COUNTER_H + +#include "common-hal/microcontroller/Pin.h" +#include "common-hal/countio/Counter.h" + +extern const mp_obj_type_t countio_counter_type; + +extern void common_hal_countio_counter_construct(countio_counter_obj_t* self, + const mcu_pin_obj_t* pin_a); +extern void common_hal_countio_counter_deinit(countio_counter_obj_t* self); +extern bool common_hal_countio_counter_deinited(countio_counter_obj_t* self); +extern mp_int_t common_hal_countio_counter_get_count(countio_counter_obj_t* self); +extern void common_hal_countio_counter_set_count(countio_counter_obj_t* self, + mp_int_t new_count); +extern void common_hal_countio_counter_reset(countio_counter_obj_t* self); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_COUNTER_H diff --git a/shared-bindings/countio/__init__.c b/shared-bindings/countio/__init__.c new file mode 100644 index 0000000000..8929bf7edb --- /dev/null +++ b/shared-bindings/countio/__init__.c @@ -0,0 +1,48 @@ + +#include + +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/countio/__init__.h" +#include "shared-bindings/countio/Counter.h" + +//| :mod:`countio` --- Support for edge counting +//| ======================================================== +//| +//| .. module:: countio +//| :synopsis: Support for edge counting +//| :platform: SAMD +//| +//| The `countio` module contains logic to read and count edge transistions +//| +//| Libraries +//| +//| .. toctree:: +//| :maxdepth: 3 +//| +//| Counter +//| + +//| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the +//| :ref:`module-support-matrix` for more info. +//| + +//| All classes change hardware state and should be deinitialized when they +//| are no longer needed if the program continues after use. To do so, either +//| call :py:meth:`!deinit` or use a context manager. See +//| :ref:`lifetime-and-contextmanagers` for more info. +//| + +STATIC const mp_rom_map_elem_t countio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_countio) }, + { MP_ROM_QSTR(MP_QSTR_Counter), MP_ROM_PTR(&countio_counter_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(countio_module_globals, countio_module_globals_table); + +const mp_obj_module_t countio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&countio_module_globals, +}; diff --git a/shared-bindings/countio/__init__.h b/shared-bindings/countio/__init__.h new file mode 100644 index 0000000000..35ae9f0354 --- /dev/null +++ b/shared-bindings/countio/__init__.h @@ -0,0 +1,9 @@ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO___INIT___H + +#include "py/obj.h" + +// Nothing now. + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO___INIT___H From 0ecc5155441e79e9b82cff8e2ff8eff6ff74c91e Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Tue, 5 May 2020 15:46:58 +1000 Subject: [PATCH 038/216] added missing translation --- locale/circuitpython.pot | 2 +- locale/sv.po | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index aa82bfe29c..5f5b5b7c52 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-05 14:57+1000\n" +"POT-Creation-Date: 2020-05-05 15:46+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/sv.po b/locale/sv.po index f993e52d32..6cefc8a03d 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-27 18:34-0700\n" +"POT-Creation-Date: 2020-05-05 15:46+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -244,6 +244,7 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" msgstr "" @@ -1197,6 +1198,10 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" msgstr "" From d5c24b99b8860adc33ac95e3001b2bc53ce6055f Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Tue, 5 May 2020 16:04:28 +1000 Subject: [PATCH 039/216] hallowing m0 - exclude countio --- ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk index af4a5a2932..5469f13388 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk @@ -19,7 +19,7 @@ CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 - +CIRCUITPY_COUNTIO = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 From f63ee9fb9b8c6f2e7f72bbaeede0315c545d4332 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Tue, 5 May 2020 16:15:57 +1000 Subject: [PATCH 040/216] excluded countio from other smaller boards --- ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk index c1dbf514d7..9309fdce0d 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk @@ -23,6 +23,7 @@ CIRCUITPY_TOUCHIO_USE_NATIVE=0 CIRCUITPY_TOUCHIO=0 CIRCUITPY_USB_MIDI=0 CIRCUITPY_RTC=0 +CIRCUITPY_COUNTIO=0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice From 7f1be814c89e4ecbaf6c396561ce2d01d9e7a049 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Wed, 6 May 2020 09:04:15 +1000 Subject: [PATCH 041/216] changed build variables as per advice --- ports/atmel-samd/boards/pyruler/mpconfigboard.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk index b799406732..475d8b6342 100644 --- a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk @@ -9,10 +9,10 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - +CIRCUITPY_COUNTIO = 0 SUPEROPT_GC = 0 CFLAGS_BOARD = --param max-inline-insns-auto=15 ifeq ($(TRANSLATION), zh_Latn_pinyin) CFLAGS_INLINE_LIMIT = 35 -endif \ No newline at end of file +endif From 8961dd9fe74a3ba6e55bfb1b8132a93de920a1dc Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Wed, 6 May 2020 09:05:14 +1000 Subject: [PATCH 042/216] changed build variables as per advice --- py/circuitpy_mpconfig.mk | 4 ++-- shared-bindings/countio/Counter.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 7ef87a7ea2..be1e0ad9af 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -110,7 +110,7 @@ endif CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO = 1 +CIRCUITPY_COUNTIO ?= 1 endif CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) @@ -214,7 +214,7 @@ endif CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO) ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO = 1 +CIRCUITPY_COUNTIO = $(CIRCUITPY_FULL_BUILD) endif CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index c10294199a..efa3387a6f 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -31,10 +31,9 @@ //| from board import * //| //| pin_counter = countio.Counter(board.D1) -//| +//| #reset the count after 100 counts //| while True: -//| count = pin_counter.count -//| if count == None 10: +//| if pin_counter.count == 100: //| pin_counter.reset() //| print(pin_counter.count) //| From 84c806a4bebb72b8deaae8cb5cada9d5ab7aa41b Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Thu, 7 May 2020 12:42:46 +1000 Subject: [PATCH 043/216] updated descriptions and build variable --- py/circuitpy_mpconfig.mk | 2 +- shared-bindings/countio/Counter.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index be1e0ad9af..95e3512f10 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -110,7 +110,7 @@ endif CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO ?= 1 +CIRCUITPY_COUNTIO = 1 endif CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index efa3387a6f..1777acc8a2 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -11,15 +11,15 @@ //| .. currentmodule:: countio //| -//| :class:`Counter` -- Track the count of edge transistions (pulses) on a given pin +//| :class:`Counter` -- Track the count of falling edge transistions (pulses) on a given pin //| ==================================================================================== //| -//| Counter will keep track of the number of edge transistions (pulses) on a given pin +//| Counter will keep track of the number of falling edge transistions (pulses) on a given pin //| //| .. class:: Counter(pin_a) //| //| Create an Counter object associated with the given pin. It tracks the number of -//| pulses relative when the object is contructed. +//| falling pulses relative when the object is constructed. //| //| :param ~microcontroller.Pin pin_a: Pin to read pulses from. //| From 2ebe3035dff0ce66b2fe65eb91d6889c4ba93b5c Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 7 May 2020 10:54:09 -0400 Subject: [PATCH 044/216] Did board, digitalio, displayio --- shared-bindings/board/__init__.c | 33 ++-- shared-bindings/digitalio/DigitalInOut.c | 109 ++++++------ shared-bindings/digitalio/Direction.c | 25 ++- shared-bindings/digitalio/DriveMode.c | 27 ++- shared-bindings/digitalio/Pull.c | 29 ++- shared-bindings/digitalio/__init__.c | 4 +- shared-bindings/displayio/Bitmap.c | 65 ++++--- shared-bindings/displayio/ColorConverter.c | 31 ++-- shared-bindings/displayio/Display.c | 196 ++++++++++----------- shared-bindings/displayio/EPaperDisplay.c | 128 +++++++------- shared-bindings/displayio/FourWire.c | 57 +++--- shared-bindings/displayio/Group.c | 115 ++++++------ shared-bindings/displayio/I2CDisplay.c | 47 ++--- shared-bindings/displayio/OnDiskBitmap.c | 79 ++++----- shared-bindings/displayio/Palette.c | 58 +++--- shared-bindings/displayio/ParallelBus.c | 58 +++--- shared-bindings/displayio/Shape.c | 31 ++-- shared-bindings/displayio/TileGrid.c | 107 ++++++----- shared-bindings/displayio/__init__.c | 18 +- 19 files changed, 600 insertions(+), 617 deletions(-) diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index 3dda59fb8e..501879be80 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -29,7 +29,7 @@ #include "shared-bindings/board/__init__.h" -//| :mod:`board` --- Board specific pin names +//| """:mod:`board` --- Board specific pin names //| ======================================================== //| //| .. module:: board @@ -39,11 +39,11 @@ //| board so don't expect portability when using this module. //| //| .. warning:: The board module varies by board. The APIs documented here may or may not be -//| available on a specific board. +//| available on a specific board.""" -//| .. function:: I2C() -//| -//| Returns the `busio.I2C` object for the board designated SDA and SCL pins. It is a singleton. +//| def I2C() -> Any: +//| """Returns the `busio.I2C` object for the board designated SDA and SCL pins. It is a singleton.""" +//| ... //| #if BOARD_I2C @@ -65,10 +65,10 @@ mp_obj_t board_i2c(void) { MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c); -//| .. function:: SPI() -//| -//| Returns the `busio.SPI` object for the board designated SCK, MOSI and MISO pins. It is a -//| singleton. +//| def SPI() -> Any: +//| """Returns the `busio.SPI` object for the board designated SCK, MOSI and MISO pins. It is a +//| singleton.""" +//| ... //| #if BOARD_SPI mp_obj_t board_spi(void) { @@ -89,15 +89,14 @@ mp_obj_t board_spi(void) { #endif MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi); -//| .. function:: UART() -//| -//| Returns the `busio.UART` object for the board designated TX and RX pins. It is a singleton. -//| -//| The object created uses the default parameter values for `busio.UART`. If you need to set -//| parameters that are not changeable after creation, such as ``receiver_buffer_size``, -//| do not use `board.UART()`; instead create a `busio.UART` object explicitly with the -//| desired parameters. +//| def UART() -> Any: +//| """Returns the `busio.UART` object for the board designated TX and RX pins. It is a singleton. //| +//| The object created uses the default parameter values for `busio.UART`. If you need to set +//| parameters that are not changeable after creation, such as ``receiver_buffer_size``, +//| do not use `board.UART()`; instead create a `busio.UART` object explicitly with the +//| desired parameters.""" +//| ... //| #if BOARD_UART mp_obj_t board_uart(void) { diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 39da00cf71..5fffb3f653 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -43,23 +43,23 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: digitalio +//| class DigitalInOut: +//| """.. currentmodule:: digitalio //| -//| :class:`DigitalInOut` -- digital input and output -//| ========================================================= +//| :class:`DigitalInOut` -- digital input and output +//| ========================================================= //| -//| A DigitalInOut is used to digitally control I/O pins. For analog control of -//| a pin, see the :py:class:`analogio.AnalogIn` and -//| :py:class:`analogio.AnalogOut` classes. +//| A DigitalInOut is used to digitally control I/O pins. For analog control of +//| a pin, see the :py:class:`analogio.AnalogIn` and +//| :py:class:`analogio.AnalogOut` classes.""" //| - -//| .. class:: DigitalInOut(pin) +//| def __init__(self, pin: microcontroller.Pin): +//| """Create a new DigitalInOut object associated with the pin. Defaults to input +//| with no pull. Use :py:meth:`switch_to_input` and +//| :py:meth:`switch_to_output` to change the direction. //| -//| Create a new DigitalInOut object associated with the pin. Defaults to input -//| with no pull. Use :py:meth:`switch_to_input` and -//| :py:meth:`switch_to_output` to change the direction. -//| -//| :param ~microcontroller.Pin pin: The pin to control +//| :param ~microcontroller.Pin pin: The pin to control""" +//| ... //| STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { @@ -74,9 +74,9 @@ STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type, return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Turn off the DigitalInOut and release the pin for other use. +//| def deinit(self, ) -> Any: +//| """Turn off the DigitalInOut and release the pin for other use.""" +//| ... //| STATIC mp_obj_t digitalio_digitalinout_obj_deinit(mp_obj_t self_in) { digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -85,16 +85,16 @@ STATIC mp_obj_t digitalio_digitalinout_obj_deinit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_deinit_obj, digitalio_digitalinout_obj_deinit); -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t digitalio_digitalinout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -109,14 +109,13 @@ STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) { } } +//| def switch_to_output(self, value: bool = False, drive_mode: digitalio.DriveMode = digitalio.DriveMode.PUSH_PULL) -> Any: +//| """Set the drive mode and value and then switch to writing out digital +//| values. //| -//| .. method:: switch_to_output(value=False, drive_mode=digitalio.DriveMode.PUSH_PULL) -//| -//| Set the drive mode and value and then switch to writing out digital -//| values. -//| -//| :param bool value: default value to set upon switching -//| :param ~digitalio.DriveMode drive_mode: drive mode for the output +//| :param bool value: default value to set upon switching +//| :param ~digitalio.DriveMode drive_mode: drive mode for the output""" +//| ... //| STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_value, ARG_drive_mode }; @@ -139,22 +138,22 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_ } MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_output_obj, 1, digitalio_digitalinout_switch_to_output); -//| .. method:: switch_to_input(pull=None) +//| def switch_to_input(self, pull: Pull = None) -> Any: +//| """Set the pull and then switch to read in digital values. //| -//| Set the pull and then switch to read in digital values. +//| :param Pull pull: pull configuration for the input //| -//| :param Pull pull: pull configuration for the input +//| Example usage:: //| -//| Example usage:: +//| import digitalio +//| import board //| -//| import digitalio -//| import board -//| -//| switch = digitalio.DigitalInOut(board.SLIDE_SWITCH) -//| switch.switch_to_input(pull=digitalio.Pull.UP) -//| # Or, after switch_to_input -//| switch.pull = digitalio.Pull.UP -//| print(switch.value) +//| switch = digitalio.DigitalInOut(board.SLIDE_SWITCH) +//| switch.switch_to_input(pull=digitalio.Pull.UP) +//| # Or, after switch_to_input +//| switch.pull = digitalio.Pull.UP +//| print(switch.value)""" +//| ... //| STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pull }; @@ -178,14 +177,13 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o } MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_input_obj, 1, digitalio_digitalinout_switch_to_input); -//| .. attribute:: direction -//| -//| The direction of the pin. +//| direction: Any = ... +//| """The direction of the pin. //| //| Setting this will use the defaults from the corresponding //| :py:meth:`switch_to_input` or :py:meth:`switch_to_output` method. If //| you want to set pull, value or drive mode prior to switching, then use -//| those methods instead. +//| those methods instead.""" //| typedef struct { mp_obj_base_t base; @@ -225,9 +223,8 @@ const mp_obj_property_t digitalio_digitalio_direction_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: value -//| -//| The digital logic level of the pin. +//| value: Any = ... +//| """The digital logic level of the pin.""" //| 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); @@ -256,12 +253,11 @@ const mp_obj_property_t digitalio_digitalinout_value_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: drive_mode -//| -//| The pin drive mode. One of: +//| drive_mode: Any = ... +//| """The pin drive mode. One of: //| //| - `digitalio.DriveMode.PUSH_PULL` -//| - `digitalio.DriveMode.OPEN_DRAIN` +//| - `digitalio.DriveMode.OPEN_DRAIN`""" //| 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); @@ -301,15 +297,14 @@ const mp_obj_property_t digitalio_digitalio_drive_mode_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: pull -//| -//| The pin pull direction. One of: +//| pull: Any = ... +//| """The pin pull direction. One of: //| //| - `digitalio.Pull.UP` //| - `digitalio.Pull.DOWN` //| - `None` //| -//| :raises AttributeError: if `direction` is :py:data:`~digitalio.Direction.OUTPUT`. +//| :raises AttributeError: if `direction` is :py:data:`~digitalio.Direction.OUTPUT`.""" //| 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); diff --git a/shared-bindings/digitalio/Direction.c b/shared-bindings/digitalio/Direction.c index c8188fc899..0586e95def 100644 --- a/shared-bindings/digitalio/Direction.c +++ b/shared-bindings/digitalio/Direction.c @@ -38,23 +38,22 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" -//| .. currentmodule:: digitalio +//| class Direction: +//| """.. currentmodule:: digitalio //| -//| :class:`Direction` -- defines the direction of a digital pin -//| ============================================================= +//| :class:`Direction` -- defines the direction of a digital pin +//| =============================================================""" //| -//| .. class:: Direction +//| def __init__(self, ): +//| """Enum-like class to define which direction the digital values are +//| going.""" +//| ... //| -//| Enum-like class to define which direction the digital values are -//| going. +//| INPUT: Any = ... +//| """Read digital data in""" //| -//| .. data:: INPUT -//| -//| Read digital data in -//| -//| .. data:: OUTPUT -//| -//| Write digital data out +//| OUTPUT: Any = ... +//| """Write digital data out""" //| const mp_obj_type_t digitalio_direction_type; diff --git a/shared-bindings/digitalio/DriveMode.c b/shared-bindings/digitalio/DriveMode.c index 51e1e2ee50..23745b0469 100644 --- a/shared-bindings/digitalio/DriveMode.c +++ b/shared-bindings/digitalio/DriveMode.c @@ -26,24 +26,23 @@ #include "shared-bindings/digitalio/DriveMode.h" -//| .. currentmodule:: digitalio +//| class DriveMode: +//| """.. currentmodule:: digitalio //| -//| :class:`DriveMode` -- defines the drive mode of a digital pin -//| ============================================================= +//| :class:`DriveMode` -- defines the drive mode of a digital pin +//| =============================================================""" //| -//| .. class:: DriveMode +//| def __init__(self, ): +//| """Enum-like class to define the drive mode used when outputting +//| digital values.""" +//| ... //| -//| Enum-like class to define the drive mode used when outputting -//| digital values. +//| PUSH_PULL: Any = ... +//| """Output both high and low digital values""" //| -//| .. data:: PUSH_PULL -//| -//| Output both high and low digital values -//| -//| .. data:: OPEN_DRAIN -//| -//| Output low digital values but go into high z for digital high. This is -//| useful for i2c and other protocols that share a digital line. +//| OPEN_DRAIN: Any = ... +//| """Output low digital values but go into high z for digital high. This is +//| useful for i2c and other protocols that share a digital line.""" //| const mp_obj_type_t digitalio_drive_mode_type; diff --git a/shared-bindings/digitalio/Pull.c b/shared-bindings/digitalio/Pull.c index 813268db78..1e64d07887 100644 --- a/shared-bindings/digitalio/Pull.c +++ b/shared-bindings/digitalio/Pull.c @@ -26,25 +26,24 @@ #include "shared-bindings/digitalio/Pull.h" -//| .. currentmodule:: digitalio +//| class Pull: +//| """.. currentmodule:: digitalio //| -//| :class:`Pull` -- defines the pull of a digital input pin -//| ============================================================= +//| :class:`Pull` -- defines the pull of a digital input pin +//| =============================================================""" //| -//| .. class:: Pull +//| def __init__(self, ): +//| """Enum-like class to define the pull value, if any, used while reading +//| digital values in.""" +//| ... //| -//| Enum-like class to define the pull value, if any, used while reading -//| digital values in. +//| UP: Any = ... +//| """When the input line isn't being driven the pull up can pull the state +//| of the line high so it reads as true.""" //| -//| .. data:: UP -//| -//| When the input line isn't being driven the pull up can pull the state -//| of the line high so it reads as true. -//| -//| .. data:: DOWN -//| -//| When the input line isn't being driven the pull down can pull the -//| state of the line low so it reads as false. +//| DOWN: Any = ... +//| """When the input line isn't being driven the pull down can pull the +//| state of the line low so it reads as false.""" //| const mp_obj_type_t digitalio_pull_type; diff --git a/shared-bindings/digitalio/__init__.c b/shared-bindings/digitalio/__init__.c index 1632262d2a..5a11436a23 100644 --- a/shared-bindings/digitalio/__init__.c +++ b/shared-bindings/digitalio/__init__.c @@ -38,7 +38,7 @@ #include "py/runtime.h" -//| :mod:`digitalio` --- Basic digital pin support +//| """:mod:`digitalio` --- Basic digital pin support //| ================================================= //| //| .. module:: digitalio @@ -86,7 +86,7 @@ //| led.value = True //| time.sleep(0.1) //| led.value = False -//| time.sleep(0.1) +//| time.sleep(0.1)""" //| STATIC const mp_rom_map_elem_t digitalio_module_globals_table[] = { diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 391f3e5955..d15c3b1078 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -36,22 +36,23 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class Bitmap: +//| """.. currentmodule:: displayio //| -//| :class:`Bitmap` -- Stores values in a 2D array -//| ========================================================================== +//| :class:`Bitmap` -- Stores values in a 2D array +//| ========================================================================== //| -//| Stores values of a certain size in a 2D array +//| Stores values of a certain size in a 2D array""" //| -//| .. class:: Bitmap(width, height, value_count) +//| def __init__(self, width: int, height: int, value_count: int): +//| """Create a Bitmap object with the given fixed size. Each pixel stores a value that is used to +//| index into a corresponding palette. This enables differently colored sprites to share the +//| underlying Bitmap. value_count is used to minimize the memory used to store the Bitmap. //| -//| Create a Bitmap object with the given fixed size. Each pixel stores a value that is used to -//| index into a corresponding palette. This enables differently colored sprites to share the -//| underlying Bitmap. value_count is used to minimize the memory used to store the Bitmap. -//| -//| :param int width: The number of values wide -//| :param int height: The number of values high -//| :param int value_count: The number of possible pixel values. +//| :param int width: The number of values wide +//| :param int height: The number of values high +//| :param int value_count: The number of possible pixel values.""" +//| ... //| STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 3, 3, false); @@ -77,9 +78,8 @@ STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| .. attribute:: width -//| -//| Width of the bitmap. (read only) +//| width: Any = ... +//| """Width of the bitmap. (read only)""" //| STATIC mp_obj_t displayio_bitmap_obj_get_width(mp_obj_t self_in) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); @@ -96,9 +96,8 @@ const mp_obj_property_t displayio_bitmap_width_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: height -//| -//| Height of the bitmap. (read only) +//| height: Any = ... +//| """Height of the bitmap. (read only)""" //| STATIC mp_obj_t displayio_bitmap_obj_get_height(mp_obj_t self_in) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); @@ -115,23 +114,23 @@ const mp_obj_property_t displayio_bitmap_height_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: __getitem__(index) +//| def __getitem__(self, index: Any) -> Any: +//| """Returns the value at the given index. The index can either be an x,y tuple or an int equal +//| to ``y * width + x``. //| -//| Returns the value at the given index. The index can either be an x,y tuple or an int equal -//| to ``y * width + x``. +//| This allows you to:: //| -//| This allows you to:: +//| print(bitmap[0,1])""" +//| ... //| -//| print(bitmap[0,1]) +//| def __setitem__(self, index: Any, value: Any) -> Any: +//| """Sets the value at the given index. The index can either be an x,y tuple or an int equal +//| to ``y * width + x``. //| -//| .. method:: __setitem__(index, value) +//| This allows you to:: //| -//| Sets the value at the given index. The index can either be an x,y tuple or an int equal -//| to ``y * width + x``. -//| -//| This allows you to:: -//| -//| bitmap[0,1] = 3 +//| bitmap[0,1] = 3""" +//| ... //| STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { if (value_obj == mp_const_none) { @@ -178,9 +177,9 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val return mp_const_none; } -//| .. method:: fill(value) -//| -//| Fills the bitmap with the supplied palette index value. +//| def fill(self, value: Any) -> Any: +//| """Fills the bitmap with the supplied palette index value.""" +//| ... //| STATIC mp_obj_t displayio_bitmap_obj_fill(mp_obj_t self_in, mp_obj_t value_obj) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index db2d1b6e29..1d6e5a0cc9 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -36,18 +36,20 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class ColorConverter: +//| """.. currentmodule:: displayio //| -//| :class:`ColorConverter` -- Converts one color format to another -//| ========================================================================================= +//| :class:`ColorConverter` -- Converts one color format to another +//| ========================================================================================= //| -//| Converts one color format to another. +//| Converts one color format to another.""" //| -//| .. class:: ColorConverter(*, dither=False) +//| def __init__(self, *, dither: bool = False): +//| """Create a ColorConverter object to convert color formats. Only supports RGB888 to RGB565 +//| currently. +//| :param bool dither: Adds random noise to dither the output image""" +//| ... //| -//| Create a ColorConverter object to convert color formats. Only supports RGB888 to RGB565 -//| currently. -//| :param bool dither: Adds random noise to dither the output image // TODO(tannewt): Add support for other color formats. //| @@ -68,9 +70,9 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz return MP_OBJ_FROM_PTR(self); } -//| .. method:: convert(color) -//| -//| Converts the given RGB888 color to RGB565 +//| def convert(self, color: Any) -> Any: +//| """Converts the given RGB888 color to RGB565""" +//| ... //| STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t color_obj) { displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); @@ -87,10 +89,9 @@ STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(displayio_colorconverter_convert_obj, displayio_colorconverter_obj_convert); -//| .. attribute:: dither -//| -//| When true the color converter dithers the output by adding random noise when -//| truncating to display bitdepth +//| dither: Any = ... +//| """When true the color converter dithers the output by adding random noise when +//| truncating to display bitdepth""" //| STATIC mp_obj_t displayio_colorconverter_obj_get_dither(mp_obj_t self_in) { displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index a22b2add22..12abec1c83 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -39,73 +39,74 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class Display: +//| """.. currentmodule:: displayio //| -//| :class:`Display` -- Manage updating a display over a display bus -//| ========================================================================== +//| :class:`Display` -- Manage updating a display over a display bus +//| ========================================================================== //| -//| This initializes a display and connects it into CircuitPython. Unlike other -//| objects in CircuitPython, Display objects live until `displayio.release_displays()` -//| is called. This is done so that CircuitPython can use the display itself. +//| This initializes a display and connects it into CircuitPython. Unlike other +//| objects in CircuitPython, Display objects live until `displayio.release_displays()` +//| is called. This is done so that CircuitPython can use the display itself. //| -//| Most people should not use this class directly. Use a specific display driver instead that will -//| contain the initialization sequence at minimum. +//| Most people should not use this class directly. Use a specific display driver instead that will +//| contain the initialization sequence at minimum.""" //| -//| .. class:: Display(display_bus, init_sequence, *, width, height, colstart=0, rowstart=0, rotation=0, color_depth=16, grayscale=False, pixels_in_byte_share_row=True, bytes_per_cell=1, reverse_pixels_in_byte=False, set_column_command=0x2a, set_row_command=0x2b, write_ram_command=0x2c, set_vertical_scroll=0, backlight_pin=None, brightness_command=None, brightness=1.0, auto_brightness=False, single_byte_bounds=False, data_as_commands=False, auto_refresh=True, native_frames_per_second=60) +//| def __init__(self, display_bus: Any, init_sequence: buffer, *, width: int, height: int, colstart: int = 0, rowstart: int = 0, rotation: int = 0, color_depth: int = 16, grayscale: bool = False, pixels_in_byte_share_row: bool = True, bytes_per_cell: int = 1, reverse_pixels_in_byte: bool = False, set_column_command: int = 0x2a, set_row_command: int = 0x2b, write_ram_command: int = 0x2c, set_vertical_scroll: int = 0, backlight_pin: microcontroller.Pin = None, brightness_command: int = None, brightness: bool = 1.0, auto_brightness: bool = False, single_byte_bounds: bool = False, data_as_commands: bool = False, auto_refresh: bool = True, native_frames_per_second: int = 60): +//| """Create a Display object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`). //| -//| Create a Display object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`). +//| The ``init_sequence`` is bitpacked to minimize the ram impact. Every command begins with a +//| command byte followed by a byte to determine the parameter count and if a delay is need after. +//| When the top bit of the second byte is 1, the next byte will be the delay time in milliseconds. +//| The remaining 7 bits are the parameter count excluding any delay byte. The third through final +//| bytes are the remaining command parameters. The next byte will begin a new command definition. +//| Here is a portion of ILI9341 init code: //| -//| The ``init_sequence`` is bitpacked to minimize the ram impact. Every command begins with a -//| command byte followed by a byte to determine the parameter count and if a delay is need after. -//| When the top bit of the second byte is 1, the next byte will be the delay time in milliseconds. -//| The remaining 7 bits are the parameter count excluding any delay byte. The third through final -//| bytes are the remaining command parameters. The next byte will begin a new command definition. -//| Here is a portion of ILI9341 init code: +//| .. code-block:: python //| -//| .. code-block:: python +//| init_sequence = (b"\xe1\x0f\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F" # Set Gamma +//| b"\x11\x80\x78"# Exit Sleep then delay 0x78 (120ms) +//| b"\x29\x80\x78"# Display on then delay 0x78 (120ms) +//| ) +//| display = displayio.Display(display_bus, init_sequence, width=320, height=240) //| -//| init_sequence = (b"\xe1\x0f\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F" # Set Gamma -//| b"\x11\x80\x78"# Exit Sleep then delay 0x78 (120ms) -//| b"\x29\x80\x78"# Display on then delay 0x78 (120ms) -//| ) -//| display = displayio.Display(display_bus, init_sequence, width=320, height=240) +//| The first command is 0xe1 with 15 (0xf) parameters following. The second and third are 0x11 and +//| 0x29 respectively with delays (0x80) of 120ms (0x78) and no parameters. Multiple byte literals +//| (b"") are merged together on load. The parens are needed to allow byte literals on subsequent +//| lines. //| -//| The first command is 0xe1 with 15 (0xf) parameters following. The second and third are 0x11 and -//| 0x29 respectively with delays (0x80) of 120ms (0x78) and no parameters. Multiple byte literals -//| (b"") are merged together on load. The parens are needed to allow byte literals on subsequent -//| lines. +//| The initialization sequence should always leave the display memory access inline with the scan +//| of the display to minimize tearing artifacts. //| -//| The initialization sequence should always leave the display memory access inline with the scan -//| of the display to minimize tearing artifacts. -//| -//| :param display_bus: The bus that the display is connected to -//| :type display_bus: displayio.FourWire or displayio.ParallelBus -//| :param buffer init_sequence: Byte-packed initialization sequence. -//| :param int width: Width in pixels -//| :param int height: Height in pixels -//| :param int colstart: The index if the first visible column -//| :param int rowstart: The index if the first visible row -//| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270) -//| :param int color_depth: The number of bits of color per pixel transmitted. (Some displays -//| support 18 bit but 16 is easier to transmit. The last bit is extrapolated.) -//| :param bool grayscale: True if the display only shows a single color. -//| :param bool pixels_in_byte_share_row: True when pixels are less than a byte and a byte includes pixels from the same row of the display. When False, pixels share a column. -//| :param int bytes_per_cell: Number of bytes per addressable memory location when color_depth < 8. When greater than one, bytes share a row or column according to pixels_in_byte_share_row. -//| :param bool reverse_pixels_in_byte: Reverses the pixel order within each byte when color_depth < 8. Does not apply across multiple bytes even if there is more than one byte per cell (bytes_per_cell.) -//| :param bool reverse_bytes_in_word: Reverses the order of bytes within a word when color_depth == 16 -//| :param int set_column_command: Command used to set the start and end columns to update -//| :param int set_row_command: Command used so set the start and end rows to update -//| :param int write_ram_command: Command used to write pixels values into the update region. Ignored if data_as_commands is set. -//| :param int set_vertical_scroll: Command used to set the first row to show -//| :param microcontroller.Pin backlight_pin: Pin connected to the display's backlight -//| :param int brightness_command: Command to set display brightness. Usually available in OLED controllers. -//| :param bool brightness: Initial display brightness. This value is ignored if auto_brightness is True. -//| :param bool auto_brightness: If True, brightness is controlled via an ambient light sensor or other mechanism. -//| :param bool single_byte_bounds: Display column and row commands use single bytes -//| :param bool data_as_commands: Treat all init and boundary data as SPI commands. Certain displays require this. -//| :param bool auto_refresh: Automatically refresh the screen -//| :param int native_frames_per_second: Number of display refreshes per second that occur with the given init_sequence. -//| :param bool backlight_on_high: If True, pulling the backlight pin high turns the backlight on. +//| :param display_bus: The bus that the display is connected to +//| :type display_bus: displayio.FourWire or displayio.ParallelBus +//| :param buffer init_sequence: Byte-packed initialization sequence. +//| :param int width: Width in pixels +//| :param int height: Height in pixels +//| :param int colstart: The index if the first visible column +//| :param int rowstart: The index if the first visible row +//| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270) +//| :param int color_depth: The number of bits of color per pixel transmitted. (Some displays +//| support 18 bit but 16 is easier to transmit. The last bit is extrapolated.) +//| :param bool grayscale: True if the display only shows a single color. +//| :param bool pixels_in_byte_share_row: True when pixels are less than a byte and a byte includes pixels from the same row of the display. When False, pixels share a column. +//| :param int bytes_per_cell: Number of bytes per addressable memory location when color_depth < 8. When greater than one, bytes share a row or column according to pixels_in_byte_share_row. +//| :param bool reverse_pixels_in_byte: Reverses the pixel order within each byte when color_depth < 8. Does not apply across multiple bytes even if there is more than one byte per cell (bytes_per_cell.) +//| :param bool reverse_bytes_in_word: Reverses the order of bytes within a word when color_depth == 16 +//| :param int set_column_command: Command used to set the start and end columns to update +//| :param int set_row_command: Command used so set the start and end rows to update +//| :param int write_ram_command: Command used to write pixels values into the update region. Ignored if data_as_commands is set. +//| :param int set_vertical_scroll: Command used to set the first row to show +//| :param microcontroller.Pin backlight_pin: Pin connected to the display's backlight +//| :param int brightness_command: Command to set display brightness. Usually available in OLED controllers. +//| :param bool brightness: Initial display brightness. This value is ignored if auto_brightness is True. +//| :param bool auto_brightness: If True, brightness is controlled via an ambient light sensor or other mechanism. +//| :param bool single_byte_bounds: Display column and row commands use single bytes +//| :param bool data_as_commands: Treat all init and boundary data as SPI commands. Certain displays require this. +//| :param bool auto_refresh: Automatically refresh the screen +//| :param int native_frames_per_second: Number of display refreshes per second that occur with the given init_sequence. +//| :param bool backlight_on_high: If True, pulling the backlight pin high turns the backlight on.""" +//| ... //| STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high }; @@ -190,12 +191,13 @@ static displayio_display_obj_t* native_display(mp_obj_t display_obj) { return MP_OBJ_TO_PTR(native_display); } -//| .. method:: show(group) +//| def show(self, group: Group) -> Any: +//| """Switches to displaying the given group of layers. When group is None, the default +//| CircuitPython terminal will be shown. //| -//| Switches to displaying the given group of layers. When group is None, the default -//| CircuitPython terminal will be shown. +//| :param Group group: The group to show.""" +//| ... //| -//| :param Group group: The group to show. STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in) { displayio_display_obj_t *self = native_display(self_in); displayio_group_t* group = NULL; @@ -211,21 +213,21 @@ STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in) } MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show); -//| .. method:: refresh(*, target_frames_per_second=60, minimum_frames_per_second=1) +//| def refresh(self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1) -> Any: +//| """When auto refresh is off, waits for the target frame rate and then refreshes the display, +//| returning True. If the call has taken too long since the last refresh call for the given +//| target frame rate, then the refresh returns False immediately without updating the screen to +//| hopefully help getting caught up. //| -//| When auto refresh is off, waits for the target frame rate and then refreshes the display, -//| returning True. If the call has taken too long since the last refresh call for the given -//| target frame rate, then the refresh returns False immediately without updating the screen to -//| hopefully help getting caught up. +//| If the time since the last successful refresh is below the minimum frame rate, then an +//| exception will be raised. Set minimum_frames_per_second to 0 to disable. //| -//| If the time since the last successful refresh is below the minimum frame rate, then an -//| exception will be raised. Set minimum_frames_per_second to 0 to disable. +//| When auto refresh is on, updates the display immediately. (The display will also update +//| without calls to this.) //| -//| When auto refresh is on, updates the display immediately. (The display will also update -//| without calls to this.) -//| -//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. -//| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second. +//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. +//| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" +//| ... //| STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second }; @@ -246,9 +248,8 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos } MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_refresh_obj, 1, displayio_display_obj_refresh); -//| .. attribute:: auto_refresh -//| -//| True when the display is refreshed automatically. +//| auto_refresh: Any = ... +//| """True when the display is refreshed automatically.""" //| STATIC mp_obj_t displayio_display_obj_get_auto_refresh(mp_obj_t self_in) { displayio_display_obj_t *self = native_display(self_in); @@ -272,11 +273,10 @@ const mp_obj_property_t displayio_display_auto_refresh_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: brightness -//| -//| The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When +//| brightness: Any = ... +//| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When //| `auto_brightness` is True, the value of `brightness` will change automatically. -//| If `brightness` is set, `auto_brightness` will be disabled and will be set to False. +//| If `brightness` is set, `auto_brightness` will be disabled and will be set to False.""" //| STATIC mp_obj_t displayio_display_obj_get_brightness(mp_obj_t self_in) { displayio_display_obj_t *self = native_display(self_in); @@ -310,12 +310,11 @@ const mp_obj_property_t displayio_display_brightness_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: auto_brightness -//| -//| True when the display brightness is adjusted automatically, based on an ambient +//| auto_brightness: Any = ... +//| """True when the display brightness is adjusted automatically, based on an ambient //| light sensor or other method. Note that some displays may have this set to True by default, //| but not actually implement automatic brightness adjustment. `auto_brightness` is set to False -//| if `brightness` is set manually. +//| if `brightness` is set manually.""" //| STATIC mp_obj_t displayio_display_obj_get_auto_brightness(mp_obj_t self_in) { displayio_display_obj_t *self = native_display(self_in); @@ -342,9 +341,8 @@ const mp_obj_property_t displayio_display_auto_brightness_obj = { -//| .. attribute:: width -//| -//| Gets the width of the board +//| width: Any = ... +//| Gets the width of the board //| //| STATIC mp_obj_t displayio_display_obj_get_width(mp_obj_t self_in) { @@ -360,9 +358,8 @@ const mp_obj_property_t displayio_display_width_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: height -//| -//| Gets the height of the board +//| height: Any = ... +//| """Gets the height of the board""" //| //| STATIC mp_obj_t displayio_display_obj_get_height(mp_obj_t self_in) { @@ -378,9 +375,8 @@ const mp_obj_property_t displayio_display_height_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: rotation -//| -//| The rotation of the display as an int in degrees. +//| rotation: Any = ... +//| """The rotation of the display as an int in degrees.""" //| STATIC mp_obj_t displayio_display_obj_get_rotation(mp_obj_t self_in) { displayio_display_obj_t *self = native_display(self_in); @@ -402,9 +398,8 @@ const mp_obj_property_t displayio_display_rotation_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: bus -//| -//| The bus being used by the display +//| bus: Any = ... +//| """The bus being used by the display""" //| //| STATIC mp_obj_t displayio_display_obj_get_bus(mp_obj_t self_in) { @@ -421,12 +416,13 @@ const mp_obj_property_t displayio_display_bus_obj = { }; -//| .. method:: fill_row(y, buffer) +//| def fill_row(self, y: int, buffer: bytearray) -> Any: +//| """Extract the pixels from a single row //| -//| Extract the pixels from a single row +//| :param int y: The top edge of the area +//| :param bytearray buffer: The buffer in which to place the pixel data""" +//| ... //| -//| :param int y: The top edge of the area -//| :param bytearray buffer: The buffer in which to place the pixel data STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_y, ARG_buffer }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index 1459c16809..8b03ddc067 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -39,55 +39,56 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class EPaperDisplay: +//| """.. currentmodule:: displayio //| -//| :class:`EPaperDisplay` -- Manage updating an epaper display over a display bus -//| ============================================================================== +//| :class:`EPaperDisplay` -- Manage updating an epaper display over a display bus +//| ============================================================================== //| -//| This initializes an epaper display and connects it into CircuitPython. Unlike other -//| objects in CircuitPython, EPaperDisplay objects live until `displayio.release_displays()` -//| is called. This is done so that CircuitPython can use the display itself. +//| This initializes an epaper display and connects it into CircuitPython. Unlike other +//| objects in CircuitPython, EPaperDisplay objects live until `displayio.release_displays()` +//| is called. This is done so that CircuitPython can use the display itself. //| -//| Most people should not use this class directly. Use a specific display driver instead that will -//| contain the startup and shutdown sequences at minimum. +//| Most people should not use this class directly. Use a specific display driver instead that will +//| contain the startup and shutdown sequences at minimum.""" //| -//| .. class:: EPaperDisplay(display_bus, start_sequence, stop_sequence, *, width, height, ram_width, ram_height, colstart=0, rowstart=0, rotation=0, set_column_window_command=None, set_row_window_command=None, single_byte_bounds=False, write_black_ram_command, black_bits_inverted=False, write_color_ram_command=None, color_bits_inverted=False, highlight_color=0x000000, refresh_display_command, refresh_time=40, busy_pin=None, busy_state=True, seconds_per_frame=180, always_toggle_chip_select=False) +//| def __init__(self, display_bus: Any, start_sequence: buffer, stop_sequence: buffer, *, width: int, height: int, ram_width: int, ram_height: int, colstart: int = 0, rowstart: int = 0, rotation: int = 0, set_column_window_command: int = None, set_row_window_command: int = None, single_byte_bounds: Any = False, write_black_ram_command: int, black_bits_inverted: bool = False, write_color_ram_command: int = None, color_bits_inverted: bool = False, highlight_color: int = 0x000000, refresh_display_command: int, refresh_time: float = 40, busy_pin: microcontroller.Pin = None, busy_state: bool = True, seconds_per_frame: float = 180, always_toggle_chip_select: bool = False): +//| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`). //| -//| Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`). +//| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every +//| command begins with a command byte followed by a byte to determine the parameter count and if +//| a delay is need after. When the top bit of the second byte is 1, the next byte will be the +//| delay time in milliseconds. The remaining 7 bits are the parameter count excluding any delay +//| byte. The third through final bytes are the remaining command parameters. The next byte will +//| begin a new command definition. //| -//| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every -//| command begins with a command byte followed by a byte to determine the parameter count and if -//| a delay is need after. When the top bit of the second byte is 1, the next byte will be the -//| delay time in milliseconds. The remaining 7 bits are the parameter count excluding any delay -//| byte. The third through final bytes are the remaining command parameters. The next byte will -//| begin a new command definition. -//| -//| :param display_bus: The bus that the display is connected to -//| :type display_bus: displayio.FourWire or displayio.ParallelBus -//| :param buffer start_sequence: Byte-packed initialization sequence. -//| :param buffer stop_sequence: Byte-packed initialization sequence. -//| :param int width: Width in pixels -//| :param int height: Height in pixels -//| :param int ram_width: RAM width in pixels -//| :param int ram_height: RAM height in pixels -//| :param int colstart: The index if the first visible column -//| :param int rowstart: The index if the first visible row -//| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270) -//| :param int set_column_window_command: Command used to set the start and end columns to update -//| :param int set_row_window_command: Command used so set the start and end rows to update -//| :param int set_current_column_command: Command used to set the current column location -//| :param int set_current_row_command: Command used to set the current row location -//| :param int write_black_ram_command: Command used to write pixels values into the update region -//| :param bool black_bits_inverted: True if 0 bits are used to show black pixels. Otherwise, 1 means to show black. -//| :param int write_color_ram_command: Command used to write pixels values into the update region -//| :param bool color_bits_inverted: True if 0 bits are used to show the color. Otherwise, 1 means to show color. -//| :param int highlight_color: RGB888 of source color to highlight with third ePaper color. -//| :param int refresh_display_command: Command used to start a display refresh -//| :param float refresh_time: Time it takes to refresh the display before the stop_sequence should be sent. Ignored when busy_pin is provided. -//| :param microcontroller.Pin busy_pin: Pin used to signify the display is busy -//| :param bool busy_state: State of the busy pin when the display is busy -//| :param float seconds_per_frame: Minimum number of seconds between screen refreshes -//| :param bool always_toggle_chip_select: When True, chip select is toggled every byte +//| :param display_bus: The bus that the display is connected to +//| :type display_bus: displayio.FourWire or displayio.ParallelBus +//| :param buffer start_sequence: Byte-packed initialization sequence. +//| :param buffer stop_sequence: Byte-packed initialization sequence. +//| :param int width: Width in pixels +//| :param int height: Height in pixels +//| :param int ram_width: RAM width in pixels +//| :param int ram_height: RAM height in pixels +//| :param int colstart: The index if the first visible column +//| :param int rowstart: The index if the first visible row +//| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270) +//| :param int set_column_window_command: Command used to set the start and end columns to update +//| :param int set_row_window_command: Command used so set the start and end rows to update +//| :param int set_current_column_command: Command used to set the current column location +//| :param int set_current_row_command: Command used to set the current row location +//| :param int write_black_ram_command: Command used to write pixels values into the update region +//| :param bool black_bits_inverted: True if 0 bits are used to show black pixels. Otherwise, 1 means to show black. +//| :param int write_color_ram_command: Command used to write pixels values into the update region +//| :param bool color_bits_inverted: True if 0 bits are used to show the color. Otherwise, 1 means to show color. +//| :param int highlight_color: RGB888 of source color to highlight with third ePaper color. +//| :param int refresh_display_command: Command used to start a display refresh +//| :param float refresh_time: Time it takes to refresh the display before the stop_sequence should be sent. Ignored when busy_pin is provided. +//| :param microcontroller.Pin busy_pin: Pin used to signify the display is busy +//| :param bool busy_state: State of the busy pin when the display is busy +//| :param float seconds_per_frame: Minimum number of seconds between screen refreshes +//| :param bool always_toggle_chip_select: When True, chip select is toggled every byte""" +//| ... //| STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_display_bus, ARG_start_sequence, ARG_stop_sequence, ARG_width, ARG_height, ARG_ram_width, ARG_ram_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_set_column_window_command, ARG_set_row_window_command, ARG_set_current_column_command, ARG_set_current_row_command, ARG_write_black_ram_command, ARG_black_bits_inverted, ARG_write_color_ram_command, ARG_color_bits_inverted, ARG_highlight_color, ARG_refresh_display_command, ARG_refresh_time, ARG_busy_pin, ARG_busy_state, ARG_seconds_per_frame, ARG_always_toggle_chip_select }; @@ -170,12 +171,13 @@ static displayio_epaperdisplay_obj_t* native_display(mp_obj_t display_obj) { return MP_OBJ_TO_PTR(native_display); } -//| .. method:: show(group) +//| def show(self, group: Group) -> Any: +//| """Switches to displaying the given group of layers. When group is None, the default +//| CircuitPython terminal will be shown. //| -//| Switches to displaying the given group of layers. When group is None, the default -//| CircuitPython terminal will be shown. +//| :param Group group: The group to show.""" +//| ... //| -//| :param Group group: The group to show. STATIC mp_obj_t displayio_epaperdisplay_obj_show(mp_obj_t self_in, mp_obj_t group_in) { displayio_epaperdisplay_obj_t *self = native_display(self_in); displayio_group_t* group = NULL; @@ -191,10 +193,10 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_show(mp_obj_t self_in, mp_obj_t grou } MP_DEFINE_CONST_FUN_OBJ_2(displayio_epaperdisplay_show_obj, displayio_epaperdisplay_obj_show); -//| .. method:: refresh() -//| -//| Refreshes the display immediately or raises an exception if too soon. Use -//| ``time.sleep(display.time_to_refresh)`` to sleep until a refresh can occur. +//| def refresh(self, ) -> Any: +//| """Refreshes the display immediately or raises an exception if too soon. Use +//| ``time.sleep(display.time_to_refresh)`` to sleep until a refresh can occur.""" +//| ... //| STATIC mp_obj_t displayio_epaperdisplay_obj_refresh(mp_obj_t self_in) { displayio_epaperdisplay_obj_t *self = native_display(self_in); @@ -206,10 +208,8 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_refresh(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_refresh_obj, displayio_epaperdisplay_obj_refresh); -//| .. attribute:: time_to_refresh -//| -//| Time, in fractional seconds, until the ePaper display can be refreshed. -//| +//| time_to_refresh: Any = ... +//| """Time, in fractional seconds, until the ePaper display can be refreshed.""" //| STATIC mp_obj_t displayio_epaperdisplay_obj_get_time_to_refresh(mp_obj_t self_in) { displayio_epaperdisplay_obj_t *self = native_display(self_in); @@ -224,10 +224,8 @@ const mp_obj_property_t displayio_epaperdisplay_time_to_refresh_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: width -//| -//| Gets the width of the display in pixels -//| +//| width: Any = ... +//| """Gets the width of the display in pixels""" //| STATIC mp_obj_t displayio_epaperdisplay_obj_get_width(mp_obj_t self_in) { displayio_epaperdisplay_obj_t *self = native_display(self_in); @@ -242,10 +240,8 @@ const mp_obj_property_t displayio_epaperdisplay_width_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: height -//| -//| Gets the height of the display in pixels -//| +//| height: Any = ... +//| """Gets the height of the display in pixels""" //| STATIC mp_obj_t displayio_epaperdisplay_obj_get_height(mp_obj_t self_in) { displayio_epaperdisplay_obj_t *self = native_display(self_in); @@ -260,10 +256,8 @@ const mp_obj_property_t displayio_epaperdisplay_height_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: bus -//| -//| The bus being used by the display -//| +//| bus: Any = ... +//| """The bus being used by the display""" //| STATIC mp_obj_t displayio_epaperdisplay_obj_get_bus(mp_obj_t self_in) { displayio_epaperdisplay_obj_t *self = native_display(self_in); diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index 6ad1624114..649045039e 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -38,31 +38,32 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class FourWire: +//| """.. currentmodule:: displayio //| -//| :class:`FourWire` -- Manage updating a display over SPI four wire protocol -//| ========================================================================== +//| :class:`FourWire` -- Manage updating a display over SPI four wire protocol +//| ========================================================================== //| -//| Manage updating a display over SPI four wire protocol in the background while Python code runs. -//| It doesn't handle display initialization. +//| Manage updating a display over SPI four wire protocol in the background while Python code runs. +//| It doesn't handle display initialization.""" //| -//| .. class:: FourWire(spi_bus, *, command, chip_select, reset=None, baudrate=24000000, polarity=0, phase=0) +//| def __init__(self, spi_bus: busio.SPI, *, command: microcontroller.Pin, chip_select: microcontroller.Pin, reset: microcontroller.Pin = None, baudrate: int = 24000000, polarity: int = 0, phase: int = 0): +//| """Create a FourWire object associated with the given pins. //| -//| Create a FourWire object associated with the given pins. +//| The SPI bus and pins are then in use by the display until `displayio.release_displays()` is +//| called even after a reload. (It does this so CircuitPython can use the display after your code +//| is done.) So, the first time you initialize a display bus in code.py you should call +//| :py:func`displayio.release_displays` first, otherwise it will error after the first code.py run. //| -//| The SPI bus and pins are then in use by the display until `displayio.release_displays()` is -//| called even after a reload. (It does this so CircuitPython can use the display after your code -//| is done.) So, the first time you initialize a display bus in code.py you should call -//| :py:func`displayio.release_displays` first, otherwise it will error after the first code.py run. -//| -//| :param busio.SPI spi_bus: The SPI bus that make up the clock and data lines -//| :param microcontroller.Pin command: Data or command pin -//| :param microcontroller.Pin chip_select: Chip select pin -//| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used -//| :param int baudrate: Maximum baudrate in Hz for the display on the bus -//| :param int polarity: the base state of the clock line (0 or 1) -//| :param int phase: the edge of the clock that data is captured. First (0) -//| or second (1). Rising or falling depends on clock polarity. +//| :param busio.SPI spi_bus: The SPI bus that make up the clock and data lines +//| :param microcontroller.Pin command: Data or command pin +//| :param microcontroller.Pin chip_select: Chip select pin +//| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used +//| :param int baudrate: Maximum baudrate in Hz for the display on the bus +//| :param int polarity: the base state of the clock line (0 or 1) +//| :param int phase: the edge of the clock that data is captured. First (0) +//| or second (1). Rising or falling depends on clock polarity.""" +//| ... //| STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_spi_bus, ARG_command, ARG_chip_select, ARG_reset, ARG_baudrate, ARG_polarity, ARG_phase }; @@ -100,10 +101,10 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ return self; } -//| .. method:: reset() -//| -//| Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin -//| is available. +//| def reset(self, ) -> Any: +//| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin +//| is available.""" +//| ... //| STATIC mp_obj_t displayio_fourwire_obj_reset(mp_obj_t self_in) { displayio_fourwire_obj_t *self = self_in; @@ -115,10 +116,10 @@ STATIC mp_obj_t displayio_fourwire_obj_reset(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_fourwire_reset_obj, displayio_fourwire_obj_reset); -//| .. method:: send(command, data, *, toggle_every_byte=False) -//| -//| Sends the given command value followed by the full set of data. Display state, such as -//| vertical scroll, set via ``send`` may or may not be reset once the code is done. +//| def send(self, command: Any, data: Any, *, toggle_every_byte: Any = False) -> Any: +//| """Sends the given command value followed by the full set of data. Display state, such as +//| vertical scroll, set via ``send`` may or may not be reset once the code is done.""" +//| ... //| STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_command, ARG_data, ARG_toggle_every_byte }; diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index dd7600eb9c..36e137dc9b 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -35,22 +35,23 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class Group: +//| """.. currentmodule:: displayio //| -//| :class:`Group` -- Group together sprites and subgroups -//| ========================================================================== +//| :class:`Group` -- Group together sprites and subgroups +//| ========================================================================== //| -//| Manage a group of sprites and groups and how they are inter-related. +//| Manage a group of sprites and groups and how they are inter-related.""" //| -//| .. class:: Group(*, max_size=4, scale=1, x=0, y=0) +//| def __init__(self, *, max_size: int = 4, scale: int = 1, x: int = 0, y: int = 0): +//| """Create a Group of a given size and scale. Scale is in one dimension. For example, scale=2 +//| leads to a layer's pixel being 2x2 pixels when in the group. //| -//| Create a Group of a given size and scale. Scale is in one dimension. For example, scale=2 -//| leads to a layer's pixel being 2x2 pixels when in the group. -//| -//| :param int max_size: The maximum group size. -//| :param int scale: Scale of layer pixels in one dimension. -//| :param int x: Initial x position within the parent. -//| :param int y: Initial y position within the parent. +//| :param int max_size: The maximum group size. +//| :param int scale: Scale of layer pixels in one dimension. +//| :param int x: Initial x position within the parent. +//| :param int y: Initial y position within the parent.""" +//| ... //| STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_max_size, ARG_scale, ARG_x, ARG_y }; @@ -90,10 +91,9 @@ displayio_group_t* native_group(mp_obj_t group_obj) { return MP_OBJ_TO_PTR(native_group); } -//| .. attribute:: hidden -//| -//| True when the Group and all of it's layers are not visible. When False, the Group's layers -//| are visible if they haven't been hidden. +//| hidden: Any = ... +//| """True when the Group and all of it's layers are not visible. When False, the Group's layers +//| are visible if they haven't been hidden.""" //| STATIC mp_obj_t displayio_group_obj_get_hidden(mp_obj_t self_in) { displayio_group_t *self = native_group(self_in); @@ -116,10 +116,9 @@ const mp_obj_property_t displayio_group_hidden_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: scale -//| -//| Scales each pixel within the Group in both directions. For example, when scale=2 each pixel -//| will be represented by 2x2 pixels. +//| scale: Any = ... +//| """Scales each pixel within the Group in both directions. For example, when scale=2 each pixel +//| will be represented by 2x2 pixels.""" //| STATIC mp_obj_t displayio_group_obj_get_scale(mp_obj_t self_in) { displayio_group_t *self = native_group(self_in); @@ -146,9 +145,8 @@ const mp_obj_property_t displayio_group_scale_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: x -//| -//| X position of the Group in the parent. +//| x: Any = ... +//| """X position of the Group in the parent.""" //| STATIC mp_obj_t displayio_group_obj_get_x(mp_obj_t self_in) { displayio_group_t *self = native_group(self_in); @@ -172,9 +170,8 @@ const mp_obj_property_t displayio_group_x_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: y -//| -//| Y position of the Group in the parent. +//| y: Any = ... +//| """Y position of the Group in the parent.""" //| STATIC mp_obj_t displayio_group_obj_get_y(mp_obj_t self_in) { displayio_group_t *self = native_group(self_in); @@ -198,9 +195,9 @@ const mp_obj_property_t displayio_group_y_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: append(layer) -//| -//| Append a layer to the group. It will be drawn above other layers. +//| def append(self, layer: Any) -> Any: +//| """Append a layer to the group. It will be drawn above other layers.""" +//| ... //| STATIC mp_obj_t displayio_group_obj_append(mp_obj_t self_in, mp_obj_t layer) { displayio_group_t *self = native_group(self_in); @@ -209,9 +206,9 @@ STATIC mp_obj_t displayio_group_obj_append(mp_obj_t self_in, mp_obj_t layer) { } MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_append_obj, displayio_group_obj_append); -//| .. method:: insert(index, layer) -//| -//| Insert a layer into the group. +//| def insert(self, index: Any, layer: Any) -> Any: +//| """Insert a layer into the group.""" +//| ... //| STATIC mp_obj_t displayio_group_obj_insert(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t layer) { displayio_group_t *self = native_group(self_in); @@ -222,9 +219,9 @@ STATIC mp_obj_t displayio_group_obj_insert(mp_obj_t self_in, mp_obj_t index_obj, MP_DEFINE_CONST_FUN_OBJ_3(displayio_group_insert_obj, displayio_group_obj_insert); -//| .. method:: index(layer) -//| -//| Returns the index of the first copy of layer. Raises ValueError if not found. +//| def index(self, layer: Any) -> Any: +//| """Returns the index of the first copy of layer. Raises ValueError if not found.""" +//| ... //| STATIC mp_obj_t displayio_group_obj_index(mp_obj_t self_in, mp_obj_t layer) { displayio_group_t *self = native_group(self_in); @@ -236,9 +233,9 @@ STATIC mp_obj_t displayio_group_obj_index(mp_obj_t self_in, mp_obj_t layer) { } MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_index_obj, displayio_group_obj_index); -//| .. method:: pop(i=-1) -//| -//| Remove the ith item and return it. +//| def pop(self, i: Any = -1) -> Any: +//| """Remove the ith item and return it.""" +//| ... //| STATIC mp_obj_t displayio_group_obj_pop(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_i }; @@ -259,9 +256,9 @@ STATIC mp_obj_t displayio_group_obj_pop(size_t n_args, const mp_obj_t *pos_args, MP_DEFINE_CONST_FUN_OBJ_KW(displayio_group_pop_obj, 1, displayio_group_obj_pop); -//| .. method:: remove(layer) -//| -//| Remove the first copy of layer. Raises ValueError if it is not present. +//| def remove(self, layer: Any) -> Any: +//| """Remove the first copy of layer. Raises ValueError if it is not present.""" +//| ... //| STATIC mp_obj_t displayio_group_obj_remove(mp_obj_t self_in, mp_obj_t layer) { mp_obj_t index = displayio_group_obj_index(self_in, layer); @@ -272,9 +269,9 @@ STATIC mp_obj_t displayio_group_obj_remove(mp_obj_t self_in, mp_obj_t layer) { } MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_remove_obj, displayio_group_obj_remove); -//| .. method:: __len__() -//| -//| Returns the number of layers in a Group +//| def __len__(self, ) -> Any: +//| """Returns the number of layers in a Group""" +//| ... //| STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { displayio_group_t *self = native_group(self_in); @@ -286,29 +283,29 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } -//| .. method:: __getitem__(index) +//| def __getitem__(self, index: Any) -> Any: +//| """Returns the value at the given index. //| -//| Returns the value at the given index. +//| This allows you to:: //| -//| This allows you to:: +//| print(group[0])""" +//| ... //| -//| print(group[0]) +//| def __setitem__(self, index: Any, value: Any) -> Any: +//| """Sets the value at the given index. //| -//| .. method:: __setitem__(index, value) +//| This allows you to:: //| -//| Sets the value at the given index. +//| group[0] = sprite""" +//| ... //| -//| This allows you to:: +//| def __delitem__(self, index: Any) -> Any: +//| """Deletes the value at the given index. //| -//| group[0] = sprite +//| This allows you to:: //| -//| .. method:: __delitem__(index) -//| -//| Deletes the value at the given index. -//| -//| This allows you to:: -//| -//| del group[0] +//| del group[0]""" +//| ... //| STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { displayio_group_t *self = native_group(self_in); diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c index 963e8377c5..e2402dc49b 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/displayio/I2CDisplay.c @@ -38,26 +38,27 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class I2CDisplay: +//| """.. currentmodule:: displayio //| -//| :class:`I2CDisplay` -- Manage updating a display over I2C -//| ========================================================================== +//| :class:`I2CDisplay` -- Manage updating a display over I2C +//| ========================================================================== //| -//| Manage updating a display over I2C in the background while Python code runs. -//| It doesn't handle display initialization. +//| Manage updating a display over I2C in the background while Python code runs. +//| It doesn't handle display initialization.""" //| -//| .. class:: I2CDisplay(i2c_bus, *, device_address, reset=None) +//| def __init__(self, i2c_bus: busio.I2C, *, device_address: int, reset: microcontroller.Pin = None): +//| """Create a I2CDisplay object associated with the given I2C bus and reset pin. //| -//| Create a I2CDisplay object associated with the given I2C bus and reset pin. +//| The I2C bus and pins are then in use by the display until `displayio.release_displays()` is +//| called even after a reload. (It does this so CircuitPython can use the display after your code +//| is done.) So, the first time you initialize a display bus in code.py you should call +//| :py:func`displayio.release_displays` first, otherwise it will error after the first code.py run. //| -//| The I2C bus and pins are then in use by the display until `displayio.release_displays()` is -//| called even after a reload. (It does this so CircuitPython can use the display after your code -//| is done.) So, the first time you initialize a display bus in code.py you should call -//| :py:func`displayio.release_displays` first, otherwise it will error after the first code.py run. -//| -//| :param busio.I2C i2c_bus: The I2C bus that make up the clock and data lines -//| :param int device_address: The I2C address of the device -//| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used +//| :param busio.I2C i2c_bus: The I2C bus that make up the clock and data lines +//| :param int device_address: The I2C address of the device +//| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used""" +//| ... //| STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_i2c_bus, ARG_device_address, ARG_reset }; @@ -80,10 +81,10 @@ STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t return self; } -//| .. method:: reset() -//| -//| Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin -//| is available. +//| def reset(self, ) -> Any: +//| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin +//| is available.""" +//| ... //| STATIC mp_obj_t displayio_i2cdisplay_obj_reset(mp_obj_t self_in) { displayio_i2cdisplay_obj_t *self = self_in; @@ -95,10 +96,10 @@ STATIC mp_obj_t displayio_i2cdisplay_obj_reset(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_i2cdisplay_reset_obj, displayio_i2cdisplay_obj_reset); -//| .. method:: send(command, data) -//| -//| Sends the given command value followed by the full set of data. Display state, such as -//| vertical scroll, set via ``send`` may or may not be reset once the code is done. +//| def send(self, command: Any, data: Any) -> Any: +//| """Sends the given command value followed by the full set of data. Display state, such as +//| vertical scroll, set via ``send`` may or may not be reset once the code is done.""" +//| ... //| STATIC mp_obj_t displayio_i2cdisplay_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { mp_int_t command_int = MP_OBJ_SMALL_INT_VALUE(command_obj); diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index 57179947ed..95c890c3b9 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -33,51 +33,52 @@ #include "supervisor/shared/translate.h" #include "shared-bindings/displayio/OnDiskBitmap.h" -//| .. currentmodule:: displayio +//| class OnDiskBitmap: +//| """.. currentmodule:: displayio //| -//| :class:`OnDiskBitmap` -- Loads pixels straight from disk -//| ========================================================================== +//| :class:`OnDiskBitmap` -- Loads pixels straight from disk +//| ========================================================================== //| -//| Loads values straight from disk. This minimizes memory use but can lead to -//| much slower pixel load times. These load times may result in frame tearing where only part of -//| the image is visible. +//| Loads values straight from disk. This minimizes memory use but can lead to +//| much slower pixel load times. These load times may result in frame tearing where only part of +//| the image is visible. //| -//| It's easiest to use on a board with a built in display such as the `Hallowing M0 Express -//| `_. +//| It's easiest to use on a board with a built in display such as the `Hallowing M0 Express +//| `_. //| -//| .. code-block:: Python +//| .. code-block:: Python //| -//| import board -//| import displayio -//| import time -//| import pulseio +//| import board +//| import displayio +//| import time +//| import pulseio //| -//| board.DISPLAY.auto_brightness = False -//| board.DISPLAY.brightness = 0 -//| splash = displayio.Group() -//| board.DISPLAY.show(splash) +//| board.DISPLAY.auto_brightness = False +//| board.DISPLAY.brightness = 0 +//| splash = displayio.Group() +//| board.DISPLAY.show(splash) //| -//| with open("/sample.bmp", "rb") as f: -//| odb = displayio.OnDiskBitmap(f) -//| face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter()) -//| splash.append(face) -//| # Wait for the image to load. -//| board.DISPLAY.refresh(target_frames_per_second=60) +//| with open("/sample.bmp", "rb") as f: +//| odb = displayio.OnDiskBitmap(f) +//| face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter()) +//| splash.append(face) +//| # Wait for the image to load. +//| board.DISPLAY.refresh(target_frames_per_second=60) //| -//| # Fade up the backlight -//| for i in range(100): -//| board.DISPLAY.brightness = 0.01 * i -//| time.sleep(0.05) +//| # Fade up the backlight +//| for i in range(100): +//| board.DISPLAY.brightness = 0.01 * i +//| time.sleep(0.05) //| -//| # Wait forever -//| while True: -//| pass +//| # Wait forever +//| while True: +//| pass""" //| -//| .. class:: OnDiskBitmap(file) +//| def __init__(self, file: file): +//| """Create an OnDiskBitmap object with the given file. //| -//| Create an OnDiskBitmap object with the given file. -//| -//| :param file file: The open bitmap file +//| :param file file: The open bitmap file""" +//| ... //| STATIC mp_obj_t displayio_ondiskbitmap_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 1, false); @@ -93,9 +94,8 @@ STATIC mp_obj_t displayio_ondiskbitmap_make_new(const mp_obj_type_t *type, size_ return MP_OBJ_FROM_PTR(self); } -//| .. attribute:: width -//| -//| Width of the bitmap. (read only) +//| width: Any = ... +//| """Width of the bitmap. (read only)""" //| STATIC mp_obj_t displayio_ondiskbitmap_obj_get_width(mp_obj_t self_in) { displayio_ondiskbitmap_t *self = MP_OBJ_TO_PTR(self_in); @@ -113,9 +113,8 @@ const mp_obj_property_t displayio_ondiskbitmap_width_obj = { }; -//| .. attribute:: height -//| -//| Height of the bitmap. (read only) +//| height: Any = ... +//| """Height of the bitmap. (read only)""" //| STATIC mp_obj_t displayio_ondiskbitmap_obj_get_height(mp_obj_t self_in) { displayio_ondiskbitmap_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 67a7db85b8..5df11d2b10 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -36,19 +36,27 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio + + + + + + +//| class Palette: +//| """.. currentmodule:: displayio //| -//| :class:`Palette` -- Stores a mapping from bitmap pixel palette_indexes to display colors -//| ========================================================================================= +//| :class:`Palette` -- Stores a mapping from bitmap pixel palette_indexes to display colors +//| ========================================================================================= //| -//| Map a pixel palette_index to a full color. Colors are transformed to the display's format internally to -//| save memory. +//| Map a pixel palette_index to a full color. Colors are transformed to the display's format internally to +//| save memory.""" //| -//| .. class:: Palette(color_count) +//| def __init__(self, color_count: int): +//| """Create a Palette object to store a set number of colors. //| -//| Create a Palette object to store a set number of colors. +//| :param int color_count: The number of colors in the Palette""" +//| ... //| -//| :param int color_count: The number of colors in the Palette // TODO(tannewt): Add support for other color formats. // TODO(tannewt): Add support for 8-bit alpha blending. //| @@ -67,9 +75,9 @@ STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } -//| .. method:: __len__() -//| -//| Returns the number of colors in a Palette +//| def __len__(self, ) -> Any: +//| """Returns the number of colors in a Palette""" +//| ... //| STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); @@ -81,21 +89,21 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } -//| .. method:: __setitem__(index, value) +//| def __setitem__(self, index: Any, value: Any) -> Any: +//| """Sets the pixel color at the given index. The index should be an integer in the range 0 to color_count-1. //| -//| Sets the pixel color at the given index. The index should be an integer in the range 0 to color_count-1. +//| The value argument represents a color, and can be from 0x000000 to 0xFFFFFF (to represent an RGB value). +//| Value can be an int, bytes (3 bytes (RGB) or 4 bytes (RGB + pad byte)), bytearray, +//| or a tuple or list of 3 integers. //| -//| The value argument represents a color, and can be from 0x000000 to 0xFFFFFF (to represent an RGB value). -//| Value can be an int, bytes (3 bytes (RGB) or 4 bytes (RGB + pad byte)), bytearray, -//| or a tuple or list of 3 integers. +//| This allows you to:: //| -//| This allows you to:: -//| -//| palette[0] = 0xFFFFFF # set using an integer -//| palette[1] = b'\xff\xff\x00' # set using 3 bytes -//| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes -//| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes -//| palette[4] = (10, 20, 30) # set using a tuple of 3 integers +//| palette[0] = 0xFFFFFF # set using an integer +//| palette[1] = b'\xff\xff\x00' # set using 3 bytes +//| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes +//| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes +//| palette[4] = (10, 20, 30) # set using a tuple of 3 integers""" +//| ... //| STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { @@ -144,7 +152,7 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val return mp_const_none; } -//| .. method:: make_transparent(palette_index) +//| def make_transparent(self, palette_index: Any) -> Any: ... //| STATIC mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_t palette_index_obj) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); @@ -158,7 +166,7 @@ STATIC mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_ } MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_transparent_obj, displayio_palette_obj_make_transparent); -//| .. method:: make_opaque(palette_index) +//| def make_opaque(self, palette_index: Any) -> Any: ... //| STATIC mp_obj_t displayio_palette_obj_make_opaque(mp_obj_t self_in, mp_obj_t palette_index_obj) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/displayio/ParallelBus.c b/shared-bindings/displayio/ParallelBus.c index bdafdaef6d..cedcf1de52 100644 --- a/shared-bindings/displayio/ParallelBus.c +++ b/shared-bindings/displayio/ParallelBus.c @@ -37,31 +37,32 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class ParallelBus: +//| """.. currentmodule:: displayio //| -//| :class:`ParallelBus` -- Manage updating a display over 8-bit parallel bus -//| ============================================================================== +//| :class:`ParallelBus` -- Manage updating a display over 8-bit parallel bus +//| ============================================================================== //| -//| Manage updating a display over 8-bit parallel bus in the background while Python code runs. This -//| protocol may be refered to as 8080-I Series Parallel Interface in datasheets. It doesn't handle -//| display initialization. +//| Manage updating a display over 8-bit parallel bus in the background while Python code runs. This +//| protocol may be refered to as 8080-I Series Parallel Interface in datasheets. It doesn't handle +//| display initialization.""" //| -//| .. class:: ParallelBus(*, data0, command, chip_select, write, read, reset) +//| def __init__(self, *, data0: microcontroller.Pin, command: microcontroller.Pin, chip_select: microcontroller.Pin, write: microcontroller.Pin, read: microcontroller.Pin, reset: microcontroller.Pin): +//| """Create a ParallelBus object associated with the given pins. The bus is inferred from data0 +//| by implying the next 7 additional pins on a given GPIO port. //| -//| Create a ParallelBus object associated with the given pins. The bus is inferred from data0 -//| by implying the next 7 additional pins on a given GPIO port. +//| The parallel bus and pins are then in use by the display until `displayio.release_displays()` +//| is called even after a reload. (It does this so CircuitPython can use the display after your +//| code is done.) So, the first time you initialize a display bus in code.py you should call +//| :py:func`displayio.release_displays` first, otherwise it will error after the first code.py run. //| -//| The parallel bus and pins are then in use by the display until `displayio.release_displays()` -//| is called even after a reload. (It does this so CircuitPython can use the display after your -//| code is done.) So, the first time you initialize a display bus in code.py you should call -//| :py:func`displayio.release_displays` first, otherwise it will error after the first code.py run. -//| -//| :param microcontroller.Pin data0: The first data pin. The rest are implied -//| :param microcontroller.Pin command: Data or command pin -//| :param microcontroller.Pin chip_select: Chip select pin -//| :param microcontroller.Pin write: Write pin -//| :param microcontroller.Pin read: Read pin -//| :param microcontroller.Pin reset: Reset pin +//| :param microcontroller.Pin data0: The first data pin. The rest are implied +//| :param microcontroller.Pin command: Data or command pin +//| :param microcontroller.Pin chip_select: Chip select pin +//| :param microcontroller.Pin write: Write pin +//| :param microcontroller.Pin read: Read pin +//| :param microcontroller.Pin reset: Reset pin""" +//| ... //| STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_data0, ARG_command, ARG_chip_select, ARG_write, ARG_read, ARG_reset }; @@ -90,11 +91,12 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t return self; } -//| .. method:: reset() -//| -//| Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin -//| is available. +//| def reset(self, ) -> Any: +//| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin +//| is available.""" +//| ... //| + STATIC mp_obj_t displayio_parallelbus_obj_reset(mp_obj_t self_in) { displayio_parallelbus_obj_t *self = self_in; @@ -105,10 +107,10 @@ STATIC mp_obj_t displayio_parallelbus_obj_reset(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_parallelbus_reset_obj, displayio_parallelbus_obj_reset); -//| .. method:: send(command, data) -//| -//| Sends the given command value followed by the full set of data. Display state, such as -//| vertical scroll, set via ``send`` may or may not be reset once the code is done. +//| def send(self, command: Any, data: Any) -> Any: +//| """Sends the given command value followed by the full set of data. Display state, such as +//| vertical scroll, set via ``send`` may or may not be reset once the code is done.""" +//| ... //| STATIC mp_obj_t displayio_parallelbus_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { mp_int_t command_int = MP_OBJ_SMALL_INT_VALUE(command_obj); diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index 7c7b105015..0f22bb2a3e 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -34,22 +34,23 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class Shape: +//| """.. currentmodule:: displayio //| -//| :class:`Shape` -- Represents a shape by defining its bounds on each row -//| ========================================================================== +//| :class:`Shape` -- Represents a shape by defining its bounds on each row +//| ========================================================================== //| -//| Represents any shape made by defining boundaries that may be mirrored. +//| Represents any shape made by defining boundaries that may be mirrored.""" //| -//| .. class:: Shape(width, height, *, mirror_x=False, mirror_y=False) +//| def __init__(self, width: int, height: int, *, mirror_x: bool = False, mirror_y: bool = False): +//| """Create a Shape object with the given fixed size. Each pixel is one bit and is stored by the +//| column boundaries of the shape on each row. Each row's boundary defaults to the full row. //| -//| Create a Shape object with the given fixed size. Each pixel is one bit and is stored by the -//| column boundaries of the shape on each row. Each row's boundary defaults to the full row. -//| -//| :param int width: The number of pixels wide -//| :param int height: The number of pixels high -//| :param bool mirror_x: When true the left boundary is mirrored to the right. -//| :param bool mirror_y: When true the top boundary is mirrored to the bottom. +//| :param int width: The number of pixels wide +//| :param int height: The number of pixels high +//| :param bool mirror_x: When true the left boundary is mirrored to the right. +//| :param bool mirror_y: When true the top boundary is mirrored to the bottom.""" +//| ... //| STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_width, ARG_height, ARG_mirror_x, ARG_mirror_y }; @@ -83,9 +84,9 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg } -//| .. method:: set_boundary(y, start_x, end_x) -//| -//| Loads pre-packed data into the given row. +//| def set_boundary(self, y: Any, start_x: Any, end_x: Any) -> Any: +//| """Loads pre-packed data into the given row.""" +//| ... //| STATIC mp_obj_t displayio_shape_obj_set_boundary(size_t n_args, const mp_obj_t *args) { (void) n_args; diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 288eb4b236..e7410e4b67 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -40,33 +40,33 @@ #include "shared-bindings/displayio/Shape.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: displayio +//| class TileGrid: +//| """.. currentmodule:: displayio //| -//| :class:`TileGrid` -- A grid of tiles sourced out of one bitmap -//| ========================================================================== +//| :class:`TileGrid` -- A grid of tiles sourced out of one bitmap +//| ========================================================================== //| -//| Position a grid of tiles sourced from a bitmap and pixel_shader combination. Multiple grids -//| can share bitmaps and pixel shaders. +//| Position a grid of tiles sourced from a bitmap and pixel_shader combination. Multiple grids +//| can share bitmaps and pixel shaders. //| -//| A single tile grid is also known as a Sprite. +//| A single tile grid is also known as a Sprite.""" //| -//| .. class:: TileGrid(bitmap, *, pixel_shader, width=1, height=1, tile_width=None, tile_height=None, default_tile=0, x=0, y=0) +//| def __init__(self, bitmap: displayio.Bitmap, *, pixel_shader: displayio.Palette, width: int = 1, height: int = 1, tile_width: int = None, tile_height: int = None, default_tile: int = 0, x: int = 0, y: int = 0): +//| """Create a TileGrid object. The bitmap is source for 2d pixels. The pixel_shader is used to +//| convert the value and its location to a display native pixel color. This may be a simple color +//| palette lookup, a gradient, a pattern or a color transformer. //| -//| Create a TileGrid object. The bitmap is source for 2d pixels. The pixel_shader is used to -//| convert the value and its location to a display native pixel color. This may be a simple color -//| palette lookup, a gradient, a pattern or a color transformer. +//| tile_width and tile_height match the height of the bitmap by default. //| -//| tile_width and tile_height match the height of the bitmap by default. -//| -//| :param displayio.Bitmap bitmap: The bitmap storing one or more tiles. -//| :param displayio.Palette pixel_shader: The pixel shader that produces colors from values -//| :param int width: Width of the grid in tiles. -//| :param int height: Height of the grid in tiles. -//| :param int tile_width: Width of a single tile in pixels. Defaults to the full Bitmap and must evenly divide into the Bitmap's dimensions. -//| :param int tile_height: Height of a single tile in pixels. Defaults to the full Bitmap and must evenly divide into the Bitmap's dimensions. -//| :param int default_tile: Default tile index to show. -//| :param int x: Initial x position of the left edge within the parent. -//| :param int y: Initial y position of the top edge within the parent. +//| :param displayio.Bitmap bitmap: The bitmap storing one or more tiles. +//| :param displayio.Palette pixel_shader: The pixel shader that produces colors from values +//| :param int width: Width of the grid in tiles. +//| :param int height: Height of the grid in tiles. +//| :param int tile_width: Width of a single tile in pixels. Defaults to the full Bitmap and must evenly divide into the Bitmap's dimensions. +//| :param int tile_height: Height of a single tile in pixels. Defaults to the full Bitmap and must evenly divide into the Bitmap's dimensions. +//| :param int default_tile: Default tile index to show. +//| :param int x: Initial x position of the left edge within the parent. +//| :param int y: Initial y position of the top edge within the parent.""" //| STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_pixel_shader, ARG_width, ARG_height, ARG_tile_width, ARG_tile_height, ARG_default_tile, ARG_x, ARG_y }; @@ -144,9 +144,8 @@ static displayio_tilegrid_t* native_tilegrid(mp_obj_t tilegrid_obj) { mp_obj_assert_native_inited(native_tilegrid); return MP_OBJ_TO_PTR(native_tilegrid); } -//| .. attribute:: hidden -//| -//| True when the TileGrid is hidden. This may be False even when a part of a hidden Group. +//| hidden: Any = ... +//| """True when the TileGrid is hidden. This may be False even when a part of a hidden Group.""" //| STATIC mp_obj_t displayio_tilegrid_obj_get_hidden(mp_obj_t self_in) { displayio_tilegrid_t *self = native_tilegrid(self_in); @@ -169,9 +168,8 @@ const mp_obj_property_t displayio_tilegrid_hidden_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: x -//| -//| X position of the left edge in the parent. +//| x: Any = ... +//| """X position of the left edge in the parent.""" //| STATIC mp_obj_t displayio_tilegrid_obj_get_x(mp_obj_t self_in) { displayio_tilegrid_t *self = native_tilegrid(self_in); @@ -195,9 +193,8 @@ const mp_obj_property_t displayio_tilegrid_x_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: y -//| -//| Y position of the top edge in the parent. +//| y: Any = ... +//| """Y position of the top edge in the parent.""" //| STATIC mp_obj_t displayio_tilegrid_obj_get_y(mp_obj_t self_in) { displayio_tilegrid_t *self = native_tilegrid(self_in); @@ -221,9 +218,8 @@ 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. +//| flip_x: Any = ... +//| """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); @@ -246,9 +242,8 @@ const mp_obj_property_t displayio_tilegrid_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. +//| flip_y: Any = ... +//| """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); @@ -272,10 +267,9 @@ const mp_obj_property_t displayio_tilegrid_flip_y_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. +//| transpose_xy: Any = ... +//| """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); @@ -298,9 +292,8 @@ const mp_obj_property_t displayio_tilegrid_transpose_xy_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: pixel_shader -//| -//| The pixel shader of the tilegrid. +//| pixel_shader: Any = ... +//| """The pixel shader of the tilegrid.""" //| STATIC mp_obj_t displayio_tilegrid_obj_get_pixel_shader(mp_obj_t self_in) { displayio_tilegrid_t *self = native_tilegrid(self_in); @@ -327,27 +320,27 @@ const mp_obj_property_t displayio_tilegrid_pixel_shader_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: __getitem__(index) +//| def __getitem__(self, index: Any) -> Any: +//| """Returns the tile index at the given index. The index can either be an x,y tuple or an int equal +//| to ``y * width + x``. //| -//| Returns the tile index at the given index. The index can either be an x,y tuple or an int equal -//| to ``y * width + x``. +//| This allows you to:: //| -//| This allows you to:: +//| print(grid[0])""" +//| ... //| -//| print(grid[0]) +//| def __setitem__(self, index: Any, tile_index: Any) -> Any: +//| """Sets the tile index at the given index. The index can either be an x,y tuple or an int equal +//| to ``y * width + x``. //| -//| .. method:: __setitem__(index, tile_index) +//| This allows you to:: //| -//| Sets the tile index at the given index. The index can either be an x,y tuple or an int equal -//| to ``y * width + x``. +//| grid[0] = 10 //| -//| This allows you to:: +//| or:: //| -//| grid[0] = 10 -//| -//| or:: -//| -//| grid[0,0] = 10 +//| grid[0,0] = 10""" +//| ... //| STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { displayio_tilegrid_t *self = native_tilegrid(self_in); diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index f783255930..37c0253292 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -43,7 +43,7 @@ #include "shared-bindings/displayio/Shape.h" #include "shared-bindings/displayio/TileGrid.h" -//| :mod:`displayio` --- Native display driving +//| """:mod:`displayio` --- Native display driving //| ========================================================================= //| //| .. module:: displayio @@ -69,18 +69,18 @@ //| Palette //| ParallelBus //| Shape -//| TileGrid +//| TileGrid""" //| -//| .. function:: release_displays() +//| def release_displays() -> Any: +//| """Releases any actively used displays so their busses and pins can be used again. This will also +//| release the builtin display on boards that have one. You will need to reinitialize it yourself +//| afterwards. This may take seconds to complete if an active EPaperDisplay is refreshing. //| -//| Releases any actively used displays so their busses and pins can be used again. This will also -//| release the builtin display on boards that have one. You will need to reinitialize it yourself -//| afterwards. This may take seconds to complete if an active EPaperDisplay is refreshing. -//| -//| Use this once in your code.py if you initialize a display. Place it right before the -//| initialization so the display is active as long as possible. +//| Use this once in your code.py if you initialize a display. Place it right before the +//| initialization so the display is active as long as possible.""" +//| ... //| STATIC mp_obj_t displayio_release_displays(void) { common_hal_displayio_release_displays(); From a3d5adb43c897d591baabaaf1e7ef83deedbd3ce Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 7 May 2020 11:56:46 -0400 Subject: [PATCH 045/216] Did _eve, fontio, framebufferio, and frequencyio --- shared-bindings/_eve/__init__.c | 441 +++++++++--------- shared-bindings/fontio/BuiltinFont.c | 38 +- shared-bindings/fontio/Glyph.c | 29 +- shared-bindings/fontio/__init__.c | 4 +- .../framebufferio/FramebufferDisplay.c | 109 +++-- shared-bindings/framebufferio/__init__.c | 4 +- shared-bindings/frequencyio/FrequencyIn.c | 106 ++--- shared-bindings/frequencyio/__init__.c | 4 +- 8 files changed, 371 insertions(+), 364 deletions(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 9bc790f5d1..0e78cea160 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -34,7 +34,20 @@ #include "shared-module/_eve/__init__.h" #include "shared-bindings/_eve/__init__.h" -//| :mod:`_eve` --- low-level BridgeTek EVE bindings + + + + + + + + + + + + + +//| """:mod:`_eve` --- low-level BridgeTek EVE bindings //| ================================================ //| //| .. module:: _eve @@ -43,7 +56,7 @@ //| //| The `_eve` module provides a class _EVE which //| contains methods for constructing EVE command -//| buffers and appending basic graphics commands. +//| buffers and appending basic graphics commands.""" //| typedef struct _mp_obj__EVE_t { @@ -63,11 +76,11 @@ STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); -//| .. method:: flush() -//| -//| Send any queued drawing commands directly to the hardware. +//| def flush(self, ) -> Any: +//| """Send any queued drawing commands directly to the hardware. //| -//| :param int width: The width of the grid in tiles, or 1 for sprites. +//| :param int width: The width of the grid in tiles, or 1 for sprites.""" +//| ... //| STATIC mp_obj_t _flush(mp_obj_t self) { common_hal__eve_flush(EVEHAL(self)); @@ -75,11 +88,11 @@ STATIC mp_obj_t _flush(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); -//| .. method:: cc(b) -//| -//| Append bytes to the command FIFO. +//| def cc(self, b: bytes) -> Any: +//| """Append bytes to the command FIFO. //| -//| :param bytes b: The bytes to add +//| :param bytes b: The bytes to add""" +//| ... //| STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { mp_buffer_info_t buffer_info; @@ -91,14 +104,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); //{ -//| .. method:: AlphaFunc(func, ref) -//| -//| Set the alpha test function +//| def AlphaFunc(self, func: int, ref: int) -> Any: +//| """Set the alpha test function //| //| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7) //| :param int ref: specifies the reference value for the alpha test. Range 0-255. The initial value is 0 //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -109,14 +122,14 @@ STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); -//| .. method:: Begin(prim) -//| -//| Begin drawing a graphics primitive +//| def Begin(self, prim: int) -> Any: +//| """Begin drawing a graphics primitive //| //| :param int prim: graphics primitive. //| -//| Valid primitives are ``BITMAPS``, ``POINTS``, ``LINES``, ``LINE_STRIP``, ``EDGE_STRIP_R``, ``EDGE_STRIP_L``, ``EDGE_STRIP_A``, ``EDGE_STRIP_B`` and ``RECTS``. -//| +//| Valid primitives are ``BITMAPS``, ``POINTS``, ``LINES``, ``LINE_STRIP``, ``EDGE_STRIP_R``, ``EDGE_STRIP_L``, ``EDGE_STRIP_A``, ``EDGE_STRIP_B`` and ``RECTS``.""" +//| ... +//| STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { uint32_t prim = mp_obj_get_int_truncated(a0); @@ -125,11 +138,11 @@ STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); -//| .. method:: BitmapExtFormat(format) +//| def BitmapExtFormat(self, format: int) -> Any: +//| """Set the bitmap format //| -//| Set the bitmap format -//| -//| :param int format: bitmap pixel format. +//| :param int format: bitmap pixel format.""" +//| ... //| STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { @@ -139,13 +152,13 @@ STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); -//| .. method:: BitmapHandle(handle) -//| -//| Set the bitmap handle +//| def BitmapHandle(self, handle: int) -> Any: +//| """Set the bitmap handle //| //| :param int handle: bitmap handle. Range 0-31. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) { @@ -155,12 +168,12 @@ STATIC mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); -//| .. method:: BitmapLayoutH(linestride, height) -//| -//| Set the source bitmap memory format and layout for the current handle. high bits for large bitmaps +//| def BitmapLayoutH(self, linestride: int, height: int) -> Any: +//| """Set the source bitmap memory format and layout for the current handle. high bits for large bitmaps //| //| :param int linestride: high part of bitmap line stride, in bytes. Range 0-7 -//| :param int height: high part of bitmap height, in lines. Range 0-3 +//| :param int height: high part of bitmap height, in lines. Range 0-3""" +//| ... //| STATIC mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -171,13 +184,13 @@ STATIC mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); -//| .. method:: BitmapLayout(format, linestride, height) -//| -//| Set the source bitmap memory format and layout for the current handle +//| def BitmapLayout(self, format: int, linestride: int, height: int) -> Any: +//| """Set the source bitmap memory format and layout for the current handle //| //| :param int format: bitmap pixel format, or GLFORMAT to use BITMAP_EXT_FORMAT instead. Range 0-31 //| :param int linestride: bitmap line stride, in bytes. Range 0-1023 -//| :param int height: bitmap height, in lines. Range 0-511 +//| :param int height: bitmap height, in lines. Range 0-511""" +//| ... //| STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { @@ -189,12 +202,12 @@ STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout); -//| .. method:: BitmapSizeH(width, height) -//| -//| Set the screen drawing of bitmaps for the current handle. high bits for large bitmaps +//| def BitmapSizeH(self, width: int, height: int) -> Any: +//| """Set the screen drawing of bitmaps for the current handle. high bits for large bitmaps //| //| :param int width: high part of drawn bitmap width, in pixels. Range 0-3 -//| :param int height: high part of drawn bitmap height, in pixels. Range 0-3 +//| :param int height: high part of drawn bitmap height, in pixels. Range 0-3""" +//| ... //| STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -205,15 +218,15 @@ STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); -//| .. method:: BitmapSize(filter, wrapx, wrapy, width, height) -//| -//| Set the screen drawing of bitmaps for the current handle +//| def BitmapSize(self, filter: int, wrapx: int, wrapy: int, width: int, height: int) -> Any: +//| """Set the screen drawing of bitmaps for the current handle //| //| :param int filter: bitmap filtering mode, one of ``NEAREST`` or ``BILINEAR``. Range 0-1 //| :param int wrapx: bitmap :math:`x` wrap mode, one of ``REPEAT`` or ``BORDER``. Range 0-1 //| :param int wrapy: bitmap :math:`y` wrap mode, one of ``REPEAT`` or ``BORDER``. Range 0-1 //| :param int width: drawn bitmap width, in pixels. Range 0-511 -//| :param int height: drawn bitmap height, in pixels. Range 0-511 +//| :param int height: drawn bitmap height, in pixels. Range 0-511""" +//| ... //| STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { @@ -227,11 +240,11 @@ STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); -//| .. method:: BitmapSource(addr) +//| def BitmapSource(self, addr: int) -> Any: +//| """Set the source address for bitmap graphics //| -//| Set the source address for bitmap graphics -//| -//| :param int addr: Bitmap start address, pixel-aligned. May be in SRAM or flash. Range 0-16777215 +//| :param int addr: Bitmap start address, pixel-aligned. May be in SRAM or flash. Range 0-16777215""" +//| ... //| STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { @@ -241,14 +254,14 @@ STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); -//| .. method:: BitmapSwizzle(r, g, b, a) -//| -//| Set the source for the r,g,b and a channels of a bitmap +//| def BitmapSwizzle(self, r: int, g: int, b: int, a: int) -> Any: +//| """Set the source for the r,g,b and a channels of a bitmap //| //| :param int r: red component source channel. Range 0-7 //| :param int g: green component source channel. Range 0-7 //| :param int b: blue component source channel. Range 0-7 -//| :param int a: alpha component source channel. Range 0-7 +//| :param int a: alpha component source channel. Range 0-7""" +//| ... //| STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { @@ -261,16 +274,16 @@ STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle); -//| .. method:: BitmapTransformA(p, v) -//| -//| Set the :math:`a` component of the bitmap transform matrix +//| def BitmapTransformA(self, p: Any, v: int) -> Any: +//| """Set the :math:`a` component of the bitmap transform matrix //| //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`a` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 //| //| The initial value is **p** = 0, **v** = 256. This represents the value 1.0. //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -281,16 +294,16 @@ STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); -//| .. method:: BitmapTransformB(p, v) -//| -//| Set the :math:`b` component of the bitmap transform matrix +//| def BitmapTransformB(self, p: Any, v: int) -> Any: +//| """Set the :math:`b` component of the bitmap transform matrix //| //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`b` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 //| //| The initial value is **p** = 0, **v** = 0. This represents the value 0.0. //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -301,13 +314,13 @@ STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); -//| .. method:: BitmapTransformC(v) -//| -//| Set the :math:`c` component of the bitmap transform matrix +//| def BitmapTransformC(self, v: int) -> Any: +//| """Set the :math:`c` component of the bitmap transform matrix //| //| :param int v: The :math:`c` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0) { @@ -317,16 +330,16 @@ STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformc_obj, _bitmaptransformc); -//| .. method:: BitmapTransformD(p, v) -//| -//| Set the :math:`d` component of the bitmap transform matrix +//| def BitmapTransformD(self, p: Any, v: int) -> Any: +//| """Set the :math:`d` component of the bitmap transform matrix //| //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`d` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 //| //| The initial value is **p** = 0, **v** = 0. This represents the value 0.0. //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -337,16 +350,16 @@ STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); -//| .. method:: BitmapTransformE(p, v) -//| -//| Set the :math:`e` component of the bitmap transform matrix +//| def BitmapTransformE(self, p: Any, v: int) -> Any: +//| """Set the :math:`e` component of the bitmap transform matrix //| //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`e` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 //| //| The initial value is **p** = 0, **v** = 256. This represents the value 1.0. //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -357,13 +370,13 @@ STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); -//| .. method:: BitmapTransformF(v) -//| -//| Set the :math:`f` component of the bitmap transform matrix +//| def BitmapTransformF(self, v: int) -> Any: +//| """Set the :math:`f` component of the bitmap transform matrix //| //| :param int v: The :math:`f` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0) { @@ -373,14 +386,14 @@ STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformf_obj, _bitmaptransformf); -//| .. method:: BlendFunc(src, dst) -//| -//| Set pixel arithmetic +//| def BlendFunc(self, src: int, dst: int) -> Any: +//| """Set pixel arithmetic //| //| :param int src: specifies how the source blending factor is computed. One of ``ZERO``, ``ONE``, ``SRC_ALPHA``, ``DST_ALPHA``, ``ONE_MINUS_SRC_ALPHA`` or ``ONE_MINUS_DST_ALPHA``. Range 0-7. The initial value is SRC_ALPHA(2) //| :param int dst: specifies how the destination blending factor is computed, one of the same constants as **src**. Range 0-7. The initial value is ONE_MINUS_SRC_ALPHA(4) //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -391,11 +404,11 @@ STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); -//| .. method:: Call(dest) +//| def Call(self, dest: int) -> Any: +//| """Execute a sequence of commands at another location in the display list //| -//| Execute a sequence of commands at another location in the display list -//| -//| :param int dest: display list address. Range 0-65535 +//| :param int dest: display list address. Range 0-65535""" +//| ... //| STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { @@ -405,13 +418,13 @@ STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); -//| .. method:: Cell(cell) -//| -//| Set the bitmap cell number for the vertex2f command +//| def Cell(self, cell: int) -> Any: +//| """Set the bitmap cell number for the vertex2f command //| //| :param int cell: bitmap cell number. Range 0-127. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { @@ -421,13 +434,13 @@ STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); -//| .. method:: ClearColorA(alpha) -//| -//| Set clear value for the alpha channel +//| def ClearColorA(self, alpha: int) -> Any: +//| """Set clear value for the alpha channel //| //| :param int alpha: alpha value used when the color buffer is cleared. Range 0-255. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { @@ -437,15 +450,15 @@ STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); -//| .. method:: ClearColorRGB(red, green, blue) -//| -//| Set clear values for red, green and blue channels +//| def ClearColorRGB(self, red: int, green: int, blue: int) -> Any: +//| """Set clear values for red, green and blue channels //| //| :param int red: red value used when the color buffer is cleared. Range 0-255. The initial value is 0 //| :param int green: green value used when the color buffer is cleared. Range 0-255. The initial value is 0 //| :param int blue: blue value used when the color buffer is cleared. Range 0-255. The initial value is 0 //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { @@ -457,13 +470,13 @@ STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb); -//| .. method:: Clear(c, s, t) -//| -//| Clear buffers to preset values +//| def Clear(self, c: int, s: int, t: int) -> Any: +//| """Clear buffers to preset values //| //| :param int c: clear color buffer. Range 0-1 //| :param int s: clear stencil buffer. Range 0-1 -//| :param int t: clear tag buffer. Range 0-1 +//| :param int t: clear tag buffer. Range 0-1""" +//| ... //| STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { @@ -475,13 +488,13 @@ STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear); -//| .. method:: ClearStencil(s) -//| -//| Set clear value for the stencil buffer +//| def ClearStencil(self, s: int) -> Any: +//| """Set clear value for the stencil buffer //| //| :param int s: value used when the stencil buffer is cleared. Range 0-255. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { @@ -491,13 +504,12 @@ STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); -//| .. method:: ClearTag(s) -//| -//| Set clear value for the tag buffer +//| def ClearTag(self, s: int) -> Any: +//| """Set clear value for the tag buffer //| //| :param int s: value used when the tag buffer is cleared. Range 0-255. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" //| STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { @@ -507,13 +519,13 @@ STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); -//| .. method:: ColorA(alpha) -//| -//| Set the current color alpha +//| def ColorA(self, alpha: int) -> Any: +//| """Set the current color alpha //| //| :param int alpha: alpha for the current color. Range 0-255. The initial value is 255 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { @@ -523,16 +535,16 @@ STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); -//| .. method:: ColorMask(r, g, b, a) -//| -//| Enable and disable writing of frame buffer color components +//| def ColorMask(self, r: int, g: int, b: int, a: int) -> Any: +//| """Enable and disable writing of frame buffer color components //| //| :param int r: allow updates to the frame buffer red component. Range 0-1. The initial value is 1 //| :param int g: allow updates to the frame buffer green component. Range 0-1. The initial value is 1 //| :param int b: allow updates to the frame buffer blue component. Range 0-1. The initial value is 1 //| :param int a: allow updates to the frame buffer alpha component. Range 0-1. The initial value is 1 //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { @@ -545,15 +557,15 @@ STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); -//| .. method:: ColorRGB(red, green, blue) -//| -//| Set the drawing color +//| def ColorRGB(self, red: int, green: int, blue: int) -> Any: +//| """Set the drawing color //| //| :param int red: red value for the current color. Range 0-255. The initial value is 255 //| :param int green: green for the current color. Range 0-255. The initial value is 255 //| :param int blue: blue for the current color. Range 0-255. The initial value is 255 //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { @@ -565,9 +577,8 @@ STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); -//| .. method:: Display() -//| -//| End the display list +//| def Display(self, ) -> Any: ... +//| """End the display list""" //| STATIC mp_obj_t _display(mp_obj_t self) { @@ -577,12 +588,12 @@ STATIC mp_obj_t _display(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); -//| .. method:: End() +//| def End(self, ) -> Any: +//| """End drawing a graphics primitive //| -//| End drawing a graphics primitive +//| :meth:`Vertex2ii` and :meth:`Vertex2f` calls are ignored until the next :meth:`Begin`.""" +//| ... //| -//| :meth:`Vertex2ii` and :meth:`Vertex2f` calls are ignored until the next :meth:`Begin`. -//| STATIC mp_obj_t _end(mp_obj_t self) { @@ -591,11 +602,11 @@ STATIC mp_obj_t _end(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); -//| .. method:: Jump(dest) +//| def Jump(self, dest: int) -> Any: +//| """Execute commands at another location in the display list //| -//| Execute commands at another location in the display list -//| -//| :param int dest: display list address. Range 0-65535 +//| :param int dest: display list address. Range 0-65535""" +//| ... //| STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { @@ -605,13 +616,13 @@ STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); -//| .. method:: LineWidth(width) -//| -//| Set the width of rasterized lines +//| def LineWidth(self, width: int) -> Any: +//| """Set the width of rasterized lines //| //| :param int width: line width in :math:`1/16` pixel. Range 0-4095. The initial value is 16 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { @@ -621,11 +632,11 @@ STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); -//| .. method:: Macro(m) +//| def Macro(self, m: int) -> Any: +//| """Execute a single command from a macro register //| -//| Execute a single command from a macro register -//| -//| :param int m: macro register to read. Range 0-1 +//| :param int m: macro register to read. Range 0-1""" +//| ... //| STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { @@ -635,9 +646,9 @@ STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); -//| .. method:: Nop() -//| -//| No operation +//| def Nop(self, ) -> Any: +//| """No operation""" +//| ... //| STATIC mp_obj_t _nop(mp_obj_t self) { @@ -647,13 +658,13 @@ STATIC mp_obj_t _nop(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); -//| .. method:: PaletteSource(addr) -//| -//| Set the base address of the palette +//| def PaletteSource(self, addr: int) -> Any: +//| """Set the base address of the palette //| //| :param int addr: Address in graphics SRAM, 2-byte aligned. Range 0-4194303. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { @@ -663,13 +674,13 @@ STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); -//| .. method:: PointSize(size) -//| -//| Set the radius of rasterized points +//| def PointSize(self, size: int) -> Any: +//| """Set the radius of rasterized points //| //| :param int size: point radius in :math:`1/16` pixel. Range 0-8191. The initial value is 16 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { @@ -679,9 +690,9 @@ STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); -//| .. method:: RestoreContext() -//| -//| Restore the current graphics context from the context stack +//| def RestoreContext(self, ) -> Any: +//| """Restore the current graphics context from the context stack""" +//| ... //| STATIC mp_obj_t _restorecontext(mp_obj_t self) { @@ -691,9 +702,9 @@ STATIC mp_obj_t _restorecontext(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); -//| .. method:: Return() -//| -//| Return from a previous call command +//| def Return(self, ) -> Any: +//| """Return from a previous call command""" +//| ... //| STATIC mp_obj_t _return(mp_obj_t self) { @@ -703,9 +714,9 @@ STATIC mp_obj_t _return(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); -//| .. method:: SaveContext() -//| -//| Push the current graphics context on the context stack +//| def SaveContext(self, ) -> Any: +//| """Push the current graphics context on the context stack""" +//| ... //| STATIC mp_obj_t _savecontext(mp_obj_t self) { @@ -715,14 +726,14 @@ STATIC mp_obj_t _savecontext(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); -//| .. method:: ScissorSize(width, height) -//| -//| Set the size of the scissor clip rectangle +//| def ScissorSize(self, width: int, height: int) -> Any: +//| """Set the size of the scissor clip rectangle //| //| :param int width: The width of the scissor clip rectangle, in pixels. Range 0-4095. The initial value is hsize //| :param int height: The height of the scissor clip rectangle, in pixels. Range 0-4095. The initial value is 2048 //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -733,14 +744,14 @@ STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); -//| .. method:: ScissorXY(x, y) -//| -//| Set the top left corner of the scissor clip rectangle +//| def ScissorXY(self, x: int, y: int) -> Any: +//| """Set the top left corner of the scissor clip rectangle //| //| :param int x: The :math:`x` coordinate of the scissor clip rectangle, in pixels. Range 0-2047. The initial value is 0 //| :param int y: The :math:`y` coordinate of the scissor clip rectangle, in pixels. Range 0-2047. The initial value is 0 //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -751,15 +762,15 @@ STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); -//| .. method:: StencilFunc(func, ref, mask) -//| -//| Set function and reference value for stencil testing +//| def StencilFunc(self, func: int, ref: int, mask: int) -> Any: +//| """Set function and reference value for stencil testing //| //| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7) //| :param int ref: specifies the reference value for the stencil test. Range 0-255. The initial value is 0 //| :param int mask: specifies a mask that is ANDed with the reference value and the stored stencil value. Range 0-255. The initial value is 255 //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { @@ -771,13 +782,13 @@ STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); -//| .. method:: StencilMask(mask) -//| -//| Control the writing of individual bits in the stencil planes +//| def StencilMask(self, mask: int) -> Any: +//| """Control the writing of individual bits in the stencil planes //| //| :param int mask: the mask used to enable writing stencil bits. Range 0-255. The initial value is 255 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { @@ -787,14 +798,14 @@ STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); -//| .. method:: StencilOp(sfail, spass) -//| -//| Set stencil test actions +//| def StencilOp(self, sfail: int, spass: int) -> Any: +//| """Set stencil test actions //| //| :param int sfail: specifies the action to take when the stencil test fails, one of ``KEEP``, ``ZERO``, ``REPLACE``, ``INCR``, ``INCR_WRAP``, ``DECR``, ``DECR_WRAP``, and ``INVERT``. Range 0-7. The initial value is KEEP(1) //| :param int spass: specifies the action to take when the stencil test passes, one of the same constants as **sfail**. Range 0-7. The initial value is KEEP(1) //| -//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { @@ -805,13 +816,13 @@ STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); -//| .. method:: TagMask(mask) -//| -//| Control the writing of the tag buffer +//| def TagMask(self, mask: int) -> Any: +//| """Control the writing of the tag buffer //| //| :param int mask: allow updates to the tag buffer. Range 0-1. The initial value is 1 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { @@ -821,13 +832,13 @@ STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); -//| .. method:: Tag(s) -//| -//| Set the current tag value +//| def Tag(self, s: int) -> Any: +//| """Set the current tag value //| //| :param int s: tag value. Range 0-255. The initial value is 255 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { @@ -837,13 +848,13 @@ STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); -//| .. method:: VertexTranslateX(x) -//| -//| Set the vertex transformation's x translation component +//| def VertexTranslateX(self, x: int) -> Any: +//| """Set the vertex transformation's x translation component //| //| :param int x: signed x-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { @@ -853,13 +864,13 @@ STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); -//| .. method:: VertexTranslateY(y) -//| -//| Set the vertex transformation's y translation component +//| def VertexTranslateY(self, y: int) -> Any: +//| """Set the vertex transformation's y translation component //| //| :param int y: signed y-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| @@ -870,13 +881,13 @@ STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); -//| .. method:: VertexFormat(frac) -//| -//| Set the precision of vertex2f coordinates +//| def VertexFormat(self, frac: int) -> Any: +//| """Set the precision of vertex2f coordinates //| //| :param int frac: Number of fractional bits in X,Y coordinates, 0-4. Range 0-7. The initial value is 4 //| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... //| STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { @@ -886,15 +897,15 @@ STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); -//| .. method:: Vertex2ii(x, y, handle, cell) -//| -//| :param int x: x-coordinate in pixels. Range 0-511 +//| def Vertex2ii(self, x: int, y: int, handle: int, cell: int) -> Any: +//| """:param int x: x-coordinate in pixels. Range 0-511 //| :param int y: y-coordinate in pixels. Range 0-511 //| :param int handle: bitmap handle. Range 0-31 //| :param int cell: cell number. Range 0-127 //| -//| This method is an alternative to :meth:`Vertex2f`. -//| +//| This method is an alternative to :meth:`Vertex2f`.""" +//| ... +//| STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { uint32_t x = mp_obj_get_int_truncated(args[1]); @@ -961,12 +972,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); // Hand-written functions { -//| .. method:: Vertex2f(b) -//| -//| Draw a point. +//| def Vertex2f(self, b: Any) -> Any: +//| """Draw a point. //| //| :param float x: pixel x-coordinate -//| :param float y: pixel y-coordinate +//| :param float y: pixel y-coordinate""" +//| ... //| STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { mp_float_t x = mp_obj_get_float(a0); @@ -980,14 +991,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); #define ADD_X(self, x) \ common_hal__eve_add(EVEHAL(self), sizeof(x), &(x)); -//| .. method:: cmd0(n) -//| -//| Append the command word n to the FIFO +//| def cmd0(self, n: int) -> Any: +//| """Append the command word n to the FIFO //| //| :param int n: The command code //| //| This method is used by the ``eve`` module to efficiently add -//| commands to the FIFO. +//| commands to the FIFO.""" +//| ... //| STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { @@ -997,9 +1008,8 @@ STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); -//| .. method:: cmd(n, fmt, args) -//| -//| Append a command packet to the FIFO. +//| def cmd(self, n: int, fmt: str, args: tuple) -> Any: +//| """Append a command packet to the FIFO. //| //| :param int n: The command code //| :param str fmt: The command format `struct` layout @@ -1008,7 +1018,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); //| Supported format codes: h, H, i, I. //| //| This method is used by the ``eve`` module to efficiently add -//| commands to the FIFO. +//| commands to the FIFO.""" +//| ... //| STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { mp_obj_t self = args[0]; diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index 74bc4d29ea..f60c9e36c7 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -36,25 +36,25 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: fontio +//| class BuiltinFont: +//| """.. currentmodule:: fontio //| -//| :class:`BuiltinFont` -- A font built into CircuitPython -//| ========================================================================================= +//| :class:`BuiltinFont` -- A font built into CircuitPython +//| ========================================================================================= //| -//| A font built into CircuitPython. +//| A font built into CircuitPython.""" //| -//| .. class:: BuiltinFont() -//| -//| Creation not supported. Available fonts are defined when CircuitPython is built. See the -//| `Adafruit_CircuitPython_Bitmap_Font `_ -//| library for dynamically loaded fonts. +//| def __init__(self, ): +//| """Creation not supported. Available fonts are defined when CircuitPython is built. See the +//| `Adafruit_CircuitPython_Bitmap_Font `_ +//| library for dynamically loaded fonts.""" +//| ... //| -//| .. attribute:: bitmap -//| -//| Bitmap containing all font glyphs starting with ASCII and followed by unicode. Use +//| bitmap: Any = ... +//| """Bitmap containing all font glyphs starting with ASCII and followed by unicode. Use //| `get_glyph` in most cases. This is useful for use with `displayio.TileGrid` and -//| `terminalio.Terminal`. +//| `terminalio.Terminal`.""" //| STATIC mp_obj_t fontio_builtinfont_obj_get_bitmap(mp_obj_t self_in) { fontio_builtinfont_t *self = MP_OBJ_TO_PTR(self_in); @@ -69,9 +69,9 @@ const mp_obj_property_t fontio_builtinfont_bitmap_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: get_bounding_box() -//| -//| Returns the maximum bounds of all glyphs in the font in a tuple of two values: width, height. +//| def get_bounding_box(self, ) -> Any: +//| """Returns the maximum bounds of all glyphs in the font in a tuple of two values: width, height.""" +//| ... //| STATIC mp_obj_t fontio_builtinfont_obj_get_bounding_box(mp_obj_t self_in) { fontio_builtinfont_t *self = MP_OBJ_TO_PTR(self_in); @@ -81,9 +81,9 @@ STATIC mp_obj_t fontio_builtinfont_obj_get_bounding_box(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(fontio_builtinfont_get_bounding_box_obj, fontio_builtinfont_obj_get_bounding_box); -//| .. method:: get_glyph(codepoint) -//| -//| Returns a `fontio.Glyph` for the given codepoint or None if no glyph is available. +//| def get_glyph(self, codepoint: Any) -> Any: +//| """Returns a `fontio.Glyph` for the given codepoint or None if no glyph is available.""" +//| ... //| STATIC mp_obj_t fontio_builtinfont_obj_get_glyph(mp_obj_t self_in, mp_obj_t codepoint_obj) { fontio_builtinfont_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/fontio/Glyph.c b/shared-bindings/fontio/Glyph.c index a232841521..6235dbc46f 100644 --- a/shared-bindings/fontio/Glyph.c +++ b/shared-bindings/fontio/Glyph.c @@ -28,23 +28,24 @@ #include -//| .. currentmodule:: fontio +//| class Glyph: +//| """.. currentmodule:: fontio //| -//| :class:`Glyph` -- Storage of glyph info -//| ========================================================================== +//| :class:`Glyph` -- Storage of glyph info +//| ==========================================================================""" //| -//| .. class:: Glyph(bitmap, tile_index, width, height, dx, dy, shift_x, shift_y) +//| def __init__(self, bitmap: displayio.Bitmap, tile_index: int, width: int, height: int, dx: int, dy: int, shift_x: int, shift_y: int): +//| """Named tuple used to capture a single glyph and its attributes. //| -//| Named tuple used to capture a single glyph and its attributes. -//| -//| :param displayio.Bitmap bitmap: the bitmap including the glyph -//| :param int tile_index: the tile index within the bitmap -//| :param int width: the width of the glyph's bitmap -//| :param int height: the height of the glyph's bitmap -//| :param int dx: x adjustment to the bitmap's position -//| :param int dy: y adjustment to the bitmap's position -//| :param int shift_x: the x difference to the next glyph -//| :param int shift_y: the y difference to the next glyph +//| :param displayio.Bitmap bitmap: the bitmap including the glyph +//| :param int tile_index: the tile index within the bitmap +//| :param int width: the width of the glyph's bitmap +//| :param int height: the height of the glyph's bitmap +//| :param int dx: x adjustment to the bitmap's position +//| :param int dy: y adjustment to the bitmap's position +//| :param int shift_x: the x difference to the next glyph +//| :param int shift_y: the y difference to the next glyph""" +//| ... //| const mp_obj_namedtuple_type_t fontio_glyph_type = { .base = { diff --git a/shared-bindings/fontio/__init__.c b/shared-bindings/fontio/__init__.c index cd0f5ab0f8..478fc18068 100644 --- a/shared-bindings/fontio/__init__.c +++ b/shared-bindings/fontio/__init__.c @@ -33,7 +33,7 @@ #include "shared-bindings/fontio/BuiltinFont.h" #include "shared-bindings/fontio/Glyph.h" -//| :mod:`fontio` --- Core font related data structures +//| """:mod:`fontio` --- Core font related data structures //| ========================================================================= //| //| .. module:: fontio @@ -48,7 +48,7 @@ //| :maxdepth: 3 //| //| BuiltinFont -//| Glyph +//| Glyph""" //| STATIC const mp_rom_map_elem_t fontio_module_globals_table[] = { diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index 9ff6cc12d7..5e63b988e3 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -40,23 +40,24 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: framebufferio +//| class FramebufferDisplay: +//| """.. currentmodule:: framebufferio //| -//| :class:`FramebufferDisplay` -- Manage updating a display with framebuffer in RAM -//| ================================================================================ +//| :class:`FramebufferDisplay` -- Manage updating a display with framebuffer in RAM +//| ================================================================================ //| -//| This initializes a display and connects it into CircuitPython. Unlike other -//| objects in CircuitPython, Display objects live until `displayio.release_displays()` -//| is called. This is done so that CircuitPython can use the display itself. +//| This initializes a display and connects it into CircuitPython. Unlike other +//| objects in CircuitPython, Display objects live until `displayio.release_displays()` +//| is called. This is done so that CircuitPython can use the display itself.""" //| -//| .. class:: FramebufferDisplay(framebuffer, *, rotation=0, auto_refresh=True) +//| def __init__(self, framebuffer: Any, *, rotation: int = 0, auto_refresh: bool = True): +//| """Create a Display object with the given framebuffer (a buffer, array, ulab.array, etc) //| -//| Create a Display object with the given framebuffer (a buffer, array, ulab.array, etc) -//| -//| :param framebuffer: The framebuffer that the display is connected to -//| :type framebuffer: any core object implementing the framebuffer protocol -//| :param bool auto_refresh: Automatically refresh the screen -//| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270) +//| :param framebuffer: The framebuffer that the display is connected to +//| :type framebuffer: any core object implementing the framebuffer protocol +//| :param bool auto_refresh: Automatically refresh the screen +//| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270)""" +//| ... //| STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_framebuffer, ARG_rotation, ARG_auto_refresh, NUM_ARGS }; @@ -96,12 +97,12 @@ static framebufferio_framebufferdisplay_obj_t* native_display(mp_obj_t display_o return MP_OBJ_TO_PTR(native_display); } -//| .. method:: show(group) +//| def show(self, group: Group) -> Any: +//| """Switches to displaying the given group of layers. When group is None, the default +//| CircuitPython terminal will be shown. //| -//| Switches to displaying the given group of layers. When group is None, the default -//| CircuitPython terminal will be shown. -//| -//| :param Group group: The group to show. +//| :param Group group: The group to show.""" +//| ... //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_show(mp_obj_t self_in, mp_obj_t group_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); @@ -118,21 +119,21 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_show(mp_obj_t self_in, mp_o } MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_show_obj, framebufferio_framebufferdisplay_obj_show); -//| .. method:: refresh(*, target_frames_per_second=60, minimum_frames_per_second=1) +//| def refresh(self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1) -> Any: +//| """When auto refresh is off, waits for the target frame rate and then refreshes the display, +//| returning True. If the call has taken too long since the last refresh call for the given +//| target frame rate, then the refresh returns False immediately without updating the screen to +//| hopefully help getting caught up. //| -//| When auto refresh is off, waits for the target frame rate and then refreshes the display, -//| returning True. If the call has taken too long since the last refresh call for the given -//| target frame rate, then the refresh returns False immediately without updating the screen to -//| hopefully help getting caught up. +//| If the time since the last successful refresh is below the minimum frame rate, then an +//| exception will be raised. Set minimum_frames_per_second to 0 to disable. //| -//| If the time since the last successful refresh is below the minimum frame rate, then an -//| exception will be raised. Set minimum_frames_per_second to 0 to disable. +//| When auto refresh is on, updates the display immediately. (The display will also update +//| without calls to this.) //| -//| When auto refresh is on, updates the display immediately. (The display will also update -//| without calls to this.) -//| -//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. -//| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second. +//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated. +//| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.""" +//| ... //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second }; @@ -153,9 +154,8 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_refresh(size_t n_args, cons } MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_refresh_obj, 1, framebufferio_framebufferdisplay_obj_refresh); -//| .. attribute:: auto_refresh -//| -//| True when the display is refreshed automatically. +//| auto_refresh: Any = ... +//| """True when the display is refreshed automatically.""" //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_auto_refresh(mp_obj_t self_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); @@ -179,11 +179,10 @@ const mp_obj_property_t framebufferio_framebufferdisplay_auto_refresh_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: brightness -//| -//| The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When +//| brightness: Any = ... +//| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When //| `auto_brightness` is True, the value of `brightness` will change automatically. -//| If `brightness` is set, `auto_brightness` will be disabled and will be set to False. +//| If `brightness` is set, `auto_brightness` will be disabled and will be set to False.""" //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_brightness(mp_obj_t self_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); @@ -217,12 +216,11 @@ const mp_obj_property_t framebufferio_framebufferdisplay_brightness_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: auto_brightness -//| -//| True when the display brightness is adjusted automatically, based on an ambient +//| auto_brightness: Any = ... +//| """True when the display brightness is adjusted automatically, based on an ambient //| light sensor or other method. Note that some displays may have this set to True by default, //| but not actually implement automatic brightness adjustment. `auto_brightness` is set to False -//| if `brightness` is set manually. +//| if `brightness` is set manually.""" //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_auto_brightness(mp_obj_t self_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); @@ -249,9 +247,8 @@ const mp_obj_property_t framebufferio_framebufferdisplay_auto_brightness_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: width -//| -//| Gets the width of the framebuffer +//| width: Any = ... +//| """Gets the width of the framebuffer""" //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_width(mp_obj_t self_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); @@ -266,9 +263,8 @@ const mp_obj_property_t framebufferio_framebufferdisplay_width_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: height -//| -//| Gets the height of the framebuffer +//| height: Any = ... +//| """Gets the height of the framebuffer""" //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_height(mp_obj_t self_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); @@ -283,9 +279,8 @@ const mp_obj_property_t framebufferio_framebufferdisplay_height_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: rotation -//| -//| The rotation of the display as an int in degrees. +//| rotation: Any = ... +//| """The rotation of the display as an int in degrees.""" //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_rotation(mp_obj_t self_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); @@ -307,9 +302,8 @@ const mp_obj_property_t framebufferio_framebufferdisplay_rotation_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: framebuffer -//| -//| The framebuffer being used by the display +//| framebuffer: Any = ... +//| """The framebuffer being used by the display""" //| //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_framebuffer(mp_obj_t self_in) { @@ -326,12 +320,13 @@ const mp_obj_property_t framebufferio_framebufferframebuffer_obj = { }; -//| .. method:: fill_row(y, buffer) +//| def fill_row(self, y: int, buffer: bytearray) -> Any: +//| """Extract the pixels from a single row //| -//| Extract the pixels from a single row +//| :param int y: The top edge of the area +//| :param bytearray buffer: The buffer in which to place the pixel data""" +//| ... //| -//| :param int y: The top edge of the area -//| :param bytearray buffer: The buffer in which to place the pixel data STATIC mp_obj_t framebufferio_framebufferdisplay_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_y, ARG_buffer }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/framebufferio/__init__.c b/shared-bindings/framebufferio/__init__.c index 88f69bb2c3..50725c5150 100644 --- a/shared-bindings/framebufferio/__init__.c +++ b/shared-bindings/framebufferio/__init__.c @@ -28,7 +28,7 @@ #include "shared-bindings/framebufferio/__init__.h" #include "shared-bindings/framebufferio/FramebufferDisplay.h" -//| :mod:`framebufferio` --- Native framebuffer display driving +//| """:mod:`framebufferio` --- Native framebuffer display driving //| ========================================================================= //| //| .. module:: framebufferio @@ -46,7 +46,7 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| FramebufferDisplay +//| FramebufferDisplay""" //| #if CIRCUITPY_FRAMEBUFFERIO diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index 6743f87063..270fa87c31 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -35,43 +35,44 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: frequencyio +//| class FrequencyIn: +//| """.. currentmodule:: frequencyio //| -//| :class:`FrequencyIn` -- Read a frequency signal -//| ======================================================== +//| :class:`FrequencyIn` -- Read a frequency signal +//| ======================================================== //| -//| FrequencyIn is used to measure the frequency, in hertz, of a digital signal -//| on an incoming pin. Accuracy has shown to be within 10%, if not better. It -//| is recommended to utilize an average of multiple samples to smooth out readings. +//| FrequencyIn is used to measure the frequency, in hertz, of a digital signal +//| on an incoming pin. Accuracy has shown to be within 10%, if not better. It +//| is recommended to utilize an average of multiple samples to smooth out readings. //| -//| Frequencies below 1KHz are not currently detectable. +//| Frequencies below 1KHz are not currently detectable. //| -//| FrequencyIn will not determine pulse width (use ``PulseIn``). +//| FrequencyIn will not determine pulse width (use ``PulseIn``).""" //| -//| .. class:: FrequencyIn(pin, capture_period=10) +//| def __init__(self, pin: microcontroller.Pin, capture_period: int = 10): +//| """Create a FrequencyIn object associated with the given pin. //| -//| Create a FrequencyIn object associated with the given pin. +//| :param ~microcontroller.Pin pin: Pin to read frequency from. +//| :param int capture_period: Keyword argument to set the measurement period, in +//| milliseconds. Default is 10ms; range is 1ms - 500ms. //| -//| :param ~microcontroller.Pin pin: Pin to read frequency from. -//| :param int capture_period: Keyword argument to set the measurement period, in -//| milliseconds. Default is 10ms; range is 1ms - 500ms. +//| Read the incoming frequency from a pin:: //| -//| Read the incoming frequency from a pin:: +//| import frequencyio +//| import board //| -//| import frequencyio -//| import board +//| frequency = frequencyio.FrequencyIn(board.D11) //| -//| frequency = frequencyio.FrequencyIn(board.D11) +//| # Loop while printing the detected frequency +//| while True: +//| print(frequency.value) //| -//| # Loop while printing the detected frequency -//| while True: -//| print(frequency.value) -//| -//| # Optional clear() will reset the value -//| # to zero. Without this, if the incoming -//| # signal stops, the last reading will remain -//| # as the value. -//| frequency.clear() +//| # Optional clear() will reset the value +//| # to zero. Without this, if the incoming +//| # signal stops, the last reading will remain +//| # as the value. +//| frequency.clear()""" +//| ... //| STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -96,9 +97,9 @@ STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the FrequencyIn and releases any hardware resources for reuse. +//| def deinit(self, ) -> Any: +//| """Deinitialises the FrequencyIn and releases any hardware resources for reuse.""" +//| ... //| STATIC mp_obj_t frequencyio_frequencyin_deinit(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -113,16 +114,16 @@ STATIC void check_for_deinit(frequencyio_frequencyin_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t frequencyio_frequencyin_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -131,9 +132,9 @@ STATIC mp_obj_t frequencyio_frequencyin_obj___exit__(size_t n_args, const mp_obj } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(frequencyio_frequencyin___exit___obj, 4, 4, frequencyio_frequencyin_obj___exit__); -//| .. method:: pause() -//| -//| Pause frequency capture. +//| def pause(self, ) -> Any: +//| """Pause frequency capture.""" +//| ... //| STATIC mp_obj_t frequencyio_frequencyin_obj_pause(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -144,9 +145,9 @@ STATIC mp_obj_t frequencyio_frequencyin_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_pause_obj, frequencyio_frequencyin_obj_pause); -//| .. method:: resume() -//| -//| Resumes frequency capture. +//| def resume(self, ) -> Any: +//| """Resumes frequency capture.""" +//| ... //| STATIC mp_obj_t frequencyio_frequencyin_obj_resume(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -157,9 +158,9 @@ STATIC mp_obj_t frequencyio_frequencyin_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_resume_obj, frequencyio_frequencyin_obj_resume); -//| .. method:: clear() -//| -//| Clears the last detected frequency capture value. +//| def clear(self, ) -> Any: +//| """Clears the last detected frequency capture value.""" +//| ... //| STATIC mp_obj_t frequencyio_frequencyin_obj_clear(mp_obj_t self_in) { @@ -171,14 +172,13 @@ STATIC mp_obj_t frequencyio_frequencyin_obj_clear(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_clear_obj, frequencyio_frequencyin_obj_clear); -//| .. attribute:: capture_period -//| -//| The capture measurement period. Lower incoming frequencies will be measured +//| capture_period: Any = ... +//| """The capture measurement period. Lower incoming frequencies will be measured //| more accurately with longer capture periods. Higher frequencies are more //| accurate with shorter capture periods. //| -//| .. note:: When setting a new ``capture_period``, all previous capture information is -//| cleared with a call to ``clear()``. +//| .. note:: When setting a new ``capture_period``, all previous capture information is +//| cleared with a call to ``clear()``.""" //| 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); @@ -204,9 +204,9 @@ const mp_obj_property_t frequencyio_frequencyin_capture_period_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: __get__(index) -//| -//| Returns the value of the last frequency captured. +//| def __get__(self, index: Any) -> Any: +//| """Returns the value of the last frequency captured.""" +//| ... //| 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); diff --git a/shared-bindings/frequencyio/__init__.c b/shared-bindings/frequencyio/__init__.c index 48a0268249..219d5f6452 100644 --- a/shared-bindings/frequencyio/__init__.c +++ b/shared-bindings/frequencyio/__init__.c @@ -33,7 +33,7 @@ #include "shared-bindings/frequencyio/__init__.h" #include "shared-bindings/frequencyio/FrequencyIn.h" -//| :mod:`frequencyio` --- Support for frequency based protocols +//| """:mod:`frequencyio` --- Support for frequency based protocols //| ============================================================= //| //| .. module:: frequencyio @@ -73,7 +73,7 @@ //| :py:data:`~frequencyio.FrequencyIn.capture_period`, and then sleep 0.1 seconds. //| CircuitPython will automatically turn off FrequencyIn capture when it resets all //| hardware after program completion. Use ``deinit()`` or a ``with`` statement -//| to do it yourself. +//| to do it yourself.""" //| STATIC const mp_rom_map_elem_t frequencyio_module_globals_table[] = { From 4f33a20d17c7b7688e5dd1ee37346ff2d4f4a340 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 7 May 2020 15:10:44 -0400 Subject: [PATCH 046/216] Added gamepad, gamepadshift, and i2cslave --- shared-bindings/gamepad/GamePad.c | 104 +++++++-------- shared-bindings/gamepad/__init__.c | 4 +- shared-bindings/gamepadshift/GamePadShift.c | 41 +++--- shared-bindings/gamepadshift/__init__.c | 4 +- shared-bindings/i2cslave/I2CSlave.c | 138 ++++++++++---------- shared-bindings/i2cslave/__init__.c | 4 +- 6 files changed, 146 insertions(+), 149 deletions(-) diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index d3c29019a5..946a24dbff 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -34,65 +34,65 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "supervisor/shared/translate.h" - -//| .. currentmodule:: gamepad +//| class GamePad: +//| """.. currentmodule:: gamepad //| -//| :class:`GamePad` -- Scan buttons for presses -//| ============================================ +//| :class:`GamePad` -- Scan buttons for presses +//| ============================================ //| -//| Usage:: +//| Usage:: //| -//| import board -//| import digitalio -//| import gamepad -//| import time +//| import board +//| import digitalio +//| import gamepad +//| import time //| -//| B_UP = 1 << 0 -//| B_DOWN = 1 << 1 +//| B_UP = 1 << 0 +//| B_DOWN = 1 << 1 //| //| -//| pad = gamepad.GamePad( -//| digitalio.DigitalInOut(board.D10), -//| digitalio.DigitalInOut(board.D11), -//| ) +//| pad = gamepad.GamePad( +//| digitalio.DigitalInOut(board.D10), +//| digitalio.DigitalInOut(board.D11), +//| ) //| -//| y = 0 -//| while True: -//| buttons = pad.get_pressed() -//| if buttons & B_UP: -//| y -= 1 -//| print(y) -//| elif buttons & B_DOWN: -//| y += 1 -//| print(y) -//| time.sleep(0.1) -//| while buttons: -//| # Wait for all buttons to be released. +//| y = 0 +//| while True: //| buttons = pad.get_pressed() +//| if buttons & B_UP: +//| y -= 1 +//| print(y) +//| elif buttons & B_DOWN: +//| y += 1 +//| print(y) //| time.sleep(0.1) +//| while buttons: +//| # Wait for all buttons to be released. +//| buttons = pad.get_pressed() +//| time.sleep(0.1)""" //| -//| .. class:: GamePad([b1[, b2[, b3[, b4[, b5[, b6[, b7[, b8]]]]]]]]) +//| def __init__(self, b1: Any, b2: Any, b3: Any, b4: Any, b5: Any, b6: Any, b7: Any, b8: Any): +//| """Initializes button scanning routines. //| -//| Initializes button scanning routines. +//| The ``b1``-``b8`` parameters are ``DigitalInOut`` objects, which +//| immediately get switched to input with a pull-up, (unless they already +//| were set to pull-down, in which case they remain so), and then scanned +//| regularly for button presses. The order is the same as the order of +//| bits returned by the ``get_pressed`` function. You can re-initialize +//| it with different keys, then the new object will replace the previous +//| one. //| -//| The ``b1``-``b8`` parameters are ``DigitalInOut`` objects, which -//| immediately get switched to input with a pull-up, (unless they already -//| were set to pull-down, in which case they remain so), and then scanned -//| regularly for button presses. The order is the same as the order of -//| bits returned by the ``get_pressed`` function. You can re-initialize -//| it with different keys, then the new object will replace the previous -//| one. +//| The basic feature required here is the ability to poll the keys at +//| regular intervals (so that de-bouncing is consistent) and fast enough +//| (so that we don't miss short button presses) while at the same time +//| letting the user code run normally, call blocking functions and wait +//| on delays. //| -//| The basic feature required here is the ability to poll the keys at -//| regular intervals (so that de-bouncing is consistent) and fast enough -//| (so that we don't miss short button presses) while at the same time -//| letting the user code run normally, call blocking functions and wait -//| on delays. -//| -//| They button presses are accumulated, until the ``get_pressed`` method -//| is called, at which point the button state is cleared, and the new -//| button presses start to be recorded. +//| They button presses are accumulated, until the ``get_pressed`` method +//| is called, at which point the button state is cleared, and the new +//| button presses start to be recorded.""" +//| ... //| STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { @@ -114,15 +114,15 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(gamepad_singleton); } -//| .. method:: get_pressed() -//| -//| Get the status of buttons pressed since the last call and clear it. +//| def get_pressed(self, ) -> Any: +//| """Get the status of buttons pressed since the last call and clear it. //| //| Returns an 8-bit number, with bits that correspond to buttons, //| which have been pressed (or held down) since the last call to this //| function set to 1, and the remaining bits set to 0. Then it clears //| the button state, so that new button presses (or buttons that are -//| held down) can be recorded for the next call. +//| held down) can be recorded for the next call.""" +//| ... //| STATIC mp_obj_t gamepad_get_pressed(mp_obj_t self_in) { gamepad_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton); @@ -133,9 +133,9 @@ STATIC mp_obj_t gamepad_get_pressed(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(gamepad_get_pressed_obj, gamepad_get_pressed); -//| .. method:: deinit() -//| -//| Disable button scanning. +//| def deinit(self, ) -> Any: +//| """Disable button scanning.""" +//| ... //| STATIC mp_obj_t gamepad_deinit(mp_obj_t self_in) { common_hal_gamepad_gamepad_deinit(self_in); diff --git a/shared-bindings/gamepad/__init__.c b/shared-bindings/gamepad/__init__.c index cea0b4ee96..0c32fd6c1c 100644 --- a/shared-bindings/gamepad/__init__.c +++ b/shared-bindings/gamepad/__init__.c @@ -29,7 +29,7 @@ #include "shared-bindings/gamepad/GamePad.h" #include "shared-bindings/util.h" -//| :mod:`gamepad` --- Button handling +//| """:mod:`gamepad` --- Button handling //| ================================== //| //| .. module:: gamepad @@ -39,7 +39,7 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| GamePad +//| GamePad""" //| STATIC const mp_rom_map_elem_t gamepad_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gamepad) }, diff --git a/shared-bindings/gamepadshift/GamePadShift.c b/shared-bindings/gamepadshift/GamePadShift.c index 91203ad20d..37be3d9576 100644 --- a/shared-bindings/gamepadshift/GamePadShift.c +++ b/shared-bindings/gamepadshift/GamePadShift.c @@ -32,24 +32,25 @@ #include "shared-bindings/gamepadshift/__init__.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: gamepadshift +//| class GamePadShift: +//| """.. currentmodule:: gamepadshift //| -//| :class:`GamePadShift` -- Scan buttons for presses through a shift register -//| =========================================================================== +//| :class:`GamePadShift` -- Scan buttons for presses through a shift register +//| ===========================================================================""" //| -//| .. class:: GamePadShift(clock, data, latch) +//| def __init__(self, clock: Any, data: Any, latch: Any): +//| """Initializes button scanning routines. //| -//| Initializes button scanning routines. +//| The ``clock``, ``data`` and ``latch`` parameters are ``DigitalInOut`` +//| objects connected to the shift register controlling the buttons. //| -//| The ``clock``, ``data`` and ``latch`` parameters are ``DigitalInOut`` -//| objects connected to the shift register controlling the buttons. +//| They button presses are accumulated, until the ``get_pressed`` method +//| is called, at which point the button state is cleared, and the new +//| button presses start to be recorded. //| -//| They button presses are accumulated, until the ``get_pressed`` method -//| is called, at which point the button state is cleared, and the new -//| button presses start to be recorded. -//| -//| Only one gamepad (`gamepad.GamePad` or `gamepadshift.GamePadShift`) -//| may be used at a time. +//| Only one gamepad (`gamepad.GamePad` or `gamepadshift.GamePadShift`) +//| may be used at a time.""" +//| ... //| STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -81,15 +82,15 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(gamepad_singleton); } -//| .. method:: get_pressed() -//| -//| Get the status of buttons pressed since the last call and clear it. +//| def get_pressed(self, ) -> Any: +//| """Get the status of buttons pressed since the last call and clear it. //| //| Returns an 8-bit number, with bits that correspond to buttons, //| which have been pressed (or held down) since the last call to this //| function set to 1, and the remaining bits set to 0. Then it clears //| the button state, so that new button presses (or buttons that are -//| held down) can be recorded for the next call. +//| held down) can be recorded for the next call.""" +//| ... //| STATIC mp_obj_t gamepadshift_get_pressed(mp_obj_t self_in) { gamepadshift_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton); @@ -99,9 +100,9 @@ STATIC mp_obj_t gamepadshift_get_pressed(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(gamepadshift_get_pressed_obj, gamepadshift_get_pressed); -//| .. method:: deinit() -//| -//| Disable button scanning. +//| def deinit(self, ) -> Any: +//| """Disable button scanning.""" +//| ... //| STATIC mp_obj_t gamepadshift_deinit(mp_obj_t self_in) { common_hal_gamepadshift_gamepadshift_deinit(self_in); diff --git a/shared-bindings/gamepadshift/__init__.c b/shared-bindings/gamepadshift/__init__.c index 2d36677260..3763b04877 100644 --- a/shared-bindings/gamepadshift/__init__.c +++ b/shared-bindings/gamepadshift/__init__.c @@ -30,7 +30,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/util.h" -//| :mod:`gamepadshift` --- Tracks button presses read through a shift register +//| """:mod:`gamepadshift` --- Tracks button presses read through a shift register //| =========================================================================== //| //| .. module:: gamepadshift @@ -40,7 +40,7 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| GamePadShift +//| GamePadShift""" //| STATIC const mp_rom_map_elem_t gamepadshift_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gamepadshift) }, diff --git a/shared-bindings/i2cslave/I2CSlave.c b/shared-bindings/i2cslave/I2CSlave.c index e28eb3f253..5bab2af74e 100644 --- a/shared-bindings/i2cslave/I2CSlave.c +++ b/shared-bindings/i2cslave/I2CSlave.c @@ -49,20 +49,21 @@ STATIC mp_obj_t mp_obj_new_i2cslave_i2c_slave_request(i2cslave_i2c_slave_obj_t * return (mp_obj_t)self; } -//| .. currentmodule:: i2cslave +//| class I2CSlave: +//| """.. currentmodule:: i2cslave //| -//| :class:`I2CSlave` --- Two wire serial protocol slave -//| ---------------------------------------------------- +//| :class:`I2CSlave` --- Two wire serial protocol slave +//| ----------------------------------------------------""" //| -//| .. class:: I2CSlave(scl, sda, addresses, smbus=False) +//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, addresses: tuple, smbus: bool = False): +//| """I2C is a two-wire protocol for communicating between devices. +//| This implements the slave side. //| -//| I2C is a two-wire protocol for communicating between devices. -//| This implements the slave side. -//| -//| :param ~microcontroller.Pin scl: The clock pin -//| :param ~microcontroller.Pin sda: The data pin -//| :param tuple addresses: The I2C addresses to respond to (how many is hw dependent). -//| :param bool smbus: Use SMBUS timings if the hardware supports it +//| :param ~microcontroller.Pin scl: The clock pin +//| :param ~microcontroller.Pin sda: The data pin +//| :param tuple addresses: The I2C addresses to respond to (how many is hw dependent). +//| :param bool smbus: Use SMBUS timings if the hardware supports it""" +//| ... //| STATIC mp_obj_t i2cslave_i2c_slave_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { i2cslave_i2c_slave_obj_t *self = m_new_obj(i2cslave_i2c_slave_obj_t); @@ -104,9 +105,9 @@ STATIC mp_obj_t i2cslave_i2c_slave_make_new(const mp_obj_type_t *type, size_t n_ return (mp_obj_t)self; } -//| .. method:: deinit() -//| -//| Releases control of the underlying hardware so other classes can use it. +//| def deinit(self, ) -> Any: +//| """Releases control of the underlying hardware so other classes can use it.""" +//| ... //| STATIC mp_obj_t i2cslave_i2c_slave_obj_deinit(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &i2cslave_i2c_slave_type)); @@ -116,16 +117,16 @@ STATIC mp_obj_t i2cslave_i2c_slave_obj_deinit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(i2cslave_i2c_slave_deinit_obj, i2cslave_i2c_slave_obj_deinit); -//| .. method:: __enter__() -//| -//| No-op used in Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used in Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware on context exit. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware on context exit. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t i2cslave_i2c_slave_obj___exit__(size_t n_args, const mp_obj_t *args) { mp_check_self(MP_OBJ_IS_TYPE(args[0], &i2cslave_i2c_slave_type)); @@ -135,13 +136,12 @@ STATIC mp_obj_t i2cslave_i2c_slave_obj___exit__(size_t n_args, const mp_obj_t *a } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(i2cslave_i2c_slave___exit___obj, 4, 4, i2cslave_i2c_slave_obj___exit__); -//| .. method:: request(timeout=-1) +//| def request(self, timeout: float = -1) -> Any: +//| """Wait for an I2C request from a master. //| -//| Wait for an I2C request from a master. -//| -//| :param float timeout: Timeout in seconds. Zero means wait forever, a negative value means check once -//| :return: I2C Slave Request or None if timeout=-1 and there's no request -//| :rtype: ~i2cslave.I2CSlaveRequest +//| :param float timeout: Timeout in seconds. Zero means wait forever, a negative value means check once +//| :return: I2C Slave Request or None if timeout=-1 and there's no request +//| :rtype: ~i2cslave.I2CSlaveRequest""" //| 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)); @@ -228,34 +228,33 @@ const mp_obj_type_t i2cslave_i2c_slave_type = { .locals_dict = (mp_obj_dict_t*)&i2cslave_i2c_slave_locals_dict, }; - -//| :class:`I2CSlaveRequest` --- I2C Slave Request -//| ---------------------------------------------- +//| class I2CSlaveRequest: +//| """:class:`I2CSlaveRequest` --- I2C Slave Request +//| ----------------------------------------------""" //| -//| .. class:: I2CSlaveRequest(slave, address, is_read, is_restart) +//| def __init__(self, slave: i2cslave.I2CSlave, address: int, is_read: bool, is_restart: bool): +//| """I2C transfer request from a master. +//| This cannot be instantiated directly, but is returned by :py:meth:`I2CSlave.request`. //| -//| I2C transfer request from a master. -//| This cannot be instantiated directly, but is returned by :py:meth:`I2CSlave.request`. -//| -//| :param ~i2cslave.I2CSlave slave: The I2C Slave receiving this request -//| :param int address: I2C address -//| :param bool is_read: I2C Master read request -//| :param bool is_restart: Repeated Start Condition +//| :param ~i2cslave.I2CSlave slave: The I2C Slave receiving this request +//| :param int address: I2C address +//| :param bool is_read: I2C Master read request +//| :param bool is_restart: Repeated Start Condition""" //| STATIC mp_obj_t i2cslave_i2c_slave_request_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 4, 4, false); return mp_obj_new_i2cslave_i2c_slave_request(args[0], mp_obj_get_int(args[1]), mp_obj_is_true(args[2]), mp_obj_is_true(args[3])); } -//| .. method:: __enter__() -//| -//| No-op used in Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used in Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Close the request. +//| def __exit__(self, ) -> Any: +//| """Close the request.""" +//| ... //| STATIC mp_obj_t i2cslave_i2c_slave_request_obj___exit__(size_t n_args, const mp_obj_t *args) { mp_check_self(MP_OBJ_IS_TYPE(args[0], &i2cslave_i2c_slave_request_type)); @@ -265,9 +264,8 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_obj___exit__(size_t n_args, const mp_ } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(i2cslave_i2c_slave_request___exit___obj, 4, 4, i2cslave_i2c_slave_request_obj___exit__); -//| .. attribute:: address -//| -//| The I2C address of the request. +//| address: Any = ... +//| """The I2C address of the request.""" //| STATIC mp_obj_t i2cslave_i2c_slave_request_get_address(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &i2cslave_i2c_slave_request_type)); @@ -276,9 +274,8 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_get_address(mp_obj_t self_in) { } MP_DEFINE_CONST_PROP_GET(i2cslave_i2c_slave_request_address_obj, i2cslave_i2c_slave_request_get_address); -//| .. attribute:: is_read -//| -//| The I2C master is reading from the device. +//| is_read: Any = ... +//| """The I2C master is reading from the device.""" //| STATIC mp_obj_t i2cslave_i2c_slave_request_get_is_read(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &i2cslave_i2c_slave_request_type)); @@ -287,9 +284,8 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_get_is_read(mp_obj_t self_in) { } MP_DEFINE_CONST_PROP_GET(i2cslave_i2c_slave_request_is_read_obj, i2cslave_i2c_slave_request_get_is_read); -//| .. attribute:: is_restart -//| -//| Is Repeated Start Condition. +//| is_restart: Any = ... +//| """Is Repeated Start Condition.""" //| STATIC mp_obj_t i2cslave_i2c_slave_request_get_is_restart(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &i2cslave_i2c_slave_request_type)); @@ -298,15 +294,15 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_get_is_restart(mp_obj_t self_in) { } MP_DEFINE_CONST_PROP_GET(i2cslave_i2c_slave_request_is_restart_obj, i2cslave_i2c_slave_request_get_is_restart); -//| .. method:: read(n=-1, ack=True) +//| def read(self, n: int = -1, ack: bool = True) -> Any: +//| """Read data. +//| If ack=False, the caller is responsible for calling :py:meth:`I2CSlaveRequest.ack`. //| -//| Read data. -//| If ack=False, the caller is responsible for calling :py:meth:`I2CSlaveRequest.ack`. -//| -//| :param int n: Number of bytes to read (negative means all) -//| :param bool ack: Whether or not to send an ACK after the n'th byte -//| :return: Bytes read -//| :rtype: bytearray +//| :param int n: Number of bytes to read (negative means all) +//| :param bool ack: Whether or not to send an ACK after the n'th byte +//| :return: Bytes read +//| :rtype: bytearray""" +//| ... //| STATIC mp_obj_t i2cslave_i2c_slave_request_read(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_request_type)); @@ -359,12 +355,12 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_read(size_t n_args, const mp_obj_t *p } MP_DEFINE_CONST_FUN_OBJ_KW(i2cslave_i2c_slave_request_read_obj, 1, i2cslave_i2c_slave_request_read); -//| .. method:: write(buffer) +//| def write(self, buffer: bytearray) -> Any: +//| """Write the data contained in buffer. //| -//| Write the data contained in buffer. -//| -//| :param bytearray buffer: Write out the data in this buffer -//| :return: Number of bytes written +//| :param bytearray buffer: Write out the data in this buffer +//| :return: Number of bytes written""" +//| ... //| STATIC mp_obj_t i2cslave_i2c_slave_request_write(mp_obj_t self_in, mp_obj_t buf_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &i2cslave_i2c_slave_request_type)); @@ -393,12 +389,12 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_write(mp_obj_t self_in, mp_obj_t buf_ } STATIC MP_DEFINE_CONST_FUN_OBJ_2(i2cslave_i2c_slave_request_write_obj, i2cslave_i2c_slave_request_write); -//| .. method:: ack(ack=True) +//| def ack(self, ack: bool = True) -> Any: +//| """Acknowledge or Not Acknowledge last byte received. +//| Use together with :py:meth:`I2CSlaveRequest.read` ack=False. //| -//| Acknowledge or Not Acknowledge last byte received. -//| Use together with :py:meth:`I2CSlaveRequest.read` ack=False. -//| -//| :param bool ack: Whether to send an ACK or NACK +//| :param bool ack: Whether to send an ACK or NACK""" +//| ... //| STATIC mp_obj_t i2cslave_i2c_slave_request_ack(uint n_args, const mp_obj_t *args) { mp_check_self(MP_OBJ_IS_TYPE(args[0], &i2cslave_i2c_slave_request_type)); diff --git a/shared-bindings/i2cslave/__init__.c b/shared-bindings/i2cslave/__init__.c index 1c692e54e7..ffeb216fae 100644 --- a/shared-bindings/i2cslave/__init__.c +++ b/shared-bindings/i2cslave/__init__.c @@ -35,7 +35,7 @@ #include "py/runtime.h" -//| :mod:`i2cslave` --- Two wire serial protocol slave +//| """:mod:`i2cslave` --- Two wire serial protocol slave //| ================================================== //| //| .. module:: i2cslave @@ -101,7 +101,7 @@ //| //| Raspberry Pi in particular does not support this with its I2C hw block. //| This can be worked around by using the ``i2c-gpio`` bit banging driver. -//| Since the RPi firmware uses the hw i2c, it's not possible to emulate a HAT eeprom. +//| Since the RPi firmware uses the hw i2c, it's not possible to emulate a HAT eeprom.""" //| STATIC const mp_rom_map_elem_t i2cslave_module_globals_table[] = { From e31e9eeaa1e1dad1bd2243b7be76012aa2ee64b8 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 7 May 2020 15:59:52 -0400 Subject: [PATCH 047/216] Did math, microcontroller, and multiterminal --- shared-bindings/math/__init__.c | 164 ++++++++++---------- shared-bindings/microcontroller/Pin.c | 19 +-- shared-bindings/microcontroller/Processor.c | 49 +++--- shared-bindings/microcontroller/RunMode.c | 37 ++--- shared-bindings/microcontroller/__init__.c | 78 +++++----- shared-bindings/multiterminal/__init__.c | 32 ++-- 6 files changed, 184 insertions(+), 195 deletions(-) diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index 0bf8047c98..755bf75897 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -38,7 +38,7 @@ #define MP_PI MICROPY_FLOAT_CONST(3.14159265358979323846) -//| :mod:`math` --- mathematical functions +//| """:mod:`math` --- mathematical functions //| ======================================================== //| //| .. module:: math @@ -46,7 +46,7 @@ //| :platform: SAMD21/SAMD51 //| //| The `math` module provides some basic mathematical functions for -//| working with floating-point numbers. +//| working with floating-point numbers.""" //| STATIC NORETURN void math_error(void) { @@ -86,117 +86,113 @@ STATIC NORETURN void math_error(void) { //| Constants //| --------- //| - //| .. data:: e + //| e: Any = ... + //| """base of the natural logarithm""" //| - //| base of the natural logarithm - //| - //| .. data:: pi - //| - //| the ratio of a circle's circumference to its diameter + //| pi: Any = ... + //| """the ratio of a circle's circumference to its diameter""" //| //| Functions //| --------- //| - //| .. function:: acos(x) + //| def acos(x: Any) -> Any: + //| """Return the inverse cosine of ``x``.""" + //| ... //| - //| Return the inverse cosine of ``x``. + //| def asin(x: Any) -> Any: + //| """Return the inverse sine of ``x``.""" + //| ... //| - //| .. function:: asin(x) + //| def atan(x: Any) -> Any: + //| """Return the inverse tangent of ``x``.""" + //| ... //| - //| Return the inverse sine of ``x``. + //| def atan2(y: Any, x: Any) -> Any: + //| """Return the principal value of the inverse tangent of ``y/x``.""" + //| ... //| - //| .. function:: atan(x) + //| def ceil(x: Any) -> Any: + //| """Return an integer, being ``x`` rounded towards positive infinity.""" + //| ... //| - //| Return the inverse tangent of ``x``. + //| def copysign(x: Any, y: Any) -> Any: + //| """Return ``x`` with the sign of ``y``.""" + //| ... //| - //| .. function:: atan2(y,x) + //| def cos(x: Any) -> Any: + //| """Return the cosine of ``x``.""" + //| ... //| - //| Return the principal value of the inverse tangent of ``y/x``. + //| def degrees(x: Any) -> Any: + //| """Return radians ``x`` converted to degrees.""" + //| ... //| - //| .. function:: ceil(x) + //| def exp(x: Any) -> Any: + //| """Return the exponential of ``x``.""" + //| ... //| - //| Return an integer, being ``x`` rounded towards positive infinity. + //| def fabs(x: Any) -> Any: + //| """Return the absolute value of ``x``.""" + //| ... //| - //| .. function:: copysign(x,y) + //| def floor(x: Any) -> Any: + //| """Return an integer, being ``x`` rounded towards negative infinity.""" + //| ... //| - //| Return ``x`` with the sign of ``y``. + //| def fmod(x: Any, y: Any) -> Any: + //| """Return the remainder of ``x/y``.""" + //| ... //| - //| .. function:: cos(x) + //| def frexp(x: Any) -> Any: + //| """Decomposes a floating-point number into its mantissa and exponent. + //| The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e`` + //| exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise + //| the relation ``0.5 <= abs(m) < 1`` holds.""" + //| ... //| - //| Return the cosine of ``x``. + //| def isfinite(x: Any) -> Any: + //| """Return ``True`` if ``x`` is finite.""" + //| ... //| - //| .. function:: degrees(x) + //| def isinf(x: Any) -> Any: + //| """Return ``True`` if ``x`` is infinite.""" + //| ... //| - //| Return radians ``x`` converted to degrees. + //| def isnan(x: Any) -> Any: + //| """Return ``True`` if ``x`` is not-a-number""" + //| ... //| - //| .. function:: exp(x) + //| def ldexp(x: Any, exp: Any) -> Any: + //| """Return ``x * (2**exp)``.""" + //| ... //| - //| Return the exponential of ``x``. + //| def modf(x: Any) -> Any: + //| """Return a tuple of two floats, being the fractional and integral parts of + //| ``x``. Both return values have the same sign as ``x``.""" + //| ... //| - //| .. function:: fabs(x) + //| def pow(x: Any, y: Any) -> Any: + //| """Returns ``x`` to the power of ``y``.""" //| - //| Return the absolute value of ``x``. + //| def radians(x: Any) -> Any: + //| """Return degrees ``x`` converted to radians.""" //| - //| .. function:: floor(x) + //| def sin(x: Any) -> Any: + //| """Return the sine of ``x``.""" + //| ... //| - //| Return an integer, being ``x`` rounded towards negative infinity. + //| def sqrt(x: Any) -> Any: + //| """Returns the square root of ``x``.""" + //| ... //| - //| .. function:: fmod(x,y) + //| def tan(x: Any) -> Any: ... + //| """Return the tangent of ``x``.""" + //| ... //| - //| Return the remainder of ``x/y``. - //| - //| .. function:: frexp(x) - //| - //| Decomposes a floating-point number into its mantissa and exponent. - //| The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e`` - //| exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise - //| the relation ``0.5 <= abs(m) < 1`` holds. - //| - //| .. function:: isfinite(x) - //| - //| Return ``True`` if ``x`` is finite. - //| - //| .. function:: isinf(x) - //| - //| Return ``True`` if ``x`` is infinite. - //| - //| .. function:: isnan(x) - //| - //| Return ``True`` if ``x`` is not-a-number - //| - //| .. function:: ldexp(x, exp) - //| - //| Return ``x * (2**exp)``. - //| - //| .. function:: modf(x) - //| - //| Return a tuple of two floats, being the fractional and integral parts of - //| ``x``. Both return values have the same sign as ``x``. - //| - //| .. function:: pow(x, y) - //| - //| Returns ``x`` to the power of ``y``. - //| - //| .. function:: radians(x) - //| - //| Return degrees ``x`` converted to radians. - //| - //| .. function:: sin(x) - //| - //| Return the sine of ``x``. - //| - //| .. function:: sqrt(x) - //| - //| Returns the square root of ``x``. - //| - //| .. function:: tan(x) - //| - //| Return the tangent of ``x``. - //| - //| .. function:: trunc(x) - //| - //| Return an integer, being ``x`` rounded towards 0. + //| def trunc(x: Any) -> Any: + //| """Return an integer, being ``x`` rounded towards 0.""" + //| ... //| MATH_FUN_1_ERRCOND(sqrt, sqrt, (x < (mp_float_t)0.0)) diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index 67aecaf66e..cad0d67b1d 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -33,18 +33,19 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: microcontroller +//| class Pin: +//| """.. currentmodule:: microcontroller //| -//| :class:`Pin` --- Pin reference -//| ------------------------------------------ +//| :class:`Pin` --- Pin reference +//| ------------------------------------------ //| -//| Identifies an IO pin on the microcontroller. +//| Identifies an IO pin on the microcontroller.""" //| -//| .. class:: Pin() -//| -//| Identifies an IO pin on the microcontroller. They are fixed by the -//| hardware so they cannot be constructed on demand. Instead, use -//| `board` or `microcontroller.pin` to reference the desired pin. +//| def __init__(self, ): +//| """Identifies an IO pin on the microcontroller. They are fixed by the +//| hardware so they cannot be constructed on demand. Instead, use +//| `board` or `microcontroller.pin` to reference the desired pin.""" +//| ... //| static void get_pin_name(const mcu_pin_obj_t *self, qstr* package, qstr* module, qstr* name) { diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index 023f063e02..dedb5a27c2 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -34,29 +34,29 @@ #include "py/runtime.h" -//| .. currentmodule:: microcontroller +//| class Processor: +//| """.. currentmodule:: microcontroller //| -//| :class:`Processor` --- Microcontroller CPU information and control -//| ------------------------------------------------------------------ +//| :class:`Processor` --- Microcontroller CPU information and control +//| ------------------------------------------------------------------ //| -//| Get information about the microcontroller CPU and control it. +//| Get information about the microcontroller CPU and control it. //| -//| Usage:: +//| Usage:: //| -//| import microcontroller -//| print(microcontroller.cpu.frequency) -//| print(microcontroller.cpu.temperature) +//| import microcontroller +//| print(microcontroller.cpu.frequency) +//| print(microcontroller.cpu.temperature)""" //| -//| .. class:: Processor() -//| -//| You cannot create an instance of `microcontroller.Processor`. -//| Use `microcontroller.cpu` to access the sole instance available. +//| def __init__(self, ): +//| """You cannot create an instance of `microcontroller.Processor`. +//| Use `microcontroller.cpu` to access the sole instance available.""" +//| ... //| -//| .. attribute:: frequency -//| -//| The CPU operating frequency as an `int`, in Hertz. (read-only) +//| frequency: Any = ... +//| """The CPU operating frequency as an `int`, in Hertz. (read-only)""" //| STATIC mp_obj_t mcu_processor_get_frequency(mp_obj_t self) { return mp_obj_new_int_from_uint(common_hal_mcu_processor_get_frequency()); @@ -72,11 +72,10 @@ const mp_obj_property_t mcu_processor_frequency_obj = { }, }; -//| .. attribute:: temperature +//| temperature: Any = ... +//| """The on-chip temperature, in Celsius, as a float. (read-only) //| -//| The on-chip temperature, in Celsius, as a float. (read-only) -//| -//| Is `None` if the temperature is not available. +//| Is `None` if the temperature is not available.""" //| STATIC mp_obj_t mcu_processor_get_temperature(mp_obj_t self) { float temperature = common_hal_mcu_processor_get_temperature(); @@ -93,9 +92,8 @@ const mp_obj_property_t mcu_processor_temperature_obj = { }, }; -//| .. attribute:: uid -//| -//| The unique id (aka serial number) of the chip as a `bytearray`. (read-only) +//| uid: Any = ... +//| """The unique id (aka serial number) of the chip as a `bytearray`. (read-only)""" //| STATIC mp_obj_t mcu_processor_get_uid(mp_obj_t self) { uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; @@ -113,11 +111,10 @@ const mp_obj_property_t mcu_processor_uid_obj = { }, }; -//| .. attribute:: voltage +//| voltage: Any = ... +//| """The input voltage to the microcontroller, as a float. (read-only) //| -//| The input voltage to the microcontroller, as a float. (read-only) -//| -//| Is `None` if the voltage is not available. +//| Is `None` if the voltage is not available.""" //| STATIC mp_obj_t mcu_processor_get_voltage(mp_obj_t self) { float voltage = common_hal_mcu_processor_get_voltage(); diff --git a/shared-bindings/microcontroller/RunMode.c b/shared-bindings/microcontroller/RunMode.c index 913242ad26..df3ff41868 100644 --- a/shared-bindings/microcontroller/RunMode.c +++ b/shared-bindings/microcontroller/RunMode.c @@ -26,34 +26,31 @@ #include "shared-bindings/microcontroller/RunMode.h" -//| .. currentmodule:: microcontroller +//| class RunMode: +//| """.. currentmodule:: microcontroller //| -//| :class:`RunMode` -- run state of the microcontroller -//| ============================================================= +//| :class:`RunMode` -- run state of the microcontroller +//| =============================================================""" //| -//| .. class:: RunMode() +//| def __init__(self, ): +//| """Enum-like class to define the run mode of the microcontroller and +//| CircuitPython.""" //| -//| Enum-like class to define the run mode of the microcontroller and -//| CircuitPython. +//| NORMAL: Any = ... +//| """Run CircuitPython as normal. //| -//| .. attribute:: NORMAL +//| :type microcontroller.RunMode:""" //| -//| Run CircuitPython as normal. +//| SAFE_MODE: Any = ... +//| """Run CircuitPython in safe mode. User code will not be run and the +//| file system will be writeable over USB. //| -//| :type microcontroller.RunMode: +//| :type microcontroller.RunMode:""" //| -//| .. attribute:: SAFE_MODE +//| BOOTLOADER: Any = ... +//| """Run the bootloader. //| -//| Run CircuitPython in safe mode. User code will not be run and the -//| file system will be writeable over USB. -//| -//| :type microcontroller.RunMode: -//| -//| .. attribute:: BOOTLOADER -//| -//| Run the bootloader. -//| -//| :type microcontroller.RunMode: +//| :type microcontroller.RunMode:""" //| const mp_obj_type_t mcu_runmode_type; diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 090c4564da..75b7639808 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -42,7 +42,7 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//| :mod:`microcontroller` --- Pin references and cpu functionality +//| """:mod:`microcontroller` --- Pin references and cpu functionality //| ================================================================ //| //| .. module:: microcontroller @@ -59,24 +59,23 @@ //| //| Pin //| Processor -//| RunMode +//| RunMode""" //| -//| .. data:: cpu -//| -//| CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency`` -//| (clock frequency). -//| This object is the sole instance of `microcontroller.Processor`. +//| cpu: Any = ... +//| """CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency`` +//| (clock frequency). +//| This object is the sole instance of `microcontroller.Processor`.""" //| -//| .. function:: delay_us(delay) -//| -//| Dedicated delay method used for very short delays. **Do not** do long delays -//| because this stops all other functions from completing. Think of this as an empty -//| ``while`` loop that runs for the specified ``(delay)`` time. If you have other -//| code or peripherals (e.g audio recording) that require specific timing or -//| processing while you are waiting, explore a different avenue such as using -//| `time.sleep()`. +//| def delay_us(delay: Any) -> Any: +//| """Dedicated delay method used for very short delays. **Do not** do long delays +//| because this stops all other functions from completing. Think of this as an empty +//| ``while`` loop that runs for the specified ``(delay)`` time. If you have other +//| code or peripherals (e.g audio recording) that require specific timing or +//| processing while you are waiting, explore a different avenue such as using +//| `time.sleep()`.""" +//| ... //| STATIC mp_obj_t mcu_delay_us(mp_obj_t delay_obj) { uint32_t delay = mp_obj_get_int(delay_obj); @@ -87,9 +86,9 @@ STATIC mp_obj_t mcu_delay_us(mp_obj_t delay_obj) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mcu_delay_us_obj, mcu_delay_us); -//| .. function:: disable_interrupts() -//| -//| Disable all interrupts. Be very careful, this can stall everything. +//| def disable_interrupts() -> Any: +//| """Disable all interrupts. Be very careful, this can stall everything.""" +//| ... //| STATIC mp_obj_t mcu_disable_interrupts(void) { common_hal_mcu_disable_interrupts(); @@ -97,9 +96,9 @@ STATIC mp_obj_t mcu_disable_interrupts(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_disable_interrupts_obj, mcu_disable_interrupts); -//| .. function:: enable_interrupts() -//| -//| Enable the interrupts that were enabled at the last disable. +//| def enable_interrupts() -> Any: +//| """Enable the interrupts that were enabled at the last disable.""" +//| ... //| STATIC mp_obj_t mcu_enable_interrupts(void) { common_hal_mcu_enable_interrupts(); @@ -107,12 +106,12 @@ STATIC mp_obj_t mcu_enable_interrupts(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_enable_interrupts_obj, mcu_enable_interrupts); -//| .. function:: on_next_reset(run_mode) +//| def on_next_reset(run_mode: microcontroller.RunMode) -> Any: +//| """Configure the run mode used the next time the microcontroller is reset but +//| not powered down. //| -//| Configure the run mode used the next time the microcontroller is reset but -//| not powered down. -//| -//| :param ~microcontroller.RunMode run_mode: The next run mode +//| :param ~microcontroller.RunMode run_mode: The next run mode""" +//| ... //| STATIC mp_obj_t mcu_on_next_reset(mp_obj_t run_mode_obj) { mcu_runmode_t run_mode; @@ -132,14 +131,14 @@ STATIC mp_obj_t mcu_on_next_reset(mp_obj_t run_mode_obj) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mcu_on_next_reset_obj, mcu_on_next_reset); -//| .. function:: reset() +//| def reset() -> Any: +//| """Reset the microcontroller. After reset, the microcontroller will enter the +//| run mode last set by `on_next_reset`. //| -//| Reset the microcontroller. After reset, the microcontroller will enter the -//| run mode last set by `on_next_reset`. -//| -//| .. warning:: This may result in file system corruption when connected to a -//| host computer. Be very careful when calling this! Make sure the device -//| "Safely removed" on Windows or "ejected" on Mac OSX and Linux. +//| .. warning:: This may result in file system corruption when connected to a +//| host computer. Be very careful when calling this! Make sure the device +//| "Safely removed" on Windows or "ejected" on Mac OSX and Linux.""" +//| ... //| STATIC mp_obj_t mcu_reset(void) { common_hal_mcu_reset(); @@ -148,22 +147,21 @@ STATIC mp_obj_t mcu_reset(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset); -//| .. data:: nvm +//| nvm: Any = ... +//| """Available non-volatile memory. +//| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise. //| -//| Available non-volatile memory. -//| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise. -//| -//| :type: nvm.ByteArray or None +//| :type: nvm.ByteArray or None""" //| -//| :mod:`microcontroller.pin` --- Microcontroller pin names +//| """:mod:`microcontroller.pin` --- Microcontroller pin names //| -------------------------------------------------------- //| //| .. module:: microcontroller.pin //| :synopsis: Microcontroller pin names //| :platform: SAMD21 //| -//| References to pins as named by the microcontroller +//| References to pins as named by the microcontroller""" //| const mp_obj_module_t mcu_pin_module = { .base = { &mp_type_module }, diff --git a/shared-bindings/multiterminal/__init__.c b/shared-bindings/multiterminal/__init__.c index 8de3c50d7b..3a40650191 100644 --- a/shared-bindings/multiterminal/__init__.c +++ b/shared-bindings/multiterminal/__init__.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//| :mod:`multiterminal` --- Manage additional terminal sources +//| """:mod:`multiterminal` --- Manage additional terminal sources //| =========================================================== //| //| .. module:: multiterminal @@ -39,25 +39,25 @@ //| //| The `multiterminal` module allows you to configure an additional serial //| terminal source. Incoming characters are accepted from both the internal -//| serial connection and the optional secondary connection. +//| serial connection and the optional secondary connection.""" //| -//| .. function:: get_secondary_terminal() -//| -//| Returns the current secondary terminal. +//| def get_secondary_terminal() -> Any: +//| """Returns the current secondary terminal.""" +//| ... //| STATIC mp_obj_t multiterminal_obj_get_secondary_terminal() { return common_hal_multiterminal_get_secondary_terminal(); } MP_DEFINE_CONST_FUN_OBJ_0(multiterminal_get_secondary_terminal_obj, multiterminal_obj_get_secondary_terminal); -//| .. function:: set_secondary_terminal(stream) -//| -//| Read additional input from the given stream and write out back to it. +//| def set_secondary_terminal(stream: stream) -> Any: +//| """Read additional input from the given stream and write out back to it. //| This doesn't replace the core stream (usually UART or native USB) but is //| mixed in instead. //| -//| :param stream stream: secondary stream +//| :param stream stream: secondary stream""" +//| ... //| STATIC mp_obj_t multiterminal_obj_set_secondary_terminal(mp_obj_t secondary_terminal) { mp_obj_t write_m[3]; @@ -73,9 +73,9 @@ STATIC mp_obj_t multiterminal_obj_set_secondary_terminal(mp_obj_t secondary_term } MP_DEFINE_CONST_FUN_OBJ_1(multiterminal_set_secondary_terminal_obj, multiterminal_obj_set_secondary_terminal); -//| .. function:: clear_secondary_terminal() -//| -//| Clears the secondary terminal. +//| def clear_secondary_terminal() -> Any: +//| """Clears the secondary terminal.""" +//| ... //| STATIC mp_obj_t multiterminal_obj_clear_secondary_terminal() { common_hal_multiterminal_clear_secondary_terminal(); @@ -83,11 +83,11 @@ STATIC mp_obj_t multiterminal_obj_clear_secondary_terminal() { } MP_DEFINE_CONST_FUN_OBJ_0(multiterminal_clear_secondary_terminal_obj, multiterminal_obj_clear_secondary_terminal); -//| .. function:: schedule_secondary_terminal_read(socket) -//| -//| In cases where the underlying OS is doing task scheduling, this notifies +//| def schedule_secondary_terminal_read(socket: Any) -> Any: +//| """In cases where the underlying OS is doing task scheduling, this notifies //| the OS when more data is available on the socket to read. This is useful -//| as a callback for lwip sockets. +//| as a callback for lwip sockets.""" +//| ... //| // TODO(tannewt): This is a funny API. Replace it with a direct call into the OS // by the lwip object. From 94ca233d976a9641c207a244f7c92097cb75da91 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Fri, 8 May 2020 07:55:11 +1000 Subject: [PATCH 048/216] Update py/circuitpy_mpconfig.mk Co-authored-by: Scott Shawcroft --- py/circuitpy_mpconfig.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 95e3512f10..c805b0501a 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -109,9 +109,7 @@ CIRCUITPY_DIGITALIO = 1 endif CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) -ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO = 1 -endif +CIRCUITPY_COUNTIO ?= 1 CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) From d750096befe2e6d23b1d0d4796306382cfbbb198 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 7 May 2020 18:40:46 -0400 Subject: [PATCH 049/216] Did neopixel, network, nvm --- shared-bindings/neopixel_write/__init__.c | 13 ++++----- shared-bindings/network/__init__.c | 10 +++---- shared-bindings/nvm/ByteArray.c | 34 +++++++++++++---------- shared-bindings/nvm/__init__.c | 5 ++-- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index 1ee66337bb..f18c7fdfd1 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -31,7 +31,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "supervisor/shared/translate.h" -//| :mod:`neopixel_write` --- Low-level neopixel implementation +//| """:mod:`neopixel_write` --- Low-level neopixel implementation //| =========================================================== //| //| .. module:: neopixel_write @@ -53,15 +53,14 @@ //| pin = digitalio.DigitalInOut(board.NEOPIXEL) //| pin.direction = digitalio.Direction.OUTPUT //| pixel_off = bytearray([0, 0, 0]) -//| neopixel_write.neopixel_write(pin, pixel_off) +//| neopixel_write.neopixel_write(pin, pixel_off)""" //| -//| .. function:: neopixel_write(digitalinout, buf) -//| -//| Write buf out on the given DigitalInOut. +//| def neopixel_write(digitalinout: digitalio.DigitalInOut, buf: bytearray) -> Any: +//| """Write buf out on the given DigitalInOut. //| //| :param ~digitalio.DigitalInOut digitalinout: the DigitalInOut to output with -//| :param bytearray buf: The bytes to clock out. No assumption is made about color order -//| +//| :param bytearray buf: The bytes to clock out. No assumption is made about color order""" +//| ... STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj_t buf) { if (!MP_OBJ_IS_TYPE(digitalinout_obj, &digitalio_digitalinout_type)) { mp_raise_TypeError_varg(translate("Expected a %q"), digitalio_digitalinout_type.name); diff --git a/shared-bindings/network/__init__.c b/shared-bindings/network/__init__.c index 01763a73c5..4f03781cf4 100644 --- a/shared-bindings/network/__init__.c +++ b/shared-bindings/network/__init__.c @@ -38,7 +38,7 @@ #if CIRCUITPY_NETWORK -//| :mod:`network` --- Network Interface Management +//| """:mod:`network` --- Network Interface Management //| =============================================== //| //| .. module:: network @@ -47,11 +47,11 @@ //| //| This module provides a registry of configured NICs. //| It is used by the 'socket' module to look up a suitable -//| NIC when a socket is created. +//| NIC when a socket is created.""" //| -//| .. function:: route() -//| -//| Returns a list of all configured NICs. +//| def route() -> Any: +//| """Returns a list of all configured NICs.""" +//| ... //| STATIC mp_obj_t network_route(void) { diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 31bedeacc0..a28c2c4f9a 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -31,29 +31,33 @@ #include "shared-bindings/nvm/ByteArray.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: nvm + + + +//| class ByteArray: +//| """.. currentmodule:: nvm //| -//| :class:`ByteArray` -- Presents a stretch of non-volatile memory as a bytearray. -//| ================================================================================ +//| :class:`ByteArray` -- Presents a stretch of non-volatile memory as a bytearray. +//| ================================================================================ //| -//| Non-volatile memory is available as a byte array that persists over reloads -//| and power cycles. Each assignment causes an erase and write cycle so its recommended to assign -//| all values to change at once. +//| Non-volatile memory is available as a byte array that persists over reloads +//| and power cycles. Each assignment causes an erase and write cycle so its recommended to assign +//| all values to change at once. //| -//| Usage:: +//| Usage:: //| -//| import microcontroller -//| microcontroller.nvm[0:3] = b"\xcc\x10\x00" +//| import microcontroller +//| microcontroller.nvm[0:3] = b\"\xcc\x10\x00\"""" //| -//| .. class:: ByteArray() -//| -//| Not currently dynamically supported. Access the sole instance through `microcontroller.nvm`. +//| def __init__(self, ): +//| """Not currently dynamically supported. Access the sole instance through `microcontroller.nvm`.""" +//| ... //| -//| .. method:: __len__() -//| -//| Return the length. This is used by (`len`) +//| def __len__(self, ) -> Any: +//| """Return the length. This is used by (`len`)""" +//| ... //| STATIC mp_obj_t nvm_bytearray_unary_op(mp_unary_op_t op, mp_obj_t self_in) { nvm_bytearray_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/nvm/__init__.c b/shared-bindings/nvm/__init__.c index 811855c093..3bd9a309b5 100644 --- a/shared-bindings/nvm/__init__.c +++ b/shared-bindings/nvm/__init__.c @@ -31,7 +31,7 @@ #include "shared-bindings/nvm/__init__.h" #include "shared-bindings/nvm/ByteArray.h" -//| :mod:`nvm` --- Non-volatile memory +//| """:mod:`nvm` --- Non-volatile memory //| =========================================================== //| //| .. module:: nvm @@ -47,7 +47,8 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| ByteArray +//| ByteArray""" +//| STATIC const mp_rom_map_elem_t nvm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_nvm) }, { MP_ROM_QSTR(MP_QSTR_ByteArray), MP_ROM_PTR(&nvm_bytearray_type) }, From 5249a7b02cc326d7b88caa90d6def6a10d84525a Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 7 May 2020 14:49:33 -0400 Subject: [PATCH 050/216] Add timeout and adjustment to LSI --- ports/stm/supervisor/port.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c index 779348c02a..328a8d660c 100644 --- a/ports/stm/supervisor/port.c +++ b/ports/stm/supervisor/port.c @@ -153,9 +153,9 @@ __attribute__((used, naked)) void Reset_Handler(void) { static RTC_HandleTypeDef _hrtc; #if BOARD_HAS_LOW_SPEED_CRYSTAL -#define RTC_CLOCK_FREQUENCY LSE_VALUE +static uint32_t rtc_clock_frequency = LSE_VALUE; #else -#define RTC_CLOCK_FREQUENCY LSI_VALUE +static uint32_t rtc_clock_frequency = LSI_VALUE; #endif safe_mode_t port_init(void) { @@ -172,22 +172,36 @@ safe_mode_t port_init(void) { HAL_PWR_EnableBkUpAccess(); #if BOARD_HAS_LOW_SPEED_CRYSTAL __HAL_RCC_LSE_CONFIG(RCC_LSE_ON); - while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) {} + bool lse_setupsuccess = true; + uint32_t i = 0; + while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) { + if ( ++i > 1000000 ) + { + lse_setupsuccess = false; + __HAL_RCC_LSE_CONFIG(RCC_LSE_OFF); + __HAL_RCC_LSI_ENABLE(); + rtc_clock_frequency = LSI_VALUE; + } + } #else __HAL_RCC_LSI_ENABLE(); #endif #if BOARD_HAS_LOW_SPEED_CRYSTAL - __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE); + if (lse_setupsuccess) { + __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE); + } else { + __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI); + } #else __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI); #endif __HAL_RCC_RTC_ENABLE(); _hrtc.Instance = RTC; _hrtc.Init.HourFormat = RTC_HOURFORMAT_24; - // Divide async as little as possible so that we have RTC_CLOCK_FREQUENCY count in subseconds. + // Divide async as little as possible so that we have rtc_clock_frequency count in subseconds. // This ensures our timing > 1 second is correct. _hrtc.Init.AsynchPrediv = 0x0; - _hrtc.Init.SynchPrediv = RTC_CLOCK_FREQUENCY - 1; + _hrtc.Init.SynchPrediv = rtc_clock_frequency - 1; _hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; HAL_RTC_Init(&_hrtc); @@ -293,7 +307,7 @@ volatile uint32_t cached_date = 0; volatile uint32_t seconds_to_minute = 0; volatile uint32_t cached_hours_minutes = 0; uint64_t port_get_raw_ticks(uint8_t* subticks) { - uint32_t subseconds = RTC_CLOCK_FREQUENCY - (uint32_t)(RTC->SSR); + uint32_t subseconds = rtc_clock_frequency - (uint32_t)(RTC->SSR); uint32_t time = (uint32_t)(RTC->TR & RTC_TR_RESERVED_MASK); uint32_t date = (uint32_t)(RTC->DR & RTC_DR_RESERVED_MASK); if (date != cached_date) { @@ -341,7 +355,7 @@ void RTC_Alarm_IRQHandler(void) { // Enable 1/1024 second tick. void port_enable_tick(void) { - HAL_RTCEx_SetWakeUpTimer_IT(&_hrtc, RTC_CLOCK_FREQUENCY / 1024 / 2, RTC_WAKEUPCLOCK_RTCCLK_DIV2); + HAL_RTCEx_SetWakeUpTimer_IT(&_hrtc, rtc_clock_frequency / 1024 / 2, RTC_WAKEUPCLOCK_RTCCLK_DIV2); HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 1, 0U); HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn); } @@ -372,7 +386,7 @@ void port_interrupt_after_ticks(uint32_t ticks) { alarm.AlarmMask = RTC_ALARMMASK_ALL; } - alarm.AlarmTime.SubSeconds = RTC_CLOCK_FREQUENCY - + alarm.AlarmTime.SubSeconds = rtc_clock_frequency - ((raw_ticks % 1024) * 32); alarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; alarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_SET; From 09530e5dc34d6fbcbf5fa85a1f7df9d47d8c8329 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 8 May 2020 16:03:39 -0400 Subject: [PATCH 051/216] Did os, _pixelbuf, _pew --- shared-bindings/_pew/PewPew.c | 40 ++++----- shared-bindings/_pew/__init__.c | 4 +- shared-bindings/_pixelbuf/PixelBuf.c | 94 ++++++++++----------- shared-bindings/_pixelbuf/__init__.c | 14 ++-- shared-bindings/os/__init__.c | 120 +++++++++++++-------------- 5 files changed, 134 insertions(+), 138 deletions(-) diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c index 3ff2087614..37188d2b74 100644 --- a/shared-bindings/_pew/PewPew.c +++ b/shared-bindings/_pew/PewPew.c @@ -34,33 +34,33 @@ #include "shared-module/_pew/PewPew.h" #include "supervisor/shared/translate.h" - -//| .. currentmodule:: _pew +//| class PewPew: +//| """.. currentmodule:: _pew //| -//| :class:`PewPew` -- LED matrix and button driver -//| =============================================== +//| :class:`PewPew` -- LED matrix and button driver +//| =============================================== //| -//| This is an internal module to be used by the ``pew.py`` library from -//| https://github.com/pewpew-game/pew-pewpew-standalone-10.x to handle the -//| LED matrix display and buttons on the ``pewpew10`` board. +//| This is an internal module to be used by the ``pew.py`` library from +//| https://github.com/pewpew-game/pew-pewpew-standalone-10.x to handle the +//| LED matrix display and buttons on the ``pewpew10`` board. //| -//| Usage:: +//| Usage:: //| -//| This singleton class is instantiated by the ``pew`` library, and -//| used internally by it. All user-visible interactions are done through -//| that library. +//| This singleton class is instantiated by the ``pew`` library, and +//| used internally by it. All user-visible interactions are done through +//| that library.""" //| -//| .. class:: PewPew(buffer, rows, cols, buttons) +//| def __init__(self, buffer: Any, rows: Any, cols: Any, buttons: Any): +//| """Initializes matrix scanning routines. //| -//| Initializes matrix scanning routines. -//| -//| The ``buffer`` is a 64 byte long ``bytearray`` that stores what should -//| be displayed on the matrix. ``rows`` and ``cols`` are both lists of -//| eight ``DigitalInputOutput`` objects that are connected to the matrix -//| rows and columns. ``buttons`` is a ``DigitalInputOutput`` object that -//| is connected to the common side of all buttons (the other sides of the -//| buttons are connected to rows of the matrix). +//| The ``buffer`` is a 64 byte long ``bytearray`` that stores what should +//| be displayed on the matrix. ``rows`` and ``cols`` are both lists of +//| eight ``DigitalInputOutput`` objects that are connected to the matrix +//| rows and columns. ``buttons`` is a ``DigitalInputOutput`` object that +//| is connected to the common side of all buttons (the other sides of the +//| buttons are connected to rows of the matrix).""" +//| ... //| STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { diff --git a/shared-bindings/_pew/__init__.c b/shared-bindings/_pew/__init__.c index 6c5520ac58..b6aab67264 100644 --- a/shared-bindings/_pew/__init__.c +++ b/shared-bindings/_pew/__init__.c @@ -41,7 +41,7 @@ STATIC mp_obj_t get_pressed(void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_pressed_obj, get_pressed); -//| :mod:`_pew` --- LED matrix driver +//| """:mod:`_pew` --- LED matrix driver //| ================================== //| //| .. module:: _pew @@ -51,7 +51,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_pressed_obj, get_pressed); //| .. toctree:: //| :maxdepth: 3 //| -//| PewPew +//| PewPew""" //| STATIC const mp_rom_map_elem_t pew_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pew) }, diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 61b4c9ae09..1c0888802d 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -44,31 +44,32 @@ extern const int32_t colorwheel(float pos); static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed); -//| .. currentmodule:: pixelbuf +//| class PixelBuf: +//| """.. currentmodule:: pixelbuf //| -//| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices -//| =========================================================================== +//| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices +//| =========================================================================== //| -//| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction. +//| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction.""" //| -//| .. class:: PixelBuf(size, *, byteorder="BGR", brightness=0, auto_write=False, header=b"", trailer=b"") +//| def __init__(self, size: int, *, byteorder: str = "BGR", brightness: float = 0, auto_write: bool = False, header: bytes = b"", trailer: bytes = b""): +//| """Create a PixelBuf object of the specified size, byteorder, and bits per pixel. //| -//| Create a PixelBuf object of the specified size, byteorder, and bits per pixel. +//| When brightness is less than 1.0, a second buffer will be used to store the color values +//| before they are adjusted for brightness. //| -//| When brightness is less than 1.0, a second buffer will be used to store the color values -//| before they are adjusted for brightness. +//| When ``P`` (pwm duration) is present as the 4th character of the byteorder +//| string, the 4th value in the tuple/list for a pixel is the individual pixel +//| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the +//| output buffer (``buf``). //| -//| When ``P`` (pwm duration) is present as the 4th character of the byteorder -//| string, the 4th value in the tuple/list for a pixel is the individual pixel -//| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the -//| output buffer (``buf``). -//| -//| :param ~int size: Number of pixelsx -//| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR") -//| :param ~float brightness: Brightness (0 to 1.0, default 1.0) -//| :param ~bool auto_write: Whether to automatically write pixels (Default False) -//| :param bytes header: Sequence of bytes to always send before pixel values. -//| :param bytes trailer: Sequence of bytes to always send after pixel values. +//| :param ~int size: Number of pixelsx +//| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR") +//| :param ~float brightness: Brightness (0 to 1.0, default 1.0) +//| :param ~bool auto_write: Whether to automatically write pixels (Default False) +//| :param bytes header: Sequence of bytes to always send before pixel values. +//| :param bytes trailer: Sequence of bytes to always send after pixel values.""" +//| ... //| STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, MP_OBJ_FUN_ARGS_MAX, true); @@ -156,9 +157,8 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t } } -//| .. attribute:: bpp -//| -//| The number of bytes per pixel in the buffer (read-only) +//| bpp: Any = ... +//| """The number of bytes per pixel in the buffer (read-only)""" //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp(mp_obj_t self_in) { return MP_OBJ_NEW_SMALL_INT(common_hal__pixelbuf_pixelbuf_get_bpp(self_in)); @@ -173,12 +173,11 @@ const mp_obj_property_t pixelbuf_pixelbuf_bpp_obj = { }; -//| .. attribute:: brightness -//| -//| Float value between 0 and 1. Output brightness. +//| brightness: Any = ... +//| """Float value between 0 and 1. Output brightness. //| //| When brightness is less than 1.0, a second buffer will be used to store the color values -//| before they are adjusted for brightness. +//| before they are adjusted for brightness.""" //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_brightness(mp_obj_t self_in) { return mp_obj_new_float(common_hal__pixelbuf_pixelbuf_get_brightness(self_in)); @@ -205,9 +204,8 @@ const mp_obj_property_t pixelbuf_pixelbuf_brightness_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: auto_write -//| -//| Whether to automatically write the pixels after each update. +//| auto_write: Any = ... +//| """Whether to automatically write the pixels after each update.""" //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_auto_write(mp_obj_t self_in) { return mp_obj_new_bool(common_hal__pixelbuf_pixelbuf_get_auto_write(self_in)); @@ -228,9 +226,8 @@ const mp_obj_property_t pixelbuf_pixelbuf_auto_write_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: byteorder -//| -//| byteorder string for the buffer (read-only) +//| byteorder: Any = ... +//| """byteorder string for the buffer (read-only)""" //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { return common_hal__pixelbuf_pixelbuf_get_byteorder_string(self_in); @@ -253,10 +250,10 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } -//| .. method:: show() -//| -//| Transmits the color data to the pixels so that they are shown. This is done automatically -//| when `auto_write` is True. +//| def show(self, ) -> Any: +//| """Transmits the color data to the pixels so that they are shown. This is done automatically +//| when `auto_write` is True.""" +//| ... //| STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { @@ -265,9 +262,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); -//| .. function:: fill(color) -//| -//| Fills the given pixelbuf with the given color. +//| def fill(color: Any) -> Any: +//| """Fills the given pixelbuf with the given color.""" +//| ... //| STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { @@ -277,17 +274,16 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); - -//| .. method:: __getitem__(index) +//| def __getitem__(self, index: Any) -> Any: +//| """Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values +//| between 0 and 255.""" +//| ... //| -//| Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values -//| between 0 and 255. -//| -//| .. method:: __setitem__(index, value) -//| -//| Sets the pixel value at the given index. Value can either be a tuple of (Red, Green, Blue -//| [, White]) values between 0 and 255 or an integer where the red, green and blue values are -//| packed into the lower three bytes (0xRRGGBB). +//| def __setitem__(self, index: Any, value: Any) -> Any: +//| """Sets the pixel value at the given index. Value can either be a tuple of (Red, Green, Blue +//| [, White]) values between 0 and 255 or an integer where the red, green and blue values are +//| packed into the lower three bytes (0xRRGGBB).""" +//| ... //| STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 424ed23e4c..3c04d436ad 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -33,7 +33,7 @@ #include "shared-bindings/_pixelbuf/PixelBuf.h" -//| :mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers +//| """:mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers //| =========================================================== //| .. module:: _pixelbuf @@ -50,13 +50,13 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| PixelBuf - - -//| .. function:: wheel(n) +//| PixelBuf""" //| -//| C implementation of the common wheel() function found in many examples. -//| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar). + +//| def wheel(n: Any) -> Any: +//| """C implementation of the common wheel() function found in many examples. +//| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar).""" +//| ... //| STATIC mp_obj_t pixelbuf_wheel(mp_obj_t n) { diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index f3b745aefe..2a6b13c9b0 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -37,7 +37,7 @@ #include "py/runtime.h" #include "shared-bindings/os/__init__.h" -//| :mod:`os` --- functions that an OS normally provides +//| """:mod:`os` --- functions that an OS normally provides //| ======================================================== //| //| .. module:: os @@ -46,22 +46,22 @@ //| //| The `os` module is a strict subset of the CPython `cpython:os` module. So, //| code written in CircuitPython will work in CPython but not necessarily the -//| other way around. +//| other way around.""" //| -//| .. function:: uname() -//| -//| Returns a named tuple of operating specific and CircuitPython port -//| specific information. +//| def uname() -> Any: +//| """Returns a named tuple of operating specific and CircuitPython port +//| specific information.""" +//| ... //| STATIC mp_obj_t os_uname(void) { return common_hal_os_uname(); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname); -//| .. function:: chdir(path) -//| -//| Change current directory. +//| def chdir(path: Any) -> Any: +//| """Change current directory.""" +//| ... //| mp_obj_t os_chdir(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); @@ -70,18 +70,18 @@ mp_obj_t os_chdir(mp_obj_t path_in) { } MP_DEFINE_CONST_FUN_OBJ_1(os_chdir_obj, os_chdir); -//| .. function:: getcwd() -//| -//| Get the current directory. +//| def getcwd() -> Any: +//| """Get the current directory.""" +//| ... //| mp_obj_t os_getcwd(void) { return common_hal_os_getcwd(); } MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd); -//| .. function:: listdir([dir]) -//| -//| With no argument, list the current directory. Otherwise list the given directory. +//| def listdir(dir: Any) -> Any: +//| """With no argument, list the current directory. Otherwise list the given directory.""" +//| ... //| mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) { const char* path; @@ -94,9 +94,9 @@ mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) { } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(os_listdir_obj, 0, 1, os_listdir); -//| .. function:: mkdir(path) -//| -//| Create a new directory. +//| def mkdir(path: Any) -> Any: +//| """Create a new directory.""" +//| ... //| mp_obj_t os_mkdir(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); @@ -105,9 +105,9 @@ mp_obj_t os_mkdir(mp_obj_t path_in) { } MP_DEFINE_CONST_FUN_OBJ_1(os_mkdir_obj, os_mkdir); -//| .. function:: remove(path) -//| -//| Remove a file. +//| def remove(path: Any) -> Any: +//| """Remove a file.""" +//| ... //| mp_obj_t os_remove(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); @@ -116,9 +116,9 @@ mp_obj_t os_remove(mp_obj_t path_in) { } MP_DEFINE_CONST_FUN_OBJ_1(os_remove_obj, os_remove); -//| .. function:: rmdir(path) -//| -//| Remove a directory. +//| def rmdir(path: Any) -> Any: +//| """Remove a directory.""" +//| ... //| mp_obj_t os_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) { const char *old_path = mp_obj_str_get_str(old_path_in); @@ -128,9 +128,9 @@ mp_obj_t os_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) { } MP_DEFINE_CONST_FUN_OBJ_2(os_rename_obj, os_rename); -//| .. function:: rename(old_path, new_path) -//| -//| Rename a file. +//| def rename(old_path: Any, new_path: Any) -> Any: +//| """Rename a file.""" +//| ... //| mp_obj_t os_rmdir(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); @@ -139,14 +139,14 @@ mp_obj_t os_rmdir(mp_obj_t path_in) { } MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir); -//| .. function:: stat(path) +//| def stat(path: Any) -> Any: +//| """Get the status of a file or directory. //| -//| Get the status of a file or directory. -//| -//| .. note:: On builds without long integers, the number of seconds -//| for contemporary dates will not fit in a small integer. -//| So the time fields return 946684800, -//| which is the number of seconds corresponding to 1999-12-31. +//| .. note:: On builds without long integers, the number of seconds +//| for contemporary dates will not fit in a small integer. +//| So the time fields return 946684800, +//| which is the number of seconds corresponding to 1999-12-31.""" +//| ... //| mp_obj_t os_stat(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); @@ -154,26 +154,26 @@ mp_obj_t os_stat(mp_obj_t path_in) { } MP_DEFINE_CONST_FUN_OBJ_1(os_stat_obj, os_stat); -//| .. function:: statvfs(path) +//| def statvfs(path: Any) -> Any: +//| """Get the status of a fileystem. //| -//| Get the status of a fileystem. +//| Returns a tuple with the filesystem information in the following order: //| -//| Returns a tuple with the filesystem information in the following order: +//| * ``f_bsize`` -- file system block size +//| * ``f_frsize`` -- fragment size +//| * ``f_blocks`` -- size of fs in f_frsize units +//| * ``f_bfree`` -- number of free blocks +//| * ``f_bavail`` -- number of free blocks for unpriviliged users +//| * ``f_files`` -- number of inodes +//| * ``f_ffree`` -- number of free inodes +//| * ``f_favail`` -- number of free inodes for unpriviliged users +//| * ``f_flag`` -- mount flags +//| * ``f_namemax`` -- maximum filename length //| -//| * ``f_bsize`` -- file system block size -//| * ``f_frsize`` -- fragment size -//| * ``f_blocks`` -- size of fs in f_frsize units -//| * ``f_bfree`` -- number of free blocks -//| * ``f_bavail`` -- number of free blocks for unpriviliged users -//| * ``f_files`` -- number of inodes -//| * ``f_ffree`` -- number of free inodes -//| * ``f_favail`` -- number of free inodes for unpriviliged users -//| * ``f_flag`` -- mount flags -//| * ``f_namemax`` -- maximum filename length -//| -//| Parameters related to inodes: ``f_files``, ``f_ffree``, ``f_avail`` -//| and the ``f_flags`` parameter may return ``0`` as they can be unavailable -//| in a port-specific implementation. +//| Parameters related to inodes: ``f_files``, ``f_ffree``, ``f_avail`` +//| and the ``f_flags`` parameter may return ``0`` as they can be unavailable +//| in a port-specific implementation.""" +//| ... //| mp_obj_t os_statvfs(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); @@ -181,9 +181,9 @@ mp_obj_t os_statvfs(mp_obj_t path_in) { } MP_DEFINE_CONST_FUN_OBJ_1(os_statvfs_obj, os_statvfs); -//| .. function:: sync() -//| -//| Sync all filesystems. +//| def sync() -> Any: +//| """Sync all filesystems.""" +//| ... //| STATIC mp_obj_t os_sync(void) { for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { @@ -194,10 +194,10 @@ STATIC mp_obj_t os_sync(void) { } MP_DEFINE_CONST_FUN_OBJ_0(os_sync_obj, os_sync); -//| .. function:: urandom(size) -//| -//| Returns a string of *size* random bytes based on a hardware True Random -//| Number Generator. When not available, it will raise a NotImplementedError. +//| def urandom(size: Any) -> Any: +//| """Returns a string of *size* random bytes based on a hardware True Random +//| Number Generator. When not available, it will raise a NotImplementedError.""" +//| ... //| STATIC mp_obj_t os_urandom(mp_obj_t size_in) { mp_int_t size = mp_obj_get_int(size_in); @@ -229,9 +229,9 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&os_urandom_obj) }, -//| .. data:: sep +//| """.. data:: sep //| -//| Separator used to delineate path components such as folder and file names. +//| Separator used to delineate path components such as folder and file names.""" //| { MP_ROM_QSTR(MP_QSTR_sep), MP_ROM_QSTR(MP_QSTR__slash_) }, }; From e947e4eb580e080d37445240ec88610fc1787975 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Sat, 9 May 2020 17:56:38 +1000 Subject: [PATCH 052/216] removed duplicate build param --- py/circuitpy_mpconfig.mk | 4 ---- 1 file changed, 4 deletions(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index c805b0501a..73eb4fa5ae 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -211,10 +211,6 @@ CIRCUITPY_ROTARYIO = 1 endif CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO) -ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO = $(CIRCUITPY_FULL_BUILD) -endif -CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) ifndef CIRCUITPY_RTC CIRCUITPY_RTC = 1 From 9ef28d85363718b2bf0dd17e78c50f422712bccb Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Sat, 9 May 2020 12:00:59 -0700 Subject: [PATCH 053/216] Replacing device that was accidentally deleted --- supervisor/shared/external_flash/devices.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/supervisor/shared/external_flash/devices.h b/supervisor/shared/external_flash/devices.h index 08e38ed912..f99fad4e70 100644 --- a/supervisor/shared/external_flash/devices.h +++ b/supervisor/shared/external_flash/devices.h @@ -511,6 +511,25 @@ typedef struct { .single_status_byte = true, \ } +// Settings for the Macronix MX25R1635F 8MiB SPI flash. +// Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7595/MX25R1635F,%20Wide%20Range,%2016Mb,%20v1.6.pdf +// In low power mode, quad operations can only run at 8 MHz. +#define MX25R1635F {\ + .total_size = (1 << 21), /* 2 MiB */ \ + .start_up_time_us = 800, \ + .manufacturer_id = 0xc2, \ + .memory_type = 0x28, \ + .capacity = 0x18, \ + .max_clock_speed_mhz = 33, /* 8 mhz for dual/quad */ \ + .quad_enable_bit_mask = 0x80, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = true, \ +} + // Settings for the Macronix MX25L51245G 64MiB SPI flash. // Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7437/MX25L51245G,%203V,%20512Mb,%20v1.6.pdf #define MX25L51245G {\ From 9e01bb213617fd46723f3dbb869ba51c1985ac21 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Sat, 9 May 2020 12:03:26 -0700 Subject: [PATCH 054/216] Removing erroneous else statements --- .../shared/external_flash/external_flash.c | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 168bbbf68a..a2d8ff5f3a 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -131,31 +131,30 @@ static bool page_erased(uint32_t sector_address) { if (flash_device->no_erase_cmd){ // skip this if device doesn't have an erase command. return true; - } else { - uint8_t short_buffer[4]; - if (read_flash(sector_address, short_buffer, 4)) { - for (uint16_t i = 0; i < 4; i++) { - if (short_buffer[i] != 0xff) { - return false; - } - } - } else { - return false; - } - - // Now check the full length. - uint8_t full_buffer[FILESYSTEM_BLOCK_SIZE]; - if (read_flash(sector_address, full_buffer, FILESYSTEM_BLOCK_SIZE)) { - for (uint16_t i = 0; i < FILESYSTEM_BLOCK_SIZE; i++) { - if (short_buffer[i] != 0xff) { - return false; - } - } - } else { - return false; - } - return true; } + uint8_t short_buffer[4]; + if (read_flash(sector_address, short_buffer, 4)) { + for (uint16_t i = 0; i < 4; i++) { + if (short_buffer[i] != 0xff) { + return false; + } + } + } else { + return false; + } + + // Now check the full length. + uint8_t full_buffer[FILESYSTEM_BLOCK_SIZE]; + if (read_flash(sector_address, full_buffer, FILESYSTEM_BLOCK_SIZE)) { + for (uint16_t i = 0; i < FILESYSTEM_BLOCK_SIZE; i++) { + if (short_buffer[i] != 0xff) { + return false; + } + } + } else { + return false; + } + return true; } // Erases the given sector. Make sure you copied all of the data out of it you @@ -166,16 +165,15 @@ static bool erase_sector(uint32_t sector_address) { if (flash_device->no_erase_cmd){ // skip this if device doesn't have an erase command. return true; - } else { - if (!wait_for_flash_ready() || !write_enable()) { - return false; - } - if (flash_device->no_erase_cmd) { - return true; - } else { - spi_flash_sector_command(CMD_SECTOR_ERASE, sector_address); + } + if (!wait_for_flash_ready() || !write_enable()) { + return false; + } + if (flash_device->no_erase_cmd) { return true; - } + } else { + spi_flash_sector_command(CMD_SECTOR_ERASE, sector_address); + return true; } } From 8b6587a0c646089608b0c8bbace97a73462cf88f Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Sat, 9 May 2020 12:09:01 -0700 Subject: [PATCH 055/216] Unified single_status_byte & no_reset_cmd behavior --- supervisor/shared/external_flash/external_flash.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index a2d8ff5f3a..71b2d6d541 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -244,13 +244,14 @@ void supervisor_flash_init(void) { do { spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); } while ((read_status_response[0] & 0x1) != 0); - - if (!(flash_device->no_reset_cmd)){ + if (!flash_device->single_status_byte) { // The suspended write/erase bit should be low. do { spi_flash_read_command(CMD_READ_STATUS2, read_status_response, 1); } while ((read_status_response[0] & 0x80) != 0); - } else { + } + + if (!(flash_device->no_reset_cmd)){ spi_flash_command(CMD_ENABLE_RESET); spi_flash_command(CMD_RESET); } From 964040b7702a66f44aa8e9f4af6cf74712ed44ed Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Sat, 9 May 2020 12:16:04 -0700 Subject: [PATCH 056/216] More erroneous else statements --- supervisor/shared/external_flash/external_flash.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 71b2d6d541..5bde7fd485 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -62,13 +62,12 @@ static bool wait_for_flash_ready(void) { if (flash_device->no_ready_bit){ // For NVM without a ready bit in status register return ok; - } else { - uint8_t read_status_response[1] = {0x00}; - do { - ok = spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); - } while (ok && (read_status_response[0] & 0x3) != 0); - return ok; } + uint8_t read_status_response[1] = {0x00}; + do { + ok = spi_flash_read_command(CMD_READ_STATUS, read_status_response, 1); + } while (ok && (read_status_response[0] & 0x3) != 0); + return ok; } // Turn on the write enable bit so we can program and erase the flash. @@ -171,10 +170,9 @@ static bool erase_sector(uint32_t sector_address) { } if (flash_device->no_erase_cmd) { return true; - } else { + } spi_flash_sector_command(CMD_SECTOR_ERASE, sector_address); return true; - } } // Sector is really 24 bits. From 206d0e598adb66e2b23a39a7d11e2f5087513205 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Sat, 2 May 2020 02:21:35 -0700 Subject: [PATCH 057/216] Add vectorio: for drawing shapes vectorio builds on m4 express feather Concrete shapes are composed into a VectorShape which is put into a displayio Group for display. VectorShape provides transpose and x/y positioning for shape implementations. Included Shapes: * Circle - A radius; Circle is positioned at its axis in the VectorShape. - You can freely modify the radius to grow and shrink the circle in-place. * Polygon - An ordered list of points. - Beteween each successive point an edge is inferred. A final edge closing the shape is inferred between the last point and the first point. - You can modify the points in a Polygon. The points' coordinate system is relative to (0, 0) so if you'd like a top-center justified 10x20 rectangle you can do points [(-5, 0), (5, 0), (5, 20), (0, 20)] and your VectorShape x and y properties will position the rectangle relative to its top center point * Rectangle A width and a height. --- .../feather_m4_express/mpconfigboard.mk | 3 + py/circuitpy_defns.mk | 8 + py/circuitpy_mpconfig.h | 6 + py/circuitpy_mpconfig.mk | 3 + shared-bindings/vectorio/Circle.c | 79 +++++ shared-bindings/vectorio/Circle.h | 22 ++ shared-bindings/vectorio/Polygon.c | 139 +++++++++ shared-bindings/vectorio/Polygon.h | 24 ++ shared-bindings/vectorio/Rectangle.c | 56 ++++ shared-bindings/vectorio/Rectangle.h | 15 + shared-bindings/vectorio/VectorShape.c | 213 +++++++++++++ shared-bindings/vectorio/VectorShape.h | 25 ++ shared-bindings/vectorio/__init__.c | 46 +++ shared-module/displayio/Group.c | 35 ++- shared-module/displayio/display_core.c | 4 + shared-module/vectorio/Circle.c | 55 ++++ shared-module/vectorio/Circle.h | 17 ++ shared-module/vectorio/Polygon.c | 110 +++++++ shared-module/vectorio/Polygon.h | 16 + shared-module/vectorio/Rectangle.c | 35 +++ shared-module/vectorio/Rectangle.h | 15 + shared-module/vectorio/VectorShape.c | 282 ++++++++++++++++++ shared-module/vectorio/VectorShape.h | 51 ++++ shared-module/vectorio/__init__.c | 3 + shared-module/vectorio/__init__.h | 15 + 25 files changed, 1276 insertions(+), 1 deletion(-) create mode 100644 shared-bindings/vectorio/Circle.c create mode 100644 shared-bindings/vectorio/Circle.h create mode 100644 shared-bindings/vectorio/Polygon.c create mode 100644 shared-bindings/vectorio/Polygon.h create mode 100644 shared-bindings/vectorio/Rectangle.c create mode 100644 shared-bindings/vectorio/Rectangle.h create mode 100644 shared-bindings/vectorio/VectorShape.c create mode 100644 shared-bindings/vectorio/VectorShape.h create mode 100644 shared-bindings/vectorio/__init__.c create mode 100644 shared-module/vectorio/Circle.c create mode 100644 shared-module/vectorio/Circle.h create mode 100644 shared-module/vectorio/Polygon.c create mode 100644 shared-module/vectorio/Polygon.h create mode 100644 shared-module/vectorio/Rectangle.c create mode 100644 shared-module/vectorio/Rectangle.h create mode 100644 shared-module/vectorio/VectorShape.c create mode 100644 shared-module/vectorio/VectorShape.h create mode 100644 shared-module/vectorio/__init__.c create mode 100644 shared-module/vectorio/__init__.h diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk index 38dd477581..7cb53bd130 100644 --- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk @@ -10,3 +10,6 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ + +CIRCUITPY_VECTORIO = 1 + diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index e3892d98e4..c6ea2b45bb 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -145,6 +145,9 @@ endif ifeq ($(CIRCUITPY_DISPLAYIO),1) SRC_PATTERNS += displayio/% terminalio/% fontio/% endif +ifeq ($(CIRCUITPY_VECTORIO),1) +SRC_PATTERNS += vectorio/% +endif ifeq ($(CIRCUITPY_FRAMEBUFFERIO),1) SRC_PATTERNS += framebufferio/% endif @@ -358,6 +361,11 @@ SRC_SHARED_MODULE_ALL = \ displayio/Shape.c \ displayio/TileGrid.c \ displayio/__init__.c \ + vectorio/Circle.c \ + vectorio/Rectangle.c \ + vectorio/Polygon.c \ + vectorio/VectorShape.c \ + vectorio/__init__.c \ fontio/BuiltinFont.c \ fontio/__init__.c \ framebufferio/FramebufferDisplay.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 6b7fc192f9..f48a648c49 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -352,6 +352,11 @@ extern const struct _mp_obj_module_t framebufferio_module; #define FRAMEBUFFERIO_MODULE #endif +#if CIRCUITPY_VECTORIO +extern const struct _mp_obj_module_t vectorio_module; +#define VECTORIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_vectorio), (mp_obj_t)&vectorio_module }, +#endif + #if CIRCUITPY_FREQUENCYIO extern const struct _mp_obj_module_t frequencyio_module; #define FREQUENCYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_frequencyio), (mp_obj_t)&frequencyio_module }, @@ -642,6 +647,7 @@ extern const struct _mp_obj_module_t ustack_module; DISPLAYIO_MODULE \ FONTIO_MODULE \ TERMINALIO_MODULE \ + VECTORIO_MODULE \ ERRNO_MODULE \ FRAMEBUFFERIO_MODULE \ FREQUENCYIO_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 105253aec4..e9e3d80138 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -94,6 +94,9 @@ CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO) CIRCUITPY_FRAMEBUFFERIO ?= 0 CFLAGS += -DCIRCUITPY_FRAMEBUFFERIO=$(CIRCUITPY_FRAMEBUFFERIO) +CIRCUITPY_VECTORIO ?= 0 +CFLAGS += -DCIRCUITPY_VECTORIO=$(CIRCUITPY_VECTORIO) + CIRCUITPY_FREQUENCYIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_FREQUENCYIO=$(CIRCUITPY_FREQUENCYIO) diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c new file mode 100644 index 0000000000..8f409bd654 --- /dev/null +++ b/shared-bindings/vectorio/Circle.c @@ -0,0 +1,79 @@ + +#include "shared-bindings/vectorio/Circle.h" + + +#include + +#include "py/objproperty.h" +#include "py/objtype.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + + +//| .. currentmodule:: vectorio +//| +//| :class:`Circle` -- Represents a circle by its radius +//| ========================================================================== +//| +//| .. class:: Circle(radius) +//| +//| :param int radius: The radius of the circle in pixels +//| +static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_radius }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_radius, MP_ARG_REQUIRED | MP_ARG_INT }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_int_t radius = args[ARG_radius].u_int; + if (radius < 1) { + mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_radius); + } + + vectorio_circle_t *self = m_new_obj(vectorio_circle_t); + self->base.type = &vectorio_circle_type; + common_hal_vectorio_circle_construct(self, radius); + + return MP_OBJ_FROM_PTR(self); +} + + +//| .. attribute:: radius +//| +//| Update the radius of the circle +//| +STATIC mp_obj_t vectorio_circle_obj_get_radius(mp_obj_t self_in) { + vectorio_circle_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_int(common_hal_vectorio_circle_get_radius(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_circle_get_radius_obj, vectorio_circle_obj_get_radius); + +STATIC mp_obj_t vectorio_circle_obj_set_radius(mp_obj_t self_in, mp_obj_t radius) { + vectorio_circle_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_vectorio_circle_set_radius(self, mp_obj_get_int(radius)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_circle_set_radius_obj, vectorio_circle_obj_set_radius); + +const mp_obj_property_t vectorio_circle_radius_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_circle_get_radius_obj, + (mp_obj_t)&vectorio_circle_set_radius_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + +STATIC const mp_rom_map_elem_t vectorio_circle_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_radius), MP_ROM_PTR(&vectorio_circle_radius_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(vectorio_circle_locals_dict, vectorio_circle_locals_dict_table); + +const mp_obj_type_t vectorio_circle_type = { + { &mp_type_type }, + .name = MP_QSTR_Circle, + .make_new = vectorio_circle_make_new, + .locals_dict = (mp_obj_dict_t*)&vectorio_circle_locals_dict, +}; + diff --git a/shared-bindings/vectorio/Circle.h b/shared-bindings/vectorio/Circle.h new file mode 100644 index 0000000000..e8fc048eb8 --- /dev/null +++ b/shared-bindings/vectorio/Circle.h @@ -0,0 +1,22 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_CIRCLE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_CIRCLE_H + +#include "shared-module/vectorio/__init__.h" +#include "shared-module/vectorio/Circle.h" +#include "shared-module/displayio/area.h" + +extern const mp_obj_type_t vectorio_circle_type; + +void common_hal_vectorio_circle_construct(vectorio_circle_t *self, uint16_t radius); + +void common_hal_vectorio_circle_set_on_dirty(vectorio_circle_t *self, vectorio_event_t notification); + +uint32_t common_hal_vectorio_circle_get_pixel(void *circle, int16_t x, int16_t y); + +void common_hal_vectorio_circle_get_area(void *circle, displayio_area_t *out_area); + + +int16_t common_hal_vectorio_circle_get_radius(void *circle); +void common_hal_vectorio_circle_set_radius(void *circle, int16_t radius); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_CIRCLE_H diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c new file mode 100644 index 0000000000..b8bb377ac5 --- /dev/null +++ b/shared-bindings/vectorio/Polygon.c @@ -0,0 +1,139 @@ + +#include "shared-module/vectorio/__init__.h" +#include "shared-bindings/vectorio/Polygon.h" + +#include + +#include "py/obj.h" +#include "py/objproperty.h" +#include "py/objtype.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + + +#define VECTORIO_POLYGON_DEBUG(...) (void)0 +// #define VECTORIO_POLYGON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + + +// Converts a list of points tuples to a flat list of ints for speedier internal use. +// Also validates the points. +static mp_obj_t _to_points_list(mp_obj_t points_tuple_list) { + size_t len = 0; + mp_obj_t *items; + mp_obj_list_get(points_tuple_list, &len, &items); + VECTORIO_POLYGON_DEBUG("polygon_points_list len: %d\n", len); + + if ( len == 0 ) { + mp_raise_TypeError_varg(translate("empty %q list"), MP_QSTR_point); + } + + mp_obj_t points_list = mp_obj_new_list(0, NULL); + + for ( size_t i = 0; i < len; ++i) { + size_t tuple_len = 0; + mp_obj_t *tuple_items; + mp_obj_tuple_get(items[i], &tuple_len, &tuple_items); + + if (tuple_len != 2) { + mp_raise_ValueError_varg(translate("%q must be a tuple of length 2"), MP_QSTR_point); + } + int value; + if (!mp_obj_get_int_maybe(tuple_items[0], &value)) { + mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); + } + mp_obj_list_append(points_list, MP_OBJ_NEW_SMALL_INT(value)); + if (!mp_obj_get_int_maybe(tuple_items[1], &value)) { + mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); + } + mp_obj_list_append(points_list, MP_OBJ_NEW_SMALL_INT(value)); + } + return points_list; +} + + + +//| .. currentmodule:: vectorio +//| +//| :class:`Polygon` -- Represents a closed shape by ordered vertices +//| ========================================================================== +//| +//| .. class:: Polygon( List[ Tuple[ x, y ], ... ] ) +//| +//| :param [Point] points_array: Vertices for the polygon +//| +static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_points_list }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_points, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + if (!MP_OBJ_IS_TYPE(args[ARG_points_list].u_obj, &mp_type_list)) { + mp_raise_TypeError_varg(translate("%q list must be a list"), MP_QSTR_point); + } + mp_obj_t points_list = _to_points_list(args[ARG_points_list].u_obj); + + vectorio_polygon_t *self = m_new_obj(vectorio_polygon_t); + self->base.type = &vectorio_polygon_type; + + common_hal_vectorio_polygon_construct(self, points_list); + + return MP_OBJ_FROM_PTR(self); +} + + +//| .. attribute:: points +//| +//| Set a new look and shape for this polygon +//| +STATIC mp_obj_t vectorio_polygon_obj_get_points(mp_obj_t self_in) { + vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t list = mp_obj_new_list(0, NULL); + + size_t len = 0; + mp_obj_t *items; + mp_obj_list_get(common_hal_vectorio_polygon_get_points(self), &len, &items); + + for (size_t i = 0; i < len; i += 2) { + mp_obj_t tuple[] = { items[i], items[i+1] }; + mp_obj_list_append( + list, + mp_obj_new_tuple(2, tuple) + ); + } + return list; +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_polygon_get_points_obj, vectorio_polygon_obj_get_points); + +STATIC mp_obj_t vectorio_polygon_obj_set_points(mp_obj_t self_in, mp_obj_t points) { + vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in); + + mp_obj_t points_list = _to_points_list(points); + + common_hal_vectorio_polygon_set_points(self, points_list); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_polygon_set_points_obj, vectorio_polygon_obj_set_points); + +const mp_obj_property_t vectorio_polygon_points_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_polygon_get_points_obj, + (mp_obj_t)&vectorio_polygon_set_points_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + + +STATIC const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_points), MP_ROM_PTR(&vectorio_polygon_points_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(vectorio_polygon_locals_dict, vectorio_polygon_locals_dict_table); + +const mp_obj_type_t vectorio_polygon_type = { + { &mp_type_type }, + .name = MP_QSTR_Polygon, + .make_new = vectorio_polygon_make_new, + .locals_dict = (mp_obj_dict_t*)&vectorio_polygon_locals_dict, +}; + diff --git a/shared-bindings/vectorio/Polygon.h b/shared-bindings/vectorio/Polygon.h new file mode 100644 index 0000000000..5594fbec4a --- /dev/null +++ b/shared-bindings/vectorio/Polygon.h @@ -0,0 +1,24 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_POLYGON_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_POLYGON_H + +#include "shared-module/vectorio/Polygon.h" +#include "shared-module/displayio/area.h" +#include "shared-module/vectorio/__init__.h" + +extern const mp_obj_type_t vectorio_polygon_type; + +void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t points_list); +void common_hal_vectorio_polygon_set_on_dirty(vectorio_polygon_t *self, vectorio_event_t notification); + + +uint32_t common_hal_vectorio_polygon_get_pixel(void *polygon, int16_t x, int16_t y); + +void common_hal_vectorio_polygon_get_area(void *polygon, displayio_area_t *out_area); + + + +mp_obj_t common_hal_vectorio_polygon_get_points(vectorio_polygon_t *self); +void common_hal_vectorio_polygon_set_points(vectorio_polygon_t *self, mp_obj_t points_list); + + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_POLYGON_H diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c new file mode 100644 index 0000000000..ea468f7888 --- /dev/null +++ b/shared-bindings/vectorio/Rectangle.c @@ -0,0 +1,56 @@ + +#include "shared-bindings/vectorio/Rectangle.h" + +#include + +#include "py/objtype.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + + +//| .. currentmodule:: vectorio +//| +//| :class:`Rectangle` -- Represents a rectangle by defining its bounds +//| ========================================================================== +//| +//| .. class:: Rectangle(width, height) +//| +//| :param int width: The number of pixels wide +//| :param int height: The number of pixels high +//| +static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_width, ARG_height }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_width, MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_height, MP_ARG_REQUIRED | MP_ARG_INT }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_int_t width = args[ARG_width].u_int; + if (width < 1) { + mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_width); + } + mp_int_t height = args[ARG_height].u_int; + if (height < 1) { + mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_height); + } + + vectorio_rectangle_t *self = m_new_obj(vectorio_rectangle_t); + self->base.type = &vectorio_rectangle_type; + common_hal_vectorio_rectangle_construct(self, width, height); + + return MP_OBJ_FROM_PTR(self); +} + + +STATIC const mp_rom_map_elem_t vectorio_rectangle_locals_dict_table[] = { +}; +STATIC MP_DEFINE_CONST_DICT(vectorio_rectangle_locals_dict, vectorio_rectangle_locals_dict_table); + +const mp_obj_type_t vectorio_rectangle_type = { + { &mp_type_type }, + .name = MP_QSTR_Rectangle, + .make_new = vectorio_rectangle_make_new, + .locals_dict = (mp_obj_dict_t*)&vectorio_rectangle_locals_dict, +}; diff --git a/shared-bindings/vectorio/Rectangle.h b/shared-bindings/vectorio/Rectangle.h new file mode 100644 index 0000000000..bb461ed9d5 --- /dev/null +++ b/shared-bindings/vectorio/Rectangle.h @@ -0,0 +1,15 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_RECTANGLE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_RECTANGLE_H + +#include "shared-module/vectorio/Rectangle.h" +#include "shared-module/displayio/area.h" + +extern const mp_obj_type_t vectorio_rectangle_type; + +void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_t width, uint32_t height); + +uint32_t common_hal_vectorio_rectangle_get_pixel(void *rectangle, int16_t x, int16_t y); + +void common_hal_vectorio_rectangle_get_area(void *rectangle, displayio_area_t *out_area); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_RECTANGLE_H diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c new file mode 100644 index 0000000000..8f99577b4f --- /dev/null +++ b/shared-bindings/vectorio/VectorShape.c @@ -0,0 +1,213 @@ + +#include "shared-module/vectorio/__init__.h" +#include "shared-bindings/vectorio/VectorShape.h" +#include "shared-bindings/vectorio/Circle.h" +#include "shared-bindings/vectorio/Polygon.h" +#include "shared-bindings/vectorio/Rectangle.h" + +#include "shared-bindings/displayio/ColorConverter.h" +#include "shared-bindings/displayio/Palette.h" + +#include + +#include "lib/utils/context_manager_helpers.h" + +#include "py/binary.h" +#include "py/objproperty.h" +#include "py/objtype.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + + +//| .. currentmodule:: vectorio +//| +//| :class:`VectorShape` -- Binds a vector shape to a location and pixel color +//| ========================================================================== +//| +//| .. class:: VectorShape( shape, pixel_shader, x=0, y=0) +//| +//| :param vectorio.Polygon shape: The shape to draw. +//| :param displayio.Palette pixel_shader: The pixel shader that produces colors from values +//| :param int x: Initial x position of the center axis of the shape within the parent. +//| :param int y: Initial y position of the center axis of the shape within the parent. +//| +STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_shape, ARG_pixel_shader, ARG_x, ARG_y, ARG_transpose_xy }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_shape, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, + { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, + { MP_QSTR_x, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, + { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, + { MP_QSTR_transpose_xy, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj; + if (!MP_OBJ_IS_TYPE(pixel_shader, &displayio_colorconverter_type) && + !MP_OBJ_IS_TYPE(pixel_shader, &displayio_palette_type)) { + mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader); + } + + int16_t x = args[ARG_x].u_int; + int16_t y = args[ARG_y].u_int; + + mp_obj_t shape = args[ARG_shape].u_obj; + vectorio_ishape_t ishape; + // Wire up shape functions + if (MP_OBJ_IS_TYPE(shape, &vectorio_polygon_type)) { + ishape.shape = shape; + ishape.get_area = &common_hal_vectorio_polygon_get_area; + ishape.get_pixel = &common_hal_vectorio_polygon_get_pixel; + } else if (MP_OBJ_IS_TYPE(shape, &vectorio_rectangle_type)) { + ishape.shape = shape; + ishape.get_area = &common_hal_vectorio_rectangle_get_area; + ishape.get_pixel = &common_hal_vectorio_rectangle_get_pixel; + } else if (MP_OBJ_IS_TYPE(shape, &vectorio_circle_type)) { + ishape.shape = shape; + ishape.get_area = &common_hal_vectorio_circle_get_area; + ishape.get_pixel = &common_hal_vectorio_circle_get_pixel; + } else { + mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_shape); + } + + vectorio_vector_shape_t *self = m_new_obj(vectorio_vector_shape_t); + self->base.type = &vectorio_vector_shape_type; + common_hal_vectorio_vector_shape_construct(self, + ishape, pixel_shader, x, y, args[ARG_transpose_xy].u_bool + ); + + // Wire up event callbacks + vectorio_event_t on_dirty = { + .obj = self, + .event = &common_hal_vectorio_vector_shape_set_dirty + }; + + if (MP_OBJ_IS_TYPE(shape, &vectorio_polygon_type)) { + common_hal_vectorio_polygon_set_on_dirty(self->ishape.shape, on_dirty); + } else if (MP_OBJ_IS_TYPE(shape, &vectorio_rectangle_type)) { + common_hal_vectorio_circle_set_on_dirty(self->ishape.shape, on_dirty); + } else if (MP_OBJ_IS_TYPE(shape, &vectorio_circle_type)) { + } else { + mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_shape); + } + + return MP_OBJ_FROM_PTR(self); +} + + +//| .. attribute:: x +//| +//| X position of the center point of the shape in the parent. +//| +STATIC mp_obj_t vectorio_vector_shape_obj_get_x(mp_obj_t self_in) { + vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_vectorio_vector_shape_get_x(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_x_obj, vectorio_vector_shape_obj_get_x); + +STATIC mp_obj_t vectorio_vector_shape_obj_set_x(mp_obj_t self_in, mp_obj_t x_obj) { + vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); + + mp_int_t x = mp_obj_get_int(x_obj); + common_hal_vectorio_vector_shape_set_x(self, x); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_x_obj, vectorio_vector_shape_obj_set_x); + +const mp_obj_property_t vectorio_vector_shape_x_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_vector_shape_get_x_obj, + (mp_obj_t)&vectorio_vector_shape_set_x_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + +//| .. attribute:: y +//| +//| Y position of the center point of the shape in the parent. +//| +STATIC mp_obj_t vectorio_vector_shape_obj_get_y(mp_obj_t self_in) { + vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_vectorio_vector_shape_get_y(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_y_obj, vectorio_vector_shape_obj_get_y); + +STATIC mp_obj_t vectorio_vector_shape_obj_set_y(mp_obj_t self_in, mp_obj_t y_obj) { + vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); + + mp_int_t y = mp_obj_get_int(y_obj); + common_hal_vectorio_vector_shape_set_y(self, y); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_y_obj, vectorio_vector_shape_obj_set_y); + +const mp_obj_property_t vectorio_vector_shape_y_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_vector_shape_get_y_obj, + (mp_obj_t)&vectorio_vector_shape_set_y_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + +//| .. attribute:: transpose_xy +//| +//| true if the object is to be flipped. +//| +STATIC mp_obj_t vectorio_vector_shape_obj_get_transpose_xy(mp_obj_t self_in) { + vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_bool(common_hal_vectorio_vector_shape_get_transpose_xy(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_transpose_xy_obj, vectorio_vector_shape_obj_get_transpose_xy); + +const mp_obj_property_t vectorio_vector_shape_transpose_xy_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_vector_shape_get_transpose_xy_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +//| .. attribute:: pixel_shader +//| +//| The pixel shader of the shape. +//| +STATIC mp_obj_t vectorio_vector_shape_obj_get_pixel_shader(mp_obj_t self_in) { + vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_vectorio_vector_shape_get_pixel_shader(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_pixel_shader_obj, vectorio_vector_shape_obj_get_pixel_shader); + +STATIC mp_obj_t vectorio_vector_shape_obj_set_pixel_shader(mp_obj_t self_in, mp_obj_t pixel_shader) { + vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); + if (!MP_OBJ_IS_TYPE(pixel_shader, &displayio_palette_type) && !MP_OBJ_IS_TYPE(pixel_shader, &displayio_colorconverter_type)) { + mp_raise_TypeError(translate("pixel_shader must be displayio.Palette or displayio.ColorConverter")); + } + + common_hal_vectorio_vector_shape_set_pixel_shader(self, pixel_shader); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_pixel_shader_obj, vectorio_vector_shape_obj_set_pixel_shader); + +const mp_obj_property_t vectorio_vector_shape_pixel_shader_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_vector_shape_get_pixel_shader_obj, + (mp_obj_t)&vectorio_vector_shape_set_pixel_shader_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + +STATIC const mp_rom_map_elem_t vectorio_vector_shape_locals_dict_table[] = { + // Properties + { MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&vectorio_vector_shape_x_obj) }, + { MP_ROM_QSTR(MP_QSTR_y), MP_ROM_PTR(&vectorio_vector_shape_y_obj) }, + { MP_ROM_QSTR(MP_QSTR_pixel_shader), MP_ROM_PTR(&vectorio_vector_shape_pixel_shader_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(vectorio_vector_shape_locals_dict, vectorio_vector_shape_locals_dict_table); + +const mp_obj_type_t vectorio_vector_shape_type = { + { &mp_type_type }, + .name = MP_QSTR_VectorShape, + .make_new = vectorio_vector_shape_make_new, + .locals_dict = (mp_obj_dict_t*)&vectorio_vector_shape_locals_dict, +}; diff --git a/shared-bindings/vectorio/VectorShape.h b/shared-bindings/vectorio/VectorShape.h new file mode 100644 index 0000000000..ad745b30ff --- /dev/null +++ b/shared-bindings/vectorio/VectorShape.h @@ -0,0 +1,25 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H + +#include "shared-module/vectorio/VectorShape.h" + +extern const mp_obj_type_t vectorio_vector_shape_type; + +void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, + vectorio_ishape_t ishape, + mp_obj_t pixel_shader, uint16_t x, uint16_t y, bool transpose_xy); + +void common_hal_vectorio_vector_shape_set_dirty(void *self); + +mp_int_t common_hal_vectorio_vector_shape_get_x(vectorio_vector_shape_t *self); +void common_hal_vectorio_vector_shape_set_x(vectorio_vector_shape_t *self, mp_int_t x); + +mp_int_t common_hal_vectorio_vector_shape_get_y(vectorio_vector_shape_t *self); +void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_int_t y); + +bool common_hal_vectorio_vector_shape_get_transpose_xy(vectorio_vector_shape_t *self); + +mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape_t *self); +void common_hal_vectorio_vector_shape_set_pixel_shader(vectorio_vector_shape_t *self, mp_obj_t pixel_shader); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H diff --git a/shared-bindings/vectorio/__init__.c b/shared-bindings/vectorio/__init__.c new file mode 100644 index 0000000000..b9e3828bdc --- /dev/null +++ b/shared-bindings/vectorio/__init__.c @@ -0,0 +1,46 @@ +#include + +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/vectorio/Circle.h" +#include "shared-bindings/vectorio/Polygon.h" +#include "shared-bindings/vectorio/Rectangle.h" +#include "shared-bindings/vectorio/VectorShape.h" + +//| :mod:`vectorio` --- Lightweight 2d shapes for displays +//| ========================================================================= +//| +//| .. module:: vectorio +//| :synopsis: Adds vector graphics to displayio +//| :platform: SAMD21, SAMD51, nRF52 +//| +//| The `vectorio` module contains classes to construct shapes +//| by describing their points rather than providing them in bitmaps. +//| +//| Libraries +//| +//| .. toctree:: +//| :maxdepth: 3 +//| +//| Circle +//| Polygon +//| Rectangle +//| VectorShape +//| + + +STATIC const mp_rom_map_elem_t vectorio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_vectorio) }, + { MP_ROM_QSTR(MP_QSTR_Circle), MP_ROM_PTR(&vectorio_circle_type) }, + { MP_ROM_QSTR(MP_QSTR_Polygon), MP_ROM_PTR(&vectorio_polygon_type) }, + { MP_ROM_QSTR(MP_QSTR_Rectangle), MP_ROM_PTR(&vectorio_rectangle_type) }, + { MP_ROM_QSTR(MP_QSTR_VectorShape), MP_ROM_PTR(&vectorio_vector_shape_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(vectorio_module_globals, vectorio_module_globals_table); + +const mp_obj_module_t vectorio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&vectorio_module_globals, +}; diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index d69e9f5859..9d50dabec7 100644 --- a/shared-module/displayio/Group.c +++ b/shared-module/displayio/Group.c @@ -29,6 +29,11 @@ #include "py/runtime.h" #include "shared-bindings/displayio/TileGrid.h" +#if CIRCUITPY_VECTORIO +#include "shared-bindings/vectorio/VectorShape.h" +#endif + + void common_hal_displayio_group_construct(displayio_group_t* self, uint32_t max_size, uint32_t scale, mp_int_t x, mp_int_t y) { displayio_group_child_t* children = m_new(displayio_group_child_t, max_size); displayio_group_construct(self, children, max_size, scale, x, y); @@ -200,7 +205,14 @@ void common_hal_displayio_group_set_y(displayio_group_t* self, mp_int_t y) { } 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); + mp_obj_t native_layer; +#if CIRCUITPY_VECTORIO + native_layer = mp_instance_cast_to_native_base(layer, &vectorio_vector_shape_type); + if (native_layer != MP_OBJ_NULL) { + return native_layer; + } +#endif + 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) { @@ -317,6 +329,15 @@ bool displayio_group_fill_area(displayio_group_t *self, const _displayio_colorsp bool full_coverage = false; for (int32_t i = self->size - 1; i >= 0 ; i--) { mp_obj_t layer = self->children[i].native; +#if CIRCUITPY_VECTORIO + if (MP_OBJ_IS_TYPE(layer, &vectorio_vector_shape_type)) { + if (vectorio_vector_shape_fill_area(layer, colorspace, area, mask, buffer)) { + full_coverage = true; + break; + } + } + else +#endif if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) { if (displayio_tilegrid_fill_area(layer, colorspace, area, mask, buffer)) { full_coverage = true; @@ -336,6 +357,12 @@ void displayio_group_finish_refresh(displayio_group_t *self) { self->item_removed = false; for (int32_t i = self->size - 1; i >= 0 ; i--) { mp_obj_t layer = self->children[i].native; +#if CIRCUITPY_VECTORIO + if (MP_OBJ_IS_TYPE(layer, &vectorio_vector_shape_type)) { + vectorio_vector_shape_finish_refresh(layer); + } + else +#endif if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) { displayio_tilegrid_finish_refresh(layer); } else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) { @@ -352,6 +379,12 @@ displayio_area_t* displayio_group_get_refresh_areas(displayio_group_t *self, dis for (int32_t i = self->size - 1; i >= 0 ; i--) { mp_obj_t layer = self->children[i].native; +#if CIRCUITPY_VECTORIO + if (MP_OBJ_IS_TYPE(layer, &vectorio_vector_shape_type)) { + tail = vectorio_vector_shape_get_refresh_areas(layer, tail); + } + else +#endif 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)) { diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index d01100f7f1..43f2d19375 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -40,6 +40,9 @@ #include #include +#define DISPLAYIO_CORE_DEBUG(...) (void)0 +// #define DISPLAYIO_CORE_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + void displayio_display_core_construct(displayio_display_core_t* self, mp_obj_t bus, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word) { @@ -298,6 +301,7 @@ void displayio_display_core_start_refresh(displayio_display_core_t* self) { void displayio_display_core_finish_refresh(displayio_display_core_t* self) { if (self->current_group != NULL) { + DISPLAYIO_CORE_DEBUG("displayiocore group_finish_refresh\n"); displayio_group_finish_refresh(self->current_group); } self->full_refresh = false; diff --git a/shared-module/vectorio/Circle.c b/shared-module/vectorio/Circle.c new file mode 100644 index 0000000000..6bcd6318fe --- /dev/null +++ b/shared-module/vectorio/Circle.c @@ -0,0 +1,55 @@ + +#include "shared-bindings/vectorio/Circle.h" +#include "shared-module/vectorio/__init__.h" +#include "shared-module/displayio/area.h" + +#include "py/runtime.h" +#include "stdlib.h" + + +void common_hal_vectorio_circle_construct(vectorio_circle_t *self, uint16_t radius) { + self->radius = radius; + self->on_dirty.obj = NULL; +} + +void common_hal_vectorio_circle_set_on_dirty(vectorio_circle_t *self, vectorio_event_t on_dirty) { + if (self->on_dirty.obj != NULL) { + mp_raise_TypeError(translate("circle can only be registered in one parent")); + } + self->on_dirty = on_dirty; +} + + +uint32_t common_hal_vectorio_circle_get_pixel(void *obj, int16_t x, int16_t y) { + vectorio_circle_t *self = obj; + int16_t radius = abs(self->radius); + x = abs(x); + y = abs(y); + if (x+y <= radius) return 1; + if (x > radius) return 0; + if (y > radius) return 0; + return (int32_t)x*x + (int32_t)y*y <= (int32_t)radius*radius; +} + + +void common_hal_vectorio_circle_get_area(void *circle, displayio_area_t *out_area) { + vectorio_circle_t *self = circle; + out_area->x1 = -1 * self->radius; + out_area->y1 = -1 * self->radius; + out_area->x2 = self->radius + 1; + out_area->y2 = self->radius + 1; +} + +int16_t common_hal_vectorio_circle_get_radius(void *obj) { + vectorio_circle_t *self = obj; + return self->radius; +} + +void common_hal_vectorio_circle_set_radius(void *obj, int16_t radius) { + vectorio_circle_t *self = obj; + self->radius = abs(radius); + if (self->on_dirty.obj != NULL) { + self->on_dirty.event(self->on_dirty.obj); + } +} + diff --git a/shared-module/vectorio/Circle.h b/shared-module/vectorio/Circle.h new file mode 100644 index 0000000000..4b43d767ec --- /dev/null +++ b/shared-module/vectorio/Circle.h @@ -0,0 +1,17 @@ +#ifndef MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_CIRCLE_H +#define MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_CIRCLE_H + +#include + +#include "py/obj.h" + +#include "shared-module/vectorio/__init__.h" + +typedef struct { + mp_obj_base_t base; + uint16_t radius; + vectorio_event_t on_dirty; +} vectorio_circle_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_CIRCLE_H + diff --git a/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c new file mode 100644 index 0000000000..6722912c2d --- /dev/null +++ b/shared-module/vectorio/Polygon.c @@ -0,0 +1,110 @@ + +#include "shared-module/vectorio/__init__.h" +#include "shared-bindings/vectorio/Polygon.h" +#include "shared-module/displayio/area.h" + +#include "py/runtime.h" +#include "stdlib.h" +#include + + +#define VECTORIO_POLYGON_DEBUG(...) (void)0 +// #define VECTORIO_POLYGON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + + +void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t points_list) { + VECTORIO_POLYGON_DEBUG("%p polygon_construct\n", self); + self->points_list = points_list; + self->on_dirty.obj = NULL; +} + + +mp_obj_t common_hal_vectorio_polygon_get_points(vectorio_polygon_t *self) { + return self->points_list; +} +void common_hal_vectorio_polygon_set_points(vectorio_polygon_t *self, mp_obj_t points_list) { + self->points_list = points_list; + if (self->on_dirty.obj != NULL) { + self->on_dirty.event(self->on_dirty.obj); + } +} + +void common_hal_vectorio_polygon_set_on_dirty(vectorio_polygon_t *self, vectorio_event_t notification) { + if ( self->on_dirty.obj != NULL ) { + mp_raise_TypeError(translate("polygon can only be registered in one parent")); + } + self->on_dirty = notification; +} + + +void common_hal_vectorio_polygon_get_area(void *polygon, displayio_area_t *area) { + VECTORIO_POLYGON_DEBUG("%p polygon get_area", polygon); + vectorio_polygon_t *self = polygon; + size_t len; + mp_obj_t *points; + mp_obj_list_get(self->points_list, &len, &points); + VECTORIO_POLYGON_DEBUG(" len: %2d, points: %d\n", len, len/2); + + area->x1 = SHRT_MAX; + area->y1 = SHRT_MAX; + area->x2 = SHRT_MIN; + area->y2 = SHRT_MIN; + for (size_t i=0; i < len; ++i) { + mp_int_t x = mp_obj_get_int(points[i]); + ++i; + mp_int_t y = mp_obj_get_int(points[i]); + if (x <= area->x1) area->x1 = x-1; + if (y <= area->y1) area->y1 = y-1; + if (x >= area->x2) area->x2 = x+1; + if (y >= area->y2) area->y2 = y+1; + } +} + + +// <0 if the point is to the left of the line vector +// 0 if the point is on the line +// >0 if the point is to the right of the line vector +__attribute__((always_inline)) static inline int line_side( mp_int_t x1, mp_int_t y1, mp_int_t x2, mp_int_t y2, int16_t px, int16_t py ) { + return (px - x1) * (y2 - y1) + - (py - y1) * (x2 - x1); +} + + +uint32_t common_hal_vectorio_polygon_get_pixel(void *obj, int16_t x, int16_t y) { + VECTORIO_POLYGON_DEBUG("%p polygon get_pixel %d, %d\n", obj, x, y); + vectorio_polygon_t *self = obj; + size_t len; + mp_obj_t *points; + mp_obj_list_get(self->points_list, &len, &points); + + if (len == 0) { + return 0; + } + + int winding_number = 0; + mp_int_t x1 = mp_obj_get_int(points[0]); + mp_int_t y1 = mp_obj_get_int(points[1]); + for (size_t i=2; i <= len + 1; ++i) { + VECTORIO_POLYGON_DEBUG(" {(%3d, %3d),", x1, y1); + mp_int_t x2 = mp_obj_get_int(points[i % len]); + ++i; + mp_int_t y2 = mp_obj_get_int(points[i % len]); + VECTORIO_POLYGON_DEBUG(" (%3d, %3d)}\n", x2, y2); + if ( y1 <= y ) { + if ( y2 > y && line_side(x1, y1, x2, y2, x, y) > 0 ) { + // Wind up, point is to the right of the edge vector + ++winding_number; + VECTORIO_POLYGON_DEBUG(" wind:%2d winding_number:%2d\n", 1, winding_number); + } + } else if ( y2 <= y && line_side(x1, y1, x2, y2, x, y) < 0 ) { + // Wind down, point is to the left of the edge vector + --winding_number; + VECTORIO_POLYGON_DEBUG(" wind:%2d winding_number:%2d\n", -1, winding_number); + } + + x1 = x2; + y1 = y2; + } + return winding_number == 0 ? 0 : 1; +} + diff --git a/shared-module/vectorio/Polygon.h b/shared-module/vectorio/Polygon.h new file mode 100644 index 0000000000..1aef854a7b --- /dev/null +++ b/shared-module/vectorio/Polygon.h @@ -0,0 +1,16 @@ +#ifndef MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_POLYGON_H +#define MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_POLYGON_H + +#include + +#include "py/obj.h" +#include "shared-module/vectorio/__init__.h" + +typedef struct { + mp_obj_base_t base; + // A micropython List[ x, y, ... ] + mp_obj_t points_list; + vectorio_event_t on_dirty; +} vectorio_polygon_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_POLYGON_H diff --git a/shared-module/vectorio/Rectangle.c b/shared-module/vectorio/Rectangle.c new file mode 100644 index 0000000000..dfad58a4d1 --- /dev/null +++ b/shared-module/vectorio/Rectangle.c @@ -0,0 +1,35 @@ +#include "shared-bindings/vectorio/Rectangle.h" +#include "shared-module/displayio/area.h" + +#include "py/runtime.h" + + +void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_t width, uint32_t height) { + self->width = width; + self->height = height; +} + + +uint32_t common_hal_vectorio_rectangle_get_pixel(void *obj, int16_t x, int16_t y) { + vectorio_rectangle_t *self = obj; + if (x < 0 || x >= self->width || y >= self->height || y < 0) { + return 0; + } + return 1; +} + + +void common_hal_vectorio_rectangle_get_area(void *rectangle, displayio_area_t *out_area) { + vectorio_rectangle_t *self = rectangle; + out_area->x1 = 0; + out_area->y1 = 0; + out_area->x2 = self->width; + out_area->y2 = self->height; +} + + +uint32_t common_hal_vectorio_rectangle_get_height(void *rectangle) { + vectorio_rectangle_t *self = rectangle; + return self->height; +} + diff --git a/shared-module/vectorio/Rectangle.h b/shared-module/vectorio/Rectangle.h new file mode 100644 index 0000000000..c1f2a7a64e --- /dev/null +++ b/shared-module/vectorio/Rectangle.h @@ -0,0 +1,15 @@ +#ifndef MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_RECTANGLE_H +#define MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_RECTANGLE_H + +#include + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + uint16_t width; + uint16_t height; +} vectorio_rectangle_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_RECTANGLE_H + diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c new file mode 100644 index 0000000000..985b778584 --- /dev/null +++ b/shared-module/vectorio/VectorShape.c @@ -0,0 +1,282 @@ + +#include "stdlib.h" + +#include "shared-module/vectorio/__init__.h" +#include "shared-bindings/vectorio/VectorShape.h" + +#include "py/runtime.h" +#include "shared-bindings/displayio/ColorConverter.h" +#include "shared-bindings/displayio/Palette.h" + +#include "shared-bindings/vectorio/Circle.h" +#include "shared-bindings/vectorio/Polygon.h" +#include "shared-bindings/vectorio/Rectangle.h" + +// Lifecycle actions. +#define VECTORIO_SHAPE_DEBUG(...) (void)0 +// #define VECTORIO_SHAPE_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + + +// Really verbose. +#define VECTORIO_SHAPE_PIXEL_DEBUG(...) (void)0 +// #define VECTORIO_SHAPE_PIXEL_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + + +inline __attribute__((always_inline)) +static int32_t max(int32_t a, int32_t b) { + return a > b ? a : b; +} + + +inline __attribute__((always_inline)) +static void _transpose_area(displayio_area_t *out_area) { + int16_t swap = out_area->x1; + out_area->x1 = out_area->y1; + out_area->y1 = swap; + swap = out_area->x2; + out_area->x2 = out_area->y2; + out_area->y2 = swap; +} + + +inline __attribute__((always_inline)) +static void _get_shape_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) { + VECTORIO_SHAPE_DEBUG("%p get_area\n", self); + self->ishape.get_area(self->ishape.shape, out_area); +} + + +inline __attribute__((always_inline)) +static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) { + VECTORIO_SHAPE_DEBUG("%p get_screen_area\n", self); + self->ishape.get_area(self->ishape.shape, out_area); + if (self->transpose_xy) { + _transpose_area(out_area); + displayio_area_shift(out_area, self->y, self->x); + } else { + displayio_area_shift(out_area, self->x, self->y); + } +} + + +// This must be invoked each time a shape changes its position or its shape in any way. +void common_hal_vectorio_vector_shape_set_dirty(void *vector_shape) { + vectorio_vector_shape_t *self = vector_shape; + // In screen space. Need to offset the shape space. + displayio_area_t current_area; + _get_screen_area(self, ¤t_area); + VECTORIO_SHAPE_DEBUG("%p shape_dirty current:{(%3d,%3d), (%3d,%3d)} dirty:{(%3d,%3d), (%3d,%3d)}", + self, + current_area.x1, current_area.y1, current_area.x2, current_area.y2, + self->ephemeral_dirty_area.x1, self->ephemeral_dirty_area.y1, self->ephemeral_dirty_area.x2, self->ephemeral_dirty_area.y2); + self->dirty = true; + // Dirty area tracks the shape's footprint between draws. It's reset on refresh finish, + displayio_area_expand(&self->ephemeral_dirty_area, ¤t_area); + VECTORIO_SHAPE_DEBUG(" -> expanded:{(%3d,%3d), (%3d,%3d)}\n", self->ephemeral_dirty_area.x1, self->ephemeral_dirty_area.y1, self->ephemeral_dirty_area.x2, self->ephemeral_dirty_area.y2); +} + + +void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, + vectorio_ishape_t ishape, + mp_obj_t pixel_shader, uint16_t x, uint16_t y, bool transpose_xy) { + VECTORIO_SHAPE_DEBUG("%p vector_shape_construct x:%3d, y:%3d\n", self, x, y); + self->x = x; + self->y = y; + self->pixel_shader = pixel_shader; + self->ishape = ishape; + self->transpose_xy = transpose_xy; + self->dirty = true; + _get_screen_area(self, &self->ephemeral_dirty_area); + self->ephemeral_dirty_area.next = NULL; +} + + +mp_int_t common_hal_vectorio_vector_shape_get_x(vectorio_vector_shape_t *self) { + VECTORIO_SHAPE_DEBUG("%p get_x\n", self); + return self->x; +} + + +void common_hal_vectorio_vector_shape_set_x(vectorio_vector_shape_t *self, mp_int_t x) { + VECTORIO_SHAPE_DEBUG("%p set_x %d\n", self, x); + if (self->x == x) { + return; + } + self->x = x; + common_hal_vectorio_vector_shape_set_dirty(self); +} + + +mp_int_t common_hal_vectorio_vector_shape_get_y(vectorio_vector_shape_t *self) { + VECTORIO_SHAPE_DEBUG("%p get_y\n", self); + return self->y; +} + + +void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_int_t y) { + VECTORIO_SHAPE_DEBUG("%p set_y %d\n", self, y); + if (self->y == y) { + return; + } + self->y = y; + common_hal_vectorio_vector_shape_set_dirty(self); +} + + +bool common_hal_vectorio_vector_shape_get_transpose_xy(vectorio_vector_shape_t *self) { + VECTORIO_SHAPE_DEBUG("%p get_transpose_xy\n", self); + return self->transpose_xy; +} + + +mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape_t *self) { + VECTORIO_SHAPE_DEBUG("%p get_pixel_shader\n", self); + return self->pixel_shader; +} + +void common_hal_vectorio_vector_shape_set_pixel_shader(vectorio_vector_shape_t *self, mp_obj_t pixel_shader) { + VECTORIO_SHAPE_DEBUG("%p set_pixel_shader\n", self); + self->pixel_shader = pixel_shader; + common_hal_vectorio_vector_shape_set_dirty(self); +} + + +bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displayio_colorspace_t* colorspace, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer) { + // Shape areas are relative to 0,0. This will allow rotation about a known axis. + // The consequence is that the area reported by the shape itself is _relative_ to 0,0. + // To make it relative to the VectorShape position, we must shift it. + // Pixels are drawn on the screen_area (shifted) coordinate space, while pixels are _determined_ from + // the shape_area (unshifted) space. + displayio_area_t overlap; + displayio_area_t shape_area; + _get_shape_area(self, &shape_area); + VECTORIO_SHAPE_DEBUG("%p fill_area dirty:%d fill: {(%3d,%3d), (%3d,%3d)} dirty: {(%3d,%3d), (%3d,%3d)}", + self, self->dirty, + area->x1, area->y1, area->x2, area->y2, + self->ephemeral_dirty_area.x1, self->ephemeral_dirty_area.y1, self->ephemeral_dirty_area.x2, self->ephemeral_dirty_area.y2 + ); + if (!displayio_area_compute_overlap(area, &self->ephemeral_dirty_area, &overlap)) { + VECTORIO_SHAPE_DEBUG(" no overlap\n"); + return false; + } + VECTORIO_SHAPE_DEBUG(", overlap: {(%3d,%3d), (%3d,%3d)}", overlap.x1, overlap.y1, overlap.x2, overlap.y2); + + bool full_coverage = displayio_area_equal(area, &overlap); + + uint8_t pixels_per_byte = 8 / colorspace->depth; + + uint32_t linestride_px = displayio_area_width(area); + uint32_t line_dirty_offset_px = (overlap.y1 - area->y1) * linestride_px; + uint32_t column_dirty_offset_px = overlap.x1 - area->x1; + VECTORIO_SHAPE_DEBUG(", linestride:%3d line_offset:%3d col_offset:%3d depth:%2d ppb:%2d\n", linestride_px, line_dirty_offset_px, column_dirty_offset_px, colorspace->depth, pixels_per_byte); + + displayio_input_pixel_t input_pixel; + displayio_output_pixel_t output_pixel; + + uint32_t mask_start_px = line_dirty_offset_px; + for (input_pixel.y = overlap.y1; input_pixel.y < overlap.y2; ++input_pixel.y) { + mask_start_px += column_dirty_offset_px; + for (input_pixel.x = overlap.x1; input_pixel.x < overlap.x2; ++input_pixel.x) { + // Check the mask first to see if the pixel has already been set. + uint32_t pixel_index = mask_start_px + (input_pixel.x - overlap.x1); + uint32_t *mask_doubleword = &(mask[pixel_index / 32]); + uint8_t mask_bit = pixel_index % 32; + VECTORIO_SHAPE_PIXEL_DEBUG("%p pixel_index: %5u mask_bit: %2u", self, pixel_index, mask_bit); + if ((*mask_doubleword & (1u << mask_bit)) != 0) { + VECTORIO_SHAPE_PIXEL_DEBUG(" masked\n"); + continue; + } + output_pixel.pixel = 0; + + // Get the target pixel based on the shape's coordinate space + int16_t pixel_to_get_x; + int16_t pixel_to_get_y; + if (self->transpose_xy) { + pixel_to_get_x = input_pixel.y - self->x; + pixel_to_get_y = input_pixel.x - self->y; + } else { + pixel_to_get_x = input_pixel.x - self->x; + pixel_to_get_y = input_pixel.y - self->y; + } + VECTORIO_SHAPE_PIXEL_DEBUG(" get_pixel %p (%3d, %3d) -> ( %3d, %3d )", self->ishape.shape, input_pixel.x, input_pixel.y, pixel_to_get_x, pixel_to_get_y); + input_pixel.pixel = self->ishape.get_pixel(self->ishape.shape, pixel_to_get_x, pixel_to_get_y); + VECTORIO_SHAPE_PIXEL_DEBUG(" -> %d", input_pixel.pixel); + + output_pixel.opaque = true; + if (self->pixel_shader == mp_const_none) { + output_pixel.pixel = input_pixel.pixel; + } else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type)) { + output_pixel.opaque = displayio_palette_get_color(self->pixel_shader, colorspace, input_pixel.pixel, &output_pixel.pixel); + } else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type)) { + displayio_colorconverter_convert(self->pixel_shader, colorspace, &input_pixel, &output_pixel); + } + if (!output_pixel.opaque) { + VECTORIO_SHAPE_PIXEL_DEBUG(" (encountered transparent pixel; input area is not fully covered)\n"); + full_coverage = false; + } else { + *mask_doubleword |= 1u << mask_bit; + if (colorspace->depth == 16) { + VECTORIO_SHAPE_PIXEL_DEBUG(" buffer = %04x 16\n", output_pixel.pixel); + *(((uint16_t*) buffer) + pixel_index) = output_pixel.pixel; + } else if (colorspace->depth == 8) { + VECTORIO_SHAPE_PIXEL_DEBUG(" buffer = %02x 8\n", output_pixel.pixel); + *(((uint8_t*) buffer) + pixel_index) = output_pixel.pixel; + } else if (colorspace->depth < 8) { + // Reorder the offsets to pack multiple rows into a byte (meaning they share a column). + if (!colorspace->pixels_in_byte_share_row) { + uint16_t width = linestride_px; + uint16_t row = pixel_index / width; + uint16_t col = pixel_index % width; + pixel_index = col * pixels_per_byte + (row / pixels_per_byte) * pixels_per_byte * width + row % pixels_per_byte; + } + uint8_t shift = (pixel_index % pixels_per_byte) * colorspace->depth; + if (colorspace->reverse_pixels_in_byte) { + // Reverse the shift by subtracting it from the leftmost shift. + shift = (pixels_per_byte - 1) * colorspace->depth - shift; + } + VECTORIO_SHAPE_PIXEL_DEBUG(" buffer = %2d %d\n", output_pixel.pixel, colorspace->depth); + ((uint8_t*)buffer)[pixel_index / pixels_per_byte] |= output_pixel.pixel << shift; + } + } + } + mask_start_px += linestride_px - column_dirty_offset_px; + } + return full_coverage; +} + + +void vectorio_vector_shape_finish_refresh(vectorio_vector_shape_t *self) { + if ( !self->dirty ) { + return; + } + VECTORIO_SHAPE_DEBUG("%p finish_refresh was:{(%3d,%3d), (%3d,%3d)}\n", self, self->ephemeral_dirty_area.x1, self->ephemeral_dirty_area.y1, self->ephemeral_dirty_area.x2, self->ephemeral_dirty_area.y2); + self->dirty = false; + // Reset dirty area tracking to current footprint + _get_screen_area(self, &self->ephemeral_dirty_area); + self->ephemeral_dirty_area.next = NULL; + VECTORIO_SHAPE_DEBUG("%p finish_refresh now:{(%3d,%3d), (%3d,%3d)}\n", self, self->ephemeral_dirty_area.x1, self->ephemeral_dirty_area.y1, self->ephemeral_dirty_area.x2, self->ephemeral_dirty_area.y2); + + 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)) { + displayio_colorconverter_finish_refresh(self->pixel_shader); + } +} + + +// Assembles a singly linked list of dirty areas from all components on the display. +displayio_area_t* vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_t *self, displayio_area_t* tail) { + if (self->dirty + || (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)) + ) { + VECTORIO_SHAPE_DEBUG("%p get_refresh_area dirty:%d {(%3d,%3d), (%3d,%3d)}", self, self->dirty, self->ephemeral_dirty_area.x1, self->ephemeral_dirty_area.y1, self->ephemeral_dirty_area.x2, self->ephemeral_dirty_area.y2); + common_hal_vectorio_vector_shape_set_dirty(self); + // vector.add_to_head + self->ephemeral_dirty_area.next = tail; + VECTORIO_SHAPE_DEBUG(" this_area: %p next: %p after: %p\n", &self->ephemeral_dirty_area, tail, tail == NULL ? NULL : tail->next); + return &self->ephemeral_dirty_area; + } + return tail; +} + diff --git a/shared-module/vectorio/VectorShape.h b/shared-module/vectorio/VectorShape.h new file mode 100644 index 0000000000..ac60e5b985 --- /dev/null +++ b/shared-module/vectorio/VectorShape.h @@ -0,0 +1,51 @@ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_SHAPE_H +#define MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_SHAPE_H + +#include +#include + +#include "py/obj.h" +#include "shared-module/displayio/area.h" +#include "shared-module/displayio/Palette.h" + +typedef void get_area_function(mp_obj_t shape, displayio_area_t *out_area); +typedef uint32_t get_pixel_function(mp_obj_t shape, int16_t x, int16_t y); + +// This struct binds a shape's common Shape support functions (its vector shape interface) +// to its instance pointer. We only check at construction time what the type of the +// associated shape is and link the correct functions up. +// Later when using the shape for drawing logic these functions may be invoked +// unconditionally. This simplifies the addition of new types and restricts the +// respective responsibilities of VectorShape and actual shape implementations. +typedef struct { + mp_obj_t shape; + get_area_function *get_area; + get_pixel_function *get_pixel; +} vectorio_ishape_t; + +typedef struct { + mp_obj_base_t base; + vectorio_ishape_t ishape; + mp_obj_t pixel_shader; + int16_t x; + int16_t y; + bool transpose_xy; + bool dirty; // True if we need to draw + // Tracks current shape footprint and expands outward as the shape dirties and changes. + // This is suboptimal if you move your shape far. Could add more state to only redraw + // exactly what we left behind. + displayio_area_t ephemeral_dirty_area; +} vectorio_vector_shape_t; + +displayio_area_t* vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_t *self, displayio_area_t* tail); + +// Area is always in absolute screen coordinates. +bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displayio_colorspace_t *colorspace, const displayio_area_t *area, uint32_t *mask, uint32_t *buffer); + +// Fills in out_area with the maximum bounds of all related pixels in the last rendered frame. Returns +// false if the vector shape wasn't rendered in the last frame. +bool vectorio_vector_shape_get_previous_area(vectorio_vector_shape_t *self, displayio_area_t *out_area); +void vectorio_vector_shape_finish_refresh(vectorio_vector_shape_t *self); + +#endif // MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_SHAPE_H diff --git a/shared-module/vectorio/__init__.c b/shared-module/vectorio/__init__.c new file mode 100644 index 0000000000..473c509c3c --- /dev/null +++ b/shared-module/vectorio/__init__.c @@ -0,0 +1,3 @@ + +// Don't need anything in here yet + diff --git a/shared-module/vectorio/__init__.h b/shared-module/vectorio/__init__.h new file mode 100644 index 0000000000..6ae381f067 --- /dev/null +++ b/shared-module/vectorio/__init__.h @@ -0,0 +1,15 @@ +#ifndef MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_INIT_H +#define MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_INIT_H + +#include "py/obj.h" + +typedef void event_function(mp_obj_t obj); + +typedef struct { + mp_obj_t obj; + event_function *event; +} vectorio_event_t; + + +#endif + From 7697c419b4718a96ec8b86620a82af5f8d81f958 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Sat, 9 May 2020 16:45:55 -0700 Subject: [PATCH 058/216] translations for vectorio --- locale/ID.po | 41 +++++++++++++++++++++++++++++++--------- locale/circuitpython.pot | 41 +++++++++++++++++++++++++++++++--------- locale/de_DE.po | 41 +++++++++++++++++++++++++++++++--------- locale/en_US.po | 41 +++++++++++++++++++++++++++++++--------- locale/en_x_pirate.po | 41 +++++++++++++++++++++++++++++++--------- locale/es.po | 41 +++++++++++++++++++++++++++++++--------- locale/fil.po | 41 +++++++++++++++++++++++++++++++--------- locale/fr.po | 41 +++++++++++++++++++++++++++++++--------- locale/it_IT.po | 41 +++++++++++++++++++++++++++++++--------- locale/ko.po | 41 +++++++++++++++++++++++++++++++--------- locale/pl.po | 41 +++++++++++++++++++++++++++++++--------- locale/pt_BR.po | 41 +++++++++++++++++++++++++++++++--------- locale/sv.po | 41 +++++++++++++++++++++++++++++++--------- locale/zh_Latn_pinyin.po | 41 +++++++++++++++++++++++++++++++--------- 14 files changed, 448 insertions(+), 126 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 3a2afdef8f..8fccb8c1a7 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -70,13 +70,22 @@ msgstr "" msgid "%q indices must be integers, not %s" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c #, fuzzy msgid "%q must be >= 1" msgstr "buffers harus mempunyai panjang yang sama" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "" @@ -797,7 +806,8 @@ msgstr "" msgid "Group full" msgstr "" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1050,7 +1060,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1058,7 +1068,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1089,11 +1099,11 @@ msgstr "Tidak ada DAC (Digital Analog Converter) di dalam chip" msgid "No DMA channel found" msgstr "tidak ada channel DMA ditemukan" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -2012,6 +2022,10 @@ msgstr "" msgid "chr() arg not in range(256)" msgstr "" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" @@ -2114,6 +2128,10 @@ msgstr "" msgid "empty" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "heap kosong" @@ -2804,10 +2822,14 @@ msgstr "" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3127,7 +3149,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index edfef28df4..dd0162c2cd 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -70,12 +70,21 @@ msgstr "" msgid "%q indices must be integers, not %s" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c msgid "%q must be >= 1" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "" @@ -786,7 +795,8 @@ msgstr "" msgid "Group full" msgstr "" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1039,7 +1049,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1047,7 +1057,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1078,11 +1088,11 @@ msgstr "" msgid "No DMA channel found" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -1988,6 +1998,10 @@ msgstr "" msgid "chr() arg not in range(256)" msgstr "" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" @@ -2090,6 +2104,10 @@ msgstr "" msgid "empty" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -2779,10 +2797,14 @@ msgstr "" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3101,7 +3123,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 578e2d86b2..476962dd26 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2020-04-30 17:01+0000\n" "Last-Translator: Jeff Epler \n" "Language-Team: German = 1" msgstr "%q muss >= 1 sein" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "%q sollte ein int sein" @@ -799,7 +808,8 @@ msgstr "Gruppe schon benutzt" msgid "Group full" msgstr "Gruppe voll" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1055,7 +1065,7 @@ msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" "Die Startverzögerung des Mikrofons muss im Bereich von 0,0 bis 1,0 liegen" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1063,7 +1073,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "Muss eine %q Unterklasse sein." -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1094,11 +1104,11 @@ msgstr "Kein DAC im Chip vorhanden" msgid "No DMA channel found" msgstr "Kein DMA Kanal gefunden" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -2023,6 +2033,10 @@ msgstr "chr() arg ist nicht in range(0x110000)" msgid "chr() arg not in range(256)" msgstr "chr() arg ist nicht in range(256)" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "Farbpuffer muss 3 Bytes (RGB) oder 4 Bytes (RGB + pad byte) sein" @@ -2126,6 +2140,10 @@ msgstr "Division durch Null" msgid "empty" msgstr "leer" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "leerer heap" @@ -2824,10 +2842,14 @@ msgstr "Pixelkoordinaten außerhalb der Grenzen" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader muss displayio.Palette oder displayio.ColorConverter sein" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3153,7 +3175,8 @@ msgstr "" msgid "unreadable attribute" msgstr "nicht lesbares Attribut" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "Nicht unterstützter %q-Typ" diff --git a/locale/en_US.po b/locale/en_US.po index 6aba6d3262..b1b03a3e7f 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -70,12 +70,21 @@ msgstr "" msgid "%q indices must be integers, not %s" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c msgid "%q must be >= 1" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "" @@ -786,7 +795,8 @@ msgstr "" msgid "Group full" msgstr "" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1039,7 +1049,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1047,7 +1057,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1078,11 +1088,11 @@ msgstr "" msgid "No DMA channel found" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -1988,6 +1998,10 @@ msgstr "" msgid "chr() arg not in range(256)" msgstr "" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" @@ -2090,6 +2104,10 @@ msgstr "" msgid "empty" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -2779,10 +2797,14 @@ msgstr "" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3101,7 +3123,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 36583bfd2f..9828932bee 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2020-03-30 22:11+0000\n" "Last-Translator: Tannewt \n" "Language-Team: English = 1" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "" @@ -795,7 +804,8 @@ msgstr "" msgid "Group full" msgstr "" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1048,7 +1058,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1056,7 +1066,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1087,11 +1097,11 @@ msgstr "Shiver me timbers! There be no DAC on this chip" msgid "No DMA channel found" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -1997,6 +2007,10 @@ msgstr "" msgid "chr() arg not in range(256)" msgstr "" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" @@ -2099,6 +2113,10 @@ msgstr "" msgid "empty" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -2788,10 +2806,14 @@ msgstr "" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3110,7 +3132,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" diff --git a/locale/es.po b/locale/es.po index b20ddff7df..0c7ba72ac7 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -72,12 +72,21 @@ msgstr "%q indice fuera de rango" msgid "%q indices must be integers, not %s" msgstr "%q indices deben ser enteros, no %s" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c msgid "%q must be >= 1" msgstr "%q debe ser >= 1" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "%q debe ser un int" @@ -792,7 +801,8 @@ msgstr "" msgid "Group full" msgstr "Group lleno" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1047,7 +1057,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Micrófono demora de inicio debe estar en el rango 0.0 a 1.0" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1055,7 +1065,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "Debe de ser una subclase de %q" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1086,11 +1096,11 @@ msgstr "El chip no tiene DAC" msgid "No DMA channel found" msgstr "No se encontró el canal DMA" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -2017,6 +2027,10 @@ msgstr "El argumento de chr() esta fuera de rango(0x110000)" msgid "chr() arg not in range(256)" msgstr "El argumento de chr() no esta en el rango(256)" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "color buffer debe ser 3 bytes (RGB) ó 4 bytes (RGB + pad byte)" @@ -2121,6 +2135,10 @@ msgstr "división por cero" msgid "empty" msgstr "vacío" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "heap vacío" @@ -2817,10 +2835,14 @@ msgstr "coordenadas del pixel fuera de límites" msgid "pixel value requires too many bits" msgstr "valor del pixel require demasiado bits" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader debe ser displayio.Palette o displayio.ColorConverter" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3142,7 +3164,8 @@ msgstr "No coinciden '{' en format" msgid "unreadable attribute" msgstr "atributo no legible" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "tipo de %q no soportado" diff --git a/locale/fil.po b/locale/fil.po index 1af4bbc3cf..44206d6e7b 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -70,13 +70,22 @@ msgstr "%q indeks wala sa sakop" msgid "%q indices must be integers, not %s" msgstr "%q indeks ay dapat integers, hindi %s" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c #, fuzzy msgid "%q must be >= 1" msgstr "aarehas na haba dapat ang buffer slices" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c #, fuzzy msgid "%q should be an int" @@ -800,7 +809,8 @@ msgstr "" msgid "Group full" msgstr "Puno ang group" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1055,7 +1065,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Ang delay ng startup ng mikropono ay dapat na nasa 0.0 hanggang 1.0" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1063,7 +1073,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1094,11 +1104,11 @@ msgstr "Walang DAC sa chip" msgid "No DMA channel found" msgstr "Walang DMA channel na mahanap" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -2028,6 +2038,10 @@ msgstr "chr() arg wala sa sakop ng range(0x110000)" msgid "chr() arg not in range(256)" msgstr "chr() arg wala sa sakop ng range(256)" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "color buffer ay dapat na 3 bytes (RGB) o 4 bytes (RGB + pad byte)" @@ -2134,6 +2148,10 @@ msgstr "dibisyon ng zero" msgid "empty" msgstr "walang laman" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "walang laman ang heap" @@ -2831,10 +2849,14 @@ msgstr "wala sa sakop ang address" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader ay dapat displayio.Palette o displayio.ColorConverter" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3157,7 +3179,8 @@ msgstr "hindi tugma ang '{' sa format" msgid "unreadable attribute" msgstr "hindi mabasa ang attribute" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "Hindi supportadong tipo ng %q" diff --git a/locale/fr.po b/locale/fr.po index ede3d2f2da..61263f6c36 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2020-05-05 20:24+0000\n" "Last-Translator: Jeff Epler \n" "Language-Team: French = 1" msgstr "%q doit être >=1" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "%q doit être un entier (int)" @@ -810,7 +819,8 @@ msgstr "" msgid "Group full" msgstr "Groupe plein" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1069,7 +1079,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Le délais au démarrage du micro doit être entre 0.0 et 1.0" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1077,7 +1087,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1108,11 +1118,11 @@ msgstr "Pas de DAC sur la puce" msgid "No DMA channel found" msgstr "Aucun canal DMA trouvé" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -2058,6 +2068,10 @@ msgstr "argument de chr() hors de la gamme range(0x11000)" msgid "chr() arg not in range(256)" msgstr "argument de chr() hors de la gamme range(256)" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "le tampon de couleur doit faire 3 octets (RVB) ou 4 (RVB + pad byte)" @@ -2166,6 +2180,10 @@ msgstr "division par zéro" msgid "empty" msgstr "vide" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "tas vide" @@ -2869,11 +2887,15 @@ msgstr "coordonnées de pixel hors limites" msgid "pixel value requires too many bits" msgstr "la valeur du pixel requiet trop de bits" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" "pixel_shader doit être un objet displayio.Palette ou displayio.ColorConverter" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3197,7 +3219,8 @@ msgstr "'{' sans correspondance dans le format" msgid "unreadable attribute" msgstr "attribut illisible" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c #, fuzzy msgid "unsupported %q type" msgstr "type de %q non supporté" diff --git a/locale/it_IT.po b/locale/it_IT.po index ad7964feaf..17895aa3f6 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -70,13 +70,22 @@ msgstr "indice %q fuori intervallo" msgid "%q indices must be integers, not %s" msgstr "gli indici %q devono essere interi, non %s" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c #, fuzzy msgid "%q must be >= 1" msgstr "slice del buffer devono essere della stessa lunghezza" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c #, fuzzy msgid "%q should be an int" @@ -800,7 +809,8 @@ msgstr "" msgid "Group full" msgstr "Gruppo pieno" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1059,7 +1069,7 @@ msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" "Il ritardo di avvio del microfono deve essere nell'intervallo tra 0.0 e 1.0" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1067,7 +1077,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1098,11 +1108,11 @@ msgstr "Nessun DAC sul chip" msgid "No DMA channel found" msgstr "Nessun canale DMA trovato" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -2028,6 +2038,10 @@ msgstr "argomento di chr() non è in range(0x110000)" msgid "chr() arg not in range(256)" msgstr "argomento di chr() non è in range(256)" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" @@ -2135,6 +2149,10 @@ msgstr "divisione per zero" msgid "empty" msgstr "vuoto" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "heap vuoto" @@ -2838,10 +2856,14 @@ msgstr "indirizzo fuori limite" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader deve essere displayio.Palette o displayio.ColorConverter" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3164,7 +3186,8 @@ msgstr "'{' spaiato nella stringa di formattazione" msgid "unreadable attribute" msgstr "attributo non leggibile" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "tipo di %q non supportato" diff --git a/locale/ko.po b/locale/ko.po index 5f28a85992..51bbad5646 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -72,12 +72,21 @@ msgstr "%q 인덱스 범위를 벗어났습니다" msgid "%q indices must be integers, not %s" msgstr "%q 인덱스는 %s 가 아닌 정수 여야합니다" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c msgid "%q must be >= 1" msgstr "%q 는 >=1이어야합니다" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "%q 는 정수(int) 여야합니다" @@ -790,7 +799,8 @@ msgstr "" msgid "Group full" msgstr "" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1043,7 +1053,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1051,7 +1061,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1082,11 +1092,11 @@ msgstr "" msgid "No DMA channel found" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -1993,6 +2003,10 @@ msgstr "" msgid "chr() arg not in range(256)" msgstr "" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" @@ -2095,6 +2109,10 @@ msgstr "" msgid "empty" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -2784,10 +2802,14 @@ msgstr "" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3106,7 +3128,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 6e410cbbbc..5c71601b67 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -71,12 +71,21 @@ msgstr "%q poza zakresem" msgid "%q indices must be integers, not %s" msgstr "%q indeks musi być liczbą całkowitą, a nie %s" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c msgid "%q must be >= 1" msgstr "%q musi być >= 1" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "%q powinno być typu int" @@ -789,7 +798,8 @@ msgstr "" msgid "Group full" msgstr "Grupa pełna" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1044,7 +1054,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Opóźnienie włączenia mikrofonu musi być w zakresie od 0.0 do 1.0" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1052,7 +1062,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1083,11 +1093,11 @@ msgstr "Brak DAC" msgid "No DMA channel found" msgstr "Nie znaleziono kanału DMA" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -1996,6 +2006,10 @@ msgstr "argument chr() poza zakresem range(0x110000)" msgid "chr() arg not in range(256)" msgstr "argument chr() poza zakresem range(256)" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "bufor kolorów musi nieć 3 bajty (RGB) lub 4 bajty (RGB + wypełnienie)" @@ -2099,6 +2113,10 @@ msgstr "dzielenie przez zero" msgid "empty" msgstr "puste" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "pusta sterta" @@ -2788,11 +2806,15 @@ msgstr "współrzędne piksela poza zakresem" msgid "pixel value requires too many bits" msgstr "wartość piksela wymaga zbyt wielu bitów" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" "pixel_shader musi być typu displayio.Palette lub dispalyio.ColorConverter" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3112,7 +3134,8 @@ msgstr "niepasujące '{' for formacie" msgid "unreadable attribute" msgstr "nieczytelny atrybut" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "zły typ %q" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index c5ef3b9c19..1669056357 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -70,13 +70,22 @@ msgstr "" msgid "%q indices must be integers, not %s" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c #, fuzzy msgid "%q must be >= 1" msgstr "buffers devem ser o mesmo tamanho" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c #, fuzzy msgid "%q should be an int" @@ -795,7 +804,8 @@ msgstr "" msgid "Group full" msgstr "Grupo cheio" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1051,7 +1061,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1059,7 +1069,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1090,11 +1100,11 @@ msgstr "Nenhum DAC no chip" msgid "No DMA channel found" msgstr "Nenhum canal DMA encontrado" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -2009,6 +2019,10 @@ msgstr "" msgid "chr() arg not in range(256)" msgstr "" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" @@ -2111,6 +2125,10 @@ msgstr "divisão por zero" msgid "empty" msgstr "vazio" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "heap vazia" @@ -2801,10 +2819,14 @@ msgstr "" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3125,7 +3147,8 @@ msgstr "" msgid "unreadable attribute" msgstr "atributo ilegível" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" diff --git a/locale/sv.po b/locale/sv.po index 7c5f43e19d..15fb0ee849 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -70,12 +70,21 @@ msgstr "" msgid "%q indices must be integers, not %s" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c msgid "%q must be >= 1" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "" @@ -786,7 +795,8 @@ msgstr "" msgid "Group full" msgstr "" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "" @@ -1039,7 +1049,7 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "" @@ -1047,7 +1057,7 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "" @@ -1078,11 +1088,11 @@ msgstr "" msgid "No DMA channel found" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "" @@ -1988,6 +1998,10 @@ msgstr "" msgid "chr() arg not in range(256)" msgstr "" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" @@ -2090,6 +2104,10 @@ msgstr "" msgid "empty" msgstr "" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -2779,10 +2797,14 @@ msgstr "" msgid "pixel value requires too many bits" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3101,7 +3123,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 51c59e7631..1905ead0a4 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-06 17:47+0800\n" +"POT-Creation-Date: 2020-05-09 16:44-0700\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -77,12 +77,21 @@ msgstr "%q suǒyǐn chāochū fànwéi" msgid "%q indices must be integers, not %s" msgstr "%q suǒyǐn bìxū shì zhěngshù, ér bùshì %s" +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c -#: shared-bindings/displayio/Shape.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c msgid "%q must be >= 1" msgstr "%q bìxū dàyú huò děngyú 1" +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" msgstr "%q yīnggāi shì yīgè int" @@ -797,7 +806,8 @@ msgstr "Jítuán yǐjīng shǐyòngguò" msgid "Group full" msgstr "Fēnzǔ yǐ mǎn" -#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" msgstr "Yìngjiàn máng, qǐng chángshì qítā zhēnjiǎo" @@ -1052,7 +1062,7 @@ msgstr "MicroPython zhìmìng cuòwù." msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Màikèfēng qǐdòng yánchí bìxū zài 0.0 Dào 1.0 De fànwéi nèi" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" msgstr "Quēshǎo MISO huò MOSI yǐn jiǎo" @@ -1060,7 +1070,7 @@ msgstr "Quēshǎo MISO huò MOSI yǐn jiǎo" msgid "Must be a %q subclass." msgstr "Bìxū shì %q zi lèi." -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" msgstr "Bìxū tígōng MISO huò MOSI yǐn jiǎo" @@ -1091,11 +1101,11 @@ msgstr "Méiyǒu DAC zài xīnpiàn shàng de" msgid "No DMA channel found" msgstr "Wèi zhǎodào DMA píndào" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" msgstr "Méiyǒu MISO yǐn jiǎo" -#: ports/stm/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" msgstr "Méiyǒu MOSI yǐn jiǎo" @@ -2021,6 +2031,10 @@ msgstr "chr() cān shǔ bùzài fànwéi (0x110000)" msgid "chr() arg not in range(256)" msgstr "chr() cān shǔ bùzài fànwéi (256)" +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" @@ -2127,6 +2141,10 @@ msgstr "bèi líng chú" msgid "empty" msgstr "kòngxián" +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "kōng yīn yīnxiào" @@ -2818,10 +2836,14 @@ msgstr "xiàngsù zuòbiāo chāochū biānjiè" msgid "pixel value requires too many bits" msgstr "xiàngsù zhí xūyào tài duō wèi" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader bìxū shì displayio.Palette huò displayio.ColorConverter" +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -3142,7 +3164,8 @@ msgstr "géshì wèi pǐpèi '{'" msgid "unreadable attribute" msgstr "bùkě dú shǔxìng" -#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "bù zhīchí %q lèixíng" From 1c6e646f5630a46ea77e848788947c099e2c1f31 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Sat, 9 May 2020 17:58:01 -0700 Subject: [PATCH 059/216] vectorio: fix mpconfig definition for disabled boards --- py/circuitpy_mpconfig.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index f48a648c49..a62ac11e9c 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -355,6 +355,8 @@ extern const struct _mp_obj_module_t framebufferio_module; #if CIRCUITPY_VECTORIO extern const struct _mp_obj_module_t vectorio_module; #define VECTORIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_vectorio), (mp_obj_t)&vectorio_module }, +#else +#define VECTORIO_MODULE #endif #if CIRCUITPY_FREQUENCYIO From 4086600b61f14e043f02c1b8771e7780b82f313c Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Fri, 8 May 2020 23:03:15 -0700 Subject: [PATCH 060/216] vectorio: switch per-shape transform to Display Rather than maintain a transform per-shape, we'll just use whatever settings are on the Display. Currently only transpose is done. --- shared-bindings/vectorio/VectorShape.c | 22 ++--------------- shared-bindings/vectorio/VectorShape.h | 8 +++--- shared-module/displayio/Group.c | 6 +++++ shared-module/vectorio/VectorShape.c | 34 ++++++++++++++++++-------- shared-module/vectorio/VectorShape.h | 2 +- 5 files changed, 38 insertions(+), 34 deletions(-) diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index 8f99577b4f..02a42536d7 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -32,13 +32,12 @@ //| :param int y: Initial y position of the center axis of the shape within the parent. //| STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_shape, ARG_pixel_shader, ARG_x, ARG_y, ARG_transpose_xy }; + enum { ARG_shape, ARG_pixel_shader, ARG_x, ARG_y }; static const mp_arg_t allowed_args[] = { { MP_QSTR_shape, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, { MP_QSTR_x, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, - { MP_QSTR_transpose_xy, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -74,7 +73,7 @@ STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t vectorio_vector_shape_t *self = m_new_obj(vectorio_vector_shape_t); self->base.type = &vectorio_vector_shape_type; common_hal_vectorio_vector_shape_construct(self, - ishape, pixel_shader, x, y, args[ARG_transpose_xy].u_bool + ishape, pixel_shader, x, y ); // Wire up event callbacks @@ -150,23 +149,6 @@ const mp_obj_property_t vectorio_vector_shape_y_obj = { }; -//| .. attribute:: transpose_xy -//| -//| true if the object is to be flipped. -//| -STATIC mp_obj_t vectorio_vector_shape_obj_get_transpose_xy(mp_obj_t self_in) { - vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(common_hal_vectorio_vector_shape_get_transpose_xy(self)); -} -MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_transpose_xy_obj, vectorio_vector_shape_obj_get_transpose_xy); - -const mp_obj_property_t vectorio_vector_shape_transpose_xy_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_vector_shape_get_transpose_xy_obj, - (mp_obj_t)&mp_const_none_obj, - (mp_obj_t)&mp_const_none_obj}, -}; - //| .. attribute:: pixel_shader //| //| The pixel shader of the shape. diff --git a/shared-bindings/vectorio/VectorShape.h b/shared-bindings/vectorio/VectorShape.h index ad745b30ff..d098504e93 100644 --- a/shared-bindings/vectorio/VectorShape.h +++ b/shared-bindings/vectorio/VectorShape.h @@ -2,12 +2,13 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H #include "shared-module/vectorio/VectorShape.h" +#include "shared-module/displayio/area.h" extern const mp_obj_type_t vectorio_vector_shape_type; void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, vectorio_ishape_t ishape, - mp_obj_t pixel_shader, uint16_t x, uint16_t y, bool transpose_xy); + mp_obj_t pixel_shader, uint16_t x, uint16_t y); void common_hal_vectorio_vector_shape_set_dirty(void *self); @@ -17,9 +18,10 @@ void common_hal_vectorio_vector_shape_set_x(vectorio_vector_shape_t *self, mp_in mp_int_t common_hal_vectorio_vector_shape_get_y(vectorio_vector_shape_t *self); void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_int_t y); -bool common_hal_vectorio_vector_shape_get_transpose_xy(vectorio_vector_shape_t *self); - mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape_t *self); void common_hal_vectorio_vector_shape_set_pixel_shader(vectorio_vector_shape_t *self, mp_obj_t pixel_shader); + +void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displayio_buffer_transform_t *group_transform); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index 9d50dabec7..0c31de5320 100644 --- a/shared-module/displayio/Group.c +++ b/shared-module/displayio/Group.c @@ -122,6 +122,12 @@ static void _update_child_transforms(displayio_group_t* self) { } for (size_t i = 0; i < self->size; i++) { mp_obj_t layer = self->children[i].native; +#if CIRCUITPY_VECTORIO + if (MP_OBJ_IS_TYPE(layer, &vectorio_vector_shape_type)) { + vectorio_vector_shape_update_transform(layer, &self->absolute_transform); + } + else +#endif 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)) { diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index 985b778584..6030c1e3d5 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -50,7 +50,7 @@ inline __attribute__((always_inline)) static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) { VECTORIO_SHAPE_DEBUG("%p get_screen_area\n", self); self->ishape.get_area(self->ishape.shape, out_area); - if (self->transpose_xy) { + if (self->absolute_transform->transpose_xy) { _transpose_area(out_area); displayio_area_shift(out_area, self->y, self->x); } else { @@ -76,18 +76,32 @@ void common_hal_vectorio_vector_shape_set_dirty(void *vector_shape) { } +static displayio_buffer_transform_t null_transform = { + .x = 0, + .y = 0, + .dx = 0, + .dy = 0, + .scale = 1, + .width = 0, + .height = 0, + .mirror_x = false, + .mirror_y = false, + .transpose_xy = false +}; + + void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, vectorio_ishape_t ishape, - mp_obj_t pixel_shader, uint16_t x, uint16_t y, bool transpose_xy) { + mp_obj_t pixel_shader, uint16_t x, uint16_t y) { VECTORIO_SHAPE_DEBUG("%p vector_shape_construct x:%3d, y:%3d\n", self, x, y); self->x = x; self->y = y; self->pixel_shader = pixel_shader; self->ishape = ishape; - self->transpose_xy = transpose_xy; self->dirty = true; _get_screen_area(self, &self->ephemeral_dirty_area); self->ephemeral_dirty_area.next = NULL; + self->absolute_transform = &null_transform; } @@ -123,12 +137,6 @@ void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_in } -bool common_hal_vectorio_vector_shape_get_transpose_xy(vectorio_vector_shape_t *self) { - VECTORIO_SHAPE_DEBUG("%p get_transpose_xy\n", self); - return self->transpose_xy; -} - - mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape_t *self) { VECTORIO_SHAPE_DEBUG("%p get_pixel_shader\n", self); return self->pixel_shader; @@ -191,7 +199,7 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ // Get the target pixel based on the shape's coordinate space int16_t pixel_to_get_x; int16_t pixel_to_get_y; - if (self->transpose_xy) { + if (self->absolute_transform->transpose_xy) { pixel_to_get_x = input_pixel.y - self->x; pixel_to_get_y = input_pixel.x - self->y; } else { @@ -280,3 +288,9 @@ displayio_area_t* vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_ return tail; } +void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displayio_buffer_transform_t *group_transform) { + self->absolute_transform = group_transform; + common_hal_vectorio_vector_shape_set_dirty(self); +} + + diff --git a/shared-module/vectorio/VectorShape.h b/shared-module/vectorio/VectorShape.h index ac60e5b985..8fc698dbc1 100644 --- a/shared-module/vectorio/VectorShape.h +++ b/shared-module/vectorio/VectorShape.h @@ -30,7 +30,7 @@ typedef struct { mp_obj_t pixel_shader; int16_t x; int16_t y; - bool transpose_xy; + displayio_buffer_transform_t *absolute_transform; bool dirty; // True if we need to draw // Tracks current shape footprint and expands outward as the shape dirties and changes. // This is suboptimal if you move your shape far. Could add more state to only redraw From 2f7c0ec8e4497c95bb7f5f5ee630c3748acdf9a9 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 10 May 2020 16:22:01 -0400 Subject: [PATCH 061/216] Minor fixes to _pixelbuf.PixelBuf docs --- shared-bindings/_pixelbuf/PixelBuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 61b4c9ae09..78f94b66bc 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -44,7 +44,7 @@ extern const int32_t colorwheel(float pos); static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed); -//| .. currentmodule:: pixelbuf +//| .. currentmodule:: _pixelbuf //| //| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices //| =========================================================================== @@ -64,7 +64,7 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t //| output buffer (``buf``). //| //| :param ~int size: Number of pixelsx -//| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR") +//| :param ~str byteorder: Byte order string (such as "BGR" or "BGRP") //| :param ~float brightness: Brightness (0 to 1.0, default 1.0) //| :param ~bool auto_write: Whether to automatically write pixels (Default False) //| :param bytes header: Sequence of bytes to always send before pixel values. From 6660311a96f063e935e85a228f8b12e3a07ca95c Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Sun, 10 May 2020 14:17:57 -0700 Subject: [PATCH 062/216] vectorio: respect display transpose and mirror. VectorShape now just uses the Group's and Display's absolute transforms. --- shared-module/displayio/Group.c | 7 +++ shared-module/vectorio/Circle.c | 4 +- shared-module/vectorio/VectorShape.c | 69 +++++++++++++++------------- 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index 0c31de5320..d6df01f3de 100644 --- a/shared-module/displayio/Group.c +++ b/shared-module/displayio/Group.c @@ -215,6 +215,7 @@ static mp_obj_t _add_layer(displayio_group_t* self, mp_obj_t layer) { #if CIRCUITPY_VECTORIO native_layer = mp_instance_cast_to_native_base(layer, &vectorio_vector_shape_type); if (native_layer != MP_OBJ_NULL) { + vectorio_vector_shape_update_transform(native_layer, &self->absolute_transform); return native_layer; } #endif @@ -247,6 +248,12 @@ 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 CIRCUITPY_VECTORIO + if (MP_OBJ_IS_TYPE(layer, &vectorio_vector_shape_type)) { + vectorio_vector_shape_update_transform(layer, NULL); + } + else +#endif 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); diff --git a/shared-module/vectorio/Circle.c b/shared-module/vectorio/Circle.c index 6bcd6318fe..e6e3268e7e 100644 --- a/shared-module/vectorio/Circle.c +++ b/shared-module/vectorio/Circle.c @@ -34,8 +34,8 @@ uint32_t common_hal_vectorio_circle_get_pixel(void *obj, int16_t x, int16_t y) { void common_hal_vectorio_circle_get_area(void *circle, displayio_area_t *out_area) { vectorio_circle_t *self = circle; - out_area->x1 = -1 * self->radius; - out_area->y1 = -1 * self->radius; + out_area->x1 = -1 * self->radius - 1; + out_area->y1 = -1 * self->radius - 1; out_area->x2 = self->radius + 1; out_area->y2 = self->radius + 1; } diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index 6030c1e3d5..b23baa4cf2 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -28,34 +28,39 @@ static int32_t max(int32_t a, int32_t b) { } -inline __attribute__((always_inline)) -static void _transpose_area(displayio_area_t *out_area) { - int16_t swap = out_area->x1; - out_area->x1 = out_area->y1; - out_area->y1 = swap; - swap = out_area->x2; - out_area->x2 = out_area->y2; - out_area->y2 = swap; -} - - -inline __attribute__((always_inline)) -static void _get_shape_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) { - VECTORIO_SHAPE_DEBUG("%p get_area\n", self); - self->ishape.get_area(self->ishape.shape, out_area); -} - - inline __attribute__((always_inline)) static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) { - VECTORIO_SHAPE_DEBUG("%p get_screen_area\n", self); + VECTORIO_SHAPE_DEBUG("%p get_screen_area tform:{x:%d y:%d dx:%d dy:%d scl:%d w:%d h:%d mx:%d my:%d tr:%d}", self, + self->absolute_transform->x, self->absolute_transform->y, self->absolute_transform->dx, self->absolute_transform->dy, self->absolute_transform->scale, + self->absolute_transform->width, self->absolute_transform->height, self->absolute_transform->mirror_x, self->absolute_transform->mirror_y, self->absolute_transform->transpose_xy + ); self->ishape.get_area(self->ishape.shape, out_area); + VECTORIO_SHAPE_DEBUG(" in:{(%5d,%5d), (%5d,%5d)}", out_area->x1, out_area->y1, out_area->x2, out_area->y2); if (self->absolute_transform->transpose_xy) { - _transpose_area(out_area); - displayio_area_shift(out_area, self->y, self->x); + int16_t swap = out_area->x1; + out_area->x1 = (out_area->y1 + self->y) * self->absolute_transform->dx + self->absolute_transform->x; + out_area->y1 = (swap + self->x) * self->absolute_transform->dy + self->absolute_transform->y; + swap = out_area->x2; + out_area->x2 = (out_area->y2 + self->y) * self->absolute_transform->dx + self->absolute_transform->x; + out_area->y2 = (swap + self->x) * self->absolute_transform->dy + self->absolute_transform->y; } else { - displayio_area_shift(out_area, self->x, self->y); + out_area->x1 = (out_area->x1 + self->x) * self->absolute_transform->dx + self->absolute_transform->x; + out_area->y1 = (out_area->y1 + self->y) * self->absolute_transform->dy + self->absolute_transform->y; + out_area->x2 = (out_area->x2 + self->x) * self->absolute_transform->dx + self->absolute_transform->x; + out_area->y2 = (out_area->y2 + self->y) * self->absolute_transform->dy + self->absolute_transform->y; } + // We might have mirrored due to dx + if (out_area->x2 < out_area->x1) { + int16_t swap = out_area->x1; + out_area->x1 = out_area->x2; + out_area->x2 = swap; + } + if (out_area->y2 < out_area->y1) { + int16_t swap = out_area->y1; + out_area->y1 = out_area->y2; + out_area->y2 = swap; + } + VECTORIO_SHAPE_DEBUG(" out:{(%5d,%5d), (%5d,%5d)}\n", out_area->x1, out_area->y1, out_area->x2, out_area->y2); } @@ -79,8 +84,8 @@ void common_hal_vectorio_vector_shape_set_dirty(void *vector_shape) { static displayio_buffer_transform_t null_transform = { .x = 0, .y = 0, - .dx = 0, - .dy = 0, + .dx = 1, + .dy = 1, .scale = 1, .width = 0, .height = 0, @@ -99,9 +104,9 @@ void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, self->pixel_shader = pixel_shader; self->ishape = ishape; self->dirty = true; + self->absolute_transform = &null_transform; // Critical to have a valid transform before getting screen area. _get_screen_area(self, &self->ephemeral_dirty_area); self->ephemeral_dirty_area.next = NULL; - self->absolute_transform = &null_transform; } @@ -156,9 +161,7 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ // Pixels are drawn on the screen_area (shifted) coordinate space, while pixels are _determined_ from // the shape_area (unshifted) space. displayio_area_t overlap; - displayio_area_t shape_area; - _get_shape_area(self, &shape_area); - VECTORIO_SHAPE_DEBUG("%p fill_area dirty:%d fill: {(%3d,%3d), (%3d,%3d)} dirty: {(%3d,%3d), (%3d,%3d)}", + VECTORIO_SHAPE_DEBUG("%p fill_area dirty:%d fill: {(%5d,%5d), (%5d,%5d)} dirty: {(%5d,%5d), (%5d,%5d)}", self, self->dirty, area->x1, area->y1, area->x2, area->y2, self->ephemeral_dirty_area.x1, self->ephemeral_dirty_area.y1, self->ephemeral_dirty_area.x2, self->ephemeral_dirty_area.y2 @@ -200,11 +203,11 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ int16_t pixel_to_get_x; int16_t pixel_to_get_y; if (self->absolute_transform->transpose_xy) { - pixel_to_get_x = input_pixel.y - self->x; - pixel_to_get_y = input_pixel.x - self->y; + pixel_to_get_x = (input_pixel.y - self->absolute_transform->dy * self->x - self->absolute_transform->y) / self->absolute_transform->dy; + pixel_to_get_y = (input_pixel.x - self->absolute_transform->dx * self->y - self->absolute_transform->x) / self->absolute_transform->dx; } else { - pixel_to_get_x = input_pixel.x - self->x; - pixel_to_get_y = input_pixel.y - self->y; + pixel_to_get_x = (input_pixel.x - self->absolute_transform->dx * self->x) / self->absolute_transform->dx; + pixel_to_get_y = (input_pixel.y - self->absolute_transform->dy * self->y) / self->absolute_transform->dy; } VECTORIO_SHAPE_PIXEL_DEBUG(" get_pixel %p (%3d, %3d) -> ( %3d, %3d )", self->ishape.shape, input_pixel.x, input_pixel.y, pixel_to_get_x, pixel_to_get_y); input_pixel.pixel = self->ishape.get_pixel(self->ishape.shape, pixel_to_get_x, pixel_to_get_y); @@ -289,7 +292,7 @@ displayio_area_t* vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_ } void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displayio_buffer_transform_t *group_transform) { - self->absolute_transform = group_transform; + self->absolute_transform = group_transform == NULL ? &null_transform : group_transform; common_hal_vectorio_vector_shape_set_dirty(self); } From 58c8e00745064bd290fc9ec18a838960b27c1eea Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Sun, 10 May 2020 15:36:23 -0700 Subject: [PATCH 063/216] vectorio: clean up after group removal VectorShape tells the Group to redraw whatever it left behind when it is removed now. --- shared-module/displayio/Group.c | 2 ++ shared-module/vectorio/VectorShape.c | 7 +++++++ shared-module/vectorio/VectorShape.h | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index d6df01f3de..15cf5b8e48 100644 --- a/shared-module/displayio/Group.c +++ b/shared-module/displayio/Group.c @@ -250,6 +250,8 @@ static void _remove_layer(displayio_group_t* self, size_t index) { bool rendered_last_frame = false; #if CIRCUITPY_VECTORIO if (MP_OBJ_IS_TYPE(layer, &vectorio_vector_shape_type)) { + bool has_dirty_area = vectorio_vector_shape_get_dirty_area(layer, &layer_area); + rendered_last_frame = has_dirty_area; vectorio_vector_shape_update_transform(layer, NULL); } else diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index b23baa4cf2..f57739047a 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -64,6 +64,13 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou } +// For use by Group to know where it needs to redraw on layer removal. +bool vectorio_vector_shape_get_dirty_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) { + displayio_area_copy(&self->ephemeral_dirty_area, out_area); + return true; // For now just always redraw. +} + + // This must be invoked each time a shape changes its position or its shape in any way. void common_hal_vectorio_vector_shape_set_dirty(void *vector_shape) { vectorio_vector_shape_t *self = vector_shape; diff --git a/shared-module/vectorio/VectorShape.h b/shared-module/vectorio/VectorShape.h index 8fc698dbc1..56eb3d8a53 100644 --- a/shared-module/vectorio/VectorShape.h +++ b/shared-module/vectorio/VectorShape.h @@ -38,7 +38,9 @@ typedef struct { displayio_area_t ephemeral_dirty_area; } vectorio_vector_shape_t; -displayio_area_t* vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_t *self, displayio_area_t* tail); +displayio_area_t* vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_t *self, displayio_area_t *tail); + +bool vectorio_vector_shape_get_dirty_area(vectorio_vector_shape_t *self, displayio_area_t *current_dirty_area); // Area is always in absolute screen coordinates. bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displayio_colorspace_t *colorspace, const displayio_area_t *area, uint32_t *mask, uint32_t *buffer); From 32f85f7a44b6ce753070168b4f008a9499d70883 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Sun, 10 May 2020 16:21:07 -0700 Subject: [PATCH 064/216] vectorio: fix up Rectangle * Fix drawing 1 pixel too large * Need to pad dirty area to ensure removed shapes are fully removed --- shared-module/vectorio/Rectangle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-module/vectorio/Rectangle.c b/shared-module/vectorio/Rectangle.c index dfad58a4d1..7fabe6ff93 100644 --- a/shared-module/vectorio/Rectangle.c +++ b/shared-module/vectorio/Rectangle.c @@ -12,7 +12,7 @@ void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_ uint32_t common_hal_vectorio_rectangle_get_pixel(void *obj, int16_t x, int16_t y) { vectorio_rectangle_t *self = obj; - if (x < 0 || x >= self->width || y >= self->height || y < 0) { + if (x < 0 || x > self->width || y > self->height || y < 0) { return 0; } return 1; @@ -21,8 +21,8 @@ uint32_t common_hal_vectorio_rectangle_get_pixel(void *obj, int16_t x, int16_t y void common_hal_vectorio_rectangle_get_area(void *rectangle, displayio_area_t *out_area) { vectorio_rectangle_t *self = rectangle; - out_area->x1 = 0; - out_area->y1 = 0; + out_area->x1 = -1; + out_area->y1 = -1; out_area->x2 = self->width; out_area->y2 = self->height; } From 70f2ef3f8ef3707744741549bf7f094fd60f8435 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 10 May 2020 19:50:10 -0400 Subject: [PATCH 065/216] Fix docs some more --- shared-bindings/_pixelbuf/PixelBuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 78f94b66bc..3414b5d62b 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -58,7 +58,7 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t //| When brightness is less than 1.0, a second buffer will be used to store the color values //| before they are adjusted for brightness. //| -//| When ``P`` (pwm duration) is present as the 4th character of the byteorder +//| When ``P`` (pwm duration) is present as the first character of the byteorder //| string, the 4th value in the tuple/list for a pixel is the individual pixel //| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the //| output buffer (``buf``). @@ -265,7 +265,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); -//| .. function:: fill(color) +//| .. method:: fill(color) //| //| Fills the given pixelbuf with the given color. //| From 09fedb3fd5d0dd5852d7aa54ac9826c9a0b287b0 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 10 May 2020 21:35:37 -0400 Subject: [PATCH 066/216] fix another doc error (pixelsx - thanks @theacodes) --- shared-bindings/_pixelbuf/PixelBuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 3414b5d62b..626dde680c 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -63,7 +63,7 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t //| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the //| output buffer (``buf``). //| -//| :param ~int size: Number of pixelsx +//| :param ~int size: Number of pixels //| :param ~str byteorder: Byte order string (such as "BGR" or "BGRP") //| :param ~float brightness: Brightness (0 to 1.0, default 1.0) //| :param ~bool auto_write: Whether to automatically write pixels (Default False) From eb3d5fa453bd04cc116e704c36a97250c93b7b4b Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Sun, 10 May 2020 20:45:42 -0700 Subject: [PATCH 067/216] ujson: do not eat trailing whitespace Ujson should only worry about whitespace before JSON. This becomes apparent when you are using MP stream protocol to read directly from input buffers. When you attempt to read(1) on a UART (and possibly other protocols) you have to wait for either the byte or the timeout. Fixes: - Waiting for a timeout after you have completed reading a correct and complete JSON off the input. - Raising an OSError after reading a correct and complete JSON off the input. - Eating more data than semantically owned off the input buffer. - Blocking to start parsing JSON until the entire JSON body has been loaded into a potentially large, contiguous Python object. Code you would write before: ``` line = board_busio_uart_port.read_line() json_dict = json.loads(line) ``` or reaching for fixed buffers and swapping them around in Python. Code that did not work before that does now: ``` json_dict = json.load(board_busio_uart_port) ``` - This removes the need for intermediate copies of data when reading JSON from micropython stream protocol inputs. - It also increases total application speed by parsing JSON concurrently with receiving on boards that read from UART via DMA. - It simplifies code that users write while improving their apps. --- extmod/modujson.c | 26 ++++++++++++++++-------- ports/atmel-samd/common-hal/busio/UART.c | 3 +++ shared-bindings/busio/UART.c | 4 ++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/extmod/modujson.c b/extmod/modujson.c index 6b24bf5781..daefe18baf 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -53,6 +53,10 @@ STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps); +#define JSON_DEBUG(...) (void)0 +// #define JSON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + + // The function below implements a simple non-recursive JSON parser. // // The JSON specification is at http://www.ietf.org/rfc/rfc4627.txt @@ -80,6 +84,7 @@ typedef struct _ujson_stream_t { STATIC byte ujson_stream_next(ujson_stream_t *s) { mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode); + JSON_DEBUG(" usjon_stream_next err:%2d cur: %c \n", s->errcode, s->cur); if (s->errcode != 0) { mp_raise_OSError(s->errcode); } @@ -92,6 +97,7 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) { STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ); ujson_stream_t s = {stream_obj, stream_p->read, 0, 0}; + JSON_DEBUG("got JSON stream\n"); vstr_t vstr; vstr_init(&vstr, 8); mp_obj_list_t stack; // we use a list as a simple stack for nested JSON @@ -101,6 +107,15 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { mp_obj_type_t *stack_top_type = NULL; mp_obj_t stack_key = MP_OBJ_NULL; S_NEXT(s); + // Eat _leading_ whitespace. + // If we eat trailing whitespace we will block for timeout on streams like UART that + // wait for requested data. Furthermore, it is an OSError to read(1) and incur + // a timeout on those APIs. + // For these reasons, we must only eat _leading_ whitespace. + while (unichar_isspace(S_CUR(s))) { + JSON_DEBUG("Eating leading whitespace"); + S_NEXT(s); + } for (;;) { cont: if (S_END(s)) { @@ -262,14 +277,9 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { } } success: - // eat trailing whitespace - while (unichar_isspace(S_CUR(s))) { - S_NEXT(s); - } - if (!S_END(s)) { - // unexpected chars - goto fail; - } + // It is legal for a stream to have contents before and after JSON. + // If this parser has consumed a full successful JSON and its parse + // stack is empty, the parse has succeeded. if (stack_top == MP_OBJ_NULL || stack.len != 0) { // not exactly 1 object goto fail; diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 1f6b75f972..d6c13eb7e5 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -45,6 +45,9 @@ #include "samd/sercom.h" +#define UART_DEBUG(...) (void)0 +// #define UART_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + // Do-nothing callback needed so that usart_async code will enable rx interrupts. // See comment below re usart_async_register_callback() static void usart_async_rxc_callback(const struct usart_async_descriptor *const descr) { diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index f231924d50..883b4630f7 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -39,6 +39,9 @@ #include "py/stream.h" #include "supervisor/shared/translate.h" +#define STREAM_DEBUG(...) (void)0 +// #define STREAM_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + //| .. currentmodule:: busio //| @@ -219,6 +222,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) { + STREAM_DEBUG("busio_uart_read stream %d\n", size); busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); byte *buf = buf_in; From d8491f31768b04322728bc436b2f8e6c5f2bf0d6 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Sun, 10 May 2020 21:56:01 -0700 Subject: [PATCH 068/216] ujson: back out overeager loads() change; only change load() --- extmod/modujson.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/extmod/modujson.c b/extmod/modujson.c index daefe18baf..0f93ccb110 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -94,7 +94,7 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) { return s->cur; } -STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { +STATIC mp_obj_t _mod_ujson_load(mp_obj_t stream_obj, bool return_first_json) { const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ); ujson_stream_t s = {stream_obj, stream_p->read, 0, 0}; JSON_DEBUG("got JSON stream\n"); @@ -107,15 +107,6 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { mp_obj_type_t *stack_top_type = NULL; mp_obj_t stack_key = MP_OBJ_NULL; S_NEXT(s); - // Eat _leading_ whitespace. - // If we eat trailing whitespace we will block for timeout on streams like UART that - // wait for requested data. Furthermore, it is an OSError to read(1) and incur - // a timeout on those APIs. - // For these reasons, we must only eat _leading_ whitespace. - while (unichar_isspace(S_CUR(s))) { - JSON_DEBUG("Eating leading whitespace"); - S_NEXT(s); - } for (;;) { cont: if (S_END(s)) { @@ -277,9 +268,19 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { } } success: - // It is legal for a stream to have contents before and after JSON. - // If this parser has consumed a full successful JSON and its parse - // stack is empty, the parse has succeeded. + // It is legal for a stream to have contents after JSON. + // E.g., A UART is not closed after receiving an object; in load() we will + // return the first complete JSON object, while in loads() we will retain + // strict adherence to the buffer's complete semantic. + if (!return_first_json) { + while (unichar_isspace(S_CUR(s))) { + S_NEXT(s); + } + if (!S_END(s)) { + // unexpected chars + goto fail; + } + } if (stack_top == MP_OBJ_NULL || stack.len != 0) { // not exactly 1 object goto fail; @@ -290,6 +291,10 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { fail: mp_raise_ValueError(translate("syntax error in JSON")); } + +STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { + return _mod_ujson_load(stream_obj, true); +} STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_load_obj, mod_ujson_load); STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) { @@ -297,7 +302,7 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) { const char *buf = mp_obj_str_get_data(obj, &len); vstr_t vstr = {len, len, (char*)buf, true}; mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL}; - return mod_ujson_load(MP_OBJ_FROM_PTR(&sio)); + return _mod_ujson_load(MP_OBJ_FROM_PTR(&sio), false); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_loads_obj, mod_ujson_loads); From 838b6c56858fa3888c558e5640031b8764c313d7 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 11 May 2020 10:48:11 -0400 Subject: [PATCH 069/216] Did ps2io, pulseio, random --- shared-bindings/ps2io/Ps2.c | 135 ++++++++++++------------ shared-bindings/ps2io/__init__.c | 4 +- shared-bindings/pulseio/PWMOut.c | 114 ++++++++++---------- shared-bindings/pulseio/PulseIn.c | 161 ++++++++++++++--------------- shared-bindings/pulseio/PulseOut.c | 83 +++++++-------- shared-bindings/pulseio/__init__.c | 4 +- shared-bindings/random/__init__.c | 55 +++++----- 7 files changed, 278 insertions(+), 278 deletions(-) diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index 89ed0a76ce..d327d41801 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -36,38 +36,39 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: ps2io +//| class Ps2: +//| """.. currentmodule:: ps2io //| -//| :class:`Ps2` -- Communicate with a PS/2 keyboard or mouse -//| ========================================================= +//| :class:`Ps2` -- Communicate with a PS/2 keyboard or mouse +//| ========================================================= //| -//| Ps2 implements the PS/2 keyboard/mouse serial protocol, used in -//| legacy devices. It is similar to UART but there are only two -//| lines (Data and Clock). PS/2 devices are 5V, so bidirectional -//| level converters must be used to connect the I/O lines to pins -//| of 3.3V boards. +//| Ps2 implements the PS/2 keyboard/mouse serial protocol, used in +//| legacy devices. It is similar to UART but there are only two +//| lines (Data and Clock). PS/2 devices are 5V, so bidirectional +//| level converters must be used to connect the I/O lines to pins +//| of 3.3V boards.""" //| -//| .. class:: Ps2(data_pin, clock_pin) +//| def __init__(self, data_pin: microcontroller.Pin, clock_pin: microcontroller.Pin): +//| """Create a Ps2 object associated with the given pins. //| -//| Create a Ps2 object associated with the given pins. +//| :param ~microcontroller.Pin data_pin: Pin tied to data wire. +//| :param ~microcontroller.Pin clock_pin: Pin tied to clock wire. +//| This pin must support interrupts. //| -//| :param ~microcontroller.Pin data_pin: Pin tied to data wire. -//| :param ~microcontroller.Pin clock_pin: Pin tied to clock wire. -//| This pin must support interrupts. +//| Read one byte from PS/2 keyboard and turn on Scroll Lock LED:: //| -//| Read one byte from PS/2 keyboard and turn on Scroll Lock LED:: +//| import ps2io +//| import board //| -//| import ps2io -//| import board +//| kbd = ps2io.Ps2(board.D10, board.D11) //| -//| kbd = ps2io.Ps2(board.D10, board.D11) +//| while len(kbd) == 0: +//| pass //| -//| while len(kbd) == 0: -//| pass -//| -//| print(kbd.popleft()) -//| print(kbd.sendcmd(0xed)) -//| print(kbd.sendcmd(0x01)) +//| print(kbd.popleft()) +//| print(kbd.sendcmd(0xed)) +//| print(kbd.sendcmd(0x01))""" +//| ... //| STATIC mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_datapin, ARG_clkpin }; @@ -89,9 +90,9 @@ STATIC mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, con return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the Ps2 and releases any hardware resources for reuse. +//| def deinit(self, ) -> Any: +//| """Deinitialises the Ps2 and releases any hardware resources for reuse.""" +//| ... //| STATIC mp_obj_t ps2io_ps2_deinit(mp_obj_t self_in) { ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -106,16 +107,16 @@ STATIC void check_for_deinit(ps2io_ps2_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t ps2io_ps2_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -124,10 +125,10 @@ STATIC mp_obj_t ps2io_ps2_obj___exit__(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ps2io_ps2___exit___obj, 4, 4, ps2io_ps2_obj___exit__); -//| .. method:: popleft() -//| -//| Removes and returns the oldest received byte. When buffer -//| is empty, raises an IndexError exception. +//| def popleft(self, ) -> Any: +//| """Removes and returns the oldest received byte. When buffer +//| is empty, raises an IndexError exception.""" +//| ... //| STATIC mp_obj_t ps2io_ps2_obj_popleft(mp_obj_t self_in) { ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -141,18 +142,18 @@ STATIC mp_obj_t ps2io_ps2_obj_popleft(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(ps2io_ps2_popleft_obj, ps2io_ps2_obj_popleft); -//| .. method:: sendcmd(byte) +//| def sendcmd(self, byte: int) -> Any: +//| """Sends a command byte to PS/2. Returns the response byte, typically +//| the general ack value (0xFA). Some commands return additional data +//| which is available through :py:func:`popleft()`. //| -//| Sends a command byte to PS/2. Returns the response byte, typically -//| the general ack value (0xFA). Some commands return additional data -//| which is available through :py:func:`popleft()`. +//| Raises a RuntimeError in case of failure. The root cause can be found +//| by calling :py:func:`clear_errors()`. It is advisable to call +//| :py:func:`clear_errors()` before :py:func:`sendcmd()` to flush any +//| previous errors. //| -//| Raises a RuntimeError in case of failure. The root cause can be found -//| by calling :py:func:`clear_errors()`. It is advisable to call -//| :py:func:`clear_errors()` before :py:func:`sendcmd()` to flush any -//| previous errors. -//| -//| :param int byte: byte value of the command +//| :param int byte: byte value of the command""" +//| ... //| 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); @@ -166,35 +167,35 @@ STATIC mp_obj_t ps2io_ps2_obj_sendcmd(mp_obj_t self_in, mp_obj_t ob) { } MP_DEFINE_CONST_FUN_OBJ_2(ps2io_ps2_sendcmd_obj, ps2io_ps2_obj_sendcmd); -//| .. method:: clear_errors() +//| def clear_errors(self, ) -> Any: +//| """Returns and clears a bitmap with latest recorded communication errors. //| -//| Returns and clears a bitmap with latest recorded communication errors. +//| Reception errors (arise asynchronously, as data is received): //| -//| Reception errors (arise asynchronously, as data is received): +//| 0x01: start bit not 0 //| -//| 0x01: start bit not 0 +//| 0x02: timeout //| -//| 0x02: timeout +//| 0x04: parity bit error //| -//| 0x04: parity bit error +//| 0x08: stop bit not 1 //| -//| 0x08: stop bit not 1 +//| 0x10: buffer overflow, newest data discarded //| -//| 0x10: buffer overflow, newest data discarded +//| Transmission errors (can only arise in the course of sendcmd()): //| -//| Transmission errors (can only arise in the course of sendcmd()): +//| 0x100: clock pin didn't go to LO in time //| -//| 0x100: clock pin didn't go to LO in time +//| 0x200: clock pin didn't go to HI in time //| -//| 0x200: clock pin didn't go to HI in time +//| 0x400: data pin didn't ACK //| -//| 0x400: data pin didn't ACK +//| 0x800: clock pin didn't ACK //| -//| 0x800: clock pin didn't ACK +//| 0x1000: device didn't respond to RTS //| -//| 0x1000: device didn't respond to RTS -//| -//| 0x2000: device didn't send a response byte in time +//| 0x2000: device didn't send a response byte in time""" +//| ... //| 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); @@ -204,10 +205,10 @@ STATIC mp_obj_t ps2io_ps2_obj_clear_errors(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(ps2io_ps2_clear_errors_obj, ps2io_ps2_obj_clear_errors); -//| .. method:: __len__() -//| -//| Returns the number of received bytes in buffer, available -//| to :py:func:`popleft()`. +//| def __len__(self, ) -> Any: +//| """Returns the number of received bytes in buffer, available +//| to :py:func:`popleft()`.""" +//| ... //| 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); diff --git a/shared-bindings/ps2io/__init__.c b/shared-bindings/ps2io/__init__.c index ec7c43e51f..081127bac4 100644 --- a/shared-bindings/ps2io/__init__.c +++ b/shared-bindings/ps2io/__init__.c @@ -33,7 +33,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/ps2io/Ps2.h" -//| :mod:`ps2io` --- Support for PS/2 protocol +//| """:mod:`ps2io` --- Support for PS/2 protocol //| ===================================================== //| //| .. module:: ps2io @@ -57,7 +57,7 @@ //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| :ref:`lifetime-and-contextmanagers` for more info.""" //| STATIC const mp_rom_map_elem_t ps2io_module_globals_table[] = { diff --git a/shared-bindings/pulseio/PWMOut.c b/shared-bindings/pulseio/PWMOut.c index 2491a5c3f1..3a25d69380 100644 --- a/shared-bindings/pulseio/PWMOut.c +++ b/shared-bindings/pulseio/PWMOut.c @@ -35,55 +35,56 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: pulseio +//| class PWMOut: +//| """.. currentmodule:: pulseio //| -//| :class:`PWMOut` -- Output a Pulse Width Modulated signal -//| ======================================================== +//| :class:`PWMOut` -- Output a Pulse Width Modulated signal +//| ======================================================== //| -//| PWMOut can be used to output a PWM signal on a given pin. +//| PWMOut can be used to output a PWM signal on a given pin.""" //| -//| .. class:: PWMOut(pin, *, duty_cycle=0, frequency=500, variable_frequency=False) +//| def __init__(self, pin: microcontroller.Pin, *, duty_cycle: int = 0, frequency: int = 500, variable_frequency: bool = False): +//| """Create a PWM object associated with the given pin. This allows you to +//| write PWM signals out on the given pin. Frequency is fixed after init +//| unless ``variable_frequency`` is True. //| -//| Create a PWM object associated with the given pin. This allows you to -//| write PWM signals out on the given pin. Frequency is fixed after init -//| unless ``variable_frequency`` is True. +//| .. note:: When ``variable_frequency`` is True, further PWM outputs may be +//| limited because it may take more internal resources to be flexible. So, +//| when outputting both fixed and flexible frequency signals construct the +//| fixed outputs first. //| -//| .. note:: When ``variable_frequency`` is True, further PWM outputs may be -//| limited because it may take more internal resources to be flexible. So, -//| when outputting both fixed and flexible frequency signals construct the -//| fixed outputs first. +//| :param ~microcontroller.Pin pin: The pin to output to +//| :param int duty_cycle: The fraction of each pulse which is high. 16-bit +//| :param int frequency: The target frequency in Hertz (32-bit) +//| :param bool variable_frequency: True if the frequency will change over time //| -//| :param ~microcontroller.Pin pin: The pin to output to -//| :param int duty_cycle: The fraction of each pulse which is high. 16-bit -//| :param int frequency: The target frequency in Hertz (32-bit) -//| :param bool variable_frequency: True if the frequency will change over time +//| Simple LED fade:: //| -//| Simple LED fade:: +//| import pulseio +//| import board //| -//| import pulseio -//| import board +//| pwm = pulseio.PWMOut(board.D13) # output on D13 +//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz //| -//| pwm = pulseio.PWMOut(board.D13) # output on D13 -//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz +//| PWM at specific frequency (servos and motors):: //| -//| PWM at specific frequency (servos and motors):: +//| import pulseio +//| import board //| -//| import pulseio -//| import board +//| pwm = pulseio.PWMOut(board.D13, frequency=50) +//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz //| -//| pwm = pulseio.PWMOut(board.D13, frequency=50) -//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz +//| Variable frequency (usually tones):: //| -//| Variable frequency (usually tones):: +//| import pulseio +//| import board +//| import time //| -//| import pulseio -//| import board -//| import time -//| -//| pwm = pulseio.PWMOut(board.D13, duty_cycle=2 ** 15, frequency=440, variable_frequency=True) -//| time.sleep(0.2) -//| pwm.frequency = 880 -//| time.sleep(0.1) +//| pwm = pulseio.PWMOut(board.D13, duty_cycle=2 ** 15, frequency=440, variable_frequency=True) +//| time.sleep(0.2) +//| pwm.frequency = 880 +//| time.sleep(0.1)""" +//| ... //| STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { enum { ARG_pin, ARG_duty_cycle, ARG_frequency, ARG_variable_frequency }; @@ -119,9 +120,9 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the PWMOut and releases any hardware resources for reuse. +//| def deinit(self, ) -> Any: +//| """Deinitialises the PWMOut and releases any hardware resources for reuse.""" +//| ... //| STATIC mp_obj_t pulseio_pwmout_deinit(mp_obj_t self_in) { pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -136,16 +137,16 @@ STATIC void check_for_deinit(pulseio_pwmout_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t pulseio_pwmout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -154,16 +155,16 @@ STATIC mp_obj_t pulseio_pwmout_obj___exit__(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pwmout___exit___obj, 4, 4, pulseio_pwmout_obj___exit__); -//| .. attribute:: duty_cycle +//| duty_cycle: Any = ... +//| """16 bit value that dictates how much of one cycle is high (1) versus low +//| (0). 0xffff will always be high, 0 will always be low and 0x7fff will +//| be half high and then half low. //| -//| 16 bit value that dictates how much of one cycle is high (1) versus low -//| (0). 0xffff will always be high, 0 will always be low and 0x7fff will -//| be half high and then half low. +//| Depending on how PWM is implemented on a specific board, the internal +//| representation for duty cycle might have less than 16 bits of resolution. +//| Reading this property will return the value from the internal representation, +//| so it may differ from the value set.""" //| -//| Depending on how PWM is implemented on a specific board, the internal -//| representation for duty cycle might have less than 16 bits of resolution. -//| Reading this property will return the value from the internal representation, -//| so it may differ from the value set. 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); check_for_deinit(self); @@ -190,16 +191,15 @@ const mp_obj_property_t pulseio_pwmout_duty_cycle_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: frequency -//| -//| 32 bit value that dictates the PWM frequency in Hertz (cycles per +//| frequency: Any = ... +//| """32 bit value that dictates the PWM frequency in Hertz (cycles per //| second). Only writeable when constructed with ``variable_frequency=True``. //| //| Depending on how PWM is implemented on a specific board, the internal value //| for the PWM's duty cycle may need to be recalculated when the frequency //| changes. In these cases, the duty cycle is automatically recalculated //| from the original duty cycle value. This should happen without any need -//| to manually re-set the duty cycle. +//| to manually re-set the duty cycle.""" //| 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); diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 6c01a4c178..9024f53e3b 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -35,51 +35,52 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: pulseio +//| class PulseIn: +//| """.. currentmodule:: pulseio //| -//| :class:`PulseIn` -- Read a series of pulse durations -//| ======================================================== +//| :class:`PulseIn` -- Read a series of pulse durations +//| ======================================================== //| -//| PulseIn is used to measure a series of active and idle pulses. This is -//| commonly used in infrared receivers and low cost temperature sensors (DHT). -//| The pulsed signal consists of timed active and idle periods. Unlike PWM, -//| there is no set duration for active and idle pairs. +//| PulseIn is used to measure a series of active and idle pulses. This is +//| commonly used in infrared receivers and low cost temperature sensors (DHT). +//| The pulsed signal consists of timed active and idle periods. Unlike PWM, +//| there is no set duration for active and idle pairs.""" //| -//| .. class:: PulseIn(pin, maxlen=2, *, idle_state=False) +//| def __init__(self, pin: microcontroller.Pin, maxlen: int = 2, *, idle_state: bool = False): +//| """Create a PulseIn object associated with the given pin. The object acts as +//| a read-only sequence of pulse lengths with a given max length. When it is +//| active, new pulse lengths are added to the end of the list. When there is +//| no more room (len() == `maxlen`) the oldest pulse length is removed to +//| make room. //| -//| Create a PulseIn object associated with the given pin. The object acts as -//| a read-only sequence of pulse lengths with a given max length. When it is -//| active, new pulse lengths are added to the end of the list. When there is -//| no more room (len() == `maxlen`) the oldest pulse length is removed to -//| make room. +//| :param ~microcontroller.Pin pin: Pin to read pulses from. +//| :param int maxlen: Maximum number of pulse durations to store at once +//| :param bool idle_state: Idle state of the pin. At start and after `resume` +//| the first recorded pulse will the opposite state from idle. //| -//| :param ~microcontroller.Pin pin: Pin to read pulses from. -//| :param int maxlen: Maximum number of pulse durations to store at once -//| :param bool idle_state: Idle state of the pin. At start and after `resume` -//| the first recorded pulse will the opposite state from idle. +//| Read a short series of pulses:: //| -//| Read a short series of pulses:: +//| import pulseio +//| import board //| -//| import pulseio -//| import board +//| pulses = pulseio.PulseIn(board.D7) //| -//| pulses = pulseio.PulseIn(board.D7) +//| # Wait for an active pulse +//| while len(pulses) == 0: +//| pass +//| # Pause while we do something with the pulses +//| pulses.pause() //| -//| # Wait for an active pulse -//| while len(pulses) == 0: -//| pass -//| # Pause while we do something with the pulses -//| pulses.pause() +//| # Print the pulses. pulses[0] is an active pulse unless the length +//| # reached max length and idle pulses are recorded. +//| print(pulses) //| -//| # Print the pulses. pulses[0] is an active pulse unless the length -//| # reached max length and idle pulses are recorded. -//| print(pulses) +//| # Clear the rest +//| pulses.clear() //| -//| # Clear the rest -//| pulses.clear() -//| -//| # Resume with an 80 microsecond active pulse -//| pulses.resume(80) +//| # Resume with an 80 microsecond active pulse +//| pulses.resume(80)""" +//| ... //| STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pin, ARG_maxlen, ARG_idle_state }; @@ -101,9 +102,9 @@ STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the PulseIn and releases any hardware resources for reuse. +//| def deinit(self, ) -> Any: +//| """Deinitialises the PulseIn and releases any hardware resources for reuse.""" +//| ... //| STATIC mp_obj_t pulseio_pulsein_deinit(mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -118,16 +119,16 @@ STATIC void check_for_deinit(pulseio_pulsein_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t pulseio_pulsein_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -136,9 +137,9 @@ STATIC mp_obj_t pulseio_pulsein_obj___exit__(size_t n_args, const mp_obj_t *args } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulsein___exit___obj, 4, 4, pulseio_pulsein_obj___exit__); -//| .. method:: pause() -//| -//| Pause pulse capture +//| def pause(self, ) -> Any: +//| """Pause pulse capture""" +//| ... //| STATIC mp_obj_t pulseio_pulsein_obj_pause(mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -149,16 +150,16 @@ STATIC mp_obj_t pulseio_pulsein_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_pause_obj, pulseio_pulsein_obj_pause); -//| .. method:: resume(trigger_duration=0) +//| def resume(self, trigger_duration: int = 0) -> Any: +//| """Resumes pulse capture after an optional trigger pulse. //| -//| Resumes pulse capture after an optional trigger pulse. +//| .. warning:: Using trigger pulse with a device that drives both high and +//| low signals risks a short. Make sure your device is open drain (only +//| drives low) when using a trigger pulse. You most likely added a +//| "pull-up" resistor to your circuit to do this. //| -//| .. warning:: Using trigger pulse with a device that drives both high and -//| low signals risks a short. Make sure your device is open drain (only -//| drives low) when using a trigger pulse. You most likely added a -//| "pull-up" resistor to your circuit to do this. -//| -//| :param int trigger_duration: trigger pulse duration in microseconds +//| :param int trigger_duration: trigger pulse duration in microseconds""" +//| ... //| STATIC mp_obj_t pulseio_pulsein_obj_resume(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_trigger_duration }; @@ -176,9 +177,9 @@ STATIC mp_obj_t pulseio_pulsein_obj_resume(size_t n_args, const mp_obj_t *pos_ar } MP_DEFINE_CONST_FUN_OBJ_KW(pulseio_pulsein_resume_obj, 1, pulseio_pulsein_obj_resume); -//| .. method:: clear() -//| -//| Clears all captured pulses +//| def clear(self, ) -> Any: +//| """Clears all captured pulses""" +//| ... //| STATIC mp_obj_t pulseio_pulsein_obj_clear(mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -189,9 +190,9 @@ STATIC mp_obj_t pulseio_pulsein_obj_clear(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_clear_obj, pulseio_pulsein_obj_clear); -//| .. method:: popleft() -//| -//| Removes and returns the oldest read pulse. +//| def popleft(self, ) -> Any: +//| """Removes and returns the oldest read pulse.""" +//| ... //| STATIC mp_obj_t pulseio_pulsein_obj_popleft(mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -201,10 +202,9 @@ STATIC mp_obj_t pulseio_pulsein_obj_popleft(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_popleft_obj, pulseio_pulsein_obj_popleft); -//| .. attribute:: maxlen -//| -//| The maximum length of the PulseIn. When len() is equal to maxlen, -//| it is unclear which pulses are active and which are idle. +//| maxlen: Any = ... +//| """The maximum length of the PulseIn. When len() is equal to maxlen, +//| it is unclear which pulses are active and which are idle.""" //| 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); @@ -221,10 +221,9 @@ const mp_obj_property_t pulseio_pulsein_maxlen_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: paused -//| -//| True when pulse capture is paused as a result of :py:func:`pause` or an error during capture -//| such as a signal that is too fast. +//| paused: Any = ... +//| """True when pulse capture is paused as a result of :py:func:`pause` or an error during capture +//| such as a signal that is too fast.""" //| 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); @@ -241,14 +240,14 @@ const mp_obj_property_t pulseio_pulsein_paused_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: __len__() +//| def __len__(self, ) -> Any: +//| """Returns the current pulse length //| -//| Returns the current pulse length +//| This allows you to:: //| -//| This allows you to:: -//| -//| pulses = pulseio.PulseIn(pin) -//| print(len(pulses)) +//| pulses = pulseio.PulseIn(pin) +//| print(len(pulses))""" +//| ... //| 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); @@ -261,14 +260,14 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } -//| .. method:: __getitem__(index) +//| def __getitem__(self, index: Any) -> Any: +//| """Returns the value at the given index or values in slice. //| -//| Returns the value at the given index or values in slice. +//| This allows you to:: //| -//| This allows you to:: -//| -//| pulses = pulseio.PulseIn(pin) -//| print(pulses[0]) +//| pulses = pulseio.PulseIn(pin) +//| print(pulses[0])""" +//| ... //| STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { if (value == mp_const_none) { diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index 172459e5df..9c650731bb 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -36,37 +36,38 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: pulseio +//| class PulseOut: +//| """.. currentmodule:: pulseio //| -//| :class:`PulseOut` -- Output a pulse train -//| ======================================================== +//| :class:`PulseOut` -- Output a pulse train +//| ======================================================== //| -//| PulseOut is used to pulse PWM "carrier" output on and off. This is commonly -//| used in infrared remotes. The pulsed signal consists of timed on and off -//| periods. Unlike PWM, there is no set duration for on and off pairs. +//| PulseOut is used to pulse PWM "carrier" output on and off. This is commonly +//| used in infrared remotes. The pulsed signal consists of timed on and off +//| periods. Unlike PWM, there is no set duration for on and off pairs.""" //| -//| .. class:: PulseOut(carrier) +//| def __init__(self, carrier: pulseio.PWMOut): +//| """Create a PulseOut object associated with the given PWMout object. //| -//| Create a PulseOut object associated with the given PWMout object. +//| :param ~pulseio.PWMOut carrier: PWMOut that is set to output on the desired pin. //| -//| :param ~pulseio.PWMOut carrier: PWMOut that is set to output on the desired pin. +//| Send a short series of pulses:: //| -//| Send a short series of pulses:: +//| import array +//| import pulseio +//| import board //| -//| import array -//| import pulseio -//| import board +//| # 50% duty cycle at 38kHz. +//| pwm = pulseio.PWMOut(board.D13, frequency=38000, duty_cycle=32768) +//| pulse = pulseio.PulseOut(pwm) +//| # on off on off on +//| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000]) +//| pulse.send(pulses) //| -//| # 50% duty cycle at 38kHz. -//| pwm = pulseio.PWMOut(board.D13, frequency=38000, duty_cycle=32768) -//| pulse = pulseio.PulseOut(pwm) -//| # on off on off on -//| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000]) -//| pulse.send(pulses) -//| -//| # Modify the array of pulses. -//| pulses[0] = 200 -//| pulse.send(pulses) +//| # Modify the array of pulses. +//| pulses[0] = 200 +//| pulse.send(pulses)""" +//| ... //| STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 1, false); @@ -85,9 +86,9 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitialises the PulseOut and releases any hardware resources for reuse. +//| def deinit(self, ) -> Any: +//| """Deinitialises the PulseOut and releases any hardware resources for reuse.""" +//| ... //| STATIC mp_obj_t pulseio_pulseout_deinit(mp_obj_t self_in) { pulseio_pulseout_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -96,16 +97,16 @@ STATIC mp_obj_t pulseio_pulseout_deinit(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulseout_deinit_obj, pulseio_pulseout_deinit); -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t pulseio_pulseout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -114,16 +115,16 @@ STATIC mp_obj_t pulseio_pulseout_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulseout___exit___obj, 4, 4, pulseio_pulseout_obj___exit__); -//| .. method:: send(pulses) +//| def send(self, pulses: array.array) -> Any: +//| """Pulse alternating on and off durations in microseconds starting with on. +//| ``pulses`` must be an `array.array` with data type 'H' for unsigned +//| halfword (two bytes). //| -//| Pulse alternating on and off durations in microseconds starting with on. -//| ``pulses`` must be an `array.array` with data type 'H' for unsigned -//| halfword (two bytes). +//| This method waits until the whole array of pulses has been sent and +//| ensures the signal is off afterwards. //| -//| This method waits until the whole array of pulses has been sent and -//| ensures the signal is off afterwards. -//| -//| :param array.array pulses: pulse durations in microseconds +//| :param array.array pulses: pulse durations in microseconds""" +//| ... //| 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); diff --git a/shared-bindings/pulseio/__init__.c b/shared-bindings/pulseio/__init__.c index a3cec3dca5..70cb61fc30 100644 --- a/shared-bindings/pulseio/__init__.c +++ b/shared-bindings/pulseio/__init__.c @@ -35,7 +35,7 @@ #include "shared-bindings/pulseio/PulseOut.h" #include "shared-bindings/pulseio/PWMOut.h" -//| :mod:`pulseio` --- Support for pulse based protocols +//| """:mod:`pulseio` --- Support for pulse based protocols //| ===================================================== //| //| .. module:: pulseio @@ -73,7 +73,7 @@ //| :py:data:`~pulseio.PWMOut.duty_cycle`, and then sleep 0.1 seconds. //| CircuitPython will automatically turn off the PWM when it resets all //| hardware after program completion. Use ``deinit()`` or a ``with`` statement -//| to do it yourself. +//| to do it yourself.""" //| STATIC const mp_rom_map_elem_t pulseio_module_globals_table[] = { diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index de4c90910d..d8b266be00 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -33,7 +33,7 @@ #include "shared-bindings/random/__init__.h" #include "supervisor/shared/translate.h" -//| :mod:`random` --- pseudo-random numbers and choices +//| """:mod:`random` --- pseudo-random numbers and choices //| ======================================================== //| //| .. module:: random @@ -49,13 +49,13 @@ //| Once seeded, it will be deterministic, which is why its bad for cryptography. //| //| .. warning:: Numbers from this module are not cryptographically strong! Use -//| bytes from `os.urandom` directly for true randomness. +//| bytes from `os.urandom` directly for true randomness.""" //| -//| .. function:: seed(seed) -//| -//| Sets the starting seed of the random number generation. Further calls to -//| `random` will return deterministic results afterwards. +//| def seed(seed: Any) -> Any: +//| """Sets the starting seed of the random number generation. Further calls to +//| `random` will return deterministic results afterwards.""" +//| ... //| STATIC mp_obj_t random_seed(mp_obj_t seed_in) { mp_uint_t seed = mp_obj_get_int_truncated(seed_in); @@ -64,9 +64,9 @@ STATIC mp_obj_t random_seed(mp_obj_t seed_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_seed_obj, random_seed); -//| .. function:: getrandbits(k) -//| -//| Returns an integer with *k* random bits. +//| def getrandbits(k: Any) -> Any: +//| """Returns an integer with *k* random bits.""" +//| ... //| STATIC mp_obj_t random_getrandbits(mp_obj_t num_in) { int n = mp_obj_get_int(num_in); @@ -77,10 +77,9 @@ STATIC mp_obj_t random_getrandbits(mp_obj_t num_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_getrandbits_obj, random_getrandbits); -//| .. function:: randrange(stop) -//| randrange(start, stop, step=1) -//| -//| Returns a randomly selected integer from ``range(start, stop, step)``. +//| def randrange(stop: Any) -> Any: +//| """Returns a randomly selected integer from ``range(start, stop, step)``.""" +//| ... //| STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { mp_int_t start = 0; @@ -120,10 +119,10 @@ STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(random_randrange_obj, 1, 3, random_randrange); -//| .. function:: randint(a, b) -//| -//| Returns a randomly selected integer between a and b inclusive. Equivalent -//| to ``randrange(a, b + 1, 1)`` +//| def randint(a: Any, b: Any) -> Any: +//| """Returns a randomly selected integer between a and b inclusive. Equivalent +//| to ``randrange(a, b + 1, 1)``""" +//| ... //| STATIC mp_obj_t random_randint(mp_obj_t a_in, mp_obj_t b_in) { mp_int_t a = mp_obj_get_int(a_in); @@ -135,10 +134,10 @@ STATIC mp_obj_t random_randint(mp_obj_t a_in, mp_obj_t b_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(random_randint_obj, random_randint); -//| .. function:: choice(seq) -//| -//| Returns a randomly selected element from the given sequence. Raises -//| IndexError when the sequence is empty. +//| def choice(seq: Any) -> Any: +//| """Returns a randomly selected element from the given sequence. Raises +//| IndexError when the sequence is empty.""" +//| ... //| STATIC mp_obj_t random_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); @@ -149,19 +148,19 @@ STATIC mp_obj_t random_choice(mp_obj_t seq) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_choice_obj, random_choice); -//| .. function:: random() -//| -//| Returns a random float between 0 and 1.0. +//| def random() -> Any: +//| """Returns a random float between 0 and 1.0.""" +//| ... //| STATIC mp_obj_t random_random(void) { return mp_obj_new_float(shared_modules_random_random()); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(random_random_obj, random_random); -//| .. function:: uniform(a, b) -//| -//| Returns a random float between a and b. It may or may not be inclusive -//| depending on float rounding. +//| def uniform(a: Any, b: Any) -> Any: +//| """Returns a random float between a and b. It may or may not be inclusive +//| depending on float rounding.""" +//| ... //| STATIC mp_obj_t random_uniform(mp_obj_t a_in, mp_obj_t b_in) { mp_float_t a = mp_obj_get_float(a_in); From 2ddfab315ca8709a5a18aa8411abdc899b71b44f Mon Sep 17 00:00:00 2001 From: DavePutz Date: Mon, 11 May 2020 11:31:18 -0500 Subject: [PATCH 070/216] Added call to rtc_reset() in rtc_init() Fix for issue #2872. The rtc_time_source had not been initialized; causing a time.time() call to fail. --- ports/atmel-samd/supervisor/port.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index b3903bb862..f232572e47 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -174,6 +174,7 @@ static void rtc_init(void) { #endif NVIC_ClearPendingIRQ(RTC_IRQn); NVIC_EnableIRQ(RTC_IRQn); + rtc_reset(); } safe_mode_t port_init(void) { From c7a9d49cba38499ec6701fdfef0c14e1dd5503a8 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 11 May 2020 13:00:19 -0400 Subject: [PATCH 071/216] Did rgbmatrix, rotaryio, and RTC --- shared-bindings/rgbmatrix/RGBMatrix.c | 103 +++++++++--------- shared-bindings/rgbmatrix/__init__.c | 5 +- shared-bindings/rotaryio/IncrementalEncoder.c | 72 ++++++------ shared-bindings/rotaryio/__init__.c | 4 +- shared-bindings/rtc/RTC.c | 49 +++++---- shared-bindings/rtc/__init__.c | 30 ++--- 6 files changed, 132 insertions(+), 131 deletions(-) diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index d758774d9f..e2393eb61d 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -38,10 +38,11 @@ #include "shared-module/framebufferio/__init__.h" #include "shared-module/framebufferio/FramebufferDisplay.h" -//| .. currentmodule:: rgbmatrix +//| class RGBMatrix: +//| """.. currentmodule:: rgbmatrix //| -//| :class:`RGBMatrix` -- Driver for HUB75-style RGB LED matrices -//| ================================================================ +//| :class:`RGBMatrix` -- Driver for HUB75-style RGB LED matrices +//| ================================================================ //| extern Protomatter_core *_PM_protoPtr; @@ -133,45 +134,45 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ } } -//| :class:`~rgbmatrix.RGBMatrix` displays an in-memory framebuffer to an LED matrix. + +//| :class:`~rgbmatrix.RGBMatrix` displays an in-memory framebuffer to an LED matrix.""" //| -//| .. class:: RGBMatrix(*, width, bit_depth, rgb_pins, addr_pins, clock_pin, latch_pin, output_enable_pin, doublebuffer=True, framebuffer=None, height=0) +//| def __init__(self, *, width: Any, bit_depth: Any, rgb_pins: Any, addr_pins: Any, clock_pin: Any, latch_pin: Any, output_enable_pin: Any, doublebuffer: Any = True, framebuffer: Any = None, height: Any = 0): +//| """Create a RGBMatrix object with the given attributes. The height of +//| the display is determined by the number of rgb and address pins: +//| len(rgb_pins) // 3 * 2 ** len(address_pins). With 6 RGB pins and 4 +//| address lines, the display will be 32 pixels tall. If the optional height +//| parameter is specified and is not 0, it is checked against the calculated +//| height. //| -//| Create a RGBMatrix object with the given attributes. The height of -//| the display is determined by the number of rgb and address pins: -//| len(rgb_pins) // 3 * 2 ** len(address_pins). With 6 RGB pins and 4 -//| address lines, the display will be 32 pixels tall. If the optional height -//| parameter is specified and is not 0, it is checked against the calculated -//| height. +//| Up to 30 RGB pins and 8 address pins are supported. //| -//| Up to 30 RGB pins and 8 address pins are supported. +//| The RGB pins must be within a single "port" and performance and memory +//| usage are best when they are all within "close by" bits of the port. +//| The clock pin must also be on the same port as the RGB pins. See the +//| documentation of the underlying protomatter C library for more +//| information. Generally, Adafruit's interface boards are designed so +//| that these requirements are met when matched with the intended +//| microcontroller board. For instance, the Feather M4 Express works +//| together with the RGB Matrix Feather. //| -//| The RGB pins must be within a single "port" and performance and memory -//| usage are best when they are all within "close by" bits of the port. -//| The clock pin must also be on the same port as the RGB pins. See the -//| documentation of the underlying protomatter C library for more -//| information. Generally, Adafruit's interface boards are designed so -//| that these requirements are met when matched with the intended -//| microcontroller board. For instance, the Feather M4 Express works -//| together with the RGB Matrix Feather. +//| The framebuffer is in "RGB565" format. //| -//| The framebuffer is in "RGB565" format. +//| "RGB565" means that it is organized as a series of 16-bit numbers +//| where the highest 5 bits are interpreted as red, the next 6 as +//| green, and the final 5 as blue. The object can be any buffer, but +//| `array.array` and `ulab.array` objects are most often useful. +//| To update the content, modify the framebuffer and call refresh. //| -//| "RGB565" means that it is organized as a series of 16-bit numbers -//| where the highest 5 bits are interpreted as red, the next 6 as -//| green, and the final 5 as blue. The object can be any buffer, but -//| `array.array` and `ulab.array` objects are most often useful. -//| To update the content, modify the framebuffer and call refresh. +//| If a framebuffer is not passed in, one is allocated and initialized +//| to all black. In any case, the framebuffer can be retrieved +//| by passing the RGBMatrix object to memoryview(). //| -//| If a framebuffer is not passed in, one is allocated and initialized -//| to all black. In any case, the framebuffer can be retrieved -//| by passing the RGBMatrix object to memoryview(). +//| If doublebuffer is False, some memory is saved, but the display may +//| flicker during updates. //| -//| If doublebuffer is False, some memory is saved, but the display may -//| flicker during updates. -//| -//| A RGBMatrix is often used in conjunction with a -//| `framebufferio.FramebufferDisplay`. +//| A RGBMatrix is often used in conjunction with a +//| `framebufferio.FramebufferDisplay`.""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -245,11 +246,11 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit -//| -//| Free the resources (pins, timers, etc.) associated with this -//| rgbmatrix instance. After deinitialization, no further operations -//| may be performed. +//| def deinit(self, ) -> Any: +//| """Free the resources (pins, timers, etc.) associated with this +//| rgbmatrix instance. After deinitialization, no further operations +//| may be performed.""" +//| ... //| STATIC mp_obj_t rgbmatrix_rgbmatrix_deinit(mp_obj_t self_in) { rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; @@ -265,10 +266,9 @@ static void check_for_deinit(rgbmatrix_rgbmatrix_obj_t *self) { } } -//| .. attribute:: brightness -//| -//| In the current implementation, 0.0 turns the display off entirely -//| and any other value up to 1.0 turns the display on fully. +//| brightness: Any = ... +//| """In the current implementation, 0.0 turns the display off entirely +//| and any other value up to 1.0 turns the display on fully.""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_get_brightness(mp_obj_t self_in) { rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; @@ -297,10 +297,9 @@ const mp_obj_property_t rgbmatrix_rgbmatrix_brightness_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: refresh() -//| -//| Transmits the color data in the buffer to the pixels so that -//| they are shown. +//| def refresh(self, ) -> Any: ... +//| """Transmits the color data in the buffer to the pixels so that +//| they are shown.""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_refresh(mp_obj_t self_in) { rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; @@ -310,9 +309,8 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_refresh(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rgbmatrix_rgbmatrix_refresh_obj, rgbmatrix_rgbmatrix_refresh); -//| .. attribute:: width -//| -//| The width of the display, in pixels +//| width: Any = ... +//| """The width of the display, in pixels""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_get_width(mp_obj_t self_in) { rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; @@ -327,9 +325,8 @@ const mp_obj_property_t rgbmatrix_rgbmatrix_width_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: height -//| -//| The height of the display, in pixels +//| height: Any = ... +//| """The height of the display, in pixels""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_get_height(mp_obj_t self_in) { rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; diff --git a/shared-bindings/rgbmatrix/__init__.c b/shared-bindings/rgbmatrix/__init__.c index 662d2c4f6c..f61002a780 100644 --- a/shared-bindings/rgbmatrix/__init__.c +++ b/shared-bindings/rgbmatrix/__init__.c @@ -31,7 +31,7 @@ #include "shared-bindings/rgbmatrix/RGBMatrix.h" -//| :mod:`rgbmatrix` --- Low-level routines for bitbanged LED matrices +//| """:mod:`rgbmatrix` --- Low-level routines for bitbanged LED matrices //| ===================================================================== //| //| .. module:: rgbmatrix @@ -40,7 +40,8 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| RGBMatrix +//| RGBMatrix""" +//| STATIC const mp_rom_map_elem_t rgbmatrix_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_rgbmatrix) }, diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index 058241d24a..a10fb6fd5f 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -34,35 +34,36 @@ #include "shared-bindings/rotaryio/IncrementalEncoder.h" #include "shared-bindings/util.h" -//| .. currentmodule:: rotaryio +//| class IncrementalEncoder: +//| """.. currentmodule:: rotaryio //| -//| :class:`IncrementalEncoder` -- Track the relative position of an incremental encoder -//| ==================================================================================== +//| :class:`IncrementalEncoder` -- Track the relative position of an incremental encoder +//| ==================================================================================== //| -//| IncrementalEncoder determines the relative rotational position based on two series of pulses. +//| IncrementalEncoder determines the relative rotational position based on two series of pulses.""" //| -//| .. class:: IncrementalEncoder(pin_a, pin_b) +//| def __init__(self, pin_a: microcontroller.Pin, pin_b: microcontroller.Pin): +//| """Create an IncrementalEncoder object associated with the given pins. It tracks the positional +//| state of an incremental rotary encoder (also known as a quadrature encoder.) Position is +//| relative to the position when the object is contructed. //| -//| Create an IncrementalEncoder object associated with the given pins. It tracks the positional -//| state of an incremental rotary encoder (also known as a quadrature encoder.) Position is -//| relative to the position when the object is contructed. +//| :param ~microcontroller.Pin pin_a: First pin to read pulses from. +//| :param ~microcontroller.Pin pin_b: Second pin to read pulses from. //| -//| :param ~microcontroller.Pin pin_a: First pin to read pulses from. -//| :param ~microcontroller.Pin pin_b: Second pin to read pulses from. +//| For example:: //| -//| For example:: +//| import rotaryio +//| import time +//| from board import * //| -//| import rotaryio -//| import time -//| from board import * -//| -//| enc = rotaryio.IncrementalEncoder(D1, D2) -//| last_position = None -//| while True: -//| position = enc.position -//| if last_position == None or position != last_position: -//| print(position) -//| last_position = position +//| enc = rotaryio.IncrementalEncoder(D1, D2) +//| last_position = None +//| while True: +//| position = enc.position +//| if last_position == None or position != last_position: +//| print(position) +//| last_position = position""" +//| ... //| STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pin_a, ARG_pin_b }; @@ -84,9 +85,9 @@ STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitializes the IncrementalEncoder and releases any hardware resources for reuse. +//| def deinit(self, ) -> Any: +//| """Deinitializes the IncrementalEncoder and releases any hardware resources for reuse.""" +//| ... //| STATIC mp_obj_t rotaryio_incrementalencoder_deinit(mp_obj_t self_in) { rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -101,16 +102,16 @@ STATIC void check_for_deinit(rotaryio_incrementalencoder_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t rotaryio_incrementalencoder_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -120,10 +121,9 @@ STATIC mp_obj_t rotaryio_incrementalencoder_obj___exit__(size_t n_args, const mp STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(rotaryio_incrementalencoder___exit___obj, 4, 4, rotaryio_incrementalencoder_obj___exit__); -//| .. attribute:: position -//| -//| The current position in terms of pulses. The number of pulses per rotation is defined by the -//| specific hardware. +//| position: Any = ... +//| """The current position in terms of pulses. The number of pulses per rotation is defined by the +//| specific hardware.""" //| 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); diff --git a/shared-bindings/rotaryio/__init__.c b/shared-bindings/rotaryio/__init__.c index a0166771ab..0cc8eb5560 100644 --- a/shared-bindings/rotaryio/__init__.c +++ b/shared-bindings/rotaryio/__init__.c @@ -33,7 +33,7 @@ #include "shared-bindings/rotaryio/__init__.h" #include "shared-bindings/rotaryio/IncrementalEncoder.h" -//| :mod:`rotaryio` --- Support for reading rotation sensors +//| """:mod:`rotaryio` --- Support for reading rotation sensors //| ======================================================== //| //| .. module:: rotaryio @@ -59,7 +59,7 @@ //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| :ref:`lifetime-and-contextmanagers` for more info.""" //| STATIC const mp_rom_map_elem_t rotaryio_module_globals_table[] = { diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index 3ff09a4ec5..8a3e89d732 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -38,14 +38,19 @@ const rtc_rtc_obj_t rtc_rtc_obj = {{&rtc_rtc_type}}; -//| .. currentmodule:: rtc + + + + +//| class RTC: +//| """.. currentmodule:: rtc //| -//| :class:`RTC` --- Real Time Clock -//| -------------------------------- +//| :class:`RTC` --- Real Time Clock +//| --------------------------------""" //| -//| .. class:: RTC() -//| -//| This class represents the onboard Real Time Clock. It is a singleton and will always return the same instance. +//| def __init__(self, ): +//| """This class represents the onboard Real Time Clock. It is a singleton and will always return the same instance.""" +//| ... //| STATIC mp_obj_t rtc_rtc_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // No arguments @@ -55,25 +60,24 @@ STATIC mp_obj_t rtc_rtc_make_new(const mp_obj_type_t *type, size_t n_args, const return (mp_obj_t)&rtc_rtc_obj; } -//| .. attribute:: datetime +//| datetime: Any = ... +//| """The current date and time of the RTC as a `time.struct_time`. //| -//| The current date and time of the RTC as a `time.struct_time`. +//| This must be set to the current date and time whenever the board loses power:: //| -//| This must be set to the current date and time whenever the board loses power:: +//| import rtc +//| import time //| -//| import rtc -//| import time -//| -//| r = rtc.RTC() -//| r.datetime = rtctime.struct_time((2019, 5, 29, 15, 14, 15, 0, -1, -1)) +//| r = rtc.RTC() +//| r.datetime = rtctime.struct_time((2019, 5, 29, 15, 14, 15, 0, -1, -1)) //| //| -//| Once set, the RTC will automatically update this value as time passes. You can read this -//| property to get a snapshot of the current time:: +//| Once set, the RTC will automatically update this value as time passes. You can read this +//| property to get a snapshot of the current time:: //| -//| current_time = r.datetime -//| print(current_time) -//| # struct_time(tm_year=2019, tm_month=5, ...) +//| current_time = r.datetime +//| print(current_time) +//| # struct_time(tm_year=2019, tm_month=5, ...)""" //| STATIC mp_obj_t rtc_rtc_obj_get_datetime(mp_obj_t self_in) { timeutils_struct_time_t tm; @@ -97,12 +101,11 @@ const mp_obj_property_t rtc_rtc_datetime_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: calibration -//| -//| The RTC calibration value as an `int`. +//| calibration: Any = ... +//| """The RTC calibration value as an `int`. //| //| A positive value speeds up the clock and a negative value slows it down. -//| Range and value is hardware specific, but one step is often approximately 1 ppm. +//| Range and value is hardware specific, but one step is often approximately 1 ppm.""" //| STATIC mp_obj_t rtc_rtc_obj_get_calibration(mp_obj_t self_in) { int calibration = common_hal_rtc_get_calibration(); diff --git a/shared-bindings/rtc/__init__.c b/shared-bindings/rtc/__init__.c index 22eda9b663..66669ca5fe 100644 --- a/shared-bindings/rtc/__init__.c +++ b/shared-bindings/rtc/__init__.c @@ -31,7 +31,7 @@ #include "shared-bindings/rtc/RTC.h" #include "shared-bindings/time/__init__.h" -//| :mod:`rtc` --- Real Time Clock +//| """:mod:`rtc` --- Real Time Clock //| ======================================================== //| //| .. module:: rtc @@ -47,7 +47,7 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| RTC +//| RTC""" //| void rtc_reset(void) { @@ -62,22 +62,22 @@ mp_obj_t rtc_get_time_source_time(void) { return struct_time_from_tm(&tm); } -//| .. function:: set_time_source(rtc) +//| def set_time_source(rtc: Any) -> Any: +//| """Sets the RTC time source used by :func:`time.localtime`. +//| The default is :class:`rtc.RTC`, but it's useful to use this to override the +//| time source for testing purposes. For example:: //| -//| Sets the RTC time source used by :func:`time.localtime`. -//| The default is :class:`rtc.RTC`, but it's useful to use this to override the -//| time source for testing purposes. For example:: +//| import rtc +//| import time //| -//| import rtc -//| import time +//| class RTC(object): +//| @property +//| def datetime(self): +//| return time.struct_time((2018, 3, 17, 21, 1, 47, 0, 0, 0)) //| -//| class RTC(object): -//| @property -//| def datetime(self): -//| return time.struct_time((2018, 3, 17, 21, 1, 47, 0, 0, 0)) -//| -//| r = RTC() -//| rtc.set_time_source(r) +//| r = RTC() +//| rtc.set_time_source(r)""" +//| ... //| STATIC mp_obj_t rtc_set_time_source(mp_obj_t time_source) { MP_STATE_VM(rtc_time_source) = time_source; From 407938bf3a7d194a3ac4e0888037ca7025185c2f Mon Sep 17 00:00:00 2001 From: DavePutz Date: Mon, 11 May 2020 12:03:44 -0500 Subject: [PATCH 072/216] Added a check for platforms supporting RTC before calling rtc_reset() Added an #if CIRCUITPY_RTC check for platforms supporting RTC --- ports/atmel-samd/supervisor/port.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index f232572e47..04e2c9191a 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -174,7 +174,10 @@ static void rtc_init(void) { #endif NVIC_ClearPendingIRQ(RTC_IRQn); NVIC_EnableIRQ(RTC_IRQn); +#if CIRCUITPY_RTC rtc_reset(); +#endif + } safe_mode_t port_init(void) { From 603df58f971743bc36b9e391cd5fb04812262533 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 11 May 2020 13:40:02 -0400 Subject: [PATCH 073/216] Did stage, socket, storage --- shared-bindings/_stage/Layer.c | 45 +++++---- shared-bindings/_stage/Text.c | 37 +++---- shared-bindings/_stage/__init__.c | 12 +-- shared-bindings/socket/__init__.c | 156 +++++++++++++++-------------- shared-bindings/storage/__init__.c | 138 ++++++++++++------------- 5 files changed, 196 insertions(+), 192 deletions(-) diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index 12028b1319..437114cd31 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -30,25 +30,26 @@ #include "Layer.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: _stage +//| class Layer: +//| """.. currentmodule:: _stage //| -//| :class:`Layer` -- Keep information about a single layer of graphics -//| =================================================================== +//| :class:`Layer` -- Keep information about a single layer of graphics +//| ===================================================================""" //| -//| .. class:: Layer(width, height, graphic, palette, [grid]) +//| def __init__(self, width: int, height: int, graphic: bytearray, palette: bytearray, grid: bytearray): +//| """Keep internal information about a layer of graphics (either a +//| ``Grid`` or a ``Sprite``) in a format suitable for fast rendering +//| with the ``render()`` function. //| -//| Keep internal information about a layer of graphics (either a -//| ``Grid`` or a ``Sprite``) in a format suitable for fast rendering -//| with the ``render()`` function. +//| :param int width: The width of the grid in tiles, or 1 for sprites. +//| :param int height: The height of the grid in tiles, or 1 for sprites. +//| :param bytearray graphic: The graphic data of the tiles. +//| :param bytearray palette: The color palette to be used. +//| :param bytearray grid: The contents of the grid map. //| -//| :param int width: The width of the grid in tiles, or 1 for sprites. -//| :param int height: The height of the grid in tiles, or 1 for sprites. -//| :param bytearray graphic: The graphic data of the tiles. -//| :param bytearray palette: The color palette to be used. -//| :param bytearray grid: The contents of the grid map. -//| -//| This class is intended for internal use in the ``stage`` library and -//| it shouldn't be used on its own. +//| This class is intended for internal use in the ``stage`` library and +//| it shouldn't be used on its own.""" +//| ... //| STATIC mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { @@ -90,9 +91,9 @@ STATIC mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(self); } -//| .. method:: move(x, y) -//| -//| Set the offset of the layer to the specified values. +//| def move(self, x: Any, y: Any) -> Any: +//| """Set the offset of the layer to the specified values.""" +//| ... //| STATIC mp_obj_t layer_move(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) { layer_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -102,10 +103,10 @@ STATIC mp_obj_t layer_move(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(layer_move_obj, layer_move); -//| .. method:: frame(frame, rotation) -//| -//| Set the animation frame of the sprite, and optionally rotation its -//| graphic. +//| def frame(self, frame: Any, rotation: Any) -> Any: +//| """Set the animation frame of the sprite, and optionally rotation its +//| graphic.""" +//| ... //| STATIC mp_obj_t layer_frame(mp_obj_t self_in, mp_obj_t frame_in, mp_obj_t rotation_in) { diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index 49c1d00ca8..8797f74dbe 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -30,25 +30,26 @@ #include "Text.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: _stage +//| class Text: +//| """.. currentmodule:: _stage //| -//| :class:`Text` -- Keep information about a single text of text -//| ============================================================== +//| :class:`Text` -- Keep information about a single text of text +//| ==============================================================""" //| -//| .. class:: Text(width, height, font, palette, chars) +//| def __init__(self, width: int, height: int, font: bytearray, palette: bytearray, chars: bytearray): +//| """Keep internal information about a text of text +//| in a format suitable for fast rendering +//| with the ``render()`` function. //| -//| Keep internal information about a text of text -//| in a format suitable for fast rendering -//| with the ``render()`` function. +//| :param int width: The width of the grid in tiles, or 1 for sprites. +//| :param int height: The height of the grid in tiles, or 1 for sprites. +//| :param bytearray font: The font data of the characters. +//| :param bytearray palette: The color palette to be used. +//| :param bytearray chars: The contents of the character grid. //| -//| :param int width: The width of the grid in tiles, or 1 for sprites. -//| :param int height: The height of the grid in tiles, or 1 for sprites. -//| :param bytearray font: The font data of the characters. -//| :param bytearray palette: The color palette to be used. -//| :param bytearray chars: The contents of the character grid. -//| -//| This class is intended for internal use in the ``stage`` library and -//| it shouldn't be used on its own. +//| This class is intended for internal use in the ``stage`` library and +//| it shouldn't be used on its own.""" +//| ... //| STATIC mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { @@ -84,9 +85,9 @@ STATIC mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(self); } -//| .. method:: move(x, y) -//| -//| Set the offset of the text to the specified values. +//| def move(self, x: Any, y: Any) -> Any: +//| """Set the offset of the text to the specified values.""" +//| ... //| STATIC mp_obj_t text_move(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) { text_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 4bac280bf2..6b5c4fd8b1 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -34,7 +34,7 @@ #include "Layer.h" #include "Text.h" -//| :mod:`_stage` --- C-level helpers for animation of sprites on a stage +//| """:mod:`_stage` --- C-level helpers for animation of sprites on a stage //| ===================================================================== //| //| .. module:: _stage @@ -49,11 +49,10 @@ //| :maxdepth: 3 //| //| Layer -//| Text +//| Text""" //| -//| .. function:: render(x0, y0, x1, y1, layers, buffer, display[, scale[, background]]) -//| -//| Render and send to the display a fragment of the screen. +//| def render(x0: int, y0: int, x1: int, y1: int, layers: list, buffer: bytearray, display: displayio.Display, scale: int, background: int) -> Any: +//| """Render and send to the display a fragment of the screen. //| //| :param int x0: Left edge of the fragment. //| :param int y0: Top edge of the fragment. @@ -70,7 +69,8 @@ //| valid. //| //| This function is intended for internal use in the ``stage`` library -//| and all the necessary checks are performed there. +//| and all the necessary checks are performed there.""" +//| STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { uint16_t x0 = mp_obj_get_int(args[0]); uint16_t y0 = mp_obj_get_int(args[1]); diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c index 2d6c16e90f..4c0811bdb6 100644 --- a/shared-bindings/socket/__init__.c +++ b/shared-bindings/socket/__init__.c @@ -37,27 +37,28 @@ #include "shared-module/network/__init__.h" -//| :mod:`socket` --- TCP, UDP and RAW socket support +//| """:mod:`socket` --- TCP, UDP and RAW socket support //| ================================================= //| //| .. module:: socket //| :synopsis: TCP, UDP and RAW sockets //| :platform: SAMD21, SAMD51 //| -//| Create TCP, UDP and RAW sockets for communicating over the Internet. +//| Create TCP, UDP and RAW sockets for communicating over the Internet.""" //| STATIC const mp_obj_type_t socket_type; -//| .. currentmodule:: socket +//| class socket: +//| """.. currentmodule:: socket""" //| -//| .. class:: socket(family, type, proto) +//| def __init__(self, family: int, type: int, proto: int): +//| """Create a new socket //| -//| Create a new socket -//| -//| :param ~int family: AF_INET or AF_INET6 -//| :param ~int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW -//| :param ~int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored) +//| :param ~int family: AF_INET or AF_INET6 +//| :param ~int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW +//| :param ~int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)""" +//| ... //| STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { @@ -98,11 +99,11 @@ STATIC void socket_select_nic(mod_network_socket_obj_t *self, const byte *ip) { } } -//| .. method:: bind(address) +//| def bind(self, address: tuple) -> Any: +//| """Bind a socket to an address //| -//| Bind a socket to an address -//| -//| :param ~tuple address: tuple of (remote_address, remote_port) +//| :param ~tuple address: tuple of (remote_address, remote_port)""" +//| ... //| STATIC mp_obj_t socket_bind(mp_obj_t self_in, mp_obj_t addr_in) { @@ -125,11 +126,11 @@ STATIC mp_obj_t socket_bind(mp_obj_t self_in, mp_obj_t addr_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind); -//| .. method:: listen(backlog) +//| def listen(self, backlog: int) -> Any: +//| """Set socket to listen for incoming connections //| -//| Set socket to listen for incoming connections -//| -//| :param ~int backlog: length of backlog queue for waiting connetions +//| :param ~int backlog: length of backlog queue for waiting connetions""" +//| ... //| STATIC mp_obj_t socket_listen(mp_obj_t self_in, mp_obj_t backlog) { @@ -150,11 +151,10 @@ STATIC mp_obj_t socket_listen(mp_obj_t self_in, mp_obj_t backlog) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_listen_obj, socket_listen); -//| .. method:: accept() -//| -//| Accept a connection on a listening socket of type SOCK_STREAM, -//| creating a new socket of type SOCK_STREAM. -//| Returns a tuple of (new_socket, remote_address) +//| def accept(self, ) -> Any: +//| """Accept a connection on a listening socket of type SOCK_STREAM, +//| creating a new socket of type SOCK_STREAM. +//| Returns a tuple of (new_socket, remote_address)""" //| STATIC mp_obj_t socket_accept(mp_obj_t self_in) { @@ -188,11 +188,11 @@ STATIC mp_obj_t socket_accept(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_accept_obj, socket_accept); -//| .. method:: connect(address) +//| def connect(self, address: tuple) -> Any: +//| """Connect a socket to a remote address //| -//| Connect a socket to a remote address -//| -//| :param ~tuple address: tuple of (remote_address, remote_port) +//| :param ~tuple address: tuple of (remote_address, remote_port)""" +//| ... //| STATIC mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) { @@ -215,12 +215,12 @@ STATIC mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_connect_obj, socket_connect); -//| .. method:: send(bytes) +//| def send(self, bytes: bytes) -> Any: +//| """Send some bytes to the connected remote address. +//| Suits sockets of type SOCK_STREAM //| -//| Send some bytes to the connected remote address. -//| Suits sockets of type SOCK_STREAM -//| -//| :param ~bytes bytes: some bytes to send +//| :param ~bytes bytes: some bytes to send""" +//| ... //| STATIC mp_obj_t socket_send(mp_obj_t self_in, mp_obj_t buf_in) { @@ -252,19 +252,20 @@ STATIC mp_int_t _socket_recv_into(mod_network_socket_obj_t *sock, byte *buf, mp_ } -//| .. method:: recv_into(buffer[, bufsize]) +//| def recv_into(self, buffer: bytearray, bufsize: int) -> Any: +//| """Reads some bytes from the connected remote address, writing +//| into the provided buffer. If bufsize <= len(buffer) is given, +//| a maximum of bufsize bytes will be read into the buffer. If no +//| valid value is given for bufsize, the default is the length of +//| the given buffer. //| -//| Reads some bytes from the connected remote address, writing -//| into the provided buffer. If bufsize <= len(buffer) is given, -//| a maximum of bufsize bytes will be read into the buffer. If no -//| valid value is given for bufsize, the default is the length of -//| the given buffer. +//| Suits sockets of type SOCK_STREAM +//| Returns an int of number of bytes read. //| -//| Suits sockets of type SOCK_STREAM -//| Returns an int of number of bytes read. +//| :param bytearray buffer: buffer to receive into +//| :param int bufsize: optionally, a maximum number of bytes to read.""" +//| ... //| -//| :param bytearray buffer: buffer to receive into -//| :param int bufsize: optionally, a maximum number of bytes to read. STATIC mp_obj_t socket_recv_into(size_t n_args, const mp_obj_t *args) { mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(args[0]); @@ -287,13 +288,14 @@ STATIC mp_obj_t socket_recv_into(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_recv_into_obj, 2, 3, socket_recv_into); -//| .. method:: recv(bufsize) +//| def recv(self, bufsize: int) -> Any: +//| """Reads some bytes from the connected remote address. +//| Suits sockets of type SOCK_STREAM +//| Returns a bytes() of length <= bufsize //| -//| Reads some bytes from the connected remote address. -//| Suits sockets of type SOCK_STREAM -//| Returns a bytes() of length <= bufsize +//| :param ~int bufsize: maximum number of bytes to receive""" +//| ... //| -//| :param ~int bufsize: maximum number of bytes to receive STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) { mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -313,13 +315,13 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_recv_obj, socket_recv); -//| .. method:: sendto(bytes, address) +//| def sendto(self, bytes: bytes, address: tuple) -> Any: +//| """Send some bytes to a specific address. +//| Suits sockets of type SOCK_DGRAM //| -//| Send some bytes to a specific address. -//| Suits sockets of type SOCK_DGRAM -//| -//| :param ~bytes bytes: some bytes to send -//| :param ~tuple address: tuple of (remote_address, remote_port) +//| :param ~bytes bytes: some bytes to send +//| :param ~tuple address: tuple of (remote_address, remote_port)""" +//| ... //| STATIC mp_obj_t socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_in) { @@ -347,16 +349,16 @@ STATIC mp_obj_t socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_ } STATIC MP_DEFINE_CONST_FUN_OBJ_3(socket_sendto_obj, socket_sendto); -//| .. method:: recvfrom(bufsize) +//| def recvfrom(self, bufsize: int) -> Any: +//| """Reads some bytes from the connected remote address. +//| Suits sockets of type SOCK_STREAM //| -//| Reads some bytes from the connected remote address. -//| Suits sockets of type SOCK_STREAM +//| Returns a tuple containing +//| * a bytes() of length <= bufsize +//| * a remote_address, which is a tuple of ip address and port number //| -//| Returns a tuple containing -//| * a bytes() of length <= bufsize -//| * a remote_address, which is a tuple of ip address and port number -//| -//| :param ~int bufsize: maximum number of bytes to receive +//| :param ~int bufsize: maximum number of bytes to receive""" +//| ... //| STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) { @@ -386,9 +388,9 @@ STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_recvfrom_obj, socket_recvfrom); -//| .. method:: setsockopt(level, optname, value) -//| -//| Sets socket options +//| def setsockopt(self, level: Any, optname: Any, value: Any) -> Any: +//| """Sets socket options""" +//| ... //| STATIC mp_obj_t socket_setsockopt(size_t n_args, const mp_obj_t *args) { @@ -420,11 +422,11 @@ STATIC mp_obj_t socket_setsockopt(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_setsockopt_obj, 4, 4, socket_setsockopt); -//| .. method:: settimeout(value) +//| def settimeout(self, value: int) -> Any: +//| """Set the timeout value for this socket. //| -//| Set the timeout value for this socket. -//| -//| :param ~int value: timeout in seconds. 0 means non-blocking. None means block indefinitely. +//| :param ~int value: timeout in seconds. 0 means non-blocking. None means block indefinitely.""" +//| ... //| STATIC mp_obj_t socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) { @@ -451,11 +453,11 @@ STATIC mp_obj_t socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_settimeout_obj, socket_settimeout); -//| .. method:: setblocking(flag) +//| def setblocking(self, flag: bool) -> Any: +//| """Set the blocking behaviour of this socket. //| -//| Set the blocking behaviour of this socket. -//| -//| :param ~bool flag: False means non-blocking, True means block indefinitely. +//| :param ~bool flag: False means non-blocking, True means block indefinitely.""" +//| ... //| // method socket.setblocking(flag) @@ -513,13 +515,13 @@ STATIC const mp_obj_type_t socket_type = { .locals_dict = (mp_obj_dict_t*)&socket_locals_dict, }; -//| .. function:: getaddrinfo(host, port) +//| def getaddrinfo(host: Any, port: Any) -> Any: +//| """Gets the address information for a hostname and port //| -//| Gets the address information for a hostname and port -//| -//| Returns the appropriate family, socket type, socket protocol and -//| address information to call socket.socket() and socket.connect() with, -//| as a tuple. +//| Returns the appropriate family, socket type, socket protocol and +//| address information to call socket.socket() and socket.connect() with, +//| as a tuple.""" +//| ... //| STATIC mp_obj_t socket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) { diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index ba439b951c..feb1a9bd76 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -35,7 +35,7 @@ #include "shared-bindings/storage/__init__.h" #include "supervisor/shared/translate.h" -//| :mod:`storage` --- storage management +//| """:mod:`storage` --- storage management //| ======================================================== //| //| .. module:: storage @@ -45,16 +45,16 @@ //| The `storage` provides storage management functionality such as mounting and //| unmounting which is typically handled by the operating system hosting Python. //| CircuitPython does not have an OS, so this module provides this functionality -//| directly. +//| directly.""" //| -//| .. function:: mount(filesystem, mount_path, *, readonly=False) +//| def mount(filesystem: Any, mount_path: Any, *, readonly: bool = False) -> Any: +//| """Mounts the given filesystem object at the given path. //| -//| Mounts the given filesystem object at the given path. +//| This is the CircuitPython analog to the UNIX ``mount`` command. //| -//| This is the CircuitPython analog to the UNIX ``mount`` command. -//| -//| :param bool readonly: True when the filesystem should be readonly to CircuitPython. +//| :param bool readonly: True when the filesystem should be readonly to CircuitPython.""" +//| ... //| mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_readonly }; @@ -85,12 +85,12 @@ mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg } MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 2, storage_mount); -//| .. function:: umount(mount) +//| def umount(mount: Any) -> Any: +//| """Unmounts the given filesystem object or if *mount* is a path, then unmount +//| the filesystem mounted at that location. //| -//| Unmounts the given filesystem object or if *mount* is a path, then unmount -//| the filesystem mounted at that location. -//| -//| This is the CircuitPython analog to the UNIX ``umount`` command. +//| This is the CircuitPython analog to the UNIX ``umount`` command.""" +//| ... //| mp_obj_t storage_umount(mp_obj_t mnt_in) { if (MP_OBJ_IS_STR(mnt_in)) { @@ -103,15 +103,15 @@ mp_obj_t storage_umount(mp_obj_t mnt_in) { } MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount); -//| .. function:: remount(mount_path, readonly=False, *, disable_concurrent_write_protection=False) +//| def remount(mount_path: Any, readonly: bool = False, *, disable_concurrent_write_protection: bool = False) -> Any: +//| """Remounts the given path with new parameters. //| -//| Remounts the given path with new parameters. -//| -//| :param bool readonly: True when the filesystem should be readonly to CircuitPython. -//| :param bool disable_concurrent_write_protection: When True, the check that makes sure the -//| underlying filesystem data is written by one computer is disabled. Disabling the protection -//| allows CircuitPython and a host to write to the same filesystem with the risk that the -//| filesystem will be corrupted. +//| :param bool readonly: True when the filesystem should be readonly to CircuitPython. +//| :param bool disable_concurrent_write_protection: When True, the check that makes sure the +//| underlying filesystem data is written by one computer is disabled. Disabling the protection +//| allows CircuitPython and a host to write to the same filesystem with the risk that the +//| filesystem will be corrupted.""" +//| ... //| mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_readonly, ARG_disable_concurrent_write_protection }; @@ -133,28 +133,29 @@ mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a } MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 1, storage_remount); -//| .. function:: getmount(mount_path) -//| -//| Retrieves the mount object associated with the mount path +//| def getmount(mount_path: Any) -> Any: +//| """Retrieves the mount object associated with the mount path""" +//| ... //| mp_obj_t storage_getmount(const mp_obj_t mnt_in) { return common_hal_storage_getmount(mp_obj_str_get_str(mnt_in)); } MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount); -//| .. function:: erase_filesystem() +//| def erase_filesystem() -> Any: +//| """Erase and re-create the ``CIRCUITPY`` filesystem. //| -//| Erase and re-create the ``CIRCUITPY`` filesystem. +//| On boards that present USB-visible ``CIRCUITPY`` drive (e.g., SAMD21 and SAMD51), +//| then call `microcontroller.reset()` to restart CircuitPython and have the +//| host computer remount CIRCUITPY. //| -//| On boards that present USB-visible ``CIRCUITPY`` drive (e.g., SAMD21 and SAMD51), -//| then call `microcontroller.reset()` to restart CircuitPython and have the -//| host computer remount CIRCUITPY. +//| This function can be called from the REPL when ``CIRCUITPY`` +//| has become corrupted. //| -//| This function can be called from the REPL when ``CIRCUITPY`` -//| has become corrupted. +//| .. warning:: All the data on ``CIRCUITPY`` will be lost, and +//| CircuitPython will restart on certain boards.""" +//| ... //| -//| .. warning:: All the data on ``CIRCUITPY`` will be lost, and -//| CircuitPython will restart on certain boards. mp_obj_t storage_erase_filesystem(void) { common_hal_storage_erase_filesystem(); @@ -171,54 +172,53 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_getmount), MP_ROM_PTR(&storage_getmount_obj) }, { MP_ROM_QSTR(MP_QSTR_erase_filesystem), MP_ROM_PTR(&storage_erase_filesystem_obj) }, - //| .. class:: VfsFat(block_device) + //| class VfsFat: + //| def __init__(self, block_device: Any): ... + //| """Create a new VfsFat filesystem around the given block device. //| - //| Create a new VfsFat filesystem around the given block device. + //| :param block_device: Block device the the filesystem lives on""" //| - //| :param block_device: Block device the the filesystem lives on + //| label: Any = ... + //| """The filesystem label, up to 11 case-insensitive bytes. Note that + //| this property can only be set when the device is writable by the + //| microcontroller.""" //| - //| .. attribute:: label + //| def mkfs(self, ) -> Any: + //| """Format the block device, deleting any data that may have been there""" + //| ... //| - //| The filesystem label, up to 11 case-insensitive bytes. Note that - //| this property can only be set when the device is writable by the - //| microcontroller. + //| def open(self, path: Any, mode: Any) -> Any: + //| """Like builtin ``open()``""" + //| ... //| - //| .. method:: mkfs() + //| def ilistdir(self, path: Any) -> Any: + //| """Return an iterator whose values describe files and folders within + //| ``path``""" + //| ... //| - //| Format the block device, deleting any data that may have been there + //| def mkdir(self, path: Any) -> Any: + //| """Like `os.mkdir`""" + //| ... //| - //| .. method:: open(path, mode) + //| def rmdir(self, path: Any) -> Any: + //| """Like `os.rmdir`""" + //| ... //| - //| Like builtin ``open()`` + //| def stat(self, path: Any) -> Any: + //| """Like `os.stat`""" + //| ... //| - //| .. method:: ilistdir([path]) + //| def statvfs(self, path: Any) -> Any: + //| """Like `os.statvfs`""" + //| ... //| - //| Return an iterator whose values describe files and folders within - //| ``path`` + //| def mount(self, readonly: Any, mkfs: Any) -> Any: + //| """Don't call this directly, call `storage.mount`.""" + //| ... //| - //| .. method:: mkdir(path) - //| - //| Like `os.mkdir` - //| - //| .. method:: rmdir(path) - //| - //| Like `os.rmdir` - //| - //| .. method:: stat(path) - //| - //| Like `os.stat` - //| - //| .. method:: statvfs(path) - //| - //| Like `os.statvfs` - //| - //| .. method:: mount(readonly, mkfs) - //| - //| Don't call this directly, call `storage.mount`. - //| - //| .. method:: umount() - //| - //| Don't call this directly, call `storage.umount`. + //| def umount(self, ) -> Any: + //| """Don't call this directly, call `storage.umount`.""" + //| ... //| { MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) }, }; From 61450cbd5604a2e2c371bda4637f082151d3d8c8 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 11 May 2020 13:58:58 -0700 Subject: [PATCH 074/216] Add Teensy 4.1 board definition --- .github/workflows/build.yml | 1 + ports/mimxrt10xx/boards/teensy41/board.c | 39 ++++++ ports/mimxrt10xx/boards/teensy41/board.ld | 1 + .../mimxrt10xx/boards/teensy41/flash_config.c | 126 ++++++++++++++++++ .../boards/teensy41/mpconfigboard.h | 18 +++ .../boards/teensy41/mpconfigboard.mk | 8 ++ ports/mimxrt10xx/boards/teensy41/pins.c | 116 ++++++++++++++++ 7 files changed, 309 insertions(+) create mode 100644 ports/mimxrt10xx/boards/teensy41/board.c create mode 100644 ports/mimxrt10xx/boards/teensy41/board.ld create mode 100644 ports/mimxrt10xx/boards/teensy41/flash_config.c create mode 100644 ports/mimxrt10xx/boards/teensy41/mpconfigboard.h create mode 100644 ports/mimxrt10xx/boards/teensy41/mpconfigboard.mk create mode 100644 ports/mimxrt10xx/boards/teensy41/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2125a7c725..6cd6289b30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -249,6 +249,7 @@ jobs: - "stm32f746g_discovery" - "stringcar_m0_express" - "teensy40" + - "teensy41" - "teknikio_bluebird" - "thunderpack" - "trellis_m4_express" diff --git a/ports/mimxrt10xx/boards/teensy41/board.c b/ports/mimxrt10xx/boards/teensy41/board.c new file mode 100644 index 0000000000..52dd498b3f --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy41/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2019 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/mimxrt10xx/boards/teensy41/board.ld b/ports/mimxrt10xx/boards/teensy41/board.ld new file mode 100644 index 0000000000..8f19810a35 --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy41/board.ld @@ -0,0 +1 @@ +_ld_reserved_flash_size = 4K; diff --git a/ports/mimxrt10xx/boards/teensy41/flash_config.c b/ports/mimxrt10xx/boards/teensy41/flash_config.c new file mode 100644 index 0000000000..426deb884d --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy41/flash_config.c @@ -0,0 +1,126 @@ +/* + * Copyright 2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fsl_flexspi_nor_boot.h" +#include "fsl_flexspi_nor_config.h" + +/* Component ID definition, used by tools. */ +#ifndef FSL_COMPONENT_ID +#define FSL_COMPONENT_ID "platform.drivers.xip_device" +#endif + +__attribute__((section(".boot_hdr.ivt"))) +/************************************* + * IVT Data + *************************************/ +const ivt image_vector_table = { + IVT_HEADER, /* IVT Header */ + IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ + IVT_RSVD, /* Reserved = 0 */ + (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ + (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ + (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ + (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ + IVT_RSVD /* Reserved = 0 */ +}; + +__attribute__((section(".boot_hdr.boot_data"))) +/************************************* + * Boot Data + *************************************/ +const BOOT_DATA_T boot_data = { + FLASH_BASE, /* boot start location */ + FLASH_SIZE, /* size */ + PLUGIN_FLAG, /* Plugin flag*/ + 0xFFFFFFFF /* empty - extra data word */ +}; + +__attribute__((section(".boot_hdr.conf"))) +// Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 +const flexspi_nor_config_t qspiflash_config = { + .memConfig = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .csHoldTime = 1u, + .csSetupTime = 2u, + // Enable DDR mode, Wordaddressable, Safe configuration, Differential clock + .deviceType = kFlexSpiDeviceType_SerialNOR, + .sflashPadType = kSerialFlash_4Pads, + .serialClkFreq = kFlexSpiSerialClk_60MHz, // 03 + .sflashA1Size = FLASH_SIZE, + .lookupTable = + { + // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | + // FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) + // Read LUTs + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18), + FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04), + 0, + 0, + + 0x24040405, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000406, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x08180420, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x081804D8, + 0, + 0, + 0, + + 0x08180402, + 0x00002004, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000460, + }, + }, + .pageSize = 256u, + .sectorSize = 4u * 1024u, + .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .blockSize = 0x00010000, + .isUniformBlockSize = false, +}; diff --git a/ports/mimxrt10xx/boards/teensy41/mpconfigboard.h b/ports/mimxrt10xx/boards/teensy41/mpconfigboard.h new file mode 100644 index 0000000000..15b8c0f34a --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy41/mpconfigboard.h @@ -0,0 +1,18 @@ +#define MICROPY_HW_BOARD_NAME "Teensy 4.1" +#define MICROPY_HW_MCU_NAME "IMXRT1062DVJ6A" + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (8 * 1024 * 1024) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO_AD_B1_00) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO_AD_B1_01) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO_B0_03) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO_B0_02) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO_B0_01) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO_AD_B0_03) +#define DEFAULT_UART_BUS_TX (&pin_GPIO_AD_B0_02) diff --git a/ports/mimxrt10xx/boards/teensy41/mpconfigboard.mk b/ports/mimxrt10xx/boards/teensy41/mpconfigboard.mk new file mode 100644 index 0000000000..201e0e660f --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy41/mpconfigboard.mk @@ -0,0 +1,8 @@ +USB_VID = 0x239A +USB_PID = 0x80AE +USB_PRODUCT = "Teensy 4.1" +USB_MANUFACTURER = "PJRC" + +CHIP_VARIANT = MIMXRT1062DVJ6A +CHIP_FAMILY = MIMXRT1062 +FLASH = W25Q64JV diff --git a/ports/mimxrt10xx/boards/teensy41/pins.c b/ports/mimxrt10xx/boards/teensy41/pins.c new file mode 100644 index 0000000000..5eb5ab0f55 --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy41/pins.c @@ -0,0 +1,116 @@ +#include "shared-bindings/board/__init__.h" + +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + // With USB on left. Bottom edge. + { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO_AD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO_AD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_GPIO_AD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO_AD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO_AD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_GPIO_AD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO_EMC_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO_EMC_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO_EMC_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_EMC_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO_B0_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_B0_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO_B0_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO_B0_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO_B0_01) }, + + // Bottom Edge extended for 4.1 + { MP_OBJ_NEW_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO_AD_B0_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_GPIO_AD_B0_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO_AD_B0_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_GPIO_AD_B0_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO_AD_B1_14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_GPIO_AD_B1_14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A13), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D28), MP_ROM_PTR(&pin_GPIO_EMC_32) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D29), MP_ROM_PTR(&pin_GPIO_EMC_31) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D30), MP_ROM_PTR(&pin_GPIO_EMC_37) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D31), MP_ROM_PTR(&pin_GPIO_EMC_36) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D32), MP_ROM_PTR(&pin_GPIO_B0_12) }, + + // Top edge + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO_AD_B1_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO_AD_B1_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO_AD_B1_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO_AD_B1_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA0), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL0), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_GPIO_AD_B1_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO_AD_B1_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO_AD_B1_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO_AD_B1_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, + + // Top edge extended for Teensy 4.1 + { MP_OBJ_NEW_QSTR(MP_QSTR_D33), MP_ROM_PTR(&pin_GPIO_EMC_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO_B1_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO_B1_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO_B1_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO_B1_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO_AD_B1_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO_AD_B1_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D40), MP_ROM_PTR(&pin_GPIO_AD_B1_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO_AD_B1_05) }, + + // SD Card slot + { MP_OBJ_NEW_QSTR(MP_QSTR_DAT1), MP_ROM_PTR(&pin_GPIO_SD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D42), MP_ROM_PTR(&pin_GPIO_SD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_DAT0), MP_ROM_PTR(&pin_GPIO_SD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D43), MP_ROM_PTR(&pin_GPIO_SD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO_SD_B0_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D44), MP_ROM_PTR(&pin_GPIO_SD_B0_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CMD), MP_ROM_PTR(&pin_GPIO_SD_B0_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D45), MP_ROM_PTR(&pin_GPIO_SD_B0_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_DAT3), MP_ROM_PTR(&pin_GPIO_SD_B0_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D46), MP_ROM_PTR(&pin_GPIO_SD_B0_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_DAT2), MP_ROM_PTR(&pin_GPIO_SD_B0_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D47), MP_ROM_PTR(&pin_GPIO_SD_B0_04) }, + + // Flash expansion spot and PSRAM expansion spot on a shared QSPI BUS + { MP_OBJ_NEW_QSTR(MP_QSTR_D48), MP_ROM_PTR(&pin_GPIO_EMC_24) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_PSRAM_CS), MP_ROM_PTR(&pin_GPIO_EMC_24) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D49), MP_ROM_PTR(&pin_GPIO_EMC_27) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_QSPI_IO1), MP_ROM_PTR(&pin_GPIO_EMC_27) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D50), MP_ROM_PTR(&pin_GPIO_EMC_28) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_QSPI_IO2), MP_ROM_PTR(&pin_GPIO_EMC_28) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D51), MP_ROM_PTR(&pin_GPIO_EMC_22) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_CS), MP_ROM_PTR(&pin_GPIO_EMC_22) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D52), MP_ROM_PTR(&pin_GPIO_EMC_26) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_QSPI_IO0), MP_ROM_PTR(&pin_GPIO_EMC_26) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D53), MP_ROM_PTR(&pin_GPIO_EMC_25) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_QSPI_CLK), MP_ROM_PTR(&pin_GPIO_EMC_25) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D54), MP_ROM_PTR(&pin_GPIO_EMC_29) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_QSPI_IO3), MP_ROM_PTR(&pin_GPIO_EMC_29) }, + + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 94949fb46f88ab92de5a424287f90e03b2981817 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Mon, 11 May 2020 18:02:40 -0400 Subject: [PATCH 075/216] Add recovery domain write access, adjust stack --- ports/stm/boards/STM32F401xd_fs.ld | 2 +- ports/stm/boards/STM32F401xe_boot.ld | 2 +- ports/stm/boards/STM32F401xe_fs.ld | 2 +- ports/stm/boards/STM32F405_boot.ld | 2 +- ports/stm/boards/STM32F405_default.ld | 2 +- ports/stm/boards/STM32F405_fs.ld | 2 +- ports/stm/boards/STM32F407_fs.ld | 2 +- ports/stm/boards/STM32F411_fs.ld | 2 +- ports/stm/boards/STM32F411_nvm.ld | 2 +- ports/stm/boards/STM32F412_fs.ld | 2 +- ports/stm/boards/STM32F746xG_fs.ld | 2 +- ports/stm/boards/STM32F767_fs.ld | 2 +- ports/stm/boards/STM32H743_fs.ld | 2 +- ports/stm/supervisor/port.c | 50 ++++++++++++++++++++++----- 14 files changed, 54 insertions(+), 22 deletions(-) diff --git a/ports/stm/boards/STM32F401xd_fs.ld b/ports/stm/boards/STM32F401xd_fs.ld index 3086c2c6b0..69bae46cb6 100644 --- a/ports/stm/boards/STM32F401xd_fs.ld +++ b/ports/stm/boards/STM32F401xd_fs.ld @@ -13,7 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F401xe_boot.ld b/ports/stm/boards/STM32F401xe_boot.ld index 0409476949..37827c3301 100644 --- a/ports/stm/boards/STM32F401xe_boot.ld +++ b/ports/stm/boards/STM32F401xe_boot.ld @@ -12,7 +12,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F401xe_fs.ld b/ports/stm/boards/STM32F401xe_fs.ld index b55bc4bb4a..20247930c2 100644 --- a/ports/stm/boards/STM32F401xe_fs.ld +++ b/ports/stm/boards/STM32F401xe_fs.ld @@ -13,7 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F405_boot.ld b/ports/stm/boards/STM32F405_boot.ld index 906f56e0d2..5768d1a01e 100644 --- a/ports/stm/boards/STM32F405_boot.ld +++ b/ports/stm/boards/STM32F405_boot.ld @@ -13,7 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define the top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F405_default.ld b/ports/stm/boards/STM32F405_default.ld index 0aafdbcac5..4c11fd7cf3 100644 --- a/ports/stm/boards/STM32F405_default.ld +++ b/ports/stm/boards/STM32F405_default.ld @@ -13,7 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F405_fs.ld b/ports/stm/boards/STM32F405_fs.ld index bff312660e..e6c66127fb 100644 --- a/ports/stm/boards/STM32F405_fs.ld +++ b/ports/stm/boards/STM32F405_fs.ld @@ -14,7 +14,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F407_fs.ld b/ports/stm/boards/STM32F407_fs.ld index 5330b4116f..f06c19d992 100644 --- a/ports/stm/boards/STM32F407_fs.ld +++ b/ports/stm/boards/STM32F407_fs.ld @@ -14,7 +14,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F411_fs.ld b/ports/stm/boards/STM32F411_fs.ld index 82c7aea065..1b45f235fa 100644 --- a/ports/stm/boards/STM32F411_fs.ld +++ b/ports/stm/boards/STM32F411_fs.ld @@ -13,7 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F411_nvm.ld b/ports/stm/boards/STM32F411_nvm.ld index 897b996313..5ac3e52a6e 100644 --- a/ports/stm/boards/STM32F411_nvm.ld +++ b/ports/stm/boards/STM32F411_nvm.ld @@ -14,7 +14,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define the top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F412_fs.ld b/ports/stm/boards/STM32F412_fs.ld index afd51c6b19..8837bd87d6 100644 --- a/ports/stm/boards/STM32F412_fs.ld +++ b/ports/stm/boards/STM32F412_fs.ld @@ -13,7 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F746xG_fs.ld b/ports/stm/boards/STM32F746xG_fs.ld index f1bd3d5dc0..be10a14294 100644 --- a/ports/stm/boards/STM32F746xG_fs.ld +++ b/ports/stm/boards/STM32F746xG_fs.ld @@ -38,7 +38,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32F767_fs.ld b/ports/stm/boards/STM32F767_fs.ld index 40e67829bf..25322b0b6f 100644 --- a/ports/stm/boards/STM32F767_fs.ld +++ b/ports/stm/boards/STM32F767_fs.ld @@ -13,7 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; _minimum_heap_size = 16K; /* Define tho top end of the stack. The stack is full descending so begins just diff --git a/ports/stm/boards/STM32H743_fs.ld b/ports/stm/boards/STM32H743_fs.ld index 686f93ea36..b6c3d5b62d 100644 --- a/ports/stm/boards/STM32H743_fs.ld +++ b/ports/stm/boards/STM32H743_fs.ld @@ -22,7 +22,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_minimum_stack_size = 24K; /*TODO: this can probably be bigger, but how big?*/ _minimum_heap_size = 16K; /* brainless copy paste for stack code. Results in ambiguous hard crash */ diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c index 328a8d660c..23ba7d8745 100644 --- a/ports/stm/supervisor/port.c +++ b/ports/stm/supervisor/port.c @@ -49,7 +49,7 @@ #include STM32_HAL_H //only enable the Reset Handler overwrite for the H7 for now -#if defined(STM32H7) +#if (CPY_STM32H7) // Device memories must be accessed in order. #define DEVICE 2 @@ -162,7 +162,7 @@ safe_mode_t port_init(void) { HAL_Init(); __HAL_RCC_SYSCFG_CLK_ENABLE(); - #if defined(STM32F4) + #if (CPY_STM32F4) __HAL_RCC_PWR_CLK_ENABLE(); #endif @@ -170,31 +170,63 @@ safe_mode_t port_init(void) { stm32_peripherals_gpio_init(); HAL_PWR_EnableBkUpAccess(); + + // TODO: move all of this to clocks.c #if BOARD_HAS_LOW_SPEED_CRYSTAL - __HAL_RCC_LSE_CONFIG(RCC_LSE_ON); + uint32_t tickstart = HAL_GetTick(); + + // H7/F7 untested with LSE, so autofail them until above move is done + #if (CPY_STM32F4) bool lse_setupsuccess = true; - uint32_t i = 0; + #else + bool lse_setupsuccess = false; + #endif + + // Update LSE configuration in Backup Domain control register + // Requires to enable write access to Backup Domain of necessary + // TODO: should be using the HAL OSC initializer, otherwise we'll need + // preprocessor defines for every register to account for F7/H7 + #if (CPY_STM32F4) + if(HAL_IS_BIT_CLR(PWR->CR, PWR_CR_DBP)) + { + // Enable write access to Backup domain + SET_BIT(PWR->CR, PWR_CR_DBP); + // Wait for Backup domain Write protection disable + tickstart = HAL_GetTick(); + while(HAL_IS_BIT_CLR(PWR->CR, PWR_CR_DBP)) + { + if((HAL_GetTick() - tickstart) > RCC_DBP_TIMEOUT_VALUE) + { + lse_setupsuccess = false; + } + } + } + #endif + + __HAL_RCC_LSE_CONFIG(RCC_LSE_ON); + tickstart = HAL_GetTick(); while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) { - if ( ++i > 1000000 ) + if((HAL_GetTick() - tickstart ) > LSE_STARTUP_TIMEOUT) { lse_setupsuccess = false; __HAL_RCC_LSE_CONFIG(RCC_LSE_OFF); __HAL_RCC_LSI_ENABLE(); rtc_clock_frequency = LSI_VALUE; + break; } } - #else - __HAL_RCC_LSI_ENABLE(); - #endif - #if BOARD_HAS_LOW_SPEED_CRYSTAL + if (lse_setupsuccess) { __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE); } else { __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI); } + #else + __HAL_RCC_LSI_ENABLE(); __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI); #endif + __HAL_RCC_RTC_ENABLE(); _hrtc.Instance = RTC; _hrtc.Init.HourFormat = RTC_HOURFORMAT_24; From 235098efb84d9b64537884910cf080640d8ce28d Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Wed, 6 May 2020 12:03:18 +0800 Subject: [PATCH 076/216] nrf: simmel: correct CSn pin The CSn pin is pin 6 on bank 1, not bank 0. Signed-off-by: Sean Cross --- ports/nrf/boards/simmel/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/boards/simmel/pins.c b/ports/nrf/boards/simmel/pins.c index c946493d47..6c572cae21 100644 --- a/ports/nrf/boards/simmel/pins.c +++ b/ports/nrf/boards/simmel/pins.c @@ -1,7 +1,7 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_SPI_CSN), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_SPI_CSN), MP_ROM_PTR(&pin_P1_06) }, { MP_ROM_QSTR(MP_QSTR_SPI_MISO), MP_ROM_PTR(&pin_P1_04) }, { MP_ROM_QSTR(MP_QSTR_SPI_MOSI), MP_ROM_PTR(&pin_P0_09) }, { MP_ROM_QSTR(MP_QSTR_SPI_SCK), MP_ROM_PTR(&pin_P0_10) }, From 79c055f958dc5d85942cadf21b384b4654e92bba Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 7 May 2020 11:28:50 +0800 Subject: [PATCH 077/216] nrf: simmel: enable aesio This adds AES support to simmel. Signed-off-by: Sean Cross --- ports/nrf/boards/simmel/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index e71ada1de6..83fda6bda1 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -11,6 +11,7 @@ MCU_CHIP = nrf52833 INTERNAL_FLASH_FILESYSTEM = 1 +CIRCUITPY_AESIO = 1 CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BUSIO = 1 CIRCUITPY_DISPLAYIO = 0 From 370fc7293a9ebe8015b70b9579f15386e59cbfea Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 7 May 2020 17:00:51 +0800 Subject: [PATCH 078/216] nrf: support disabling SPIM3 SPIM3 is faster than all other SPI blocks, and is capable of generating a 32 MHz clock. However, it cannot be used at the same time as the BLE radio without dedicating an additional 8 kB of RAM to it. Therefore, some boards may want to disable this. Support pre-defining NRFX_SPIM3_ENABLED on the command line to disable it on some bords. Signed-off-by: Sean Cross --- ports/nrf/nrfx_config.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h index 05ec95ae38..7a7f2e6d64 100644 --- a/ports/nrf/nrfx_config.h +++ b/ports/nrf/nrfx_config.h @@ -41,12 +41,14 @@ #define NRFX_SPIM1_ENABLED 1 #endif #define NRFX_SPIM2_ENABLED 1 +#ifndef NRFX_SPIM3_ENABLED #if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) #define NRFX_SPIM_EXTENDED_ENABLED 1 #define NRFX_SPIM3_ENABLED 1 #elif CIRCUITPY_NRF_NUM_I2C == 2 #define NRFX_SPIM3_ENABLED 0 #endif +#endif #define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 7 From f7fcd43516f8aa51184ae45fe16d5b56af92f2d9 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 7 May 2020 17:02:40 +0800 Subject: [PATCH 079/216] nrf: simmel: disable SPIM3 Disable the SPIM3 controller to avoid needing to dedicate 8 kB to the SPIM3 block. Signed-off-by: Sean Cross --- ports/nrf/boards/simmel/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index 83fda6bda1..36a6fadda2 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -30,4 +30,4 @@ CIRCUITPY_ULAB = 0 # These defines must be overridden before mpconfigboard.h is included, which is # why they are passed on the command line. -CFLAGS += -DSPIM3_BUFFER_SIZE=0 -DSOFTDEVICE_RAM_SIZE='(32*1024)' +CFLAGS += -DSPIM3_BUFFER_SIZE=0 -DSOFTDEVICE_RAM_SIZE='(32*1024)' -DNRFX_SPIM3_ENABLED=0 From ffaeeda749e8cd6d284d256f7676378ce9425b13 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Tue, 12 May 2020 09:29:23 +0800 Subject: [PATCH 080/216] nrf: simmel: decrease flash filesystem size The flash filesystem must be reduced in order to allow the current build to fit. Signed-off-by: Sean Cross --- ports/nrf/boards/simmel/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/boards/simmel/mpconfigboard.h b/ports/nrf/boards/simmel/mpconfigboard.h index 4c73e86eb2..bcffb40ea5 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.h +++ b/ports/nrf/boards/simmel/mpconfigboard.h @@ -40,7 +40,7 @@ #endif #define CIRCUITPY_INTERNAL_NVM_SIZE 0 -#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (84*1024) +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (80*1024) #define BOOTLOADER_SIZE (0x4000) // 12 kiB #define CIRCUITPY_BLE_CONFIG_SIZE (12*1024) From cfd0de9c11629216f743a9edcadf93ad9e48fa1e Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Mon, 11 May 2020 21:08:58 -0700 Subject: [PATCH 081/216] set vectorio to FULL_BUILD and see what works --- py/circuitpy_mpconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index e9e3d80138..687ef72635 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -94,7 +94,7 @@ CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO) CIRCUITPY_FRAMEBUFFERIO ?= 0 CFLAGS += -DCIRCUITPY_FRAMEBUFFERIO=$(CIRCUITPY_FRAMEBUFFERIO) -CIRCUITPY_VECTORIO ?= 0 +CIRCUITPY_VECTORIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_VECTORIO=$(CIRCUITPY_VECTORIO) CIRCUITPY_FREQUENCYIO ?= $(CIRCUITPY_FULL_BUILD) From 040beb0577f4360f34953db16c285a9af1bea6b8 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Mon, 11 May 2020 21:15:40 -0700 Subject: [PATCH 082/216] Clean up circle documentation --- shared-bindings/vectorio/Circle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 8f409bd654..260e80d0fb 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -17,6 +17,8 @@ //| //| .. class:: Circle(radius) //| +//| Circle is positioned on screen by its center point. +//| //| :param int radius: The radius of the circle in pixels //| static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -42,7 +44,7 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg //| .. attribute:: radius //| -//| Update the radius of the circle +//| The radius of the circle in pixels. //| STATIC mp_obj_t vectorio_circle_obj_get_radius(mp_obj_t self_in) { vectorio_circle_t *self = MP_OBJ_TO_PTR(self_in); From 78444a1018f5a9dbac6e2fac1b7385970accedbc Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Mon, 11 May 2020 21:21:05 -0700 Subject: [PATCH 083/216] fix VectorShape on_dirty callback registration being set for the wrong type --- shared-bindings/vectorio/VectorShape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index 02a42536d7..4b39ec9960 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -85,8 +85,8 @@ STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t if (MP_OBJ_IS_TYPE(shape, &vectorio_polygon_type)) { common_hal_vectorio_polygon_set_on_dirty(self->ishape.shape, on_dirty); } else if (MP_OBJ_IS_TYPE(shape, &vectorio_rectangle_type)) { - common_hal_vectorio_circle_set_on_dirty(self->ishape.shape, on_dirty); } else if (MP_OBJ_IS_TYPE(shape, &vectorio_circle_type)) { + common_hal_vectorio_circle_set_on_dirty(self->ishape.shape, on_dirty); } else { mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_shape); } From 22bf99ccc438e499378af099a446d1c6d9b542ac Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Tue, 12 May 2020 14:52:48 +1000 Subject: [PATCH 084/216] Fixed underline in documentation --- shared-bindings/countio/Counter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index 1777acc8a2..d9d97f0ead 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -12,13 +12,13 @@ //| .. currentmodule:: countio //| //| :class:`Counter` -- Track the count of falling edge transistions (pulses) on a given pin -//| ==================================================================================== +//| ======================================================================================== //| //| Counter will keep track of the number of falling edge transistions (pulses) on a given pin //| //| .. class:: Counter(pin_a) //| -//| Create an Counter object associated with the given pin. It tracks the number of +//| Create a Counter object associated with the given pin. It tracks the number of //| falling pulses relative when the object is constructed. //| //| :param ~microcontroller.Pin pin_a: Pin to read pulses from. From 5e5461e77eec52dd866b0fe840dd946948ca3dc2 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Tue, 12 May 2020 16:32:35 +1000 Subject: [PATCH 085/216] removed countio from catwan_usbstick build --- ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk index 8724e0d4bb..61869e6b2d 100644 --- a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk +++ b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk @@ -9,3 +9,4 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 +CIRCUITPY_COUNTIO = 0 From c00f81c0a3e94cebfead9a1868b84282b53c7e57 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Tue, 12 May 2020 16:33:09 +1000 Subject: [PATCH 086/216] changed branch on protomatter --- lib/protomatter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/protomatter b/lib/protomatter index c411714cbd..9f71088d2c 160000 --- a/lib/protomatter +++ b/lib/protomatter @@ -1 +1 @@ -Subproject commit c411714cbdc05725e80398acb18c3c1fb6fa68a4 +Subproject commit 9f71088d2c32206c6f0495704ae0c040426d5764 From 62bdfb74e3c13ab65f598fc57b646ec2ca3df495 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Tue, 12 May 2020 16:40:23 +1000 Subject: [PATCH 087/216] removed lib from catwan_usbstick - updated transalations overflowed --- ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk index 61869e6b2d..892a5371ef 100644 --- a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk +++ b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk @@ -10,3 +10,4 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 CIRCUITPY_COUNTIO = 0 +CIRCUITPY_ROTARYIO = 0 From 991045b9ce958db9d7102d621f4e7860301e4c21 Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 12 May 2020 11:28:33 -0400 Subject: [PATCH 088/216] Did struct, supervisor, terminalio --- shared-bindings/struct/__init__.c | 48 +++++++++++++-------------- shared-bindings/supervisor/Runtime.c | 41 +++++++++++------------ shared-bindings/supervisor/__init__.c | 47 +++++++++++++------------- shared-bindings/terminalio/Terminal.c | 26 +++++++-------- shared-bindings/terminalio/__init__.c | 4 +-- 5 files changed, 82 insertions(+), 84 deletions(-) diff --git a/shared-bindings/struct/__init__.c b/shared-bindings/struct/__init__.c index ea14b37637..3772f93a76 100644 --- a/shared-bindings/struct/__init__.c +++ b/shared-bindings/struct/__init__.c @@ -38,7 +38,7 @@ #include "shared-module/struct/__init__.h" #include "supervisor/shared/translate.h" -//| :mod:`struct` --- manipulation of c-style data +//| """:mod:`struct` --- manipulation of c-style data //| ======================================================== //| //| .. module:: struct @@ -52,13 +52,13 @@ //| Supported size/byte order prefixes: *@*, *<*, *>*, *!*. //| //| Supported format codes: *b*, *B*, *x*, *h*, *H*, *i*, *I*, *l*, *L*, *q*, *Q*, -//| *s*, *P*, *f*, *d* (the latter 2 depending on the floating-point support). +//| *s*, *P*, *f*, *d* (the latter 2 depending on the floating-point support).""" //| -//| .. function:: calcsize(fmt) -//| -//| Return the number of bytes needed to store the given fmt. +//| def calcsize(fmt: Any) -> Any: +//| """Return the number of bytes needed to store the given fmt.""" +//| ... //| STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) { @@ -67,10 +67,10 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) { } MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize); -//| .. function:: pack(fmt, *values) -//| -//| Pack the values according to the format string fmt. -//| The return value is a bytes object encoding the values. +//| def pack(fmt: Any, *values: Any) -> Any: +//| """Pack the values according to the format string fmt. +//| The return value is a bytes object encoding the values.""" +//| ... //| STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) { @@ -85,10 +85,10 @@ STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) { } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack); -//| .. function:: pack_into(fmt, buffer, offset, *values) -//| -//| Pack the values according to the format string fmt into a buffer -//| starting at offset. offset may be negative to count from the end of buffer. +//| def pack_into(fmt: Any, buffer: Any, offset: Any, *values: Any) -> Any: +//| """Pack the values according to the format string fmt into a buffer +//| starting at offset. offset may be negative to count from the end of buffer.""" +//| ... //| STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { @@ -111,11 +111,11 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into); -//| .. function:: unpack(fmt, data) -//| -//| Unpack from the data according to the format string fmt. The return value -//| is a tuple of the unpacked values. The buffer size must match the size -//| required by the format. +//| def unpack(fmt: Any, data: Any) -> Any: +//| """Unpack from the data according to the format string fmt. The return value +//| is a tuple of the unpacked values. The buffer size must match the size +//| required by the format.""" +//| ... //| STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) { @@ -129,12 +129,12 @@ STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) { } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_obj, 2, 3, struct_unpack); -//| .. function:: unpack_from(fmt, data, offset=0) -//| -//| Unpack from the data starting at offset according to the format string fmt. -//| offset may be negative to count from the end of buffer. The return value is -//| a tuple of the unpacked values. The buffer size must be at least as big -//| as the size required by the form. +//| def unpack_from(fmt: Any, data: Any, offset: Any = 0) -> Any: +//| """Unpack from the data starting at offset according to the format string fmt. +//| offset may be negative to count from the end of buffer. The return value is +//| a tuple of the unpacked values. The buffer size must be at least as big +//| as the size required by the form.""" +//| ... //| STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 746dfe5ee7..05921899ce 100755 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -29,35 +29,35 @@ #include "shared-bindings/supervisor/Runtime.h" //TODO: add USB, REPL to description once they're operational -//| .. currentmodule:: supervisor +//| class Runtime: +//| """.. currentmodule:: supervisor //| -//| :class:`Runtime` --- Supervisor Runtime information -//| ---------------------------------------------------- +//| :class:`Runtime` --- Supervisor Runtime information +//| ---------------------------------------------------- //| -//| Get current status of runtime objects. +//| Get current status of runtime objects. //| -//| Usage:: +//| Usage:: //| -//| import supervisor -//| if supervisor.runtime.serial_connected: -//| print("Hello World!") +//| import supervisor +//| if supervisor.runtime.serial_connected: +//| print("Hello World!")""" //| -//| .. class:: Runtime() -//| -//| You cannot create an instance of `supervisor.Runtime`. -//| Use `supervisor.runtime` to access the sole instance available. +//| def __init__(self, ): +//| """You cannot create an instance of `supervisor.Runtime`. +//| Use `supervisor.runtime` to access the sole instance available.""" +//| ... //| -//| .. attribute:: runtime.serial_connected -//| -//| Returns the USB serial communication status (read-only). +//| runtime.serial_connected: Any = ... +//| """Returns the USB serial communication status (read-only). //| //| .. note:: //| //| SAMD: Will return ``True`` if the USB serial connection //| has been established at any point. Will not reset if -//| USB is disconnected but power remains (e.g. battery connected) +//| USB is disconnected but power remains (e.g. battery connected)""" //| STATIC mp_obj_t supervisor_get_serial_connected(mp_obj_t self){ @@ -78,11 +78,10 @@ const mp_obj_property_t supervisor_serial_connected_obj = { }; -//| .. attribute:: runtime.serial_bytes_available -//| -//| Returns the whether any bytes are available to read -//| on the USB serial input. Allows for polling to see whether -//| to call the built-in input() or wait. (read-only) +//| runtime.serial_bytes_available: Any = ... +//| """Returns the whether any bytes are available to read +//| on the USB serial input. Allows for polling to see whether +//| to call the built-in input() or wait. (read-only)""" //| STATIC mp_obj_t supervisor_get_serial_bytes_available(mp_obj_t self){ if (!common_hal_get_serial_bytes_available()) { diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 2705c8e581..7fe6668f48 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -36,7 +36,7 @@ #include "shared-bindings/supervisor/__init__.h" #include "shared-bindings/supervisor/Runtime.h" -//| :mod:`supervisor` --- Supervisor settings +//| """:mod:`supervisor` --- Supervisor settings //| ================================================= //| //| .. module:: supervisor @@ -50,19 +50,18 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| Runtime +//| Runtime""" //| -//| .. attribute:: runtime -//| -//| Runtime information, such as `runtime.serial_connected` -//| (USB serial connection status). -//| This object is the sole instance of `supervisor.Runtime`. +//| runtime: Any = ... +//| """Runtime information, such as `runtime.serial_connected` +//| (USB serial connection status). +//| This object is the sole instance of `supervisor.Runtime`.""" //| -//| .. method:: enable_autoreload() -//| -//| Enable autoreload based on USB file write activity. +//| def enable_autoreload(self, ) -> Any: +//| """Enable autoreload based on USB file write activity.""" +//| ... //| STATIC mp_obj_t supervisor_enable_autoreload(void) { autoreload_enable(); @@ -70,10 +69,10 @@ STATIC mp_obj_t supervisor_enable_autoreload(void) { } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_enable_autoreload_obj, supervisor_enable_autoreload); -//| .. method:: disable_autoreload() -//| -//| Disable autoreload based on USB file write activity until -//| `enable_autoreload` is called. +//| def disable_autoreload(self, ) -> Any: +//| """Disable autoreload based on USB file write activity until +//| `enable_autoreload` is called.""" +//| ... //| STATIC mp_obj_t supervisor_disable_autoreload(void) { autoreload_disable(); @@ -81,10 +80,10 @@ STATIC mp_obj_t supervisor_disable_autoreload(void) { } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_autoreload_obj, supervisor_disable_autoreload); -//| .. method:: set_rgb_status_brightness() -//| -//| Set brightness of status neopixel from 0-255 -//| `set_rgb_status_brightness` is called. +//| def set_rgb_status_brightness(self, ) -> Any: +//| """Set brightness of status neopixel from 0-255 +//| `set_rgb_status_brightness` is called.""" +//| ... //| STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){ // This must be int. If cast to uint8_t first, will never raise a ValueError. @@ -97,9 +96,9 @@ STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){ } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_set_rgb_status_brightness); -//| .. method:: reload() -//| -//| Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL). +//| def reload(self, ) -> Any: +//| """Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL).""" +//| ... //| STATIC mp_obj_t supervisor_reload(void) { reload_requested = true; @@ -108,9 +107,9 @@ STATIC mp_obj_t supervisor_reload(void) { } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload); -//| .. method:: set_next_stack_limit(size) -//| -//| Set the size of the stack for the next vm run. If its too large, the default will be used. +//| def set_next_stack_limit(self, size: Any) -> Any: +//| """Set the size of the stack for the next vm run. If its too large, the default will be used.""" +//| ... //| STATIC mp_obj_t supervisor_set_next_stack_limit(mp_obj_t size_obj) { mp_int_t size = mp_obj_get_int(size_obj); diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index 9c01fba20b..1288b70182 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -37,16 +37,16 @@ #include "shared-bindings/fontio/BuiltinFont.h" #include "supervisor/shared/translate.h" - -//| .. currentmodule:: terminalio +//| class Terminal: +//| """.. currentmodule:: terminalio //| -//| :class:`Terminal` -- display a character stream with a TileGrid -//| ================================================================ +//| :class:`Terminal` -- display a character stream with a TileGrid +//| ================================================================""" //| -//| .. class:: Terminal(tilegrid, font) -//| -//| Terminal manages tile indices and cursor position based on VT100 commands. The font should be -//| a `fontio.BuiltinFont` and the TileGrid's bitmap should match the font's bitmap. +//| def __init__(self, tilegrid: Any, font: Any): +//| """Terminal manages tile indices and cursor position based on VT100 commands. The font should be +//| a `fontio.BuiltinFont` and the TileGrid's bitmap should match the font's bitmap.""" +//| ... //| STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -75,12 +75,12 @@ STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n // These are standard stream methods. Code is in py/stream.c. // -//| .. method:: write(buf) +//| def write(self, buf: Any) -> Any: +//| """Write the buffer of bytes to the bus. //| -//| Write the buffer of bytes to the bus. -//| -//| :return: the number of bytes written -//| :rtype: int or None +//| :return: the number of bytes written +//| :rtype: int or None""" +//| ... //| STATIC mp_uint_t terminalio_terminal_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) { terminalio_terminal_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/terminalio/__init__.c b/shared-bindings/terminalio/__init__.c index a9fe20f30b..591be839ad 100644 --- a/shared-bindings/terminalio/__init__.c +++ b/shared-bindings/terminalio/__init__.c @@ -35,7 +35,7 @@ #include "py/runtime.h" -//| :mod:`terminalio` --- Displays text in a TileGrid +//| """:mod:`terminalio` --- Displays text in a TileGrid //| ================================================= //| //| .. module:: terminalio @@ -49,7 +49,7 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| Terminal +//| Terminal""" //| //| STATIC const mp_rom_map_elem_t terminalio_module_globals_table[] = { From e4589543fbe8df12f5c30101e94ddc0fa95cd29e Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 12 May 2020 11:43:24 -0400 Subject: [PATCH 089/216] Did time, touchio, uheap --- shared-bindings/time/__init__.c | 103 +++++++++++++++-------------- shared-bindings/touchio/TouchIn.c | 68 +++++++++---------- shared-bindings/touchio/__init__.c | 4 +- shared-bindings/uheap/__init__.c | 12 ++-- 4 files changed, 93 insertions(+), 94 deletions(-) diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 8d7f2f3fd2..36eaa27f63 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -36,7 +36,7 @@ #include "shared-bindings/time/__init__.h" #include "supervisor/shared/translate.h" -//| :mod:`time` --- time and timing related functions +//| """:mod:`time` --- time and timing related functions //| ======================================================== //| //| .. module:: time @@ -45,15 +45,15 @@ //| //| The `time` module is a strict subset of the CPython `cpython:time` module. So, code //| written in MicroPython will work in CPython but not necessarily the other -//| way around. +//| way around.""" //| -//| .. function:: monotonic() +//| def monotonic() -> Any: +//| """Returns an always increasing value of time with an unknown reference +//| point. Only use it to compare against other values from `monotonic`. //| -//| Returns an always increasing value of time with an unknown reference -//| point. Only use it to compare against other values from `monotonic`. -//| -//| :return: the current monotonic time -//| :rtype: float +//| :return: the current monotonic time +//| :rtype: float""" +//| ... //| STATIC mp_obj_t time_monotonic(void) { uint64_t time64 = common_hal_time_monotonic(); @@ -62,11 +62,11 @@ STATIC mp_obj_t time_monotonic(void) { } MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_obj, time_monotonic); -//| .. function:: sleep(seconds) +//| def sleep(seconds: float) -> Any: +//| """Sleep for a given number of seconds. //| -//| Sleep for a given number of seconds. -//| -//| :param float seconds: the time to sleep in fractional seconds +//| :param float seconds: the time to sleep in fractional seconds""" +//| ... //| STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { #if MICROPY_PY_BUILTINS_FLOAT @@ -97,21 +97,22 @@ mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp return namedtuple_make_new(type, 9, tuple->items, NULL); } -//| .. class:: struct_time(time_tuple) +//| class struct_time: +//| def __init__(self, time_tuple: Any): +//| """Structure used to capture a date and time. Note that it takes a tuple! //| -//| Structure used to capture a date and time. Note that it takes a tuple! +//| :param tuple time_tuple: Tuple of time info: ``(tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst)`` //| -//| :param tuple time_tuple: Tuple of time info: ``(tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst)`` -//| -//| * ``tm_year``: the year, 2017 for example -//| * ``tm_month``: the month, range [1, 12] -//| * ``tm_mday``: the day of the month, range [1, 31] -//| * ``tm_hour``: the hour, range [0, 23] -//| * ``tm_minute``: the minute, range [0, 59] -//| * ``tm_sec``: the second, range [0, 61] -//| * ``tm_wday``: the day of the week, range [0, 6], Monday is 0 -//| * ``tm_yday``: the day of the year, range [1, 366], -1 indicates not known -//| * ``tm_isdst``: 1 when in daylight savings, 0 when not, -1 if unknown. +//| * ``tm_year``: the year, 2017 for example +//| * ``tm_month``: the month, range [1, 12] +//| * ``tm_mday``: the day of the month, range [1, 31] +//| * ``tm_hour``: the hour, range [0, 23] +//| * ``tm_minute``: the minute, range [0, 59] +//| * ``tm_sec``: the second, range [0, 61] +//| * ``tm_wday``: the day of the week, range [0, 6], Monday is 0 +//| * ``tm_yday``: the day of the year, range [1, 366], -1 indicates not known +//| * ``tm_isdst``: 1 when in daylight savings, 0 when not, -1 if unknown.""" +//| ... //| const mp_obj_namedtuple_type_t struct_time_type_obj = { .base = { @@ -194,12 +195,12 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { mp_raise_RuntimeError(translate("RTC is not supported on this board")); } -//| .. function:: time() +//| def time() -> Any: +//| """Return the current time in seconds since since Jan 1, 1970. //| -//| Return the current time in seconds since since Jan 1, 1970. -//| -//| :return: the current time -//| :rtype: int +//| :return: the current time +//| :rtype: int""" +//| ... //| STATIC mp_obj_t time_time(void) { timeutils_struct_time_t tm; @@ -210,12 +211,12 @@ STATIC mp_obj_t time_time(void) { } MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); -//| .. function:: monotonic_ns() +//| def monotonic_ns() -> Any: +//| """Return the time of the specified clock clk_id in nanoseconds. //| -//| Return the time of the specified clock clk_id in nanoseconds. -//| -//| :return: the current time -//| :rtype: int +//| :return: the current time +//| :rtype: int""" +//| ... //| STATIC mp_obj_t time_monotonic_ns(void) { uint64_t time64 = common_hal_time_monotonic_ns(); @@ -223,15 +224,15 @@ STATIC mp_obj_t time_monotonic_ns(void) { } MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_ns_obj, time_monotonic_ns); -//| .. function:: localtime([secs]) +//| def localtime(secs: Any) -> Any: +//| """Convert a time expressed in seconds since Jan 1, 1970 to a struct_time in +//| local time. If secs is not provided or None, the current time as returned +//| by time() is used. +//| The earliest date for which it can generate a time is Jan 1, 2000. //| -//| Convert a time expressed in seconds since Jan 1, 1970 to a struct_time in -//| local time. If secs is not provided or None, the current time as returned -//| by time() is used. -//| The earliest date for which it can generate a time is Jan 1, 2000. -//| -//| :return: the current time -//| :rtype: time.struct_time +//| :return: the current time +//| :rtype: time.struct_time""" +//| ... //| STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) { if (n_args == 0 || args[0] == mp_const_none) { @@ -256,15 +257,15 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) { } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime); -//| .. function:: mktime(t) +//| def mktime(t: Any) -> Any: +//| """This is the inverse function of localtime(). Its argument is the +//| struct_time or full 9-tuple (since the dst flag is needed; use -1 as the +//| dst flag if it is unknown) which expresses the time in local time, not UTC. +//| The earliest date for which it can generate a time is Jan 1, 2000. //| -//| This is the inverse function of localtime(). Its argument is the -//| struct_time or full 9-tuple (since the dst flag is needed; use -1 as the -//| dst flag if it is unknown) which expresses the time in local time, not UTC. -//| The earliest date for which it can generate a time is Jan 1, 2000. -//| -//| :return: seconds -//| :rtype: int +//| :return: seconds +//| :rtype: int""" +//| ... //| STATIC mp_obj_t time_mktime(mp_obj_t t) { mp_obj_t *elem; diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index db53ec1bc8..6d59a17446 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -38,27 +38,28 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: touchio +//| class TouchIn: +//| """.. currentmodule:: touchio //| -//| :class:`TouchIn` -- Read the state of a capacitive touch sensor -//| =================================================================== +//| :class:`TouchIn` -- Read the state of a capacitive touch sensor +//| =================================================================== //| -//| Usage:: +//| Usage:: //| -//| import touchio -//| from board import * +//| import touchio +//| from board import * //| -//| touch = touchio.TouchIn(A1) -//| while True: -//| if touch.value: -//| print("touched!") +//| touch = touchio.TouchIn(A1) +//| while True: +//| if touch.value: +//| print("touched!")""" //| -//| .. class:: TouchIn(pin) +//| def __init__(self, pin: microcontroller.Pin): +//| """Use the TouchIn on the given pin. //| -//| Use the TouchIn on the given pin. -//| -//| :param ~microcontroller.Pin pin: the pin to read from +//| :param ~microcontroller.Pin pin: the pin to read from""" +//| ... //| STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { @@ -75,9 +76,9 @@ STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type, return (mp_obj_t) self; } -//| .. method:: deinit() -//| -//| Deinitialises the TouchIn and releases any hardware resources for reuse. +//| def deinit(self, ) -> Any: +//| """Deinitialises the TouchIn and releases any hardware resources for reuse.""" +//| ... //| STATIC mp_obj_t touchio_touchin_deinit(mp_obj_t self_in) { touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -92,16 +93,16 @@ STATIC void check_for_deinit(touchio_touchin_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self, ) -> Any: +//| """No-op used by Context Managers.""" +//| ... //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self, ) -> Any: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... //| STATIC mp_obj_t touchio_touchin_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -110,11 +111,10 @@ STATIC mp_obj_t touchio_touchin_obj___exit__(size_t n_args, const mp_obj_t *args } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(touchio_touchin___exit___obj, 4, 4, touchio_touchin_obj___exit__); -//| .. attribute:: value +//| value: Any = ... +//| """Whether the touch pad is being touched or not. (read-only) //| -//| Whether the touch pad is being touched or not. (read-only) -//| -//| True when `raw_value` > `threshold`. +//| True when `raw_value` > `threshold`.""" //| 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); @@ -131,9 +131,8 @@ const mp_obj_property_t touchio_touchin_value_obj = { }; -//| .. attribute:: raw_value -//| -//| The raw touch measurement as an `int`. (read-only) +//| raw_value: Any = ... +//| """The raw touch measurement as an `int`. (read-only)""" //| 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); @@ -151,14 +150,13 @@ const mp_obj_property_t touchio_touchin_raw_value_obj = { }; -//| .. attribute:: threshold -//| -//| Minimum `raw_value` needed to detect a touch (and for `value` to be `True`). +//| threshold: Any = ... +//| """Minimum `raw_value` needed to detect a touch (and for `value` to be `True`). //| //| When the **TouchIn** object is created, an initial `raw_value` is read from the pin, //| and then `threshold` is set to be 100 + that value. //| -//| You can adjust `threshold` to make the pin more or less sensitive. +//| You can adjust `threshold` to make the pin more or less sensitive.""" //| 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); diff --git a/shared-bindings/touchio/__init__.c b/shared-bindings/touchio/__init__.c index 6adbe09cf8..96367f0823 100644 --- a/shared-bindings/touchio/__init__.c +++ b/shared-bindings/touchio/__init__.c @@ -35,7 +35,7 @@ #include "py/runtime.h" -//| :mod:`touchio` --- Touch related IO +//| """:mod:`touchio` --- Touch related IO //| ================================================= //| //| .. module:: touchio @@ -66,7 +66,7 @@ //| print(touch_pin.value) //| //| This example will initialize the the device, and print the -//| :py:data:`~touchio.TouchIn.value`. +//| :py:data:`~touchio.TouchIn.value`.""" //| STATIC const mp_rom_map_elem_t touchio_module_globals_table[] = { diff --git a/shared-bindings/uheap/__init__.c b/shared-bindings/uheap/__init__.c index 0d699cd282..f1be304247 100644 --- a/shared-bindings/uheap/__init__.c +++ b/shared-bindings/uheap/__init__.c @@ -31,17 +31,17 @@ #include "shared-bindings/uheap/__init__.h" -//| :mod:`uheap` --- Heap size analysis +//| """:mod:`uheap` --- Heap size analysis //| ================================================================ //| //| .. module:: uheap -//| :synopsis: Heap size analysis +//| :synopsis: Heap size analysis""" //| -//| .. function:: info(object) -//| -//| Prints memory debugging info for the given object and returns the -//| estimated size. +//| def info(object: Any) -> Any: +//| """Prints memory debugging info for the given object and returns the +//| estimated size.""" +//| ... //| STATIC mp_obj_t uheap_info(mp_obj_t obj) { uint32_t size = shared_module_uheap_info(obj); From 6490137812eb9f0c0b08ad81bc77ea21f5f31d04 Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 12 May 2020 12:08:46 -0400 Subject: [PATCH 090/216] Did usb_hid, usb_midi, ustack, wiznet --- shared-bindings/usb_hid/Device.c | 39 ++++++++++---------- shared-bindings/usb_hid/__init__.c | 14 ++++---- shared-bindings/usb_midi/PortIn.c | 46 ++++++++++++------------ shared-bindings/usb_midi/PortOut.c | 27 +++++++------- shared-bindings/usb_midi/__init__.c | 4 +-- shared-bindings/ustack/__init__.c | 31 ++++++++-------- shared-bindings/wiznet/__init__.c | 4 +-- shared-bindings/wiznet/wiznet5k.c | 55 ++++++++++++++--------------- 8 files changed, 110 insertions(+), 110 deletions(-) diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index b1097fb24b..bcea5b2c55 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -27,27 +27,28 @@ #include "py/objproperty.h" #include "shared-bindings/usb_hid/Device.h" -//| .. currentmodule:: usb_hid +//| class Device: +//| """.. currentmodule:: usb_hid //| -//| :class:`Device` -- HID Device -//| ============================================ +//| :class:`Device` -- HID Device +//| ============================================ //| -//| Usage:: +//| Usage:: //| -//| import usb_hid +//| import usb_hid //| -//| mouse = usb_hid.devices[0] +//| mouse = usb_hid.devices[0] //| -//| mouse.send_report() +//| mouse.send_report()""" //| -//| .. class:: Device() +//| def __init__(self, ): +//| """Not currently dynamically supported.""" +//| ... //| -//| Not currently dynamically supported. -//| -//| .. method:: send_report(buf) -//| -//| Send a HID report. +//| def send_report(self, buf: Any) -> Any: +//| """Send a HID report.""" +//| ... //| STATIC mp_obj_t usb_hid_device_send_report(mp_obj_t self_in, mp_obj_t buffer) { usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -60,9 +61,8 @@ STATIC mp_obj_t usb_hid_device_send_report(mp_obj_t self_in, mp_obj_t buffer) { } MP_DEFINE_CONST_FUN_OBJ_2(usb_hid_device_send_report_obj, usb_hid_device_send_report); -//| .. attribute:: usage_page -//| -//| The usage page of the device as an `int`. Can be thought of a category. (read-only) +//| usage_page: Any = ... +//| """The usage page of the device as an `int`. Can be thought of a category. (read-only)""" //| STATIC mp_obj_t usb_hid_device_obj_get_usage_page(mp_obj_t self_in) { usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -77,12 +77,11 @@ const mp_obj_property_t usb_hid_device_usage_page_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: usage -//| -//| The functionality of the device as an int. (read-only) +//| usage: Any = ... +//| """The functionality of the device as an int. (read-only) //| //| For example, Keyboard is 0x06 within the generic desktop usage page 0x01. -//| Mouse is 0x02 within the same usage page. +//| Mouse is 0x02 within the same usage page.""" //| STATIC mp_obj_t usb_hid_device_obj_get_usage(mp_obj_t self_in) { usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/usb_hid/__init__.c b/shared-bindings/usb_hid/__init__.c index 3ad5b06e04..3d0978d623 100644 --- a/shared-bindings/usb_hid/__init__.c +++ b/shared-bindings/usb_hid/__init__.c @@ -31,27 +31,27 @@ #include "shared-bindings/usb_hid/__init__.h" #include "shared-bindings/usb_hid/Device.h" -//| :mod:`usb_hid` --- USB Human Interface Device +//| """:mod:`usb_hid` --- USB Human Interface Device //| =========================================================== //| //| .. module:: usb_hid //| :synopsis: USB Human Interface Device //| :platform: SAMD21 //| -//| The `usb_hid` module allows you to output data as a HID device. +//| The `usb_hid` module allows you to output data as a HID device.""" //| -//| .. attribute:: usb_hid.devices -//| -//| Tuple of all active HID device interfaces. +//| usb_hid.devices: Any = ... +//| """Tuple of all active HID device interfaces.""" //| -//| Libraries +//| """Libraries //| //| .. toctree:: //| :maxdepth: 3 //| -//| Device +//| Device""" +//| STATIC const mp_rom_map_elem_t usb_hid_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid) }, { MP_ROM_QSTR(MP_QSTR_devices), MP_ROM_PTR(&common_hal_usb_hid_devices) }, diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c index e2df56e954..55a5865ca7 100644 --- a/shared-bindings/usb_midi/PortIn.c +++ b/shared-bindings/usb_midi/PortIn.c @@ -35,39 +35,39 @@ #include "py/stream.h" #include "supervisor/shared/translate.h" - -//| .. currentmodule:: usb_midi +//| class PortIn: +//| """.. currentmodule:: usb_midi //| -//| :class:`PortIn` -- receives midi commands over USB -//| =================================================== +//| :class:`PortIn` -- receives midi commands over USB +//| ===================================================""" //| -//| .. class:: PortIn() +//| def __init__(self, ): +//| """You cannot create an instance of `usb_midi.PortIn`. //| -//| You cannot create an instance of `usb_midi.PortIn`. -//| -//| PortIn objects are constructed for every corresponding entry in the USB -//| descriptor and added to the ``usb_midi.ports`` tuple. +//| PortIn objects are constructed for every corresponding entry in the USB +//| descriptor and added to the ``usb_midi.ports`` tuple.""" +//| ... //| // These are standard stream methods. Code is in py/stream.c. // -//| .. method:: read(nbytes=None) +//| def read(self, nbytes: Any = None) -> Any: +//| """Read characters. If ``nbytes`` is specified then read at most that many +//| bytes. Otherwise, read everything that arrives until the connection +//| times out. Providing the number of bytes expected is highly recommended +//| because it will be faster. //| -//| Read characters. If ``nbytes`` is specified then read at most that many -//| bytes. Otherwise, read everything that arrives until the connection -//| times out. Providing the number of bytes expected is highly recommended -//| because it will be faster. +//| :return: Data read +//| :rtype: bytes or None""" +//| ... //| -//| :return: Data read -//| :rtype: bytes or None +//| def readinto(self, buf: Any, nbytes: Any = None) -> Any: +//| """Read bytes into the ``buf``. If ``nbytes`` is specified then read at most +//| that many bytes. Otherwise, read at most ``len(buf)`` bytes. //| -//| .. method:: readinto(buf, nbytes=None) -//| -//| Read bytes into the ``buf``. If ``nbytes`` is specified then read at most -//| that many bytes. Otherwise, read at most ``len(buf)`` bytes. -//| -//| :return: number of bytes read and stored into ``buf`` -//| :rtype: bytes or None +//| :return: number of bytes read and stored into ``buf`` +//| :rtype: bytes or None""" +//| ... //| // These three methods are used by the shared stream methods. diff --git a/shared-bindings/usb_midi/PortOut.c b/shared-bindings/usb_midi/PortOut.c index e3eddfaf57..d83eb53b69 100644 --- a/shared-bindings/usb_midi/PortOut.c +++ b/shared-bindings/usb_midi/PortOut.c @@ -35,28 +35,27 @@ #include "py/stream.h" #include "supervisor/shared/translate.h" - -//| .. currentmodule:: usb_midi +//| class PortOut: +//| """.. currentmodule:: usb_midi //| -//| :class:`PortOut` -- sends midi messages to a computer over USB -//| ============================================================== +//| :class:`PortOut` -- sends midi messages to a computer over USB +//| ==============================================================""" //| -//| .. class:: PortOut() +//| def __init__(self, ): +//| """You cannot create an instance of `usb_midi.PortOut`. //| -//| You cannot create an instance of `usb_midi.PortOut`. -//| -//| PortOut objects are constructed for every corresponding entry in the USB -//| descriptor and added to the ``usb_midi.ports`` tuple. +//| PortOut objects are constructed for every corresponding entry in the USB +//| descriptor and added to the ``usb_midi.ports`` tuple.""" //| // These are standard stream methods. Code is in py/stream.c. // -//| .. method:: write(buf) +//| def write(self, buf: Any) -> Any: +//| """Write the buffer of bytes to the bus. //| -//| Write the buffer of bytes to the bus. -//| -//| :return: the number of bytes written -//| :rtype: int or None +//| :return: the number of bytes written +//| :rtype: int or None""" +//| ... //| STATIC mp_uint_t usb_midi_portout_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) { diff --git a/shared-bindings/usb_midi/__init__.c b/shared-bindings/usb_midi/__init__.c index f57d3631bc..2631d8a882 100644 --- a/shared-bindings/usb_midi/__init__.c +++ b/shared-bindings/usb_midi/__init__.c @@ -35,7 +35,7 @@ #include "py/runtime.h" -//| :mod:`usb_midi` --- MIDI over USB +//| """:mod:`usb_midi` --- MIDI over USB //| ================================================= //| //| .. module:: usb_midi @@ -49,7 +49,7 @@ //| :maxdepth: 3 //| //| PortIn -//| PortOut +//| PortOut""" //| //| mp_map_elem_t usb_midi_module_globals_table[] = { diff --git a/shared-bindings/ustack/__init__.c b/shared-bindings/ustack/__init__.c index 08b772e41e..073840abac 100644 --- a/shared-bindings/ustack/__init__.c +++ b/shared-bindings/ustack/__init__.c @@ -31,17 +31,20 @@ #include "shared-bindings/ustack/__init__.h" -//| :mod:`ustack` --- Stack information and analysis + + + +//| """:mod:`ustack` --- Stack information and analysis //| ======================================================== //| //| .. module:: ustack -//| :synopsis: stack information functions +//| :synopsis: stack information functions""" //| #if MICROPY_MAX_STACK_USAGE -//| .. function:: max_stack_usage() -//| -//| Return the maximum excursion of the stack so far. +//| def max_stack_usage() -> Any: +//| """Return the maximum excursion of the stack so far.""" +//| ... //| STATIC mp_obj_t max_stack_usage(void) { return MP_OBJ_NEW_SMALL_INT(shared_module_ustack_max_stack_usage()); @@ -50,21 +53,21 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(max_stack_usage_obj, max_stack_usage); #endif // MICROPY_MAX_STACK_USAGE -//| .. function:: stack_size() -//| -//| Return the size of the entire stack. -//| Same as in micropython.mem_info(), but returns a value instead -//| of just printing it. +//| def stack_size() -> Any: +//| """Return the size of the entire stack. +//| Same as in micropython.mem_info(), but returns a value instead +//| of just printing it.""" +//| ... //| STATIC mp_obj_t stack_size(void) { return MP_OBJ_NEW_SMALL_INT(shared_module_ustack_stack_size()); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(stack_size_obj, stack_size); -//| .. function:: stack_usage() -//| -//| Return how much stack is currently in use. -//| Same as micropython.stack_use(); duplicated here for convenience. +//| def stack_usage() -> Any: +//| """Return how much stack is currently in use. +//| Same as micropython.stack_use(); duplicated here for convenience.""" +//| ... //| STATIC mp_obj_t stack_usage(void) { return MP_OBJ_NEW_SMALL_INT(shared_module_ustack_stack_usage()); diff --git a/shared-bindings/wiznet/__init__.c b/shared-bindings/wiznet/__init__.c index e230deeccc..5c8e8d3fd2 100644 --- a/shared-bindings/wiznet/__init__.c +++ b/shared-bindings/wiznet/__init__.c @@ -35,7 +35,7 @@ #include "shared-module/network/__init__.h" -//| :mod:`wiznet` --- Support for WizNet hardware +//| """:mod:`wiznet` --- Support for WizNet hardware //| ============================================= //| //| .. module:: wiznet @@ -49,7 +49,7 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| wiznet5k +//| wiznet5k""" //| extern const mod_network_nic_type_t mod_network_nic_type_wiznet5k; diff --git a/shared-bindings/wiznet/wiznet5k.c b/shared-bindings/wiznet/wiznet5k.c index 786978bfe8..2e2ee39496 100644 --- a/shared-bindings/wiznet/wiznet5k.c +++ b/shared-bindings/wiznet/wiznet5k.c @@ -46,25 +46,26 @@ #include "shared-module/network/__init__.h" #include "shared-module/wiznet/wiznet5k.h" -//| .. currentmodule:: wiznet +//| class WIZNET5K: +//| """.. currentmodule:: wiznet //| -//| :class:`WIZNET5K` -- wrapper for Wiznet 5500 Ethernet interface -//| =============================================================== +//| :class:`WIZNET5K` -- wrapper for Wiznet 5500 Ethernet interface +//| ===============================================================""" //| -//| .. class:: WIZNET5K(spi, cs, rst, dhcp=True) +//| def __init__(self, spi: busio.SPI, cs: microcontroller.Pin, rst: microcontroller.Pin, dhcp: bool = True): +//| """Create a new WIZNET5500 interface using the specified pins //| -//| Create a new WIZNET5500 interface using the specified pins +//| :param ~busio.SPI spi: spi bus to use +//| :param ~microcontroller.Pin cs: pin to use for Chip Select +//| :param ~microcontroller.Pin rst: pin to use for Reset (optional) +//| :param bool dhcp: boolean flag, whether to start DHCP automatically (optional, keyword only, default True) //| -//| :param ~busio.SPI spi: spi bus to use -//| :param ~microcontroller.Pin cs: pin to use for Chip Select -//| :param ~microcontroller.Pin rst: pin to use for Reset (optional) -//| :param bool dhcp: boolean flag, whether to start DHCP automatically (optional, keyword only, default True) -//| -//| * The reset pin is optional: if supplied it is used to reset the -//| wiznet board before initialization. -//| * The SPI bus will be initialized appropriately by this library. -//| * At present, the WIZNET5K object is a singleton, so only one WizNet -//| interface is supported at a time. +//| * The reset pin is optional: if supplied it is used to reset the +//| wiznet board before initialization. +//| * The SPI bus will be initialized appropriately by this library. +//| * At present, the WIZNET5K object is a singleton, so only one WizNet +//| interface is supported at a time.""" +//| ... //| STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -86,9 +87,8 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, cons return ret; } -//| .. attribute:: connected -//| -//| (boolean, readonly) is this device physically connected? +//| connected: Any = ... +//| """(boolean, readonly) is this device physically connected?""" //| STATIC mp_obj_t wiznet5k_connected_get_value(mp_obj_t self_in) { @@ -104,11 +104,10 @@ const mp_obj_property_t wiznet5k_connected_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: dhcp +//| dhcp: Any = ... +//| """(boolean, readwrite) is DHCP active on this device? //| -//| (boolean, readwrite) is DHCP active on this device? -//| -//| * set to True to activate DHCP, False to turn it off +//| * set to True to activate DHCP, False to turn it off""" //| STATIC mp_obj_t wiznet5k_dhcp_get_value(mp_obj_t self_in) { @@ -138,13 +137,13 @@ const mp_obj_property_t wiznet5k_dhcp_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. method:: ifconfig(params=None) +//| def ifconfig(self, params: Any = None) -> Any: +//| """Called without parameters, returns a tuple of +//| (ip_address, subnet_mask, gateway_address, dns_server) //| -//| Called without parameters, returns a tuple of -//| (ip_address, subnet_mask, gateway_address, dns_server) -//| -//| Or can be called with the same tuple to set those parameters. -//| Setting ifconfig parameters turns DHCP off, if it was on. +//| Or can be called with the same tuple to set those parameters. +//| Setting ifconfig parameters turns DHCP off, if it was on.""" +//| ... //| STATIC mp_obj_t wiznet5k_ifconfig(size_t n_args, const mp_obj_t *args) { From 5af59cbabebca75f156acd995f23591361726321 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Tue, 12 May 2020 11:46:04 -0700 Subject: [PATCH 091/216] Enable vectorio by default where displayio is enabled --- py/circuitpy_mpconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 687ef72635..046d91caa8 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -94,7 +94,7 @@ CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO) CIRCUITPY_FRAMEBUFFERIO ?= 0 CFLAGS += -DCIRCUITPY_FRAMEBUFFERIO=$(CIRCUITPY_FRAMEBUFFERIO) -CIRCUITPY_VECTORIO ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_VECTORIO ?= $(CIRCUITPY_DISPLAYIO) CFLAGS += -DCIRCUITPY_VECTORIO=$(CIRCUITPY_VECTORIO) CIRCUITPY_FREQUENCYIO ?= $(CIRCUITPY_FULL_BUILD) From 6aa9709d98c578bf9de342117137ef6595251960 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Tue, 12 May 2020 11:47:19 -0700 Subject: [PATCH 092/216] make Circle return explicit --- shared-module/vectorio/Circle.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared-module/vectorio/Circle.c b/shared-module/vectorio/Circle.c index e6e3268e7e..999d625121 100644 --- a/shared-module/vectorio/Circle.c +++ b/shared-module/vectorio/Circle.c @@ -28,7 +28,8 @@ uint32_t common_hal_vectorio_circle_get_pixel(void *obj, int16_t x, int16_t y) { if (x+y <= radius) return 1; if (x > radius) return 0; if (y > radius) return 0; - return (int32_t)x*x + (int32_t)y*y <= (int32_t)radius*radius; + const bool pythagorasSmallerThanRadius = (int32_t)x*x + (int32_t)y*y <= (int32_t)radius*radius; + return pythagorasSmallerThanRadius ? 1 : 0; } From fd94c08cf45d1b0669c276ba61bbad1b501ee13f Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Tue, 12 May 2020 11:49:15 -0700 Subject: [PATCH 093/216] add performance measurement to VectorShape --- shared-module/vectorio/VectorShape.c | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index f57739047a..4fb353aae7 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -5,6 +5,7 @@ #include "shared-bindings/vectorio/VectorShape.h" #include "py/runtime.h" +#include "shared-bindings/time/__init__.h" #include "shared-bindings/displayio/ColorConverter.h" #include "shared-bindings/displayio/Palette.h" @@ -17,6 +18,10 @@ // #define VECTORIO_SHAPE_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) +// Used in both logging and ifdefs, for extra variables +// #define VECTORIO_PERF(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + + // Really verbose. #define VECTORIO_SHAPE_PIXEL_DEBUG(...) (void)0 // #define VECTORIO_SHAPE_PIXEL_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) @@ -167,6 +172,10 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ // To make it relative to the VectorShape position, we must shift it. // Pixels are drawn on the screen_area (shifted) coordinate space, while pixels are _determined_ from // the shape_area (unshifted) space. +#ifdef VECTORIO_PERF + uint64_t start = common_hal_time_monotonic_ns(); + uint64_t pixel_time = 0; +#endif displayio_area_t overlap; VECTORIO_SHAPE_DEBUG("%p fill_area dirty:%d fill: {(%5d,%5d), (%5d,%5d)} dirty: {(%5d,%5d), (%5d,%5d)}", self, self->dirty, @@ -186,7 +195,8 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ uint32_t linestride_px = displayio_area_width(area); uint32_t line_dirty_offset_px = (overlap.y1 - area->y1) * linestride_px; uint32_t column_dirty_offset_px = overlap.x1 - area->x1; - VECTORIO_SHAPE_DEBUG(", linestride:%3d line_offset:%3d col_offset:%3d depth:%2d ppb:%2d\n", linestride_px, line_dirty_offset_px, column_dirty_offset_px, colorspace->depth, pixels_per_byte); + VECTORIO_SHAPE_DEBUG(", linestride:%3d line_offset:%3d col_offset:%3d depth:%2d ppb:%2d shape:%s", + linestride_px, line_dirty_offset_px, column_dirty_offset_px, colorspace->depth, pixels_per_byte, mp_obj_get_type_str(self->ishape.shape)); displayio_input_pixel_t input_pixel; displayio_output_pixel_t output_pixel; @@ -217,7 +227,14 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ pixel_to_get_y = (input_pixel.y - self->absolute_transform->dy * self->y) / self->absolute_transform->dy; } VECTORIO_SHAPE_PIXEL_DEBUG(" get_pixel %p (%3d, %3d) -> ( %3d, %3d )", self->ishape.shape, input_pixel.x, input_pixel.y, pixel_to_get_x, pixel_to_get_y); +#ifdef VECTORIO_PERF + uint64_t pre_pixel = common_hal_time_monotonic_ns(); +#endif input_pixel.pixel = self->ishape.get_pixel(self->ishape.shape, pixel_to_get_x, pixel_to_get_y); +#ifdef VECTORIO_PERF + uint64_t post_pixel = common_hal_time_monotonic_ns(); + pixel_time += post_pixel - pre_pixel; +#endif VECTORIO_SHAPE_PIXEL_DEBUG(" -> %d", input_pixel.pixel); output_pixel.opaque = true; @@ -259,6 +276,19 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ } mask_start_px += linestride_px - column_dirty_offset_px; } +#ifdef VECTORIO_PERF + uint64_t end = common_hal_time_monotonic_ns(); + uint32_t pixels = (overlap.x2 - overlap.x1) * (overlap.y2 - overlap.y1); + VECTORIO_PERF("draw %16s -> shape:{%4dpx, %4.1fms,%9.1fpps fill} shape_pixels:{%6.1fus total, %4.1fus/px}\n", + mp_obj_get_type_str(self->ishape.shape), + (overlap.x2 - overlap.x1) * (overlap.y2 - overlap.y1), + (double)((end - start) / 1000000.0), + (double)(max(1, pixels * (1000000000.0 / (end - start)))), + (double)(pixel_time / 1000.0), + (double)(pixel_time / 1000.0 / pixels) + ); +#endif + VECTORIO_SHAPE_DEBUG(" -> pixels:%4d\n"); return full_coverage; } From 5a80f5e606fe893a6ccd78cb8ebf7f39055e2e43 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Tue, 12 May 2020 15:23:00 -0700 Subject: [PATCH 094/216] nerf vectorio on a ton of m0 and overcommitted m4 boards due to translation text size --- ports/atmel-samd/boards/bdmicro_vina_m0/mpconfigboard.mk | 1 + .../atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk | 2 ++ .../circuitplayground_express_displayio/mpconfigboard.mk | 2 ++ ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk | 1 + .../atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk | 2 ++ .../boards/feather_radiofruit_zigbee/mpconfigboard.mk | 4 ++++ ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk | 1 + ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk | 2 ++ ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk | 1 + ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk | 1 + ports/atmel-samd/boards/snekboard/mpconfigboard.mk | 1 + ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk | 1 + .../boards/sparkfun_redboard_turbo/mpconfigboard.mk | 1 + ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk | 1 + 14 files changed, 21 insertions(+) diff --git a/ports/atmel-samd/boards/bdmicro_vina_m0/mpconfigboard.mk b/ports/atmel-samd/boards/bdmicro_vina_m0/mpconfigboard.mk index 1537540424..5a47a5890d 100644 --- a/ports/atmel-samd/boards/bdmicro_vina_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/bdmicro_vina_m0/mpconfigboard.mk @@ -13,6 +13,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_VECTORIO = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk index 3587f1a33b..19e5dd2ab9 100755 --- a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk @@ -14,3 +14,5 @@ LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_VECTORIO = 0 + diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index d65dc993f7..4220aa77ff 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -17,6 +17,8 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_RTC = 0 +# So not all of displayio, sorry! +CIRCUITPY_VECTORIO = 0 SUPEROPT_GC = 0 CFLAGS_INLINE_LIMIT = 55 diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk index cdee7b7946..199cef362a 100644 --- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk @@ -14,6 +14,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_VECTORIO = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk index cb13adb76d..a94dd3c4e7 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk @@ -14,6 +14,8 @@ LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 +# supersized, not ultra-supersized +CIRCUITPY_VECTORIO = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk index 05c305b1a2..3aa7c5721a 100755 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk @@ -15,3 +15,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_AUDIOBUSIO = 0 # No DAC on SAMR21G CIRCUITPY_AUDIOIO = 0 + +# Too much flash for Korean translations +CIRCUITPY_VECTORIO = 0 + diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk index 875d23f9b7..d848363a0c 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk @@ -19,6 +19,7 @@ CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 +CIRCUITPY_VECTORIO = 0 CFLAGS_INLINE_LIMIT = 55 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk index 4d516c75b6..812c208ccb 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk @@ -17,6 +17,8 @@ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_RTC = 0 +# too itsy bitsy for all of displayio +CIRCUITPY_VECTORIO = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk index b52b1343fb..588e50ee1b 100644 --- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk @@ -13,6 +13,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_VECTORIO = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index f5b6ca3899..87f92ae9ec 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -34,6 +34,7 @@ CIRCUITPY_NETWORK = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_SAMD = 0 CIRCUITPY_TOUCHIO = 0 +CIRCUITPY_VECTORIO = 0 CIRCUITPY_AUDIOMIXER = 1 CIRCUITPY_AUDIOIO = 1 diff --git a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk index 4faa041b1b..08f8d431ea 100644 --- a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk +++ b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk @@ -14,6 +14,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_VECTORIO = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk index 6a2afc306e..3f75d175c8 100755 --- a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk @@ -13,5 +13,6 @@ LONGINT_IMPL = MPZ CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_VECTORIO = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk index f2d4eccad9..7a9b44e4c9 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk @@ -13,6 +13,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_VECTORIO = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk index 20feabd189..c4b1f6d5af 100644 --- a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk @@ -18,6 +18,7 @@ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_RTC = 0 +CIRCUITPY_VECTORIO = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 From 4e8de3c554024d3ac89e9ee77b958a6932a64bec Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 12 May 2020 17:15:28 -0700 Subject: [PATCH 095/216] Swap sphinx to autoapi and the inline stubs --- .github/workflows/build.yml | 2 +- .gitignore | 2 + Makefile | 6 +- conf.py | 14 +++- docs/c2rst.py | 31 --------- ports/atmel-samd/README.rst | 2 +- ports/atmel-samd/bindings/samd/Clock.c | 36 ++++------- ports/atmel-samd/bindings/samd/__init__.c | 19 +----- setup.py | 8 +-- shared-bindings/_bleio/Adapter.c | 5 +- shared-bindings/_bleio/Address.c | 9 +-- shared-bindings/_bleio/Attribute.c | 6 +- shared-bindings/_bleio/Characteristic.c | 9 +-- shared-bindings/_bleio/CharacteristicBuffer.c | 7 +- shared-bindings/_bleio/Connection.c | 14 ++-- shared-bindings/_bleio/Descriptor.c | 6 +- shared-bindings/_bleio/PacketBuffer.c | 26 +++----- shared-bindings/_bleio/ScanEntry.c | 9 +-- shared-bindings/_bleio/ScanResults.c | 7 +- shared-bindings/_bleio/Service.c | 7 +- shared-bindings/_bleio/UUID.c | 9 +-- shared-bindings/_bleio/__init__.c | 26 +------- shared-bindings/_eve/__init__.c | 22 +------ shared-bindings/_pew/PewPew.c | 7 +- shared-bindings/_pew/__init__.c | 12 +--- shared-bindings/_pixelbuf/PixelBuf.c | 7 +- shared-bindings/_pixelbuf/__init__.c | 27 ++------ shared-bindings/_stage/Layer.c | 5 +- shared-bindings/_stage/Text.c | 7 +- shared-bindings/_stage/__init__.c | 16 +---- shared-bindings/aesio/__init__.c | 17 +---- shared-bindings/aesio/aes.c | 64 +++++++++---------- shared-bindings/analogio/AnalogIn.c | 5 +- shared-bindings/analogio/AnalogOut.c | 7 +- shared-bindings/analogio/__init__.c | 15 +---- shared-bindings/audiobusio/I2SOut.c | 7 +- shared-bindings/audiobusio/PDMIn.c | 7 +- shared-bindings/audiobusio/__init__.c | 15 +---- shared-bindings/audiocore/RawSample.c | 13 +--- shared-bindings/audiocore/WaveFile.c | 5 +- shared-bindings/audiocore/__init__.c | 17 +---- shared-bindings/audioio/AudioOut.c | 7 +- shared-bindings/audioio/__init__.c | 14 +--- shared-bindings/audiomixer/Mixer.c | 7 +- shared-bindings/audiomixer/MixerVoice.c | 5 +- shared-bindings/audiomixer/__init__.c | 16 +---- shared-bindings/audiomp3/MP3Decoder.c | 7 +- shared-bindings/audiomp3/__init__.c | 15 +---- shared-bindings/audiopwmio/PWMAudioOut.c | 7 +- shared-bindings/audiopwmio/__init__.c | 14 +--- shared-bindings/bitbangio/I2C.c | 5 +- shared-bindings/bitbangio/OneWire.c | 5 +- shared-bindings/bitbangio/SPI.c | 5 +- shared-bindings/bitbangio/__init__.c | 16 +---- shared-bindings/board/__init__.c | 6 +- shared-bindings/busio/I2C.c | 5 +- shared-bindings/busio/OneWire.c | 5 +- shared-bindings/busio/SPI.c | 7 +- shared-bindings/busio/UART.c | 5 +- shared-bindings/busio/__init__.c | 17 +---- shared-bindings/digitalio/DigitalInOut.c | 5 +- shared-bindings/digitalio/Direction.c | 5 +- shared-bindings/digitalio/DriveMode.c | 5 +- shared-bindings/digitalio/Pull.c | 5 +- shared-bindings/digitalio/__init__.c | 17 +---- shared-bindings/displayio/Bitmap.c | 7 +- shared-bindings/displayio/ColorConverter.c | 7 +- shared-bindings/displayio/Display.c | 5 +- shared-bindings/displayio/EPaperDisplay.c | 5 +- shared-bindings/displayio/FourWire.c | 7 +- shared-bindings/displayio/Group.c | 7 +- shared-bindings/displayio/I2CDisplay.c | 7 +- shared-bindings/displayio/OnDiskBitmap.c | 7 +- shared-bindings/displayio/Palette.c | 7 +- shared-bindings/displayio/ParallelBus.c | 7 +- shared-bindings/displayio/Shape.c | 7 +- shared-bindings/displayio/TileGrid.c | 5 +- shared-bindings/displayio/__init__.c | 27 +------- shared-bindings/fontio/BuiltinFont.c | 7 +- shared-bindings/fontio/Glyph.c | 31 +++++---- shared-bindings/fontio/__init__.c | 17 +---- .../framebufferio/FramebufferDisplay.c | 5 +- shared-bindings/framebufferio/__init__.c | 16 +---- shared-bindings/frequencyio/FrequencyIn.c | 5 +- shared-bindings/frequencyio/__init__.c | 17 +---- shared-bindings/gamepad/GamePad.c | 7 +- shared-bindings/gamepad/__init__.c | 12 +--- shared-bindings/gamepadshift/GamePadShift.c | 5 +- shared-bindings/gamepadshift/__init__.c | 12 +--- shared-bindings/help.c | 34 ---------- shared-bindings/help.rst | 31 +++++++++ shared-bindings/i2cslave/I2CSlave.c | 36 +++++------ shared-bindings/i2cslave/__init__.c | 14 +--- shared-bindings/index.rst | 10 ++- shared-bindings/math/__init__.c | 7 +- shared-bindings/microcontroller/Pin.c | 7 +- shared-bindings/microcontroller/Processor.c | 11 +--- shared-bindings/microcontroller/RunMode.c | 5 +- shared-bindings/microcontroller/__init__.c | 20 +----- shared-bindings/multiterminal/__init__.c | 7 +- shared-bindings/neopixel_write/__init__.c | 13 ++-- shared-bindings/network/__init__.c | 7 +- shared-bindings/nvm/ByteArray.c | 8 +-- shared-bindings/nvm/__init__.c | 17 +---- shared-bindings/os/__init__.c | 7 +- shared-bindings/ps2io/Ps2.c | 5 +- shared-bindings/ps2io/__init__.c | 14 +--- shared-bindings/pulseio/PWMOut.c | 7 +- shared-bindings/pulseio/PulseIn.c | 12 +--- shared-bindings/pulseio/PulseOut.c | 13 ++-- shared-bindings/pulseio/__init__.c | 16 +---- shared-bindings/random/__init__.c | 7 +- shared-bindings/rgbmatrix/RGBMatrix.c | 14 ++-- shared-bindings/rgbmatrix/__init__.c | 11 +--- shared-bindings/rotaryio/IncrementalEncoder.c | 7 +- shared-bindings/rotaryio/__init__.c | 18 +----- shared-bindings/rtc/RTC.c | 13 +--- shared-bindings/rtc/__init__.c | 16 +---- shared-bindings/socket/__init__.c | 8 +-- shared-bindings/storage/__init__.c | 7 +- shared-bindings/struct/__init__.c | 9 +-- shared-bindings/supervisor/Runtime.c | 11 +--- shared-bindings/supervisor/__init__.c | 30 +++------ shared-bindings/terminalio/Terminal.c | 5 +- shared-bindings/terminalio/__init__.c | 16 +---- shared-bindings/time/__init__.c | 7 +- shared-bindings/touchio/TouchIn.c | 5 +- shared-bindings/touchio/__init__.c | 14 +--- shared-bindings/uheap/__init__.c | 6 +- .../ulab/{__init__.rst => __init__.pyi} | 0 shared-bindings/usb_hid/Device.c | 5 +- shared-bindings/usb_hid/__init__.c | 15 +---- shared-bindings/usb_midi/PortIn.c | 7 +- shared-bindings/usb_midi/PortOut.c | 5 +- shared-bindings/usb_midi/__init__.c | 17 +---- shared-bindings/ustack/__init__.c | 10 +-- shared-bindings/wiznet/__init__.c | 16 +---- shared-bindings/wiznet/wiznet5k.c | 5 +- tools/extract_pyi.py | 12 +++- 139 files changed, 337 insertions(+), 1239 deletions(-) delete mode 100644 docs/c2rst.py delete mode 100644 shared-bindings/help.c create mode 100644 shared-bindings/help.rst rename shared-bindings/ulab/{__init__.rst => __init__.pyi} (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3dda76db4e..057395eeef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: run: | sudo apt-get install -y eatmydata sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64 - pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinxcontrib-svg2pdfconverter polib pyyaml + pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml - name: Versions run: | gcc --version diff --git a/.gitignore b/.gitignore index 435ed73a78..403fcc2997 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ ############ dist/ *.egg-info +.eggs # Logs and Databases ###################### @@ -51,6 +52,7 @@ _build # Generated rst files ###################### genrst/ +autoapi/ # ctags and similar ################### diff --git a/Makefile b/Makefile index aa8fc26d1f..1971076a38 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ clean: rm -rf $(BUILDDIR)/* rm -rf $(STUBDIR) $(DISTDIR) *.egg-info -html: +html: stubs $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." @@ -213,8 +213,10 @@ check-translate: locale/circuitpython.pot $(wildcard locale/*.po) $(PYTHON) tools/check_translations.py $^ stubs: + mkdir -p circuitpython-stubs python tools/extract_pyi.py shared-bindings/ $(STUBDIR) - #python setup.py sdist + python tools/extract_pyi.py ports/atmel-samd/bindings $(STUBDIR) + python setup.py sdist update-frozen-libraries: @echo "Updating all frozen libraries to latest tagged version." diff --git a/conf.py b/conf.py index 2e503737c9..aea84dd21d 100644 --- a/conf.py +++ b/conf.py @@ -55,7 +55,6 @@ extensions = [ 'sphinx.ext.todo', 'sphinx.ext.coverage', 'rstjinja', - 'c2rst', 'recommonmark', ] @@ -66,9 +65,17 @@ templates_path = ['templates'] source_suffix = { '.rst': 'restructuredtext', '.md': 'markdown', - '.c': '' } +extensions.append('autoapi.extension') + +autoapi_type = 'python' +# Uncomment this if debugging autoapi +# autoapi_keep_files = True +autoapi_dirs = ['circuitpython-stubs'] +autoapi_add_toctree_entry = False +autoapi_options = ['members', 'undoc-members', 'private-members', 'show-inheritance', 'special-members', 'show-module-summary'] +autoapi_template_dir = 'docs/autoapi/templates' # The encoding of source files. #source_encoding = 'utf-8-sig' @@ -78,7 +85,7 @@ source_suffix = { # General information about the project. project = 'Adafruit CircuitPython' -copyright = '2014-2018, MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)' +copyright = '2014-2020, MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)' # These are overwritten on ReadTheDocs. # The version info for the project you're documenting, acts as replacement for @@ -105,6 +112,7 @@ exclude_patterns = ["**/build*", ".git", ".venv", ".direnv", + "docs/autoapi", "docs/README.md", "drivers", "examples", diff --git a/docs/c2rst.py b/docs/c2rst.py deleted file mode 100644 index 76489dca30..0000000000 --- a/docs/c2rst.py +++ /dev/null @@ -1,31 +0,0 @@ -def c2rst(app, docname, source): - """ Pre-parse '.c' & '.h' files that contain rST source. - """ - # Make sure we're outputting HTML - if app.builder.format != 'html': - return - - fname = app.env.doc2path(docname) - if (not fname.endswith(".c") and - not fname.endswith(".h")): - #print("skipping:", fname) - return - - src = source[0] - - stripped = [] - for line in src.split("\n"): - line = line.strip() - if line == "//|": - stripped.append("") - elif line.startswith("//| "): - stripped.append(line[len("//| "):]) - stripped = "\r\n".join(stripped) - - rendered = app.builder.templates.render_string( - stripped, app.config.html_context - ) - source[0] = rendered - -def setup(app): - app.connect("source-read", c2rst) diff --git a/ports/atmel-samd/README.rst b/ports/atmel-samd/README.rst index 7211772750..a6881902e9 100644 --- a/ports/atmel-samd/README.rst +++ b/ports/atmel-samd/README.rst @@ -21,4 +21,4 @@ Port Specific modules --------------------- .. toctree:: - bindings/samd/__init__ + ../../autoapi/samd/index diff --git a/ports/atmel-samd/bindings/samd/Clock.c b/ports/atmel-samd/bindings/samd/Clock.c index b88bb82e22..24e425e8cb 100644 --- a/ports/atmel-samd/bindings/samd/Clock.c +++ b/ports/atmel-samd/bindings/samd/Clock.c @@ -30,18 +30,12 @@ #include "py/objproperty.h" #include "py/runtime.h" -//| .. currentmodule:: samd +//| import typing +//| class Clock: +//| """Identifies a clock on the microcontroller. //| -//| :class:`Clock` --- Clock reference -//| ------------------------------------------ -//| -//| Identifies a clock on the microcontroller. -//| -//| .. class:: Clock -//| -//| Identifies a clock on the microcontroller. They are fixed by the -//| hardware so they cannot be constructed on demand. Instead, use -//| `samd.clock` to reference the desired clock. +//| They are fixed by the hardware so they cannot be constructed on demand. Instead, use +//| ``samd.clock`` to reference the desired clock.""" //| STATIC void samd_clock_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { @@ -50,9 +44,8 @@ STATIC void samd_clock_print(const mp_print_t *print, mp_obj_t self_in, mp_print mp_printf(print, "%q.%q.%q", MP_QSTR_samd, MP_QSTR_clock, self->name); } -//| .. attribute:: enabled -//| -//| Is the clock enabled? (read-only) +//| enabled: bool = ... +//| """Is the clock enabled? (read-only)""" //| STATIC mp_obj_t samd_clock_get_enabled(mp_obj_t self_in) { samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -69,9 +62,8 @@ const mp_obj_property_t samd_clock_enabled_obj = { }, }; -//| .. attribute:: parent -//| -//| Clock parent. (read-only) +//| parent: typing.Union(Clock | None) = ... +//| """Clock parent. (read-only)""" //| STATIC mp_obj_t samd_clock_get_parent(mp_obj_t self_in) { samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -98,9 +90,8 @@ const mp_obj_property_t samd_clock_parent_obj = { }, }; -//| .. attribute:: frequency -//| -//| Clock frequency. (read-only) +//| frequency: int = ... +//| """Clock frequency in Herz. (read-only)""" //| STATIC mp_obj_t samd_clock_get_frequency(mp_obj_t self_in) { samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -117,9 +108,8 @@ const mp_obj_property_t samd_clock_frequency_obj = { }, }; -//| .. attribute:: calibration -//| -//| Clock calibration. Not all clocks can be calibrated. +//| calibration: int = ... +//| """Clock calibration. Not all clocks can be calibrated.""" //| STATIC mp_obj_t samd_clock_get_calibration(mp_obj_t self_in) { samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/ports/atmel-samd/bindings/samd/__init__.c b/ports/atmel-samd/bindings/samd/__init__.c index 55a10001d2..6e9b68ccc6 100644 --- a/ports/atmel-samd/bindings/samd/__init__.c +++ b/ports/atmel-samd/bindings/samd/__init__.c @@ -30,29 +30,16 @@ #include "bindings/samd/Clock.h" -//| :mod:`samd` --- SAMD implementation settings -//| ================================================= -//| -//| .. module:: samd -//| :synopsis: SAMD implementation settings -//| :platform: SAMD21 -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Clock -//| +//| """SAMD implementation settings""" -//| :mod:`samd.clock` --- samd clock names +//| """:mod:`samd.clock` --- samd clock names //| -------------------------------------------------------- //| //| .. module:: samd.clock //| :synopsis: samd clock names //| :platform: SAMD21 //| -//| References to clocks as named by the microcontroller +//| References to clocks as named by the microcontroller""" //| const mp_obj_module_t samd_clock_module = { .base = { &mp_type_module }, diff --git a/setup.py b/setup.py index 1e0d81da36..37afb6f1b1 100644 --- a/setup.py +++ b/setup.py @@ -5,18 +5,16 @@ from pathlib import Path stub_root = Path("circuitpython-stubs") stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")] -now = datetime.utcnow() -version = now.strftime("%Y.%m.%d") - setup( name="circuitpython-stubs", description="PEP 561 type stubs for CircuitPython", url="https://github.com/adafruit/circuitpython", maintainer="CircuitPythonistas", author_email="circuitpython@adafruit.com", - version=version, + use_scm_version=True, license="MIT", package_data={"circuitpython-stubs": stubs}, packages=["circuitpython-stubs"], - setup_requires=["setuptools>=38.6.0"], + setup_requires=["setuptools>=38.6.0", + "setuptools_scm"], ) diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 6fb5c323d7..4816294f7f 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -48,10 +48,7 @@ #define WINDOW_DEFAULT (0.1f) //| class Adapter: -//| """.. currentmodule:: _bleio -//| -//| :class:`Adapter` --- BLE adapter -//| ---------------------------------------------------- +//| """BLE adapter //| //| The Adapter manages the discovery and connection to other nearby Bluetooth Low Energy devices. //| This part of the Bluetooth Low Energy Specification is known as Generic Access Profile (GAP). diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index 2071bd3b24..ccbab1b9d2 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -35,12 +35,7 @@ #include "shared-module/_bleio/Address.h" //| class Address: -//| """.. currentmodule:: _bleio -//| -//| :class:`Address` -- BLE address -//| ========================================================= -//| -//| Encapsulates the address of a BLE device.""" +//| """Encapsulates the address of a BLE device.""" //| //| def __init__(self, address: buf, address_type: Any): @@ -97,7 +92,7 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, //| >>> _bleio.adapter.address //|
//| >>> _bleio.adapter.address.address_bytes -//| b'5\xa8\xed\xf5\x1d\xc8'""" +//| b'5\\xa8\\xed\\xf5\\x1d\\xc8'""" //| STATIC mp_obj_t bleio_address_get_address_bytes(mp_obj_t self_in) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/Attribute.c b/shared-bindings/_bleio/Attribute.c index 72fd13d1cc..6c47c87ba8 100644 --- a/shared-bindings/_bleio/Attribute.c +++ b/shared-bindings/_bleio/Attribute.c @@ -30,12 +30,8 @@ #include "shared-bindings/_bleio/UUID.h" //| class Attribute: -//| """.. currentmodule:: _bleio +//| """Definitions associated with all BLE attributes: characteristics, descriptors, etc. //| -//| :class:`Attribute` -- BLE Attribute -//| ========================================================= -//| -//| Definitions associated with all BLE attributes: characteristics, descriptors, etc. //| :py:class:`~_bleio.Attribute` is, notionally, a superclass of //| :py:class:`~Characteristic` and :py:class:`~Descriptor`, //| but is not defined as a Python superclass of those classes.""" diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index f8f18d0bd6..785b677d67 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -34,13 +34,8 @@ #include "shared-bindings/_bleio/UUID.h" //| class Characteristic: -//| """.. currentmodule:: _bleio -//| -//| :class:`Characteristic` -- BLE service characteristic -//| ========================================================= -//| -//| Stores information about a BLE service characteristic and allows reading -//| and writing of the characteristic's value.""" +//| """Stores information about a BLE service characteristic and allows reading +//| and writing of the characteristic's value.""" //| //| def __init__(self, ): //| """There is no regular constructor for a Characteristic. A new local Characteristic can be created diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index f38f650d91..6cbd587c64 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -42,12 +42,7 @@ STATIC void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self } //| class CharacteristicBuffer: -//| """.. currentmodule:: _bleio -//| -//| :class:`CharacteristicBuffer` -- BLE Service incoming values buffer. -//| ===================================================================== -//| -//| Accumulates a Characteristic's incoming values in a FIFO buffer.""" +//| """Accumulates a Characteristic's incoming values in a FIFO buffer.""" //| //| def __init__(self, characteristic: Characteristic, *, timeout: int = 1, buffer_size: int = 64): //| diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index 93600e76d9..0a96d8a111 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -43,12 +43,7 @@ #include "shared-bindings/_bleio/Service.h" //| class Connection: -//| """.. currentmodule:: _bleio -//| -//| :class:`Connection` -- A BLE connection -//| ========================================================= -//| -//| A BLE connection to another device. Used to discover and interact with services on the other +//| """A BLE connection to another device. Used to discover and interact with services on the other //| device. //| //| Usage:: @@ -211,15 +206,14 @@ STATIC mp_obj_t bleio_connection_get_connection_interval(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_get_connection_interval_obj, bleio_connection_get_connection_interval); -//| .. attribute:: max_packet_length -//| -//| The maximum number of data bytes that can be sent in a single transmission, +//| attribute: Any = ... +//| """The maximum number of data bytes that can be sent in a single transmission, //| not including overhead bytes. //| //| This is the maximum number of bytes that can be sent in a notification, //| which must be sent in a single packet. //| But for a regular characteristic read or write, may be sent in multiple packets, -//| so this limit does not apply. +//| so this limit does not apply.""" //| STATIC mp_obj_t bleio_connection_get_max_packet_length(mp_obj_t self_in) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index 00b3bacf51..9d70208494 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -34,12 +34,8 @@ #include "shared-bindings/_bleio/UUID.h" //| class Descriptor: -//| """.. currentmodule:: _bleio +//| """Stores information about a BLE descriptor. //| -//| :class:`Descriptor` -- BLE descriptor -//| ========================================================= -//| -//| Stores information about a BLE descriptor. //| Descriptors are attached to BLE characteristics and provide contextual //| information about the characteristic.""" //| diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index 80beadb158..907bfabd27 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -36,12 +36,7 @@ #include "shared-bindings/util.h" //| class PacketBuffer: -//| """.. currentmodule:: _bleio -//| -//| :class:`PacketBuffer` -- Packet-oriented characteristic usage. -//| ===================================================================== -//| -//| Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware +//| """Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware //| outgoing writes. A packet's size is either the characteristic length or the maximum transmission //| unit (MTU) minus overhead, whichever is smaller. The MTU can change so check `incoming_packet_length` //| and `outgoing_packet_length` before creating a buffer to store data. @@ -60,7 +55,7 @@ //| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic //| in a remote Service that a Central has connected to. //| :param int buffer_size: Size of ring buffer (in packets of the Characteristic's maximum -//| length) that stores incoming packets coming from the peer. +//| length) that stores incoming packets coming from the peer.""" //| ... //| STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -126,11 +121,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_packet_buffer_readinto_obj, bleio_packet_ //| """Writes all bytes from data into the same outgoing packet. The bytes from header are included //| before data when the pending packet is currently empty. //| -//| This does not block until the data is sent. It only blocks until the data is pending.""" -//| ... +//| This does not block until the data is sent. It only blocks until the data is pending. //| -//| :return: number of bytes written. May include header bytes when packet is empty. -//| :rtype: int +//| :return: number of bytes written. May include header bytes when packet is empty. +//| :rtype: int""" +//| ... //| // TODO: Add a kwarg `merge=False` to dictate whether subsequent writes are merged into a pending // one. @@ -174,7 +169,7 @@ STATIC mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_ } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_packet_buffer_write_obj, 1, bleio_packet_buffer_write); -//| def deinit(self, ) -> Any: +//| def deinit(self) -> Any: //| """Disable permanently.""" //| ... STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) { @@ -184,7 +179,7 @@ STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_deinit_obj, bleio_packet_buffer_deinit); -//| packet_size: Any = ... +//| packet_size: int = ... //| """`packet_size` is the same as `incoming_packet_length`. //| The name `packet_size` is deprecated and //| will be removed in CircuitPython 6.0.0.""" @@ -210,9 +205,8 @@ const mp_obj_property_t bleio_packet_buffer_incoming_packet_length_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: outgoing_packet_length -//| -//| Maximum length in bytes of a packet we are writing. +//| outgoing_packet_length: int = ... +//| """Maximum length in bytes of a packet we are writing.""" //| STATIC mp_obj_t bleio_packet_buffer_get_outgoing_packet_length(mp_obj_t self_in) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c index a92b247be3..905bea81d2 100644 --- a/shared-bindings/_bleio/ScanEntry.c +++ b/shared-bindings/_bleio/ScanEntry.c @@ -36,12 +36,7 @@ #include "shared-module/_bleio/ScanEntry.h" //| class ScanEntry: -//| """.. currentmodule:: _bleio -//| -//| :class:`ScanEntry` -- BLE scan data -//| ========================================================= -//| -//| Encapsulates information about a device that was received during scanning. It can be +//| """Encapsulates information about a device that was received during scanning. It can be //| advertisement or scan response data. This object may only be created by a `_bleio.ScanResults`: //| it has no user-visible constructor.""" //| @@ -68,7 +63,7 @@ STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_ar 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); - + mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_prefixes].u_obj, &bufinfo, MP_BUFFER_READ); return mp_obj_new_bool(common_hal_bleio_scanentry_matches(self, bufinfo.buf, bufinfo.len, args[ARG_all].u_bool)); diff --git a/shared-bindings/_bleio/ScanResults.c b/shared-bindings/_bleio/ScanResults.c index 4b274fc682..6077dcbdae 100644 --- a/shared-bindings/_bleio/ScanResults.c +++ b/shared-bindings/_bleio/ScanResults.c @@ -33,12 +33,7 @@ #include "shared-bindings/_bleio/ScanResults.h" //| class ScanResults: -//| """.. currentmodule:: _bleio -//| -//| :class:`ScanResults` -- An Iterator over BLE scanning results -//| =============================================================== -//| -//| Iterates over advertising data received while scanning. This object is always created +//| """Iterates over advertising data received while scanning. This object is always created //| by a `_bleio.Adapter`: it has no user-visible constructor.""" //| STATIC mp_obj_t scanresults_iternext(mp_obj_t self_in) { diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index 3526ce1899..5ca7504f27 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -33,12 +33,7 @@ #include "shared-bindings/_bleio/UUID.h" //| class Service: -//| """.. currentmodule:: _bleio -//| -//| :class:`Service` -- BLE GATT Service -//| ========================================================= -//| -//| Stores information about a BLE service and its characteristics.""" +//| """Stores information about a BLE service and its characteristics.""" //| //| def __init__(self, uuid: UUID, *, secondary: bool = False): //| """Create a new Service identified by the specified UUID. It can be accessed by all diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index d4b0f84cad..78161b9566 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -34,12 +34,7 @@ #include "shared-bindings/_bleio/UUID.h" //| class UUID: -//| """.. currentmodule:: _bleio -//| -//| :class:`UUID` -- BLE UUID -//| ========================================================= -//| -//| A 16-bit or 128-bit UUID. Can be used for services, characteristics, descriptors and more.""" +//| """A 16-bit or 128-bit UUID. Can be used for services, characteristics, descriptors and more.""" //| //| def __init__(self, value: Any): //| """Create a new UUID or UUID object encapsulating the uuid value. @@ -207,7 +202,7 @@ STATIC mp_obj_t bleio_uuid_pack_into(mp_uint_t n_args, const mp_obj_t *pos_args, 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); - + mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_WRITE); diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c index da7bfdd816..90b185f79a 100644 --- a/shared-bindings/_bleio/__init__.c +++ b/shared-bindings/_bleio/__init__.c @@ -41,13 +41,7 @@ #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" -//| """:mod:`_bleio` --- Bluetooth Low Energy (BLE) communication -//| ================================================================ -//| -//| .. module:: _bleio -//| :synopsis: Bluetooth Low Energy functionality -//| :platform: nRF -//| +//| """ //| The `_bleio` module provides necessary low-level functionality for communicating //| using Bluetooth Low Energy (BLE). The '_' prefix indicates this module is meant //| for internal use by libraries but not by the end user. Its API may change incompatibly @@ -58,24 +52,6 @@ //| provides higher-level convenience functionality, including predefined beacons, clients, //| servers. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Address -//| Adapter -//| Attribute -//| Characteristic -//| CharacteristicBuffer -//| Connection -//| Descriptor -//| PacketBuffer -//| ScanEntry -//| ScanResults -//| Service -//| UUID -//| //| .. attribute:: adapter //| //| BLE Adapter used to manage device discovery and connections. diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 0e78cea160..4fa48f2c75 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -34,28 +34,10 @@ #include "shared-module/_eve/__init__.h" #include "shared-bindings/_eve/__init__.h" - - - - - - - - - - - - - -//| """:mod:`_eve` --- low-level BridgeTek EVE bindings -//| ================================================ -//| -//| .. module:: _eve -//| :synopsis: low-level BridgeTek EVE bindings -//| :platform: SAMD21/SAMD51 +//| """Low-level BridgeTek EVE bindings //| //| The `_eve` module provides a class _EVE which -//| contains methods for constructing EVE command +//| contains methods for constructing EVE command //| buffers and appending basic graphics commands.""" //| diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c index 37188d2b74..82bf04a617 100644 --- a/shared-bindings/_pew/PewPew.c +++ b/shared-bindings/_pew/PewPew.c @@ -35,12 +35,7 @@ #include "supervisor/shared/translate.h" //| class PewPew: -//| """.. currentmodule:: _pew -//| -//| :class:`PewPew` -- LED matrix and button driver -//| =============================================== -//| -//| This is an internal module to be used by the ``pew.py`` library from +//| """This is an internal module to be used by the ``pew.py`` library from //| https://github.com/pewpew-game/pew-pewpew-standalone-10.x to handle the //| LED matrix display and buttons on the ``pewpew10`` board. //| diff --git a/shared-bindings/_pew/__init__.c b/shared-bindings/_pew/__init__.c index b6aab67264..6e0070d8e2 100644 --- a/shared-bindings/_pew/__init__.c +++ b/shared-bindings/_pew/__init__.c @@ -41,17 +41,7 @@ STATIC mp_obj_t get_pressed(void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_pressed_obj, get_pressed); -//| """:mod:`_pew` --- LED matrix driver -//| ================================== -//| -//| .. module:: _pew -//| :synopsis: LED matrix driver -//| :platform: SAMD21 -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| PewPew""" +//| """LED matrix driver""" //| STATIC const mp_rom_map_elem_t pew_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pew) }, diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 2d1f4fff2f..71a91d7076 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -45,12 +45,7 @@ extern const int32_t colorwheel(float pos); static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed); //| class PixelBuf: -//| """.. currentmodule:: _pixelbuf -//| -//| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices -//| =========================================================================== -//| -//| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction.""" +//| """A fast RGB[W] pixel buffer for LED and similar devices.""" //| //| def __init__(self, size: int, *, byteorder: str = "BGR", brightness: float = 0, auto_write: bool = False, header: bytes = b"", trailer: bytes = b""): //| """Create a PixelBuf object of the specified size, byteorder, and bits per pixel. diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 30656f1c78..bfd479fde0 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -33,35 +33,22 @@ #include "shared-bindings/_pixelbuf/PixelBuf.h" -//| """:mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers -//| =========================================================== - -//| .. module:: _pixelbuf -//| :synopsis: A fast RGB(W) pixel buffer library for like NeoPixel and DotStar. +//| """A fast RGB(W) pixel buffer library for like NeoPixel and DotStar. //| //| The `_pixelbuf` module provides the :py:class:`PixelBuf` class to accelerate //| RGB(W) strip/matrix manipulation, such as DotStar and Neopixel. //| -//| Byteorders are configured with strings, such as "RGB" or "RGBD". -//| TODO: Pull in docs from pypixelbuf. +//| Byteorders are configured with strings, such as "RGB" or "RGBD".""" +// TODO: Pull in docs from pypixelbuf. -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| PixelBuf""" - -//| def colorwheel(n: Any) -> Any: ... -//| - -//| def wheel(n: Any) -> Any: +//| def colorwheel(n: int) -> Any: //| """C implementation of the common wheel() function found in many examples. //| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar).""" //| ... //| -//| .. function:: wheel(n) -//| Use of wheel() is deprecated. Please use colorwheel(). +//| def wheel(n: Any) -> Any: +//| """Use of wheel() is deprecated. Please use colorwheel().""" +//| STATIC mp_obj_t pixelbuf_colorwheel(mp_obj_t n) { return MP_OBJ_NEW_SMALL_INT(colorwheel(MP_OBJ_IS_SMALL_INT(n) ? MP_OBJ_SMALL_INT_VALUE(n) : mp_obj_float_get(n))); diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index 437114cd31..0f8260e53f 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -31,10 +31,7 @@ #include "supervisor/shared/translate.h" //| class Layer: -//| """.. currentmodule:: _stage -//| -//| :class:`Layer` -- Keep information about a single layer of graphics -//| ===================================================================""" +//| """Keep information about a single layer of graphics""" //| //| def __init__(self, width: int, height: int, graphic: bytearray, palette: bytearray, grid: bytearray): //| """Keep internal information about a layer of graphics (either a diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index 8797f74dbe..b0ff1525c3 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -31,13 +31,10 @@ #include "supervisor/shared/translate.h" //| class Text: -//| """.. currentmodule:: _stage -//| -//| :class:`Text` -- Keep information about a single text of text -//| ==============================================================""" +//| """Keep information about a single grid of text""" //| //| def __init__(self, width: int, height: int, font: bytearray, palette: bytearray, chars: bytearray): -//| """Keep internal information about a text of text +//| """Keep internal information about a grid of text //| in a format suitable for fast rendering //| with the ``render()`` function. //| diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 6b5c4fd8b1..6a56381856 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -34,22 +34,10 @@ #include "Layer.h" #include "Text.h" -//| """:mod:`_stage` --- C-level helpers for animation of sprites on a stage -//| ===================================================================== -//| -//| .. module:: _stage -//| :synopsis: C-level helpers for animation of sprites on a stage -//| :platform: SAMD21 +//| """C-level helpers for animation of sprites on a stage //| //| The `_stage` module contains native code to speed-up the ```stage`` Library -//| `_. -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Layer -//| Text""" +//| `_.""" //| //| def render(x0: int, y0: int, x1: int, y1: int, layers: list, buffer: bytearray, display: displayio.Display, scale: int, background: int) -> Any: //| """Render and send to the display a fragment of the screen. diff --git a/shared-bindings/aesio/__init__.c b/shared-bindings/aesio/__init__.c index 43dc73e8b1..fa2a2c426e 100644 --- a/shared-bindings/aesio/__init__.c +++ b/shared-bindings/aesio/__init__.c @@ -31,23 +31,10 @@ #include "__init__.h" -//| :mod:`aesio` --- AES encryption routines -//| ======================================== -//| -//| .. module:: aesio -//| :synopsis: Embedded implementation of AES +//| """AES encryption routines //| //| The `AES` module contains classes used to implement encryption -//| and decryption. It aims to be low overhead in terms of memory. -//| -//| - -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| aes +//| and decryption. It aims to be low overhead in terms of memory.""" STATIC const mp_obj_tuple_t mp_aes_key_size_obj = { diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index 4ddcfa898b..7a559b0bbe 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -9,35 +9,31 @@ // Defined at the end of this file -//| .. currentmodule:: aesio +//| class AES: +//| """Encrypt and decrypt AES streams""" //| -//| :class:`aesio` -- Encrypt and decrypt AES streams -//| ===================================================== +//| def __init__(self, key, mode=0, iv=None, segment_size=8) -> Any: +//| """Create a new AES state with the given key. //| -//| An object that represents an AES stream, including the current state. +//| :param bytearray key: A 16-, 24-, or 32-byte key +//| :param int mode: AES mode to use. One of: AES.MODE_ECB, AES.MODE_CBC, or +//| AES.MODE_CTR +//| :param bytearray iv: Initialization vector to use for CBC or CTR mode //| -//| .. class:: AES(key, mode=0, iv=None, segment_size=8) +//| Additional arguments are supported for legacy reasons. //| -//| Create a new AES state with the given key. +//| Encrypting a string:: //| -//| :param bytearray key: A 16-, 24-, or 32-byte key -//| :param int mode: AES mode to use. One of: AES.MODE_ECB, AES.MODE_CBC, or -//| AES.MODE_CTR -//| :param bytearray iv: Initialization vector to use for CBC or CTR mode +//| import aesio +//| from binascii import hexlify //| -//| Additional arguments are supported for legacy reasons. -//| -//| Encrypting a string:: -//| -//| import aesio -//| from binascii import hexlify -//| -//| key = b'Sixteen byte key' -//| inp = b'Circuit Python!!' # Note: 16-bytes long -//| outp = bytearray(len(inp)) -//| cipher = aesio.AES(key, aesio.mode.MODE_ECB) -//| cipher.encrypt_into(inp, outp) -//| hexlify(outp) +//| key = b'Sixteen byte key' +//| inp = b'Circuit Python!!' # Note: 16-bytes long +//| outp = bytearray(len(inp)) +//| cipher = aesio.AES(key, aesio.mode.MODE_ECB) +//| cipher.encrypt_into(inp, outp) +//| hexlify(outp)""" +//| ... //| STATIC mp_obj_t aesio_aes_make_new(const mp_obj_type_t *type, size_t n_args, @@ -154,12 +150,13 @@ STATIC void validate_length(aesio_aes_obj_t *self, size_t src_length, } } -//| .. method:: encrypt_into(src, dest) +//| def encrypt_into(src, dest) -> None: +//| """Encrypt the buffer from ``src`` into ``dest``. //| -//| Encrypt the buffer from ``src`` into ``dest``. -//| For ECB mode, the buffers must be 16 bytes long. For CBC mode, the -//| buffers must be a multiple of 16 bytes, and must be equal length. For -//| CTX mode, there are no restrictions. +//| For ECB mode, the buffers must be 16 bytes long. For CBC mode, the +//| buffers must be a multiple of 16 bytes, and must be equal length. For +//| CTX mode, there are no restrictions.""" +//| ... //| STATIC mp_obj_t aesio_aes_encrypt_into(mp_obj_t aesio_obj, mp_obj_t src, mp_obj_t dest) { @@ -184,12 +181,13 @@ STATIC mp_obj_t aesio_aes_encrypt_into(mp_obj_t aesio_obj, mp_obj_t src, STATIC MP_DEFINE_CONST_FUN_OBJ_3(aesio_aes_encrypt_into_obj, aesio_aes_encrypt_into); -//| .. method:: decrypt_into(src, dest) +//| def decrypt_into(src, dest) -> None: //| -//| Decrypt the buffer from ``src`` into ``dest``. -//| For ECB mode, the buffers must be 16 bytes long. For CBC mode, the -//| buffers must be a multiple of 16 bytes, and must be equal length. For -//| CTX mode, there are no restrictions. +//| """Decrypt the buffer from ``src`` into ``dest``. +//| For ECB mode, the buffers must be 16 bytes long. For CBC mode, the +//| buffers must be a multiple of 16 bytes, and must be equal length. For +//| CTX mode, there are no restrictions.""" +//| ... //| STATIC mp_obj_t aesio_aes_decrypt_into(mp_obj_t aesio_obj, mp_obj_t src, mp_obj_t dest) { diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index 2fb5051ebe..bafa287ff1 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -37,10 +37,7 @@ #include "shared-bindings/util.h" //| class AnalogIn: -//| """.. currentmodule:: analogio -//| -//| :class:`AnalogIn` -- read analog voltage -//| ============================================ +//| """Read analog voltage levels //| //| Usage:: //| diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index 9064bb5dce..a8edcc0ae1 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -37,12 +37,7 @@ #include "supervisor/shared/translate.h" //| class AnalogOut: -//| """.. currentmodule:: analogio -//| -//| :class:`AnalogOut` -- output analog voltage -//| ============================================ -//| -//| The AnalogOut is used to output analog values (a specific voltage). +//| """Output analog values (a specific voltage). //| //| Example usage:: //| diff --git a/shared-bindings/analogio/__init__.c b/shared-bindings/analogio/__init__.c index 79627f16aa..1f059f3402 100644 --- a/shared-bindings/analogio/__init__.c +++ b/shared-bindings/analogio/__init__.c @@ -34,25 +34,12 @@ #include "shared-bindings/analogio/AnalogIn.h" #include "shared-bindings/analogio/AnalogOut.h" -//| """:mod:`analogio` --- Analog hardware support -//| ================================================= -//| -//| .. module:: analogio -//| :synopsis: Analog hardware support -//| :platform: SAMD21, ESP8266 +//| """Analog hardware support //| //| The `analogio` module contains classes to provide access to analog IO //| typically implemented with digital-to-analog (DAC) and analog-to-digital //| (ADC) converters. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| AnalogIn -//| AnalogOut -//| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 724a65a347..d965aac89e 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -36,12 +36,7 @@ #include "supervisor/shared/translate.h" //| class I2SOut: -//| """.. currentmodule:: audiobusio -//| -//| :class:`I2SOut` -- Output an I2S audio signal -//| ======================================================== -//| -//| I2S is used to output an audio signal on an I2S bus.""" +//| """Output an I2S audio signal""" //| //| def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool): //| """Create a I2SOut object associated with the given pins. diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 6cc834724b..5b950297b5 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -37,12 +37,7 @@ #include "supervisor/shared/translate.h" //| class PDMIn: -//| """.. currentmodule:: audiobusio -//| -//| :class:`PDMIn` -- Record an input PDM audio stream -//| ======================================================== -//| -//| PDMIn can be used to record an input audio signal on a given set of pins.""" +//| """Record an input PDM audio stream""" //| //| def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11): //| """Create a PDMIn object associated with the given pins. This allows you to diff --git a/shared-bindings/audiobusio/__init__.c b/shared-bindings/audiobusio/__init__.c index c5c3873619..89ccbb88b5 100644 --- a/shared-bindings/audiobusio/__init__.c +++ b/shared-bindings/audiobusio/__init__.c @@ -34,26 +34,13 @@ #include "shared-bindings/audiobusio/I2SOut.h" #include "shared-bindings/audiobusio/PDMIn.h" -//| """:mod:`audiobusio` --- Support for audio input and output over digital bus -//| ========================================================================= -//| -//| .. module:: audiobusio -//| :synopsis: Support for audio input and output over digital bus -//| :platform: SAMD21 +//| """Support for audio input and output over digital buses //| //| The `audiobusio` module contains classes to provide access to audio IO //| over digital buses. These protocols are used to communicate audio to other //| chips in the same circuit. It doesn't include audio interconnect protocols //| such as S/PDIF. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| I2SOut -//| PDMIn -//| //| All libraries change hardware state and should be deinitialized when they //| are no longer needed. To do so, either call :py:meth:`!deinit` or use a //| context manager.""" diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 6091fbfc00..c0f9325e67 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -35,19 +35,8 @@ #include "shared-bindings/audiocore/RawSample.h" #include "supervisor/shared/translate.h" - - - - - - //| class RawSample: -//| """.. currentmodule:: audiocore -//| -//| :class:`RawSample` -- A raw audio sample buffer -//| ======================================================== -//| -//| An in-memory sound sample""" +//| """A raw audio sample buffer in memory""" //| //| def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000): //| """Create a RawSample based on the given buffer of signed values. If channel_count is more than diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 65b42fb6c4..a067f6cda8 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -34,10 +34,7 @@ #include "supervisor/shared/translate.h" //| class WaveFile: -//| """.. currentmodule:: audiocore -//| -//| :class:`WaveFile` -- Load a wave file for audio playback -//| ======================================================== +//| """Load a wave file for audio playback //| //| A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must //| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating diff --git a/shared-bindings/audiocore/__init__.c b/shared-bindings/audiocore/__init__.c index 38f91d8eeb..b400b94548 100644 --- a/shared-bindings/audiocore/__init__.c +++ b/shared-bindings/audiocore/__init__.c @@ -35,22 +35,7 @@ #include "shared-bindings/audiocore/WaveFile.h" //#include "shared-bindings/audiomixer/Mixer.h" -//| """:mod:`audiocore` --- Support for audio samples and mixer -//| ======================================================== -//| -//| .. module:: audiocore -//| :synopsis: Support for audio samples and mixer -//| :platform: SAMD21 -//| -//| The `audiocore` module contains core classes for audio IO -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| RawSample -//| WaveFile""" +//| """Support for audio samples""" //| STATIC const mp_rom_map_elem_t audiocore_module_globals_table[] = { diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 84e5e44227..5748682020 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -37,12 +37,7 @@ #include "supervisor/shared/translate.h" //| class AudioOut: -//| """.. currentmodule:: audioio -//| -//| :class:`AudioOut` -- Output an analog audio signal -//| ======================================================== -//| -//| AudioOut can be used to output an analog audio signal on a given pin.""" +//| """Output an analog audio signal""" //| //| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): //| """Create a AudioOut object associated with the given pin(s). This allows you to diff --git a/shared-bindings/audioio/__init__.c b/shared-bindings/audioio/__init__.c index bc2e26cfce..7ec927834f 100644 --- a/shared-bindings/audioio/__init__.c +++ b/shared-bindings/audioio/__init__.c @@ -42,22 +42,10 @@ #include "shared-bindings/audiomixer/Mixer.h" #endif -//| """:mod:`audioio` --- Support for audio input and output -//| ====================================================== -//| -//| .. module:: audioio -//| :synopsis: Support for audio input and output -//| :platform: SAMD21 +//| """Support for audio output //| //| The `audioio` module contains classes to provide access to audio IO. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| AudioOut -//| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 966581d454..31e62cdae1 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -39,12 +39,7 @@ #include "supervisor/shared/translate.h" //| class Mixer: -//| """.. currentmodule:: audiomixer -//| -//| :class:`Mixer` -- Mixes one or more audio samples together -//| =========================================================== -//| -//| Mixer mixes multiple samples into one sample.""" +//| """Mixes one or more audio samples together into one sample.""" //| //| def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000): //| """Create a Mixer object that can mix multiple channels with the same sample rate. diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index 257d9507b9..ec5768d2f0 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -38,10 +38,7 @@ #include "supervisor/shared/translate.h" //| class MixerVoice: -//| """.. currentmodule:: audiomixer -//| -//| :class:`MixerVoice` -- Voice objects used with Mixer -//| ===================================================== +//| """Voice objects used with Mixer //| //| Used to access and control samples with `audiomixer.Mixer`.""" //| diff --git a/shared-bindings/audiomixer/__init__.c b/shared-bindings/audiomixer/__init__.c index c90a4a0e65..1146bb7981 100644 --- a/shared-bindings/audiomixer/__init__.c +++ b/shared-bindings/audiomixer/__init__.c @@ -32,21 +32,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiomixer/Mixer.h" -//| """:mod:`audiomixer` --- Support for audio mixer -//| ======================================================== -//| -//| .. module:: audiomixer -//| :synopsis: Support for audio mixer -//| -//| The `audiomixer` module contains core classes for mixing audio sources -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Mixer -//| MixerVoice""" +//| """Support for audio mixing""" //| STATIC const mp_rom_map_elem_t audiomixer_module_globals_table[] = { diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index d9c85bbf63..e6d48e32cb 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -35,12 +35,7 @@ #include "supervisor/shared/translate.h" //| class MP3: -//| """.. currentmodule:: audiomp3 -//| -//| :class:`MP3Decoder` -- Load a mp3 file for audio playback -//| ========================================================= -//| -//| An object that decodes MP3 files for playback on an audio device.""" +//| """Load a mp3 file for audio playback""" //| //| def __init__(self, file: typing.BinaryIO, buffer: bytearray): //| diff --git a/shared-bindings/audiomp3/__init__.c b/shared-bindings/audiomp3/__init__.c index 50b29da529..62e5f56cbb 100644 --- a/shared-bindings/audiomp3/__init__.c +++ b/shared-bindings/audiomp3/__init__.c @@ -31,20 +31,7 @@ #include "shared-bindings/audiomp3/MP3Decoder.h" -//| """:mod:`audiomp3` --- Support for MP3-compressed audio files -//| ========================================================== -//| -//| .. module:: audiomp3 -//| :synopsis: Support for mp3 files -//| -//| The `audiomp3` module contains an mp3 decoder -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| MP3Decoder""" +//| """Support for MP3-compressed audio files""" //| STATIC const mp_rom_map_elem_t audiomp3_module_globals_table[] = { diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index 17f82e3f64..d6b102317f 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -37,12 +37,7 @@ #include "supervisor/shared/translate.h" //| class PWMAudioOut: -//| """.. currentmodule:: audiopwmio -//| -//| :class:`PWMAudioOut` -- Output an analog audio signal -//| ======================================================== -//| -//| AudioOut can be used to output an analog audio signal on a given pin.""" +//| """Output an analog audio signal by varying the PWM duty cycle.""" //| //| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): //| """Create a PWMAudioOut object associated with the given pin(s). This allows you to diff --git a/shared-bindings/audiopwmio/__init__.c b/shared-bindings/audiopwmio/__init__.c index 74d22b45ec..5caea14209 100644 --- a/shared-bindings/audiopwmio/__init__.c +++ b/shared-bindings/audiopwmio/__init__.c @@ -33,22 +33,10 @@ #include "shared-bindings/audiopwmio/__init__.h" #include "shared-bindings/audiopwmio/PWMAudioOut.h" -//| """:mod:`audiopwmio` --- Support for audio input and output -//| ======================================================== -//| -//| .. module:: audiopwmio -//| :synopsis: Support for audio output via digital PWM -//| :platform: NRF52 +//| """Audio output via digital PWM //| //| The `audiopwmio` module contains classes to provide access to audio IO. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| PWMAudioOut -//| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index a682e050e1..2043fc903f 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -38,10 +38,7 @@ #include "supervisor/shared/translate.h" //| class I2C: -//| """.. currentmodule:: bitbangio -//| -//| :class:`I2C` --- Two wire serial protocol -//| ------------------------------------------""" +//| """Two wire serial protocol""" //| //| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int): //| """I2C is a two-wire protocol for communicating between devices. At the diff --git a/shared-bindings/bitbangio/OneWire.c b/shared-bindings/bitbangio/OneWire.c index 1c9405bd8d..a236f4c2aa 100644 --- a/shared-bindings/bitbangio/OneWire.c +++ b/shared-bindings/bitbangio/OneWire.c @@ -35,10 +35,7 @@ #include "shared-bindings/util.h" //| class OneWire: -//| """.. currentmodule:: bitbangio -//| -//| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol -//| =============================================================== +//| """Lowest-level of the Maxim OneWire protocol //| //| :class:`~bitbangio.OneWire` implements the timing-sensitive foundation of //| the Maxim (formerly Dallas Semi) OneWire protocol. diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index 38e0926e8d..08bbf1257f 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -40,10 +40,7 @@ #include "supervisor/shared/translate.h" //| class SPI: -//| """.. currentmodule:: bitbangio -//| -//| :class:`SPI` -- a 3-4 wire serial protocol -//| ----------------------------------------------- +//| """A 3-4 wire serial protocol //| //| SPI is a serial protocol that has exclusive pins for data in and out of the //| master. It is typically faster than :py:class:`~bitbangio.I2C` because a diff --git a/shared-bindings/bitbangio/__init__.c b/shared-bindings/bitbangio/__init__.c index e9600a7e66..e04bdf7011 100644 --- a/shared-bindings/bitbangio/__init__.c +++ b/shared-bindings/bitbangio/__init__.c @@ -40,12 +40,7 @@ #include "py/runtime.h" -//| """:mod:`bitbangio` --- Digital protocols implemented by the CPU -//| ============================================================= -//| -//| .. module:: bitbangio -//| :synopsis: Digital protocols implemented by the CPU -//| :platform: SAMD21, ESP8266 +//| """Digital protocols implemented by the CPU //| //| The `bitbangio` module contains classes to provide digital bus protocol //| support regardless of whether the underlying hardware exists to use the @@ -55,15 +50,6 @@ //| hardware to implement the protocols. Native implementations will be faster //| than bitbanged versions and have more capabilities. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| I2C -//| OneWire -//| SPI -//| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index 77675e0937..010a9fb92a 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -29,11 +29,7 @@ #include "shared-bindings/board/__init__.h" -//| """:mod:`board` --- Board specific pin names -//| ======================================================== -//| -//| .. module:: board -//| :synopsis: Board specific pin names +//| """Board specific pin names //| //| Common container for board base pin names. These will vary from board to //| board so don't expect portability when using this module. diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 8ae3658eee..7e8af765f7 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -37,10 +37,7 @@ #include "supervisor/shared/translate.h" //| class I2C: -//| """.. currentmodule:: busio -//| -//| :class:`I2C` --- Two wire serial protocol -//| ------------------------------------------""" +//| """Two wire serial protocol""" //| //| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255): //| diff --git a/shared-bindings/busio/OneWire.c b/shared-bindings/busio/OneWire.c index 556e567efc..723cc031a8 100644 --- a/shared-bindings/busio/OneWire.c +++ b/shared-bindings/busio/OneWire.c @@ -35,10 +35,7 @@ #include "shared-bindings/util.h" //| class OneWire: -//| """.. currentmodule:: busio -//| -//| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol -//| =================================================================""" +//| """Lowest-level of the Maxim OneWire protocol""" //| //| def __init__(self, pin: microcontroller.Pin): //| """(formerly Dallas Semi) OneWire protocol. diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 5b1881702c..2ba9a4c22c 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -42,10 +42,7 @@ //| class SPI: -//| """.. currentmodule:: busio -//| -//| `SPI` -- a 3-4 wire serial protocol -//| ----------------------------------------------- +//| """A 3-4 wire serial protocol //| //| SPI is a serial protocol that has exclusive pins for data in and out of the //| master. It is typically faster than :py:class:`~busio.I2C` because a @@ -147,7 +144,7 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) { //| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any: //| """Configures the SPI bus. The SPI object must be locked. //| -//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower +//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower //| due to the granularity of available clock settings. //| Check the `frequency` attribute for the actual clock rate. //| :param int polarity: the base state of the clock line (0 or 1) diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 5984194a9a..d4642225c0 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -43,10 +43,7 @@ // #define STREAM_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) //| class UART: -//| """.. currentmodule:: busio -//| -//| :class:`UART` -- a bidirectional serial protocol -//| =================================================""" +//| """A bidirectional serial protocol""" //| def __init__(self, tx: microcontroller.Pin, rx: microcontroller.Pin, *, baudrate: int = 9600, bits: int = 8, parity: Parity = None, stop: int = 1, timeout: float = 1, receiver_buffer_size: int = 64): //| """A common bidirectional serial protocol that uses an an agreed upon speed //| rather than a shared clock line. diff --git a/shared-bindings/busio/__init__.c b/shared-bindings/busio/__init__.c index 212b3218c1..04632c2f4a 100644 --- a/shared-bindings/busio/__init__.c +++ b/shared-bindings/busio/__init__.c @@ -38,12 +38,7 @@ #include "py/runtime.h" -//| """:mod:`busio` --- Hardware accelerated behavior -//| ================================================= -//| -//| .. module:: busio -//| :synopsis: Hardware accelerated behavior -//| :platform: SAMD21 +//| """Hardware accelerated external bus access //| //| The `busio` module contains classes to support a variety of serial //| protocols. @@ -54,16 +49,6 @@ //| then a RuntimeError will be raised. Use the `bitbangio` module to explicitly //| bitbang a serial protocol on any general purpose pins. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| I2C -//| OneWire -//| SPI -//| UART -//| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 5fffb3f653..54ced099db 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -44,10 +44,7 @@ #include "supervisor/shared/translate.h" //| class DigitalInOut: -//| """.. currentmodule:: digitalio -//| -//| :class:`DigitalInOut` -- digital input and output -//| ========================================================= +//| """Digital input and output //| //| A DigitalInOut is used to digitally control I/O pins. For analog control of //| a pin, see the :py:class:`analogio.AnalogIn` and diff --git a/shared-bindings/digitalio/Direction.c b/shared-bindings/digitalio/Direction.c index 0586e95def..dbd0e93e47 100644 --- a/shared-bindings/digitalio/Direction.c +++ b/shared-bindings/digitalio/Direction.c @@ -39,10 +39,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" //| class Direction: -//| """.. currentmodule:: digitalio -//| -//| :class:`Direction` -- defines the direction of a digital pin -//| =============================================================""" +//| """Defines the direction of a digital pin""" //| //| def __init__(self, ): //| """Enum-like class to define which direction the digital values are diff --git a/shared-bindings/digitalio/DriveMode.c b/shared-bindings/digitalio/DriveMode.c index 23745b0469..31b682d388 100644 --- a/shared-bindings/digitalio/DriveMode.c +++ b/shared-bindings/digitalio/DriveMode.c @@ -27,10 +27,7 @@ #include "shared-bindings/digitalio/DriveMode.h" //| class DriveMode: -//| """.. currentmodule:: digitalio -//| -//| :class:`DriveMode` -- defines the drive mode of a digital pin -//| =============================================================""" +//| """Defines the drive mode of a digital pin""" //| //| def __init__(self, ): //| """Enum-like class to define the drive mode used when outputting diff --git a/shared-bindings/digitalio/Pull.c b/shared-bindings/digitalio/Pull.c index 1e64d07887..9aeec1f331 100644 --- a/shared-bindings/digitalio/Pull.c +++ b/shared-bindings/digitalio/Pull.c @@ -27,10 +27,7 @@ #include "shared-bindings/digitalio/Pull.h" //| class Pull: -//| """.. currentmodule:: digitalio -//| -//| :class:`Pull` -- defines the pull of a digital input pin -//| =============================================================""" +//| """Defines the pull of a digital input pin""" //| //| def __init__(self, ): //| """Enum-like class to define the pull value, if any, used while reading diff --git a/shared-bindings/digitalio/__init__.c b/shared-bindings/digitalio/__init__.c index 5a11436a23..f8f45b158b 100644 --- a/shared-bindings/digitalio/__init__.c +++ b/shared-bindings/digitalio/__init__.c @@ -38,25 +38,10 @@ #include "py/runtime.h" -//| """:mod:`digitalio` --- Basic digital pin support -//| ================================================= -//| -//| .. module:: digitalio -//| :synopsis: Basic digital pin support -//| :platform: SAMD21, ESP8266 +//| """Basic digital pin support //| //| The `digitalio` module contains classes to provide access to basic digital IO. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| DigitalInOut -//| Direction -//| DriveMode -//| Pull -//| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index d15c3b1078..a52840f2e0 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -37,12 +37,7 @@ #include "supervisor/shared/translate.h" //| class Bitmap: -//| """.. currentmodule:: displayio -//| -//| :class:`Bitmap` -- Stores values in a 2D array -//| ========================================================================== -//| -//| Stores values of a certain size in a 2D array""" +//| """Stores values of a certain size in a 2D array""" //| //| def __init__(self, width: int, height: int, value_count: int): //| """Create a Bitmap object with the given fixed size. Each pixel stores a value that is used to diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 1d6e5a0cc9..505e9f7665 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -37,12 +37,7 @@ #include "supervisor/shared/translate.h" //| class ColorConverter: -//| """.. currentmodule:: displayio -//| -//| :class:`ColorConverter` -- Converts one color format to another -//| ========================================================================================= -//| -//| Converts one color format to another.""" +//| """Converts one color format to another.""" //| //| def __init__(self, *, dither: bool = False): //| """Create a ColorConverter object to convert color formats. Only supports RGB888 to RGB565 diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 12abec1c83..62ef0f5d00 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -40,10 +40,7 @@ #include "supervisor/shared/translate.h" //| class Display: -//| """.. currentmodule:: displayio -//| -//| :class:`Display` -- Manage updating a display over a display bus -//| ========================================================================== +//| """Manage updating a display over a display bus //| //| This initializes a display and connects it into CircuitPython. Unlike other //| objects in CircuitPython, Display objects live until `displayio.release_displays()` diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index 8b03ddc067..8b77e4df37 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -40,10 +40,7 @@ #include "supervisor/shared/translate.h" //| class EPaperDisplay: -//| """.. currentmodule:: displayio -//| -//| :class:`EPaperDisplay` -- Manage updating an epaper display over a display bus -//| ============================================================================== +//| """Manage updating an epaper display over a display bus //| //| This initializes an epaper display and connects it into CircuitPython. Unlike other //| objects in CircuitPython, EPaperDisplay objects live until `displayio.release_displays()` diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index 649045039e..5ee4ec5a9a 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -39,12 +39,7 @@ #include "supervisor/shared/translate.h" //| class FourWire: -//| """.. currentmodule:: displayio -//| -//| :class:`FourWire` -- Manage updating a display over SPI four wire protocol -//| ========================================================================== -//| -//| Manage updating a display over SPI four wire protocol in the background while Python code runs. +//| """Manage updating a display over SPI four wire protocol in the background while Python code runs. //| It doesn't handle display initialization.""" //| //| def __init__(self, spi_bus: busio.SPI, *, command: microcontroller.Pin, chip_select: microcontroller.Pin, reset: microcontroller.Pin = None, baudrate: int = 24000000, polarity: int = 0, phase: int = 0): diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 36e137dc9b..b6f96883b9 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -36,12 +36,7 @@ #include "supervisor/shared/translate.h" //| class Group: -//| """.. currentmodule:: displayio -//| -//| :class:`Group` -- Group together sprites and subgroups -//| ========================================================================== -//| -//| Manage a group of sprites and groups and how they are inter-related.""" +//| """Manage a group of sprites and groups and how they are inter-related.""" //| //| def __init__(self, *, max_size: int = 4, scale: int = 1, x: int = 0, y: int = 0): //| """Create a Group of a given size and scale. Scale is in one dimension. For example, scale=2 diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c index e2402dc49b..0cfac66720 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/displayio/I2CDisplay.c @@ -39,12 +39,7 @@ #include "supervisor/shared/translate.h" //| class I2CDisplay: -//| """.. currentmodule:: displayio -//| -//| :class:`I2CDisplay` -- Manage updating a display over I2C -//| ========================================================================== -//| -//| Manage updating a display over I2C in the background while Python code runs. +//| """Manage updating a display over I2C in the background while Python code runs. //| It doesn't handle display initialization.""" //| //| def __init__(self, i2c_bus: busio.I2C, *, device_address: int, reset: microcontroller.Pin = None): diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index 95c890c3b9..170873653a 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -34,12 +34,7 @@ #include "shared-bindings/displayio/OnDiskBitmap.h" //| class OnDiskBitmap: -//| """.. currentmodule:: displayio -//| -//| :class:`OnDiskBitmap` -- Loads pixels straight from disk -//| ========================================================================== -//| -//| Loads values straight from disk. This minimizes memory use but can lead to +//| """Loads values straight from disk. This minimizes memory use but can lead to //| much slower pixel load times. These load times may result in frame tearing where only part of //| the image is visible. //| diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 5df11d2b10..871b2b06af 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -43,12 +43,7 @@ //| class Palette: -//| """.. currentmodule:: displayio -//| -//| :class:`Palette` -- Stores a mapping from bitmap pixel palette_indexes to display colors -//| ========================================================================================= -//| -//| Map a pixel palette_index to a full color. Colors are transformed to the display's format internally to +//| """Map a pixel palette_index to a full color. Colors are transformed to the display's format internally to //| save memory.""" //| //| def __init__(self, color_count: int): diff --git a/shared-bindings/displayio/ParallelBus.c b/shared-bindings/displayio/ParallelBus.c index cedcf1de52..eb75ecc038 100644 --- a/shared-bindings/displayio/ParallelBus.c +++ b/shared-bindings/displayio/ParallelBus.c @@ -38,12 +38,7 @@ #include "supervisor/shared/translate.h" //| class ParallelBus: -//| """.. currentmodule:: displayio -//| -//| :class:`ParallelBus` -- Manage updating a display over 8-bit parallel bus -//| ============================================================================== -//| -//| Manage updating a display over 8-bit parallel bus in the background while Python code runs. This +//| """Manage updating a display over 8-bit parallel bus in the background while Python code runs. This //| protocol may be refered to as 8080-I Series Parallel Interface in datasheets. It doesn't handle //| display initialization.""" //| diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index 0f22bb2a3e..fce89c7716 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -35,12 +35,7 @@ #include "supervisor/shared/translate.h" //| class Shape: -//| """.. currentmodule:: displayio -//| -//| :class:`Shape` -- Represents a shape by defining its bounds on each row -//| ========================================================================== -//| -//| Represents any shape made by defining boundaries that may be mirrored.""" +//| """Represents a shape made by defining boundaries that may be mirrored.""" //| //| def __init__(self, width: int, height: int, *, mirror_x: bool = False, mirror_y: bool = False): //| """Create a Shape object with the given fixed size. Each pixel is one bit and is stored by the diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index e7410e4b67..01fba46a58 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -41,10 +41,7 @@ #include "supervisor/shared/translate.h" //| class TileGrid: -//| """.. currentmodule:: displayio -//| -//| :class:`TileGrid` -- A grid of tiles sourced out of one bitmap -//| ========================================================================== +//| """A grid of tiles sourced out of one bitmap //| //| Position a grid of tiles sourced from a bitmap and pixel_shader combination. Multiple grids //| can share bitmaps and pixel shaders. diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index 37c0253292..b791336b56 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -43,33 +43,10 @@ #include "shared-bindings/displayio/Shape.h" #include "shared-bindings/displayio/TileGrid.h" -//| """:mod:`displayio` --- Native display driving -//| ========================================================================= -//| -//| .. module:: displayio -//| :synopsis: Native helpers for driving displays -//| :platform: SAMD21, SAMD51, nRF52 +//| """Native helpers for driving displays //| //| The `displayio` module contains classes to manage display output -//| including synchronizing with refresh rates and partial updating. -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Bitmap -//| ColorConverter -//| Display -//| EPaperDisplay -//| FourWire -//| Group -//| I2CDisplay -//| OnDiskBitmap -//| Palette -//| ParallelBus -//| Shape -//| TileGrid""" +//| including synchronizing with refresh rates and partial updating.""" //| diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index f60c9e36c7..bf9a658739 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -37,12 +37,7 @@ #include "supervisor/shared/translate.h" //| class BuiltinFont: -//| """.. currentmodule:: fontio -//| -//| :class:`BuiltinFont` -- A font built into CircuitPython -//| ========================================================================================= -//| -//| A font built into CircuitPython.""" +//| """A font built into CircuitPython""" //| //| def __init__(self, ): //| """Creation not supported. Available fonts are defined when CircuitPython is built. See the diff --git a/shared-bindings/fontio/Glyph.c b/shared-bindings/fontio/Glyph.c index 6235dbc46f..6558e2e7a1 100644 --- a/shared-bindings/fontio/Glyph.c +++ b/shared-bindings/fontio/Glyph.c @@ -29,22 +29,27 @@ #include //| class Glyph: -//| """.. currentmodule:: fontio +//| """Storage of glyph info""" //| -//| :class:`Glyph` -- Storage of glyph info -//| ==========================================================================""" -//| -//| def __init__(self, bitmap: displayio.Bitmap, tile_index: int, width: int, height: int, dx: int, dy: int, shift_x: int, shift_y: int): +//| def __init__(self, +//| bitmap: displayio.Bitmap, +//| tile_index: int, +//| width: int, +//| height: int, +//| dx: int, +//| dy: int, +//| shift_x: int, +//| shift_y: int): //| """Named tuple used to capture a single glyph and its attributes. //| -//| :param displayio.Bitmap bitmap: the bitmap including the glyph -//| :param int tile_index: the tile index within the bitmap -//| :param int width: the width of the glyph's bitmap -//| :param int height: the height of the glyph's bitmap -//| :param int dx: x adjustment to the bitmap's position -//| :param int dy: y adjustment to the bitmap's position -//| :param int shift_x: the x difference to the next glyph -//| :param int shift_y: the y difference to the next glyph""" +//| :param bitmap: the bitmap including the glyph +//| :param tile_index: the tile index within the bitmap +//| :param width: the width of the glyph's bitmap +//| :param height: the height of the glyph's bitmap +//| :param dx: x adjustment to the bitmap's position +//| :param dy: y adjustment to the bitmap's position +//| :param shift_x: the x difference to the next glyph +//| :param shift_y: the y difference to the next glyph""" //| ... //| const mp_obj_namedtuple_type_t fontio_glyph_type = { diff --git a/shared-bindings/fontio/__init__.c b/shared-bindings/fontio/__init__.c index 478fc18068..f376f35035 100644 --- a/shared-bindings/fontio/__init__.c +++ b/shared-bindings/fontio/__init__.c @@ -33,22 +33,7 @@ #include "shared-bindings/fontio/BuiltinFont.h" #include "shared-bindings/fontio/Glyph.h" -//| """:mod:`fontio` --- Core font related data structures -//| ========================================================================= -//| -//| .. module:: fontio -//| :synopsis: Core font related data structures -//| :platform: SAMD21, SAMD51, nRF52 -//| -//| The `fontio` module contains classes to store font related information. -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| BuiltinFont -//| Glyph""" +//| """Core font related data structures""" //| STATIC const mp_rom_map_elem_t fontio_module_globals_table[] = { diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index 5e63b988e3..51ef090599 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -41,10 +41,7 @@ #include "supervisor/shared/translate.h" //| class FramebufferDisplay: -//| """.. currentmodule:: framebufferio -//| -//| :class:`FramebufferDisplay` -- Manage updating a display with framebuffer in RAM -//| ================================================================================ +//| """Manage updating a display with framebuffer in RAM //| //| This initializes a display and connects it into CircuitPython. Unlike other //| objects in CircuitPython, Display objects live until `displayio.release_displays()` diff --git a/shared-bindings/framebufferio/__init__.c b/shared-bindings/framebufferio/__init__.c index 50725c5150..492423464a 100644 --- a/shared-bindings/framebufferio/__init__.c +++ b/shared-bindings/framebufferio/__init__.c @@ -28,25 +28,13 @@ #include "shared-bindings/framebufferio/__init__.h" #include "shared-bindings/framebufferio/FramebufferDisplay.h" -//| """:mod:`framebufferio` --- Native framebuffer display driving -//| ========================================================================= -//| -//| .. module:: framebufferio -//| :synopsis: Native helpers for driving displays -//| :platform: SAMD51, nRF52 +//| """Native framebuffer display driving //| //| The `framebufferio` module contains classes to manage display output //| including synchronizing with refresh rates and partial updating. //| It is used in conjunction with classes from `displayio` to actually //| place items on the display; and classes like `RGBMatrix` to actually -//| drive the display. -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| FramebufferDisplay""" +//| drive the display.""" //| #if CIRCUITPY_FRAMEBUFFERIO diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index 270fa87c31..2d628088b7 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -36,10 +36,7 @@ #include "supervisor/shared/translate.h" //| class FrequencyIn: -//| """.. currentmodule:: frequencyio -//| -//| :class:`FrequencyIn` -- Read a frequency signal -//| ======================================================== +//| """Read a frequency signal //| //| FrequencyIn is used to measure the frequency, in hertz, of a digital signal //| on an incoming pin. Accuracy has shown to be within 10%, if not better. It diff --git a/shared-bindings/frequencyio/__init__.c b/shared-bindings/frequencyio/__init__.c index 219d5f6452..031004d4b4 100644 --- a/shared-bindings/frequencyio/__init__.c +++ b/shared-bindings/frequencyio/__init__.c @@ -33,23 +33,8 @@ #include "shared-bindings/frequencyio/__init__.h" #include "shared-bindings/frequencyio/FrequencyIn.h" -//| """:mod:`frequencyio` --- Support for frequency based protocols -//| ============================================================= +//| """Support for frequency based protocols //| -//| .. module:: frequencyio -//| :synopsis: Support for frequency based protocols -//| :platform: SAMD51 -//| -//| The `frequencyio` module contains classes to provide access to basic frequency IO. -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| FrequencyIn -//| - //| .. warning:: This module is not available in SAMD21 builds. See the //| :ref:`module-support-matrix` for more info. //| diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index 946a24dbff..a750892fef 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -35,10 +35,7 @@ #include "supervisor/shared/translate.h" //| class GamePad: -//| """.. currentmodule:: gamepad -//| -//| :class:`GamePad` -- Scan buttons for presses -//| ============================================ +//| """Scan buttons for presses //| //| Usage:: //| @@ -90,7 +87,7 @@ //| on delays. //| //| They button presses are accumulated, until the ``get_pressed`` method -//| is called, at which point the button state is cleared, and the new +//| is called, at which point the button state is cleared, and the new //| button presses start to be recorded.""" //| ... //| diff --git a/shared-bindings/gamepad/__init__.c b/shared-bindings/gamepad/__init__.c index 0c32fd6c1c..557777f50b 100644 --- a/shared-bindings/gamepad/__init__.c +++ b/shared-bindings/gamepad/__init__.c @@ -29,17 +29,7 @@ #include "shared-bindings/gamepad/GamePad.h" #include "shared-bindings/util.h" -//| """:mod:`gamepad` --- Button handling -//| ================================== -//| -//| .. module:: gamepad -//| :synopsis: Button handling -//| :platform: SAMD21 -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| GamePad""" +//| """Button handling in the background""" //| STATIC const mp_rom_map_elem_t gamepad_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gamepad) }, diff --git a/shared-bindings/gamepadshift/GamePadShift.c b/shared-bindings/gamepadshift/GamePadShift.c index 37be3d9576..48b579457d 100644 --- a/shared-bindings/gamepadshift/GamePadShift.c +++ b/shared-bindings/gamepadshift/GamePadShift.c @@ -33,10 +33,7 @@ #include "supervisor/shared/translate.h" //| class GamePadShift: -//| """.. currentmodule:: gamepadshift -//| -//| :class:`GamePadShift` -- Scan buttons for presses through a shift register -//| ===========================================================================""" +//| """Scan buttons for presses through a shift register""" //| //| def __init__(self, clock: Any, data: Any, latch: Any): //| """Initializes button scanning routines. diff --git a/shared-bindings/gamepadshift/__init__.c b/shared-bindings/gamepadshift/__init__.c index 3763b04877..f171358930 100644 --- a/shared-bindings/gamepadshift/__init__.c +++ b/shared-bindings/gamepadshift/__init__.c @@ -30,17 +30,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/util.h" -//| """:mod:`gamepadshift` --- Tracks button presses read through a shift register -//| =========================================================================== -//| -//| .. module:: gamepadshift -//| :synopsis: Tracks button presses read through a shift register -//| :platform: SAMD21, SAMD51 -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| GamePadShift""" +//| """Tracks button presses read through a shift register""" //| STATIC const mp_rom_map_elem_t gamepadshift_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gamepadshift) }, diff --git a/shared-bindings/help.c b/shared-bindings/help.c deleted file mode 100644 index 4e7c3a78bb..0000000000 --- a/shared-bindings/help.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -//| :func:`help` - Built-in method to provide helpful information -//| ============================================================== -//| -//| .. function:: help(object=None) -//| -//| Prints a help method about the given object. When ``object`` is none, -//| prints general port information. -//| diff --git a/shared-bindings/help.rst b/shared-bindings/help.rst new file mode 100644 index 0000000000..63991bff2c --- /dev/null +++ b/shared-bindings/help.rst @@ -0,0 +1,31 @@ +# This file is part of the MicroPython project, http://micropython.org/ +# +# The MIT License (MIT) +# +# Copyright (c) 2016 Scott Shawcroft for Adafruit Industries +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +:func:`help` - Built-in method to provide helpful information +============================================================== + +.. function:: help(object=None) + + Prints a help method about the given object. When ``object`` is none, + prints general port information. diff --git a/shared-bindings/i2cslave/I2CSlave.c b/shared-bindings/i2cslave/I2CSlave.c index 5bab2af74e..80875ce758 100644 --- a/shared-bindings/i2cslave/I2CSlave.c +++ b/shared-bindings/i2cslave/I2CSlave.c @@ -50,10 +50,7 @@ STATIC mp_obj_t mp_obj_new_i2cslave_i2c_slave_request(i2cslave_i2c_slave_obj_t * } //| class I2CSlave: -//| """.. currentmodule:: i2cslave -//| -//| :class:`I2CSlave` --- Two wire serial protocol slave -//| ----------------------------------------------------""" +//| """Two wire serial protocol slave""" //| //| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, addresses: tuple, smbus: bool = False): //| """I2C is a two-wire protocol for communicating between devices. @@ -229,17 +226,15 @@ const mp_obj_type_t i2cslave_i2c_slave_type = { }; //| class I2CSlaveRequest: -//| """:class:`I2CSlaveRequest` --- I2C Slave Request -//| ----------------------------------------------""" //| //| def __init__(self, slave: i2cslave.I2CSlave, address: int, is_read: bool, is_restart: bool): //| """I2C transfer request from a master. //| This cannot be instantiated directly, but is returned by :py:meth:`I2CSlave.request`. //| -//| :param ~i2cslave.I2CSlave slave: The I2C Slave receiving this request -//| :param int address: I2C address -//| :param bool is_read: I2C Master read request -//| :param bool is_restart: Repeated Start Condition""" +//| :param slave: The I2C Slave receiving this request +//| :param address: I2C address +//| :param is_read: I2C Master read request +//| :param is_restart: Repeated Start Condition""" //| STATIC mp_obj_t i2cslave_i2c_slave_request_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 4, 4, false); @@ -264,7 +259,7 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_obj___exit__(size_t n_args, const mp_ } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(i2cslave_i2c_slave_request___exit___obj, 4, 4, i2cslave_i2c_slave_request_obj___exit__); -//| address: Any = ... +//| address: int = ... //| """The I2C address of the request.""" //| STATIC mp_obj_t i2cslave_i2c_slave_request_get_address(mp_obj_t self_in) { @@ -274,7 +269,7 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_get_address(mp_obj_t self_in) { } MP_DEFINE_CONST_PROP_GET(i2cslave_i2c_slave_request_address_obj, i2cslave_i2c_slave_request_get_address); -//| is_read: Any = ... +//| is_read: bool = ... //| """The I2C master is reading from the device.""" //| STATIC mp_obj_t i2cslave_i2c_slave_request_get_is_read(mp_obj_t self_in) { @@ -284,7 +279,7 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_get_is_read(mp_obj_t self_in) { } MP_DEFINE_CONST_PROP_GET(i2cslave_i2c_slave_request_is_read_obj, i2cslave_i2c_slave_request_get_is_read); -//| is_restart: Any = ... +//| is_restart: bool = ... //| """Is Repeated Start Condition.""" //| STATIC mp_obj_t i2cslave_i2c_slave_request_get_is_restart(mp_obj_t self_in) { @@ -294,14 +289,13 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_get_is_restart(mp_obj_t self_in) { } MP_DEFINE_CONST_PROP_GET(i2cslave_i2c_slave_request_is_restart_obj, i2cslave_i2c_slave_request_get_is_restart); -//| def read(self, n: int = -1, ack: bool = True) -> Any: +//| def read(self, n: int = -1, ack: bool = True) -> bytearray: //| """Read data. //| If ack=False, the caller is responsible for calling :py:meth:`I2CSlaveRequest.ack`. //| -//| :param int n: Number of bytes to read (negative means all) -//| :param bool ack: Whether or not to send an ACK after the n'th byte -//| :return: Bytes read -//| :rtype: bytearray""" +//| :param n: Number of bytes to read (negative means all) +//| :param ack: Whether or not to send an ACK after the n'th byte +//| :return: Bytes read""" //| ... //| STATIC mp_obj_t i2cslave_i2c_slave_request_read(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -355,10 +349,10 @@ STATIC mp_obj_t i2cslave_i2c_slave_request_read(size_t n_args, const mp_obj_t *p } MP_DEFINE_CONST_FUN_OBJ_KW(i2cslave_i2c_slave_request_read_obj, 1, i2cslave_i2c_slave_request_read); -//| def write(self, buffer: bytearray) -> Any: +//| def write(self, buffer: bytearray) -> int: //| """Write the data contained in buffer. //| -//| :param bytearray buffer: Write out the data in this buffer +//| :param buffer: Write out the data in this buffer //| :return: Number of bytes written""" //| ... //| @@ -393,7 +387,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(i2cslave_i2c_slave_request_write_obj, i2cslave_ //| """Acknowledge or Not Acknowledge last byte received. //| Use together with :py:meth:`I2CSlaveRequest.read` ack=False. //| -//| :param bool ack: Whether to send an ACK or NACK""" +//| :param ack: Whether to send an ACK or NACK""" //| ... //| STATIC mp_obj_t i2cslave_i2c_slave_request_ack(uint n_args, const mp_obj_t *args) { diff --git a/shared-bindings/i2cslave/__init__.c b/shared-bindings/i2cslave/__init__.c index ffeb216fae..41b42fef83 100644 --- a/shared-bindings/i2cslave/__init__.c +++ b/shared-bindings/i2cslave/__init__.c @@ -35,22 +35,10 @@ #include "py/runtime.h" -//| """:mod:`i2cslave` --- Two wire serial protocol slave -//| ================================================== -//| -//| .. module:: i2cslave -//| :synopsis: Two wire serial protocol slave -//| :platform: SAMD21, SAMD51 +//| """Two wire serial protocol slave //| //| The `i2cslave` module contains classes to support a I2C slave. //| -//| Classes -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| I2CSlave -//| //| Example emulating 2 devices:: //| //| import board diff --git a/shared-bindings/index.rst b/shared-bindings/index.rst index cbffdb6140..d941773943 100644 --- a/shared-bindings/index.rst +++ b/shared-bindings/index.rst @@ -7,13 +7,17 @@ present or if flash space is limited. For example, a microcontroller without analog features will not have `analogio`. See the `support_matrix` page for a list of modules supported on each board. +.. toctree:: + :hidden: + + support_matrix + Modules --------- .. toctree:: :glob: - :maxdepth: 3 + :maxdepth: 2 - support_matrix - */__init__ + ../autoapi/*/index help diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index 755bf75897..56155306ff 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -38,12 +38,7 @@ #define MP_PI MICROPY_FLOAT_CONST(3.14159265358979323846) -//| """:mod:`math` --- mathematical functions -//| ======================================================== -//| -//| .. module:: math -//| :synopsis: mathematical functions -//| :platform: SAMD21/SAMD51 +//| """mathematical functions //| //| The `math` module provides some basic mathematical functions for //| working with floating-point numbers.""" diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index cad0d67b1d..765e602e5f 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -34,12 +34,7 @@ #include "supervisor/shared/translate.h" //| class Pin: -//| """.. currentmodule:: microcontroller -//| -//| :class:`Pin` --- Pin reference -//| ------------------------------------------ -//| -//| Identifies an IO pin on the microcontroller.""" +//| """Identifies an IO pin on the microcontroller.""" //| //| def __init__(self, ): //| """Identifies an IO pin on the microcontroller. They are fixed by the diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index dedb5a27c2..c4b2491247 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -35,12 +35,7 @@ #include "py/runtime.h" //| class Processor: -//| """.. currentmodule:: microcontroller -//| -//| :class:`Processor` --- Microcontroller CPU information and control -//| ------------------------------------------------------------------ -//| -//| Get information about the microcontroller CPU and control it. +//| """Microcontroller CPU information and control //| //| Usage:: //| @@ -55,8 +50,8 @@ //| ... //| -//| frequency: Any = ... -//| """The CPU operating frequency as an `int`, in Hertz. (read-only)""" +//| frequency: int = ... +//| """The CPU operating frequency in Hertz. (read-only)""" //| STATIC mp_obj_t mcu_processor_get_frequency(mp_obj_t self) { return mp_obj_new_int_from_uint(common_hal_mcu_processor_get_frequency()); diff --git a/shared-bindings/microcontroller/RunMode.c b/shared-bindings/microcontroller/RunMode.c index df3ff41868..6db315d8d9 100644 --- a/shared-bindings/microcontroller/RunMode.c +++ b/shared-bindings/microcontroller/RunMode.c @@ -27,10 +27,7 @@ #include "shared-bindings/microcontroller/RunMode.h" //| class RunMode: -//| """.. currentmodule:: microcontroller -//| -//| :class:`RunMode` -- run state of the microcontroller -//| =============================================================""" +//| """run state of the microcontroller""" //| //| def __init__(self, ): //| """Enum-like class to define the run mode of the microcontroller and diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 75b7639808..21e1c90a92 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -42,27 +42,13 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//| """:mod:`microcontroller` --- Pin references and cpu functionality -//| ================================================================ -//| -//| .. module:: microcontroller -//| :synopsis: Pin references and core functionality -//| :platform: SAMD21, ESP8266 +//| """Pin references and cpu functionality //| //| The `microcontroller` module defines the pins from the perspective of the -//| microcontroller. See `board` for board-specific pin mappings. -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Pin -//| Processor -//| RunMode""" +//| microcontroller. See `board` for board-specific pin mappings.""" //| -//| cpu: Any = ... +//| cpu: Processor = ... //| """CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency`` //| (clock frequency). //| This object is the sole instance of `microcontroller.Processor`.""" diff --git a/shared-bindings/multiterminal/__init__.c b/shared-bindings/multiterminal/__init__.c index 3a40650191..baf2fb6749 100644 --- a/shared-bindings/multiterminal/__init__.c +++ b/shared-bindings/multiterminal/__init__.c @@ -30,12 +30,7 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" -//| """:mod:`multiterminal` --- Manage additional terminal sources -//| =========================================================== -//| -//| .. module:: multiterminal -//| :synopsis: Manage additional terminal sources -//| :platform: ESP8266 +//| """Manage additional terminal sources //| //| The `multiterminal` module allows you to configure an additional serial //| terminal source. Incoming characters are accepted from both the internal diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index f18c7fdfd1..5e5bc31eb7 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -31,12 +31,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "supervisor/shared/translate.h" -//| """:mod:`neopixel_write` --- Low-level neopixel implementation -//| =========================================================== -//| -//| .. module:: neopixel_write -//| :synopsis: Low-level neopixel implementation -//| :platform: SAMD21 +//| """Low-level neopixel implementation //| //| The `neopixel_write` module contains a helper method to write out bytes in //| the 800khz neopixel protocol. @@ -55,11 +50,11 @@ //| pixel_off = bytearray([0, 0, 0]) //| neopixel_write.neopixel_write(pin, pixel_off)""" //| -//| def neopixel_write(digitalinout: digitalio.DigitalInOut, buf: bytearray) -> Any: +//| def neopixel_write(digitalinout: digitalio.DigitalInOut, buf: bytearray) -> None: //| """Write buf out on the given DigitalInOut. //| -//| :param ~digitalio.DigitalInOut digitalinout: the DigitalInOut to output with -//| :param bytearray buf: The bytes to clock out. No assumption is made about color order""" +//| :param digitalinout: the DigitalInOut to output with +//| :param buf: The bytes to clock out. No assumption is made about color order""" //| ... STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj_t buf) { if (!MP_OBJ_IS_TYPE(digitalinout_obj, &digitalio_digitalinout_type)) { diff --git a/shared-bindings/network/__init__.c b/shared-bindings/network/__init__.c index 4f03781cf4..6af86688eb 100644 --- a/shared-bindings/network/__init__.c +++ b/shared-bindings/network/__init__.c @@ -38,12 +38,7 @@ #if CIRCUITPY_NETWORK -//| """:mod:`network` --- Network Interface Management -//| =============================================== -//| -//| .. module:: network -//| :synopsis: Network Interface Management -//| :platform: SAMD +//| """Network Interface Management //| //| This module provides a registry of configured NICs. //| It is used by the 'socket' module to look up a suitable diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index a28c2c4f9a..326f719a83 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -31,14 +31,8 @@ #include "shared-bindings/nvm/ByteArray.h" #include "supervisor/shared/translate.h" - - - //| class ByteArray: -//| """.. currentmodule:: nvm -//| -//| :class:`ByteArray` -- Presents a stretch of non-volatile memory as a bytearray. -//| ================================================================================ +//| """Presents a stretch of non-volatile memory as a bytearray. //| //| Non-volatile memory is available as a byte array that persists over reloads //| and power cycles. Each assignment causes an erase and write cycle so its recommended to assign diff --git a/shared-bindings/nvm/__init__.c b/shared-bindings/nvm/__init__.c index 3bd9a309b5..51c5bb2789 100644 --- a/shared-bindings/nvm/__init__.c +++ b/shared-bindings/nvm/__init__.c @@ -31,23 +31,10 @@ #include "shared-bindings/nvm/__init__.h" #include "shared-bindings/nvm/ByteArray.h" -//| """:mod:`nvm` --- Non-volatile memory -//| =========================================================== -//| -//| .. module:: nvm -//| :synopsis: Non-volatile memory -//| :platform: SAMD21 +//| """Non-volatile memory //| //| The `nvm` module allows you to store whatever raw bytes you wish in a -//| reserved section non-volatile memory. -//| - -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| ByteArray""" +//| reserved section non-volatile memory.""" //| STATIC const mp_rom_map_elem_t nvm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_nvm) }, diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index 2a6b13c9b0..4e991d089d 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -37,12 +37,7 @@ #include "py/runtime.h" #include "shared-bindings/os/__init__.h" -//| """:mod:`os` --- functions that an OS normally provides -//| ======================================================== -//| -//| .. module:: os -//| :synopsis: functions that an OS normally provides -//| :platform: SAMD21 +//| """functions that an OS normally provides //| //| The `os` module is a strict subset of the CPython `cpython:os` module. So, //| code written in CircuitPython will work in CPython but not necessarily the diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index d327d41801..a87b14ddd7 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -37,10 +37,7 @@ #include "supervisor/shared/translate.h" //| class Ps2: -//| """.. currentmodule:: ps2io -//| -//| :class:`Ps2` -- Communicate with a PS/2 keyboard or mouse -//| ========================================================= +//| """Communicate with a PS/2 keyboard or mouse //| //| Ps2 implements the PS/2 keyboard/mouse serial protocol, used in //| legacy devices. It is similar to UART but there are only two diff --git a/shared-bindings/ps2io/__init__.c b/shared-bindings/ps2io/__init__.c index 081127bac4..38a70b1a27 100644 --- a/shared-bindings/ps2io/__init__.c +++ b/shared-bindings/ps2io/__init__.c @@ -33,22 +33,10 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/ps2io/Ps2.h" -//| """:mod:`ps2io` --- Support for PS/2 protocol -//| ===================================================== -//| -//| .. module:: ps2io -//| :synopsis: Support for PS/2 based devices -//| :platform: SAMD21 +//| """Support for PS/2 protocol //| //| The `ps2io` module contains classes to provide PS/2 communication. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Ps2 -//| //| .. warning:: This module is not available in some SAMD21 builds. See the //| :ref:`module-support-matrix` for more info. diff --git a/shared-bindings/pulseio/PWMOut.c b/shared-bindings/pulseio/PWMOut.c index 3a25d69380..7970c02f34 100644 --- a/shared-bindings/pulseio/PWMOut.c +++ b/shared-bindings/pulseio/PWMOut.c @@ -36,12 +36,7 @@ #include "supervisor/shared/translate.h" //| class PWMOut: -//| """.. currentmodule:: pulseio -//| -//| :class:`PWMOut` -- Output a Pulse Width Modulated signal -//| ======================================================== -//| -//| PWMOut can be used to output a PWM signal on a given pin.""" +//| """Output a Pulse Width Modulated signal on a given pin.""" //| //| def __init__(self, pin: microcontroller.Pin, *, duty_cycle: int = 0, frequency: int = 500, variable_frequency: bool = False): //| """Create a PWM object associated with the given pin. This allows you to diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 9024f53e3b..5c52b25822 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -36,15 +36,9 @@ #include "supervisor/shared/translate.h" //| class PulseIn: -//| """.. currentmodule:: pulseio -//| -//| :class:`PulseIn` -- Read a series of pulse durations -//| ======================================================== -//| -//| PulseIn is used to measure a series of active and idle pulses. This is -//| commonly used in infrared receivers and low cost temperature sensors (DHT). -//| The pulsed signal consists of timed active and idle periods. Unlike PWM, -//| there is no set duration for active and idle pairs.""" +//| """Measure a series of active and idle pulses. This is commonly used in infrared receivers +//| and low cost temperature sensors (DHT). The pulsed signal consists of timed active and +//| idle periods. Unlike PWM, there is no set duration for active and idle pairs.""" //| //| def __init__(self, pin: microcontroller.Pin, maxlen: int = 2, *, idle_state: bool = False): //| """Create a PulseIn object associated with the given pin. The object acts as diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index 9c650731bb..16b0a6f0cc 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -37,14 +37,9 @@ #include "supervisor/shared/translate.h" //| class PulseOut: -//| """.. currentmodule:: pulseio -//| -//| :class:`PulseOut` -- Output a pulse train -//| ======================================================== -//| -//| PulseOut is used to pulse PWM "carrier" output on and off. This is commonly -//| used in infrared remotes. The pulsed signal consists of timed on and off -//| periods. Unlike PWM, there is no set duration for on and off pairs.""" +//| """Pulse PWM "carrier" output on and off. This is commonly used in infrared remotes. The +//| pulsed signal consists of timed on and off periods. Unlike PWM, there is no set duration +//| for on and off pairs.""" //| //| def __init__(self, carrier: pulseio.PWMOut): //| """Create a PulseOut object associated with the given PWMout object. @@ -115,7 +110,7 @@ STATIC mp_obj_t pulseio_pulseout_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulseout___exit___obj, 4, 4, pulseio_pulseout_obj___exit__); -//| def send(self, pulses: array.array) -> Any: +//| def send(self, pulses: array.array) -> Any: //| """Pulse alternating on and off durations in microseconds starting with on. //| ``pulses`` must be an `array.array` with data type 'H' for unsigned //| halfword (two bytes). diff --git a/shared-bindings/pulseio/__init__.c b/shared-bindings/pulseio/__init__.c index 70cb61fc30..87946e5f0b 100644 --- a/shared-bindings/pulseio/__init__.c +++ b/shared-bindings/pulseio/__init__.c @@ -35,24 +35,10 @@ #include "shared-bindings/pulseio/PulseOut.h" #include "shared-bindings/pulseio/PWMOut.h" -//| """:mod:`pulseio` --- Support for pulse based protocols -//| ===================================================== -//| -//| .. module:: pulseio -//| :synopsis: Support for pulse based protocols -//| :platform: SAMD21, ESP8266 +//| """Support for pulse based protocols //| //| The `pulseio` module contains classes to provide access to basic pulse IO. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| PulseIn -//| PulseOut -//| PWMOut -//| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index d8b266be00..c0124df417 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -33,12 +33,7 @@ #include "shared-bindings/random/__init__.h" #include "supervisor/shared/translate.h" -//| """:mod:`random` --- pseudo-random numbers and choices -//| ======================================================== -//| -//| .. module:: random -//| :synopsis: pseudo-random numbers and choices -//| :platform: SAMD21, ESP8266 +//| """pseudo-random numbers and choices //| //| The `random` module is a strict subset of the CPython `cpython:random` //| module. So, code written in CircuitPython will work in CPython but not diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index e2393eb61d..cbf570958a 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -39,10 +39,7 @@ #include "shared-module/framebufferio/FramebufferDisplay.h" //| class RGBMatrix: -//| """.. currentmodule:: rgbmatrix -//| -//| :class:`RGBMatrix` -- Driver for HUB75-style RGB LED matrices -//| ================================================================ +//| """Displays an in-memory framebuffer to a HUB75-style RGB LED matrix.""" //| extern Protomatter_core *_PM_protoPtr; @@ -134,9 +131,6 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ } } - -//| :class:`~rgbmatrix.RGBMatrix` displays an in-memory framebuffer to an LED matrix.""" -//| //| def __init__(self, *, width: Any, bit_depth: Any, rgb_pins: Any, addr_pins: Any, clock_pin: Any, latch_pin: Any, output_enable_pin: Any, doublebuffer: Any = True, framebuffer: Any = None, height: Any = 0): //| """Create a RGBMatrix object with the given attributes. The height of //| the display is determined by the number of rgb and address pins: @@ -297,7 +291,7 @@ const mp_obj_property_t rgbmatrix_rgbmatrix_brightness_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def refresh(self, ) -> Any: ... +//| def refresh(self) -> Any: ... //| """Transmits the color data in the buffer to the pixels so that //| they are shown.""" //| @@ -309,7 +303,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_refresh(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rgbmatrix_rgbmatrix_refresh_obj, rgbmatrix_rgbmatrix_refresh); -//| width: Any = ... +//| width: int = ... //| """The width of the display, in pixels""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_get_width(mp_obj_t self_in) { @@ -325,7 +319,7 @@ const mp_obj_property_t rgbmatrix_rgbmatrix_width_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| height: Any = ... +//| height: int = ... //| """The height of the display, in pixels""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_get_height(mp_obj_t self_in) { diff --git a/shared-bindings/rgbmatrix/__init__.c b/shared-bindings/rgbmatrix/__init__.c index f61002a780..7f0576652a 100644 --- a/shared-bindings/rgbmatrix/__init__.c +++ b/shared-bindings/rgbmatrix/__init__.c @@ -31,16 +31,7 @@ #include "shared-bindings/rgbmatrix/RGBMatrix.h" -//| """:mod:`rgbmatrix` --- Low-level routines for bitbanged LED matrices -//| ===================================================================== -//| -//| .. module:: rgbmatrix -//| :synopsis: Low-level routines for bitbanged LED matrices -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| RGBMatrix""" +//| """Low-level routines for bitbanged LED matrices""" //| STATIC const mp_rom_map_elem_t rgbmatrix_module_globals_table[] = { diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index a10fb6fd5f..8b27238668 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -35,12 +35,7 @@ #include "shared-bindings/util.h" //| class IncrementalEncoder: -//| """.. currentmodule:: rotaryio -//| -//| :class:`IncrementalEncoder` -- Track the relative position of an incremental encoder -//| ==================================================================================== -//| -//| IncrementalEncoder determines the relative rotational position based on two series of pulses.""" +//| """IncrementalEncoder determines the relative rotational position based on two series of pulses.""" //| //| def __init__(self, pin_a: microcontroller.Pin, pin_b: microcontroller.Pin): //| """Create an IncrementalEncoder object associated with the given pins. It tracks the positional diff --git a/shared-bindings/rotaryio/__init__.c b/shared-bindings/rotaryio/__init__.c index 0cc8eb5560..0fa457ca73 100644 --- a/shared-bindings/rotaryio/__init__.c +++ b/shared-bindings/rotaryio/__init__.c @@ -33,27 +33,13 @@ #include "shared-bindings/rotaryio/__init__.h" #include "shared-bindings/rotaryio/IncrementalEncoder.h" -//| """:mod:`rotaryio` --- Support for reading rotation sensors -//| ======================================================== -//| -//| .. module:: rotaryio -//| :synopsis: Support for reading rotation sensors -//| :platform: SAMD +//| """Support for reading rotation sensors //| //| The `rotaryio` module contains classes to read different rotation encoding schemes. See //| `Wikipedia's Rotary Encoder page `_ for more //| background. -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| IncrementalEncoder -//| -//| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the -//| :ref:`module-support-matrix` for more info. +//| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the :ref:`module-support-matrix` for more info. //| //| All classes change hardware state and should be deinitialized when they diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index 663f5be6cb..58fe308f53 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -38,15 +38,8 @@ const rtc_rtc_obj_t rtc_rtc_obj = {{&rtc_rtc_type}}; - - - - //| class RTC: -//| """.. currentmodule:: rtc -//| -//| :class:`RTC` --- Real Time Clock -//| --------------------------------""" +//| """Real Time Clock""" //| //| def __init__(self, ): //| """This class represents the onboard Real Time Clock. It is a singleton and will always return the same instance.""" @@ -60,7 +53,7 @@ STATIC mp_obj_t rtc_rtc_make_new(const mp_obj_type_t *type, size_t n_args, const return (mp_obj_t)&rtc_rtc_obj; } -//| datetime: Any = ... +//| datetime: time.struct_time = ... //| """The current date and time of the RTC as a `time.struct_time`. //| //| This must be set to the current date and time whenever the board loses power:: @@ -101,7 +94,7 @@ const mp_obj_property_t rtc_rtc_datetime_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| calibration: Any = ... +//| calibration: int = ... //| """The RTC calibration value as an `int`. //| //| A positive value speeds up the clock and a negative value slows it down. diff --git a/shared-bindings/rtc/__init__.c b/shared-bindings/rtc/__init__.c index 66669ca5fe..b204d511c9 100644 --- a/shared-bindings/rtc/__init__.c +++ b/shared-bindings/rtc/__init__.c @@ -31,23 +31,11 @@ #include "shared-bindings/rtc/RTC.h" #include "shared-bindings/time/__init__.h" -//| """:mod:`rtc` --- Real Time Clock -//| ======================================================== -//| -//| .. module:: rtc -//| :synopsis: Real Time Clock -//| :platform: SAMD21, SAMD51, nRF52 +//| """Real Time Clock //| //| The `rtc` module provides support for a Real Time Clock. You can access and manage the //| RTC using :class:`rtc.RTC`. It also backs the :func:`time.time` and :func:`time.localtime` -//| functions using the onboard RTC if present. -//| -//| Classes -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| RTC""" +//| functions using the onboard RTC if present.""" //| void rtc_reset(void) { diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c index 4c0811bdb6..19c4850cde 100644 --- a/shared-bindings/socket/__init__.c +++ b/shared-bindings/socket/__init__.c @@ -37,12 +37,7 @@ #include "shared-module/network/__init__.h" -//| """:mod:`socket` --- TCP, UDP and RAW socket support -//| ================================================= -//| -//| .. module:: socket -//| :synopsis: TCP, UDP and RAW sockets -//| :platform: SAMD21, SAMD51 +//| """TCP, UDP and RAW socket support //| //| Create TCP, UDP and RAW sockets for communicating over the Internet.""" //| @@ -50,7 +45,6 @@ STATIC const mp_obj_type_t socket_type; //| class socket: -//| """.. currentmodule:: socket""" //| //| def __init__(self, family: int, type: int, proto: int): //| """Create a new socket diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index feb1a9bd76..8ac08d8c9b 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -35,12 +35,7 @@ #include "shared-bindings/storage/__init__.h" #include "supervisor/shared/translate.h" -//| """:mod:`storage` --- storage management -//| ======================================================== -//| -//| .. module:: storage -//| :synopsis: storage management -//| :platform: SAMD21, SAMD51 +//| """Storage management //| //| The `storage` provides storage management functionality such as mounting and //| unmounting which is typically handled by the operating system hosting Python. diff --git a/shared-bindings/struct/__init__.c b/shared-bindings/struct/__init__.c index 3772f93a76..256b385c8e 100644 --- a/shared-bindings/struct/__init__.c +++ b/shared-bindings/struct/__init__.c @@ -38,12 +38,7 @@ #include "shared-module/struct/__init__.h" #include "supervisor/shared/translate.h" -//| """:mod:`struct` --- manipulation of c-style data -//| ======================================================== -//| -//| .. module:: struct -//| :synopsis: byte data control -//| :platform: SAMD21 +//| """Manipulation of c-style data //| //| This module implements a subset of the corresponding CPython module, //| as described below. For more information, refer to the original CPython @@ -56,7 +51,7 @@ //| -//| def calcsize(fmt: Any) -> Any: +//| def calcsize(fmt: str) -> int: //| """Return the number of bytes needed to store the given fmt.""" //| ... //| diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 05921899ce..a420d5b805 100755 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -30,12 +30,7 @@ //TODO: add USB, REPL to description once they're operational //| class Runtime: -//| """.. currentmodule:: supervisor -//| -//| :class:`Runtime` --- Supervisor Runtime information -//| ---------------------------------------------------- -//| -//| Get current status of runtime objects. +//| """Current status of runtime objects. //| //| Usage:: //| @@ -50,7 +45,7 @@ //| ... //| -//| runtime.serial_connected: Any = ... +//| serial_connected: bool = ... //| """Returns the USB serial communication status (read-only). //| //| .. note:: @@ -78,7 +73,7 @@ const mp_obj_property_t supervisor_serial_connected_obj = { }; -//| runtime.serial_bytes_available: Any = ... +//| serial_bytes_available: int = ... //| """Returns the whether any bytes are available to read //| on the USB serial input. Allows for polling to see whether //| to call the built-in input() or wait. (read-only)""" diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 7fe6668f48..1830308b7d 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -36,30 +36,16 @@ #include "shared-bindings/supervisor/__init__.h" #include "shared-bindings/supervisor/Runtime.h" -//| """:mod:`supervisor` --- Supervisor settings -//| ================================================= -//| -//| .. module:: supervisor -//| :synopsis: Supervisor settings -//| :platform: SAMD21/51 (All), nRF (Runtime only) -//| -//| The `supervisor` module. (TODO: expand description) -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Runtime""" +//| """Supervisor settings""" //| -//| runtime: Any = ... -//| """Runtime information, such as `runtime.serial_connected` +//| runtime: Runtime = ... +//| """Runtime information, such as ``runtime.serial_connected`` //| (USB serial connection status). //| This object is the sole instance of `supervisor.Runtime`.""" //| -//| def enable_autoreload(self, ) -> Any: +//| def enable_autoreload(self) -> None: //| """Enable autoreload based on USB file write activity.""" //| ... //| @@ -69,7 +55,7 @@ STATIC mp_obj_t supervisor_enable_autoreload(void) { } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_enable_autoreload_obj, supervisor_enable_autoreload); -//| def disable_autoreload(self, ) -> Any: +//| def disable_autoreload(self) -> None: //| """Disable autoreload based on USB file write activity until //| `enable_autoreload` is called.""" //| ... @@ -80,7 +66,7 @@ STATIC mp_obj_t supervisor_disable_autoreload(void) { } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_autoreload_obj, supervisor_disable_autoreload); -//| def set_rgb_status_brightness(self, ) -> Any: +//| def set_rgb_status_brightness(self, brightness: int) -> None: //| """Set brightness of status neopixel from 0-255 //| `set_rgb_status_brightness` is called.""" //| ... @@ -96,7 +82,7 @@ STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){ } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_set_rgb_status_brightness); -//| def reload(self, ) -> Any: +//| def reload(self) -> None: //| """Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL).""" //| ... //| @@ -107,7 +93,7 @@ STATIC mp_obj_t supervisor_reload(void) { } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload); -//| def set_next_stack_limit(self, size: Any) -> Any: +//| def set_next_stack_limit(self, size: int) -> None: //| """Set the size of the stack for the next vm run. If its too large, the default will be used.""" //| ... //| diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index 1288b70182..5c045fdee2 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -38,10 +38,7 @@ #include "supervisor/shared/translate.h" //| class Terminal: -//| """.. currentmodule:: terminalio -//| -//| :class:`Terminal` -- display a character stream with a TileGrid -//| ================================================================""" +//| """Display a character stream with a TileGrid""" //| //| def __init__(self, tilegrid: Any, font: Any): //| """Terminal manages tile indices and cursor position based on VT100 commands. The font should be diff --git a/shared-bindings/terminalio/__init__.c b/shared-bindings/terminalio/__init__.c index 591be839ad..5892111395 100644 --- a/shared-bindings/terminalio/__init__.c +++ b/shared-bindings/terminalio/__init__.c @@ -35,22 +35,10 @@ #include "py/runtime.h" -//| """:mod:`terminalio` --- Displays text in a TileGrid -//| ================================================= -//| -//| .. module:: terminalio -//| :synopsis: Displays text in a TileGrid +//| """Displays text in a TileGrid //| //| The `terminalio` module contains classes to display a character stream on a display. The built -//| in font is available as ``terminalio.FONT``. -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Terminal""" -//| +//| in font is available as ``terminalio.FONT``.""" //| STATIC const mp_rom_map_elem_t terminalio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_terminalio) }, diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 36eaa27f63..20277d6b07 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -36,12 +36,7 @@ #include "shared-bindings/time/__init__.h" #include "supervisor/shared/translate.h" -//| """:mod:`time` --- time and timing related functions -//| ======================================================== -//| -//| .. module:: time -//| :synopsis: time and timing related functions -//| :platform: SAMD21 +//| """time and timing related functions //| //| The `time` module is a strict subset of the CPython `cpython:time` module. So, code //| written in MicroPython will work in CPython but not necessarily the other diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index 6d59a17446..4c1d534eaa 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -39,10 +39,7 @@ #include "supervisor/shared/translate.h" //| class TouchIn: -//| """.. currentmodule:: touchio -//| -//| :class:`TouchIn` -- Read the state of a capacitive touch sensor -//| =================================================================== +//| """Read the state of a capacitive touch sensor //| //| Usage:: //| diff --git a/shared-bindings/touchio/__init__.c b/shared-bindings/touchio/__init__.c index 96367f0823..92e067cf68 100644 --- a/shared-bindings/touchio/__init__.c +++ b/shared-bindings/touchio/__init__.c @@ -35,23 +35,11 @@ #include "py/runtime.h" -//| """:mod:`touchio` --- Touch related IO -//| ================================================= -//| -//| .. module:: touchio -//| :synopsis: Hardware accelerated behavior -//| :platform: SAMD21 +//| """Touch related IO //| //| The `touchio` module contains classes to provide access to touch IO typically //| accelerated by hardware on the onboard microcontroller. //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| TouchIn -//| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See diff --git a/shared-bindings/uheap/__init__.c b/shared-bindings/uheap/__init__.c index f1be304247..f089f29221 100644 --- a/shared-bindings/uheap/__init__.c +++ b/shared-bindings/uheap/__init__.c @@ -31,11 +31,7 @@ #include "shared-bindings/uheap/__init__.h" -//| """:mod:`uheap` --- Heap size analysis -//| ================================================================ -//| -//| .. module:: uheap -//| :synopsis: Heap size analysis""" +//| """Heap size analysis""" //| //| def info(object: Any) -> Any: diff --git a/shared-bindings/ulab/__init__.rst b/shared-bindings/ulab/__init__.pyi similarity index 100% rename from shared-bindings/ulab/__init__.rst rename to shared-bindings/ulab/__init__.pyi diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index bcea5b2c55..8c0c364ff3 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -28,10 +28,7 @@ #include "shared-bindings/usb_hid/Device.h" //| class Device: -//| """.. currentmodule:: usb_hid -//| -//| :class:`Device` -- HID Device -//| ============================================ +//| """HID Device //| //| Usage:: //| diff --git a/shared-bindings/usb_hid/__init__.c b/shared-bindings/usb_hid/__init__.c index 3d0978d623..e12ea8da4e 100644 --- a/shared-bindings/usb_hid/__init__.c +++ b/shared-bindings/usb_hid/__init__.c @@ -31,12 +31,7 @@ #include "shared-bindings/usb_hid/__init__.h" #include "shared-bindings/usb_hid/Device.h" -//| """:mod:`usb_hid` --- USB Human Interface Device -//| =========================================================== -//| -//| .. module:: usb_hid -//| :synopsis: USB Human Interface Device -//| :platform: SAMD21 +//| """USB Human Interface Device //| //| The `usb_hid` module allows you to output data as a HID device.""" //| @@ -44,14 +39,6 @@ //| usb_hid.devices: Any = ... //| """Tuple of all active HID device interfaces.""" //| - -//| """Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Device""" -//| STATIC const mp_rom_map_elem_t usb_hid_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid) }, { MP_ROM_QSTR(MP_QSTR_devices), MP_ROM_PTR(&common_hal_usb_hid_devices) }, diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c index 55a5865ca7..9d9310b47a 100644 --- a/shared-bindings/usb_midi/PortIn.c +++ b/shared-bindings/usb_midi/PortIn.c @@ -36,12 +36,9 @@ #include "supervisor/shared/translate.h" //| class PortIn: -//| """.. currentmodule:: usb_midi +//| """Receives midi commands over USB""" //| -//| :class:`PortIn` -- receives midi commands over USB -//| ===================================================""" -//| -//| def __init__(self, ): +//| def __init__(self): //| """You cannot create an instance of `usb_midi.PortIn`. //| //| PortIn objects are constructed for every corresponding entry in the USB diff --git a/shared-bindings/usb_midi/PortOut.c b/shared-bindings/usb_midi/PortOut.c index d83eb53b69..14ed0e767e 100644 --- a/shared-bindings/usb_midi/PortOut.c +++ b/shared-bindings/usb_midi/PortOut.c @@ -36,10 +36,7 @@ #include "supervisor/shared/translate.h" //| class PortOut: -//| """.. currentmodule:: usb_midi -//| -//| :class:`PortOut` -- sends midi messages to a computer over USB -//| ==============================================================""" +//| """Sends midi messages to a computer over USB""" //| //| def __init__(self, ): //| """You cannot create an instance of `usb_midi.PortOut`. diff --git a/shared-bindings/usb_midi/__init__.c b/shared-bindings/usb_midi/__init__.c index 2631d8a882..5570b601ca 100644 --- a/shared-bindings/usb_midi/__init__.c +++ b/shared-bindings/usb_midi/__init__.c @@ -35,22 +35,7 @@ #include "py/runtime.h" -//| """:mod:`usb_midi` --- MIDI over USB -//| ================================================= -//| -//| .. module:: usb_midi -//| :synopsis: MIDI over USB -//| -//| The `usb_midi` module contains classes to transmit and receive MIDI messages over USB -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| PortIn -//| PortOut""" -//| +//| """Classes to transmit and receive MIDI messages over USB""" //| mp_map_elem_t usb_midi_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usb_midi) }, diff --git a/shared-bindings/ustack/__init__.c b/shared-bindings/ustack/__init__.c index 073840abac..e5fac69417 100644 --- a/shared-bindings/ustack/__init__.c +++ b/shared-bindings/ustack/__init__.c @@ -34,15 +34,11 @@ -//| """:mod:`ustack` --- Stack information and analysis -//| ======================================================== -//| -//| .. module:: ustack -//| :synopsis: stack information functions""" +//| """Stack information and analysis""" //| #if MICROPY_MAX_STACK_USAGE -//| def max_stack_usage() -> Any: +//| def max_stack_usage() -> int: //| """Return the maximum excursion of the stack so far.""" //| ... //| @@ -53,7 +49,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(max_stack_usage_obj, max_stack_usage); #endif // MICROPY_MAX_STACK_USAGE -//| def stack_size() -> Any: +//| def stack_size() -> int: //| """Return the size of the entire stack. //| Same as in micropython.mem_info(), but returns a value instead //| of just printing it.""" diff --git a/shared-bindings/wiznet/__init__.c b/shared-bindings/wiznet/__init__.c index 5c8e8d3fd2..0b0b7b14b7 100644 --- a/shared-bindings/wiznet/__init__.c +++ b/shared-bindings/wiznet/__init__.c @@ -35,21 +35,7 @@ #include "shared-module/network/__init__.h" -//| """:mod:`wiznet` --- Support for WizNet hardware -//| ============================================= -//| -//| .. module:: wiznet -//| :synopsis: Support for WizNet hardware -//| :platform: SAMD -//| -//| Support for WizNet hardware, including the WizNet 5500 Ethernet adaptor. -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| wiznet5k""" +//| """Support for WizNet hardware, including the WizNet 5500 Ethernet adaptor.""" //| extern const mod_network_nic_type_t mod_network_nic_type_wiznet5k; diff --git a/shared-bindings/wiznet/wiznet5k.c b/shared-bindings/wiznet/wiznet5k.c index 2e2ee39496..2f49dffea9 100644 --- a/shared-bindings/wiznet/wiznet5k.c +++ b/shared-bindings/wiznet/wiznet5k.c @@ -47,10 +47,7 @@ #include "shared-module/wiznet/wiznet5k.h" //| class WIZNET5K: -//| """.. currentmodule:: wiznet -//| -//| :class:`WIZNET5K` -- wrapper for Wiznet 5500 Ethernet interface -//| ===============================================================""" +//| """Wrapper for Wiznet 5500 Ethernet interface""" //| //| def __init__(self, spi: busio.SPI, cs: microcontroller.Pin, rst: microcontroller.Pin, dhcp: bool = True): //| """Create a new WIZNET5500 interface using the specified pins diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index de783eb270..95370f7619 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -22,7 +22,7 @@ for module in modules: pyi_lines = [] classes = os.listdir(module_path) classes = [x for x in sorted(classes) if x.endswith(".c")] - if classes[-1] == "__init__.c": + if classes and classes[-1] == "__init__.c": classes.insert(0, classes.pop()) for class_file in classes: class_path = os.path.join(module_path, class_file) @@ -37,6 +37,13 @@ for module in modules: continue pyi_lines.append(line) + raw_stubs = [x for x in sorted(classes) if x.endswith(".pyi")] + if raw_stubs and raw_stubs[-1] == "__init__.pyi": + raw_stubs.insert(0, raw_stubs.pop()) + for raw_stub in raw_stubs: + raw_stub_path = os.path.join(module_path, raw_stub) + with open(raw_stub_path, "r") as f: + pyi_lines.extend(f.readlines()) stub_filename = os.path.join(stub_directory, module + ".pyi") print(stub_filename) stub_contents = "".join(pyi_lines) @@ -54,3 +61,6 @@ for module in modules: print() print(f"{ok} ok out of {total}") + +if ok != total: + sys.exit(total - ok) From c816cfed58a6f875f91a3bb8629dd81acf076882 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 12 May 2020 17:37:42 -0700 Subject: [PATCH 096/216] Build stubs before docs --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 057395eeef..7ecdb66ee3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: run: | sudo apt-get install -y eatmydata sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64 - pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml + pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid - name: Versions run: | gcc --version @@ -64,6 +64,8 @@ jobs: - name: mpy Tests run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --via-mpy -d basics float working-directory: tests + - name: Stubs + run: make stubs -j2 - name: Docs run: sphinx-build -E -W -b html . _build/html - name: Translations From 4e646ee6e4473195df3eba4bd7e006e44bfd1cdc Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 12 May 2020 18:40:02 -0700 Subject: [PATCH 097/216] Move vectorio to stubs --- shared-bindings/vectorio/Circle.c | 18 +++++--------- shared-bindings/vectorio/Polygon.c | 23 +++++++----------- shared-bindings/vectorio/Rectangle.c | 14 ++++------- shared-bindings/vectorio/VectorShape.c | 33 +++++++++++--------------- shared-bindings/vectorio/__init__.c | 21 +--------------- 5 files changed, 34 insertions(+), 75 deletions(-) diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 260e80d0fb..6b5682e149 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -9,17 +9,12 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" - -//| .. currentmodule:: vectorio +//| class Circle: //| -//| :class:`Circle` -- Represents a circle by its radius -//| ========================================================================== +//| def __init__(self, radius: int): +//| """Circle is positioned on screen by its center point. //| -//| .. class:: Circle(radius) -//| -//| Circle is positioned on screen by its center point. -//| -//| :param int radius: The radius of the circle in pixels +//| :param radius: The radius of the circle in pixels""" //| static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_radius }; @@ -42,9 +37,8 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg } -//| .. attribute:: radius -//| -//| The radius of the circle in pixels. +//| radius : int = ... +//| """The radius of the circle in pixels.""" //| STATIC mp_obj_t vectorio_circle_obj_get_radius(mp_obj_t self_in) { vectorio_circle_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index b8bb377ac5..5f4d85e211 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -49,17 +49,13 @@ static mp_obj_t _to_points_list(mp_obj_t points_tuple_list) { } return points_list; } - - - -//| .. currentmodule:: vectorio +//| from typing import List, Tuple //| -//| :class:`Polygon` -- Represents a closed shape by ordered vertices -//| ========================================================================== +//| class Polygon: +//| def __init__(self, points: List[ Tuple[ x, y ], ... ] ): +//| """Represents a closed shape by ordered vertices //| -//| .. class:: Polygon( List[ Tuple[ x, y ], ... ] ) -//| -//| :param [Point] points_array: Vertices for the polygon +//| :param points: Vertices for the polygon""" //| static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_points_list }; @@ -83,14 +79,13 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar } -//| .. attribute:: points -//| -//| Set a new look and shape for this polygon +//| points: List[ Tuple[ x, y ], ... ] = ... +//| """Set a new look and shape for this polygon""" //| STATIC mp_obj_t vectorio_polygon_obj_get_points(mp_obj_t self_in) { vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_t list = mp_obj_new_list(0, NULL); - + size_t len = 0; mp_obj_t *items; mp_obj_list_get(common_hal_vectorio_polygon_get_points(self), &len, &items); @@ -123,8 +118,6 @@ const mp_obj_property_t vectorio_polygon_points_obj = { (mp_obj_t)&mp_const_none_obj}, }; - - STATIC const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_points), MP_ROM_PTR(&vectorio_polygon_points_obj) }, }; diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index ea468f7888..f04a25c35a 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -7,16 +7,12 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" - -//| .. currentmodule:: vectorio +//| class Rectangle: +//| def __init__(self, width: int, height: int): +//| """Represents a rectangle by defining its bounds //| -//| :class:`Rectangle` -- Represents a rectangle by defining its bounds -//| ========================================================================== -//| -//| .. class:: Rectangle(width, height) -//| -//| :param int width: The number of pixels wide -//| :param int height: The number of pixels high +//| :param width: The number of pixels wide +//| :param height: The number of pixels high""" //| static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_width, ARG_height }; diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index 4b39ec9960..c512bcd546 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -19,17 +19,15 @@ #include "supervisor/shared/translate.h" -//| .. currentmodule:: vectorio +//| class VectorShape: +//| def __init__(self, shape: vectorio.Polygon, pixel_shader: displayio.Palette, x: int=0, y: int=0): +//| """Binds a vector shape to a location and pixel color //| -//| :class:`VectorShape` -- Binds a vector shape to a location and pixel color -//| ========================================================================== -//| -//| .. class:: VectorShape( shape, pixel_shader, x=0, y=0) -//| -//| :param vectorio.Polygon shape: The shape to draw. -//| :param displayio.Palette pixel_shader: The pixel shader that produces colors from values -//| :param int x: Initial x position of the center axis of the shape within the parent. -//| :param int y: Initial y position of the center axis of the shape within the parent. +//| :param shape: The shape to draw. +//| :param pixel_shader: The pixel shader that produces colors from values +//| :param x: Initial x position of the center axis of the shape within the parent. +//| :param y: Initial y position of the center axis of the shape within the parent.""" +//| ... //| STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_shape, ARG_pixel_shader, ARG_x, ARG_y }; @@ -95,9 +93,8 @@ STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t } -//| .. attribute:: x -//| -//| X position of the center point of the shape in the parent. +//| x: int = ... +//| """X position of the center point of the shape in the parent.""" //| STATIC mp_obj_t vectorio_vector_shape_obj_get_x(mp_obj_t self_in) { vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); @@ -122,9 +119,8 @@ const mp_obj_property_t vectorio_vector_shape_x_obj = { }; -//| .. attribute:: y -//| -//| Y position of the center point of the shape in the parent. +//| y: int = ... +//| """Y position of the center point of the shape in the parent.""" //| STATIC mp_obj_t vectorio_vector_shape_obj_get_y(mp_obj_t self_in) { vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); @@ -149,9 +145,8 @@ const mp_obj_property_t vectorio_vector_shape_y_obj = { }; -//| .. attribute:: pixel_shader -//| -//| The pixel shader of the shape. +//| pixel_shader: displayio.Palette = ... +//| """The pixel shader of the shape.""" //| STATIC mp_obj_t vectorio_vector_shape_obj_get_pixel_shader(mp_obj_t self_in) { vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/vectorio/__init__.c b/shared-bindings/vectorio/__init__.c index b9e3828bdc..c747834263 100644 --- a/shared-bindings/vectorio/__init__.c +++ b/shared-bindings/vectorio/__init__.c @@ -8,27 +8,8 @@ #include "shared-bindings/vectorio/Rectangle.h" #include "shared-bindings/vectorio/VectorShape.h" -//| :mod:`vectorio` --- Lightweight 2d shapes for displays -//| ========================================================================= +//| """Lightweight 2d shapes for displays""" //| -//| .. module:: vectorio -//| :synopsis: Adds vector graphics to displayio -//| :platform: SAMD21, SAMD51, nRF52 -//| -//| The `vectorio` module contains classes to construct shapes -//| by describing their points rather than providing them in bitmaps. -//| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Circle -//| Polygon -//| Rectangle -//| VectorShape -//| - STATIC const mp_rom_map_elem_t vectorio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_vectorio) }, From 80129c5a21fb51e37d0a634b9714911201e74555 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 12 May 2020 18:55:49 -0700 Subject: [PATCH 098/216] Disable countio on trinket haxpress --- ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk index bd6c9c9ff7..e56517b5c7 100644 --- a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk @@ -12,6 +12,7 @@ EXTERNAL_FLASH_DEVICES = W25Q32BV LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 +CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 From 4612270f98988ac4646c5cbf4bebddb35e71f660 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 12 May 2020 19:00:51 -0700 Subject: [PATCH 099/216] Only enable COUNTIO in full builds --- py/circuitpy_mpconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 74ad7a2cc2..0801540bc0 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -88,7 +88,7 @@ CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO) CIRCUITPY_DIGITALIO ?= 1 CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) -CIRCUITPY_COUNTIO ?= 1 +CIRCUITPY_COUNTIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD) From 2efe17bcb76197137287ae4a984b4481ab77be15 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 12 May 2020 19:01:17 -0700 Subject: [PATCH 100/216] Don't build in empty help.c --- py/circuitpy_defns.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index c6ea2b45bb..9913329c2d 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -318,7 +318,6 @@ $(filter $(SRC_PATTERNS), \ ) SRC_BINDINGS_ENUMS += \ - help.c \ util.c SRC_SHARED_MODULE_ALL = \ From fbf052bb2755b2a3afb85b94ea9625ab29da4ab0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 13 May 2020 10:04:19 -0500 Subject: [PATCH 101/216] Gamepad & GamepadShift: Enable ticks while object exists Otherwise, button presses might not be noticed. --- shared-bindings/gamepad/GamePad.c | 4 ++++ shared-bindings/gamepadshift/GamePadShift.c | 4 ++++ shared-module/gamepad/GamePad.c | 2 ++ shared-module/gamepad/__init__.c | 4 ++++ shared-module/gamepadshift/GamePadShift.c | 2 ++ 5 files changed, 16 insertions(+) diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index d3c29019a5..88f072f3eb 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -33,6 +33,7 @@ #include "shared-bindings/gamepad/__init__.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "supervisor/shared/translate.h" +#include "supervisor/shared/tick.h" //| .. currentmodule:: gamepad @@ -108,6 +109,9 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, gamepad_singleton = m_new_obj(gamepad_obj_t); gamepad_singleton->base.type = &gamepad_type; gamepad_singleton = gc_make_long_lived(gamepad_singleton); + if (!MP_STATE_VM(gamepad_singleton)) { + supervisor_enable_tick(); + } MP_STATE_VM(gamepad_singleton) = gamepad_singleton; } common_hal_gamepad_gamepad_init(gamepad_singleton, args, n_args); diff --git a/shared-bindings/gamepadshift/GamePadShift.c b/shared-bindings/gamepadshift/GamePadShift.c index 91203ad20d..76f054aae9 100644 --- a/shared-bindings/gamepadshift/GamePadShift.c +++ b/shared-bindings/gamepadshift/GamePadShift.c @@ -31,6 +31,7 @@ #include "shared-bindings/gamepadshift/GamePadShift.h" #include "shared-bindings/gamepadshift/__init__.h" #include "supervisor/shared/translate.h" +#include "supervisor/shared/tick.h" //| .. currentmodule:: gamepadshift //| @@ -75,6 +76,9 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, gamepad_singleton = m_new_obj(gamepadshift_obj_t); gamepad_singleton->base.type = &gamepadshift_type; gamepad_singleton = gc_make_long_lived(gamepad_singleton); + if (!MP_STATE_VM(gamepad_singleton)) { + supervisor_enable_tick(); + } MP_STATE_VM(gamepad_singleton) = gamepad_singleton; } common_hal_gamepadshift_gamepadshift_init(gamepad_singleton, clock_pin, data_pin, latch_pin); diff --git a/shared-module/gamepad/GamePad.c b/shared-module/gamepad/GamePad.c index fdce0caab4..7b4108eb2e 100644 --- a/shared-module/gamepad/GamePad.c +++ b/shared-module/gamepad/GamePad.c @@ -27,6 +27,7 @@ #include "py/mpstate.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/gamepad/GamePad.h" +#include "supervisor/shared/tick.h" void common_hal_gamepad_gamepad_init(gamepad_obj_t *gamepad, const mp_obj_t pins[], size_t n_pins) { @@ -54,4 +55,5 @@ void common_hal_gamepad_gamepad_init(gamepad_obj_t *gamepad, void common_hal_gamepad_gamepad_deinit(gamepad_obj_t *self) { MP_STATE_VM(gamepad_singleton) = NULL; + supervisor_disable_tick(); } diff --git a/shared-module/gamepad/__init__.c b/shared-module/gamepad/__init__.c index 3e17a0fb5b..9874b27529 100644 --- a/shared-module/gamepad/__init__.c +++ b/shared-module/gamepad/__init__.c @@ -29,6 +29,7 @@ #include "py/mpstate.h" #include "shared-bindings/gamepad/__init__.h" #include "shared-bindings/gamepad/GamePad.h" +#include "supervisor/shared/tick.h" #include "shared-bindings/digitalio/DigitalInOut.h" @@ -59,5 +60,8 @@ void gamepad_tick(void) { } void gamepad_reset(void) { + if (MP_STATE_VM(gamepad_singleton)) { + supervisor_disable_tick(); + } MP_STATE_VM(gamepad_singleton) = NULL; } diff --git a/shared-module/gamepadshift/GamePadShift.c b/shared-module/gamepadshift/GamePadShift.c index b8fb4d3f44..51da617021 100644 --- a/shared-module/gamepadshift/GamePadShift.c +++ b/shared-module/gamepadshift/GamePadShift.c @@ -27,6 +27,7 @@ #include "py/mpstate.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-module/gamepadshift/GamePadShift.h" +#include "supervisor/shared/tick.h" void common_hal_gamepadshift_gamepadshift_init(gamepadshift_obj_t *gamepadshift, digitalio_digitalinout_obj_t *clock_pin, @@ -46,4 +47,5 @@ void common_hal_gamepadshift_gamepadshift_init(gamepadshift_obj_t *gamepadshift, void common_hal_gamepadshift_gamepadshift_deinit(gamepadshift_obj_t *gamepadshift) { MP_STATE_VM(gamepad_singleton) = NULL; + supervisor_disable_tick(); } From 23ba58bbf574d029d5b18e57c40d4257b37dfd7a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 13 May 2020 10:05:48 -0500 Subject: [PATCH 102/216] Gamepad & GamepadShift: Initially allocate as long-lived This makes less heap churn and decreases code size a tiny bit --- shared-bindings/gamepad/GamePad.c | 3 +-- shared-bindings/gamepadshift/GamePadShift.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index 88f072f3eb..d6f91c1c08 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -106,9 +106,8 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, gamepad_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton); if (!gamepad_singleton || !MP_OBJ_IS_TYPE(MP_OBJ_FROM_PTR(gamepad_singleton), &gamepad_type)) { - gamepad_singleton = m_new_obj(gamepad_obj_t); + gamepad_singleton = m_new_ll_obj(gamepad_obj_t); gamepad_singleton->base.type = &gamepad_type; - gamepad_singleton = gc_make_long_lived(gamepad_singleton); if (!MP_STATE_VM(gamepad_singleton)) { supervisor_enable_tick(); } diff --git a/shared-bindings/gamepadshift/GamePadShift.c b/shared-bindings/gamepadshift/GamePadShift.c index 76f054aae9..9586e01ed9 100644 --- a/shared-bindings/gamepadshift/GamePadShift.c +++ b/shared-bindings/gamepadshift/GamePadShift.c @@ -73,9 +73,8 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, if (!gamepad_singleton || !MP_OBJ_IS_TYPE(MP_OBJ_FROM_PTR(gamepad_singleton), &gamepadshift_type)) { - gamepad_singleton = m_new_obj(gamepadshift_obj_t); + gamepad_singleton = m_new_ll_obj(gamepadshift_obj_t); gamepad_singleton->base.type = &gamepadshift_type; - gamepad_singleton = gc_make_long_lived(gamepad_singleton); if (!MP_STATE_VM(gamepad_singleton)) { supervisor_enable_tick(); } From adef45403bc05dfc2bae616003fc90d2f40a3da4 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 13 May 2020 10:29:36 -0500 Subject: [PATCH 103/216] samd: audio dma: enable/disable supervisor tick as needed --- ports/atmel-samd/audio_dma.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/atmel-samd/audio_dma.c b/ports/atmel-samd/audio_dma.c index 352af89802..93cd96b985 100644 --- a/ports/atmel-samd/audio_dma.c +++ b/ports/atmel-samd/audio_dma.c @@ -31,6 +31,7 @@ #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/audiocore/WaveFile.h" +#include "supervisor/shared/tick.h" #include "py/mpstate.h" #include "py/runtime.h" @@ -60,6 +61,7 @@ void audio_dma_free_channel(uint8_t channel) { assert(audio_dma_allocated[channel]); audio_dma_disable_channel(channel); audio_dma_allocated[channel] = false; + supervisor_disable_tick(); } void audio_dma_disable_channel(uint8_t channel) { @@ -71,6 +73,7 @@ void audio_dma_disable_channel(uint8_t channel) { void audio_dma_enable_channel(uint8_t channel) { if (channel >= AUDIO_DMA_CHANNEL_COUNT) return; + supervisor_enable_tick(); dma_enable_channel(channel); } @@ -318,6 +321,9 @@ void audio_dma_reset(void) { for (uint8_t i = 0; i < AUDIO_DMA_CHANNEL_COUNT; i++) { audio_dma_state[i] = NULL; audio_dma_pending[i] = false; + if (audio_dma_allocated[i]) { + supervisor_disable_tick(); + } audio_dma_allocated[i] = false; audio_dma_disable_channel(i); dma_descriptor(i)->BTCTRL.bit.VALID = false; From 3ffa5604fc0523aa131be4a353fb883a9c8a37ff Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 13 May 2020 08:36:16 -0700 Subject: [PATCH 104/216] Update countio to python stub docs --- shared-bindings/busio/UART.c | 10 ++--- shared-bindings/countio/Counter.c | 70 ++++++++++++++---------------- shared-bindings/countio/__init__.c | 16 +------ 3 files changed, 38 insertions(+), 58 deletions(-) diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index d4642225c0..2bd36145d2 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -346,13 +346,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_o //| class Parity: //| """Enum-like class to define the parity used to verify correct data transfer.""" //| -//| def __init__(self, ): -//| ODD: Any = ... -//| """Total number of ones should be odd.""" +//| ODD: Any = ... +//| """Total number of ones should be odd.""" //| -//| EVEN: Any = ... -//| """Total number of ones should be even.""" -//| ... +//| EVEN: Any = ... +//| """Total number of ones should be even.""" //| const mp_obj_type_t busio_uart_parity_type; diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index d9d97f0ead..8db795015d 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -9,45 +9,41 @@ #include "shared-bindings/countio/Counter.h" #include "shared-bindings/util.h" -//| .. currentmodule:: countio +//| class Counter: +//| """Counter will keep track of the number of falling edge transistions (pulses) on a +//| given pin""" //| -//| :class:`Counter` -- Track the count of falling edge transistions (pulses) on a given pin -//| ======================================================================================== +//| def __init__(self, pin_a): +//| """Create a Counter object associated with the given pin. It tracks the number of +//| falling pulses relative when the object is constructed. //| -//| Counter will keep track of the number of falling edge transistions (pulses) on a given pin +//| :param ~microcontroller.Pin pin_a: Pin to read pulses from. //| -//| .. class:: Counter(pin_a) //| -//| Create a Counter object associated with the given pin. It tracks the number of -//| falling pulses relative when the object is constructed. +//| For example:: //| -//| :param ~microcontroller.Pin pin_a: Pin to read pulses from. -//| +//| import countio +//| import time +//| from board import * //| -//| For example:: -//| -//| import countio -//| import time -//| from board import * -//| -//| pin_counter = countio.Counter(board.D1) -//| #reset the count after 100 counts -//| while True: -//| if pin_counter.count == 100: -//| pin_counter.reset() -//| print(pin_counter.count) +//| pin_counter = countio.Counter(board.D1) +//| #reset the count after 100 counts +//| while True: +//| if pin_counter.count == 100: +//| pin_counter.reset() +//| print(pin_counter.count)""" //| STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pin_a }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin_a, MP_ARG_REQUIRED | MP_ARG_OBJ } - + }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); const mcu_pin_obj_t* pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj); - + countio_counter_obj_t *self = m_new_obj(countio_counter_obj_t); self->base.type = &countio_counter_type; @@ -57,9 +53,8 @@ STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_arg return MP_OBJ_FROM_PTR(self); } -//| .. method:: deinit() -//| -//| Deinitializes the Counter and releases any hardware resources for reuse. +//| def deinit(self): +//| """Deinitializes the Counter and releases any hardware resources for reuse.""" //| STATIC mp_obj_t countio_counter_deinit(mp_obj_t self_in) { countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -74,16 +69,14 @@ STATIC void check_for_deinit(countio_counter_obj_t *self) { } } -//| .. method:: __enter__() -//| -//| No-op used by Context Managers. +//| def __enter__(self): +//| """No-op used by Context Managers.""" //| // Provided by context manager helper. -//| .. method:: __exit__() -//| -//| Automatically deinitializes the hardware when exiting a context. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| def __exit__(self): +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" //| STATIC mp_obj_t countio_counter_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; @@ -93,10 +86,8 @@ STATIC mp_obj_t countio_counter_obj___exit__(size_t n_args, const mp_obj_t *args STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(countio_counter___exit___obj, 4, 4, countio_counter_obj___exit__); -//| .. attribute:: count -//| -//| The current count in terms of pulses. -//| +//| count: int = ... +//| """The current count in terms of pulses.""" //| STATIC mp_obj_t countio_counter_obj_get_count(mp_obj_t self_in) { countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -122,6 +113,9 @@ const mp_obj_property_t countio_counter_count_obj = { (mp_obj_t)&mp_const_none_obj}, }; +//| def reset(self): +//| """Resets the count back to 0.""" +//| STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in){ countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -129,7 +123,7 @@ STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in){ common_hal_countio_counter_reset(self); return mp_const_none; } - + MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_reset_obj, countio_counter_reset); diff --git a/shared-bindings/countio/__init__.c b/shared-bindings/countio/__init__.c index 8929bf7edb..7046a5e721 100644 --- a/shared-bindings/countio/__init__.c +++ b/shared-bindings/countio/__init__.c @@ -8,22 +8,10 @@ #include "shared-bindings/countio/__init__.h" #include "shared-bindings/countio/Counter.h" -//| :mod:`countio` --- Support for edge counting -//| ======================================================== -//| -//| .. module:: countio -//| :synopsis: Support for edge counting -//| :platform: SAMD +//| """Support for edge counting //| //| The `countio` module contains logic to read and count edge transistions //| -//| Libraries -//| -//| .. toctree:: -//| :maxdepth: 3 -//| -//| Counter -//| //| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the //| :ref:`module-support-matrix` for more info. @@ -32,7 +20,7 @@ //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See -//| :ref:`lifetime-and-contextmanagers` for more info. +//| :ref:`lifetime-and-contextmanagers` for more info.""" //| STATIC const mp_rom_map_elem_t countio_module_globals_table[] = { From 794d5f5900410730b84a1ab47c2c286b954b5c0a Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 13 May 2020 14:45:09 -0700 Subject: [PATCH 105/216] Correct version numbering --- setup.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 37afb6f1b1..769bc66e1d 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,36 @@ from datetime import datetime from setuptools import setup from pathlib import Path +import subprocess +import re stub_root = Path("circuitpython-stubs") stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")] +git_out = subprocess.check_output(["git", "describe", "--tags"]) +version = git_out.strip().decode("utf-8") + +# Detect a development build and mutate it to be valid semver and valid python version. +pieces = version.split("-") +if len(pieces) > 2: + # Merge the commit portion onto the commit count since the tag. + pieces[-2] += "+" + pieces[-1] + pieces.pop() + # Merge the commit count and build to the pre-release identifier. + pieces[-2] += ".dev." + pieces[-1] + pieces.pop() +version = "-".join(pieces) + setup( name="circuitpython-stubs", description="PEP 561 type stubs for CircuitPython", url="https://github.com/adafruit/circuitpython", maintainer="CircuitPythonistas", + maintainer_email="circuitpython@adafruit.com", author_email="circuitpython@adafruit.com", - use_scm_version=True, + version=version, license="MIT", package_data={"circuitpython-stubs": stubs}, packages=["circuitpython-stubs"], - setup_requires=["setuptools>=38.6.0", - "setuptools_scm"], + setup_requires=["setuptools>=38.6.0"], ) From 3d6a23411f065fdec2d9e501305ae90200bbdbe2 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Thu, 14 May 2020 11:59:07 +0000 Subject: [PATCH 106/216] Translated using Weblate (Swedish) Currently translated at 3.4% (26 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/sv/ --- locale/sv.po | 62 ++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 493245dbfc..7ca0af3e2f 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -3,25 +3,28 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2020-05-14 12:23+0000\n" +"Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" -"Language: \n" +"Language: sv\n" "MIME-Version: 1.0\n" "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.1-dev\n" #: main.c msgid "" "\n" "Code done running. Waiting for reload.\n" msgstr "" +"\n" +"Koden har kört klart. Väntar på omladdning.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -38,11 +41,11 @@ msgstr "" #: py/obj.c msgid " File \"%q\"" -msgstr "" +msgstr " Filen \"%q\"" #: py/obj.c msgid " File \"%q\", line %d" -msgstr "" +msgstr " Fil \"%q\", rad %d" #: main.c msgid " output:\n" @@ -51,7 +54,7 @@ msgstr "" #: py/objstr.c #, c-format msgid "%%c requires int or char" -msgstr "" +msgstr "%%c kräver int eller char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format @@ -60,42 +63,43 @@ msgstr "" #: shared-bindings/microcontroller/Pin.c msgid "%q in use" -msgstr "" +msgstr "%q används redan" #: py/obj.c msgid "%q index out of range" -msgstr "" +msgstr "Index %q ligger utanför intervallet" #: py/obj.c msgid "%q indices must be integers, not %s" -msgstr "" +msgstr "Indexet %q måste vara ett heltal, inte %s" #: shared-bindings/vectorio/Polygon.c +#, fuzzy msgid "%q list must be a list" -msgstr "" +msgstr "%q-listan måste vara en lista" #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c #: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c #: shared-bindings/vectorio/Rectangle.c msgid "%q must be >= 1" -msgstr "" +msgstr "%q måste vara >= 1" #: shared-bindings/vectorio/Polygon.c msgid "%q must be a tuple of length 2" -msgstr "" +msgstr "%q måste vara en tuple av längd 2" #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" -msgstr "" +msgstr "%q ska vara en int" #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" -msgstr "" +msgstr "%q() kräver %d positionsargument men %d gavs" #: py/argcheck.c msgid "'%q' argument required" -msgstr "" +msgstr "'%q' argument krävs" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format @@ -105,17 +109,17 @@ msgstr "" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a register" -msgstr "" +msgstr "'%s' förväntar sig ett register" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects a special register" -msgstr "" +msgstr "'%s' förväntar sig ett specialregister" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects an FPU register" -msgstr "" +msgstr "'%s' förväntar sig ett FPU-register" #: py/emitinlinethumb.c #, c-format @@ -125,35 +129,35 @@ msgstr "" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects an integer" -msgstr "" +msgstr "'%s' förväntar sig ett heltal" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects at most r%d" -msgstr "" +msgstr "'%s' förväntar sig högst r%d" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects {r0, r1, ...}" -msgstr "" +msgstr "'%s' förväntar sig {r0, r1, ...}" #: py/emitinlinextensa.c #, c-format msgid "'%s' integer %d is not within range %d..%d" -msgstr "" +msgstr "'%s' heltal %d ligger inte inom intervallet %d..%d" #: py/emitinlinethumb.c #, c-format msgid "'%s' integer 0x%x does not fit in mask 0x%x" -msgstr "" +msgstr "'%s' heltal 0x%x får inte plats i mask 0x%x" #: py/runtime.c msgid "'%s' object cannot assign attribute '%q'" -msgstr "" +msgstr "Objektet '%s' kan inte tilldela attributet '%q'" #: py/proto.c msgid "'%s' object does not support '%q'" -msgstr "" +msgstr "Objektet '%s' har inte stöd för '%q'" #: py/obj.c #, c-format @@ -167,17 +171,17 @@ msgstr "" #: py/runtime.c msgid "'%s' object has no attribute '%q'" -msgstr "" +msgstr "Objektet '%s' har inget attribut '%q'" #: py/runtime.c #, c-format msgid "'%s' object is not an iterator" -msgstr "" +msgstr "Objektet '%s' är inte en iterator" #: py/objtype.c py/runtime.c #, c-format msgid "'%s' object is not callable" -msgstr "" +msgstr "Objektet '%s' kan inte anropas" #: py/runtime.c #, c-format From b446d3eee1011a5c7834abfb66101d0911f5505d Mon Sep 17 00:00:00 2001 From: Anonymous Date: Thu, 14 May 2020 12:22:49 +0000 Subject: [PATCH 107/216] Translated using Weblate (Swedish) Currently translated at 3.4% (26 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/sv/ --- locale/sv.po | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/locale/sv.po b/locale/sv.po index 7ca0af3e2f..410a3f271e 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -9,7 +9,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-14 12:23+0000\n" -"Last-Translator: Jonny Bergdahl \n" +"Last-Translator: Anonymous \n" "Language-Team: LANGUAGE \n" "Language: sv\n" "MIME-Version: 1.0\n" @@ -38,6 +38,8 @@ msgid "" "\n" "To exit, please reset the board without " msgstr "" +"\n" +"För att avsluta, återställ brädet utan" #: py/obj.c msgid " File \"%q\"" From 09e740d6ea8676366b70fab453e8b1b57b4e979f Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Thu, 14 May 2020 12:23:15 +0000 Subject: [PATCH 108/216] Translated using Weblate (Swedish) Currently translated at 3.7% (28 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/sv/ --- locale/sv.po | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 410a3f271e..5708b66427 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-14 12:23+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-14 12:41+0000\n" +"Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" "MIME-Version: 1.0\n" @@ -39,7 +39,7 @@ msgid "" "To exit, please reset the board without " msgstr "" "\n" -"För att avsluta, återställ brädet utan" +"För att avsluta, resetta kortet utan " #: py/obj.c msgid " File \"%q\"" @@ -50,8 +50,9 @@ msgid " File \"%q\", line %d" msgstr " Fil \"%q\", rad %d" #: main.c +#, fuzzy msgid " output:\n" -msgstr "" +msgstr " utdata:\n" #: py/objstr.c #, c-format @@ -106,7 +107,7 @@ msgstr "'%q' argument krävs" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" -msgstr "" +msgstr "'%s' förväntar sig en etikett" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format @@ -126,7 +127,7 @@ msgstr "'%s' förväntar sig ett FPU-register" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects an address of the form [a, b]" -msgstr "" +msgstr "'%s' förväntar sig en adress i formen [a, b]" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format From b477c4812d1f0d0ed0fe56abcdcaa356cc3a652e Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 14 May 2020 16:58:25 -0400 Subject: [PATCH 109/216] Fixed minor indentation issue --- shared-bindings/analogio/AnalogIn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index bafa287ff1..400784b390 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -70,9 +70,9 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Turn off the AnalogIn and release the pin for other use.""" -//| ... +//| def deinit(self, ) -> Any: +//| """Turn off the AnalogIn and release the pin for other use.""" +//| ... //| STATIC mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) { analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in); From afc84c2fd115aa1c7a80bd5d83834c30c4563a6c Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 14 May 2020 15:57:35 -0700 Subject: [PATCH 110/216] Fix ulab, math and template. --- .gitignore | 2 +- Makefile | 9 +- conf.py | 6 +- docs/autoapi/templates/python/module.rst | 93 +++ shared-bindings/math/__init__.c | 322 +++++------ shared-bindings/ulab/__init__.pyi | 606 ++++---------------- shared-bindings/ulab/compare/__init__.pyi | 30 + shared-bindings/ulab/extras/__init__.pyi | 10 + shared-bindings/ulab/fft/__init__.pyi | 22 + shared-bindings/ulab/filter/__init__.pyi | 19 + shared-bindings/ulab/linalg/__init__.pyi | 57 ++ shared-bindings/ulab/numerical/__init__.pyi | 57 ++ shared-bindings/ulab/poly/__init__.pyi | 10 + shared-bindings/ulab/vector/__init__.pyi | 108 ++++ tools/extract_pyi.py | 77 +-- 15 files changed, 739 insertions(+), 689 deletions(-) create mode 100644 docs/autoapi/templates/python/module.rst create mode 100644 shared-bindings/ulab/compare/__init__.pyi create mode 100644 shared-bindings/ulab/extras/__init__.pyi create mode 100644 shared-bindings/ulab/fft/__init__.pyi create mode 100644 shared-bindings/ulab/filter/__init__.pyi create mode 100644 shared-bindings/ulab/linalg/__init__.pyi create mode 100644 shared-bindings/ulab/numerical/__init__.pyi create mode 100644 shared-bindings/ulab/poly/__init__.pyi create mode 100644 shared-bindings/ulab/vector/__init__.pyi diff --git a/.gitignore b/.gitignore index 403fcc2997..f5edb89f0e 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,7 @@ _build # Generated rst files ###################### genrst/ -autoapi/ +/autoapi/ # ctags and similar ################### diff --git a/Makefile b/Makefile index 1971076a38..842c18da5b 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,7 @@ help: clean: rm -rf $(BUILDDIR)/* + rm -rf autoapi rm -rf $(STUBDIR) $(DISTDIR) *.egg-info html: stubs @@ -213,10 +214,10 @@ check-translate: locale/circuitpython.pot $(wildcard locale/*.po) $(PYTHON) tools/check_translations.py $^ stubs: - mkdir -p circuitpython-stubs - python tools/extract_pyi.py shared-bindings/ $(STUBDIR) - python tools/extract_pyi.py ports/atmel-samd/bindings $(STUBDIR) - python setup.py sdist + @mkdir -p circuitpython-stubs + @$(PYTHON) tools/extract_pyi.py shared-bindings/ $(STUBDIR) + @$(PYTHON) tools/extract_pyi.py ports/atmel-samd/bindings $(STUBDIR) + @$(PYTHON) setup.py -q sdist update-frozen-libraries: @echo "Updating all frozen libraries to latest tagged version." diff --git a/conf.py b/conf.py index aea84dd21d..ee65e39fb4 100644 --- a/conf.py +++ b/conf.py @@ -71,11 +71,13 @@ extensions.append('autoapi.extension') autoapi_type = 'python' # Uncomment this if debugging autoapi -# autoapi_keep_files = True -autoapi_dirs = ['circuitpython-stubs'] +autoapi_keep_files = True +autoapi_dirs = [os.path.join('circuitpython-stubs', x) for x in os.listdir('circuitpython-stubs')] +print(autoapi_dirs) autoapi_add_toctree_entry = False autoapi_options = ['members', 'undoc-members', 'private-members', 'show-inheritance', 'special-members', 'show-module-summary'] autoapi_template_dir = 'docs/autoapi/templates' +autoapi_python_use_implicit_namespaces = True # The encoding of source files. #source_encoding = 'utf-8-sig' diff --git a/docs/autoapi/templates/python/module.rst b/docs/autoapi/templates/python/module.rst new file mode 100644 index 0000000000..7ede6bdfdf --- /dev/null +++ b/docs/autoapi/templates/python/module.rst @@ -0,0 +1,93 @@ +{% if not obj.display %} +:orphan: + +{% endif %} +:mod:`{{ obj.name }}` +======={{ "=" * obj.name|length }} + +.. py:module:: {{ obj.name }} + +{% if obj.docstring %} +.. autoapi-nested-parse:: + + {{ obj.docstring|prepare_docstring|indent(3) }} + +{% endif %} + +{% block subpackages %} +{% set visible_subpackages = obj.subpackages|selectattr("display")|list %} +{% if visible_subpackages %} +.. toctree:: + :titlesonly: + :maxdepth: 3 + +{% for subpackage in visible_subpackages %} + {{ subpackage.short_name }}/index.rst +{% endfor %} + + +{% endif %} +{% endblock %} +{% block submodules %} +{% set visible_submodules = obj.submodules|selectattr("display")|list %} +{% if visible_submodules %} + +.. toctree:: + :titlesonly: + :maxdepth: 1 + +{% for submodule in visible_submodules %} + {{ submodule.short_name }}/index.rst +{% endfor %} + + +{% endif %} +{% endblock %} +{% block content %} +{% if obj.all is not none %} +{% set visible_children = obj.children|selectattr("short_name", "in", obj.all)|list %} +{% elif obj.type is equalto("package") %} +{% set visible_children = obj.children|selectattr("display")|list %} +{% else %} +{% set visible_children = obj.children|selectattr("display")|rejectattr("imported")|list %} +{% endif %} +{% if visible_children %} + +{% set visible_classes = visible_children|selectattr("type", "equalto", "class")|list %} +{% set visible_functions = visible_children|selectattr("type", "equalto", "function")|list %} +{% if "show-module-summary" in autoapi_options and (visible_classes or visible_functions) %} +{% block classes %} +{% if visible_classes %} +Classes +~~~~~~~ + +.. autoapisummary:: + +{% for klass in visible_classes %} + {{ klass.id }} +{% endfor %} + + +{% endif %} +{% endblock %} + +{% block functions %} +{% if visible_functions %} +Functions +~~~~~~~~~ + +.. autoapisummary:: + +{% for function in visible_functions %} + {{ function.id }} +{% endfor %} + + +{% endif %} +{% endblock %} +{% endif %} +{% for obj_item in visible_children %} +{{ obj_item.rendered|indent(0) }} +{% endfor %} +{% endif %} +{% endblock %} diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index 56155306ff..8226a08ecb 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -78,178 +78,170 @@ STATIC NORETURN void math_error(void) { // 1.442695040888963407354163704 is 1/_M_LN2 #define log2(x) (log(x) * 1.442695040888963407354163704) #endif - //| Constants - //| --------- - //| - //| e: Any = ... - //| """base of the natural logarithm""" - //| - //| pi: Any = ... - //| """the ratio of a circle's circumference to its diameter""" - //| - //| Functions - //| --------- - //| - //| def acos(x: Any) -> Any: - //| """Return the inverse cosine of ``x``.""" - //| ... - //| - //| def asin(x: Any) -> Any: - //| """Return the inverse sine of ``x``.""" - //| ... - //| - //| def atan(x: Any) -> Any: - //| """Return the inverse tangent of ``x``.""" - //| ... - //| - //| def atan2(y: Any, x: Any) -> Any: - //| """Return the principal value of the inverse tangent of ``y/x``.""" - //| ... - //| - //| def ceil(x: Any) -> Any: - //| """Return an integer, being ``x`` rounded towards positive infinity.""" - //| ... - //| - //| def copysign(x: Any, y: Any) -> Any: - //| """Return ``x`` with the sign of ``y``.""" - //| ... - //| - //| def cos(x: Any) -> Any: - //| """Return the cosine of ``x``.""" - //| ... - //| - //| def degrees(x: Any) -> Any: - //| """Return radians ``x`` converted to degrees.""" - //| ... - //| - //| def exp(x: Any) -> Any: - //| """Return the exponential of ``x``.""" - //| ... - //| - //| def fabs(x: Any) -> Any: - //| """Return the absolute value of ``x``.""" - //| ... - //| - //| def floor(x: Any) -> Any: - //| """Return an integer, being ``x`` rounded towards negative infinity.""" - //| ... - //| - //| def fmod(x: Any, y: Any) -> Any: - //| """Return the remainder of ``x/y``.""" - //| ... - //| - //| def frexp(x: Any) -> Any: - //| """Decomposes a floating-point number into its mantissa and exponent. - //| The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e`` - //| exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise - //| the relation ``0.5 <= abs(m) < 1`` holds.""" - //| ... - //| - //| def isfinite(x: Any) -> Any: - //| """Return ``True`` if ``x`` is finite.""" - //| ... - //| - //| def isinf(x: Any) -> Any: - //| """Return ``True`` if ``x`` is infinite.""" - //| ... - //| - //| def isnan(x: Any) -> Any: - //| """Return ``True`` if ``x`` is not-a-number""" - //| ... - //| - //| def ldexp(x: Any, exp: Any) -> Any: - //| """Return ``x * (2**exp)``.""" - //| ... - //| - //| def modf(x: Any) -> Any: - //| """Return a tuple of two floats, being the fractional and integral parts of - //| ``x``. Both return values have the same sign as ``x``.""" - //| ... - //| - //| def pow(x: Any, y: Any) -> Any: - //| """Returns ``x`` to the power of ``y``.""" - //| - //| def radians(x: Any) -> Any: - //| """Return degrees ``x`` converted to radians.""" - //| - //| def sin(x: Any) -> Any: - //| """Return the sine of ``x``.""" - //| ... - //| - //| def sqrt(x: Any) -> Any: - //| """Returns the square root of ``x``.""" - //| ... - //| - //| def tan(x: Any) -> Any: ... - //| """Return the tangent of ``x``.""" - //| ... - //| - //| def trunc(x: Any) -> Any: - //| """Return an integer, being ``x`` rounded towards 0.""" - //| ... - //| +//| e: Any = ... +//| """base of the natural logarithm""" +//| +//| pi: Any = ... +//| """the ratio of a circle's circumference to its diameter""" +//| + +//| def acos(x: Any) -> Any: +//| """Return the inverse cosine of ``x``.""" +//| ... +//| +//| def asin(x: Any) -> Any: +//| """Return the inverse sine of ``x``.""" +//| ... +//| +//| def atan(x: Any) -> Any: +//| """Return the inverse tangent of ``x``.""" +//| ... +//| +//| def atan2(y: Any, x: Any) -> Any: +//| """Return the principal value of the inverse tangent of ``y/x``.""" +//| ... +//| +//| def ceil(x: Any) -> Any: +//| """Return an integer, being ``x`` rounded towards positive infinity.""" +//| ... +//| +//| def copysign(x: Any, y: Any) -> Any: +//| """Return ``x`` with the sign of ``y``.""" +//| ... +//| +//| def cos(x: Any) -> Any: +//| """Return the cosine of ``x``.""" +//| ... +//| +//| def degrees(x: Any) -> Any: +//| """Return radians ``x`` converted to degrees.""" +//| ... +//| +//| def exp(x: Any) -> Any: +//| """Return the exponential of ``x``.""" +//| ... +//| +//| def fabs(x: Any) -> Any: +//| """Return the absolute value of ``x``.""" +//| ... +//| +//| def floor(x: Any) -> Any: +//| """Return an integer, being ``x`` rounded towards negative infinity.""" +//| ... +//| +//| def fmod(x: Any, y: Any) -> Any: +//| """Return the remainder of ``x/y``.""" +//| ... +//| +//| def frexp(x: Any) -> Any: +//| """Decomposes a floating-point number into its mantissa and exponent. +//| The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e`` +//| exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise +//| the relation ``0.5 <= abs(m) < 1`` holds.""" +//| ... +//| +//| def isfinite(x: Any) -> Any: +//| """Return ``True`` if ``x`` is finite.""" +//| ... +//| +//| def isinf(x: Any) -> Any: +//| """Return ``True`` if ``x`` is infinite.""" +//| ... +//| +//| def isnan(x: Any) -> Any: +//| """Return ``True`` if ``x`` is not-a-number""" +//| ... +//| +//| def ldexp(x: Any, exp: Any) -> Any: +//| """Return ``x * (2**exp)``.""" +//| ... +//| +//| def modf(x: Any) -> Any: +//| """Return a tuple of two floats, being the fractional and integral parts of +//| ``x``. Both return values have the same sign as ``x``.""" +//| ... +//| +//| def pow(x: Any, y: Any) -> Any: +//| """Returns ``x`` to the power of ``y``.""" +//| +//| def radians(x: Any) -> Any: +//| """Return degrees ``x`` converted to radians.""" +//| +//| def sin(x: Any) -> Any: +//| """Return the sine of ``x``.""" +//| ... +//| +//| def sqrt(x: Any) -> Any: +//| """Returns the square root of ``x``.""" +//| ... +//| +//| def tan(x: Any) -> Any: +//| """Return the tangent of ``x``.""" +//| ... +//| +//| def trunc(x: Any) -> Any: +//| """Return an integer, being ``x`` rounded towards 0.""" +//| ... +//| MATH_FUN_1_ERRCOND(sqrt, sqrt, (x < (mp_float_t)0.0)) MATH_FUN_2(pow, pow) MATH_FUN_1(exp, exp) #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS -// Special functions -// ----------------- -// -// .. function:: expm1(x) -// -// Return ``exp(x) - 1``. -// +//| def expm1(x): +//| """Return ``exp(x) - 1``.""" +//| ... +//| MATH_FUN_1(expm1, expm1) -// .. function:: log2(x) -// -// Return the base-2 logarithm of ``x``. -// +//| def log2(x): +//| """Return the base-2 logarithm of ``x``.""" +//| ... +//| MATH_FUN_1_ERRCOND(log2, log2, (x <= (mp_float_t)0.0)) -// .. function:: log10(x) -// -// Return the base-10 logarithm of ``x``. -// +//| def log10(x): +//| """Return the base-10 logarithm of ``x``.""" +//| ... +//| MATH_FUN_1_ERRCOND(log10, log10, (x <= (mp_float_t)0.0)) -// .. function:: cosh(x) -// -// Return the hyperbolic cosine of ``x``. -// +//| def cosh(x): +//| """Return the hyperbolic cosine of ``x``.""" +//| ... +//| MATH_FUN_1(cosh, cosh) -// .. function:: sinh(x) -// -// Return the hyperbolic sine of ``x``. -// +//| def sinh(x): +//| """Return the hyperbolic sine of ``x``.""" +//| ... +//| MATH_FUN_1(sinh, sinh) -// .. function:: tanh(x) -// -// Return the hyperbolic tangent of ``x``. -// +//| def tanh(x): +//| """Return the hyperbolic tangent of ``x``.""" +//| ... +//| MATH_FUN_1(tanh, tanh) -// .. function:: acosh(x) -// -// Return the inverse hyperbolic cosine of ``x``. -// +//| def acosh(x): +//| """Return the inverse hyperbolic cosine of ``x``.""" +//| ... +//| MATH_FUN_1(acosh, acosh) -// .. function:: asinh(x) -// -// Return the inverse hyperbolic sine of ``x``. -// +//| def asinh(x): +//| """Return the inverse hyperbolic sine of ``x``.""" +//| ... +//| MATH_FUN_1(asinh, asinh) -// .. function:: atanh(x) -// -// Return the inverse hyperbolic tangent of ``x``. -// +//| def atanh(x): +//| """Return the inverse hyperbolic tangent of ``x``.""" +//| ... +//| MATH_FUN_1(atanh, atanh) #endif @@ -288,28 +280,28 @@ MATH_FUN_1_TO_INT(trunc, trunc) MATH_FUN_2(ldexp, ldexp) #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS -// .. function:: erf(x) -// -// Return the error function of ``x``. -// +//| def erf(x): +//| """Return the error function of ``x``.""" +//| ... +//| MATH_FUN_1(erf, erf) -// .. function:: erfc(x) -// -// Return the complementary error function of ``x``. -// +//| def erfc(x): +//| """Return the complementary error function of ``x``.""" +//| ... +//| MATH_FUN_1(erfc, erfc) -// .. function:: gamma(x) -// -// Return the gamma function of ``x``. -// +//| def gamma(x): +//| """Return the gamma function of ``x``.""" +//| ... +//| MATH_FUN_1(gamma, tgamma) -// .. function:: lgamma(x) -// -// Return the natural logarithm of the gamma function of ``x``. -// +//| def lgamma(x): +//| """Return the natural logarithm of the gamma function of ``x``.""" +//| ... +//| MATH_FUN_1(lgamma, lgamma) #endif //TODO: factorial, fsum diff --git a/shared-bindings/ulab/__init__.pyi b/shared-bindings/ulab/__init__.pyi index d2ff7eb80b..e5de1391b6 100644 --- a/shared-bindings/ulab/__init__.pyi +++ b/shared-bindings/ulab/__init__.pyi @@ -1,9 +1,4 @@ - -:mod:`ulab` --- Manipulate numeric data similar to numpy -======================================================== - -.. module:: ulab - :synopsis: Manipulate numeric data similar to numpy +"""Manipulate numeric data similar to numpy `ulab` is a numpy-like module for micropython, meant to simplify and speed up common mathematical operations on arrays. The primary goal was to @@ -17,507 +12,158 @@ https://micropython-ulab.readthedocs.io/en/latest/ `ulab` is modeled after numpy, and aims to be a compatible subset where possible. Numpy's documentation can be found at -https://docs.scipy.org/doc/numpy/index.html - -.. contents:: - -.. attribute:: __version__ - -The closest corresponding version of micropython-ulab - -ulab.array -- 1- and 2- dimensional array ------------------------------------------ - -.. class:: ulab.array(values, \*, dtype=float) - - :param sequence values: Sequence giving the initial content of the array. - :param dtype: The type of array values, ``int8``, ``uint8``, ``int16``, ``uint16``, or ``float`` - - The `values` sequence can either be another ~ulab.array, sequence of numbers - (in which case a 1-dimensional array is created), or a sequence where each - subsequence has the same length (in which case a 2-dimensional array is - created). - - Passing a ~ulab.array and a different dtype can be used to convert an array - from one dtype to another. - - In many cases, it is more convenient to create an array from a function - like `zeros` or `linspace`. - - `ulab.array` implements the buffer protocol, so it can be used in many - places an `array.array` can be used. - - .. attribute:: shape - - The size of the array, a tuple of length 1 or 2 - - .. attribute:: size - - The number of elements in the array - - .. attribute:: itemsize - - The number of elements in the array - - .. method:: flatten(\*, order='C') - - :param order: Whether to flatten by rows ('C') or columns ('F') - - Returns a new `ulab.array` object which is always 1 dimensional. - If order is 'C' (the default", then the data is ordered in rows; - If it is 'F', then the data is ordered in columns. "C" and "F" refer - to the typical storage organization of the C and Fortran languages. - - .. method:: sort(\*, axis=1) - - :param axis: Whether to sort elements within rows (0), columns (1), or elements (None) - - .. method:: transpose() - - Swap the rows and columns of a 2-dimensional array - - .. method:: __add__() - - Adds corresponding elements of the two arrays, or adds a number to all - elements of the array. If both arguments are arrays, their sizes must match. - - .. method:: __sub__() - - Subtracts corresponding elements of the two arrays, or adds a number to all - elements of the array. If both arguments are arrays, their sizes must match. - - .. method:: __mul__() - - Multiplies corresponding elements of the two arrays, or multiplies - all elements of the array by a number. If both arguments are arrays, - their sizes must match. - - .. method:: __div__() - - Multiplies corresponding elements of the two arrays, or divides - all elements of the array by a number. If both arguments are arrays, - their sizes must match. - - .. method:: __pow__() - - Computes the power (x**y) of corresponding elements of the the two arrays, - or one number and one array. If both arguments are arrays, their sizes - must match. - - .. method:: __getitem__() - - Retrieve an element of the array. - - .. method:: __setitem__() - - Set an element of the array. - -Array type codes ----------------- -.. attribute:: int8 - - Type code for signed integers in the range -128 .. 127 inclusive, like the 'b' typecode of `array.array` - -.. attribute:: int16 - - Type code for signed integers in the range -32768 .. 32767 inclusive, like the 'h' typecode of `array.array` - -.. attribute:: float - - Type code for floating point values, like the 'f' typecode of `array.array` - -.. attribute:: uint8 - - Type code for unsigned integers in the range 0 .. 255 inclusive, like the 'H' typecode of `array.array` - -.. attribute:: uint16 - - Type code for unsigned integers in the range 0 .. 65535 inclusive, like the 'h' typecode of `array.array` +https://docs.scipy.org/doc/numpy/index.html""" -Basic Array defining functions ------------------------------- +class array: + """1- and 2- dimensional array""" + def __init__(self, values, *, dtype=float): + """:param sequence values: Sequence giving the initial content of the array. + :param dtype: The type of array values, ``int8``, ``uint8``, ``int16``, ``uint16``, or ``float`` -.. method:: ones(shape, \*, dtype=float) + The `values` sequence can either be another ~ulab.array, sequence of numbers + (in which case a 1-dimensional array is created), or a sequence where each + subsequence has the same length (in which case a 2-dimensional array is + created). - .. param: shape - Shape of the array, either an integer (for a 1-D array) or a tuple of 2 integers (for a 2-D array) + Passing a ~ulab.array and a different dtype can be used to convert an array + from one dtype to another. - .. param: dtype - Type of values in the array + In many cases, it is more convenient to create an array from a function + like `zeros` or `linspace`. - Return a new array of the given shape with all elements set to 1. + `ulab.array` implements the buffer protocol, so it can be used in many + places an `array.array` can be used.""" + ... -.. method:: zeros + shape: tuple = ... + """The size of the array, a tuple of length 1 or 2""" - .. param: shape - Shape of the array, either an integer (for a 1-D array) or a tuple of 2 integers (for a 2-D array) + size: int = ... + """The number of elements in the array""" - .. param: dtype - Type of values in the array + itemsize: int = ... + """The number of elements in the array""" - Return a new array of the given shape with all elements set to 0. + def flatten(self, *, order='C'): + """:param order: Whether to flatten by rows ('C') or columns ('F') + + Returns a new `ulab.array` object which is always 1 dimensional. + If order is 'C' (the default", then the data is ordered in rows; + If it is 'F', then the data is ordered in columns. "C" and "F" refer + to the typical storage organization of the C and Fortran languages.""" + ... + + def sort(self, *, axis=1): + """:param axis: Whether to sort elements within rows (0), columns (1), or elements (None)""" + ... + + def transpose(self): + """Swap the rows and columns of a 2-dimensional array""" + ... + + def __add__(self): + """Adds corresponding elements of the two arrays, or adds a number to all + elements of the array. If both arguments are arrays, their sizes must match.""" + ... + + def __sub__(self): + """Subtracts corresponding elements of the two arrays, or adds a number to all + elements of the array. If both arguments are arrays, their sizes must match.""" + ... + + def __mul__(self): + """Multiplies corresponding elements of the two arrays, or multiplies + all elements of the array by a number. If both arguments are arrays, + their sizes must match.""" + ... + + def __div__(self): + """Multiplies corresponding elements of the two arrays, or divides + all elements of the array by a number. If both arguments are arrays, + their sizes must match.""" + ... + + def __pow__(): + """Computes the power (x**y) of corresponding elements of the the two arrays, + or one number and one array. If both arguments are arrays, their sizes + must match.""" + ... + + def __getitem__(): + """Retrieve an element of the array.""" + ... + + def __setitem__(): + """Set an element of the array.""" + ... + +int8 = ... +"""Type code for signed integers in the range -128 .. 127 inclusive, like the 'b' typecode of `array.array`""" + +int16 = ... +"""Type code for signed integers in the range -32768 .. 32767 inclusive, like the 'h' typecode of `array.array`""" + +float = ... +"""Type code for floating point values, like the 'f' typecode of `array.array`""" + +uint8 = ... +"""Type code for unsigned integers in the range 0 .. 255 inclusive, like the 'H' typecode of `array.array`""" + +uint16 = ... +"""Type code for unsigned integers in the range 0 .. 65535 inclusive, like the 'h' typecode of `array.array`""" + +def ones(shape, *, dtype=float): + """ + .. param: shape + Shape of the array, either an integer (for a 1-D array) or a tuple of 2 integers (for a 2-D array) + + .. param: dtype + Type of values in the array + + Return a new array of the given shape with all elements set to 1.""" + ... + +def zeros(shape, *, dtype): + """ + .. param: shape + Shape of the array, either an integer (for a 1-D array) or a tuple of 2 integers (for a 2-D array) + + .. param: dtype + Type of values in the array + + Return a new array of the given shape with all elements set to 0.""" + ... -.. method:: eye(size, \*, dtype=float) +def eye(size, *, dtype=float): + """Return a new square array of size, with the diagonal elements set to 1 + and the other elements set to 0.""" + ... - Return a new square array of size, with the diagonal elements set to 1 - and the other elements set to 0. - -.. method:: linspace(start, stop, \*, dtype=float, num=50, endpoint=True) - - .. param: start +def linspace(start, stop, *, dtype=float, num=50, endpoint=True): + """ + .. param: start First value in the array - .. param: stop + .. param: stop Final value in the array - .. param int: num + .. param int: num Count of values in the array - .. param: dtype + .. param: dtype Type of values in the array - .. param bool: endpoint + .. param bool: endpoint Whether the ``stop`` value is included. Note that even when endpoint=True, the exact ``stop`` value may not be included due to the inaccuracy of floating point arithmetic. - Return a new 1-D array with ``num`` elements ranging from ``start`` to ``stop`` linearly. - - -:mod:`ulab.compare` --- Comparison functions -============================================ - -.. module::ulab.compare - -.. method:: clip(x1, x2, x3) - - Constrain the values from ``x1`` to be between ``x2`` and ``x3``. - ``x2`` is assumed to be less than or equal to ``x3``. - - Arguments may be ulab arrays or numbers. All array arguments - must be the same size. If the inputs are all scalars, a 1-element - array is returned. - - Shorthand for ``ulab.maximum(x2, ulab.minimum(x1, x3))`` - -.. method:: maximum(x1, x2) - - Compute the element by element maximum of the arguments. - - Arguments may be ulab arrays or numbers. All array arguments - must be the same size. If the inputs are both scalars, a number is - returned - -.. method:: minimum(x1, x2) - - Compute the element by element minimum of the arguments. - - Arguments may be ulab arrays or numbers. All array arguments - must be the same size. If the inputs are both scalars, a number is - returned - - -:mod:`ulab.vector` --- Element-by-element functions -=================================================== - -.. module:: ulab.vector - -These functions can operate on numbers, 1-D arrays, or 2-D arrays by -applying the function to every element in the array. This is typically -much more efficient than expressing the same operation as a Python loop. - -.. method:: acos - - Computes the inverse cosine function - -.. method:: acosh - - Computes the inverse hyperbolic cosine function - -.. method:: asin - - Computes the inverse sine function - -.. method:: asinh - - Computes the inverse hyperbolic sine function - -.. method:: around(a, \*, decimals) - - Returns a new float array in which each element is rounded to - ``decimals`` places. - -.. method:: atan - - Computes the inverse tangent function; the return values are in the - range [-pi/2,pi/2]. - -.. method:: atan2(y,x) - - Computes the inverse tangent function of y/x; the return values are in - the range [-pi, pi]. - -.. method:: atanh - - Computes the inverse hyperbolic tangent function - -.. method:: ceil - - Rounds numbers up to the next whole number - -.. method:: cos - - Computes the cosine function - -.. method:: erf - - Computes the error function, which has applications in statistics - -.. method:: erfc - - Computes the complementary error function, which has applications in statistics - -.. method:: exp - - Computes the exponent function. - -.. method:: expm1 - - Computes $e^x-1$. In certain applications, using this function preserves numeric accuracy better than the `exp` function. - -.. method:: floor - - Rounds numbers up to the next whole number - -.. method:: gamma - - Computes the gamma function - -.. method:: lgamma - - Computes the natural log of the gamma function - -.. method:: log - - Computes the natural log - -.. method:: log10 - - Computes the log base 10 - -.. method:: log2 - - Computes the log base 2 - -.. method:: sin - - Computes the sine - -.. method:: sinh - - Computes the hyperbolic sine - -.. method:: sqrt - - Computes the square root - -.. method:: tan - - Computes the tangent - -.. method:: tanh - - Computes the hyperbolic tangent - -:mod:`ulab.linalg` - Linear algebra functions -============================================= - -.. module:: ulab.linalg - -.. method:: cholesky(A) - - :param ~ulab.array A: a positive definite, symmetric square matrix - :return ~ulab.array L: a square root matrix in the lower triangular form - :raises ValueError: If the input does not fulfill the necessary conditions - - The returned matrix satisfies the equation m=LL* - -.. method:: det - - :param: m, a square matrix - :return float: The determinant of the matrix - - Computes the eigenvalues and eigenvectors of a square matrix - -.. method:: dot(m1, m2) - - :param ~ulab.array m1: a matrix - :param ~ulab.array m2: a matrix - - Computes the matrix product of two matrices - - **WARNING:** Unlike ``numpy``, this function cannot be used to compute the dot product of two vectors - -.. method:: eig(m) - - :param m: a square matrix - :return tuple (eigenvectors, eigenvalues): - - Computes the eigenvalues and eigenvectors of a square matrix - -.. method:: inv(m) - - :param ~ulab.array m: a square matrix - :return: The inverse of the matrix, if it exists - :raises ValueError: if the matrix is not invertible - - Computes the inverse of a square matrix - -.. method:: size(array) - - Return the total number of elements in the array, as an integer. - -.. method:: trace(m) - - :param m: a square matrix - - Compute the trace of the matrix, the sum of its diagonal elements. - -:mod:`ulab.filter` --- Filtering functions -========================================== - -.. module:: ulab.filter - -.. method:: convolve(r, c=None) - - :param ulab.array a: - :param ulab.array v: - - Returns the discrete, linear convolution of two one-dimensional sequences. - The result is always an array of float. Only the ``full`` mode is supported, - and the ``mode`` named parameter of numpy is not accepted. Note that all other - modes can be had by slicing a ``full`` result. - - Convolution filters can implement high pass, low pass, band pass, etc., - filtering operations. Convolution filters are typically constructed ahead - of time. This can be done using desktop python with scipy, or on web pages - such as https://fiiir.com/ - - Convolution is most time-efficient when both inputs are of float type. - -:mod:`ulab.fft` --- Frequency-domain functions -============================================== - -.. module:: ulab.fft - -.. method:: fft(r, c=None) - - :param ulab.array r: A 1-dimension array of values whose size is a power of 2 - :param ulab.array c: An optional 1-dimension array of values whose size is a power of 2, giving the complex part of the value - :return tuple (r, c): The real and complex parts of the FFT - - Perform a Fast Fourier Transform from the time domain into the frequency domain - - See also ~ulab.extras.spectrum, which computes the magnitude of the fft, - rather than separately returning its real and imaginary parts. - -.. method:: ifft(r, c=None) - - :param ulab.array r: A 1-dimension array of values whose size is a power of 2 - :param ulab.array c: An optional 1-dimension array of values whose size is a power of 2, giving the complex part of the value - :return tuple (r, c): The real and complex parts of the inverse FFT - - Perform an Inverse Fast Fourier Transform from the frequeny domain into the time domain - -:mod:`ulab.numerical` --- Numerical and Statistical functions -============================================================= - -.. module:: ulab.numerical - -Most of these functions take an "axis" argument, which indicates whether to -operate over the flattened array (None), rows (0), or columns (1). - -.. method:: argmax(array, \*, axis=None) - - Return the index of the maximum element of the 1D array - -.. method:: argmin(array, \*, axis=None) - - Return the index of the minimum element of the 1D array - -.. method:: argsort(array, \*, axis=None) - - Returns an array which gives indices into the input array from least to greatest. - -.. method:: diff(array, \*, axis=1) - - Return the numerical derivative of successive elements of the array, as - an array. axis=None is not supported. - -.. method:: flip(array, \*, axis=None) - - Returns a new array that reverses the order of the elements along the - given axis, or along all axes if axis is None. - -.. method:: max(array, \*, axis=None) - - Return the maximum element of the 1D array - -.. method:: mean(array, \*, axis=None) - - Return the mean element of the 1D array, as a number if axis is None, otherwise as an array. - -.. method:: min(array, \*, axis=None) - - Return the minimum element of the 1D array - -.. method:: roll(array, distance, \*, axis=None) - - Shift the content of a vector by the positions given as the second - argument. If the ``axis`` keyword is supplied, the shift is applied to - the given axis. The array is modified in place. - -.. method:: std(array, \*, axis=None) - - Return the standard deviation of the array, as a number if axis is None, otherwise as an array. - -.. method:: sum(array, \*, axis=None) - - Return the sum of the array, as a number if axis is None, otherwise as an array. - -.. method:: sort(array, \*, axis=0) - - Sort the array along the given axis, or along all axes if axis is None. - The array is modified in place. - -:mod:`ulab.poly` --- Polynomial functions -========================================= - -.. module:: ulab.poly - -.. method:: polyfit([x, ] y, degree) - - Return a polynomial of given degree that approximates the function - f(x)=y. If x is not supplied, it is the range(len(y)). - -.. method:: polyval(p, x) - - Evaluate the polynomial p at the points x. x must be an array. - -:mod:`ulab.extras` --- Additional functions not in numpy -======================================================== - -.. method:: spectrum(r): - - :param ulab.array r: A 1-dimension array of values whose size is a power of 2 - - Computes the spectrum of the input signal. This is the absolute value of the (complex-valued) fft of the signal. - - This function is similar to scipy's ``scipy.signal.spectrogram``. + Return a new 1-D array with ``num`` elements ranging from ``start`` to ``stop`` linearly.""" + ... diff --git a/shared-bindings/ulab/compare/__init__.pyi b/shared-bindings/ulab/compare/__init__.pyi new file mode 100644 index 0000000000..00a9eae1e6 --- /dev/null +++ b/shared-bindings/ulab/compare/__init__.pyi @@ -0,0 +1,30 @@ +"""Comparison functions""" + +def clip(x1, x2, x3): + """ + Constrain the values from ``x1`` to be between ``x2`` and ``x3``. + ``x2`` is assumed to be less than or equal to ``x3``. + + Arguments may be ulab arrays or numbers. All array arguments + must be the same size. If the inputs are all scalars, a 1-element + array is returned. + + Shorthand for ``ulab.maximum(x2, ulab.minimum(x1, x3))``""" + ... + +def maximum(x1, x2): + """ + Compute the element by element maximum of the arguments. + + Arguments may be ulab arrays or numbers. All array arguments + must be the same size. If the inputs are both scalars, a number is + returned""" + ... + +def minimum(x1, x2): + """Compute the element by element minimum of the arguments. + + Arguments may be ulab arrays or numbers. All array arguments + must be the same size. If the inputs are both scalars, a number is + returned""" + ... diff --git a/shared-bindings/ulab/extras/__init__.pyi b/shared-bindings/ulab/extras/__init__.pyi new file mode 100644 index 0000000000..4da56a5822 --- /dev/null +++ b/shared-bindings/ulab/extras/__init__.pyi @@ -0,0 +1,10 @@ +"""Additional functions not in numpy""" + +def spectrum(r): + """ + :param ulab.array r: A 1-dimension array of values whose size is a power of 2 + + Computes the spectrum of the input signal. This is the absolute value of the (complex-valued) fft of the signal. + + This function is similar to scipy's ``scipy.signal.spectrogram``.""" + ... diff --git a/shared-bindings/ulab/fft/__init__.pyi b/shared-bindings/ulab/fft/__init__.pyi new file mode 100644 index 0000000000..401ecb6445 --- /dev/null +++ b/shared-bindings/ulab/fft/__init__.pyi @@ -0,0 +1,22 @@ +"""Frequency-domain functions""" + +def fft(r, c=None): + """ + :param ulab.array r: A 1-dimension array of values whose size is a power of 2 + :param ulab.array c: An optional 1-dimension array of values whose size is a power of 2, giving the complex part of the value + :return tuple (r, c): The real and complex parts of the FFT + + Perform a Fast Fourier Transform from the time domain into the frequency domain + + See also ~ulab.extras.spectrum, which computes the magnitude of the fft, + rather than separately returning its real and imaginary parts.""" + ... + +def ifft(r, c=None): + """ + :param ulab.array r: A 1-dimension array of values whose size is a power of 2 + :param ulab.array c: An optional 1-dimension array of values whose size is a power of 2, giving the complex part of the value + :return tuple (r, c): The real and complex parts of the inverse FFT + + Perform an Inverse Fast Fourier Transform from the frequeny domain into the time domain""" + ... diff --git a/shared-bindings/ulab/filter/__init__.pyi b/shared-bindings/ulab/filter/__init__.pyi new file mode 100644 index 0000000000..fff404300b --- /dev/null +++ b/shared-bindings/ulab/filter/__init__.pyi @@ -0,0 +1,19 @@ +"""Filtering functions""" + +def convolve(r, c=None): + """ + :param ulab.array a: + :param ulab.array v: + + Returns the discrete, linear convolution of two one-dimensional sequences. + The result is always an array of float. Only the ``full`` mode is supported, + and the ``mode`` named parameter of numpy is not accepted. Note that all other + modes can be had by slicing a ``full`` result. + + Convolution filters can implement high pass, low pass, band pass, etc., + filtering operations. Convolution filters are typically constructed ahead + of time. This can be done using desktop python with scipy, or on web pages + such as https://fiiir.com/ + + Convolution is most time-efficient when both inputs are of float type.""" + ... diff --git a/shared-bindings/ulab/linalg/__init__.pyi b/shared-bindings/ulab/linalg/__init__.pyi new file mode 100644 index 0000000000..d16e61807b --- /dev/null +++ b/shared-bindings/ulab/linalg/__init__.pyi @@ -0,0 +1,57 @@ +"""Linear algebra functions""" + + +def cholesky(A): + """ + :param ~ulab.array A: a positive definite, symmetric square matrix + :return ~ulab.array L: a square root matrix in the lower triangular form + :raises ValueError: If the input does not fulfill the necessary conditions + + The returned matrix satisfies the equation m=LL*""" + ... + +def det(): + """ + :param: m, a square matrix + :return float: The determinant of the matrix + + Computes the eigenvalues and eigenvectors of a square matrix""" + ... + +def dot(m1, m2): + """ + :param ~ulab.array m1: a matrix + :param ~ulab.array m2: a matrix + + Computes the matrix product of two matrices + + **WARNING:** Unlike ``numpy``, this function cannot be used to compute the dot product of two vectors""" + ... + +def eig(m): + """ + :param m: a square matrix + :return tuple (eigenvectors, eigenvalues): + + Computes the eigenvalues and eigenvectors of a square matrix""" + ... + +def inv(m): + """ + :param ~ulab.array m: a square matrix + :return: The inverse of the matrix, if it exists + :raises ValueError: if the matrix is not invertible + + Computes the inverse of a square matrix""" + ... + +def size(array): + """Return the total number of elements in the array, as an integer.""" + ... + +def trace(m): + """ + :param m: a square matrix + + Compute the trace of the matrix, the sum of its diagonal elements.""" + ... diff --git a/shared-bindings/ulab/numerical/__init__.pyi b/shared-bindings/ulab/numerical/__init__.pyi new file mode 100644 index 0000000000..7596789218 --- /dev/null +++ b/shared-bindings/ulab/numerical/__init__.pyi @@ -0,0 +1,57 @@ +"""Numerical and Statistical functions + +Most of these functions take an "axis" argument, which indicates whether to +operate over the flattened array (None), rows (0), or columns (1).""" + +def argmax(array, *, axis=None): + """Return the index of the maximum element of the 1D array""" + ... + +def argmin(array, *, axis=None): + """Return the index of the minimum element of the 1D array""" + ... + +def argsort(array, *, axis=None): + """Returns an array which gives indices into the input array from least to greatest.""" + ... + +def diff(array, *, axis=1): + """Return the numerical derivative of successive elements of the array, as + an array. axis=None is not supported.""" + ... + +def flip(array, *, axis=None): + """Returns a new array that reverses the order of the elements along the + given axis, or along all axes if axis is None.""" + ... + +def max(array, *, axis=None): + """Return the maximum element of the 1D array""" + ... + +def mean(array, *, axis=None): + """Return the mean element of the 1D array, as a number if axis is None, otherwise as an array.""" + ... + +def min(array, *, axis=None): + """Return the minimum element of the 1D array""" + ... + +def roll(array, distance, *, axis=None): + """Shift the content of a vector by the positions given as the second + argument. If the ``axis`` keyword is supplied, the shift is applied to + the given axis. The array is modified in place.""" + ... + +def std(array, *, axis=None): + """Return the standard deviation of the array, as a number if axis is None, otherwise as an array.""" + ... + +def sum(array, *, axis=None): + """Return the sum of the array, as a number if axis is None, otherwise as an array.""" + ... + +def sort(array, *, axis=0): + """Sort the array along the given axis, or along all axes if axis is None. + The array is modified in place.""" + ... diff --git a/shared-bindings/ulab/poly/__init__.pyi b/shared-bindings/ulab/poly/__init__.pyi new file mode 100644 index 0000000000..d051bbded4 --- /dev/null +++ b/shared-bindings/ulab/poly/__init__.pyi @@ -0,0 +1,10 @@ +"""Polynomial functions""" + +def polyfit(x, y, degree): + """Return a polynomial of given degree that approximates the function + f(x)=y. If x is not supplied, it is the range(len(y)).""" + ... + +def polyval(p, x): + """Evaluate the polynomial p at the points x. x must be an array.""" + ... diff --git a/shared-bindings/ulab/vector/__init__.pyi b/shared-bindings/ulab/vector/__init__.pyi new file mode 100644 index 0000000000..2c7a804463 --- /dev/null +++ b/shared-bindings/ulab/vector/__init__.pyi @@ -0,0 +1,108 @@ +"""Element-by-element functions + +These functions can operate on numbers, 1-D arrays, or 2-D arrays by +applying the function to every element in the array. This is typically +much more efficient than expressing the same operation as a Python loop.""" + +def acos(): + """Computes the inverse cosine function""" + ... + +def acosh(): + """Computes the inverse hyperbolic cosine function""" + ... + +def asin(): + """Computes the inverse sine function""" + ... + +def asinh(): + """Computes the inverse hyperbolic sine function""" + ... + +def around(a, *, decimals): + """Returns a new float array in which each element is rounded to + ``decimals`` places.""" + ... + +def atan(): + """Computes the inverse tangent function; the return values are in the + range [-pi/2,pi/2].""" + ... + +def atan2(y,x): + """Computes the inverse tangent function of y/x; the return values are in + the range [-pi, pi].""" + ... + +def atanh(): + """Computes the inverse hyperbolic tangent function""" + ... + +def ceil(): + """Rounds numbers up to the next whole number""" + ... + +def cos(): + """Computes the cosine function""" + ... + +def erf(): + """Computes the error function, which has applications in statistics""" + ... + +def erfc(): + """Computes the complementary error function, which has applications in statistics""" + ... + +def exp(): + """Computes the exponent function.""" + ... + +def expm1(): + """Computes $e^x-1$. In certain applications, using this function preserves numeric accuracy better than the `exp` function.""" + ... + +def floor(): + """Rounds numbers up to the next whole number""" + ... + +def gamma(): + """Computes the gamma function""" + ... + +def lgamma(): + """Computes the natural log of the gamma function""" + ... + +def log(): + """Computes the natural log""" + ... + +def log10(): + """Computes the log base 10""" + ... + +def log2(): + """Computes the log base 2""" + ... + +def sin(): + """Computes the sine""" + ... + +def sinh(): + """Computes the hyperbolic sine""" + ... + +def sqrt(): + """Computes the square root""" + ... + +def tan(): + """Computes the tangent""" + ... + +def tanh(): + """Computes the hyperbolic tangent""" + ... diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index 95370f7619..f15f15ba67 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -6,47 +6,47 @@ import traceback top_level = sys.argv[1].strip("/") stub_directory = sys.argv[2] -if top_level.count("/") == 1: - top_level, module = top_level.split("/") - modules = [module] -else: - modules = os.listdir(top_level) - modules = sorted(modules) - -ok = 0 -total = 0 -for module in modules: - module_path = os.path.join(top_level, module) - if not os.path.isdir(module_path): - continue +def convert_folder(top_level, stub_directory): + print(top_level, stub_directory) + ok = 0 + total = 0 + filenames = sorted(os.listdir(top_level)) pyi_lines = [] - classes = os.listdir(module_path) - classes = [x for x in sorted(classes) if x.endswith(".c")] - if classes and classes[-1] == "__init__.c": - classes.insert(0, classes.pop()) - for class_file in classes: - class_path = os.path.join(module_path, class_file) - with open(class_path, "r") as f: - for line in f: - if line.startswith("//|"): - if line[3] == " ": - line = line[4:] - elif line[3] == "\n": - line = line[3:] - else: - continue - pyi_lines.append(line) + for filename in filenames: + full_path = os.path.join(top_level, filename) + file_lines = [] + if os.path.isdir(full_path): + mok, mtotal = convert_folder(full_path, os.path.join(stub_directory, filename)) + ok += mok + total += mtotal + elif filename.endswith(".c"): + with open(full_path, "r") as f: + for line in f: + if line.startswith("//|"): + if line[3] == " ": + line = line[4:] + elif line[3] == "\n": + line = line[3:] + else: + continue + file_lines.append(line) + elif filename.endswith(".pyi"): + with open(full_path, "r") as f: + file_lines.extend(f.readlines()) - raw_stubs = [x for x in sorted(classes) if x.endswith(".pyi")] - if raw_stubs and raw_stubs[-1] == "__init__.pyi": - raw_stubs.insert(0, raw_stubs.pop()) - for raw_stub in raw_stubs: - raw_stub_path = os.path.join(module_path, raw_stub) - with open(raw_stub_path, "r") as f: - pyi_lines.extend(f.readlines()) - stub_filename = os.path.join(stub_directory, module + ".pyi") + # Always put the contents from an __init__ first. + if filename.startswith("__init__."): + pyi_lines = file_lines + pyi_lines + else: + pyi_lines.extend(file_lines) + + if not pyi_lines: + return ok, total + + stub_filename = os.path.join(stub_directory, "__init__.pyi") print(stub_filename) stub_contents = "".join(pyi_lines) + os.makedirs(stub_directory, exist_ok=True) with open(stub_filename, "w") as f: f.write(stub_contents) @@ -59,6 +59,9 @@ for module in modules: e = e.__cause__ traceback.print_exception(type(e), e, e.__traceback__) print() + return ok, total + +ok, total = convert_folder(top_level, stub_directory) print(f"{ok} ok out of {total}") From 15c2d16bf927c4cbf6c4dbb9773b7c835f26c06d Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 14 May 2020 16:06:13 -0700 Subject: [PATCH 111/216] Fix help doc --- shared-bindings/help.rst | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/shared-bindings/help.rst b/shared-bindings/help.rst index 63991bff2c..f6d72a5568 100644 --- a/shared-bindings/help.rst +++ b/shared-bindings/help.rst @@ -1,26 +1,26 @@ -# This file is part of the MicroPython project, http://micropython.org/ -# -# The MIT License (MIT) -# -# Copyright (c) 2016 Scott Shawcroft for Adafruit Industries -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +.. This file is part of the MicroPython project, http://micropython.org/ + + The MIT License (MIT) + + Copyright (c) 2016 Scott Shawcroft for Adafruit Industries + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. :func:`help` - Built-in method to provide helpful information ============================================================== From 8ac3e7977f87219454dbab50264a723e797b877a Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 14 May 2020 18:48:07 -0700 Subject: [PATCH 112/216] Remove debug prints --- conf.py | 1 - tools/extract_pyi.py | 1 - 2 files changed, 2 deletions(-) diff --git a/conf.py b/conf.py index ee65e39fb4..d6fa8f7e50 100644 --- a/conf.py +++ b/conf.py @@ -73,7 +73,6 @@ autoapi_type = 'python' # Uncomment this if debugging autoapi autoapi_keep_files = True autoapi_dirs = [os.path.join('circuitpython-stubs', x) for x in os.listdir('circuitpython-stubs')] -print(autoapi_dirs) autoapi_add_toctree_entry = False autoapi_options = ['members', 'undoc-members', 'private-members', 'show-inheritance', 'special-members', 'show-module-summary'] autoapi_template_dir = 'docs/autoapi/templates' diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index f15f15ba67..e590e25f1f 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -7,7 +7,6 @@ top_level = sys.argv[1].strip("/") stub_directory = sys.argv[2] def convert_folder(top_level, stub_directory): - print(top_level, stub_directory) ok = 0 total = 0 filenames = sorted(os.listdir(top_level)) From aba36e4abff80bc8897e752b93e7a2ffa4fd69e6 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 15 May 2020 10:14:09 +0800 Subject: [PATCH 113/216] aesio: use bufinfo rather than mp_str_bytes In order to accept both `bytes` objects and `bytearray` objects, use a `bufinfo` construct to retrieve the data rather than `mp_obj_str_get_data()`. Signed-off-by: Sean Cross --- shared-bindings/aesio/aes.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index 4ddcfa898b..a8f92e251e 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -103,9 +103,10 @@ STATIC mp_obj_t aesio_aes_make_new(const mp_obj_type_t *type, size_t n_args, STATIC mp_obj_t aesio_aes_rekey(size_t n_args, const mp_obj_t *pos_args) { aesio_aes_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - size_t key_length = 0; - const uint8_t *key = - (const uint8_t *)mp_obj_str_get_data(pos_args[1], &key_length); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(pos_args[1], &bufinfo, MP_BUFFER_READ); + const uint8_t *key = bufinfo.buf; + size_t key_length = bufinfo.len; if (key == NULL) { mp_raise_ValueError(translate("No key was specified")); } @@ -115,8 +116,9 @@ STATIC mp_obj_t aesio_aes_rekey(size_t n_args, const mp_obj_t *pos_args) { const uint8_t *iv = NULL; if (n_args > 2) { - size_t iv_length = 0; - iv = (const uint8_t *)mp_obj_str_get_data(pos_args[2], &iv_length); + mp_get_buffer_raise(pos_args[2], &bufinfo, MP_BUFFER_READ); + size_t iv_length = bufinfo.len; + iv = (const uint8_t *)bufinfo.buf; if (iv_length != AES_BLOCKLEN) { mp_raise_TypeError_varg(translate("IV must be %d bytes long"), AES_BLOCKLEN); @@ -246,11 +248,8 @@ MP_DEFINE_CONST_FUN_OBJ_2(aesio_aes_set_mode_obj, aesio_aes_set_mode); const mp_obj_property_t aesio_aes_mode_obj = { .base.type = &mp_type_property, - .proxy = { - (mp_obj_t)&aesio_aes_get_mode_obj, - (mp_obj_t)&aesio_aes_set_mode_obj, - (mp_obj_t)&mp_const_none_obj - }, + .proxy = {(mp_obj_t)&aesio_aes_get_mode_obj, + (mp_obj_t)&aesio_aes_set_mode_obj, (mp_obj_t)&mp_const_none_obj}, }; STATIC const mp_rom_map_elem_t aesio_locals_dict_table[] = { From f9ed3acf6d7582f495a4b6c1ae25aff5619a55ad Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 15 May 2020 10:20:49 +0800 Subject: [PATCH 114/216] aesio: specify writable buffers for destination buffers When calling `AES.decrypt_into()` or `AES.encrypt_into()`, the destination buffers may be any buffer kind. However, we currently aren't checking to make sure the destination buffer is actually writable. Specify `MP_BUFFER_WRITE` for the destination buffers of both of these objects so we don't inadvertently write to immutable data. Signed-off-by: Sean Cross --- shared-bindings/aesio/aes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index a8f92e251e..d92865b8a1 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -173,7 +173,7 @@ STATIC mp_obj_t aesio_aes_encrypt_into(mp_obj_t aesio_obj, mp_obj_t src, mp_buffer_info_t srcbufinfo, destbufinfo; mp_get_buffer_raise(src, &srcbufinfo, MP_BUFFER_READ); - mp_get_buffer_raise(dest, &destbufinfo, MP_BUFFER_READ); + mp_get_buffer_raise(dest, &destbufinfo, MP_BUFFER_WRITE); validate_length(aes, srcbufinfo.len, destbufinfo.len); memcpy(destbufinfo.buf, srcbufinfo.buf, srcbufinfo.len); @@ -203,7 +203,7 @@ STATIC mp_obj_t aesio_aes_decrypt_into(mp_obj_t aesio_obj, mp_obj_t src, mp_buffer_info_t srcbufinfo, destbufinfo; mp_get_buffer_raise(src, &srcbufinfo, MP_BUFFER_READ); - mp_get_buffer_raise(dest, &destbufinfo, MP_BUFFER_READ); + mp_get_buffer_raise(dest, &destbufinfo, MP_BUFFER_WRITE); validate_length(aes, srcbufinfo.len, destbufinfo.len); memcpy(destbufinfo.buf, srcbufinfo.buf, srcbufinfo.len); From fe3e8ee02c08e78691ebad293796985c9589824f Mon Sep 17 00:00:00 2001 From: Thea Flowers Date: Thu, 14 May 2020 21:16:26 -0700 Subject: [PATCH 115/216] Add bytearray.decode() for CPython compatibility CPython has a `decode()` method on `bytearray`. This adds that method using the code from `bytes.decode`. Test program: ```python byte_boi = bytes([0x6D, 0x65, 0x65, 0x70]) print(byte_boi) # b'meep' byte_boi_str = byte_boi.decode("utf-8") print(byte_boi_str) # meep byte_array_boi = bytearray(byte_boi) print(byte_array_boi) # bytearray(b'meep') byte_array_boi_str = byte_array_boi.decode("utf-8") print(byte_array_boi_str) # meep print(byte_array_boi_str == byte_boi_str) # True ``` --- py/objarray.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/py/objarray.c b/py/objarray.c index 9114a63c5a..5cdbd26788 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -63,6 +63,10 @@ STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_bu STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg); STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in); STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); +#if MICROPY_CPYTHON_COMPAT +STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args); +#endif + /******************************************************************************/ // array @@ -546,10 +550,30 @@ STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_ui return 0; } + +#if MICROPY_CPYTHON_COMPAT +// Directly lifted from objstr.c +STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args) { + mp_obj_t new_args[2]; + if (n_args == 1) { + new_args[0] = args[0]; + new_args[1] = MP_OBJ_NEW_QSTR(MP_QSTR_utf_hyphen_8); + args = new_args; + n_args++; + } + return mp_obj_str_make_new(&mp_type_str, n_args, args, NULL); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(array_decode_obj, 1, 3, array_decode); +#endif + + #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY STATIC const mp_rom_map_elem_t array_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&array_append_obj) }, { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&array_extend_obj) }, +#if MICROPY_CPYTHON_COMPAT + { MP_ROM_QSTR(MP_QSTR_decode), MP_ROM_PTR(&array_decode_obj) }, +#endif }; STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table); From 0876034adb8487f45c88224cb1ce29743848244e Mon Sep 17 00:00:00 2001 From: Thea Flowers Date: Fri, 15 May 2020 14:32:44 -0700 Subject: [PATCH 116/216] Make decode only apply to bytearray and not array as well --- py/objarray.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/py/objarray.c b/py/objarray.c index 5cdbd26788..fccb966a2b 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -551,7 +551,7 @@ STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_ui } -#if MICROPY_CPYTHON_COMPAT +#if MICROPY_CPYTHON_COMPAT && MICROPY_PY_BUILTINS_BYTEARRAY // Directly lifted from objstr.c STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args) { mp_obj_t new_args[2]; @@ -567,18 +567,28 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(array_decode_obj, 1, 3, array_decode); #endif -#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY +#if MICROPY_PY_ARRAY STATIC const mp_rom_map_elem_t array_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&array_append_obj) }, { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&array_extend_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table); +#endif + +#if MICROPY_PY_BUILTINS_BYTEARRAY +STATIC const mp_rom_map_elem_t bytearray_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&array_append_obj) }, + { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&array_extend_obj) }, #if MICROPY_CPYTHON_COMPAT { MP_ROM_QSTR(MP_QSTR_decode), MP_ROM_PTR(&array_decode_obj) }, #endif }; -STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(bytearray_locals_dict, bytearray_locals_dict_table); #endif + #if MICROPY_PY_ARRAY const mp_obj_type_t mp_type_array = { { &mp_type_type }, @@ -605,7 +615,7 @@ const mp_obj_type_t mp_type_bytearray = { .binary_op = array_binary_op, .subscr = array_subscr, .buffer_p = { .get_buffer = array_get_buffer }, - .locals_dict = (mp_obj_dict_t*)&array_locals_dict, + .locals_dict = (mp_obj_dict_t*)&bytearray_locals_dict, }; #endif From 7d167560af0e317edef2d4bc4385dfa0982f19f8 Mon Sep 17 00:00:00 2001 From: Thea Flowers Date: Fri, 15 May 2020 14:53:14 -0700 Subject: [PATCH 117/216] Note that nvm.ByteArray is available at microcontroller.nvm Fixes #2766 --- shared-bindings/nvm/__init__.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shared-bindings/nvm/__init__.c b/shared-bindings/nvm/__init__.c index 51c5bb2789..cdcc285dc4 100644 --- a/shared-bindings/nvm/__init__.c +++ b/shared-bindings/nvm/__init__.c @@ -34,7 +34,11 @@ //| """Non-volatile memory //| //| The `nvm` module allows you to store whatever raw bytes you wish in a -//| reserved section non-volatile memory.""" +//| reserved section non-volatile memory. +//| +//| Note that this module can't be imported and used directly. The sole +//| instance of :class:`ByteArray` is available at +//| :attr:`microcontroller.nvm`.""" //| STATIC const mp_rom_map_elem_t nvm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_nvm) }, From a3ca9401b4eab35d4fa3190141d576bcd059d070 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 15 May 2020 18:29:37 -0400 Subject: [PATCH 118/216] Shrink crickit build --- .../boards/circuitplayground_express_crickit/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index c5ef958c9b..3daa2e4fcd 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -20,7 +20,7 @@ CIRCUITPY_PIXELBUF = 1 CIRCUITPY_RTC = 0 SUPEROPT_GC = 0 -CFLAGS_INLINE_LIMIT = 55 +CFLAGS_INLINE_LIMIT = 50 # Include these Python libraries in firmware. From bad635e117e0b6a7aca55c72cb9a15e7a557507f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 15 May 2020 19:05:31 -0500 Subject: [PATCH 119/216] add new Czech (cs) translation file --- locale/cs.po | 3214 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3214 insertions(+) create mode 100644 locale/cs.po diff --git a/locale/cs.po b/locale/cs.po new file mode 100644 index 0000000000..493245dbfc --- /dev/null +++ b/locale/cs.po @@ -0,0 +1,3214 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: main.c +msgid "" +"\n" +"Code done running. Waiting for reload.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + +#: py/obj.c +msgid " File \"%q\"" +msgstr "" + +#: py/obj.c +msgid " File \"%q\", line %d" +msgstr "" + +#: main.c +msgid " output:\n" +msgstr "" + +#: py/objstr.c +#, c-format +msgid "%%c requires int or char" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgstr "" + +#: shared-bindings/microcontroller/Pin.c +msgid "%q in use" +msgstr "" + +#: py/obj.c +msgid "%q index out of range" +msgstr "" + +#: py/obj.c +msgid "%q indices must be integers, not %s" +msgstr "" + +#: shared-bindings/vectorio/Polygon.c +msgid "%q list must be a list" +msgstr "" + +#: shared-bindings/_bleio/CharacteristicBuffer.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c +#: shared-bindings/vectorio/Rectangle.c +msgid "%q must be >= 1" +msgstr "" + +#: shared-bindings/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "" + +#: shared-bindings/fontio/BuiltinFont.c +msgid "%q should be an int" +msgstr "" + +#: py/bc.c py/objnamedtuple.c +msgid "%q() takes %d positional arguments but %d were given" +msgstr "" + +#: py/argcheck.c +msgid "'%q' argument required" +msgstr "" + +#: py/emitinlinethumb.c py/emitinlinextensa.c +#, c-format +msgid "'%s' expects a label" +msgstr "" + +#: py/emitinlinethumb.c py/emitinlinextensa.c +#, c-format +msgid "'%s' expects a register" +msgstr "" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects a special register" +msgstr "" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects an FPU register" +msgstr "" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects an address of the form [a, b]" +msgstr "" + +#: py/emitinlinethumb.c py/emitinlinextensa.c +#, c-format +msgid "'%s' expects an integer" +msgstr "" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects at most r%d" +msgstr "" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects {r0, r1, ...}" +msgstr "" + +#: py/emitinlinextensa.c +#, c-format +msgid "'%s' integer %d is not within range %d..%d" +msgstr "" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' integer 0x%x does not fit in mask 0x%x" +msgstr "" + +#: py/runtime.c +msgid "'%s' object cannot assign attribute '%q'" +msgstr "" + +#: py/proto.c +msgid "'%s' object does not support '%q'" +msgstr "" + +#: py/obj.c +#, c-format +msgid "'%s' object does not support item assignment" +msgstr "" + +#: py/obj.c +#, c-format +msgid "'%s' object does not support item deletion" +msgstr "" + +#: py/runtime.c +msgid "'%s' object has no attribute '%q'" +msgstr "" + +#: py/runtime.c +#, c-format +msgid "'%s' object is not an iterator" +msgstr "" + +#: py/objtype.c py/runtime.c +#, c-format +msgid "'%s' object is not callable" +msgstr "" + +#: py/runtime.c +#, c-format +msgid "'%s' object is not iterable" +msgstr "" + +#: py/obj.c +#, c-format +msgid "'%s' object is not subscriptable" +msgstr "" + +#: py/objstr.c +msgid "'=' alignment not allowed in string format specifier" +msgstr "" + +#: shared-module/struct/__init__.c +msgid "'S' and 'O' are not supported format types" +msgstr "" + +#: py/compile.c +msgid "'align' requires 1 argument" +msgstr "" + +#: py/compile.c +msgid "'async for' or 'async with' outside async function" +msgstr "" + +#: py/compile.c +msgid "'await' outside function" +msgstr "" + +#: py/compile.c +msgid "'break' outside loop" +msgstr "" + +#: py/compile.c +msgid "'continue' outside loop" +msgstr "" + +#: py/compile.c +msgid "'data' requires at least 2 arguments" +msgstr "" + +#: py/compile.c +msgid "'data' requires integer arguments" +msgstr "" + +#: py/compile.c +msgid "'label' requires 1 argument" +msgstr "" + +#: py/compile.c +msgid "'return' outside function" +msgstr "" + +#: py/compile.c +msgid "'yield' outside function" +msgstr "" + +#: py/compile.c +msgid "*x must be assignment target" +msgstr "" + +#: py/obj.c +msgid ", in %q\n" +msgstr "" + +#: py/objcomplex.c +msgid "0.0 to a complex power" +msgstr "" + +#: py/modbuiltins.c +msgid "3-arg pow() not supported" +msgstr "" + +#: ports/atmel-samd/common-hal/countio/Counter.c +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +msgid "A hardware interrupt channel is already in use" +msgstr "" + +#: shared-bindings/_bleio/Address.c +#, c-format +msgid "Address must be %d bytes long" +msgstr "" + +#: shared-bindings/_bleio/Address.c +msgid "Address type out of range" +msgstr "" + +#: ports/nrf/common-hal/busio/I2C.c +msgid "All I2C peripherals are in use" +msgstr "" + +#: ports/nrf/common-hal/busio/SPI.c +msgid "All SPI peripherals are in use" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c +msgid "All UART peripherals are in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "All event channels in use" +msgstr "" + +#: ports/atmel-samd/audio_dma.c ports/atmel-samd/common-hal/audiobusio/PDMIn.c +msgid "All sync event channels in use" +msgstr "" + +#: shared-bindings/pulseio/PWMOut.c +msgid "All timers for this pin are in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c +#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c +msgid "All timers in use" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Already advertising." +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c +#: ports/nrf/common-hal/analogio/AnalogOut.c +msgid "AnalogOut functionality not supported" +msgstr "" + +#: shared-bindings/analogio/AnalogOut.c +msgid "AnalogOut is only 16 bits. Value must be less than 65536." +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogOut.c +msgid "AnalogOut not supported on given pin" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c +msgid "Another send is already active" +msgstr "" + +#: shared-bindings/pulseio/PulseOut.c +msgid "Array must contain halfwords (type 'H')" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c +msgid "Array values should be single bytes." +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "At most %d %q may be specified (not %d)" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Attempted heap allocation when MicroPython VM not running." +msgstr "" + +#: main.c +msgid "Auto-reload is off.\n" +msgstr "" + +#: main.c +msgid "" +"Auto-reload is on. Simply save files over USB to run them or enter REPL to " +"disable.\n" +msgstr "" + +#: shared-module/displayio/Display.c +#: shared-module/framebufferio/FramebufferDisplay.c +msgid "Below minimum frame rate" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +msgid "Bit clock and word select must share a clock unit" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Bit depth must be multiple of 8." +msgstr "" + +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +msgid "Both pins must support hardware interrupts" +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "Brightness must be 0-1.0" +msgstr "" + +#: shared-bindings/supervisor/__init__.c +msgid "Brightness must be between 0 and 255" +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Brightness not adjustable" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +#, c-format +msgid "Buffer + offset too small %d %d %d" +msgstr "" + +#: shared-module/usb_hid/Device.c +#, c-format +msgid "Buffer incorrect size. Should be %d bytes." +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Buffer is too small" +msgstr "" + +#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +msgid "Buffer must be at least length 1" +msgstr "" + +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + +#: shared-bindings/_bleio/PacketBuffer.c +#, c-format +msgid "Buffer too short by %d bytes" +msgstr "" + +#: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/nrf/common-hal/displayio/ParallelBus.c +#, c-format +msgid "Bus pin %d is already in use" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "Byte buffer must be 16 bytes." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c +msgid "Bytes must be between 0 and 255." +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "CBC blocks must be multiples of 16 bytes" +msgstr "" + +#: py/objtype.c +msgid "Call super().__init__() before accessing native object." +msgstr "" + +#: ports/nrf/common-hal/_bleio/Characteristic.c +msgid "Can't set CCCD on local Characteristic" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c +msgid "Cannot delete values" +msgstr "" + +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c +#: ports/nrf/common-hal/digitalio/DigitalInOut.c +msgid "Cannot get pull while in output mode" +msgstr "" + +#: ports/nrf/common-hal/microcontroller/Processor.c +msgid "Cannot get temperature" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "Cannot output both channels on the same pin" +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "Cannot read without MISO pin." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Cannot record to a file" +msgstr "" + +#: shared-module/storage/__init__.c +msgid "Cannot remount '/' when USB is active." +msgstr "" + +#: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c +msgid "Cannot reset into bootloader because no bootloader is present." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Cannot set value when direction is input." +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + +#: py/objslice.c +msgid "Cannot subclass slice" +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "Cannot transfer without MOSI and MISO pins." +msgstr "" + +#: extmod/moductypes.c +msgid "Cannot unambiguously get sizeof scalar" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "Cannot write without MOSI pin." +msgstr "" + +#: shared-bindings/_bleio/CharacteristicBuffer.c +msgid "CharacteristicBuffer writing not provided" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "Clock pin init failed." +msgstr "" + +#: shared-module/bitbangio/I2C.c +msgid "Clock stretch too long" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +msgid "Clock unit in use" +msgstr "" + +#: shared-bindings/_pew/PewPew.c +msgid "Column entry must be digitalio.DigitalInOut" +msgstr "" + +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c +msgid "Command must be an int between 0 and 255" +msgstr "" + +#: shared-bindings/_bleio/Connection.c +msgid "" +"Connection has been disconnected and can no longer be used. Create a new " +"connection." +msgstr "" + +#: py/persistentcode.c +msgid "Corrupt .mpy file" +msgstr "" + +#: py/emitglue.c +msgid "Corrupt raw code" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +msgid "Could not initialize UART" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c +msgid "Couldn't allocate decoder" +msgstr "" + +#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3Decoder.c +msgid "Couldn't allocate first buffer" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c +msgid "Couldn't allocate input buffer" +msgstr "" + +#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3Decoder.c +msgid "Couldn't allocate second buffer" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Crash into the HardFault_Handler." +msgstr "" + +#: ports/stm/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "DAC already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/nrf/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned" +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Data chunk must follow fmt chunk" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Data too large for advertisement packet" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Destination capacity is smaller than destination_length." +msgstr "" + +#: ports/nrf/common-hal/audiobusio/I2SOut.c +msgid "Device in use" +msgstr "" + +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/displayio/EPaperDisplay.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Display rotation must be in 90 degree increments" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Drive mode not used when direction is input." +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "ECB only operates on 16 bytes at a time" +msgstr "" + +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/atmel-samd/common-hal/ps2io/Ps2.c +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c +msgid "EXTINT channel already in use" +msgstr "" + +#: extmod/modure.c +msgid "Error in regex" +msgstr "" + +#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c +#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c +#: shared-bindings/terminalio/Terminal.c +msgid "Expected a %q" +msgstr "" + +#: shared-bindings/_bleio/CharacteristicBuffer.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c +msgid "Expected a Characteristic" +msgstr "" + +#: shared-bindings/_bleio/Characteristic.c +msgid "Expected a Service" +msgstr "" + +#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Service.c +msgid "Expected a UUID" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "Expected an Address" +msgstr "" + +#: shared-module/_pixelbuf/PixelBuf.c +#, c-format +msgid "Expected tuple of length %d, got %d" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + +#: extmod/ulab/code/fft.c +msgid "FFT is defined for ndarrays only" +msgstr "" + +#: shared-bindings/ps2io/Ps2.c +msgid "Failed sending command." +msgstr "" + +#: ports/nrf/sd_mutex.c +#, c-format +msgid "Failed to acquire mutex, err 0x%04x" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +msgid "Failed to allocate RX buffer" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c +#: ports/nrf/common-hal/pulseio/PulseIn.c +#: ports/stm/common-hal/pulseio/PulseIn.c +#, c-format +msgid "Failed to allocate RX buffer of %d bytes" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Failed to connect: internal error" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Failed to connect: timeout" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c +msgid "Failed to parse MP3 file" +msgstr "" + +#: ports/nrf/sd_mutex.c +#, c-format +msgid "Failed to release mutex, err 0x%04x" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + +#: py/moduerrno.c +msgid "File exists" +msgstr "" + +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +msgid "Frequency captured is above capability. Capture Paused." +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c +#: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c +msgid "Function requires lock" +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/displayio/EPaperDisplay.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Group already used" +msgstr "" + +#: shared-module/displayio/Group.c +msgid "Group full" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + +#: extmod/vfs_posix_file.c py/objstringio.c +msgid "I/O operation on closed file" +msgstr "" + +#: ports/stm/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + +#: extmod/machine_i2c.c +msgid "I2C operation not supported" +msgstr "" + +#: shared-bindings/aesio/aes.c +#, c-format +msgid "IV must be %d bytes long" +msgstr "" + +#: py/persistentcode.c +msgid "" +"Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/" +"mpy-update for more info." +msgstr "" + +#: shared-bindings/_pew/PewPew.c +msgid "Incorrect buffer size" +msgstr "" + +#: py/moduerrno.c +msgid "Input/output error" +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +msgid "Insufficient authentication" +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +msgid "Insufficient encryption" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + +#: shared-module/rgbmatrix/RGBMatrix.c +#, c-format +msgid "Internal error #%d" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +msgid "Invalid %q pin" +msgstr "" + +#: ports/stm/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c +msgid "Invalid BMP file" +msgstr "" + +#: ports/stm/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c +#: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c +msgid "Invalid PWM frequency" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + +#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +msgid "Invalid argument" +msgstr "" + +#: shared-module/displayio/Bitmap.c +msgid "Invalid bits per value" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +msgid "Invalid buffer size" +msgstr "" + +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +msgid "Invalid capture period. Valid range: 1 - 500" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "Invalid channel count" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Invalid direction." +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Invalid file" +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Invalid format chunk size" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + +#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c +msgid "Invalid number of bits" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c +#: shared-bindings/displayio/FourWire.c +msgid "Invalid phase" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/atmel-samd/common-hal/touchio/TouchIn.c +#: shared-bindings/pulseio/PWMOut.c shared-module/rgbmatrix/RGBMatrix.c +msgid "Invalid pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "Invalid pin for left channel" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "Invalid pin for right channel" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/SPI.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +msgid "Invalid pins" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "Invalid pins for PWMOut" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c +#: shared-bindings/displayio/FourWire.c +msgid "Invalid polarity" +msgstr "" + +#: shared-bindings/_bleio/Characteristic.c +msgid "Invalid properties" +msgstr "" + +#: shared-bindings/microcontroller/__init__.c +msgid "Invalid run mode." +msgstr "" + +#: shared-module/_bleio/Attribute.c +msgid "Invalid security_mode" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "Invalid voice" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "Invalid voice count" +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Invalid wave file" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "Key must be 16, 24, or 32 bytes long" +msgstr "" + +#: py/compile.c +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 "" + +#: py/objslice.c +msgid "Length must be an int" +msgstr "" + +#: py/objslice.c +msgid "Length must be non-negative" +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "MISO pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "MOSI pin init failed." +msgstr "" + +#: shared-module/displayio/Shape.c +#, c-format +msgid "Maximum x value when mirrored is %d" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "MicroPython NLR jump failed. Likely memory corruption." +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "MicroPython fatal error." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Microphone startup delay must be in range 0.0 to 1.0" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + +#: shared-bindings/displayio/Group.c +msgid "Must be a %q subclass." +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "Must use a multiple of 6 rgb pins, not %d" +msgstr "" + +#: py/parse.c +msgid "Name too long" +msgstr "" + +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm/common-hal/analogio/AnalogOut.c +msgid "No DAC on chip" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "No DMA channel found" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c +msgid "No RX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c +msgid "No TX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +msgid "No available clocks" +msgstr "" + +#: shared-bindings/_bleio/PacketBuffer.c +msgid "No connection: length cannot be determined" +msgstr "" + +#: shared-bindings/board/__init__.c +msgid "No default %q bus" +msgstr "" + +#: ports/atmel-samd/common-hal/touchio/TouchIn.c +msgid "No free GCLKs" +msgstr "" + +#: shared-bindings/os/__init__.c +msgid "No hardware random available" +msgstr "" + +#: ports/atmel-samd/common-hal/ps2io/Ps2.c +msgid "No hardware support on clk pin" +msgstr "" + +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +msgid "No hardware support on pin" +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "No key was specified" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "No long integer support" +msgstr "" + +#: ports/stm/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + +#: shared-module/touchio/TouchIn.c +msgid "No pulldown on pin; 1Mohm recommended" +msgstr "" + +#: py/moduerrno.c +msgid "No space left on device" +msgstr "" + +#: py/moduerrno.c +msgid "No such file/directory" +msgstr "" + +#: shared-module/rgbmatrix/RGBMatrix.c +msgid "No timer available" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +#: shared-bindings/_bleio/CharacteristicBuffer.c +msgid "Not connected" +msgstr "" + +#: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/PWMAudioOut.c +msgid "Not playing" +msgstr "" + +#: shared-bindings/util.c +msgid "" +"Object has been deinitialized and can no longer be used. Create a new object." +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c +msgid "Odd parity is not supported" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +msgid "Only 8 or 16 bit mono with " +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c +#, c-format +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c +#, c-format +msgid "" +"Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: " +"%d bpp given" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Oversample must be multiple of 8." +msgstr "" + +#: shared-bindings/pulseio/PWMOut.c +msgid "" +"PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)" +msgstr "" + +#: shared-bindings/pulseio/PWMOut.c +msgid "" +"PWM frequency not writable when variable_frequency is False on construction." +msgstr "" + +#: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c +#: ports/stm/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + +#: py/moduerrno.c +msgid "Permission denied" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c +#: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm/common-hal/analogio/AnalogIn.c +msgid "Pin does not have ADC capabilities" +msgstr "" + +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + +#: ports/stm/common-hal/pulseio/PulseIn.c +msgid "Pin number already reserved by EXTI" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "" +"Pinout uses %d bytes per element, which consumes more than the ideal %d " +"bytes. If this cannot be avoided, pass allow_inefficient=True to the " +"constructor" +msgstr "" + +#: py/builtinhelp.c +msgid "Plus any modules on the filesystem\n" +msgstr "" + +#: shared-bindings/ps2io/Ps2.c +msgid "Pop from an empty Ps2 buffer" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "Prefix buffer must be on the heap" +msgstr "" + +#: main.c +msgid "Press any key to enter the REPL. Use CTRL-D to reload." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Pull not used when direction is output." +msgstr "" + +#: ports/stm/common-hal/pulseio/PulseIn.c +msgid "PulseIn not supported on this chip" +msgstr "" + +#: ports/stm/common-hal/pulseio/PulseOut.c +msgid "PulseOut not supported on this chip" +msgstr "" + +#: ports/stm/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c +#: ports/nrf/common-hal/rtc/RTC.c +msgid "RTC calibration is not supported on this board" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "RTC is not supported on this board" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + +#: ports/stm/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c +msgid "Read-only" +msgstr "" + +#: extmod/vfs_fat.c py/moduerrno.c +msgid "Read-only filesystem" +msgstr "" + +#: shared-module/displayio/Bitmap.c +msgid "Read-only object" +msgstr "" + +#: shared-bindings/displayio/EPaperDisplay.c +msgid "Refresh too soon" +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "Requested AES mode is unsupported" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "Right channel unsupported" +msgstr "" + +#: shared-bindings/_pew/PewPew.c +msgid "Row entry must be digitalio.DigitalInOut" +msgstr "" + +#: main.c +msgid "Running in safe mode! Auto-reload is off.\n" +msgstr "" + +#: main.c +msgid "Running in safe mode! Not running saved code.\n" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +msgid "SDA or SCL needs a pull up" +msgstr "" + +#: ports/stm/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "Sample rate must be positive" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +#, c-format +msgid "Sample rate too high. It must be less than %d" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Scan already in progess. Stop with stop_scan." +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +msgid "Serializer in use" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c +msgid "Slice and value different lengths." +msgstr "" + +#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c +msgid "Slices not supported" +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "Source and destination buffers must be the same length" +msgstr "" + +#: extmod/modure.c +msgid "Splitting with sub-captures" +msgstr "" + +#: shared-bindings/supervisor/__init__.c +msgid "Stack size must be at least 256" +msgstr "" + +#: shared-bindings/multiterminal/__init__.c +msgid "Stream missing readinto() or write() method." +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + +#: ports/stm/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Please increase the stack size if you know how, or if not:" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"The `microcontroller` module was used to boot into safe mode. Press reset to " +"exit safe mode.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"The microcontroller's power dipped. Make sure your power supply provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" + +#: shared-module/audiomixer/MixerVoice.c +msgid "The sample's bits_per_sample does not match the mixer's" +msgstr "" + +#: shared-module/audiomixer/MixerVoice.c +msgid "The sample's channel count does not match the mixer's" +msgstr "" + +#: shared-module/audiomixer/MixerVoice.c +msgid "The sample's sample rate does not match the mixer's" +msgstr "" + +#: shared-module/audiomixer/MixerVoice.c +msgid "The sample's signedness does not match the mixer's" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c +msgid "Tile height must exactly divide bitmap height" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c shared-module/displayio/TileGrid.c +msgid "Tile index out of bounds" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c +msgid "Tile value out of bounds" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c +msgid "Tile width must exactly divide bitmap width" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +msgid "Too many channels in sample." +msgstr "" + +#: shared-module/displayio/__init__.c +msgid "Too many display busses" +msgstr "" + +#: shared-module/displayio/__init__.c +msgid "Too many displays" +msgstr "" + +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Total data to write is larger than outgoing_packet_length" +msgstr "" + +#: py/obj.c +msgid "Traceback (most recent call last):\n" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "Tuple or struct_time argument required" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + +#: shared-module/usb_hid/Device.c +msgid "USB Busy" +msgstr "" + +#: shared-module/usb_hid/Device.c +msgid "USB Error" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "UUID integer value must be 0-0xffff" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "UUID value is not str, int or byte buffer" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "Unable to allocate buffers for signed conversion" +msgstr "" + +#: shared-module/displayio/I2CDisplay.c +#, c-format +msgid "Unable to find I2C Display at %x" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +msgid "Unable to find free GCLK" +msgstr "" + +#: py/parse.c +msgid "Unable to init parser" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c +msgid "Unable to read color palette data" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c +msgid "Unable to write to nvm." +msgstr "" + +#: ports/nrf/common-hal/_bleio/UUID.c +msgid "Unexpected nrfx uuid type" +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown gatt error: 0x%04x" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown security error: 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown soft device error: %04x" +msgstr "" + +#: shared-bindings/_pixelbuf/PixelBuf.c +#, c-format +msgid "Unmatched number of items on RHS (expected %d, got %d)." +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +msgid "" +"Unspecified issue. Can be that the pairing prompt on the other device was " +"declined or ignored." +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c +msgid "Unsupported baudrate" +msgstr "" + +#: shared-module/displayio/display_core.c +msgid "Unsupported display bus type" +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Unsupported format" +msgstr "" + +#: py/moduerrno.c +msgid "Unsupported operation" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Unsupported pull value." +msgstr "" + +#: ports/nrf/common-hal/_bleio/Characteristic.c +#: ports/nrf/common-hal/_bleio/Descriptor.c +msgid "Value length != required fixed length" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Characteristic.c +#: ports/nrf/common-hal/_bleio/Descriptor.c +msgid "Value length > max_length" +msgstr "" + +#: py/emitnative.c +msgid "Viper functions don't currently support more than 4 arguments" +msgstr "" + +#: ports/stm/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + +#: main.c +msgid "WARNING: Your code filename has two extensions\n" +msgstr "" + +#: py/builtinhelp.c +#, c-format +msgid "" +"Welcome to Adafruit CircuitPython %s!\n" +"\n" +"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"\n" +"To list built-in modules please do `help(\"modules\")`.\n" +msgstr "" + +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "You are in safe mode: something unanticipated happened.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "You requested starting safe mode by " +msgstr "" + +#: py/objtype.c +msgid "__init__() should return None" +msgstr "" + +#: py/objtype.c +#, c-format +msgid "__init__() should return None, not '%s'" +msgstr "" + +#: py/objobject.c +msgid "__new__ arg must be a user-type" +msgstr "" + +#: extmod/modubinascii.c extmod/moduhashlib.c +msgid "a bytes-like object is required" +msgstr "" + +#: lib/embed/abort_.c +msgid "abort() called" +msgstr "" + +#: extmod/machine_mem.c +#, c-format +msgid "address %08x is not aligned to %d bytes" +msgstr "" + +#: shared-bindings/i2cslave/I2CSlave.c +msgid "address out of bounds" +msgstr "" + +#: shared-bindings/i2cslave/I2CSlave.c +msgid "addresses is empty" +msgstr "" + +#: extmod/ulab/code/vectorise.c +msgid "arctan2 is implemented for scalars and ndarrays only" +msgstr "" + +#: py/modbuiltins.c +msgid "arg is an empty sequence" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "argsort argument must be an ndarray" +msgstr "" + +#: py/runtime.c +msgid "argument has wrong type" +msgstr "" + +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +msgid "argument num/types mismatch" +msgstr "" + +#: py/runtime.c +msgid "argument should be a '%q' not a '%q'" +msgstr "" + +#: extmod/ulab/code/linalg.c +msgid "arguments must be ndarrays" +msgstr "" + +#: py/objarray.c shared-bindings/nvm/ByteArray.c +msgid "array/bytes required on right side" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "attempt to get argmin/argmax of an empty sequence" +msgstr "" + +#: py/objstr.c +msgid "attributes not supported yet" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "axis must be -1, 0, None, or 1" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "axis must be -1, 0, or 1" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "axis must be None, 0, or 1" +msgstr "" + +#: py/builtinevex.c +msgid "bad compile mode" +msgstr "" + +#: py/objstr.c +msgid "bad conversion specifier" +msgstr "" + +#: py/objstr.c +msgid "bad format string" +msgstr "" + +#: py/binary.c +msgid "bad typecode" +msgstr "" + +#: py/emitnative.c +msgid "binary op %q not implemented" +msgstr "" + +#: shared-bindings/busio/UART.c +msgid "bits must be 7, 8 or 9" +msgstr "" + +#: extmod/machine_spi.c +msgid "bits must be 8" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "bits_per_sample must be 8 or 16" +msgstr "" + +#: py/emitinlinethumb.c +msgid "branch not in range" +msgstr "" + +#: shared-bindings/audiocore/RawSample.c +msgid "buffer must be a bytes-like object" +msgstr "" + +#: shared-module/struct/__init__.c +msgid "buffer size must match format" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c +msgid "buffer slices must be of equal length" +msgstr "" + +#: py/modstruct.c shared-bindings/struct/__init__.c +#: shared-module/struct/__init__.c +msgid "buffer too small" +msgstr "" + +#: extmod/machine_spi.c +msgid "buffers must be the same length" +msgstr "" + +#: shared-bindings/_pew/PewPew.c +msgid "buttons must be digitalio.DigitalInOut" +msgstr "" + +#: py/vm.c +msgid "byte code not implemented" +msgstr "" + +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "byteorder is not a string" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "bytes > 8 bits not supported" +msgstr "" + +#: py/objstr.c +msgid "bytes value out of range" +msgstr "" + +#: ports/atmel-samd/bindings/samd/Clock.c +msgid "calibration is out of range" +msgstr "" + +#: ports/atmel-samd/bindings/samd/Clock.c +msgid "calibration is read only" +msgstr "" + +#: ports/atmel-samd/common-hal/rtc/RTC.c +msgid "calibration value out of range +/-127" +msgstr "" + +#: py/emitinlinethumb.c +msgid "can only have up to 4 parameters to Thumb assembly" +msgstr "" + +#: py/emitinlinextensa.c +msgid "can only have up to 4 parameters to Xtensa assembly" +msgstr "" + +#: py/persistentcode.c +msgid "can only save bytecode" +msgstr "" + +#: py/objtype.c +msgid "can't add special method to already-subclassed class" +msgstr "" + +#: py/compile.c +msgid "can't assign to expression" +msgstr "" + +#: py/obj.c +#, c-format +msgid "can't convert %s to complex" +msgstr "" + +#: py/obj.c +#, c-format +msgid "can't convert %s to float" +msgstr "" + +#: py/obj.c +#, c-format +msgid "can't convert %s to int" +msgstr "" + +#: py/objstr.c +msgid "can't convert '%q' object to %q implicitly" +msgstr "" + +#: py/objint.c +msgid "can't convert NaN to int" +msgstr "" + +#: shared-bindings/i2cslave/I2CSlave.c +msgid "can't convert address to int" +msgstr "" + +#: py/objint.c +msgid "can't convert inf to int" +msgstr "" + +#: py/obj.c +msgid "can't convert to complex" +msgstr "" + +#: py/obj.c +msgid "can't convert to float" +msgstr "" + +#: py/obj.c +msgid "can't convert to int" +msgstr "" + +#: py/objstr.c +msgid "can't convert to str implicitly" +msgstr "" + +#: py/compile.c +msgid "can't declare nonlocal in outer code" +msgstr "" + +#: py/compile.c +msgid "can't delete expression" +msgstr "" + +#: py/emitnative.c +msgid "can't do binary op between '%q' and '%q'" +msgstr "" + +#: py/objcomplex.c +msgid "can't do truncated division of a complex number" +msgstr "" + +#: py/compile.c +msgid "can't have multiple **x" +msgstr "" + +#: py/compile.c +msgid "can't have multiple *x" +msgstr "" + +#: py/emitnative.c +msgid "can't implicitly convert '%q' to 'bool'" +msgstr "" + +#: py/emitnative.c +msgid "can't load from '%q'" +msgstr "" + +#: py/emitnative.c +msgid "can't load with '%q' index" +msgstr "" + +#: py/objgenerator.c +msgid "can't pend throw to just-started generator" +msgstr "" + +#: py/objgenerator.c +msgid "can't send non-None value to a just-started generator" +msgstr "" + +#: py/objnamedtuple.c +msgid "can't set attribute" +msgstr "" + +#: py/emitnative.c +msgid "can't store '%q'" +msgstr "" + +#: py/emitnative.c +msgid "can't store to '%q'" +msgstr "" + +#: py/emitnative.c +msgid "can't store with '%q' index" +msgstr "" + +#: py/objstr.c +msgid "" +"can't switch from automatic field numbering to manual field specification" +msgstr "" + +#: py/objstr.c +msgid "" +"can't switch from manual field specification to automatic field numbering" +msgstr "" + +#: py/objtype.c +msgid "cannot create '%q' instances" +msgstr "" + +#: py/objtype.c +msgid "cannot create instance" +msgstr "" + +#: py/runtime.c +msgid "cannot import name %q" +msgstr "" + +#: py/builtinimport.c +msgid "cannot perform relative import" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot reshape array (incompatible input/output shape)" +msgstr "" + +#: py/emitnative.c +msgid "casting" +msgstr "" + +#: shared-bindings/_stage/Text.c +msgid "chars buffer too small" +msgstr "" + +#: py/modbuiltins.c +msgid "chr() arg not in range(0x110000)" +msgstr "" + +#: py/modbuiltins.c +msgid "chr() arg not in range(256)" +msgstr "" + +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "color buffer must be a buffer, tuple, list, or int" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "color buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "color must be between 0x000000 and 0xffffff" +msgstr "" + +#: shared-bindings/displayio/ColorConverter.c +msgid "color should be an int" +msgstr "" + +#: py/objcomplex.c +msgid "complex division by zero" +msgstr "" + +#: py/objfloat.c py/parsenum.c +msgid "complex values not supported" +msgstr "" + +#: extmod/moduzlib.c +msgid "compression header" +msgstr "" + +#: py/parse.c +msgid "constant must be an integer" +msgstr "" + +#: py/emitnative.c +msgid "conversion to object" +msgstr "" + +#: extmod/ulab/code/filter.c +msgid "convolve arguments must be linear arrays" +msgstr "" + +#: extmod/ulab/code/filter.c +msgid "convolve arguments must be ndarrays" +msgstr "" + +#: extmod/ulab/code/filter.c +msgid "convolve arguments must not be empty" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "could not broadast input array from shape" +msgstr "" + +#: extmod/ulab/code/poly.c +msgid "could not invert Vandermonde matrix" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "ddof must be smaller than length of data set" +msgstr "" + +#: py/parsenum.c +msgid "decimal numbers not supported" +msgstr "" + +#: py/compile.c +msgid "default 'except' must be last" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "" +"destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "destination buffer must be an array of type 'H' for bit_depth = 16" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "destination_length must be an int >= 0" +msgstr "" + +#: py/objdict.c +msgid "dict update sequence has wrong length" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "diff argument must be an ndarray" +msgstr "" + +#: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c +#: shared-bindings/math/__init__.c +msgid "division by zero" +msgstr "" + +#: py/objdeque.c +msgid "empty" +msgstr "" + +#: shared-bindings/vectorio/Polygon.c +msgid "empty %q list" +msgstr "" + +#: extmod/moduheapq.c extmod/modutimeq.c +msgid "empty heap" +msgstr "" + +#: py/objstr.c +msgid "empty separator" +msgstr "" + +#: shared-bindings/random/__init__.c +msgid "empty sequence" +msgstr "" + +#: py/objstr.c +msgid "end of format while looking for conversion specifier" +msgstr "" + +#: shared-bindings/displayio/Shape.c +msgid "end_x should be an int" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: py/runtime.c +msgid "exceptions must derive from BaseException" +msgstr "" + +#: py/objstr.c +msgid "expected ':' after format specifier" +msgstr "" + +#: py/obj.c +msgid "expected tuple/list" +msgstr "" + +#: py/modthread.c +msgid "expecting a dict for keyword args" +msgstr "" + +#: py/compile.c +msgid "expecting an assembler instruction" +msgstr "" + +#: py/compile.c +msgid "expecting just a value for set" +msgstr "" + +#: py/compile.c +msgid "expecting key:value for dict" +msgstr "" + +#: py/argcheck.c +msgid "extra keyword arguments given" +msgstr "" + +#: py/argcheck.c +msgid "extra positional arguments given" +msgstr "" + +#: py/parse.c +msgid "f-string expression part cannot include a '#'" +msgstr "" + +#: py/parse.c +msgid "f-string expression part cannot include a backslash" +msgstr "" + +#: py/parse.c +msgid "f-string: empty expression not allowed" +msgstr "" + +#: py/parse.c +msgid "f-string: expecting '}'" +msgstr "" + +#: py/parse.c +msgid "f-string: single '}' is not allowed" +msgstr "" + +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c +#: shared-bindings/displayio/OnDiskBitmap.c +msgid "file must be a file opened in byte mode" +msgstr "" + +#: shared-bindings/storage/__init__.c +msgid "filesystem must provide mount method" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "first argument must be an iterable" +msgstr "" + +#: extmod/ulab/code/vectorise.c +msgid "first argument must be an ndarray" +msgstr "" + +#: py/objtype.c +msgid "first argument to super() must be type" +msgstr "" + +#: extmod/machine_spi.c +msgid "firstbit must be MSB" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "flattening order must be either 'C', or 'F'" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "flip argument must be an ndarray" +msgstr "" + +#: py/objint.c +msgid "float too big" +msgstr "" + +#: shared-bindings/_stage/Text.c +msgid "font must be 2048 bytes long" +msgstr "" + +#: py/objstr.c +msgid "format requires a dict" +msgstr "" + +#: py/objdeque.c +msgid "full" +msgstr "" + +#: py/argcheck.c +msgid "function does not take keyword arguments" +msgstr "" + +#: py/argcheck.c +#, c-format +msgid "function expected at most %d arguments, got %d" +msgstr "" + +#: py/bc.c py/objnamedtuple.c +msgid "function got multiple values for argument '%q'" +msgstr "" + +#: extmod/ulab/code/compare.c +msgid "function is implemented for scalars and ndarrays only" +msgstr "" + +#: py/argcheck.c +#, c-format +msgid "function missing %d required positional arguments" +msgstr "" + +#: py/bc.c +msgid "function missing keyword-only argument" +msgstr "" + +#: py/bc.c +msgid "function missing required keyword argument '%q'" +msgstr "" + +#: py/bc.c +#, c-format +msgid "function missing required positional argument #%d" +msgstr "" + +#: py/argcheck.c py/bc.c py/objnamedtuple.c +#, c-format +msgid "function takes %d positional arguments but %d were given" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "function takes exactly 9 arguments" +msgstr "" + +#: py/objgenerator.c +msgid "generator already executing" +msgstr "" + +#: py/objgenerator.c +msgid "generator ignored GeneratorExit" +msgstr "" + +#: shared-bindings/_stage/Layer.c +msgid "graphic must be 2048 bytes long" +msgstr "" + +#: extmod/moduheapq.c +msgid "heap must be a list" +msgstr "" + +#: py/compile.c +msgid "identifier redefined as global" +msgstr "" + +#: py/compile.c +msgid "identifier redefined as nonlocal" +msgstr "" + +#: py/objstr.c +msgid "incomplete format" +msgstr "" + +#: py/objstr.c +msgid "incomplete format key" +msgstr "" + +#: extmod/modubinascii.c +msgid "incorrect padding" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "index is out of bounds" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c +#: ports/nrf/common-hal/pulseio/PulseIn.c +#: ports/stm/common-hal/pulseio/PulseIn.c py/obj.c +msgid "index out of range" +msgstr "" + +#: py/obj.c +msgid "indices must be integers" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "indices must be integers, slices, or Boolean lists" +msgstr "" + +#: py/compile.c +msgid "inline assembler must be a function" +msgstr "" + +#: extmod/ulab/code/create.c +msgid "input argument must be an integer or a 2-tuple" +msgstr "" + +#: extmod/ulab/code/fft.c +msgid "input array length must be power of 2" +msgstr "" + +#: extmod/ulab/code/poly.c +msgid "input data must be an iterable" +msgstr "" + +#: extmod/ulab/code/linalg.c +msgid "input matrix is asymmetric" +msgstr "" + +#: extmod/ulab/code/linalg.c +msgid "input matrix is singular" +msgstr "" + +#: extmod/ulab/code/linalg.c +msgid "input must be square matrix" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "input must be tuple, list, range, or ndarray" +msgstr "" + +#: extmod/ulab/code/poly.c +msgid "input vectors must be of equal length" +msgstr "" + +#: py/parsenum.c +msgid "int() arg 2 must be >= 2 and <= 36" +msgstr "" + +#: py/objstr.c +msgid "integer required" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +#, c-format +msgid "interval must be in range %s-%s" +msgstr "" + +#: extmod/machine_i2c.c +msgid "invalid I2C peripheral" +msgstr "" + +#: extmod/machine_spi.c +msgid "invalid SPI peripheral" +msgstr "" + +#: lib/netutils/netutils.c +msgid "invalid arguments" +msgstr "" + +#: extmod/modussl_axtls.c +msgid "invalid cert" +msgstr "" + +#: extmod/uos_dupterm.c +msgid "invalid dupterm index" +msgstr "" + +#: extmod/modframebuf.c +msgid "invalid format" +msgstr "" + +#: py/objstr.c +msgid "invalid format specifier" +msgstr "" + +#: extmod/modussl_axtls.c +msgid "invalid key" +msgstr "" + +#: py/compile.c +msgid "invalid micropython decorator" +msgstr "" + +#: shared-bindings/random/__init__.c +msgid "invalid step" +msgstr "" + +#: py/compile.c py/parse.c +msgid "invalid syntax" +msgstr "" + +#: py/parsenum.c +msgid "invalid syntax for integer" +msgstr "" + +#: py/parsenum.c +#, c-format +msgid "invalid syntax for integer with base %d" +msgstr "" + +#: py/parsenum.c +msgid "invalid syntax for number" +msgstr "" + +#: py/objtype.c +msgid "issubclass() arg 1 must be a class" +msgstr "" + +#: py/objtype.c +msgid "issubclass() arg 2 must be a class or a tuple of classes" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "iterables are not of the same length" +msgstr "" + +#: extmod/ulab/code/linalg.c +msgid "iterations did not converge" +msgstr "" + +#: py/objstr.c +msgid "join expects a list of str/bytes objects consistent with self object" +msgstr "" + +#: py/argcheck.c +msgid "keyword argument(s) not yet implemented - use normal args instead" +msgstr "" + +#: py/bc.c +msgid "keywords must be strings" +msgstr "" + +#: py/emitinlinethumb.c py/emitinlinextensa.c +msgid "label '%q' not defined" +msgstr "" + +#: py/compile.c +msgid "label redefined" +msgstr "" + +#: py/stream.c +msgid "length argument not allowed for this type" +msgstr "" + +#: shared-bindings/audiomixer/MixerVoice.c +msgid "level must be between 0 and 1" +msgstr "" + +#: py/objarray.c +msgid "lhs and rhs should be compatible" +msgstr "" + +#: py/emitnative.c +msgid "local '%q' has type '%q' but source is '%q'" +msgstr "" + +#: py/emitnative.c +msgid "local '%q' used before type known" +msgstr "" + +#: py/vm.c +msgid "local variable referenced before assignment" +msgstr "" + +#: py/objint.c +msgid "long int not supported in this build" +msgstr "" + +#: py/parse.c +msgid "malformed f-string" +msgstr "" + +#: shared-bindings/_stage/Layer.c +msgid "map buffer too small" +msgstr "" + +#: py/modmath.c shared-bindings/math/__init__.c +msgid "math domain error" +msgstr "" + +#: extmod/ulab/code/linalg.c +msgid "matrix dimensions do not match" +msgstr "" + +#: extmod/ulab/code/linalg.c +msgid "matrix is not positive definite" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Characteristic.c +#: ports/nrf/common-hal/_bleio/Descriptor.c +#, c-format +msgid "max_length must be 0-%d when fixed_length is %s" +msgstr "" + +#: py/runtime.c +msgid "maximum recursion depth exceeded" +msgstr "" + +#: py/runtime.c +#, c-format +msgid "memory allocation failed, allocating %u bytes" +msgstr "" + +#: py/runtime.c +msgid "memory allocation failed, heap is locked" +msgstr "" + +#: py/builtinimport.c +msgid "module not found" +msgstr "" + +#: extmod/ulab/code/poly.c +msgid "more degrees of freedom than data points" +msgstr "" + +#: py/compile.c +msgid "multiple *x in assignment" +msgstr "" + +#: py/objtype.c +msgid "multiple bases have instance lay-out conflict" +msgstr "" + +#: py/objtype.c +msgid "multiple inheritance not supported" +msgstr "" + +#: py/emitnative.c +msgid "must raise an object" +msgstr "" + +#: extmod/machine_spi.c +msgid "must specify all of sck/mosi/miso" +msgstr "" + +#: py/modbuiltins.c +msgid "must use keyword argument for key function" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "n must be between 0, and 9" +msgstr "" + +#: py/runtime.c +msgid "name '%q' is not defined" +msgstr "" + +#: py/runtime.c +msgid "name not defined" +msgstr "" + +#: py/compile.c +msgid "name reused for argument" +msgstr "" + +#: py/emitnative.c +msgid "native yield" +msgstr "" + +#: py/runtime.c +#, c-format +msgid "need more than %d values to unpack" +msgstr "" + +#: py/objint_longlong.c py/objint_mpz.c py/runtime.c +msgid "negative power with no float support" +msgstr "" + +#: py/objint_mpz.c py/runtime.c +msgid "negative shift count" +msgstr "" + +#: py/vm.c +msgid "no active exception to reraise" +msgstr "" + +#: shared-bindings/socket/__init__.c shared-module/network/__init__.c +msgid "no available NIC" +msgstr "" + +#: py/compile.c +msgid "no binding for nonlocal found" +msgstr "" + +#: py/builtinimport.c +msgid "no module named '%q'" +msgstr "" + +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c +msgid "no reset pin available" +msgstr "" + +#: py/runtime.c +msgid "no such attribute" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Connection.c +msgid "non-UUID found in service_uuids_whitelist" +msgstr "" + +#: py/compile.c +msgid "non-default argument follows default argument" +msgstr "" + +#: extmod/modubinascii.c +msgid "non-hex digit found" +msgstr "" + +#: py/compile.c +msgid "non-keyword arg after */**" +msgstr "" + +#: py/compile.c +msgid "non-keyword arg after keyword arg" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "not a 128-bit UUID" +msgstr "" + +#: py/objstr.c +msgid "not all arguments converted during string formatting" +msgstr "" + +#: py/objstr.c +msgid "not enough arguments for format string" +msgstr "" + +#: extmod/ulab/code/poly.c +msgid "number of arguments must be 2, or 3" +msgstr "" + +#: extmod/ulab/code/create.c +msgid "number of points must be at least 2" +msgstr "" + +#: py/obj.c +#, c-format +msgid "object '%s' is not a tuple or list" +msgstr "" + +#: py/obj.c +msgid "object does not support item assignment" +msgstr "" + +#: py/obj.c +msgid "object does not support item deletion" +msgstr "" + +#: py/obj.c +msgid "object has no len" +msgstr "" + +#: py/obj.c +msgid "object is not subscriptable" +msgstr "" + +#: py/runtime.c +msgid "object not an iterator" +msgstr "" + +#: py/objtype.c py/runtime.c +msgid "object not callable" +msgstr "" + +#: py/sequence.c shared-bindings/displayio/Group.c +msgid "object not in sequence" +msgstr "" + +#: py/runtime.c +msgid "object not iterable" +msgstr "" + +#: py/obj.c +#, c-format +msgid "object of type '%s' has no len()" +msgstr "" + +#: py/obj.c +msgid "object with buffer protocol required" +msgstr "" + +#: extmod/modubinascii.c +msgid "odd-length string" +msgstr "" + +#: py/objstr.c py/objstrunicode.c +msgid "offset out of bounds" +msgstr "" + +#: ports/nrf/common-hal/audiobusio/PDMIn.c +msgid "only bit_depth=16 is supported" +msgstr "" + +#: ports/nrf/common-hal/audiobusio/PDMIn.c +msgid "only sample_rate=16000 is supported" +msgstr "" + +#: py/objarray.c py/objstr.c py/objstrunicode.c py/objtuple.c +#: shared-bindings/nvm/ByteArray.c +msgid "only slices with step=1 (aka None) are supported" +msgstr "" + +#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c +#: extmod/ulab/code/vectorise.c +msgid "operands could not be broadcast together" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "operation is not implemented on ndarrays" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "operation is not supported for given type" +msgstr "" + +#: py/modbuiltins.c +msgid "ord expects a character" +msgstr "" + +#: py/modbuiltins.c +#, c-format +msgid "ord() expected a character, but string of length %d found" +msgstr "" + +#: py/objint_mpz.c +msgid "overflow converting long int to machine word" +msgstr "" + +#: shared-bindings/_stage/Layer.c shared-bindings/_stage/Text.c +msgid "palette must be 32 bytes long" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "palette_index should be an int" +msgstr "" + +#: py/compile.c +msgid "parameter annotation must be an identifier" +msgstr "" + +#: py/emitinlinextensa.c +msgid "parameters must be registers in sequence a2 to a5" +msgstr "" + +#: py/emitinlinethumb.c +msgid "parameters must be registers in sequence r0 to r3" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c +msgid "pixel coordinates out of bounds" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c +msgid "pixel value requires too many bits" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" +msgstr "" + +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c +#: ports/nrf/common-hal/pulseio/PulseIn.c +#: ports/stm/common-hal/pulseio/PulseIn.c +msgid "pop from an empty PulseIn" +msgstr "" + +#: py/objset.c +msgid "pop from an empty set" +msgstr "" + +#: py/objlist.c +msgid "pop from empty list" +msgstr "" + +#: py/objdict.c +msgid "popitem(): dictionary is empty" +msgstr "" + +#: py/objint_mpz.c +msgid "pow() 3rd argument cannot be 0" +msgstr "" + +#: py/objint_mpz.c +msgid "pow() with 3 arguments requires integers" +msgstr "" + +#: extmod/modutimeq.c +msgid "queue overflow" +msgstr "" + +#: py/parse.c +msgid "raw f-strings are not implemented" +msgstr "" + +#: extmod/ulab/code/fft.c +msgid "real and imaginary parts must be of equal length" +msgstr "" + +#: py/builtinimport.c +msgid "relative import" +msgstr "" + +#: py/obj.c +#, c-format +msgid "requested length %d but object has length %d" +msgstr "" + +#: py/compile.c +msgid "return annotation must be an identifier" +msgstr "" + +#: py/emitnative.c +msgid "return expected '%q' but got '%q'" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "rgb_pins[%d] duplicates another pin assignment" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "rgb_pins[%d] is not on the same port as clock" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "right hand side must be an ndarray, or a scalar" +msgstr "" + +#: py/objstr.c +msgid "rsplit(None,n)" +msgstr "" + +#: shared-bindings/audiocore/RawSample.c +msgid "" +"sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " +"'B'" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +msgid "sampling rate out of range" +msgstr "" + +#: py/modmicropython.c +msgid "schedule stack full" +msgstr "" + +#: lib/utils/pyexec.c py/builtinimport.c +msgid "script compilation not supported" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "shape must be a 2-tuple" +msgstr "" + +#: py/objstr.c +msgid "sign not allowed in string format specifier" +msgstr "" + +#: py/objstr.c +msgid "sign not allowed with integer format specifier 'c'" +msgstr "" + +#: py/objstr.c +msgid "single '}' encountered in format string" +msgstr "" + +#: extmod/ulab/code/linalg.c +msgid "size is defined for ndarrays only" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "sleep length must be non-negative" +msgstr "" + +#: py/objslice.c py/sequence.c +msgid "slice step cannot be zero" +msgstr "" + +#: py/objint.c py/sequence.c +msgid "small int overflow" +msgstr "" + +#: main.c +msgid "soft reboot\n" +msgstr "" + +#: extmod/ulab/code/numerical.c +msgid "sort argument must be an ndarray" +msgstr "" + +#: py/objstr.c +msgid "start/end indices" +msgstr "" + +#: shared-bindings/displayio/Shape.c +msgid "start_x should be an int" +msgstr "" + +#: shared-bindings/random/__init__.c +msgid "step must be non-zero" +msgstr "" + +#: shared-bindings/busio/UART.c +msgid "stop must be 1 or 2" +msgstr "" + +#: shared-bindings/random/__init__.c +msgid "stop not reachable from start" +msgstr "" + +#: py/stream.c +msgid "stream operation not supported" +msgstr "" + +#: py/objstrunicode.c +msgid "string index out of range" +msgstr "" + +#: py/objstrunicode.c +#, c-format +msgid "string indices must be integers, not %s" +msgstr "" + +#: py/stream.c +msgid "string not supported; use bytes or bytearray" +msgstr "" + +#: extmod/moductypes.c +msgid "struct: cannot index" +msgstr "" + +#: extmod/moductypes.c +msgid "struct: index out of range" +msgstr "" + +#: extmod/moductypes.c +msgid "struct: no fields" +msgstr "" + +#: py/objstr.c +msgid "substring not found" +msgstr "" + +#: py/compile.c +msgid "super() can't find self" +msgstr "" + +#: extmod/modujson.c +msgid "syntax error in JSON" +msgstr "" + +#: extmod/moductypes.c +msgid "syntax error in uctypes descriptor" +msgstr "" + +#: shared-bindings/touchio/TouchIn.c +msgid "threshold must be in the range 0-65536" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "time.struct_time() takes a 9-sequence" +msgstr "" + +#: shared-bindings/busio/UART.c +msgid "timeout must be 0.0-100.0 seconds" +msgstr "" + +#: shared-bindings/_bleio/CharacteristicBuffer.c +msgid "timeout must be >= 0.0" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "timestamp out of range for platform time_t" +msgstr "" + +#: shared-module/struct/__init__.c +msgid "too many arguments provided with the given format" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "too many indices" +msgstr "" + +#: py/runtime.c +#, c-format +msgid "too many values to unpack (expected %d)" +msgstr "" + +#: extmod/ulab/code/linalg.c py/objstr.c +msgid "tuple index out of range" +msgstr "" + +#: py/obj.c +msgid "tuple/list has wrong length" +msgstr "" + +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "tuple/list required on RHS" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: shared-bindings/busio/UART.c +msgid "tx and rx cannot both be None" +msgstr "" + +#: py/objtype.c +msgid "type '%q' is not an acceptable base type" +msgstr "" + +#: py/objtype.c +msgid "type is not an acceptable base type" +msgstr "" + +#: py/runtime.c +msgid "type object '%q' has no attribute '%q'" +msgstr "" + +#: py/objtype.c +msgid "type takes 1 or 3 arguments" +msgstr "" + +#: py/objint_longlong.c +msgid "ulonglong too large" +msgstr "" + +#: py/emitnative.c +msgid "unary op %q not implemented" +msgstr "" + +#: py/parse.c +msgid "unexpected indent" +msgstr "" + +#: py/bc.c +msgid "unexpected keyword argument" +msgstr "" + +#: py/bc.c py/objnamedtuple.c +msgid "unexpected keyword argument '%q'" +msgstr "" + +#: py/lexer.c +msgid "unicode name escapes" +msgstr "" + +#: py/parse.c +msgid "unindent does not match any outer indentation level" +msgstr "" + +#: py/objstr.c +#, c-format +msgid "unknown conversion specifier %c" +msgstr "" + +#: py/objstr.c +#, c-format +msgid "unknown format code '%c' for object of type '%s'" +msgstr "" + +#: py/compile.c +msgid "unknown type" +msgstr "" + +#: py/emitnative.c +msgid "unknown type '%q'" +msgstr "" + +#: py/objstr.c +msgid "unmatched '{' in format" +msgstr "" + +#: py/objtype.c py/runtime.c +msgid "unreadable attribute" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c +#: shared-bindings/vectorio/VectorShape.c +msgid "unsupported %q type" +msgstr "" + +#: py/emitinlinethumb.c +#, c-format +msgid "unsupported Thumb instruction '%s' with %d arguments" +msgstr "" + +#: py/emitinlinextensa.c +#, c-format +msgid "unsupported Xtensa instruction '%s' with %d arguments" +msgstr "" + +#: py/objstr.c +#, c-format +msgid "unsupported format character '%c' (0x%x) at index %d" +msgstr "" + +#: py/runtime.c +msgid "unsupported type for %q: '%s'" +msgstr "" + +#: py/runtime.c +msgid "unsupported type for operator" +msgstr "" + +#: py/runtime.c +msgid "unsupported types for %q: '%s', '%s'" +msgstr "" + +#: py/objint.c +#, c-format +msgid "value must fit in %d byte(s)" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "window must be <= interval" +msgstr "" + +#: extmod/ulab/code/linalg.c +msgid "wrong argument type" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "wrong index type" +msgstr "" + +#: py/objstr.c +msgid "wrong number of arguments" +msgstr "" + +#: py/runtime.c +msgid "wrong number of values to unpack" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "wrong operand type" +msgstr "" + +#: shared-module/displayio/Shape.c +msgid "x value out of bounds" +msgstr "" + +#: shared-bindings/displayio/Shape.c +msgid "y should be an int" +msgstr "" + +#: shared-module/displayio/Shape.c +msgid "y value out of bounds" +msgstr "" + +#: py/objrange.c +msgid "zero step" +msgstr "" From e175a64036585a4848892c33620e7b0ac1d40ece Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 15 May 2020 20:35:12 -0400 Subject: [PATCH 120/216] disable rotaryio in CPX crickit --- .../boards/circuitplayground_express_crickit/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index 3daa2e4fcd..46a245e609 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -17,6 +17,7 @@ CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_PIXELBUF = 1 +CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 SUPEROPT_GC = 0 From 7424e418272eaf34e84ae579188e89e18a5f5a9f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 16 May 2020 11:20:25 -0400 Subject: [PATCH 121/216] update frozen libs --- frozen/Adafruit_CircuitPython_BLE | 2 +- frozen/Adafruit_CircuitPython_BusDevice | 2 +- frozen/Adafruit_CircuitPython_CircuitPlayground | 2 +- frozen/Adafruit_CircuitPython_Crickit | 2 +- frozen/Adafruit_CircuitPython_DotStar | 2 +- frozen/Adafruit_CircuitPython_ESP32SPI | 2 +- frozen/Adafruit_CircuitPython_HID | 2 +- frozen/Adafruit_CircuitPython_IRRemote | 2 +- frozen/Adafruit_CircuitPython_LIS3DH | 2 +- frozen/Adafruit_CircuitPython_LSM6DS | 2 +- frozen/Adafruit_CircuitPython_Motor | 2 +- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- frozen/Adafruit_CircuitPython_Register | 2 +- frozen/Adafruit_CircuitPython_Requests | 2 +- frozen/Adafruit_CircuitPython_SD | 2 +- frozen/Adafruit_CircuitPython_Thermistor | 2 +- frozen/Adafruit_CircuitPython_seesaw | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_BLE b/frozen/Adafruit_CircuitPython_BLE index 96774b15da..5d584576ef 160000 --- a/frozen/Adafruit_CircuitPython_BLE +++ b/frozen/Adafruit_CircuitPython_BLE @@ -1 +1 @@ -Subproject commit 96774b15da61da54662bcfbbf15b5bdc27315a9f +Subproject commit 5d584576ef79ca36506e6c7470e7ac5204cf0a8d diff --git a/frozen/Adafruit_CircuitPython_BusDevice b/frozen/Adafruit_CircuitPython_BusDevice index 0b0d1e999a..e9411c4244 160000 --- a/frozen/Adafruit_CircuitPython_BusDevice +++ b/frozen/Adafruit_CircuitPython_BusDevice @@ -1 +1 @@ -Subproject commit 0b0d1e999a6c7944e55bed59a30ccc21b3c96666 +Subproject commit e9411c4244984b69ec6928370ede40cec014c10b diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index 2cf0f40ab8..e9f15d6150 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit 2cf0f40ab818fddbc2cecf3ec495ed16067c5f7e +Subproject commit e9f15d61502f34173912ba271aaaf9446dae8da1 diff --git a/frozen/Adafruit_CircuitPython_Crickit b/frozen/Adafruit_CircuitPython_Crickit index 09bd10e948..0e1230676a 160000 --- a/frozen/Adafruit_CircuitPython_Crickit +++ b/frozen/Adafruit_CircuitPython_Crickit @@ -1 +1 @@ -Subproject commit 09bd10e94894a4eec7e3a02b51ffb5d8581b3024 +Subproject commit 0e1230676a54da17a309d1dfffdd7fa90240191c diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index 84eadeafa9..f4f66fa039 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit 84eadeafa9144829b8c6faf903b4282d58a77353 +Subproject commit f4f66fa03990428c239eac68d37f79a7245b4cd3 diff --git a/frozen/Adafruit_CircuitPython_ESP32SPI b/frozen/Adafruit_CircuitPython_ESP32SPI index f523b2316b..94b03517c1 160000 --- a/frozen/Adafruit_CircuitPython_ESP32SPI +++ b/frozen/Adafruit_CircuitPython_ESP32SPI @@ -1 +1 @@ -Subproject commit f523b2316bc3e25220b88c5435868c6a5880dfab +Subproject commit 94b03517c1f4ff68cc2bb09b0963f7e7e3ce3d04 diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index f044548d6d..65fb213b8c 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit f044548d6d3aa21650b50232bb16e0b29f540b8f +Subproject commit 65fb213b8c554181d54b77f75335e16e2f4c0987 diff --git a/frozen/Adafruit_CircuitPython_IRRemote b/frozen/Adafruit_CircuitPython_IRRemote index 9dac9628e4..d435fc9a9d 160000 --- a/frozen/Adafruit_CircuitPython_IRRemote +++ b/frozen/Adafruit_CircuitPython_IRRemote @@ -1 +1 @@ -Subproject commit 9dac9628e48675308d447b70b2005f7d1f0ddf6b +Subproject commit d435fc9a9d90cb063608ae037bf5284b33bc5e84 diff --git a/frozen/Adafruit_CircuitPython_LIS3DH b/frozen/Adafruit_CircuitPython_LIS3DH index 42a55eafcb..457aba6dd5 160000 --- a/frozen/Adafruit_CircuitPython_LIS3DH +++ b/frozen/Adafruit_CircuitPython_LIS3DH @@ -1 +1 @@ -Subproject commit 42a55eafcb29f563b31e23af902c31dac8289900 +Subproject commit 457aba6dd59ad00502b80c9031655d3d26ecc82b diff --git a/frozen/Adafruit_CircuitPython_LSM6DS b/frozen/Adafruit_CircuitPython_LSM6DS index 24224cc905..ee8f2187d4 160000 --- a/frozen/Adafruit_CircuitPython_LSM6DS +++ b/frozen/Adafruit_CircuitPython_LSM6DS @@ -1 +1 @@ -Subproject commit 24224cc905fad4646506caeb2451b4a495804ffc +Subproject commit ee8f2187d4795b08ae4aa60558f564d26c997be9 diff --git a/frozen/Adafruit_CircuitPython_Motor b/frozen/Adafruit_CircuitPython_Motor index ddcd1e7154..5fd72fb963 160000 --- a/frozen/Adafruit_CircuitPython_Motor +++ b/frozen/Adafruit_CircuitPython_Motor @@ -1 +1 @@ -Subproject commit ddcd1e7154f1b27f9a87daffb6e691e1e7051b64 +Subproject commit 5fd72fb963c4a0318d29282ca2cc988f19787fda diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index 10db851c81..59add970cc 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit 10db851c81873fd8db207ff0c4d9342426ee25a4 +Subproject commit 59add970cc66f9b0f2d45082e86b25650843a159 diff --git a/frozen/Adafruit_CircuitPython_Register b/frozen/Adafruit_CircuitPython_Register index c525eedeb0..56358b4494 160000 --- a/frozen/Adafruit_CircuitPython_Register +++ b/frozen/Adafruit_CircuitPython_Register @@ -1 +1 @@ -Subproject commit c525eedeb0d20c9829febfbf621eab707da71f8a +Subproject commit 56358b4494da825cd99a56a854119f926abca670 diff --git a/frozen/Adafruit_CircuitPython_Requests b/frozen/Adafruit_CircuitPython_Requests index e8a759719e..41de8b3c05 160000 --- a/frozen/Adafruit_CircuitPython_Requests +++ b/frozen/Adafruit_CircuitPython_Requests @@ -1 +1 @@ -Subproject commit e8a759719e94c69a01f9e07d418ca6db39114db3 +Subproject commit 41de8b3c05dd78d7be8893a0f6cb47a7e9b421a2 diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD index efd548b1e3..96ee9954a3 160000 --- a/frozen/Adafruit_CircuitPython_SD +++ b/frozen/Adafruit_CircuitPython_SD @@ -1 +1 @@ -Subproject commit efd548b1e36c534bbce494f4cb0d9a625dd170cd +Subproject commit 96ee9954a3099ee9c9d7d7b7747f30ab3c6a45bf diff --git a/frozen/Adafruit_CircuitPython_Thermistor b/frozen/Adafruit_CircuitPython_Thermistor index ac83a3dc70..b5bbdbd56c 160000 --- a/frozen/Adafruit_CircuitPython_Thermistor +++ b/frozen/Adafruit_CircuitPython_Thermistor @@ -1 +1 @@ -Subproject commit ac83a3dc703ec50b2236c773d22c47a0c0aaba43 +Subproject commit b5bbdbd56ca205c581ba2c84d927ef99befce88e diff --git a/frozen/Adafruit_CircuitPython_seesaw b/frozen/Adafruit_CircuitPython_seesaw index dc01285aa4..76c0dd1329 160000 --- a/frozen/Adafruit_CircuitPython_seesaw +++ b/frozen/Adafruit_CircuitPython_seesaw @@ -1 +1 @@ -Subproject commit dc01285aa45dd8260bb3ae35a657e4cdcbf325b8 +Subproject commit 76c0dd13294ce8ae0518cb9882dcad5d3668977e From db924fb01eaf267b9516d355ba8cb3ba404c7096 Mon Sep 17 00:00:00 2001 From: ppolk-nocimed Date: Sat, 16 May 2020 12:47:49 -0700 Subject: [PATCH 122/216] Digital In Out Type Hints --- shared-bindings/digitalio/DigitalInOut.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 54ced099db..0ae8b804c7 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -71,7 +71,7 @@ STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type, return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: +//| def deinit(self) -> None: //| """Turn off the DigitalInOut and release the pin for other use.""" //| ... //| @@ -82,13 +82,13 @@ STATIC mp_obj_t digitalio_digitalinout_obj_deinit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_deinit_obj, digitalio_digitalinout_obj_deinit); -//| def __enter__(self, ) -> Any: +//| def __enter__(self, ) -> self: //| """No-op used by Context Managers.""" //| ... //| // Provided by context manager helper. -//| def __exit__(self, ) -> Any: +//| def __exit__(self, ) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... @@ -106,12 +106,13 @@ STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) { } } -//| def switch_to_output(self, value: bool = False, drive_mode: digitalio.DriveMode = digitalio.DriveMode.PUSH_PULL) -> Any: +//| def switch_to_output(self, value: bool = False, drive_mode: digitalio.DriveMode = digitalio.DriveMode.PUSH_PULL) -> None: //| """Set the drive mode and value and then switch to writing out digital //| values. //| //| :param bool value: default value to set upon switching -//| :param ~digitalio.DriveMode drive_mode: drive mode for the output""" +//| :param ~digitalio.DriveMode drive_mode: drive mode for the output +//| """ //| ... //| STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -135,7 +136,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_ } MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_output_obj, 1, digitalio_digitalinout_switch_to_output); -//| def switch_to_input(self, pull: Pull = None) -> Any: +//| def switch_to_input(self, pull: Pull = None) -> None: //| """Set the pull and then switch to read in digital values. //| //| :param Pull pull: pull configuration for the input @@ -161,6 +162,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o 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); + digitalio_pull_t pull = PULL_NONE; if (args[ARG_pull].u_rom_obj == &digitalio_pull_up_obj) { @@ -174,7 +176,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o } MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_input_obj, 1, digitalio_digitalinout_switch_to_input); -//| direction: Any = ... +//| direction: Direction = ... //| """The direction of the pin. //| //| Setting this will use the defaults from the corresponding @@ -220,7 +222,7 @@ const mp_obj_property_t digitalio_digitalio_direction_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| value: Any = ... +//| value: Bool = ... //| """The digital logic level of the pin.""" //| STATIC mp_obj_t digitalio_digitalinout_obj_get_value(mp_obj_t self_in) { @@ -250,7 +252,7 @@ const mp_obj_property_t digitalio_digitalinout_value_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| drive_mode: Any = ... +//| drive_mode: DriveMode = ... //| """The pin drive mode. One of: //| //| - `digitalio.DriveMode.PUSH_PULL` @@ -294,7 +296,7 @@ const mp_obj_property_t digitalio_digitalio_drive_mode_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| pull: Any = ... +//| pull: Optional[Pull] ... //| """The pin pull direction. One of: //| //| - `digitalio.Pull.UP` From f76ff1eb698ed20d47d6cdd968dca300093836cc Mon Sep 17 00:00:00 2001 From: ppolk-nocimed Date: Sat, 16 May 2020 13:14:50 -0700 Subject: [PATCH 123/216] Fixed Optional[Pull] --- shared-bindings/digitalio/DigitalInOut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 0ae8b804c7..342f684ba6 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -162,7 +162,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o 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); - + digitalio_pull_t pull = PULL_NONE; if (args[ARG_pull].u_rom_obj == &digitalio_pull_up_obj) { @@ -296,7 +296,7 @@ const mp_obj_property_t digitalio_digitalio_drive_mode_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| pull: Optional[Pull] ... +//| pull: Optional[Pull] = ... //| """The pin pull direction. One of: //| //| - `digitalio.Pull.UP` From c6406c74eccb585d8034b948b0228a09d6717b30 Mon Sep 17 00:00:00 2001 From: ppolk-nocimed Date: Sat, 16 May 2020 13:21:34 -0700 Subject: [PATCH 124/216] Added DigitalInOut suggestion --- shared-bindings/digitalio/DigitalInOut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 342f684ba6..0cea74da0b 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -82,7 +82,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_deinit(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_deinit_obj, digitalio_digitalinout_obj_deinit); -//| def __enter__(self, ) -> self: +//| def __enter__(self, ) -> DigitalInOut: //| """No-op used by Context Managers.""" //| ... //| From 5e43f7a36174267515cfdf651f0a9b871953543b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 16 May 2020 17:58:08 -0500 Subject: [PATCH 125/216] add weblate status badge in readme --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 51db41a8bc..dfddd13373 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ CircuitPython .. image:: https://s3.amazonaws.com/adafruit-circuit-python/CircuitPython_Repo_header_logo.png -|Build Status| |Doc Status| |License| |Discord| +|Build Status| |Doc Status| |License| |Discord| |Weblate| `circuitpython.org `__ \| `Get CircuitPython <#get-circuitpython>`__ \| `Documentation <#documentation>`__ \| `Contributing <#contributing>`__ \| @@ -219,3 +219,5 @@ The remaining port directories not listed above are in the repo to maintain comp :target: https://adafru.it/discord .. |License| image:: https://img.shields.io/badge/License-MIT-brightgreen.svg :target: https://choosealicense.com/licenses/mit/ +.. |Weblate| image:: https://hosted.weblate.org/widgets/circuitpython/-/svg-badge.svg + :target: https://hosted.weblate.org/engage/circuitpython/?utm_source=widget From 58e7f280578ed076d23166f7ab9b4b4f7b1fb6ee Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Sat, 16 May 2020 20:42:17 +0000 Subject: [PATCH 126/216] Translated using Weblate (Swedish) Currently translated at 80.6% (602 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/sv/ --- locale/sv.po | 1148 ++++++++++++++++++++++++++------------------------ 1 file changed, 597 insertions(+), 551 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 5708b66427..ef958db944 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-14 12:41+0000\n" +"PO-Revision-Date: 2020-05-17 15:24+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -32,6 +32,9 @@ msgid "" "Please file an issue with the contents of your CIRCUITPY drive at \n" "https://github.com/adafruit/circuitpython/issues\n" msgstr "" +"\n" +"Skapa ett ärende med innehållet i din CIRCUITPY på\n" +"https://github.com/adafruit/circuitpython/issues\n" #: supervisor/shared/safe_mode.c msgid "" @@ -50,7 +53,6 @@ msgid " File \"%q\", line %d" msgstr " Fil \"%q\", rad %d" #: main.c -#, fuzzy msgid " output:\n" msgstr " utdata:\n" @@ -62,7 +64,7 @@ msgstr "%%c kräver int eller char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" -msgstr "" +msgstr "%d adresspinnar och %d RGB-pinnar indikerar en höjd av %d, inte %d" #: shared-bindings/microcontroller/Pin.c msgid "%q in use" @@ -77,7 +79,6 @@ msgid "%q indices must be integers, not %s" msgstr "Indexet %q måste vara ett heltal, inte %s" #: shared-bindings/vectorio/Polygon.c -#, fuzzy msgid "%q list must be a list" msgstr "%q-listan måste vara en lista" @@ -165,12 +166,12 @@ msgstr "Objektet '%s' har inte stöd för '%q'" #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" -msgstr "" +msgstr "Objektet \"%s\" stöder inte tilldelning av objekt" #: py/obj.c #, c-format msgid "'%s' object does not support item deletion" -msgstr "" +msgstr "'%s'-objekt stöder inte borttagning av objekt" #: py/runtime.c msgid "'%s' object has no attribute '%q'" @@ -189,114 +190,114 @@ msgstr "Objektet '%s' kan inte anropas" #: py/runtime.c #, c-format msgid "'%s' object is not iterable" -msgstr "" +msgstr "Objektet '%s' är inte itererbar" #: py/obj.c #, c-format msgid "'%s' object is not subscriptable" -msgstr "" +msgstr "Objektet \"%s\" är inte indexbar" #: py/objstr.c msgid "'=' alignment not allowed in string format specifier" -msgstr "" +msgstr "'='-justering tillåts inte i strängformatspecificerare" #: shared-module/struct/__init__.c msgid "'S' and 'O' are not supported format types" -msgstr "" +msgstr "'S' och 'O' stöds inte som formattyper" #: py/compile.c msgid "'align' requires 1 argument" -msgstr "" +msgstr "'align' kräver 1 argument" #: py/compile.c msgid "'async for' or 'async with' outside async function" -msgstr "" +msgstr "'async for' eller 'async with' utanför asynk-funktion" #: py/compile.c msgid "'await' outside function" -msgstr "" +msgstr "'await' utanför funktion" #: py/compile.c msgid "'break' outside loop" -msgstr "" +msgstr "'break' utanför loop" #: py/compile.c msgid "'continue' outside loop" -msgstr "" +msgstr "'continue' utanför loop" #: py/compile.c msgid "'data' requires at least 2 arguments" -msgstr "" +msgstr "'data' kräver minst 2 argument" #: py/compile.c msgid "'data' requires integer arguments" -msgstr "" +msgstr "'data' kräver heltalsargument" #: py/compile.c msgid "'label' requires 1 argument" -msgstr "" +msgstr "'label' kräver 1 argument" #: py/compile.c msgid "'return' outside function" -msgstr "" +msgstr "'return' utanför funktion" #: py/compile.c msgid "'yield' outside function" -msgstr "" +msgstr "'yield' utanför funktion" #: py/compile.c msgid "*x must be assignment target" -msgstr "" +msgstr "*x måste vara mål för tilldelning" #: py/obj.c msgid ", in %q\n" -msgstr "" +msgstr ", i %q\n" #: py/objcomplex.c msgid "0.0 to a complex power" -msgstr "" +msgstr "0,0 till ett komplext nummer" #: py/modbuiltins.c msgid "3-arg pow() not supported" -msgstr "" +msgstr "3-arguments pow() stöds inte" #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" -msgstr "" +msgstr "En kanal för hårdvaruavbrotts används redan" #: shared-bindings/_bleio/Address.c #, c-format msgid "Address must be %d bytes long" -msgstr "" +msgstr "Adressen måste vara %d byte lång" #: shared-bindings/_bleio/Address.c msgid "Address type out of range" -msgstr "" +msgstr "Adresstyp utanför intervallet" #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" -msgstr "" +msgstr "All I2C-kringutrustning används" #: ports/nrf/common-hal/busio/SPI.c msgid "All SPI peripherals are in use" -msgstr "" +msgstr "All SPI-kringutrustning används" #: ports/nrf/common-hal/busio/UART.c msgid "All UART peripherals are in use" -msgstr "" +msgstr "Alla UART-tillbehör används" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "All event channels in use" -msgstr "" +msgstr "Alla händelsekanaler används" #: ports/atmel-samd/audio_dma.c ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "All sync event channels in use" -msgstr "" +msgstr "Alla händelsekanaler används" #: shared-bindings/pulseio/PWMOut.c msgid "All timers for this pin are in use" -msgstr "" +msgstr "Alla timers för denna pinne är i bruk" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c @@ -307,444 +308,453 @@ msgstr "" #: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c #: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c msgid "All timers in use" -msgstr "" +msgstr "Alla timers används" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." -msgstr "" +msgstr "Annonserar redan." #: ports/cxd56/common-hal/analogio/AnalogIn.c msgid "AnalogIn not supported on given pin" -msgstr "" +msgstr "AnalogIn stöds inte på en given pinne" #: ports/cxd56/common-hal/analogio/AnalogOut.c #: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" -msgstr "" +msgstr "AnalogOut-funktionalitet stöds inte" #: shared-bindings/analogio/AnalogOut.c msgid "AnalogOut is only 16 bits. Value must be less than 65536." -msgstr "" +msgstr "AnalogOut är bara 16 bitar. Värdet måste vara mindre än 65536." #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "AnalogOut not supported on given pin" -msgstr "" +msgstr "AnalogOut stöds inte på given pinne" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" -msgstr "" +msgstr "En annan sändning är redan aktiv" #: shared-bindings/pulseio/PulseOut.c msgid "Array must contain halfwords (type 'H')" -msgstr "" +msgstr "Matrisen måste innehålla halfwords (typ \"H\")" #: shared-bindings/nvm/ByteArray.c msgid "Array values should be single bytes." -msgstr "" +msgstr "Matrisvärden ska vara enstaka byte." #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "At most %d %q may be specified (not %d)" -msgstr "" +msgstr "Högst %d %q kan anges (inte %d)" #: supervisor/shared/safe_mode.c msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "" +msgstr "Försökte tilldelning av heap när MicroPython VM inte körs." #: main.c msgid "Auto-reload is off.\n" -msgstr "" +msgstr "Autoladdning är avstängd.\n" #: main.c msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" msgstr "" +"Autoladdning är på. Spara bara filer via USB för att köra dem eller ange " +"REPL för att inaktivera.\n" #: shared-module/displayio/Display.c #: shared-module/framebufferio/FramebufferDisplay.c msgid "Below minimum frame rate" -msgstr "" +msgstr "Under minsta bildfrekvens" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Bit clock and word select must share a clock unit" -msgstr "" +msgstr "Bitklocka och ordval måste dela en klockenhet" #: shared-bindings/audiobusio/PDMIn.c msgid "Bit depth must be multiple of 8." -msgstr "" +msgstr "Bitdjupet måste vara multipel av 8." #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "Both pins must support hardware interrupts" -msgstr "" +msgstr "Båda pinnarna måste stödja maskinvaruavbrott" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" -msgstr "" +msgstr "Ljusstyrkan måste vara 0-1,0" #: shared-bindings/supervisor/__init__.c msgid "Brightness must be between 0 and 255" -msgstr "" +msgstr "Ljusstyrkan måste vara mellan 0 och 255" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" -msgstr "" +msgstr "Ljusstyrkan kan inte justeras" #: shared-bindings/_bleio/UUID.c #, c-format msgid "Buffer + offset too small %d %d %d" -msgstr "" +msgstr "Buffert + offset för liten %d %d %d" #: shared-module/usb_hid/Device.c #, c-format msgid "Buffer incorrect size. Should be %d bytes." -msgstr "" +msgstr "Buffert har felaktig storlek. Ska vara %d byte." #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Buffer is not a bytearray." -msgstr "" +msgstr "Buffert är inte en bytearray." #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Buffer is too small" -msgstr "" +msgstr "Bufferten är för liten" #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Buffer length %d too big. It must be less than %d" -msgstr "" +msgstr "Buffertlängd %d för stor. Den måste vara mindre än %d" #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" -msgstr "" +msgstr "Bufferten måste ha minst längd 1" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Buffer too large and unable to allocate" -msgstr "" +msgstr "Bufferten är för stor och kan inte allokeras" #: shared-bindings/_bleio/PacketBuffer.c #, c-format msgid "Buffer too short by %d bytes" -msgstr "" +msgstr "Buffert för kort med %d bytes" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" -msgstr "" +msgstr "Busspinne %d används redan" #: shared-bindings/_bleio/UUID.c msgid "Byte buffer must be 16 bytes." -msgstr "" +msgstr "Byte-buffert måste vara 16 byte." #: shared-bindings/nvm/ByteArray.c msgid "Bytes must be between 0 and 255." -msgstr "" +msgstr "Bytes måste vara mellan 0 och 255." #: shared-bindings/aesio/aes.c msgid "CBC blocks must be multiples of 16 bytes" -msgstr "" +msgstr "CBC-block måste vara multiplar om 16 byte" #: py/objtype.c msgid "Call super().__init__() before accessing native object." -msgstr "" +msgstr "Anropa super().__init__() innan du använder det nativa objektet." #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" -msgstr "" +msgstr "Kan inte ställa in CCCD på lokal karaktäristik" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" -msgstr "" +msgstr "Kan radera värden" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c #: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" -msgstr "" +msgstr "Kan inte ange pull i output-läge" #: ports/nrf/common-hal/microcontroller/Processor.c msgid "Cannot get temperature" -msgstr "" +msgstr "Kan inte hämta temperatur" #: shared-bindings/_bleio/Adapter.c msgid "Cannot have scan responses for extended, connectable advertisements." msgstr "" +"Det går inte att ha skanningssvar för utökade, anslutningsbara aviseringar." #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" -msgstr "" +msgstr "Det går inte att mata ut båda kanalerna på samma pinne" #: shared-module/bitbangio/SPI.c msgid "Cannot read without MISO pin." -msgstr "" +msgstr "Kan inte läsa utan MISO-pinne." #: shared-bindings/audiobusio/PDMIn.c msgid "Cannot record to a file" -msgstr "" +msgstr "Det går inte att spela in till en fil" #: shared-module/storage/__init__.c msgid "Cannot remount '/' when USB is active." -msgstr "" +msgstr "Kan inte återmontera '/' när USB är aktivt." #: ports/atmel-samd/common-hal/microcontroller/__init__.c #: ports/cxd56/common-hal/microcontroller/__init__.c #: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" +"Det går inte att återställa till bootloader eftersom det inte finns någon " +"bootloader." #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." -msgstr "" +msgstr "Kan inte sätta värde när riktning är input." #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Cannot specify RTS or CTS in RS485 mode" -msgstr "" +msgstr "Det går inte att specificera RTS eller CTS i RS485-läget" #: py/objslice.c msgid "Cannot subclass slice" -msgstr "" +msgstr "Det går inte att subklassa slice" #: shared-module/bitbangio/SPI.c msgid "Cannot transfer without MOSI and MISO pins." -msgstr "" +msgstr "Kan inte överföra utan MOSI- och MISO-pinnar." #: extmod/moductypes.c msgid "Cannot unambiguously get sizeof scalar" -msgstr "" +msgstr "Kan inte entydigt få sizeof scalar" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Cannot vary frequency on a timer that is already in use" -msgstr "" +msgstr "Det går inte att ändra frekvensen på en timer som redan används" #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." -msgstr "" +msgstr "Kan inte skriva utan MOSI-pinne." #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" -msgstr "" +msgstr "Skrivning för CharacteristicBuffer är inte tillhandahållen" #: supervisor/shared/safe_mode.c msgid "CircuitPython core code crashed hard. Whoops!\n" -msgstr "" +msgstr "CircuitPython kärnkod kraschade hårt. Hoppsan!\n" #: supervisor/shared/safe_mode.c msgid "" "CircuitPython is in safe mode because you pressed the reset button during " "boot. Press again to exit safe mode.\n" msgstr "" +"CircuitPython är i säkert läge eftersom du tryckte på återställningsknappen " +"under start. Tryck igen för att lämna säkert läge.\n" #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." -msgstr "" +msgstr "Initiering av klockpinne misslyckades." #: shared-module/bitbangio/I2C.c msgid "Clock stretch too long" -msgstr "" +msgstr "Klockförlängning för lång" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Clock unit in use" -msgstr "" +msgstr "Klockenhet används" #: shared-bindings/_pew/PewPew.c msgid "Column entry must be digitalio.DigitalInOut" -msgstr "" +msgstr "Kolumnposten måste vara digitalio. DigitalInOut" #: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c #: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" -msgstr "" +msgstr "Kommandot måste vara en int mellan 0 och 255" #: shared-bindings/_bleio/Connection.c msgid "" "Connection has been disconnected and can no longer be used. Create a new " "connection." msgstr "" +"Anslutningen har kopplats bort och kan inte längre användas. Skapa en ny " +"anslutning." #: py/persistentcode.c msgid "Corrupt .mpy file" -msgstr "" +msgstr "Skadad .mpy-fil" #: py/emitglue.c msgid "Corrupt raw code" -msgstr "" +msgstr "Korrupt rå kod" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" -msgstr "" +msgstr "Det gick inte att initiera UART" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not initialize channel" -msgstr "" +msgstr "Det gick inte att initiera kanalen" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not initialize timer" -msgstr "" +msgstr "Det gick inte att initialisera timern" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not re-init channel" -msgstr "" +msgstr "Det gick inte att återinitiera kanalen" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not re-init timer" -msgstr "" +msgstr "Det gick inte att återinitiera timern" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not restart PWM" -msgstr "" +msgstr "Det gick inte att starta om PWM" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not start PWM" -msgstr "" +msgstr "Det gick inte att starta PWM" #: ports/stm/common-hal/busio/UART.c msgid "Could not start interrupt, RX busy" -msgstr "" +msgstr "Det gick inte att starta avbrott, RX upptagen" #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" -msgstr "" +msgstr "Det gick inte att allokera avkodaren" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" -msgstr "" +msgstr "Det gick inte att allokera den första bufferten" #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" -msgstr "" +msgstr "Det gick inte att allokera indatabufferten" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" -msgstr "" +msgstr "Det gick inte att allokera den andra bufferten" #: supervisor/shared/safe_mode.c msgid "Crash into the HardFault_Handler." -msgstr "" +msgstr "Krasch in i HardFault_Handler." #: ports/stm/common-hal/analogio/AnalogOut.c msgid "DAC Channel Init Error" -msgstr "" +msgstr "Initieringsfel för DAC-kanal" #: ports/stm/common-hal/analogio/AnalogOut.c msgid "DAC Device Init Error" -msgstr "" +msgstr "Initieringsfel för DAC-enhet" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" -msgstr "" +msgstr "DAC används redan" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c msgid "Data 0 pin must be byte aligned" -msgstr "" +msgstr "Datapinne 0 måste vara bytejusterad" #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" -msgstr "" +msgstr "Datasegmentet måste följa fmt-segmentet" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" -msgstr "" +msgstr "Data för stor för annonseringspaket" #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." -msgstr "" +msgstr "Målkapaciteten är mindre än destination_length." #: ports/nrf/common-hal/audiobusio/I2SOut.c msgid "Device in use" -msgstr "" +msgstr "Enheten används redan" #: ports/cxd56/common-hal/digitalio/DigitalInOut.c msgid "DigitalInOut not supported on given pin" -msgstr "" +msgstr "DigitalInOut stöds inte på given pinne" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Display must have a 16 bit colorspace." -msgstr "" +msgstr "Displayen måste ha en 16-bitars färgrymd." #: shared-bindings/displayio/Display.c #: shared-bindings/displayio/EPaperDisplay.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Display rotation must be in 90 degree increments" -msgstr "" +msgstr "Displayens rotation måste vara i steg om 90 grader" #: shared-bindings/digitalio/DigitalInOut.c msgid "Drive mode not used when direction is input." -msgstr "" +msgstr "Drivläge används inte när riktning är input." #: shared-bindings/aesio/aes.c msgid "ECB only operates on 16 bytes at a time" -msgstr "" +msgstr "ECB arbetar endast på 16 byte åt gången" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" -msgstr "" +msgstr "EXTINT-kanalen används redan" #: extmod/modure.c msgid "Error in regex" -msgstr "" +msgstr "Fel i regex" #: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c #: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c #: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" -msgstr "" +msgstr "Förväntade %q" #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" -msgstr "" +msgstr "Förväntade en karaktäristik" #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" -msgstr "" +msgstr "Förväntade en tjänst" #: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c #: shared-bindings/_bleio/Service.c msgid "Expected a UUID" -msgstr "" +msgstr "Förväntade en UUID" #: shared-bindings/_bleio/Adapter.c msgid "Expected an Address" -msgstr "" +msgstr "Förväntade en adress" #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" -msgstr "" +msgstr "Förväntad tupel med längd %d, fick %d" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." -msgstr "" +msgstr "Utökad annonsering i kombination med skanningssvar stöds inte." #: extmod/ulab/code/fft.c msgid "FFT is defined for ndarrays only" -msgstr "" +msgstr "FFT är enbart definierade för ndarrays" #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." -msgstr "" +msgstr "Det gick inte att skicka kommandot." #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to acquire mutex, err 0x%04x" -msgstr "" +msgstr "Det gick inte att förvärva mutex, fel 0x%04x" #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" -msgstr "" +msgstr "Det gick inte att tilldela RX-buffert" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c @@ -753,214 +763,216 @@ msgstr "" #: ports/stm/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" -msgstr "" +msgstr "Det gick inte att allokera RX-bufferten på %d byte" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" -msgstr "" +msgstr "Det gick inte att ansluta: internt fel" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: timeout" -msgstr "" +msgstr "Det gick inte att ansluta: timeout" #: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" -msgstr "" +msgstr "Det gick inte att tolka MP3-filen" #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" -msgstr "" +msgstr "Det gick inte att frigöra mutex, fel 0x%04x" #: supervisor/shared/safe_mode.c msgid "Failed to write internal flash." -msgstr "" +msgstr "Det gick inte att skriva till intern flash." #: py/moduerrno.c msgid "File exists" -msgstr "" +msgstr "Filen finns redan" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." -msgstr "" +msgstr "Infångningsfrekvens är för hög. Infångning pausad." #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Frequency must match existing PWMOut using this timer" -msgstr "" +msgstr "Frekvensen måste matcha befintlig PWMOut med denna timer" #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" -msgstr "" +msgstr "Funktion kräver lås" #: shared-bindings/displayio/Display.c #: shared-bindings/displayio/EPaperDisplay.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Group already used" -msgstr "" +msgstr "Grupp används redan" #: shared-module/displayio/Group.c msgid "Group full" -msgstr "" +msgstr "Gruppen är full" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" -msgstr "" +msgstr "Hårdvaran är upptagen, prova alternativa pinnar" #: ports/stm/common-hal/busio/UART.c msgid "Hardware in use, try alternative pins" -msgstr "" +msgstr "Hårdvaran används redan, prova alternativa pinnar" #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" -msgstr "" +msgstr "I/O-operation på stängd fil" #: ports/stm/common-hal/busio/I2C.c msgid "I2C Init Error" -msgstr "" +msgstr "I2C init-fel" #: extmod/machine_i2c.c msgid "I2C operation not supported" -msgstr "" +msgstr "I2C-åtgärd stöds inte" #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" -msgstr "" +msgstr "IV måste vara %d byte lång" #: py/persistentcode.c msgid "" "Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/" "mpy-update for more info." msgstr "" +"Inkompatibel .mpy-fil. Uppdatera alla .mpy-filer. Se http://adafru.it/mpy-" +"update för mer information." #: shared-bindings/_pew/PewPew.c msgid "Incorrect buffer size" -msgstr "" +msgstr "Fel buffertstorlek" #: py/moduerrno.c msgid "Input/output error" -msgstr "" +msgstr "Indata-/utdatafel" #: ports/nrf/common-hal/_bleio/__init__.c msgid "Insufficient authentication" -msgstr "" +msgstr "Otillräcklig autentisering" #: ports/nrf/common-hal/_bleio/__init__.c msgid "Insufficient encryption" -msgstr "" +msgstr "Otillräcklig kryptering" #: ports/stm/common-hal/busio/UART.c msgid "Internal define error" -msgstr "" +msgstr "Internt define-fel" #: shared-module/rgbmatrix/RGBMatrix.c #, c-format msgid "Internal error #%d" -msgstr "" +msgstr "Internt fel #%d" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" -msgstr "" +msgstr "Ogiltig %q-pinne" #: ports/stm/common-hal/analogio/AnalogIn.c msgid "Invalid ADC Unit value" -msgstr "" +msgstr "Ogiltigt ADC-enhetsvärde" #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" -msgstr "" +msgstr "Ogiltig BMP-fil" #: ports/stm/common-hal/analogio/AnalogOut.c msgid "Invalid DAC pin supplied" -msgstr "" +msgstr "Ogiltig DAC-pinne angiven" #: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm/common-hal/busio/I2C.c msgid "Invalid I2C pin selection" -msgstr "" +msgstr "Ogiltigt val av I2C-pinne" #: ports/atmel-samd/common-hal/pulseio/PWMOut.c #: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" -msgstr "" +msgstr "Ogiltig PWM-frekvens" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Invalid SPI pin selection" -msgstr "" +msgstr "Ogiltigt val av SPI-pinne" #: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "Invalid UART pin selection" -msgstr "" +msgstr "Ogiltigt val av UART-pinne" #: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" -msgstr "" +msgstr "Ogiltigt argument" #: shared-module/displayio/Bitmap.c msgid "Invalid bits per value" -msgstr "" +msgstr "Ogiltigt värde för bitar per värde" #: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "Invalid buffer size" -msgstr "" +msgstr "Ogiltig buffertstorlek" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Invalid byteorder string" -msgstr "" +msgstr "Ogiltig byteorder-sträng" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" -msgstr "" +msgstr "Ogiltig inspelningsperiod. Giltigt intervall: 1 - 500" #: shared-bindings/audiomixer/Mixer.c msgid "Invalid channel count" -msgstr "" +msgstr "Ogiltigt kanalantal" #: shared-bindings/digitalio/DigitalInOut.c msgid "Invalid direction." -msgstr "" +msgstr "Ogiltig riktning." #: shared-module/audiocore/WaveFile.c msgid "Invalid file" -msgstr "" +msgstr "Felaktig fil" #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" -msgstr "" +msgstr "Ogiltig formatsegmentstorlek" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Invalid frequency supplied" -msgstr "" +msgstr "Ogiltig frekvens angiven" #: supervisor/shared/safe_mode.c msgid "Invalid memory access." -msgstr "" +msgstr "Ogiltig minnesåtkomst." #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" -msgstr "" +msgstr "Ogiltigt antal bitar" #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c #: shared-bindings/displayio/FourWire.c msgid "Invalid phase" -msgstr "" +msgstr "Ogiltig fas" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: shared-bindings/pulseio/PWMOut.c shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" -msgstr "" +msgstr "Ogiltig pinne" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Invalid pin for left channel" -msgstr "" +msgstr "Ogiltig pinne för vänster kanal" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Invalid pin for right channel" -msgstr "" +msgstr "Ogiltig pinne för höger kanal" #: ports/atmel-samd/common-hal/busio/I2C.c #: ports/atmel-samd/common-hal/busio/SPI.c @@ -969,242 +981,245 @@ msgstr "" #: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c #: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c msgid "Invalid pins" -msgstr "" +msgstr "Ogiltiga pinnar" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Invalid pins for PWMOut" -msgstr "" +msgstr "Ogiltiga pinnar för PWMOut" #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c #: shared-bindings/displayio/FourWire.c msgid "Invalid polarity" -msgstr "" +msgstr "Ogiltig polaritet" #: shared-bindings/_bleio/Characteristic.c msgid "Invalid properties" -msgstr "" +msgstr "Ogiltiga egenskaper" #: shared-bindings/microcontroller/__init__.c msgid "Invalid run mode." -msgstr "" +msgstr "Ogiltigt körläge." #: shared-module/_bleio/Attribute.c msgid "Invalid security_mode" -msgstr "" +msgstr "Ogiltigt säkerhetsläge" #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" -msgstr "" +msgstr "Ogiltig kanal" #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice count" -msgstr "" +msgstr "Ogiltigt kanalantal" #: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" -msgstr "" +msgstr "Ogiltig wave-fil" #: ports/stm/common-hal/busio/UART.c msgid "Invalid word/bit length" -msgstr "" +msgstr "Ogiltig word-/bitlängd" #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" -msgstr "" +msgstr "Nyckeln måste vara 16, 24 eller 32 byte lång" #: py/compile.c msgid "LHS of keyword arg must be an id" -msgstr "" +msgstr "LHS av keword arg måste vara ett id" #: shared-module/displayio/Group.c msgid "Layer already in a group." -msgstr "" +msgstr "Lagret finns redan i en grupp." #: shared-module/displayio/Group.c msgid "Layer must be a Group or TileGrid subclass." -msgstr "" +msgstr "Layer måste vara en subklass av Group eller TileGrid." #: py/objslice.c msgid "Length must be an int" -msgstr "" +msgstr "Length måste vara en int" #: py/objslice.c msgid "Length must be non-negative" -msgstr "" +msgstr "Length måste vara positiv" #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." -msgstr "" +msgstr "init för MISO-pinne misslyckades." #: shared-module/bitbangio/SPI.c msgid "MOSI pin init failed." -msgstr "" +msgstr "init för MOSI-pinne misslyckades." #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" -msgstr "" +msgstr "Maximum x-värde vid spegling är %d" #: supervisor/shared/safe_mode.c msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" +msgstr "MicroPython NLR jump misslyckades. Troligen korrupt minne." #: supervisor/shared/safe_mode.c msgid "MicroPython fatal error." -msgstr "" +msgstr "MicroPython fatalt fel." #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" -msgstr "" +msgstr "Startfördröjningen för mikrofonen måste vara i intervallet 0,0 till 1,0" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" -msgstr "" +msgstr "MISO- eller MOSI-pinne saknas" #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." -msgstr "" +msgstr "Måste vara en %q-subklass." #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" -msgstr "" +msgstr "Måste ange MISO- eller MOSI-pinne" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "Must use a multiple of 6 rgb pins, not %d" -msgstr "" +msgstr "Måste använda ett multipel av 6 rgb-pinnar, inte %d" #: py/parse.c msgid "Name too long" -msgstr "" +msgstr "Name är för långt" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" -msgstr "" +msgstr "Negativt step stöds inte" #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" -msgstr "" +msgstr "Ingen CCCD för denna karaktäristik" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c #: ports/stm/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" -msgstr "" +msgstr "Ingen DAC på chipet" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "No DMA channel found" -msgstr "" +msgstr "Ingen DMA-kanal hittades" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" -msgstr "" +msgstr "Ingen MISO-pinne" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" -msgstr "" +msgstr "Ingen MOSI-pinne" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c #: ports/stm/common-hal/busio/UART.c msgid "No RX pin" -msgstr "" +msgstr "Ingen RX-pinne" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c #: ports/stm/common-hal/busio/UART.c msgid "No TX pin" -msgstr "" +msgstr "Ingen TX-pinne" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "No available clocks" -msgstr "" +msgstr "Inga tillgängliga klockor" #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" -msgstr "" +msgstr "Ingen anslutning: längden kan inte bestämmas" #: shared-bindings/board/__init__.c msgid "No default %q bus" -msgstr "" +msgstr "Ingen standard %q-buss" #: ports/atmel-samd/common-hal/touchio/TouchIn.c msgid "No free GCLKs" -msgstr "" +msgstr "Inga fria GCLK: er" #: shared-bindings/os/__init__.c msgid "No hardware random available" -msgstr "" +msgstr "Ingen hårdvaru-random tillgänglig" #: ports/atmel-samd/common-hal/ps2io/Ps2.c msgid "No hardware support on clk pin" -msgstr "" +msgstr "Inget hårdvarustöd på clk-pinne" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" -msgstr "" +msgstr "Inget hårdvarustöd på pinne" #: shared-bindings/aesio/aes.c msgid "No key was specified" -msgstr "" +msgstr "Ingen nyckel angavs" #: shared-bindings/time/__init__.c msgid "No long integer support" -msgstr "" +msgstr "Inget stöd för långt heltal" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "No more timers available on this pin." -msgstr "" +msgstr "Inga fler timers tillgängliga på denna pinne." #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" -msgstr "" +msgstr "Ingen pulldown på pinnen; 1Mohm rekommenderas" #: py/moduerrno.c msgid "No space left on device" -msgstr "" +msgstr "Inget utrymme kvar på enheten" #: py/moduerrno.c msgid "No such file/directory" -msgstr "" +msgstr "Ingen sådan fil/katalog" #: shared-module/rgbmatrix/RGBMatrix.c msgid "No timer available" -msgstr "" +msgstr "Ingen timer tillgänglig" #: supervisor/shared/safe_mode.c msgid "Nordic Soft Device failure assertion." -msgstr "" +msgstr "Nordic Soft Device failure assertion." #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" -msgstr "" +msgstr "Inte ansluten" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c #: shared-bindings/audiopwmio/PWMAudioOut.c msgid "Not playing" -msgstr "" +msgstr "Ingen uppspelning" #: shared-bindings/util.c msgid "" "Object has been deinitialized and can no longer be used. Create a new object." msgstr "" +"Objektet har deinitialiserats och kan inte längre användas. Skapa ett nytt " +"objekt." #: ports/nrf/common-hal/busio/UART.c msgid "Odd parity is not supported" -msgstr "" +msgstr "Udda paritet stöds inte" #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Only 8 or 16 bit mono with " -msgstr "" +msgstr "Endast 8 eller 16 bitars mono med " #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" "Only Windows format, uncompressed BMP supported: given header size is %d" msgstr "" +"Endast Windows-format, okomprimerad BMP stöds: given headerstorlek är %d" #: shared-module/displayio/OnDiskBitmap.c #, c-format @@ -1212,29 +1227,33 @@ msgid "" "Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: " "%d bpp given" msgstr "" +"Endast monokrom, indexerad 4 bpp eller 8 bpp och 16 bpp eller högre BMP: er " +"stöds: %d bpp angiven" #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." -msgstr "" +msgstr "Översampling måste vara multipel av 8." #: shared-bindings/pulseio/PWMOut.c msgid "" "PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)" -msgstr "" +msgstr "PWM duty_cykel måste vara mellan 0 och 65535 (16 bitars upplösning)" #: shared-bindings/pulseio/PWMOut.c msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" +"PWM-frekvensen är inte skrivbar när variable_frequency är falsk vid " +"skapandet." #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" -msgstr "" +msgstr "ParallelBus stöds ännu inte" #: py/moduerrno.c msgid "Permission denied" -msgstr "" +msgstr "Åtkomst nekad" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c #: ports/cxd56/common-hal/analogio/AnalogIn.c @@ -1242,15 +1261,15 @@ msgstr "" #: ports/nrf/common-hal/analogio/AnalogIn.c #: ports/stm/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" -msgstr "" +msgstr "Pinnen har inte ADC-funktionalitet" #: ports/atmel-samd/common-hal/countio/Counter.c msgid "Pin must support hardware interrupts" -msgstr "" +msgstr "Pinnen måste stödja hårdvaruavbrott" #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" -msgstr "" +msgstr "PInn-nummer redan reserverat av EXTI" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format @@ -1259,183 +1278,191 @@ msgid "" "bytes. If this cannot be avoided, pass allow_inefficient=True to the " "constructor" msgstr "" +"Pinout använder %d byte per element, vilket förbrukar mer än det idealiska %" +"d byte. Om detta inte kan undvikas, skicka allow_inefficient=True till " +"konstruktorn" #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" -msgstr "" +msgstr "Plus eventuella moduler i filsystemet\n" #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" -msgstr "" +msgstr "Pop från en tom Ps2-buffert" #: shared-bindings/_bleio/Adapter.c msgid "Prefix buffer must be on the heap" -msgstr "" +msgstr "Prefixbufferten måste finnas på heap" #: main.c msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" +"Tryck på valfri knapp för att gå in i REPL. Använd CTRL-D för att ladda om." #: shared-bindings/digitalio/DigitalInOut.c msgid "Pull not used when direction is output." -msgstr "" +msgstr "Pull används inte när riktningen är output." #: ports/stm/common-hal/pulseio/PulseIn.c msgid "PulseIn not supported on this chip" -msgstr "" +msgstr "PulseIn stöds inte av detta chip" #: ports/stm/common-hal/pulseio/PulseOut.c msgid "PulseOut not supported on this chip" -msgstr "" +msgstr "PulseIn stöds inte av detta chip" #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" -msgstr "" +msgstr "RNG DeInit-fel" #: ports/stm/common-hal/os/__init__.c msgid "RNG Init Error" -msgstr "" +msgstr "RNG Init-fel" #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" -msgstr "" +msgstr "RS485-inversion specificerad när den inte är i RS485-läge" #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" -msgstr "" +msgstr "RTC-kalibrering stöds inte av detta kort" #: shared-bindings/time/__init__.c msgid "RTC is not supported on this board" -msgstr "" +msgstr "RTC stöds inte av detta kort" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c #: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" -msgstr "" +msgstr "RTS/CTS/RS485 Stöds ännu inte på den här enheten" #: ports/stm/common-hal/os/__init__.c msgid "Random number generation error" -msgstr "" +msgstr "Fel vid generering av slumptal" #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" -msgstr "" +msgstr "Skrivskyddad" #: extmod/vfs_fat.c py/moduerrno.c msgid "Read-only filesystem" -msgstr "" +msgstr "Skrivskyddat filsystem" #: shared-module/displayio/Bitmap.c msgid "Read-only object" -msgstr "" +msgstr "Skrivskyddat objekt" #: shared-bindings/displayio/EPaperDisplay.c msgid "Refresh too soon" -msgstr "" +msgstr "Uppdaterad för tidigt" #: shared-bindings/aesio/aes.c msgid "Requested AES mode is unsupported" -msgstr "" +msgstr "Det begärda AES-läget stöds inte" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Right channel unsupported" -msgstr "" +msgstr "Höger kanal stöds inte" #: shared-bindings/_pew/PewPew.c msgid "Row entry must be digitalio.DigitalInOut" -msgstr "" +msgstr "Radvärdet måste vara digitalio.DigitalInOut" #: main.c msgid "Running in safe mode! Auto-reload is off.\n" -msgstr "" +msgstr "Kör i säkert läge! Autoladdning är avstängd.\n" #: main.c msgid "Running in safe mode! Not running saved code.\n" -msgstr "" +msgstr "Kör i säkert läge! Sparad kod körs inte.\n" #: ports/atmel-samd/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c msgid "SDA or SCL needs a pull up" -msgstr "" +msgstr "SDA eller SCL behöver en pullup" #: ports/stm/common-hal/busio/SPI.c msgid "SPI Init Error" -msgstr "" +msgstr "SPI Init-fel" #: ports/stm/common-hal/busio/SPI.c msgid "SPI Re-initialization error" -msgstr "" +msgstr "SPI reinitialiseringsfel" #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" -msgstr "" +msgstr "Samplingsfrekvensen måste vara positiv" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" -msgstr "" +msgstr "Samplingsfrekvensen är för hög. Den måste vara mindre än %d" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." -msgstr "" +msgstr "Skanning pågår redan. Avsluta med stop_scan." #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Selected CTS pin not valid" -msgstr "" +msgstr "Vald CTS-pinne är inte giltig" #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Selected RTS pin not valid" -msgstr "" +msgstr "Vald CTS-pinne är inte giltig" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" -msgstr "" +msgstr "Serializern används redan" #: shared-bindings/nvm/ByteArray.c msgid "Slice and value different lengths." -msgstr "" +msgstr "Slice och värde har olika längd." #: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c #: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c msgid "Slices not supported" -msgstr "" +msgstr "Slice stöds inte" #: shared-bindings/aesio/aes.c msgid "Source and destination buffers must be the same length" -msgstr "" +msgstr "Käll- och målbuffertar måste ha samma längd" #: extmod/modure.c msgid "Splitting with sub-captures" -msgstr "" +msgstr "Splitting med sub-captures" #: shared-bindings/supervisor/__init__.c msgid "Stack size must be at least 256" -msgstr "" +msgstr "Stackstorleken måste vara minst 256" #: shared-bindings/multiterminal/__init__.c msgid "Stream missing readinto() or write() method." -msgstr "" +msgstr "Stream saknar readinto() eller write() metod." #: ports/stm/common-hal/busio/UART.c msgid "Supply at least one UART pin" -msgstr "" +msgstr "Ange minst en UART-pinne" #: ports/stm/common-hal/microcontroller/Processor.c msgid "Temperature read timed out" -msgstr "" +msgstr "Temperaturavläsning tog för lång tid" #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" "Please increase the stack size if you know how, or if not:" msgstr "" +"CircuitPythons heap blev korrupt eftersom stacken var för liten.\n" +"Öka stackstorleken om du vet hur, eller om inte:" #: supervisor/shared/safe_mode.c msgid "" "The `microcontroller` module was used to boot into safe mode. Press reset to " "exit safe mode.\n" msgstr "" +"Modulen \"microkontroller\" användes för att starta i säkert läge. Tryck på " +"reset för att lämna säkert läge.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -1443,205 +1470,211 @@ msgid "" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" +"Mikrokontrollerns matningsspänning droppade. Se till att strömförsörjningen " +"ger\n" +"tillräckligt med ström för hela kretsen och tryck på reset (efter utmatning " +"av CIRCUITPY).\n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" -msgstr "" +msgstr "Samplingens bits_per_sample matchar inte mixerns" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's channel count does not match the mixer's" -msgstr "" +msgstr "Samplingens kanalantal matchar inte mixerns" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's sample rate does not match the mixer's" -msgstr "" +msgstr "Samplingens frekvens matchar inte mixerns" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's signedness does not match the mixer's" -msgstr "" +msgstr "Samplingens signerad/osignerad stämmer inte med mixern" #: shared-bindings/displayio/TileGrid.c msgid "Tile height must exactly divide bitmap height" -msgstr "" +msgstr "Tile-höjden måste vara jämnt delbar med höjd på bitmap" #: shared-bindings/displayio/TileGrid.c shared-module/displayio/TileGrid.c msgid "Tile index out of bounds" -msgstr "" +msgstr "Tile-index utanför gräns" #: shared-bindings/displayio/TileGrid.c msgid "Tile value out of bounds" -msgstr "" +msgstr "Tile-värde utanför intervall" #: shared-bindings/displayio/TileGrid.c msgid "Tile width must exactly divide bitmap width" -msgstr "" +msgstr "Tile-bredd måste vara jämnt delbar med bredd på bitmap" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." -msgstr "" +msgstr "För många kanaler i sampling." #: shared-module/displayio/__init__.c msgid "Too many display busses" -msgstr "" +msgstr "För många display-bussar" #: shared-module/displayio/__init__.c msgid "Too many displays" -msgstr "" +msgstr "För många displayer" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than outgoing_packet_length" -msgstr "" +msgstr "Total data som ska skrivas är större än outgoing_packet_length" #: py/obj.c msgid "Traceback (most recent call last):\n" -msgstr "" +msgstr "Traceback (senaste anrop):\n" #: shared-bindings/time/__init__.c msgid "Tuple or struct_time argument required" -msgstr "" +msgstr "Tuple- eller struct_time-argument krävs" #: ports/stm/common-hal/busio/UART.c msgid "UART Buffer allocation error" -msgstr "" +msgstr "UART-buffertallokeringsfel" #: ports/stm/common-hal/busio/UART.c msgid "UART De-init error" -msgstr "" +msgstr "UART deinit-fel" #: ports/stm/common-hal/busio/UART.c msgid "UART Init Error" -msgstr "" +msgstr "UART Init-fel" #: ports/stm/common-hal/busio/UART.c msgid "UART Re-init error" -msgstr "" +msgstr "UART reinit-fel" #: ports/stm/common-hal/busio/UART.c msgid "UART write error" -msgstr "" +msgstr "UART skrivfel" #: shared-module/usb_hid/Device.c msgid "USB Busy" -msgstr "" +msgstr "USB upptagen" #: shared-module/usb_hid/Device.c msgid "USB Error" -msgstr "" +msgstr "USB-fel" #: shared-bindings/_bleio/UUID.c msgid "UUID integer value must be 0-0xffff" -msgstr "" +msgstr "UUID-heltal måste vara 0-0xffff" #: shared-bindings/_bleio/UUID.c msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" -msgstr "" +msgstr "UUID-sträng inte \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"" #: shared-bindings/_bleio/UUID.c msgid "UUID value is not str, int or byte buffer" -msgstr "" +msgstr "UUID-värdet är inte str, int eller byte-buffert" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Unable to allocate buffers for signed conversion" -msgstr "" +msgstr "Det går inte att allokera buffert för signerad konvertering" #: shared-module/displayio/I2CDisplay.c #, c-format msgid "Unable to find I2C Display at %x" -msgstr "" +msgstr "Det gick inte att hitta I2C-display på %x" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Unable to find free GCLK" -msgstr "" +msgstr "Det gick inte att hitta ledig GCLK" #: py/parse.c msgid "Unable to init parser" -msgstr "" +msgstr "Kan inte initiera tolken" #: shared-module/displayio/OnDiskBitmap.c msgid "Unable to read color palette data" -msgstr "" +msgstr "Det går inte att läsa färgpalettdata" #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." -msgstr "" +msgstr "Det gick inte att skriva till nvm." #: ports/nrf/common-hal/_bleio/UUID.c msgid "Unexpected nrfx uuid type" -msgstr "" +msgstr "Oväntad nrfx uuid-typ" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown gatt error: 0x%04x" -msgstr "" +msgstr "Okänt gatt-fel: 0x%04x" #: supervisor/shared/safe_mode.c msgid "Unknown reason." -msgstr "" +msgstr "Okänd anledning." #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" -msgstr "" +msgstr "Okänt säkerhetsfel: 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown soft device error: %04x" -msgstr "" +msgstr "Okänt mjukvarufel: %04x" #: shared-bindings/_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." -msgstr "" +msgstr "Omatchat antal på RHS (förväntat %d, fick %d)." #: ports/nrf/common-hal/_bleio/__init__.c msgid "" "Unspecified issue. Can be that the pairing prompt on the other device was " "declined or ignored." msgstr "" +"Ospecificerat problem. Kan vara att parningen på den andra enheten avvisades " +"eller ignorerades." #: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" -msgstr "" +msgstr "Baudrate stöd inte" #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" -msgstr "" +msgstr "Busstyp för display stöds inte" #: shared-module/audiocore/WaveFile.c msgid "Unsupported format" -msgstr "" +msgstr "Formatet stöds inte" #: py/moduerrno.c msgid "Unsupported operation" -msgstr "" +msgstr "Åtgärd som inte stöds" #: shared-bindings/digitalio/DigitalInOut.c msgid "Unsupported pull value." -msgstr "" +msgstr "Ogiltigt Pull-värde." #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" -msgstr "" +msgstr "Värdets längde ! = krävd fast längd" #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" -msgstr "" +msgstr "Värdets längd > max_length" #: py/emitnative.c msgid "Viper functions don't currently support more than 4 arguments" -msgstr "" +msgstr "Viper-funktioner stöder för närvarande inte mer än fyra argument" #: ports/stm/common-hal/microcontroller/Processor.c msgid "Voltage read timed out" -msgstr "" +msgstr "Avläsning av spänning tog för lång tid" #: main.c msgid "WARNING: Your code filename has two extensions\n" -msgstr "" +msgstr "VARNING: Ditt filnamn för kod har två tillägg\n" #: py/builtinhelp.c #, c-format @@ -1652,972 +1685,985 @@ msgid "" "\n" "To list built-in modules please do `help(\"modules\")`.\n" msgstr "" +"Välkommen till Adafruit CircuitPython %s!\n" +"\n" +"Besök learning.adafruit.com/category/circuitpython för projektguider.\n" +"\n" +"För att lista inbyggda moduler, vänligen `help(\" modules \")`.\n" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" -msgstr "" +msgstr "Skrivning stöds inte på karaktäristik" #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" -msgstr "" +msgstr "Du är i säkert läge: något öväntat hände.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " -msgstr "" +msgstr "Du begärt att starta i felsäkert läge genom att " #: py/objtype.c msgid "__init__() should return None" -msgstr "" +msgstr "__init __ () ska returnera None" #: py/objtype.c #, c-format msgid "__init__() should return None, not '%s'" -msgstr "" +msgstr "__init __ () ska returnera None, inte '%s'" #: py/objobject.c msgid "__new__ arg must be a user-type" -msgstr "" +msgstr "__new__ arg måste vara en användartyp" #: extmod/modubinascii.c extmod/moduhashlib.c msgid "a bytes-like object is required" -msgstr "" +msgstr "ett bytesliknande objekt krävs" #: lib/embed/abort_.c msgid "abort() called" -msgstr "" +msgstr "abort() anropad" #: extmod/machine_mem.c #, c-format msgid "address %08x is not aligned to %d bytes" -msgstr "" +msgstr "adressen %08x är inte justerad till %d byte" #: shared-bindings/i2cslave/I2CSlave.c msgid "address out of bounds" -msgstr "" +msgstr "adress utanför gränsen" #: shared-bindings/i2cslave/I2CSlave.c msgid "addresses is empty" -msgstr "" +msgstr "adresserna är tomma" #: extmod/ulab/code/vectorise.c msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" +msgstr "arctan2 är enbart implementerad för scalar och ndarray" #: py/modbuiltins.c msgid "arg is an empty sequence" -msgstr "" +msgstr "arg är en tom sekvens" #: extmod/ulab/code/numerical.c msgid "argsort argument must be an ndarray" -msgstr "" +msgstr "argumentet argsort måste vara en ndarray" #: py/runtime.c msgid "argument has wrong type" -msgstr "" +msgstr "argumentet har fel typ" #: py/argcheck.c shared-bindings/_stage/__init__.c #: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" -msgstr "" +msgstr "argument antal/typ matchar inte" #: py/runtime.c msgid "argument should be a '%q' not a '%q'" -msgstr "" +msgstr "argumentet skall vara en '%q', inte en '%q'" #: extmod/ulab/code/linalg.c msgid "arguments must be ndarrays" -msgstr "" +msgstr "argumenten måste vara ndarray" #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" -msgstr "" +msgstr "array/bytes krävs på höger sida" #: extmod/ulab/code/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" -msgstr "" +msgstr "försök att få argmin/argmax för en tom sekvens" #: py/objstr.c msgid "attributes not supported yet" -msgstr "" +msgstr "attribut stöds inte än" #: extmod/ulab/code/numerical.c msgid "axis must be -1, 0, None, or 1" -msgstr "" +msgstr "axis ska vara -1, 0, None eller 1" #: extmod/ulab/code/numerical.c msgid "axis must be -1, 0, or 1" -msgstr "" +msgstr "axis ska vara -1, 0 eller 1" #: extmod/ulab/code/numerical.c msgid "axis must be None, 0, or 1" -msgstr "" +msgstr "axis ska vara None, 0, eller 1" #: py/builtinevex.c msgid "bad compile mode" -msgstr "" +msgstr "Ogiltigt kompileringsläge" #: py/objstr.c msgid "bad conversion specifier" -msgstr "" +msgstr "Ogiltig konverteringsspecifikation" #: py/objstr.c msgid "bad format string" -msgstr "" +msgstr "Ogiltig formatsträng" #: py/binary.c msgid "bad typecode" -msgstr "" +msgstr "Ogiltig typkod" #: py/emitnative.c msgid "binary op %q not implemented" -msgstr "" +msgstr "binär op %q är inte implementerad" #: shared-bindings/busio/UART.c msgid "bits must be 7, 8 or 9" -msgstr "" +msgstr "bits måste vara 7, 8 eller 9" #: extmod/machine_spi.c msgid "bits must be 8" -msgstr "" +msgstr "bits måste vara 8" #: shared-bindings/audiomixer/Mixer.c msgid "bits_per_sample must be 8 or 16" -msgstr "" +msgstr "bits_per_sample måste vara 8 eller 16" #: py/emitinlinethumb.c msgid "branch not in range" -msgstr "" +msgstr "branch utanför räckvidd" #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" -msgstr "" +msgstr "buffer måste vara en byte-liknande objekt" #: shared-module/struct/__init__.c msgid "buffer size must match format" -msgstr "" +msgstr "buffertstorleken måste matcha formatet" #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "buffer slices must be of equal length" -msgstr "" +msgstr "buffertsegmenten måste vara lika långa" #: py/modstruct.c shared-bindings/struct/__init__.c #: shared-module/struct/__init__.c msgid "buffer too small" -msgstr "" +msgstr "buffert för liten" #: extmod/machine_spi.c msgid "buffers must be the same length" -msgstr "" +msgstr "buffertar måste vara samma längd" #: shared-bindings/_pew/PewPew.c msgid "buttons must be digitalio.DigitalInOut" -msgstr "" +msgstr "buttons måste vara digitalio.DigitalInOut" #: py/vm.c msgid "byte code not implemented" -msgstr "" +msgstr "byte-kod inte implementerad" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "byteorder is not a string" -msgstr "" +msgstr "byteorder är inte en sträng" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" -msgstr "" +msgstr "bytes> 8 bitar stöds inte" #: py/objstr.c msgid "bytes value out of range" -msgstr "" +msgstr "bytevärde utanför intervallet" #: ports/atmel-samd/bindings/samd/Clock.c msgid "calibration is out of range" -msgstr "" +msgstr "kalibrering är utanför intervallet" #: ports/atmel-samd/bindings/samd/Clock.c msgid "calibration is read only" -msgstr "" +msgstr "kalibrering är skrivskyddad" #: ports/atmel-samd/common-hal/rtc/RTC.c msgid "calibration value out of range +/-127" -msgstr "" +msgstr "kalibreringsvärde utanför intervallet +/- 127" #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" -msgstr "" +msgstr "kan bara ha upp till 4 parametrar för Thumbs assembly" #: py/emitinlinextensa.c msgid "can only have up to 4 parameters to Xtensa assembly" -msgstr "" +msgstr "kan bara ha upp till 4 parametrar att Xtensa assembly" #: py/persistentcode.c msgid "can only save bytecode" -msgstr "" +msgstr "kan bara spara bytekod" #: py/objtype.c msgid "can't add special method to already-subclassed class" -msgstr "" +msgstr "kan inte lägga till särskild metod för redan subklassad klass" #: py/compile.c msgid "can't assign to expression" -msgstr "" +msgstr "kan inte tilldela uttryck" #: py/obj.c #, c-format msgid "can't convert %s to complex" -msgstr "" +msgstr "kan inte konvertera %s till komplex" #: py/obj.c #, c-format msgid "can't convert %s to float" -msgstr "" +msgstr "kan inte konvertera %s till float" #: py/obj.c #, c-format msgid "can't convert %s to int" -msgstr "" +msgstr "kan inte konvertera %s till int" #: py/objstr.c msgid "can't convert '%q' object to %q implicitly" -msgstr "" +msgstr "kan inte konvertera '%q' objekt implicit till %q" #: py/objint.c msgid "can't convert NaN to int" -msgstr "" +msgstr "kan inte konvertera NaN till int" #: shared-bindings/i2cslave/I2CSlave.c msgid "can't convert address to int" -msgstr "" +msgstr "kan inte konvertera address till int" #: py/objint.c msgid "can't convert inf to int" -msgstr "" +msgstr "kan inte konvertera inf till int" #: py/obj.c msgid "can't convert to complex" -msgstr "" +msgstr "kan inte konvertera till komplex" #: py/obj.c msgid "can't convert to float" -msgstr "" +msgstr "kan inte konvertera till float" #: py/obj.c msgid "can't convert to int" -msgstr "" +msgstr "kan inte konvertera till int" #: py/objstr.c msgid "can't convert to str implicitly" -msgstr "" +msgstr "kan inte implicit konvertera till str" #: py/compile.c msgid "can't declare nonlocal in outer code" -msgstr "" +msgstr "kan inte deklarera icke-lokalt i yttre kod" #: py/compile.c msgid "can't delete expression" -msgstr "" +msgstr "kan inte ta bort uttryck" #: py/emitnative.c msgid "can't do binary op between '%q' and '%q'" -msgstr "" +msgstr "kan inte göra binära op mellan '%q' och '%q'" #: py/objcomplex.c msgid "can't do truncated division of a complex number" -msgstr "" +msgstr "kan inte göra trunkerad division av komplext tal" #: py/compile.c msgid "can't have multiple **x" -msgstr "" +msgstr "kan inte ha flera **x" #: py/compile.c msgid "can't have multiple *x" -msgstr "" +msgstr "kan inte ha flera *x" #: py/emitnative.c msgid "can't implicitly convert '%q' to 'bool'" -msgstr "" +msgstr "kan inte implicit konvertera '%q' till 'bool'" #: py/emitnative.c msgid "can't load from '%q'" -msgstr "" +msgstr "kan inte ladda från '%q'" #: py/emitnative.c msgid "can't load with '%q' index" -msgstr "" +msgstr "kan inte ladda med '%q' index" #: py/objgenerator.c msgid "can't pend throw to just-started generator" -msgstr "" +msgstr "kan inte 'pend throw' för nystartad generator" #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" -msgstr "" +msgstr "kan inte skicka icke-None värde till nystartad generator" #: py/objnamedtuple.c msgid "can't set attribute" -msgstr "" +msgstr "kan inte att ange attribut" #: py/emitnative.c msgid "can't store '%q'" -msgstr "" +msgstr "kan inte lagra '%q'" #: py/emitnative.c msgid "can't store to '%q'" -msgstr "" +msgstr "kan inte spara till '%q'" #: py/emitnative.c msgid "can't store with '%q' index" -msgstr "" +msgstr "kan inte lagra med '%q'-index" #: py/objstr.c msgid "" "can't switch from automatic field numbering to manual field specification" msgstr "" +"kan inte byta från automatisk fältnumrering till manuell fältspecifikation" #: py/objstr.c msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "" +"kan inte byta från manuell fältspecifikation till automatisk fältnumrering" #: py/objtype.c msgid "cannot create '%q' instances" -msgstr "" +msgstr "kan inte skapa instanser av '% q'" #: py/objtype.c msgid "cannot create instance" -msgstr "" +msgstr "kan inte skapa instans" #: py/runtime.c msgid "cannot import name %q" -msgstr "" +msgstr "kan inte importera namn %q" #: py/builtinimport.c msgid "cannot perform relative import" -msgstr "" +msgstr "kan inte utföra relativ import" #: extmod/ulab/code/ndarray.c msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" +msgstr "kan inte omforma matris (inkompatibel indata-/utdataform)" #: py/emitnative.c msgid "casting" -msgstr "" +msgstr "casting" #: shared-bindings/_stage/Text.c msgid "chars buffer too small" -msgstr "" +msgstr "teckenbuffert för liten" #: py/modbuiltins.c msgid "chr() arg not in range(0x110000)" -msgstr "" +msgstr "chr() arg är inte i intervallet(0x110000)" #: py/modbuiltins.c msgid "chr() arg not in range(256)" -msgstr "" +msgstr "chr() arg är inte i intervallet(256)" #: shared-module/vectorio/Circle.c msgid "circle can only be registered in one parent" -msgstr "" +msgstr "circle kan endast registreras i en förälder" #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" -msgstr "" +msgstr "färgbuffert måste vara 3 byte (RGB) eller 4 byte (RGB + pad byte)" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a buffer, tuple, list, or int" -msgstr "" +msgstr "färgbuffert måste vara en buffert, tupel, en lista, eller int" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" -msgstr "" +msgstr "färgbuffert måste vara en bytearray eller matris av typ 'b' eller 'B'" #: shared-bindings/displayio/Palette.c msgid "color must be between 0x000000 and 0xffffff" -msgstr "" +msgstr "färg måste vara mellan 0x000000 och 0xffffff" #: shared-bindings/displayio/ColorConverter.c msgid "color should be an int" -msgstr "" +msgstr "color ska vara en int" #: py/objcomplex.c msgid "complex division by zero" -msgstr "" +msgstr "komplex division med noll" #: py/objfloat.c py/parsenum.c msgid "complex values not supported" -msgstr "" +msgstr "komplexa värden stöds inte" #: extmod/moduzlib.c msgid "compression header" -msgstr "" +msgstr "komprimeringsheader" #: py/parse.c msgid "constant must be an integer" -msgstr "" +msgstr "konstant måste vara ett heltal" #: py/emitnative.c msgid "conversion to object" -msgstr "" +msgstr "konvertering till objekt" #: extmod/ulab/code/filter.c msgid "convolve arguments must be linear arrays" -msgstr "" +msgstr "Argumenten convolve måste vara linjära matriser" #: extmod/ulab/code/filter.c msgid "convolve arguments must be ndarrays" -msgstr "" +msgstr "Argumenten convolve måste vara ndarray:er" #: extmod/ulab/code/filter.c msgid "convolve arguments must not be empty" -msgstr "" +msgstr "Argumenten convolve kan inte vara tomma" #: extmod/ulab/code/ndarray.c msgid "could not broadast input array from shape" -msgstr "" +msgstr "Kan inte sända indatamatris från form" #: extmod/ulab/code/poly.c msgid "could not invert Vandermonde matrix" -msgstr "" +msgstr "kan inte invertera Vandermonde-matris" #: extmod/ulab/code/numerical.c msgid "ddof must be smaller than length of data set" -msgstr "" +msgstr "ddof måste vara mindre än längden på datauppsättningen" #: py/parsenum.c msgid "decimal numbers not supported" -msgstr "" +msgstr "decimaltal stöds inte" #: py/compile.c msgid "default 'except' must be last" -msgstr "" +msgstr "standard \"except\" måste ligga sist" #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" msgstr "" +"destinationsbuffert måste vara en bytearray eller matris av typ 'B' för " +"bit_depth = 8" #: shared-bindings/audiobusio/PDMIn.c msgid "destination buffer must be an array of type 'H' for bit_depth = 16" msgstr "" +"destinationsbufferten måste vara en matris av typen 'H' för bit_depth = 16" #: shared-bindings/audiobusio/PDMIn.c msgid "destination_length must be an int >= 0" -msgstr "" +msgstr "destination_length måste vara ett heltal >= 0" #: py/objdict.c msgid "dict update sequence has wrong length" -msgstr "" +msgstr "uppdateringssekvensen för dict har fel längd" #: extmod/ulab/code/numerical.c msgid "diff argument must be an ndarray" -msgstr "" +msgstr "argumentet diff måste vara en ndarray" #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" -msgstr "" +msgstr "division med noll" #: py/objdeque.c msgid "empty" -msgstr "" +msgstr "tom" #: shared-bindings/vectorio/Polygon.c msgid "empty %q list" -msgstr "" +msgstr "tom %q-lista" #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" -msgstr "" +msgstr "tom heap" #: py/objstr.c msgid "empty separator" -msgstr "" +msgstr "tom separator" #: shared-bindings/random/__init__.c msgid "empty sequence" -msgstr "" +msgstr "tom sekvens" #: py/objstr.c msgid "end of format while looking for conversion specifier" -msgstr "" +msgstr "slut på format vid sökning efter konverteringsspecificerare" #: shared-bindings/displayio/Shape.c msgid "end_x should be an int" -msgstr "" +msgstr "color ska vara en int" #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" -msgstr "" +msgstr "fel = 0x%08lX" #: py/runtime.c msgid "exceptions must derive from BaseException" -msgstr "" +msgstr "exceptions måste ärvas från BaseException" #: py/objstr.c msgid "expected ':' after format specifier" -msgstr "" +msgstr "förväntade ':' efter formatspecifikation" #: py/obj.c msgid "expected tuple/list" -msgstr "" +msgstr "förväntade tupel/lista" #: py/modthread.c msgid "expecting a dict for keyword args" -msgstr "" +msgstr "förväntar en dict för keyword args" #: py/compile.c msgid "expecting an assembler instruction" -msgstr "" +msgstr "förväntar en assemblerinstruktion" #: py/compile.c msgid "expecting just a value for set" -msgstr "" +msgstr "förväntar bara ett värde för set" #: py/compile.c msgid "expecting key:value for dict" -msgstr "" +msgstr "förväntar nyckel:värde för dict" #: py/argcheck.c msgid "extra keyword arguments given" -msgstr "" +msgstr "extra keyword-argument angivna" #: py/argcheck.c msgid "extra positional arguments given" -msgstr "" +msgstr "extra positions-argument angivna" #: py/parse.c msgid "f-string expression part cannot include a '#'" -msgstr "" +msgstr "f-stränguttrycksdelen kan inte innehålla en '#'" #: py/parse.c msgid "f-string expression part cannot include a backslash" -msgstr "" +msgstr "f-string-uttrycksdelen kan inte innehålla ett omvänt snedstreck" #: py/parse.c msgid "f-string: empty expression not allowed" -msgstr "" +msgstr "f-sträng: tomt uttryck inte tillåten" #: py/parse.c msgid "f-string: expecting '}'" -msgstr "" +msgstr "f-string: förväntat '}'" #: py/parse.c msgid "f-string: single '}' is not allowed" -msgstr "" +msgstr "f-string: singel '}' är inte tillåten" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" -msgstr "" +msgstr "filen måste vara en fil som öppnats i byte-läge" #: shared-bindings/storage/__init__.c msgid "filesystem must provide mount method" -msgstr "" +msgstr "filsystemet måste tillhandahålla mount-metod" #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" -msgstr "" +msgstr "första argumentet måste vara en iterable" #: extmod/ulab/code/vectorise.c msgid "first argument must be an ndarray" -msgstr "" +msgstr "första argumentet måste vara en ndarray" #: py/objtype.c msgid "first argument to super() must be type" -msgstr "" +msgstr "första argumentet till super() måste vara typ" #: extmod/machine_spi.c msgid "firstbit must be MSB" -msgstr "" +msgstr "firstbit måste vara MSB" #: extmod/ulab/code/ndarray.c msgid "flattening order must be either 'C', or 'F'" -msgstr "" +msgstr "förenklingsordningen måste vara antingen \"C\" eller \"F\"" #: extmod/ulab/code/numerical.c msgid "flip argument must be an ndarray" -msgstr "" +msgstr "Argumentet flip måste vara en ndarray" #: py/objint.c msgid "float too big" -msgstr "" +msgstr "flyttalet för stort" #: shared-bindings/_stage/Text.c msgid "font must be 2048 bytes long" -msgstr "" +msgstr "typsnitt måste vara 2048 bytes långt" #: py/objstr.c msgid "format requires a dict" -msgstr "" +msgstr "formatet kräver en dict" #: py/objdeque.c msgid "full" -msgstr "" +msgstr "full" #: py/argcheck.c msgid "function does not take keyword arguments" -msgstr "" +msgstr "funktionen tar inte nyckelordsargument" #: py/argcheck.c #, c-format msgid "function expected at most %d arguments, got %d" -msgstr "" +msgstr "funktionen förväntar som mest %d argument, fick %d" #: py/bc.c py/objnamedtuple.c msgid "function got multiple values for argument '%q'" -msgstr "" +msgstr "funktionen fick flera värden för argumentet '%q'" #: extmod/ulab/code/compare.c msgid "function is implemented for scalars and ndarrays only" -msgstr "" +msgstr "funktionen är endast implementerad för scalar och ndarray" #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" -msgstr "" +msgstr "funktion saknar %d obligatoriska positionsargument" #: py/bc.c msgid "function missing keyword-only argument" -msgstr "" +msgstr "funktionen saknar nyckelordsargument" #: py/bc.c msgid "function missing required keyword argument '%q'" -msgstr "" +msgstr "funktionen saknar det obligatoriska nyckelordsargumentet '%q'" #: py/bc.c #, c-format msgid "function missing required positional argument #%d" -msgstr "" +msgstr "funktionen saknar det obligatoriska positionsargumentet #%d" #: py/argcheck.c py/bc.c py/objnamedtuple.c #, c-format msgid "function takes %d positional arguments but %d were given" -msgstr "" +msgstr "funktionen kräver %d positionsargument men %d angavs" #: shared-bindings/time/__init__.c msgid "function takes exactly 9 arguments" -msgstr "" +msgstr "funktionen kräver exakt 9 argument" #: py/objgenerator.c msgid "generator already executing" -msgstr "" +msgstr "generatorn kör redan" #: py/objgenerator.c msgid "generator ignored GeneratorExit" -msgstr "" +msgstr "generatorn ignorerade GeneratorExit" #: shared-bindings/_stage/Layer.c msgid "graphic must be 2048 bytes long" -msgstr "" +msgstr "graphic måste vara 2048 byte lång" #: extmod/moduheapq.c msgid "heap must be a list" -msgstr "" +msgstr "heap måste vara en lista" #: py/compile.c msgid "identifier redefined as global" -msgstr "" +msgstr "identifieraren omdefinierad till global" #: py/compile.c msgid "identifier redefined as nonlocal" -msgstr "" +msgstr "identifieraren omdefinierad som icke-lokal" #: py/objstr.c msgid "incomplete format" -msgstr "" +msgstr "ofullständigt format" #: py/objstr.c msgid "incomplete format key" -msgstr "" +msgstr "ofullständig formatnyckel" #: extmod/modubinascii.c msgid "incorrect padding" -msgstr "" +msgstr "felaktig utfyllnad" #: extmod/ulab/code/ndarray.c msgid "index is out of bounds" -msgstr "" +msgstr "index är utanför gränserna" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #: ports/stm/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" -msgstr "" +msgstr "index utanför intervallet" #: py/obj.c msgid "indices must be integers" -msgstr "" +msgstr "index måste vara heltal" #: extmod/ulab/code/ndarray.c msgid "indices must be integers, slices, or Boolean lists" -msgstr "" +msgstr "index måste vara heltal, slices, eller Boolean-listor" #: py/compile.c msgid "inline assembler must be a function" -msgstr "" +msgstr "inline assembler måste vara en funktion" #: extmod/ulab/code/create.c msgid "input argument must be an integer or a 2-tuple" -msgstr "" +msgstr "indataargumentet måste vara ett heltal eller en 2-tupel" #: extmod/ulab/code/fft.c msgid "input array length must be power of 2" -msgstr "" +msgstr "indataarraylängden måste vara en multipel av 2" #: extmod/ulab/code/poly.c msgid "input data must be an iterable" -msgstr "" +msgstr "indata måste vara en iterable" #: extmod/ulab/code/linalg.c msgid "input matrix is asymmetric" -msgstr "" +msgstr "indatamatrisen är asymmetrisk" #: extmod/ulab/code/linalg.c msgid "input matrix is singular" -msgstr "" +msgstr "indatamatrisen är singulär" #: extmod/ulab/code/linalg.c msgid "input must be square matrix" -msgstr "" +msgstr "indata måste vara kvadratmatris" #: extmod/ulab/code/numerical.c msgid "input must be tuple, list, range, or ndarray" -msgstr "" +msgstr "indata måste vara tupel, lista, range, eller ndarray" #: extmod/ulab/code/poly.c msgid "input vectors must be of equal length" -msgstr "" +msgstr "indatavektorer måste ha samma längd" #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" -msgstr "" +msgstr "int() arg 2 måste vara >= 2 och <= 36" #: py/objstr.c msgid "integer required" -msgstr "" +msgstr "heltal krävs" #: shared-bindings/_bleio/Adapter.c #, c-format msgid "interval must be in range %s-%s" -msgstr "" +msgstr "interval måste vara i intervallet %s-%s" #: extmod/machine_i2c.c msgid "invalid I2C peripheral" -msgstr "" +msgstr "ogiltig I2C-kringutrustning" #: extmod/machine_spi.c msgid "invalid SPI peripheral" -msgstr "" +msgstr "ogiltig SPI-kringutrustning" #: lib/netutils/netutils.c msgid "invalid arguments" -msgstr "" +msgstr "ogiltiga argument" #: extmod/modussl_axtls.c msgid "invalid cert" -msgstr "" +msgstr "ogiltigt certifikat" #: extmod/uos_dupterm.c msgid "invalid dupterm index" -msgstr "" +msgstr "ogiltigt dupterm index" #: extmod/modframebuf.c msgid "invalid format" -msgstr "" +msgstr "ogiltigt format" #: py/objstr.c msgid "invalid format specifier" -msgstr "" +msgstr "ogiltig formatspecificerare" #: extmod/modussl_axtls.c msgid "invalid key" -msgstr "" +msgstr "ogiltig nyckel" #: py/compile.c msgid "invalid micropython decorator" -msgstr "" +msgstr "ogiltig mikropython-dekorator" #: shared-bindings/random/__init__.c msgid "invalid step" -msgstr "" +msgstr "ogiltigt steg" #: py/compile.c py/parse.c msgid "invalid syntax" -msgstr "" +msgstr "ogiltig syntax" #: py/parsenum.c msgid "invalid syntax for integer" -msgstr "" +msgstr "ogiltig syntax för heltal" #: py/parsenum.c #, c-format msgid "invalid syntax for integer with base %d" -msgstr "" +msgstr "ogiltig syntax för heltal med bas %d" #: py/parsenum.c msgid "invalid syntax for number" -msgstr "" +msgstr "ogiltig syntax för tal" #: py/objtype.c msgid "issubclass() arg 1 must be a class" -msgstr "" +msgstr "issubclass() arg 1 måste vara en klass" #: py/objtype.c msgid "issubclass() arg 2 must be a class or a tuple of classes" -msgstr "" +msgstr "issubclass() arg 2 måste vara en klass eller en tupel av klasser" #: extmod/ulab/code/ndarray.c msgid "iterables are not of the same length" -msgstr "" +msgstr "iterables är inte av samma längd" #: extmod/ulab/code/linalg.c msgid "iterations did not converge" -msgstr "" +msgstr "iterations konvergerar inte" #: py/objstr.c msgid "join expects a list of str/bytes objects consistent with self object" msgstr "" +"join förväntar sig en lista över str/bytes-objekt som överensstämmer med " +"objektet self" #: py/argcheck.c msgid "keyword argument(s) not yet implemented - use normal args instead" msgstr "" +"nyckelordsargument är ännu inte implementerade - använd vanliga argument" #: py/bc.c msgid "keywords must be strings" -msgstr "" +msgstr "nyckelord måste vara strängar" #: py/emitinlinethumb.c py/emitinlinextensa.c msgid "label '%q' not defined" -msgstr "" +msgstr "etiketten '%q' har inte definierats" #: py/compile.c msgid "label redefined" -msgstr "" +msgstr "etiketten omdefinierad" #: py/stream.c msgid "length argument not allowed for this type" -msgstr "" +msgstr "argumentet length är inte är tillåten för denna typ" #: shared-bindings/audiomixer/MixerVoice.c msgid "level must be between 0 and 1" -msgstr "" +msgstr "level ska ligga mellan 0 och 1" #: py/objarray.c msgid "lhs and rhs should be compatible" -msgstr "" +msgstr "lhs och rhs måste vara kompatibla" #: py/emitnative.c msgid "local '%q' has type '%q' but source is '%q'" -msgstr "" +msgstr "lokala '%q' har typ '%q' men källan är '%q'" #: py/emitnative.c msgid "local '%q' used before type known" -msgstr "" +msgstr "lokal '%q' används innan typen är känd" #: py/vm.c msgid "local variable referenced before assignment" -msgstr "" +msgstr "lokal variabel refererad före tilldelning" #: py/objint.c msgid "long int not supported in this build" -msgstr "" +msgstr "long int stöds inte i denna build" #: py/parse.c msgid "malformed f-string" -msgstr "" +msgstr "f-sträng har felaktigt format" #: shared-bindings/_stage/Layer.c msgid "map buffer too small" -msgstr "" +msgstr "map-buffert för liten" #: py/modmath.c shared-bindings/math/__init__.c msgid "math domain error" -msgstr "" +msgstr "matematikdomänfel" #: extmod/ulab/code/linalg.c msgid "matrix dimensions do not match" -msgstr "" +msgstr "matrisdimensioner matchar inte" #: extmod/ulab/code/linalg.c msgid "matrix is not positive definite" -msgstr "" +msgstr "matrisen är inte positiv bestämd" #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" -msgstr "" +msgstr "max_length måste vara 0-%d när fixed_length är %s" #: py/runtime.c msgid "maximum recursion depth exceeded" -msgstr "" +msgstr "maximal rekursionsdjup överskriden" #: py/runtime.c #, c-format msgid "memory allocation failed, allocating %u bytes" -msgstr "" +msgstr "minnesallokering misslyckades, allokerar %u byte" #: py/runtime.c msgid "memory allocation failed, heap is locked" -msgstr "" +msgstr "minnesallokeringen misslyckades, heapen är låst" #: py/builtinimport.c msgid "module not found" -msgstr "" +msgstr "modulen hittades inte" #: extmod/ulab/code/poly.c msgid "more degrees of freedom than data points" -msgstr "" +msgstr "fler frihetsgrader än datapunkter" #: py/compile.c msgid "multiple *x in assignment" -msgstr "" +msgstr "flera *x i tilldelning" #: py/objtype.c msgid "multiple bases have instance lay-out conflict" -msgstr "" +msgstr "Multipla basklasser har instanslayoutkonflikt" #: py/objtype.c msgid "multiple inheritance not supported" -msgstr "" +msgstr "multipelt arv stöds inte" #: py/emitnative.c msgid "must raise an object" -msgstr "" +msgstr "måste ge ett objekt" #: extmod/machine_spi.c msgid "must specify all of sck/mosi/miso" -msgstr "" +msgstr "måste ange alla av sck/mosi/miso" #: py/modbuiltins.c msgid "must use keyword argument for key function" -msgstr "" +msgstr "måste använda nyckelordsargument för nyckelfunktion" #: extmod/ulab/code/numerical.c msgid "n must be between 0, and 9" -msgstr "" +msgstr "n måste vara mellan 0 och 9" #: py/runtime.c msgid "name '%q' is not defined" -msgstr "" +msgstr "namnet '%q' är inte definierat" #: py/runtime.c msgid "name not defined" -msgstr "" +msgstr "namn inte definierat" #: py/compile.c msgid "name reused for argument" -msgstr "" +msgstr "namn återanvänt för argument" #: py/emitnative.c msgid "native yield" -msgstr "" +msgstr "native yield" #: py/runtime.c #, c-format msgid "need more than %d values to unpack" -msgstr "" +msgstr "behöver mer än %d värden för att packa upp" #: py/objint_longlong.c py/objint_mpz.c py/runtime.c msgid "negative power with no float support" From 1d3447b5a36aff1f3ab8ebd081ea7fa155ca8f1a Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:27:46 +0000 Subject: [PATCH 127/216] Translated using Weblate (French) Currently translated at 63.9% (477 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index b87e0cd216..9dee0e20a2 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-05 20:24+0000\n" -"Last-Translator: Jeff Epler \n" +"PO-Revision-Date: 2020-05-17 15:28+0000\n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -45,7 +45,7 @@ msgid "" "To exit, please reset the board without " msgstr "" "\n" -"Pour repartir, veuillez réinitialiser sans " +"Pour quitter, veuillez réinitialiser la carte sans" #: py/obj.c msgid " File \"%q\"" From aa57a2c800395fec319236b364b5150a5f5c2232 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:28:10 +0000 Subject: [PATCH 128/216] Translated using Weblate (French) Currently translated at 64.0% (478 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 9dee0e20a2..1710c0cf3e 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:28+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -45,7 +45,7 @@ msgid "" "To exit, please reset the board without " msgstr "" "\n" -"Pour quitter, veuillez réinitialiser la carte sans" +"Pour quitter, veuillez réinitialiser la carte sans " #: py/obj.c msgid " File \"%q\"" From 9e590c14e3e3105c4536e3b53b6a9b47f7b8a152 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:28:34 +0000 Subject: [PATCH 129/216] Translated using Weblate (French) Currently translated at 64.0% (478 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/locale/fr.po b/locale/fr.po index 1710c0cf3e..0206e7917c 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:28+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -68,6 +68,8 @@ msgstr "%%c nécessite un entier 'int' ou un caractère 'char'" #, c-format msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" msgstr "" +"Les broches d'adresse% d et les broches RVB% d indiquent une hauteur de% d, " +"pas% d" #: shared-bindings/microcontroller/Pin.c msgid "%q in use" From 530469ff69d329dcb8c1e3f1775835e93bfe4754 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:28:52 +0000 Subject: [PATCH 130/216] Translated using Weblate (French) Currently translated at 64.2% (479 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 0206e7917c..27909e1e6f 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:28+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:29+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -68,8 +68,8 @@ msgstr "%%c nécessite un entier 'int' ou un caractère 'char'" #, c-format msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" msgstr "" -"Les broches d'adresse% d et les broches RVB% d indiquent une hauteur de% d, " -"pas% d" +"Les broches d'adresse %d et les broches RVB %d indiquent une hauteur de %d, " +"pas %d" #: shared-bindings/microcontroller/Pin.c msgid "%q in use" From aea15ad1694cca7e9accba0964e63bbe64dd5006 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:29:04 +0000 Subject: [PATCH 131/216] Translated using Weblate (French) Currently translated at 64.2% (479 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 27909e1e6f..9af41fb7b0 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:29+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -85,7 +85,7 @@ msgstr "les indices %q doivent être des entiers, pas %s" #: shared-bindings/vectorio/Polygon.c msgid "%q list must be a list" -msgstr "" +msgstr "La liste% q doit être une liste" #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c From eed21c4886671f3d0184f6f1df0822634fd34b44 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:29:33 +0000 Subject: [PATCH 132/216] Translated using Weblate (French) Currently translated at 64.3% (480 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 9af41fb7b0..2bdb2ace04 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:29+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -85,7 +85,7 @@ msgstr "les indices %q doivent être des entiers, pas %s" #: shared-bindings/vectorio/Polygon.c msgid "%q list must be a list" -msgstr "La liste% q doit être une liste" +msgstr "La liste %q doit être une liste" #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c From e8adbdbddc5d440034859683e527f5b72f8875e9 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:29:42 +0000 Subject: [PATCH 133/216] Translated using Weblate (French) Currently translated at 64.3% (480 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 2bdb2ace04..7508170ca4 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:29+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -96,7 +96,7 @@ msgstr "%q doit être >=1" #: shared-bindings/vectorio/Polygon.c msgid "%q must be a tuple of length 2" -msgstr "" +msgstr "% q doit être un tuple de longueur 2" #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" From e054e7ec9af69a07f6e10047162a45ea7cce84bb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:29:48 +0000 Subject: [PATCH 134/216] Translated using Weblate (French) Currently translated at 64.7% (483 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 7508170ca4..d052920d24 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:29+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:33+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -96,7 +96,7 @@ msgstr "%q doit être >=1" #: shared-bindings/vectorio/Polygon.c msgid "%q must be a tuple of length 2" -msgstr "% q doit être un tuple de longueur 2" +msgstr "%q doit être un tuple de longueur 2" #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" @@ -162,11 +162,11 @@ msgstr "'%s' l'entier 0x%x ne correspond pas au masque 0x%x" #: py/runtime.c msgid "'%s' object cannot assign attribute '%q'" -msgstr "L'objet '%s' ne peut pas assigner l'attribut '%q'" +msgstr "L'objet '%s' ne peut pas attribuer '%q'" #: py/proto.c msgid "'%s' object does not support '%q'" -msgstr "L'objet '%s' ne prends pas en charge '%q'" +msgstr "L'objet '%s' ne prend pas en charge '%q'" #: py/obj.c #, c-format @@ -216,7 +216,7 @@ msgstr "'align' nécessite 1 argument" #: py/compile.c msgid "'async for' or 'async with' outside async function" -msgstr "'async for' ou 'async with' sans fonction async" +msgstr "'async for' ou 'async with' sans fonction asynchrone extérieure" #: py/compile.c msgid "'await' outside function" From 50dab65dd998f1f416432c5bcdc7403272787d8d Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:31:13 +0000 Subject: [PATCH 135/216] Translated using Weblate (French) Currently translated at 64.7% (483 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index d052920d24..34ee14671c 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:33+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -278,7 +278,7 @@ msgstr "L'adresse doit être longue de %d octets" #: shared-bindings/_bleio/Address.c msgid "Address type out of range" -msgstr "" +msgstr "Type d'adresse hors plage" #: ports/nrf/common-hal/busio/I2C.c #, fuzzy @@ -324,7 +324,7 @@ msgstr "" #: ports/cxd56/common-hal/analogio/AnalogIn.c msgid "AnalogIn not supported on given pin" -msgstr "" +msgstr "'AnalogOut' n'est pas supporté sur la broche indiquée" #: ports/cxd56/common-hal/analogio/AnalogOut.c #: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c @@ -356,7 +356,7 @@ msgstr "Les valeurs du tableau doivent être des octets simples 'bytes'." #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "At most %d %q may be specified (not %d)" -msgstr "" +msgstr "Au plus% d% q peut être spécifié (pas% d)" #: supervisor/shared/safe_mode.c msgid "Attempted heap allocation when MicroPython VM not running." From f67e35a88b1622b4d22284a975e3faf78ade075c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:33:29 +0000 Subject: [PATCH 136/216] Translated using Weblate (French) Currently translated at 65.1% (486 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 34ee14671c..9925e29606 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:33+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:34+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -356,7 +356,7 @@ msgstr "Les valeurs du tableau doivent être des octets simples 'bytes'." #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "At most %d %q may be specified (not %d)" -msgstr "Au plus% d% q peut être spécifié (pas% d)" +msgstr "Au plus %d %q peut être spécifié (pas %d)" #: supervisor/shared/safe_mode.c msgid "Attempted heap allocation when MicroPython VM not running." From fa418945b7a10118d5947cb8065855aebfe93923 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:33:41 +0000 Subject: [PATCH 137/216] Translated using Weblate (French) Currently translated at 65.1% (486 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 9925e29606..b534157c45 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:34+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -361,6 +361,8 @@ msgstr "Au plus %d %q peut être spécifié (pas %d)" #: supervisor/shared/safe_mode.c msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" +"Tentative d'allocation de segments lorsque la machine virtuelle MicroPython " +"n'est pas en cours d'exécution." #: main.c msgid "Auto-reload is off.\n" @@ -377,7 +379,7 @@ msgstr "" #: shared-module/displayio/Display.c #: shared-module/framebufferio/FramebufferDisplay.c msgid "Below minimum frame rate" -msgstr "" +msgstr "Inférieur à la fréquence d'images minimale" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Bit clock and word select must share a clock unit" @@ -395,7 +397,7 @@ msgstr "Les deux entrées doivent supporter les interruptions matérielles" #: shared-bindings/framebufferio/FramebufferDisplay.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" -msgstr "" +msgstr "La luminosité doit être de 0 à 1,0" #: shared-bindings/supervisor/__init__.c msgid "Brightness must be between 0 and 255" From 94868852a16b825679456d414b1f0678a312470b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:34:01 +0000 Subject: [PATCH 138/216] Translated using Weblate (French) Currently translated at 65.2% (487 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index b534157c45..2a8998b36d 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:34+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -397,7 +397,7 @@ msgstr "Les deux entrées doivent supporter les interruptions matérielles" #: shared-bindings/framebufferio/FramebufferDisplay.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" -msgstr "La luminosité doit être de 0 à 1,0" +msgstr "La luminosité doit être de 0 à 1.0" #: shared-bindings/supervisor/__init__.c msgid "Brightness must be between 0 and 255" From a0b1d98c7986ad773aca28fc7c7ec71da96ab56c Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:34:10 +0000 Subject: [PATCH 139/216] Translated using Weblate (French) Currently translated at 65.2% (487 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 2a8998b36d..e0bd19d835 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:34+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -411,7 +411,7 @@ msgstr "Luminosité non-ajustable" #: shared-bindings/_bleio/UUID.c #, c-format msgid "Buffer + offset too small %d %d %d" -msgstr "" +msgstr "Tampon + décalage trop petit% d% d% d" #: shared-module/usb_hid/Device.c #, c-format From d05c0ec590531ef5f63f6bfa4a45280919bfc152 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:34:27 +0000 Subject: [PATCH 140/216] Translated using Weblate (French) Currently translated at 65.6% (490 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index e0bd19d835..2821c1b1bf 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:34+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:35+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -411,7 +411,7 @@ msgstr "Luminosité non-ajustable" #: shared-bindings/_bleio/UUID.c #, c-format msgid "Buffer + offset too small %d %d %d" -msgstr "Tampon + décalage trop petit% d% d% d" +msgstr "Tampon + décalage trop petit %d %d %d" #: shared-module/usb_hid/Device.c #, c-format @@ -421,7 +421,7 @@ msgstr "Tampon de taille incorrect. Devrait être de %d octets." #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Buffer is not a bytearray." -msgstr "" +msgstr "Le tampon n'est pas un 'bytearray'." #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c From 69d1a91edeeed8c176a9bf9b70a9ccbec0eaf47b Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:35:04 +0000 Subject: [PATCH 141/216] Translated using Weblate (French) Currently translated at 65.6% (490 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 2821c1b1bf..11d46c821b 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:35+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -426,12 +426,12 @@ msgstr "Le tampon n'est pas un 'bytearray'." #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Buffer is too small" -msgstr "" +msgstr "Le tampon est trop petit" #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Buffer length %d too big. It must be less than %d" -msgstr "" +msgstr "La longueur du tampon% d est trop grande. Il doit être inférieur à% d" #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" From ec1e51c683263f5dcc7185a41286e60002bb1afa Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:35:18 +0000 Subject: [PATCH 142/216] Translated using Weblate (French) Currently translated at 65.9% (492 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 11d46c821b..2ed236224c 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:35+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -431,7 +431,7 @@ msgstr "Le tampon est trop petit" #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Buffer length %d too big. It must be less than %d" -msgstr "La longueur du tampon% d est trop grande. Il doit être inférieur à% d" +msgstr "La longueur du tampon %d est trop grande. Il doit être inférieur à %d" #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" From 292d61b0d79495226bd2576afd05ec3485c845a2 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:35:25 +0000 Subject: [PATCH 143/216] Translated using Weblate (French) Currently translated at 65.9% (492 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 2ed236224c..54c3094eca 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:35+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -439,12 +439,12 @@ msgstr "Le tampon doit être de longueur au moins 1" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Buffer too large and unable to allocate" -msgstr "" +msgstr "Tampon trop volumineux et impossible à allouer" #: shared-bindings/_bleio/PacketBuffer.c #, c-format msgid "Buffer too short by %d bytes" -msgstr "" +msgstr "Tampon trop court de% d octets" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c From fb1892409964a04b7789b0db46b95cfe30a9f7aa Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:35:36 +0000 Subject: [PATCH 144/216] Translated using Weblate (French) Currently translated at 66.3% (495 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 54c3094eca..75b3fe25cd 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:35+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:36+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -444,7 +444,7 @@ msgstr "Tampon trop volumineux et impossible à allouer" #: shared-bindings/_bleio/PacketBuffer.c #, c-format msgid "Buffer too short by %d bytes" -msgstr "Tampon trop court de% d octets" +msgstr "Tampon trop court de %d octets" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c From 2edb2c86f2b182df64df6491f0d227e0bde4829a Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:35:45 +0000 Subject: [PATCH 145/216] Translated using Weblate (French) Currently translated at 66.3% (495 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 75b3fe25cd..92abe51fde 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:36+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -463,15 +463,15 @@ msgstr "Les octets 'bytes' doivent être entre 0 et 255" #: shared-bindings/aesio/aes.c msgid "CBC blocks must be multiples of 16 bytes" -msgstr "" +msgstr "Les blocs CBC doivent être des multiples de 16 octets" #: py/objtype.c msgid "Call super().__init__() before accessing native object." -msgstr "" +msgstr "Appelez super () .__ init __ () avant d'accéder à l'objet natif." #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" -msgstr "" +msgstr "Impossible de définir CCCD sur la caractéristique locale" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" From 8a58d1a42e1370cc6820a2afb5183b27db86df66 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:36:11 +0000 Subject: [PATCH 146/216] Translated using Weblate (French) Currently translated at 71.3% (532 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 92abe51fde..f63cbaa761 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:36+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:40+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -471,7 +471,7 @@ msgstr "Appelez super () .__ init __ () avant d'accéder à l'objet natif." #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" -msgstr "Impossible de définir CCCD sur la caractéristique locale" +msgstr "Impossible de définir CCCD sur une caractéristique locale" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" From 1a7fbd83fa98355e3c26312a7e7b0a7f9420c159 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:36:31 +0000 Subject: [PATCH 147/216] Translated using Weblate (French) Currently translated at 71.3% (532 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 76 ++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index f63cbaa761..332d022a43 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:40+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -521,7 +521,7 @@ msgstr "Impossible d'affecter une valeur quand la direction est 'input'." #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Cannot specify RTS or CTS in RS485 mode" -msgstr "" +msgstr "Impossible de spécifier RTS ou CTS en mode RS485" #: py/objslice.c msgid "Cannot subclass slice" @@ -537,7 +537,7 @@ msgstr "Impossible d'obtenir la taille du scalaire sans ambigüité" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Cannot vary frequency on a timer that is already in use" -msgstr "" +msgstr "Impossible de faire varier la fréquence sur une minuterie déjà utilisée" #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." @@ -549,13 +549,16 @@ msgstr "Ecriture sur 'CharacteristicBuffer' non fournie" #: supervisor/shared/safe_mode.c msgid "CircuitPython core code crashed hard. Whoops!\n" -msgstr "" +msgstr "Le code principal de CircuitPython s'est écrasé durement. Oups!\n" #: supervisor/shared/safe_mode.c msgid "" "CircuitPython is in safe mode because you pressed the reset button during " "boot. Press again to exit safe mode.\n" msgstr "" +"CircuitPython est en mode sans échec car vous avez appuyé sur le bouton de " +"réinitialisation pendant le démarrage. Appuyez à nouveau pour quitter le " +"mode sans échec.\n" #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." @@ -584,14 +587,16 @@ msgid "" "Connection has been disconnected and can no longer be used. Create a new " "connection." msgstr "" +"La connexion a été déconnectée et ne peut plus être utilisée. Créez une " +"nouvelle connexion." #: py/persistentcode.c msgid "Corrupt .mpy file" -msgstr "" +msgstr "Fichier .mpy corrompu" #: py/emitglue.c msgid "Corrupt raw code" -msgstr "" +msgstr "Code brut corrompu" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" @@ -599,35 +604,35 @@ msgstr "L'UART n'a pu être initialisé" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not initialize channel" -msgstr "" +msgstr "Impossible d'initialiser la chaîne" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not initialize timer" -msgstr "" +msgstr "Impossible d'initialiser la minuterie" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not re-init channel" -msgstr "" +msgstr "Impossible de réinitialiser la chaîne" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not re-init timer" -msgstr "" +msgstr "Impossible de réinitialiser le minuteur" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not restart PWM" -msgstr "" +msgstr "Impossible de redémarrer PWM" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Could not start PWM" -msgstr "" +msgstr "Impossible de démarrer PWM" #: ports/stm/common-hal/busio/UART.c msgid "Could not start interrupt, RX busy" -msgstr "" +msgstr "Impossible de démarrer l'interruption, RX occupé" #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" -msgstr "" +msgstr "Impossible d'allouer le décodeur" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3Decoder.c @@ -636,7 +641,7 @@ msgstr "Impossible d'allouer le 1er tampon" #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" -msgstr "" +msgstr "Impossible d'allouer le tampon d'entrée" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3Decoder.c @@ -645,15 +650,15 @@ msgstr "Impossible d'allouer le 2e tampon" #: supervisor/shared/safe_mode.c msgid "Crash into the HardFault_Handler." -msgstr "" +msgstr "Crash dans le HardFault_Handler." #: ports/stm/common-hal/analogio/AnalogOut.c msgid "DAC Channel Init Error" -msgstr "" +msgstr "Erreur d'initialisation du canal DAC" #: ports/stm/common-hal/analogio/AnalogOut.c msgid "DAC Device Init Error" -msgstr "" +msgstr "Erreur d'initialisation du périphérique DAC" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" @@ -679,16 +684,16 @@ msgstr "La capacité de destination est plus petite que 'destination_length'." #: ports/nrf/common-hal/audiobusio/I2SOut.c msgid "Device in use" -msgstr "" +msgstr "Appareil utilisé" #: ports/cxd56/common-hal/digitalio/DigitalInOut.c msgid "DigitalInOut not supported on given pin" -msgstr "" +msgstr "DigitalInOut non pris en charge sur la broche donnée" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Display must have a 16 bit colorspace." -msgstr "" +msgstr "L'affichage doit avoir un espace colorimétrique de 16 bits." #: shared-bindings/displayio/Display.c #: shared-bindings/displayio/EPaperDisplay.c @@ -702,7 +707,7 @@ msgstr "Le mode Drive n'est pas utilisé quand la direction est 'input'." #: shared-bindings/aesio/aes.c msgid "ECB only operates on 16 bytes at a time" -msgstr "" +msgstr "La BCE ne fonctionne que sur 16 octets à la fois" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c @@ -729,7 +734,7 @@ msgstr "Une 'Characteristic' est attendue" #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" -msgstr "" +msgstr "Attendu un service" #: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c #: shared-bindings/_bleio/Service.c @@ -739,7 +744,7 @@ msgstr "Un UUID est attendu" #: shared-bindings/_bleio/Adapter.c msgid "Expected an Address" -msgstr "" +msgstr "Attendu une adresse" #: shared-module/_pixelbuf/PixelBuf.c #, c-format @@ -752,11 +757,11 @@ msgstr "" #: extmod/ulab/code/fft.c msgid "FFT is defined for ndarrays only" -msgstr "" +msgstr "La FFT est définie pour les ndarrays uniquement" #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." -msgstr "" +msgstr "Échec de l'envoi de la commande." #: ports/nrf/sd_mutex.c #, fuzzy, c-format @@ -778,15 +783,15 @@ msgstr "Echec de l'allocation de %d octets du tampon RX" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" -msgstr "" +msgstr "Impossible de se connecter: erreur interne" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: timeout" -msgstr "" +msgstr "Impossible de se connecter: délai d'expiration" #: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" -msgstr "" +msgstr "Impossible d'analyser le fichier MP3" #: ports/nrf/sd_mutex.c #, fuzzy, c-format @@ -795,7 +800,7 @@ msgstr "Impossible de libérer mutex, err 0x%04x" #: supervisor/shared/safe_mode.c msgid "Failed to write internal flash." -msgstr "" +msgstr "Échec de l'écriture du flash interne." #: py/moduerrno.c msgid "File exists" @@ -808,6 +813,7 @@ msgstr "La fréquence capturée est au delà des capacités. Capture en pause." #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Frequency must match existing PWMOut using this timer" msgstr "" +"La fréquence doit correspondre à PWMOut existant à l'aide de cette minuterie" #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c @@ -818,7 +824,7 @@ msgstr "La fonction nécessite un verrou" #: shared-bindings/displayio/EPaperDisplay.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Group already used" -msgstr "" +msgstr "Groupe déjà utilisé" #: shared-module/displayio/Group.c msgid "Group full" @@ -827,11 +833,11 @@ msgstr "Groupe plein" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" -msgstr "" +msgstr "Matériel occupé, essayez d'autres broches" #: ports/stm/common-hal/busio/UART.c msgid "Hardware in use, try alternative pins" -msgstr "" +msgstr "Matériel utilisé, essayez d'autres broches" #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" @@ -839,7 +845,7 @@ msgstr "opération d'E/S sur un fichier fermé" #: ports/stm/common-hal/busio/I2C.c msgid "I2C Init Error" -msgstr "" +msgstr "Erreur d'initialisation I2C" #: extmod/machine_i2c.c msgid "I2C operation not supported" @@ -848,7 +854,7 @@ msgstr "opération sur I2C non supportée" #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" -msgstr "" +msgstr "IV doit être long de% d octets" #: py/persistentcode.c msgid "" From 5c950fc2bc2fa3840b9669fe76c9e4f72bff69b3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:40:52 +0000 Subject: [PATCH 148/216] Translated using Weblate (French) Currently translated at 71.8% (536 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 332d022a43..1cfd8ef913 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:40+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:41+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -854,7 +854,7 @@ msgstr "opération sur I2C non supportée" #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" -msgstr "IV doit être long de% d octets" +msgstr "IV doit être long de %d octets" #: py/persistentcode.c msgid "" From 1689cc6ec0f9262f4de7047018c0d1951c46d5e7 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:40:59 +0000 Subject: [PATCH 149/216] Translated using Weblate (French) Currently translated at 71.8% (536 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 1cfd8ef913..f71c926898 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:41+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -874,20 +874,20 @@ msgstr "Erreur d'entrée/sortie" #: ports/nrf/common-hal/_bleio/__init__.c msgid "Insufficient authentication" -msgstr "" +msgstr "Authentification insuffisante" #: ports/nrf/common-hal/_bleio/__init__.c msgid "Insufficient encryption" -msgstr "" +msgstr "Chiffrement insuffisant" #: ports/stm/common-hal/busio/UART.c msgid "Internal define error" -msgstr "" +msgstr "Erreur de définition interne" #: shared-module/rgbmatrix/RGBMatrix.c #, c-format msgid "Internal error #%d" -msgstr "" +msgstr "Erreur interne #% d" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c From ad06264e66e48fa4f5bb6a297bb90b1d8e2e3ad5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:41:19 +0000 Subject: [PATCH 150/216] Translated using Weblate (French) Currently translated at 73.1% (546 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index f71c926898..dc6ad0baa6 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:41+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:42+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -887,7 +887,7 @@ msgstr "Erreur de définition interne" #: shared-module/rgbmatrix/RGBMatrix.c #, c-format msgid "Internal error #%d" -msgstr "Erreur interne #% d" +msgstr "Erreur interne #%d" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c From 9ef61896d8842319fd2e3d9aaa2933534ab8b3a9 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:41:27 +0000 Subject: [PATCH 151/216] Translated using Weblate (French) Currently translated at 73.1% (546 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index dc6ad0baa6..1a6cadd7de 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:42+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -896,7 +896,7 @@ msgstr "Broche invalide pour '%q'" #: ports/stm/common-hal/analogio/AnalogIn.c msgid "Invalid ADC Unit value" -msgstr "" +msgstr "Valeur d'unité ADC non valide" #: shared-module/displayio/OnDiskBitmap.c #, fuzzy @@ -905,11 +905,11 @@ msgstr "Fichier BMP invalide" #: ports/stm/common-hal/analogio/AnalogOut.c msgid "Invalid DAC pin supplied" -msgstr "" +msgstr "Broche DAC non valide fournie" #: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm/common-hal/busio/I2C.c msgid "Invalid I2C pin selection" -msgstr "" +msgstr "Sélection de broches I2C non valide" #: ports/atmel-samd/common-hal/pulseio/PWMOut.c #: ports/cxd56/common-hal/pulseio/PWMOut.c @@ -919,11 +919,11 @@ msgstr "Fréquence de PWM invalide" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Invalid SPI pin selection" -msgstr "" +msgstr "Sélection de broches SPI non valide" #: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "Invalid UART pin selection" -msgstr "" +msgstr "Sélection de broches UART non valide" #: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" @@ -940,7 +940,7 @@ msgstr "Longueur de tampon invalide" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Invalid byteorder string" -msgstr "" +msgstr "Chaîne d'octets non valide" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" @@ -965,11 +965,11 @@ msgstr "Taille de bloc de formatage invalide" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Invalid frequency supplied" -msgstr "" +msgstr "Fréquence invalide fournie" #: supervisor/shared/safe_mode.c msgid "Invalid memory access." -msgstr "" +msgstr "Accès mémoire invalide." #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" @@ -1005,7 +1005,7 @@ msgstr "Broches invalides" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Invalid pins for PWMOut" -msgstr "" +msgstr "Broches non valides pour PWMOut" #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c #: shared-bindings/displayio/FourWire.c @@ -1014,7 +1014,7 @@ msgstr "Polarité invalide" #: shared-bindings/_bleio/Characteristic.c msgid "Invalid properties" -msgstr "" +msgstr "Propriétés non valides" #: shared-bindings/microcontroller/__init__.c msgid "Invalid run mode." From 0480776e8516bade7f5d2f8654a663996d01b276 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:42:50 +0000 Subject: [PATCH 152/216] Translated using Weblate (French) Currently translated at 73.3% (547 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 1a6cadd7de..90c6d5cb13 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:42+0000\n" +"PO-Revision-Date: 2020-05-17 15:43+0000\n" "Last-Translator: Anonymous \n" "Language-Team: French \n" @@ -1022,7 +1022,7 @@ msgstr "Mode de lancement invalide." #: shared-module/_bleio/Attribute.c msgid "Invalid security_mode" -msgstr "" +msgstr "Mode_sécurité non valide" #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" From f6d057fe10e66d745557e80ec11d789c05c2ecfc Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:43:03 +0000 Subject: [PATCH 153/216] Translated using Weblate (French) Currently translated at 74.3% (555 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 90c6d5cb13..d07ae6f36f 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:43+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:44+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1022,7 +1022,7 @@ msgstr "Mode de lancement invalide." #: shared-module/_bleio/Attribute.c msgid "Invalid security_mode" -msgstr "Mode_sécurité non valide" +msgstr "'mode_security' non valide" #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" From 63e25360233daf505ca159b84339c11fd636cf93 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:43:09 +0000 Subject: [PATCH 154/216] Translated using Weblate (French) Currently translated at 74.3% (555 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index d07ae6f36f..0ed18ddf2b 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:44+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1026,7 +1026,7 @@ msgstr "'mode_security' non valide" #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" -msgstr "" +msgstr "Voix invalide" #: shared-bindings/audiomixer/Mixer.c #, fuzzy @@ -1039,11 +1039,11 @@ msgstr "Fichier WAVE invalide" #: ports/stm/common-hal/busio/UART.c msgid "Invalid word/bit length" -msgstr "" +msgstr "Longueur de mot / bit non valide" #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" -msgstr "" +msgstr "La clé doit comporter 16, 24 ou 32 octets" #: py/compile.c msgid "LHS of keyword arg must be an id" @@ -1051,7 +1051,7 @@ msgstr "La partie gauche de l'argument nommé doit être un identifiant" #: shared-module/displayio/Group.c msgid "Layer already in a group." -msgstr "" +msgstr "Couche déjà dans un groupe." #: shared-module/displayio/Group.c msgid "Layer must be a Group or TileGrid subclass." @@ -1080,11 +1080,11 @@ msgstr "La valeur max. de x est %d lors d'une opération miroir" #: supervisor/shared/safe_mode.c msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" +msgstr "Le saut MicroPython NLR a échoué. Altération probable de la mémoire." #: supervisor/shared/safe_mode.c msgid "MicroPython fatal error." -msgstr "" +msgstr "Erreur fatale MicroPython." #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" @@ -1092,11 +1092,11 @@ msgstr "Le délais au démarrage du micro doit être entre 0.0 et 1.0" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" -msgstr "" +msgstr "Broche MISO ou MOSI manquante" #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." -msgstr "" +msgstr "Doit être une sous-classe% q." #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" From ce8896844cf4ee58ef0d57323c7d5fb6e2b59bce Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:44:04 +0000 Subject: [PATCH 155/216] Translated using Weblate (French) Currently translated at 74.6% (557 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 0ed18ddf2b..7cb0e1ef4c 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:44+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1096,7 +1096,7 @@ msgstr "Broche MISO ou MOSI manquante" #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." -msgstr "Doit être une sous-classe% q." +msgstr "Doit être une sous-classe de %q." #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" From b2f4c8cb9865573c5298f8d33ff531ab13a3de03 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:44:08 +0000 Subject: [PATCH 156/216] Translated using Weblate (French) Currently translated at 74.6% (557 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 7cb0e1ef4c..57f07fc347 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:44+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1100,12 +1100,12 @@ msgstr "Doit être une sous-classe de %q." #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" -msgstr "" +msgstr "Doit fournir une broche MISO ou MOSI" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "Must use a multiple of 6 rgb pins, not %d" -msgstr "" +msgstr "Doit utiliser un multiple de 6 broches RVB, pas% d" #: py/parse.c msgid "Name too long" From c51ef206429725bebb272e7009fd93513e344e2b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:44:21 +0000 Subject: [PATCH 157/216] Translated using Weblate (French) Currently translated at 76.5% (571 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 57f07fc347..fdb8419ef2 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:44+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:45+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1105,7 +1105,7 @@ msgstr "Doit fournir une broche MISO ou MOSI" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "Must use a multiple of 6 rgb pins, not %d" -msgstr "Doit utiliser un multiple de 6 broches RVB, pas% d" +msgstr "Doit utiliser un multiple de 6 broches RVB, pas %d" #: py/parse.c msgid "Name too long" From 0cd6e233ba2febcd3afa54f6874459e6665715b3 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:44:27 +0000 Subject: [PATCH 158/216] Translated using Weblate (French) Currently translated at 76.5% (571 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index fdb8419ef2..5d8f007d23 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:45+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1109,15 +1109,15 @@ msgstr "Doit utiliser un multiple de 6 broches RVB, pas %d" #: py/parse.c msgid "Name too long" -msgstr "" +msgstr "Nom trop long" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" -msgstr "" +msgstr "Étape négative non prise en charge" #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" -msgstr "" +msgstr "Pas de CCCD pour cette caractéristique" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c #: ports/stm/common-hal/analogio/AnalogOut.c @@ -1131,11 +1131,11 @@ msgstr "Aucun canal DMA trouvé" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" -msgstr "" +msgstr "Pas de broche MISO" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" -msgstr "" +msgstr "Pas de broche MOSI" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c @@ -1155,7 +1155,7 @@ msgstr "Pas d'horloge disponible" #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" -msgstr "" +msgstr "Pas de connexion: la longueur ne peut pas être déterminée" #: shared-bindings/board/__init__.c msgid "No default %q bus" @@ -1171,7 +1171,7 @@ msgstr "Pas de source matérielle d'aléa disponible" #: ports/atmel-samd/common-hal/ps2io/Ps2.c msgid "No hardware support on clk pin" -msgstr "" +msgstr "Pas de support matériel sur la broche clk" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c @@ -1180,19 +1180,19 @@ msgstr "Pas de support matériel pour cette broche" #: shared-bindings/aesio/aes.c msgid "No key was specified" -msgstr "" +msgstr "Aucune clé n'a été spécifiée" #: shared-bindings/time/__init__.c msgid "No long integer support" -msgstr "" +msgstr "Pas de support entier long" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "No more timers available on this pin." -msgstr "" +msgstr "Plus de minuteurs disponibles sur cette broche." #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" -msgstr "" +msgstr "Pas de pulldown sur la broche; 1Mohm recommandé" #: py/moduerrno.c msgid "No space left on device" @@ -1204,11 +1204,11 @@ msgstr "Fichier/dossier introuvable" #: shared-module/rgbmatrix/RGBMatrix.c msgid "No timer available" -msgstr "" +msgstr "Pas de minuterie disponible" #: supervisor/shared/safe_mode.c msgid "Nordic Soft Device failure assertion." -msgstr "" +msgstr "Affirmation de défaillance du Nordic Soft Device." #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c @@ -1251,6 +1251,8 @@ msgid "" "Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: " "%d bpp given" msgstr "" +"Prise en charge uniquement des monochromes, 4 bpp ou 8 bpp indexés et 16 bpp " +"ou plus:% d bpp fournis" #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." From 7adc63125eb510c09a0250c6bc166deb4ff705fc Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:45:48 +0000 Subject: [PATCH 159/216] Translated using Weblate (French) Currently translated at 77.0% (575 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 5d8f007d23..06f4857830 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:45+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:46+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1252,7 +1252,7 @@ msgid "" "%d bpp given" msgstr "" "Prise en charge uniquement des monochromes, 4 bpp ou 8 bpp indexés et 16 bpp " -"ou plus:% d bpp fournis" +"ou plus: %d bpp fournis" #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." From 5ebc1d4746217404c38045b747da26f182ffe347 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:45:54 +0000 Subject: [PATCH 160/216] Translated using Weblate (French) Currently translated at 77.0% (575 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 06f4857830..63aea61881 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:46+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1276,7 +1276,7 @@ msgstr "" #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" -msgstr "" +msgstr "ParallelBus pas encore pris en charge" #: py/moduerrno.c msgid "Permission denied" @@ -1292,11 +1292,11 @@ msgstr "La broche ne peut être utilisée pour l'ADC" #: ports/atmel-samd/common-hal/countio/Counter.c msgid "Pin must support hardware interrupts" -msgstr "" +msgstr "La broche doit prendre en charge les interruptions matérielles" #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin number already reserved by EXTI" -msgstr "" +msgstr "Numéro de broche déjà réservé par EXTI" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format @@ -1305,6 +1305,9 @@ msgid "" "bytes. If this cannot be avoided, pass allow_inefficient=True to the " "constructor" msgstr "" +"Le brochage utilise% d octets par élément, ce qui consomme plus que le% d " +"octets idéal. Si cela ne peut pas être évité, transmettez allow_inefficient =" +" True au constructeur" #: py/builtinhelp.c #, fuzzy From bb962554ad9e134fc940fdcb8ba92143f70991db Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:46:27 +0000 Subject: [PATCH 161/216] Translated using Weblate (French) Currently translated at 81.3% (607 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 63aea61881..23db9fb483 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:46+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:49+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1305,7 +1305,7 @@ msgid "" "bytes. If this cannot be avoided, pass allow_inefficient=True to the " "constructor" msgstr "" -"Le brochage utilise% d octets par élément, ce qui consomme plus que le% d " +"Le brochage utilise %d octets par élément, ce qui consomme plus que le %d " "octets idéal. Si cela ne peut pas être évité, transmettez allow_inefficient =" " True au constructeur" From ce1767ef0840f8e0e986a02c0c9a1b5062fe84ee Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:46:35 +0000 Subject: [PATCH 162/216] Translated using Weblate (French) Currently translated at 81.3% (607 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 67 +++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 23db9fb483..7ad6313949 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:49+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1316,11 +1316,11 @@ msgstr "Ainsi que tout autre module présent sur le système de fichiers\n" #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" -msgstr "" +msgstr "Pop à partir d'un tampon Ps2 vide" #: shared-bindings/_bleio/Adapter.c msgid "Prefix buffer must be on the heap" -msgstr "" +msgstr "Le tampon de préfixe doit être sur le tas" #: main.c msgid "Press any key to enter the REPL. Use CTRL-D to reload." @@ -1332,23 +1332,23 @@ msgstr "Le tirage 'pull' n'est pas utilisé quand la direction est 'output'." #: ports/stm/common-hal/pulseio/PulseIn.c msgid "PulseIn not supported on this chip" -msgstr "" +msgstr "PulseIn non pris en charge sur cette puce" #: ports/stm/common-hal/pulseio/PulseOut.c msgid "PulseOut not supported on this chip" -msgstr "" +msgstr "PulseOut non pris en charge sur cette puce" #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" -msgstr "" +msgstr "Erreur RNG DeInit" #: ports/stm/common-hal/os/__init__.c msgid "RNG Init Error" -msgstr "" +msgstr "Erreur d'initialisation RNG" #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" -msgstr "" +msgstr "Inversion RS485 spécifiée lorsqu'elle n'est pas en mode RS485" #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c @@ -1362,11 +1362,11 @@ msgstr "RTC non supportée sur cette carte" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c #: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "RTS/CTS/RS485 Not yet supported on this device" -msgstr "" +msgstr "RTS / CTS / RS485 Pas encore pris en charge sur cet appareil" #: ports/stm/common-hal/os/__init__.c msgid "Random number generation error" -msgstr "" +msgstr "Erreur de génération de nombres aléatoires" #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" @@ -1383,11 +1383,11 @@ msgstr "Objet en lecture seule" #: shared-bindings/displayio/EPaperDisplay.c msgid "Refresh too soon" -msgstr "" +msgstr "Rafraîchissez trop tôt" #: shared-bindings/aesio/aes.c msgid "Requested AES mode is unsupported" -msgstr "" +msgstr "Le mode AES demandé n'est pas pris en charge" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Right channel unsupported" @@ -1411,11 +1411,11 @@ msgstr "SDA ou SCL a besoin d'une résistance de tirage ('pull up')" #: ports/stm/common-hal/busio/SPI.c msgid "SPI Init Error" -msgstr "" +msgstr "Erreur d'initialisation SPI" #: ports/stm/common-hal/busio/SPI.c msgid "SPI Re-initialization error" -msgstr "" +msgstr "Erreur de réinitialisation SPI" #: shared-bindings/audiomixer/Mixer.c #, fuzzy @@ -1429,15 +1429,15 @@ msgstr "Taux d'échantillonage trop élevé. Doit être inf. à %d" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." -msgstr "" +msgstr "Scan déjà en cours. Arrêtez avec stop_scan." #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Selected CTS pin not valid" -msgstr "" +msgstr "Broche CTS sélectionnée non valide" #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Selected RTS pin not valid" -msgstr "" +msgstr "Broche RTS sélectionnée non valide" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -1455,7 +1455,7 @@ msgstr "Tranches non supportées" #: shared-bindings/aesio/aes.c msgid "Source and destination buffers must be the same length" -msgstr "" +msgstr "Les tampons source et de destination doivent être de la même longueur" #: extmod/modure.c msgid "Splitting with sub-captures" @@ -1471,23 +1471,27 @@ msgstr "Il manque une méthode readinto() ou write() au flux." #: ports/stm/common-hal/busio/UART.c msgid "Supply at least one UART pin" -msgstr "" +msgstr "Fournissez au moins une broche UART" #: ports/stm/common-hal/microcontroller/Processor.c msgid "Temperature read timed out" -msgstr "" +msgstr "Temporisation de lecture dépassée" #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" "Please increase the stack size if you know how, or if not:" msgstr "" +"Le tas CircuitPython a été corrompu car la pile était trop petite.\n" +"Veuillez augmenter la taille de la pile si vous savez comment, ou sinon:" #: supervisor/shared/safe_mode.c msgid "" "The `microcontroller` module was used to boot into safe mode. Press reset to " "exit safe mode.\n" msgstr "" +"Le module `microcontrôleur` a été utilisé pour démarrer en mode sans échec. " +"Appuyez sur reset pour quitter le mode sans échec.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -1495,6 +1499,10 @@ msgid "" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" +"La puissance du microcontrôleur a baissé. Assurez-vous que votre " +"alimentation\n" +"assez de puissance pour tout le circuit et appuyez sur reset (après avoir " +"éjecté CIRCUITPY).\n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1519,11 +1527,11 @@ msgstr "La hauteur de la tuile doit diviser exactement la hauteur de l'image" #: shared-bindings/displayio/TileGrid.c shared-module/displayio/TileGrid.c msgid "Tile index out of bounds" -msgstr "" +msgstr "Index des tuiles hors limites" #: shared-bindings/displayio/TileGrid.c msgid "Tile value out of bounds" -msgstr "" +msgstr "Valeur de tuile hors limites" #: shared-bindings/displayio/TileGrid.c msgid "Tile width must exactly divide bitmap width" @@ -1544,6 +1552,7 @@ msgstr "Trop d'affichages" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than outgoing_packet_length" msgstr "" +"Le nombre total de données à écrire est supérieur à outgoing_packet_length" #: py/obj.c msgid "Traceback (most recent call last):\n" @@ -1555,23 +1564,23 @@ msgstr "Argument de type tuple ou struct_time nécessaire" #: ports/stm/common-hal/busio/UART.c msgid "UART Buffer allocation error" -msgstr "" +msgstr "Erreur d'allocation de tampon UART" #: ports/stm/common-hal/busio/UART.c msgid "UART De-init error" -msgstr "" +msgstr "Erreur de désactivation UART" #: ports/stm/common-hal/busio/UART.c msgid "UART Init Error" -msgstr "" +msgstr "Erreur d'initialisation UART" #: ports/stm/common-hal/busio/UART.c msgid "UART Re-init error" -msgstr "" +msgstr "Erreur de réinitialisation UART" #: ports/stm/common-hal/busio/UART.c msgid "UART write error" -msgstr "" +msgstr "Erreur d'écriture UART" #: shared-module/usb_hid/Device.c msgid "USB Busy" @@ -1583,7 +1592,7 @@ msgstr "Erreur USB" #: shared-bindings/_bleio/UUID.c msgid "UUID integer value must be 0-0xffff" -msgstr "" +msgstr "La valeur entière UUID doit être 0-0xffff" #: shared-bindings/_bleio/UUID.c msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" @@ -1604,7 +1613,7 @@ msgstr "Impossible d'allouer des tampons pour une conversion signée" #: shared-module/displayio/I2CDisplay.c #, c-format msgid "Unable to find I2C Display at %x" -msgstr "" +msgstr "Impossible de trouver l'affichage I2C à% x" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c From d5097891f13057a20a582a20c0d4eb01056aac91 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:49:36 +0000 Subject: [PATCH 163/216] Translated using Weblate (French) Currently translated at 81.5% (608 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 7ad6313949..e3ca027ecf 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:49+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1613,7 +1613,7 @@ msgstr "Impossible d'allouer des tampons pour une conversion signée" #: shared-module/displayio/I2CDisplay.c #, c-format msgid "Unable to find I2C Display at %x" -msgstr "Impossible de trouver l'affichage I2C à% x" +msgstr "Impossible de trouver l'affichage I2C à %x" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c From 4341b4a356a0318f37ff594dbe4c92c771ecc349 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:49:41 +0000 Subject: [PATCH 164/216] Translated using Weblate (French) Currently translated at 81.5% (608 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index e3ca027ecf..c1a6606ab3 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:49+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1640,7 +1640,7 @@ msgstr "Type inattendu pour l'uuid nrfx" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown gatt error: 0x%04x" -msgstr "" +msgstr "Erreur gatt inconnue: 0x% 04x" #: supervisor/shared/safe_mode.c msgid "Unknown reason." From 2263b3c536ba470343ea1016508b0195f08295eb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:49:48 +0000 Subject: [PATCH 165/216] Translated using Weblate (French) Currently translated at 81.7% (610 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index c1a6606ab3..07f9e55e11 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:49+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:50+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1640,7 +1640,7 @@ msgstr "Type inattendu pour l'uuid nrfx" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown gatt error: 0x%04x" -msgstr "Erreur gatt inconnue: 0x% 04x" +msgstr "Erreur gatt inconnue: 0x%04x" #: supervisor/shared/safe_mode.c msgid "Unknown reason." From eee39afdbe6d6b627bc3505c89923b05df3307c8 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:49:53 +0000 Subject: [PATCH 166/216] Translated using Weblate (French) Currently translated at 81.7% (610 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 07f9e55e11..c64c57f718 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:50+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1644,12 +1644,12 @@ msgstr "Erreur gatt inconnue: 0x%04x" #: supervisor/shared/safe_mode.c msgid "Unknown reason." -msgstr "" +msgstr "Raison inconnue." #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" -msgstr "" +msgstr "Erreur de sécurité inconnue: 0x% 04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format From fbdd45cbb7c0825ee5480fdf263290cecc1f84a9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:50:03 +0000 Subject: [PATCH 167/216] Translated using Weblate (French) Currently translated at 81.9% (611 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index c64c57f718..d727be5eb2 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:50+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1649,7 +1649,7 @@ msgstr "Raison inconnue." #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" -msgstr "Erreur de sécurité inconnue: 0x% 04x" +msgstr "Erreur de sécurité inconnue: 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format From 1238850bc6978f027c55bea532e8ae87561c97c5 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:50:27 +0000 Subject: [PATCH 168/216] Translated using Weblate (French) Currently translated at 81.9% (611 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index d727be5eb2..25520a7eb0 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:50+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1654,7 +1654,7 @@ msgstr "Erreur de sécurité inconnue: 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown soft device error: %04x" -msgstr "" +msgstr "Erreur de périphérique logiciel inconnue:% 04x" #: shared-bindings/_pixelbuf/PixelBuf.c #, c-format From 78506469e587cd68b66b282d1dc31432dc76e675 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:50:35 +0000 Subject: [PATCH 169/216] Translated using Weblate (French) Currently translated at 82.3% (614 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 25520a7eb0..34d28dc076 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:50+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:52+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1654,7 +1654,7 @@ msgstr "Erreur de sécurité inconnue: 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown soft device error: %04x" -msgstr "Erreur de périphérique logiciel inconnue:% 04x" +msgstr "Erreur de périphérique logiciel inconnue: %04x" #: shared-bindings/_pixelbuf/PixelBuf.c #, c-format From 0475897b69a7ec9d1997f424729d3af4acfdcde6 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:50:40 +0000 Subject: [PATCH 170/216] Translated using Weblate (French) Currently translated at 82.3% (614 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 34d28dc076..5253e97bc1 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:52+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1667,6 +1667,8 @@ msgid "" "Unspecified issue. Can be that the pairing prompt on the other device was " "declined or ignored." msgstr "" +"Problème non spécifié. Il se peut que l'invite d'association sur l'autre " +"appareil ait été refusée ou ignorée." #: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" @@ -1692,12 +1694,12 @@ msgstr "Valeur de tirage 'pull' non supportée." #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" -msgstr "" +msgstr "Longueur de valeur! = Longueur fixe requise" #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" -msgstr "" +msgstr "Longueur de la valeur> longueur_max" #: py/emitnative.c msgid "Viper functions don't currently support more than 4 arguments" From 9aee97c0a05fd3b7eb50f6830d356c5c715b26ad Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:52:24 +0000 Subject: [PATCH 171/216] Translated using Weblate (French) Currently translated at 82.7% (617 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 5253e97bc1..68b52d4220 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:52+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:53+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1699,7 +1699,7 @@ msgstr "Longueur de valeur! = Longueur fixe requise" #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" -msgstr "Longueur de la valeur> longueur_max" +msgstr "Longueur de la valeur > max_length" #: py/emitnative.c msgid "Viper functions don't currently support more than 4 arguments" From 56c8a3d5bd9d44e7a55aeeeb8d6bae9ccdc94ebb Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:52:31 +0000 Subject: [PATCH 172/216] Translated using Weblate (French) Currently translated at 82.7% (617 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 68b52d4220..276a3afa34 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:53+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1708,7 +1708,7 @@ msgstr "" #: ports/stm/common-hal/microcontroller/Processor.c msgid "Voltage read timed out" -msgstr "" +msgstr "La lecture de la tension a expiré" #: main.c msgid "WARNING: Your code filename has two extensions\n" @@ -1731,11 +1731,11 @@ msgstr "" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" -msgstr "" +msgstr "Écritures non prises en charge sur la caractéristique" #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" -msgstr "" +msgstr "Vous êtes en mode sans échec: quelque chose d'imprévu s'est produit.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " From 8ed19c16e23b71b5c74dfc619571d14efd8e703b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:53:12 +0000 Subject: [PATCH 173/216] Translated using Weblate (French) Currently translated at 83.3% (622 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 276a3afa34..8d36b29e4c 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:53+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1735,7 +1735,7 @@ msgstr "Écritures non prises en charge sur la caractéristique" #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" -msgstr "Vous êtes en mode sans échec: quelque chose d'imprévu s'est produit.\n" +msgstr "Vous êtes en mode sans échec: quelque chose d'imprévu s'est passé.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " From aa0b21a852afa28c59c8b85b96cad8e907bfa3ec Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:53:29 +0000 Subject: [PATCH 174/216] Translated using Weblate (French) Currently translated at 83.3% (622 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 8d36b29e4c..715101c449 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:53+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1777,7 +1777,7 @@ msgstr "adresses vides" #: extmod/ulab/code/vectorise.c msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" +msgstr "arctan2 est implémenté uniquement pour les scalaires et les ndarrays" #: py/modbuiltins.c msgid "arg is an empty sequence" @@ -1785,7 +1785,7 @@ msgstr "l'argument est une séquence vide" #: extmod/ulab/code/numerical.c msgid "argsort argument must be an ndarray" -msgstr "" +msgstr "L'argument argsort doit être un ndarray" #: py/runtime.c msgid "argument has wrong type" @@ -1802,7 +1802,7 @@ msgstr "l'argument devrait être un(e) '%q', pas '%q'" #: extmod/ulab/code/linalg.c msgid "arguments must be ndarrays" -msgstr "" +msgstr "les arguments doivent être des ndarrays" #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" @@ -1810,7 +1810,7 @@ msgstr "tableau/octets requis à droite" #: extmod/ulab/code/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" -msgstr "" +msgstr "tenter d'obtenir argmin / argmax d'une séquence vide" #: py/objstr.c msgid "attributes not supported yet" @@ -1818,7 +1818,7 @@ msgstr "attribut pas encore supporté" #: extmod/ulab/code/numerical.c msgid "axis must be -1, 0, None, or 1" -msgstr "" +msgstr "l'axe doit être -1, 0, Aucun ou 1" #: extmod/ulab/code/numerical.c msgid "axis must be -1, 0, or 1" From 19eec97959e5c5dc6987002f756ebc952843699f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:53:58 +0000 Subject: [PATCH 175/216] Translated using Weblate (French) Currently translated at 83.6% (624 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 715101c449..b1dcba1d70 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:53+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:54+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1818,7 +1818,7 @@ msgstr "attribut pas encore supporté" #: extmod/ulab/code/numerical.c msgid "axis must be -1, 0, None, or 1" -msgstr "l'axe doit être -1, 0, Aucun ou 1" +msgstr "l'axe doit être -1, 0, None ou 1" #: extmod/ulab/code/numerical.c msgid "axis must be -1, 0, or 1" From c51f5a6b26b3717f53cd8ec26278d8e167a731e4 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:54:03 +0000 Subject: [PATCH 176/216] Translated using Weblate (French) Currently translated at 83.6% (624 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index b1dcba1d70..58b8567516 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:54+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1822,11 +1822,11 @@ msgstr "l'axe doit être -1, 0, None ou 1" #: extmod/ulab/code/numerical.c msgid "axis must be -1, 0, or 1" -msgstr "" +msgstr "l'axe doit être -1, 0 ou 1" #: extmod/ulab/code/numerical.c msgid "axis must be None, 0, or 1" -msgstr "" +msgstr "l'axe doit être Aucun, 0 ou 1" #: py/builtinevex.c msgid "bad compile mode" From d40ac8e65da26bd3c96cbc2f87be243a3f02ef0f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:54:18 +0000 Subject: [PATCH 177/216] Translated using Weblate (French) Currently translated at 85.2% (636 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 58b8567516..6a31fbaab7 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:54+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:55+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -1826,7 +1826,7 @@ msgstr "l'axe doit être -1, 0 ou 1" #: extmod/ulab/code/numerical.c msgid "axis must be None, 0, or 1" -msgstr "l'axe doit être Aucun, 0 ou 1" +msgstr "l'axe doit être None, 0 ou 1" #: py/builtinevex.c msgid "bad compile mode" From 992f290eb83db99a378925478d9e580cbd93405d Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:54:26 +0000 Subject: [PATCH 178/216] Translated using Weblate (French) Currently translated at 85.2% (636 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 6a31fbaab7..2c0b57e845 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:55+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -1898,7 +1898,7 @@ msgstr "bytecode non implémenté" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "byteorder is not a string" -msgstr "" +msgstr "byteorder n'est pas une chaîne" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2085,7 +2085,7 @@ msgstr "ne peut pas réaliser un import relatif" #: extmod/ulab/code/ndarray.c msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" +msgstr "ne peut pas remodeler le tableau (forme d'entrée / sortie incompatible)" #: py/emitnative.c msgid "casting" @@ -2105,7 +2105,7 @@ msgstr "argument de chr() hors de la gamme range(256)" #: shared-module/vectorio/Circle.c msgid "circle can only be registered in one parent" -msgstr "" +msgstr "le cercle ne peut être enregistré que dans un seul parent" #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" @@ -2114,6 +2114,7 @@ msgstr "le tampon de couleur doit faire 3 octets (RVB) ou 4 (RVB + pad byte)" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a buffer, tuple, list, or int" msgstr "" +"le tampon de couleur doit être un tampon, un tuple, une liste ou un entier" #: shared-bindings/displayio/Palette.c #, fuzzy @@ -2153,27 +2154,27 @@ msgstr "conversion en objet" #: extmod/ulab/code/filter.c msgid "convolve arguments must be linear arrays" -msgstr "" +msgstr "les arguments convolve doivent être des tableaux linéaires" #: extmod/ulab/code/filter.c msgid "convolve arguments must be ndarrays" -msgstr "" +msgstr "les arguments convolve doivent être des ndarrays" #: extmod/ulab/code/filter.c msgid "convolve arguments must not be empty" -msgstr "" +msgstr "les arguments convolve ne doivent pas être vides" #: extmod/ulab/code/ndarray.c msgid "could not broadast input array from shape" -msgstr "" +msgstr "n'a pas pu diffuser le tableau d'entrée à partir de la forme" #: extmod/ulab/code/poly.c msgid "could not invert Vandermonde matrix" -msgstr "" +msgstr "n'a pas pu inverser la matrice Vandermonde" #: extmod/ulab/code/numerical.c msgid "ddof must be smaller than length of data set" -msgstr "" +msgstr "ddof doit être inférieur à la longueur de l'ensemble de données" #: py/parsenum.c msgid "decimal numbers not supported" @@ -2204,7 +2205,7 @@ msgstr "la séquence de mise à jour de dict a une mauvaise longueur" #: extmod/ulab/code/numerical.c msgid "diff argument must be an ndarray" -msgstr "" +msgstr "l'argument diff doit être un ndarray" #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c @@ -2217,7 +2218,7 @@ msgstr "vide" #: shared-bindings/vectorio/Polygon.c msgid "empty %q list" -msgstr "" +msgstr "liste% q vide" #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" From a7f4a35d80ea89628266575531f09df93abf6e67 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:55:31 +0000 Subject: [PATCH 179/216] Translated using Weblate (French) Currently translated at 88.0% (657 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 2c0b57e845..35a14cbd31 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:55+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:57+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -2218,7 +2218,7 @@ msgstr "vide" #: shared-bindings/vectorio/Polygon.c msgid "empty %q list" -msgstr "liste% q vide" +msgstr "liste %q vide" #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" From a65182dccf2ec0a97fd6a831a7e0f7a10a855f87 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:55:38 +0000 Subject: [PATCH 180/216] Translated using Weblate (French) Currently translated at 88.0% (657 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 35a14cbd31..7e265dd282 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:57+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -2284,23 +2284,25 @@ msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)" #: py/parse.c msgid "f-string expression part cannot include a '#'" -msgstr "" +msgstr "La partie d'expression de chaîne f ne peut pas inclure de '#'" #: py/parse.c msgid "f-string expression part cannot include a backslash" msgstr "" +"La partie d'expression de chaîne f ne peut pas inclure de barre oblique " +"inverse" #: py/parse.c msgid "f-string: empty expression not allowed" -msgstr "" +msgstr "f-string: expression vide non autorisée" #: py/parse.c msgid "f-string: expecting '}'" -msgstr "" +msgstr "f-string: attend '}'" #: py/parse.c msgid "f-string: single '}' is not allowed" -msgstr "" +msgstr "f-string: single '}' n'est pas autorisé" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c @@ -2313,11 +2315,11 @@ msgstr "le system de fichier doit fournir une méthode 'mount'" #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" -msgstr "" +msgstr "le premier argument doit être un itérable" #: extmod/ulab/code/vectorise.c msgid "first argument must be an ndarray" -msgstr "" +msgstr "le premier argument doit être un ndarray" #: py/objtype.c msgid "first argument to super() must be type" @@ -2329,11 +2331,11 @@ msgstr "le 1er bit doit être le MSB" #: extmod/ulab/code/ndarray.c msgid "flattening order must be either 'C', or 'F'" -msgstr "" +msgstr "l'ordre d'aplatissement doit être «C» ou «F»" #: extmod/ulab/code/numerical.c msgid "flip argument must be an ndarray" -msgstr "" +msgstr "l'argument flip doit être un ndarray" #: py/objint.c msgid "float too big" @@ -2367,6 +2369,7 @@ msgstr "la fonction a reçu plusieurs valeurs pour l'argument '%q'" #: extmod/ulab/code/compare.c msgid "function is implemented for scalars and ndarrays only" msgstr "" +"la fonction est implémentée pour les scalaires et les ndarrays uniquement" #: py/argcheck.c #, c-format @@ -2433,7 +2436,7 @@ msgstr "espacement incorrect" #: extmod/ulab/code/ndarray.c msgid "index is out of bounds" -msgstr "" +msgstr "l'index est hors limites" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c @@ -2449,6 +2452,7 @@ msgstr "les indices doivent être des entiers" #: extmod/ulab/code/ndarray.c msgid "indices must be integers, slices, or Boolean lists" msgstr "" +"les indices doivent être des entiers, des tranches ou des listes booléennes" #: py/compile.c msgid "inline assembler must be a function" @@ -2456,35 +2460,35 @@ msgstr "l'assembleur doit être une fonction" #: extmod/ulab/code/create.c msgid "input argument must be an integer or a 2-tuple" -msgstr "" +msgstr "l'argument d'entrée doit être un entier ou un tuple 2" #: extmod/ulab/code/fft.c msgid "input array length must be power of 2" -msgstr "" +msgstr "la longueur du tableau d'entrée doit être une puissance de 2" #: extmod/ulab/code/poly.c msgid "input data must be an iterable" -msgstr "" +msgstr "les données d'entrée doivent être un itérable" #: extmod/ulab/code/linalg.c msgid "input matrix is asymmetric" -msgstr "" +msgstr "la matrice d'entrée est asymétrique" #: extmod/ulab/code/linalg.c msgid "input matrix is singular" -msgstr "" +msgstr "la matrice d'entrée est singulière" #: extmod/ulab/code/linalg.c msgid "input must be square matrix" -msgstr "" +msgstr "l'entrée doit être une matrice carrée" #: extmod/ulab/code/numerical.c msgid "input must be tuple, list, range, or ndarray" -msgstr "" +msgstr "l'entrée doit être tuple, list, range ou ndarray" #: extmod/ulab/code/poly.c msgid "input vectors must be of equal length" -msgstr "" +msgstr "les vecteurs d'entrée doivent être de longueur égale" #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" @@ -2497,7 +2501,7 @@ msgstr "entier requis" #: shared-bindings/_bleio/Adapter.c #, c-format msgid "interval must be in range %s-%s" -msgstr "" +msgstr "l'intervalle doit être dans la plage% s-% s" #: extmod/machine_i2c.c msgid "invalid I2C peripheral" From 362c4d3443479fc119d731ee7bb29de5ca4a1974 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:57:18 +0000 Subject: [PATCH 181/216] Translated using Weblate (French) Currently translated at 89.0% (664 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 7e265dd282..08c64c50a0 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:57+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:58+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -2501,7 +2501,7 @@ msgstr "entier requis" #: shared-bindings/_bleio/Adapter.c #, c-format msgid "interval must be in range %s-%s" -msgstr "l'intervalle doit être dans la plage% s-% s" +msgstr "l'intervalle doit être dans la plage %s-%s" #: extmod/machine_i2c.c msgid "invalid I2C peripheral" From e942dd6f7819cdbbe526c6edc9ded247b8e42477 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:57:26 +0000 Subject: [PATCH 182/216] Translated using Weblate (French) Currently translated at 89.0% (664 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 08c64c50a0..a5a3c2fbd1 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:58+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -2571,11 +2571,11 @@ msgstr "" #: extmod/ulab/code/ndarray.c msgid "iterables are not of the same length" -msgstr "" +msgstr "les itérables ne sont pas de la même longueur" #: extmod/ulab/code/linalg.c msgid "iterations did not converge" -msgstr "" +msgstr "les itérations n'ont pas convergé" #: py/objstr.c msgid "join expects a list of str/bytes objects consistent with self object" @@ -2606,7 +2606,7 @@ msgstr "argument 'length' non-permis pour ce type" #: shared-bindings/audiomixer/MixerVoice.c msgid "level must be between 0 and 1" -msgstr "" +msgstr "le niveau doit être compris entre 0 et 1" #: py/objarray.c msgid "lhs and rhs should be compatible" @@ -2630,7 +2630,7 @@ msgstr "entiers longs non supportés dans cette build" #: py/parse.c msgid "malformed f-string" -msgstr "" +msgstr "f-string mal formé" #: shared-bindings/_stage/Layer.c msgid "map buffer too small" @@ -2642,17 +2642,17 @@ msgstr "erreur de domaine math" #: extmod/ulab/code/linalg.c msgid "matrix dimensions do not match" -msgstr "" +msgstr "les dimensions de la matrice ne correspondent pas" #: extmod/ulab/code/linalg.c msgid "matrix is not positive definite" -msgstr "" +msgstr "la matrice n'est pas définie positive" #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" -msgstr "" +msgstr "max_length doit être 0-% d lorsque fixed_length est% s" #: py/runtime.c msgid "maximum recursion depth exceeded" From 2f363b5052c8503f69ee0d76b1055d8c0abfdb70 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:58:07 +0000 Subject: [PATCH 183/216] Translated using Weblate (French) Currently translated at 89.4% (667 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index a5a3c2fbd1..e5f0b963ef 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:58+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -2652,7 +2652,7 @@ msgstr "la matrice n'est pas définie positive" #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" -msgstr "max_length doit être 0-% d lorsque fixed_length est% s" +msgstr "max_length doit être 0-%d lorsque fixed_length est %s" #: py/runtime.c msgid "maximum recursion depth exceeded" From b88541158c9843499d9d4188e2fddb3279d874b5 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:58:14 +0000 Subject: [PATCH 184/216] Translated using Weblate (French) Currently translated at 89.4% (667 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index e5f0b963ef..c5fb7d5479 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:58+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -2673,7 +2673,7 @@ msgstr "module introuvable" #: extmod/ulab/code/poly.c msgid "more degrees of freedom than data points" -msgstr "" +msgstr "plus de degrés de liberté que de points de données" #: py/compile.c msgid "multiple *x in assignment" @@ -2701,7 +2701,7 @@ msgstr "doit utiliser un argument nommé pour une fonction key" #: extmod/ulab/code/numerical.c msgid "n must be between 0, and 9" -msgstr "" +msgstr "n doit être compris entre 0 et 9" #: py/runtime.c msgid "name '%q' is not defined" @@ -2717,7 +2717,7 @@ msgstr "nom réutilisé comme argument" #: py/emitnative.c msgid "native yield" -msgstr "" +msgstr "rendement natif" #: py/runtime.c #, c-format From f4e82134392ded670a7e879acdb36ad94e79bd14 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:58:35 +0000 Subject: [PATCH 185/216] Translated using Weblate (French) Currently translated at 91.1% (680 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index c5fb7d5479..6800417f33 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:58+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 15:59+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -2717,7 +2717,7 @@ msgstr "nom réutilisé comme argument" #: py/emitnative.c msgid "native yield" -msgstr "rendement natif" +msgstr "'yield' natif" #: py/runtime.c #, c-format From 4642c60f14d813cde7d477b647356932d38a74db Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:58:40 +0000 Subject: [PATCH 186/216] Translated using Weblate (French) Currently translated at 91.1% (680 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 6800417f33..c9e67842cb 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:59+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -2752,7 +2752,7 @@ msgstr "pas de module '%q'" #: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c #: shared-bindings/displayio/ParallelBus.c msgid "no reset pin available" -msgstr "" +msgstr "pas de broche de réinitialisation disponible" #: py/runtime.c msgid "no such attribute" @@ -2760,7 +2760,7 @@ msgstr "pas de tel attribut" #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" -msgstr "" +msgstr "non UUID trouvé dans service_uuids_whitelist" #: py/compile.c msgid "non-default argument follows default argument" @@ -2794,11 +2794,11 @@ msgstr "pas assez d'arguments pour la chaîne de format" #: extmod/ulab/code/poly.c msgid "number of arguments must be 2, or 3" -msgstr "" +msgstr "le nombre d'arguments doit être 2 ou 3" #: extmod/ulab/code/create.c msgid "number of points must be at least 2" -msgstr "" +msgstr "le nombre de points doit être d'au moins 2" #: py/obj.c #, c-format @@ -2857,11 +2857,11 @@ msgstr "adresse hors limites" #: ports/nrf/common-hal/audiobusio/PDMIn.c msgid "only bit_depth=16 is supported" -msgstr "" +msgstr "seul bit_depth = 16 est pris en charge" #: ports/nrf/common-hal/audiobusio/PDMIn.c msgid "only sample_rate=16000 is supported" -msgstr "" +msgstr "seul sample_rate = 16000 est pris en charge" #: py/objarray.c py/objstr.c py/objstrunicode.c py/objtuple.c #: shared-bindings/nvm/ByteArray.c @@ -2871,15 +2871,15 @@ msgstr "seules les tranches avec 'step=1' (cad None) sont supportées" #: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c #: extmod/ulab/code/vectorise.c msgid "operands could not be broadcast together" -msgstr "" +msgstr "les opérandes ne pouvaient pas être diffusés ensemble" #: extmod/ulab/code/numerical.c msgid "operation is not implemented on ndarrays" -msgstr "" +msgstr "l'opération n'est pas implémentée sur les ndarrays" #: extmod/ulab/code/ndarray.c msgid "operation is not supported for given type" -msgstr "" +msgstr "l'opération n'est pas prise en charge pour un type donné" #: py/modbuiltins.c msgid "ord expects a character" @@ -2934,7 +2934,7 @@ msgstr "" #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" -msgstr "" +msgstr "le polygone ne peut être enregistré que dans un parent" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c @@ -2969,11 +2969,11 @@ msgstr "dépassement de file" #: py/parse.c msgid "raw f-strings are not implemented" -msgstr "" +msgstr "les chaînes f brutes ne sont pas implémentées" #: extmod/ulab/code/fft.c msgid "real and imaginary parts must be of equal length" -msgstr "" +msgstr "les parties réelles et imaginaires doivent être de longueur égale" #: py/builtinimport.c msgid "relative import" @@ -2995,7 +2995,7 @@ msgstr "return attendait '%q' mais a reçu '%q'" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] duplicates another pin assignment" -msgstr "" +msgstr "rgb_pins [% d] duplique une autre affectation de broches" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format From a0d7f5cce35912c267dfb382a148d2c551fe03fb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:59:43 +0000 Subject: [PATCH 187/216] Translated using Weblate (French) Currently translated at 91.2% (681 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index c9e67842cb..74c0947a09 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:59+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -2995,7 +2995,7 @@ msgstr "return attendait '%q' mais a reçu '%q'" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] duplicates another pin assignment" -msgstr "rgb_pins [% d] duplique une autre affectation de broches" +msgstr "rgb_pins [%d] duplique une autre affectation de broches" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format From f48a50fdd160957139d6c3e2bc7ef399231766ee Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 15:59:49 +0000 Subject: [PATCH 188/216] Translated using Weblate (French) Currently translated at 91.2% (681 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 74c0947a09..64be6c43b5 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 15:59+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -3000,7 +3000,7 @@ msgstr "rgb_pins [%d] duplique une autre affectation de broches" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] is not on the same port as clock" -msgstr "" +msgstr "rgb_pins [% d] n'est pas sur le même port que l'horloge" #: extmod/ulab/code/ndarray.c msgid "right hand side must be an ndarray, or a scalar" From 68406d0eea6d62d7b96954d5307698ec1f6ffe79 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 15:59:55 +0000 Subject: [PATCH 189/216] Translated using Weblate (French) Currently translated at 91.5% (683 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 64be6c43b5..9e01035dbc 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:59+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 16:00+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -2995,12 +2995,12 @@ msgstr "return attendait '%q' mais a reçu '%q'" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] duplicates another pin assignment" -msgstr "rgb_pins [%d] duplique une autre affectation de broches" +msgstr "rgb_pins[%d] duplique une autre affectation de broches" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] is not on the same port as clock" -msgstr "rgb_pins [% d] n'est pas sur le même port que l'horloge" +msgstr "rgb_pins[%d] n'est pas sur le même port que l'horloge" #: extmod/ulab/code/ndarray.c msgid "right hand side must be an ndarray, or a scalar" From edb033c63ba79a0ed35e1cb5d83f1f9763cdb632 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 16:00:13 +0000 Subject: [PATCH 190/216] Translated using Weblate (French) Currently translated at 91.5% (683 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 9e01035dbc..c4cf732f54 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 16:00+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -3004,11 +3004,11 @@ msgstr "rgb_pins[%d] n'est pas sur le même port que l'horloge" #: extmod/ulab/code/ndarray.c msgid "right hand side must be an ndarray, or a scalar" -msgstr "" +msgstr "le côté droit doit être un ndarray ou un scalaire" #: py/objstr.c msgid "rsplit(None,n)" -msgstr "" +msgstr "rsplit (Aucun, n)" #: shared-bindings/audiocore/RawSample.c msgid "" From 5eb43a35a26ebbfe48990cbf389bff28d6dcb6a6 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 16:00:28 +0000 Subject: [PATCH 191/216] Translated using Weblate (French) Currently translated at 91.9% (686 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index c4cf732f54..75909d4f43 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 16:00+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -3008,7 +3008,7 @@ msgstr "le côté droit doit être un ndarray ou un scalaire" #: py/objstr.c msgid "rsplit(None,n)" -msgstr "rsplit (Aucun, n)" +msgstr "rsplit(None, n)" #: shared-bindings/audiocore/RawSample.c msgid "" From 0d7e22b36da6b7e28f82d6486be74ba8c1a6eb04 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 16:00:33 +0000 Subject: [PATCH 192/216] Translated using Weblate (French) Currently translated at 91.9% (686 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 75909d4f43..2bd6f0a387 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 16:00+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -3032,7 +3032,7 @@ msgstr "compilation de script non supportée" #: extmod/ulab/code/ndarray.c msgid "shape must be a 2-tuple" -msgstr "" +msgstr "la forme doit être un tuple 2" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3048,7 +3048,7 @@ msgstr "'}' seule rencontrée dans une chaîne de format" #: extmod/ulab/code/linalg.c msgid "size is defined for ndarrays only" -msgstr "" +msgstr "la taille est définie pour les ndarrays uniquement" #: shared-bindings/time/__init__.c msgid "sleep length must be non-negative" @@ -3068,7 +3068,7 @@ msgstr "redémarrage logiciel\n" #: extmod/ulab/code/numerical.c msgid "sort argument must be an ndarray" -msgstr "" +msgstr "l'argument de tri doit être un ndarray" #: py/objstr.c msgid "start/end indices" From 360777e7fe10d153329d9b68a29e6cd71212f6aa Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 16:00:52 +0000 Subject: [PATCH 193/216] Translated using Weblate (French) Currently translated at 92.0% (687 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 2bd6f0a387..e1784e74a0 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 16:00+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 16:01+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -3068,7 +3068,7 @@ msgstr "redémarrage logiciel\n" #: extmod/ulab/code/numerical.c msgid "sort argument must be an ndarray" -msgstr "l'argument de tri doit être un ndarray" +msgstr "l'argument de «sort» doit être un ndarray" #: py/objstr.c msgid "start/end indices" From a543f9fd7160992b6d7f47a6aed706e6474bd35f Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 16:00:58 +0000 Subject: [PATCH 194/216] Translated using Weblate (French) Currently translated at 92.0% (687 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index e1784e74a0..2ea90249a1 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 16:01+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -3147,7 +3147,7 @@ msgstr "time.struct_time() prend une séquence de longueur 9" #: shared-bindings/busio/UART.c msgid "timeout must be 0.0-100.0 seconds" -msgstr "" +msgstr "le délai doit être compris entre 0,0 et 100,0 secondes" #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy From 2c4e18be60519c116aba96ca27384f95b4749722 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 16:01:06 +0000 Subject: [PATCH 195/216] Translated using Weblate (French) Currently translated at 92.3% (689 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 2ea90249a1..5e904628ea 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 16:01+0000\n" -"Last-Translator: Anonymous \n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -3147,7 +3147,7 @@ msgstr "time.struct_time() prend une séquence de longueur 9" #: shared-bindings/busio/UART.c msgid "timeout must be 0.0-100.0 seconds" -msgstr "le délai doit être compris entre 0,0 et 100,0 secondes" +msgstr "le délai doit être compris entre 0.0 et 100.0 secondes" #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy From 85fb23163935ebfadd4f38989e466d1049cd1191 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 16:01:12 +0000 Subject: [PATCH 196/216] Translated using Weblate (French) Currently translated at 92.3% (689 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 5e904628ea..3bdaf42528 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 16:01+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -3164,7 +3164,7 @@ msgstr "trop d'arguments fournis avec ce format" #: extmod/ulab/code/ndarray.c msgid "too many indices" -msgstr "" +msgstr "trop d'indices" #: py/runtime.c #, c-format @@ -3295,7 +3295,7 @@ msgstr "type non supporté pour %q: '%s', '%s'" #: py/objint.c #, c-format msgid "value must fit in %d byte(s)" -msgstr "" +msgstr "la valeur doit tenir dans% d octet (s)" #: shared-bindings/displayio/Bitmap.c msgid "value_count must be > 0" From a04d453e5cbad159e3f14e0eed68ecabf73a91db Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 16:01:26 +0000 Subject: [PATCH 197/216] Translated using Weblate (French) Currently translated at 92.8% (693 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 3bdaf42528..43ddc9c99a 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 16:01+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 17:36+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -3295,7 +3295,7 @@ msgstr "type non supporté pour %q: '%s', '%s'" #: py/objint.c #, c-format msgid "value must fit in %d byte(s)" -msgstr "la valeur doit tenir dans% d octet (s)" +msgstr "la valeur doit tenir dans %d octet(s)" #: shared-bindings/displayio/Bitmap.c msgid "value_count must be > 0" From b7292a3c349ea303029f04eda7e6961d600ee984 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 16:01:33 +0000 Subject: [PATCH 198/216] Translated using Weblate (French) Currently translated at 92.8% (693 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 43ddc9c99a..0659514b2f 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 17:36+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -3303,15 +3303,15 @@ msgstr "'value_count' doit être > 0" #: shared-bindings/_bleio/Adapter.c msgid "window must be <= interval" -msgstr "" +msgstr "la fenêtre doit être <= intervalle" #: extmod/ulab/code/linalg.c msgid "wrong argument type" -msgstr "" +msgstr "type d'argument incorrect" #: extmod/ulab/code/ndarray.c msgid "wrong index type" -msgstr "" +msgstr "type d'index incorrect" #: py/objstr.c msgid "wrong number of arguments" @@ -3323,7 +3323,7 @@ msgstr "mauvais nombre de valeurs à dégrouper" #: extmod/ulab/code/ndarray.c msgid "wrong operand type" -msgstr "" +msgstr "type d'opérande incorrect" #: shared-module/displayio/Shape.c #, fuzzy From 5506765db5807bd678b248f77ecf9def79f22078 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Sun, 17 May 2020 15:24:51 +0000 Subject: [PATCH 199/216] Translated using Weblate (Swedish) Currently translated at 100.0% (746 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/sv/ --- locale/sv.po | 291 ++++++++++++++++++++++++++------------------------- 1 file changed, 147 insertions(+), 144 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index ef958db944..15ff0802b0 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 15:24+0000\n" +"PO-Revision-Date: 2020-05-17 17:36+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -2040,7 +2040,7 @@ msgstr "kan inte omforma matris (inkompatibel indata-/utdataform)" #: py/emitnative.c msgid "casting" -msgstr "casting" +msgstr "casting inte implementerad" #: shared-bindings/_stage/Text.c msgid "chars buffer too small" @@ -2667,601 +2667,604 @@ msgstr "behöver mer än %d värden för att packa upp" #: py/objint_longlong.c py/objint_mpz.c py/runtime.c msgid "negative power with no float support" -msgstr "" +msgstr "negativ exponent utan stöd för flyttal" #: py/objint_mpz.c py/runtime.c msgid "negative shift count" -msgstr "" +msgstr "negativt skiftantal" #: py/vm.c msgid "no active exception to reraise" -msgstr "" +msgstr "ingen aktiv exception för reraise" #: shared-bindings/socket/__init__.c shared-module/network/__init__.c msgid "no available NIC" -msgstr "" +msgstr "ingen tillgänglig NIC" #: py/compile.c msgid "no binding for nonlocal found" -msgstr "" +msgstr "ingen bindning för ickelokal hittad" #: py/builtinimport.c msgid "no module named '%q'" -msgstr "" +msgstr "ingen modul med namnet '%q'" #: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c #: shared-bindings/displayio/ParallelBus.c msgid "no reset pin available" -msgstr "" +msgstr "ingen reset-pinne tillgänglig" #: py/runtime.c msgid "no such attribute" -msgstr "" +msgstr "inget sådant attribut" #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" -msgstr "" +msgstr "icke-UUID hittades i service_uuids_whitelist" #: py/compile.c msgid "non-default argument follows default argument" -msgstr "" +msgstr "icke-standard argument följer standard argument" #: extmod/modubinascii.c msgid "non-hex digit found" -msgstr "" +msgstr "icke-hexnummer hittade" #: py/compile.c msgid "non-keyword arg after */**" -msgstr "" +msgstr "icke nyckelord arg efter * / **" #: py/compile.c msgid "non-keyword arg after keyword arg" -msgstr "" +msgstr "icke nyckelord arg efter nyckelord arg" #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" -msgstr "" +msgstr "inte en 128-bitars UUID" #: py/objstr.c msgid "not all arguments converted during string formatting" -msgstr "" +msgstr "inte alla argument omvandlade under strängformatering" #: py/objstr.c msgid "not enough arguments for format string" -msgstr "" +msgstr "inte tillräckligt med argument för formatsträng" #: extmod/ulab/code/poly.c msgid "number of arguments must be 2, or 3" -msgstr "" +msgstr "antal argument måste vara 2 eller 3" #: extmod/ulab/code/create.c msgid "number of points must be at least 2" -msgstr "" +msgstr "antal punkter måste vara minst 2" #: py/obj.c #, c-format msgid "object '%s' is not a tuple or list" -msgstr "" +msgstr "objektet '%s' är inte en tupel eller lista" #: py/obj.c msgid "object does not support item assignment" -msgstr "" +msgstr "Objektet stöder inte tilldelning" #: py/obj.c msgid "object does not support item deletion" -msgstr "" +msgstr "objektet stöder inte borttagning" #: py/obj.c msgid "object has no len" -msgstr "" +msgstr "objektet har inte len" #: py/obj.c msgid "object is not subscriptable" -msgstr "" +msgstr "Objektet är inte indexbart" #: py/runtime.c msgid "object not an iterator" -msgstr "" +msgstr "objektet är inte en iterator" #: py/objtype.c py/runtime.c msgid "object not callable" -msgstr "" +msgstr "objektet är inte anropbart" #: py/sequence.c shared-bindings/displayio/Group.c msgid "object not in sequence" -msgstr "" +msgstr "objektet är inte i sekvens" #: py/runtime.c msgid "object not iterable" -msgstr "" +msgstr "objektet är inte iterable" #: py/obj.c #, c-format msgid "object of type '%s' has no len()" -msgstr "" +msgstr "objekt av typen '%s' har ingen len()" #: py/obj.c msgid "object with buffer protocol required" -msgstr "" +msgstr "objekt med buffertprotokoll krävs" #: extmod/modubinascii.c msgid "odd-length string" -msgstr "" +msgstr "sträng har udda längd" #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" -msgstr "" +msgstr "offset utanför gränserna" #: ports/nrf/common-hal/audiobusio/PDMIn.c msgid "only bit_depth=16 is supported" -msgstr "" +msgstr "bara bit_depth=16 stöds" #: ports/nrf/common-hal/audiobusio/PDMIn.c msgid "only sample_rate=16000 is supported" -msgstr "" +msgstr "enbart sample_rate=16000 stöds" #: py/objarray.c py/objstr.c py/objstrunicode.c py/objtuple.c #: shared-bindings/nvm/ByteArray.c msgid "only slices with step=1 (aka None) are supported" -msgstr "" +msgstr "endast segment med steg=1 (aka Ingen) stöds" #: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c #: extmod/ulab/code/vectorise.c msgid "operands could not be broadcast together" -msgstr "" +msgstr "operander kan inte sändas tillsammans" #: extmod/ulab/code/numerical.c msgid "operation is not implemented on ndarrays" -msgstr "" +msgstr "åtgärden är inte implementerad för ndarray:er" #: extmod/ulab/code/ndarray.c msgid "operation is not supported for given type" -msgstr "" +msgstr "åtgärden stöds inte för given typ" #: py/modbuiltins.c msgid "ord expects a character" -msgstr "" +msgstr "ord förväntar sig ett tecken" #: py/modbuiltins.c #, c-format msgid "ord() expected a character, but string of length %d found" -msgstr "" +msgstr "ord() förväntade sig ett tecken, men en sträng med längden %d hittades" #: py/objint_mpz.c msgid "overflow converting long int to machine word" -msgstr "" +msgstr "Konvertering av long int till machine word överskred maxvärde" #: shared-bindings/_stage/Layer.c shared-bindings/_stage/Text.c msgid "palette must be 32 bytes long" -msgstr "" +msgstr "palette måste vara 32 bytes lång" #: shared-bindings/displayio/Palette.c msgid "palette_index should be an int" -msgstr "" +msgstr "palette_index ska vara en int" #: py/compile.c msgid "parameter annotation must be an identifier" -msgstr "" +msgstr "parametern annotation måste vara en identifierare" #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" -msgstr "" +msgstr "parametrarna måste registreras i följd a2-a5" #: py/emitinlinethumb.c msgid "parameters must be registers in sequence r0 to r3" -msgstr "" +msgstr "parametrarna måste registreras i följd r0-r3" #: shared-bindings/displayio/Bitmap.c msgid "pixel coordinates out of bounds" -msgstr "" +msgstr "pixelkoordinater utanför gränserna" #: shared-bindings/displayio/Bitmap.c msgid "pixel value requires too many bits" -msgstr "" +msgstr "pixelvärdet kräver för många bitar" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +"pixel_shader måste vara displayio.Palette eller displayio.ColorConverter" #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" -msgstr "" +msgstr "polygon kan endast registreras i en förälder" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #: ports/stm/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" -msgstr "" +msgstr "pop från en tom PulseIn" #: py/objset.c msgid "pop from an empty set" -msgstr "" +msgstr "pop från en tom uppsättning" #: py/objlist.c msgid "pop from empty list" -msgstr "" +msgstr "pop från tom lista" #: py/objdict.c msgid "popitem(): dictionary is empty" -msgstr "" +msgstr "popitem(): ordlistan är tom" #: py/objint_mpz.c msgid "pow() 3rd argument cannot be 0" -msgstr "" +msgstr "pow() 3: e argument kan inte vara 0" #: py/objint_mpz.c msgid "pow() with 3 arguments requires integers" -msgstr "" +msgstr "pow() med 3 argument kräver heltal" #: extmod/modutimeq.c msgid "queue overflow" -msgstr "" +msgstr "köstorlek överskreds" #: py/parse.c msgid "raw f-strings are not implemented" -msgstr "" +msgstr "råa f-strängar inte implementerade" #: extmod/ulab/code/fft.c msgid "real and imaginary parts must be of equal length" -msgstr "" +msgstr "verkliga och imaginära delar måste ha samma längd" #: py/builtinimport.c msgid "relative import" -msgstr "" +msgstr "relativ import" #: py/obj.c #, c-format msgid "requested length %d but object has length %d" -msgstr "" +msgstr "begärd längd %d men objektet har längden %d" #: py/compile.c msgid "return annotation must be an identifier" -msgstr "" +msgstr "retur-annotation måste vara en identifierare" #: py/emitnative.c msgid "return expected '%q' but got '%q'" -msgstr "" +msgstr "retur förväntade '%q' men fick '%q'" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] duplicates another pin assignment" -msgstr "" +msgstr "rgb_pins[%d] duplicerar en annan pinntilldelning" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] is not on the same port as clock" -msgstr "" +msgstr "rgb_pins[%d] är inte på samma port som en klocka" #: extmod/ulab/code/ndarray.c msgid "right hand side must be an ndarray, or a scalar" -msgstr "" +msgstr "höger sida måste vara en ndarray, eller en scalar" #: py/objstr.c msgid "rsplit(None,n)" -msgstr "" +msgstr "rsplit(None,n)" #: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" msgstr "" +"sample_source buffert måste vara en bytearray eller matris av typ 'h', 'H', " +"'b' eller 'B'" #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "sampling rate out of range" -msgstr "" +msgstr "samplingsfrekvens utanför räckvidden" #: py/modmicropython.c msgid "schedule stack full" -msgstr "" +msgstr "schemastack full" #: lib/utils/pyexec.c py/builtinimport.c msgid "script compilation not supported" -msgstr "" +msgstr "skriptkompilering stöds inte" #: extmod/ulab/code/ndarray.c msgid "shape must be a 2-tuple" -msgstr "" +msgstr "shape måste vara en 2-tupel" #: py/objstr.c msgid "sign not allowed in string format specifier" -msgstr "" +msgstr "tecknet tillåts inte i strängformatspecificerare" #: py/objstr.c msgid "sign not allowed with integer format specifier 'c'" -msgstr "" +msgstr "tecken tillåts inte med heltalsformatspecificeraren 'c'" #: py/objstr.c msgid "single '}' encountered in format string" -msgstr "" +msgstr "Enkelt '}' påträffades i formatsträngen" #: extmod/ulab/code/linalg.c msgid "size is defined for ndarrays only" -msgstr "" +msgstr "storlek är enbart definierad ndarrays" #: shared-bindings/time/__init__.c msgid "sleep length must be non-negative" -msgstr "" +msgstr "värdet för sleep måste vara positivt" #: py/objslice.c py/sequence.c msgid "slice step cannot be zero" -msgstr "" +msgstr "segmentsteg får inte vara noll" #: py/objint.c py/sequence.c msgid "small int overflow" -msgstr "" +msgstr "värdet för konvertering till small int överskreds" #: main.c msgid "soft reboot\n" -msgstr "" +msgstr "mjuk omstart\n" #: extmod/ulab/code/numerical.c msgid "sort argument must be an ndarray" -msgstr "" +msgstr "argumentet sort måste vara en ndarray" #: py/objstr.c msgid "start/end indices" -msgstr "" +msgstr "start-/slutindex" #: shared-bindings/displayio/Shape.c msgid "start_x should be an int" -msgstr "" +msgstr "start_x ska vara en int" #: shared-bindings/random/__init__.c msgid "step must be non-zero" -msgstr "" +msgstr "step måste vara icke-noll" #: shared-bindings/busio/UART.c msgid "stop must be 1 or 2" -msgstr "" +msgstr "stop måste vara 1 eller 2" #: shared-bindings/random/__init__.c msgid "stop not reachable from start" -msgstr "" +msgstr "stop kan inte nås från start" #: py/stream.c msgid "stream operation not supported" -msgstr "" +msgstr "stream-åtgärd stöds inte" #: py/objstrunicode.c msgid "string index out of range" -msgstr "" +msgstr "strängindex utanför intervallet" #: py/objstrunicode.c #, c-format msgid "string indices must be integers, not %s" -msgstr "" +msgstr "strängindex måste vara heltal, inte %s" #: py/stream.c msgid "string not supported; use bytes or bytearray" -msgstr "" +msgstr "sträng stöds inte; använd bytes eller bytearray" #: extmod/moductypes.c msgid "struct: cannot index" -msgstr "" +msgstr "struct: kan inte indexera" #: extmod/moductypes.c msgid "struct: index out of range" -msgstr "" +msgstr "struct: index utanför intervallet" #: extmod/moductypes.c msgid "struct: no fields" -msgstr "" +msgstr "struct: inga fält" #: py/objstr.c msgid "substring not found" -msgstr "" +msgstr "det gick inte att hitta delsträng" #: py/compile.c msgid "super() can't find self" -msgstr "" +msgstr "super() kan inte hitta self" #: extmod/modujson.c msgid "syntax error in JSON" -msgstr "" +msgstr "syntaxfel i JSON" #: extmod/moductypes.c msgid "syntax error in uctypes descriptor" -msgstr "" +msgstr "syntaxfel i uctypes deskriptor" #: shared-bindings/touchio/TouchIn.c msgid "threshold must be in the range 0-65536" -msgstr "" +msgstr "tröskelvärdet måste ligga i intervallet 0-65536" #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" -msgstr "" +msgstr "time.struct_time() kräver en 9-sekvens" #: shared-bindings/busio/UART.c msgid "timeout must be 0.0-100.0 seconds" -msgstr "" +msgstr "timeout måste vara 0.0-100.0 sekunder" #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "timeout must be >= 0.0" -msgstr "" +msgstr "timeout måste vara >= 0.0" #: shared-bindings/time/__init__.c msgid "timestamp out of range for platform time_t" -msgstr "" +msgstr "timestamp utom räckvidd för plattformens \"time_t\"" #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" -msgstr "" +msgstr "för många argument för det givna formatet" #: extmod/ulab/code/ndarray.c msgid "too many indices" -msgstr "" +msgstr "för många index" #: py/runtime.c #, c-format msgid "too many values to unpack (expected %d)" -msgstr "" +msgstr "för många värden att packa upp (förväntat %d)" #: extmod/ulab/code/linalg.c py/objstr.c msgid "tuple index out of range" -msgstr "" +msgstr "tupelindex utanför intervallet" #: py/obj.c msgid "tuple/list has wrong length" -msgstr "" +msgstr "tupel/lista har fel längd" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "tuple/list required on RHS" -msgstr "" +msgstr "tupel/lista krävs för RHS" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c #: shared-bindings/busio/UART.c msgid "tx and rx cannot both be None" -msgstr "" +msgstr "tx och rx kan inte båda vara None" #: py/objtype.c msgid "type '%q' is not an acceptable base type" -msgstr "" +msgstr "typ '%q' är inte en acceptabel bastyp" #: py/objtype.c msgid "type is not an acceptable base type" -msgstr "" +msgstr "typ är inte en acceptabel bastyp" #: py/runtime.c msgid "type object '%q' has no attribute '%q'" -msgstr "" +msgstr "typobjektet '%q' har inget attribut '%q'" #: py/objtype.c msgid "type takes 1 or 3 arguments" -msgstr "" +msgstr "typen tar 1 eller 3 argument" #: py/objint_longlong.c msgid "ulonglong too large" -msgstr "" +msgstr "ulonglong för stor" #: py/emitnative.c msgid "unary op %q not implemented" -msgstr "" +msgstr "binär op %q är inte implementerad" #: py/parse.c msgid "unexpected indent" -msgstr "" +msgstr "oväntat indrag" #: py/bc.c msgid "unexpected keyword argument" -msgstr "" +msgstr "oväntat nyckelordsargument" #: py/bc.c py/objnamedtuple.c msgid "unexpected keyword argument '%q'" -msgstr "" +msgstr "oväntat nyckelordsargument '%q'" #: py/lexer.c msgid "unicode name escapes" -msgstr "" +msgstr "unicode name escapes" #: py/parse.c msgid "unindent does not match any outer indentation level" -msgstr "" +msgstr "indentering inte matchar någon yttre indenteringsnivå" #: py/objstr.c #, c-format msgid "unknown conversion specifier %c" -msgstr "" +msgstr "okänd konverteringsspecificerare %c" #: py/objstr.c #, c-format msgid "unknown format code '%c' for object of type '%s'" -msgstr "" +msgstr "okänt format '%c' för objekt av typ '%s'" #: py/compile.c msgid "unknown type" -msgstr "" +msgstr "okänd typ" #: py/emitnative.c msgid "unknown type '%q'" -msgstr "" +msgstr "okänd typ '%q'" #: py/objstr.c msgid "unmatched '{' in format" -msgstr "" +msgstr "omatchad '{' i format" #: py/objtype.c py/runtime.c msgid "unreadable attribute" -msgstr "" +msgstr "attribut kan inte läsas" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c #: shared-bindings/vectorio/VectorShape.c msgid "unsupported %q type" -msgstr "" +msgstr "typ %q stöds inte" #: py/emitinlinethumb.c #, c-format msgid "unsupported Thumb instruction '%s' with %d arguments" -msgstr "" +msgstr "Thumb-instruktion '%s' med %d argument stöd inte" #: py/emitinlinextensa.c #, c-format msgid "unsupported Xtensa instruction '%s' with %d arguments" -msgstr "" +msgstr "Xtensa-instruktion '%s' med %d argument stöds inte" #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" -msgstr "" +msgstr "Formattecknet '%c' (0x%x) stöds inte vid index %d" #: py/runtime.c msgid "unsupported type for %q: '%s'" -msgstr "" +msgstr "typ som inte stöds för %q: '%s'" #: py/runtime.c msgid "unsupported type for operator" -msgstr "" +msgstr "typ stöds inte för operatören" #: py/runtime.c msgid "unsupported types for %q: '%s', '%s'" -msgstr "" +msgstr "typ som inte stöds för %q: '%s', '%s'" #: py/objint.c #, c-format msgid "value must fit in %d byte(s)" -msgstr "" +msgstr "värdet måste passa i %d byte(s)" #: shared-bindings/displayio/Bitmap.c msgid "value_count must be > 0" -msgstr "" +msgstr "value_count måste vara > 0" #: shared-bindings/_bleio/Adapter.c msgid "window must be <= interval" -msgstr "" +msgstr "window måste vara <= interval" #: extmod/ulab/code/linalg.c msgid "wrong argument type" -msgstr "" +msgstr "fel typ av argument" #: extmod/ulab/code/ndarray.c msgid "wrong index type" -msgstr "" +msgstr "fel indextyp" #: py/objstr.c msgid "wrong number of arguments" -msgstr "" +msgstr "fel antal argument" #: py/runtime.c msgid "wrong number of values to unpack" -msgstr "" +msgstr "fel antal värden för att packa upp" #: extmod/ulab/code/ndarray.c msgid "wrong operand type" -msgstr "" +msgstr "fel operandtyp" #: shared-module/displayio/Shape.c msgid "x value out of bounds" -msgstr "" +msgstr "x-värde utanför intervall" #: shared-bindings/displayio/Shape.c msgid "y should be an int" -msgstr "" +msgstr "y ska vara en int" #: shared-module/displayio/Shape.c msgid "y value out of bounds" -msgstr "" +msgstr "y-värde utanför intervall" #: py/objrange.c msgid "zero step" -msgstr "" +msgstr "noll steg" From 5454877fb87f4e1259d9948b69df713964e98eaa Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 19:08:21 +0000 Subject: [PATCH 200/216] Translated using Weblate (Spanish) Currently translated at 68.9% (514 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/es/ --- locale/es.po | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/locale/es.po b/locale/es.po index 12ecb0c182..60a8af0599 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,14 +8,15 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2018-08-24 22:56-0500\n" -"Last-Translator: \n" +"PO-Revision-Date: 2020-05-17 20:56+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: \n" -"Language: en_US\n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.1.1\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.1-dev\n" #: main.c msgid "" @@ -1802,6 +1803,7 @@ msgid "bits_per_sample must be 8 or 16" msgstr "bits_per_sample debe ser 8 ó 16" #: py/emitinlinethumb.c +#, fuzzy msgid "branch not in range" msgstr "El argumento de chr() no esta en el rango(256)" From bc64b8b35857e81b0d1e199bb44a6b0ae746356a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 May 2020 18:48:04 +0000 Subject: [PATCH 201/216] Translated using Weblate (French) Currently translated at 100.0% (746 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 154 +++++++++++++++++++-------------------------------- 1 file changed, 57 insertions(+), 97 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 0659514b2f..5fdaae07c7 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -9,8 +9,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 17:36+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-17 20:56+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: French \n" "Language: fr\n" @@ -121,12 +121,12 @@ msgid "'%s' expects a register" msgstr "'%s' attend un registre" #: py/emitinlinethumb.c -#, fuzzy, c-format +#, c-format msgid "'%s' expects a special register" msgstr "'%s' attend un registre special" #: py/emitinlinethumb.c -#, fuzzy, c-format +#, c-format msgid "'%s' expects an FPU register" msgstr "'%s' attend un registre FPU" @@ -141,12 +141,12 @@ msgid "'%s' expects an integer" msgstr "'%s' attend un entier" #: py/emitinlinethumb.c -#, fuzzy, c-format +#, c-format msgid "'%s' expects at most r%d" msgstr "'%s' s'attend au plus à r%d" #: py/emitinlinethumb.c -#, fuzzy, c-format +#, c-format msgid "'%s' expects {r0, r1, ...}" msgstr "'%s' attend {r0, r1, ...}" @@ -156,7 +156,7 @@ msgid "'%s' integer %d is not within range %d..%d" msgstr "'%s' l'entier %d n'est pas dans la gamme %d..%d" #: py/emitinlinethumb.c -#, fuzzy, c-format +#, c-format msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' l'entier 0x%x ne correspond pas au masque 0x%x" @@ -272,7 +272,7 @@ msgid "A hardware interrupt channel is already in use" msgstr "Un canal d'interruptions matérielles est déjà utilisé" #: shared-bindings/_bleio/Address.c -#, fuzzy, c-format +#, c-format msgid "Address must be %d bytes long" msgstr "L'adresse doit être longue de %d octets" @@ -281,19 +281,16 @@ msgid "Address type out of range" msgstr "Type d'adresse hors plage" #: ports/nrf/common-hal/busio/I2C.c -#, fuzzy msgid "All I2C peripherals are in use" msgstr "Tous les périphériques I2C sont utilisés" #: ports/nrf/common-hal/busio/SPI.c -#, fuzzy msgid "All SPI peripherals are in use" msgstr "Tous les périphériques SPI sont utilisés" #: ports/nrf/common-hal/busio/UART.c -#, fuzzy msgid "All UART peripherals are in use" -msgstr "Tous les périphériques I2C sont utilisés" +msgstr "Tous les périphériques UART sont utilisés" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "All event channels in use" @@ -320,7 +317,7 @@ msgstr "Tous les timers sont utilisés" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." -msgstr "" +msgstr "S'annonce déjà." #: ports/cxd56/common-hal/analogio/AnalogIn.c msgid "AnalogIn not supported on given pin" @@ -448,18 +445,17 @@ msgstr "Tampon trop court de %d octets" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c -#, fuzzy, c-format +#, c-format msgid "Bus pin %d is already in use" msgstr "La broche %d du bus est déjà utilisée" #: shared-bindings/_bleio/UUID.c -#, fuzzy msgid "Byte buffer must be 16 bytes." -msgstr "Le tampon d'octets doit être de 16 octets." +msgstr "Le tampon doit être de 16 octets." #: shared-bindings/nvm/ByteArray.c msgid "Bytes must be between 0 and 255." -msgstr "Les octets 'bytes' doivent être entre 0 et 255" +msgstr "Les octets 'bytes' doivent être entre 0 et 255." #: shared-bindings/aesio/aes.c msgid "CBC blocks must be multiples of 16 bytes" @@ -484,7 +480,6 @@ msgid "Cannot get pull while in output mode" msgstr "Ne peut être tiré ('pull') en mode 'output'" #: ports/nrf/common-hal/microcontroller/Processor.c -#, fuzzy msgid "Cannot get temperature" msgstr "Impossible de lire la température" @@ -549,7 +544,7 @@ msgstr "Ecriture sur 'CharacteristicBuffer' non fournie" #: supervisor/shared/safe_mode.c msgid "CircuitPython core code crashed hard. Whoops!\n" -msgstr "Le code principal de CircuitPython s'est écrasé durement. Oups!\n" +msgstr "Le code principal de CircuitPython s'est écrasé durement. Oups !\n" #: supervisor/shared/safe_mode.c msgid "" @@ -562,7 +557,7 @@ msgstr "" #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." -msgstr "Echec de l'init. de la broche d'horloge" +msgstr "Echec de l'init. de la broche d'horloge." #: shared-module/bitbangio/I2C.c msgid "Clock stretch too long" @@ -578,7 +573,6 @@ msgstr "L'entrée 'Column' doit être un digitalio.DigitalInOut" #: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c #: shared-bindings/displayio/ParallelBus.c -#, fuzzy msgid "Command must be an int between 0 and 255" msgstr "La commande doit être un entier entre 0 et 255" @@ -666,7 +660,6 @@ msgstr "DAC déjà utilisé" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c -#, fuzzy msgid "Data 0 pin must be byte aligned" msgstr "La broche 'Data 0' doit être aligné sur l'octet" @@ -728,7 +721,6 @@ msgstr "Attendu un %q" #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -#, fuzzy msgid "Expected a Characteristic" msgstr "Une 'Characteristic' est attendue" @@ -738,7 +730,6 @@ msgstr "Attendu un service" #: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c #: shared-bindings/_bleio/Service.c -#, fuzzy msgid "Expected a UUID" msgstr "Un UUID est attendu" @@ -764,7 +755,7 @@ msgid "Failed sending command." msgstr "Échec de l'envoi de la commande." #: ports/nrf/sd_mutex.c -#, fuzzy, c-format +#, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "Echec de l'obtention de mutex, err 0x%04x" @@ -783,18 +774,18 @@ msgstr "Echec de l'allocation de %d octets du tampon RX" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" -msgstr "Impossible de se connecter: erreur interne" +msgstr "Impossible de se connecter : erreur interne" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: timeout" -msgstr "Impossible de se connecter: délai d'expiration" +msgstr "Impossible de se connecter : délai d'expiration" #: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "Impossible d'analyser le fichier MP3" #: ports/nrf/sd_mutex.c -#, fuzzy, c-format +#, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "Impossible de libérer mutex, err 0x%04x" @@ -899,7 +890,6 @@ msgid "Invalid ADC Unit value" msgstr "Valeur d'unité ADC non valide" #: shared-module/displayio/OnDiskBitmap.c -#, fuzzy msgid "Invalid BMP file" msgstr "Fichier BMP invalide" @@ -934,7 +924,6 @@ msgid "Invalid bits per value" msgstr "Bits par valeur invalides" #: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c -#, fuzzy msgid "Invalid buffer size" msgstr "Longueur de tampon invalide" @@ -944,16 +933,15 @@ msgstr "Chaîne d'octets non valide" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" -msgstr "Période de capture invalide. Gamme valide: 1 à 500" +msgstr "Période de capture invalide. Gamme valide : 1 à 500" #: shared-bindings/audiomixer/Mixer.c -#, fuzzy msgid "Invalid channel count" msgstr "Nombre de canaux invalide" #: shared-bindings/digitalio/DigitalInOut.c msgid "Invalid direction." -msgstr "Direction invalide" +msgstr "Direction invalide." #: shared-module/audiocore/WaveFile.c msgid "Invalid file" @@ -1029,7 +1017,6 @@ msgid "Invalid voice" msgstr "Voix invalide" #: shared-bindings/audiomixer/Mixer.c -#, fuzzy msgid "Invalid voice count" msgstr "Nombre de voix invalide" @@ -1067,11 +1054,11 @@ msgstr "La longueur ne doit pas être négative" #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." -msgstr "Echec de l'init. de la broche MISO" +msgstr "Echec de l'init. de la broche MISO." #: shared-module/bitbangio/SPI.c msgid "MOSI pin init failed." -msgstr "Echec de l'init. de la broche MOSI" +msgstr "Echec de l'init. de la broche MOSI." #: shared-module/displayio/Shape.c #, c-format @@ -1155,7 +1142,7 @@ msgstr "Pas d'horloge disponible" #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" -msgstr "Pas de connexion: la longueur ne peut pas être déterminée" +msgstr "Pas de connexion : la longueur ne peut pas être déterminée" #: shared-bindings/board/__init__.c msgid "No default %q bus" @@ -1192,7 +1179,7 @@ msgstr "Plus de minuteurs disponibles sur cette broche." #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" -msgstr "Pas de pulldown sur la broche; 1Mohm recommandé" +msgstr "Pas de pulldown sur la broche ; 1Mohm recommandé" #: py/moduerrno.c msgid "No space left on device" @@ -1212,7 +1199,6 @@ msgstr "Affirmation de défaillance du Nordic Soft Device." #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c -#, fuzzy msgid "Not connected" msgstr "Non connecté" @@ -1229,7 +1215,6 @@ msgstr "" "objet." #: ports/nrf/common-hal/busio/UART.c -#, fuzzy msgid "Odd parity is not supported" msgstr "Parité impaire non supportée" @@ -1242,8 +1227,8 @@ msgstr "Uniquement 8 ou 16 bit mono avec " msgid "" "Only Windows format, uncompressed BMP supported: given header size is %d" msgstr "" -"Seul le format BMP Windows, non compressé est supporté: la taille de " -"l'entêtefournie est %d" +"Seul le format BMP Windows, non compressé est supporté : la taille de " +"l'entête fournie est %d" #: shared-module/displayio/OnDiskBitmap.c #, c-format @@ -1252,7 +1237,7 @@ msgid "" "%d bpp given" msgstr "" "Prise en charge uniquement des monochromes, 4 bpp ou 8 bpp indexés et 16 bpp " -"ou plus: %d bpp fournis" +"ou plus : %d bpp fournis" #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." @@ -1266,7 +1251,6 @@ msgstr "" "bits)" #: shared-bindings/pulseio/PWMOut.c -#, fuzzy msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" @@ -1310,7 +1294,6 @@ msgstr "" " True au constructeur" #: py/builtinhelp.c -#, fuzzy msgid "Plus any modules on the filesystem\n" msgstr "Ainsi que tout autre module présent sur le système de fichiers\n" @@ -1377,7 +1360,6 @@ msgid "Read-only filesystem" msgstr "Système de fichier en lecture seule" #: shared-module/displayio/Bitmap.c -#, fuzzy msgid "Read-only object" msgstr "Objet en lecture seule" @@ -1399,11 +1381,11 @@ msgstr "L'entrée de ligne 'Row' doit être un digitalio.DigitalInOut" #: main.c msgid "Running in safe mode! Auto-reload is off.\n" -msgstr "Mode sans-échec! Auto-chargement désactivé.\n" +msgstr "Mode sans-échec ! Auto-chargement désactivé.\n" #: main.c msgid "Running in safe mode! Not running saved code.\n" -msgstr "Mode sans-échec! Le code sauvegardé n'est pas éxecuté.\n" +msgstr "Mode sans-échec ! Le code sauvegardé n'est pas éxecuté.\n" #: ports/atmel-samd/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c msgid "SDA or SCL needs a pull up" @@ -1418,7 +1400,6 @@ msgid "SPI Re-initialization error" msgstr "Erreur de réinitialisation SPI" #: shared-bindings/audiomixer/Mixer.c -#, fuzzy msgid "Sample rate must be positive" msgstr "Le taux d'échantillonage doit être positif" @@ -1446,7 +1427,7 @@ msgstr "Sérialiseur en cours d'utilisation" #: shared-bindings/nvm/ByteArray.c msgid "Slice and value different lengths." -msgstr "Tranche et valeur de tailles différentes" +msgstr "Tranche et valeur de tailles différentes." #: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c #: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c @@ -1483,7 +1464,7 @@ msgid "" "Please increase the stack size if you know how, or if not:" msgstr "" "Le tas CircuitPython a été corrompu car la pile était trop petite.\n" -"Veuillez augmenter la taille de la pile si vous savez comment, ou sinon:" +"Veuillez augmenter la taille de la pile si vous savez comment, ou sinon :" #: supervisor/shared/safe_mode.c msgid "" @@ -1556,7 +1537,7 @@ msgstr "" #: py/obj.c msgid "Traceback (most recent call last):\n" -msgstr "Trace (appels les plus récents en dernier):\n" +msgstr "Trace (appels les plus récents en dernier) :\n" #: shared-bindings/time/__init__.c msgid "Tuple or struct_time argument required" @@ -1633,14 +1614,13 @@ msgid "Unable to write to nvm." msgstr "Impossible d'écrire sur la mémoire non-volatile." #: ports/nrf/common-hal/_bleio/UUID.c -#, fuzzy msgid "Unexpected nrfx uuid type" msgstr "Type inattendu pour l'uuid nrfx" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown gatt error: 0x%04x" -msgstr "Erreur gatt inconnue: 0x%04x" +msgstr "Erreur gatt inconnue : 0x%04x" #: supervisor/shared/safe_mode.c msgid "Unknown reason." @@ -1649,18 +1629,18 @@ msgstr "Raison inconnue." #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" -msgstr "Erreur de sécurité inconnue: 0x%04x" +msgstr "Erreur de sécurité inconnue : 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown soft device error: %04x" -msgstr "Erreur de périphérique logiciel inconnue: %04x" +msgstr "Erreur de périphérique logiciel inconnue : %04x" #: shared-bindings/_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." msgstr "" -"Pas de correspondance du nombres d'éléments à droite (attendu %d, obtenu %d)" +"Pas de correspondance du nombres d'éléments à droite (attendu %d, obtenu %d)." #: ports/nrf/common-hal/_bleio/__init__.c msgid "" @@ -1675,7 +1655,6 @@ msgid "Unsupported baudrate" msgstr "Débit non supporté" #: shared-module/displayio/display_core.c -#, fuzzy msgid "Unsupported display bus type" msgstr "Type de bus d'affichage non supporté" @@ -1694,7 +1673,7 @@ msgstr "Valeur de tirage 'pull' non supportée." #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" -msgstr "Longueur de valeur! = Longueur fixe requise" +msgstr "Longueur de valeur != Longueur fixe requise" #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c @@ -1712,7 +1691,7 @@ msgstr "La lecture de la tension a expiré" #: main.c msgid "WARNING: Your code filename has two extensions\n" -msgstr "ATTENTION: le nom de fichier de votre code a deux extensions\n" +msgstr "ATTENTION : le nom de fichier de votre code a deux extensions\n" #: py/builtinhelp.c #, c-format @@ -1723,7 +1702,7 @@ msgid "" "\n" "To list built-in modules please do `help(\"modules\")`.\n" msgstr "" -"Bienvenue sur Adafruit CircuitPython %s!\n" +"Bienvenue sur Adafruit CircuitPython %s !\n" "\n" "Visitez learn.adafruit.com/category/circuitpython pour les guides.\n" "\n" @@ -1735,7 +1714,7 @@ msgstr "Écritures non prises en charge sur la caractéristique" #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" -msgstr "Vous êtes en mode sans échec: quelque chose d'imprévu s'est passé.\n" +msgstr "Vous êtes en mode sans échec : quelque chose d'imprévu s'est passé.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -1857,12 +1836,10 @@ msgid "bits must be 8" msgstr "les bits doivent être 8" #: shared-bindings/audiomixer/Mixer.c -#, fuzzy msgid "bits_per_sample must be 8 or 16" msgstr "'bits_per_sample' doivent être 8 ou 16" #: py/emitinlinethumb.c -#, fuzzy msgid "branch not in range" msgstr "branche hors-bornes" @@ -1871,7 +1848,6 @@ msgid "buffer must be a bytes-like object" msgstr "le tampon doit être un objet bytes-like" #: shared-module/struct/__init__.c -#, fuzzy msgid "buffer size must match format" msgstr "la taille du tampon doit correspondre au format" @@ -1965,7 +1941,6 @@ msgid "can't convert NaN to int" msgstr "on ne peut convertir NaN en entier 'int'" #: shared-bindings/i2cslave/I2CSlave.c -#, fuzzy msgid "can't convert address to int" msgstr "ne peut convertir l'adresse en entier 'int'" @@ -2117,18 +2092,15 @@ msgstr "" "le tampon de couleur doit être un tampon, un tuple, une liste ou un entier" #: shared-bindings/displayio/Palette.c -#, fuzzy msgid "color buffer must be a bytearray or array of type 'b' or 'B'" msgstr "" "le tampon de couleur doit être un bytearray ou un tableau de type 'b' ou 'B'" #: shared-bindings/displayio/Palette.c -#, fuzzy msgid "color must be between 0x000000 and 0xffffff" msgstr "la couleur doit être entre 0x000000 et 0xffffff" #: shared-bindings/displayio/ColorConverter.c -#, fuzzy msgid "color should be an int" msgstr "la couleur doit être un entier 'int'" @@ -2237,9 +2209,8 @@ msgid "end of format while looking for conversion specifier" msgstr "fin de format en cherchant une spécification de conversion" #: shared-bindings/displayio/Shape.c -#, fuzzy msgid "end_x should be an int" -msgstr "y doit être un entier 'int'" +msgstr "end_x doit être un entier 'int'" #: ports/nrf/common-hal/busio/UART.c #, c-format @@ -2294,15 +2265,15 @@ msgstr "" #: py/parse.c msgid "f-string: empty expression not allowed" -msgstr "f-string: expression vide non autorisée" +msgstr "f-string : expression vide non autorisée" #: py/parse.c msgid "f-string: expecting '}'" -msgstr "f-string: attend '}'" +msgstr "f-string : attend '}'" #: py/parse.c msgid "f-string: single '}' is not allowed" -msgstr "f-string: single '}' n'est pas autorisé" +msgstr "f-string : single '}' n'est pas autorisé" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c @@ -2737,7 +2708,6 @@ msgid "no active exception to reraise" msgstr "aucune exception active à relever" #: shared-bindings/socket/__init__.c shared-module/network/__init__.c -#, fuzzy msgid "no available NIC" msgstr "adapteur réseau non disponible" @@ -2851,9 +2821,8 @@ msgid "odd-length string" msgstr "chaîne de longueur impaire" #: py/objstr.c py/objstrunicode.c -#, fuzzy msgid "offset out of bounds" -msgstr "adresse hors limites" +msgstr "décalage hors limites" #: ports/nrf/common-hal/audiobusio/PDMIn.c msgid "only bit_depth=16 is supported" @@ -2901,7 +2870,6 @@ msgid "palette must be 32 bytes long" msgstr "la palette doit être longue de 32 octets" #: shared-bindings/displayio/Palette.c -#, fuzzy msgid "palette_index should be an int" msgstr "palette_index devrait être un entier 'int'" @@ -2914,12 +2882,10 @@ msgid "parameters must be registers in sequence a2 to a5" msgstr "les paramètres doivent être des registres dans la séquence a2 à a5" #: py/emitinlinethumb.c -#, fuzzy msgid "parameters must be registers in sequence r0 to r3" msgstr "les paramètres doivent être des registres dans la séquence r0 à r3" #: shared-bindings/displayio/Bitmap.c -#, fuzzy msgid "pixel coordinates out of bounds" msgstr "coordonnées de pixel hors limites" @@ -2953,7 +2919,7 @@ msgstr "'pop' d'une liste vide" #: py/objdict.c msgid "popitem(): dictionary is empty" -msgstr "popitem(): dictionnaire vide" +msgstr "popitem() : dictionnaire vide" #: py/objint_mpz.c msgid "pow() 3rd argument cannot be 0" @@ -3075,7 +3041,6 @@ msgid "start/end indices" msgstr "indices de début/fin" #: shared-bindings/displayio/Shape.c -#, fuzzy msgid "start_x should be an int" msgstr "'start_x' doit être un entier 'int'" @@ -3107,19 +3072,19 @@ msgstr "les indices de chaîne de caractères doivent être des entiers, pas %s" #: py/stream.c msgid "string not supported; use bytes or bytearray" msgstr "" -"chaîne de carac. non supportée; utilisez des bytes ou un tableau de bytes" +"chaîne de carac. non supportée ; utilisez des bytes ou un tableau de bytes" #: extmod/moductypes.c msgid "struct: cannot index" -msgstr "struct: indexage impossible" +msgstr "struct : indexage impossible" #: extmod/moductypes.c msgid "struct: index out of range" -msgstr "struct: index hors limites" +msgstr "struct : index hors limites" #: extmod/moductypes.c msgid "struct: no fields" -msgstr "struct: aucun champs" +msgstr "struct : aucun champs" #: py/objstr.c msgid "substring not found" @@ -3150,9 +3115,8 @@ msgid "timeout must be 0.0-100.0 seconds" msgstr "le délai doit être compris entre 0.0 et 100.0 secondes" #: shared-bindings/_bleio/CharacteristicBuffer.c -#, fuzzy msgid "timeout must be >= 0.0" -msgstr "'timeout' doit être >=0.0" +msgstr "'timeout' doit être >= 0.0" #: shared-bindings/time/__init__.c msgid "timestamp out of range for platform time_t" @@ -3261,12 +3225,11 @@ msgstr "attribut illisible" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c #: shared-bindings/vectorio/VectorShape.c -#, fuzzy msgid "unsupported %q type" -msgstr "type de %q non supporté" +msgstr "type %q non pris on charge" #: py/emitinlinethumb.c -#, fuzzy, c-format +#, c-format msgid "unsupported Thumb instruction '%s' with %d arguments" msgstr "instruction Thumb '%s' non supportée avec %d arguments" @@ -3282,7 +3245,7 @@ msgstr "caractère de format '%c' (0x%x) non supporté à l'index %d" #: py/runtime.c msgid "unsupported type for %q: '%s'" -msgstr "type non supporté pour %q: '%s'" +msgstr "type non supporté pour %q : '%s'" #: py/runtime.c msgid "unsupported type for operator" @@ -3290,7 +3253,7 @@ msgstr "type non supporté pour l'opérateur" #: py/runtime.c msgid "unsupported types for %q: '%s', '%s'" -msgstr "type non supporté pour %q: '%s', '%s'" +msgstr "type non supporté pour %q : '%s', '%s'" #: py/objint.c #, c-format @@ -3326,17 +3289,14 @@ msgid "wrong operand type" msgstr "type d'opérande incorrect" #: shared-module/displayio/Shape.c -#, fuzzy msgid "x value out of bounds" msgstr "valeur x hors limites" #: shared-bindings/displayio/Shape.c -#, fuzzy msgid "y should be an int" -msgstr "y doit être un entier 'int'" +msgstr "'y' doit être un entier 'int'" #: shared-module/displayio/Shape.c -#, fuzzy msgid "y value out of bounds" msgstr "valeur y hors limites" From 4d1cbf3d635f0b1963d8edfca10df66719da9c2f Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 19:07:19 +0000 Subject: [PATCH 202/216] Translated using Weblate (French) Currently translated at 100.0% (746 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/fr/ --- locale/fr.po | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/locale/fr.po b/locale/fr.po index 5fdaae07c7..4958ee7452 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" "PO-Revision-Date: 2020-05-17 20:56+0000\n" -"Last-Translator: Jeff Epler \n" +"Last-Translator: Anonymous \n" "Language-Team: French \n" "Language: fr\n" @@ -486,6 +486,8 @@ msgstr "Impossible de lire la température" #: shared-bindings/_bleio/Adapter.c msgid "Cannot have scan responses for extended, connectable advertisements." msgstr "" +"Impossible d'avoir des réponses d'analyse pour les publicités étendues et " +"connectables." #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" @@ -745,6 +747,7 @@ msgstr "Tuple de longueur %d attendu, obtenu %d" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" +"Les publicités étendues avec réponse d'analyse ne sont pas prises en charge." #: extmod/ulab/code/fft.c msgid "FFT is defined for ndarrays only" From f362ee1e75bc3603b83d122bcd0f46e05d2e53cd Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sun, 17 May 2020 19:13:47 +0000 Subject: [PATCH 203/216] Translated using Weblate (Swedish) Currently translated at 100.0% (746 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/sv/ --- locale/sv.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 15ff0802b0..8d64d4b7b5 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-17 17:36+0000\n" -"Last-Translator: Jonny Bergdahl \n" +"PO-Revision-Date: 2020-05-17 20:56+0000\n" +"Last-Translator: Anonymous \n" "Language-Team: LANGUAGE \n" "Language: sv\n" "MIME-Version: 1.0\n" @@ -1187,7 +1187,7 @@ msgstr "Ingen timer tillgänglig" #: supervisor/shared/safe_mode.c msgid "Nordic Soft Device failure assertion." -msgstr "Nordic Soft Device failure assertion." +msgstr "Påståendet om Nordic Soft Device-fel." #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c From cb3c8f1423fda4d836caf9f4873f87a129e340bd Mon Sep 17 00:00:00 2001 From: Anonymous Date: Mon, 18 May 2020 02:46:17 +0000 Subject: [PATCH 204/216] Translated using Weblate (German) Currently translated at 66.6% (497 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/de/ --- locale/de_DE.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/de_DE.po b/locale/de_DE.po index 797c095b83..2c6565bc4b 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-04-30 17:01+0000\n" -"Last-Translator: Jeff Epler \n" +"PO-Revision-Date: 2020-05-18 02:47+0000\n" +"Last-Translator: Anonymous \n" "Language-Team: German \n" "Language: de_DE\n" @@ -17,7 +17,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.0.2\n" +"X-Generator: Weblate 4.1-dev\n" #: main.c msgid "" @@ -81,7 +81,7 @@ msgstr "%q Indizes müssen ganze Zahlen sein, nicht %s" #: shared-bindings/vectorio/Polygon.c msgid "%q list must be a list" -msgstr "" +msgstr "% q Liste muss eine Liste sein" #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c @@ -92,7 +92,7 @@ msgstr "%q muss >= 1 sein" #: shared-bindings/vectorio/Polygon.c msgid "%q must be a tuple of length 2" -msgstr "" +msgstr "% q muss ein Tupel der Länge 2 sein" #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" From 66b79c994e3d1f83e1e4460169911dd0c65a3d1c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 18 May 2020 02:47:42 +0000 Subject: [PATCH 205/216] Translated using Weblate (German) Currently translated at 66.6% (497 of 746 strings) Translation: CircuitPython/master Translate-URL: https://hosted.weblate.org/projects/circuitpython/master/de/ --- locale/de_DE.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/de_DE.po b/locale/de_DE.po index 2c6565bc4b..d90c49bf23 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-12 14:37+1000\n" -"PO-Revision-Date: 2020-05-18 02:47+0000\n" -"Last-Translator: Anonymous \n" +"PO-Revision-Date: 2020-05-18 02:48+0000\n" +"Last-Translator: Jeff Epler \n" "Language-Team: German \n" "Language: de_DE\n" @@ -81,7 +81,7 @@ msgstr "%q Indizes müssen ganze Zahlen sein, nicht %s" #: shared-bindings/vectorio/Polygon.c msgid "%q list must be a list" -msgstr "% q Liste muss eine Liste sein" +msgstr "%q Liste muss eine Liste sein" #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c @@ -92,7 +92,7 @@ msgstr "%q muss >= 1 sein" #: shared-bindings/vectorio/Polygon.c msgid "%q must be a tuple of length 2" -msgstr "% q muss ein Tupel der Länge 2 sein" +msgstr "%q muss ein Tupel der Länge 2 sein" #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" From f002c784c0af2272b1fdd5430379bc7775d89743 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 18 May 2020 11:43:21 +0800 Subject: [PATCH 206/216] nrf: linker: add a new .uninitialized section This section immediately follows the .bss section, and is designed to contain uninitialized variables that should persist across reboots. The section is placed directly after .bss, under the theory that the size of Circuit Python's .bss + .data is bigger than the bootloader's .bss + .data, so there is less likely to be a conflict. Signed-off-by: Sean Cross --- ports/nrf/boards/common.template.ld | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ports/nrf/boards/common.template.ld b/ports/nrf/boards/common.template.ld index a2bbf0ec80..9a7df69a47 100644 --- a/ports/nrf/boards/common.template.ld +++ b/ports/nrf/boards/common.template.ld @@ -103,7 +103,7 @@ SECTIONS _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ } >RAM - /* Uninitialized data section */ + /* Zero-initialized data section */ .bss : { . = ALIGN(4); @@ -116,6 +116,19 @@ SECTIONS _ebss = .; /* define a global symbol at bss end; used by startup code and GC */ } >RAM + /* Uninitialized data section + Data placed into this section will remain unchanged across reboots. */ + .uninitialized (NOLOAD) : + { + . = ALIGN(4); + _suninitialized = .; /* define a global symbol at uninitialized start; currently unused */ + *(.uninitialized) + *(.uninitialized*) + + . = ALIGN(4); + _euninitialized = .; /* define a global symbol at uninitialized end; currently unused */ + } >RAM + /* this is to define the start of the heap, and make sure we have a minimum size */ .heap : { From 192bb155fafb78b2f6073fdbfbbf41d8c44dc12e Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 18 May 2020 11:45:35 +0800 Subject: [PATCH 207/216] nrf: port: move the heap after .uninitialized Previously, it was placed following .bss. However, now that there is a new section after .bss, the heap must be moved forward. Signed-off-by: Sean Cross --- ports/nrf/supervisor/port.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 539a9cf90b..a0c7be62ba 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -177,8 +177,13 @@ void reset_cpu(void) { NVIC_SystemReset(); } +// The uninitialized data section is placed directly after BSS, under the theory +// that Circuit Python has a lot more .data and .bss than the bootloader. As a +// result, this section is less likely to be tampered with by the bootloader. +extern uint32_t _euninitialized; + uint32_t *port_heap_get_bottom(void) { - return port_stack_get_limit(); + return &_euninitialized; } uint32_t *port_heap_get_top(void) { @@ -186,14 +191,13 @@ uint32_t *port_heap_get_top(void) { } uint32_t *port_stack_get_limit(void) { - return &_ebss; + return &_euninitialized; } uint32_t *port_stack_get_top(void) { return &_estack; } -extern uint32_t _ebss; // Place the word to save just after our BSS section that gets blanked. void port_set_saved_word(uint32_t value) { _ebss = value; From 3b5f5ddaa6232a8d3ac868c703e8a511abe045e0 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 18 May 2020 11:46:38 +0800 Subject: [PATCH 208/216] nrf: port: move saved word into .uninitialized section Circuit Python supports saving a single word of data across reboots. Previously, this data was placed immediately following the .bss. However, this appeared to not work, as Circuit Python zeroes out the heap when it starts up, and the heap begins immediately after the .bss. Switch to using the new .uninitialized section in order to store this word across resets. Signed-off-by: Sean Cross --- ports/nrf/supervisor/port.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index a0c7be62ba..3a76fa878c 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -198,13 +198,14 @@ uint32_t *port_stack_get_top(void) { return &_estack; } -// Place the word to save just after our BSS section that gets blanked. +// Place the word in the uninitialized section so it won't get overwritten. +__attribute__((section(".uninitialized"))) uint32_t _saved_word; void port_set_saved_word(uint32_t value) { - _ebss = value; + _saved_word = value; } uint32_t port_get_saved_word(void) { - return _ebss; + return _saved_word; } uint64_t port_get_raw_ticks(uint8_t* subticks) { From 83680c41db821672ff006b96151c6daeca6280e3 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 18 May 2020 11:48:23 +0800 Subject: [PATCH 209/216] nrf: rtc: persist rtc offset across reboots Store the RTC value in the .uninitialized section, but make sure to flank it with some known values. That way we can determine if the RTC value has been initialized, or if it's random uninitialized garbage. As part of this, add a `common_hal_rtc_init()` routine to determine if the value is correct, or reset it to 0 if it is not valid. Signed-off-by: Sean Cross --- ports/nrf/common-hal/rtc/RTC.c | 29 ++++++++++++++++++++++++++--- ports/nrf/common-hal/rtc/RTC.h | 1 + 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ports/nrf/common-hal/rtc/RTC.c b/ports/nrf/common-hal/rtc/RTC.c index 9f56f2f0df..06345f5895 100644 --- a/ports/nrf/common-hal/rtc/RTC.c +++ b/ports/nrf/common-hal/rtc/RTC.c @@ -34,11 +34,28 @@ #include "supervisor/shared/translate.h" // This is the time in seconds since 2000 that the RTC was started. -static uint32_t rtc_offset = 0; +__attribute__((section(".uninitialized"))) static uint32_t rtc_offset[3]; + +// These values are placed before and after the current RTC count. They are +// used to determine if the RTC count is valid. These randomly-generated values +// will be set when the RTC value is set in order to mark the RTC as valid. If +// the system crashes or reboots, these values will remain undisturbed and the +// RTC offset will remain valid. +// +// If Circuit Python is updated or these symbols shift around, the prefix and +// suffix will no longer match, and the time will no longer be valid. +#define RTC_OFFSET_CHECK_PREFIX 0x25ea7e2a +#define RTC_OFFSET_CHECK_SUFFIX 0x2b80b69e + +void common_hal_rtc_init(void) { + // If the prefix and suffix are not valid, zero-initialize the RTC offset. + if ((rtc_offset[0] != RTC_OFFSET_CHECK_PREFIX) || (rtc_offset[2] != RTC_OFFSET_CHECK_SUFFIX)) + rtc_offset[1] = 0; +} void common_hal_rtc_get_time(timeutils_struct_time_t *tm) { uint64_t ticks_s = port_get_raw_ticks(NULL) / 1024; - timeutils_seconds_since_2000_to_struct_time(rtc_offset + ticks_s, tm); + timeutils_seconds_since_2000_to_struct_time(rtc_offset[1] + ticks_s, tm); } void common_hal_rtc_set_time(timeutils_struct_time_t *tm) { @@ -46,7 +63,13 @@ void common_hal_rtc_set_time(timeutils_struct_time_t *tm) { uint32_t epoch_s = timeutils_seconds_since_2000( tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec ); - rtc_offset = epoch_s - ticks_s; + rtc_offset[1] = epoch_s - ticks_s; + + // Set the prefix and suffix in order to indicate the time is valid. This + // must be done after the offset is updated, in case there is a crash or + // power failure. + rtc_offset[0] = RTC_OFFSET_CHECK_PREFIX; + rtc_offset[2] = RTC_OFFSET_CHECK_SUFFIX; } int common_hal_rtc_get_calibration(void) { diff --git a/ports/nrf/common-hal/rtc/RTC.h b/ports/nrf/common-hal/rtc/RTC.h index 0207c8338c..e51f1f7848 100644 --- a/ports/nrf/common-hal/rtc/RTC.h +++ b/ports/nrf/common-hal/rtc/RTC.h @@ -29,5 +29,6 @@ extern void rtc_init(void); extern void rtc_reset(void); +extern void common_hal_rtc_init(void); #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H From 9f7c26c60ddcd8ef371290e505f21148e3c98726 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 18 May 2020 11:50:04 +0800 Subject: [PATCH 210/216] nrf: port: call common_hal_rtc_init() during init Call the new function to set the RTC, or reset it if the offset is not valid. Signed-off-by: Sean Cross --- ports/nrf/supervisor/port.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 3a76fa878c..4edb78f7c0 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -120,6 +120,10 @@ safe_mode_t port_init(void) { // Configure millisecond timer initialization. tick_init(); +#if CIRCUITPY_RTC + common_hal_rtc_init(); +#endif + #if CIRCUITPY_ANALOGIO analogin_init(); #endif From f92d53eaab6261c680b05e6016524cd87a5b7b6e Mon Sep 17 00:00:00 2001 From: arturo182 Date: Mon, 18 May 2020 22:07:38 +0200 Subject: [PATCH 211/216] mimxrt1010: Increase max SPI speed --- ports/mimxrt10xx/common-hal/busio/SPI.c | 2 +- ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.c b/ports/mimxrt10xx/common-hal/busio/SPI.c index cc19ba354c..15c320140a 100644 --- a/ports/mimxrt10xx/common-hal/busio/SPI.c +++ b/ports/mimxrt10xx/common-hal/busio/SPI.c @@ -58,7 +58,7 @@ STATIC void config_periph_pin(const mcu_periph_obj_t *periph) { | IOMUXC_SW_PAD_CTL_PAD_SRE(0)); } -#define LPSPI_MASTER_CLK_FREQ (CLOCK_GetFreq(kCLOCK_Usb1PllPfd0Clk) / (CLOCK_GetDiv(kCLOCK_LpspiDiv))) +#define LPSPI_MASTER_CLK_FREQ (CLOCK_GetFreq(kCLOCK_Usb1PllPfd0Clk) / (CLOCK_GetDiv(kCLOCK_LpspiDiv) + 1)) void spi_reset(void) { for (int i = 0; i < MAX_SPI; i++) { diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c index 854ae4dee9..61888fcaa7 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c @@ -55,7 +55,7 @@ #define BOARD_BOOTCLOCKRUN_GPT2_IPG_CLK_HIGHFREQ 62500000UL #define BOARD_BOOTCLOCKRUN_IPG_CLK_ROOT 125000000UL #define BOARD_BOOTCLOCKRUN_LPI2C_CLK_ROOT 60000000UL -#define BOARD_BOOTCLOCKRUN_LPSPI_CLK_ROOT 105600000UL +#define BOARD_BOOTCLOCKRUN_LPSPI_CLK_ROOT 130900000UL #define BOARD_BOOTCLOCKRUN_MQS_MCLK 63529411UL #define BOARD_BOOTCLOCKRUN_PERCLK_CLK_ROOT 62500000UL #define BOARD_BOOTCLOCKRUN_SAI1_CLK_ROOT 63529411UL @@ -137,7 +137,7 @@ void clocks_init(void) { CLOCK_DisableClock(kCLOCK_Lpspi1); CLOCK_DisableClock(kCLOCK_Lpspi2); /* Set LPSPI_PODF. */ - CLOCK_SetDiv(kCLOCK_LpspiDiv, 7); + CLOCK_SetDiv(kCLOCK_LpspiDiv, 2); /* Set Lpspi clock source. */ CLOCK_SetMux(kCLOCK_LpspiMux, 1); /* Disable TRACE clock gate. */ From 058a73128cf7b52d6eea9b97e1abeaa369a853f0 Mon Sep 17 00:00:00 2001 From: arturo182 Date: Mon, 18 May 2020 22:29:31 +0200 Subject: [PATCH 212/216] mimxrt10xx: Fix cpu.temperature crash Fixes #2514 --- ports/mimxrt10xx/common-hal/microcontroller/Processor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index 0c8131ef40..f3a578014e 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -37,11 +37,13 @@ float common_hal_mcu_processor_get_temperature(void) { tempmon_config_t config; TEMPMON_GetDefaultConfig(&config); + OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk)); TEMPMON_Init(TEMPMON, &config); TEMPMON_StartMeasure(TEMPMON); const float temp = TEMPMON_GetCurrentTemperature(TEMPMON); TEMPMON_Deinit(TEMPMON); + OCOTP_Deinit(OCOTP); return temp; } From 4bbb80e31af4c5626d118995e36ade470935fafe Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Tue, 12 May 2020 21:55:18 -0700 Subject: [PATCH 213/216] vectorio: speed up polygon This change takes polygon from 126k pixels per second fill to 240k pps fill on a reference 5 point star 50x66px polygon, updating both location and shape at 10hz. Tested on an m4 express feather. As a curiosity, the flat-out fill rate of a shape whose get_pixel is `return 0;` fills just shy of 375k pixels per second. --- shared-bindings/vectorio/Polygon.c | 42 +--------------- shared-module/vectorio/Polygon.c | 79 +++++++++++++++++++++++------- shared-module/vectorio/Polygon.h | 5 +- 3 files changed, 65 insertions(+), 61 deletions(-) diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index 5f4d85e211..e9e90942a9 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -15,41 +15,6 @@ // #define VECTORIO_POLYGON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) -// Converts a list of points tuples to a flat list of ints for speedier internal use. -// Also validates the points. -static mp_obj_t _to_points_list(mp_obj_t points_tuple_list) { - size_t len = 0; - mp_obj_t *items; - mp_obj_list_get(points_tuple_list, &len, &items); - VECTORIO_POLYGON_DEBUG("polygon_points_list len: %d\n", len); - - if ( len == 0 ) { - mp_raise_TypeError_varg(translate("empty %q list"), MP_QSTR_point); - } - - mp_obj_t points_list = mp_obj_new_list(0, NULL); - - for ( size_t i = 0; i < len; ++i) { - size_t tuple_len = 0; - mp_obj_t *tuple_items; - mp_obj_tuple_get(items[i], &tuple_len, &tuple_items); - - if (tuple_len != 2) { - mp_raise_ValueError_varg(translate("%q must be a tuple of length 2"), MP_QSTR_point); - } - int value; - if (!mp_obj_get_int_maybe(tuple_items[0], &value)) { - mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); - } - mp_obj_list_append(points_list, MP_OBJ_NEW_SMALL_INT(value)); - if (!mp_obj_get_int_maybe(tuple_items[1], &value)) { - mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); - } - mp_obj_list_append(points_list, MP_OBJ_NEW_SMALL_INT(value)); - } - return points_list; -} -//| from typing import List, Tuple //| //| class Polygon: //| def __init__(self, points: List[ Tuple[ x, y ], ... ] ): @@ -68,12 +33,11 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar if (!MP_OBJ_IS_TYPE(args[ARG_points_list].u_obj, &mp_type_list)) { mp_raise_TypeError_varg(translate("%q list must be a list"), MP_QSTR_point); } - mp_obj_t points_list = _to_points_list(args[ARG_points_list].u_obj); vectorio_polygon_t *self = m_new_obj(vectorio_polygon_t); self->base.type = &vectorio_polygon_type; - common_hal_vectorio_polygon_construct(self, points_list); + common_hal_vectorio_polygon_construct(self, args[ARG_points_list].u_obj); return MP_OBJ_FROM_PTR(self); } @@ -104,9 +68,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(vectorio_polygon_get_points_obj, vectorio_polygon_obj_ STATIC mp_obj_t vectorio_polygon_obj_set_points(mp_obj_t self_in, mp_obj_t points) { vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t points_list = _to_points_list(points); - - common_hal_vectorio_polygon_set_points(self, points_list); + common_hal_vectorio_polygon_set_points(self, points); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_polygon_set_points_obj, vectorio_polygon_obj_set_points); diff --git a/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c index 6722912c2d..7e3a3acfe9 100644 --- a/shared-module/vectorio/Polygon.c +++ b/shared-module/vectorio/Polygon.c @@ -4,6 +4,8 @@ #include "shared-module/displayio/area.h" #include "py/runtime.h" +#include "py/gc.h" + #include "stdlib.h" #include @@ -12,10 +14,57 @@ // #define VECTORIO_POLYGON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) +// Converts a list of points tuples to a flat list of ints for speedier internal use. +// Also validates the points. +static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple_list) { + size_t len = 0; + mp_obj_t *items; + mp_obj_list_get(points_tuple_list, &len, &items); + VECTORIO_POLYGON_DEBUG("polygon_points_list len: %d\n", len); + + if ( len < 3 ) { + mp_raise_TypeError_varg(translate("Polygon needs at least 3 points")); + } + + if ( self->len < 2*len ) { + if ( self->points_list != NULL ) { + gc_free( self->points_list ); + } + self->points_list = gc_alloc( 2 * len * sizeof(int), false, false ); + } + self->len = 2*len; + + for ( size_t i = 0; i < len; ++i) { + size_t tuple_len = 0; + mp_obj_t *tuple_items; + mp_obj_tuple_get(items[i], &tuple_len, &tuple_items); + + if (tuple_len != 2) { + mp_raise_ValueError_varg(translate("%q must be a tuple of length 2"), MP_QSTR_point); + } + if (!mp_obj_get_int_maybe(tuple_items[0], &self->points_list[2*i])) { + self->len = 0; + gc_free( self->points_list ); + self->points_list = NULL; + mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); + } + if (!mp_obj_get_int_maybe(tuple_items[1], &self->points_list[2*i + 1])) { + self->len = 0; + gc_free( self->points_list ); + self->points_list = NULL; + mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); + } + } +} + + + void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t points_list) { VECTORIO_POLYGON_DEBUG("%p polygon_construct\n", self); - self->points_list = points_list; + self->points_list = NULL; + self->len = 0; self->on_dirty.obj = NULL; + _clobber_points_list( self, points_list ); } @@ -23,7 +72,7 @@ mp_obj_t common_hal_vectorio_polygon_get_points(vectorio_polygon_t *self) { return self->points_list; } void common_hal_vectorio_polygon_set_points(vectorio_polygon_t *self, mp_obj_t points_list) { - self->points_list = points_list; + _clobber_points_list( self, points_list ); if (self->on_dirty.obj != NULL) { self->on_dirty.event(self->on_dirty.obj); } @@ -38,21 +87,16 @@ void common_hal_vectorio_polygon_set_on_dirty(vectorio_polygon_t *self, vectorio void common_hal_vectorio_polygon_get_area(void *polygon, displayio_area_t *area) { - VECTORIO_POLYGON_DEBUG("%p polygon get_area", polygon); vectorio_polygon_t *self = polygon; - size_t len; - mp_obj_t *points; - mp_obj_list_get(self->points_list, &len, &points); - VECTORIO_POLYGON_DEBUG(" len: %2d, points: %d\n", len, len/2); area->x1 = SHRT_MAX; area->y1 = SHRT_MAX; area->x2 = SHRT_MIN; area->y2 = SHRT_MIN; - for (size_t i=0; i < len; ++i) { - mp_int_t x = mp_obj_get_int(points[i]); + for (size_t i=0; i < self->len; ++i) { + int x = self->points_list[i]; ++i; - mp_int_t y = mp_obj_get_int(points[i]); + int y = self->points_list[i]; if (x <= area->x1) area->x1 = x-1; if (y <= area->y1) area->y1 = y-1; if (x >= area->x2) area->x2 = x+1; @@ -73,22 +117,19 @@ __attribute__((always_inline)) static inline int line_side( mp_int_t x1, mp_int_ uint32_t common_hal_vectorio_polygon_get_pixel(void *obj, int16_t x, int16_t y) { VECTORIO_POLYGON_DEBUG("%p polygon get_pixel %d, %d\n", obj, x, y); vectorio_polygon_t *self = obj; - size_t len; - mp_obj_t *points; - mp_obj_list_get(self->points_list, &len, &points); - if (len == 0) { + if (self->len == 0) { return 0; } int winding_number = 0; - mp_int_t x1 = mp_obj_get_int(points[0]); - mp_int_t y1 = mp_obj_get_int(points[1]); - for (size_t i=2; i <= len + 1; ++i) { + int x1 = self->points_list[0]; + int y1 = self->points_list[1]; + for (size_t i=2; i <= self->len + 1; ++i) { VECTORIO_POLYGON_DEBUG(" {(%3d, %3d),", x1, y1); - mp_int_t x2 = mp_obj_get_int(points[i % len]); + int x2 = self->points_list[i % self->len]; ++i; - mp_int_t y2 = mp_obj_get_int(points[i % len]); + int y2 = self->points_list[i % self->len]; VECTORIO_POLYGON_DEBUG(" (%3d, %3d)}\n", x2, y2); if ( y1 <= y ) { if ( y2 > y && line_side(x1, y1, x2, y2, x, y) > 0 ) { diff --git a/shared-module/vectorio/Polygon.h b/shared-module/vectorio/Polygon.h index 1aef854a7b..70de9036d7 100644 --- a/shared-module/vectorio/Polygon.h +++ b/shared-module/vectorio/Polygon.h @@ -8,8 +8,9 @@ typedef struct { mp_obj_base_t base; - // A micropython List[ x, y, ... ] - mp_obj_t points_list; + // An int array[ x, y, ... ] + int *points_list; + size_t len; vectorio_event_t on_dirty; } vectorio_polygon_t; From dde66cadde44e478d7b11358f768b1debc0b03c7 Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Thu, 14 May 2020 11:44:36 -0700 Subject: [PATCH 214/216] remove a duplication in polygon.c --- shared-bindings/vectorio/Polygon.c | 1 + shared-module/vectorio/Polygon.c | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index e9e90942a9..01045d098f 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -15,6 +15,7 @@ // #define VECTORIO_POLYGON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) +//| from typing import List, Tuple //| //| class Polygon: //| def __init__(self, points: List[ Tuple[ x, y ], ... ] ): diff --git a/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c index 7e3a3acfe9..aadf47911a 100644 --- a/shared-module/vectorio/Polygon.c +++ b/shared-module/vectorio/Polygon.c @@ -42,13 +42,9 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple if (tuple_len != 2) { mp_raise_ValueError_varg(translate("%q must be a tuple of length 2"), MP_QSTR_point); } - if (!mp_obj_get_int_maybe(tuple_items[0], &self->points_list[2*i])) { - self->len = 0; - gc_free( self->points_list ); - self->points_list = NULL; - mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); - } - if (!mp_obj_get_int_maybe(tuple_items[1], &self->points_list[2*i + 1])) { + if ( !mp_obj_get_int_maybe(tuple_items[ 0 ], &self->points_list[2*i ]) + || !mp_obj_get_int_maybe(tuple_items[ 1 ], &self->points_list[2*i + 1]) + ) { self->len = 0; gc_free( self->points_list ); self->points_list = NULL; From a78f245ea649c2bf67e2748d068b531b352cc4aa Mon Sep 17 00:00:00 2001 From: warriorofwire <3454741+WarriorOfWire@users.noreply.github.com> Date: Mon, 18 May 2020 13:33:16 -0700 Subject: [PATCH 215/216] translations for polygon --- locale/ID.po | 16 ++++++++-------- locale/circuitpython.pot | 16 ++++++++-------- locale/cs.po | 16 ++++++++-------- locale/de_DE.po | 16 ++++++++-------- locale/en_US.po | 16 ++++++++-------- locale/en_x_pirate.po | 16 ++++++++-------- locale/es.po | 16 ++++++++-------- locale/fil.po | 16 ++++++++-------- locale/fr.po | 29 +++++++++++++++++------------ locale/it_IT.po | 16 ++++++++-------- locale/ko.po | 16 ++++++++-------- locale/pl.po | 16 ++++++++-------- locale/pt_BR.po | 16 ++++++++-------- locale/sv.po | 26 +++++++++++++++----------- locale/zh_Latn_pinyin.po | 16 ++++++++-------- 15 files changed, 136 insertions(+), 127 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index e4420f046f..9c1c3b9bf9 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -82,7 +82,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "buffers harus mempunyai panjang yang sama" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1269,6 +1269,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "Tambahkan module apapun pada filesystem\n" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2137,10 +2141,6 @@ msgstr "" msgid "empty" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "heap kosong" @@ -3158,8 +3158,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index d1f4978059..5654256464 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -81,7 +81,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1257,6 +1257,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2113,10 +2117,6 @@ msgstr "" msgid "empty" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -3132,8 +3132,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index 493245dbfc..7f02e5215d 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -81,7 +81,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1257,6 +1257,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2113,10 +2117,6 @@ msgstr "" msgid "empty" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -3132,8 +3132,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index d90c49bf23..d81570b70f 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2020-05-18 02:48+0000\n" "Last-Translator: Jeff Epler \n" "Language-Team: German = 1" msgstr "%q muss >= 1 sein" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "%q muss ein Tupel der Länge 2 sein" @@ -1279,6 +1279,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "und alle Module im Dateisystem \n" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2149,10 +2153,6 @@ msgstr "Division durch Null" msgid "empty" msgstr "leer" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "leerer heap" @@ -3184,8 +3184,8 @@ msgstr "" msgid "unreadable attribute" msgstr "nicht lesbares Attribut" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "Nicht unterstützter %q-Typ" diff --git a/locale/en_US.po b/locale/en_US.po index d18ea18083..9e07d2bf22 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -81,7 +81,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1257,6 +1257,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2113,10 +2117,6 @@ msgstr "" msgid "empty" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -3132,8 +3132,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 6515beaf9f..8737a3d8d6 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2020-03-30 22:11+0000\n" "Last-Translator: Tannewt \n" "Language-Team: English = 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1266,6 +1266,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2122,10 +2126,6 @@ msgstr "" msgid "empty" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -3141,8 +3141,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "" diff --git a/locale/es.po b/locale/es.po index 60a8af0599..6b904200b3 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2020-05-17 20:56+0000\n" "Last-Translator: Jeff Epler \n" "Language-Team: \n" @@ -84,7 +84,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "%q debe ser >= 1" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1273,6 +1273,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "Incapaz de montar de nuevo el sistema de archivos" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "Pop de un buffer Ps2 vacio" @@ -2146,10 +2150,6 @@ msgstr "división por cero" msgid "empty" msgstr "vacío" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "heap vacío" @@ -3175,8 +3175,8 @@ msgstr "No coinciden '{' en format" msgid "unreadable attribute" msgstr "atributo no legible" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "tipo de %q no soportado" diff --git a/locale/fil.po b/locale/fil.po index 2dd773eef0..b9af70d854 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -82,7 +82,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "aarehas na haba dapat ang buffer slices" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1277,6 +1277,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "Kasama ang kung ano pang modules na sa filesystem\n" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2157,10 +2161,6 @@ msgstr "dibisyon ng zero" msgid "empty" msgstr "walang laman" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "walang laman ang heap" @@ -3188,8 +3188,8 @@ msgstr "hindi tugma ang '{' sa format" msgid "unreadable attribute" msgstr "hindi mabasa ang attribute" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "Hindi supportadong tipo ng %q" diff --git a/locale/fr.po b/locale/fr.po index 4958ee7452..820bd9375a 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2020-05-17 20:56+0000\n" "Last-Translator: Anonymous \n" "Language-Team: French = 1" msgstr "%q doit être >=1" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "%q doit être un tuple de longueur 2" @@ -534,7 +534,8 @@ msgstr "Impossible d'obtenir la taille du scalaire sans ambigüité" #: ports/stm/common-hal/pulseio/PWMOut.c msgid "Cannot vary frequency on a timer that is already in use" -msgstr "Impossible de faire varier la fréquence sur une minuterie déjà utilisée" +msgstr "" +"Impossible de faire varier la fréquence sur une minuterie déjà utilisée" #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." @@ -1293,13 +1294,17 @@ msgid "" "constructor" msgstr "" "Le brochage utilise %d octets par élément, ce qui consomme plus que le %d " -"octets idéal. Si cela ne peut pas être évité, transmettez allow_inefficient =" -" True au constructeur" +"octets idéal. Si cela ne peut pas être évité, transmettez allow_inefficient " +"= True au constructeur" #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Ainsi que tout autre module présent sur le système de fichiers\n" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "Pop à partir d'un tampon Ps2 vide" @@ -2063,7 +2068,8 @@ msgstr "ne peut pas réaliser un import relatif" #: extmod/ulab/code/ndarray.c msgid "cannot reshape array (incompatible input/output shape)" -msgstr "ne peut pas remodeler le tableau (forme d'entrée / sortie incompatible)" +msgstr "" +"ne peut pas remodeler le tableau (forme d'entrée / sortie incompatible)" #: py/emitnative.c msgid "casting" @@ -2191,10 +2197,6 @@ msgstr "division par zéro" msgid "empty" msgstr "vide" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "liste %q vide" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "tas vide" @@ -3226,8 +3228,8 @@ msgstr "'{' sans correspondance dans le format" msgid "unreadable attribute" msgstr "attribut illisible" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "type %q non pris on charge" @@ -3701,6 +3703,9 @@ msgstr "'step' nul" #~ msgid "either pos or kw args are allowed" #~ msgstr "soit 'pos', soit 'kw' est permis en argument" +#~ msgid "empty %q list" +#~ msgstr "liste %q vide" + #~ msgid "expected a DigitalInOut" #~ msgstr "objet DigitalInOut attendu" diff --git a/locale/it_IT.po b/locale/it_IT.po index 61de76f544..44c5cccbad 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -82,7 +82,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "slice del buffer devono essere della stessa lunghezza" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1287,6 +1287,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "Imposssibile rimontare il filesystem" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2158,10 +2162,6 @@ msgstr "divisione per zero" msgid "empty" msgstr "vuoto" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "heap vuoto" @@ -3195,8 +3195,8 @@ msgstr "'{' spaiato nella stringa di formattazione" msgid "unreadable attribute" msgstr "attributo non leggibile" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "tipo di %q non supportato" diff --git a/locale/ko.po b/locale/ko.po index e6e386b304..ac2a75a9e4 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -83,7 +83,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "%q 는 >=1이어야합니다" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1261,6 +1261,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2118,10 +2122,6 @@ msgstr "" msgid "empty" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "" @@ -3137,8 +3137,8 @@ msgstr "" msgid "unreadable attribute" msgstr "" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 962c090054..f872b28ba6 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -82,7 +82,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "%q musi być >= 1" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1262,6 +1262,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "Oraz moduły w systemie plików\n" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "" @@ -2122,10 +2126,6 @@ msgstr "dzielenie przez zero" msgid "empty" msgstr "puste" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "pusta sterta" @@ -3143,8 +3143,8 @@ msgstr "niepasujące '{' for formacie" msgid "unreadable attribute" msgstr "nieczytelny atrybut" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "zły typ %q" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index e18355fa3e..a376fdf063 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -82,7 +82,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "buffers devem ser o mesmo tamanho" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1273,6 +1273,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "Não é possível remontar o sistema de arquivos" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "Buffer Ps2 vazio" @@ -2134,10 +2138,6 @@ msgstr "divisão por zero" msgid "empty" msgstr "vazio" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "heap vazia" @@ -3156,8 +3156,8 @@ msgstr "" msgid "unreadable attribute" msgstr "atributo ilegível" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "" diff --git a/locale/sv.po b/locale/sv.po index 8d64d4b7b5..34927a2516 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2020-05-17 20:56+0000\n" "Last-Translator: Anonymous \n" "Language-Team: LANGUAGE \n" @@ -89,7 +89,7 @@ msgstr "%q-listan måste vara en lista" msgid "%q must be >= 1" msgstr "%q måste vara >= 1" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "%q måste vara en tuple av längd 2" @@ -1067,7 +1067,8 @@ msgstr "MicroPython fatalt fel." #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" -msgstr "Startfördröjningen för mikrofonen måste vara i intervallet 0,0 till 1,0" +msgstr "" +"Startfördröjningen för mikrofonen måste vara i intervallet 0,0 till 1,0" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" @@ -1278,14 +1279,18 @@ msgid "" "bytes. If this cannot be avoided, pass allow_inefficient=True to the " "constructor" msgstr "" -"Pinout använder %d byte per element, vilket förbrukar mer än det idealiska %" -"d byte. Om detta inte kan undvikas, skicka allow_inefficient=True till " +"Pinout använder %d byte per element, vilket förbrukar mer än det idealiska " +"%d byte. Om detta inte kan undvikas, skicka allow_inefficient=True till " "konstruktorn" #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Plus eventuella moduler i filsystemet\n" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "Pop från en tom Ps2-buffert" @@ -2163,10 +2168,6 @@ msgstr "division med noll" msgid "empty" msgstr "tom" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "tom %q-lista" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "tom heap" @@ -3188,8 +3189,8 @@ msgstr "omatchad '{' i format" msgid "unreadable attribute" msgstr "attribut kan inte läsas" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "typ %q stöds inte" @@ -3268,3 +3269,6 @@ msgstr "y-värde utanför intervall" #: py/objrange.c msgid "zero step" msgstr "noll steg" + +#~ msgid "empty %q list" +#~ msgstr "tom %q-lista" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 9d0bd392d8..e2247c79d9 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-12 14:37+1000\n" +"POT-Creation-Date: 2020-05-18 13:32-0700\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -88,7 +88,7 @@ msgstr "" msgid "%q must be >= 1" msgstr "%q bìxū dàyú huò děngyú 1" -#: shared-bindings/vectorio/Polygon.c +#: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -1276,6 +1276,10 @@ msgstr "" msgid "Plus any modules on the filesystem\n" msgstr "Zài wénjiàn xìtǒng shàng tiānjiā rènhé mókuài\n" +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Pop from an empty Ps2 buffer" msgstr "Cóng kōng de Ps2 huǎnchōng qū dànchū" @@ -2150,10 +2154,6 @@ msgstr "bèi líng chú" msgid "empty" msgstr "kòngxián" -#: shared-bindings/vectorio/Polygon.c -msgid "empty %q list" -msgstr "" - #: extmod/moduheapq.c extmod/modutimeq.c msgid "empty heap" msgstr "kōng yīn yīnxiào" @@ -3173,8 +3173,8 @@ msgstr "géshì wèi pǐpèi '{'" msgid "unreadable attribute" msgstr "bùkě dú shǔxìng" -#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c -#: shared-bindings/vectorio/VectorShape.c +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c msgid "unsupported %q type" msgstr "bù zhīchí %q lèixíng" From 007c92ee6ab8da342dacb8967ef999b6d83596ec Mon Sep 17 00:00:00 2001 From: Mark Olsson Date: Mon, 18 May 2020 14:04:55 +0200 Subject: [PATCH 216/216] Enable showing the console on a debug uart --- main.c | 3 ++ ports/atmel-samd/common-hal/busio/UART.c | 3 +- ports/cxd56/common-hal/busio/UART.c | 3 +- ports/mimxrt10xx/common-hal/busio/UART.c | 3 +- ports/nrf/common-hal/busio/UART.c | 3 +- .../stm/boards/nucleo_f746zg/mpconfigboard.h | 3 ++ ports/stm/boards/nucleo_f746zg/pins.c | 5 +- ports/stm/common-hal/busio/UART.c | 52 ++++++++++++++++--- ports/stm/common-hal/busio/UART.h | 2 + shared-bindings/busio/UART.c | 2 +- shared-bindings/busio/UART.h | 6 ++- shared-module/board/__init__.c | 2 +- supervisor/serial.h | 1 + supervisor/shared/serial.c | 52 +++++++++++++++++++ supervisor/stub/serial.c | 4 ++ 15 files changed, 128 insertions(+), 16 deletions(-) diff --git a/main.c b/main.c index c60cded165..a3bf49fc31 100755 --- a/main.c +++ b/main.c @@ -430,6 +430,9 @@ int __attribute__((used)) main(void) { // displays init after filesystem, since they could share the flash SPI board_init(); + // Start the debug serial + serial_early_init(); + // Reset everything and prep MicroPython to run boot.py. reset_port(); reset_board(); diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 1f6b75f972..30a618cca6 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -56,7 +56,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, const mcu_pin_obj_t * rs485_dir, bool rs485_invert, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, - mp_float_t timeout, uint16_t receiver_buffer_size) { + mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer, + bool sigint_enabled) { Sercom* sercom = NULL; uint8_t sercom_index = 255; // Unset index diff --git a/ports/cxd56/common-hal/busio/UART.c b/ports/cxd56/common-hal/busio/UART.c index 3bca240e01..e455b0568d 100644 --- a/ports/cxd56/common-hal/busio/UART.c +++ b/ports/cxd56/common-hal/busio/UART.c @@ -57,7 +57,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, const mcu_pin_obj_t * rs485_dir, bool rs485_invert, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, - mp_float_t timeout, uint16_t receiver_buffer_size) { + mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer, + bool sigint_enabled) { struct termios tio; if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) { diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index e3642daf59..fbb45eeea4 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -76,7 +76,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, const mcu_pin_obj_t * rs485_dir, bool rs485_invert, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, - mp_float_t timeout, uint16_t receiver_buffer_size) { + mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer, + bool sigint_enabled) { // TODO: Allow none rx or tx diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index dbf40ea516..89f3c9f327 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -134,7 +134,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, const mcu_pin_obj_t * rs485_dir, bool rs485_invert, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, - mp_float_t timeout, uint16_t receiver_buffer_size) { + mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer, + bool sigint_enabled) { if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) { mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device")); diff --git a/ports/stm/boards/nucleo_f746zg/mpconfigboard.h b/ports/stm/boards/nucleo_f746zg/mpconfigboard.h index 1d86149193..b1abd140fa 100644 --- a/ports/stm/boards/nucleo_f746zg/mpconfigboard.h +++ b/ports/stm/boards/nucleo_f746zg/mpconfigboard.h @@ -34,3 +34,6 @@ #define FLASH_PAGE_SIZE (0x4000) #define BOARD_OSC_DIV (8) + +#define DEBUG_UART_TX (&pin_PD08) +#define DEBUG_UART_RX (&pin_PD09) diff --git a/ports/stm/boards/nucleo_f746zg/pins.c b/ports/stm/boards/nucleo_f746zg/pins.c index 56b6a745f9..7c6a075e23 100644 --- a/ports/stm/boards/nucleo_f746zg/pins.c +++ b/ports/stm/boards/nucleo_f746zg/pins.c @@ -58,8 +58,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_USB_ID), MP_ROM_PTR(&pin_PA10) }, { MP_ROM_QSTR(MP_QSTR_USB_DM), MP_ROM_PTR(&pin_PA11) }, { MP_ROM_QSTR(MP_QSTR_USB_DP), MP_ROM_PTR(&pin_PA12) }, -{ MP_ROM_QSTR(MP_QSTR_VCP_TX), MP_ROM_PTR(&pin_PD08) }, -{ MP_ROM_QSTR(MP_QSTR_VCP_RX), MP_ROM_PTR(&pin_PD09) }, +// As we use these for the debug_console, we won't enable them here. +// { MP_ROM_QSTR(MP_QSTR_VCP_TX), MP_ROM_PTR(&pin_PD08) }, +// { MP_ROM_QSTR(MP_QSTR_VCP_RX), MP_ROM_PTR(&pin_PD09) }, { MP_ROM_QSTR(MP_QSTR_UART2_TX), MP_ROM_PTR(&pin_PD05) }, { MP_ROM_QSTR(MP_QSTR_UART2_RX), MP_ROM_PTR(&pin_PD06) }, { MP_ROM_QSTR(MP_QSTR_UART2_RTS), MP_ROM_PTR(&pin_PD04) }, diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index 54ac68d738..c83479126a 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -28,6 +28,7 @@ #include "shared-bindings/busio/UART.h" #include "mpconfigport.h" +#include "lib/mp-readline/readline.h" #include "lib/utils/interrupt_char.h" #include "py/gc.h" #include "py/mperrno.h" @@ -39,6 +40,7 @@ //arrays use 0 based numbering: UART1 is stored at index 0 STATIC bool reserved_uart[MAX_UART]; +STATIC bool never_reset_uart[MAX_UART]; int errflag; //Used to restart read halts STATIC void uart_clock_enable(uint16_t mask); @@ -61,11 +63,16 @@ STATIC USART_TypeDef * assign_uart_or_throw(busio_uart_obj_t* self, bool pin_eva } void uart_reset(void) { + uint16_t never_reset_mask = 0x00; for (uint8_t i = 0; i < MAX_UART; i++) { - reserved_uart[i] = false; - MP_STATE_PORT(cpy_uart_obj_all)[i] = NULL; + if (!never_reset_uart[i]) { + reserved_uart[i] = false; + MP_STATE_PORT(cpy_uart_obj_all)[i] = NULL; + } else { + never_reset_mask |= 1 << i; + } } - uart_clock_disable(ALL_UARTS); + uart_clock_disable(ALL_UARTS & ~(never_reset_mask)); } void common_hal_busio_uart_construct(busio_uart_obj_t *self, @@ -73,7 +80,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, const mcu_pin_obj_t * rs485_dir, bool rs485_invert, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, - mp_float_t timeout, uint16_t receiver_buffer_size) { + mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer, + bool sigint_enabled) { //match pins to UART objects USART_TypeDef * USARTx; @@ -209,8 +217,12 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // Init buffer for rx and claim pins if (self->rx != NULL) { - if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) { - mp_raise_ValueError(translate("UART Buffer allocation error")); + if (receiver_buffer != NULL) { + self->ringbuf = (ringbuf_t){ receiver_buffer, receiver_buffer_size }; + } else { + if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) { + mp_raise_ValueError(translate("UART Buffer allocation error")); + } } claim_pin(rx); } @@ -219,6 +231,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, } self->baudrate = baudrate; self->timeout_ms = timeout * 1000; + self->sigint_enabled = sigint_enabled; //start the interrupt series if ((HAL_UART_GetState(&self->handle) & HAL_UART_STATE_BUSY_RX) == HAL_UART_STATE_BUSY_RX) { @@ -234,6 +247,17 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, errflag = HAL_OK; } +void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) { + for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_uart_banks); i++) { + if (mcu_uart_banks[i] == self->handle.Instance) { + never_reset_uart[i] = true; + never_reset_pin_number(self->tx->pin->port, self->tx->pin->number); + never_reset_pin_number(self->rx->pin->port, self->rx->pin->number); + break; + } + } +} + bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { return self->tx->pin == NULL; } @@ -241,6 +265,13 @@ bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { if (common_hal_busio_uart_deinited(self)) return; + for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_uart_banks); i++) { + if (mcu_uart_banks[i] == self->handle.Instance) { + never_reset_uart[i] = false; + break; + } + } + reset_pin_number(self->tx->pin->port,self->tx->pin->number); reset_pin_number(self->rx->pin->port,self->rx->pin->number); self->tx = NULL; @@ -289,7 +320,8 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, bool write_err = false; //write error shouldn't disable interrupts HAL_NVIC_DisableIRQ(self->irq); - if (HAL_UART_Transmit(&self->handle, (uint8_t*)data, len, HAL_MAX_DELAY) != HAL_OK) { + HAL_StatusTypeDef ret = HAL_UART_Transmit(&self->handle, (uint8_t*)data, len, HAL_MAX_DELAY); + if (ret != HAL_OK) { write_err = true; } HAL_UART_Receive_IT(&self->handle, &self->rx_char, 1); @@ -313,6 +345,12 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *handle) } ringbuf_put_n(&context->ringbuf, &context->rx_char, 1); errflag = HAL_UART_Receive_IT(handle, &context->rx_char, 1); + if (context->sigint_enabled) { + if (context->rx_char == CHAR_CTRL_C) { + common_hal_busio_uart_clear_rx_buffer(context); + mp_keyboard_interrupt(); + } + } return; } diff --git a/ports/stm/common-hal/busio/UART.h b/ports/stm/common-hal/busio/UART.h index d1971ce27a..a6a69a5922 100644 --- a/ports/stm/common-hal/busio/UART.h +++ b/ports/stm/common-hal/busio/UART.h @@ -52,6 +52,8 @@ typedef struct { uint32_t baudrate; uint32_t timeout_ms; + + bool sigint_enabled; } busio_uart_obj_t; void uart_reset(void); diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index f231924d50..a448abb780 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -140,7 +140,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert, args[ARG_baudrate].u_int, bits, parity, stop, timeout, - args[ARG_receiver_buffer_size].u_int); + args[ARG_receiver_buffer_size].u_int, NULL, false); return (mp_obj_t)self; } diff --git a/shared-bindings/busio/UART.h b/shared-bindings/busio/UART.h index fe71e86689..3aed4e534c 100644 --- a/shared-bindings/busio/UART.h +++ b/shared-bindings/busio/UART.h @@ -29,6 +29,7 @@ #include "common-hal/microcontroller/Pin.h" #include "common-hal/busio/UART.h" +#include "py/ringbuf.h" extern const mp_obj_type_t busio_uart_type; @@ -44,7 +45,8 @@ extern void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, const mcu_pin_obj_t * rs485_dir, bool rs485_invert, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, - mp_float_t timeout, uint16_t receiver_buffer_size); + mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer, + bool sigint_enabled); extern void common_hal_busio_uart_deinit(busio_uart_obj_t *self); extern bool common_hal_busio_uart_deinited(busio_uart_obj_t *self); @@ -66,4 +68,6 @@ extern uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t * extern void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self); extern bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self); +extern void common_hal_busio_uart_never_reset(busio_uart_obj_t *self); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_UART_H diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 789318a053..0fbf916cd9 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -123,7 +123,7 @@ mp_obj_t common_hal_board_create_uart(void) { #endif common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert, - 9600, 8, PARITY_NONE, 1, 1.0f, 64); + 9600, 8, PARITY_NONE, 1, 1.0f, 64, NULL, false); MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self); return MP_STATE_VM(shared_uart_bus); } diff --git a/supervisor/serial.h b/supervisor/serial.h index 84b3062a3b..ef88ad346d 100644 --- a/supervisor/serial.h +++ b/supervisor/serial.h @@ -38,6 +38,7 @@ FIL* boot_output_file; #endif +void serial_early_init(void); void serial_init(void); void serial_write(const char* text); // Only writes up to given length. Does not check for null termination at all. diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index a61899576f..513022667a 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -32,26 +32,73 @@ #include "shared-bindings/terminalio/Terminal.h" #include "supervisor/serial.h" #include "supervisor/usb.h" +#include "shared-bindings/microcontroller/Pin.h" #include "tusb.h" +/* + * Note: DEBUG_UART currently only works on STM32, + * enabling on another platform will cause a crash. + */ + +#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) +#include "shared-bindings/busio/UART.h" +busio_uart_obj_t debug_uart; +byte buf_array[64]; +#endif + +void serial_early_init(void) { +#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + debug_uart.base.type = &busio_uart_type; + + const mcu_pin_obj_t* rx = MP_OBJ_TO_PTR(DEBUG_UART_RX); + const mcu_pin_obj_t* tx = MP_OBJ_TO_PTR(DEBUG_UART_TX); + + common_hal_busio_uart_construct(&debug_uart, tx, rx, NULL, NULL, NULL, + false, 115200, 8, PARITY_NONE, 1, 1.0f, 64, + buf_array, true); + common_hal_busio_uart_never_reset(&debug_uart); +#endif +} + void serial_init(void) { usb_init(); } bool serial_connected(void) { +#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + return true; +#else return tud_cdc_connected(); +#endif } char serial_read(void) { +#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + if (tud_cdc_connected() && tud_cdc_available() > 0) { + return (char) tud_cdc_read_char(); + } + int uart_errcode; + char text; + common_hal_busio_uart_read(&debug_uart, (uint8_t*) &text, 1, &uart_errcode); + return text; +#else return (char) tud_cdc_read_char(); +#endif } bool serial_bytes_available(void) { +#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + return common_hal_busio_uart_rx_characters_available(&debug_uart) || (tud_cdc_available() > 0); +#else return tud_cdc_available() > 0; +#endif } void serial_write_substring(const char* text, uint32_t length) { + if (length == 0) { + return; + } #if CIRCUITPY_DISPLAYIO int errcode; common_hal_terminalio_terminal_write(&supervisor_terminal, (const uint8_t*) text, length, &errcode); @@ -62,6 +109,11 @@ void serial_write_substring(const char* text, uint32_t length) { count += tud_cdc_write(text + count, length - count); usb_background(); } + +#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + int uart_errcode; + common_hal_busio_uart_write(&debug_uart, (const uint8_t*) text, length, &uart_errcode); +#endif } void serial_write(const char* text) { diff --git a/supervisor/stub/serial.c b/supervisor/stub/serial.c index 9565519141..34b433e536 100644 --- a/supervisor/stub/serial.c +++ b/supervisor/stub/serial.c @@ -26,6 +26,10 @@ #include "supervisor/serial.h" +void serial_early_init(void) { + +} + void serial_init(void) { }