LibDriver ST7789
Loading...
Searching...
No Matches
driver_st7789_display_test.c
Go to the documentation of this file.
1
36
39#include <stdlib.h>
40
41static st7789_handle_t gs_handle;
42
51{
52 uint8_t res;
53 uint8_t reg;
54 uint16_t i;
55 uint16_t j;
56 uint8_t param[14];
57 uint8_t params[64];
58 st7789_info_t info;
59 char test_str1[] ="Test";
60 char test_str2[] ="st7789";
61 char test_str3[] ="ABCabc";
62 char test_str4[] ="123?!#$%";
63
64 /* link functions */
77
78 /* st7789 info */
79 res = st7789_info(&info);
80 if (res != 0)
81 {
82 st7789_interface_debug_print("st7789: get info failed.\n");
83
84 return 1;
85 }
86 else
87 {
88 /* print chip information */
89 st7789_interface_debug_print("st7789: chip is %s.\n", info.chip_name);
90 st7789_interface_debug_print("st7789: manufacturer is %s.\n", info.manufacturer_name);
91 st7789_interface_debug_print("st7789: interface is %s.\n", info.interface);
92 st7789_interface_debug_print("st7789: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
93 st7789_interface_debug_print("st7789: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
94 st7789_interface_debug_print("st7789: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
95 st7789_interface_debug_print("st7789: max current is %0.2fmA.\n", info.max_current_ma);
96 st7789_interface_debug_print("st7789: max temperature is %0.1fC.\n", info.temperature_max);
97 st7789_interface_debug_print("st7789: min temperature is %0.1fC.\n", info.temperature_min);
98 }
99
100 /* start display test */
101 st7789_interface_debug_print("st7789: start display test.\n");
102
103 /* st7789 init */
104 res = st7789_init(&gs_handle);
105 if (res != 0)
106 {
107 st7789_interface_debug_print("st7789: init failed.\n");
108
109 return 1;
110 }
111
112 /* set column */
113 res = st7789_set_column(&gs_handle, 240);
114 if (res != 0)
115 {
116 st7789_interface_debug_print("st7789: set column failed.\n");
117 (void)st7789_deinit(&gs_handle);
118
119 return 1;
120 }
121
122 /* set row */
123 res = st7789_set_row(&gs_handle, 320);
124 if (res != 0)
125 {
126 st7789_interface_debug_print("st7789: set row failed.\n");
127 (void)st7789_deinit(&gs_handle);
128
129 return 1;
130 }
131
132 /* sleep out */
133 res = st7789_sleep_out(&gs_handle);
134 if (res != 0)
135 {
136 st7789_interface_debug_print("st7789: sleep out failed.\n");
137 (void)st7789_deinit(&gs_handle);
138
139 return 1;
140 }
141
142 /* idle mode off */
143 res = st7789_idle_mode_off(&gs_handle);
144 if (res != 0)
145 {
146 st7789_interface_debug_print("st7789: idle mode off failed.\n");
147 (void)st7789_deinit(&gs_handle);
148
149 return 1;
150 }
151
152 /* normal display mode on */
153 res = st7789_normal_display_mode_on(&gs_handle);
154 if (res != 0)
155 {
156 st7789_interface_debug_print("st7789: normal display mode on failed.\n");
157 (void)st7789_deinit(&gs_handle);
158
159 return 1;
160 }
161
162 /* display inversion on */
163 res = st7789_display_inversion_on(&gs_handle);
164 if (res != 0)
165 {
166 st7789_interface_debug_print("st7789: display inversion on failed.\n");
167 (void)st7789_deinit(&gs_handle);
168
169 return 1;
170 }
171
172 /* set gamma */
173 res = st7789_set_gamma(&gs_handle, ST7789_GAMMA_CURVE_1);
174 if (res != 0)
175 {
176 st7789_interface_debug_print("st7789: set gamma failed.\n");
177 (void)st7789_deinit(&gs_handle);
178
179 return 1;
180 }
181
182 /* set memory data access control */
186 if (res != 0)
187 {
188 st7789_interface_debug_print("st7789: set memory data access control failed.\n");
189 (void)st7789_deinit(&gs_handle);
190
191 return 1;
192 }
193
194 /* 262k 16bit */
196 if (res != 0)
197 {
198 st7789_interface_debug_print("st7789: set interface pixel format failed.\n");
199 (void)st7789_deinit(&gs_handle);
200
201 return 1;
202 }
203
204 /* max brightness */
205 res = st7789_set_display_brightness(&gs_handle, 0xFF);
206 if (res != 0)
207 {
208 st7789_interface_debug_print("st7789: set display brightness failed.\n");
209 (void)st7789_deinit(&gs_handle);
210
211 return 1;
212 }
213
214 /* disable brightness control */
216 if (res != 0)
217 {
218 st7789_interface_debug_print("st7789: set display control failed.\n");
219 (void)st7789_deinit(&gs_handle);
220
221 return 1;
222 }
223
224 /* enable color enhancement */
227 if (res != 0)
228 {
229 st7789_interface_debug_print("st7789: set brightness control and color enhancement failed.\n");
230 (void)st7789_deinit(&gs_handle);
231
232 return 1;
233 }
234
235 /* set 0x00 */
236 res = st7789_set_cabc_minimum_brightness(&gs_handle, 0x00);
237 if (res != 0)
238 {
239 st7789_interface_debug_print("st7789: set cabc minimum brightness failed.\n");
240 (void)st7789_deinit(&gs_handle);
241
242 return 1;
243 }
244
245 /* set ram control */
246 res = st7789_set_ram_control(&gs_handle,
253 if (res != 0)
254 {
255 st7789_interface_debug_print("st7789: set ram control failed.\n");
256 (void)st7789_deinit(&gs_handle);
257
258 return 1;
259 }
260
261 /* set rgb interface control */
262 res = st7789_set_rgb_interface_control(&gs_handle,
269 0x02,
270 0x14);
271 if (res != 0)
272 {
273 st7789_interface_debug_print("st7789: set rgb interface control failed.\n");
274 (void)st7789_deinit(&gs_handle);
275
276 return 1;
277 }
278
279 /* set porch */
280 res = st7789_set_porch(&gs_handle,
281 0x0C,
282 0x0C,
284 0x03,
285 0x03,
286 0x03,
287 0x03);
288 if (res != 0)
289 {
290 st7789_interface_debug_print("st7789: set porch failed.\n");
291 (void)st7789_deinit(&gs_handle);
292
293 return 1;
294 }
295
296 /* set frame rate control */
297 res = st7789_set_frame_rate_control(&gs_handle,
301 0x0F,
303 0x0F);
304 if (res != 0)
305 {
306 st7789_interface_debug_print("st7789: set frame rate control failed.\n");
307 (void)st7789_deinit(&gs_handle);
308
309 return 1;
310 }
311
312 /* set partial mode control */
313 res = st7789_set_partial_mode_control(&gs_handle,
317 if (res != 0)
318 {
319 st7789_interface_debug_print("st7789: set partial mode control failed.\n");
320 (void)st7789_deinit(&gs_handle);
321
322 return 1;
323 }
324
325 /* set gate control */
327 if (res != 0)
328 {
329 st7789_interface_debug_print("st7789: set gate control failed.\n");
330 (void)st7789_deinit(&gs_handle);
331
332 return 1;
333 }
334
335 /* set gate on timing adjustment */
336 res = st7789_set_gate_on_timing_adjustment(&gs_handle,
337 0x22,
338 0x07,
339 0x05);
340 if (res != 0)
341 {
342 st7789_interface_debug_print("st7789: set gate on timing adjustment failed.\n");
343 (void)st7789_deinit(&gs_handle);
344
345 return 1;
346 }
347
348 /* enable digital gamma */
350 if (res != 0)
351 {
352 st7789_interface_debug_print("st7789: set digital gamma failed.\n");
353 (void)st7789_deinit(&gs_handle);
354
355 return 1;
356 }
357
358 /* vcom convert to register */
359 res = st7789_vcom_convert_to_register(&gs_handle, 1.625f, &reg);
360 if (res != 0)
361 {
362 st7789_interface_debug_print("st7789: vcom convert to register failed.\n");
363 (void)st7789_deinit(&gs_handle);
364
365 return 1;
366 }
367
368 /* set vcoms */
369 res = st7789_set_vcoms(&gs_handle, reg);
370 if (res != 0)
371 {
372 st7789_interface_debug_print("st7789: set vcoms failed.\n");
373 (void)st7789_deinit(&gs_handle);
374
375 return 1;
376 }
377
378 /* set lcm control */
379 res = st7789_set_lcm_control(&gs_handle,
387 if (res != 0)
388 {
389 st7789_interface_debug_print("st7789: set lcm control failed.\n");
390 (void)st7789_deinit(&gs_handle);
391
392 return 1;
393 }
394
395 /* from cmd */
397 if (res != 0)
398 {
399 st7789_interface_debug_print("st7789: set vdv vrh from failed.\n");
400 (void)st7789_deinit(&gs_handle);
401
402 return 1;
403 }
404
405 /* vrhs convert to register */
406 res = st7789_vrhs_convert_to_register(&gs_handle, 4.8f, &reg);
407 if (res != 0)
408 {
409 st7789_interface_debug_print("st7789: vrhs convert to register failed.\n");
410 (void)st7789_deinit(&gs_handle);
411
412 return 1;
413 }
414
415 /* set vrhs */
416 res = st7789_set_vrhs(&gs_handle, reg);
417 if (res != 0)
418 {
419 st7789_interface_debug_print("st7789: set vrhs failed.\n");
420 (void)st7789_deinit(&gs_handle);
421
422 return 1;
423 }
424
425 /* vdv convert to register */
426 res = st7789_vdv_convert_to_register(&gs_handle, 0.0f, &reg);
427 if (res != 0)
428 {
429 st7789_interface_debug_print("st7789: vdv convert to register failed.\n");
430 (void)st7789_deinit(&gs_handle);
431
432 return 1;
433 }
434
435 /* set vdv */
436 res = st7789_set_vdv(&gs_handle, reg);
437 if (res != 0)
438 {
439 st7789_interface_debug_print("st7789: set vdv failed.\n");
440 (void)st7789_deinit(&gs_handle);
441
442 return 1;
443 }
444
445 /* vcoms offset convert to register */
446 res = st7789_vcoms_offset_convert_to_register(&gs_handle, 0.0f, &reg);
447 if (res != 0)
448 {
449 st7789_interface_debug_print("st7789: vcoms offset convert to register failed.\n");
450 (void)st7789_deinit(&gs_handle);
451
452 return 1;
453 }
454
455 /* set vcoms offset */
456 res = st7789_set_vcoms_offset(&gs_handle, reg);
457 if (res != 0)
458 {
459 st7789_interface_debug_print("st7789: set vcoms offset failed.\n");
460 (void)st7789_deinit(&gs_handle);
461
462 return 1;
463 }
464
465 /* set frame rate */
467 if (res != 0)
468 {
469 st7789_interface_debug_print("st7789: set frame rate failed.\n");
470 (void)st7789_deinit(&gs_handle);
471
472 return 1;
473 }
474
475 /* set cabc control */
476 res = st7789_set_cabc_control(&gs_handle,
481 if (res != 0)
482 {
483 st7789_interface_debug_print("st7789: set cabc control failed.\n");
484 (void)st7789_deinit(&gs_handle);
485
486 return 1;
487 }
488
489 /* set pwm frequency */
491 if (res != 0)
492 {
493 st7789_interface_debug_print("st7789: set pwm frequency failed.\n");
494 (void)st7789_deinit(&gs_handle);
495
496 return 1;
497 }
498
499 /* set power control 1 */
501 if (res != 0)
502 {
503 st7789_interface_debug_print("st7789: set power control 1 failed.\n");
504 (void)st7789_deinit(&gs_handle);
505
506 return 1;
507 }
508
509 /* set command 2 disable */
511 if (res != 0)
512 {
513 st7789_interface_debug_print("st7789: set command 2 enable failed.\n");
514 (void)st7789_deinit(&gs_handle);
515
516 return 1;
517 }
518
519 /* set positive voltage gamma control */
520 param[0] = 0xD0;
521 param[1] = 0x04;
522 param[2] = 0x0D;
523 param[3] = 0x11;
524 param[4] = 0x13;
525 param[5] = 0x2B;
526 param[6] = 0x3F;
527 param[7] = 0x54;
528 param[8] = 0x4C;
529 param[9] = 0x18;
530 param[10] = 0x0D;
531 param[11] = 0x0B;
532 param[12] = 0x1F;
533 param[13] = 0x23;
534 res = st7789_set_positive_voltage_gamma_control(&gs_handle, param);
535 if (res != 0)
536 {
537 st7789_interface_debug_print("st7789: set positive voltage gamma control failed.\n");
538 (void)st7789_deinit(&gs_handle);
539
540 return 1;
541 }
542
543 /* set negative voltage gamma control */
544 param[0] = 0xD0;
545 param[1] = 0x04;
546 param[2] = 0x0C;
547 param[3] = 0x11;
548 param[4] = 0x13;
549 param[5] = 0x2C;
550 param[6] = 0x3F;
551 param[7] = 0x44;
552 param[8] = 0x51;
553 param[9] = 0x2F;
554 param[10] = 0x1F;
555 param[11] = 0x1F;
556 param[12] = 0x20;
557 param[13] = 0x23;
558 res = st7789_set_negative_voltage_gamma_control(&gs_handle, param);
559 if (res != 0)
560 {
561 st7789_interface_debug_print("st7789: set negative voltage gamma control failed.\n");
562 (void)st7789_deinit(&gs_handle);
563
564 return 1;
565 }
566
567 /* create the table */
568 for (i = 0; i < 64; i++)
569 {
570 params[i] = i * 4;
571 }
572
573 /* set digital gamma look up table red */
574 res = st7789_set_digital_gamma_look_up_table_red(&gs_handle, params);
575 if (res != 0)
576 {
577 st7789_interface_debug_print("st7789: set digital gamma look up table red ailed.\n");
578 (void)st7789_deinit(&gs_handle);
579
580 return 1;
581 }
582
583 /* set digital gamma look up table blue */
584 res = st7789_set_digital_gamma_look_up_table_blue(&gs_handle, params);
585 if (res != 0)
586 {
587 st7789_interface_debug_print("st7789: set digital gamma look up table blue ailed.\n");
588 (void)st7789_deinit(&gs_handle);
589
590 return 1;
591 }
592
593 /* gate line convert to register */
594 res = st7789_gate_line_convert_to_register(&gs_handle, 320, &reg);
595 if (res != 0)
596 {
597 st7789_interface_debug_print("st7789: gate line convert to register failed.\n");
598 (void)st7789_deinit(&gs_handle);
599
600 return 1;
601 }
602
603 /* set gate */
604 res = st7789_set_gate(&gs_handle,
605 reg,
606 0x00,
609 if (res != 0)
610 {
611 st7789_interface_debug_print("st7789: set gate failed.\n");
612 (void)st7789_deinit(&gs_handle);
613
614 return 1;
615 }
616
617 /* disable spi2 */
619 if (res != 0)
620 {
621 st7789_interface_debug_print("st7789: set spi2 enable failed.\n");
622 (void)st7789_deinit(&gs_handle);
623
624 return 1;
625 }
626
627 /* set power control 2 */
629 if (res != 0)
630 {
631 st7789_interface_debug_print("st7789: set power control 2 failed.\n");
632 (void)st7789_deinit(&gs_handle);
633
634 return 1;
635 }
636
637 /* set equalize time control */
638 res = st7789_set_equalize_time_control(&gs_handle, 0x11, 0x11, 0x08);
639 if (res != 0)
640 {
641 st7789_interface_debug_print("st7789: set equalize time control failed.\n");
642 (void)st7789_deinit(&gs_handle);
643
644 return 1;
645 }
646
647 /* disable program mode */
649 if (res != 0)
650 {
651 st7789_interface_debug_print("st7789: set program mode enable ailed.\n");
652 (void)st7789_deinit(&gs_handle);
653
654 return 1;
655 }
656
657 /* display on */
658 res = st7789_display_on(&gs_handle);
659 if (res != 0)
660 {
661 st7789_interface_debug_print("st7789: display on failed.\n");
662 (void)st7789_deinit(&gs_handle);
663
664 return 1;
665 }
666
667 /* clear */
668 res = st7789_clear(&gs_handle);
669 if (res != 0)
670 {
671 st7789_interface_debug_print("st7789: clear failed.\n");
672 (void)st7789_deinit(&gs_handle);
673
674 return 1;
675 }
676
677 /* font 12 test */
678 st7789_interface_debug_print("st7789: font 12 test.\n");
679
680 /* write string */
681 res = st7789_write_string(&gs_handle, 0, 0, test_str1, (uint16_t)strlen(test_str1), 0xF800U, ST7789_FONT_12);
682 if (res != 0)
683 {
684 st7789_interface_debug_print("st7789: write string failed.\n");
685 (void)st7789_deinit(&gs_handle);
686
687 return 1;
688 }
689
690 /* write string */
691 res = st7789_write_string(&gs_handle, 0, 50, test_str2, (uint16_t)strlen(test_str2), 0x07E0U, ST7789_FONT_12);
692 if (res != 0)
693 {
694 st7789_interface_debug_print("st7789: write string failed.\n");
695 (void)st7789_deinit(&gs_handle);
696
697 return 1;
698 }
699
700 /* write string */
701 res = st7789_write_string(&gs_handle, 0, 100, test_str3, (uint16_t)strlen(test_str3), 0x003FU, ST7789_FONT_12);
702 if (res != 0)
703 {
704 st7789_interface_debug_print("st7789: write string failed.\n");
705 (void)st7789_deinit(&gs_handle);
706
707 return 1;
708 }
709
710 /* write string */
711 res = st7789_write_string(&gs_handle, 0, 150, test_str4, (uint16_t)strlen(test_str4), 0xFFFFU, ST7789_FONT_12);
712 if (res != 0)
713 {
714 st7789_interface_debug_print("st7789: write string failed.\n");
715 (void)st7789_deinit(&gs_handle);
716
717 return 1;
718 }
719
720 /* delay 1000ms */
722
723 /* clear */
724 res = st7789_clear(&gs_handle);
725 if (res != 0)
726 {
727 st7789_interface_debug_print("st7789: clear failed.\n");
728 (void)st7789_deinit(&gs_handle);
729
730 return 1;
731 }
732
733 /* font 16 test */
734 st7789_interface_debug_print("st7789: font 16 test.\n");
735
736 /* write string */
737 res = st7789_write_string(&gs_handle, 0, 0, test_str1, (uint16_t)strlen(test_str1), 0xF800U, ST7789_FONT_16);
738 if (res != 0)
739 {
740 st7789_interface_debug_print("st7789: write string failed.\n");
741 (void)st7789_deinit(&gs_handle);
742
743 return 1;
744 }
745
746 /* write string */
747 res = st7789_write_string(&gs_handle, 0, 50, test_str2, (uint16_t)strlen(test_str2), 0x07E0U, ST7789_FONT_16);
748 if (res != 0)
749 {
750 st7789_interface_debug_print("st7789: write string failed.\n");
751 (void)st7789_deinit(&gs_handle);
752
753 return 1;
754 }
755
756 /* write string */
757 res = st7789_write_string(&gs_handle, 0, 100, test_str3, (uint16_t)strlen(test_str3), 0x003FU, ST7789_FONT_16);
758 if (res != 0)
759 {
760 st7789_interface_debug_print("st7789: write string failed.\n");
761 (void)st7789_deinit(&gs_handle);
762
763 return 1;
764 }
765
766 /* write string */
767 res = st7789_write_string(&gs_handle, 0, 150, test_str4, (uint16_t)strlen(test_str4), 0xFFFFU, ST7789_FONT_16);
768 if (res != 0)
769 {
770 st7789_interface_debug_print("st7789: write string failed.\n");
771 (void)st7789_deinit(&gs_handle);
772
773 return 1;
774 }
775
776 /* delay 1000ms */
778
779 /* clear */
780 res = st7789_clear(&gs_handle);
781 if (res != 0)
782 {
783 st7789_interface_debug_print("st7789: clear failed.\n");
784 (void)st7789_deinit(&gs_handle);
785
786 return 1;
787 }
788
789 /* font 24 test */
790 st7789_interface_debug_print("st7789: font 24 test.\n");
791
792 /* write string */
793 res = st7789_write_string(&gs_handle, 0, 0, test_str1, (uint16_t)strlen(test_str1), 0xF800U, ST7789_FONT_24);
794 if (res != 0)
795 {
796 st7789_interface_debug_print("st7789: write string failed.\n");
797 (void)st7789_deinit(&gs_handle);
798
799 return 1;
800 }
801
802 /* write string */
803 res = st7789_write_string(&gs_handle, 0, 50, test_str2, (uint16_t)strlen(test_str2), 0x07E0U, ST7789_FONT_24);
804 if (res != 0)
805 {
806 st7789_interface_debug_print("st7789: write string failed.\n");
807 (void)st7789_deinit(&gs_handle);
808
809 return 1;
810 }
811
812 /* write string */
813 res = st7789_write_string(&gs_handle, 0, 100, test_str3, (uint16_t)strlen(test_str3), 0x003FU, ST7789_FONT_24);
814 if (res != 0)
815 {
816 st7789_interface_debug_print("st7789: write string failed.\n");
817 (void)st7789_deinit(&gs_handle);
818
819 return 1;
820 }
821
822 /* write string */
823 res = st7789_write_string(&gs_handle, 0, 150, test_str4, (uint16_t)strlen(test_str4), 0xFFFFU, ST7789_FONT_24);
824 if (res != 0)
825 {
826 st7789_interface_debug_print("st7789: write string failed.\n");
827 (void)st7789_deinit(&gs_handle);
828
829 return 1;
830 }
831
832 /* delay 1000ms */
834
835 /* clear */
836 res = st7789_clear(&gs_handle);
837 if (res != 0)
838 {
839 st7789_interface_debug_print("st7789: clear failed.\n");
840 (void)st7789_deinit(&gs_handle);
841
842 return 1;
843 }
844
845 /* rectangle test */
846 st7789_interface_debug_print("st7789: rectangle test.\n");
847
848 /* fill rect */
849 res = st7789_fill_rect(&gs_handle, 0, 0, 100, 100, 0xF800U);
850 if (res != 0)
851 {
852 st7789_interface_debug_print("st7789: fill rect failed.\n");
853 (void)st7789_deinit(&gs_handle);
854
855 return 1;
856 }
857
858 /* fill rect */
859 res = st7789_fill_rect(&gs_handle, 0, 150, 100, 200, 0x003FU);
860 if (res != 0)
861 {
862 st7789_interface_debug_print("st7789: fill rect failed.\n");
863 (void)st7789_deinit(&gs_handle);
864
865 return 1;
866 }
867
868 /* fill rect */
869 res = st7789_fill_rect(&gs_handle, 0, 280, 200,310, 0x08E0U);
870 if (res != 0)
871 {
872 st7789_interface_debug_print("st7789: fill rect failed.\n");
873 (void)st7789_deinit(&gs_handle);
874
875 return 1;
876 }
877
878 /* delay 1000ms */
880
881 /* clear */
882 res = st7789_clear(&gs_handle);
883 if (res != 0)
884 {
885 st7789_interface_debug_print("st7789: clear failed.\n");
886 (void)st7789_deinit(&gs_handle);
887
888 return 1;
889 }
890
891 /* rand point test */
892 st7789_interface_debug_print("st7789: rand point test.\n");
893
894 for (i = 0; i < 240; i++)
895 {
896 for (j = 0; j < 320; j++)
897 {
898 if ((rand() % 2) != 0)
899 {
900 res = st7789_draw_point(&gs_handle, i, j, 0xFFFFU);
901 if (res != 0)
902 {
903 st7789_interface_debug_print("st7789: draw point failed.\n");
904 (void)st7789_deinit(&gs_handle);
905
906 return 1;
907 }
908 }
909 }
910 }
911
912 /* delay 1000ms */
914
915 /* clear */
916 res = st7789_clear(&gs_handle);
917 if (res != 0)
918 {
919 st7789_interface_debug_print("st7789: clear failed.\n");
920 (void)st7789_deinit(&gs_handle);
921
922 return 1;
923 }
924
925 /* picture test */
926 st7789_interface_debug_print("st7789: picture test.\n");
927
928 /* draw picture */
929 res = st7789_draw_picture_16bits(&gs_handle, 0, 0, 239, 319, (uint16_t *)gsc_image);
930 if (res != 0)
931 {
932 st7789_interface_debug_print("st7789: draw picture 16bits failed.\n");
933 (void)st7789_deinit(&gs_handle);
934
935 return 1;
936 }
937
938 /* delay 1000ms */
940
941 /* clear */
942 res = st7789_clear(&gs_handle);
943 if (res != 0)
944 {
945 st7789_interface_debug_print("st7789: clear failed.\n");
946 (void)st7789_deinit(&gs_handle);
947
948 return 1;
949 }
950
951 /* finish display test */
952 st7789_interface_debug_print("st7789: finish display test.\n");
953 (void)st7789_deinit(&gs_handle);
954
955 return 0;
956}
driver st7789 display image header file
driver st7789 display test header file
uint8_t st7789_vrhs_convert_to_register(st7789_handle_t *handle, float v, uint8_t *reg)
convert the vrhs to the register raw data
uint8_t st7789_set_gate_on_timing_adjustment(st7789_handle_t *handle, uint8_t gate_on_timing_adjustment, uint8_t gate_off_timing_adjustment_rgb, uint8_t gate_off_timing_adjustment)
set gate on timing adjustment
uint8_t st7789_vdv_convert_to_register(st7789_handle_t *handle, float v, uint8_t *reg)
convert the vdv to the register raw data
uint8_t st7789_set_vcoms_offset(st7789_handle_t *handle, uint8_t offset)
set vcoms offset
uint8_t st7789_set_rgb_interface_control(st7789_handle_t *handle, st7789_direct_rgb_mode_t rgb_mode, st7789_rgb_if_enable_mode_t rgb_if_mode, st7789_pin_level_t vspl, st7789_pin_level_t hspl, st7789_pin_level_t dpl, st7789_pin_level_t epl, uint8_t vbp, uint8_t hbp)
set rgb interface control
uint8_t st7789_set_program_mode_enable(st7789_handle_t *handle, st7789_bool_t enable)
enable or disable program mode
uint8_t st7789_set_command_2_enable(st7789_handle_t *handle, st7789_bool_t enable)
enable or disable command 2
uint8_t st7789_set_equalize_time_control(st7789_handle_t *handle, uint8_t source_equalize_time, uint8_t source_pre_drive_time, uint8_t gate_equalize_time)
set equalize time control
uint8_t st7789_set_positive_voltage_gamma_control(st7789_handle_t *handle, uint8_t param[14])
set positive voltage gamma control
uint8_t st7789_set_vdv_vrh_from(st7789_handle_t *handle, st7789_vdv_vrh_from_t from)
set vdv vrh from
uint8_t st7789_set_vcoms(st7789_handle_t *handle, uint8_t vcoms)
set vcoms
uint8_t st7789_set_digital_gamma(st7789_handle_t *handle, st7789_bool_t enable)
enable or disable digital gamma
uint8_t st7789_set_frame_rate(st7789_handle_t *handle, st7789_inversion_selection_t selection, st7789_frame_rate_t rate)
set frame rate
uint8_t st7789_set_negative_voltage_gamma_control(st7789_handle_t *handle, uint8_t param[14])
set negative voltage gamma control
uint8_t st7789_set_lcm_control(st7789_handle_t *handle, st7789_bool_t xmy, st7789_bool_t xbgr, st7789_bool_t xinv, st7789_bool_t xmx, st7789_bool_t xmh, st7789_bool_t xmv, st7789_bool_t xgs)
set lcm control
uint8_t st7789_set_power_control_1(st7789_handle_t *handle, st7789_avdd_t avdd, st7789_avcl_t avcl, st7789_vds_t vds)
set power control 1
uint8_t st7789_set_frame_rate_control(st7789_handle_t *handle, st7789_bool_t separate_fr_control, st7789_frame_rate_divided_control_t div_control, st7789_inversion_idle_mode_t idle_mode, uint8_t idle_frame_rate, st7789_inversion_partial_mode_t partial_mode, uint8_t partial_frame_rate)
set frame rate control
uint8_t st7789_set_ram_control(st7789_handle_t *handle, st7789_ram_access_t ram_mode, st7789_display_mode_t display_mode, st7789_frame_type_t frame_type, st7789_data_mode_t data_mode, st7789_rgb_bus_width_t bus_width, st7789_pixel_type_t pixel_type)
set ram control
uint8_t st7789_vcoms_offset_convert_to_register(st7789_handle_t *handle, float v, uint8_t *reg)
convert the vcoms offset to the register raw data
uint8_t st7789_set_gate(st7789_handle_t *handle, uint8_t gate_line_number, uint8_t first_scan_line_number, st7789_gate_scan_mode_t mode, st7789_gate_scan_direction_t direction)
set gate
uint8_t st7789_set_gate_control(st7789_handle_t *handle, st7789_vghs_t vghs, st7789_vgls_t vgls)
set gate control
uint8_t st7789_set_cabc_control(st7789_handle_t *handle, st7789_bool_t led_on, st7789_bool_t led_pwm_init, st7789_bool_t led_pwm_fix, st7789_bool_t led_pwm_polarity)
set cabc control
uint8_t st7789_set_partial_mode_control(st7789_handle_t *handle, st7789_non_display_source_output_level_t level, st7789_non_display_area_scan_mode_t mode, st7789_non_display_frame_frequency_t frequency)
set partial mode control
uint8_t st7789_set_pwm_frequency(st7789_handle_t *handle, st7789_pwm_frequency_t frequency)
set pwm frequency
uint8_t st7789_set_spi2_enable(st7789_handle_t *handle, st7789_bool_t date_lane, st7789_bool_t command_table_2)
set spi2 enable
uint8_t st7789_set_porch(st7789_handle_t *handle, uint8_t back_porch_normal, uint8_t front_porch_normal, st7789_bool_t separate_porch_enable, uint8_t back_porch_idle, uint8_t front_porch_idle, uint8_t back_porch_partial, uint8_t front_porch_partial)
set porch
uint8_t st7789_set_power_control_2(st7789_handle_t *handle, st7789_sbclk_div_t sbclk, st7789_stp14ck_div_t stp14ck)
set power control 2
uint8_t st7789_vcom_convert_to_register(st7789_handle_t *handle, float v, uint8_t *reg)
convert the vcom to the register raw data
uint8_t st7789_set_vdv(st7789_handle_t *handle, uint8_t vdv)
set vdv
uint8_t st7789_set_vrhs(st7789_handle_t *handle, uint8_t vrhs)
set vrhs
uint8_t st7789_set_digital_gamma_look_up_table_blue(st7789_handle_t *handle, uint8_t param[64])
set blue digital gamma look up table
uint8_t st7789_set_digital_gamma_look_up_table_red(st7789_handle_t *handle, uint8_t param[64])
set red digital gamma look up table
uint8_t st7789_gate_line_convert_to_register(st7789_handle_t *handle, uint16_t l, uint8_t *reg)
convert the gate line to the register raw data
@ ST7789_FRAME_RATE_60_HZ
@ ST7789_VDS_2P3_V
@ ST7789_RGB_BUS_WIDTH_18_BIT
@ ST7789_AVDD_6P8_V
@ ST7789_STP14CK_DIV_6
@ ST7789_VDV_VRH_FROM_CMD
@ ST7789_FRAME_RATE_DIVIDED_CONTROL_DIV_1
@ ST7789_PIXEL_TYPE_0
@ ST7789_INVERSION_SELECTION_DOT
@ ST7789_PIN_LEVEL_LOW
@ ST7789_VGLS_NEGATIVE_8P23
@ ST7789_INVERSION_PARTIAL_MODE_DOT
@ ST7789_NON_DISPLAY_FRAME_FREQUENCY_EVERY
@ ST7789_AVCL_NEGTIVE_4P8_V
@ ST7789_PWM_FREQUENCY_9P8_KHZ
@ ST7789_SBCLK_DIV_3
@ ST7789_FRAME_TYPE_0
@ ST7789_VGHS_14P97_V
@ ST7789_NON_DISPLAY_SOURCE_OUTPUT_LEVEL_V63
@ ST7789_DATA_MODE_MSB
@ ST7789_INVERSION_IDLE_MODE_DOT
@ ST7789_DIRECT_RGB_MODE_MEM
@ ST7789_NON_DISPLAY_AREA_SCAN_MODE_NORMAL
@ ST7789_RGB_IF_ENABLE_MODE_MCU
@ ST7789_RAM_ACCESS_MCU
@ ST7789_GATE_SCAN_DIRECTION_0_319
@ ST7789_GATE_SCAN_MODE_INTERLACE
@ ST7789_DISPLAY_MODE_MCU
uint8_t st7789_display_on(st7789_handle_t *handle)
display on
uint8_t st7789_init(st7789_handle_t *handle)
initialize the chip
struct st7789_handle_s st7789_handle_t
st7789 handle structure definition
uint8_t st7789_set_row(st7789_handle_t *handle, uint16_t row)
set row
uint8_t st7789_normal_display_mode_on(st7789_handle_t *handle)
normal display mode on
uint8_t st7789_write_string(st7789_handle_t *handle, uint16_t x, uint16_t y, char *str, uint16_t len, uint32_t color, st7789_font_t font)
write a string in the display
uint8_t st7789_set_display_control(st7789_handle_t *handle, st7789_bool_t brightness_control_block, st7789_bool_t display_dimming, st7789_bool_t backlight_control)
set display control
uint8_t st7789_fill_rect(st7789_handle_t *handle, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint32_t color)
fill the rect
uint8_t st7789_set_cabc_minimum_brightness(st7789_handle_t *handle, uint8_t brightness)
set cabc minimum brightness
uint8_t st7789_set_interface_pixel_format(st7789_handle_t *handle, st7789_rgb_interface_color_format_t rgb, st7789_control_interface_color_format_t control)
set interface pixel format
uint8_t st7789_idle_mode_off(st7789_handle_t *handle)
idle mode off
uint8_t st7789_deinit(st7789_handle_t *handle)
close the chip
uint8_t st7789_set_brightness_control_and_color_enhancement(st7789_handle_t *handle, st7789_bool_t color_enhancement, st7789_color_enhancement_mode_t mode, st7789_color_enhancement_level_t level)
set brightness control and color enhancement
uint8_t st7789_info(st7789_info_t *info)
get chip's information
uint8_t st7789_draw_picture_16bits(st7789_handle_t *handle, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint16_t *image)
draw a picture
uint8_t st7789_clear(st7789_handle_t *handle)
clear the display
struct st7789_info_s st7789_info_t
st7789 information structure definition
uint8_t st7789_set_gamma(st7789_handle_t *handle, uint8_t gamma)
set gamma
uint8_t st7789_set_display_brightness(st7789_handle_t *handle, uint8_t brightness)
set display brightness
uint8_t st7789_set_column(st7789_handle_t *handle, uint16_t column)
set column
uint8_t st7789_display_inversion_on(st7789_handle_t *handle)
display inversion on
uint8_t st7789_draw_point(st7789_handle_t *handle, uint16_t x, uint16_t y, uint32_t color)
draw a point in the display
uint8_t st7789_sleep_out(st7789_handle_t *handle)
sleep out
uint8_t st7789_set_memory_data_access_control(st7789_handle_t *handle, uint8_t order)
set memory data access control
@ ST7789_FONT_24
@ ST7789_FONT_16
@ ST7789_FONT_12
@ ST7789_COLOR_ENHANCEMENT_MODE_USER_INTERFACE
@ ST7789_RGB_INTERFACE_COLOR_FORMAT_262K
@ ST7789_GAMMA_CURVE_1
@ ST7789_COLOR_ENHANCEMENT_LEVEL_HIGH
@ ST7789_BOOL_TRUE
@ ST7789_BOOL_FALSE
@ ST7789_CONTROL_INTERFACE_COLOR_FORMAT_16_BIT
@ ST7789_ORDER_LINE_TOP_TO_BOTTOM
@ ST7789_ORDER_PAGE_TOP_TO_BOTTOM
@ ST7789_ORDER_REFRESH_LEFT_TO_RIGHT
@ ST7789_ORDER_PAGE_COLUMN_NORMAL
@ ST7789_ORDER_COLUMN_LEFT_TO_RIGHT
@ ST7789_ORDER_COLOR_RGB
uint8_t st7789_interface_cmd_data_gpio_init(void)
interface command && data gpio init
void st7789_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t st7789_interface_reset_gpio_deinit(void)
interface reset gpio deinit
uint8_t st7789_interface_cmd_data_gpio_write(uint8_t value)
interface command && data gpio write
uint8_t st7789_interface_spi_init(void)
interface spi bus init
uint8_t st7789_interface_reset_gpio_init(void)
interface reset gpio init
void st7789_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t st7789_interface_spi_deinit(void)
interface spi bus deinit
uint8_t st7789_interface_reset_gpio_write(uint8_t value)
interface reset gpio write
uint8_t st7789_interface_spi_write_cmd(uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t st7789_interface_cmd_data_gpio_deinit(void)
interface command && data gpio deinit
uint8_t st7789_display_test(void)
display test
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]