daily_automated
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/* Demo of draw circle's APP
|
||||
drawCircle(int poX, int poY, int r,INT16U color);
|
||||
fillCircle(int poX, int poY, int r,INT16U color);
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <TFTv2.h>
|
||||
#include <SPI.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
TFT_BL_ON; //turn on the background light
|
||||
|
||||
Tft.TFTinit(); //init TFT library
|
||||
|
||||
Tft.drawCircle(100, 100, 30,YELLOW); //center: (100, 100), r = 30 ,color : YELLOW
|
||||
|
||||
Tft.drawCircle(100, 200, 40,CYAN); // center: (100, 200), r = 10 ,color : CYAN
|
||||
|
||||
Tft.fillCircle(200, 100, 30,RED); //center: (200, 100), r = 30 ,color : RED
|
||||
|
||||
Tft.fillCircle(200, 200, 30,BLUE); //center: (200, 200), r = 30 ,color : BLUE
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Demo of draw line's APP
|
||||
drawLine(unsigned int x0,unsigned int y0,unsigned int x1,unsigned int y1,unsigned int color);
|
||||
drawVerticalLine(unsigned int poX, unsigned int poY,unsigned int length,unsigned int color);
|
||||
drawHorizontalLine(unsigned int poX, unsigned int poY,unsigned int length,unsigned int color);
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <TFTv2.h>
|
||||
#include <SPI.h>
|
||||
void setup()
|
||||
{
|
||||
TFT_BL_ON; // turn on the background light
|
||||
Tft.TFTinit(); //init TFT library
|
||||
|
||||
Tft.drawLine(0,0,239,319,RED); //start: (0, 0) end: (239, 319), color : RED
|
||||
|
||||
Tft.drawVerticalLine(60,100,100,GREEN); // Draw a vertical line
|
||||
// start: (60, 100) length: 100 color: green
|
||||
|
||||
Tft.drawHorizontalLine(30,60,150,BLUE); //Draw a horizontal line
|
||||
//start: (30, 60), high: 150, color: blue
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,40 @@
|
||||
/* draw number's APP
|
||||
drawNumber(long long_num,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor);
|
||||
drawFloat(float floatNumber,INT8U decimal,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor);
|
||||
drawFloat(float floatNumber,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor);
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <TFTv2.h>
|
||||
#include <SPI.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
TFT_BL_ON; // turn on the background light
|
||||
|
||||
Tft.TFTinit(); // init TFT library
|
||||
|
||||
Tft.drawNumber(1024, 0, 0, 1, RED); // draw a integer: 1024, Location: (0, 0), size: 1, color: RED
|
||||
|
||||
Tft.drawNumber(1024, 0, 20, 2, BLUE); // draw a integer: 1024, Location: (0, 20), size: 2, color: BLUE
|
||||
|
||||
Tft.drawNumber(1024, 0, 50, 3, GREEN); // draw a integer: 1024, Location: (0, 50), size: 3, color: GREEN
|
||||
|
||||
Tft.drawNumber(1024, 0, 90, 4, BLUE); // draw a integer: 1024, Location: (0, 90), size:4, color: BLUE
|
||||
|
||||
Tft.drawFloat(1.2345, 0, 150, 4, YELLOW); // draw a float number: 1.2345, Location: (0, 150), size: 4, color: YELLOW
|
||||
|
||||
Tft.drawFloat(1.2345, 2, 0, 200, 4, BLUE); // draw a float number: 1.2345: Location: (0, 200), size: 4, decimal: 2, color: BLUE
|
||||
|
||||
Tft.drawFloat(1.2345, 4, 0, 250, 4, RED); // draw a float number: 1.2345 Location: (0, 250), size: 4, decimal: 4, color: RED
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,26 @@
|
||||
/* Draw Boxes - Demonstrate drawRectangle and fillRectangle
|
||||
fillScreen(INT16U XL,INT16U XR,INT16U YU,INT16U YD,INT16U color);
|
||||
fillRectangle(INT16U poX, INT16U poY, INT16U length, INT16U width, INT16U color);
|
||||
drawRectangle(INT16U poX, INT16U poY, INT16U length,INT16U width,INT16U color);
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <TFTv2.h>
|
||||
#include <SPI.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
TFT_BL_ON; // turn on the background light
|
||||
Tft.TFTinit(); // init TFT library
|
||||
|
||||
Tft.fillScreen(80, 160, 50, 150,RED);
|
||||
Tft.fillRectangle(30, 120, 100,65,YELLOW);
|
||||
Tft.drawRectangle(100, 170, 120,60,BLUE);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
55
trunk/Arduino/libraries/TFTv2/examples/paint/paint.ino
Normal file
55
trunk/Arduino/libraries/TFTv2/examples/paint/paint.ino
Normal file
@@ -0,0 +1,55 @@
|
||||
// Paint application - Demonstate both TFT and Touch Screen
|
||||
#include <stdint.h>
|
||||
#include <SeeedTouchScreen.h>
|
||||
#include <TFTv2.h>
|
||||
#include <SPI.h>
|
||||
|
||||
int ColorPaletteHigh = 30;
|
||||
int color = WHITE; //Paint brush color
|
||||
unsigned int colors[8] = {BLACK, RED, GREEN, BLUE, CYAN, YELLOW, WHITE, GRAY1};
|
||||
|
||||
// For better pressure precision, we need to know the resistance
|
||||
// between X+ and X- Use any multimeter to read it
|
||||
// The 2.8" TFT Touch shield has 300 ohms across the X plate
|
||||
|
||||
TouchScreen ts = TouchScreen(XP, YP, XM, YM); //init TouchScreen port pins
|
||||
|
||||
void setup()
|
||||
{
|
||||
Tft.TFTinit(); //init TFT library
|
||||
Serial.begin(115200);
|
||||
//Draw the pallet
|
||||
for(int i = 0; i<8; i++)
|
||||
{
|
||||
Tft.fillRectangle(i*30, 0, 30, ColorPaletteHigh, colors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// a point object holds x y and z coordinates.
|
||||
Point p = ts.getPoint();
|
||||
|
||||
//map the ADC value read to into pixel co-ordinates
|
||||
|
||||
p.x = map(p.x, TS_MINX, TS_MAXX, 0, 240);
|
||||
p.y = map(p.y, TS_MINY, TS_MAXY, 0, 320);
|
||||
|
||||
// we have some minimum pressure we consider 'valid'
|
||||
// pressure of 0 means no pressing!
|
||||
|
||||
if (p.z > __PRESURE) {
|
||||
// Detect paint brush color change
|
||||
if(p.y < ColorPaletteHigh+2)
|
||||
{
|
||||
color = colors[p.x/30];
|
||||
}
|
||||
else
|
||||
{
|
||||
Tft.fillCircle(p.x,p.y,2,color);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
23
trunk/Arduino/libraries/TFTv2/examples/shapes/shapes.ino
Normal file
23
trunk/Arduino/libraries/TFTv2/examples/shapes/shapes.ino
Normal file
@@ -0,0 +1,23 @@
|
||||
// Draw Boxes - Demonstrate drawRectangle and fillRectangle
|
||||
|
||||
#include <stdint.h>
|
||||
#include <TFTv2.h>
|
||||
#include <SPI.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
TFT_BL_ON; // turn on the background light
|
||||
Tft.TFTinit(); // init TFT library
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
for(int r=0;r<115;r=r+2) //set r : 0--115
|
||||
{
|
||||
Tft.drawCircle(119,160,r,random(0xFFFF)); //draw circle, center:(119, 160), color: random
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
35
trunk/Arduino/libraries/TFTv2/examples/text/text.ino
Normal file
35
trunk/Arduino/libraries/TFTv2/examples/text/text.ino
Normal file
@@ -0,0 +1,35 @@
|
||||
/* draw text's APP
|
||||
drawChar(INT8U ascii,INT16U poX, INT16U poY,INT16U size, INT16U fgcolor);
|
||||
drawString(char *string,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor);
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <TFTv2.h>
|
||||
#include <SPI.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
TFT_BL_ON; // turn on the background light
|
||||
Tft.TFTinit(); // init TFT library
|
||||
|
||||
Tft.drawChar('S',0,0,1,RED); // draw char: 'S', (0, 0), size: 1, color: RED
|
||||
|
||||
Tft.drawChar('E',10,10,2,BLUE); // draw char: 'E', (10, 10), size: 2, color: BLUE
|
||||
|
||||
Tft.drawChar('E',20,40,3,GREEN); // draw char: 'E', (20, 40), size: 3, color: GREEN
|
||||
|
||||
Tft.drawChar('E',30,80,4,YELLOW); // draw char: 'E', (30, 80), size: 4, color: YELLOW
|
||||
|
||||
Tft.drawChar('D',40,120,4,YELLOW); // draw char: 'D', (40, 120), size: 4, color: YELLOW
|
||||
|
||||
Tft.drawString("Hello",0,180,3,CYAN); // draw string: "hello", (0, 180), size: 3, color: CYAN
|
||||
|
||||
Tft.drawString("World!!",60,220,4,WHITE); // draw string: "world!!", (80, 230), size: 4, color: WHITE
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
BIN
trunk/Arduino/libraries/TFTv2/examples/tftbmp/flower.BMP
Normal file
BIN
trunk/Arduino/libraries/TFTv2/examples/tftbmp/flower.BMP
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 225 KiB |
BIN
trunk/Arduino/libraries/TFTv2/examples/tftbmp/hibiscus.bmp
Normal file
BIN
trunk/Arduino/libraries/TFTv2/examples/tftbmp/hibiscus.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 225 KiB |
BIN
trunk/Arduino/libraries/TFTv2/examples/tftbmp/test.bmp
Normal file
BIN
trunk/Arduino/libraries/TFTv2/examples/tftbmp/test.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 225 KiB |
213
trunk/Arduino/libraries/TFTv2/examples/tftbmp/tftbmp.ino
Normal file
213
trunk/Arduino/libraries/TFTv2/examples/tftbmp/tftbmp.ino
Normal file
@@ -0,0 +1,213 @@
|
||||
#include <SD.h>
|
||||
#include <SPI.h>
|
||||
#include "TFTv2.h"
|
||||
File bmpFile;
|
||||
|
||||
unsigned char saved_spimode;
|
||||
int bmpWidth, bmpHeight;
|
||||
uint8_t bmpDepth, bmpImageoffset;
|
||||
|
||||
#define chipSelect 4
|
||||
|
||||
//set up variables using the SD utility library functions:
|
||||
Sd2Card card;
|
||||
SdVolume volume;
|
||||
SdFile root;
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(11,INPUT);
|
||||
pinMode(12,INPUT);
|
||||
pinMode(13,INPUT);
|
||||
TFT_CS_HIGH;
|
||||
pinMode(chipSelect,OUTPUT);
|
||||
digitalWrite(chipSelect,HIGH);
|
||||
|
||||
Serial.begin(38400);
|
||||
SPI.begin();
|
||||
Tft.TFTinit();
|
||||
//SPI.setClockDivider(SPI_CLOCK_DIV4);
|
||||
//SDcard_info();
|
||||
/**/
|
||||
DDRB |= 0x04;
|
||||
card.init(SPI_FULL_SPEED,chipSelect);//SPI_QUARTER_SPEED SPI_HALF_SPEED, SPI_FULL_SPEED,
|
||||
if(!SD.begin(chipSelect))//SPI_QUARTER_SPEED,
|
||||
{ //53 is used as chip select pin
|
||||
Serial.println("failed!");
|
||||
while(1);
|
||||
}
|
||||
Serial.println("SD OK!");
|
||||
|
||||
Tft.setCol(0,239);
|
||||
Tft.setPage(0,319);
|
||||
Tft.sendCMD(0x2c);//start to write to display ram
|
||||
TFT_BL_ON;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
/*
|
||||
*/
|
||||
char bmpfiles[][18]=
|
||||
{
|
||||
"123.bmp","hibiscus.bmp","test.bmp"
|
||||
};
|
||||
for(unsigned char i=0;i<3;i++)
|
||||
{
|
||||
//TFT_BL_OFF;
|
||||
bmpFile = SD.open(bmpfiles[i]);
|
||||
if (! bmpFile)
|
||||
{
|
||||
Serial.println("didnt find image");
|
||||
while (1);
|
||||
}
|
||||
|
||||
if (! bmpReadHeader(bmpFile)) {
|
||||
Serial.println("bad bmp");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.print("image size ");
|
||||
Serial.print(bmpWidth, DEC);
|
||||
Serial.print(", ");
|
||||
Serial.println(bmpHeight, DEC);
|
||||
bmpdraw(bmpFile, 0, 0);
|
||||
bmpFile.close();
|
||||
//TFT_BL_ON;
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
// This procedure reads a bitmap and draws it to the screen
|
||||
// its sped up by reading many pixels worth of data at a time
|
||||
// instead of just one pixel at a time. increading the buffer takes
|
||||
// more RAM but makes the drawing a little faster. 20 pixels' worth
|
||||
// is probably a good place
|
||||
|
||||
|
||||
#define BUFFPIXEL 20
|
||||
|
||||
void bmpdraw(File f, int x, int y)
|
||||
{
|
||||
bmpFile.seek(bmpImageoffset);
|
||||
|
||||
uint32_t time = millis();
|
||||
uint16_t p;
|
||||
uint8_t g, b;
|
||||
int i, j;
|
||||
|
||||
uint8_t sdbuffer[3 * BUFFPIXEL]; // 3 * pixels to buffer
|
||||
uint8_t buffidx = 3*BUFFPIXEL;
|
||||
|
||||
|
||||
for (i=0; i< bmpHeight; i++)
|
||||
{
|
||||
|
||||
for (j=bmpWidth; j>0; j--)
|
||||
{
|
||||
// read more pixels
|
||||
if (buffidx >= 3*BUFFPIXEL)
|
||||
{
|
||||
bmpFile.read(sdbuffer, 3*BUFFPIXEL);
|
||||
buffidx = 0;
|
||||
}
|
||||
|
||||
// convert pixel from 888 to 565
|
||||
b = sdbuffer[buffidx++]; // blue
|
||||
g = sdbuffer[buffidx++]; // green
|
||||
p = sdbuffer[buffidx++]; // red
|
||||
|
||||
p >>= 3;
|
||||
p <<= 6;
|
||||
|
||||
g >>= 2;
|
||||
p |= g;
|
||||
p <<= 5;
|
||||
|
||||
b >>= 3;
|
||||
p |= b;
|
||||
|
||||
// write out the 16 bits of color
|
||||
Tft.setPixel(j,i,p);
|
||||
}
|
||||
}
|
||||
Serial.print(millis() - time, DEC);
|
||||
Serial.println(" ms");
|
||||
}
|
||||
|
||||
boolean bmpReadHeader(File f) {
|
||||
// read header
|
||||
uint32_t tmp;
|
||||
|
||||
if (read16(f) != 0x4D42) {
|
||||
// magic bytes missing
|
||||
return false;
|
||||
}
|
||||
|
||||
// read file size
|
||||
tmp = read32(f);
|
||||
Serial.print("size 0x");
|
||||
Serial.println(tmp, HEX);
|
||||
|
||||
// read and ignore creator bytes
|
||||
read32(f);
|
||||
|
||||
bmpImageoffset = read32(f);
|
||||
Serial.print("offset ");
|
||||
Serial.println(bmpImageoffset, DEC);
|
||||
|
||||
// read DIB header
|
||||
tmp = read32(f);
|
||||
Serial.print("header size ");
|
||||
Serial.println(tmp, DEC);
|
||||
bmpWidth = read32(f);
|
||||
bmpHeight = read32(f);
|
||||
|
||||
|
||||
if (read16(f) != 1)
|
||||
return false;
|
||||
|
||||
bmpDepth = read16(f);
|
||||
Serial.print("bitdepth ");
|
||||
Serial.println(bmpDepth, DEC);
|
||||
|
||||
if (read32(f) != 0) {
|
||||
// compression not supported!
|
||||
return false;
|
||||
}
|
||||
|
||||
Serial.print("compression ");
|
||||
Serial.println(tmp, DEC);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
// These read data from the SD card file and convert them to big endian
|
||||
// (the data is stored in little endian format!)
|
||||
|
||||
// LITTLE ENDIAN!
|
||||
uint16_t read16(File f)
|
||||
{
|
||||
uint16_t d;
|
||||
uint8_t b;
|
||||
b = f.read();
|
||||
d = f.read();
|
||||
d <<= 8;
|
||||
d |= b;
|
||||
return d;
|
||||
}
|
||||
|
||||
// LITTLE ENDIAN!
|
||||
uint32_t read32(File f)
|
||||
{
|
||||
uint32_t d;
|
||||
uint16_t b;
|
||||
|
||||
b = read16(f);
|
||||
d = read16(f);
|
||||
d <<= 16;
|
||||
d |= b;
|
||||
return d;
|
||||
}
|
||||
Reference in New Issue
Block a user