+/***************************************************
+ This is a first stab at modifying the code below, which
+ originally worked on an Arduino, to work directly with
+ an ESP8266, it is not clever, it is not optimised yet
+ but it works. I've tested in landscape mode using GPIOs
+ 4,5,12 and 15 (you may not need RST at all, I hooked it
+ to ESP reset. I did check to see if you can do away with
+ You need EASYGPIO for this - OR you could decide beforehand
+ the pins you want to use and hard-code the IO which would make
+ it marginally faster. Or you could go HERE
+ https://github.com/MetalPhreak/ESP8266_SPI_Driver
+ and transform this software by using hardware SPI on the ESP.
+ I've not done this yet as I want to get the fonts working.
+ Next step is to put the init code in FLASH but it gets messy
+ (fonts will really need to be in flash) so I thought I'd
+ make this available before I start really hacking it up.
+ 17/09/2015 Peter Scargill - http://tech.scargill.net
+ So in use I added this to my main code
+ #include "QDTech/QDTech.h"
+ Then this code to test... remember to scrap any other init or use
+ of the relevant port bits in your code
+ QD_init(4,5,15,12,0,160,128);
+ QD_setAddrWindow(0,0,160,128);
+ QD_fillScreen(QD_Color565(255,0,0));
+ QD_fillRect(30,30,90,90,QD_Color565(0,255,0));
+ for (int qq=0; qq<160;qq++) QD_drawPixel(qq,qq,QD_Color565(0,0,255));
+ There is referrence below to the stock Adafruit GFX library for fonts
+ - not included that yet as that will need modifying to put the fonts
+/***************************************************
+ This is a modification of the Adafruit SPI LCD library,
+ customised for hardware SPI and the QDTech board
+ using a Samsung S6D02A1 chip.
+ Most changes are made to the initialisation routine but
+ non-Arduino code has been removed too.
+ The initialisation sequence comes from Henning Karlsen's
+ UTFT library: http://henningkarlsen.com
+ Using the hardware SPI pins is highly recommeneded.
+ You will also need the stock "Adafruit_GFX" library.
+ https://github.com/adafruit/Adafruit-GFX-Library
+ 6/2/14 1.1 Fixed RGB colour order error
+/***************************************************
+ This is a library for the Adafruit 1.8" SPI display.
+ This library works with the Adafruit 1.8" TFT Breakout w/SD card
+ ----> http://www.adafruit.com/products/358
+ as well as Adafruit raw 1.8" TFT display
+ ----> http://www.adafruit.com/products/618
+ Check out the links above for our tutorials and wiring diagrams
+ These displays use SPI to communicate, 4 or 5 pins are required to
+ interface (RST is optional)
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+ Written by Limor Fried/Ladyada for Adafruit Industries.
+ MIT license, all text above must be included in any redistribution
+ ****************************************************/
+#include "easygpio/easygpio.h"
+#define QDTech_TFTWIDTH 128
+#define QDTech_TFTHEIGHT 160
+// Some used command definitions kept from original
+#define QDTech_INVOFF 0x20
+#define QDTech_INVON 0x21
+#define QDTech_DISPOFF 0x28
+#define QDTech_DISPON 0x29
+#define QDTech_CASET 0x2A
+#define QDTech_RASET 0x2B
+#define QDTech_RAMWR 0x2C
+#define QDTech_RAMRD 0x2E
+#define QDTech_PTLAR 0x30
+#define QDTech_COLMOD 0x3A
+#define QDTech_MADCTL 0x36
+// Basic colour definitions
+#define QDTech_BLACK 0x0000
+#define QDTech_RED 0xF800
+#define QDTech_GREEN 0x07E0
+#define QDTech_BLUE 0x001F
+#define QDTech_YELLOW 0xFFE0
+#define QDTech_MAGENTA 0xF81F
+#define QDTech_CYAN 0x07FF
+#define QDTech_WHITE 0xFFFF
+#define QDTech_GREY 0x632C
+ void QD_init(uint8_t CS, uint8_t RS, uint8_t SID, uint8_t SCLK, uint8_t RST,uint8_t qwidth,uint8_t qheight ),
+ QD_setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1),
+ QD_pushColor(uint16_t color),
+ QD_fillScreen(uint16_t color),
+ QD_drawPixel(int16_t x, int16_t y, uint16_t color),
+ QD_drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
+ QD_drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
+ QD_fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
+ QD_setRotation(uint8_t r),
+ QD_invertDisplay(uint8_t i);
+uint16_t QD_Color565(uint8_t r, uint8_t g, uint8_t b);
+ void QD_spiwrite(uint8_t),
+ QD_writecommand(uint8_t c),
+ QD_writedata(uint8_t d),
+ QD_commandList(const uint8_t *addr),
+ QD_commonInit(const uint8_t *cmdList);
+ uint8_t _cs, _rs, _rst, _sid, _sclk,
+ colstart, rowstart,_width,_height,rotation; // some displays need this changed