#define TFT_DC 53
#define TFT_CS 10
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
#include <DS18B20.h>
#include <SD.h>
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
int WhichScreen =1; // This variable stores the current Screen number
boolean hasChanged = true;
const int buttonPin = A0; // the number of the pushbutton pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup()
{
tft.begin();
pinMode(buttonPin, INPUT);
const unsigned char logo1 [] PROGMEM = {
}
;
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(0, 60);
tft.setTextSize(6);
tft.setTextColor(ILI9341_BLUE);
tft.setTextWrap(true);
tft.print("SUZUKI");
delay(3300);
tft.setCursor(0, 140);
tft.setTextSize(5);
tft.print("GS 500 E");
delay(1000);
tft.fillScreen(ILI9341_BLACK);
tft.fillRect(0,80,322,2,ILI9341_WHITE);
}
void loop()
{
if (hasChanged == true) {
switch(WhichScreen) {
case 1:
{
firstScreen();
}
break;
case 2:
{
secondScreen();
}
break;
case 3:
{
thirdScreen();
}
break;
case 4:
{
fourthScreen();
}
break;
case 5:
{
fifthScreen();
}
break;
case 6:
{
sixthScreen();
}
break;
case 0:
{
}
break;
}
}
//-------------------------------
// BEGIN of the switch debouncing code
int reading = digitalRead(buttonPin);
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
// if the button state has changed:
if (reading != buttonState) {
buttonState = reading;
// only toggle the LED if the new button state is HIGH
if (buttonState == HIGH) {
hasChanged = true;
WhichScreen++;
}
} else {
hasChanged = false;
}
}
lastButtonState = reading;
// END of the switch Debouncing code
// --------------------------------------
if (WhichScreen > 6){
WhichScreen = 1;
}
}
void firstScreen()
{
tft.fillRect(0,90,322,180,ILI9341_BLACK);
tft.setCursor(0, 91);
tft.setTextSize(4);
tft.setTextColor(ILI9341_WHITE);
tft.setTextWrap(true);
tft.print("OIL TEMP");
}
void secondScreen()
{
tft.fillRect(0,90,322,180,ILI9341_BLACK);
tft.setCursor(0, 91);
tft.setTextSize(4);
tft.setTextColor(ILI9341_WHITE);
tft.setTextWrap(true);
tft.print("FUEL");
}
void thirdScreen()
{
tft.fillRect(0,90,322,180,ILI9341_BLACK);
tft.setCursor(0, 91);
tft.setTextSize(4);
tft.setTextColor(ILI9341_WHITE);
tft.setTextWrap(true);
tft.print("BATTERY");
}
void fourthScreen()
{
tft.fillRect(0,90,322,180,ILI9341_BLACK);
tft.setCursor(0, 91);
tft.setTextSize(4);
tft.setTextColor(ILI9341_WHITE);
tft.setTextWrap(true);
tft.print("MENU3");
}
void fifthScreen()
{
tft.fillRect(0,90,322,180,ILI9341_BLACK);
tft.setCursor(0, 91);
tft.setTextSize(4);
tft.setTextColor(ILI9341_WHITE);
tft.setTextWrap(true);
tft.print("MENU3");
}
void sixthScreen()
{
tft.fillRect(0,90,322,180,ILI9341_BLACK);
tft.setCursor(0, 91);
tft.setTextSize(4);
tft.setTextColor(ILI9341_WHITE);
tft.setTextWrap(true);
tft.print("ALL DATA");
}