Merge pull request #10178 from adafruit/9.2.x

Merge current 9.2.x to main
This commit is contained in:
Dan Halbert 2025-03-26 11:37:32 -04:00 committed by GitHub
commit 9ba4104f7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 301 additions and 48 deletions

10
.github/pull_request_template.md vendored Normal file
View file

@ -0,0 +1,10 @@
Thanks for submitting a pull request to CircuitPython! Remove these instructions before submitting.
See https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github for detailed instructions.
- Consider whether to submit this PR against `main` or against (if it exists) the branch for the current stable release or an upcoming minor release. The branch will be named `i.j.x`, for example, `9.2.x`. Bug fixes and minor enhancements can be submitted against the stable release branch, and will be merged to `main` regularly.
- Create your own fork of `circuitpython` and create a branch for your changes.
- Use `pre-commit` to check your commits before submitting. See https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/check-your-code.
- Test your changes and tell us how you tested.
---

View file

@ -10,9 +10,9 @@ repos:
hooks:
- id: check-yaml
- id: end-of-file-fixer
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|ports/raspberrypi/sdk|lib/tinyusb)'
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|ports/mimxrt10xx/sdk|ports/raspberrypi/sdk|lib/tinyusb)'
- id: trailing-whitespace
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|lib/mbedtls_errors/generate_errors.diff|ports/raspberrypi/sdk|lib/tinyusb)'
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|lib/mbedtls_errors/generate_errors.diff|ports/raspberrypi/sdk|ports/mimxrt10xx/sdk|lib/tinyusb)'
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
@ -59,3 +59,4 @@ repos:
rev: "v2.5.0"
hooks:
- id: pyproject-fmt
exclude: '^(ports/mimxrt10xx/sdk)'

View file

@ -7,7 +7,7 @@
|see_cpython_module| :mod:`python:errno`.
This module provides access to symbolic error codes for `OSError` exception.
The codes available may vary per CircuitPython build.
Some codes are not available on the smallest CircuitPython builds, such as SAMD21, for space reasons.
Constants
---------

View file

@ -26,4 +26,3 @@ CIRCUITPY_DISPLAYIO = 1
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Shapes
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM9x

View file

@ -30,18 +30,9 @@ uint8_t display_init_sequence[] = {
};
static void display_init(void) {
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
common_hal_busio_spi_construct(
spi,
&pin_GPIO12, // CLK
&pin_GPIO11, // MOSI
NULL, // MISO not connected
false); // Not half-duplex
bus->base.type = &fourwire_fourwire_type;
common_hal_fourwire_fourwire_construct(

View file

@ -17,6 +17,6 @@
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO17)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO16)
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36)
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35)
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37)
#define CIRCUITPY_BOARD_SPI (2)
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO12, .mosi = &pin_GPIO11}, \
{.clock = &pin_GPIO36, .mosi = &pin_GPIO35, .miso = &pin_GPIO37}}

View file

@ -5,8 +5,10 @@
// SPDX-License-Identifier: MIT
#include "shared-bindings/board/__init__.h"
#include "shared-module/displayio/__init__.h"
CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 1)
static const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
@ -64,11 +66,11 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
// SD Card
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO36)},
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35)},
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO37)},
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO34)},
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO36) },
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35) },
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO37) },
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO34) },
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_sd_spi_obj) },
// Pin 38 is for the SDIO interface, and therefore not included in the SPI object
// LCD
@ -78,6 +80,7 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO9) },
{ MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO8) },
{ MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
};

View file

