Last active
September 27, 2017 14:43
-
-
Save motters/38a26a66020f674b6389063932048e4c to your computer and use it in GitHub Desktop.
Driver for ILI9844
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change the width and height if required (defined in portrait mode) | |
// or use the constructor to over-ride defaults | |
#define TFT_WIDTH 320 | |
#define TFT_HEIGHT 480 | |
// Delay between some initialisation commands | |
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked | |
/** | |
* Generic commands used by TFT_eSPI.cpp | |
*/ | |
#define TFT_SWRST 0x01 // Software reset | |
#define TFT_CASET 0x2A // Coloumn Address Set | |
#define TFT_PASET 0x2B // Page address set | |
#define TFT_RAMWR 0x2C // Memory write | |
#define TFT_RAMRD 0x2E // Read Memory | |
//#define TFT_IDXRD 0xDD // ILI9341 only, indexed control register read | |
/** | |
* For rotation function | |
*/ | |
#define TFT_MADCTL 0x36 // 0x36 | |
#define TFT_MAD_MY 0x80 // 0x80 128 | |
#define TFT_MAD_MX 0x40 // 0x40 64 | |
#define TFT_MAD_MV 0x20 // 0x20 32 | |
#define TFT_MAD_ML 0x10 // 0x10 16 | |
#define TFT_MAD_BGR 0x08 | |
#define TFT_MAD_MH 0x04 | |
#define TFT_MAD_RGB 0x00 | |
#define TFT_INVOFF 0x20 | |
#define TFT_INVON 0x21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the command sequence that initialises the ILI9844 driver | |
// | |
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions | |
// | |
// See ST7735_Setup.h file for an alternative format | |
{ | |
writecommand(0xE0); | |
writedata(0x00); | |
writedata(0x03); | |
writedata(0x09); | |
writedata(0x08); | |
writedata(0x16); | |
writedata(0x0A); | |
writedata(0x3F); | |
writedata(0x78); | |
writedata(0x4C); | |
writedata(0x09); | |
writedata(0x0A); | |
writedata(0x08); | |
writedata(0x16); | |
writedata(0x1A); | |
writedata(0x0F); | |
writecommand(0XE1); | |
writedata(0x00); | |
writedata(0x16); | |
writedata(0x19); | |
writedata(0x03); | |
writedata(0x0F); | |
writedata(0x05); | |
writedata(0x32); | |
writedata(0x45); | |
writedata(0x46); | |
writedata(0x04); | |
writedata(0x0E); | |
writedata(0x0D); | |
writedata(0x35); | |
writedata(0x37); | |
writedata(0x0F); | |
writecommand(0XC0); //Power Control 1 | |
writedata(0x17); //Vreg1out | |
writedata(0x15); //Verg2out | |
writecommand(0xC1); //Power Control 2 | |
writedata(0x41); //VGH,VGL | |
writecommand(0xC5); //Power Control 3 | |
writedata(0x00); | |
writedata(0x12); //Vcom | |
writedata(0x80); | |
writecommand(0x36); //Memory Access | |
writedata(0x48); | |
writecommand(0x3A); // Interface Pixel Format | |
writedata(0x31); //18 bit | |
writecommand(0XB0); // Interface Mode Control | |
writedata(0x80); //SDO NOT USE | |
writecommand(0xB1); //Frame rate | |
writedata(0xA0); //60Hz | |
writecommand(0xB4); //Display Inversion Control | |
writedata(0x02); //2-dot | |
//writedata(0x00); | |
// writedata(0x18); | |
writecommand(0XB6); //Display Function Control RGB/MCU Interface Control | |
writedata(0x02); //MCU | |
writedata(0x02); //Source,Gate scan dieection | |
writecommand(0XE9); // Set Image Functio | |
writedata(0x00); // Disable 24 bit data | |
writecommand(0xF7); // Adjust Control | |
writedata(0xA9); | |
writedata(0x51); | |
writedata(0x2C); | |
writedata(0x82); // D7 stream, loose | |
writecommand(0x11); //Sleep out | |
delay(120); | |
writecommand(0x29); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the command sequence that rotates the ILI9844 (based of ILI9341) driver coordinate frame | |
rotation = m % 8; // Limit the range of values to 0-7 | |
writecommand(TFT_MADCTL); | |
switch (rotation) { | |
case 0: | |
writedata(TFT_MAD_MX | TFT_MAD_BGR); | |
_width = TFT_WIDTH; | |
_height = TFT_HEIGHT; | |
break; | |
case 1: | |
writedata(TFT_MAD_MV | TFT_MAD_BGR); | |
_width = TFT_HEIGHT; | |
_height = TFT_WIDTH; | |
break; | |
case 2: | |
writedata(TFT_MAD_MY | TFT_MAD_BGR); | |
_width = TFT_WIDTH; | |
_height = TFT_HEIGHT; | |
break; | |
case 3: | |
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); | |
_width = TFT_HEIGHT; | |
_height = TFT_WIDTH; | |
break; | |
// These next rotations are for bottum up BMP drawing | |
case 4: | |
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); | |
_width = TFT_WIDTH; | |
_height = TFT_HEIGHT; | |
break; | |
case 5: | |
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR); | |
_width = TFT_HEIGHT; | |
_height = TFT_WIDTH; | |
break; | |
case 6: | |
writedata(TFT_MAD_BGR); | |
_width = TFT_WIDTH; | |
_height = TFT_HEIGHT; | |
break; | |
case 7: | |
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); | |
_width = TFT_HEIGHT; | |
_height = TFT_WIDTH; | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment