#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 9
#define TFT_CS 10
#define VERT_PIN A0
#define HORZ_PIN A1
#define SEL_PIN 2
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
pinMode(VERT_PIN, INPUT);
pinMode(HORZ_PIN, INPUT);
pinMode(SEL_PIN, INPUT_PULLUP);
tft.begin();
tft.setCursor(50, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("ST185");
tft.setCursor(20, 160);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Multi CAN Gauge");
}
void loop() {
int page = 1;
int vert = analogRead(VERT_PIN);
int horz = analogRead(HORZ_PIN);
bool selPressed = digitalRead(SEL_PIN) == LOW;
if (vert == 512 && horz == 0){
//joystic right
if (page < 5){ page++; }
else { page = 0; }
}
if (horz == 1023 && vert == 512){
//joystic left
if (page > 1) { page--; }
else { page = 5; }
}
if (page == 1){
//page1(page);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(60, 10);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println(page);
delay(10000);
}
if (page == 2){
//page2(page);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(60, 10);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println(page);
delay(10000);
}
}
void page1(int page){
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(60, 10);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println(page);
delay(10000);
}
// void page2(int page){
// tft.fillScreen(ILI9341_BLACK);
// tft.setCursor(60, 10);
// tft.setTextColor(ILI9341_RED);
// tft.setTextSize(3);
// tft.println(page);
// delay(10000);
// }