Skip to content

Instantly share code, notes, and snippets.

@houmei
Created May 27, 2014 20:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
SainSmart TFT + 86Duino
#include <TFT.h>
#include <SPI.h>
#define TFT_CS 42
#define TFT_DC 43
#define TFT_RST 0
#define TFT_SCLK 0
#define TFT_MOSI 0
TFT screen = TFT(TFT_CS, TFT_DC, TFT_RST); // for UNO
/// TFT screen = TFT(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); // for Leonardo
void setup(void) {
// Serial.begin(9600); while(!Serial);
// Serial.println("START");
screen.begin();
// SPI.setClockDivider(SPI_CLOCK_DIV2); // SPI speed
SPI.setClockDivider(2); // SPI speed 100/(2*n) MHz
screen.background(0,0,0);
screen.fill(255,255,255);
}
const int XMAX=ST7735_TFTHEIGHT;
const int YMAX=ST7735_TFTWIDTH;
unsigned long counter=0;
void loop() {
int x1,y1,x2,y2,r,g,b;
unsigned long stime,etime;
stime=millis();
for(int i=1;i<=1000;i++) {
r=random(256); g=random(256); b=random(256);
x1=random(0,XMAX);
y1=random(0,YMAX);
x2=random(0,XMAX);
y2=random(0,YMAX);
screen.stroke(r,g,b);
screen.line(x1,y1,x2,y2); // line ... hang 01m02s
/// screen.line(x1,y1,x1,y2); // verticalline ... hang 01m05s
/// screen.line(x1,y1,x2,y1); // horizonalline ... hang 02m56s
/// screen.point(x1,y1); // dot ... hang
/// delay(10); // ... hang
}
etime=millis();
counter++;
// Serial.println(counter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment