-
Notifications
You must be signed in to change notification settings - Fork 4
/
ILI9488.h
2145 lines (1722 loc) · 80.9 KB
/
ILI9488.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ************************************************************************
*
* ILI9488 color graphic display controller
*
* (c) 2020 by Markus Reschke
*
* ************************************************************************ */
/* ************************************************************************
* standard command set
* ************************************************************************ */
/*
* no operation
* - 1 byte cmd
*/
#define CMD_NOP 0b00000000 /* no operation */
/*
* software reset
* - 1 byte cmd
*/
#define CMD_RESET 0b00000001 /* software reset */
/*
* read display identification information
* - 1 byte cmd + 4 bytes data (read mode)
*/
#define CMD_READ_DISP_ID 0b00000100 /* read display ID */
/* data byte #1: dummy byte */
/* data byte #2: manufacturer ID */
/* data byte #3: module/driver version ID */
/* data byte #4: module/driver ID */
/*
* read number of MIPI DSI errors (MIPI Display Serial Interface)
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_ERRORS 0b00000101 /* read number of errors */
/* data byte #1: dummy data */
/* data byte #2: number of errors */
/* bits 0-6: number of errors */
/* bit 7: overflow indicator */
/*
* read display status
* - 1 byte cmd + 5 bytes data (read mode)
*/
#define CMD_READ_STATUS 0b00001001 /* read display status */
/* data byte #1: dummy data */
/* data byte #2: status */
/* horizontal refresh: */
#define FLAG_STAT_HOR_NORM 0b00000000 /* left to right */
#define FLAG_STAT_HOR_REV 0b00000010 /* right to left */
/* RGB/BGR order */
#define FLAG_STAT_COLOR_RGB 0b00000000 /* RGB */
#define FLAG_STAT_COLOR_BGR 0b00000100 /* BGR */
/* vertical refresh: */
#define FLAG_STAT_VER_NORM 0b00000000 /* top to bottom */
#define FLAG_STAT_VER_REV 0b00001000 /* bottom to top */
/* row/column exchange: */
#define FLAG_STAT_XY_NORM 0b00000000 /* normal */
#define FLAG_STAT_XY_REV 0b00010000 /* reversed (X & Y swapped) */
/* column address order: */
#define FLAG_STAT_COL_NORM 0b00000000 /* left to right */
#define FLAG_STAT_COL_REV 0b00100000 /* right to left */
/* row address order: */
#define FLAG_STAT_ROW_NORM 0b00000000 /* top to bottom */
#define FLAG_STAT_ROW_REV 0b01000000 /* bottom to top */
/* booster voltage: */
#define FLAG_STAT_BOOST_OFF 0b00000000 /* booster on */
#define FLAG_STAT_BOOST_ON 0b10000000 /* booster off */
/* data byte #3: status */
/* display normal mode: */
#define FLAG_STAT_NORM_OFF 0b00000000 /* off */
#define FLAG_STAT_NORM_ON 0b00000001 /* on */
/* sleep mode: */
#define FLAG_STAT_SLEEP_OFF 0b00000000 /* off */
#define FLAG_STAT_SLEEP_ON 0b00000010 /* on */
/* partial mode: */
#define FLAG_STAT_PART_OFF 0b00000000 /* off */
#define FLAG_STAT_PART_ON 0b00000100 /* on */
/* idle mode: */
#define FLAG_STAT_IDLE_OFF 0b00000000 /* off */
#define FLAG_STAT_IDLE_ON 0b00001000 /* on */
/* interface color pixel format: */
#define FLAG_STAT_PIX_16 0b01010000 /* 16 bits per pixel */
#define FLAG_STAT_PIX_18 0b01100000 /* 18 bits per pixel */
#define FLAG_STAT_PIX_24 0b01110000 /* 24 bits per pixel */
/* data byte #4: status */
/* gamma curve - bit 2: bit 0 (always 0) */
/* tearing effect line: */
#define FLAG_STAT_TEAR_OFF 0b00000000 /* off */
#define FLAG_STAT_TEAR_ON 0b00000010 /* on */
/* display: */
#define FLAG_STAT_DISP_OFF 0b00000000 /* off */
#define FLAG_STAT_DISP_ON 0b00000100 /* on */
/* inversion: */
#define FLAG_STAT_INVERS_OFF 0b00000000 /* off */
#define FLAG_STAT_INVERS_ON 0b00100000 /* on */
/* vertical scrolling: */
#define FLAG_STAT_VSCROLL_OFF 0b00000000 /* off */
#define FLAG_STAT_VSCROLL_ON 0b10000000 /* on */
/* data byte #5: status */
/* tearing effect line mode: */
#define FLAG_STAT_TEAR_MODE1 0b00000000 /* mode 1: V-blanking */
#define FLAG_STAT_TEAR_MODE2 0b00100000 /* mode 2: V-blanking and H-blanking */
/* gamma curve - bits 1 and 0: */
#define FLAG_STAT_GAMMA0 0b00000000 /* gamma curve 0 */
#define FLAG_STAT_GAMMA1 0b01000000 /* gamma curve 1 */
#define FLAG_STAT_GAMMA2 0b10000000 /* gamma curve 2 */
#define FLAG_STAT_GAMMA3 0b11000000 /* gamma curve 3 */
/*
* read display power mode
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_PWR_MODE 0b00001010 /* read display power mode */
/* data byte #1: dummy data */
/* data byte #2: status */
/* display: */
#define FLAG_DISPLAY_OFF 0b00000000 /* off */
#define FLAG_DISPLAY_ON 0b00000100 /* on */
/* display normal mode: */
#define FLAG_NORMAL_OFF 0b00000000 /* off */
#define FLAG_NORMAL_ON 0b00001000 /* on */
/* sleep mode: */
#define FLAG_SLEEP_OFF 0b00000000 /* off */
#define FLAG_SLEEP_ON 0b00010000 /* on */
/* partial mode: */
#define FLAG_PARTIAL_OFF 0b00000000 /* off */
#define FLAG_PARTIAL_ON 0b00100000 /* on */
/* idle mode: */
#define FLAG_IDLE_OFF 0b00000000 /* off */
#define FLAG_IDLE_ON 0b01000000 /* on */
/* booster: */
#define FLAG_BOOSTER_OFF 0b00000000 /* off or faulty */
#define FLAG_BOOSTER_ON 0b10000000 /* on and working fine */
/*
* read display MADCTL (memory acccess control)
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_MADCTL 0b00001011 /* read display MADCTL */
/* data byte #1: dummy data */
/* data byte #2: status */
/* same as byte #1 of CMD_MEM_CTRL */
/* display data latch data order (horizontal refereshing): */
#define RFLAG_HREFRESH_NORM 0b00000000 /* left to right */
#define RFLAG_HREFRESH_REV 0b00000100 /* right to left */
/* color order: */
#define RFLAG_COLOR_RGB 0b00000000 /* RGB */
#define RFLAG_COLOR_BGR 0b00001000 /* BGR */
/* line address order (vertical refereshing): */
#define RFLAG_VREFRESH_NORM 0b00000000 /* top to bottom */
#define RFLAG_VREFRESH_REV 0b00010000 /* bottom to top */
/* page/column order: */
#define RFLAG_XY_NORM 0b00000000 /* normal */
#define RFLAG_XY_REV 0b00100000 /* reversed (X & Y swapped) */
/* column address order: */
#define RFLAG_COL_NORM 0b00000000 /* left to right */
#define RFLAG_COL_REV 0b01000000 /* right to left */
/* page (row) address order: */
#define RFLAG_PAGE_NORM 0b00000000 /* top to bottom */
#define RFLAG_PAGE_REV 0b10000000 /* bottom to top */
/*
* read display pixel format
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_PIX_FORMAT 0b00001100 /* read display pixel format */
/* data byte #1: dummy data */
/* data byte #2: status */
/* same as byte #1 of CMD_SET_PIX_FORMAT */
/* pixel format of display bus interface (MCU interface): */
#define RFLAG_DBI_8 0b00000001 /* 3 bits per pixel */
#define RFLAG_DBI_16 0b00000101 /* 16 bits per pixel */
#define RFLAG_DBI_18 0b00000110 /* 18 bits per pixel */
#define RFLAG_DBI_24 0b00000111 /* 24 bits per pixel */
/* pixel format of display pixel interface (RGB interface): */
#define RFLAG_DPI_16 0b01010000 /* 16 bits per pixel */
#define RFLAG_DPI_18 0b01100000 /* 18 bits per pixel */
#define RFLAG_DPI_24 0b11100000 /* 18 bits per pixel */
/*
* read display image mode
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_IMAGE_MODE 0b00001101 /* read display image mode */
/* data byte #1: dummy data */
/* data byte #2: status */
/* inversion */
#define FLAG_INVERSION_OFF 0b00000000 /* off */
#define FLAG_INVERSION_ON 0b00100000 /* on */
/* vertical scrolling */
#define FLAG_VSCROLL_OFF 0b00000000 /* off */
#define FLAG_VSCROLL_ON 0b10000000 /* on */
/*
* read display signal mode
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_SIGNAL_MODE 0b00001110 /* read display signal mode */
/* data byte #1: dummy data */
/* data byte #2: mode flags */
/* MIPI DSI errors: */
#define FLAG_SIG_ERR_OFF 0b00000000 /* no errors */
#define FLAG_SIG_ERR_ON 0b00000001 /* errors detected */
/* data enable (DE, RGB interface): */
#define FLAG_SIG_DE_OFF 0b00000000 /* data enable off */
#define FLAG_SIG_DE_ON 0b00000100 /* data enable on */
/* pixel clock (DOTCLK, RGB interface): */
#define FLAG_SIG_CLK_OFF 0b00000000 /* pixel clock off */
#define FLAG_SIG_CLK_ON 0b00001000 /* pixel clock on */
/* vertical sync (RGB interface): */
#define FLAG_SIG_VSYNC_OFF 0b00000000 /* V-sync off */
#define FLAG_SIG_VSYNC_ON 0b00010000 /* V-sync on */
/* horizontal sync (RGB interface): */
#define FLAG_SIG_HSYNC_OFF 0b00000000 /* H-sync off */
#define FLAG_SIG_HSYNC_ON 0b00100000 /* H-sync on */
/* tearing effect line mode: */
#define FLAG_SIG_TEAR_1 0b00000000 /* effect mode 1 */
#define FLAG_SIG_TEAR_2 0b01000000 /* effect mode 2 */
/* tearing effect line: */
#define FLAG_SIG_TEAR_OFF 0b00000000 /* effect off */
#define FLAG_SIG_TEAR_ON 0b10000000 /* effect on */
/*
* read display self-diagnostic result
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_DIAG 0b00001111 /* read diagnostics */
/* data byte #1: dummy data */
/* data byte #2: diag flags */
#define FLAG_DIAG_SUM_ERR 0b00000001 /* checksums don't match */
#define FLAG_DIAG_DISP_OK 0b01000000 /* display works */
#define FLAG_DIAG_REGS_OK 0b10000000 /* register values loaded */
/*
* enter sleep mode (sleep in)
* - 1 byte cmd
*/
#define CMD_SLEEP_IN 0b00010000 /* enter sleep mode */
/*
* exit sleep mode (sleep out)
* - 1 byte cmd
*/
#define CMD_SLEEP_OUT 0b00010001 /* leave sleep mode */
/*
* enter partial display mode
* - 1 byte cmd
*/
#define CMD_PARTIAL_MODE 0b00010010 /* partial mode on */
/*
* enter normal display mode
* - 1 byte cmd
*/
#define CMD_NORMAL_MODE 0b00010011 /* normal mode on */
/*
* disable display inversion
* - 1 byte cmd
*/
#define CMD_INVERSION_OFF 0b00100000 /* display inversion off */
/*
* enable display inversion (invert pixels)
* - 1 byte cmd
*/
#define CMD_INVERSION_ON 0b00100001 /* display inversion on */
/*
* all pixels off (black)
* - 1 byte cmd
*/
#define CMD_PIXELS_OFF 0b00100010 /* all pixels off */
/*
* all pixels on (white)
* - 1 byte cmd
*/
#define CMD_PIXELS_ON 0b00100011 /* all pixels on */
/*
* disable display output
* - 1 byte cmd
*/
#define CMD_DISPLAY_OFF 0b00101000 /* display off */
/*
* enable display output
* - 1 byte cmd
*/
#define CMD_DISPLAY_ON 0b00101001 /* display on */
/*
* set column address (accessable frame area)
* - 1 byte cmd + 4 bytes data
*/
#define CMD_COL_ADDR_SET 0b00101010 /* set column address */
/* data byte #1: start column - MSB (bits 15-8) */
/* data byte #2: start column - LSB (bits 7-0) */
/* data byte #3: end column - MSB (bits 15-8) */
/* data byte #4: end column - LSB (bits 7-0) */
/* valid range: 0x0000 - 0x013f/0x01df */
/*
* set page address (row, accessible frame area)
* - 1 byte cmd + 4 bytes data
*/
#define CMD_PAGE_ADDR_SET 0b00101011 /* set page address */
/* data byte #1: start page - MSB (bits 15-8) */
/* data byte #2: start page - LSB (bits 7-0) */
/* data byte #3: end page - MSB (bits 15-8) */
/* data byte #4: end page - LSB (bits 7-0) */
/* valid range: 0x0000 - 0x01df/0x013f */
/*
* write memory (starting at Start Column and Start Page)
* - 1 byte cmd + x bytes data
*/
#define CMD_MEM_WRITE 0b00101100 /* write memory */
/* data byte #1 - #x: image data */
/*
* read memory (starting at Start Column and Start Page)
* - 1 byte cmd + x bytes data (read mode)
*/
#define CMD_MEM_READ 0b00101110 /* read memory */
/* data byte #1: dummy data */
/* data byte #2 - #x: image data */
/*
* partial area
* - 1 byte cmd + 4 bytes data
*/
#define CMD_PARTIAL_AREA 0b00110000 /* set partial area */
/* data byte #1: start row - MSB (bits 15-8) */
/* data byte #2: start row - LSB (bits 7-0) */
/* data byte #3: end row - MSB (bits 15-8) */
/* data byte #4: end row - LSB (bits 7-0) */
/* valid range: 0x0000 - 0x01df */
/*
* vertical scrolling definition
* - 1 byte cmd + 6 bytes data
*/
#define CMD_V_SCROLL_DEF 0b00110011 /* set vertical scrolling area */
/* data byte #1: top fixed area line number - MSB (bits 15-8) */
/* data byte #2: top fixed area line number - LSB (bits 7-0) */
/* data byte #3: height of scrolling area - MSB (bits 15-8) */
/* data byte #4: height of scrolling area - LSB (bits 7-0) */
/* data byte #5: bottom fixed area line number - MSB (bits 15-8) */
/* data byte #6: bottom fixed area line number - LSB (bits 7-0) */
/*
* disable tearing effect line
* - 1 byte cmd
*/
#define CMD_TEAR_OFF 0b00110100 /* tearing effect off */
/*
* enable tearing effect line
* - 1 byte cmd + 1 byte data
*/
#define CMD_TEAR_ON 0b00110101 /* tearing effect on */
/* data byte #1: mode */
#define FLAG_TEAR_MODE_0 0b00000000 /* V-blanking only */
#define FLAG_TEAR_MODE_1 0b00000001 /* V-blanking and H-blanking */
/*
* memory access control
* - 1 byte cmd + 1 byte data
*/
#define CMD_MEM_CTRL 0b00110110 /* memory access control */
/* data byte #1: read/write scanning direction of frame memory */
/* same as byte #2 of CMD_READ_MADCTL */
/* horizontal refereshing direction: */
#define FLAG_HREFRESH_NORM 0b00000000 /* left to right */
#define FLAG_HREFRESH_REV 0b00000100 /* right to left */
/* color selector switch: */
#define FLAG_COLOR_RGB 0b00000000 /* RGB color filter */
#define FLAG_COLOR_BGR 0b00001000 /* BGR color filter */
/* vertical refereshing direction: */
#define FLAG_VREFRESH_NORM 0b00000000 /* top to bottom */
#define FLAG_VREFRESH_REV 0b00010000 /* bottom to top */
/* page/column order (exchange): */
#define FLAG_XY_NORM 0b00000000 /* normal */
#define FLAG_XY_REV 0b00100000 /* reversed (swap x and y) */
/* column address order: */
#define FLAG_COL_NORM 0b00000000 /* left to right */
#define FLAG_COL_REV 0b01000000 /* right to left */
/* page (row) address order: */
#define FLAG_PAGE_NORM 0b00000000 /* top to bottom */
#define FLAG_PAGE_REV 0b10000000 /* bottom to top */
/*
* set vertical scrolling start address
* - 1 byte cmd + 2 bytes data
*/
#define CMD_VSCROLL_ADDR 0b00110111 /* set vertical scrolling start address */
/* data byte #1: line number - MSB (bits 15-8) */
/* data byte #2: line number - MSB (bits 7-0) */
/*
* exit idle mode (full color depth)
* - 1 byte cmd
*/
#define CMD_IDLE_OFF 0b00111000 /* idle mode off */
/*
* enter idle mode (8bit color depth)
* - 1 byte cmd
*/
#define CMD_IDLE_ON 0b00111001 /* idle mode on */
/*
* set pixel format for RGB image data
* - 1 byte cmd + 1 byte data
*/
#define CMD_SET_PIX_FORMAT 0b00111010 /* set pixel format */
/* data byte #1: formats */
/* same as byte #2 of CMD_READ_PIX_FORMAT */
/* pixel format of display bus interface (MCU interface): */
#define FLAG_DBI_3 0b00000001 /* 3 bits per pixel */
#define FLAG_DBI_16 0b00000101 /* 16 bits per pixel */
#define FLAG_DBI_18 0b00000110 /* 18 bits per pixel */
#define FLAG_DBI_24 0b00000111 /* 24 bits per pixel */
/* pixel format of display pixel interface (RGB interface): */
#define FLAG_DPI_16 0b01010000 /* 16 bits per pixel */
#define FLAG_DPI_18 0b01100000 /* 18 bits per pixel */
#define FLAG_DPI_24 0b01110000 /* 24 bits per pixel */
/*
* write memory continue (starting at last pixel position + 1)
* - 1 byte cmd + x bytes data
*/
#define CMD_WRITE_MEM_CONT 0b00111100 /* write memory continue */
/* data byte #1 - #x: image data */
/*
* read memory continue (starting at last pixel position + 1)
* - 1 byte cmd + x bytes data (read mode)
*/
#define CMD_READ_MEM_CONT 0b00111110 /* read memory continue */
/* data byte #1: dummy data */
/* data byte #2 - #x: image data */
/*
* set tearing effect scan line
* - 1 byte cmd + 2 bytes data
*/
#define CMD_SET_SCANLINE 0b01000100 /* set scan line */
/* data byte #1: line number - MSB (bits 15-8) */
#define FLAG_STS_HIGH_MIN 0b00000000 /* minimum value */
#define FLAG_STS_HIGH_MAX 0b00000001 /* maximum value */
/* data byte #2: line number - LSB (bits 7-0) */
#define FLAG_STS_LOW_MIN 0b00000000 /* minimum value */
#define FLAG_STS_LOW_MAX 0b11111111 /* maximum value */
/*
* get tearing effect scan line
* - 1 byte cmd + 3 bytes data (read mode)
*/
#define CMD_READ_SCANLINE 0b01000101 /* read scan line */
/* data byte #1: dummy data */
/* data byte #2: line number - MSB (bits 15-8) */
/* data byte #3: line number - LSB (bits 7-0) */
/*
* write display brightness
* - 1 byte cmd + 1 byte data
*/
#define CMD_WRITE_BRIGHT 0b01010001 /* write display brightness */
/* data byte #1: brightness value */
#define FLAG_BRIGHT_MIN 0b00000000 /* minimum value */
#define FLAG_BRIGHT_MAX 0b11111111 /* maximum value */
/*
* read display brightness
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_BRIGHT 0b01010010 /* read display brightness */
/* data byte #1: dummy data */
/* data byte #2: brightness value, please see above */
/*
* write CTRL
* - 1 byte cmd + 1 byte data
*/
#define CMD_WRITE_CTRL 0b01010011 /* write CTRL */
/* data byte #1: settings */
/* backlight: */
#define FLAG_BACKLIGHT_OFF 0b00000000 /* off */
#define FLAG_BACKLIGHT_ON 0b00000100 /* on */
/* display dimming for manual brightness setting: */
#define FLAG_DIMMING_OFF 0b00000000 /* off */
#define FLAG_DIMMING_ON 0b00001000 /* on */
/* brightness control block: */
#define FLAG_BCTRL_OFF 0b00000000 /* off (registers are 0x00) */
#define FLAG_BCTRL_ON 0b00100000 /* on (registers are active) */
/*
* read CTRL
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_CTRL 0b01010100 /* read CTRL */
/* data byte #1: dummy data */
/* data byte #2: settings, please see above */
/*
* write content adaptive brightness control (CABC)
* - 1 byte cmd + 1 byte data
*/
#define CMD_WRITE_CABC 0b01010101 /* write content adaptive brightness control */
/* data byte #1: mode */
#define FLAG_CABC_OFF 0b00000000 /* off */
#define FLAG_CABC_INTERFACE 0b00000001 /* user interface image */
#define FLAG_CABC_STILL 0b00000010 /* still picture */
#define FLAG_CABC_MOVING 0b00000011 /* moving image */
#define FLAG_CABC_ENH_LOW 0b10000000 /* low enhancement */
#define FLAG_CABC_ENH_MED 0b10010000 /* medium enhancement */
#define FLAG_CABC_ENH_HIGH 0b10110000 /* high enhancement */
/*
* read content adaptive brightness control (CABC)
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_CABC 0b01010110 /* read CABC */
/* data byte #1: dummy data */
/* data byte #2: mode, please see FLAG_CABC_* above */
/*
* write CABC minimum brightness
* - 1 byte cmd + 1 byte data
*/
#define CMD_WRITE_MIN_CABC 0b01011110 /* write CABC minimum brightness */
/* data byte #1: minimum brightness level of CABC function */
#define FLAG_CABC_MIN 0b00000000 /* minimum value */
#define FLAG_CABC_MAX 0b11111111 /* maximum value */
/*
* read CABC minimum brightness
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_MIN_CABC 0b01011111 /* read CABC minimum brightness */
/* data byte #1: dummy data */
/* data byte #2: minimum brightness level of CABC function */
/*
* read automatic brightness control diagnostic
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_CABC_DIAG 0b01101000 /* read CABC diagnostic */
/* data byte #1: dummy data */
/* data byte #2: */
/* pixel format of display bus interface (MCU interface): */
#define FLAG_CABC_FUNC_OK 0b01000000 /* display is working */
#define FLAG_CABC_LOAD_OK 0b10000000 /* register values loaded */
/*
* read ID1 (manufacturer)
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_ID1 0b11011010 /* read ID1 */
/* data byte #1: dummy data */
/* data byte #2: LCD module's manufacturer ID */
/*
* read ID2 (driver version)
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_ID2 0b11011011 /* read ID2 */
/* data byte #1: dummy data */
/* data byte #2: LCD module/driver version (default: 0x80) */
/*
* read ID3 (module/driver)
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_ID3 0b11011100 /* read ID3 */
/* data byte #1: dummy data */
/* data byte #2: LCD module/driver (default: 0x66) */
/* ************************************************************************
* extended command set
* ************************************************************************ */
/*
* interface mode control
* - 1 byte cmd + 1 byte data
*/
#define CMD_IF_MODE_CTRL 0b10110000 /* interface mode control */
/* data byte #1: switches */
/* DE polarity for RGB interface: */
#define FLAG_EPL_HIGH 0b00000000 /* high enable */
#define FLAG_EPL_LOW 0b00000001 /* low enable */
/* PCLK polarity: */
#define FLAG_DPL_RISE 0b00000000 /* data fetched at rising edge */
#define FLAG_DPL_FALL 0b00000010 /* data fetched at falling edge */
/* HSYNC polarity: */
#define FLAG_HSPL_LOW 0b00000000 /* low level sync */
#define FLAG_HSPL_HIGH 0b00000100 /* high level sync */
/* VSYNC polarity: */
#define FLAG_VSPL_LOW 0b00000000 /* low level sync */
#define FLAG_VSPL_HIGH 0b00001000 /* high level sync */
/* 3/4 wire serial interface: */
#define FLAG_SDA_1 0b00000000 /* use DIN & SDO */
#define FLAG_SDA_2 0b10000000 /* use DIN/SDA only */
/*
* frame rate control for normal mode (full colors)
* - 1 byte cmd + 2 bytes data
*/
#define CMD_FRAME_CTRL_NORM 0b10110001 /* frame rate for normal mode */
/* data byte #1: */
/* division ratio of internal clock: */
#define FLAG_DIVA_1 0b00000000 /* f_OSC */
#define FLAG_DIVA_2 0b00000001 /* f_OSC/2 */
#define FLAG_DIVA_4 0b00000010 /* f_OSC/4 */
#define FLAG_DIVA_8 0b00000011 /* f_OSC/8 */
/* frame frequency */
/* tearing effect off / on */
#define FLAG_FRS_28 0b00000000 /* 28.78 Hz / 27.64 Hz */
#define FLAG_FRS_30 0b00010000 /* 30.38 Hz / 29.17 Hz */
#define FLAG_FRS_32 0b00100000 /* 32.17 Hz / 30.89 Hz */
#define FLAG_FRS_34 0b00110000 /* 34.18 Hz / 32.82 Hz */
#define FLAG_FRS_36 0b01000000 /* 36.46 Hz / 35.01 Hz */
#define FLAG_FRS_39 0b01010000 /* 39.06 Hz / 37.51 Hz */
#define FLAG_FRS_42 0b01100000 /* 42.07 Hz / 40.40 Hz */
#define FLAG_FRS_46 0b01110000 /* 45.57 Hz / 43.76 Hz */
#define FLAG_FRS_50 0b10000000 /* 49.71 Hz / 47.74 Hz */
#define FLAG_FRS_55 0b10010000 /* 54.69 Hz / 52.52 Hz */
#define FLAG_FRS_60 0b10100000 /* 60.76 Hz / 58.35 Hz */
#define FLAG_FRS_68 0b10110000 /* 68.36 Hz / 65.65 Hz */
#define FLAG_FRS_78 0b11000000 /* 78.13 Hz / 75.03 Hz */
#define FLAG_FRS_91 0b11010000 /* 91.15 Hz / 87.53 Hz */
/* data byte #2: line period (clocks per line) */
#define FLAG_RTNA_16 0b00010000 /* 16 clocks */
#define FLAG_RTNA_17 0b00010001 /* 17 clocks */
#define FLAG_RTNA_18 0b00010010 /* 18 clocks */
#define FLAG_RTNA_19 0b00010011 /* 19 clocks */
#define FLAG_RTNA_20 0b00010100 /* 20 clocks */
#define FLAG_RTNA_21 0b00010101 /* 21 clocks */
#define FLAG_RTNA_22 0b00010110 /* 22 clocks */
#define FLAG_RTNA_23 0b00010111 /* 23 clocks */
#define FLAG_RTNA_24 0b00011000 /* 24 clocks */
#define FLAG_RTNA_25 0b00011001 /* 25 clocks */
#define FLAG_RTNA_26 0b00011010 /* 26 clocks */
#define FLAG_RTNA_27 0b00011011 /* 27 clocks */
#define FLAG_RTNA_28 0b00011100 /* 28 clocks */
#define FLAG_RTNA_29 0b00011101 /* 29 clocks */
#define FLAG_RTNA_30 0b00011110 /* 30 clocks */
#define FLAG_RTNA_31 0b00011111 /* 31 clocks */
/*
* frame rate control for idle mode (8bit color depth)
* - 1 byte cmd + 2 bytes data
*/
#define CMD_FRAME_CTRL_IDLE 0b10110010 /* frame rate for idle mode */
/* data byte #1: division ratio of internal clock */
#define FLAG_DIVB_1 0b00000000 /* f_OSC */
#define FLAG_DIVB_2 0b00000001 /* f_OSC/2 */
#define FLAG_DIVB_4 0b00000010 /* f_OSC/4 */
#define FLAG_DIVB_8 0b00000011 /* f_OSC/8 */
/* data byte #2: line period (clocks per line) */
#define FLAG_RTNB_16 0b00010000 /* 16 clocks */
#define FLAG_RTNB_17 0b00010001 /* 17 clocks */
#define FLAG_RTNB_18 0b00010010 /* 18 clocks */
#define FLAG_RTNB_19 0b00010011 /* 19 clocks */
#define FLAG_RTNB_20 0b00010100 /* 20 clocks */
#define FLAG_RTNB_21 0b00010101 /* 21 clocks */
#define FLAG_RTNB_22 0b00010110 /* 22 clocks */
#define FLAG_RTNB_23 0b00010111 /* 23 clocks */
#define FLAG_RTNB_24 0b00011000 /* 24 clocks */
#define FLAG_RTNB_25 0b00011001 /* 25 clocks */
#define FLAG_RTNB_26 0b00011010 /* 26 clocks */
#define FLAG_RTNB_27 0b00011011 /* 27 clocks */
#define FLAG_RTNB_28 0b00011100 /* 28 clocks */
#define FLAG_RTNB_29 0b00011101 /* 29 clocks */
#define FLAG_RTNB_30 0b00011110 /* 30 clocks */
#define FLAG_RTNB_31 0b00011111 /* 31 clocks */
/*
* frame rate control for partial mode (full colors)
* - 1 byte cmd + 2 bytes data
*/
#define CMD_FRAME_CTRL_PART 0b10110011 /* frame rate for partial mode */
/* data byte #1: division ratio of internal clock */
#define FLAG_DIVC_1 0b00000000 /* f_OSC */
#define FLAG_DIVC_2 0b00000001 /* f_OSC/2 */
#define FLAG_DIVC_4 0b00000010 /* f_OSC/4 */
#define FLAG_DIVC_8 0b00000011 /* f_OSC/8 */
/* data byte #2: line period (clocks per line) */
#define FLAG_RTNC_16 0b00010000 /* 16 clocks */
#define FLAG_RTNC_17 0b00010001 /* 17 clocks */
#define FLAG_RTNC_18 0b00010010 /* 18 clocks */
#define FLAG_RTNC_19 0b00010011 /* 19 clocks */
#define FLAG_RTNC_20 0b00010100 /* 20 clocks */
#define FLAG_RTNC_21 0b00010101 /* 21 clocks */
#define FLAG_RTNC_22 0b00010110 /* 22 clocks */
#define FLAG_RTNC_23 0b00010111 /* 23 clocks */
#define FLAG_RTNC_24 0b00011000 /* 24 clocks */
#define FLAG_RTNC_25 0b00011001 /* 25 clocks */
#define FLAG_RTNC_26 0b00011010 /* 26 clocks */
#define FLAG_RTNC_27 0b00011011 /* 27 clocks */
#define FLAG_RTNC_28 0b00011100 /* 28 clocks */
#define FLAG_RTNC_29 0b00011101 /* 29 clocks */
#define FLAG_RTNC_30 0b00011110 /* 30 clocks */
#define FLAG_RTNC_31 0b00011111 /* 31 clocks */
/*
* display inversion control
* - 1 byte cmd + 1 byte data
*/
#define CMD_INVERS_CTRL 0b10110100 /* display inversion control */
/* data byte #1: mode switches */
/* dot inversion mode: */
#define FLAG_DINV_COL 0b00000000 /* column inversion */
#define FLAG_DINV_1DOT 0b00000001 /* 1-dot inversion */
#define FLAG_DINV_2DOT 0b00000010 /* 2-dot inversion */
/*
* blanking porch control
* - 1 byte cmd + 4 byte data
*/
#define CMD_BLANK_CTRL 0b10110101 /* blanking porch control */
/* data byte #1: line number of vertical front porch period */
/* number of HSYNCs, please see datasheet: */
#define FLAG_VFP_MIN 0b00000010 /* minimum value */
#define FLAG_VFP_MAX 0b00011111 /* maximum value */
/* data byte #2: line number of vertical back porch period */
/* number of HSYNCs, please see datasheet: */
#define FLAG_VBP_MIN 0b00000010 /* minimum value */
#define FLAG_VBP_MAX 0b00011111 /* maximum value */
/* data byte #3: line number of horizontal front porch period */
/* number of DOTCLKs, please see datasheet: */
#define FLAG_HFP_MIN 0b00000010 /* minimum value */
#define FLAG_HFP_MAX 0b11111111 /* maximum value */
/* data byte #4: line number of horizontal back porch period */
/* number of DOTCLKs, please see datasheet: */
#define FLAG_HBP_MIN 0b00000010 /* minimum value */
#define FLAG_HBP_MAX 0b11000000 /* maximum value */
/*
* display function control
* - 1 byte cmd + 3 bytes data
*/
#define CMD_FUNC_CTRL 0b10110110 /* display function control */
/* data byte #1: */
/* source/VCOM output in non-display area in partial display mode: */
/* source output on non-display area */
#define FLAG_PT_0 0b00000000 /* V63 */
#define FLAG_PT_1 0b00000001 /* V0 */
#define FLAG_PT_2 0b00000010 /* AGND */
#define FLAG_PT_3 0b00000011 /* Hi-Z */
/* scan mode in non-display area: */
#define FLAG_PTG_0 0b00000000 /* normal scan */
#define FLAG_PTG_2 0b00001000 /* interval scan */
/* display operation mode: */
#define FLAG_DM_INT 0b00000000 /* internal system clock */
#define FLAG_DM_RGB 0b00010000 /* RGB interface */
/* interface to access GRAM: */
#define FLAG_RM_SYS 0b00000000 /* system interface */
#define FLAG_RM_RGB 0b00100000 /* RGB interface */
/* RGB interface selection: */
#define FLAG_RCM_DE 0b00000000 /* DE mode */
#define FLAG_RCM_SYNC 0b00000000 /* SYNC mode */
/* display data path for RGB interface: */
#define FLAG_BYPASS_MEM 0b00000000 /* memory */
#define FLAG_BYPASS_REG 0b10000000 /* direct to shift register */
/* data byte #2: */
/* scan cycle for interval scan in non-display area: */
#define FLAG_ISC_03 0b00000001 /* 3 frames / 50 ms */
#define FLAG_ISC_05 0b00000010 /* 5 frames / 84 ms */
#define FLAG_ISC_07 0b00000011 /* 7 frames / 117 ms */
#define FLAG_ISC_09 0b00000100 /* 9 frames / 150 ms */
#define FLAG_ISC_11 0b00000101 /* 11 frames / 184 ms*/
#define FLAG_ISC_13 0b00000110 /* 13 frames / 217 ms */
#define FLAG_ISC_15 0b00000111 /* 15 frames / 251 ms */
#define FLAG_ISC_17 0b00001000 /* 17 frames / 284 ms */
#define FLAG_ISC_19 0b00001001 /* 19 frames / 317 ms */
#define FLAG_ISC_21 0b00001010 /* 21 frames / 351 ms */
#define FLAG_ISC_23 0b00001011 /* 23 frames / 384 ms */
#define FLAG_ISC_25 0b00001100 /* 25 frames / 418 ms */
#define FLAG_ISC_27 0b00001101 /* 27 frames / 451 ms */
#define FLAG_ISC_29 0b00001110 /* 29 frames / 484 ms */
#define FLAG_ISC_31 0b00001111 /* 31 frames / 518 ms */
/* gate driver pin arrangement (in combination with GS): */
#define FLAG_SM_0 0b00000000 /* in sequence */
#define FLAG_SM_1 0b00010000 /* even/odd separated */
/* output shift direction / source driver scan direction: */
#define FLAG_SS_0 0b00000000 /* S1 -> S960 */
#define FLAG_SS_1 0b00100000 /* S960 -> S1 */
/* gate driver scan direction: */
#define FLAG_GS_0 0b00000000 /* G1 -> G480 */
#define FLAG_GS_1 0b01000000 /* G480 -> G1 */
/* data byte #3: number of lines to drive LCD at an interval of 8 lines: */
/* 8 * (NL + 1) */
#define FLAG_NL_008 0b00000000 /* 8 lines */
#define FLAG_NL_016 0b00000001 /* 16 lines */
#define FLAG_NL_024 0b00000010 /* 24 lines */
#define FLAG_NL_036 0b00000011 /* 32 lines */
#define FLAG_NL_040 0b00000100 /* 40 lines */
#define FLAG_NL_048 0b00000101 /* 48 lines */
#define FLAG_NL_056 0b00000110 /* 56 lines */
#define FLAG_NL_064 0b00000111 /* 64 lines */
#define FLAG_NL_072 0b00001000 /* 72 lines */
#define FLAG_NL_080 0b00001001 /* 80 lines */
#define FLAG_NL_088 0b00001010 /* 88 lines */
#define FLAG_NL_096 0b00001011 /* 96 lines */
#define FLAG_NL_104 0b00001100 /* 104 lines */
#define FLAG_NL_112 0b00001101 /* 112 lines */
#define FLAG_NL_120 0b00001110 /* 120 lines */
#define FLAG_NL_128 0b00001111 /* 128 lines */
#define FLAG_NL_136 0b00010000 /* 136 lines */
#define FLAG_NL_144 0b00010001 /* 144 lines */