comparison Discovery/Src/display.c @ 871:f7318457df4d default

support for new screen ToDo: Brightness settings
author heinrichsweikamp
date Tue, 13 Aug 2024 13:24:54 +0200
parents 5ca177d2df5d
children e373e90a48db
comparison
equal deleted inserted replaced
866:3a1c533f3840 871:f7318457df4d
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 }
32 71
33 /* RGB signals should be now for 2 frames or more (datasheet) */ 72 /* RGB signals should be now for 2 frames or more (datasheet) */
34 } 73 }
35 74
36 75
43 82
44 while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY) 83 while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY)
45 { 84 {
46 } 85 }
47 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select 86 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select
87 }
88
89 static uint8_t receive_screen(uint8_t *pData)
90 {
91 uint8_t byte;
92 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_RESET); // chip select
93 if(HAL_SPI_Transmit(&hspiDisplay,(uint8_t*)pData, 1, 10000) != HAL_OK)
94 Display_Error_Handler();
95 while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY)
96 {
97 }
98 if(HAL_SPI_Receive(&hspiDisplay, &byte, 1, 10000) != HAL_OK)
99 Display_Error_Handler();
100 while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY)
101 {
102 }
103 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select
104 return byte;
48 } 105 }
49 106
50 107
51 static uint16_t convert8to9to8(uint8_t *pInput, uint8_t *pOutput,uint16_t inputlength) 108 static uint16_t convert8to9to8(uint8_t *pInput, uint8_t *pOutput,uint16_t inputlength)
52 { 109 {
93 return outputlength; 150 return outputlength;
94 } 151 }
95 152
96 void display_power_on__2_of_2__post_RGB(void) 153 void display_power_on__2_of_2__post_RGB(void)
97 { 154 {
155 if (hardwareDisplay == 1)
156 {
157 display_power_on__2_of_2__post_RGB_display1();
158 }
159 else
160 {
161 display_power_on__2_of_2__post_RGB_display0();
162 }
163 }
164
165 void display_power_on__2_of_2__post_RGB_display0(void)
166 {
167
98 uint8_t aTxBuffer[32]; 168 uint8_t aTxBuffer[32];
99 uint8_t bTxBuffer[36]; 169 uint8_t bTxBuffer[36];
100 uint16_t i,length; 170 uint16_t i,length;
101 171
102 for(i=0;i<32;i++) 172 for(i=0;i<32;i++)
103 aTxBuffer[i] = 0; 173 aTxBuffer[i] = 0;
104 for(i=0;i<36;i++) 174 for(i=0;i<36;i++)
105 bTxBuffer[i] = 0; 175 bTxBuffer[i] = 0;
106 176
107 aTxBuffer[0] = ENABLE_EXTENDED_COMMANDS; 177 aTxBuffer[0] = TFT_ENABLE_EXTENDED_COMMANDS;
108 aTxBuffer[1] = 0xFF; 178 aTxBuffer[1] = 0xFF;
109 aTxBuffer[2] = 0x83; 179 aTxBuffer[2] = 0x83;
110 aTxBuffer[3] = 0x63; 180 aTxBuffer[3] = 0x63;
111 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,4); 181 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,4);
112 send((uint8_t*)bTxBuffer, length); 182 send((uint8_t*)bTxBuffer, length);
113 183
114 aTxBuffer[0] = SET_POWER; 184 aTxBuffer[0] = TFT_SET_POWER;
115 aTxBuffer[1] = 0x81; 185 aTxBuffer[1] = 0x81;
116 aTxBuffer[2] = 0x24; 186 aTxBuffer[2] = 0x24;
117 aTxBuffer[3] = 0x04; 187 aTxBuffer[3] = 0x04;
118 aTxBuffer[4] = 0x02; 188 aTxBuffer[4] = 0x02;
119 aTxBuffer[5] = 0x02; 189 aTxBuffer[5] = 0x02;
125 aTxBuffer[11] = 0x3F; 195 aTxBuffer[11] = 0x3F;
126 aTxBuffer[12] = 0x3F; 196 aTxBuffer[12] = 0x3F;
127 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13); 197 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13);
128 send((uint8_t*)bTxBuffer, length); 198 send((uint8_t*)bTxBuffer, length);
129 199
130 aTxBuffer[0] = SLEEP_OUT; 200 aTxBuffer[0] = TFT_SLEEP_OUT;
131 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); 201 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
132 send((uint8_t*)bTxBuffer, length); 202 send((uint8_t*)bTxBuffer, length);
133 HAL_Delay(5+1); 203 HAL_Delay(5+1);
134 204
135 aTxBuffer[0] = DISPLAY_INVERSION_OFF; 205 aTxBuffer[0] = TFT_DISPLAY_INVERSION_OFF;
136 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); 206 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
137 send((uint8_t*)bTxBuffer, length); 207 send((uint8_t*)bTxBuffer, length);
138 208
139 aTxBuffer[0] = MEMORY_ACCESS_ONTROL; 209 aTxBuffer[0] = TFT_MEMORY_ACCESS_ONTROL;
140 aTxBuffer[1] = 0x00; 210 aTxBuffer[1] = 0x00;
141 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); 211 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2);
142 send((uint8_t*)bTxBuffer, length); 212 send((uint8_t*)bTxBuffer, length);
143 213
144 aTxBuffer[0] = INTERFACE_PIXEL_FORMAT; 214 aTxBuffer[0] = TFT_INTERFACE_PIXEL_FORMAT;
145 aTxBuffer[1] = 0x70; 215 aTxBuffer[1] = 0x70;
146 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); 216 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2);
147 send((uint8_t*)bTxBuffer, length); 217 send((uint8_t*)bTxBuffer, length);
148 HAL_Delay(120+20); 218 HAL_Delay(120+20);
149 219
150 aTxBuffer[0] = SET_POWER; 220 aTxBuffer[0] = TFT_SET_POWER;
151 aTxBuffer[1] = 0x78; 221 aTxBuffer[1] = 0x78;
152 aTxBuffer[2] = 0x24; 222 aTxBuffer[2] = 0x24;
153 aTxBuffer[3] = 0x04, 223 aTxBuffer[3] = 0x04,
154 aTxBuffer[4] = 0x02; 224 aTxBuffer[4] = 0x02;
155 aTxBuffer[5] = 0x02; 225 aTxBuffer[5] = 0x02;
161 aTxBuffer[11] = 0x3F; 231 aTxBuffer[11] = 0x3F;
162 aTxBuffer[12] = 0x3F; 232 aTxBuffer[12] = 0x3F;
163 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13); 233 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13);
164 send((uint8_t*)bTxBuffer, length); 234 send((uint8_t*)bTxBuffer, length);
165 235
166 aTxBuffer[0] = SET_RGB_INTERFACE_RELATED; 236 aTxBuffer[0] = TFT_SET_RGB_INTERFACE_RELATED;
167 aTxBuffer[1] = 0x01; 237 aTxBuffer[1] = 0x01;
168 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); 238 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2);
169 send((uint8_t*)bTxBuffer, length); 239 send((uint8_t*)bTxBuffer, length);
170 240
171 aTxBuffer[0] = SET_DISPLAY_WAVEFORM; 241 aTxBuffer[0] = TFT_SET_DISPLAY_WAVEFORM;
172 aTxBuffer[1] = 0x00; 242 aTxBuffer[1] = 0x00;
173 aTxBuffer[2] = 0x08; 243 aTxBuffer[2] = 0x08;
174 aTxBuffer[3] = 0x56; 244 aTxBuffer[3] = 0x56;
175 aTxBuffer[4] = 0x07; 245 aTxBuffer[4] = 0x07;
176 aTxBuffer[5] = 0x01; 246 aTxBuffer[5] = 0x01;
179 aTxBuffer[8] = 0x01; 249 aTxBuffer[8] = 0x01;
180 aTxBuffer[9] = 0x42; 250 aTxBuffer[9] = 0x42;
181 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,10); 251 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,10);
182 send((uint8_t*)bTxBuffer, length); 252 send((uint8_t*)bTxBuffer, length);
183 253
184 aTxBuffer[0] = SET_PANEL; 254 aTxBuffer[0] = TFT_SET_PANEL;
185 aTxBuffer[1] = 0x0B; 255 aTxBuffer[1] = 0x0B;
186 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); 256 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2);
187 send((uint8_t*)bTxBuffer, length); 257 send((uint8_t*)bTxBuffer, length);
188 258
189 aTxBuffer[0] = SET_GAMMA_CURVE_RELATED; 259 aTxBuffer[0] = TFT_SET_GAMMA_CURVE_RELATED;
190 aTxBuffer[1] = 0x01; 260 aTxBuffer[1] = 0x01;
191 aTxBuffer[2] = 0x48; 261 aTxBuffer[2] = 0x48;
192 aTxBuffer[3] = 0x4D; 262 aTxBuffer[3] = 0x4D;
193 aTxBuffer[4] = 0x4E; 263 aTxBuffer[4] = 0x4E;
194 aTxBuffer[5] = 0x58; 264 aTxBuffer[5] = 0x58;
219 aTxBuffer[30] = 0x11; 289 aTxBuffer[30] = 0x11;
220 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,31); 290 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,31);
221 send((uint8_t*)bTxBuffer, length); 291 send((uint8_t*)bTxBuffer, length);
222 HAL_Delay(5+1); 292 HAL_Delay(5+1);
223 293
224 aTxBuffer[0] = DISPLAY_ON; 294 aTxBuffer[0] = TFT_DISPLAY_ON;
225 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); 295 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
226 send((uint8_t*)bTxBuffer, length); 296 send((uint8_t*)bTxBuffer, length);
227 } 297 }
228 298
299
300 void display_power_on__2_of_2__post_RGB_display1(void)
301 {
302 uint8_t aTxBuffer[3];
303
304 aTxBuffer[0] = 0x71; // Read chip Index & revision number
305 aTxBuffer[1] = 0x00; // Dummy write - reads out 0x27
306 aTxBuffer[1] = 0x00; // Dummy write - reads out 0x96
307 send((uint8_t*)aTxBuffer, 3);
308
309 aTxBuffer[0] = 0x70;
310 aTxBuffer[1] = OLED_OSCILLATOR;
311 send((uint8_t*)aTxBuffer, 2);
312 aTxBuffer[0] = 0x72;
313 aTxBuffer[1] = 0xA4;
314 send((uint8_t*)aTxBuffer, 2);
315
316 aTxBuffer[0] = 0x70;
317 aTxBuffer[1] = OLED_SCTE_SET_31h;
318 send((uint8_t*)aTxBuffer, 2);
319 aTxBuffer[0] = 0x72;
320 aTxBuffer[1] = 0x08;//8
321 send((uint8_t*)aTxBuffer, 2);
322
323 //debug read
324 aTxBuffer[0] = 0x70;
325 aTxBuffer[1] = OLED_SCTE_SET_31h;
326 send((uint8_t*)aTxBuffer, 2);
327 aTxBuffer[0] = 0x73; // Read internal register
328 aTxBuffer[1] = 0x00; // Dummy write - reads out 0x08 (The just-set OLED_SCTE_SET value)
329 send((uint8_t*)aTxBuffer, 2);
330
331 aTxBuffer[0] = 0x70;
332 aTxBuffer[1] = OLED_WCWE_SET_32h;
333 send((uint8_t*)aTxBuffer, 2);
334 aTxBuffer[0] = 0x72;
335 aTxBuffer[1] = 0x14;//14
336 send((uint8_t*)aTxBuffer, 2);
337
338 aTxBuffer[0] = 0x70;
339 aTxBuffer[1] = OLED_GATELESS1_30h;
340 send((uint8_t*)aTxBuffer, 2);
341 aTxBuffer[0] = 0x72;
342 aTxBuffer[1] = 0x02;
343 send((uint8_t*)aTxBuffer, 2);
344
345 aTxBuffer[0] = 0x70;
346 aTxBuffer[1] = OLED_GATELESS2_27h;
347 send((uint8_t*)aTxBuffer, 2);
348 aTxBuffer[0] = 0x72;
349 aTxBuffer[1] = 0x01;
350 send((uint8_t*)aTxBuffer, 2);
351
352
353 aTxBuffer[0] = 0x70;
354 aTxBuffer[1] = OLED_VBP_SET_12h;
355 send((uint8_t*)aTxBuffer, 2);
356 aTxBuffer[0] = 0x72;
357 aTxBuffer[1] = 0x08;
358 send((uint8_t*)aTxBuffer, 2);
359
360 aTxBuffer[0] = 0x70;
361 aTxBuffer[1] = OLED_VFP_SET_13h;
362 send((uint8_t*)aTxBuffer, 2);
363 aTxBuffer[0] = 0x72;
364 aTxBuffer[1] = 0x08;
365 send((uint8_t*)aTxBuffer, 2);
366
367 aTxBuffer[0] = 0x70;
368 aTxBuffer[1] = OLED_DISPLAY_CON_15h;
369 send((uint8_t*)aTxBuffer, 2);
370 aTxBuffer[0] = 0x72;
371 aTxBuffer[1] = 0x01; //SS=0
372 //aTxBuffer[1] = 0x11; //SS=1
373 send((uint8_t*)aTxBuffer, 2);
374
375 aTxBuffer[0] = 0x70;
376 aTxBuffer[1] = OLED_COLOR_DEPTH_SET_16h;
377 send((uint8_t*)aTxBuffer, 2);
378 aTxBuffer[0] = 0x72;
379 aTxBuffer[1] = 0x00;
380 send((uint8_t*)aTxBuffer, 2);
381
382 aTxBuffer[0] = 0x70;
383 aTxBuffer[1] = OLED_PENTILE_KEY_EFh; // write-only register...
384 send((uint8_t*)aTxBuffer, 2);
385 aTxBuffer[0] = 0x72;
386 aTxBuffer[1] = 0xD0;
387 send((uint8_t*)aTxBuffer, 2);
388 aTxBuffer[0] = 0x72;
389 aTxBuffer[1] = 0xE8;
390 send((uint8_t*)aTxBuffer, 2);
391
392 aTxBuffer[0] = 0x70;
393 aTxBuffer[1] = OLED_PENTILE1_A0h; // write-only register...
394 send((uint8_t*)aTxBuffer, 2);
395 aTxBuffer[0] = 0x72;
396 aTxBuffer[1] = 0x00;
397 send((uint8_t*)aTxBuffer, 2);
398 aTxBuffer[0] = 0x72;
399 aTxBuffer[1] = 0x63;
400 send((uint8_t*)aTxBuffer, 2);
401
402 aTxBuffer[0] = 0x70;
403 aTxBuffer[1] = OLED_PENTILE2_A1h; // write-only register...
404 send((uint8_t*)aTxBuffer, 2);
405 aTxBuffer[0] = 0x72;
406 aTxBuffer[1] = 0x00;
407 send((uint8_t*)aTxBuffer, 2);
408 aTxBuffer[0] = 0x72;
409 aTxBuffer[1] = 0xC0; // SID1&SID0=00
410 // aTxBuffer[1] = 0xC4; // SID1&SID0=01 CC C8 C4 C0
411 send((uint8_t*)aTxBuffer, 2);
412
413 aTxBuffer[0] = 0x70;
414 aTxBuffer[1] = OLED_PENTILE3_A2h; // write-only register...
415 send((uint8_t*)aTxBuffer, 2);
416 aTxBuffer[0] = 0x72;
417 aTxBuffer[1] = 0x00;
418 send((uint8_t*)aTxBuffer, 2);
419 aTxBuffer[0] = 0x72;
420 aTxBuffer[1] = 0x32;
421 send((uint8_t*)aTxBuffer, 2);
422
423 aTxBuffer[0] = 0x70;
424 aTxBuffer[1] = OLED_PENTILE4_A3h; // write-only register...
425 send((uint8_t*)aTxBuffer, 2);
426 aTxBuffer[0] = 0x72;
427 aTxBuffer[1] = 0x00;
428 send((uint8_t*)aTxBuffer, 2);
429 aTxBuffer[0] = 0x72;
430 aTxBuffer[1] = 0x02;
431 send((uint8_t*)aTxBuffer, 2);
432
433 aTxBuffer[0] = 0x70;
434 aTxBuffer[1] = OLED_BRIGHTNESS_CTRL_39h;
435 send((uint8_t*)aTxBuffer, 2);
436 aTxBuffer[0] = 0x72;
437 aTxBuffer[1] = 0x44;//44
438 send((uint8_t*)aTxBuffer, 2);
439
440 // GAMMA L=250
441 aTxBuffer[0] = 0x70;
442 aTxBuffer[1] = 0x40;
443 send((uint8_t*)aTxBuffer, 2);
444 aTxBuffer[0] = 0x72;
445 aTxBuffer[1] = 0x00;
446 send((uint8_t*)aTxBuffer, 2);
447
448 aTxBuffer[0] = 0x70;
449 aTxBuffer[1] = 0x41;
450 send((uint8_t*)aTxBuffer, 2);
451 aTxBuffer[0] = 0x72;
452 aTxBuffer[1] = 0x3F;
453 send((uint8_t*)aTxBuffer, 2);
454
455 aTxBuffer[0] = 0x70;
456 aTxBuffer[1] = 0x42;
457 send((uint8_t*)aTxBuffer, 2);
458 aTxBuffer[0] = 0x72;
459 aTxBuffer[1] = 0x2A;
460 send((uint8_t*)aTxBuffer, 2);
461
462 aTxBuffer[0] = 0x70;
463 aTxBuffer[1] = 0x43;
464 send((uint8_t*)aTxBuffer, 2);
465 aTxBuffer[0] = 0x72;
466 aTxBuffer[1] = 0x27;
467 send((uint8_t*)aTxBuffer, 2);
468
469 aTxBuffer[0] = 0x70;
470 aTxBuffer[1] = 0x44;
471 send((uint8_t*)aTxBuffer, 2);
472 aTxBuffer[0] = 0x72;
473 aTxBuffer[1] = 0x27;
474 send((uint8_t*)aTxBuffer, 2);
475
476 aTxBuffer[0] = 0x70;
477 aTxBuffer[1] = 0x45;
478 send((uint8_t*)aTxBuffer, 2);
479 aTxBuffer[0] = 0x72;
480 aTxBuffer[1] = 0x1F;
481 send((uint8_t*)aTxBuffer, 2);
482
483 aTxBuffer[0] = 0x70;
484 aTxBuffer[1] = 0x46;
485 send((uint8_t*)aTxBuffer, 2);
486 aTxBuffer[0] = 0x72;
487 aTxBuffer[1] = 0x44;
488 send((uint8_t*)aTxBuffer, 2);
489
490 aTxBuffer[0] = 0x70;
491 aTxBuffer[1] = 0x50;
492 send((uint8_t*)aTxBuffer, 2);
493 aTxBuffer[0] = 0x72;
494 aTxBuffer[1] = 0x00;
495 send((uint8_t*)aTxBuffer, 2);
496
497 aTxBuffer[0] = 0x70;
498 aTxBuffer[1] = 0x51;
499 send((uint8_t*)aTxBuffer, 2);
500 aTxBuffer[0] = 0x72;
501 aTxBuffer[1] = 0x00;
502 send((uint8_t*)aTxBuffer, 2);
503
504 aTxBuffer[0] = 0x70;
505 aTxBuffer[1] = 0x52;
506 send((uint8_t*)aTxBuffer, 2);
507 aTxBuffer[0] = 0x72;
508 aTxBuffer[1] = 0x17;
509 send((uint8_t*)aTxBuffer, 2);
510
511 aTxBuffer[0] = 0x70;
512 aTxBuffer[1] = 0x53;
513 send((uint8_t*)aTxBuffer, 2);
514 aTxBuffer[0] = 0x72;
515 aTxBuffer[1] = 0x24;
516 send((uint8_t*)aTxBuffer, 2);
517
518 aTxBuffer[0] = 0x70;
519 aTxBuffer[1] = 0x54;
520 send((uint8_t*)aTxBuffer, 2);
521 aTxBuffer[0] = 0x72;
522 aTxBuffer[1] = 0x26;
523 send((uint8_t*)aTxBuffer, 2);
524
525 aTxBuffer[0] = 0x70;
526 aTxBuffer[1] = 0x55;
527 send((uint8_t*)aTxBuffer, 2);
528 aTxBuffer[0] = 0x72;
529 aTxBuffer[1] = 0x1F;
530 send((uint8_t*)aTxBuffer, 2);
531
532 aTxBuffer[0] = 0x70;
533 aTxBuffer[1] = 0x56;
534 send((uint8_t*)aTxBuffer, 2);
535 aTxBuffer[0] = 0x72;
536 aTxBuffer[1] = 0x43;
537 send((uint8_t*)aTxBuffer, 2);
538
539 aTxBuffer[0] = 0x70;
540 aTxBuffer[1] = 0x60;
541 send((uint8_t*)aTxBuffer, 2);
542 aTxBuffer[0] = 0x72;
543 aTxBuffer[1] = 0x00;
544 send((uint8_t*)aTxBuffer, 2);
545
546 aTxBuffer[0] = 0x70;
547 aTxBuffer[1] = 0x61;
548 send((uint8_t*)aTxBuffer, 2);
549 aTxBuffer[0] = 0x72;
550 aTxBuffer[1] = 0x3F;
551 send((uint8_t*)aTxBuffer, 2);
552
553 aTxBuffer[0] = 0x70;
554 aTxBuffer[1] = 0x62;
555 send((uint8_t*)aTxBuffer, 2);
556 aTxBuffer[0] = 0x72;
557 aTxBuffer[1] = 0x2A;
558 send((uint8_t*)aTxBuffer, 2);
559
560 aTxBuffer[0] = 0x70;
561 aTxBuffer[1] = 0x63;
562 send((uint8_t*)aTxBuffer, 2);
563 aTxBuffer[0] = 0x72;
564 aTxBuffer[1] = 0x25;
565 send((uint8_t*)aTxBuffer, 2);
566
567 aTxBuffer[0] = 0x70;
568 aTxBuffer[1] = 0x64;
569 send((uint8_t*)aTxBuffer, 2);
570 aTxBuffer[0] = 0x72;
571 aTxBuffer[1] = 0x24;
572 send((uint8_t*)aTxBuffer, 2);
573
574 aTxBuffer[0] = 0x70;
575 aTxBuffer[1] = 0x65;
576 send((uint8_t*)aTxBuffer, 2);
577 aTxBuffer[0] = 0x72;
578 aTxBuffer[1] = 0x1B;
579 send((uint8_t*)aTxBuffer, 2);
580
581 aTxBuffer[0] = 0x70;
582 aTxBuffer[1] = 0x66;
583 send((uint8_t*)aTxBuffer, 2);
584 aTxBuffer[0] = 0x72;
585 aTxBuffer[1] = 0x5C;
586 send((uint8_t*)aTxBuffer, 2);
587
588 /*
589 // GAMMA L=150
590 aTxBuffer[0] = 0x70;
591 aTxBuffer[1] = 0x40;
592 send((uint8_t*)aTxBuffer, 2);
593 aTxBuffer[0] = 0x72;
594 aTxBuffer[1] = 0x00;
595 send((uint8_t*)aTxBuffer, 2);
596
597 aTxBuffer[0] = 0x70;
598 aTxBuffer[1] = 0x41;
599 send((uint8_t*)aTxBuffer, 2);
600 aTxBuffer[0] = 0x72;
601 aTxBuffer[1] = 0x3F;
602 send((uint8_t*)aTxBuffer, 2);
603
604 aTxBuffer[0] = 0x70;
605 aTxBuffer[1] = 0x42;
606 send((uint8_t*)aTxBuffer, 2);
607 aTxBuffer[0] = 0x72;
608 aTxBuffer[1] = 0x2D;
609 send((uint8_t*)aTxBuffer, 2);
610
611 aTxBuffer[0] = 0x70;
612 aTxBuffer[1] = 0x43;
613 send((uint8_t*)aTxBuffer, 2);
614 aTxBuffer[0] = 0x72;
615 aTxBuffer[1] = 0x29;
616 send((uint8_t*)aTxBuffer, 2);
617
618 aTxBuffer[0] = 0x70;
619 aTxBuffer[1] = 0x44;
620 send((uint8_t*)aTxBuffer, 2);
621 aTxBuffer[0] = 0x72;
622 aTxBuffer[1] = 0x28;
623 send((uint8_t*)aTxBuffer, 2);
624
625 aTxBuffer[0] = 0x70;
626 aTxBuffer[1] = 0x45;
627 send((uint8_t*)aTxBuffer, 2);
628 aTxBuffer[0] = 0x72;
629 aTxBuffer[1] = 0x23;
630 send((uint8_t*)aTxBuffer, 2);
631
632 aTxBuffer[0] = 0x70;
633 aTxBuffer[1] = 0x46;
634 send((uint8_t*)aTxBuffer, 2);
635 aTxBuffer[0] = 0x72;
636 aTxBuffer[1] = 0x37;
637 send((uint8_t*)aTxBuffer, 2);
638
639 aTxBuffer[0] = 0x70;
640 aTxBuffer[1] = 0x50;
641 send((uint8_t*)aTxBuffer, 2);
642 aTxBuffer[0] = 0x72;
643 aTxBuffer[1] = 0x00;
644 send((uint8_t*)aTxBuffer, 2);
645
646 aTxBuffer[0] = 0x70;
647 aTxBuffer[1] = 0x51;
648 send((uint8_t*)aTxBuffer, 2);
649 aTxBuffer[0] = 0x72;
650 aTxBuffer[1] = 0x00;
651 send((uint8_t*)aTxBuffer, 2);
652
653 aTxBuffer[0] = 0x70;
654 aTxBuffer[1] = 0x52;
655 send((uint8_t*)aTxBuffer, 2);
656 aTxBuffer[0] = 0x72;
657 aTxBuffer[1] = 0x0B;
658 send((uint8_t*)aTxBuffer, 2);
659
660 aTxBuffer[0] = 0x70;
661 aTxBuffer[1] = 0x53;
662 send((uint8_t*)aTxBuffer, 2);
663 aTxBuffer[0] = 0x72;
664 aTxBuffer[1] = 0x25;
665 send((uint8_t*)aTxBuffer, 2);
666
667 aTxBuffer[0] = 0x70;
668 aTxBuffer[1] = 0x54;
669 send((uint8_t*)aTxBuffer, 2);
670 aTxBuffer[0] = 0x72;
671 aTxBuffer[1] = 0x28;
672 send((uint8_t*)aTxBuffer, 2);
673
674 aTxBuffer[0] = 0x70;
675 aTxBuffer[1] = 0x55;
676 send((uint8_t*)aTxBuffer, 2);
677 aTxBuffer[0] = 0x72;
678 aTxBuffer[1] = 0x22;
679 send((uint8_t*)aTxBuffer, 2);
680
681 aTxBuffer[0] = 0x70;
682 aTxBuffer[1] = 0x56;
683 send((uint8_t*)aTxBuffer, 2);
684 aTxBuffer[0] = 0x72;
685 aTxBuffer[1] = 0x36;
686 send((uint8_t*)aTxBuffer, 2);
687
688 aTxBuffer[0] = 0x70;
689 aTxBuffer[1] = 0x60;
690 send((uint8_t*)aTxBuffer, 2);
691 aTxBuffer[0] = 0x72;
692 aTxBuffer[1] = 0x00;
693 send((uint8_t*)aTxBuffer, 2);
694
695 aTxBuffer[0] = 0x70;
696 aTxBuffer[1] = 0x61;
697 send((uint8_t*)aTxBuffer, 2);
698 aTxBuffer[0] = 0x72;
699 aTxBuffer[1] = 0x3F;
700 send((uint8_t*)aTxBuffer, 2);
701
702 aTxBuffer[0] = 0x70;
703 aTxBuffer[1] = 0x62;
704 send((uint8_t*)aTxBuffer, 2);
705 aTxBuffer[0] = 0x72;
706 aTxBuffer[1] = 0x2B;
707 send((uint8_t*)aTxBuffer, 2);
708
709 aTxBuffer[0] = 0x70;
710 aTxBuffer[1] = 0x63;
711 send((uint8_t*)aTxBuffer, 2);
712 aTxBuffer[0] = 0x72;
713 aTxBuffer[1] = 0x28;
714 send((uint8_t*)aTxBuffer, 2);
715
716 aTxBuffer[0] = 0x70;
717 aTxBuffer[1] = 0x64;
718 send((uint8_t*)aTxBuffer, 2);
719 aTxBuffer[0] = 0x72;
720 aTxBuffer[1] = 0x26;
721 send((uint8_t*)aTxBuffer, 2);
722
723 aTxBuffer[0] = 0x70;
724 aTxBuffer[1] = 0x65;
725 send((uint8_t*)aTxBuffer, 2);
726 aTxBuffer[0] = 0x72;
727 aTxBuffer[1] = 0x1F;
728 send((uint8_t*)aTxBuffer, 2);
729
730 aTxBuffer[0] = 0x70;
731 aTxBuffer[1] = 0x66;
732 send((uint8_t*)aTxBuffer, 2);
733 aTxBuffer[0] = 0x72;
734 aTxBuffer[1] = 0x4A;
735 send((uint8_t*)aTxBuffer, 2);
736 */
737
738 aTxBuffer[0] = 0x70;
739 aTxBuffer[1] = OLED_BOOSTING_FREQ;
740 send((uint8_t*)aTxBuffer, 2);
741 aTxBuffer[0] = 0x72;
742 aTxBuffer[1] = 0x22;
743 send((uint8_t*)aTxBuffer, 2);
744
745 aTxBuffer[0] = 0x70;
746 aTxBuffer[1] = OLED_AMP_SET_18h;
747 send((uint8_t*)aTxBuffer, 2);
748 aTxBuffer[0] = 0x72;
749 aTxBuffer[1] = 0x22;
750 send((uint8_t*)aTxBuffer, 2);
751
752 aTxBuffer[0] = 0x70;
753 aTxBuffer[1] = OLED_GAMMA_AMP_19h;
754 send((uint8_t*)aTxBuffer, 2);
755 aTxBuffer[0] = 0x72;
756 aTxBuffer[1] = 0x02;
757 send((uint8_t*)aTxBuffer, 2);
758
759 aTxBuffer[0] = 0x70;
760 aTxBuffer[1] = OLED_POWER_CONTROL2_1Ah;
761 send((uint8_t*)aTxBuffer, 2);
762 aTxBuffer[0] = 0x72;
763 aTxBuffer[1] = 0x00;
764 send((uint8_t*)aTxBuffer, 2);
765
766 /*
767 aTxBuffer[0] = 0x70;
768 aTxBuffer[1] = OLED_POWER_CONTROL2_1Bh;
769 send((uint8_t*)aTxBuffer, 2);
770 aTxBuffer[0] = 0x72;
771 aTxBuffer[1] = 0x4B;
772 send((uint8_t*)aTxBuffer, 2);
773
774 aTxBuffer[0] = 0x70;
775 aTxBuffer[1] = OLED_POWER_CONTROL2_1Ch;
776 send((uint8_t*)aTxBuffer, 2);
777 aTxBuffer[0] = 0x72;
778 aTxBuffer[1] = 0x05;
779 send((uint8_t*)aTxBuffer, 2);
780 */
781
782 aTxBuffer[0] = 0x70;
783 aTxBuffer[1] = OLED_INTERNAL_LOGIC_VOLTAGE;
784 send((uint8_t*)aTxBuffer, 2);
785 aTxBuffer[0] = 0x72;
786 aTxBuffer[1] = 0xA2;
787 send((uint8_t*)aTxBuffer, 2);
788
789 aTxBuffer[0] = 0x70;
790 aTxBuffer[1] = OLED_POWER_SET;
791 send((uint8_t*)aTxBuffer, 2);
792 aTxBuffer[0] = 0x72;
793 aTxBuffer[1] = 0x00;
794 send((uint8_t*)aTxBuffer, 2);
795
796 aTxBuffer[0] = 0x70;
797 aTxBuffer[1] = OLED_POWER_SET2;
798 send((uint8_t*)aTxBuffer, 2);
799 aTxBuffer[0] = 0x72;
800 aTxBuffer[1] = 0x77;
801 send((uint8_t*)aTxBuffer, 2);
802
803
804 aTxBuffer[0] = 0x70;
805 aTxBuffer[1] = OLED_DISPLAY_CONDITION_SET_26h;
806 send((uint8_t*)aTxBuffer, 2);
807 aTxBuffer[0] = 0x72;
808 aTxBuffer[1] = 0xA0;
809 send((uint8_t*)aTxBuffer, 2);
810
811 aTxBuffer[0] = 0x70;
812 aTxBuffer[1] = OLED_STB_BY_OFF;
813 send((uint8_t*)aTxBuffer, 2);
814 aTxBuffer[0] = 0x72;
815 aTxBuffer[1] = 0xA0;
816 send((uint8_t*)aTxBuffer, 2);
817
818 HAL_Delay(250);
819
820 aTxBuffer[0] = 0x70;
821 aTxBuffer[1] = OLED_DDISP_ON;
822 send((uint8_t*)aTxBuffer, 2);
823 aTxBuffer[0] = 0x72;
824 aTxBuffer[1] = 0x03;
825 send((uint8_t*)aTxBuffer, 2);
826
827 }
229 828
230 static void Display_Error_Handler(void) 829 static void Display_Error_Handler(void)
231 { 830 {
232 while(1) 831 //while(1)
233 { 832 {
234 } 833 }
235 } 834 }