|
25 | 25 | */
|
26 | 26 |
|
27 | 27 | #include "boards/board.h"
|
| 28 | +#include "mpconfigboard.h" |
| 29 | + |
| 30 | +#include "shared-bindings/busio/SPI.h" |
| 31 | +#include "shared-bindings/displayio/FourWire.h" |
| 32 | +#include "shared-module/displayio/__init__.h" |
| 33 | +#include "shared-module/displayio/mipi_constants.h" |
| 34 | +#include "tick.h" |
| 35 | + |
| 36 | +displayio_fourwire_obj_t board_display_obj; |
| 37 | + |
| 38 | +#define DELAY 0x80 |
| 39 | + |
| 40 | +uint8_t display_init_sequence[] = { |
| 41 | + 0x01, 0 | DELAY, 150, // SWRESET |
| 42 | + 0x11, 0 | DELAY, 255, // SLPOUT |
| 43 | + 0x36, 1, 0x00, // _MADCTL bottom to top refresh in vsync aligned order. |
| 44 | + 0x3a, 1, 0x55, // COLMOD - 16bit color |
| 45 | + 0x21, 0 | DELAY, 10, // _INVON |
| 46 | + 0x13, 0 | DELAY, 10, // _NORON |
| 47 | + 0x29, 0 | DELAY, 255, // _DISPON |
| 48 | +}; |
28 | 49 |
|
29 | 50 | void board_init(void) {
|
| 51 | + busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; |
| 52 | + common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL); |
| 53 | + common_hal_busio_spi_never_reset(spi); |
| 54 | + |
| 55 | + displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; |
| 56 | + bus->base.type = &displayio_fourwire_type; |
| 57 | + common_hal_displayio_fourwire_construct(bus, |
| 58 | + spi, |
| 59 | + &pin_P0_13, // TFT_DC Command or data |
| 60 | + &pin_P0_12, // TFT_CS Chip select |
| 61 | + &pin_P1_03, // TFT_RST Reset |
| 62 | + 60000000); |
| 63 | + |
| 64 | + displayio_display_obj_t* display = &displays[0].display; |
| 65 | + display->base.type = &displayio_display_type; |
| 66 | + common_hal_displayio_display_construct(display, |
| 67 | + bus, |
| 68 | + 240, // Width (after rotation) |
| 69 | + 240, // Height (after rotation) |
| 70 | + 0, // column start |
| 71 | + 0, // row start |
| 72 | + 270, // rotation |
| 73 | + 16, // Color depth |
| 74 | + false, // Grayscale |
| 75 | + false, // Pixels in a byte share a row. Only used for depth < 8 |
| 76 | + 1, // bytes per cell. Only valid for depths < 8 |
| 77 | + false, // reverse_pixels_in_byte. Only valid for depths < 8 |
| 78 | + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command |
| 79 | + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command |
| 80 | + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command |
| 81 | + 0x37, // set vertical scroll command |
| 82 | + display_init_sequence, |
| 83 | + sizeof(display_init_sequence), |
| 84 | + &pin_P1_05, // backlight pin |
| 85 | + NO_BRIGHTNESS_COMMAND, |
| 86 | + 1.0f, // brightness (ignored) |
| 87 | + true, // auto_brightness |
| 88 | + false, // single_byte_bounds |
| 89 | + false, // data_as_commands |
| 90 | + true, // auto_refresh |
| 91 | + 60); // native_frames_per_second |
30 | 92 | }
|
31 | 93 |
|
32 | 94 | bool board_requests_safe_mode(void) {
|
33 |
| - return false; |
| 95 | + return false; |
34 | 96 | }
|
35 | 97 |
|
36 | 98 | void reset_board(void) {
|
|
0 commit comments