Ported Control Serial Display Via Commands. Uses Highest Speed BAUD Rate Possible. You can DRAW,TYPE Create Menus or whatever you like just by communicating with the mbed over serial connection. I did this a while back however Ian Uploaded most of the files i published a while back to his account.
ILI9340_Driver.h
00001 /* PORTED FROM ARDUINO ADAFRUIT TO MBED */ 00002 00003 00004 00005 #include "mbed.h" 00006 00007 #ifndef ILI9340_DRIVER_h 00008 #define ILI9340_DRIVER_h 00009 00010 00011 #define _TFTWIDTH 240 00012 #define _TFTHEIGHT 320 00013 00014 #define ILI9340_NOP 0x00 00015 #define ILI9340_SWRESET 0x01 00016 #define ILI9340_RDDID 0x04 00017 #define ILI9340_RDDST 0x09 00018 00019 #define ILI9340_SLPIN 0x10 00020 #define ILI9340_SLPOUT 0x11 00021 #define ILI9340_PTLON 0x12 00022 #define ILI9340_NORON 0x13 00023 00024 #define ILI9340_RDMODE 0x0A 00025 #define ILI9340_RDMADCTL 0x0B 00026 #define ILI9340_RDPIXFMT 0x0C 00027 #define ILI9340_RDIMGFMT 0x0A 00028 #define ILI9340_RDSELFDIAG 0x0F 00029 00030 #define ILI9340_INVOFF 0x20 00031 #define ILI9340_INVON 0x21 00032 #define ILI9340_GAMMASET 0x26 00033 #define ILI9340_DISPOFF 0x28 00034 #define ILI9340_DISPON 0x29 00035 00036 #define ILI9340_CASET 0x2A 00037 #define ILI9340_PASET 0x2B 00038 #define ILI9340_RAMWR 0x2C 00039 #define ILI9340_RAMRD 0x2E 00040 00041 #define ILI9340_PTLAR 0x30 00042 #define ILI9340_MADCTL 0x36 00043 00044 00045 #define ILI9340_MADCTL_MY 0x80 00046 #define ILI9340_MADCTL_MX 0x40 00047 #define ILI9340_MADCTL_MV 0x20 00048 #define ILI9340_MADCTL_ML 0x10 00049 #define ILI9340_MADCTL_RGB 0x00 00050 #define ILI9340_MADCTL_BGR 0x08 00051 #define ILI9340_MADCTL_MH 0x04 00052 00053 #define ILI9340_PIXFMT 0x3A 00054 00055 #define ILI9340_FRMCTR1 0xB1 00056 #define ILI9340_FRMCTR2 0xB2 00057 #define ILI9340_FRMCTR3 0xB3 00058 #define ILI9340_INVCTR 0xB4 00059 #define ILI9340_DFUNCTR 0xB6 00060 00061 #define ILI9340_PWCTR1 0xC0 00062 #define ILI9340_PWCTR2 0xC1 00063 #define ILI9340_PWCTR3 0xC2 00064 #define ILI9340_PWCTR4 0xC3 00065 #define ILI9340_PWCTR5 0xC4 00066 #define ILI9340_VMCTR1 0xC5 00067 #define ILI9340_VMCTR2 0xC7 00068 00069 #define ILI9340_RDID1 0xDA 00070 #define ILI9340_RDID2 0xDB 00071 #define ILI9340_RDID3 0xDC 00072 #define ILI9340_RDID4 0xDD 00073 00074 #define ILI9340_GMCTRP1 0xE0 00075 #define ILI9340_GMCTRN1 0xE1 00076 /* 00077 #define ILI9340_PWCTR6 0xFC 00078 00079 */ 00080 00081 // Color definitions 00082 #define ILI9340_BLACK 0x0000 00083 #define ILI9340_BLUE 0x001F 00084 #define ILI9340_RED 0xF800 00085 #define ILI9340_GREEN 0x07E0 00086 #define ILI9340_CYAN 0x07FF 00087 #define ILI9340_MAGENTA 0xF81F 00088 #define ILI9340_YELLOW 0xFFE0 00089 #define ILI9340_WHITE 0xFFFF 00090 00091 00092 00093 class ILI9340_Display { 00094 00095 public: 00096 00097 uint16_t _height; 00098 uint16_t _width; 00099 00100 ILI9340_Display(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName dc); 00101 00102 void DispInit(); 00103 void WriteCommand(uint8_t); 00104 void WriteData(uint8_t); 00105 void SetRotation(uint8_t); 00106 void InvertDisplay(bool); 00107 void SetAddrWindow(uint16_t, uint16_t, uint16_t, uint16_t); 00108 00109 void DrawPixel(uint16_t, uint16_t, uint16_t); 00110 void FillScreen(uint16_t); 00111 void DrawFastVLine(int16_t, int16_t, int16_t, uint16_t); 00112 void DrawFastHLine(int16_t, int16_t, int16_t, uint16_t); 00113 void FillRect(int16_t, int16_t, int16_t, int16_t, uint16_t); 00114 void DrawRect(int16_t, int16_t, int16_t, int16_t, uint16_t); 00115 void DrawCircle(int16_t, int16_t, int16_t, uint16_t); 00116 uint16_t Colour565(uint8_t, uint8_t, uint8_t); 00117 00118 void DrawAscii(unsigned char, uint16_t, uint16_t, uint16_t, uint16_t); 00119 void DrawString(char *string, uint16_t, uint16_t, uint8_t, uint16_t); 00120 void IntToChars (char*, int, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t, uint16_t); 00121 00122 void Swap(int16_t*, int16_t*); 00123 void DrawLine(int16_t, int16_t, int16_t, int16_t, uint16_t); 00124 00125 protected: 00126 SPI spi; // mosi, miso, sclk 00127 DigitalOut cs; 00128 DigitalOut rst; 00129 DigitalOut dc; 00130 00131 uint8_t orientation; 00132 00133 }; 00134 00135 00136 00137 00138 00139 #endif
Generated on Tue Jul 26 2022 04:46:04 by 1.7.2