Dimmable Moonlight

Do you have a question on how to do something.
Ask in here.
Post Reply
tkeracer619
Posts: 159
Joined: Thu Nov 24, 2011 9:50 pm
Location: Golden, CO

Dimmable Moonlight

Post by tkeracer619 »

I have read through a couple of the threads but haven't had success. I have the RA Dimmable Moonlight plugged into the Actinic PWM port. I was trying to get this working but when I think I do it says its too big. My current code is 31464 of 32256 bytes.

What should I place in my features file when adding the moonlight? I tried to use the info in this thread but it pushes it over the limit. http://forum.reefangel.com/viewtopic.ph ... ight#p1099

Is there a way that uses less memory or anything I might be able to trim away to let me squeeze by. I have 2 IO and salinity modules hooked up and would like to add the moonlight and then maybe the RF module if I can somehow make it fit. I am going to get the plus soon but for now was hoping to get it going.


This is the code the controller is running on now before any of my attempts. Thanks!

Code: Select all

     
            #define Actinic             1
            #define T5A                 2
            #define T5B                 3
            #define MH                  4
            #define Autofeeder          5
            #define Blank2              6
            #define FastFlush           7
            #define ReverseOsmosis      8

            #include <Salinity.h>
            #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 <RF.h>
            #include <IO.h>
            #include <ORP.h>
            #include <AI.h>
            #include <ReefAngel.h>
           
            byte IOIn[7];
            byte IOIn1[7];
            int Flow0;
            int Flow1;
            int Flow2;
            int Flow01;
            int Flow11;
            int Flow21;
            char text[12];

            void DrawCustomMain()
            {
              // the graph is drawn/updated when we exit the main menu &
              // when the parameters are saved
              ReefAngel.LCD.DrawDate(6, 122);
              pingSerial();
            #if defined DisplayLEDPWM && ! defined RemoveAllLights
              ReefAngel.LCD.DrawMonitor(15, 60, 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();
              char text[10];
              ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
              strcat(text,"  ");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,15,93,"Salinity:");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,75,93,text);
              pingSerial();
              byte TempRelay = ReefAngel.Relay.RelayData;
              TempRelay &= ReefAngel.Relay.RelayMaskOff;
              TempRelay |= ReefAngel.Relay.RelayMaskOn;
              ReefAngel.LCD.DrawOutletBox(12, 103, TempRelay);
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,4,"CBN:");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,15,"GFO:");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,26,"BIO:");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,4,"GPH");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,15,"GPH");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,26,"GPH");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,37,"DSP:");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,48,"BTA:");
              //ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,59,"CAL:");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,37,"GPH");
              ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,48,"GPH");
              //ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,59,"GPH");
             
          ConvertNumToString(text, Flow0, 1);
          strcat(text,"");
          ReefAngel.LCD.DrawText(0, 255, 29, 4, text);
          ConvertNumToString(text, Flow1, 1);
          strcat(text,"");
          ReefAngel.LCD.DrawText(0, 255, 29, 15, text);
          ConvertNumToString(text, Flow2, 1);
          strcat(text,"");
          ReefAngel.LCD.DrawText(0, 255, 29, 26, text);

          GetFlow1();
          ConvertNumToString(text, Flow01, 1);
          strcat(text,"");
          ReefAngel.LCD.DrawText(0, 255, 29, 37, text);
          ConvertNumToString(text, Flow11, 1);
          strcat(text,"");
          ReefAngel.LCD.DrawText(0, 255, 29, 48, text);
          //ConvertNumToString(text, Flow21, 1);
          //strcat(text,"");
          //ReefAngel.LCD.DrawText(0, 255, 29, 59, text);
            }

            void DrawCustomGraph()
            {
              //ReefAngel.LCD.DrawGraph(5, 5);
            }
            void setup()
            {
              ReefAngel.Init();  //Initialize controller
              ReefAngel.FeedingModePorts = B00000000;
              ReefAngel.WaterChangePorts = B00000000;
              ReefAngel.OverheatShutoffPorts = B00000000;
              ReefAngel.LightsOnPorts = B00000111;
            }

            void loop()
            {
              ReefAngel.StandardLights(Actinic,11,0,24,0);  //Actinic schedule 11:00am - 12:00am
              ReefAngel.StandardLights(T5A,11,30,22,15);  //Blue Plus 1 schedule 11:30am - 11:15pm
              ReefAngel.StandardLights(T5B,11,45,22,30);  //Blue Plus 2 schedule 11:45am - 11:30pm
              ReefAngel.MHLights(MH,12,30,21,15,15);  //Metal Halide schedule 12:30pm - 9:15pm with 15min cool down
              ReefAngel.StandardLights(FastFlush,9,45,9,55);  //RO Fast Flush schedule 9:45am - 9:55pm
              ReefAngel.StandardLights(ReverseOsmosis,9,45,13,0);  //RO Fast Flush schedule 9:45am - 1:00pm
              GetFlow();
              GetFlow1();
              ReefAngel.Portal("tkeracer619");
              ReefAngel.ShowInterface();
            }

            void GetFlow()
            {
              Wire.requestFrom(9,7);
              if(Wire.available())
              {
                for (int a=0;a<8;a++)
                  IOIn[a]=Wire.read();
              }
              Flow0=(IOIn[1]<<8)+IOIn[2];
              Flow1=(IOIn[3]<<8)+IOIn[4];
              Flow2=(IOIn[5]<<8)+IOIn[6];
            }

            void GetFlow1()
            {
              Wire.requestFrom(10,7);
              if(Wire.available())
              {
                for (int a=0;a<8;a++)
                  IOIn1[a]=Wire.read();
              }
              Flow01=(IOIn1[1]<<8)+IOIn1[2];
              Flow11=(IOIn1[3]<<8)+IOIn1[4];
              Flow21=(IOIn1[5]<<8)+IOIn1[6];
            }

     
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Dimmable Moonlight

