Many changes!
Works in native SPI with Teensy LC, can use alt pin on Teensy's, fixed small bugs, works with more CPU, faster with DUE.
This commit is contained in:
parent
d86d1629ec
commit
de588aabf9
6 changed files with 1094 additions and 701 deletions
887
TFT_ILI9163C.cpp
887
TFT_ILI9163C.cpp
File diff suppressed because it is too large
Load diff
565
TFT_ILI9163C.h
565
TFT_ILI9163C.h
|
|
@ -80,6 +80,8 @@
|
||||||
0.7: Init correction.Clear Screen fix v3 (last time?)
|
0.7: Init correction.Clear Screen fix v3 (last time?)
|
||||||
0.75: SPI transactions for arduino's (beta)
|
0.75: SPI transactions for arduino's (beta)
|
||||||
0.8: Compatiblke with IDE 1.0.6 (teensyduino 1.20) and IDE 1.6.x (teensyduino 1.21b)
|
0.8: Compatiblke with IDE 1.0.6 (teensyduino 1.20) and IDE 1.6.x (teensyduino 1.21b)
|
||||||
|
0.9: Many changes! Now works with more CPU's, alternative pins for Teensy and Teensy LC
|
||||||
|
Works (in standard SPI) with Teensy LC.
|
||||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
BugList of the current version:
|
BugList of the current version:
|
||||||
|
|
||||||
|
|
@ -105,154 +107,47 @@ Done!
|
||||||
#ifndef _TFT_ILI9163CLIB_H_
|
#ifndef _TFT_ILI9163CLIB_H_
|
||||||
#define _TFT_ILI9163CLIB_H_
|
#define _TFT_ILI9163CLIB_H_
|
||||||
|
|
||||||
|
//defined(__MKL26Z64__)
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Print.h"
|
#include "Print.h"
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
|
|
||||||
//DID YOU HAVE A RED PCB, BLACk PCB or WHAT DISPLAY TYPE???????????? ---> SELECT HERE <----
|
#include "_settings/TFT_ILI9163C_settings.h"
|
||||||
#define __144_RED_PCB__//128x128
|
|
||||||
//#define __144_BLACK_PCB__//128x128
|
|
||||||
//#define __22_RED_PCB__//240x320
|
|
||||||
//---------------------------------------
|
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if !defined(_ADAFRUIT_GFX_VARIANT)
|
||||||
#include <include/pio.h>
|
#ifdef __AVR__
|
||||||
#define PROGMEM
|
#include <avr/pgmspace.h>
|
||||||
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
|
#elif defined(__SAM3X8E__)
|
||||||
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
|
#include <include/pio.h>
|
||||||
typedef unsigned char prog_uchar;
|
#define PROGMEM
|
||||||
#define SPICLOCK 8000000
|
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
|
||||||
#endif
|
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
|
||||||
#ifdef __AVR__
|
typedef unsigned char prog_uchar;
|
||||||
#include <avr/pgmspace.h>
|
#endif
|
||||||
#define SPICLOCK 8000000
|
|
||||||
#endif
|
|
||||||
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
|
||||||
#define SPICLOCK 30000000
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(__144_RED_PCB__)
|
|
||||||
/*
|
|
||||||
This display:
|
|
||||||
http://www.ebay.com/itm/Replace-Nokia-5110-LCD-1-44-Red-Serial-128X128-SPI-Color-TFT-LCD-Display-Module-/271422122271
|
|
||||||
This particular display has a design error! The controller has 3 pins to configure to constrain
|
|
||||||
the memory and resolution to a fixed dimension (in that case 128x128) but they leaved those pins
|
|
||||||
configured for 128x160 so there was several pixel memory addressing problems.
|
|
||||||
I solved by setup several parameters that dinamically fix the resolution as needed so below
|
|
||||||
the parameters for this diplay. If you have a strain or a correct display (can happen with chinese)
|
|
||||||
you can copy those parameters and create setup for different displays.
|
|
||||||
*/
|
|
||||||
#define _TFTWIDTH 128//the REAL W resolution of the TFT
|
|
||||||
#define _TFTHEIGHT 128//the REAL H resolution of the TFT
|
|
||||||
#define _GRAMWIDTH 128
|
|
||||||
#define _GRAMHEIGH 160//160
|
|
||||||
#define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH//*see note 1
|
|
||||||
#define __COLORSPC 1// 1:GBR - 0:RGB
|
|
||||||
#define __GAMMASET3 //uncomment for another gamma
|
|
||||||
#define __OFFSET 32//*see note 2
|
|
||||||
//Tested!
|
|
||||||
#elif defined (__144_BLACK_PCB__)
|
|
||||||
#define _TFTWIDTH 128//the REAL W resolution of the TFT
|
|
||||||
#define _TFTHEIGHT 128//the REAL H resolution of the TFT
|
|
||||||
#define _GRAMWIDTH 128
|
|
||||||
#define _GRAMHEIGH 128
|
|
||||||
#define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH//*see note 1
|
|
||||||
#define __COLORSPC 1// 1:GBR - 0:RGB
|
|
||||||
#define __GAMMASET1 //uncomment for another gamma
|
|
||||||
#define __OFFSET 0
|
|
||||||
//not tested
|
|
||||||
#elif defined (__22_RED_PCB__)
|
|
||||||
/*
|
|
||||||
Like this one:
|
|
||||||
http://www.ebay.it/itm/2-2-Serial-SPI-TFT-LCD-Display-Module-240x320-Chip-ILI9340C-PCB-Adapter-SD-Card-/281304733556
|
|
||||||
Not tested!
|
|
||||||
*/
|
|
||||||
#define _TFTWIDTH 240//the REAL W resolution of the TFT
|
|
||||||
#define _TFTHEIGHT 320//the REAL H resolution of the TFT
|
|
||||||
#define _GRAMWIDTH 240
|
|
||||||
#define _GRAMHEIGH 320
|
|
||||||
#define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH
|
|
||||||
#define __COLORSPC 1// 1:GBR - 0:RGB
|
|
||||||
#define __GAMMASET1 //uncomment for another gamma
|
|
||||||
#define __OFFSET 0
|
|
||||||
#else
|
|
||||||
#define _TFTWIDTH 128//128
|
|
||||||
#define _TFTHEIGHT 160//160
|
|
||||||
#define _GRAMWIDTH 128
|
|
||||||
#define _GRAMHEIGH 160
|
|
||||||
#define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH
|
|
||||||
#define __COLORSPC 1// 1:GBR - 0:RGB
|
|
||||||
#define __GAMMASET1
|
|
||||||
#define __OFFSET 0
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
Note 1: The __144_RED_PCB__ display has hardware addressing of 128 x 160
|
|
||||||
but the tft resolution it's 128 x 128 so the dram should be set correctly
|
|
||||||
|
|
||||||
Note 2: This is the offset between image in RAM and TFT. In that case 160 - 128 = 32;
|
|
||||||
*/
|
|
||||||
//--------- Keep out hands from here!-------------
|
//--------- Keep out hands from here!-------------
|
||||||
|
|
||||||
#define BLACK 0x0000
|
#define BLACK 0x0000
|
||||||
#define WHITE 0xFFFF
|
#define WHITE 0xFFFF
|
||||||
|
|
||||||
//ILI9163C registers-----------------------
|
#include "_settings/TFT_ILI9163C_registers.h"
|
||||||
#define CMD_NOP 0x00//Non operation
|
|
||||||
#define CMD_SWRESET 0x01//Soft Reset
|
|
||||||
#define CMD_SLPIN 0x10//Sleep ON
|
|
||||||
#define CMD_SLPOUT 0x11//Sleep OFF
|
|
||||||
#define CMD_PTLON 0x12//Partial Mode ON
|
|
||||||
#define CMD_NORML 0x13//Normal Display ON
|
|
||||||
#define CMD_DINVOF 0x20//Display Inversion OFF
|
|
||||||
#define CMD_DINVON 0x21//Display Inversion ON
|
|
||||||
#define CMD_GAMMASET 0x26//Gamma Set (0x01[1],0x02[2],0x04[3],0x08[4])
|
|
||||||
#define CMD_DISPOFF 0x28//Display OFF
|
|
||||||
#define CMD_DISPON 0x29//Display ON
|
|
||||||
#define CMD_IDLEON 0x39//Idle Mode ON
|
|
||||||
#define CMD_IDLEOF 0x38//Idle Mode OFF
|
|
||||||
#define CMD_CLMADRS 0x2A//Column Address Set
|
|
||||||
#define CMD_PGEADRS 0x2B//Page Address Set
|
|
||||||
|
|
||||||
#define CMD_RAMWR 0x2C//Memory Write
|
|
||||||
#define CMD_RAMRD 0x2E//Memory Read
|
|
||||||
#define CMD_CLRSPACE 0x2D//Color Space : 4K/65K/262K
|
|
||||||
#define CMD_PARTAREA 0x30//Partial Area
|
|
||||||
#define CMD_VSCLLDEF 0x33//Vertical Scroll Definition
|
|
||||||
#define CMD_TEFXLON 0x35//Tearing Effect Line ON
|
|
||||||
#define CMD_TEFXLOF 0x34//Tearing Effect Line OFF
|
|
||||||
#define CMD_MADCTL 0x36//Memory Access Control
|
|
||||||
#define CMD_VSSTADRS 0x37//Vertical Scrolling Start address
|
|
||||||
#define CMD_PIXFMT 0x3A//Interface Pixel Format
|
|
||||||
#define CMD_FRMCTR1 0xB1//Frame Rate Control (In normal mode/Full colors)
|
|
||||||
#define CMD_FRMCTR2 0xB2//Frame Rate Control(In Idle mode/8-colors)
|
|
||||||
#define CMD_FRMCTR3 0xB3//Frame Rate Control(In Partial mode/full colors)
|
|
||||||
#define CMD_DINVCTR 0xB4//Display Inversion Control
|
|
||||||
#define CMD_RGBBLK 0xB5//RGB Interface Blanking Porch setting
|
|
||||||
#define CMD_DFUNCTR 0xB6//Display Fuction set 5
|
|
||||||
#define CMD_SDRVDIR 0xB7//Source Driver Direction Control
|
|
||||||
#define CMD_GDRVDIR 0xB8//Gate Driver Direction Control
|
|
||||||
|
|
||||||
#define CMD_PWCTR1 0xC0//Power_Control1
|
|
||||||
#define CMD_PWCTR2 0xC1//Power_Control2
|
|
||||||
#define CMD_PWCTR3 0xC2//Power_Control3
|
|
||||||
#define CMD_PWCTR4 0xC3//Power_Control4
|
|
||||||
#define CMD_PWCTR5 0xC4//Power_Control5
|
|
||||||
#define CMD_VCOMCTR1 0xC5//VCOM_Control 1
|
|
||||||
#define CMD_VCOMCTR2 0xC6//VCOM_Control 2
|
|
||||||
#define CMD_VCOMOFFS 0xC7//VCOM Offset Control
|
|
||||||
#define CMD_PGAMMAC 0xE0//Positive Gamma Correction Setting
|
|
||||||
#define CMD_NGAMMAC 0xE1//Negative Gamma Correction Setting
|
|
||||||
#define CMD_GAMRSEL 0xF2//GAM_R_SEL
|
|
||||||
|
|
||||||
|
|
||||||
class TFT_ILI9163C : public Adafruit_GFX {
|
class TFT_ILI9163C : public Adafruit_GFX {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TFT_ILI9163C(uint8_t cspin,uint8_t dcpin,uint8_t rstpin);
|
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||||
TFT_ILI9163C(uint8_t CS, uint8_t DC);//connect rst pin to VDD
|
TFT_ILI9163C(uint8_t cspin,uint8_t dcpin,uint8_t rstpin=255,uint8_t mosi=11,uint8_t sclk=13);
|
||||||
|
#elif defined(__MKL26Z64__)
|
||||||
|
TFT_ILI9163C(uint8_t cspin,uint8_t dcpin,uint8_t rstpin=255,bool useSPI1=false);
|
||||||
|
#else
|
||||||
|
TFT_ILI9163C(uint8_t cspin,uint8_t dcpin,uint8_t rstpin=255);
|
||||||
|
#endif
|
||||||
|
//TFT_ILI9163C(uint8_t CS, uint8_t DC);//connect rst pin to VDD
|
||||||
|
|
||||||
void begin(void),
|
void begin(void),
|
||||||
setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1),//graphic Addressing
|
setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1),//graphic Addressing
|
||||||
|
|
@ -264,8 +159,8 @@ class TFT_ILI9163C : public Adafruit_GFX {
|
||||||
drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
|
drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
|
||||||
drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
|
drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
|
||||||
#if defined(__MK20DX128__) || defined(__MK20DX256__)//workaround to get more speed from Teensy
|
#if defined(__MK20DX128__) || defined(__MK20DX256__)//workaround to get more speed from Teensy
|
||||||
drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color),
|
drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color),
|
||||||
drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
|
drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
|
||||||
#endif
|
#endif
|
||||||
fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color),
|
fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color),
|
||||||
setRotation(uint8_t r),
|
setRotation(uint8_t r),
|
||||||
|
|
@ -283,162 +178,274 @@ class TFT_ILI9163C : public Adafruit_GFX {
|
||||||
//convert 24bit color into packet 16 bit one (credits for this are all mine)
|
//convert 24bit color into packet 16 bit one (credits for this are all mine)
|
||||||
inline uint16_t Color24To565(int32_t color_) { return ((((color_ >> 16) & 0xFF) / 8) << 11) | ((((color_ >> 8) & 0xFF) / 4) << 5) | (((color_) & 0xFF) / 8);}
|
inline uint16_t Color24To565(int32_t color_) { return ((((color_ >> 16) & 0xFF) / 8) << 11) | ((((color_ >> 8) & 0xFF) / 4) << 5) | (((color_) & 0xFF) / 8);}
|
||||||
void setBitrate(uint32_t n);
|
void setBitrate(uint32_t n);
|
||||||
|
protected:
|
||||||
|
volatile uint8_t _Mactrl_Data;//container for the memory access control data
|
||||||
|
uint8_t _colorspaceData;
|
||||||
|
|
||||||
|
/* inline void startTransaction(void){
|
||||||
|
//__attribute__((always_inline)) {
|
||||||
|
#if defined(SPI_HAS_TRANSACTION)
|
||||||
|
SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
|
||||||
|
#endif
|
||||||
|
#if defined(__AVR__)
|
||||||
|
*csport &= ~cspinmask;//low
|
||||||
|
#elif defined(__SAM3X8E__)
|
||||||
|
csport->PIO_CODR |= cspinmask;//LO
|
||||||
|
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||||
|
//nop
|
||||||
|
#elif defined(__MKL26Z64__)
|
||||||
|
digitalWriteFast(_cs,LOW);
|
||||||
|
#else
|
||||||
|
digitalWrite(_cs,LOW);
|
||||||
|
#endif
|
||||||
|
} */
|
||||||
|
|
||||||
|
/* inline void stopTransaction(void){
|
||||||
|
//__attribute__((always_inline)) {
|
||||||
|
#if defined(__AVR__)
|
||||||
|
*csport |= cspinmask;//hi
|
||||||
|
#elif defined(__SAM3X8E__)
|
||||||
|
csport->PIO_SODR |= cspinmask;//HI
|
||||||
|
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||||
|
//nop
|
||||||
|
#elif defined(__MKL26Z64__)
|
||||||
|
digitalWriteFast(_cs,HIGH);
|
||||||
|
#else
|
||||||
|
digitalWrite(_cs,HIGH);
|
||||||
|
#endif
|
||||||
|
#if defined(SPI_HAS_TRANSACTION)
|
||||||
|
SPI.endTransaction();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#if defined(__AVR__)
|
||||||
|
void spiwrite(uint8_t);
|
||||||
|
volatile uint8_t *dataport, *clkport, *csport, *rsport;
|
||||||
|
uint8_t _cs,_rs,_rst;
|
||||||
|
uint8_t datapinmask, clkpinmask, cspinmask, rspinmask;
|
||||||
|
#elif defined(__SAM3X8E__)
|
||||||
|
void spiwrite(uint8_t);
|
||||||
|
Pio *dataport, *clkport, *csport, *rsport;
|
||||||
|
uint8_t _cs,_rs,_rst;
|
||||||
|
uint32_t datapinmask, clkpinmask, cspinmask, rspinmask;
|
||||||
|
#elif defined(__MKL26Z64__)
|
||||||
|
uint8_t _cs,_rs,_rst;
|
||||||
|
bool _useSPI1;
|
||||||
|
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||||
|
uint8_t _cs, _rs, _rst;
|
||||||
|
uint8_t pcs_data, pcs_command;
|
||||||
|
uint8_t _miso, _mosi, _sclk;
|
||||||
|
|
||||||
|
void _setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);//graphic Addressing for Teensy
|
||||||
|
|
||||||
|
|
||||||
|
//Here's Paul Stoffregen magic in action...
|
||||||
|
void waitFifoNotFull(void) {
|
||||||
|
uint32_t sr;
|
||||||
|
uint32_t tmp __attribute__((unused));
|
||||||
|
do {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
sr = KINETISK_SPI0.SR;
|
||||||
|
#else
|
||||||
|
sr = SPI0.SR;
|
||||||
|
#endif
|
||||||
|
if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO
|
||||||
|
} while ((sr & (15 << 12)) > (3 << 12));
|
||||||
|
}
|
||||||
|
|
||||||
|
void waitFifoEmpty(void) {
|
||||||
|
uint32_t sr;
|
||||||
|
uint32_t tmp __attribute__((unused));
|
||||||
|
do {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
sr = KINETISK_SPI0.SR;
|
||||||
|
if (sr & 0xF0) tmp = KINETISK_SPI0.POPR; // drain RX FIFO
|
||||||
|
#else
|
||||||
|
sr = SPI0.SR;
|
||||||
|
if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO
|
||||||
|
#endif
|
||||||
|
} while ((sr & 0xF0F0) > 0); // wait both RX & TX empty
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(__FORCECOMPAT_SPI)//faster
|
||||||
|
void waitTransmitComplete(void)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
uint32_t tmp __attribute__((unused));
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
while (!(KINETISK_SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
|
||||||
|
#else
|
||||||
|
while (!(SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
|
||||||
|
#endif
|
||||||
|
tmp = SPI0_POPR; // drain the final RX FIFO word
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void waitTransmitComplete(uint32_t mcr)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
uint32_t tmp __attribute__((unused));
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
while (1) {
|
||||||
|
uint32_t sr = KINETISK_SPI0.SR;
|
||||||
|
if (sr & SPI_SR_EOQF) break; // wait for last transmit
|
||||||
|
if (sr & 0xF0) tmp = KINETISK_SPI0.POPR;
|
||||||
|
}
|
||||||
|
KINETISK_SPI0.SR = SPI_SR_EOQF;
|
||||||
|
SPI0_MCR = mcr;
|
||||||
|
while (KINETISK_SPI0.SR & 0xF0) {
|
||||||
|
tmp = KINETISK_SPI0.POPR;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
while (1) {
|
||||||
|
uint32_t sr = SPI0.SR;
|
||||||
|
if (sr & SPI_SR_EOQF) break; // wait for last transmit
|
||||||
|
if (sr & 0xF0) tmp = SPI0_POPR;
|
||||||
|
}
|
||||||
|
SPI0.SR = SPI_SR_EOQF;
|
||||||
|
SPI0_MCR = mcr;
|
||||||
|
while (SPI0.SR & 0xF0) {
|
||||||
|
tmp = SPI0_POPR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void writecommand_cont(uint8_t c)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
||||||
|
#else
|
||||||
|
SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
||||||
|
#endif
|
||||||
|
waitFifoNotFull();
|
||||||
|
}
|
||||||
|
|
||||||
|
void writedata8_cont(uint8_t c)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
||||||
|
#else
|
||||||
|
SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
||||||
|
#endif
|
||||||
|
waitFifoNotFull();
|
||||||
|
}
|
||||||
|
|
||||||
|
void writedata16_cont(uint16_t d)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
|
||||||
|
#else
|
||||||
|
SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
|
||||||
|
#endif
|
||||||
|
waitFifoNotFull();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(__FORCECOMPAT_SPI)
|
||||||
|
void writecommand_last(uint8_t c)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
waitFifoEmpty();
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.SR = SPI_SR_TCF;
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0);
|
||||||
|
#else
|
||||||
|
SPI0.SR = SPI_SR_TCF;
|
||||||
|
SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0);
|
||||||
|
#endif
|
||||||
|
waitTransmitComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void writedata8_last(uint8_t c)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
waitFifoEmpty();
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.SR = SPI_SR_TCF;
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0);
|
||||||
|
#else
|
||||||
|
SPI0.SR = SPI_SR_TCF;
|
||||||
|
SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0);
|
||||||
|
#endif
|
||||||
|
waitTransmitComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
void writedata16_last(uint16_t d)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
waitFifoEmpty();
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.SR = SPI_SR_TCF;
|
||||||
|
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1);
|
||||||
|
#else
|
||||||
|
SPI0.SR = SPI_SR_TCF;
|
||||||
|
SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1);
|
||||||
|
#endif
|
||||||
|
waitTransmitComplete();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void writecommand_last(uint8_t c)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
uint32_t mcr = SPI0_MCR;
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;
|
||||||
|
#else
|
||||||
|
SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;
|
||||||
|
#endif
|
||||||
|
waitTransmitComplete(mcr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void writedata8_last(uint8_t c)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
uint32_t mcr = SPI0_MCR;
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;
|
||||||
|
#else
|
||||||
|
SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;
|
||||||
|
#endif
|
||||||
|
waitTransmitComplete(mcr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void writedata16_last(uint16_t d)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
uint32_t mcr = SPI0_MCR;
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_EOQ;
|
||||||
|
#else
|
||||||
|
SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_EOQ;
|
||||||
|
#endif
|
||||||
|
waitTransmitComplete(mcr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
void HLine(int16_t x, int16_t y, int16_t w, uint16_t color)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
_setAddrWindow(x, y, x+w-1, y);
|
||||||
|
do { writedata16_cont(color); } while (--w > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VLine(int16_t x, int16_t y, int16_t h, uint16_t color)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
_setAddrWindow(x, y, x, y+h-1);
|
||||||
|
do { writedata16_cont(color); } while (--h > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pixel(int16_t x, int16_t y, uint16_t color)
|
||||||
|
__attribute__((always_inline)) {
|
||||||
|
_setAddrWindow(x, y, x, y);
|
||||||
|
writedata16_cont(color);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
uint8_t _cs,_rs,_rst;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__MK20DX128__) && !defined(__MK20DX256__)
|
||||||
|
void writecommand(uint8_t c);
|
||||||
|
void writedata(uint8_t d);
|
||||||
|
void writedata16(uint16_t d);
|
||||||
|
#endif
|
||||||
private:
|
private:
|
||||||
uint8_t _Mactrl_Data;//container for the memory access control data
|
|
||||||
uint8_t _colorspaceData;
|
|
||||||
void colorSpace(uint8_t cspace);
|
void colorSpace(uint8_t cspace);
|
||||||
void setAddr(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
void setAddr(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||||
void endProc(void);
|
|
||||||
uint8_t sleep;
|
uint8_t sleep;
|
||||||
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
|
||||||
//
|
|
||||||
#else
|
|
||||||
void writecommand(uint8_t c);
|
|
||||||
void writedata(uint8_t d);
|
|
||||||
void writedata16(uint16_t d);
|
|
||||||
#endif
|
|
||||||
void chipInit();
|
void chipInit();
|
||||||
bool boundaryCheck(int16_t x,int16_t y);
|
bool boundaryCheck(int16_t x,int16_t y);
|
||||||
void homeAddress();
|
void homeAddress();
|
||||||
#if defined(__AVR__)
|
|
||||||
void spiwrite(uint8_t);
|
|
||||||
volatile uint8_t *dataport, *clkport, *csport, *rsport;
|
|
||||||
uint8_t _cs,_rs,_sid,_sclk,_rst;
|
|
||||||
uint8_t datapinmask, clkpinmask, cspinmask, rspinmask;
|
|
||||||
#endif // #ifdef __AVR__
|
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
|
||||||
void spiwrite(uint8_t);
|
|
||||||
Pio *dataport, *clkport, *csport, *rsport;
|
|
||||||
uint8_t _cs,_rs,_sid,_sclk,_rst;
|
|
||||||
uint32_t datapinmask, clkpinmask, cspinmask, rspinmask;
|
|
||||||
#endif // #if defined(__SAM3X8E__)
|
|
||||||
|
|
||||||
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
|
||||||
//Here's Paul Stoffregen magic in action...
|
|
||||||
uint8_t _cs, _rs, _rst;
|
|
||||||
uint8_t pcs_data, pcs_command;
|
|
||||||
|
|
||||||
void _setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);//graphic Addressing for Teensy
|
|
||||||
|
|
||||||
void waitFifoNotFull(void) {
|
|
||||||
uint32_t sr;
|
|
||||||
uint32_t tmp __attribute__((unused));
|
|
||||||
do {
|
|
||||||
#if ARDUINO >= 160
|
|
||||||
sr = KINETISK_SPI0.SR;
|
|
||||||
#else
|
|
||||||
sr = SPI0.SR;
|
|
||||||
#endif
|
|
||||||
if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO
|
|
||||||
} while ((sr & (15 << 12)) > (3 << 12));
|
|
||||||
}
|
|
||||||
|
|
||||||
void waitFifoEmpty(void) {
|
|
||||||
uint32_t sr;
|
|
||||||
uint32_t tmp __attribute__((unused));
|
|
||||||
do {
|
|
||||||
#if ARDUINO >= 160
|
|
||||||
sr = KINETISK_SPI0.SR;
|
|
||||||
#else
|
|
||||||
sr = SPI0.SR;
|
|
||||||
#endif
|
|
||||||
if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO
|
|
||||||
} while ((sr & 0xF0F0) > 0); // wait both RX & TX empty
|
|
||||||
}
|
|
||||||
|
|
||||||
void waitTransmitComplete(void) __attribute__((always_inline)) {
|
|
||||||
uint32_t tmp __attribute__((unused));
|
|
||||||
#if ARDUINO >= 160
|
|
||||||
while (!(KINETISK_SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
|
|
||||||
#else
|
|
||||||
while (!(SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
|
|
||||||
#endif
|
|
||||||
tmp = SPI0_POPR; // drain the final RX FIFO word
|
|
||||||
}
|
|
||||||
|
|
||||||
void writecommand_cont(uint8_t c) __attribute__((always_inline)) {
|
|
||||||
#if ARDUINO >= 160
|
|
||||||
KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
|
||||||
#else
|
|
||||||
SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
|
||||||
#endif
|
|
||||||
waitFifoNotFull();
|
|
||||||
}
|
|
||||||
|
|
||||||
void writedata8_cont(uint8_t c) __attribute__((always_inline)) {
|
|
||||||
#if ARDUINO >= 160
|
|
||||||
KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
|
||||||
#else
|
|
||||||
SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
|
||||||
#endif
|
|
||||||
waitFifoNotFull();
|
|
||||||
}
|
|
||||||
|
|
||||||
void writedata16_cont(uint16_t d) __attribute__((always_inline)) {
|
|
||||||
#if ARDUINO >= 160
|
|
||||||
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
|
|
||||||
#else
|
|
||||||
SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
|
|
||||||
#endif
|
|
||||||
waitFifoNotFull();
|
|
||||||
}
|
|
||||||
|
|
||||||
void writecommand_last(uint8_t c) __attribute__((always_inline)) {
|
|
||||||
waitFifoEmpty();
|
|
||||||
#if ARDUINO >= 160
|
|
||||||
KINETISK_SPI0.SR = SPI_SR_TCF;
|
|
||||||
KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0);
|
|
||||||
#else
|
|
||||||
SPI0.SR = SPI_SR_TCF;
|
|
||||||
SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0);
|
|
||||||
#endif
|
|
||||||
waitTransmitComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
void writedata8_last(uint8_t c) __attribute__((always_inline)) {
|
|
||||||
waitFifoEmpty();
|
|
||||||
#if ARDUINO >= 160
|
|
||||||
KINETISK_SPI0.SR = SPI_SR_TCF;
|
|
||||||
KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0);
|
|
||||||
#else
|
|
||||||
SPI0.SR = SPI_SR_TCF;
|
|
||||||
SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0);
|
|
||||||
#endif
|
|
||||||
waitTransmitComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
void writedata16_last(uint16_t d) __attribute__((always_inline)) {
|
|
||||||
waitFifoEmpty();
|
|
||||||
#if ARDUINO >= 160
|
|
||||||
KINETISK_SPI0.SR = SPI_SR_TCF;
|
|
||||||
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1);
|
|
||||||
#else
|
|
||||||
SPI0.SR = SPI_SR_TCF;
|
|
||||||
SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1);
|
|
||||||
#endif
|
|
||||||
waitTransmitComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HLine(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline)) {
|
|
||||||
_setAddrWindow(x, y, x+w-1, y);
|
|
||||||
//writecommand_cont(CMD_RAMWR);//not needed
|
|
||||||
do { writedata16_cont(color); } while (--w > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pixel(int16_t x, int16_t y, uint16_t color) __attribute__((always_inline)) {
|
|
||||||
_setAddrWindow(x, y, x, y);
|
|
||||||
//writecommand_cont(CMD_RAMWR);//not needed
|
|
||||||
writedata16_cont(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VLine(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline)) {
|
|
||||||
_setAddrWindow(x, y, x, y+h-1);
|
|
||||||
//writecommand_cont(CMD_RAMWR);//not needed
|
|
||||||
do { writedata16_cont(color); } while (--h > 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
54
_settings/TFT_ILI9163C_registers.h
Normal file
54
_settings/TFT_ILI9163C_registers.h
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef _TFT_ILI9163C_REG_H_
|
||||||
|
#define _TFT_ILI9163C_REG_H_
|
||||||
|
|
||||||
|
|
||||||
|
//ILI9163C registers-----------------------
|
||||||
|
#define CMD_NOP 0x00//Non operation
|
||||||
|
#define CMD_SWRESET 0x01//Soft Reset
|
||||||
|
#define CMD_SLPIN 0x10//Sleep ON
|
||||||
|
#define CMD_SLPOUT 0x11//Sleep OFF
|
||||||
|
#define CMD_PTLON 0x12//Partial Mode ON
|
||||||
|
#define CMD_NORML 0x13//Normal Display ON
|
||||||
|
#define CMD_DINVOF 0x20//Display Inversion OFF
|
||||||
|
#define CMD_DINVON 0x21//Display Inversion ON
|
||||||
|
#define CMD_GAMMASET 0x26//Gamma Set (0x01[1],0x02[2],0x04[3],0x08[4])
|
||||||
|
#define CMD_DISPOFF 0x28//Display OFF
|
||||||
|
#define CMD_DISPON 0x29//Display ON
|
||||||
|
#define CMD_IDLEON 0x39//Idle Mode ON
|
||||||
|
#define CMD_IDLEOF 0x38//Idle Mode OFF
|
||||||
|
#define CMD_CLMADRS 0x2A//Column Address Set
|
||||||
|
#define CMD_PGEADRS 0x2B//Page Address Set
|
||||||
|
|
||||||
|
#define CMD_RAMWR 0x2C//Memory Write
|
||||||
|
#define CMD_RAMRD 0x2E//Memory Read
|
||||||
|
#define CMD_CLRSPACE 0x2D//Color Space : 4K/65K/262K
|
||||||
|
#define CMD_PARTAREA 0x30//Partial Area
|
||||||
|
#define CMD_VSCLLDEF 0x33//Vertical Scroll Definition
|
||||||
|
#define CMD_TEFXLON 0x35//Tearing Effect Line ON
|
||||||
|
#define CMD_TEFXLOF 0x34//Tearing Effect Line OFF
|
||||||
|
#define CMD_MADCTL 0x36//Memory Access Control
|
||||||
|
#define CMD_VSSTADRS 0x37//Vertical Scrolling Start address
|
||||||
|
#define CMD_PIXFMT 0x3A//Interface Pixel Format
|
||||||
|
#define CMD_FRMCTR1 0xB1//Frame Rate Control (In normal mode/Full colors)
|
||||||
|
#define CMD_FRMCTR2 0xB2//Frame Rate Control(In Idle mode/8-colors)
|
||||||
|
#define CMD_FRMCTR3 0xB3//Frame Rate Control(In Partial mode/full colors)
|
||||||
|
#define CMD_DINVCTR 0xB4//Display Inversion Control
|
||||||
|
#define CMD_RGBBLK 0xB5//RGB Interface Blanking Porch setting
|
||||||
|
#define CMD_DFUNCTR 0xB6//Display Fuction set 5
|
||||||
|
#define CMD_SDRVDIR 0xB7//Source Driver Direction Control
|
||||||
|
#define CMD_GDRVDIR 0xB8//Gate Driver Direction Control
|
||||||
|
|
||||||
|
#define CMD_PWCTR1 0xC0//Power_Control1
|
||||||
|
#define CMD_PWCTR2 0xC1//Power_Control2
|
||||||
|
#define CMD_PWCTR3 0xC2//Power_Control3
|
||||||
|
#define CMD_PWCTR4 0xC3//Power_Control4
|
||||||
|
#define CMD_PWCTR5 0xC4//Power_Control5
|
||||||
|
#define CMD_VCOMCTR1 0xC5//VCOM_Control 1
|
||||||
|
#define CMD_VCOMCTR2 0xC6//VCOM_Control 2
|
||||||
|
#define CMD_VCOMOFFS 0xC7//VCOM Offset Control
|
||||||
|
#define CMD_PGAMMAC 0xE0//Positive Gamma Correction Setting
|
||||||
|
#define CMD_NGAMMAC 0xE1//Negative Gamma Correction Setting
|
||||||
|
#define CMD_GAMRSEL 0xF2//GAM_R_SEL
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
159
_settings/TFT_ILI9163C_settings.h
Normal file
159
_settings/TFT_ILI9163C_settings.h
Normal file
|
|
@ -0,0 +1,159 @@
|
||||||
|
#ifndef _TFT_ILI9163C_USETT_H_
|
||||||
|
#define _TFT_ILI9163C_USETT_H_
|
||||||
|
|
||||||
|
|
||||||
|
//DID YOU HAVE A RED PCB, BLACk PCB or WHAT DISPLAY TYPE????????????
|
||||||
|
// ---> SELECT HERE <----
|
||||||
|
#define __144_RED_PCB__//128x128
|
||||||
|
//#define __144_BLACK_PCB__//128x128
|
||||||
|
//#define __22_RED_PCB__//240x320
|
||||||
|
//---------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__144_RED_PCB__)
|
||||||
|
/*
|
||||||
|
This display:
|
||||||
|
http://www.ebay.com/itm/Replace-Nokia-5110-LCD-1-44-Red-Serial-128X128-SPI-Color-TFT-LCD-Display-Module-/271422122271
|
||||||
|
This particular display has a design error! The controller has 3 pins to configure to constrain
|
||||||
|
the memory and resolution to a fixed dimension (in that case 128x128) but they leaved those pins
|
||||||
|
configured for 128x160 so there was several pixel memory addressing problems.
|
||||||
|
I solved by setup several parameters that dinamically fix the resolution as needed so below
|
||||||
|
the parameters for this diplay. If you have a strain or a correct display (can happen with chinese)
|
||||||
|
you can copy those parameters and create setup for different displays.
|
||||||
|
*/
|
||||||
|
#define _TFTWIDTH 128//the REAL W resolution of the TFT
|
||||||
|
#define _TFTHEIGHT 128//the REAL H resolution of the TFT
|
||||||
|
#define _GRAMWIDTH 128
|
||||||
|
#define _GRAMHEIGH 160//160
|
||||||
|
#define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH//*see note 1
|
||||||
|
#define __COLORSPC 1// 1:GBR - 0:RGB
|
||||||
|
#define __GAMMASET3 //uncomment for another gamma
|
||||||
|
#define __OFFSET 32//*see note 2
|
||||||
|
//Tested!
|
||||||
|
#elif defined (__144_BLACK_PCB__)
|
||||||
|
#define _TFTWIDTH 128//the REAL W resolution of the TFT
|
||||||
|
#define _TFTHEIGHT 128//the REAL H resolution of the TFT
|
||||||
|
#define _GRAMWIDTH 128
|
||||||
|
#define _GRAMHEIGH 128
|
||||||
|
#define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH//*see note 1
|
||||||
|
#define __COLORSPC 1// 1:GBR - 0:RGB
|
||||||
|
#define __GAMMASET1 //uncomment for another gamma
|
||||||
|
#define __OFFSET 0
|
||||||
|
//not tested
|
||||||
|
#elif defined (__22_RED_PCB__)
|
||||||
|
/*
|
||||||
|
Like this one:
|
||||||
|
http://www.ebay.it/itm/2-2-Serial-SPI-TFT-LCD-Display-Module-240x320-Chip-ILI9340C-PCB-Adapter-SD-Card-/281304733556
|
||||||
|
Not tested!
|
||||||
|
*/
|
||||||
|
#define _TFTWIDTH 240//the REAL W resolution of the TFT
|
||||||
|
#define _TFTHEIGHT 320//the REAL H resolution of the TFT
|
||||||
|
#define _GRAMWIDTH 240
|
||||||
|
#define _GRAMHEIGH 320
|
||||||
|
#define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH
|
||||||
|
#define __COLORSPC 1// 1:GBR - 0:RGB
|
||||||
|
#define __GAMMASET1 //uncomment for another gamma
|
||||||
|
#define __OFFSET 0
|
||||||
|
#else
|
||||||
|
#define _TFTWIDTH 128//128
|
||||||
|
#define _TFTHEIGHT 160//160
|
||||||
|
#define _GRAMWIDTH 128
|
||||||
|
#define _GRAMHEIGH 160
|
||||||
|
#define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH
|
||||||
|
#define __COLORSPC 1// 1:GBR - 0:RGB
|
||||||
|
#define __GAMMASET1
|
||||||
|
#define __OFFSET 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GAMMASET1)
|
||||||
|
const uint8_t pGammaSet[15]= {0x36,0x29,0x12,0x22,0x1C,0x15,0x42,0xB7,0x2F,0x13,0x12,0x0A,0x11,0x0B,0x06};
|
||||||
|
const uint8_t nGammaSet[15]= {0x09,0x16,0x2D,0x0D,0x13,0x15,0x40,0x48,0x53,0x0C,0x1D,0x25,0x2E,0x34,0x39};
|
||||||
|
#elif defined(__GAMMASET2)
|
||||||
|
const uint8_t pGammaSet[15]= {0x3F,0x21,0x12,0x22,0x1C,0x15,0x42,0xB7,0x2F,0x13,0x02,0x0A,0x01,0x00,0x00};
|
||||||
|
const uint8_t nGammaSet[15]= {0x09,0x18,0x2D,0x0D,0x13,0x15,0x40,0x48,0x53,0x0C,0x1D,0x25,0x2E,0x24,0x29};
|
||||||
|
#elif defined(__GAMMASET3)
|
||||||
|
const uint8_t pGammaSet[15]= {0x3F,0x26,0x23,0x30,0x28,0x10,0x55,0xB7,0x40,0x19,0x10,0x1E,0x02,0x01,0x00};
|
||||||
|
const uint8_t nGammaSet[15]= {0x09,0x18,0x2D,0x0D,0x13,0x15,0x40,0x48,0x53,0x0C,0x1D,0x25,0x2E,0x24,0x29};
|
||||||
|
#else
|
||||||
|
const uint8_t pGammaSet[15]= {0x3F,0x25,0x1C,0x1E,0x20,0x12,0x2A,0x90,0x24,0x11,0x00,0x00,0x00,0x00,0x00};
|
||||||
|
const uint8_t nGammaSet[15]= {0x20,0x20,0x20,0x20,0x05,0x15,0x00,0xA7,0x3D,0x18,0x25,0x2A,0x2B,0x2B,0x3A};
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
Note 1: The __144_RED_PCB__ display has hardware addressing of 128 x 160
|
||||||
|
but the tft resolution it's 128 x 128 so the dram should be set correctly
|
||||||
|
|
||||||
|
Note 2: This is the offset between image in RAM and TFT. In that case 160 - 128 = 32;
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
Benchmark Time (microseconds)
|
||||||
|
Screen fill 74697
|
||||||
|
Text 4841
|
||||||
|
Lines 16025
|
||||||
|
Horiz/Vert Lines 5028
|
||||||
|
Rectangles (outline) 4181
|
||||||
|
Rectangles (filled) 91225
|
||||||
|
Circles (filled) 14452
|
||||||
|
Circles (outline) 16397
|
||||||
|
Triangles (outline) 5069
|
||||||
|
Triangles (filled) 30715
|
||||||
|
Rounded rects (outline) 10382
|
||||||
|
Rounded rects (filled) 99552
|
||||||
|
Done!
|
||||||
|
|
||||||
|
Benchmark Time (microseconds)
|
||||||
|
Screen fill 74697
|
||||||
|
Text 4453
|
||||||
|
Text2 16541
|
||||||
|
Lines 16027
|
||||||
|
Horiz/Vert Lines 5029
|
||||||
|
Rectangles (outline) 4185
|
||||||
|
Rectangles (filled) 91223
|
||||||
|
Circles (filled) 14408
|
||||||
|
Circles (outline) 15082
|
||||||
|
Triangles (outline) 5067
|
||||||
|
Triangles (filled) 17439
|
||||||
|
Rounded rects (outline) 10023
|
||||||
|
Rounded rects (filled) 99513
|
||||||
|
Done!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Benchmark Time (microseconds)
|
||||||
|
Screen fill 277415
|
||||||
|
Text 11618
|
||||||
|
Text2 36043
|
||||||
|
Lines 58163
|
||||||
|
Horiz/Vert Lines 18655
|
||||||
|
Rectangles (outline) 15391
|
||||||
|
Rectangles (filled) 338450
|
||||||
|
Circles (filled) 53050
|
||||||
|
Circles (outline) 39227
|
||||||
|
Triangles (outline) 18302
|
||||||
|
Triangles (filled) 64198
|
||||||
|
Rounded rects (outline) 29676
|
||||||
|
Rounded rects (filled) 368960
|
||||||
|
Done!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Benchmark Time (microseconds)
|
||||||
|
Screen fill 277422
|
||||||
|
Text 13066
|
||||||
|
Lines 58240
|
||||||
|
Horiz/Vert Lines 18655
|
||||||
|
Rectangles (outline) 15422
|
||||||
|
Rectangles (filled) 339230
|
||||||
|
Circles (filled) 53049
|
||||||
|
Circles (outline) 43195
|
||||||
|
Triangles (outline) 18350
|
||||||
|
Triangles (filled) 113536
|
||||||
|
Rounded rects (outline) 31470
|
||||||
|
Rounded rects (filled) 369703
|
||||||
|
Done!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#define GREEN 0x07E0
|
#define GREEN 0x07E0
|
||||||
#define CYAN 0x07FF
|
#define CYAN 0x07FF
|
||||||
#define MAGENTA 0xF81F
|
#define MAGENTA 0xF81F
|
||||||
#define YELLOW 0xFFE0
|
#define YELLOW 0xFFE0
|
||||||
#define WHITE 0xFFFF
|
#define WHITE 0xFFFF
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -33,15 +33,17 @@ You are using 4 wire SPI here, so:
|
||||||
Teensy 3.x can use: 2,6,9,10,15,20,21,22,23
|
Teensy 3.x can use: 2,6,9,10,15,20,21,22,23
|
||||||
Arduino's 8 bit: any
|
Arduino's 8 bit: any
|
||||||
DUE: check arduino site
|
DUE: check arduino site
|
||||||
If you do not use reset, tie it to +3V3
|
IMPORTANT!!!
|
||||||
|
If you do not use reset pin, tie it to +3V3!! Do not leave floating!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC);
|
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(38400);
|
||||||
//while (!Serial);
|
long unsigned debug_start = millis ();
|
||||||
|
while (!Serial && ((millis () - debug_start) <= 5000)) ;
|
||||||
tft.begin();
|
tft.begin();
|
||||||
|
|
||||||
Serial.println(F("Benchmark Time (microseconds)"));
|
Serial.println(F("Benchmark Time (microseconds)"));
|
||||||
|
|
@ -52,6 +54,10 @@ void setup() {
|
||||||
Serial.print(F("Text "));
|
Serial.print(F("Text "));
|
||||||
Serial.println(testText());
|
Serial.println(testText());
|
||||||
delay(3000);
|
delay(3000);
|
||||||
|
|
||||||
|
Serial.print(F("Text2 "));
|
||||||
|
Serial.println(testText2());
|
||||||
|
delay(3000);
|
||||||
|
|
||||||
Serial.print(F("Lines "));
|
Serial.print(F("Lines "));
|
||||||
Serial.println(testLines(CYAN));
|
Serial.println(testLines(CYAN));
|
||||||
|
|
@ -66,14 +72,14 @@ void setup() {
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Rectangles (filled) "));
|
Serial.print(F("Rectangles (filled) "));
|
||||||
Serial.println(testFilledRects(YELLOW,MAGENTA));
|
Serial.println(testFilledRects(YELLOW, MAGENTA));
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Circles (filled) "));
|
Serial.print(F("Circles (filled) "));
|
||||||
Serial.println(testFilledCircles(10,MAGENTA));
|
Serial.println(testFilledCircles(10, MAGENTA));
|
||||||
|
|
||||||
Serial.print(F("Circles (outline) "));
|
Serial.print(F("Circles (outline) "));
|
||||||
Serial.println(testCircles(10,WHITE));
|
Serial.println(testCircles(10, WHITE));
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Triangles (outline) "));
|
Serial.print(F("Triangles (outline) "));
|
||||||
|
|
@ -96,7 +102,7 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(void) {
|
void loop(void) {
|
||||||
for(uint8_t rotation=0; rotation<4; rotation++) {
|
for (uint8_t rotation = 0; rotation < 4; rotation++) {
|
||||||
tft.setRotation(rotation);
|
tft.setRotation(rotation);
|
||||||
testText();
|
testText();
|
||||||
delay(2000);
|
delay(2000);
|
||||||
|
|
@ -118,19 +124,29 @@ unsigned long testText() {
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
unsigned long start = micros();
|
unsigned long start = micros();
|
||||||
tft.setCursor(0, 0);
|
tft.setCursor(0, 0);
|
||||||
tft.setTextColor(WHITE);
|
tft.setTextColor(WHITE);
|
||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
tft.println("Hello World!");
|
tft.println("Hello World!");
|
||||||
tft.setTextColor(YELLOW);
|
tft.setTextColor(YELLOW);
|
||||||
tft.setTextSize(2);
|
tft.setTextSize(2);
|
||||||
tft.println(1234.56);
|
tft.println(1234.56);
|
||||||
tft.setTextColor(RED);
|
tft.setTextColor(RED);
|
||||||
tft.setTextSize(3);
|
tft.setTextSize(3);
|
||||||
tft.println(0xDEAD, HEX);
|
tft.println(0xDEAD, HEX);
|
||||||
tft.println();
|
tft.println();
|
||||||
tft.setTextColor(GREEN);
|
tft.setTextColor(GREEN);
|
||||||
tft.setTextSize(4);
|
tft.setTextSize(4);
|
||||||
tft.println("Hello");
|
tft.println("Hello");
|
||||||
|
return micros() - start;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long testText2() {
|
||||||
|
tft.fillScreen();
|
||||||
|
unsigned long start = micros();
|
||||||
|
tft.setCursor(0, 0);
|
||||||
|
tft.setTextColor(WHITE);
|
||||||
tft.setTextSize(2);
|
tft.setTextSize(2);
|
||||||
tft.println("I implore thee,");
|
tft.println("I implore thee,");
|
||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
|
|
@ -147,17 +163,17 @@ unsigned long testText() {
|
||||||
unsigned long testLines(uint16_t color) {
|
unsigned long testLines(uint16_t color) {
|
||||||
unsigned long start, t;
|
unsigned long start, t;
|
||||||
int x1, y1, x2, y2,
|
int x1, y1, x2, y2,
|
||||||
w = tft.width(),
|
w = tft.width(),
|
||||||
h = tft.height();
|
h = tft.height();
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
|
|
||||||
x1 = y1 = 0;
|
x1 = y1 = 0;
|
||||||
y2 = h - 1;
|
y2 = h - 1;
|
||||||
start = micros();
|
start = micros();
|
||||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
|
||||||
x2 = w - 1;
|
x2 = w - 1;
|
||||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
|
||||||
t = micros() - start; // fillScreen doesn't count against timing
|
t = micros() - start; // fillScreen doesn't count against timing
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
|
|
@ -166,9 +182,9 @@ unsigned long testLines(uint16_t color) {
|
||||||
y1 = 0;
|
y1 = 0;
|
||||||
y2 = h - 1;
|
y2 = h - 1;
|
||||||
start = micros();
|
start = micros();
|
||||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
|
||||||
x2 = 0;
|
x2 = 0;
|
||||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
|
||||||
t += micros() - start;
|
t += micros() - start;
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
|
|
@ -177,9 +193,9 @@ unsigned long testLines(uint16_t color) {
|
||||||
y1 = h - 1;
|
y1 = h - 1;
|
||||||
y2 = 0;
|
y2 = 0;
|
||||||
start = micros();
|
start = micros();
|
||||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
|
||||||
x2 = w - 1;
|
x2 = w - 1;
|
||||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
|
||||||
t += micros() - start;
|
t += micros() - start;
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
|
|
@ -188,9 +204,9 @@ unsigned long testLines(uint16_t color) {
|
||||||
y1 = h - 1;
|
y1 = h - 1;
|
||||||
y2 = 0;
|
y2 = 0;
|
||||||
start = micros();
|
start = micros();
|
||||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
|
||||||
x2 = 0;
|
x2 = 0;
|
||||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
|
||||||
|
|
||||||
return micros() - start;
|
return micros() - start;
|
||||||
}
|
}
|
||||||
|
|
@ -201,8 +217,8 @@ unsigned long testFastLines(uint16_t color1, uint16_t color2) {
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
start = micros();
|
start = micros();
|
||||||
for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
|
for (y = 0; y < h; y += 5) tft.drawFastHLine(0, y, w, color1);
|
||||||
for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);
|
for (x = 0; x < w; x += 5) tft.drawFastVLine(x, 0, h, color2);
|
||||||
|
|
||||||
return micros() - start;
|
return micros() - start;
|
||||||
}
|
}
|
||||||
|
|
@ -210,15 +226,15 @@ unsigned long testFastLines(uint16_t color1, uint16_t color2) {
|
||||||
unsigned long testRects(uint16_t color) {
|
unsigned long testRects(uint16_t color) {
|
||||||
unsigned long start;
|
unsigned long start;
|
||||||
int n, i, i2,
|
int n, i, i2,
|
||||||
cx = tft.width() / 2,
|
cx = tft.width() / 2,
|
||||||
cy = tft.height() / 2;
|
cy = tft.height() / 2;
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
n = min(tft.width(), tft.height());
|
n = min(tft.width(), tft.height());
|
||||||
start = micros();
|
start = micros();
|
||||||
for(i=2; i<n; i+=6) {
|
for (i = 2; i < n; i += 6) {
|
||||||
i2 = i / 2;
|
i2 = i / 2;
|
||||||
tft.drawRect(cx-i2, cy-i2, i, i, color);
|
tft.drawRect(cx - i2, cy - i2, i, i, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
return micros() - start;
|
return micros() - start;
|
||||||
|
|
@ -227,18 +243,18 @@ unsigned long testRects(uint16_t color) {
|
||||||
unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
|
unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
|
||||||
unsigned long start, t = 0;
|
unsigned long start, t = 0;
|
||||||
int n, i, i2,
|
int n, i, i2,
|
||||||
cx = (tft.width() / 2) - 1,
|
cx = (tft.width() / 2) - 1,
|
||||||
cy = (tft.height() / 2) - 1;
|
cy = (tft.height() / 2) - 1;
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
n = min(tft.width(), tft.height());
|
n = min(tft.width(), tft.height());
|
||||||
for(i=n; i>0; i-=6) {
|
for (i = n; i > 0; i -= 6) {
|
||||||
i2 = i / 2;
|
i2 = i / 2;
|
||||||
start = micros();
|
start = micros();
|
||||||
tft.fillRect(cx-i2, cy-i2, i, i, color1);
|
tft.fillRect(cx - i2, cy - i2, i, i, color1);
|
||||||
t += micros() - start;
|
t += micros() - start;
|
||||||
// Outlines are not included in timing results
|
// Outlines are not included in timing results
|
||||||
tft.drawRect(cx-i2, cy-i2, i, i, color2);
|
tft.drawRect(cx - i2, cy - i2, i, i, color2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
|
@ -250,8 +266,8 @@ unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
start = micros();
|
start = micros();
|
||||||
for(x=radius; x<w; x+=r2) {
|
for (x = radius; x < w; x += r2) {
|
||||||
for(y=radius; y<h; y+=r2) {
|
for (y = radius; y < h; y += r2) {
|
||||||
tft.fillCircle(x, y, radius, color);
|
tft.fillCircle(x, y, radius, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -262,14 +278,14 @@ unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
|
||||||
unsigned long testCircles(uint8_t radius, uint16_t color) {
|
unsigned long testCircles(uint8_t radius, uint16_t color) {
|
||||||
unsigned long start;
|
unsigned long start;
|
||||||
int x, y, r2 = radius * 2,
|
int x, y, r2 = radius * 2,
|
||||||
w = tft.width() + radius,
|
w = tft.width() + radius,
|
||||||
h = tft.height() + radius;
|
h = tft.height() + radius;
|
||||||
|
|
||||||
// Screen is not cleared for this one -- this is
|
// Screen is not cleared for this one -- this is
|
||||||
// intentional and does not affect the reported time.
|
// intentional and does not affect the reported time.
|
||||||
start = micros();
|
start = micros();
|
||||||
for(x=0; x<w; x+=r2) {
|
for (x = 0; x < w; x += r2) {
|
||||||
for(y=0; y<h; y+=r2) {
|
for (y = 0; y < h; y += r2) {
|
||||||
tft.drawCircle(x, y, radius, color);
|
tft.drawCircle(x, y, radius, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -280,17 +296,17 @@ unsigned long testCircles(uint8_t radius, uint16_t color) {
|
||||||
unsigned long testTriangles() {
|
unsigned long testTriangles() {
|
||||||
unsigned long start;
|
unsigned long start;
|
||||||
int n, i, cx = tft.width() / 2 - 1,
|
int n, i, cx = tft.width() / 2 - 1,
|
||||||
cy = (tft.height() / 2) - 1;
|
cy = (tft.height() / 2) - 1;
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
n = min(cx, cy);
|
n = min(cx, cy);
|
||||||
start = micros();
|
start = micros();
|
||||||
for(i=0; i<n; i+=5) {
|
for (i = 0; i < n; i += 5) {
|
||||||
tft.drawTriangle(
|
tft.drawTriangle(
|
||||||
cx , cy - i, // peak
|
cx , cy - i, // peak
|
||||||
cx - i, cy + i, // bottom left
|
cx - i, cy + i, // bottom left
|
||||||
cx + i, cy + i, // bottom right
|
cx + i, cy + i, // bottom right
|
||||||
tft.Color565(0, 0, i));
|
tft.Color565(0, 0, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return micros() - start;
|
return micros() - start;
|
||||||
|
|
@ -299,17 +315,17 @@ unsigned long testTriangles() {
|
||||||
unsigned long testFilledTriangles() {
|
unsigned long testFilledTriangles() {
|
||||||
unsigned long start, t = 0;
|
unsigned long start, t = 0;
|
||||||
int i, cx = (tft.width() / 2) - 1,
|
int i, cx = (tft.width() / 2) - 1,
|
||||||
cy = tft.height() / 2 - 1;
|
cy = tft.height() / 2 - 1;
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
start = micros();
|
start = micros();
|
||||||
for(i=min(cx,cy); i>10; i-=5) {
|
for (i = min(cx, cy); i > 10; i -= 5) {
|
||||||
start = micros();
|
start = micros();
|
||||||
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||||
tft.Color565(0, i, i));
|
tft.Color565(0, i, i));
|
||||||
t += micros() - start;
|
t += micros() - start;
|
||||||
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||||
tft.Color565(i, i, 0));
|
tft.Color565(i, i, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
|
@ -318,15 +334,15 @@ unsigned long testFilledTriangles() {
|
||||||
unsigned long testRoundRects() {
|
unsigned long testRoundRects() {
|
||||||
unsigned long start;
|
unsigned long start;
|
||||||
int w, i, i2,
|
int w, i, i2,
|
||||||
cx = (tft.width() / 2) - 1,
|
cx = (tft.width() / 2) - 1,
|
||||||
cy = (tft.height() / 2) - 1;
|
cy = (tft.height() / 2) - 1;
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
w = min(tft.width(), tft.height());
|
w = min(tft.width(), tft.height());
|
||||||
start = micros();
|
start = micros();
|
||||||
for(i=0; i<w; i+=6) {
|
for (i = 0; i < w; i += 6) {
|
||||||
i2 = i / 2;
|
i2 = i / 2;
|
||||||
tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.Color565(i, 0, 0));
|
tft.drawRoundRect(cx - i2, cy - i2, i, i, i / 8, tft.Color565(i, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return micros() - start;
|
return micros() - start;
|
||||||
|
|
@ -335,14 +351,14 @@ unsigned long testRoundRects() {
|
||||||
unsigned long testFilledRoundRects() {
|
unsigned long testFilledRoundRects() {
|
||||||
unsigned long start;
|
unsigned long start;
|
||||||
int i, i2,
|
int i, i2,
|
||||||
cx = (tft.width() / 2) - 1,
|
cx = (tft.width() / 2) - 1,
|
||||||
cy = (tft.height() / 2) - 1;
|
cy = (tft.height() / 2) - 1;
|
||||||
|
|
||||||
tft.fillScreen();
|
tft.fillScreen();
|
||||||
start = micros();
|
start = micros();
|
||||||
for(i=min(tft.width(), tft.height()); i>20; i-=6) {
|
for (i = min(tft.width(), tft.height()); i > 20; i -= 6) {
|
||||||
i2 = i / 2;
|
i2 = i / 2;
|
||||||
tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.Color565(0, i, 0));
|
tft.fillRoundRect(cx - i2, cy - i2, i, i, i / 8, tft.Color565(0, i, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return micros() - start;
|
return micros() - start;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
name=TFT_ILI9163C
|
name=TFT_ILI9163C
|
||||||
version=0.8
|
version=0.9
|
||||||
author=Max MC Costa
|
author=Max MC Costa
|
||||||
maintainer=sumotoy <sumotoy@gmail.com>
|
maintainer=sumotoy <sumotoy@gmail.com>
|
||||||
sentence=A fast SPI driver for TFT drived by ILI9163C, fully SPI Transaction compatible and very fast with Teensy 3
|
sentence=A fast SPI driver for TFT drived by ILI9163C, fully SPI Transaction compatible and very fast with Teensy 3
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue