#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// For the Adafruit shield, these are the default.
const byte TFT_RST = 7;
const byte TFT_DC = 9;
const byte TFT_CS = 10;
byte X = 200;
byte Y = 15;
byte W = 40;
byte H = 15;
//byte X = 0;
//byte Y = 40;
//byte W = 240;
//byte H = 50;
byte progress = 0;
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup()
{
Serial.begin(9600);
Serial.println("ILI9341 bargraph Test!");
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
//tft.setRotation(1);
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(2);
tft.println(" bargraph Test!");
tft.drawRect(X, Y, W, H, ILI9341_WHITE);
}
void loop()
{
barProgress();
}
void barProgress()
{
static unsigned long timer = 0;
unsigned long interval = 1000;
if (millis() - timer >= interval)
{
timer = millis();
tft.fillRect(X, Y, progress, H, ILI9341_WHITE);
tft.setCursor(130, 100);
tft.print("Progress = ");
tft.fillRect(100, 150, 20, H, ILI9341_BLACK); // erase old data
tft.setCursor(140, 100);
tft.println(progress);
progress = 4;
if(progress > 240)
{
while (1); // finished just wait. Take this out for your use.
// or reset the numbers for another go
}
}
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
lcd1:VCC
lcd1:GND
lcd1:CS
lcd1:RST
lcd1:D/C
lcd1:MOSI
lcd1:SCK
lcd1:LED
lcd1:MISO