|
28 | 28 | #include "mpconfigboard.h"
|
29 | 29 | #include "hal/include/hal_gpio.h"
|
30 | 30 |
|
| 31 | +#include "shared-bindings/busio/SPI.h" |
| 32 | +#include "shared-bindings/displayio/FourWire.h" |
| 33 | + |
31 | 34 | #include "shared-module/displayio/__init__.h"
|
32 | 35 | #include "shared-module/displayio/mipi_constants.h"
|
33 | 36 |
|
|
36 | 39 | #define DELAY 0x80
|
37 | 40 |
|
38 | 41 | uint8_t display_init_sequence[] = {
|
39 |
| - 0xEF, 3, 0x03, 0x80, 0x02, |
40 |
| - 0xCF, 3, 0x00, 0xC1, 0x30, |
41 |
| - 0xED, 4, 0x64, 0x03, 0x12, 0x81, |
42 |
| - 0xE8, 3, 0x85, 0x00, 0x78, |
43 |
| - 0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02, |
44 |
| - 0xF7, 1, 0x20, |
45 |
| - 0xEA, 2, 0x00, 0x00, |
46 |
| - 0xc0, 1, 0x23, // Power control VRH[5:0] |
47 |
| - 0xc1, 1, 0x10, // Power control SAP[2:0];BT[3:0] |
48 |
| - 0xc5, 2, 0x3e, 0x28, // VCM control |
49 |
| - 0xc7, 1, 0x86, // VCM control2 |
50 |
| - 0x36, 1, 0xa8, // Memory Access Control |
51 |
| - 0x37, 1, 0x00, // Vertical scroll zero |
52 |
| - 0x3a, 1, 0x55, // COLMOD: Pixel Format Set |
53 |
| - 0xb1, 2, 0x00, 0x18, // Frame Rate Control (In Normal Mode/Full Colors) |
54 |
| - 0xb6, 3, 0x08, 0xa2, 0x27, // Display Function Control |
55 |
| - 0xF2, 1, 0x00, // 3Gamma Function Disable |
56 |
| - 0x26, 1, 0x01, // Gamma curve selected |
57 |
| - 0xe0, 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, // Set Gamma |
58 |
| - 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, |
59 |
| - 0xe1, 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, // Set Gamma |
60 |
| - 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, |
61 |
| - 0x11, DELAY, 120, // Exit Sleep |
62 |
| - 0x29, DELAY, 120, // Display on |
| 42 | + 0x01, 2, 0x80, 0x64, // swreset |
| 43 | + 0xB9, 5, 0x83, 0xFF, 0x83, 0x57, 0xFF, |
| 44 | + 0xB3, 5, 0x04, 0x80, 0x00, 0x06, 0x06, |
| 45 | + 0xB6, 2, 0x01, 0x25, |
| 46 | + 0xCC, 2, 0x01, 0x05, |
| 47 | + 0xB1, 7, |
| 48 | + 0x06, 0x00, 0x15, 0x1C, 0x1C, 0x83, 0xAA, |
| 49 | + 0xC0, 7, |
| 50 | + 0x06, 0x50, 0x50, 0x01, 0x3C, 0x1E, 0x08, |
| 51 | + 0xB4, 8, |
| 52 | + 0x07, 0x02, 0x40, 0x00, 0x2A, 0x2A, 0x0D, 0x78, |
| 53 | + 0xE0, 34, |
| 54 | + 0x02, 0x0A, 0x11, 0x1d, 0x23, 0x35, 0x41, 0x4b, 0x4b, |
| 55 | + 0x42, 0x3A, 0x27, 0x1B, 0x08, 0x09, 0x03, 0x02, 0x0A, |
| 56 | + 0x11, 0x1d, 0x23, 0x35, 0x41, 0x4b, 0x4b, 0x42, 0x3A, |
| 57 | + 0x27, 0x1B, 0x08, 0x09, 0x03, 0x00, 0x01, |
| 58 | + 0x3a, 1, 0x55, |
| 59 | + 0x36, 1, 0xC0, |
| 60 | + 0x35, 1, 0x00, |
| 61 | + 0x44, 2, 0x00, 0x02, |
| 62 | + 0x11, 0x80 + 150/5, // Exit Sleep, then delay 150 ms |
| 63 | + 0x29, 0x80 + 50/5 |
63 | 64 | };
|
64 | 65 |
|
65 | 66 | void board_init(void) {
|
66 |
| - displayio_parallelbus_obj_t* bus = &displays[0].parallel_bus; |
67 |
| - bus->base.type = &displayio_parallelbus_type; |
68 |
| - common_hal_displayio_parallelbus_construct(bus, |
69 |
| - &pin_PA16, // Data0 |
70 |
| - &pin_PB05, // Command or data |
71 |
| - &pin_PB06, // Chip select |
72 |
| - &pin_PB09, // Write |
73 |
| - &pin_PB04, // Read |
74 |
| - &pin_PA00); // Reset |
| 67 | + busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; |
| 68 | + common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, &pin_PA14); |
| 69 | + common_hal_busio_spi_never_reset(spi); |
| 70 | + |
| 71 | + displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; |
| 72 | + bus->base.type = &displayio_fourwire_type; |
| 73 | + common_hal_displayio_fourwire_construct(bus, |
| 74 | + spi, |
| 75 | + &pin_PB05, // TFT_DC Command or data |
| 76 | + &pin_PB06, // TFT_CS Chip select |
| 77 | + &pin_PA00, // TFT_RST Reset |
| 78 | + 24000000); |
75 | 79 |
|
76 | 80 | displayio_display_obj_t* display = &displays[0].display;
|
77 | 81 | display->base.type = &displayio_display_type;
|
78 | 82 | common_hal_displayio_display_construct(display,
|
79 | 83 | bus,
|
80 | 84 | 320, // Width
|
81 |
| - 240, // Height |
| 85 | + 480, // Height |
82 | 86 | 0, // column start
|
83 | 87 | 0, // row start
|
84 | 88 | 0, // rotation
|
|
0 commit comments