|
28 | 28 | #include "mpconfigboard.h"
|
29 | 29 | #include "shared-bindings/microcontroller/Pin.h"
|
30 | 30 |
|
| 31 | +#include "shared-bindings/busio/SPI.h" |
| 32 | +#include "shared-bindings/displayio/FourWire.h" |
| 33 | +#include "shared-module/displayio/__init__.h" |
| 34 | +#include "shared-module/displayio/mipi_constants.h" |
| 35 | + |
| 36 | +uint8_t display_init_sequence[] = { |
| 37 | + 0x01, 0x80, 0x96, // _SWRESET and Delay 150ms |
| 38 | + 0x11, 0x80, 0xFF, // _SLPOUT and Delay 500ms |
| 39 | + 0x3A, 0x81, 0x55, 0x0A, // _COLMOD and Delay 10ms |
| 40 | + 0x36, 0x01, 0x08, // _MADCTL |
| 41 | + 0x13, 0x80, 0x0A, // _NORON and Delay 10ms |
| 42 | + 0x36, 0x01, 0xC0, // _MADCTL |
| 43 | + 0x29, 0x80, 0xFF, // _DISPON and Delay 500ms |
| 44 | +}; |
| 45 | + |
31 | 46 | void board_init(void) {
|
| 47 | + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; |
| 48 | + common_hal_busio_spi_construct(spi, &pin_GPIO7, &pin_GPIO6, NULL); |
| 49 | + common_hal_busio_spi_never_reset(spi); |
| 50 | + |
| 51 | + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; |
| 52 | + bus->base.type = &displayio_fourwire_type; |
| 53 | + common_hal_displayio_fourwire_construct(bus, |
| 54 | + spi, |
| 55 | + &pin_GPIO4, // TFT_DC Command or data |
| 56 | + &pin_GPIO5, // TFT_CS Chip select |
| 57 | + &pin_GPIO48, // TFT_RST Reset |
| 58 | + 60000000, // Baudrate |
| 59 | + 0, // Polarity |
| 60 | + 0); // Phase |
| 61 | + |
| 62 | + displayio_display_obj_t *display = &displays[0].display; |
| 63 | + display->base.type = &displayio_display_type; |
| 64 | + common_hal_displayio_display_construct(display, |
| 65 | + bus, |
| 66 | + 320, // Width |
| 67 | + 240, // Height |
| 68 | + 0, // column start |
| 69 | + 0, // row start |
| 70 | + 0, // rotation |
| 71 | + 16, // Color depth |
| 72 | + false, // Grayscale |
| 73 | + false, // pixels in a byte share a row. Only valid for depths < 8 |
| 74 | + 1, // bytes per cell. Only valid for depths < 8 |
| 75 | + false, // reverse_pixels_in_byte. Only valid for depths < 8 |
| 76 | + true, // reverse_pixels_in_word |
| 77 | + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command |
| 78 | + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command |
| 79 | + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command |
| 80 | + display_init_sequence, |
| 81 | + sizeof(display_init_sequence), |
| 82 | + &pin_GPIO45, // backlight pin |
| 83 | + NO_BRIGHTNESS_COMMAND, |
| 84 | + 1.0f, // brightness (ignored) |
| 85 | + true, // auto_brightness |
| 86 | + false, // single_byte_bounds |
| 87 | + false, // data_as_commands |
| 88 | + true, // auto_refresh |
| 89 | + 60, // native_frames_per_second |
| 90 | + true, // backlight_on_high |
| 91 | + false); // SH1107_addressing |
| 92 | + |
32 | 93 | // USB
|
33 | 94 | common_hal_never_reset_pin(&pin_GPIO19);
|
34 | 95 | common_hal_never_reset_pin(&pin_GPIO20);
|
|
0 commit comments