comparison Discovery/Src/display.c @ 873:e373e90a48db Evo_2_23

merge new screen stuff
author heinrichsweikamp
date Wed, 14 Aug 2024 16:44:46 +0200
parents f7318457df4d
children 6b06143cbfea
comparison
equal deleted inserted replaced
872:5e027b0f7475 873:e373e90a48db
1 1
2 #include "stm32f4xx_hal.h" /* for HAL_Delay() */ 2 #include "stm32f4xx_hal.h" /* for HAL_Delay() */
3 #include "ostc.h" 3 #include "ostc.h"
4 #include "display.h" 4 #include "display.h"
5 5
6 #define ENABLE_EXTENDED_COMMANDS 0xB9 6 #define TFT_ENABLE_EXTENDED_COMMANDS 0xB9
7 #define SET_POWER 0xB1 7 #define TFT_SET_POWER 0xB1
8 #define SLEEP_OUT 0x11 8 #define TFT_SLEEP_OUT 0x11
9 #define DISPLAY_INVERSION_OFF 0x20 9 #define TFT_DISPLAY_INVERSION_OFF 0x20
10 #define MEMORY_ACCESS_ONTROL 0x36 10 #define TFT_MEMORY_ACCESS_ONTROL 0x36
11 #define INTERFACE_PIXEL_FORMAT 0x3A 11 #define TFT_INTERFACE_PIXEL_FORMAT 0x3A
12 #define SET_RGB_INTERFACE_RELATED 0xB3 12 #define TFT_SET_RGB_INTERFACE_RELATED 0xB3
13 #define SET_DISPLAY_WAVEFORM 0xB4 13 #define TFT_SET_DISPLAY_WAVEFORM 0xB4
14 #define SET_PANEL 0xCC 14 #define TFT_SET_PANEL 0xCC
15 #define SET_GAMMA_CURVE_RELATED 0xE0 15 #define TFT_SET_GAMMA_CURVE_RELATED 0xE0
16 #define DISPLAY_ON 0x29 16 #define TFT_DISPLAY_ON 0x29
17 #define DISPLAY_OFF 0x28 17 #define TFT_DISPLAY_OFF 0x28
18 #define SLEEP_IN 0x10 18 #define TFT_SLEEP_IN 0x10
19 19
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
20 48
21 static void Display_Error_Handler(void); 49 static void Display_Error_Handler(void);
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();
22 53
23 void display_power_on__1_of_2__pre_RGB(void) 54 void display_power_on__1_of_2__pre_RGB(void)
24 { 55 {
25 /* reset system */ 56 uint8_t aTxBuffer[3];
57 /* reset system */
26 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select 58 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select
27 59
28 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET); 60 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET);
29 HAL_Delay(10); 61 HAL_Delay(10);
30 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET); 62 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET);
31 HAL_Delay(10); 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 }
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 }
32 79
33 /* RGB signals should be now for 2 frames or more (datasheet) */ 80 /* RGB signals should be now for 2 frames or more (datasheet) */
34 } 81 }
35 82
36 83
43 90
44 while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY) 91 while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY)
45 { 92 {
46 } 93 }
47 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select 94 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select
95 }
96
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;
48 } 113 }
49 114
50 115
51 static uint16_t convert8to9to8(uint8_t *pInput, uint8_t *pOutput,uint16_t inputlength) 116 static uint16_t convert8to9to8(uint8_t *pInput, uint8_t *pOutput,uint16_t inputlength)
52 { 117 {
93 return outputlength; 158 return outputlength;
94 } 159 }
95 160
96 void display_power_on__2_of_2__post_RGB(void) 161 void display_power_on__2_of_2__post_RGB(void)
97 { 162 {
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
98 uint8_t aTxBuffer[32]; 176 uint8_t aTxBuffer[32];
99 uint8_t bTxBuffer[36]; 177 uint8_t bTxBuffer[36];
100 uint16_t i,length; 178 uint16_t i,length;
101 179
102 for(i=0;i<32;i++) 180 for(i=0;i<32;i++)
103 aTxBuffer[i] = 0; 181 aTxBuffer[i] = 0;
104 for(i=0;i<36;i++) 182 for(i=0;i<36;i++)
105 bTxBuffer[i] = 0; 183 bTxBuffer[i] = 0;
106 184
107 aTxBuffer[0] = ENABLE_EXTENDED_COMMANDS; 185 aTxBuffer[0] = TFT_ENABLE_EXTENDED_COMMANDS;
108 aTxBuffer[1] = 0xFF; 186 aTxBuffer[1] = 0xFF;
109 aTxBuffer[2] = 0x83; 187 aTxBuffer[2] = 0x83;
110 aTxBuffer[3] = 0x63; 188 aTxBuffer[3] = 0x63;
111 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,4); 189 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,4);
112 send((uint8_t*)bTxBuffer, length); 190 send((uint8_t*)bTxBuffer, length);
113 191
114 aTxBuffer[0] = SET_POWER; 192 aTxBuffer[0] = TFT_SET_POWER;
115 aTxBuffer[1] = 0x81; 193 aTxBuffer[1] = 0x81;
116 aTxBuffer[2] = 0x24; 194 aTxBuffer[2] = 0x24;
117 aTxBuffer[3] = 0x04; 195 aTxBuffer[3] = 0x04;
118 aTxBuffer[4] = 0x02; 196 aTxBuffer[4] = 0x02;
119 aTxBuffer[5] = 0x02; 197 aTxBuffer[5] = 0x02;
125 aTxBuffer[11] = 0x3F; 203 aTxBuffer[11] = 0x3F;
126 aTxBuffer[12] = 0x3F; 204 aTxBuffer[12] = 0x3F;
127 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13); 205 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13);
128 send((uint8_t*)bTxBuffer, length); 206 send((uint8_t*)bTxBuffer, length);
129 207
130 aTxBuffer[0] = SLEEP_OUT; 208 aTxBuffer[0] = TFT_SLEEP_OUT;
131 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); 209 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
132 send((uint8_t*)bTxBuffer, length); 210 send((uint8_t*)bTxBuffer, length);
133 HAL_Delay(5+1); 211 HAL_Delay(5+1);
134 212
135 aTxBuffer[0] = DISPLAY_INVERSION_OFF; 213 aTxBuffer[0] = TFT_DISPLAY_INVERSION_OFF;
136 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); 214 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
137 send((uint8_t*)bTxBuffer, length); 215 send((uint8_t*)bTxBuffer, length);
138 216
139 aTxBuffer[0] = MEMORY_ACCESS_ONTROL; 217 aTxBuffer[0] = TFT_MEMORY_ACCESS_ONTROL;
140 aTxBuffer[1] = 0x00; 218 aTxBuffer[1] = 0x00;
141 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); 219 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2);
142 send((uint8_t*)bTxBuffer, length); 220 send((uint8_t*)bTxBuffer, length);
143 221
144 aTxBuffer[0] = INTERFACE_PIXEL_FORMAT; 222 aTxBuffer[0] = TFT_INTERFACE_PIXEL_FORMAT;
145 aTxBuffer[1] = 0x70; 223 aTxBuffer[1] = 0x70;
146 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); 224 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2);
147 send((uint8_t*)bTxBuffer, length); 225 send((uint8_t*)bTxBuffer, length);
148 HAL_Delay(120+20); 226 HAL_Delay(120+20);
149 227
150 aTxBuffer[0] = SET_POWER; 228 aTxBuffer[0] = TFT_SET_POWER;
151 aTxBuffer[1] = 0x78; 229 aTxBuffer[1] = 0x78;
152 aTxBuffer[2] = 0x24; 230 aTxBuffer[2] = 0x24;
153 aTxBuffer[3] = 0x04, 231 aTxBuffer[3] = 0x04,
154 aTxBuffer[4] = 0x02; 232 aTxBuffer[4] = 0x02;
155 aTxBuffer[5] = 0x02; 233 aTxBuffer[5] = 0x02;
161 aTxBuffer[11] = 0x3F; 239 aTxBuffer[11] = 0x3F;
162 aTxBuffer[12] = 0x3F; 240 aTxBuffer[12] = 0x3F;
163 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13); 241 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13);
164 send((uint8_t*)bTxBuffer, length); 242 send((uint8_t*)bTxBuffer, length);
165 243
166 aTxBuffer[0] = SET_RGB_INTERFACE_RELATED; 244 aTxBuffer[0] = TFT_SET_RGB_INTERFACE_RELATED;
167 aTxBuffer[1] = 0x01; 245 aTxBuffer[1] = 0x01;
168 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); 246 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2);
169 send((uint8_t*)bTxBuffer, length); 247 send((uint8_t*)bTxBuffer, length);
170 248
171 aTxBuffer[0] = SET_DISPLAY_WAVEFORM; 249 aTxBuffer[0] = TFT_SET_DISPLAY_WAVEFORM;
172 aTxBuffer[1] = 0x00; 250 aTxBuffer[1] = 0x00;
173 aTxBuffer[2] = 0x08; 251 aTxBuffer[2] = 0x08;
174 aTxBuffer[3] = 0x56; 252 aTxBuffer[3] = 0x56;
175 aTxBuffer[4] = 0x07; 253 aTxBuffer[4] = 0x07;
176 aTxBuffer[5] = 0x01; 254 aTxBuffer[5] = 0x01;
179 aTxBuffer[8] = 0x01; 257 aTxBuffer[8] = 0x01;
180 aTxBuffer[9] = 0x42; 258 aTxBuffer[9] = 0x42;
181 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,10); 259 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,10);
182 send((uint8_t*)bTxBuffer, length); 260 send((uint8_t*)bTxBuffer, length);
183 261
184 aTxBuffer[0] = SET_PANEL; 262 aTxBuffer[0] = TFT_SET_PANEL;
185 aTxBuffer[1] = 0x0B; 263 aTxBuffer[1] = 0x0B;
186 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); 264 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2);
187 send((uint8_t*)bTxBuffer, length); 265 send((uint8_t*)bTxBuffer, length);
188 266
189 aTxBuffer[0] = SET_GAMMA_CURVE_RELATED; 267 aTxBuffer[0] = TFT_SET_GAMMA_CURVE_RELATED;
190 aTxBuffer[1] = 0x01; 268 aTxBuffer[1] = 0x01;
191 aTxBuffer[2] = 0x48; 269 aTxBuffer[2] = 0x48;
192 aTxBuffer[3] = 0x4D; 270 aTxBuffer[3] = 0x4D;
193 aTxBuffer[4] = 0x4E; 271 aTxBuffer[4] = 0x4E;
194 aTxBuffer[5] = 0x58; 272 aTxBuffer[5] = 0x58;
219 aTxBuffer[30] = 0x11; 297 aTxBuffer[30] = 0x11;
220 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,31); 298 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,31);
221 send((uint8_t*)bTxBuffer, length); 299 send((uint8_t*)bTxBuffer, length);
222 HAL_Delay(5+1); 300 HAL_Delay(5+1);
223 301
224 aTxBuffer[0] = DISPLAY_ON; 302 aTxBuffer[0] = TFT_DISPLAY_ON;
225 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); 303 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
226 send((uint8_t*)bTxBuffer, length); 304 send((uint8_t*)bTxBuffer, length);
227 } 305 }
228 306
307
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 }
229 836
230 static void Display_Error_Handler(void) 837 static void Display_Error_Handler(void)
231 { 838 {
232 while(1) 839 //while(1)
233 { 840 {
234 } 841 }
235 } 842 }