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_ILI9486.h (3820B)

      1 /*
      2  * start rewrite from:
      3  * https://github.com/nopnop2002/esp-idf-parallel-tft
      4  */
      5 #ifndef _ARDUINO_ILI9486_H_
      6 #define _ARDUINO_ILI9486_H_
      7 
      8 #include <Arduino.h>
      9 #include <Print.h>
     10 #include "../Arduino_GFX.h"
     11 #include "../Arduino_TFT.h"
     12 
     13 #define ILI9486_TFTWIDTH 320  ///< ILI9486 max TFT width
     14 #define ILI9486_TFTHEIGHT 480 ///< ILI9486 max TFT height
     15 
     16 #define ILI9486_RST_DELAY 120    ///< delay ms wait for reset finish
     17 #define ILI9486_SLPIN_DELAY 120  ///< delay ms wait for sleep in finish
     18 #define ILI9486_SLPOUT_DELAY 150 ///< delay ms wait for sleep out finish
     19 
     20 #define ILI9486_NOP 0x00     ///< No-op register
     21 #define ILI9486_SWRESET 0x01 ///< Software reset register
     22 #define ILI9486_RDDID 0x04   ///< Read display identification information
     23 #define ILI9486_RDDST 0x09   ///< Read Display Status
     24 
     25 #define ILI9486_SLPIN 0x10  ///< Enter Sleep Mode
     26 #define ILI9486_SLPOUT 0x11 ///< Sleep Out
     27 #define ILI9486_PTLON 0x12  ///< Partial Mode ON
     28 #define ILI9486_NORON 0x13  ///< Normal Display Mode ON
     29 
     30 #define ILI9486_RDMODE 0x0A     ///< Read Display Power Mode
     31 #define ILI9486_RDMADCTL 0x0B   ///< Read Display MADCTL
     32 #define ILI9486_RDPIXFMT 0x0C   ///< Read Display Pixel Format
     33 #define ILI9486_RDIMGFMT 0x0D   ///< Read Display Image Format
     34 #define ILI9486_RDSELFDIAG 0x0F ///< Read Display Self-Diagnostic Result
     35 
     36 #define ILI9486_INVOFF 0x20   ///< Display Inversion OFF
     37 #define ILI9486_INVON 0x21    ///< Display Inversion ON
     38 #define ILI9486_GAMMASET 0x26 ///< Gamma Set
     39 #define ILI9486_DISPOFF 0x28  ///< Display OFF
     40 #define ILI9486_DISPON 0x29   ///< Display ON
     41 
     42 #define ILI9486_CASET 0x2A ///< Column Address Set
     43 #define ILI9486_PASET 0x2B ///< Page Address Set
     44 #define ILI9486_RAMWR 0x2C ///< Memory Write
     45 #define ILI9486_RAMRD 0x2E ///< Memory Read
     46 
     47 #define ILI9486_MADCTL 0x36 ///< Memory Access Control
     48 #define ILI9486_PIXFMT 0x3A ///< COLMOD: Pixel Format Set
     49 
     50 #define ILI9486_GMCTRP1 0xE0 ///< Positive Gamma Correction
     51 #define ILI9486_GMCTRN1 0xE1 ///< Negative Gamma Correction
     52 
     53 #define ILI9486_MADCTL_MY 0x80  ///< Bottom to top
     54 #define ILI9486_MADCTL_MX 0x40  ///< Right to left
     55 #define ILI9486_MADCTL_MV 0x20  ///< Reverse Mode
     56 #define ILI9486_MADCTL_ML 0x10  ///< LCD refresh Bottom to top
     57 #define ILI9486_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
     58 #define ILI9486_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
     59 #define ILI9486_MADCTL_MH 0x04  ///< LCD refresh right to left
     60 #define ILI9486_MADCTL_SS 0x02
     61 #define ILI9486_MADCTL_GS 0x01
     62 
     63 static const uint8_t ili9486_init_operations[] = {
     64     BEGIN_WRITE,
     65     WRITE_COMMAND_8, ILI9486_SWRESET,
     66     END_WRITE,
     67 
     68     DELAY, ILI9486_RST_DELAY,
     69 
     70     BEGIN_WRITE,
     71     WRITE_COMMAND_8, ILI9486_SLPOUT,
     72     END_WRITE,
     73 
     74     DELAY, ILI9486_SLPOUT_DELAY,
     75 
     76     BEGIN_WRITE,
     77     WRITE_C8_D8, ILI9486_PIXFMT, 0x55, // 16 bit colour interface
     78     WRITE_C8_D8, 0xC2, 0x44,
     79     WRITE_COMMAND_8, 0xC5,
     80     WRITE_BYTES, 4, 0x00, 0x00, 0x00, 0x00,
     81     WRITE_COMMAND_8, 0xE0,
     82     WRITE_BYTES, 15,
     83     0x0F, 0x1F, 0x1C, 0x0C, 0x0F,
     84     0x08, 0x48, 0x98, 0x37, 0x0A,
     85     0x13, 0x04, 0x11, 0x0D, 0x00,
     86     WRITE_COMMAND_8, 0xE1,
     87     WRITE_BYTES, 15,
     88     0x0F, 0x32, 0x2E, 0x0B, 0x0D,
     89     0x05, 0x47, 0x75, 0x37, 0x06,
     90     0x10, 0x03, 0x24, 0x20, 0x00,
     91     WRITE_C8_D8, 0x36, 0x48,
     92     WRITE_COMMAND_8, 0x29, // display on
     93     END_WRITE,
     94     DELAY, ILI9486_SLPOUT_DELAY};
     95 
     96 class Arduino_ILI9486 : public Arduino_TFT
     97 {
     98 public:
     99   Arduino_ILI9486(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
    100 
    101   bool begin(int32_t speed = GFX_NOT_DEFINED) override;
    102 
    103   void setRotation(uint8_t r) override;
    104 
    105   void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
    106 
    107   void invertDisplay(bool) override;
    108   void displayOn() override;
    109   void displayOff() override;
    110 
    111 protected:
    112   void tftInit() override;
    113 
    114 private:
    115 };
    116 
    117 #endif