25
25
*/
26
26
27
27
#include "supervisor/board.h"
28
+ #include "mpconfigboard.h"
29
+ #include "shared-bindings/busio/SPI.h"
30
+ #include "shared-bindings/displayio/FourWire.h"
31
+ #include "shared-module/displayio/__init__.h"
32
+ #include "shared-module/displayio/mipi_constants.h"
33
+ #include "supervisor/shared/board.h"
34
+
35
+ displayio_fourwire_obj_t board_display_obj ;
36
+
37
+ #define DELAY 0x80
38
+
39
+ uint8_t display_init_sequence [] = {
40
+ 0x01 , 0 | DELAY , 150 , // SWRESET
41
+
42
+ 0x36 , 1 , 0x04 , // MADCTL
43
+ 0x35 , 1 , 0x00 , // TEON
44
+ 0xB2 , 5 , 0x0c , 0x0c , 0x00 , 0x33 , 0x33 , // FRMCTR2
45
+ 0x3A , 1 , 0x05 , // COLMOD
46
+ 0xB7 , 1 , 0x14 , // GCTRL
47
+ 0xBB , 1 , 0x37 , // VCOMS
48
+ 0xC0 , 1 , 0x2c , // LCMCTRL
49
+ 0xC2 , 1 , 0x01 , // VDVVRHEN
50
+ 0xC3 , 1 , 0x12 , // VRHS
51
+ 0xC4 , 1 , 0x20 , // VDVS
52
+ 0xD0 , 2 , 0xa4 , 0xa1 , // PWRCTRL1
53
+ 0xC6 , 1 , 0x0f , // FRCTRL2
54
+ 0xE0 , 14 , 0xd0 , 0x04 , 0x0d , 0x11 , 0x13 , 0x2b , 0x3f , 0x54 , 0x4c , 0x18 , 0x0d , 0x0b , 0x1f , 0x23 , // GMCTRP1
55
+ 0xE1 , 14 , 0xd0 , 0x04 , 0x0c , 0x11 , 0x13 , 0x2c , 0x3f , 0x44 , 0x51 , 0x2f , 0x1f , 0x1f , 0x20 , 0x23 , // GMCTRN1
56
+ 0x21 , 0 , // INVON
57
+
58
+ 0x11 , 0 | DELAY , 255 , // SLPOUT
59
+ 0x29 , 0 | DELAY , 100 , // DISPON
60
+
61
+ 0x2a , 4 , 0x00 , 0 , 0x00 , 0xfe , // CASET
62
+ 0x2b , 4 , 0x00 , 0 , 0x00 , 0xfe , // RASET
63
+ 0x2c , 0 , // RAMWR
64
+ };
28
65
29
66
void board_init (void ) {
67
+ busio_spi_obj_t * spi = & displays [0 ].fourwire_bus .inline_bus ;
68
+ common_hal_busio_spi_construct (spi , & pin_GPIO6 , & pin_GPIO7 , NULL );
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_GPIO9 , // TFT_DC Command or data
76
+ & pin_GPIO5 , // TFT_CS Chip select
77
+ & pin_GPIO4 , // TFT_RST Reset
78
+ 60000000 , // Baudrate
79
+ 0 , // Polarity
80
+ 0 ); // Phase
81
+
82
+ displayio_display_obj_t * display = & displays [0 ].display ;
83
+ display -> base .type = & displayio_display_type ;
84
+ common_hal_displayio_display_construct (display ,
85
+ bus ,
86
+ 240 , // Width
87
+ 240 , // Height
88
+ 0 , // column start
89
+ 0 , // row start
90
+ 0 , // rotation
91
+ 16 , // Color depth
92
+ false, // Grayscale
93
+ false, // pixels in a byte share a row. Only valid for depths < 8
94
+ 1 , // bytes per cell. Only valid for depths < 8
95
+ false, // reverse_pixels_in_byte. Only valid for depths < 8
96
+ true, // reverse_bytes_in_word
97
+ MIPI_COMMAND_SET_COLUMN_ADDRESS , // Set column command
98
+ MIPI_COMMAND_SET_PAGE_ADDRESS , // Set row command
99
+ MIPI_COMMAND_WRITE_MEMORY_START , // Write memory command
100
+ display_init_sequence ,
101
+ sizeof (display_init_sequence ),
102
+ & pin_GPIO12 , // backlight pin
103
+ NO_BRIGHTNESS_COMMAND ,
104
+ 1.0f , // brightness (ignored)
105
+ true, // auto_brightness
106
+ false, // single_byte_bounds
107
+ false, // data_as_commands
108
+ true, // auto_refresh
109
+ 60 , // native_frames_per_second
110
+ true, // backlight_on_high
111
+ false); // SH1107_addressing
112
+ }
113
+
114
+ void board_deinit (void ) {
30
115
}
31
116
32
117
bool board_requests_safe_mode (void ) {
@@ -35,6 +120,3 @@ bool board_requests_safe_mode(void) {
35
120
36
121
void reset_board (void ) {
37
122
}
38
-
39
- void board_deinit (void ) {
40
- }
0 commit comments