comparison Discovery/Src/display.c @ 981:c6c781a2e85b default

Merge into default
author heinrichsweikamp
date Tue, 11 Feb 2025 18:12:00 +0100
parents 8d3f3a635397
children 75f958ca5d0e
comparison
equal deleted inserted replaced
871:f7318457df4d 981:c6c781a2e85b
41 #define OLED_POWER_CONTROL2_1Ch 0x1C // 41 #define OLED_POWER_CONTROL2_1Ch 0x1C //
42 #define OLED_INTERNAL_LOGIC_VOLTAGE 0x22 // VCC*0,65 = 3,3V * 0,55 = 0x00A2 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 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 44 #define OLED_POWER_SET2 0x24 // VREG2OUT = 5,4V, VREG1OUT = 4,2V =0x77
45 #define OLED_DISPLAY_CONDITION_SET_26h 0x26 // 0x00A0 45 #define OLED_DISPLAY_CONDITION_SET_26h 0x26 // 0x00A0
46 #define OLED_STB_BY_OFF 0x1D // 00A0 + 300ms wait 46 #define OLED_STB_BY_OFF_1Dh 0x1D // 00A0 + 300ms wait
47 #define OLED_DDISP_ON 0x14 // 0003 47 #define OLED_DDISP_ON_14h 0x14 // 0003
48 48
49 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); 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); 51 static void display_power_on__2_of_2__post_RGB_display1(void);
52 void display_1_brightness_max(void);
53 void display_1_brightness_high(void);
54 void display_1_brightness_std(void);
55 void display_1_brightness_eco(void);
56 void display_1_brightness_cave(void);
57
52 static uint8_t receive_screen(); 58 static uint8_t receive_screen();
59 uint8_t brightness_screen1;
53 60
54 void display_power_on__1_of_2__pre_RGB(void) 61 void display_power_on__1_of_2__pre_RGB(void)
55 { 62 {
56 uint8_t aTxBuffer[3]; 63 uint8_t aTxBuffer[3];
57 /* reset system */ 64 /* reset system */
59 66
60 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET); 67 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET);
61 HAL_Delay(10); 68 HAL_Delay(10);
62 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET); 69 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET);
63 HAL_Delay(25); 70 HAL_Delay(25);
71
64 // check for new screen 72 // check for new screen
65 hardwareDisplay=0; // default is old screen
66 aTxBuffer[0] = 0x71; // Read internal register 73 aTxBuffer[0] = 0x71; // Read internal register
67 if (receive_screen((uint8_t*)aTxBuffer) == 0x27) // chip Index (=0x27 for new screen) 74 if (receive_screen((uint8_t*)aTxBuffer) == 0x27) // chip Index (=0x27 for new screen)
68 { 75 {
69 hardwareDisplay=1; 76 SetDisplayVersion(DISPLAY_VERSION_NEW);
70 } 77 }
78 else
79 { // re-reset the screen to be sure the 0x71 command did nothing
80 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET);
81 HAL_Delay(10);
82 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET);
83 HAL_Delay(25);
84
85 SetDisplayVersion(DISPLAY_VERSION_LCD);
86 }
71 87
72 /* RGB signals should be now for 2 frames or more (datasheet) */ 88 /* RGB signals should be now for 2 frames or more (datasheet) */
73 } 89 }
74 90
75 91
148 } 164 }
149 } 165 }
150 return outputlength; 166 return outputlength;
151 } 167 }
152 168
169 void display_power_off(void)
170 {
171 if (isNewDisplay())
172 {
173 uint8_t aTxBuffer[3];
174
175 aTxBuffer[0] = 0x70;
176 aTxBuffer[1] = OLED_DDISP_ON_14h;
177 send((uint8_t*)aTxBuffer, 2);
178 aTxBuffer[0] = 0x72;
179 aTxBuffer[1] = 0x00;
180 send((uint8_t*)aTxBuffer, 2);
181 HAL_Delay(25);
182 aTxBuffer[0] = 0x70;
183 aTxBuffer[1] = OLED_STB_BY_OFF_1Dh;
184 send((uint8_t*)aTxBuffer, 2);
185 aTxBuffer[0] = 0x72;
186 aTxBuffer[1] = 0xA1;
187 send((uint8_t*)aTxBuffer, 2);
188 HAL_Delay(200);
189 HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET);
190 }
191 else
192 {
193 // display 0
194 }
195 }
196
197
153 void display_power_on__2_of_2__post_RGB(void) 198 void display_power_on__2_of_2__post_RGB(void)
154 { 199 {
155 if (hardwareDisplay == 1) 200 if (isNewDisplay())
156 { 201 {
157 display_power_on__2_of_2__post_RGB_display1(); 202 display_power_on__2_of_2__post_RGB_display1();
158 } 203 }
159 else 204 else
160 { 205 {
318 send((uint8_t*)aTxBuffer, 2); 363 send((uint8_t*)aTxBuffer, 2);
319 aTxBuffer[0] = 0x72; 364 aTxBuffer[0] = 0x72;
320 aTxBuffer[1] = 0x08;//8 365 aTxBuffer[1] = 0x08;//8
321 send((uint8_t*)aTxBuffer, 2); 366 send((uint8_t*)aTxBuffer, 2);
322 367
323 //debug read 368 /*//debug read
324 aTxBuffer[0] = 0x70; 369 aTxBuffer[0] = 0x70;
325 aTxBuffer[1] = OLED_SCTE_SET_31h; 370 aTxBuffer[1] = OLED_SCTE_SET_31h;
326 send((uint8_t*)aTxBuffer, 2); 371 send((uint8_t*)aTxBuffer, 2);
327 aTxBuffer[0] = 0x73; // Read internal register 372 aTxBuffer[0] = 0x73; // Read internal register
328 aTxBuffer[1] = 0x00; // Dummy write - reads out 0x08 (The just-set OLED_SCTE_SET value) 373 aTxBuffer[1] = 0x00; // Dummy write - reads out 0x08 (The just-set OLED_SCTE_SET value)
329 send((uint8_t*)aTxBuffer, 2); 374 send((uint8_t*)aTxBuffer, 2);
375 */
330 376
331 aTxBuffer[0] = 0x70; 377 aTxBuffer[0] = 0x70;
332 aTxBuffer[1] = OLED_WCWE_SET_32h; 378 aTxBuffer[1] = OLED_WCWE_SET_32h;
333 send((uint8_t*)aTxBuffer, 2); 379 send((uint8_t*)aTxBuffer, 2);
334 aTxBuffer[0] = 0x72; 380 aTxBuffer[0] = 0x72;
435 send((uint8_t*)aTxBuffer, 2); 481 send((uint8_t*)aTxBuffer, 2);
436 aTxBuffer[0] = 0x72; 482 aTxBuffer[0] = 0x72;
437 aTxBuffer[1] = 0x44;//44 483 aTxBuffer[1] = 0x44;//44
438 send((uint8_t*)aTxBuffer, 2); 484 send((uint8_t*)aTxBuffer, 2);
439 485
440 // GAMMA L=250 486
487 display_1_brightness_std(); // boot brightness
488
489
490 aTxBuffer[0] = 0x70;
491 aTxBuffer[1] = OLED_BOOSTING_FREQ;
492 send((uint8_t*)aTxBuffer, 2);
493 aTxBuffer[0] = 0x72;
494 aTxBuffer[1] = 0x22;
495 send((uint8_t*)aTxBuffer, 2);
496
497 aTxBuffer[0] = 0x70;
498 aTxBuffer[1] = OLED_AMP_SET_18h;
499 send((uint8_t*)aTxBuffer, 2);
500 aTxBuffer[0] = 0x72;
501 aTxBuffer[1] = 0x22;
502 send((uint8_t*)aTxBuffer, 2);
503
504 aTxBuffer[0] = 0x70;
505 aTxBuffer[1] = OLED_GAMMA_AMP_19h;
506 send((uint8_t*)aTxBuffer, 2);
507 aTxBuffer[0] = 0x72;
508 aTxBuffer[1] = 0x02;
509 send((uint8_t*)aTxBuffer, 2);
510
511 aTxBuffer[0] = 0x70;
512 aTxBuffer[1] = OLED_POWER_CONTROL2_1Ah;
513 send((uint8_t*)aTxBuffer, 2);
514 aTxBuffer[0] = 0x72;
515 aTxBuffer[1] = 0x00;
516 send((uint8_t*)aTxBuffer, 2);
517
518 /*
519 aTxBuffer[0] = 0x70;
520 aTxBuffer[1] = OLED_POWER_CONTROL2_1Bh;
521 send((uint8_t*)aTxBuffer, 2);
522 aTxBuffer[0] = 0x72;
523 aTxBuffer[1] = 0x4B;
524 send((uint8_t*)aTxBuffer, 2);
525
526 aTxBuffer[0] = 0x70;
527 aTxBuffer[1] = OLED_POWER_CONTROL2_1Ch;
528 send((uint8_t*)aTxBuffer, 2);
529 aTxBuffer[0] = 0x72;
530 aTxBuffer[1] = 0x05;
531 send((uint8_t*)aTxBuffer, 2);
532 */
533
534 aTxBuffer[0] = 0x70;
535 aTxBuffer[1] = OLED_INTERNAL_LOGIC_VOLTAGE;
536 send((uint8_t*)aTxBuffer, 2);
537 aTxBuffer[0] = 0x72;
538 aTxBuffer[1] = 0xA2;
539 send((uint8_t*)aTxBuffer, 2);
540
541 aTxBuffer[0] = 0x70;
542 aTxBuffer[1] = OLED_POWER_SET;
543 send((uint8_t*)aTxBuffer, 2);
544 aTxBuffer[0] = 0x72;
545 aTxBuffer[1] = 0x00;
546 send((uint8_t*)aTxBuffer, 2);
547
548 aTxBuffer[0] = 0x70;
549 aTxBuffer[1] = OLED_POWER_SET2;
550 send((uint8_t*)aTxBuffer, 2);
551 aTxBuffer[0] = 0x72;
552 aTxBuffer[1] = 0x77;
553 send((uint8_t*)aTxBuffer, 2);
554
555
556 aTxBuffer[0] = 0x70;
557 aTxBuffer[1] = OLED_DISPLAY_CONDITION_SET_26h;
558 send((uint8_t*)aTxBuffer, 2);
559 aTxBuffer[0] = 0x72;
560 aTxBuffer[1] = 0xA0;
561 send((uint8_t*)aTxBuffer, 2);
562
563 aTxBuffer[0] = 0x70;
564 aTxBuffer[1] = OLED_STB_BY_OFF_1Dh;
565 send((uint8_t*)aTxBuffer, 2);
566 aTxBuffer[0] = 0x72;
567 aTxBuffer[1] = 0xA0;
568 send((uint8_t*)aTxBuffer, 2);
569
570 HAL_Delay(250);
571
572 aTxBuffer[0] = 0x70;
573 aTxBuffer[1] = OLED_DDISP_ON_14h;
574 send((uint8_t*)aTxBuffer, 2);
575 aTxBuffer[0] = 0x72;
576 aTxBuffer[1] = 0x03;
577 send((uint8_t*)aTxBuffer, 2);
578 }
579
580 void display_1_brightness_max(void)
581 {
582 uint8_t aTxBuffer[3];
583
584 if (brightness_screen1 == 4)
585 {
586 // do nothing
587 }
588 else
589 {
590 // GAMMA L=250
591 aTxBuffer[0] = 0x70;
592 aTxBuffer[1] = 0x40;
593 send((uint8_t*)aTxBuffer, 2);
594 aTxBuffer[0] = 0x72;
595 aTxBuffer[1] = 0x00;
596 send((uint8_t*)aTxBuffer, 2);
597
598 aTxBuffer[0] = 0x70;
599 aTxBuffer[1] = 0x41;
600 send((uint8_t*)aTxBuffer, 2);
601 aTxBuffer[0] = 0x72;
602 aTxBuffer[1] = 0x3F;
603 send((uint8_t*)aTxBuffer, 2);
604
605 aTxBuffer[0] = 0x70;
606 aTxBuffer[1] = 0x42;
607 send((uint8_t*)aTxBuffer, 2);
608 aTxBuffer[0] = 0x72;
609 aTxBuffer[1] = 0x2A;
610 send((uint8_t*)aTxBuffer, 2);
611
612 aTxBuffer[0] = 0x70;
613 aTxBuffer[1] = 0x43;
614 send((uint8_t*)aTxBuffer, 2);
615 aTxBuffer[0] = 0x72;
616 aTxBuffer[1] = 0x27;
617 send((uint8_t*)aTxBuffer, 2);
618
619 aTxBuffer[0] = 0x70;
620 aTxBuffer[1] = 0x44;
621 send((uint8_t*)aTxBuffer, 2);
622 aTxBuffer[0] = 0x72;
623 aTxBuffer[1] = 0x27;
624 send((uint8_t*)aTxBuffer, 2);
625
626 aTxBuffer[0] = 0x70;
627 aTxBuffer[1] = 0x45;
628 send((uint8_t*)aTxBuffer, 2);
629 aTxBuffer[0] = 0x72;
630 aTxBuffer[1] = 0x1F;
631 send((uint8_t*)aTxBuffer, 2);
632
633 aTxBuffer[0] = 0x70;
634 aTxBuffer[1] = 0x46;
635 send((uint8_t*)aTxBuffer, 2);
636 aTxBuffer[0] = 0x72;
637 aTxBuffer[1] = 0x44;
638 send((uint8_t*)aTxBuffer, 2);
639
640 aTxBuffer[0] = 0x70;
641 aTxBuffer[1] = 0x50;
642 send((uint8_t*)aTxBuffer, 2);
643 aTxBuffer[0] = 0x72;
644 aTxBuffer[1] = 0x00;
645 send((uint8_t*)aTxBuffer, 2);
646
647 aTxBuffer[0] = 0x70;
648 aTxBuffer[1] = 0x51;
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] = 0x52;
656 send((uint8_t*)aTxBuffer, 2);
657 aTxBuffer[0] = 0x72;
658 aTxBuffer[1] = 0x17;
659 send((uint8_t*)aTxBuffer, 2);
660
661 aTxBuffer[0] = 0x70;
662 aTxBuffer[1] = 0x53;
663 send((uint8_t*)aTxBuffer, 2);
664 aTxBuffer[0] = 0x72;
665 aTxBuffer[1] = 0x24;
666 send((uint8_t*)aTxBuffer, 2);
667
668 aTxBuffer[0] = 0x70;
669 aTxBuffer[1] = 0x54;
670 send((uint8_t*)aTxBuffer, 2);
671 aTxBuffer[0] = 0x72;
672 aTxBuffer[1] = 0x26;
673 send((uint8_t*)aTxBuffer, 2);
674
675 aTxBuffer[0] = 0x70;
676 aTxBuffer[1] = 0x55;
677 send((uint8_t*)aTxBuffer, 2);
678 aTxBuffer[0] = 0x72;
679 aTxBuffer[1] = 0x1F;
680 send((uint8_t*)aTxBuffer, 2);
681
682 aTxBuffer[0] = 0x70;
683 aTxBuffer[1] = 0x56;
684 send((uint8_t*)aTxBuffer, 2);
685 aTxBuffer[0] = 0x72;
686 aTxBuffer[1] = 0x43;
687 send((uint8_t*)aTxBuffer, 2);
688
689 aTxBuffer[0] = 0x70;
690 aTxBuffer[1] = 0x60;
691 send((uint8_t*)aTxBuffer, 2);
692 aTxBuffer[0] = 0x72;
693 aTxBuffer[1] = 0x00;
694 send((uint8_t*)aTxBuffer, 2);
695
696 aTxBuffer[0] = 0x70;
697 aTxBuffer[1] = 0x61;
698 send((uint8_t*)aTxBuffer, 2);
699 aTxBuffer[0] = 0x72;
700 aTxBuffer[1] = 0x3F;
701 send((uint8_t*)aTxBuffer, 2);
702
703 aTxBuffer[0] = 0x70;
704 aTxBuffer[1] = 0x62;
705 send((uint8_t*)aTxBuffer, 2);
706 aTxBuffer[0] = 0x72;
707 aTxBuffer[1] = 0x2A;
708 send((uint8_t*)aTxBuffer, 2);
709
710 aTxBuffer[0] = 0x70;
711 aTxBuffer[1] = 0x63;
712 send((uint8_t*)aTxBuffer, 2);
713 aTxBuffer[0] = 0x72;
714 aTxBuffer[1] = 0x25;
715 send((uint8_t*)aTxBuffer, 2);
716
717 aTxBuffer[0] = 0x70;
718 aTxBuffer[1] = 0x64;
719 send((uint8_t*)aTxBuffer, 2);
720 aTxBuffer[0] = 0x72;
721 aTxBuffer[1] = 0x24;
722 send((uint8_t*)aTxBuffer, 2);
723
724 aTxBuffer[0] = 0x70;
725 aTxBuffer[1] = 0x65;
726 send((uint8_t*)aTxBuffer, 2);
727 aTxBuffer[0] = 0x72;
728 aTxBuffer[1] = 0x1B;
729 send((uint8_t*)aTxBuffer, 2);
730
731 aTxBuffer[0] = 0x70;
732 aTxBuffer[1] = 0x66;
733 send((uint8_t*)aTxBuffer, 2);
734 aTxBuffer[0] = 0x72;
735 aTxBuffer[1] = 0x5C;
736 send((uint8_t*)aTxBuffer, 2);
737
738 brightness_screen1=4;
739 }
740 }
741
742 void display_1_brightness_high(void)
743 {
744 uint8_t aTxBuffer[3];
745 if (brightness_screen1 == 3)
746 {
747 // do nothing
748 }
749 else
750 {
751 // GAMMA L=200
441 aTxBuffer[0] = 0x70; 752 aTxBuffer[0] = 0x70;
442 aTxBuffer[1] = 0x40; 753 aTxBuffer[1] = 0x40;
443 send((uint8_t*)aTxBuffer, 2); 754 send((uint8_t*)aTxBuffer, 2);
444 aTxBuffer[0] = 0x72; 755 aTxBuffer[0] = 0x72;
445 aTxBuffer[1] = 0x00; 756 aTxBuffer[1] = 0x00;
583 send((uint8_t*)aTxBuffer, 2); 894 send((uint8_t*)aTxBuffer, 2);
584 aTxBuffer[0] = 0x72; 895 aTxBuffer[0] = 0x72;
585 aTxBuffer[1] = 0x5C; 896 aTxBuffer[1] = 0x5C;
586 send((uint8_t*)aTxBuffer, 2); 897 send((uint8_t*)aTxBuffer, 2);
587 898
588 /* 899 brightness_screen1=3;
900 }
901 }
902
903
904 void display_1_brightness_std(void)
905 {
906 uint8_t aTxBuffer[3];
907
908 if (brightness_screen1 == 2)
909 {
910 // do nothing
911 }
912 else
913 {
589 // GAMMA L=150 914 // GAMMA L=150
590 aTxBuffer[0] = 0x70; 915 aTxBuffer[0] = 0x70;
591 aTxBuffer[1] = 0x40; 916 aTxBuffer[1] = 0x40;
592 send((uint8_t*)aTxBuffer, 2); 917 send((uint8_t*)aTxBuffer, 2);
593 aTxBuffer[0] = 0x72; 918 aTxBuffer[0] = 0x72;
731 aTxBuffer[1] = 0x66; 1056 aTxBuffer[1] = 0x66;
732 send((uint8_t*)aTxBuffer, 2); 1057 send((uint8_t*)aTxBuffer, 2);
733 aTxBuffer[0] = 0x72; 1058 aTxBuffer[0] = 0x72;
734 aTxBuffer[1] = 0x4A; 1059 aTxBuffer[1] = 0x4A;
735 send((uint8_t*)aTxBuffer, 2); 1060 send((uint8_t*)aTxBuffer, 2);
736 */ 1061
737 1062 brightness_screen1=2;
738 aTxBuffer[0] = 0x70; 1063 }
739 aTxBuffer[1] = OLED_BOOSTING_FREQ; 1064 }
1065
1066 void display_1_brightness_eco(void)
1067 {
1068 uint8_t aTxBuffer[3];
1069
1070 if (brightness_screen1 == 1)
1071 {
1072 // do nothing
1073 }
1074 else
1075 {
1076 // GAMMA L=100
1077 aTxBuffer[0] = 0x70;
1078 aTxBuffer[1] = 0x40;
1079 send((uint8_t*)aTxBuffer, 2);
1080 aTxBuffer[0] = 0x72;
1081 aTxBuffer[1] = 0x00;
1082 send((uint8_t*)aTxBuffer, 2);
1083
1084 aTxBuffer[0] = 0x70;
1085 aTxBuffer[1] = 0x41;
1086 send((uint8_t*)aTxBuffer, 2);
1087 aTxBuffer[0] = 0x72;
1088 aTxBuffer[1] = 0x3F;
1089 send((uint8_t*)aTxBuffer, 2);
1090
1091 aTxBuffer[0] = 0x70;
1092 aTxBuffer[1] = 0x42;
1093 send((uint8_t*)aTxBuffer, 2);
1094 aTxBuffer[0] = 0x72;
1095 aTxBuffer[1] = 0x30;
1096 send((uint8_t*)aTxBuffer, 2);
1097
1098 aTxBuffer[0] = 0x70;
1099 aTxBuffer[1] = 0x43;
1100 send((uint8_t*)aTxBuffer, 2);
1101 aTxBuffer[0] = 0x72;
1102 aTxBuffer[1] = 0x2A;
1103 send((uint8_t*)aTxBuffer, 2);
1104
1105 aTxBuffer[0] = 0x70;
1106 aTxBuffer[1] = 0x44;
1107 send((uint8_t*)aTxBuffer, 2);
1108 aTxBuffer[0] = 0x72;
1109 aTxBuffer[1] = 0x2B;
1110 send((uint8_t*)aTxBuffer, 2);
1111
1112 aTxBuffer[0] = 0x70;
1113 aTxBuffer[1] = 0x45;
1114 send((uint8_t*)aTxBuffer, 2);
1115 aTxBuffer[0] = 0x72;
1116 aTxBuffer[1] = 0x24;
1117 send((uint8_t*)aTxBuffer, 2);
1118
1119 aTxBuffer[0] = 0x70;
1120 aTxBuffer[1] = 0x46;
1121 send((uint8_t*)aTxBuffer, 2);
1122 aTxBuffer[0] = 0x72;
1123 aTxBuffer[1] = 0x2F;
1124 send((uint8_t*)aTxBuffer, 2);
1125
1126 aTxBuffer[0] = 0x70;
1127 aTxBuffer[1] = 0x50;
1128 send((uint8_t*)aTxBuffer, 2);
1129 aTxBuffer[0] = 0x72;
1130 aTxBuffer[1] = 0x00;
1131 send((uint8_t*)aTxBuffer, 2);
1132
1133 aTxBuffer[0] = 0x70;
1134 aTxBuffer[1] = 0x51;
1135 send((uint8_t*)aTxBuffer, 2);
1136 aTxBuffer[0] = 0x72;
1137 aTxBuffer[1] = 0x00;
1138 send((uint8_t*)aTxBuffer, 2);
1139
1140 aTxBuffer[0] = 0x70;
1141 aTxBuffer[1] = 0x52;
1142 send((uint8_t*)aTxBuffer, 2);
1143 aTxBuffer[0] = 0x72;
1144 aTxBuffer[1] = 0x00;
1145 send((uint8_t*)aTxBuffer, 2);
1146
1147 aTxBuffer[0] = 0x70;
1148 aTxBuffer[1] = 0x53;
1149 send((uint8_t*)aTxBuffer, 2);
1150 aTxBuffer[0] = 0x72;
1151 aTxBuffer[1] = 0x25;
1152 send((uint8_t*)aTxBuffer, 2);
1153
1154 aTxBuffer[0] = 0x70;
1155 aTxBuffer[1] = 0x54;
1156 send((uint8_t*)aTxBuffer, 2);
1157 aTxBuffer[0] = 0x72;
1158 aTxBuffer[1] = 0x29;
1159 send((uint8_t*)aTxBuffer, 2);
1160
1161 aTxBuffer[0] = 0x70;
1162 aTxBuffer[1] = 0x55;
1163 send((uint8_t*)aTxBuffer, 2);
1164 aTxBuffer[0] = 0x72;
1165 aTxBuffer[1] = 0x24;
1166 send((uint8_t*)aTxBuffer, 2);
1167
1168 aTxBuffer[0] = 0x70;
1169 aTxBuffer[1] = 0x56;
1170 send((uint8_t*)aTxBuffer, 2);
1171 aTxBuffer[0] = 0x72;
1172 aTxBuffer[1] = 0x2E;
1173 send((uint8_t*)aTxBuffer, 2);
1174
1175 aTxBuffer[0] = 0x70;
1176 aTxBuffer[1] = 0x60;
1177 send((uint8_t*)aTxBuffer, 2);
1178 aTxBuffer[0] = 0x72;
1179 aTxBuffer[1] = 0x00;
1180 send((uint8_t*)aTxBuffer, 2);
1181
1182 aTxBuffer[0] = 0x70;
1183 aTxBuffer[1] = 0x61;
1184 send((uint8_t*)aTxBuffer, 2);
1185 aTxBuffer[0] = 0x72;
1186 aTxBuffer[1] = 0x3F;
1187 send((uint8_t*)aTxBuffer, 2);
1188
1189 aTxBuffer[0] = 0x70;
1190 aTxBuffer[1] = 0x62;
1191 send((uint8_t*)aTxBuffer, 2);
1192 aTxBuffer[0] = 0x72;
1193 aTxBuffer[1] = 0x2F;
1194 send((uint8_t*)aTxBuffer, 2);
1195
1196 aTxBuffer[0] = 0x70;
1197 aTxBuffer[1] = 0x63;
1198 send((uint8_t*)aTxBuffer, 2);
1199 aTxBuffer[0] = 0x72;
1200 aTxBuffer[1] = 0x29;
1201 send((uint8_t*)aTxBuffer, 2);
1202
1203 aTxBuffer[0] = 0x70;
1204 aTxBuffer[1] = 0x64;
1205 send((uint8_t*)aTxBuffer, 2);
1206 aTxBuffer[0] = 0x72;
1207 aTxBuffer[1] = 0x29;
1208 send((uint8_t*)aTxBuffer, 2);
1209
1210 aTxBuffer[0] = 0x70;
1211 aTxBuffer[1] = 0x65;
1212 send((uint8_t*)aTxBuffer, 2);
1213 aTxBuffer[0] = 0x72;
1214 aTxBuffer[1] = 0x21;
1215 send((uint8_t*)aTxBuffer, 2);
1216
1217 aTxBuffer[0] = 0x70;
1218 aTxBuffer[1] = 0x66;
1219 send((uint8_t*)aTxBuffer, 2);
1220 aTxBuffer[0] = 0x72;
1221 aTxBuffer[1] = 0x3F;
1222 send((uint8_t*)aTxBuffer, 2);
1223
1224 brightness_screen1=1;
1225 }
1226 }
1227
1228 void display_1_brightness_cave(void)
1229 {
1230 uint8_t aTxBuffer[3];
1231
1232 if (brightness_screen1 == 0)
1233 {
1234 // do nothing
1235 }
1236 else
1237 {
1238 // GAMMA L=50
1239 aTxBuffer[0] = 0x70;
1240 aTxBuffer[1] = 0x40;
1241 send((uint8_t*)aTxBuffer, 2);
1242 aTxBuffer[0] = 0x72;
1243 aTxBuffer[1] = 0x00;
1244 send((uint8_t*)aTxBuffer, 2);
1245
1246 aTxBuffer[0] = 0x70;
1247 aTxBuffer[1] = 0x41;
1248 send((uint8_t*)aTxBuffer, 2);
1249 aTxBuffer[0] = 0x72;
1250 aTxBuffer[1] = 0x3F;
1251 send((uint8_t*)aTxBuffer, 2);
1252
1253 aTxBuffer[0] = 0x70;
1254 aTxBuffer[1] = 0x42;
1255 send((uint8_t*)aTxBuffer, 2);
1256 aTxBuffer[0] = 0x72;
1257 aTxBuffer[1] = 0x3C;
1258 send((uint8_t*)aTxBuffer, 2);
1259
1260 aTxBuffer[0] = 0x70;
1261 aTxBuffer[1] = 0x43;
1262 send((uint8_t*)aTxBuffer, 2);
1263 aTxBuffer[0] = 0x72;
1264 aTxBuffer[1] = 0x2C;
1265 send((uint8_t*)aTxBuffer, 2);
1266
1267 aTxBuffer[0] = 0x70;
1268 aTxBuffer[1] = 0x44;
1269 send((uint8_t*)aTxBuffer, 2);
1270 aTxBuffer[0] = 0x72;
1271 aTxBuffer[1] = 0x2D;
1272 send((uint8_t*)aTxBuffer, 2);
1273
1274 aTxBuffer[0] = 0x70;
1275 aTxBuffer[1] = 0x45;
1276 send((uint8_t*)aTxBuffer, 2);
1277 aTxBuffer[0] = 0x72;
1278 aTxBuffer[1] = 0x27;
1279 send((uint8_t*)aTxBuffer, 2);
1280
1281 aTxBuffer[0] = 0x70;
1282 aTxBuffer[1] = 0x46;
1283 send((uint8_t*)aTxBuffer, 2);
1284 aTxBuffer[0] = 0x72;
1285 aTxBuffer[1] = 0x24;
1286 send((uint8_t*)aTxBuffer, 2);
1287
1288 aTxBuffer[0] = 0x70;
1289 aTxBuffer[1] = 0x50;
1290 send((uint8_t*)aTxBuffer, 2);
1291 aTxBuffer[0] = 0x72;
1292 aTxBuffer[1] = 0x00;
1293 send((uint8_t*)aTxBuffer, 2);
1294
1295 aTxBuffer[0] = 0x70;
1296 aTxBuffer[1] = 0x51;
1297 send((uint8_t*)aTxBuffer, 2);
1298 aTxBuffer[0] = 0x72;
1299 aTxBuffer[1] = 0x00;
1300 send((uint8_t*)aTxBuffer, 2);
1301
1302 aTxBuffer[0] = 0x70;
1303 aTxBuffer[1] = 0x52;
1304 send((uint8_t*)aTxBuffer, 2);
1305 aTxBuffer[0] = 0x72;
1306 aTxBuffer[1] = 0x00;
1307 send((uint8_t*)aTxBuffer, 2);
1308
1309 aTxBuffer[0] = 0x70;
1310 aTxBuffer[1] = 0x53;
740 send((uint8_t*)aTxBuffer, 2); 1311 send((uint8_t*)aTxBuffer, 2);
741 aTxBuffer[0] = 0x72; 1312 aTxBuffer[0] = 0x72;
742 aTxBuffer[1] = 0x22; 1313 aTxBuffer[1] = 0x22;
743 send((uint8_t*)aTxBuffer, 2); 1314 send((uint8_t*)aTxBuffer, 2);
744 1315
745 aTxBuffer[0] = 0x70; 1316 aTxBuffer[0] = 0x70;
746 aTxBuffer[1] = OLED_AMP_SET_18h; 1317 aTxBuffer[1] = 0x54;
747 send((uint8_t*)aTxBuffer, 2); 1318 send((uint8_t*)aTxBuffer, 2);
748 aTxBuffer[0] = 0x72; 1319 aTxBuffer[0] = 0x72;
749 aTxBuffer[1] = 0x22; 1320 aTxBuffer[1] = 0x2A;
750 send((uint8_t*)aTxBuffer, 2); 1321 send((uint8_t*)aTxBuffer, 2);
751 1322
752 aTxBuffer[0] = 0x70; 1323 aTxBuffer[0] = 0x70;
753 aTxBuffer[1] = OLED_GAMMA_AMP_19h; 1324 aTxBuffer[1] = 0x55;
754 send((uint8_t*)aTxBuffer, 2); 1325 send((uint8_t*)aTxBuffer, 2);
755 aTxBuffer[0] = 0x72; 1326 aTxBuffer[0] = 0x72;
756 aTxBuffer[1] = 0x02; 1327 aTxBuffer[1] = 0x27;
757 send((uint8_t*)aTxBuffer, 2); 1328 send((uint8_t*)aTxBuffer, 2);
758 1329
759 aTxBuffer[0] = 0x70; 1330 aTxBuffer[0] = 0x70;
760 aTxBuffer[1] = OLED_POWER_CONTROL2_1Ah; 1331 aTxBuffer[1] = 0x56;
761 send((uint8_t*)aTxBuffer, 2); 1332 send((uint8_t*)aTxBuffer, 2);
762 aTxBuffer[0] = 0x72; 1333 aTxBuffer[0] = 0x72;
763 aTxBuffer[1] = 0x00; 1334 aTxBuffer[1] = 0x23;
764 send((uint8_t*)aTxBuffer, 2); 1335 send((uint8_t*)aTxBuffer, 2);
765 1336
766 /* 1337 aTxBuffer[0] = 0x70;
767 aTxBuffer[0] = 0x70; 1338 aTxBuffer[1] = 0x60;
768 aTxBuffer[1] = OLED_POWER_CONTROL2_1Bh; 1339 send((uint8_t*)aTxBuffer, 2);
769 send((uint8_t*)aTxBuffer, 2); 1340 aTxBuffer[0] = 0x72;
770 aTxBuffer[0] = 0x72; 1341 aTxBuffer[1] = 0x00;
771 aTxBuffer[1] = 0x4B; 1342 send((uint8_t*)aTxBuffer, 2);
772 send((uint8_t*)aTxBuffer, 2); 1343
773 1344 aTxBuffer[0] = 0x70;
774 aTxBuffer[0] = 0x70; 1345 aTxBuffer[1] = 0x61;
775 aTxBuffer[1] = OLED_POWER_CONTROL2_1Ch; 1346 send((uint8_t*)aTxBuffer, 2);
776 send((uint8_t*)aTxBuffer, 2); 1347 aTxBuffer[0] = 0x72;
777 aTxBuffer[0] = 0x72; 1348 aTxBuffer[1] = 0x3F;
778 aTxBuffer[1] = 0x05; 1349 send((uint8_t*)aTxBuffer, 2);
779 send((uint8_t*)aTxBuffer, 2); 1350
780 */ 1351 aTxBuffer[0] = 0x70;
781 1352 aTxBuffer[1] = 0x62;
782 aTxBuffer[0] = 0x70; 1353 send((uint8_t*)aTxBuffer, 2);
783 aTxBuffer[1] = OLED_INTERNAL_LOGIC_VOLTAGE; 1354 aTxBuffer[0] = 0x72;
784 send((uint8_t*)aTxBuffer, 2); 1355 aTxBuffer[1] = 0x3B;
785 aTxBuffer[0] = 0x72; 1356 send((uint8_t*)aTxBuffer, 2);
786 aTxBuffer[1] = 0xA2; 1357
787 send((uint8_t*)aTxBuffer, 2); 1358 aTxBuffer[0] = 0x70;
788 1359 aTxBuffer[1] = 0x63;
789 aTxBuffer[0] = 0x70; 1360 send((uint8_t*)aTxBuffer, 2);
790 aTxBuffer[1] = OLED_POWER_SET; 1361 aTxBuffer[0] = 0x72;
791 send((uint8_t*)aTxBuffer, 2); 1362 aTxBuffer[1] = 0x2C;
792 aTxBuffer[0] = 0x72; 1363 send((uint8_t*)aTxBuffer, 2);
793 aTxBuffer[1] = 0x00; 1364
794 send((uint8_t*)aTxBuffer, 2); 1365 aTxBuffer[0] = 0x70;
795 1366 aTxBuffer[1] = 0x64;
796 aTxBuffer[0] = 0x70; 1367 send((uint8_t*)aTxBuffer, 2);
797 aTxBuffer[1] = OLED_POWER_SET2; 1368 aTxBuffer[0] = 0x72;
798 send((uint8_t*)aTxBuffer, 2); 1369 aTxBuffer[1] = 0x2B;
799 aTxBuffer[0] = 0x72; 1370 send((uint8_t*)aTxBuffer, 2);
800 aTxBuffer[1] = 0x77; 1371
801 send((uint8_t*)aTxBuffer, 2); 1372 aTxBuffer[0] = 0x70;
802 1373 aTxBuffer[1] = 0x65;
803 1374 send((uint8_t*)aTxBuffer, 2);
804 aTxBuffer[0] = 0x70; 1375 aTxBuffer[0] = 0x72;
805 aTxBuffer[1] = OLED_DISPLAY_CONDITION_SET_26h; 1376 aTxBuffer[1] = 0x24;
806 send((uint8_t*)aTxBuffer, 2); 1377 send((uint8_t*)aTxBuffer, 2);
807 aTxBuffer[0] = 0x72; 1378
808 aTxBuffer[1] = 0xA0; 1379 aTxBuffer[0] = 0x70;
809 send((uint8_t*)aTxBuffer, 2); 1380 aTxBuffer[1] = 0x66;
810 1381 send((uint8_t*)aTxBuffer, 2);
811 aTxBuffer[0] = 0x70; 1382 aTxBuffer[0] = 0x72;
812 aTxBuffer[1] = OLED_STB_BY_OFF; 1383 aTxBuffer[1] = 0x31;
813 send((uint8_t*)aTxBuffer, 2); 1384 send((uint8_t*)aTxBuffer, 2);
814 aTxBuffer[0] = 0x72; 1385
815 aTxBuffer[1] = 0xA0; 1386 brightness_screen1=0;
816 send((uint8_t*)aTxBuffer, 2); 1387 }
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 } 1388 }
828 1389
829 static void Display_Error_Handler(void) 1390 static void Display_Error_Handler(void)
830 { 1391 {
831 //while(1) 1392 //while(1)