Page 1 of 1

setting up ReefAngel plus

Posted: Sat Jun 23, 2012 10:07 pm
by psyrob
I just got the new board and I haven't popped it in yet, but I have a question about uploading code. I generated a new file with ReefAngel Generator, open Arduino and switch under tools>controller to "ReefAngel Plus"verify it and it is ok.

Then I open my current .INO file and cut and paste my custom code into the new ino generated by the RA Gen....But when I verify that, I keep getting errors I never saw before, ...it's long, too long to type, but starts with something like, "program files (x86) reefangel controller/hardware/tools/avr/bin etc"
What do I need to do to start the process of moving over to the RA plus board?
Thanks

Re: setting up ReefAngel plus

Posted: Sat Jun 23, 2012 10:40 pm
by psyrob

Code: Select all

// Autogenerated file by RAGen (v1.2.2.171), (06/23/2012 21:48)
// RA_062312_2148.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define DisplayImages
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 4
#define CUSTOM_MAIN
#define COLORS_PDE
#define FONT_8x8
#define FONT_8x16
*/


#include <ReefAngel_Features.h>
#include <RA_Colors.h>
#include <RA_CustomColors.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 <ReefAngel.h>

////// Place global variable code below here
byte wmport=Port5;
boolean wmdelay=false;

////// Place global variable code above here

#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Feeding Mode";
prog_char menu1_label[] PROGMEM = "Water Change";
prog_char menu2_label[] PROGMEM = "ph calibrate";
prog_char menu3_label[] PROGMEM = "Clear Overheat";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label  };

void MenuEntry1()
{
ReefAngel.DisplayMenuEntry("Item 1");
ReefAngel.FeedingModeStart();

}
void MenuEntry2()
{
ReefAngel.DisplayMenuEntry("Item 2");
ReefAngel.WaterChangeModeStart();

}
void MenuEntry3()
{
ReefAngel.DisplayMenuEntry("Item 3");
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;

}
void MenuEntry4()
{
ReefAngel.DisplayMenuEntry("Item 4");

}

void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 120);
  ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 4, 4 , "ROB'S REEF ANGEL");
  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();


  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 8, 15, "Big Tank");
  char text[7];
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, DefaultBGColor, 18, 30, text);
 
  pingSerial(); 
  ReefAngel.LCD.DrawText(COLOR_RED, COLOR_WHITE,8,48,"Frag:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_RED, 40, 48, 10);

  ReefAngel.LCD.DrawText(COLOR_DARKORCHID, COLOR_WHITE,70,48,"Room:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 100, 48, 10);

  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 92, 15, "pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);

  ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, 88, 30, text);
  pingSerial();


  // Display arrows for Wavemaker
  ReefAngel.LCD.DrawText(DPColor,DefaultBGColor, 5, 64,"WAVE FLOW:");
  if (bitRead(ReefAngel.Relay.RelayData,Port5-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"----->"); //port 5 on
  else if (bitRead(ReefAngel.Relay.RelayData,Port6-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"<-----");  //port 6 on
  else ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64," 00000 "); //port5 and port 6 off, wavemaker delay
  //show the timer for wavemaker
  int t=ReefAngel.Timer[1].Trigger-now();
  if (t>=0)
    ReefAngel.LCD.Clear(255,105,64,135,74);
  ReefAngel.LCD.DrawText(APColor, COLOR_KHAKI,110,64,t);
  pingSerial();
 
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,79,"Actinic");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,89,"FragLt");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,99,"WM RT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,109,"Fan");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,79,"ATO");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,89,"DayLts");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,99,"WM LFT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,109,"Heater");
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawCircleOutletBox(60, 81, TempRelay, true);
}

