#include <PID_v1.h>
#include <Servo.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <INA226_WE.h>
#include <I2C_RTC.h>
#include "Adafruit_FRAM_I2C.h"
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_ST7796S_kbv.h"
static PCF8563 RTC;
#define TFT_RST 48
#define TFT_DC 49
#define TFT_CS 53
Adafruit_ST7796S_kbv tft = Adafruit_ST7796S_kbv(TFT_CS, TFT_DC, TFT_RST);
INA226_WE ina226_Out_12vdc = INA226_WE(0x40);
INA226_WE ina226_Servo = INA226_WE(0x44);
INA226_WE ina226_Arduino = INA226_WE(0x41);
int MENU_FORWARD_BUTTON_PIN = 2;
int MENU_BACK_BUTTON_PIN = 3;
#define Stop_Pump_Servo_PIN 4 //input
#define Boiler_Flame_PIN 5 // input
#define CaseFan_PIN 8 //pwm output
#define SERVO_PIN 9 //pwm output
#define CircPump_PIN 10 // output
#define Boiler_PIN 11 // output
#define ONE_WIRE_BUS 23 // data
#define Boiler_Hys 5 //-------------------------------------------------Hysteresis Boiler
#define CircPump_Set 20 //----------------------------------------------CircPump Setpoint
#define CircPump_Hys 5 //-----------------------------------------------Hysteresis CircPump
int currentPage = 1; //variable to keep track of the current menu page
double FlowF_Set = 55; //-----------------------------------------------Will be overwritten later in map fuction
double FlowF_Temp, output;
double Kp = 2.0; //-----------------------------------------------------Proportional gain
double Ki = 5.0; //-----------------------------------------------------Integral gain
double Kd = 1.0; //-----------------------------------------------------Derivative gain
PID myPID(&FlowF_Temp, &output, &FlowF_Set, Kp, Ki, Kd, DIRECT);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
Servo servo;
float Boiler_Temp;
float Out_Temp_Sensor1, Out_Temp_Sensor2;
float average; //---------------Variable to store average temperature OutTemp_Sensor1, OutTemp_Sensor2--//
float Case_Temp;
float FlowR_Temp;
float Cwater_Temp;
float Wwater_Temp;
float Chimney_Temp;
//------------------------------Variables operating counter(Boiler_Flame / CircPump)--------------------//
bool lastState_Boiler_Flame = false;
bool lastState_CircPump = false;
unsigned int timeBufferTimer_Boiler_Flame = 0;
unsigned int timeBufferTimer_CircPump = 0;
byte timeBufferMinutter_Boiler_Flame = 0;
byte timeBufferMinutter_CircPump = 0;
byte timeBufferSekunder_Boiler_Flame = 0;
byte timeBufferSekunder_CircPump = 0;
unsigned long timerStart_Boiler_Flame = 0;
unsigned long timerStart_CircPump= 0;
unsigned int CounterTurnOnTimes_Boiler_Flame = 0;
unsigned int CounterTurnOnTimes_CircPump = 0;
//----------------------------------------------------------------------------------------------------//
//------------------------------Printer operating counter---------------------------------------------//
unsigned long lastPrintUpdate = 0;
unsigned long IntervalPrintUpdate = 1000;//Print besked hver 1s
//----------------------------------------------------------------------------------------------------//
//------------------------------Screen automatic updater---------------------------------------------//
unsigned long lastScreenUpdate = 0;
unsigned long IntervalScreenUpdate = 1000;//Print besked hver 1s
//----------------------------------------------------------------------------------------------------//
//------------------------------Variables to CircPump if it has been stopped to long-----------------//
long lastTimeBeginOn = 0;
long lastTimeBeginOff = 0;
long lastTimeFinishedInterval = 0;
bool CirPumpOldState = 0;
long TimeToBeOn = 100000;//----Time the CircPump will be running if it has been stopped for too long (10m=600000 millis)
long MaxTimeOff = 200000;//---Max time the pump can be stopped before turning on the CircPump (12t=43200000 millis)
//---------------------------------------------------------------------------------------------------//
//For FRAM
Adafruit_FRAM_I2C fram = Adafruit_FRAM_I2C();
bool FRAM_OK = false;
long lastFRAMwrite = 0;
//Global vars
float Out_12vdc_V = 0.0;
float Out_12vdc_mA = 0.0;
float Servo_V = 0.0;
float Servo_mA = 0.0;
float Arduino_V = 0.0;
float Arduino_mA = 0.0;
float average_Out_Temp = 0.0;
float Case_Set = 0.0;
float Boiler_Set = 0.0;
float output_Percentage = 0.0;
float Case_Set_Percentage = 0.0;
bool Boiler_pin_cache_old = false;
//Application cycle time monitor
unsigned long Time_Start = 0;
unsigned long Time_TFT_loop = 0;
unsigned long Time_Sensors_loop = 0;
unsigned long Time_IO_loop = 0;
unsigned long Time_Counter_loop = 0;
unsigned long Time_FRAM_updater = 0;
unsigned long Time_Serial_updater = 0;
unsigned int Time_TFT_loop_LAST = 0;
unsigned int Time_Sensors_loop_LAST = 0;
unsigned int Time_IO_loop_LAST = 0;
unsigned int Time_Counter_loop_LAST = 0;
unsigned int Time_FRAM_updater_LAST = 0;
unsigned int Time_Serial_updater_LAST = 0;
unsigned int CycleTime_SUM_RUNS = 0;
unsigned long Time_TFT_loop_SUM = 0;
unsigned long Time_Sensors_loop_SUM = 0;
unsigned long Time_IO_loop_SUM = 0;
unsigned long Time_Counter_loop_SUM = 0;
unsigned long Time_FRAM_updater_SUM = 0;
unsigned long Time_Serial_updater_SUM = 0;
unsigned long Time_TFT_loop_AVG = 0;
unsigned long Time_Sensors_loop_AVG = 0;
unsigned long Time_IO_loop_AVG = 0;
unsigned long Time_Counter_loop_AVG = 0;
unsigned long Time_FRAM_updater_AVG = 0;
unsigned long Time_Serial_updater_AVG = 0;
void FRAM_reset(){
//---timeBufferTimer_Boiler_Flame
fram.write(0, 0);
fram.write(1, 0);
//---timeBufferTimer_CircPump
fram.write(2, 0);
fram.write(3, 0);
//---timeBufferMinutter_Boiler_Flame
fram.write(4, 0);
//---timeBufferMinutter_CircPump
fram.write(5, 0);
//---timeBufferSekunder_Boiler_Flame
fram.write(6, 0);
//---timeBufferSekunder_CircPump
fram.write(7, 0);
//---CounterTurnOnTimes_Boiler_Flame
fram.write(8, 0);
fram.write(9, 0);
//---CounterTurnOnTimes_CircPump
fram.write(10, 0);
fram.write(11, 0);
}
void FRAM_reset_only_CircPump_Time(){
//---timeBufferTimer_Boiler_Flame
//fram.write(0, 0);
//fram.write(1, 0);
//---timeBufferTimer_CircPump
fram.write(2, 0);
fram.write(3, 0);
//---timeBufferMinutter_Boiler_Flame
//fram.write(4, 0);
//---timeBufferMinutter_CircPump
fram.write(5, 0);
//---timeBufferSekunder_Boiler_Flame
//fram.write(6, 0);
//---timeBufferSekunder_CircPump
fram.write(7, 0);
//---CounterTurnOnTimes_Boiler_Flame
//fram.write(8, 0);
//fram.write(9, 0);
//---CounterTurnOnTimes_CircPump
//fram.write(10, 0);
//fram.write(11, 0);
}
void FRAM_reset_only_Boiler_Time(){
//---timeBufferTimer_Boiler_Flame
fram.write(0, 0);
fram.write(1, 0);
//---timeBufferTimer_CircPump
//fram.write(2, 0);
//fram.write(3, 0);
//---timeBufferMinutter_Boiler_Flame
fram.write(4, 0);
//---timeBufferMinutter_CircPump
//fram.write(5, 0);
//---timeBufferSekunder_Boiler_Flame
fram.write(6, 0);
//---timeBufferSekunder_CircPump
//fram.write(7, 0);
//---CounterTurnOnTimes_Boiler_Flame
//fram.write(8, 0);
//fram.write(9, 0);
//---CounterTurnOnTimes_CircPump
//fram.write(10, 0);
//fram.write(11, 0);
}
DeviceAddress Boiler_Temp_addr = {0x28, 0x61, 0x64, 0x34, 0x89, 0x59, 0xFD, 0x02};
DeviceAddress FlowF_Temp_addr = {0x28, 0x61, 0x64, 0x34, 0x89, 0x63, 0x3A, 0x81};
DeviceAddress FlowR_Temp_addr = {0x28, 0x26, 0xF4, 0x36, 0x00, 0x00, 0x00, 0xE2};
DeviceAddress Cwater_Temp_addr = {0x28, 0x52, 0x53, 0x37, 0x00, 0x00, 0x00, 0x4B};
DeviceAddress Wwater_Temp_addr = {0x28, 0x2F, 0x9C, 0x35, 0x00, 0x00, 0x00, 0xD3};
DeviceAddress Out_Temp_Sensor1_addr = {0x28, 0x33, 0x24, 0x34, 0x00, 0x00, 0x00, 0x0B};
DeviceAddress Out_Temp_Sensor2_addr = {0x28, 0xB2, 0xDE, 0x37, 0x00, 0x00, 0x00, 0x45};
DeviceAddress Case_Temp_addr = {0x28, 0x1C, 0xAF, 0x36, 0x00, 0x00, 0x00, 0x25};
DeviceAddress Chimney_Temp_addr = {0x28, 0xCB, 0x94, 0x38, 0x00, 0x00, 0x00, 0x85};
void setup() {
Serial.begin(115200);
Wire.begin();
while (!Serial);
RTC.begin();
tft.begin();
tft.setRotation(3);
tft.fillScreen(0);
pinMode(CaseFan_PIN, OUTPUT);
pinMode(Stop_Pump_Servo_PIN, INPUT);
pinMode(CircPump_PIN, OUTPUT);
pinMode(Boiler_Flame_PIN, INPUT);
pinMode(Boiler_PIN, OUTPUT);
pinMode(MENU_FORWARD_BUTTON_PIN, INPUT);
pinMode(MENU_BACK_BUTTON_PIN, INPUT);
//----------------------------Change PWM freq to CaseFan--------------------------------------------//
TCCR2B &= ~ _BV (CS22); // cancel pre-scaler of 64 -----------PWM freq to fan
TCCR2B |= _BV (CS20); // no pre-scaler----------------------PWM freq to fan
analogWrite (CaseFan_PIN, 78); // 78,4 % duty cycle--------PWM freq to fan
//-------------------------------------------------------------------------------------------------//
ina226_Out_12vdc.init();
ina226_Servo.init();
ina226_Arduino.init();
ina226_Out_12vdc.setResistorRange(0.010,6.0); //-----------------(0).(choose shunt resistor).(Max current)
ina226_Servo.setResistorRange(0.010,6.0); //---------------------(0).(choose shunt resistor).(Max current)
ina226_Arduino.setResistorRange(0.010,6.0); //-------------------(0).(choose shunt resistor).(Max current)
ina226_Out_12vdc.setCorrectionFactor(1.00);//---------------------Offset for INA226(only current)
ina226_Servo.setCorrectionFactor(1.00);//-------------------------Offset for INA226(only current)
ina226_Arduino.setCorrectionFactor(1.00);//-----------------------Offset for INA226(only current)
servo.attach(SERVO_PIN);
myPID.SetMode(AUTOMATIC);
myPID.SetOutputLimits(50, 135); //-------------------------------------------Max/Min output Shunt_Set(Servo) remenber to set line 95 too
sensors.begin();
//INIT FRAM
if (fram.begin()) { // you can stick the new i2c addr in here, e.g. begin(0x51);
Serial.println("Found I2C FRAM");
FRAM_OK = true;
} else {
Serial.println("I2C FRAM not identified ... check your connections?\r\n");
}
//RESET FRAM DATA TO ZERO:
//FRAM_reset(); //Kommenter denne linje ud, hvis timetællerne ikke skal slettes!
//FRAM_reset_only_CircPump_Time();//Kommenter denne linje ud, hvis timetællerne circ ikke skal slettes!
//FRAM_reset_only_Boiler_Time();//Kommenter denne linje ud, hvis boiler timetællerne ikke skal slettes!
if(FRAM_OK){
//Move data from FRAM to variables
/*VARIABLE : FRAM address
unsigned int timeBufferTimer_Boiler_Flame : 0-1 (2 bytes)
unsigned int timeBufferTimer_CircPump : 2-3 (2 bytes)
byte timeBufferMinutter_Boiler_Flame : 4
byte timeBufferMinutter_CircPump : 5
byte timeBufferSekunder_Boiler_Flame : 6
byte timeBufferSekunder_CircPump : 7
unsigned int CounterTurnOnTimes_Boiler_Flame: 8-9 (2 bytes)
unsigned int CounterTurnOnTimes_CircPump = 0: 10-11 (2 bytes)
*/
//---timeBufferTimer_Boiler_Flame
uint8_t byteArray_timeBufferTimer_Boiler_Flame[2];
byteArray_timeBufferTimer_Boiler_Flame[0] = fram.read(0);
byteArray_timeBufferTimer_Boiler_Flame[1] = fram.read(1);
timeBufferTimer_Boiler_Flame |= (uint32_t)byteArray_timeBufferTimer_Boiler_Flame[0];
timeBufferTimer_Boiler_Flame |= (uint32_t)byteArray_timeBufferTimer_Boiler_Flame[1] << 8;
//---timeBufferTimer_CircPump
uint8_t byteArray_timeBufferTimer_CircPump[2];
byteArray_timeBufferTimer_CircPump[0] = fram.read(2);
byteArray_timeBufferTimer_CircPump[1] = fram.read(3);
timeBufferTimer_CircPump |= (uint32_t)byteArray_timeBufferTimer_CircPump[0];
timeBufferTimer_CircPump |= (uint32_t)byteArray_timeBufferTimer_CircPump[1] << 8;
//---timeBufferMinutter_Boiler_Flame
timeBufferMinutter_Boiler_Flame = fram.read(4);
//---timeBufferMinutter_CircPump
timeBufferMinutter_CircPump = fram.read(5);
//---timeBufferSekunder_Boiler_Flame
timeBufferSekunder_Boiler_Flame = fram.read(6);
//---timeBufferSekunder_CircPump
timeBufferSekunder_CircPump = fram.read(7);
//---CounterTurnOnTimes_Boiler_Flame
uint8_t byteArray_CounterTurnOnTimes_Boiler_Flame[2];
byteArray_CounterTurnOnTimes_Boiler_Flame[0] = fram.read(8);
byteArray_CounterTurnOnTimes_Boiler_Flame[1] = fram.read(9);
CounterTurnOnTimes_Boiler_Flame |= (uint32_t)byteArray_CounterTurnOnTimes_Boiler_Flame[0];
CounterTurnOnTimes_Boiler_Flame |= (uint32_t)byteArray_CounterTurnOnTimes_Boiler_Flame[1] << 8;
//---CounterTurnOnTimes_CircPump
uint8_t byteArray_CounterTurnOnTimes_CircPump[2];
byteArray_CounterTurnOnTimes_CircPump[0] = fram.read(10);
byteArray_CounterTurnOnTimes_CircPump[1] = fram.read(11);
CounterTurnOnTimes_CircPump |= (uint32_t)byteArray_CounterTurnOnTimes_CircPump[0];
CounterTurnOnTimes_CircPump |= (uint32_t)byteArray_CounterTurnOnTimes_CircPump[1] << 8;
}
//Initiate DS18B20 sensors
sensors.setResolution(Boiler_Temp_addr , 9);
sensors.setResolution(FlowF_Temp_addr , 9);
sensors.setResolution(FlowR_Temp_addr , 9);
sensors.setResolution(Cwater_Temp_addr , 9);
sensors.setResolution(Wwater_Temp_addr , 9);
sensors.setResolution(Out_Temp_Sensor1_addr , 9);
sensors.setResolution(Out_Temp_Sensor2_addr , 9);
sensors.setResolution(Case_Temp_addr , 9);
sensors.setResolution(Chimney_Temp_addr , 9);
}
char dateString[] = "xx-xx-xxxx xx:xx:xx";//Alle x bliver erstattet senere.
//---------Topline all page---------
float pageFloatBuffer_0 = 0;
//----------------------------------
//----------Buffer page 1-----------
float pageFloatBuffer_1 = 0;
float pageFloatBuffer_2 = 0;
float pageFloatBuffer_3 = 0;
float pageFloatBuffer_4 = 0;
float pageFloatBuffer_5 = 0;
float pageFloatBuffer_6 = 0;
//---------------------------------
//----------Buffer page 2----------
unsigned int pageUIntBuffer_7 = 0;
byte pageByteBuffer_8 = 0;
byte pageByteBuffer_9 = 0;
float pageFloatBuffer_10 = 0;
unsigned int pageUIntBuffer_11 = 0;
byte pageByteBuffer_12 = 0;
byte pageByteBuffer_13 = 0;
float pageFloatBuffer_14 = 0;
//--------------------------------
//----------Buffer page 3---------
float pageFloatBuffer_15 = 0;
float pageFloatBuffer_16 = 0;
float pageFloatBuffer_17 = 0;
float pageFloatBuffer_18 = 0;
//--------------------------------
//----------Buffer page 4---------
float pageFloatBuffer_19 = 0;
float pageFloatBuffer_20 = 0;
float pageFloatBuffer_21 = 0;
float pageFloatBuffer_22 = 0;
float pageFloatBuffer_23 = 0;
//-------------------------------
//----------Buffer page 5--------
float pageFloatBuffer_24 = 0;
float pageFloatBuffer_25 = 0;
float pageFloatBuffer_26 = 0;
float pageFloatBuffer_27 = 0;
float pageFloatBuffer_28 = 0;
//-------------------------------
//----------Buffer page 6--------
float pageFloatBuffer_29 = 0;
float pageFloatBuffer_30 = 0;
//-------------------------------
//----------Buffer page 7--------
float pageFloatBuffer_31 = 0;
float pageFloatBuffer_32 = 0;
float pageFloatBuffer_33 = 0;
float pageFloatBuffer_34 = 0;
float pageFloatBuffer_35 = 0;
float pageFloatBuffer_36 = 0;
//-------------------------------
/*//---------Buffer page 8---------
float pageFloatBuffer_37 = 0;
float pageFloatBuffer_38 = 0;
float pageFloatBuffer_39 = 0;
float pageFloatBuffer_40 = 0;
float pageFloatBuffer_41 = 0;
float pageFloatBuffer_42 = 0;
//-------------------------------*/
void updatePage(){
//---------- Top line on all page--------
tft.setCursor(245, 0);
tft.setTextSize(2);
//tft.print("4-12-2024 11:42:10");
//Slet gammelt print ved at skrive gammel tekst med baggrundsfarve
tft.setTextColor(0x0000);
tft.print(dateString);//tft.print("4-12-2024 11:42:10");
char bufferString[6];
int time_buffer = RTC.getDay();
itoa(time_buffer, bufferString, 10);//itoa(heltal som skal konverteres, String buffer, 10 tals systemet);
if(time_buffer < 10){
dateString[0] = ' '; // 0x-xx-xxxx xx:xx:xx
dateString[1] = bufferString[0]; // xN-xx-xxxx xx:xx:xx
}else{
dateString[0] = bufferString[0]; // Nx-xx-xxxx xx:xx:xx
dateString[1] = bufferString[1]; // xN-xx-xxxx xx:xx:xx
}
//dateString[2] = '-';//Allerede gjort ved initiering
time_buffer = RTC.getMonth();
itoa(time_buffer, bufferString, 10);//itoa(heltal som skal konverteres, String buffer, 10 tals systemet);
if(time_buffer < 10){
dateString[3] = ' '; // xx-0x-xxxx xx:xx:xx
dateString[4] = bufferString[0]; // xx-xN-xxxx xx:xx:xx
}else{
dateString[3] = bufferString[0]; // xx-0x-xxxx xx:xx:xx
dateString[4] = bufferString[1]; // xx-xN-xxxx xx:xx:xx
}
//dateString[5] = '-';//Allerede gjort ved initiering
time_buffer = RTC.getYear();
itoa(time_buffer, bufferString, 10);//itoa(heltal som skal konverteres, String buffer, 10 tals systemet);
dateString[6] = bufferString[0]; // xx-xx-Nxxx xx:xx:xx
dateString[7] = bufferString[1]; // xx-xx-xNxx xx:xx:xx
dateString[8] = bufferString[2]; // xx-xx-xxNx xx:xx:xx
dateString[9] = bufferString[3]; // xx-xx-xxxN xx:xx:xx
//dateString[10] = ' ';//Allerede gjort ved initiering
time_buffer = RTC.getHours();
itoa(time_buffer, bufferString, 10);//itoa(heltal som skal konverteres, String buffer, 10 tals systemet);
if(time_buffer < 10){
dateString[11] = '0'; // xx-xx-xxxx 0x:xx:xx
dateString[12] = bufferString[0]; // xx-xx-xxxx xN:xx:xx
}else{
dateString[11] = bufferString[0]; // xx-xx-xxxx Nx:xx:xx
dateString[12] = bufferString[1]; // xx-xx-xxxx xN:xx:xx
}
//dateString[13] = ':';//Allerede gjort ved initiering
time_buffer = RTC.getMinutes();
itoa(time_buffer, bufferString, 10);//itoa(heltal som skal konverteres, String buffer, 10 tals systemet);
if(time_buffer < 10){
dateString[14] = '0'; // xx-xx-xxxx xx:0x:xx
dateString[15] = bufferString[0]; // xx-xx-xxxx xx:xN:xx
}else{
dateString[14] = bufferString[0]; // xx-xx-xxxx xx:Nx:xx
dateString[15] = bufferString[1]; // xx-xx-xxxx xx:xN:xx
}
//dateString[16] = ':';//Allerede gjort ved initiering
time_buffer = RTC.getSeconds();
itoa(time_buffer, bufferString, 10);//itoa(heltal som skal konverteres, String buffer, 10 tals systemet);
if(time_buffer < 10){
dateString[17] = '0'; // xx-xx-xxxx xx:xx:0x
dateString[18] = bufferString[0]; // xx-xx-xxxx xx:xx:xN
}else{
dateString[17] = bufferString[0]; // xx-xx-xxxx xx:xx:Nx
dateString[18] = bufferString[1]; // xx-xx-xxxx xx:xx:xN
}
//Printer ny dato og tid
tft.setCursor(245, 0);
tft.setTextColor(0xFFFF);
tft.print(dateString);//tft.print("4-12-2024 11:42:10");
//ooooooooooooooooooooooooooooooooooooooooooooooooooooo
//----------Top line Out_Temp----------
//ERASE OLD
tft.setCursor(60, 0);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(2);
tft.print("Out:");
tft.print(pageFloatBuffer_0);
tft.write(0xF7);
tft.print("C");
//PRINT NEW
tft.setCursor(60, 0);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(2);
tft.print("Out:");
pageFloatBuffer_0 = average_Out_Temp;
tft.print(average_Out_Temp);
tft.write(0xF7);
tft.print("C");
//ooooooooooooooooooooooooooooooooooooooooooooooooooooo
if (currentPage == 1) { //ooooooooooooooooooooooooooooooo
//--------- Page 1, Box 1--------
bool Boiler_pin_cache = digitalRead(Boiler_PIN);
if(Boiler_pin_cache_old != Boiler_pin_cache){
if(Boiler_pin_cache){//HIGH == ON
tft.fillRoundRect(4, 34, 472, 72, 6, ST7796S_RED);
}else{//BOILER OFF
tft.fillRoundRect(4, 34, 472, 72, 6, ST7796S_BLACK);
}
tft.setCursor(12, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Boiler:");
tft.setCursor(12, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Set:");
Boiler_pin_cache_old = Boiler_pin_cache;
}
//ERASE OLD
tft.setCursor(270, 40);
if(Boiler_pin_cache){//HIGH == ON
tft.setTextColor(ST7796S_RED);
}else{//BOILER OFF
tft.setTextColor(ST7796S_BLACK);
}
tft.setTextSize(3);
tft.print(pageFloatBuffer_1);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(270, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_1 = Boiler_Temp;
tft.print(Boiler_Temp);
tft.write(0xF7);
tft.println("C");
//ERASE OLD
tft.setCursor(270, 76);
if(Boiler_pin_cache){//HIGH == ON
tft.setTextColor(ST7796S_RED);
}else{//BOILER OFF
tft.setTextColor(ST7796S_BLACK);
}
tft.setTextSize(3);
tft.print(pageFloatBuffer_2);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(270, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_2 = Boiler_Set;
tft.print(Boiler_Set);
tft.write(0xF7);
tft.println("C");
//--------------------------------
//---------Page 1, Box 2----------
//ERASE OLD
tft.setCursor(270, 132);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_3);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(270, 132);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_3 = FlowF_Temp;
tft.print(FlowF_Temp);
tft.write(0xF7);
tft.println("C");
//ERASE OLD
tft.setCursor(270, 168);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_4);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(270, 168);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_4 = FlowF_Set;
tft.print(FlowF_Set);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//----------Page 1, Box 3----------
//ERASE OLD
tft.setCursor(270, 224);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_5);
tft.println("% open");
//PRINT NEW
tft.setCursor(270, 224);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_5 = output_Percentage;
tft.print(output_Percentage);
tft.println("% open");
//--------------------------------
//----------Page 1, Box 4---------
//ERASE OLD
tft.setCursor(270, 280);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_6);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(270, 280);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_6 = Chimney_Temp;
tft.print(Chimney_Temp);
tft.write(0xF7);
tft.println("C");
//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
}
else if (currentPage == 2) { //ooooooooooooooooooooooooooooooo
//---------Page 2, Box 1--------
//ERASE OLD
tft. setCursor(280, 76);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageUIntBuffer_7);
tft.print(":");
tft.print((int)pageByteBuffer_8);
tft.print(":");
tft.print((int)pageByteBuffer_9);
tft.println(" h");
//PRINT NEW
tft. setCursor(280, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageUIntBuffer_7 = timeBufferTimer_Boiler_Flame;
tft.print(timeBufferTimer_Boiler_Flame);
tft.print(":");
pageByteBuffer_8 = timeBufferMinutter_Boiler_Flame;
tft.print((int)timeBufferMinutter_Boiler_Flame);
tft.print(":");
pageByteBuffer_9 = timeBufferSekunder_Boiler_Flame;
tft.print((int)timeBufferSekunder_Boiler_Flame);
tft.println(" h");
//ERASE OLD
tft. setCursor(280, 112);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_10);
//PRINT NEW
tft. setCursor(280, 112);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_10 = CounterTurnOnTimes_Boiler_Flame;
tft.print(CounterTurnOnTimes_Boiler_Flame);
//-----------------------------------
//------------Page 2, Box 2----------
//ERASE OLD
tft. setCursor(280, 204);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageUIntBuffer_11);
tft.print(":");
tft.print((int)pageByteBuffer_12);
tft.print(":");
tft.print((int)pageByteBuffer_13);
tft.println(" h");
//PRINT NEW
tft. setCursor(280, 204);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageUIntBuffer_11 = timeBufferTimer_CircPump;
tft.print(timeBufferTimer_CircPump);
tft.print(":");
pageByteBuffer_12 = timeBufferMinutter_CircPump;
tft.print((int)timeBufferMinutter_CircPump);
tft.print(":");
pageByteBuffer_13 = timeBufferSekunder_CircPump;
tft.print((int)timeBufferSekunder_CircPump);
tft.println(" h");
//ERASE OLD
tft. setCursor(280, 240);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_14);
//PRINT NEW
tft. setCursor(280, 240);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_14 = CounterTurnOnTimes_CircPump;
tft.print(CounterTurnOnTimes_CircPump);
//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
}
else if (currentPage == 3) { //ooooooooooooooooooooooooooooooo
//-----------Page 3, Box 1----------
//ERASE OLD
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_15);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_15 = Cwater_Temp;
tft.print(Cwater_Temp);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//----------Page 3, Box 2----------
//ERASE OLD
tft.setCursor(280, 96);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_16);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 96);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_16 = Wwater_Temp;
tft.print(Wwater_Temp);
tft.write(0xF7);
tft.println("C");
//--------------------------------
//----------Page 3, Box 3---------
//ERASE OLD
tft.setCursor(280, 152);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_17);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 152);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_17 = Boiler_Temp;
tft.print(Boiler_Temp);
tft.write(0xF7);
tft.println("C");
//ERASE OLD
tft.setCursor(280, 188);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_18);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 188);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_18 = Boiler_Set;
tft.print(Boiler_Set);
tft.write(0xF7);
tft.println("C");
//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
}
else if (currentPage == 4) { //ooooooooooooooooooooooooooooooo
//----------Page 4, Box 1----------
//ERASE OLD
tft.setCursor(280,40);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_19);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280,40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_19 = FlowF_Temp;
tft.print(FlowF_Temp);
tft.write(0xF7);
tft.println("C");
//ERASE OLD
tft.setCursor(280, 76);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_20);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_20 = FlowF_Set;
tft.print(FlowF_Set);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//-----------Page 4, Box 2---------
//ERASE OLD
tft.setCursor(280, 132);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_21);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 132);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_21 = FlowR_Temp;
tft.print(FlowR_Temp);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//----------Page 4, Box 3----------
//ERASE OLD
tft. setCursor(280, 224);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(output_Percentage);
tft.print("%");
//PRINT NEW
tft. setCursor(280, 224);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_22 = output_Percentage;
tft.print(output_Percentage);
tft.print("%");
//ERASE OLD
tft. setCursor(280, 260);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_23);
tft.write(0xF7);
//PRINT NEW
tft. setCursor(280, 260);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_23 = output;
tft.print(output);
tft.write(0xF7);
//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
}
else if (currentPage == 5) { //ooooooooooooooooooooooooooooooo
//----------Page 5, Box 1-----------
//ERASE OLD
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_24);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_24 = Out_Temp_Sensor1;
tft.print(Out_Temp_Sensor1);
tft.write(0xF7);
tft.println("C");
//----------------------------------
//----------Page 5, Box 2-----------
//ERASE OLD
tft.setCursor(280, 96);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_25);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 96);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_25 = Out_Temp_Sensor2;
tft.print(Out_Temp_Sensor2);
tft.write(0xF7);
tft.println("C");
//----------------------------------
//----------Page 5, Box 3-----------
//ERASE OLD
tft.setCursor(280, 152);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_26);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 152);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_26 = average_Out_Temp;
tft.print(average_Out_Temp);
tft.write(0xF7);
tft.println("C");
//----------------------------------
//----------Page 5, Box 4-----------
//ERASE OLD
tft.setCursor(280, 208);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_27);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 208);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_27 = Boiler_Set;
tft.print(Boiler_Set);
tft.write(0xF7);
tft.println("C");
//----------------------------------
//----------Page 5, Box 5-----------
//ERASE OLD
tft.setCursor(280, 264);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_28);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 264);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_28 = FlowF_Set;
tft.print(FlowF_Set);
tft.write(0xF7);
tft.println("C");
//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
}
else if (currentPage == 6) { //ooooooooooooooooooooooooooooooo
//----------Page 6, Box 1----------
//ERASE OLD
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_29);
tft.write(0xF7);
tft.println("C");
//PRINT NEW
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_29 = Case_Temp;
tft.print(Case_Temp);
tft.write(0xF7);
tft.println("C");
//ERASE OLD
tft.setCursor(280, 76);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_30);
tft.println("%");
//PRINT NEW
tft.setCursor(280, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_30 = Case_Set_Percentage;
tft.print(Case_Set_Percentage);
tft.println("%");
//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
}
else if (currentPage == 7) { //ooooooooooooooooooooooooooooooo
//----------Page 7, Box 1-----------
//ERASE OLD
tft.setCursor(90, 76);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_31);
tft.println(" Volt.");
//PRINT NEW
tft.setCursor(90, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_31 = Out_12vdc_V;
tft.print(Out_12vdc_V);
tft.println(" Volt.");
//ERASE OLD
tft.setCursor(330, 76);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_32);
tft.println(" A.");
//PRINT NEW
tft.setCursor(330, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_32 = Out_12vdc_mA;
tft.print(Out_12vdc_mA);
tft.println(" A.");
//---------------------------------
//----------Page 7, Box 2----------
//ERASE OLD
tft.setCursor(90, 168);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_33);
tft.println(" Volt.");
//PRINT NEW
tft.setCursor(90, 168);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_33 = Arduino_V;
tft.print(Arduino_V);
tft.println(" Volt.");
//ERASE OLD
tft.setCursor(330, 168);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_34);
tft.println(" A.");
//PRINT NEW
tft.setCursor(330, 168);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_34 = Arduino_mA;
tft.print(Arduino_mA);
tft.println(" A.");
//---------------------------------
//----------Page 7, Box 3----------
//ERASE OLD
tft.setCursor(90, 260);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_35);
tft.println(" Volt.");
//PRINT NEW
tft.setCursor(90, 260);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_35 = Servo_V;
tft.print(Servo_V);
tft.println(" Volt.");
//ERASE OLD
tft.setCursor(330, 260);
tft.setTextColor(ST7796S_BLACK);
tft.setTextSize(3);
tft.print(pageFloatBuffer_36);
tft.println(" A.");
//PRINT NEW
tft.setCursor(330, 260);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_36 = Servo_mA;
tft.print(Servo_mA);
tft.println(" A.");
//oooooooooooooooooooooooooooooooooooooooooooooooooooooo
}
}
void changePage(int page) { //function to change the page based on the current page number
tft.fillScreen(0); //clear the screen
//---------- Top line on all page--------
tft.setCursor(3, 0);
tft.setTextColor(0xFFFF);
tft.setTextSize(1);
tft.print("Page_");
tft.print(currentPage);
tft.setCursor(60, 0);
tft.setTextColor(0xFFFF);
tft.setTextSize(2);
tft.print("Out:");
pageFloatBuffer_0 = average_Out_Temp;
tft.print(average_Out_Temp);
tft.write(0xF7);
tft.print("C");
if (page == 1) { //if the current page is 1
//--------- Page 1, Box 1--------
tft.fillRoundRect(0, 30, 480, 80, 10, 0xFD20);//Orange
bool Boiler_pin_cache = digitalRead(Boiler_PIN);
if(Boiler_pin_cache){//HIGH == ON
tft.fillRoundRect(4, 34, 472, 72, 6, ST7796S_RED);
}else{//BOILER OFF
tft.fillRoundRect(4, 34, 472, 72, 6, ST7796S_BLACK);
}
Boiler_pin_cache_old = Boiler_pin_cache;
tft.setCursor(12, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Boiler:");
tft.setCursor(270, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_1 = Boiler_Temp;
tft.print(Boiler_Temp);
tft.write(0xF7);
tft.println("C");
tft.setCursor(12, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Set:");
tft.setCursor(270, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_2 = Boiler_Set;
tft.print(Boiler_Set);
tft.write(0xF7);
tft.println("C");
//--------------------------------
//---------Page 1, Box 2----------
tft.fillRoundRect(0, 122, 480, 80, 10, 0xF800);//Red
tft.fillRoundRect(4, 126, 472, 72, 6, ST7796S_BLACK);
tft.setCursor(12, 132);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("FlowF:");
tft.setCursor(270, 132);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_3 = FlowF_Temp;
tft.print(FlowF_Temp);
tft.write(0xF7);
tft.println("C");
tft.setCursor(12, 168);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Set:");
tft.setCursor(270, 168);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_4 = FlowF_Set;
tft.print(FlowF_Set);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//----------Page 1, Box 3----------
tft.fillRoundRect(0, 214, 480, 44, 10, 0x780F);//Purple
tft.fillRoundRect(4, 218, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 224);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Shunt:");
tft.setCursor(270, 224);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_5 = output_Percentage;
tft.print(output_Percentage);
tft.println("% open");
//-----------Page 1, Box 4---------
tft.fillRoundRect(0, 270, 480, 44, 10, 0xFFE0);//Yellow
tft.fillRoundRect(4, 274, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 280);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Chimney");
tft.setCursor(270, 280);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_6 = Chimney_Temp;
tft.print(Chimney_Temp);
tft.write(0xF7);
tft.println("C");
//--------------------------------
}
else if (page == 2) { //if the current page is 2
//----------Page 2, Box 1----------
tft.fillRoundRect(0, 30, 480, 116, 10, 0xFD20);//Orange
tft.fillRoundRect(4, 34, 472, 108, 6, ST7796S_BLACK);
tft.setCursor(12, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Boiler Flame.");
tft.setCursor(12, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("On Time:");
tft. setCursor(280, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageUIntBuffer_7 = timeBufferTimer_Boiler_Flame;
tft.print(timeBufferTimer_Boiler_Flame);
tft.print(":");
pageByteBuffer_8 = timeBufferMinutter_Boiler_Flame;
tft.print((int)timeBufferMinutter_Boiler_Flame);
tft.print(":");
pageByteBuffer_9 = timeBufferSekunder_Boiler_Flame;
tft.print((int)timeBufferSekunder_Boiler_Flame);
tft.println(" h");
tft.setCursor(12, 112);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Start Counter:");
tft. setCursor(280, 112);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_10 = CounterTurnOnTimes_Boiler_Flame;
tft.print(CounterTurnOnTimes_Boiler_Flame);
//--------------------------------
//----------Page 2, Box2----------
tft.fillRoundRect(0, 158, 480, 116, 10, 0xF800);//Red
tft.fillRoundRect(4, 162, 472, 108, 6, ST7796S_BLACK);
tft.setCursor(12, 168);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("CircPump.");
tft.setCursor(12, 204);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("On Time:");
tft. setCursor(280, 204);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageUIntBuffer_11 = timeBufferTimer_CircPump;
tft.print(timeBufferTimer_CircPump);
tft.print(":");
pageByteBuffer_12 = timeBufferMinutter_CircPump;
tft.print((int)timeBufferMinutter_CircPump);
tft.print(":");
pageByteBuffer_13 = timeBufferSekunder_CircPump;
tft.print((int)timeBufferSekunder_CircPump);
tft.println(" h");
tft.setCursor(12, 240);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Start Counter:");
tft. setCursor(280, 240);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_14 = CounterTurnOnTimes_CircPump;
tft.print(CounterTurnOnTimes_CircPump);
//---------------------------------
}
else if (page == 3) { //if the current page is 2
//----------Page 3, Box 1----------
tft.fillRoundRect(0, 30, 480, 44, 10, 0x001F);//Blue
tft.fillRoundRect(4, 34, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Cwater");
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_15 = Cwater_Temp;
tft.print(Cwater_Temp);
tft.write(0xF7);
tft.println("C");
//--------------------------------
//----------Page 3, Box 2---------
tft.fillRoundRect(0, 86, 480, 44, 10, 0xF800);//Red
tft.fillRoundRect(4, 90, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 96);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Wwater:");
tft.setCursor(280, 96);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_16 = Wwater_Temp;
tft.print(Wwater_Temp);
tft.write(0xF7);
tft.println("C");
//--------------------------------
//----------Page 3, Box 3---------
tft.fillRoundRect(0, 142, 480, 80, 10, 0xFD20);//Orange
tft.fillRoundRect(4, 146, 472, 72, 6, ST7796S_BLACK);
tft.setCursor(12, 152);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Boiler:");
tft.setCursor(280, 152);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_17 = Boiler_Temp;
tft.print(Boiler_Temp);
tft.write(0xF7);
tft.println("C");
tft.setCursor(12, 188);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Set:");
tft.setCursor(280, 188);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_18 = Boiler_Set;
tft.print(Boiler_Set);
tft.write(0xF7);
tft.println("C");
//--------------------------------
}
else if (page == 4) { //if the current page is 2
//----------Page 4, Box 1----------
tft.fillRoundRect(0, 30, 480, 80, 10, 0xF800);//Red
tft.fillRoundRect(4, 34, 472, 72, 6, ST7796S_BLACK);
tft.setCursor(12, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("FlowF:");
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_19 = FlowF_Temp;
tft.print(FlowF_Temp);
tft.write(0xF7);
tft.println("C");
tft.setCursor(12, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Set:");
tft.setCursor(280, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_20 = FlowF_Set;
tft.print(FlowF_Set);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//----------Page 4, Box 2----------
tft.fillRoundRect(0, 122, 480, 44, 10, 0x001F);//Blue
tft.fillRoundRect(4, 126, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 132);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("FlowR:");
tft.setCursor(280, 132);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_21 = FlowR_Temp;
tft.print(FlowR_Temp);
tft.write(0xF7);
tft.println("C");
//--------------------------------
//---------Page 4, Box 3----------
tft.fillRoundRect(0, 178, 480, 116, 10, 0x780F);//Purple
tft.fillRoundRect(4, 182, 472, 108, 6, ST7796S_BLACK);
tft.setCursor(12, 188);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Shunt.");
tft.setCursor(12, 224);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Open:");
tft. setCursor(280, 224);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_22 = output_Percentage;
tft.print(output_Percentage);
tft.print("%");
tft.setCursor(12, 260);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Angel pos:");
tft. setCursor(280, 260);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_23 = output;
tft.print(output);
tft.write(0xF7);
//---------------------------------
}
else if (page == 5) { //if the current page is 2
//----------Page 5, Box 1----------
tft.fillRoundRect(0, 30, 480, 44, 10, 0xC618);//LightGrey
tft.fillRoundRect(4, 34, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Out sensor 1:");
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_24 = Out_Temp_Sensor1;
tft.print(Out_Temp_Sensor1);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//----------Page 5, Box 2----------
tft.fillRoundRect(0, 86, 480, 44, 10, 0xC618);//LightGrey
tft.fillRoundRect(4, 90, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 96);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Out sensor 2:");
tft.setCursor(280, 96);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_25 = Out_Temp_Sensor2;
tft.print(Out_Temp_Sensor2);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//----------Page 5, Box 3----------
tft.fillRoundRect(0, 142, 480, 44, 10, 0xC618);//LightGrey
tft.fillRoundRect(4, 146, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 152);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Out average:");
tft.setCursor(280, 152);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_26 = average_Out_Temp;
tft.print(average_Out_Temp);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//----------Page 5, Box 4----------
tft.fillRoundRect(0, 198, 480, 44, 10, 0xFD20);//Orange
tft.fillRoundRect(4, 202, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 208);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Boiler set:");
tft.setCursor(280, 208);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_27 = Boiler_Set;
tft.print(Boiler_Set);
tft.write(0xF7);
tft.println("C");
//---------------------------------
//----------Page 5, Box 5----------
tft.fillRoundRect(0, 254, 480, 44, 10, 0xF800);//Red
tft.fillRoundRect(4, 258, 472, 36, 6, ST7796S_BLACK);
tft.setCursor(12, 264);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("FlowF set:");
tft.setCursor(280, 264);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_28 = FlowF_Set;
tft.print(FlowF_Set);
tft.write(0xF7);
tft.println("C");
//---------------------------------
}
else if (page == 6) { //if the current page is 2
//----------Page 6, Box 1----------
tft.fillRoundRect(0, 30, 480, 80, 10, ST7796S_GREEN);
tft.fillRoundRect(4, 34, 472, 72, 6, ST7796S_BLACK);
tft.setCursor(12, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Case:");
tft.setCursor(280, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_29 = Case_Temp;
tft.print(Case_Temp);
tft.write(0xF7);
tft.println("C");
tft.setCursor(12, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Fan output:");
tft.setCursor(280, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_30 = Case_Set_Percentage;
tft.print(Case_Set_Percentage);
tft.println("%");
//---------------------------------
}
else if (page == 7) { //if the current page is 2
//----------Page 7, Box 1----------
tft.fillRoundRect(0, 30, 480, 80, 10, 0xF81F);//Magenta
tft.fillRoundRect(4, 34, 472, 72, 6, ST7796S_BLACK);
tft.setCursor(12, 40);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("12vdc supply");
tft.setCursor(90, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_31 = Out_12vdc_V;
tft.print(Out_12vdc_V);
tft.println(" Volt.");
tft.setCursor(330, 76);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_32 = Out_12vdc_mA;
tft.print(Out_12vdc_mA);
tft.println(" A.");
//---------------------------------
//----------Page 7, Box 2----------
tft.fillRoundRect(0, 122, 480, 80, 10, 0xF81F);//Magenta
tft.fillRoundRect(4, 126, 472, 72, 6, ST7796S_BLACK);
tft.setCursor(12, 132);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Arduino supply");
tft.setCursor(90, 168);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_33 = Arduino_V;
tft.print(Arduino_V);
tft.println(" Volt.");
tft.setCursor(330, 168);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_34 = Arduino_mA;
tft.print(Arduino_mA);
tft.println(" A.");
//---------------------------------
//----------Page 7, Box 3----------
tft.fillRoundRect(0, 214, 480, 80, 10, 0xF81F);//Magenta
tft.fillRoundRect(4, 218, 472, 72, 6, ST7796S_BLACK);
tft.setCursor(12, 224);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
tft.print("Servo(shunt) supply");
tft.setCursor(90, 260);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_35 = Servo_V;
tft.print(Servo_V);
tft.println(" Volt.");
tft.setCursor(330, 260);
tft.setTextColor(ST7796S_WHITE);
tft.setTextSize(3);
pageFloatBuffer_36 = Servo_mA;
tft.print(Servo_mA);
tft.println(" A.");
//--------------------------------
}
}
void TFT_loop(){
//--------------------TFT Code-----------------------
if (digitalRead(MENU_FORWARD_BUTTON_PIN) == HIGH) {
currentPage++; //increment the current page
if (currentPage > 7) { //if the current page is greater than 2, reset it to 1
currentPage = 1;
}
changePage(currentPage); //call the function to change the page
lastScreenUpdate = millis();
delay(100); //debounce delay
}
if (digitalRead(MENU_BACK_BUTTON_PIN) == HIGH) { //check if the second button is pressed
currentPage--; //decrement the current page
if (currentPage < 1) { //if the current page is less than 1, reset it to 2
currentPage = 7;
}
changePage(currentPage); //call the function to change the page
lastScreenUpdate = millis();
delay(100); //debounce delay
}
if(millis() - lastScreenUpdate > IntervalScreenUpdate){
updatePage();//Laver løbende opdatering med lavt resourceforbrug.
lastScreenUpdate = millis();
}
}
#define Boiler_Temp_offset 0.0
#define FlowF_Temp_offset 0.0
#define FlowR_Temp_offset 0.0
#define Cwater_Temp_offset 0.0
#define Wwater_Temp_offset 0.0
#define Out_Temp_Sensor1_offset 0.0
#define Out_Temp_Sensor2_offset 0.0
#define Case_Temp_offset 0.0
#define Chimney_Temp_offset 0.0
void Sensors_loop(){
sensors.requestTemperatures();
Boiler_Temp = sensors.getTempC(Boiler_Temp_addr) + Boiler_Temp_offset;
FlowF_Temp = sensors.getTempC(FlowF_Temp_addr) + FlowF_Temp_offset;
FlowR_Temp = sensors.getTempC(FlowR_Temp_addr) + FlowR_Temp_offset;
Cwater_Temp = sensors.getTempC(Cwater_Temp_addr) + Cwater_Temp_offset;
Wwater_Temp = sensors.getTempC(Wwater_Temp_addr) + Wwater_Temp_offset;
Out_Temp_Sensor1 = sensors.getTempC(Out_Temp_Sensor1_addr) + Out_Temp_Sensor1_offset;
Out_Temp_Sensor2 = sensors.getTempC(Out_Temp_Sensor2_addr) + Out_Temp_Sensor2_offset;
Case_Temp = sensors.getTempC(Case_Temp_addr) + Case_Temp_offset;
Chimney_Temp = sensors.getTempC(Chimney_Temp_addr) + Chimney_Temp_offset;
average_Out_Temp = (Out_Temp_Sensor1 + Out_Temp_Sensor2) / 2; //--Calculate average Out_Temp_Sensor's
Out_12vdc_V = ina226_Out_12vdc.getBusVoltage_V();
Out_12vdc_mA = ina226_Out_12vdc.getCurrent_mA() / 1000;
Servo_V = ina226_Servo.getBusVoltage_V();
Servo_mA = ina226_Servo.getCurrent_mA() / 1000;
Arduino_V = ina226_Arduino.getBusVoltage_V();
Arduino_mA = ina226_Arduino.getCurrent_mA() / 1000;
myPID.Compute();
}
void IO_loop(){
servo.write(output);
output_Percentage = map(output, 50, 135, 0, 100);//-----Servo Angel to percentage
//============================== FlowF Map and limits ===================================
FlowF_Set = map(average_Out_Temp, -10, 15, 60, 50); //-----Mapped Setpoint Flow_Set to PID
if(FlowF_Set > 65){ //-------------------------------------------FlowF_Set upper limit
FlowF_Set = 65;
}else if(FlowF_Set < 50){ //-------------------------------------FlowF_Set lower limit
FlowF_Set = 50;
}
//=======================================================================================
//============================= Boiler Map and limits ===================================
Boiler_Set = map(average_Out_Temp, -10, 20, 68, 58); //-----Mapped Out_Temp to Setpoint Boiler_Set
if(Boiler_Set > 68){ //-----upper limit
Boiler_Set = 68;
}else if(Boiler_Set < 58){ //-----Boiler_Set lower limit
Boiler_Set = 58;
}
//======================================================================================
//============================ CaseFan Map and limits ==================================
Case_Set = map(Case_Temp, 30, 50, 0, 255); //-----Mapped Setpoint Case_Set
if(Case_Set > 255){ //-----------------------------------------CaseFan_Set upper limit(Fan_Speed)
Case_Set = 255;
}else if(Case_Set < 60){ //-------------------------------------CaseFan_Set lower limit(Fam_Speed)
Case_Set = 0;
}// if Case__Set output comes under 60 then Output goes to 0, to be sure fan starts up
analogWrite(CaseFan_PIN, Case_Set);
Case_Set_Percentage = map(Case_Set, 0, 255, 0, 100);//----Fan output to percentage
if(Case_Set_Percentage > 100){ //----- upper limit
Case_Set_Percentage = 100;
}else if(Case_Set_Percentage < 0){ //----lower limit
Case_Set_Percentage = 0;
}
//=====================================================================================
if(Boiler_Temp < (Boiler_Set - Boiler_Hys)){
digitalWrite(Boiler_PIN, HIGH);
}
else if (Boiler_Temp > (Boiler_Set)){
digitalWrite(Boiler_PIN, LOW);
}
//------------------------------Function to stop CircPump and close Shunt(Servo)-------------------//
if(digitalRead(Stop_Pump_Servo_PIN)){
output = 50; //---------------------------------------------------Shunt(servo) close to when Stop_Pump_Servo function activate, remember line 77 too
}
else{
myPID.Compute();
}
if(digitalRead(Stop_Pump_Servo_PIN)){
if(millis() - lastTimeFinishedInterval > MaxTimeOff){
digitalWrite(CircPump_PIN, HIGH);
}else{
digitalWrite(CircPump_PIN, LOW);
}
}else{
if(average_Out_Temp < (CircPump_Set - CircPump_Hys)){
digitalWrite(CircPump_PIN, HIGH);
}
else if(average_Out_Temp > (CircPump_Set)){
if(millis() - lastTimeFinishedInterval > MaxTimeOff){
digitalWrite(CircPump_PIN, HIGH);
}else{
digitalWrite(CircPump_PIN, LOW);
}
}
}
if(digitalRead(CircPump_PIN) != CirPumpOldState){
if(digitalRead(CircPump_PIN)){
lastTimeBeginOn = millis();
}else{
lastTimeBeginOff = millis();
}
CirPumpOldState = digitalRead(CircPump_PIN);
}
if(digitalRead(CircPump_PIN)){
if(millis() - lastTimeBeginOn > TimeToBeOn){
lastTimeFinishedInterval = millis();
}
}
}
void Counter_loop(){
long RTC_millis = (1000 * (unsigned long)RTC.getEpoch());
//-----------------------------Start up counter Boiler_Flame-------------------------------------//
if(digitalRead(Boiler_Flame_PIN) != lastState_Boiler_Flame){
if(lastState_Boiler_Flame){
timeBufferSekunder_Boiler_Flame += (RTC_millis - timerStart_Boiler_Flame)/1000;
}else{
timerStart_Boiler_Flame = RTC_millis;
CounterTurnOnTimes_Boiler_Flame++;
}
lastState_Boiler_Flame = digitalRead(Boiler_Flame_PIN);
}//----------------------------------------------------------------------------------------------//
//------------------------------ Timeshift code Boiler_Flame.... s -> min -> timer --------------//
if(RTC_millis - timerStart_Boiler_Flame > 1000 && digitalRead(Boiler_Flame_PIN)){
timeBufferSekunder_Boiler_Flame++;
timerStart_Boiler_Flame += 1000;
if(timeBufferSekunder_Boiler_Flame > 59){
timeBufferSekunder_Boiler_Flame -= 60;
timeBufferMinutter_Boiler_Flame++;
if(timeBufferMinutter_Boiler_Flame > 59){
timeBufferMinutter_Boiler_Flame -= 60;
timeBufferTimer_Boiler_Flame++;
}//-----------------------------------------------------------------------------------------//
}
}
//-----------------------------Start up counter Circ_Pump--------------------------------------//
if(digitalRead(CircPump_PIN) != lastState_CircPump){
if(lastState_CircPump){
timeBufferSekunder_CircPump += (RTC_millis - timerStart_CircPump)/1000;
}else{
timerStart_CircPump = RTC_millis;
CounterTurnOnTimes_CircPump++;
}
lastState_CircPump = digitalRead(CircPump_PIN);
}//-------------------------------------------------------------------------------------------//
//------------------------------ Timeshift code CircPump.... s -> min -> timer----------------//
if(RTC_millis - timerStart_CircPump > 1000 && digitalRead(CircPump_PIN)){
timeBufferSekunder_CircPump++;
timerStart_CircPump += 1000;
if(timeBufferSekunder_CircPump > 59){
timeBufferSekunder_CircPump -= 60;
timeBufferMinutter_CircPump++;
if(timeBufferMinutter_CircPump > 59){
timeBufferMinutter_CircPump -= 60;
timeBufferTimer_CircPump++;
}//---------------------------------------------------------------------------------------//
}
}
}
void FRAM_updater(){
//Write data to FRAM every 5s
if(millis() - lastFRAMwrite > 5000){
if(FRAM_OK){
//Move data from variables to FRAM
/*VARIABLE : FRAM address
unsigned int timeBufferTimer_Boiler_Flame : 0-1 (2 bytes)
unsigned int timeBufferTimer_CircPump : 2-3 (2 bytes)
byte timeBufferMinutter_Boiler_Flame : 4
byte timeBufferMinutter_CircPump : 5
byte timeBufferSekunder_Boiler_Flame : 6
byte timeBufferSekunder_CircPump : 7
unsigned int CounterTurnOnTimes_Boiler_Flame: 8-9 (2 bytes)
unsigned int CounterTurnOnTimes_CircPump : 10-11 (2 bytes)
*/
//---timeBufferTimer_Boiler_Flame
fram.write(0, timeBufferTimer_Boiler_Flame );//Only some of the data will fit! Rest will overflow(be removed).
fram.write(1, timeBufferTimer_Boiler_Flame >> 8);//Rest of data is handled here
//---timeBufferTimer_CircPump
fram.write(2, timeBufferTimer_CircPump );//Only some of the data will fit! Rest will overflow(be removed).
fram.write(3, timeBufferTimer_CircPump >> 8 );//Rest of data is handled here
//---timeBufferMinutter_Boiler_Flame
fram.write(4, timeBufferMinutter_Boiler_Flame);
//---timeBufferMinutter_CircPump
fram.write(5, timeBufferMinutter_CircPump );
//---timeBufferSekunder_Boiler_Flame
fram.write(6, timeBufferSekunder_Boiler_Flame);
//---timeBufferSekunder_CircPump
fram.write(7, timeBufferSekunder_CircPump );
//---CounterTurnOnTimes_Boiler_Flame
fram.write(8, CounterTurnOnTimes_Boiler_Flame );//Only some of the data will fit! Rest will overflow(be removed).
fram.write(9, CounterTurnOnTimes_Boiler_Flame >> 8);//Rest of data is handled here
//---CounterTurnOnTimes_CircPump
fram.write(10, CounterTurnOnTimes_CircPump );//Only some of the data will fit! Rest will overflow(be removed).
fram.write(11, CounterTurnOnTimes_CircPump >> 8);//Rest of data is handled here
Serial.println("FRAM updated");
}else{
Serial.println("<<!!!>> FRAM not connected. Please try to restart. <<!!!>>");
}
lastFRAMwrite = millis();
}
}
void Serial_updater(){
if(millis() - lastPrintUpdate > IntervalPrintUpdate){
Serial.print("Boiler_Temp: ");
Serial.print(Boiler_Temp);
Serial.print(" / Boiler_Set: ");
Serial.println(Boiler_Set);
//------------------------------Printer running time and startup's Boiler--------------------//
Serial.print("Time_Boiler_Flame: ");
Serial.print(timeBufferTimer_Boiler_Flame);
Serial.print("h ");
Serial.print(timeBufferMinutter_Boiler_Flame);
Serial.print("m ");
Serial.print(timeBufferSekunder_Boiler_Flame);
Serial.print("s ");
Serial.print("/ Start_Up: ");
Serial.print(CounterTurnOnTimes_Boiler_Flame);
Serial.println(" times");
Serial.println("");
//------------------------------------------------------------------------------------------//
Serial.print("FlowF_Temp: ");
Serial.print(FlowF_Temp);
Serial.print(" / FlowF_Set: ");
Serial.print(FlowF_Set);
Serial.print(" / Shunt_Pos: ");
Serial.println(output);
Serial.print("FlowR_Temp: ");
Serial.println(FlowR_Temp);
Serial.println("");
Serial.print("Cwater_Temp: ");
Serial.println(Cwater_Temp);
Serial.print("Wwater_Temp: ");
Serial.println(Wwater_Temp);
Serial.println("");
Serial.print("Chimney_Temp");
Serial.println(Chimney_Temp);
Serial.println("");
//------------------------------Printer running time and startup´s CircPump----------------//
Serial.print("Running_Time_CircPump: ");
Serial.print(timeBufferTimer_CircPump);
Serial.print("h ");
Serial.print(timeBufferMinutter_CircPump);
Serial.print("m ");
Serial.print(timeBufferSekunder_CircPump);
Serial.print("s ");
Serial.print("/ Start_Up: ");
Serial.print(CounterTurnOnTimes_CircPump);
Serial.println(" times");
Serial.println("");
//----------------------------------------------------------------------------------------//
Serial.print("Out_Temp: ");
Serial.print(average_Out_Temp);
Serial.print(" / Out_Temp_Sensor1: ");
Serial.print(Out_Temp_Sensor1);
Serial.print(" / Out_Temp_Sensor2: ");
Serial.println(Out_Temp_Sensor2);
Serial.println("");
Serial.print("Case_Temp: ");
Serial.println(Case_Temp);
Serial.print("Fan_output: ");
Serial.println(Case_Set);
Serial.println("");
Serial.print("Out_12vdc_Volt: ");
Serial.println(Out_12vdc_V);
Serial.print("Out_12vdc_mA: ");
Serial.println(Out_12vdc_mA);
Serial.print("Servo_Volt: ");
Serial.println(Servo_V);
Serial.print("Servo_mA: ");
Serial.println(Servo_mA);
Serial.print("Arduino_Volt: ");
Serial.println(Arduino_V);
Serial.print("Arduino_mA: ");
Serial.println(Arduino_mA);
Serial.println("");
Serial.print(RTC.getDay());
Serial.print("-");
Serial.print(RTC.getMonth());
Serial.print("-");
Serial.print(RTC.getYear());
Serial.print(" ");
Serial.print(RTC.getHours());
Serial.print(":");
Serial.print(RTC.getMinutes());
Serial.print(":");
Serial.print(RTC.getSeconds());
Serial.println(" ");
Serial.print("Time_TFT_loop_AVG: ");
Serial.println(Time_TFT_loop_AVG);
Serial.print("Time_Sensors_loop_AVG: ");
Serial.println(Time_Sensors_loop_AVG);
Serial.print("Time_IO_loop_AVG: ");
Serial.println(Time_IO_loop_AVG);
Serial.print("Time_Counter_loop_AVG: ");
Serial.println(Time_Counter_loop_AVG);
Serial.print("Time_FRAM_updater_AVG: ");
Serial.println(Time_FRAM_updater_AVG);
Serial.print("Time_Serial_updater_AVG: ");
Serial.println(Time_Serial_updater_AVG);
Serial.print("Millis(): ");
Serial.println(millis());
Serial.println("");
lastPrintUpdate = millis();
}
}
void CycleTime_loop(){
Time_TFT_loop_LAST = Time_TFT_loop - Time_Start;
Time_Sensors_loop_LAST = Time_Sensors_loop - Time_TFT_loop;
Time_IO_loop_LAST = Time_IO_loop - Time_Sensors_loop;
Time_Counter_loop_LAST = Time_Counter_loop - Time_IO_loop;
Time_FRAM_updater_LAST = Time_FRAM_updater - Time_Counter_loop;
Time_Serial_updater_LAST = Time_Serial_updater - Time_FRAM_updater;
Time_TFT_loop_SUM += Time_TFT_loop_LAST;
Time_Sensors_loop_SUM += Time_Sensors_loop_LAST;
Time_IO_loop_SUM += Time_IO_loop_LAST;
Time_Counter_loop_SUM += Time_Counter_loop_LAST;
Time_FRAM_updater_SUM += Time_FRAM_updater_LAST;
Time_Serial_updater_SUM += Time_Serial_updater_LAST;
CycleTime_SUM_RUNS++;
if(CycleTime_SUM_RUNS > 60){
Time_TFT_loop_AVG = Time_TFT_loop_SUM / CycleTime_SUM_RUNS;
Time_Sensors_loop_AVG = Time_Sensors_loop_SUM / CycleTime_SUM_RUNS;
Time_IO_loop_AVG = Time_IO_loop_SUM / CycleTime_SUM_RUNS;
Time_Counter_loop_AVG = Time_Counter_loop_SUM / CycleTime_SUM_RUNS;
Time_FRAM_updater_AVG = Time_FRAM_updater_SUM / CycleTime_SUM_RUNS;
Time_Serial_updater_AVG = Time_Serial_updater_SUM / CycleTime_SUM_RUNS;
Time_TFT_loop_SUM = 0;
Time_Sensors_loop_SUM = 0;
Time_IO_loop_SUM = 0;
Time_Counter_loop_SUM = 0;
Time_FRAM_updater_SUM = 0;
Time_Serial_updater_SUM = 0;
CycleTime_SUM_RUNS = 0;
}
}
void loop() {
Time_Start = millis();
TFT_loop();
Time_TFT_loop = millis();
Sensors_loop();
Time_Sensors_loop = millis();
IO_loop();
Time_IO_loop = millis();
Counter_loop();
Time_Counter_loop = millis();
FRAM_updater();
Time_FRAM_updater = millis();
Serial_updater();
Time_Serial_updater = millis();
CycleTime_loop();
}