OK so i have made a lot of progresses on this and things are starting to work (a little bit)
the TFT screen will now list faults just like i want it to, but the time that is displayed for them is just the time of the most recent fault. I.E. they all list the same time, and that time is just recorded with the most recent event. i included a picture so you could see some of my setup.
heres the part of the code that I'm fighting with:
#include <DS3231.h>
#include <DallasTemperature.h>
//#include <OneWire.h>
#include <NewPing.h>
//Technical support:goodtft@163.com
// User Defined Timer Values!! These NEED TO BE SET BEFORE OPERATING PROGRAM
unsigned long LockoutAutoResetDelayTime = 10000; // Time in MS to reset burner after when autoreset is possible
unsigned long FlameTimeInVal = 100; // 1 unit = .5 seconds, the amount of time it takes to cause a flameout lockout
unsigned long FlameTimeOutVal = 100; // 1 unit = .5 seconds, the amount of time it takes to reset FlameTimeOutVal after flame is recovered
unsigned long RegainLockoutRetryTimer = 500000; // time in MS, if the burner lights and burns well for this timers duration it will gain more light attempts (up to 2 attempts max)
unsigned long PidUnderTempTimer = 100000; // the pid needs to meet alarm temp before burner lights, this is the amount of time the pid alarm can be off while burner is burning.
unsigned long BurnerStepInterval = 2000; // MS wait time between burner steps
unsigned long OilLevelCheck = 0;
unsigned long FaultTimer = 0;
// Real Inputs ///
const int PidRelay = 30; //Input from PID
const int WaterFloat = 31; // Input 31 from water Float
const int FlameSensor = A10; //Analog input 10 from flame sensor
const int WaterTempSens = A11; // Analog Input 11
// Real Ouputs //
const int Pump = 22; // Output 22 to pump
const int AirCompressor = 23; // Output 23 to air compressor
const int Preheat = 24; //Output 24 to PID
const int Burner = 25; //Output 25 to burner
const int LedPin = 32;
// Input and Output
// other nessicary tags //
unsigned long OldBurnerStepTime = 0;
unsigned long previousMillis = 0;
unsigned long PreviousMillisFlame = 0;
unsigned long FlameTimeout = 0;
unsigned long XFlameTimeout = 0;
unsigned long FlameTimein = 0;
unsigned long XFlameTimein = 0;
unsigned long LockoutRetryTimer = 0;
unsigned long LockoutRetryCounter = 0;
unsigned long PidAlarmTimeout = 0;
const long FlameOutDelay = 10000;
const int FlameSenseSP = 900; // Setpoint for flame sensor I.E. an acceptable value for flame intensity.
const int TempSPHigh = 180;
const int TempSPLow = 170;
const int off = HIGH;
const int on = LOW;
int Screen = 1;
int ScreenOneLoad = 0;
int ScreenTwoLoad = 0;
int FlameLockout = 1;
int XFlameLockout = 0;
int FlameDetected = 0;
int XFlameDetected = 1;
int BurnerStep = 0;
int XBurnerStep = 1;
int BurnerStepDelay = 0;
int XBurnerStepDelay = 1;
int XXBurnerStepDelay = 1;
int LockoutRetry = 0;
int LockoutTimer = 0;
int OilLevelHR = 0;
int OilLevel = 0;
int TemperatureF;
int FaultCode[9];
int XFaultCode[9];
int FaultCodeIndex = 0;
char* FaultCodes[40];
char* FaultTimes[10][8];
char* FaultDates[10][10];
char* FaultMsg[10][40];
int FaultArray;
int NewFaultLocation;
int Line = 0;
int TxtLine;
int NewFault = 0;
#define trigPin 52
#define echoPin 53
#define TRIGGER_PIN 52
#define ECHO_PIN 53
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
//Temp Sensor Stuff
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 35
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>
#include <EEPROM.h>
#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
#define YP A3 // must be an analog pin, use "An" notation!
#define XM A2 // must be an analog pin, use "An" notation!
#define YM 9 // can be a digital pin
#define XP 8 // can be a digital pin
#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define BLACK 0x0000
#define BLUE 0x0000
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
#define BOXSIZE 40
#define BOXSIZET 50
#define BOXSIZEW 120
#define PENRADIUS 3
int oldcolor, currentcolor;
int FirstTextLine = BOXSIZET + 10;
int SecondTextLine = FirstTextLine + 20;
int ThirdTextLine = SecondTextLine + 20;
int FourthTextLine = ThirdTextLine + 20;
DS3231 rtc(SDA, SCL); // Clock Stuff
void setup(void) {
}
#define MINPRESSURE 10 // define some shit
#define MAXPRESSURE 1000 // define more shit
void loop()
{
unsigned long currentMillis = millis();
int FlameSens = analogRead(FlameSensor);
int TimerBlackout;
int WaterFloatState = digitalRead(WaterFloat);
int PreheatDone = digitalRead(PidRelay);
if (currentMillis - FaultTimer >= 500) {
if(FlameSens < FlameSenseSP) {FaultCode[1] = 1;} else{ FaultCode[1] = 0;}
if(FlameLockout == 1){ FaultCode[2] = 1;} else { FaultCode[2] = 0;}
for (FaultCodeIndex = 0; FaultCodeIndex < 9; FaultCodeIndex ++){
if(FaultCode[FaultCodeIndex] == 0){ XFaultCode[FaultCodeIndex] = 0;}
if(FaultCode[FaultCodeIndex] != XFaultCode[FaultCodeIndex] && FaultCode[FaultCodeIndex] != 0){
FaultArray++;
if (FaultArray > 9){FaultArray = 0;}
FaultDates [FaultArray][0] = rtc.getDateStr();
FaultTimes [FaultArray][0] = rtc.getTimeStr();
if (FaultCodeIndex == 1){FaultMsg[FaultArray][0] = " Flame Sensor Dark";}
if (FaultCodeIndex == 2){FaultMsg[FaultArray][0] = " Flame Out Lockout";}
if (FaultCodeIndex == 3){FaultMsg[FaultArray][0] = " Low Water LVL";}
Serial.print(FaultDates[FaultArray][0]);
Serial.print(FaultTimes[FaultArray][0]);
Serial.println(FaultMsg[FaultArray][0]);
Serial.println("FaultArray");Serial.println(FaultArray);
XFaultCode[FaultCodeIndex] = FaultCode[FaultCodeIndex];
ScreenTwoLoad = 0;
//NewFault = 1;
}}
FaultTimer = currentMillis;
}
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////Controlls for Screen 2
if (Screen == 2) {
if(ScreenTwoLoad == 0)
{tft.drawRect(BOXSIZEW, 0, BOXSIZEW, BOXSIZET, WHITE); // Bug Fix for page buttons
tft.drawRect(0, 0, BOXSIZEW, BOXSIZET, BLUE); // Same Bug Fix
tft.fillRect(0, BOXSIZE +1, tft.width(), tft.height() - BOXSIZE -1, BLACK);
tft.drawRect(BOXSIZEW, 0, BOXSIZEW, BOXSIZET, WHITE); // Bug Fix for page buttons
tft.drawRect(0, 0, BOXSIZEW, BOXSIZET, BLUE); // Same Bug Fix
tft.setTextColor(WHITE);
tft.setTextSize(1);
for (Line = 0; Line < 9; Line++){
TxtLine = 100 + (Line *10);
NewFaultLocation = FaultArray - Line;
if (NewFaultLocation < 0) {NewFaultLocation = NewFaultLocation + 10;}
tft.setCursor(0,TxtLine);
tft.println(FaultDates[NewFaultLocation][0]);
tft.setCursor(70,TxtLine);
tft.println(FaultTimes[NewFaultLocation][0]);
tft.setCursor(110,TxtLine);
tft.println(FaultMsg[NewFaultLocation][0]);
}
ScreenOneLoad = 0;
ScreenTwoLoad = 1;
}}
}