acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

Arduino_NV3041A.h (7488B)

      1 #ifndef _ARDUINO_NV3041A_H_
      2 #define _ARDUINO_NV3041A_H_
      3 
      4 #include <Arduino.h>
      5 #include <Print.h>
      6 #include "../Arduino_GFX.h"
      7 #include "../Arduino_TFT.h"
      8 
      9 #define NV3041A_TFTWIDTH 480
     10 #define NV3041A_TFTHEIGHT 272
     11 
     12 #define NV3041A_RST_DELAY 120    ///< delay ms wait for reset finish
     13 #define NV3041A_SLPIN_DELAY 120  ///< delay ms wait for sleep in finish
     14 #define NV3041A_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
     15 
     16 #define NV3041A_NOP 0x00
     17 #define NV3041A_SWRESET 0x01
     18 
     19 #define NV3041A_SLPIN 0x10
     20 #define NV3041A_SLPOUT 0x11
     21 
     22 #define NV3041A_INVOFF 0x20
     23 #define NV3041A_INVON 0x21
     24 #define NV3041A_DISPOFF 0x28
     25 #define NV3041A_DISPON 0x29
     26 
     27 #define NV3041A_CASET 0x2A
     28 #define NV3041A_RASET 0x2B
     29 #define NV3041A_RAMWR 0x2C
     30 
     31 #define NV3041A_MADCTL 0x36
     32 #define NV3041A_COLMOD 0x3A
     33 
     34 #define NV3041A_MADCTL_MY 0x80
     35 #define NV3041A_MADCTL_MX 0x40
     36 #define NV3041A_MADCTL_MV 0x20
     37 #define NV3041A_MADCTL_ML 0x10
     38 #define NV3041A_MADCTL_RGB 0x00
     39 
     40 static const uint8_t nv3041a_init_operations[] = {
     41     BEGIN_WRITE,
     42     WRITE_C8_D8, 0xff,
     43     0xa5,
     44 
     45     WRITE_C8_D8, 0x36, //
     46     0xc0,
     47 
     48     WRITE_C8_D8, 0x3A, //
     49     0x01,              // 01---565,00---666
     50 
     51     WRITE_C8_D8, 0x41,
     52     0x03, // 01--8bit, 03-16bit
     53 
     54     WRITE_C8_D8, 0x44, // VBP  ?????
     55     0x15,              // 21
     56 
     57     WRITE_C8_D8, 0x45, // VFP  ?????
     58     0x15,              // 21
     59 
     60     WRITE_C8_D8, 0x7d, // vdds_trim[2:0]
     61     0x03,
     62 
     63     WRITE_C8_D8, 0xc1, // avdd_clp_en avdd_clp[1:0] avcl_clp_en avcl_clp[1:0]
     64     0xbb,              // 0xbb	 88		  a2
     65 
     66     WRITE_C8_D8, 0xc2, // vgl_clp_en vgl_clp[2:0]
     67     0x05,
     68 
     69     WRITE_C8_D8, 0xc3, // vgl_clp_en vgl_clp[2:0]
     70     0x10,
     71 
     72     WRITE_C8_D8, 0xc6, // avdd_ratio_sel avcl_ratio_sel vgh_ratio_sel[1:0] vgl_ratio_sel[1:0]
     73     0x3e,              // 35
     74 
     75     WRITE_C8_D8, 0xc7, // mv_clk_sel[1:0] avdd_clk_sel[1:0] avcl_clk_sel[1:0]
     76     0x25,              // 2e
     77 
     78     WRITE_C8_D8, 0xc8, //	VGL_CLK_sel
     79     0x11,              //
     80 
     81     WRITE_C8_D8, 0x7a, //	user_vgsp
     82     0x5f,              // 4f:0.8V		3f:1.04V	5f
     83 
     84     WRITE_C8_D8, 0x6f, //	user_gvdd
     85     0x44,              // 1C:5.61	  5f	 53		   2a	    3a
     86 
     87     WRITE_C8_D8, 0x78, //	user_gvcl
     88     0x70,              // 50:-3.22	  75			58	     	66
     89 
     90     WRITE_C8_D8, 0xc9, //
     91     0x00,
     92 
     93     WRITE_C8_D8, 0x67, //
     94     0x21,
     95 
     96     // gate_ed
     97 
     98     WRITE_C8_D8, 0x51, // gate_st_o[7:0]
     99     0x0a,
    100 
    101     WRITE_C8_D8, 0x52, // gate_ed_o[7:0]
    102     0x76,              // 76
    103 
    104     WRITE_C8_D8, 0x53, // gate_st_e[7:0]
    105     0x0a,              // 76
    106 
    107     WRITE_C8_D8, 0x54, // gate_ed_e[7:0]
    108     0x76,
    109     ////sorce
    110     WRITE_C8_D8, 0x46, // fsm_hbp_o[5:0]
    111     0x0a,
    112 
    113     WRITE_C8_D8, 0x47, // fsm_hfp_o[5:0]
    114     0x2a,
    115 
    116     WRITE_C8_D8, 0x48, // fsm_hbp_e[5:0]
    117     0x0a,
    118 
    119     WRITE_C8_D8, 0x49, // fsm_hfp_e[5:0]
    120     0x1a,
    121 
    122     WRITE_C8_D8, 0x56, // src_ld_wd[1:0] src_ld_st[5:0]
    123     0x43,
    124 
    125     WRITE_C8_D8, 0x57, // pn_cs_en src_cs_st[5:0]
    126     0x42,
    127 
    128     WRITE_C8_D8, 0x58, // src_cs_p_wd[6:0]
    129     0x3c,
    130 
    131     WRITE_C8_D8, 0x59, // src_cs_n_wd[6:0]
    132     0x64,
    133 
    134     WRITE_C8_D8, 0x5a, // src_pchg_st_o[6:0]
    135     0x41,              // 41
    136 
    137     WRITE_C8_D8, 0x5b, // src_pchg_wd_o[6:0]
    138     0x3c,
    139 
    140     WRITE_C8_D8, 0x5c, // src_pchg_st_e[6:0]
    141     0x02,              // 02
    142 
    143     WRITE_C8_D8, 0x5d, // src_pchg_wd_e[6:0]
    144     0x3c,              // 3c
    145 
    146     WRITE_C8_D8, 0x5e, // src_pol_sw[7:0]
    147     0x1f,
    148 
    149     WRITE_C8_D8, 0x60, // src_op_st_o[7:0]
    150     0x80,
    151 
    152     WRITE_C8_D8, 0x61, // src_op_st_e[7:0]
    153     0x3f,
    154 
    155     WRITE_C8_D8, 0x62, // src_op_ed_o[9:8] src_op_ed_e[9:8]
    156     0x21,
    157 
    158     WRITE_C8_D8, 0x63, // src_op_ed_o[7:0]
    159     0x07,
    160 
    161     WRITE_C8_D8, 0x64, // src_op_ed_e[7:0]
    162     0xe0,
    163 
    164     WRITE_C8_D8, 0x65, // chopper
    165     0x02,
    166 
    167     WRITE_C8_D8, 0xca, // avdd_mux_st_o[7:0]
    168     0x20,
    169 
    170     WRITE_C8_D8, 0xcb, // avdd_mux_ed_o[7:0]
    171     0x52,              // 52
    172 
    173     WRITE_C8_D8, 0xcc, // avdd_mux_st_e[7:0]
    174     0x10,
    175 
    176     WRITE_C8_D8, 0xcD, // avdd_mux_ed_e[7:0]
    177     0x42,
    178 
    179     WRITE_C8_D8, 0xD0, // avcl_mux_st_o[7:0]
    180     0x20,
    181 
    182     WRITE_C8_D8, 0xD1, // avcl_mux_ed_o[7:0]
    183     0x52,
    184 
    185     WRITE_C8_D8, 0xD2, // avcl_mux_st_e[7:0]
    186     0x10,
    187 
    188     WRITE_C8_D8, 0xD3, // avcl_mux_ed_e[7:0]
    189     0x42,
    190 
    191     WRITE_C8_D8, 0xD4, // vgh_mux_st[7:0]
    192     0x0a,
    193 
    194     WRITE_C8_D8, 0xD5, // vgh_mux_ed[7:0]
    195     0x32,
    196 
    197     // 2-1
    198     ////gammma  weihuan pianguangpian 0913
    199     WRITE_C8_D8, 0x80, // gam_vrp0	0					6bit
    200     0x00,
    201     WRITE_C8_D8, 0xA0, // gam_VRN0		 0-
    202     0x00,
    203 
    204     WRITE_C8_D8, 0x81, // gam_vrp1	1				   6bit
    205     0x07,
    206     WRITE_C8_D8, 0xA1, // gam_VRN1		 1-
    207     0x06,
    208 
    209     WRITE_C8_D8, 0x82, // gam_vrp2	 2					6bit
    210     0x02,
    211     WRITE_C8_D8, 0xA2, // gam_VRN2		 2-
    212     0x01,
    213 
    214     WRITE_C8_D8, 0x86, // gam_prp0	 7bit	8			7bit
    215     0x11,              // 33
    216     WRITE_C8_D8, 0xA6, // gam_PRN0	 	8-
    217     0x10,              // 2a
    218 
    219     WRITE_C8_D8, 0x87, // gam_prp1	 7bit	 40			 7bit
    220     0x27,              // 2d
    221     WRITE_C8_D8, 0xA7, // gam_PRN1	 	40-
    222     0x27,              // 2d
    223 
    224     WRITE_C8_D8, 0x83, // gam_vrp3	 61				 6bit
    225     0x37,
    226     WRITE_C8_D8, 0xA3, // gam_VRN3		61-
    227     0x37,
    228 
    229     WRITE_C8_D8, 0x84, // gam_vrp4	  62			 6bit
    230     0x35,
    231     WRITE_C8_D8, 0xA4, // gam_VRN4		62-
    232     0x35,
    233 
    234     WRITE_C8_D8, 0x85, // gam_vrp5	  63			 6bit
    235     0x3f,
    236     WRITE_C8_D8, 0xA5, // gam_VRN5		63-
    237     0x3f,
    238     //
    239 
    240     WRITE_C8_D8, 0x88, // gam_pkp0	  	 4			   5bit
    241     0x0b,              // 0b
    242     WRITE_C8_D8, 0xA8, // gam_PKN0		4-
    243     0x0b,              // 0b
    244 
    245     WRITE_C8_D8, 0x89, // gam_pkp1	  5					5bit
    246     0x14,              // 14
    247     WRITE_C8_D8, 0xA9, // gam_PKN1		5-
    248     0x14,              // 14
    249 
    250     WRITE_C8_D8, 0x8a, // gam_pkp2	  7					 5bit
    251     0x1a,              // 1a
    252     WRITE_C8_D8, 0xAa, // gam_PKN2		7-
    253     0x1a,              // 1a
    254 
    255     WRITE_C8_D8, 0x8b, // gam_PKP3	  10				 5bit
    256     0x0a,
    257     WRITE_C8_D8, 0xAb, // gam_PKN3		10-
    258     0x0a,
    259 
    260     WRITE_C8_D8, 0x8c, // gam_PKP4	   16				 5bit
    261     0x14,
    262     WRITE_C8_D8, 0xAc, // gam_PKN4		16-
    263     0x08,
    264 
    265     WRITE_C8_D8, 0x8d, // gam_PKP5		22				 5bit
    266     0x17,
    267     WRITE_C8_D8, 0xAd, // gam_PKN5		22-
    268     0x07,
    269 
    270     WRITE_C8_D8, 0x8e, // gam_PKP6		28				 5bit
    271     0x16,              // 16 change
    272     WRITE_C8_D8, 0xAe, // gam_PKN6		28-
    273     0x06,              // 13change
    274 
    275     WRITE_C8_D8, 0x8f, // gam_PKP7		34				  5bit
    276     0x1B,
    277     WRITE_C8_D8, 0xAf, // gam_PKN7		34-
    278     0x07,
    279 
    280     WRITE_C8_D8, 0x90, // gam_PKP8		 46				   5bit
    281     0x04,
    282     WRITE_C8_D8, 0xB0, // gam_PKN8		46-
    283     0x04,
    284 
    285     WRITE_C8_D8, 0x91, // gam_PKP9		 52					5bit
    286     0x0A,
    287     WRITE_C8_D8, 0xB1, // gam_PKN9		52-
    288     0x0A,
    289 
    290     WRITE_C8_D8, 0x92, // gam_PKP10		58					5bit
    291     0x16,
    292     WRITE_C8_D8, 0xB2, // gam_PKN10		58-
    293     0x15,
    294 
    295     WRITE_C8_D8, 0xff,
    296     0x00,
    297 
    298     WRITE_C8_D8, 0x11,
    299     0x00,
    300     END_WRITE,
    301 
    302     DELAY, 120,
    303 
    304     BEGIN_WRITE,
    305     WRITE_C8_D8, 0x29,
    306     0x00,
    307     END_WRITE,
    308 
    309     DELAY, 100};
    310 
    311 class Arduino_NV3041A : public Arduino_TFT
    312 {
    313 public:
    314   Arduino_NV3041A(
    315       Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
    316       bool ips = false, int16_t w = NV3041A_TFTWIDTH, int16_t h = NV3041A_TFTHEIGHT,
    317       uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
    318 
    319   bool begin(int32_t speed = GFX_NOT_DEFINED) override;
    320 
    321   void setRotation(uint8_t r) override;
    322 
    323   void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
    324 
    325   void invertDisplay(bool) override;
    326   void displayOn() override;
    327   void displayOff() override;
    328 
    329 protected:
    330   void tftInit() override;
    331 
    332 private:
    333 };
    334 
    335 #endif