Skip to content

Commit dc024cf

Browse files
committed
Add a bit more to the docs
1 parent 58a2009 commit dc024cf

4 files changed

Lines changed: 52 additions & 10 deletions

File tree

shared-bindings/displayio/Display.c

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,41 @@
4949
//|
5050
//| .. warning:: This will be changed before 4.0.0. Consider it very experimental.
5151
//|
52-
//| .. class:: Display(display_bus, *, width, height, colstart=0, rowstart=0, color_depth=16,
53-
//| set_column_command=0x2a set_row_command=0x2b, write_ram_command=0x2c)
52+
//| .. class:: Display(display_bus, init_sequence, *, width, height, colstart=0, rowstart=0, color_depth=16, set_column_command=0x2a, set_row_command=0x2b, write_ram_command=0x2c)
5453
//|
55-
//| Create a Display object.
54+
//| Create a Display object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`).
55+
//|
56+
//| The ``init_sequence`` is bitbacked to minimize the ram impact. Every command begins with a
57+
//| command byte followed by a byte to determine the parameter count and if a delay is need after.
58+
//| When the top bit of the second byte is 1, the next byte will be the delay time in milliseconds.
59+
//| The remaining 7 bits are the parameter count excluding any delay byte. The third through final
60+
//| bytes are the remaining command parameters. The next byte will begin a new command definition.
61+
//| Here is a portion of ILI9341 init code:
62+
//|
63+
//| .. code-block:: python
64+
//|
65+
//| init_sequence = (b"\xe1\x0f\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F" # Set Gamma
66+
//| b"\x11\x80\x78"# Exit Sleep then delay 0x78 (120ms)
67+
//| b"\x29\x80\x78"# Display on then delay 0x78 (120ms)
68+
//| )
69+
//| display = displayio.Display(display_bus, init_sequence, width=320, height=240)
70+
//|
71+
//| The first command is 0xe1 with 15 (0xf) parameters following. The second and third are 0x11 and
72+
//| 0x29 respectively with delays (0x80) of 120ms (0x78) and no parameters. Multiple byte literals
73+
//| (b"") are merged together on load. The parens are needed to allow byte literals on subsequent
74+
//| lines.
75+
//|
76+
//| :param displayio.FourWire or displayio.ParallelBus display_bus: The bus that the display is connected to
77+
//| :param buffer init_sequence: Byte-packed initialization sequence.
78+
//| :param int width: Width in pixels
79+
//| :param int height: Height in pixels
80+
//| :param int colstart: The index if the first visible column
81+
//| :param int rowstart: The index if the first visible row
82+
//| :param int color_depth: The number of bits of color per pixel transmitted. (Some displays
83+
//| support 18 bit but 16 is easier to transmit. The last bit is extrapolated.)
84+
//| :param int set_column_command: Command used to set the start and end columns to update
85+
//| :param int set_row_command: Command used so set the start and end rows to update
86+
//| :param int write_ram_command: Command used to write pixels values into the update region
5687
//|
5788
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) {
5889
enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_color_depth, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command };

shared-bindings/displayio/FourWire.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
//|
5353
//| Create a FourWire object associated with the given pins.
5454
//|
55+
//| :param busio.SPI spi_bus: The SPI bus that make up the clock and data lines
56+
//| :param microcontroller.Pin command: Data or command pin
57+
//| :param microcontroller.Pin chip_select: Chip select pin
58+
//| :param microcontroller.Pin reset: Reset pin
59+
//|
5560
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) {
5661
enum { ARG_spi_bus, ARG_command, ARG_chip_select, ARG_reset };
5762
static const mp_arg_t allowed_args[] = {

shared-bindings/displayio/ParallelBus.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
//| .. currentmodule:: displayio
4141
//|
4242
//| :class:`ParallelBus` -- Manage updating a display over SPI four wire protocol
43-
//| ==========================================================================
43+
//| ==============================================================================
4444
//|
4545
//| Manage updating a display over SPI four wire protocol in the background while Python code runs.
4646
//| It doesn't handle display initialization.
@@ -52,6 +52,13 @@
5252
//| Create a ParallelBus object associated with the given pins. The bus is inferred from data0
5353
//| by implying the next 7 additional pins on a given GPIO port.
5454
//|
55+
//| :param microcontroller.Pin: The first data pin. The rest are implied
56+
//| :param microcontroller.Pin command: Data or command pin
57+
//| :param microcontroller.Pin chip_select: Chip select pin
58+
//| :param microcontroller.Pin write: Write pin
59+
//| :param microcontroller.Pin read: Read pin
60+
//| :param microcontroller.Pin reset: Reset pin
61+
//|
5562
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) {
5663
enum { ARG_data0, ARG_command, ARG_chip_select, ARG_write, ARG_read, ARG_reset };
5764
static const mp_arg_t allowed_args[] = {

shared-bindings/displayio/__init__.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,10 @@
4646
//|
4747
//| .. module:: displayio
4848
//| :synopsis: Native helpers for driving displays
49-
//| :platform: SAMD21, SAMD51
49+
//| :platform: SAMD21, SAMD51, nRF52
5050
//|
5151
//| The `displayio` module contains classes to manage display output
52-
//| including synchronizing with refresh rates and partial updating. It does
53-
//| not include display initialization commands. It should live in a Python
54-
//| driver for use when a display is connected to a board. It should also be
55-
//| built into the board init when the board has the display on it.
52+
//| including synchronizing with refresh rates and partial updating.
5653
//|
5754
//| .. warning:: This will be changed before 4.0.0. Consider it very experimental.
5855
//|
@@ -78,7 +75,9 @@
7875

7976
//| .. method:: release_displays()
8077
//|
81-
//| Releases any actively used displays so theis pins can be used again.
78+
//| Releases any actively used displays so their busses and pins can be used again. This will also
79+
//| release the builtin display on boards that have one. You will need to reinitialize it yourself
80+
//| afterwards.
8281
//|
8382
STATIC mp_obj_t displayio_release_displays(void) {
8483
common_hal_displayio_release_displays();

0 commit comments

Comments
 (0)