void DrawCustomGraph()
{
    
}


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    // Initialize the custom menu
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;

    // Ports that are always on
    ReefAngel.Relay.On(Port1);
    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    // Specific functions that use Internal Memory values
    ReefAngel.StandardLights(Port2);
    ReefAngel.MHLights(Port3);
    ReefAngel.MHLights(Port4);
   // ReefAngel.Wavemaker1(Port5);
    //ReefAngel.Wavemaker2(Port6);
    ReefAngel.StandardHeater(Port7);
    ReefAngel.StandardFan(Port8);

    // PWMSlope based on Internal Memory values for Standard Lights
    ReefAngel.PWM.ActinicPWMSlope();
    ReefAngel.PWM.DaylightPWMSlope();
    ////// Place your custom code below here
    if ( ReefAngel.Timer[1].IsTriggered() )
  {
    if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a  
    {
      if (wmdelay)
      {
        ReefAngel.Timer[1].SetInterval(60);  // wm night delay
        ReefAngel.Timer[1].Start();
        ReefAngel.Relay.Off(Port5);
        ReefAngel.Relay.Off(Port6);
        if (wmport==Port5) wmport=Port6; 
        else wmport=Port5;
        wmdelay=false;
      }
      else
      {
        ReefAngel.Timer[1].SetInterval(20);  // short wave
        ReefAngel.Timer[1].Start();
        ReefAngel.Relay.On(wmport);
        wmdelay=true;
      }
    }
    else
    {
      //8a-9p normal wave settings
      ReefAngel.Timer[1].SetInterval(random(35,50));
      ReefAngel.Timer[1].Start();
      ReefAngel.Relay.Toggle(Port5);
      if bitRead(ReefAngel.Relay.RelayData,Port5-1) ReefAngel.Relay.Off(Port6); 
      else ReefAngel.Relay.On(Port6);
    }
  }

    ////// Place your custom code above here
    // This sends all the data to the portal
    // Do not add any custom code that changes any relay status after this line
    // The only code after this line should be the ShowInterface function
    ReefAngel.Portal("psyrob");

    // This should always be the last line
    ReefAngel.ShowInterface();
}

Re: setting up ReefAngel plus

Posted: Sun Jun 24, 2012 7:48 am
by rimai
Wow man, that one is something else :(
It's a bug on the way Arduino is compiling the code.
You had it just right, I guess, to get that error :shock: :) Murphy's law.
I couldn't figure out what the problem is, but the work around is to increase the size of your menu labels.
Anything should do.
I simply used "Water Change Mode" instead of "Water Changel" and the error went away... :?

Re: setting up ReefAngel plus

Posted: Sun Jun 24, 2012 11:06 am
by psyrob
Thanks Roberto, I made the change and it verified without a problem...
When I put in the RA+ board, do I just upload this code? Or do I have to upload an internal memory from RAGen first?

Re: setting up ReefAngel plus

Posted: Sun Jun 24, 2012 11:28 am
by rimai
Best to upload an internal memory first to make sure you have all memory settings initialized.

Re: setting up ReefAngel plus

Posted: Sun Jun 24, 2012 12:35 pm
by psyrob
Roberto: I got the RA+ up and running, it booted up on its own with internal memory settings loaded...

I then uploaded my code and my wave maker is messed up....It was working to pick a random time between 35 and 50 seconds, then display the number counting down and an arrow to show which pump was running. At night there was an interval of no pumps running on the wavemaker and the screen would show "OOOO" as a result.

I added moonlights to this code and now the screen is showing the "OOOOO" constantly and there is a negative number showing that is only increasing as time goes on, it started at -160 and now is up to -223 and the wavemaker isnt working...what have I screwed up?

Here is the code...
// Autogenerated file by RAGen (v1.2.2.171), (06/23/2012 21:48)
// RA_062312_2148.ino
//This is the first try to upload to ReefAngel Plus Board, includes moonlights
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define DisplayImages
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 4
#define CUSTOM_MAIN
#define COLORS_PDE
#define FONT_8x8
#define FONT_8x16
*/


#include <ReefAngel_Features.h>
#include <RA_Colors.h>
#include <RA_CustomColors.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 <ReefAngel.h>

////// Place global variable code below here
byte wmport=Port5;
boolean wmdelay=false;

////// Place global variable code above here

#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Feeding Mode";
prog_char menu1_label[] PROGMEM = "Water Change Mode";
prog_char menu2_label[] PROGMEM = "ph calibrate";
prog_char menu3_label[] PROGMEM = "Clear Overheat";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label  };

void MenuEntry1()
{
ReefAngel.DisplayMenuEntry("Item 1");
ReefAngel.FeedingModeStart();

}
void MenuEntry2()
{
ReefAngel.DisplayMenuEntry("Item 2");
ReefAngel.WaterChangeModeStart();

}
void MenuEntry3()
{
ReefAngel.DisplayMenuEntry("Item 3");
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;

}
void MenuEntry4()
{
ReefAngel.DisplayMenuEntry("Item 4");

}

