custom main

Related to the development libraries, released by Curt Binder
Post Reply
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: custom main

Post by rimai »

One thing you can do is set the timeout to something over 24hrs.
It has to be tested to make sure the timer will take this value.
Then, you can use the ReefAngel.LCD.BacklightOn() and ReefAngel.LCD.BacklightOff() for night and day.
Something like this:

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>

//custom dysplay temp+on and off relay 
void DrawCustomMain()
{
   byte x = 6;
   byte y = 2;
   byte t;
   ReefAngel.LCD.DrawDate(6, 2);
   ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
   x = 12;
   y += MENU_START_ROW+1;
   char text[7];
   ReefAngel.LCD.Clear(DefaultBGColor, x+16, y+65, x+65, y+16); 

   ConvertNumToString(text, ReefAngel.Params.Temp1, 10);
   y += MENU_START_ROW*2;
   x = 10;
   ReefAngel.LCD.Clear(DefaultBGColor,x,y,x+(16*4),y+16);
   ReefAngel.LCD.DrawHugeNumbers(T1TempColor, DefaultBGColor, x, y, text);
   x += (16*4) + 8;

   byte TempRelay = ReefAngel.Relay.RelayData;
   TempRelay &= ReefAngel.Relay.RelayMaskOff;
   TempRelay |= ReefAngel.Relay.RelayMaskOn;
   ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);
}


void DrawCustomGraph()
{
}

void setup()
{
   ReefAngel.Init(); //Initialize controller
   
   randomSeed(analogRead(0));
   ReefAngel.Timer[1].SetInterval(random(10,InternalMemory.WM1Timer_read()));
   ReefAngel.Timer[1].Start();
   ReefAngel.Relay.On(Port6);
   
   ReefAngel.FeedingModePorts = B00110000;
   ReefAngel.OverheatShutoffPorts = B00001110;
   ReefAngel.WaterChangePorts = B11110001;

   // Ports that are always on
   ReefAngel.Relay.On(Port8);
   ReefAngel.Relay.On(Port7);
   ReefAngel.Timer[LCD_TIMER].SetInterval(90000);
}

void loop()
{
   ReefAngel.ShowInterface();

   // Specific functions
   //ReefAngel.StandardATO(Port1);
   ReefAngel.StandardLights(Port2, 11, 00, 20, 00);
   ReefAngel.StandardLights(Port3, 10, 00, 22, 00);
   ReefAngel.StandardHeater(Port4);

   //wave maker fonction with night mode 
   if ( (hour() >= 22) || (hour() <= 8) ) // from 10p - 8a
   {
      ReefAngel.Relay.Off(Port6);
      ReefAngel.Relay.On(Port5);
      ReefAngel.LCD.BacklightOff();
   }
   else
   {
      // during the day
      if ( ReefAngel.Timer[1].IsTriggered() )
      {
         ReefAngel.Timer[1].SetInterval(random(25,50));
         ReefAngel.Timer[1].Start();
         ReefAngel.Relay.Toggle(Port6);
         ReefAngel.Relay.Toggle(Port5);
      } 
      ReefAngel.LCD.BacklightOn();
   }
}
Roberto.
wijigong
Posts: 51
Joined: Sat Sep 17, 2011 5:03 am

Re: custom main

Post by wijigong »

hehhee

tank you

i try it
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: custom main

Post by binder »

rimai wrote:One thing you can do is set the timeout to something over 24hrs.
It has to be tested to make sure the timer will take this value.
The max value a timer can hold is something like 4 billion because it's an unsigned long (4 byte) variable. The problem you will get into though is that the function to set the interval is only an int (2 byte) variable which can only hold a value like 32,767. There is 86,400 seconds in a day. You "might" be able to set the value manually but you won't be able to store it in the internal memory the way it is because the LCD Timer is set to be an int storage. You will also have to manually set that timeout inside the setup function too. So you would need something like this inside your setup function:

Code: Select all