Post by rimai »

Use this code:

Code: Select all


#define Actinic             1
#define T5A                 2
#define T5B                 3
#define MH                  4
#define Autofeeder          5
#define Blank2              6
#define FastFlush           7
#define ReverseOsmosis      8

#include <Salinity.h>
#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 <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

byte IOIn[7];
byte IOIn1[7];
int Flow0;
int Flow1;
int Flow2;
int Flow01;
int Flow11;
int Flow21;
char text[12];

void DrawCustomMain()
{
  // the graph is drawn/updated when we exit the main menu &
  // when the parameters are saved
  ReefAngel.LCD.DrawDate(6, 122);
  pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor(15, 60, 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();
  char text[10];
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  strcat(text,"  ");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,15,93,"Salinity:");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,75,93,text);
  pingSerial();
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 103, TempRelay);
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,4,"CBN:");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,15,"GFO:");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,26,"BIO:");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,4,"GPH");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,15,"GPH");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,26,"GPH");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,37,"DSP:");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,48,"BTA:");
  //ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,4,59,"CAL:");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,37,"GPH");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,48,"GPH");
  //ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,42,59,"GPH");

  ConvertNumToString(text, Flow0, 1);
  strcat(text,"");
  ReefAngel.LCD.DrawText(0, 255, 29, 4, text);
  ConvertNumToString(text, Flow1, 1);
  strcat(text,"");
  ReefAngel.LCD.DrawText(0, 255, 29, 15, text);
  ConvertNumToString(text, Flow2, 1);
  strcat(text,"");
  ReefAngel.LCD.DrawText(0, 255, 29, 26, text);

  GetFlow1();
  ConvertNumToString(text, Flow01, 1);
  strcat(text,"");
  ReefAngel.LCD.DrawText(0, 255, 29, 37, text);
  ConvertNumToString(text, Flow11, 1);
  strcat(text,"");
  ReefAngel.LCD.DrawText(0, 255, 29, 48, text);
  //ConvertNumToString(text, Flow21, 1);
  //strcat(text,"");
  //ReefAngel.LCD.DrawText(0, 255, 29, 59, text);
}

void DrawCustomGraph()
{
  //ReefAngel.LCD.DrawGraph(5, 5);
}
void setup()
{
  ReefAngel.Init();  //Initialize controller
  ReefAngel.FeedingModePorts = B00000000;
  ReefAngel.WaterChangePorts = B00000000;
  ReefAngel.OverheatShutoffPorts = B00000000;
  ReefAngel.LightsOnPorts = B00000111;
}

void loop()
{
  ReefAngel.StandardLights(Actinic,11,0,24,0);  //Actinic schedule 11:00am - 12:00am
  ReefAngel.StandardLights(T5A,11,30,22,15);  //Blue Plus 1 schedule 11:30am - 11:15pm
  ReefAngel.StandardLights(T5B,11,45,22,30);  //Blue Plus 2 schedule 11:45am - 11:30pm
  ReefAngel.MHLights(MH,12,30,21,15,15);  //Metal Halide schedule 12:30pm - 9:15pm with 15min cool down
  ReefAngel.StandardLights(FastFlush,9,45,9,55);  //RO Fast Flush schedule 9:45am - 9:55pm
  ReefAngel.StandardLights(ReverseOsmosis,9,45,13,0);  //RO Fast Flush schedule 9:45am - 1:00pm
  ReefAngel.PWM.SetActinic(MoonPhase());
  GetFlow();
  GetFlow1();
  ReefAngel.Portal("tkeracer619");
  ReefAngel.ShowInterface();
}

void GetFlow()
{
  Wire.requestFrom(9,7);
  if(Wire.available())
  {
    for (int a=0;a<8;a++)
      IOIn[a]=Wire.read();
  }
  Flow0=(IOIn[1]<<8)+IOIn[2];
  Flow1=(IOIn[3]<<8)+IOIn[4];
  Flow2=(IOIn[5]<<8)+IOIn[6];
}

void GetFlow1()
{
  Wire.requestFrom(10,7);
  if(Wire.available())
  {
    for (int a=0;a<8;a++)
      IOIn1[a]=Wire.read();
  }
  Flow01=(IOIn1[1]<<8)+IOIn1[2];
  Flow11=(IOIn1[3]<<8)+IOIn1[4];
  Flow21=(IOIn1[5]<<8)+IOIn1[6];
}
And this features file:

Code: Select all

#ifndef __REEFANGEL_FEATURES_H__
#define __REEFANGEL_FEATURES_H__


#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
#define CUSTOM_MAIN
#define SALINITYEXPANSION
#define RFEXPANSION


#endif  // __REEFANGEL_FEATURES_H__
With the above features file I was able to pack everything including the RF stuff.
Roberto.
tkeracer619
Posts: 159
Joined: Thu Nov 24, 2011 9:50 pm
Location: Golden, CO

Re: Dimmable Moonlight

Post by tkeracer619 »

Awesome thanks!!

I will let you know how it goes. Uploaded fine.

Also gave me a little more room for my display :mrgreen:
Image
Post Reply