@ -0,0 +1,78 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT
#include "supervisor/board.h"
#include "mpconfigboard.h"
#include "shared-bindings/busio/SPI.h"
#include "shared-bindings/fourwire/FourWire.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "shared-bindings/board/__init__.h"
#define DELAY 0x80
// display init sequence according to LilyGO example app
uint8_t display_init_sequence[] = {
0x01, DELAY, 0x96, // _SWRESET and Delay 150ms
0x11, DELAY, 0xFF, // _SLPOUT and Delay 500ms
0x3A, DELAY | 1, 0x55, 0x0A, // _COLMOD and Delay 10ms
0x21, DELAY, 0x0A, // _INVON Hack and Delay 10ms
0x13, DELAY, 0x0A, // _NORON and Delay 10ms
0x36, 0x01, 0x60, // _MADCTL
0x29, DELAY, 0xFF, // _DISPON and Delay 500ms
};
void board_init(void) {
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
bus->base.type = &fourwire_fourwire_type;
common_hal_fourwire_fourwire_construct(
bus,
spi,
&pin_GPIO42, // DC
&pin_GPIO45, // CS
&pin_GPIO0, // RST
// 24000000,
40000000, // baudrate
0, // polarity
0 // phase
);
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
display->base.type = &busdisplay_busdisplay_type;
common_hal_busdisplay_busdisplay_construct(
display,
bus,
320, // width (after rotation)
240, // height (after rotation)
0, // column start
0, // row start
0, // rotation
16, // color depth
false, // grayscale
false, // pixels in a byte share a row. Only valid for depths < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
display_init_sequence,
sizeof(display_init_sequence),
&pin_GPIO1, // backlight pin
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness
false, // single_byte_bounds
false, // data_as_commands
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false, // SH1107_addressing
50000 // backlight pwm frequency
);
}

View file

@ -0,0 +1,19 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2025 Neradoc
//
// SPDX-License-Identifier: MIT
#pragma once
#define MICROPY_HW_BOARD_NAME "Waveshare ESP32S3 Touch LCD 2"
#define MICROPY_HW_MCU_NAME "ESP32S3"
#define CIRCUITPY_BOARD_I2C (1)
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO47, .sda = &pin_GPIO48}}
#define CIRCUITPY_BOARD_SPI (1)
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO39, .mosi = &pin_GPIO38, .miso = &pin_GPIO40}}
#define DEFAULT_UART_BUS_RX (&pin_GPIO44)
#define DEFAULT_UART_BUS_TX (&pin_GPIO43)

View file

@ -0,0 +1,14 @@
USB_VID = 0x303A
USB_PID = 0x82CE
USB_MANUFACTURER = "Waveshare Electronics"
USB_PRODUCT = "ESP32S3 Touch LCD 2"
IDF_TARGET = esp32s3
CIRCUITPY_ESP_FLASH_MODE = qio
CIRCUITPY_ESP_FLASH_FREQ = 80m
CIRCUITPY_ESP_FLASH_SIZE = 16MB
CIRCUITPY_ESP_PSRAM_SIZE = 8MB
CIRCUITPY_ESP_PSRAM_MODE = opi
CIRCUITPY_ESP_PSRAM_FREQ = 80m

View file

