|
27 | 27 | #include "boards/board.h"
|
28 | 28 | #include "mpconfigboard.h"
|
29 | 29 |
|
| 30 | +#include "shared-bindings/board/__init__.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 "shared-bindings/busio/SPI.h" |
| 35 | + |
| 36 | +#include "supervisor/spi_flash_api.h" |
| 37 | + |
| 38 | +#include "tick.h" |
| 39 | + |
| 40 | +displayio_fourwire_obj_t board_display_obj; |
| 41 | + |
| 42 | +#define DELAY 0x80 |
| 43 | + |
| 44 | +uint8_t display_init_sequence[] = { |
| 45 | + 0x01, 0 | DELAY, 150, // SWRESET |
| 46 | + 0x11, 0 | DELAY, 255, // SLPOUT |
| 47 | + 0xb1, 3, 0x01, 0x2C, 0x2D, // _FRMCTR1 |
| 48 | + 0xb2, 3, 0x01, 0x2C, 0x2D, // |
| 49 | + 0xb3, 6, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D, |
| 50 | + 0xb4, 1, 0x07, // _INVCTR line inversion |
| 51 | + 0xc0, 3, 0xa2, 0x02, 0x84, // _PWCTR1 GVDD = 4.7V, 1.0uA |
| 52 | + 0xc1, 1, 0xc5, // _PWCTR2 VGH=14.7V, VGL=-7.35V |
| 53 | + 0xc2, 2, 0x0a, 0x00, // _PWCTR3 Opamp current small, Boost frequency |
| 54 | + 0xc3, 2, 0x8a, 0x2a, |
| 55 | + 0xc4, 2, 0x8a, 0xee, |
| 56 | + 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V |
| 57 | + 0x20, 0, // _INVOFF //MISMATCh 0x2a vs 0x20 |
| 58 | + 0x36, 1, 0x18, // _MADCTL bottom to top refresh |
| 59 | + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, |
| 60 | + // fix on VTL |
| 61 | + 0x3a, 1, 0x05, // COLMOD - 16bit color |
| 62 | + 0xe0, 0x10, 0x02, 0x1c, 0x07, 0x12, |
| 63 | + 0x37, 0x32, 0x29, 0x2d, |
| 64 | + 0x29, 0x25, 0x2B, 0x39, |
| 65 | + 0x00, 0x01, 0x03, 0x10, // _GMCTRP1 Gamma |
| 66 | + 0xe1, 0x10, 0x03, 0x1d, 0x07, 0x06, |
| 67 | + 0x2E, 0x2C, 0x29, 0x2D, |
| 68 | + 0x2E, 0x2E, 0x37, 0x3F, |
| 69 | + 0x00, 0x00, 0x02, 0x10, // _GMCTRN1 |
| 70 | + 0x13, 0 | DELAY, 10, // _NORON |
| 71 | + 0x29, 0 | DELAY, 100, // _DISPON |
| 72 | +}; |
| 73 | + |
30 | 74 | void board_init(void) {
|
| 75 | + displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; |
| 76 | + bus->base.type = &displayio_fourwire_type; |
| 77 | + busio_spi_obj_t *internal_spi = &spi; |
| 78 | + common_hal_displayio_fourwire_construct(bus, |
| 79 | + internal_spi, |
| 80 | + &pin_PA08, // Command or data |
| 81 | + &pin_PB12, // Chip select |
| 82 | + &pin_PB10, // Reset |
| 83 | + 24000000); |
| 84 | + |
| 85 | + displayio_display_obj_t* display = &displays[0].display; |
| 86 | + display->base.type = &displayio_display_type; |
| 87 | + common_hal_displayio_display_construct(display, |
| 88 | + bus, |
| 89 | + 160, // Width |
| 90 | + 128, // Height |
| 91 | + 0, // column start |
| 92 | + 0, // row start |
| 93 | + 90, // rotation |
| 94 | + 16, // Color depth |
| 95 | + false, // Grayscale |
| 96 | + false, // Pixels in a byte share a row. Only used for depth < 8 |
| 97 | + 1, // bytes per cell. Only valid for depths < 8 |
| 98 | + false, // reverse_pixels_in_byte. Only valid for depths < 8 |
| 99 | + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command |
| 100 | + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command |
| 101 | + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command |
| 102 | + 0x37, // set vertical scroll command |
| 103 | + display_init_sequence, |
| 104 | + sizeof(display_init_sequence), |
| 105 | + &pin_PB03, |
| 106 | + NO_BRIGHTNESS_COMMAND, |
| 107 | + 1.0f, // brightness (ignored) |
| 108 | + true, // auto_brightness |
| 109 | + false, // single_byte_bounds |
| 110 | + false, // data_as_commands |
| 111 | + true, // auto_refresh |
| 112 | + 60); // native_frames_per_second |
31 | 113 | }
|
32 | 114 |
|
33 | 115 | bool board_requests_safe_mode(void) {
|
|
0 commit comments