|
49 | 49 | //| |
50 | 50 | //| .. warning:: This will be changed before 4.0.0. Consider it very experimental. |
51 | 51 | //| |
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) |
54 | 53 | //| |
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 |
56 | 87 | //| |
57 | 88 | 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) { |
58 | 89 | 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 }; |
|
0 commit comments