#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
}
}
}