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_ILI9225.h (5977B)
1 /* 2 * start rewrite from: 3 * https://github.com/adafruit/Adafruit-GFX-Library.git 4 */ 5 #ifndef _ARDUINO_ILI9225_H_ 6 #define _ARDUINO_ILI9225_H_ 7 8 #include <Arduino.h> 9 #include <Print.h> 10 #include "../Arduino_GFX.h" 11 #include "../Arduino_TFT.h" 12 13 #define ILI9225_TFTWIDTH 176 ///< ILI9225 max TFT width 14 #define ILI9225_TFTHEIGHT 220 ///< ILI9225 max TFT height 15 16 #define ILI9225_RST_DELAY 150 ///< delay ms wait for reset finish 17 #define ILI9225_SLPIN_DELAY 150 ///< delay ms wait for sleep in finish 18 #define ILI9225_SLPOUT_DELAY 150 ///< delay ms wait for sleep out finish 19 20 #define ILI9225_DRIVER_OUTPUT_CTRL 0x01 // Driver Output Control 21 #define ILI9225_LCD_AC_DRIVING_CTRL 0x02 // LCD AC Driving Control 22 #define ILI9225_ENTRY_MODE 0x03 // Entry Mode 23 #define ILI9225_DISP_CTRL1 0x07 // Display Control 1 24 #define ILI9225_BLANK_PERIOD_CTRL1 0x08 // Blank Period Control 25 #define ILI9225_FRAME_CYCLE_CTRL 0x0B // Frame Cycle Control 26 #define ILI9225_INTERFACE_CTRL 0x0C // Interface Control 27 #define ILI9225_OSC_CTRL 0x0F // Osc Control 28 #define ILI9225_POWER_CTRL1 0x10 // Power Control 1 29 #define ILI9225_POWER_CTRL2 0x11 // Power Control 2 30 #define ILI9225_POWER_CTRL3 0x12 // Power Control 3 31 #define ILI9225_POWER_CTRL4 0x13 // Power Control 4 32 #define ILI9225_POWER_CTRL5 0x14 // Power Control 5 33 #define ILI9225_VCI_RECYCLING 0x15 // VCI Recycling 34 #define ILI9225_RAM_ADDR_SET1 0x20 // Horizontal GRAM Address Set 35 #define ILI9225_RAM_ADDR_SET2 0x21 // Vertical GRAM Address Set 36 #define ILI9225_GRAM_DATA_REG 0x22 // GRAM Data Register 37 #define ILI9225_GATE_SCAN_CTRL 0x30 // Gate Scan Control Register 38 #define ILI9225_VERTICAL_SCROLL_CTRL1 0x31 // Vertical Scroll Control 1 Register 39 #define ILI9225_VERTICAL_SCROLL_CTRL2 0x32 // Vertical Scroll Control 2 Register 40 #define ILI9225_VERTICAL_SCROLL_CTRL3 0x33 // Vertical Scroll Control 3 Register 41 #define ILI9225_PARTIAL_DRIVING_POS1 0x34 // Partial Driving Position 1 Register 42 #define ILI9225_PARTIAL_DRIVING_POS2 0x35 // Partial Driving Position 2 Register 43 #define ILI9225_HORIZONTAL_WINDOW_ADDR1 0x36 // Horizontal Address Start Position 44 #define ILI9225_HORIZONTAL_WINDOW_ADDR2 0x37 // Horizontal Address End Position 45 #define ILI9225_VERTICAL_WINDOW_ADDR1 0x38 // Vertical Address Start Position 46 #define ILI9225_VERTICAL_WINDOW_ADDR2 0x39 // Vertical Address End Position 47 #define ILI9225_GAMMA_CTRL1 0x50 // Gamma Control 1 48 #define ILI9225_GAMMA_CTRL2 0x51 // Gamma Control 2 49 #define ILI9225_GAMMA_CTRL3 0x52 // Gamma Control 3 50 #define ILI9225_GAMMA_CTRL4 0x53 // Gamma Control 4 51 #define ILI9225_GAMMA_CTRL5 0x54 // Gamma Control 5 52 #define ILI9225_GAMMA_CTRL6 0x55 // Gamma Control 6 53 #define ILI9225_GAMMA_CTRL7 0x56 // Gamma Control 7 54 #define ILI9225_GAMMA_CTRL8 0x57 // Gamma Control 8 55 #define ILI9225_GAMMA_CTRL9 0x58 // Gamma Control 9 56 #define ILI9225_GAMMA_CTRL10 0x59 // Gamma Control 10 57 58 static const uint8_t ili9225_init_operations[] = { 59 BEGIN_WRITE, 60 WRITE_C8_D16, ILI9225_LCD_AC_DRIVING_CTRL, 0x01, 0x00, 61 WRITE_C8_D16, ILI9225_BLANK_PERIOD_CTRL1, 0x08, 0x08, // set BP and FP 62 WRITE_C8_D16, ILI9225_FRAME_CYCLE_CTRL, 0x11, 0x00, // frame cycle 63 WRITE_C8_D16, ILI9225_INTERFACE_CTRL, 0x00, 0x00, // RGB interface setting R0Ch=0x0110 for RGB 18Bit and R0Ch=0111for RGB16Bit 64 WRITE_C8_D16, ILI9225_OSC_CTRL, 0x14, 0x01, // Set frame rate----0801 65 WRITE_C8_D16, ILI9225_VCI_RECYCLING, 0x00, 0x00, // set system interface 66 END_WRITE, 67 68 DELAY, 50, 69 70 //*************Power On sequence ****************// 71 BEGIN_WRITE, 72 WRITE_C8_D16, ILI9225_POWER_CTRL1, 0x08, 0x00, // Set SAP,DSTB,STB----0A00 73 WRITE_C8_D16, ILI9225_POWER_CTRL2, 0x1F, 0x3F, // Set APON,PON,AON,VCI1EN,VC----1038 74 END_WRITE, 75 76 DELAY, 50, 77 78 BEGIN_WRITE, 79 WRITE_C8_D16, ILI9225_POWER_CTRL3, 0x01, 0x21, // Internal reference voltage= Vci;----1121 80 WRITE_C8_D16, ILI9225_POWER_CTRL4, 0x00, 0x6F, // Set GVDD----0066 81 WRITE_C8_D16, ILI9225_POWER_CTRL5, 0x43, 0x49, // Set VCOMH/VCOML voltage----5F60 82 //-------------- Set GRAM area -----------------// 83 WRITE_C8_D16, ILI9225_GATE_SCAN_CTRL, 0x00, 0x00, 84 WRITE_C8_D16, ILI9225_VERTICAL_SCROLL_CTRL1, 0x00, 0xDB, 85 WRITE_C8_D16, ILI9225_VERTICAL_SCROLL_CTRL2, 0x00, 0x00, 86 WRITE_C8_D16, ILI9225_VERTICAL_SCROLL_CTRL3, 0x00, 0x00, 87 WRITE_C8_D16, ILI9225_PARTIAL_DRIVING_POS1, 0x00, 0xDB, 88 WRITE_C8_D16, ILI9225_PARTIAL_DRIVING_POS2, 0x00, 0x00, 89 // ----------- Adjust the Gamma Curve ----------// 90 WRITE_C8_D16, ILI9225_GAMMA_CTRL1, 0x00, 0x01, // 0x0400 91 WRITE_C8_D16, ILI9225_GAMMA_CTRL2, 0x20, 0x0B, // 0x060B 92 WRITE_C8_D16, ILI9225_GAMMA_CTRL3, 0x00, 0x00, // 0x0C0A 93 WRITE_C8_D16, ILI9225_GAMMA_CTRL4, 0x04, 0x04, // 0x0105 94 WRITE_C8_D16, ILI9225_GAMMA_CTRL5, 0x0C, 0x0C, // 0x0A0C 95 WRITE_C8_D16, ILI9225_GAMMA_CTRL6, 0x00, 0x0C, // 0x0B06 96 WRITE_C8_D16, ILI9225_GAMMA_CTRL7, 0x01, 0x01, // 0x0004 97 WRITE_C8_D16, ILI9225_GAMMA_CTRL8, 0x04, 0x00, // 0x0501 98 WRITE_C8_D16, ILI9225_GAMMA_CTRL9, 0x11, 0x08, // 0x0E00 99 WRITE_C8_D16, ILI9225_GAMMA_CTRL10, 0x05, 0x0C, // 0x000E 100 END_WRITE, 101 102 DELAY, 50, 103 104 BEGIN_WRITE, 105 WRITE_C8_D16, ILI9225_DISP_CTRL1, 0x10, 0x17, 106 END_WRITE}; 107 108 class Arduino_ILI9225 : public Arduino_TFT 109 { 110 public: 111 Arduino_ILI9225(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0); 112 113 bool begin(int32_t speed = GFX_NOT_DEFINED) override; 114 void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override; 115 void setRotation(uint8_t r) override; 116 void invertDisplay(bool) override; 117 void displayOn() override; 118 void displayOff() override; 119 120 protected: 121 void tftInit() override; 122 123 private: 124 }; 125 126 #endif