Max and Min Temp
Posted: Sun Jan 15, 2012 10:19 am
I am thinking about reducing my custom main screen footprint by removing the graph function. What I really want to know is did the temp go over or under a 'safe' temp. So I thought I could just show the max and min temp in the last 24 hr. period. I usually check the screen once a day or so anyway. Will this code work or is there a better way to do it?
Thanks,
Jon
Thanks,
Jon
Code: Select all
long previousMillis = 0; // will store last time was updated
long interval = 86400000; // interval for 24hrs
int maxtemp = 0;
int mintemp = 0;
int currentTemp = 0;
void DrawCustomMain()
{
// the graph is drawn/updated when we exit the main menu &
// when the parameters are saved
ReefAngel.LCD.DrawDate(6, 2);
ReefAngel.LCD.Clear(0, 1, 11, 132, 11);
pingSerial();
// Display the Tank temperature with color sensors
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,5,13,"TK:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp1, COLOR_BLACK, 23, 13, 10);
// Display the Room temperature
ReefAngel.LCD.DrawText(T2TempColor,DefaultBGColor,5,23,"HI:");
ReefAngel.LCD.DrawSingleMonitor(maxTemp, 0, 23, 23, 10);
// Display the Sump temperature
ReefAngel.LCD.DrawText(T3TempColor,DefaultBGColor,5,33,"LO:");
ReefAngel.LCD.DrawSingleMonitor(minTemp, 0, 23, 33, 1);
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 45, TempRelay);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval && ReefAngel.Params.Temp1 > currentTemp)
{
maxTemp = ReefAngel.Params.Temp1
// displays max temp in last 24 hrs.
previousMillis = currentMillis;
// resets 24 hr clock
}
if(currentMillis - previousMillis > interval && ReefAngel.Params.Temp1 < currentTemp)
{
minTemp = ReefAngel.Params.Temp1
// displays min temp in last 24 hrs.
previousMillis = currentMillis;
// resets 24 hr clock
}