Code: Select all
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
int DP3_Timer = InternalMemory.DP1Timer_read() * 4;
//Disegno schermo principale
/*
void DrawCustomMain()
{
// Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 15, 15, "LukeLuke's Cube");
ReefAngel.LCD.DrawDate(6, 112);
pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 35, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 6, 70, "DP1:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 31, 70, InternalMemory.DP1Timer_read());
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 46, 70, "DP2:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 71, 70, InternalMemory.DP2Timer_read());
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 86, 70, "DP3:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 111, 70, DP3_Timer);
// draw main relay
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 87, TempRelay);
#ifdef RelayExp
// draw 1st expansion relay
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(12, 100, TempRelay);
#endif // RelayExp
}*/
void ConvertNumToString(char* string, int num, byte decimal)
{
char temptxt[3];
int Temp = num;
if (Temp==0xFFFF) Temp=0;
itoa(Temp/decimal,string,10);
if (decimal>1)
{
itoa(Temp%decimal,temptxt,10);
strcat(string, ".");
if (Temp%decimal<10 && decimal==100) strcat(string, "0");
strcat(string, temptxt);
}
}
void DrawCustomMain()
{
byte x = 6;
byte y = 2;
byte t;
ReefAngel.LCD.DrawDate(6, 2);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
pingSerial();
x = 12;
y += MENU_START_ROW+4;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(),DPColor, x, y, 1);
t = intlength(ReefAngel.PWM.GetDaylightValue()) + 1;
t *= 5;
ReefAngel.LCD.DrawText(DPColor, DefaultBGColor, x+t, y, "%");
t += 10;
x += t;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(),APColor, x, y, 1);
t = intlength(ReefAngel.PWM.GetActinicValue()) + 1;
t *= 5;
ReefAngel.LCD.DrawText(APColor, DefaultBGColor, x+t, y, "%");
t += 10;
x += t;
char text[7];
ConvertNumToString(text, ReefAngel.Params.PH, 100);
ReefAngel.LCD.Clear(DefaultBGColor, x+16, y, x+45, y+16);
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+16, y, text,Font8x16);
pingSerial();
ConvertNumToString(text, ReefAngel.Params.Temp1, 10);
y += MENU_START_ROW*2;
x = 10;
ReefAngel.LCD.Clear(DefaultBGColor,x,y,x+(16*4),y+16);
pingSerial();
ReefAngel.LCD.DrawHugeNumbers(T1TempColor, DefaultBGColor, x, y, text);
pingSerial();
x += (16*4) + 8;
ReefAngel.LCD.DrawText(T2TempColor,DefaultBGColor,x,y,"T2:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp2, T2TempColor, x+18, y, 10);
ReefAngel.LCD.DrawText(T3TempColor,DefaultBGColor,x,y+10,"T3:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp3, T3TempColor, x+18, y+10, 10);
y += 16*2;
x = 8;
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x, y, "DP1:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+25, y, InternalMemory.DP1Timer_read());
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+37, y, "DP2:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+62, y, InternalMemory.DP2Timer_read());
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+75, y, "DP3:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+101, y, DP3_Timer);
x = 6;
y += MENU_START_ROW+6;
y -= 3;
ReefAngel.LCD.Clear(COLOR_BLACK, x, y, 124, y);
y +=1;
ReefAngel.LCD.Clear(COLOR_BLUE, x+1, y, 123, y+10);
y +=11;
ReefAngel.LCD.Clear(COLOR_BLACK, x, y, 124, y);
ReefAngel.LCD.Clear(COLOR_BLACK, x, y-11, x, y+16);
ReefAngel.LCD.Clear(COLOR_BLACK, 124, y-11, 124, y+16);
ReefAngel.LCD.DrawText(COLOR_WHITE, COLOR_BLUE, x+40, y-9, "Alarms");
y += 6;
x += 2;
byte fcolor;
// This is for the LOW Ato switch
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+2, y,"ATO:");
if ( InternalMemory.read(700) == 1 )
{
// add in InternalMemory.write(700, 1) when ato is tripped
// add in InternalMemory.write(700, 0) when ato is cleared
fcolor = COLOR_RED;
ReefAngel.LCD.DrawText(fcolor, DefaultBGColor, x+30, y, "YES");
}
else
{
fcolor = COLOR_GREEN;
ReefAngel.LCD.DrawText(fcolor, DefaultBGColor, x+30, y, "NO ");
}
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+55, y,"OverH:");
if ( InternalMemory.read(701) == 1 )
{
// add in InternalMemory.write(701, 1) when overheat is tripped
// add in InternalMemory.write(701, 0) when overheat is cleared
fcolor = COLOR_RED;
strcpy(text, "YES");
}
else
{
fcolor = COLOR_GREEN;
strcpy(text, "NO ");
}
ReefAngel.LCD.DrawText(fcolor, DefaultBGColor, x+94, y, text);
ReefAngel.LCD.Clear(COLOR_BLACK, x-2, y+11, 124, y+11);
x = 12;
y += 18;
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(x, y, TempRelay);
}
void DrawCustomGraph()
{
// ReefAngel.LCD.DrawGraph(5,50);
}
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.SetTemperatureUnit(1); // set to Celsius Temperature
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
//WifiAuthentication("lukeluke:Luca123");
// Set the ports that get toggled on & off during the following modes
// To enable a port to be toggled, place a 1 in the appropriate position
// Uncomment and update as needed
// Port 87654321
ReefAngel.FeedingModePorts = B00000011;
ReefAngel.WaterChangePorts = B00000011;
ReefAngel.OverheatShutoffPorts = B00001011;
//ReefAngel.LightsOnPorts = B00000110;
// Ports that are always on
// ReefAngel.Relay.On(Port4); //Turn the Skimmer
ReefAngel.Relay.On(Port2);
// ReefAngel.Relay.On(Port1);
int DP3_Timer = InternalMemory.DP1Timer_read() * 4;
}
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.SingleATOHigh(Port6);
ReefAngel.StandardFan(Port1);
ReefAngel.StandardHeater(Port8);
ReefAngel.DelayedOn(Port4,10);
if (ReefAngel.Params.Temp1 > 290)
{
ReefAngel.PWM.SetActinic(PWMSlope(12,15,23,45,0,InternalMemory.LEDPWMActinic_read(),90,ReefAngel.PWM.GetActinicValue()));
ReefAngel.PWM.SetDaylight(PWMSlope(13,30,22,30,0,40,30,ReefAngel.PWM.GetDaylightValue()));
}
else if (ReefAngel.Params.Temp1 > 280)
{
ReefAngel.PWM.SetActinic(PWMSlope(12,15,23,45,0,InternalMemory.LEDPWMActinic_read(),90,ReefAngel.PWM.GetActinicValue()));
ReefAngel.PWM.SetDaylight(PWMSlope(13,30,22,30,0,70,30,ReefAngel.PWM.GetDaylightValue()));
}
else
{
ReefAngel.PWM.SetActinic(PWMSlope(12,15,23,45,0,InternalMemory.LEDPWMActinic_read(),90,ReefAngel.PWM.GetActinicValue()));
ReefAngel.PWM.SetDaylight(PWMSlope(13,30,22,30,0,InternalMemory.LEDPWMDaylight_read(),30,ReefAngel.PWM.GetDaylightValue()));
}
ReefAngel.DosingPump(Port3, 1, 23, 00, InternalMemory.DP1Timer_read());
ReefAngel.DosingPump(Port3, 1, 05, 00, InternalMemory.DP1Timer_read());
ReefAngel.DosingPump(Port3, 1, 11, 00, InternalMemory.DP1Timer_read());
ReefAngel.DosingPump(Port3, 1, 17, 00, InternalMemory.DP1Timer_read());
ReefAngel.DosingPump(Port5, 2, 23, 10, InternalMemory.DP2Timer_read());
ReefAngel.DosingPump(Port5, 2, 05, 10, InternalMemory.DP2Timer_read());
ReefAngel.DosingPump(Port5, 2, 11, 10, InternalMemory.DP2Timer_read());
ReefAngel.DosingPump(Port5, 2, 17, 10, InternalMemory.DP2Timer_read());
ReefAngel.DosingPump(Port7, 4, 23, 20, DP3_Timer); // Setup Dosing Pump 3 Oligo
}
in the latest i change the PWM because i use the MH now .....