-
Notifications
You must be signed in to change notification settings - Fork 6
/
ILI9341.h
2017 lines (1643 loc) · 79.1 KB
/
ILI9341.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
/* ************************************************************************
*
* ILI9341 color graphic display controller
*
* (c) 2015-2020 by Markus Reschke
*
* ************************************************************************ */
/* ************************************************************************
* regular 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 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 */
/* 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 */
/* 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_GAMMA1 0b00000000 /* gamma curve 1 (GG2.2) */
/* ILI9342 only: */
#define FLAG_STAT_GAMMA2 0b01000000 /* gamma curve 2 (GC1.8) */
#define FLAG_STAT_GAMMA3 0b10000000 /* gamma curve 3 (GC2.5) */
#define FLAG_STAT_GAMMA4 0b11000000 /* gamma curve 4 (GC1.0) */
/*
* 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 */
/* horizontal refereshing direction: */
#define RFLAG_HREFRESH_NORM 0b00000000 /* left to right */
#define RFLAG_HREFRESH_REV 0b00000100 /* right to left */
/* color selector switch: */
#define RFLAG_COLOR_RGB 0b00000000 /* RGB color filter */
#define RFLAG_COLOR_BGR 0b00001000 /* BGR color filter */
/* vertical refereshing direction: */
#define RFLAG_VREFRESH_NORM 0b00000000 /* top to bottom */
#define RFLAG_VREFRESH_REV 0b00010000 /* bottom to top */
/* page/column order (exchange): */
#define RFLAG_XY_NORM 0b00000000 /* normal */
#define RFLAG_XY_REV 0b00100000 /* reversed */
/* 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_16 0b00000101 /* 16 bits per pixel */
#define RFLAG_DBI_18 0b00000110 /* 18 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 */
/* data transfer: */
#define RFLAG_RIM_OFF 0b00000000 /* 18 bit */
#define RFLAG_RIM_ON 0b10000000 /* 3 times 6 bit */
/*
* read display image format
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_IMG_FORMAT 0b00001101 /* read display image format */
/* data byte #1: dummy data */
/* data byte #2: status */
/* gamma curve */
#define FLAG_IMG_GAMMA1 0b00000000 /* gamma curve 1 (GC0) */
/* ILI9342 only: */
#define FLAG_IMG_GAMMA2 0b00000001 /* gamma curve 2 (GC1.8) */
#define FLAG_IMG_GAMMA3 0b00000010 /* gamma curve 3 (GC2.5) */
#define FLAG_IMG_GAMMA4 0b00000011 /* gamma curve 4 (GC1.0) */
/*
* read display signal mode
* - 1 byte cmd + 2 bytes data (read mode)
*/
#define CMD_READ_SIG_MODE 0b00001110 /* read display signal mode */
/* data byte #1: dummy data */
/* data byte #2: mode flags */
/* 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_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 /* enter partial mode */
/*
* 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 */
/*
* select gamma curve
* - 1 byte cmd + 1 byte data
*/
#define CMD_GAMMA_SET 0b00100110 /* gamma set */
/* data byte #1: gamma curve */
#define FLAG_GC_1 0b00000001 /* gamma curve 1 (G2.2) */
/* ILI9342 only: */
#define FLAG_GC_2 0b00000010 /* gamma curve 2 (GC1.8) */
#define FLAG_GC_3 0b00000100 /* gamma curve 3 (GC2.5) */
#define FLAG_GC_4 0b00001000 /* gamma curve 4 (GC1.0) */
/*
* 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 (accessible 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 - 0x00ef/0x013f */
/*
* 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 - 0x013f/0x00ef */
/*
* 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 */
/*
* define color conversion look-up-table
* - 1 byte cmd + 128 bytes data
*/
#define CMD_COLOR_SET 0b00101101 /* color set */
/* data byte #1 - #32: R00 - R31 (bits 5-0) */
/* data byte #33 - #96: G00 - G64 (bits 5-0) */
/* data byte #97 - #128: B00 - B31 (bits 5-0) */
/*
* 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 - 0x013f */
/*
* 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 /* disable tearing effect */
/*
* enable tearing effect line
* - 1 byte cmd + 1 byte data
*/
#define CMD_TEAR_ON 0b00110101 /* enable tearing effect */
/* 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_V_SCROLL_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_16 0b00000101 /* 16 bits per pixel */
#define FLAG_DBI_18 0b00000110 /* 18 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 */
/*
* 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 scanline
* - 1 byte cmd + 2 bytes data
*/
#define CMD_SET_SCANLINE 0b01000100 /* set scanline */
/* data byte #1: line number - MSB (bit 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 scanline
* - 1 byte cmd + 3 bytes data (read mode)
*/
#define CMD_READ_SCANLINE 0b01000100 /* read scanline */
/* data byte #1: dummy data */
/* data byte #2: line number - MSB (bits 9-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 */
/*
* 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 0b01010111 /* read CABC minimum brightness */
/* data byte #1: dummy data */
/* data byte #2: minimum brightness level of CABC function */
/*
* 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 */
/*
* 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 */
/* ************************************************************************
* extended command set
* ************************************************************************ */
/*
* RGB interface signal control
* - 1 byte cmd + 1 byte data
*/
#define CMD_RGB_SIG_CTRL 0b10110000 /* RGB interface signal control */
/* data byte #1: switches */
/* DE polarity: */
#define FLAG_EPL_HIGH 0b00000000 /* high enable */
#define FLAG_EPL_LOW 0b00000001 /* low enable */
/* DOTCLK 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 */
/* RGB interface, please see datasheet: */
#define FLAG_RCM_DE 0b01000000 /* DE mode */
#define FLAG_RCM_SYNC 0b01100000 /* SYNC mode */
/* data path (RGB interface): */
#define FLAG_BYPASS_DIRECT 0b00000000 /* directly to shift register */
#define FLAG_BYPASS_MEMORY 0b10000000 /* to memory */
/*
* frame rate control in normal mode (full colors)
* - 1 byte cmd + 2 bytes data
*/
#define CMD_FRAME_CTRL_NORM 0b10110001 /* frame rate in 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 */
/* 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 */
/* for full color partial mode: */
#define FLAG_NLC_LINE 0b00000000 /* line inversion */
#define FLAG_NLC_FRAME 0b00000001 /* frame inversion */
/* for idle mode: */
#define FLAG_NLB_LINE 0b00000000 /* line inversion */
#define FLAG_NLB_FRAME 0b00000010 /* frame inversion */
/* for full color normal mode: */
#define FLAG_NLA_LINE 0b00000000 /* line inversion */
#define FLAG_NLA_FRAME 0b00000100 /* frame 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 0b01111111 /* 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 0b01111111 /* 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 0b00011111 /* 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 0b00011111 /* maximum value */
/*
* display function control
* - 1 byte cmd + 4 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 pos / source neg - VCOM pos / VCOM neg */
#define FLAG_PT_0 0b00000000 /* V63 / V0 - VCOML / VCOMH */
#define FLAG_PT_1 0b00000001 /* V0 / V63 - VCOML / VCOMH */
#define FLAG_PT_2 0b00000010 /* AGND / AGND - AGND / AGND */
#define FLAG_PT_3 0b00000011 /* Hi-Z / Hi-Z - AGND / AGND */
/* scan mode in non-display area: */
#define FLAG_PTG_0 0b00000000 /* normal scan */
#define FLAG_PTG_2 0b00001000 /* interval scan */
/* data byte #2: */
/* scan cycle interval of gate driver in non-display area: */
#define FLAG_ISC_01 0b00000000 /* 1 frame */
#define FLAG_ISC_03 0b00000001 /* 3 frames */
#define FLAG_ISC_05 0b00000010 /* 5 frames */
#define FLAG_ISC_07 0b00000011 /* 7 frames */
#define FLAG_ISC_09 0b00000100 /* 9 frames */
#define FLAG_ISC_11 0b00000101 /* 11 frames */
#define FLAG_ISC_13 0b00000110 /* 13 frames */
#define FLAG_ISC_15 0b00000111 /* 15 frames */
#define FLAG_ISC_17 0b00001000 /* 17 frames */
#define FLAG_ISC_19 0b00001001 /* 19 frames */
#define FLAG_ISC_21 0b00001010 /* 21 frames */
#define FLAG_ISC_23 0b00001011 /* 24 frames */
#define FLAG_ISC_25 0b00001100 /* 25 frames */
#define FLAG_ISC_27 0b00001101 /* 27 frames */
#define FLAG_ISC_29 0b00001110 /* 29 frames */
#define FLAG_ISC_31 0b00001111 /* 31 frames */
/* 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 -> S720 */
#define FLAG_SS_1 0b00100000 /* S720 -> S1 */
/* gate driver scan direction: */
#define FLAG_GS_0 0b00000000 /* G1 -> G320 */
#define FLAG_GS_1 0b01000000 /* G320 -> G1 */
/* liquid crytal type: */
#define FLAG_REV_0 0b00000000 /* normally black */
#define FLAG_REV_1 0b10000000 /* normally white */
/* data byte #3: number of lines to drive LCD at an interval of 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 */
#define FLAG_NL_152 0b00010010 /* 152 lines */
#define FLAG_NL_160 0b00010011 /* 160 lines */
#define FLAG_NL_168 0b00010100 /* 168 lines */
#define FLAG_NL_176 0b00010101 /* 176 lines */
#define FLAG_NL_184 0b00010110 /* 184 lines */
#define FLAG_NL_192 0b00010111 /* 192 lines */
#define FLAG_NL_200 0b00011000 /* 200 lines */
#define FLAG_NL_208 0b00011001 /* 208 lines */
#define FLAG_NL_216 0b00011010 /* 216 lines */
#define FLAG_NL_224 0b00011011 /* 224 lines */
#define FLAG_NL_232 0b00011100 /* 232 lines */
#define FLAG_NL_240 0b00011101 /* 240 lines */
#define FLAG_NL_248 0b00011110 /* 248 lines */
#define FLAG_NL_256 0b00011111 /* 256 lines */
#define FLAG_NL_264 0b00100000 /* 264 lines */
#define FLAG_NL_272 0b00100001 /* 272 lines */
#define FLAG_NL_280 0b00100010 /* 280 lines */
#define FLAG_NL_288 0b00100011 /* 288 lines */
#define FLAG_NL_296 0b00100100 /* 296 lines */
#define FLAG_NL_304 0b00100101 /* 304 lines */
#define FLAG_NL_312 0b00100110 /* 312 lines */
#define FLAG_NL_320 0b00100111 /* 320 lines */
/* data byte #4: PCDIV (please see datasheet) */
/*
* entry mode
* - 1 byte cmd + 1 byte data
*/
#define CMD_ENTRY_MODE 0b10110111 /* entry mode set */
/* data byte #1: */
/* low voltage detection control: */
#define FLAG_GAS_ON 0b00000000 /* enable */
#define FLAG_GAS_OFF 0b00000001 /* disable */
/* output level of gate drivers G1-G320 */
#define FLAG_DTE_GON_0 0b00000000 /* VGH */
#define FLAG_DTE_GON_1 0b00000010 /* VGH */
#define FLAG_DTE_GON_2 0b00000100 /* VGL */
#define FLAG_DTE_GON_3 0b00000110 /* normal display */
/*
* backlight control 1
* - 1 byte cmd + 1 byte data
*/
#define CMD_BACKLIGHT_CTRL_1 0b10111000 /* backlight control 1 */