// Libary
#include <SPI.h>
#include <SPI.h>
#include <SD.h>
#include "Adafruit_HX8357.h"
// Define Pin numbers
#define TFT_CS 53
#define TFT_DC 48
#define TFT_RST 8 // RST can be set to -1 if you tie it to Arduino's reset
#define SD_CCS 42
// Colours
#define BLACK 0x0000
#define BLUE 0x001F
#define GREEN 0x07E0
#define RED 0xF800
#define WHITE 0xFFFF
// LCD variable
Adafruit_HX8357 display = Adafruit_HX8357(TFT_CS, TFT_DC);
bool graphDISPLAY = false; // Determins to display graph or menu
int MyGraph = 0; // Each selection of graphs
bool tempGraph = false; // Temprature Graph
bool humdGraph = false; // Humidity Graph
bool presGraph = false; // Pressure Graph
bool gasGraph = false; // Gas Resistance Graph
bool lighGraph = false; // Light Graph
void setup() {
display.begin(HX8357D);
display.fillScreen(BLACK); // Add colour in back ground
display.setRotation(3);
}
void loop() {
// put your main code here, to run repeatedly:
}
void LCDdisplay() {
// If the Boolean 'graphDISPLAY' is true show a graph, else Display the menu
if (graphDISPLAY) {
double x, y; // For graph
// If statment to determine which
if (MyGraph == 0) { // For TEMPRATURE
boolReset();
tempGraph = true;
for(x = 0; x <= 60; x++){
y = bme.temprature; // 0 to 65 degrees C
Graph(display, x, y, 50, 290, 390, 260, 0, 60, 1, 0, 65, 1, "Temprature Reading", " Time (s)", "Temperature (C)", BLUE, RED, GREEN, WHITE, BLACK, tempGraph)
}
}
if (MyGraph == 1) { // For HUMIDITY vs TIME
boolReset();
humdGraph = true;
for(x = 0; x <= 60; x++){
y = bme.humidity; // 0 to 100 %
Graph(display, x, y, 50, 290, 390, 260, 0, 60, 1, 0, 100, 1, "Humidity Reading", " Time (s)", "Humidity (%)", BLUE, RED, GREEN, WHITE, BLACK, humdGraph)
}
}
if (MyGraph == 2) { // For PRESSURE vs TIME
boolReset();
presGraph = true;
for(x = 0; x <= 60; x++){
y = (bme.pressure); // 300 to 110,000 Pa
Graph(display, x, y, 50, 290, 390, 260, 0, 60, 1, 0, 110000, 500, "Pressure Reading", " Time (s)", "Pressure (Pa)", BLUE, RED, GREEN, WHITE, BLACK, presGraph)
}
}
if (MyGraph == 3) { // For GAS RESISTANCE vs TIME
boolReset();
gasGraph = true;
for(x = 0; x <= 60; x++){
y = (bme.gas_resistance); // 50 to 50,000 ohms
Graph(display, x, y, 50, 290, 390, 260, 0, 60, 1, 0, 50000, 100, "Gas Resistance Reading", " Time (s)", "Gas Resistance (ohms)", BLUE, RED, GREEN, WHITE, BLACK, gasGraph)
}
}
if (MyGraph == 4) { // For LIGHT vs TIME
boolReset();
lighGraph = true;
for(x = 0; x <= 60; x++){
y = lux; // 1 to 65535 lx
Graph(display, x, y, 50, 290, 390, 260, 0, 60, 1, 0, 65535, 50, "Brightness Reading", " Time (s)", "Light (lx)", BLUE, RED, GREEN, WHITE, BLACK, lighGraph)
}
}
if ((MyGraph < 0) || (MyGraph > 4)) { // For LIGHT vs TIME
graphDISPLAY = false;
}
}
else {
// LCD DISPLAY MENU COMPONENTS
}
}
void boolReset() {
tempGraph = false;
humdGraph = false;
presGraph = false;
gasGraph = false;
lighGraph = false;
}