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_ILI9341.h (4829B)
1 /* 2 * start rewrite from: 3 * https://github.com/adafruit/Adafruit-GFX-Library.git 4 * https://github.com/adafruit/Adafruit_ILI9341.git 5 */ 6 #ifndef _ARDUINO_ILI9341_H_ 7 #define _ARDUINO_ILI9341_H_ 8 9 #include <Arduino.h> 10 #include <Print.h> 11 #include "../Arduino_GFX.h" 12 #include "../Arduino_TFT.h" 13 14 #define ILI9341_TFTWIDTH 240 ///< ILI9341 max TFT width 15 #define ILI9341_TFTHEIGHT 320 ///< ILI9341 max TFT height 16 17 #define ILI9341_RST_DELAY 150 ///< delay ms wait for reset finish 18 #define ILI9341_SLPIN_DELAY 150 ///< delay ms wait for sleep in finish 19 #define ILI9341_SLPOUT_DELAY 150 ///< delay ms wait for sleep out finish 20 21 #define ILI9341_NOP 0x00 ///< No-op register 22 #define ILI9341_SWRESET 0x01 ///< Software reset register 23 #define ILI9341_RDDID 0x04 ///< Read display identification information 24 #define ILI9341_RDDST 0x09 ///< Read Display Status 25 26 #define ILI9341_SLPIN 0x10 ///< Enter Sleep Mode 27 #define ILI9341_SLPOUT 0x11 ///< Sleep Out 28 #define ILI9341_PTLON 0x12 ///< Partial Mode ON 29 #define ILI9341_NORON 0x13 ///< Normal Display Mode ON 30 31 #define ILI9341_RDMODE 0x0A ///< Read Display Power Mode 32 #define ILI9341_RDMADCTL 0x0B ///< Read Display MADCTL 33 #define ILI9341_RDPIXFMT 0x0C ///< Read Display Pixel Format 34 #define ILI9341_RDIMGFMT 0x0D ///< Read Display Image Format 35 #define ILI9341_RDSELFDIAG 0x0F ///< Read Display Self-Diagnostic Result 36 37 #define ILI9341_INVOFF 0x20 ///< Display Inversion OFF 38 #define ILI9341_INVON 0x21 ///< Display Inversion ON 39 #define ILI9341_GAMMASET 0x26 ///< Gamma Set 40 #define ILI9341_DISPOFF 0x28 ///< Display OFF 41 #define ILI9341_DISPON 0x29 ///< Display ON 42 43 #define ILI9341_CASET 0x2A ///< Column Address Set 44 #define ILI9341_PASET 0x2B ///< Page Address Set 45 #define ILI9341_RAMWR 0x2C ///< Memory Write 46 #define ILI9341_RAMRD 0x2E ///< Memory Read 47 48 #define ILI9341_PTLAR 0x30 ///< Partial Area 49 #define ILI9341_VSCRDEF 0x33 ///< Vertical Scrolling Definition 50 #define ILI9341_MADCTL 0x36 ///< Memory Access Control 51 #define ILI9341_VSCRSADD 0x37 ///< Vertical Scrolling Start Address 52 #define ILI9341_PIXFMT 0x3A ///< COLMOD: Pixel Format Set 53 54 #define ILI9341_FRMCTR1 0xB1 ///< Frame Rate Control (In Normal Mode/Full Colors) 55 #define ILI9341_FRMCTR2 0xB2 ///< Frame Rate Control (In Idle Mode/8 colors) 56 #define ILI9341_FRMCTR3 0xB3 ///< Frame Rate control (In Partial Mode/Full Colors) 57 #define ILI9341_INVCTR 0xB4 ///< Display Inversion Control 58 #define ILI9341_DFUNCTR 0xB6 ///< Display Function Control 59 60 #define ILI9341_PWCTR1 0xC0 ///< Power Control 1 61 #define ILI9341_PWCTR2 0xC1 ///< Power Control 2 62 #define ILI9341_PWCTR3 0xC2 ///< Power Control 3 63 #define ILI9341_PWCTR4 0xC3 ///< Power Control 4 64 #define ILI9341_PWCTR5 0xC4 ///< Power Control 5 65 #define ILI9341_VMCTR1 0xC5 ///< VCOM Control 1 66 #define ILI9341_VMCTR2 0xC7 ///< VCOM Control 2 67 68 #define ILI9341_RDID1 0xDA ///< Read ID 1 69 #define ILI9341_RDID2 0xDB ///< Read ID 2 70 #define ILI9341_RDID3 0xDC ///< Read ID 3 71 #define ILI9341_RDID4 0xDD ///< Read ID 4 72 73 #define ILI9341_GMCTRP1 0xE0 ///< Positive Gamma Correction 74 #define ILI9341_GMCTRN1 0xE1 ///< Negative Gamma Correction 75 #define ILI9341_PWCTR6 0xFC 76 77 #define ILI9341_MADCTL_MY 0x80 ///< Bottom to top 78 #define ILI9341_MADCTL_MX 0x40 ///< Right to left 79 #define ILI9341_MADCTL_MV 0x20 ///< Reverse Mode 80 #define ILI9341_MADCTL_ML 0x10 ///< LCD refresh Bottom to top 81 #define ILI9341_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order 82 #define ILI9341_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order 83 #define ILI9341_MADCTL_MH 0x04 ///< LCD refresh right to left 84 85 static const uint8_t ili9341_init_operations[] = { 86 BEGIN_WRITE, 87 WRITE_C8_D8, ILI9341_PWCTR1, 0x23, // Power control VRH[5:0] 88 WRITE_C8_D8, ILI9341_PWCTR2, 0x10, // Power control SAP[2:0];BT[3:0] 89 WRITE_C8_D16, ILI9341_VMCTR1, 0x3e, 0x28, // VCM control 90 WRITE_C8_D8, ILI9341_VMCTR2, 0x86, // VCM control2 91 WRITE_C8_D8, ILI9341_VSCRSADD, 0x00, // Vertical scroll zero 92 WRITE_C8_D8, ILI9341_PIXFMT, 0x55, 93 WRITE_C8_D16, ILI9341_FRMCTR1, 0x00, 0x18, 94 95 WRITE_COMMAND_8, ILI9341_DFUNCTR, // Display Function Control 96 WRITE_BYTES, 3, 0x08, 0x82, 0x27, 97 98 WRITE_COMMAND_8, ILI9341_SLPOUT, // Exit Sleep 99 END_WRITE, 100 101 DELAY, ILI9341_SLPOUT_DELAY, 102 103 BEGIN_WRITE, 104 WRITE_COMMAND_8, ILI9341_DISPON, // Display on 105 END_WRITE}; 106 107 class Arduino_ILI9341 : public Arduino_TFT 108 { 109 public: 110 Arduino_ILI9341(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false); 111 112 bool begin(int32_t speed = GFX_NOT_DEFINED) override; 113 114 void setRotation(uint8_t r) override; 115 116 void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override; 117 118 void invertDisplay(bool) override; 119 void displayOn() override; 120 void displayOff() override; 121 122 protected: 123 void tftInit() override; 124 125 private: 126 }; 127 128 #endif