daily_automated
This commit is contained in:
@@ -0,0 +1,348 @@
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <TFT_ILI9163C.h>
|
||||
|
||||
/*
|
||||
Note for Teensy 3.x !!!!!!!!!!!!!!!!!!!
|
||||
You should choose from those pins for CS and RS:
|
||||
2,6,9,10,15,20,23
|
||||
*/
|
||||
#define __CS 10
|
||||
#define __DC 9
|
||||
#define __RST 14
|
||||
|
||||
|
||||
|
||||
// Color definitions
|
||||
#define BLACK 0x0000
|
||||
#define BLUE 0x001F
|
||||
#define RED 0xF800
|
||||
#define GREEN 0x07E0
|
||||
#define CYAN 0x07FF
|
||||
#define MAGENTA 0xF81F
|
||||
#define YELLOW 0xFFE0
|
||||
#define WHITE 0xFFFF
|
||||
#define TRANSPARENT -1
|
||||
|
||||
|
||||
TFT_ILI9163C display = TFT_ILI9163C(__CS, __DC, __RST);
|
||||
|
||||
float p = 3.1415926;
|
||||
|
||||
void setup(void) {
|
||||
display.begin();
|
||||
display.setBitrate(24000000);
|
||||
|
||||
uint16_t time = millis();
|
||||
time = millis() - time;
|
||||
|
||||
// lcdTestPattern();
|
||||
// delay(1000);
|
||||
|
||||
display.clearScreen();
|
||||
display.setCursor(0,0);
|
||||
display.print("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa");
|
||||
delay(1000);
|
||||
|
||||
tftPrintTest();
|
||||
delay(2000);
|
||||
|
||||
//a single pixel
|
||||
display.drawPixel(display.width()/2, display.height()/2, GREEN);
|
||||
delay(500);
|
||||
|
||||
// line draw test
|
||||
testlines(YELLOW);
|
||||
delay(500);
|
||||
|
||||
// optimized lines
|
||||
testfastlines(RED, BLUE);
|
||||
delay(500);
|
||||
|
||||
testdrawrects(GREEN);
|
||||
delay(1000);
|
||||
|
||||
testfillrects(BLUE, YELLOW);
|
||||
delay(1000);
|
||||
|
||||
randomRect(0);
|
||||
delay(100);
|
||||
randomCircles(0);
|
||||
delay(100);
|
||||
randomLines();
|
||||
delay(100);
|
||||
randomPoints();
|
||||
delay(500);
|
||||
|
||||
display.clearScreen();
|
||||
testfillcircles(10, BLUE);
|
||||
testdrawcircles(10, WHITE);
|
||||
delay(1000);
|
||||
|
||||
testroundrects();
|
||||
delay(500);
|
||||
|
||||
testtriangles();
|
||||
delay(500);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
testlines(random(0x0010,0xFFFF));
|
||||
randomLines();
|
||||
//randomCircles(1);
|
||||
randomCircles(0);
|
||||
randomRect(1);
|
||||
randomRect(1);
|
||||
randomRect(1);
|
||||
randomRect(1);
|
||||
randomRect(1);
|
||||
randomRect(0);
|
||||
randomRect(0);
|
||||
randomRect(0);
|
||||
randomRect(0);
|
||||
randomRect(0);
|
||||
randomRect(0);
|
||||
randomPoints();
|
||||
}
|
||||
|
||||
void testlines(uint16_t color) {
|
||||
display.clearScreen();
|
||||
for (int16_t x=0; x < display.width()-1; x+=6) {
|
||||
display.drawLine(0, 0, x, display.height()-1, color);
|
||||
}
|
||||
for (int16_t y=0; y < display.height()-1; y+=6) {
|
||||
display.drawLine(0, 0, display.width()-1, y, color);
|
||||
}
|
||||
display.clearScreen();
|
||||
for (int16_t x=0; x < display.width()-1; x+=6) {
|
||||
display.drawLine(display.width()-1, 0, x, display.height()-1, color);
|
||||
}
|
||||
for (int16_t y=0; y < display.height()-1; y+=6) {
|
||||
display.drawLine(display.width()-1, 0, 0, y, color);
|
||||
}
|
||||
|
||||
display.clearScreen();
|
||||
for (int16_t x=0; x < display.width()-1; x+=6) {
|
||||
display.drawLine(0, display.height()-1, x, 0, color);
|
||||
}
|
||||
for (int16_t y=0; y < display.height()-1; y+=6) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, y, color);
|
||||
}
|
||||
display.clearScreen();
|
||||
for (int16_t x=0; x < display.width()-1; x+=6) {
|
||||
display.drawLine(display.width()-1, display.height()-1, x, 0, color);
|
||||
}
|
||||
for (int16_t y=0; y < display.height()-1; y+=6) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, y, color);
|
||||
}
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
||||
void testdrawtext(char *text, uint16_t color) {
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
|
||||
for (uint8_t i=0; i < 168; i++) {
|
||||
if (i == '\n') continue;
|
||||
display.write(i);
|
||||
if ((i > 0) && (i % 21 == 0))
|
||||
display.println();
|
||||
}
|
||||
}
|
||||
|
||||
void testfastlines(uint16_t color1, uint16_t color2) {
|
||||
display.clearScreen();
|
||||
for (int16_t y=0; y < display.height()-1; y+=5) {
|
||||
display.drawFastHLine(0, y, display.width()-1, color1);
|
||||
}
|
||||
for (int16_t x=0; x < display.width()-1; x+=5) {
|
||||
display.drawFastVLine(x, 0, display.height()-1, color2);
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawrects(uint16_t color) {
|
||||
display.clearScreen();
|
||||
for (int16_t x=0; x < display.height()-1; x+=6) {
|
||||
display.drawRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color);
|
||||
}
|
||||
}
|
||||
|
||||
void testfillrects(uint16_t color1, uint16_t color2) {
|
||||
display.clearScreen();
|
||||
for (int16_t x=display.height()-1; x > 6; x-=6) {
|
||||
display.fillRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color1);
|
||||
display.drawRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color2);
|
||||
}
|
||||
}
|
||||
|
||||
void testfillcircles(uint8_t radius, uint16_t color) {
|
||||
for (uint8_t x=radius; x < display.width()-1; x+=radius*2) {
|
||||
for (uint8_t y=radius; y < display.height()-1; y+=radius*2) {
|
||||
display.fillCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawcircles(uint8_t radius, uint16_t color) {
|
||||
for (int16_t x=0; x < (display.width()-1)+radius; x+=radius*2) {
|
||||
for (int16_t y=0; y < (display.height())-1+radius; y+=radius*2) {
|
||||
display.drawCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void testtriangles() {
|
||||
display.clearScreen();
|
||||
int color = 0xF800;
|
||||
int t;
|
||||
int w = display.width()/2;
|
||||
int x = display.height();
|
||||
int y = 0;
|
||||
int z = display.width();
|
||||
for(t = 0 ; t <= 15; t+=1) {
|
||||
display.drawTriangle(w, y, y, x, z, x, color);
|
||||
x-=4;
|
||||
y+=4;
|
||||
z-=4;
|
||||
color+=100;
|
||||
}
|
||||
}
|
||||
|
||||
void testroundrects() {
|
||||
display.clearScreen();
|
||||
int color = 100;
|
||||
int i;
|
||||
int t;
|
||||
for(t = 0 ; t <= 4; t+=1) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int w = display.width();
|
||||
int h = display.height();
|
||||
for(i = 0 ; i <= 24; i+=1) {
|
||||
display.drawRoundRect(x, y, w, h, 5, color);
|
||||
x+=2;
|
||||
y+=3;
|
||||
w-=4;
|
||||
h-=6;
|
||||
color+=1100;
|
||||
}
|
||||
color+=100;
|
||||
}
|
||||
}
|
||||
|
||||
void tftPrintTest() {
|
||||
display.clearScreen();
|
||||
display.setCursor(0, 5);
|
||||
display.setTextColor(RED);
|
||||
display.setTextSize(1);
|
||||
display.println("Hello World!");
|
||||
display.setTextColor(YELLOW, GREEN);
|
||||
display.setTextSize(2);
|
||||
display.print("Hello Wo");
|
||||
display.setTextColor(BLUE);
|
||||
display.setTextSize(3);
|
||||
display.print(12.57);
|
||||
delay(1500);
|
||||
display.setCursor(0, 5);
|
||||
display.clearScreen();
|
||||
display.setTextColor(WHITE);
|
||||
display.setTextSize(0);
|
||||
display.println("Hello World!");
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(GREEN);
|
||||
display.print(p, 5);
|
||||
display.println(" Want pi?");
|
||||
display.print(8675309, HEX);
|
||||
display.print(" Print HEX");
|
||||
display.setTextColor(WHITE);
|
||||
display.println("Sketch has been");
|
||||
display.println("running for: ");
|
||||
display.setTextColor(MAGENTA);
|
||||
display.print(millis() / 1000);
|
||||
display.setTextColor(WHITE);
|
||||
display.print(" sec.");
|
||||
}
|
||||
|
||||
|
||||
void randomRect(bool fill){
|
||||
display.clearScreen();
|
||||
uint8_t k,c;
|
||||
for (k = 0; k < 16; k++) {
|
||||
for (c = 0; c < 32; c++) {
|
||||
uint8_t cx, cy, x, y, w, h;
|
||||
// center
|
||||
cx = random(0,display.width());
|
||||
cy = random(0,display.height());
|
||||
// size
|
||||
w = random(0,30 + 6);
|
||||
h = random(0,20 + 4);
|
||||
// upper-left
|
||||
x = cx - w / 2;
|
||||
y = cy - h / 2;
|
||||
if (x < 0) x = 0;
|
||||
if (y < 0) y = 0;
|
||||
// adjust size
|
||||
if (x + w > display.width()) w = display.width() - x;
|
||||
if (y + h > display.height()) h = display.height() - y;
|
||||
if (fill){
|
||||
display.fillRect(x, y, w, h,random(0x0010,0xFFFF));
|
||||
}
|
||||
else {
|
||||
display.drawRect(x, y, w, h,random(0x0010,0xFFFF));
|
||||
}
|
||||
|
||||
}
|
||||
display.clearScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void randomCircles(bool fill){
|
||||
display.clearScreen();
|
||||
uint8_t k,c;
|
||||
for (k = 0; k < display.height(); k++) {
|
||||
for (c = 0; c < display.height()/2; c++) {
|
||||
// coordinates
|
||||
uint8_t x = random(0,120 + 3), y = random(0,90 + 2), r = random(0,40 + 1);
|
||||
if (x - r < 0) r = x;
|
||||
if (x + r > (display.width()-1)) r = (display.width() - 1) - x;
|
||||
if (y - r < 0) r = y;
|
||||
if (y + r > (display.height()-1)) r = (display.height() - 1) - y;
|
||||
if (fill){
|
||||
display.fillCircle(x, y, r,random(0x0010,0xFFFF));
|
||||
}
|
||||
else {
|
||||
display.drawCircle(x, y, r,random(0x0010,0xFFFF));
|
||||
}
|
||||
}
|
||||
if (!fill)display.clearScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void randomLines(){
|
||||
display.clearScreen();
|
||||
uint8_t k,c;
|
||||
for (k = 0; k < display.height(); k++) {
|
||||
for (c = 0; c < display.height()/2; c++) {
|
||||
uint8_t x1 = random(0,display.width()), y1 = random(0,display.height()), x2 = random(0,display.width()), y2 = random(0,display.height());
|
||||
display.drawLine(x1, y1, x2, y2,random(0x0010,0xFFFF));
|
||||
}
|
||||
display.clearScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void randomPoints(){
|
||||
display.clearScreen();
|
||||
int k,c;
|
||||
for (k = 0; k < 128; k++) {
|
||||
for (c = 0; c < 1000; c++) {
|
||||
uint8_t x = random(0,display.width()), y = random(0,display.height());
|
||||
display.drawPixel(x, y,random(0x0010,0xFFFF));
|
||||
}
|
||||
display.clearScreen();
|
||||
}
|
||||
}
|
||||
88
trunk/Arduino/libraries/TFT_ILI9163C/examples/cube/cube.ino
Normal file
88
trunk/Arduino/libraries/TFT_ILI9163C/examples/cube/cube.ino
Normal file
@@ -0,0 +1,88 @@
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <TFT_ILI9163C.h>
|
||||
|
||||
#define __CS 10
|
||||
#define __DC 9
|
||||
#define __RST 14
|
||||
|
||||
// Color definitions
|
||||
#define BLACK 0x0000
|
||||
#define BLUE 0x001F
|
||||
#define RED 0xF800
|
||||
#define GREEN 0x07E0
|
||||
#define CYAN 0x07FF
|
||||
#define MAGENTA 0xF81F
|
||||
#define YELLOW 0xFFE0
|
||||
#define WHITE 0xFFFF
|
||||
|
||||
float sin_d[] = {
|
||||
0,0.17,0.34,0.5,0.64,0.77,0.87,0.94,0.98,1,0.98,0.94,
|
||||
0.87,0.77,0.64,0.5,0.34,0.17,0,-0.17,-0.34,-0.5,-0.64,
|
||||
-0.77,-0.87,-0.94,-0.98,-1,-0.98,-0.94,-0.87,-0.77,
|
||||
-0.64,-0.5,-0.34,-0.17 };
|
||||
float cos_d[] = {
|
||||
1,0.98,0.94,0.87,0.77,0.64,0.5,0.34,0.17,0,-0.17,-0.34,
|
||||
-0.5,-0.64,-0.77,-0.87,-0.94,-0.98,-1,-0.98,-0.94,-0.87,
|
||||
-0.77,-0.64,-0.5,-0.34,-0.17,0,0.17,0.34,0.5,0.64,0.77,
|
||||
0.87,0.94,0.98};
|
||||
float d = 10;
|
||||
float px[] = {
|
||||
-d, d, d, -d, -d, d, d, -d };
|
||||
float py[] = {
|
||||
-d, -d, d, d, -d, -d, d, d };
|
||||
float pz[] = {
|
||||
-d, -d, -d, -d, d, d, d, d };
|
||||
|
||||
float p2x[] = {
|
||||
0,0,0,0,0,0,0,0};
|
||||
float p2y[] = {
|
||||
0,0,0,0,0,0,0,0};
|
||||
|
||||
int r[] = {
|
||||
0,0,0};
|
||||
|
||||
|
||||
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST);
|
||||
|
||||
void setup() {
|
||||
tft.begin();
|
||||
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||
tft.setBitrate(24000000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop(){
|
||||
tft.fillScreen(WHITE);
|
||||
r[0]=r[0]+1;
|
||||
r[1]=r[1]+1;
|
||||
if (r[0] == 36) r[0] = 0;
|
||||
if (r[1] == 36) r[1] = 0;
|
||||
if (r[2] == 36) r[2] = 0;
|
||||
for (int i=0;i<8;i++)
|
||||
{
|
||||
float px2 = px[i];
|
||||
float py2 = cos_d[r[0]]*py[i] - sin_d[r[0]]*pz[i];
|
||||
float pz2 = sin_d[r[0]]*py[i] + cos_d[r[0]]*pz[i];
|
||||
|
||||
float px3 = cos_d[r[1]]*px2 + sin_d[r[1]]*pz2;
|
||||
float py3 = py2;
|
||||
float pz3 = -sin_d[r[1]]*px2 + cos_d[r[1]]*pz2;
|
||||
|
||||
float ax = cos_d[r[2]]*px3 - sin_d[r[2]]*py3;
|
||||
float ay = sin_d[r[2]]*px3 + cos_d[r[2]]*py3;
|
||||
float az = pz3-190;
|
||||
|
||||
p2x[i] = ((tft.width())/2)+ax*500/az;
|
||||
p2y[i] = ((tft.height())/2)+ay*500/az;
|
||||
}
|
||||
for (int i=0;i<3;i++) {
|
||||
tft.drawLine(p2x[i],p2y[i],p2x[i+1],p2y[i+1],BLACK);
|
||||
tft.drawLine(p2x[i+4],p2y[i+4],p2x[i+5],p2y[i+5],BLACK);
|
||||
tft.drawLine(p2x[i],p2y[i],p2x[i+4],p2y[i+4],BLACK);
|
||||
}
|
||||
tft.drawLine(p2x[3],p2y[3],p2x[0],p2y[0],BLACK);
|
||||
tft.drawLine(p2x[7],p2y[7],p2x[4],p2y[4],BLACK);
|
||||
tft.drawLine(p2x[3],p2y[3],p2x[7],p2y[7],BLACK);
|
||||
delay(15);
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <TFT_ILI9163C.h>
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
#undef __FlashStringHelper::F(string_literal)
|
||||
#define F(string_literal) string_literal
|
||||
#endif
|
||||
|
||||
#define __CS 10
|
||||
#define __DC 9
|
||||
#define __RST 14
|
||||
|
||||
// Color definitions
|
||||
#define BLACK 0x0000
|
||||
#define BLUE 0x001F
|
||||
#define RED 0xF800
|
||||
#define GREEN 0x07E0
|
||||
#define CYAN 0x07FF
|
||||
#define MAGENTA 0xF81F
|
||||
#define YELLOW 0xFFE0
|
||||
#define WHITE 0xFFFF
|
||||
|
||||
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
//while (!Serial);
|
||||
tft.begin();
|
||||
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||
tft.setBitrate(24000000);
|
||||
#endif
|
||||
|
||||
Serial.println(F("Benchmark Time (microseconds)"));
|
||||
Serial.print(F("Screen fill "));
|
||||
Serial.println(testFillScreen());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Text "));
|
||||
Serial.println(testText());
|
||||
delay(3000);
|
||||
|
||||
Serial.print(F("Lines "));
|
||||
Serial.println(testLines(CYAN));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Horiz/Vert Lines "));
|
||||
Serial.println(testFastLines(RED, BLUE));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rectangles (outline) "));
|
||||
Serial.println(testRects(GREEN));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rectangles (filled) "));
|
||||
Serial.println(testFilledRects(YELLOW,MAGENTA));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Circles (filled) "));
|
||||
Serial.println(testFilledCircles(10,MAGENTA));
|
||||
|
||||
Serial.print(F("Circles (outline) "));
|
||||
Serial.println(testCircles(10,WHITE));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Triangles (outline) "));
|
||||
Serial.println(testTriangles());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Triangles (filled) "));
|
||||
Serial.println(testFilledTriangles());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rounded rects (outline) "));
|
||||
Serial.println(testRoundRects());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rounded rects (filled) "));
|
||||
Serial.println(testFilledRoundRects());
|
||||
delay(500);
|
||||
|
||||
Serial.println(F("Done!"));
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
for(uint8_t rotation=0; rotation<4; rotation++) {
|
||||
tft.setRotation(rotation);
|
||||
testText();
|
||||
delay(2000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned long testFillScreen() {
|
||||
unsigned long start = micros();
|
||||
tft.fillScreen();
|
||||
tft.fillScreen(RED);
|
||||
tft.fillScreen(GREEN);
|
||||
tft.fillScreen(BLUE);
|
||||
tft.fillScreen();
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testText() {
|
||||
tft.fillScreen();
|
||||
unsigned long start = micros();
|
||||
tft.setCursor(0, 0);
|
||||
tft.setTextColor(WHITE);
|
||||
tft.setTextSize(1);
|
||||
tft.println("Hello World!");
|
||||
tft.setTextColor(YELLOW);
|
||||
tft.setTextSize(2);
|
||||
tft.println(1234.56);
|
||||
tft.setTextColor(RED);
|
||||
tft.setTextSize(3);
|
||||
tft.println(0xDEAD, HEX);
|
||||
tft.println();
|
||||
tft.setTextColor(GREEN);
|
||||
tft.setTextSize(4);
|
||||
tft.println("Hello");
|
||||
tft.setTextSize(2);
|
||||
tft.println("I implore thee,");
|
||||
tft.setTextSize(1);
|
||||
tft.println("my foonting turlingdromes.");
|
||||
tft.println("And hooptiously drangle me");
|
||||
tft.println("with crinkly bindlewurdles,");
|
||||
tft.println("Or I will rend thee");
|
||||
tft.println("in the gobberwarts");
|
||||
tft.println("with my blurglecruncheon,");
|
||||
tft.println("see if I don't!");
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testLines(uint16_t color) {
|
||||
unsigned long start, t;
|
||||
int x1, y1, x2, y2,
|
||||
w = tft.width(),
|
||||
h = tft.height();
|
||||
|
||||
tft.fillScreen();
|
||||
|
||||
x1 = y1 = 0;
|
||||
y2 = h - 1;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = w - 1;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t = micros() - start; // fillScreen doesn't count against timing
|
||||
|
||||
tft.fillScreen();
|
||||
|
||||
x1 = w - 1;
|
||||
y1 = 0;
|
||||
y2 = h - 1;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = 0;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t += micros() - start;
|
||||
|
||||
tft.fillScreen();
|
||||
|
||||
x1 = 0;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = w - 1;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t += micros() - start;
|
||||
|
||||
tft.fillScreen();
|
||||
|
||||
x1 = w - 1;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = 0;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFastLines(uint16_t color1, uint16_t color2) {
|
||||
unsigned long start;
|
||||
int x, y, w = tft.width(), h = tft.height();
|
||||
|
||||
tft.fillScreen();
|
||||
start = micros();
|
||||
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);
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testRects(uint16_t color) {
|
||||
unsigned long start;
|
||||
int n, i, i2,
|
||||
cx = tft.width() / 2,
|
||||
cy = tft.height() / 2;
|
||||
|
||||
tft.fillScreen();
|
||||
n = min(tft.width(), tft.height());
|
||||
start = micros();
|
||||
for(i=2; i<n; i+=6) {
|
||||
i2 = i / 2;
|
||||
tft.drawRect(cx-i2, cy-i2, i, i, color);
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
|
||||
unsigned long start, t = 0;
|
||||
int n, i, i2,
|
||||
cx = (tft.width() / 2) - 1,
|
||||
cy = (tft.height() / 2) - 1;
|
||||
|
||||
tft.fillScreen();
|
||||
n = min(tft.width(), tft.height());
|
||||
for(i=n; i>0; i-=6) {
|
||||
i2 = i / 2;
|
||||
start = micros();
|
||||
tft.fillRect(cx-i2, cy-i2, i, i, color1);
|
||||
t += micros() - start;
|
||||
// Outlines are not included in timing results
|
||||
tft.drawRect(cx-i2, cy-i2, i, i, color2);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
|
||||
unsigned long start;
|
||||
int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
|
||||
|
||||
tft.fillScreen();
|
||||
start = micros();
|
||||
for(x=radius; x<w; x+=r2) {
|
||||
for(y=radius; y<h; y+=r2) {
|
||||
tft.fillCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testCircles(uint8_t radius, uint16_t color) {
|
||||
unsigned long start;
|
||||
int x, y, r2 = radius * 2,
|
||||
w = tft.width() + radius,
|
||||
h = tft.height() + radius;
|
||||
|
||||
// Screen is not cleared for this one -- this is
|
||||
// intentional and does not affect the reported time.
|
||||
start = micros();
|
||||
for(x=0; x<w; x+=r2) {
|
||||
for(y=0; y<h; y+=r2) {
|
||||
tft.drawCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testTriangles() {
|
||||
unsigned long start;
|
||||
int n, i, cx = tft.width() / 2 - 1,
|
||||
cy = (tft.height() / 2) - 1;
|
||||
|
||||
tft.fillScreen();
|
||||
n = min(cx, cy);
|
||||
start = micros();
|
||||
for(i=0; i<n; i+=5) {
|
||||
tft.drawTriangle(
|
||||
cx , cy - i, // peak
|
||||
cx - i, cy + i, // bottom left
|
||||
cx + i, cy + i, // bottom right
|
||||
tft.Color565(0, 0, i));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFilledTriangles() {
|
||||
unsigned long start, t = 0;
|
||||
int i, cx = (tft.width() / 2) - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen();
|
||||
start = micros();
|
||||
for(i=min(cx,cy); i>10; i-=5) {
|
||||
start = micros();
|
||||
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||
tft.Color565(0, i, i));
|
||||
t += micros() - start;
|
||||
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||
tft.Color565(i, i, 0));
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
unsigned long testRoundRects() {
|
||||
unsigned long start;
|
||||
int w, i, i2,
|
||||
cx = (tft.width() / 2) - 1,
|
||||
cy = (tft.height() / 2) - 1;
|
||||
|
||||
tft.fillScreen();
|
||||
w = min(tft.width(), tft.height());
|
||||
start = micros();
|
||||
for(i=0; i<w; i+=6) {
|
||||
i2 = i / 2;
|
||||
tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.Color565(i, 0, 0));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFilledRoundRects() {
|
||||
unsigned long start;
|
||||
int i, i2,
|
||||
cx = (tft.width() / 2) - 1,
|
||||
cy = (tft.height() / 2) - 1;
|
||||
|
||||
tft.fillScreen();
|
||||
start = micros();
|
||||
for(i=min(tft.width(), tft.height()); i>20; i-=6) {
|
||||
i2 = i / 2;
|
||||
tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.Color565(0, i, 0));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <TFT_ILI9163C.h>
|
||||
|
||||
// Color definitions
|
||||
#define BLACK 0x0000
|
||||
#define BLUE 0x001F
|
||||
#define RED 0xF800
|
||||
#define GREEN 0x07E0
|
||||
#define CYAN 0x07FF
|
||||
#define MAGENTA 0xF81F
|
||||
#define YELLOW 0xFFE0
|
||||
#define WHITE 0xFFFF
|
||||
|
||||
TFT_ILI9163C tft = TFT_ILI9163C(10, 9, 14);
|
||||
|
||||
void setup() {
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
}
|
||||
94
trunk/Arduino/libraries/TFT_ILI9163C/examples/test/test.ino
Normal file
94
trunk/Arduino/libraries/TFT_ILI9163C/examples/test/test.ino
Normal file
@@ -0,0 +1,94 @@
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <TFT_ILI9163C.h>
|
||||
|
||||
#define __CS 10
|
||||
#define __DC 9
|
||||
#define __RST 14
|
||||
|
||||
// Color definitions
|
||||
#define BLACK 0x0000
|
||||
#define BLUE 0x001F
|
||||
#define RED 0xF800
|
||||
#define GREEN 0x07E0
|
||||
#define CYAN 0x07FF
|
||||
#define MAGENTA 0xF81F
|
||||
#define YELLOW 0xFFE0
|
||||
#define WHITE 0xFFFF
|
||||
|
||||
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST);
|
||||
|
||||
void setup() {
|
||||
tft.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
testLines(random(0x00ff,0xffff));
|
||||
delay(100);
|
||||
testText();
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
||||
unsigned long testText() {
|
||||
tft.fillScreen();
|
||||
unsigned long start = micros();
|
||||
tft.setCursor(0, 0);
|
||||
tft.setTextColor(WHITE);
|
||||
tft.setTextSize(1);
|
||||
tft.println("Hello World!");
|
||||
tft.setTextColor(YELLOW);
|
||||
tft.setTextSize(2);
|
||||
tft.println(1234.56);
|
||||
tft.setTextColor(RED);
|
||||
tft.setTextSize(3);
|
||||
tft.println(0xDEAD, HEX);
|
||||
tft.println();
|
||||
tft.setTextColor(GREEN);
|
||||
tft.setTextSize(4);
|
||||
tft.println("Hello");
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testLines(uint16_t color) {
|
||||
tft.fillScreen();
|
||||
unsigned long start, t;
|
||||
int x1, y1, x2, y2,
|
||||
w = tft.width(),
|
||||
h = tft.height();
|
||||
tft.fillScreen();
|
||||
x1 = y1 = 0;
|
||||
y2 = h - 1;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = w - 1;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t = micros() - start; // fillScreen doesn't count against timing
|
||||
tft.fillScreen();
|
||||
x1 = w - 1;
|
||||
y1 = 0;
|
||||
y2 = h - 1;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = 0;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t += micros() - start;
|
||||
tft.fillScreen();
|
||||
x1 = 0;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = w - 1;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t += micros() - start;
|
||||
tft.fillScreen();
|
||||
x1 = w - 1;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = 0;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
return micros() - start;
|
||||
}
|
||||
Reference in New Issue
Block a user