Tested on RA Controller with WiFi and one relay box.
Here is my screen Relay box is set:
1 - ATO Standard
2 - Fans on my LED (will set to always On at first)
3 - LED Daylight (using MH setting in RA Client)
4 - LED Actinic (using Standard light settings in RA Client)
5 - Wave 1
6 - Wave 2
7 - Return Pump (always On)
8 - Skimmer (always On)
I was able to set it up so you can change On/Off time for lights. MH settings are used for Daylight LED, Standard light settings are used for Actinic LED. This way I can change settings using RA Client without recompiling and uploading code.
PWM functions are set to ramp up and down from 0% to the value you set up in controller using RA Client.
The idea is to load code once and be able to change settings from client if needed. You can enable graph on screen if you like (just un-comment it and set correct location). Or you can add more relay boxes to display if you have more then one.
I;m still looking at option to show last error on display, but not sure how to do it yet. Will post update when I have it.
Here is my code.
Code: Select all
// RAMenus.pde
//
// This version designed for v0.8.5 Beta 10 and later
#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>
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;
char text[7];
ReefAngel.LCD.DrawDate(6, 2);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
pingSerial();
x = 4;
y += 12;
ReefAngel.LCD.DrawText(COLOR_BLACK, DefaultBGColor, x, y, "Temperature:");
y += 10;
ConvertNumToString(text, ReefAngel.Params.Temp1, 10);
pingSerial();
ReefAngel.LCD.DrawHugeNumbers(T1TempColor, DefaultBGColor, x, y, text);
x = 76;
ReefAngel.LCD.DrawText(T2TempColor,DefaultBGColor,x,y,"LED");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp2, T2TempColor, x+28, y, 10);
ReefAngel.LCD.DrawText(T3TempColor,DefaultBGColor,x,y+9,"ROOM");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp3, T3TempColor, x+28, y+9, 10);
pingSerial();
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 42, 132, 42);
x = 4;
y = 45;
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,x,y,"pH");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.PH, PHColor, x+28, y, 100);
y = 55;
// ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor,x,y,"ATO");
// atoH = "Off";
// if (ReefAngel.HighATO.IsActive()) atoH = "On";
// atoL = "Off";
// if (ReefAngel.LowATO.IsActive()) atoL = "On";
// ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor,x+28,y,"Hi "+atoH+" Low "+atoL);
x = 76;
y = 45;
ReefAngel.LCD.DrawText(DPColor,DefaultBGColor,x,y,"DayL");
x=104;
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, "%");
x = 76;
y = 55;
ReefAngel.LCD.DrawText(APColor,DefaultBGColor,x,y,"ActL");
x=104;
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, "%");
pingSerial();
x = 12;
y = 118;
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(0);
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
// 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 = B11110000;
ReefAngel.WaterChangePorts = B11110000;
ReefAngel.OverheatShutoffPorts = B01011100;
ReefAngel.LightsOnPorts = B00001110;
ReefAngel.Relay.On(Port7); // Return Pump
ReefAngel.Relay.On(Port8); // Skimmer
}
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.StandardATO(Port1);
ReefAngel.StandardFan(Port2);
ReefAngel.MHLights(Port3); // For LED Daylight
ReefAngel.StandardLights(Port4); // For LED Actinic
ReefAngel.Wavemaker1(Port5);
ReefAngel.Wavemaker1(Port6);
ReefAngel.PWM.SetActinic(PWMSlope(InternalMemory.StdLightsOnHour_read(),InternalMemory.StdLightsOnMinute_read(),InternalMemory.StdLightsOffHour_read(),InternalMemory.StdLightsOffMinute_read(),0,InternalMemory.LEDPWMActinic_read(),90,ReefAngel.PWM.GetActinicValue()));
ReefAngel.PWM.SetDaylight(PWMSlope(InternalMemory.MHOnHour_read(),InternalMemory.MHOnMinute_read(),InternalMemory.MHOffHour_read(),InternalMemory.MHOffMinute_read(),0,InternalMemory.LEDPWMDaylight_read(),60,ReefAngel.PWM.GetDaylightValue()));
}
Code: Select all
#ifndef __REEFANGEL_FEATURES_H__
#define __REEFANGEL_FEATURES_H__
#define SIMPLE_MENU
#define DisplayLEDPWM
#define wifi
#define FONT_8x16
#define NUMBERS_16x16
#define CUSTOM_MAIN
#endif // __REEFANGEL_FEATURES_H__
Use it as it is, or modify, or just play with it to learn. It took me some time to figure it out and changing existing code helps understand how this works.
Please let me know if you see what can be improved in this code or if you know how to add error information on the screen. This can help people if they see red LED on their unit.
Thank.