void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 120);
  ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 4, 4 , "ROB'S REEF ANGEL");
  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();


  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 8, 15, "Big Tank");
  char text[7];
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, DefaultBGColor, 18, 30, text);
 
  pingSerial();
  ReefAngel.LCD.DrawText(COLOR_RED, COLOR_WHITE,8,48,"Frag:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_RED, 40, 48, 10);

  ReefAngel.LCD.DrawText(COLOR_DARKORCHID, COLOR_WHITE,70,48,"Room:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 100, 48, 10);

  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 92, 15, "pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);

  ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, 88, 30, text);
  pingSerial();


  // Display arrows for Wavemaker
  ReefAngel.LCD.DrawText(DPColor,DefaultBGColor, 5, 64,"WAVE FLOW:");
  if (bitRead(ReefAngel.Relay.RelayData,Port5-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"----->"); //port 5 on
  else if (bitRead(ReefAngel.Relay.RelayData,Port6-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"<-----"); //port 6 on
  else ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64," 00000 "); //port5 and port 6 off, wavemaker delay
  //show the timer for wavemaker
  int t=ReefAngel.Timer[1].Trigger-now();
  if (t>=0)
    ReefAngel.LCD.Clear(255,105,64,135,74);
  ReefAngel.LCD.DrawText(APColor, COLOR_KHAKI,110,64,t);
  pingSerial();
 
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,79,"Actinic");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,89,"FragLt");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,99,"WM RT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,109,"Fan");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,79,"ATO");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,89,"DayLts");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,99,"WM LFT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,109,"Heater");
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawCircleOutletBox(60, 81, TempRelay, true);
}

void DrawCustomGraph()
{
    
}


void setup()
{
    // This must be the first line
    ReefAngel.Init(); //Initialize controller
    // Initialize the custom menu
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;
// Set Actinic and Daylight off by default
    ReefAngel.PWM.SetActinic(0);
    ReefAngel.PWM.SetDaylight(0);

    // Ports that are always on
    ReefAngel.Relay.On(Port1);
    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    // Specific functions that use Internal Memory values
    ReefAngel.StandardLights(Port2);
    ReefAngel.MHLights(Port3);
    ReefAngel.MHLights(Port4);
   // ReefAngel.Wavemaker1(Port5);
    //ReefAngel.Wavemaker2(Port6);
    ReefAngel.StandardHeater(Port7);
    ReefAngel.StandardFan(Port8);

    // PWMSlope based on Internal Memory values for Standard Lights
    ReefAngel.PWM.ActinicPWMSlope();
    ReefAngel.PWM.DaylightPWMSlope();
    ////// Place your custom code below here
    if ( hour() <= 6 || hour () >= 22 ) // Moonlights on from 7PM to 7AM
{
ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);

}

    if ( ReefAngel.Timer[1].IsTriggered() )
  {
    if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
    {
      if (wmdelay)
      {
        ReefAngel.Timer[1].SetInterval(60); // wm night delay
        ReefAngel.Timer[1].Start();
        ReefAngel.Relay.Off(Port5);
        ReefAngel.Relay.Off(Port6);
        if (wmport==Port5) wmport=Port6;
        else wmport=Port5;
        wmdelay=false;
      }
      else
      {
        ReefAngel.Timer[1].SetInterval(20); // short wave
        ReefAngel.Timer[1].Start();
        ReefAngel.Relay.On(wmport);
        wmdelay=true;
      }
    }
    else
    {
      //8a-9p normal wave settings
      ReefAngel.Timer[1].SetInterval(random(35,50));
      ReefAngel.Timer[1].Start();
      ReefAngel.Relay.Toggle(Port5);
      if bitRead(ReefAngel.Relay.RelayData,Port5-1) ReefAngel.Relay.Off(Port6);
      else ReefAngel.Relay.On(Port6);
    }
  }

    ////// Place your custom code above here
    // This sends all the data to the portal
    // Do not add any custom code that changes any relay status after this line
    // The only code after this line should be the ShowInterface function
    ReefAngel.Portal("psyrob");

    // This should always be the last line
    ReefAngel.ShowInterface();
}


Re: setting up ReefAngel plus

Posted: Sun Jun 24, 2012 3:16 pm
by rimai
I think you need to initialize the timer 1.
Add this to your setup() section:

Code: Select all

ReefAngel.Timer[1].SetInterval(1);
ReefAngel.Timer[1].Start();

Re: setting up ReefAngel plus

Posted: Sun Jun 24, 2012 3:50 pm
by psyrob
That did the trick...thanks Roberto