26
26
27
27
#include "boards/board.h"
28
28
#include "mpconfigboard.h"
29
+ #include "shared-bindings/busio/SPI.h"
30
+ #include "shared-bindings/displayio/FourWire.h"
29
31
#include "shared-bindings/microcontroller/Pin.h"
32
+ #include "shared-module/displayio/__init__.h"
33
+ #include "supervisor/shared/board.h"
34
+
35
+ #define DELAY 0x80
36
+
37
+ // This is an ILO373 control chip. The display is a 2.9" grayscale EInk.
38
+
39
+ const uint8_t display_start_sequence [] = {
40
+ 0x01 , 5 , 0x03 , 0x00 , 0x2b , 0x2b , 0x13 , // power setting
41
+ 0x06 , 3 , 0x17 , 0x17 , 0x17 , // booster soft start
42
+ 0x04 , DELAY , 200 , // power on and wait 200 ms
43
+ 0x00 , 1 , 0x7f , // panel setting
44
+ 0x50 , 1 , 0x97 , // CDI setting
45
+ 0x30 , 1 , 0x3c , // PLL set to 50 Hx (M = 7, N = 4)
46
+ 0x61 , 3 , 0x80 , 0x01 , 0x28 , // Resolution
47
+ 0x82 , DELAY | 1 , 0x12 , 50 , // VCM DC and delay 50ms
48
+
49
+ // Look up tables for voltage sequence for pixel transition
50
+ // Common voltage
51
+ 0x20 , 0x2a ,
52
+ 0x00 , 0x0a , 0x00 , 0x00 , 0x00 , 0x01 ,
53
+ 0x60 , 0x14 , 0x14 , 0x00 , 0x00 , 0x01 ,
54
+ 0x00 , 0x14 , 0x00 , 0x00 , 0x00 , 0x01 ,
55
+ 0x00 , 0x13 , 0x0a , 0x01 , 0x00 , 0x01 ,
56
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
57
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
58
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
59
+
60
+ // White to white
61
+ 0x21 , 0x2a ,
62
+ 0x40 , 0x0a , 0x00 , 0x00 , 0x00 , 0x01 ,
63
+ 0x90 , 0x14 , 0x14 , 0x00 , 0x00 , 0x01 ,
64
+ 0x10 , 0x14 , 0x0a , 0x00 , 0x00 , 0x01 ,
65
+ 0xa0 , 0x13 , 0x01 , 0x00 , 0x00 , 0x01 ,
66
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
67
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
68
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
69
+
70
+ // Black to white
71
+ 0x22 , 0x2a ,
72
+ 0x40 , 0x0a , 0x00 , 0x00 , 0x00 , 0x01 ,
73
+ 0x90 , 0x14 , 0x14 , 0x00 , 0x00 , 0x01 ,
74
+ 0x00 , 0x14 , 0x0a , 0x00 , 0x00 , 0x01 ,
75
+ 0x99 , 0x0c , 0x01 , 0x03 , 0x04 , 0x01 ,
76
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
77
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
78
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
79
+
80
+ // White to black
81
+ 0x23 , 0x2a ,
82
+ 0x40 , 0x0a , 0x00 , 0x00 , 0x00 , 0x01 ,
83
+ 0x90 , 0x14 , 0x14 , 0x00 , 0x00 , 0x01 ,
84
+ 0x00 , 0x14 , 0x0a , 0x00 , 0x00 , 0x01 ,
85
+ 0x99 , 0x0b , 0x04 , 0x04 , 0x01 , 0x01 ,
86
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
87
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
88
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
89
+
90
+ // Black to black
91
+ 0x24 , 0x2a ,
92
+ 0x80 , 0x0a , 0x00 , 0x00 , 0x00 , 0x01 ,
93
+ 0x90 , 0x14 , 0x14 , 0x00 , 0x00 , 0x01 ,
94
+ 0x20 , 0x14 , 0x0a , 0x00 , 0x00 , 0x01 ,
95
+ 0x50 , 0x13 , 0x01 , 0x00 , 0x00 , 0x01 ,
96
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
97
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
98
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
99
+ };
100
+
101
+ const uint8_t display_stop_sequence [] = {
102
+ 0x50 , 0x01 , 0x17 , // CDI Setting
103
+ 0x82 , 0x01 , 0x00 , // VCM DC to -0.1V
104
+ 0x02 , 0x00 // Power off
105
+ };
30
106
31
107
void board_init (void ) {
32
108
// USB
@@ -36,6 +112,52 @@ void board_init(void) {
36
112
// Debug UART
37
113
common_hal_never_reset_pin (& pin_GPIO43 );
38
114
common_hal_never_reset_pin (& pin_GPIO44 );
115
+
116
+ busio_spi_obj_t * spi = & displays [0 ].fourwire_bus .inline_bus ;
117
+ common_hal_busio_spi_construct (spi , & pin_GPIO36 , & pin_GPIO35 , NULL );
118
+ common_hal_busio_spi_never_reset (spi );
119
+
120
+ displayio_fourwire_obj_t * bus = & displays [0 ].fourwire_bus ;
121
+ bus -> base .type = & displayio_fourwire_type ;
122
+ common_hal_displayio_fourwire_construct (bus ,
123
+ spi ,
124
+ & pin_GPIO7 , // EPD_DC Command or data
125
+ & pin_GPIO8 , // EPD_CS Chip select
126
+ & pin_GPIO6 , // EPD_RST Reset
127
+ 4000000 , // Baudrate
128
+ 0 , // Polarity
129
+ 0 ); // Phase
130
+
131
+ displayio_epaperdisplay_obj_t * display = & displays [0 ].epaper_display ;
132
+ display -> base .type = & displayio_epaperdisplay_type ;
133
+ common_hal_displayio_epaperdisplay_construct (
134
+ display ,
135
+ bus ,
136
+ display_start_sequence , sizeof (display_start_sequence ),
137
+ display_stop_sequence , sizeof (display_stop_sequence ),
138
+ 296 , // width
139
+ 128 , // height
140
+ 160 , // ram_width
141
+ 296 , // ram_height
142
+ 0 , // colstart
143
+ 0 , // rowstart
144
+ 270 , // rotation
145
+ NO_COMMAND , // set_column_window_command
146
+ NO_COMMAND , // set_row_window_command
147
+ NO_COMMAND , // set_current_column_command
148
+ NO_COMMAND , // set_current_row_command
149
+ 0x10 , // write_black_ram_command
150
+ false, // black_bits_inverted
151
+ 0x13 , // write_color_ram_command
152
+ false, // color_bits_inverted
153
+ 0x000000 , // highlight_color
154
+ 0x12 , // refresh_display_command
155
+ 1.0 , // refresh_time
156
+ & pin_GPIO5 , // busy_pin
157
+ false, // busy_state
158
+ 5.0 , // seconds_per_frame
159
+ false, // always_toggle_chip_select
160
+ true); // grayscale
39
161
}
40
162
41
163
bool board_requests_safe_mode (void ) {
0 commit comments