SainSmart TFT + 86Duino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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