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_ILI9488_3bit.cpp (3421B)
1 #include "Arduino_DataBus.h" 2 #if !defined(LITTLE_FOOT_PRINT) 3 4 #include "Arduino_ILI9488_3bit.h" 5 6 Arduino_ILI9488_3bit::Arduino_ILI9488_3bit(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips) 7 : Arduino_G(ILI9488_TFTWIDTH, ILI9488_TFTHEIGHT), _bus(bus), _rst(rst), _rotation(r), _ips(ips) 8 { 9 } 10 11 bool Arduino_ILI9488_3bit::begin(int32_t speed) 12 { 13 if (!_bus->begin(speed)) 14 { 15 return false; 16 } 17 18 if (_rst != GFX_NOT_DEFINED) 19 { 20 pinMode(_rst, OUTPUT); 21 digitalWrite(_rst, HIGH); 22 delay(100); 23 digitalWrite(_rst, LOW); 24 delay(ILI9488_RST_DELAY); 25 digitalWrite(_rst, HIGH); 26 delay(ILI9488_RST_DELAY); 27 } 28 else 29 { 30 // Software Rest 31 _bus->sendCommand(ILI9488_SWRESET); 32 delay(ILI9488_RST_DELAY); 33 } 34 35 _bus->batchOperation(ili9488_init_operations, sizeof(ili9488_init_operations)); 36 37 _bus->beginWrite(); 38 _bus->writeC8D8(0x3A, 0x01); // Interface Pixel Format, 3 bit 39 _bus->endWrite(); 40 41 if (_ips) 42 { 43 _bus->sendCommand(ILI9488_INVON); 44 } 45 else 46 { 47 _bus->sendCommand(ILI9488_INVOFF); 48 } 49 50 uint16_t r; 51 // setRotation 52 switch (_rotation) 53 { 54 case 1: 55 r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV); 56 break; 57 case 2: 58 r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MY); 59 break; 60 case 3: 61 r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV | ILI9488_MADCTL_MX | ILI9488_MADCTL_MY); 62 break; 63 default: // case 0: 64 r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MX); 65 break; 66 } 67 _bus->beginWrite(); 68 _bus->writeC8D8(ILI9488_MADCTL, r); 69 _bus->endWrite(); 70 71 return true; 72 } 73 74 void Arduino_ILI9488_3bit::drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg) 75 { 76 printf("Not Implemented drawBitmap()"); 77 UNUSED(x); 78 UNUSED(y); 79 UNUSED(bitmap); 80 UNUSED(w); 81 UNUSED(h); 82 UNUSED(color); 83 UNUSED(bg); 84 } 85 86 void Arduino_ILI9488_3bit::drawIndexedBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint16_t *color_index, int16_t w, int16_t h) 87 { 88 printf("Not Implemented drawIndexedBitmap()"); 89 UNUSED(x); 90 UNUSED(y); 91 UNUSED(bitmap); 92 UNUSED(color_index); 93 UNUSED(w); 94 UNUSED(h); 95 } 96 97 void Arduino_ILI9488_3bit::draw3bitRGBBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h) 98 { 99 UNUSED(x); 100 UNUSED(y); 101 _bus->beginWrite(); 102 writeAddrWindow(0, 0, w, h); 103 _bus->writeBytes(bitmap, w * h / 2); 104 _bus->endWrite(); 105 } 106 107 void Arduino_ILI9488_3bit::draw16bitRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h) 108 { 109 printf("Not Implemented draw16bitRGBBitmap()"); 110 UNUSED(x); 111 UNUSED(y); 112 UNUSED(bitmap); 113 UNUSED(w); 114 UNUSED(h); 115 } 116 117 void Arduino_ILI9488_3bit::draw24bitRGBBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h) 118 { 119 printf("Not Implemented draw24bitRGBBitmap()"); 120 UNUSED(x); 121 UNUSED(y); 122 UNUSED(bitmap); 123 UNUSED(w); 124 UNUSED(h); 125 } 126 127 void Arduino_ILI9488_3bit::invertDisplay(bool i) 128 { 129 _bus->sendCommand(i ? ILI9488_INVON : ILI9488_INVOFF); 130 } 131 132 void Arduino_ILI9488_3bit::displayOn(void) 133 { 134 _bus->sendCommand(ILI9488_SLPOUT); 135 delay(ILI9488_SLPOUT_DELAY); 136 } 137 138 void Arduino_ILI9488_3bit::displayOff(void) 139 { 140 _bus->sendCommand(ILI9488_SLPIN); 141 delay(ILI9488_SLPIN_DELAY); 142 } 143 144 void Arduino_ILI9488_3bit::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) 145 { 146 _bus->writeC8D16D16(ILI9488_CASET, x, x + w - 1); 147 _bus->writeC8D16D16(ILI9488_PASET, y, y + h - 1); 148 _bus->writeCommand(ILI9488_RAMWR); 149 } 150 151 #endif // !defined(LITTLE_FOOT_PRINT)