Custom Menu with Flexible Ph Calibration
-
- Posts: 133
- Joined: Sun Mar 09, 2014 11:01 am
- Location: Santos - Brazil
Custom Menu with Flexible Ph Calibration
Hi
Since my PH is acid, I use the UseFlexiblePhCalibration() option. It used to work ok.
But with my custom menu, I call the SetupCalibratePH() as below:
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
It always shows the "simple" Setup Calibrate PH Screen, not the Flexible one (even if the "UseFlexiblePhCalibration" option is set on the "setup" section).
I found in somewhere a SetupCalibrateChoicePH() to use instead of SetupCalibratePH(), but it's not working too (I get a compile error).
Does anyone have any idea?
Best regards
Rafa
Since my PH is acid, I use the UseFlexiblePhCalibration() option. It used to work ok.
But with my custom menu, I call the SetupCalibratePH() as below:
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
It always shows the "simple" Setup Calibrate PH Screen, not the Flexible one (even if the "UseFlexiblePhCalibration" option is set on the "setup" section).
I found in somewhere a SetupCalibrateChoicePH() to use instead of SetupCalibratePH(), but it's not working too (I get a compile error).
Does anyone have any idea?
Best regards
Rafa
-
- Posts: 133
- Joined: Sun Mar 09, 2014 11:01 am
- Location: Santos - Brazil
Re: Custom Menu with Flexible Ph Calibration
Sure...
Code: Select all
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <ReefAngel.h>
void startTimeRunningRetPump();
void checkMaxSewer();
void checkMinWaterSump();
void checkMaxWaterSump();
void emergencyShutDown();
void WChange();
void DrawCustomMain();
void feedingMode();
// Custom Menu Code
#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Feeding Mode";
prog_char menu1_label[] PROGMEM = "Auto Feed";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Water Level Calib.";
prog_char menu4_label[] PROGMEM = "PH Calibration";
prog_char menu5_label[] PROGMEM = "Emergency Shut Down";
prog_char menu6_label[] PROGMEM = "Date / Time";
prog_char menu7_label[] PROGMEM = "Version";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label,
menu3_label, menu4_label, menu5_label,
menu6_label, menu7_label//, menu7_label, menu8_label
};
////// Place global variable code below here
//auto feed option on feed mode
boolean auto_Feed=false;
//Water Change Status
int wc_status=1;
// 0 - Troca de agua nao esta pronta
// 1 - Pronto para troca de agua
// 2 - transferir do reservatorio para o sump
// 3 - transferir do sump para o esgoto
// 4 - prepara timer dosador
// 5 - inicia dosador
// 6 - preencher reservatorio
boolean RETPUMP_ON_TIME=false;
//Rename ports
#define LIGHTS Port1
#define RETPUMP Port2
#define COOLER Port3
#define CO2UV Port4
#define WIN Port5
#define WCHANGE Port6
#define WOUT Port7
#define DOSER Port8
//Labes name - RA MENU
#define RA_NAME_LABEL "RAFALU"
#define TEMP_LABEL "TEMP:"
#define PH_LABEL "PH:"
#define LIGHTS_LABEL "Lights"
#define RET_PUMP "RetPump"
#define COOLER_LABEL "Cooler"
#define CO2UV_LABEL "CO2/UV"
#define WATER_IN_LABEL "WIn"
#define WATER_CHANGE_LABEL "WChange"
#define WATER_OUT_LABEL "WOut"
#define DOSER_LABEL "Doser"
//Define WaterLevel Channels
#define WL_SEWER 1
#define WL_REFUGIUM 2
#define WL_SUMP 4
#define WL_RESERVOIR 3
//Define Max and Min PH
#define MAX_PH 610
#define MIN_PH 630
//Define times to Auto Water Change (AWC)
#define WCHANGE_H_T1 9
#define WCHANGE_M_T1 0
#define WCHANGE_H_T2 21
#define WCHANGE_M_T2 0
//Min e Max parameters to Auto Water Change (AWC)
#define MIN_SEWER 10 //maximo tamanho do esgoto para iniciar a troca
#define MIN_RESERVOIR 95 //minimo do reservatorio para iniciar troca parcial
#define MAX_RESERVOIR 100 //maximo para encher reservatorio
#define MAX_SUMP 60 //valor ideal do sump no final da troca
#define MIN_RESERVOIR_AT_CHANGE 10 //minimo do reservatorio na troca
#define MAX_SEWER 70 //maximo tamanho do esgoto para iniciar a troca
//Minimun Sump Level, preventing pump damage
#define MIN_WATER_SUMP 40
//Doser Time for Auto Water Change (AWC)
#define WCHANGE_DOSER_SECOND 5
//Time On/Off Lights
#define LIGHTS_ON_H 19
#define LIGHTS_ON_M 0
#define LIGHTS_OFF_H 23
#define LIGHTS_OFF_M 59
//Time do auto-feed
#define FEEDING_H_T1 20
#define FEEDING_M_T1 30
#define FEEDING_H_T2 23
#define FEEDING_M_T2 20
//Overheat temp, in celcius
#define OVERHEATTEMP 330
//Max and Min tenperature, in celcius
#define TEMP_MIN 280
#define TEMP_MAX 290
//Seconds return pump is on before checking min-water level.
#define RETURN_PUMP_SECONDS_ON 60
//Number of feeding times done in 15 minutes
#define FEEDING_TIMES 2
//Value to avoid change water on every tyne little variation.
#define PROXY_MAX_SUMP 1.10
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
ReefAngel.SetTemperatureUnit(Celsius); // set to Celsius Temperature
ReefAngel.AddWaterLevelExpansion(); // Water Level Expansion Module
//ReefAngel.FeedingModePorts = Port2Bit;
ReefAngel.FeedingModePorts = 0;
ReefAngel.WaterChangePorts = 0;
ReefAngel.OverheatShutoffPorts = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write(OVERHEATTEMP);
// Ports that are always on
ReefAngel.Relay.On(RETPUMP);
// Ports that are always off
ReefAngel.Relay.Off(WIN);
ReefAngel.Relay.Off(WCHANGE);
ReefAngel.Relay.Off(WOUT);
ReefAngel.Relay.Off(DOSER);
//Use PH Flexible Calibration
ReefAngel.UseFlexiblePhCalibration();
}
void loop()
{
//Lights Control
ReefAngel.StandardLights(LIGHTS,LIGHTS_ON_H,LIGHTS_ON_M,LIGHTS_OFF_H,LIGHTS_OFF_M);
//Fam control
//ReefAngel.StandardFan(COOLER,TEMP_MIN,TEMP_MAX);
// CO2/UV Control
ReefAngel.CO2Control(CO2UV,MIN_PH,MAX_PH);
////// Place your custom code below here
//Auto Water Change (AWC) function
WChange();
//Configra gatilho de 2 minutos de bomba de retorno em execucao
startTimeRunningRetPump();
//Function to prevent pump burn
checkMinWaterSump();
//Funcao para deixar o Sump na medida certa
checkMaxWaterSump();
//Security function on water max level
checkMaxSewer();
//feeding mode
feedingMode();
////// Place your custom code above here
// This should always be the last line
ReefAngel.ShowInterface();
}
void startTimeRunningRetPump(){
static boolean timerOn=false;
static long finalTime=0;
if(ReefAngel.Relay.Status(RETPUMP) && !timerOn) {
finalTime = now()+RETURN_PUMP_SECONDS_ON;
timerOn=true;
}
if(now()>=finalTime && ReefAngel.Relay.Status(RETPUMP)) {
RETPUMP_ON_TIME=true;
}
if(!ReefAngel.Relay.Status(RETPUMP)){
RETPUMP_ON_TIME=false;
timerOn=false;
}
}
void checkMaxSewer()
{
if(ReefAngel.WaterLevel.GetLevel(WL_SEWER)>=MAX_SEWER){
emergencyShutDown();
}
}
void checkMinWaterSump()
{
//se agua do sump baixa e bomba retorno ligada
if(RETPUMP_ON_TIME){
if(ReefAngel.WaterLevel.GetLevel(WL_SUMP)<=MIN_WATER_SUMP){
emergencyShutDown();
}
}
}
void emergencyShutDown(){
wc_status=0; //inviabiliza futuras trocas de agua
ReefAngel.Relay.Override(WIN,0);
ReefAngel.Relay.Override(WCHANGE,0);
ReefAngel.Relay.Override(WOUT,0);
ReefAngel.Relay.Override(DOSER,0);
ReefAngel.Relay.Override(RETPUMP,0);
ReefAngel.Relay.Override(CO2UV,0);
}
void checkMaxWaterSump()
{
//se estiver em troca parcial, não mecher.
if(wc_status==1){
if(ReefAngel.WaterLevel.GetLevel(WL_SUMP)> (MAX_SUMP*PROXY_MAX_SUMP) && RETPUMP_ON_TIME){
ReefAngel.Relay.On(WOUT);
}
else {
ReefAngel.Relay.Off(WOUT);
}
}
}
void WChange()
{
// 0 - Troca de agua nao esta pronta
// 1 - Pronto para troca de agua
// 2 - transferir do reservatorio para o sump
// 3 - transferir do sump para o esgoto
// 4 - prepara timer dosador
// 5 - inicia dosador
// 6 - preencher reservatorio
static unsigned long wcDosingTimer;
//realiza somente se a bomba retorno esta funcionando a mais de alguns minutos
if(RETPUMP_ON_TIME){
switch (wc_status){
case 1:
//se execucao manual ou mediante algum horario
if((ReefAngel.DisplayedMenu==WATERCHANGE_MODE) || (hour()==WCHANGE_H_T1 && minute()==WCHANGE_M_T1) || (hour()==WCHANGE_H_T2 && minute()==WCHANGE_M_T2))
{
if(ReefAngel.WaterLevel.GetLevel(WL_RESERVOIR)<MIN_RESERVOIR){
wc_status=6;
}
else{
if(ReefAngel.WaterLevel.GetLevel(WL_SEWER)<=MIN_SEWER){
wc_status=2;
}
}
}
break;
case 2:
//transferir do reservatorio para o sump
if(ReefAngel.WaterLevel.GetLevel(WL_RESERVOIR)>(MIN_RESERVOIR_AT_CHANGE)){
ReefAngel.Relay.On(WCHANGE);
}
else{
ReefAngel.Relay.Off(WCHANGE);
wc_status = 3;
}
break;
case 3:
//transferir do sump para o esgoto
if(ReefAngel.WaterLevel.GetLevel(WL_SUMP)>(MAX_SUMP)){
ReefAngel.Relay.On(WOUT);
}
else{
ReefAngel.Relay.Off(WOUT);
wc_status = 4;
}
break;
case 4:
//prepara timer dosador
wcDosingTimer= now() + WCHANGE_DOSER_SECOND;
wc_status = 5;
break;
case 5:
if (now()<wcDosingTimer) {
ReefAngel.Relay.On(DOSER);
}
else {
ReefAngel.Relay.Off(DOSER);
wcDosingTimer=0;
wc_status = 6;
}
break;
case 6:
//preencher reservatorio, prepara proxima troca
if(ReefAngel.WaterLevel.GetLevel(WL_RESERVOIR)<MAX_RESERVOIR){
ReefAngel.Relay.On(WIN);
}
else{
ReefAngel.Relay.Off(WIN);
wc_status = 1;
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}
break;
}
}
else {
wc_status=1;
}
}
void feedingMode(){
static byte nrFeedings=0;
static boolean afeed=false;
static long timeToRun;
static long feeding;
//somente se nao estou fazendo troca automatica
if(wc_status==1){
timeToRun = 900/(FEEDING_TIMES+1);
if(auto_Feed || ((hour()==FEEDING_H_T1 && minute()==FEEDING_M_T1) || (hour()==FEEDING_H_T2 && minute()==FEEDING_M_T2))){
auto_Feed=false;
afeed=true;
feeding = now()+timeToRun;
if(!(ReefAngel.DisplayedMenu==FEEDING_MODE)) ReefAngel.FeedingModeStart();
}
ReefAngel.Relay.Set(RETPUMP, !(ReefAngel.DisplayedMenu==FEEDING_MODE) );
if(afeed){
if(now()>=feeding && nrFeedings < FEEDING_TIMES){
//if(ReefAngel.Relay.Status(LIGHTS)){
ReefAngel.Relay.Set(COOLER,!ReefAngel.Relay.Status(COOLER));
//}
nrFeedings++;
feeding = now()+timeToRun;
}
if(nrFeedings == FEEDING_TIMES){
nrFeedings=0;
afeed=false;
}
}
}
}
void DrawCustomMain()
{
//Titulo Inicial
ReefAngel.LCD.DrawDate(6, 64);
ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 40, 4 , RA_NAME_LABEL);
ReefAngel.LCD.Clear(COLOR_MAROON, 1, 13, 132, 13);
ReefAngel.LCD.Clear(COLOR_MAROON, 10, 75, 119, 75);
ReefAngel.LCD.Clear(COLOR_MAROON, 10, 59, 119, 59);
pingSerial();
//Temperatura tanque principal
ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 6, 15, TEMP_LABEL);
char text[7];
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
pingSerial();
ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, DefaultBGColor, 44, 15, text);
//PH
ReefAngel.LCD.DrawLargeText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 6, 26, PH_LABEL);
ConvertNumToString(text, ReefAngel.Params.PH, 100);
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, 44, 26, text);
pingSerial();
//WATER LEVEL 01
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 6, 38, " ");
ConvertNumToString(text, ReefAngel.WaterLevel.GetLevel(WL_SEWER), 1);
char str[80];
strcpy (str,"SEWER:");
strcat (str,text);
strcat (str,"%");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 6, 38, str);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 74, 38," ");
ConvertNumToString(text, ReefAngel.WaterLevel.GetLevel(WL_REFUGIUM), 1);
strcpy (str,"REF: ");
strcat (str,text);
strcat (str,"%");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 74, 38,str);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 6, 50, " ");
ConvertNumToString(text, ReefAngel.WaterLevel.GetLevel(WL_RESERVOIR), 1);
strcpy (str,"RES: ");
strcat (str,text);
strcat (str,"%");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 6, 50, str);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 74, 50," ");
ConvertNumToString(text, ReefAngel.WaterLevel.GetLevel(WL_SUMP), 1);
strcpy (str,"SUMP:");
strcat (str,text);
strcat (str,"%");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 74, 50,str);
pingSerial();
//Portas
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,84,RET_PUMP);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,94,CO2UV_LABEL);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,104,WATER_CHANGE_LABEL);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,114,DOSER_LABEL);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,84,LIGHTS_LABEL);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,94,COOLER_LABEL);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,104,WATER_IN_LABEL);
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,114,WATER_OUT_LABEL);
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawCircleOutletBox(60, 86, TempRelay, true);
}
void DrawCustomGraph()
{
}
void MenuEntry1()
{
auto_Feed=false;
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
auto_Feed=true;
}
void MenuEntry3()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry4()
{
ReefAngel.SetupCalibrateWaterLevel();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry5()
{
ReefAngel.SetupCalibrateChoicePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
// Clear the screen
ReefAngel.ClearScreen(DefaultBGColor);
// Display some text on the screen
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 5, 10, "Turn Everything Off");
// Turn off the ports
emergencyShutDown();
ReefAngel.Relay.Write();
}
void MenuEntry7()
{
ReefAngel.SetupDateTime();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry8()
{
ReefAngel.DisplayVersion();
}
Last edited by rrodriguess on Wed Dec 03, 2014 4:52 pm, edited 1 time in total.
-
- Posts: 133
- Joined: Sun Mar 09, 2014 11:01 am
- Location: Santos - Brazil
Re: Custom Menu with Flexible Ph Calibration
Ahhh dont you mind the comments in portuguese... coding in progress...
Rafa
Rafa
Re: Custom Menu with Flexible Ph Calibration
Just so we are on the same page, did you download and update your libraries with the dev branch?
Roberto.
-
- Posts: 133
- Joined: Sun Mar 09, 2014 11:01 am
- Location: Santos - Brazil
Re: Custom Menu with Flexible Ph Calibration
Let me make surge of it, and I get back to you. I will use this library:
https://github.com/reefangel/Libraries
Is that it?
https://github.com/reefangel/Libraries
Is that it?
Re: Custom Menu with Flexible Ph Calibration
Yes, that is the currently released libraries.
You should use that version unless you were testing or using a feature that is currently not release.
You should use that version unless you were testing or using a feature that is currently not release.
Roberto.
-
- Posts: 133
- Joined: Sun Mar 09, 2014 11:01 am
- Location: Santos - Brazil
Re: Custom Menu with Flexible Ph Calibration
To be able to use the SetupCalibrateChoicePH() which one should I use?
-
- Posts: 133
- Joined: Sun Mar 09, 2014 11:01 am
- Location: Santos - Brazil
Re: Custom Menu with Flexible Ph Calibration
Roberto
Just double checked.. I am using the currently release. I get the following error:
The following features were automatically added:
Watchdog Timer
Version Menu
The following features were detected:
Custom Main Screen
Extra Font - Medium Size (8x8 pixels)
Date/Time Setup Menu
Custom Menu
Water Level Expansion Module
Calibrate pH Menu with Choices
Calibrate pH Menu with Choices
Number of Menu Options: 8
In file included from FreshWaterWord_1_17.cpp:30:
/home/mint/Desktop/Arduino/libraries/ReefAngel/ReefAngel.h:233: error: expected unqualified-id before ‘)’ token
FreshWaterWord_1_17.cpp: In function ‘void MenuEntry5()’:
FreshWaterWord_1_17:558: error: expected unqualified-id before ‘(’ token
Just double checked.. I am using the currently release. I get the following error:
The following features were automatically added:
Watchdog Timer
Version Menu
The following features were detected:
Custom Main Screen
Extra Font - Medium Size (8x8 pixels)
Date/Time Setup Menu
Custom Menu
Water Level Expansion Module
Calibrate pH Menu with Choices
Calibrate pH Menu with Choices
Number of Menu Options: 8
In file included from FreshWaterWord_1_17.cpp:30:
/home/mint/Desktop/Arduino/libraries/ReefAngel/ReefAngel.h:233: error: expected unqualified-id before ‘)’ token
FreshWaterWord_1_17.cpp: In function ‘void MenuEntry5()’:
FreshWaterWord_1_17:558: error: expected unqualified-id before ‘(’ token
Re: Custom Menu with Flexible Ph Calibration
The bug is on the feature.txt file.
It's located at \Arduino\update\
Replace this:
With this:
It's located at \Arduino\update\
Replace this:
Code: Select all
SetupCalibrateChoicePH,ReefAngel.SetupCalibrateChoicePH,Calibrate pH Menu with Choices
Code: Select all
SETUP_CALIBRATEPH_CHOICE,ReefAngel.SetupCalibrateChoicePH,Calibrate pH Menu with Choices
Roberto.
-
- Posts: 133
- Joined: Sun Mar 09, 2014 11:01 am
- Location: Santos - Brazil
Re: Custom Menu with Flexible Ph Calibration
Roberto.. tks
It compiled alright. As soon as I get home I will upload and test it.
Rafa
It compiled alright. As soon as I get home I will upload and test it.
Rafa
-
- Posts: 133
- Joined: Sun Mar 09, 2014 11:01 am
- Location: Santos - Brazil
Re: Custom Menu with Flexible Ph Calibration
Tks Roberto... it worked just fine!