Mercurial > public > ostc4
annotate Discovery/Src/display.c @ 877:a0900e4df15c Evo_2_23
DevBugfix: Exit condition deco_stop_depth
deco_stop_depth is defined as float but handled like an integer. During code cleanup this was not considered for the break condition of the VPM calculation loop causing an endless loop condition. The legacy format has been restored in the updated version.
author | Ideenmodellierer |
---|---|
date | Tue, 20 Aug 2024 15:18:43 +0200 |
parents | e373e90a48db |
children | 6b06143cbfea |
rev | line source |
---|---|
38 | 1 |
2 #include "stm32f4xx_hal.h" /* for HAL_Delay() */ | |
3 #include "ostc.h" | |
4 #include "display.h" | |
5 | |
871 | 6 #define TFT_ENABLE_EXTENDED_COMMANDS 0xB9 |
7 #define TFT_SET_POWER 0xB1 | |
8 #define TFT_SLEEP_OUT 0x11 | |
9 #define TFT_DISPLAY_INVERSION_OFF 0x20 | |
10 #define TFT_MEMORY_ACCESS_ONTROL 0x36 | |
11 #define TFT_INTERFACE_PIXEL_FORMAT 0x3A | |
12 #define TFT_SET_RGB_INTERFACE_RELATED 0xB3 | |
13 #define TFT_SET_DISPLAY_WAVEFORM 0xB4 | |
14 #define TFT_SET_PANEL 0xCC | |
15 #define TFT_SET_GAMMA_CURVE_RELATED 0xE0 | |
16 #define TFT_DISPLAY_ON 0x29 | |
17 #define TFT_DISPLAY_OFF 0x28 | |
18 #define TFT_SLEEP_IN 0x10 | |
38 | 19 |
871 | 20 #define OLED_SCTE_SET_31h 0x31 // 0x0008 |
21 #define OLED_WCWE_SET_32h 0x32 // 0x0014 | |
22 #define OLED_GATELESS1_30h 0x30 // 0x0002 | |
23 #define OLED_GATELESS2_27h 0x27 // 0x0000 | |
24 #define OLED_OSCILLATOR 0x11 // 0x00A1 | |
25 #define OLED_VBP_SET_12h 0x12 // 0x0008 | |
26 #define OLED_VFP_SET_13h 0x13 // 0x0008 | |
27 #define OLED_DISPLAY_CON_15h 0x15 // 0x0000 | |
28 #define OLED_COLOR_DEPTH_SET_16h 0x16 // 0x0000 | |
29 #define OLED_PENTILE_KEY_EFh 0xEF // 0x00D0 or 0x00E8 | |
30 #define OLED_PENTILE1_A0h 0xA0 // 0x0063 | |
31 #define OLED_PENTILE2_A1h 0xA1 // 0x00C0 | |
32 #define OLED_PENTILE3_A2h 0xA2 // 0x0032 | |
33 #define OLED_PENTILE4_A3h 0xA3 // 0x0002 | |
34 #define OLED_BRIGHTNESS_CTRL_39h 0x39 // 0044h | |
35 // gamma table 0x40 - 0x66 | |
36 #define OLED_BOOSTING_FREQ 0x17 // 0x0022 | |
37 #define OLED_AMP_SET_18h 0x18 // 0x0033 | |
38 #define OLED_GAMMA_AMP_19h 0x19 // 0x0003 | |
39 #define OLED_POWER_CONTROL2_1Ah 0x1A // 0x0001 | |
40 #define OLED_POWER_CONTROL2_1Bh 0x1B // | |
41 #define OLED_POWER_CONTROL2_1Ch 0x1C // | |
42 #define OLED_INTERNAL_LOGIC_VOLTAGE 0x22 // VCC*0,65 = 3,3V * 0,55 = 0x00A2 | |
43 #define OLED_POWER_SET 0x23 // VC1OUT = VCI X 0.98 (default) = 0x00 | |
44 #define OLED_POWER_SET2 0x24 // VREG2OUT = 5,4V, VREG1OUT = 4,2V =0x77 | |
45 #define OLED_DISPLAY_CONDITION_SET_26h 0x26 // 0x00A0 | |
46 #define OLED_STB_BY_OFF 0x1D // 00A0 + 300ms wait | |
47 #define OLED_DDISP_ON 0x14 // 0003 | |
38 | 48 |
49 static void Display_Error_Handler(void); | |
871 | 50 static void display_power_on__2_of_2__post_RGB_display0(void); |
51 static void display_power_on__2_of_2__post_RGB_display1(void); | |
52 static uint8_t receive_screen(); | |
38 | 53 |
54 void display_power_on__1_of_2__pre_RGB(void) | |
55 { | |
871 | 56 uint8_t aTxBuffer[3]; |
57 /* reset system */ | |
38 | 58 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select |
59 | |
60 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET); | |
61 HAL_Delay(10); | |
62 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET); | |
871 | 63 HAL_Delay(25); |
64 // check for new screen | |
65 hardwareDisplay=0; // default is old screen | |
66 aTxBuffer[0] = 0x71; // Read internal register | |
67 if (receive_screen((uint8_t*)aTxBuffer) == 0x27) // chip Index (=0x27 for new screen) | |
68 { | |
69 hardwareDisplay=1; | |
70 } | |
873 | 71 else |
72 { // re-reset the screen to be sure the 0x71 command did nothing | |
73 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET); | |
74 HAL_Delay(10); | |
75 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET); | |
76 HAL_Delay(25); | |
77 | |
78 } | |
38 | 79 |
80 /* RGB signals should be now for 2 frames or more (datasheet) */ | |
81 } | |
82 | |
83 | |
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
84 static void send(uint8_t *pData, uint16_t inputlength) |
38 | 85 { |
86 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_RESET); // chip select | |
87 | |
88 if(HAL_SPI_Transmit(&hspiDisplay,(uint8_t*)pData, inputlength, 10000) != HAL_OK) | |
89 Display_Error_Handler(); | |
90 | |
91 while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY) | |
92 { | |
93 } | |
94 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select | |
95 } | |
96 | |
871 | 97 static uint8_t receive_screen(uint8_t *pData) |
98 { | |
99 uint8_t byte; | |
100 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_RESET); // chip select | |
101 if(HAL_SPI_Transmit(&hspiDisplay,(uint8_t*)pData, 1, 10000) != HAL_OK) | |
102 Display_Error_Handler(); | |
103 while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY) | |
104 { | |
105 } | |
106 if(HAL_SPI_Receive(&hspiDisplay, &byte, 1, 10000) != HAL_OK) | |
107 Display_Error_Handler(); | |
108 while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY) | |
109 { | |
110 } | |
111 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select | |
112 return byte; | |
113 } | |
114 | |
38 | 115 |
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
116 static uint16_t convert8to9to8(uint8_t *pInput, uint8_t *pOutput,uint16_t inputlength) |
38 | 117 { |
118 uint16_t outputlength; | |
119 uint8_t readbit = 0x80;//0b1000000; | |
120 uint8_t writebit = 0x40;//0b0100000; | |
121 uint16_t i,j,k; | |
122 | |
123 outputlength = ((inputlength+7)/8)*9; | |
124 | |
125 for(i=0;i<outputlength;i++) | |
126 pOutput[i] = 0; | |
127 | |
128 k = 0; | |
129 for(i=0;i<inputlength;i++) | |
130 { | |
131 if(i != 0) | |
132 { | |
133 pOutput[k] |= writebit; // 9. bit | |
134 writebit = writebit >> 1; | |
135 if(writebit == 0) | |
136 { | |
137 writebit = 0x80; | |
138 k++; | |
139 } | |
140 } | |
141 for(j=0;j<8;j++) | |
142 { | |
143 if((pInput[i] & readbit) != 0) | |
144 { | |
145 pOutput[k] |= writebit; | |
146 } | |
147 readbit = readbit >> 1; | |
148 if(readbit == 0) | |
149 readbit = 0x80; | |
150 writebit = writebit >> 1; | |
151 if(writebit == 0) | |
152 { | |
153 writebit = 0x80; | |
154 k++; | |
155 } | |
156 } | |
157 } | |
158 return outputlength; | |
159 } | |
160 | |
161 void display_power_on__2_of_2__post_RGB(void) | |
162 { | |
871 | 163 if (hardwareDisplay == 1) |
164 { | |
165 display_power_on__2_of_2__post_RGB_display1(); | |
166 } | |
167 else | |
168 { | |
169 display_power_on__2_of_2__post_RGB_display0(); | |
170 } | |
171 } | |
172 | |
173 void display_power_on__2_of_2__post_RGB_display0(void) | |
174 { | |
175 | |
38 | 176 uint8_t aTxBuffer[32]; |
177 uint8_t bTxBuffer[36]; | |
178 uint16_t i,length; | |
179 | |
180 for(i=0;i<32;i++) | |
181 aTxBuffer[i] = 0; | |
182 for(i=0;i<36;i++) | |
183 bTxBuffer[i] = 0; | |
184 | |
871 | 185 aTxBuffer[0] = TFT_ENABLE_EXTENDED_COMMANDS; |
38 | 186 aTxBuffer[1] = 0xFF; |
187 aTxBuffer[2] = 0x83; | |
188 aTxBuffer[3] = 0x63; | |
189 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,4); | |
190 send((uint8_t*)bTxBuffer, length); | |
191 | |
871 | 192 aTxBuffer[0] = TFT_SET_POWER; |
38 | 193 aTxBuffer[1] = 0x81; |
194 aTxBuffer[2] = 0x24; | |
195 aTxBuffer[3] = 0x04; | |
196 aTxBuffer[4] = 0x02; | |
197 aTxBuffer[5] = 0x02; | |
198 aTxBuffer[6] = 0x03; | |
199 aTxBuffer[7] = 0x10; | |
200 aTxBuffer[8] = 0x10; | |
201 aTxBuffer[9] = 0x34; | |
202 aTxBuffer[10] = 0x3C; | |
203 aTxBuffer[11] = 0x3F; | |
204 aTxBuffer[12] = 0x3F; | |
205 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13); | |
206 send((uint8_t*)bTxBuffer, length); | |
207 | |
871 | 208 aTxBuffer[0] = TFT_SLEEP_OUT; |
38 | 209 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); |
210 send((uint8_t*)bTxBuffer, length); | |
211 HAL_Delay(5+1); | |
212 | |
871 | 213 aTxBuffer[0] = TFT_DISPLAY_INVERSION_OFF; |
38 | 214 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); |
215 send((uint8_t*)bTxBuffer, length); | |
216 | |
871 | 217 aTxBuffer[0] = TFT_MEMORY_ACCESS_ONTROL; |
38 | 218 aTxBuffer[1] = 0x00; |
219 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); | |
220 send((uint8_t*)bTxBuffer, length); | |
221 | |
871 | 222 aTxBuffer[0] = TFT_INTERFACE_PIXEL_FORMAT; |
38 | 223 aTxBuffer[1] = 0x70; |
224 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); | |
225 send((uint8_t*)bTxBuffer, length); | |
226 HAL_Delay(120+20); | |
227 | |
871 | 228 aTxBuffer[0] = TFT_SET_POWER; |
38 | 229 aTxBuffer[1] = 0x78; |
230 aTxBuffer[2] = 0x24; | |
231 aTxBuffer[3] = 0x04, | |
232 aTxBuffer[4] = 0x02; | |
233 aTxBuffer[5] = 0x02; | |
234 aTxBuffer[6] = 0x03; | |
235 aTxBuffer[7] = 0x10; | |
236 aTxBuffer[8] = 0x10; | |
237 aTxBuffer[9] = 0x34; | |
238 aTxBuffer[10] = 0x3C; | |
239 aTxBuffer[11] = 0x3F; | |
240 aTxBuffer[12] = 0x3F; | |
241 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13); | |
242 send((uint8_t*)bTxBuffer, length); | |
243 | |
871 | 244 aTxBuffer[0] = TFT_SET_RGB_INTERFACE_RELATED; |
38 | 245 aTxBuffer[1] = 0x01; |
246 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); | |
247 send((uint8_t*)bTxBuffer, length); | |
248 | |
871 | 249 aTxBuffer[0] = TFT_SET_DISPLAY_WAVEFORM; |
38 | 250 aTxBuffer[1] = 0x00; |
251 aTxBuffer[2] = 0x08; | |
252 aTxBuffer[3] = 0x56; | |
253 aTxBuffer[4] = 0x07; | |
254 aTxBuffer[5] = 0x01; | |
255 aTxBuffer[6] = 0x01; | |
256 aTxBuffer[7] = 0x4D; | |
257 aTxBuffer[8] = 0x01; | |
258 aTxBuffer[9] = 0x42; | |
259 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,10); | |
260 send((uint8_t*)bTxBuffer, length); | |
261 | |
871 | 262 aTxBuffer[0] = TFT_SET_PANEL; |
38 | 263 aTxBuffer[1] = 0x0B; |
264 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); | |
265 send((uint8_t*)bTxBuffer, length); | |
266 | |
871 | 267 aTxBuffer[0] = TFT_SET_GAMMA_CURVE_RELATED; |
38 | 268 aTxBuffer[1] = 0x01; |
269 aTxBuffer[2] = 0x48; | |
270 aTxBuffer[3] = 0x4D; | |
271 aTxBuffer[4] = 0x4E; | |
272 aTxBuffer[5] = 0x58; | |
273 aTxBuffer[6] = 0xF6; | |
274 aTxBuffer[7] = 0x0B; | |
275 aTxBuffer[8] = 0x4E; | |
276 aTxBuffer[9] = 0x12; | |
277 aTxBuffer[10] = 0xD5; | |
278 aTxBuffer[11] = 0x15; | |
279 aTxBuffer[12] = 0x95; | |
280 aTxBuffer[13] = 0x55; | |
281 aTxBuffer[14] = 0x8E; | |
282 aTxBuffer[15] = 0x11; | |
283 aTxBuffer[16] = 0x01; | |
284 aTxBuffer[17] = 0x48; | |
285 aTxBuffer[18] = 0x4D; | |
286 aTxBuffer[19] = 0x55; | |
287 aTxBuffer[20] = 0x5F; | |
288 aTxBuffer[21] = 0xFD; | |
289 aTxBuffer[22] = 0x0A; | |
290 aTxBuffer[23] = 0x4E; | |
291 aTxBuffer[24] = 0x51; | |
292 aTxBuffer[25] = 0xD3; | |
293 aTxBuffer[26] = 0x17; | |
294 aTxBuffer[27] = 0x95; | |
295 aTxBuffer[28] = 0x96; | |
296 aTxBuffer[29] = 0x4E; | |
297 aTxBuffer[30] = 0x11; | |
298 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,31); | |
299 send((uint8_t*)bTxBuffer, length); | |
300 HAL_Delay(5+1); | |
301 | |
871 | 302 aTxBuffer[0] = TFT_DISPLAY_ON; |
38 | 303 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); |
304 send((uint8_t*)bTxBuffer, length); | |
305 } | |
306 | |
307 | |
871 | 308 void display_power_on__2_of_2__post_RGB_display1(void) |
309 { | |
310 uint8_t aTxBuffer[3]; | |
311 | |
312 aTxBuffer[0] = 0x71; // Read chip Index & revision number | |
313 aTxBuffer[1] = 0x00; // Dummy write - reads out 0x27 | |
314 aTxBuffer[1] = 0x00; // Dummy write - reads out 0x96 | |
315 send((uint8_t*)aTxBuffer, 3); | |
316 | |
317 aTxBuffer[0] = 0x70; | |
318 aTxBuffer[1] = OLED_OSCILLATOR; | |
319 send((uint8_t*)aTxBuffer, 2); | |
320 aTxBuffer[0] = 0x72; | |
321 aTxBuffer[1] = 0xA4; | |
322 send((uint8_t*)aTxBuffer, 2); | |
323 | |
324 aTxBuffer[0] = 0x70; | |
325 aTxBuffer[1] = OLED_SCTE_SET_31h; | |
326 send((uint8_t*)aTxBuffer, 2); | |
327 aTxBuffer[0] = 0x72; | |
328 aTxBuffer[1] = 0x08;//8 | |
329 send((uint8_t*)aTxBuffer, 2); | |
330 | |
331 //debug read | |
332 aTxBuffer[0] = 0x70; | |
333 aTxBuffer[1] = OLED_SCTE_SET_31h; | |
334 send((uint8_t*)aTxBuffer, 2); | |
335 aTxBuffer[0] = 0x73; // Read internal register | |
336 aTxBuffer[1] = 0x00; // Dummy write - reads out 0x08 (The just-set OLED_SCTE_SET value) | |
337 send((uint8_t*)aTxBuffer, 2); | |
338 | |
339 aTxBuffer[0] = 0x70; | |
340 aTxBuffer[1] = OLED_WCWE_SET_32h; | |
341 send((uint8_t*)aTxBuffer, 2); | |
342 aTxBuffer[0] = 0x72; | |
343 aTxBuffer[1] = 0x14;//14 | |
344 send((uint8_t*)aTxBuffer, 2); | |
345 | |
346 aTxBuffer[0] = 0x70; | |
347 aTxBuffer[1] = OLED_GATELESS1_30h; | |
348 send((uint8_t*)aTxBuffer, 2); | |
349 aTxBuffer[0] = 0x72; | |
350 aTxBuffer[1] = 0x02; | |
351 send((uint8_t*)aTxBuffer, 2); | |
352 | |
353 aTxBuffer[0] = 0x70; | |
354 aTxBuffer[1] = OLED_GATELESS2_27h; | |
355 send((uint8_t*)aTxBuffer, 2); | |
356 aTxBuffer[0] = 0x72; | |
357 aTxBuffer[1] = 0x01; | |
358 send((uint8_t*)aTxBuffer, 2); | |
359 | |
360 | |
361 aTxBuffer[0] = 0x70; | |
362 aTxBuffer[1] = OLED_VBP_SET_12h; | |
363 send((uint8_t*)aTxBuffer, 2); | |
364 aTxBuffer[0] = 0x72; | |
365 aTxBuffer[1] = 0x08; | |
366 send((uint8_t*)aTxBuffer, 2); | |
367 | |
368 aTxBuffer[0] = 0x70; | |
369 aTxBuffer[1] = OLED_VFP_SET_13h; | |
370 send((uint8_t*)aTxBuffer, 2); | |
371 aTxBuffer[0] = 0x72; | |
372 aTxBuffer[1] = 0x08; | |
373 send((uint8_t*)aTxBuffer, 2); | |
374 | |
375 aTxBuffer[0] = 0x70; | |
376 aTxBuffer[1] = OLED_DISPLAY_CON_15h; | |
377 send((uint8_t*)aTxBuffer, 2); | |
378 aTxBuffer[0] = 0x72; | |
379 aTxBuffer[1] = 0x01; //SS=0 | |
380 //aTxBuffer[1] = 0x11; //SS=1 | |
381 send((uint8_t*)aTxBuffer, 2); | |
382 | |
383 aTxBuffer[0] = 0x70; | |
384 aTxBuffer[1] = OLED_COLOR_DEPTH_SET_16h; | |
385 send((uint8_t*)aTxBuffer, 2); | |
386 aTxBuffer[0] = 0x72; | |
387 aTxBuffer[1] = 0x00; | |
388 send((uint8_t*)aTxBuffer, 2); | |
389 | |
390 aTxBuffer[0] = 0x70; | |
391 aTxBuffer[1] = OLED_PENTILE_KEY_EFh; // write-only register... | |
392 send((uint8_t*)aTxBuffer, 2); | |
393 aTxBuffer[0] = 0x72; | |
394 aTxBuffer[1] = 0xD0; | |
395 send((uint8_t*)aTxBuffer, 2); | |
396 aTxBuffer[0] = 0x72; | |
397 aTxBuffer[1] = 0xE8; | |
398 send((uint8_t*)aTxBuffer, 2); | |
399 | |
400 aTxBuffer[0] = 0x70; | |
401 aTxBuffer[1] = OLED_PENTILE1_A0h; // write-only register... | |
402 send((uint8_t*)aTxBuffer, 2); | |
403 aTxBuffer[0] = 0x72; | |
404 aTxBuffer[1] = 0x00; | |
405 send((uint8_t*)aTxBuffer, 2); | |
406 aTxBuffer[0] = 0x72; | |
407 aTxBuffer[1] = 0x63; | |
408 send((uint8_t*)aTxBuffer, 2); | |
409 | |
410 aTxBuffer[0] = 0x70; | |
411 aTxBuffer[1] = OLED_PENTILE2_A1h; // write-only register... | |
412 send((uint8_t*)aTxBuffer, 2); | |
413 aTxBuffer[0] = 0x72; | |
414 aTxBuffer[1] = 0x00; | |
415 send((uint8_t*)aTxBuffer, 2); | |
416 aTxBuffer[0] = 0x72; | |
417 aTxBuffer[1] = 0xC0; // SID1&SID0=00 | |
418 // aTxBuffer[1] = 0xC4; // SID1&SID0=01 CC C8 C4 C0 | |
419 send((uint8_t*)aTxBuffer, 2); | |
420 | |
421 aTxBuffer[0] = 0x70; | |
422 aTxBuffer[1] = OLED_PENTILE3_A2h; // write-only register... | |
423 send((uint8_t*)aTxBuffer, 2); | |
424 aTxBuffer[0] = 0x72; | |
425 aTxBuffer[1] = 0x00; | |
426 send((uint8_t*)aTxBuffer, 2); | |
427 aTxBuffer[0] = 0x72; | |
428 aTxBuffer[1] = 0x32; | |
429 send((uint8_t*)aTxBuffer, 2); | |
430 | |
431 aTxBuffer[0] = 0x70; | |
432 aTxBuffer[1] = OLED_PENTILE4_A3h; // write-only register... | |
433 send((uint8_t*)aTxBuffer, 2); | |
434 aTxBuffer[0] = 0x72; | |
435 aTxBuffer[1] = 0x00; | |
436 send((uint8_t*)aTxBuffer, 2); | |
437 aTxBuffer[0] = 0x72; | |
438 aTxBuffer[1] = 0x02; | |
439 send((uint8_t*)aTxBuffer, 2); | |
440 | |
441 aTxBuffer[0] = 0x70; | |
442 aTxBuffer[1] = OLED_BRIGHTNESS_CTRL_39h; | |
443 send((uint8_t*)aTxBuffer, 2); | |
444 aTxBuffer[0] = 0x72; | |
445 aTxBuffer[1] = 0x44;//44 | |
446 send((uint8_t*)aTxBuffer, 2); | |
447 | |
448 // GAMMA L=250 | |
449 aTxBuffer[0] = 0x70; | |
450 aTxBuffer[1] = 0x40; | |
451 send((uint8_t*)aTxBuffer, 2); | |
452 aTxBuffer[0] = 0x72; | |
453 aTxBuffer[1] = 0x00; | |
454 send((uint8_t*)aTxBuffer, 2); | |
455 | |
456 aTxBuffer[0] = 0x70; | |
457 aTxBuffer[1] = 0x41; | |
458 send((uint8_t*)aTxBuffer, 2); | |
459 aTxBuffer[0] = 0x72; | |
460 aTxBuffer[1] = 0x3F; | |
461 send((uint8_t*)aTxBuffer, 2); | |
462 | |
463 aTxBuffer[0] = 0x70; | |
464 aTxBuffer[1] = 0x42; | |
465 send((uint8_t*)aTxBuffer, 2); | |
466 aTxBuffer[0] = 0x72; | |
467 aTxBuffer[1] = 0x2A; | |
468 send((uint8_t*)aTxBuffer, 2); | |
469 | |
470 aTxBuffer[0] = 0x70; | |
471 aTxBuffer[1] = 0x43; | |
472 send((uint8_t*)aTxBuffer, 2); | |
473 aTxBuffer[0] = 0x72; | |
474 aTxBuffer[1] = 0x27; | |
475 send((uint8_t*)aTxBuffer, 2); | |
476 | |
477 aTxBuffer[0] = 0x70; | |
478 aTxBuffer[1] = 0x44; | |
479 send((uint8_t*)aTxBuffer, 2); | |
480 aTxBuffer[0] = 0x72; | |
481 aTxBuffer[1] = 0x27; | |
482 send((uint8_t*)aTxBuffer, 2); | |
483 | |
484 aTxBuffer[0] = 0x70; | |
485 aTxBuffer[1] = 0x45; | |
486 send((uint8_t*)aTxBuffer, 2); | |
487 aTxBuffer[0] = 0x72; | |
488 aTxBuffer[1] = 0x1F; | |
489 send((uint8_t*)aTxBuffer, 2); | |
490 | |
491 aTxBuffer[0] = 0x70; | |
492 aTxBuffer[1] = 0x46; | |
493 send((uint8_t*)aTxBuffer, 2); | |
494 aTxBuffer[0] = 0x72; | |
495 aTxBuffer[1] = 0x44; | |
496 send((uint8_t*)aTxBuffer, 2); | |
497 | |
498 aTxBuffer[0] = 0x70; | |
499 aTxBuffer[1] = 0x50; | |
500 send((uint8_t*)aTxBuffer, 2); | |
501 aTxBuffer[0] = 0x72; | |
502 aTxBuffer[1] = 0x00; | |
503 send((uint8_t*)aTxBuffer, 2); | |
504 | |
505 aTxBuffer[0] = 0x70; | |
506 aTxBuffer[1] = 0x51; | |
507 send((uint8_t*)aTxBuffer, 2); | |
508 aTxBuffer[0] = 0x72; | |
509 aTxBuffer[1] = 0x00; | |
510 send((uint8_t*)aTxBuffer, 2); | |
511 | |
512 aTxBuffer[0] = 0x70; | |
513 aTxBuffer[1] = 0x52; | |
514 send((uint8_t*)aTxBuffer, 2); | |
515 aTxBuffer[0] = 0x72; | |
516 aTxBuffer[1] = 0x17; | |
517 send((uint8_t*)aTxBuffer, 2); | |
518 | |
519 aTxBuffer[0] = 0x70; | |
520 aTxBuffer[1] = 0x53; | |
521 send((uint8_t*)aTxBuffer, 2); | |
522 aTxBuffer[0] = 0x72; | |
523 aTxBuffer[1] = 0x24; | |
524 send((uint8_t*)aTxBuffer, 2); | |
525 | |
526 aTxBuffer[0] = 0x70; | |
527 aTxBuffer[1] = 0x54; | |
528 send((uint8_t*)aTxBuffer, 2); | |
529 aTxBuffer[0] = 0x72; | |
530 aTxBuffer[1] = 0x26; | |
531 send((uint8_t*)aTxBuffer, 2); | |
532 | |
533 aTxBuffer[0] = 0x70; | |
534 aTxBuffer[1] = 0x55; | |
535 send((uint8_t*)aTxBuffer, 2); | |
536 aTxBuffer[0] = 0x72; | |
537 aTxBuffer[1] = 0x1F; | |
538 send((uint8_t*)aTxBuffer, 2); | |
539 | |
540 aTxBuffer[0] = 0x70; | |
541 aTxBuffer[1] = 0x56; | |
542 send((uint8_t*)aTxBuffer, 2); | |
543 aTxBuffer[0] = 0x72; | |
544 aTxBuffer[1] = 0x43; | |
545 send((uint8_t*)aTxBuffer, 2); | |
546 | |
547 aTxBuffer[0] = 0x70; | |
548 aTxBuffer[1] = 0x60; | |
549 send((uint8_t*)aTxBuffer, 2); | |
550 aTxBuffer[0] = 0x72; | |
551 aTxBuffer[1] = 0x00; | |
552 send((uint8_t*)aTxBuffer, 2); | |
553 | |
554 aTxBuffer[0] = 0x70; | |
555 aTxBuffer[1] = 0x61; | |
556 send((uint8_t*)aTxBuffer, 2); | |
557 aTxBuffer[0] = 0x72; | |
558 aTxBuffer[1] = 0x3F; | |
559 send((uint8_t*)aTxBuffer, 2); | |
560 | |
561 aTxBuffer[0] = 0x70; | |
562 aTxBuffer[1] = 0x62; | |
563 send((uint8_t*)aTxBuffer, 2); | |
564 aTxBuffer[0] = 0x72; | |
565 aTxBuffer[1] = 0x2A; | |
566 send((uint8_t*)aTxBuffer, 2); | |
567 | |
568 aTxBuffer[0] = 0x70; | |
569 aTxBuffer[1] = 0x63; | |
570 send((uint8_t*)aTxBuffer, 2); | |
571 aTxBuffer[0] = 0x72; | |
572 aTxBuffer[1] = 0x25; | |
573 send((uint8_t*)aTxBuffer, 2); | |
574 | |
575 aTxBuffer[0] = 0x70; | |
576 aTxBuffer[1] = 0x64; | |
577 send((uint8_t*)aTxBuffer, 2); | |
578 aTxBuffer[0] = 0x72; | |
579 aTxBuffer[1] = 0x24; | |
580 send((uint8_t*)aTxBuffer, 2); | |
581 | |
582 aTxBuffer[0] = 0x70; | |
583 aTxBuffer[1] = 0x65; | |
584 send((uint8_t*)aTxBuffer, 2); | |
585 aTxBuffer[0] = 0x72; | |
586 aTxBuffer[1] = 0x1B; | |
587 send((uint8_t*)aTxBuffer, 2); | |
588 | |
589 aTxBuffer[0] = 0x70; | |
590 aTxBuffer[1] = 0x66; | |
591 send((uint8_t*)aTxBuffer, 2); | |
592 aTxBuffer[0] = 0x72; | |
593 aTxBuffer[1] = 0x5C; | |
594 send((uint8_t*)aTxBuffer, 2); | |
595 | |
596 /* | |
597 // GAMMA L=150 | |
598 aTxBuffer[0] = 0x70; | |
599 aTxBuffer[1] = 0x40; | |
600 send((uint8_t*)aTxBuffer, 2); | |
601 aTxBuffer[0] = 0x72; | |
602 aTxBuffer[1] = 0x00; | |
603 send((uint8_t*)aTxBuffer, 2); | |
604 | |
605 aTxBuffer[0] = 0x70; | |
606 aTxBuffer[1] = 0x41; | |
607 send((uint8_t*)aTxBuffer, 2); | |
608 aTxBuffer[0] = 0x72; | |
609 aTxBuffer[1] = 0x3F; | |
610 send((uint8_t*)aTxBuffer, 2); | |
611 | |
612 aTxBuffer[0] = 0x70; | |
613 aTxBuffer[1] = 0x42; | |
614 send((uint8_t*)aTxBuffer, 2); | |
615 aTxBuffer[0] = 0x72; | |
616 aTxBuffer[1] = 0x2D; | |
617 send((uint8_t*)aTxBuffer, 2); | |
618 | |
619 aTxBuffer[0] = 0x70; | |
620 aTxBuffer[1] = 0x43; | |
621 send((uint8_t*)aTxBuffer, 2); | |
622 aTxBuffer[0] = 0x72; | |
623 aTxBuffer[1] = 0x29; | |
624 send((uint8_t*)aTxBuffer, 2); | |
625 | |
626 aTxBuffer[0] = 0x70; | |
627 aTxBuffer[1] = 0x44; | |
628 send((uint8_t*)aTxBuffer, 2); | |
629 aTxBuffer[0] = 0x72; | |
630 aTxBuffer[1] = 0x28; | |
631 send((uint8_t*)aTxBuffer, 2); | |
632 | |
633 aTxBuffer[0] = 0x70; | |
634 aTxBuffer[1] = 0x45; | |
635 send((uint8_t*)aTxBuffer, 2); | |
636 aTxBuffer[0] = 0x72; | |
637 aTxBuffer[1] = 0x23; | |
638 send((uint8_t*)aTxBuffer, 2); | |
639 | |
640 aTxBuffer[0] = 0x70; | |
641 aTxBuffer[1] = 0x46; | |
642 send((uint8_t*)aTxBuffer, 2); | |
643 aTxBuffer[0] = 0x72; | |
644 aTxBuffer[1] = 0x37; | |
645 send((uint8_t*)aTxBuffer, 2); | |
646 | |
647 aTxBuffer[0] = 0x70; | |
648 aTxBuffer[1] = 0x50; | |
649 send((uint8_t*)aTxBuffer, 2); | |
650 aTxBuffer[0] = 0x72; | |
651 aTxBuffer[1] = 0x00; | |
652 send((uint8_t*)aTxBuffer, 2); | |
653 | |
654 aTxBuffer[0] = 0x70; | |
655 aTxBuffer[1] = 0x51; | |
656 send((uint8_t*)aTxBuffer, 2); | |
657 aTxBuffer[0] = 0x72; | |
658 aTxBuffer[1] = 0x00; | |
659 send((uint8_t*)aTxBuffer, 2); | |
660 | |
661 aTxBuffer[0] = 0x70; | |
662 aTxBuffer[1] = 0x52; | |
663 send((uint8_t*)aTxBuffer, 2); | |
664 aTxBuffer[0] = 0x72; | |
665 aTxBuffer[1] = 0x0B; | |
666 send((uint8_t*)aTxBuffer, 2); | |
667 | |
668 aTxBuffer[0] = 0x70; | |
669 aTxBuffer[1] = 0x53; | |
670 send((uint8_t*)aTxBuffer, 2); | |
671 aTxBuffer[0] = 0x72; | |
672 aTxBuffer[1] = 0x25; | |
673 send((uint8_t*)aTxBuffer, 2); | |
674 | |
675 aTxBuffer[0] = 0x70; | |
676 aTxBuffer[1] = 0x54; | |
677 send((uint8_t*)aTxBuffer, 2); | |
678 aTxBuffer[0] = 0x72; | |
679 aTxBuffer[1] = 0x28; | |
680 send((uint8_t*)aTxBuffer, 2); | |
681 | |
682 aTxBuffer[0] = 0x70; | |
683 aTxBuffer[1] = 0x55; | |
684 send((uint8_t*)aTxBuffer, 2); | |
685 aTxBuffer[0] = 0x72; | |
686 aTxBuffer[1] = 0x22; | |
687 send((uint8_t*)aTxBuffer, 2); | |
688 | |
689 aTxBuffer[0] = 0x70; | |
690 aTxBuffer[1] = 0x56; | |
691 send((uint8_t*)aTxBuffer, 2); | |
692 aTxBuffer[0] = 0x72; | |
693 aTxBuffer[1] = 0x36; | |
694 send((uint8_t*)aTxBuffer, 2); | |
695 | |
696 aTxBuffer[0] = 0x70; | |
697 aTxBuffer[1] = 0x60; | |
698 send((uint8_t*)aTxBuffer, 2); | |
699 aTxBuffer[0] = 0x72; | |
700 aTxBuffer[1] = 0x00; | |
701 send((uint8_t*)aTxBuffer, 2); | |
702 | |
703 aTxBuffer[0] = 0x70; | |
704 aTxBuffer[1] = 0x61; | |
705 send((uint8_t*)aTxBuffer, 2); | |
706 aTxBuffer[0] = 0x72; | |
707 aTxBuffer[1] = 0x3F; | |
708 send((uint8_t*)aTxBuffer, 2); | |
709 | |
710 aTxBuffer[0] = 0x70; | |
711 aTxBuffer[1] = 0x62; | |
712 send((uint8_t*)aTxBuffer, 2); | |
713 aTxBuffer[0] = 0x72; | |
714 aTxBuffer[1] = 0x2B; | |
715 send((uint8_t*)aTxBuffer, 2); | |
716 | |
717 aTxBuffer[0] = 0x70; | |
718 aTxBuffer[1] = 0x63; | |
719 send((uint8_t*)aTxBuffer, 2); | |
720 aTxBuffer[0] = 0x72; | |
721 aTxBuffer[1] = 0x28; | |
722 send((uint8_t*)aTxBuffer, 2); | |
723 | |
724 aTxBuffer[0] = 0x70; | |
725 aTxBuffer[1] = 0x64; | |
726 send((uint8_t*)aTxBuffer, 2); | |
727 aTxBuffer[0] = 0x72; | |
728 aTxBuffer[1] = 0x26; | |
729 send((uint8_t*)aTxBuffer, 2); | |
730 | |
731 aTxBuffer[0] = 0x70; | |
732 aTxBuffer[1] = 0x65; | |
733 send((uint8_t*)aTxBuffer, 2); | |
734 aTxBuffer[0] = 0x72; | |
735 aTxBuffer[1] = 0x1F; | |
736 send((uint8_t*)aTxBuffer, 2); | |
737 | |
738 aTxBuffer[0] = 0x70; | |
739 aTxBuffer[1] = 0x66; | |
740 send((uint8_t*)aTxBuffer, 2); | |
741 aTxBuffer[0] = 0x72; | |
742 aTxBuffer[1] = 0x4A; | |
743 send((uint8_t*)aTxBuffer, 2); | |
744 */ | |
745 | |
746 aTxBuffer[0] = 0x70; | |
747 aTxBuffer[1] = OLED_BOOSTING_FREQ; | |
748 send((uint8_t*)aTxBuffer, 2); | |
749 aTxBuffer[0] = 0x72; | |
750 aTxBuffer[1] = 0x22; | |
751 send((uint8_t*)aTxBuffer, 2); | |
752 | |
753 aTxBuffer[0] = 0x70; | |
754 aTxBuffer[1] = OLED_AMP_SET_18h; | |
755 send((uint8_t*)aTxBuffer, 2); | |
756 aTxBuffer[0] = 0x72; | |
757 aTxBuffer[1] = 0x22; | |
758 send((uint8_t*)aTxBuffer, 2); | |
759 | |
760 aTxBuffer[0] = 0x70; | |
761 aTxBuffer[1] = OLED_GAMMA_AMP_19h; | |
762 send((uint8_t*)aTxBuffer, 2); | |
763 aTxBuffer[0] = 0x72; | |
764 aTxBuffer[1] = 0x02; | |
765 send((uint8_t*)aTxBuffer, 2); | |
766 | |
767 aTxBuffer[0] = 0x70; | |
768 aTxBuffer[1] = OLED_POWER_CONTROL2_1Ah; | |
769 send((uint8_t*)aTxBuffer, 2); | |
770 aTxBuffer[0] = 0x72; | |
771 aTxBuffer[1] = 0x00; | |
772 send((uint8_t*)aTxBuffer, 2); | |
773 | |
774 /* | |
775 aTxBuffer[0] = 0x70; | |
776 aTxBuffer[1] = OLED_POWER_CONTROL2_1Bh; | |
777 send((uint8_t*)aTxBuffer, 2); | |
778 aTxBuffer[0] = 0x72; | |
779 aTxBuffer[1] = 0x4B; | |
780 send((uint8_t*)aTxBuffer, 2); | |
781 | |
782 aTxBuffer[0] = 0x70; | |
783 aTxBuffer[1] = OLED_POWER_CONTROL2_1Ch; | |
784 send((uint8_t*)aTxBuffer, 2); | |
785 aTxBuffer[0] = 0x72; | |
786 aTxBuffer[1] = 0x05; | |
787 send((uint8_t*)aTxBuffer, 2); | |
788 */ | |
789 | |
790 aTxBuffer[0] = 0x70; | |
791 aTxBuffer[1] = OLED_INTERNAL_LOGIC_VOLTAGE; | |
792 send((uint8_t*)aTxBuffer, 2); | |
793 aTxBuffer[0] = 0x72; | |
794 aTxBuffer[1] = 0xA2; | |
795 send((uint8_t*)aTxBuffer, 2); | |
796 | |
797 aTxBuffer[0] = 0x70; | |
798 aTxBuffer[1] = OLED_POWER_SET; | |
799 send((uint8_t*)aTxBuffer, 2); | |
800 aTxBuffer[0] = 0x72; | |
801 aTxBuffer[1] = 0x00; | |
802 send((uint8_t*)aTxBuffer, 2); | |
803 | |
804 aTxBuffer[0] = 0x70; | |
805 aTxBuffer[1] = OLED_POWER_SET2; | |
806 send((uint8_t*)aTxBuffer, 2); | |
807 aTxBuffer[0] = 0x72; | |
808 aTxBuffer[1] = 0x77; | |
809 send((uint8_t*)aTxBuffer, 2); | |
810 | |
811 | |
812 aTxBuffer[0] = 0x70; | |
813 aTxBuffer[1] = OLED_DISPLAY_CONDITION_SET_26h; | |
814 send((uint8_t*)aTxBuffer, 2); | |
815 aTxBuffer[0] = 0x72; | |
816 aTxBuffer[1] = 0xA0; | |
817 send((uint8_t*)aTxBuffer, 2); | |
818 | |
819 aTxBuffer[0] = 0x70; | |
820 aTxBuffer[1] = OLED_STB_BY_OFF; | |
821 send((uint8_t*)aTxBuffer, 2); | |
822 aTxBuffer[0] = 0x72; | |
823 aTxBuffer[1] = 0xA0; | |
824 send((uint8_t*)aTxBuffer, 2); | |
825 | |
826 HAL_Delay(250); | |
827 | |
828 aTxBuffer[0] = 0x70; | |
829 aTxBuffer[1] = OLED_DDISP_ON; | |
830 send((uint8_t*)aTxBuffer, 2); | |
831 aTxBuffer[0] = 0x72; | |
832 aTxBuffer[1] = 0x03; | |
833 send((uint8_t*)aTxBuffer, 2); | |
834 | |
835 } | |
836 | |
38 | 837 static void Display_Error_Handler(void) |
838 { | |
871 | 839 //while(1) |
38 | 840 { |
841 } | |
842 } |