@ -0,0 +1,94 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT
#include "shared-bindings/board/__init__.h"
#include "shared-module/displayio/__init__.h"
static const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
// User accessible GPIO
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
{ MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) },
{ MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) },
{ MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) },
{ MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) },
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },
{ MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) },
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) },
{ MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) },
{ MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) },
{ MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) },
{ MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) },
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) },
// User button
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) },
{ MP_ROM_QSTR(MP_QSTR_BUTTON0), MP_ROM_PTR(&pin_GPIO0) },
// Battery ADC
{MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO5)},
// I2C
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO47) },
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO48) },
// CST816D Touch
{ MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO46) },
// QMI8658 IMU
{ MP_ROM_QSTR(MP_QSTR_IMU_INT), MP_ROM_PTR(&pin_GPIO3) },
// SPI
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO39) },
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO38) },
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO40) },
// LCD
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO42) },
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO45) },
{ MP_ROM_QSTR(MP_QSTR_LCD_RESET), MP_ROM_PTR(&pin_GPIO0) },
{ MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO1) },
// SD Card slot
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO41) },
// Camera connector
{ MP_ROM_QSTR(MP_QSTR_CAM_HREF), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_CAM_VSYNC), MP_ROM_PTR(&pin_GPIO6) },
{ MP_ROM_QSTR(MP_QSTR_CAM_XCLK), MP_ROM_PTR(&pin_GPIO8) },
{ MP_ROM_QSTR(MP_QSTR_CAM_PCLK), MP_ROM_PTR(&pin_GPIO9) },
{ MP_ROM_QSTR(MP_QSTR_CAM_PWDN), MP_ROM_PTR(&pin_GPIO17) },
{ MP_ROM_QSTR(MP_QSTR_CAM_D0), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_CAM_D1), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_CAM_D2), MP_ROM_PTR(&pin_GPIO15) },
{ MP_ROM_QSTR(MP_QSTR_CAM_D3), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_CAM_D4), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_CAM_D5), MP_ROM_PTR(&pin_GPIO10) },
{ MP_ROM_QSTR(MP_QSTR_CAM_D6), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_CAM_D7), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_TWI_CLK), MP_ROM_PTR(&pin_GPIO16) },
{ MP_ROM_QSTR(MP_QSTR_TWI_SDA), MP_ROM_PTR(&pin_GPIO21) },
// UART
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
// Objects
{ 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_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

View file

@ -13,6 +13,7 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
// On JST PH connector.
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO40) },
// On header
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO41) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO42) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO43) },
@ -27,11 +28,11 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO29) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_GPIO0) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_GPIO4) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON2), MP_ROM_PTR(&pin_GPIO5) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON2), MP_ROM_PTR(&pin_GPIO4) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON3), MP_ROM_PTR(&pin_GPIO5) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO20) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO21) },

View file

@ -111,6 +111,7 @@
#define LWIP_NETIF_EXT_STATUS_CALLBACK 1
#define MDNS_MAX_SECONDARY_HOSTNAMES 1
#define MEMP_NUM_SYS_TIMEOUT (8 + 3 * (LWIP_IPV4 + LWIP_IPV6))
#define MDNS_MAX_SERVICES 25
#endif
#ifndef NDEBUG

View file

@ -16,8 +16,8 @@
//| """C-level helpers for animation of sprites on a stage
//|
//| The `_stage` module contains native code to speed-up the ```stage`` Library
//| <https://github.com/python-ugame/circuitpython-stage>`_."""
//| The `_stage` module contains native code to speed-up the ``stage``
//| `library <https://github.com/python-ugame/circuitpython-stage>`_."""
//|
//|
//| def render(

View file

