Arduino IDE 1.0.5 + Arduino UNO + Adafruit 1.8" TFT Shield -> hang up after 1s / Solved! run well without uSD card
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
| /* | |
| TFT demo | |
| https://github.com/arduino/TFT | |
| http://arduino.cc/en/Reference/TFTLibrary | |
| */ | |
| // randomdot | |
| #include <TFT.h> | |
| #include <SPI.h> | |
| #define TFT_CS 10 | |
| #define TFT_DC 8 | |
| #define TFT_RST 0 | |
| #define TFT_SCLK 13 | |
| #define TFT_MOSI 11 | |
| #define SD_CS 4 | |
| 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_DIV16); // SPI speed | |
| 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