Skip to content

Allow setting of CIRCUITPY_DISPLAY_LIMIT in settings.toml #10214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,27 @@ Example: Configure the display to 640x480 black and white (1 bit per pixel):
`Adafruit Feather RP2350 <https://circuitpython.org/board/adafruit_feather_rp2350/>`_
`Adafruit Metro RP2350 <https://circuitpython.org/board/adafruit_metro_rp2350/>`_

CIRCUITPY_DISPLAY_LIMIT
~~~~~~~~~~~~~~~~~~~~~~~
Set the maximum supported number of displayio displays. This value overrides the
CIRCUITPY_DISPLAY_LIMIT compile-time flag defined in mpconfigport.h.
It specifies the maximum number of active display objects that can be supported simultaneously
on a CircuitPython board.

By default, the value of CIRCUITPY_DISPLAY_LIMIT is set to 1 for most boards, meaning only
one display can be active at a time. Users can modify this value by adding a settings.toml entry
to support additional displays.

The value of CIRCUITPY_DISPLAY_LIMIT should be set to a value that is supported by the
hardware and does not exceed the available memory and resources on the board. Setting the
value too high may result in unexpected behavior or crashes.

Example: Set the maximum supported number of displayio displays to 2:

.. code-block::

CIRCUITPY_DISPLAY_LIMIT=2

CIRCUITPY_TERMINAL_SCALE
~~~~~~~~~~~~~~~~~~~~~~~~
Allows the entry of a display scaling factor used during the terminalio console construction.
Expand Down
1 change: 1 addition & 0 deletions ports/atmel-samd/mpconfigport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CIRCUITPY_LTO = 1

CIRCUITPY_KEYPAD_DEMUX ?= 0
CIRCUITPY_LVFONTIO ?= 0
CIRCUITPY_SET_DISPLAY_LIMIT ?= 0

######################################################################
# Put samd21-only choices here.
Expand Down
1 change: 1 addition & 0 deletions ports/stm/boards/stm32f411ve_discovery/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ CIRCUITPY_BLEIO_HCI = 0
CIRCUITPY_CODEOP = 0
CIRCUITPY_MSGPACK = 0
CIRCUITPY_VECTORIO = 0
CIRCUITPY_SET_DISPLAY_LIMIT = 0
3 changes: 3 additions & 0 deletions py/circuitpy_mpconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO)
CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO)

CIRCUITPY_SET_DISPLAY_LIMIT ?= $(CIRCUITPY_DISPLAYIO)
CFLAGS += -DCIRCUITPY_SET_DISPLAY_LIMIT=$(CIRCUITPY_SET_DISPLAY_LIMIT)

CIRCUITPY_BUSDISPLAY ?= $(CIRCUITPY_DISPLAYIO)
CFLAGS += -DCIRCUITPY_BUSDISPLAY=$(CIRCUITPY_BUSDISPLAY)

Expand Down
26 changes: 19 additions & 7 deletions shared-module/board/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "mpconfigboard.h"
#include "py/runtime.h"

#if CIRCUITPY_OS_GETENV && CIRCUITPY_SET_DISPLAY_LIMIT
#include "shared-module/os/__init__.h"
#endif

#if CIRCUITPY_BUSIO
#include "shared-bindings/busio/I2C.h"
#include "shared-bindings/busio/SPI.h"
Expand Down Expand Up @@ -172,12 +176,20 @@ mp_obj_t common_hal_board_create_uart(const mp_int_t instance) {
#endif

void reset_board_buses(void) {
#if (CIRCUITPY_BOARD_I2C && CIRCUITPY_I2CDISPLAYBUS) || (CIRCUITPY_BOARD_SPI && (CIRCUITPY_FOURWIRE || CIRCUITPY_SHARPDISPLAY || CIRCUITPY_AURORA_EPAPER))
#if CIRCUITPY_OS_GETENV && CIRCUITPY_SET_DISPLAY_LIMIT
#define DYN_DISPLAY_BUSES(indx) (indx < CIRCUITPY_DISPLAY_LIMIT ? display_buses[indx] : display_buses_dyn[indx - CIRCUITPY_DISPLAY_LIMIT])
#else
#define DYN_DISPLAY_BUSES(indx) (display_buses[indx])
#endif
#endif

#if CIRCUITPY_BOARD_I2C
for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_I2C; instance++) {
bool display_using_i2c = false;
#if CIRCUITPY_I2CDISPLAYBUS
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
if (display_buses[i].bus_base.type == &i2cdisplaybus_i2cdisplaybus_type && display_buses[i].i2cdisplay_bus.bus == &i2c_obj[instance]) {
for (uint8_t i = 0; i < max_allocated_display; i++) {
if (DYN_DISPLAY_BUSES(i).bus_base.type == &i2cdisplaybus_i2cdisplaybus_type && DYN_DISPLAY_BUSES(i).i2cdisplay_bus.bus == &i2c_obj[instance]) {
display_using_i2c = true;
break;
}
Expand All @@ -197,22 +209,22 @@ void reset_board_buses(void) {
for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_SPI; instance++) {
bool display_using_spi = false;
#if CIRCUITPY_FOURWIRE || CIRCUITPY_SHARPDISPLAY || CIRCUITPY_AURORA_EPAPER
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
mp_const_obj_t bus_type = display_buses[i].bus_base.type;
for (uint8_t i = 0; i < max_allocated_display; i++) {
mp_const_obj_t bus_type = DYN_DISPLAY_BUSES(i).bus_base.type;
#if CIRCUITPY_FOURWIRE
if (bus_type == &fourwire_fourwire_type && display_buses[i].fourwire_bus.bus == &spi_obj[instance]) {
if (bus_type == &fourwire_fourwire_type && DYN_DISPLAY_BUSES(i).fourwire_bus.bus == &spi_obj[instance]) {
display_using_spi = true;
break;
}
#endif
#if CIRCUITPY_SHARPDISPLAY
if (bus_type == &sharpdisplay_framebuffer_type && display_buses[i].sharpdisplay.bus == &spi_obj[instance]) {
if (bus_type == &sharpdisplay_framebuffer_type && DYN_DISPLAY_BUSES(i).sharpdisplay.bus == &spi_obj[instance]) {
display_using_spi = true;
break;
}
#endif
#if CIRCUITPY_AURORA_EPAPER
if (bus_type == &aurora_epaper_framebuffer_type && display_buses[i].aurora_epaper.bus == &spi_obj[instance]) {
if (bus_type == &aurora_epaper_framebuffer_type && DYN_DISPLAY_BUSES(i).aurora_epaper.bus == &spi_obj[instance]) {
display_using_spi = true;
break;
}
Expand Down
Loading