@ -177,8 +177,10 @@ static void validate_length(aesio_aes_obj_t *self, size_t src_length,
//| """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
//| CTR mode, there are no restrictions."""
//| buffers must be a multiple of 16 bytes, and must be equal length.
//| Any included padding must conform to the required padding style for the given mode.
//| For CTR mode, there are no restrictions.
//| """
//| ...
//|
static mp_obj_t aesio_aes_encrypt_into(mp_obj_t self_in, mp_obj_t src, mp_obj_t dest) {

View file

@ -35,6 +35,12 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) {
//| If the given time is already in the past, then an exception is raised.
//| If the sleep happens after the given time, then it will wake immediately
//| due to this time alarm.
//|
//| Example::
//|
//| # Deep sleep for 30 seconds.
//| time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + 30)
//| alarm.exit_and_deep_sleep_until_alarms(time_alarm)
//| """
//| ...
//|

View file

@ -20,6 +20,9 @@
//|
//| **Limitations:** Not available on Nordic, RP2040, Spresense, as there is no on-chip DAC.
//| On Espressif, available only on ESP32 and ESP32-S2; other chips do not have a DAC.
//| On ESP32-S2 boards, GPIO18 (DAC2) is often connected to a pull-up resistor, which causes
//| `unexpected output values in the lower part of the output range
//| <https://github.com/adafruit/circuitpython/issues/7871>`_.
//|
//| Example usage::
//|

View file

@ -39,6 +39,9 @@
//| bit unpacking. Instead, use an existing driver or make one with
//| :ref:`Register <register-module-reference>` data descriptors.
//|
//| .. seealso:: This class provides an I2C controller, which controls I2C targets (peripherals).
//| To act as an I2C target, use `i2ctarget.I2CTarget`.
//|
//| :param ~microcontroller.Pin scl: The clock pin
//| :param ~microcontroller.Pin sda: The data pin
//| :param int frequency: The clock frequency in Hertz

View file

@ -28,7 +28,7 @@
//| main device. It is typically faster than :py:class:`~bitbangio.I2C` because a
//| separate pin is used to select a device 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
//| `!MOSI`, `!MISO`. It is up to the client to manage the appropriate
//| select line, often abbreviated `!CS` or `!SS`. (This is common because
//| multiple secondaries can share the `!clock`, `!MOSI` and `!MISO` lines
//| and therefore the hardware.)
@ -46,6 +46,8 @@
//| </details>
//| </p>
//|
//| .. seealso:: This class acts as an SPI main (controller).
//| To act as an SPI secondary (target), use `spitarget.SPITarget`.
//| """
//|
//| def __init__(

View file

@ -29,7 +29,8 @@
//| 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."""
//| contain the startup and shutdown sequences at minimum.
//| """
//|
//| def __init__(
//| self,

View file

@ -20,7 +20,11 @@
//| class FourWire:
//| """Manage updating a display over SPI four wire protocol in the background while Python code runs.
//| It doesn't handle display initialization."""
//| It doesn't handle display initialization.
//|
//| .. seealso:: See `busdisplay.BusDisplay` and `epaperdisplay.EPaperDisplay`
//| for how to initialize a display, given a `FourWire` bus.
//| """
//|
//| def __init__(
//| self,

View file

@ -19,7 +19,11 @@
//| class I2CDisplayBus:
//| """Manage updating a display over I2C in the background while Python code runs.
//| It doesn't handle display initialization."""
//| It doesn't handle display initialization.
//|
//| .. seealso:: See `busdisplay.BusDisplay` and `epaperdisplay.EPaperDisplay`
//| for how to initialize a display, given an `I2CDisplayBus`.
//| """
//|
//| def __init__(
//| self,

View file

@ -15,6 +15,12 @@ a list of modules supported on each board.
Modules
---------
.. note:: Some modules are documented in :doc:`/docs/library/index`, not here:
`builtins`, `heapq`, `array`, `binascii`, `collections`, `errno`, `gc`,
`io`, `json`, `re`, `sys`, `select`.
The documentation for :func:`help` is at the end of this page.
.. toctree::
:glob:
:maxdepth: 2

View file

@ -23,7 +23,8 @@
//|
//| def get(self) -> Optional[Event]:
//| """Return the next key transition event. Return ``None`` if no events are pending.
//| """Remove the next key transition event from the `EventQueue` and return it.
//| Return ``None`` if no events are pending.
//|
//| Note that the queue size is limited; see ``max_events`` in the constructor of
//| a scanner such as `Keys` or `KeyMatrix`.
@ -43,7 +44,7 @@ static mp_obj_t keypad_eventqueue_get(mp_obj_t self_in) {
MP_DEFINE_CONST_FUN_OBJ_1(keypad_eventqueue_get_obj, keypad_eventqueue_get);
//| def get_into(self, event: Event) -> bool:
//| """Store the next key transition event in the supplied event, if available,
//| """Remove the next key transition event from the ``EventQueue`, store it in ``event``,
//| and return ``True``.
//| If there are no queued events, do not touch ``event`` and return ``False``.
//|

View file

@ -18,7 +18,11 @@
//| class ParallelBus:
//| """Manage updating a display over 8-bit parallel bus in the background while Python code runs. This
//| protocol may be referred to as 8080-I Series Parallel Interface in datasheets. It doesn't handle
//| display initialization."""
//| display initialization.
//|
//| .. seealso:: See `busdisplay.BusDisplay` and `epaperdisplay.EPaperDisplay`
//| for how to initialize a display, given a `ParallelBus`.
//| """
//|
//| def __init__(
//| self,

View file

@ -42,7 +42,13 @@
//| position = enc.position
//| if last_position == None or position != last_position:
//| print(position)
//| last_position = position"""
//| last_position = position
//|
//| .. warning:: On RP2350 boards, any pulldowns used must be 8.2 kohms or less,
//| to overcome a hardware issue.
//| See the RP2350 warning in `digitalio` for more information.
//| """
//|
//| ...
//|
static mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {

View file

@ -43,7 +43,7 @@ static const uint16_t triangle[] = {0, 32767, 0, -32767};
//| An LFO's ``value`` property is computed once when it is constructed, and then
//| when its associated synthesizer updates it.
//|
//| This means that for instance an LFO **created** with ``offset=1`` has ```value==1``
//| This means that for instance an LFO **created** with ``offset=1`` has ``value==1``
//| immediately, but **updating** the ``offset`` property alone does not
//| change ``value``; it only updates through an association with an active synthesizer.
//|

View file

@ -13,9 +13,11 @@
#define EVENT_PRESSED (1 << 15)
#define EVENT_KEY_NUM_MASK ((1 << 15) - 1)
#define EVENT_SIZE_BYTES (sizeof(uint16_t) + sizeof(mp_obj_t))
void common_hal_keypad_eventqueue_construct(keypad_eventqueue_obj_t *self, size_t max_events) {
// Event queue is 16-bit values.
ringbuf_alloc(&self->encoded_events, max_events * (sizeof(uint16_t) + sizeof(mp_obj_t)));
ringbuf_alloc(&self->encoded_events, max_events * EVENT_SIZE_BYTES);
self->overflowed = false;
self->event_handler = NULL;
}
@ -63,7 +65,7 @@ void common_hal_keypad_eventqueue_clear(keypad_eventqueue_obj_t *self) {
}
size_t common_hal_keypad_eventqueue_get_length(keypad_eventqueue_obj_t *self) {
return ringbuf_num_filled(&self->encoded_events);
return ringbuf_num_filled(&self->encoded_events) / EVENT_SIZE_BYTES;
}
void common_hal_keypad_eventqueue_set_event_handler(keypad_eventqueue_obj_t *self, void (*event_handler)(keypad_eventqueue_obj_t *)) {

View file

@ -19,9 +19,7 @@ size_t common_hal_usb_cdc_serial_read(usb_cdc_serial_obj_t *self, uint8_t *data,
// Read up to len bytes immediately.
// The number of bytes read will not be larger than what is already in the TinyUSB FIFO.
uint32_t total_num_read = 0;
if (tud_cdc_n_connected(self->idx)) {
total_num_read = tud_cdc_n_read(self->idx, data, len);
}
total_num_read = tud_cdc_n_read(self->idx, data, len);
if (wait_forever || wait_for_timeout) {
// Continue filling the buffer past what we already read.
@ -48,9 +46,7 @@ size_t common_hal_usb_cdc_serial_read(usb_cdc_serial_obj_t *self, uint8_t *data,
data += num_read;
// Try to read another batch of bytes.
if (tud_cdc_n_connected(self->idx)) {
num_read = tud_cdc_n_read(self->idx, data, len);
}
num_read = tud_cdc_n_read(self->idx, data, len);
total_num_read += num_read;
}
}

View file

@ -26,8 +26,10 @@
#define LUN_COUNT 1
#endif
static bool ejected[LUN_COUNT];
static bool locked[LUN_COUNT];
// The ellipsis range in the designated initializer of `ejected` is not standard C,
// but it works in both gcc and clang.
static bool ejected[LUN_COUNT] = { [0 ... (LUN_COUNT - 1)] = true};
static bool locked[LUN_COUNT] = {false};
#include "tusb.h"