void setup()
{
    ReefAngel.Init();
    ReefAngel.Timer[LCD_TIMER].SetInterval(86400);  // LCD Sleep Mode timer
    ReefAngel.Timer[LCD_TIMER].Start();  // start timer
    // rest of functions here
}
It's worth a shot to test.

curt
wijigong
Posts: 51
Joined: Sat Sep 17, 2011 5:03 am

Re: custom main

Post by wijigong »

hello

i try this last weekend, i work find but when the screen is black(after 22h) if i push the jostick the screen dont come on

i think is need somethin like if (ReefAngel.Joystick.IsButtonPressed()) with minimum time for the screen

thank you again
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: custom main

Post by rimai »

Try this one:

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>

//custom dysplay temp+on and off relay 
void DrawCustomMain()
{
   byte x = 6;
   byte y = 2;
   byte t;
   ReefAngel.LCD.DrawDate(6, 2);
   ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
   x = 12;
   y += MENU_START_ROW+1;
   char text[7];
   ReefAngel.LCD.Clear(DefaultBGColor, x+16, y+65, x+65, y+16); 

   ConvertNumToString(text, ReefAngel.Params.Temp1, 10);
   y += MENU_START_ROW*2;
   x = 10;
   ReefAngel.LCD.Clear(DefaultBGColor,x,y,x+(16*4),y+16);
   ReefAngel.LCD.DrawHugeNumbers(T1TempColor, DefaultBGColor, x, y, text);
   x += (16*4) + 8;

   byte TempRelay = ReefAngel.Relay.RelayData;
   TempRelay &= ReefAngel.Relay.RelayMaskOff;
   TempRelay |= ReefAngel.Relay.RelayMaskOn;
   ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);
}


void DrawCustomGraph()
{
}

void setup()
{
   ReefAngel.Init(); //Initialize controller
   
   randomSeed(analogRead(0));
   ReefAngel.Timer[1].SetInterval(random(10,InternalMemory.WM1Timer_read()));
   ReefAngel.Timer[1].Start();
   ReefAngel.Relay.On(Port6);
   
   ReefAngel.FeedingModePorts = B00110000;
   ReefAngel.OverheatShutoffPorts = B00001110;
   ReefAngel.WaterChangePorts = B11110001;

   // Ports that are always on
   ReefAngel.Relay.On(Port8);
   ReefAngel.Relay.On(Port7);
}

void loop()
{
   ReefAngel.ShowInterface();

   // Specific functions
   //ReefAngel.StandardATO(Port1);
   ReefAngel.StandardLights(Port2, 11, 00, 20, 00);
   ReefAngel.StandardLights(Port3, 10, 00, 22, 00);
   ReefAngel.StandardHeater(Port4);

   //wave maker fonction with night mode 
   if ( (hour() >= 22) || (hour() <= 8) ) // from 10p - 8a
   {
      ReefAngel.Relay.Off(Port6);
      ReefAngel.Relay.On(Port5);
      ReefAngel.Timer[LCD_TIMER].SetInterval(60);
      ReefAngel.LCD.BacklightOff();
   }
   else
   {
      // during the day
      if ( ReefAngel.Timer[1].IsTriggered() )
      {
         ReefAngel.Timer[1].SetInterval(random(25,50));
         ReefAngel.Timer[1].Start();
         ReefAngel.Relay.Toggle(Port6);
         ReefAngel.Relay.Toggle(Port5);
      } 
      ReefAngel.Timer[LCD_TIMER].SetInterval(90000);
      ReefAngel.LCD.BacklightOn();
   }
}
Roberto.
wijigong
Posts: 51
Joined: Sat Sep 17, 2011 5:03 am

Re: custom main

Post by wijigong »

finaly is very simple

i juste keep the line

ReefAngel.LCD.BacklightOn();

and is work great

the day is alway on and after 10pm i use the memory setting
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: custom main

Post by rimai »

Cool :)
Nice and easy :)
Roberto.
Post Reply