Another "sketch too big" error. Need help trimming it

New members questions
Post Reply
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Another "sketch too big" error. Need help trimming it

Post by TanksNStuff »

As the subject says, I'm having a hard time building an .ino file that includes all of my expansion modules and isn't too big to upload to the controller.

Heres' my code so far, and this is straight from RAGen with nothing else added. I even deleted the "ReefAngel.LCD.DrawGraph(5, 5);" from the drawcustomgraph section to remove the graph entirely. Error says the sketch is 32872 bytes (of a 32256 byte maximum)

Code: Select all

// Autogenerated file by RAGen (v1.2.1.158), (02/19/2012 11:52)
// RA_021912_1152.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define DisplayImages
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define SIMPLE_MENU
#define PWMEXPANSION
#define CUSTOM_MAIN
#define RFEXPANSION
#define NUMBERS_8x16
*/


#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 <RF.h>
#include <ReefAngel.h>

void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 112);
    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();
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}

void DrawCustomGraph()
{
}


void setup()
{
    ReefAngel.Init();  //Initialize controller

    ReefAngel.FeedingModePorts = Port1Bit | Port6Bit | Port8Bit;
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;

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

void loop()
{
    // Specific functions
    ReefAngel.StandardHeater(Port2);
    ReefAngel.StandardLights(Port4);
    ReefAngel.Wavemaker1(Port5);
    ReefAngel.Portal("TanksNStuff");

    ReefAngel.PWM.ActinicPWMSlope();
    ReefAngel.PWM.DaylightPWMSlope();

    ReefAngel.ShowInterface();
}
I haven't even begun to add in my custom_main lines nor any of the function lines to control my equipment like I want. What can I do to make this smaller?
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Another "sketch too big" error. Need help trimming it

Post by binder »

Well, to drop some size, I'd recommend dropping these:
  • #define DisplayImages
  • #define VersionMenu
  • #define NUMBERS_8x16
I don't see anything referencing the large numbers / fonts. The DisplayImages isn't really necessary but is kinda neat to have. The VersionMenu isn't critical since you can get the version from the wifi apps. It'll save a few bytes since you are trying to trim things down.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Another "sketch too big" error. Need help trimming it

Post by binder »

Oh, and one more thing....I'd recommend moving the Portal() function down to be above ShowInterface (after the PWM stuff). It's not your fault....it's mine with RAGen. It'll be fixed on next release.

Code: Select all

void loop()
{
    // Specific functions
    ReefAngel.StandardHeater(Port2);
    ReefAngel.StandardLights(Port4);
    ReefAngel.Wavemaker1(Port5);

    ReefAngel.PWM.ActinicPWMSlope();
    ReefAngel.PWM.DaylightPWMSlope();

    ReefAngel.Portal("TanksNStuff");
    ReefAngel.ShowInterface();
}
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Another "sketch too big" error. Need help trimming it

Post by TanksNStuff »

Thanks for the tips Curt. The reason for the large numbers was due to my custom main I was going to transfer over from the old version. It showed the temps and pH numbers larger to make them easier to see. I haven't done that yet because the stock stuff

I guess I can remove that if needed, but I'd prefer that be a last resort.

Here's the latest I have with some of your suggestions. It's still showing 32370 bytes (of a 32256 byte maximum)

Code: Select all

// Autogenerated file by RAGen (v1.2.1.158), (02/19/2012 12:50)
// RA_021912_1250.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define SIMPLE_MENU
#define PWMEXPANSION
#define CUSTOM_MAIN
#define RFEXPANSION
#define NUMBERS_8x16
*/


#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 <RF.h>
#include <ReefAngel.h>

void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 112);
    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();
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}

void DrawCustomGraph()
{
}


void setup()
{
    ReefAngel.Init();  //Initialize controller

    ReefAngel.FeedingModePorts = Port1Bit | Port6Bit | Port8Bit;
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;

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

void loop()
{
    // Specific functions
    ReefAngel.StandardHeater(Port2);
    ReefAngel.StandardLights(Port4);
    ReefAngel.Wavemaker1(Port5);

    ReefAngel.PWM.ActinicPWMSlope();
    ReefAngel.PWM.DaylightPWMSlope();

    ReefAngel.Portal("TanksNStuff");
    ReefAngel.ShowInterface();
}
Looks like I'm going to have to remove the large numbers. :cry:

Do you think I could save more room by going with a custom menu, and then only adding 2 or 3 of the things that are truly needed?
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Another "sketch too big" error. Need help trimming it

Post by TanksNStuff »

Going to retry some changes again, this time with Arduino closed while generating in RAGen. Don't bother reply to my last post yet. Will update here shortly.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Another "sketch too big" error. Need help trimming it

Post by TanksNStuff »

OK, think I got a good start now. Removed a couple things (while arduino was closed) then saved and generated in RAGen. Now I have a base to start with and my file size is much smaller: 30382 bytes (of a 32256 byte maximum)

Code: Select all

// Autogenerated file by RAGen (v1.2.1.158), (02/19/2012 13:08)
// RA_021912_1308.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 1
#define PWMEXPANSION
#define CUSTOM_MAIN
#define RFEXPANSION
#define NUMBERS_8x16
*/


#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 <RF.h>
#include <ReefAngel.h>

#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Item 1";
PROGMEM const char *menu_items[] = {
menu0_label  };

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

void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 112);
    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();
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}

void DrawCustomGraph()
{
}


void setup()
{
    ReefAngel.Init();  //Initialize controller
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

    ReefAngel.FeedingModePorts = Port1Bit | Port6Bit | Port8Bit;
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;

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

void loop()
{
    // Specific functions
    ReefAngel.StandardHeater(Port2);
    ReefAngel.StandardLights(Port4);
    ReefAngel.Wavemaker1(Port5);

    ReefAngel.PWM.ActinicPWMSlope();
    ReefAngel.PWM.DaylightPWMSlope();

    ReefAngel.ShowInterface();
}
Now I'll add in my custom main stuff, and then work on a few simple menus that are "needed". Curt, are the new Clear ATO alarm and Clear Overheat alarm functions available on the android app? If so, I won't need a menu for those.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Another "sketch too big" error. Need help trimming it

Post by binder »

TanksNStuff wrote:Now I'll add in my custom main stuff, and then work on a few simple menus that are "needed". Curt, are the new Clear ATO alarm and Clear Overheat alarm functions available on the android app? If so, I won't need a menu for those.
Not yet. I've been more focused on the library updating and RAGen than the Android app. I've been wanting to make sure everything is running smooth and fix any little, minor "hiccups" with RAGen and the libraries before switching back into the Android App.

The Clear ATO & Overheat alarms are slated to be added to the Android App next. I "might" be able to get them added in this week but it's tough to say. I'm going to have a very busy week with work this week. So we shall see. So to answer your question again: No it's not in there yet.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Another "sketch too big" error. Need help trimming it

Post by TanksNStuff »

OK, I'll have to add those menus in for now then. Thanks for all the help and quick replies!
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Another "sketch too big" error. Need help trimming it

Post by TanksNStuff »

Had to take a break from this stuff yesterday to do some family stuff... so I didn't make much more progress.

I was having an issue with getting some of my expansion relay box ports to turn on using the "ReefAngel.MHLights(Box1_Port3)" (or port 4) in my Void Loop section. It worked whenever I changed the code to "ReefAngel.StandardLights(Box1_Port3)... but for some reason it wasn't activating the outlet when using MHLights function.

My internal memory has Standard lights start at 8:00 AM, end at 10:00 PM and MH Lights start at 10:00 AM, end at 8:30 PM with 5 minute delay. Therefore, they should have both worked at the time I was testing (it was between those hours).

Sorry, I'm at work right now so I can't post my code. My controller is offline at the moment too, but I had my WiFi & Android app operating last night and I was able to read/write data so I changed the MH Light start time just to see if the memory was corrupt or something. Still didn't activate the port.

Is the "ReefAngel.MHLights() function enabled during RAGen or something? None of my initial 8 ports (on main relay box) have that designation, but my Fuge Light was labeled as Standard Light... which would account for why that function worked for me but the MH one didn't.

Reason why I want to use both is to have blues work on Standard schedlue and Whites work on MH schedule.

Any advice on where to start sorting this issue out?

*EDIT ADD*
Just wanted to note that whether the lights came on or not wasn't how I was checking this... my LED fixtures have a power switch that will light up and turn on the fans when the outlet has power... so whether the PWM slope was working didn't matter.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Another "sketch too big" error. Need help trimming it

Post by TanksNStuff »

Well, noone replied on that last issue, but somehow it fixed itself. Maybe the controller just needed to be reset or something because when I booted it up again last night, the MHLights functions were working perfectly for the expansion relay box ports. Yay!

OK, I'm getting closer to getting my code finalized. Here's my Internal Memory File:

Code: Select all

// Autogenerated file by RAGen (v1.2.1.158), (02/19/2012 15:48)
// Memory_021912_1548.ino
//
// This file sets the default values to the Internal Memory
//


#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>


RA_NokiaLCD e;

void setup()
{
    e.Init();
    e.Clear(COLOR_WHITE,0,0,132,132);
    e.BacklightOn();

    InternalMemory.MHOnHour_write(9);
    InternalMemory.MHOnMinute_write(55);
    InternalMemory.MHOffHour_write(20);
    InternalMemory.MHOffMinute_write(30);
    InternalMemory.MHDelay_write(5);
    InternalMemory.StdLightsOnHour_write(8);
    InternalMemory.StdLightsOnMinute_write(0);
    InternalMemory.StdLightsOffHour_write(22);
    InternalMemory.StdLightsOffMinute_write(0);
    InternalMemory.DP1OnHour_write(20);
    InternalMemory.DP1OnMinute_write(0);
    InternalMemory.DP2OnHour_write(22);
    InternalMemory.DP2OnMinute_write(30);
    InternalMemory.DP1Timer_write(0);
    InternalMemory.DP2Timer_write(0);
    InternalMemory.DP1RepeatInterval_write(60);
    InternalMemory.DP2RepeatInterval_write(60);
    InternalMemory.ATOTimeout_write(60);
    InternalMemory.ATOHighTimeout_write(60);
    InternalMemory.ATOHourInterval_write(0);
    InternalMemory.ATOHighHourInterval_write(0);
    InternalMemory.FeedingTimer_write(900);
    InternalMemory.LCDTimer_write(600);
    InternalMemory.LEDPWMActinic_write(50);
    InternalMemory.LEDPWMDaylight_write(50);
    InternalMemory.WM1Timer_write(0);
    InternalMemory.WM2Timer_write(354);
    InternalMemory.HeaterTempOn_write(780);
    InternalMemory.HeaterTempOff_write(791);
    InternalMemory.ChillerTempOn_write(810);
    InternalMemory.ChillerTempOff_write(785);
    InternalMemory.OverheatTemp_write(1500);
    InternalMemory.PHMax_write(840);
    InternalMemory.PHMin_write(550);
    InternalMemory.SalMax_write(2550);
    InternalMemory.RFMode_write(Constant);
    InternalMemory.RFSpeed_write(140);
    InternalMemory.RFDuration_write(8);
    InternalMemory.RFDuration_write(8);
    InternalMemory.PWMSlopeStartD_write(10);
    InternalMemory.PWMSlopeEndD_write(128);
    InternalMemory.PWMSlopeDurationD_write(60);
    InternalMemory.PWMSlopeStartA_write(10);
    InternalMemory.PWMSlopeEndA_write(128);
    InternalMemory.PWMSlopeDurationA_write(60);
    InternalMemory.IMCheck_write(0x5241494D);
}

void loop()
{
    // display success screen
    e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, "Internal Memory Set");
    e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*4, "Now load your");
    e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, "   RA code file");
    delay(5000);
}
Here's my latest .ino file:

Code: Select all

// Autogenerated file by RAGen (v1.2.1.158), (02/21/2012 22:03)
// RA_022112_2203.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 1
#define PWMEXPANSION
#define CUSTOM_MAIN
#define RFEXPANSION
*/


#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 <RF.h>
#include <ReefAngel.h>
//**************************************************************************************************************
//Start of PWM Expansion Code Header

// This is just how we are going to reference the PWM expansion ports within the code.
// You can change the labels if you would like, just as long as they are changed all throughout the code too.
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3
#define LEDPWM4 4
#define LEDPWM5 5

// Initial values to all 6 channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};

//End of PWM Expansion Code Header
//*************************************************************************************************************
boolean ForceCloud=false;

prog_char menu0_label[] PROGMEM = "Feeding Mode";
prog_char menu1_label[] PROGMEM = "Water Change Mode";
prog_char menu2_label[] PROGMEM = "Force Cloud";
prog_char menu3_label[] PROGMEM = "Clear ATO Timeout";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label};

void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}

void MenuEntry3()
{
ForceCloud=true;
ReefAngel.DisplayedMenu=RETURN_MAIN_MODE;
}

void MenuEntry4()
{
ReefAngel.ATOClear();
ReefAngel.DisplayedMenu=RETURN_MAIN_MODE;
}

#include <avr/pgmspace.h>


void DrawCustomMain()
{
    //Draw Top Banner
    ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_SKYBLUE, 9, 2, " George's 75G Reef "); 

    //Draw Date & Time
    ReefAngel.LCD.DrawDate(6, 123);
    pingSerial();

#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor(15, 30, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor(15, 30, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // Display Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox(13, 97, TempRelay);
    pingSerial();

    // Display Expansion Relay Box 1
    TempRelay = ReefAngel.Relay.RelayDataE[0];
    TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
    TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
    ReefAngel.LCD.DrawOutletBox(13, 109, TempRelay);
    pingSerial();
}

void DrawCustomGraph()
{
}


void setup()
{
    ReefAngel.Init();  //Initialize controller
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

    ReefAngel.FeedingModePorts =         B10000001;
    ReefAngel.WaterChangePorts =         B11100001;
    ReefAngel.OverheatShutoffPortsE[0] = B00001111;
    ReefAngel.LightsOnPortsE[0] =        B00001111;

    // Ports that are always on
    ReefAngel.Relay.On(Port1);
    ReefAngel.Relay.On(Port3);
    ReefAngel.Relay.On(Port5);
    ReefAngel.Relay.On(Port6);
    ReefAngel.Relay.On(Port7);
    ReefAngel.Relay.On(Port8);
    ReefAngel.Relay.On(Box1_Port7);
    ReefAngel.Relay.On(Box1_Port8);
}

void loop()
{
    // Specific functions
    ReefAngel.StandardHeater(Port2);
    ReefAngel.StandardLights(Box1_Port1); //Left Blue LEDs
    ReefAngel.StandardLights(Box1_Port2); //Right Blue LEDs
    ReefAngel.MHLights(Box1_Port3); //Left White LEDs
    ReefAngel.MHLights(Box1_Port4); //Right White LEDs
    ReefAngel.MoonLights(Box1_Port5); //Left Moonlight
    ReefAngel.MoonLights(Box1_Port6); //Right Moonlight
    ReefAngel.MoonLights(Port4); //Fuge light on when main lights are out
    ReefAngel.PWM.ActinicPWMSlope();
    ReefAngel.PWM.DaylightPWMSlope();    
    ReefAngel.Portal("TanksNStuff");
    

//*********************************************************************************************************************************
//Start of PWM Expansion Code for Slope
PWMChannel[LEDPWM0]=PWMSlope(8,0,22,00,9,50,60,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(8,0,22,00,10,50,60,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(10,0,20,30,9,50,75,PWMChannel[LEDPWM2]);
PWMChannel[LEDPWM3]=PWMSlope(10,0,20,30,10,50,75,PWMChannel[LEDPWM3]);

// The lines above are what calculates the slope.
// You can change the schedule by changing the parameter inside the parenthesis of the PWMSlope() function
// The are as follow:
// 1st parameter: hour to start slope
// 2nd parameter: minute to start slope
// 3rd parameter: hour to end slope
// 4th parameter: minute to end slope
// 5th parameter: % of the PWM signal to start slope
// 6th parameter: % of the PWM signal to end slope
// 7th parameter: duration of slope in minutes
// 8th parameter: always the same as the variable before the PWMSlope() call

//PWMChannel[LEDPWM1]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM1]);

// In the example above, we are starting the slope at 3:00pm with 15% and going up to 45% within 90 minutes, which would be 4:30pm.
// Then it would stay at 45% from 4:30 to 90 minutes prior to 9:30pm, which would be 8:00pm.
// Then from 8:00pm, it would start sloping down from 45% all the way back to 15% within 90 minutes, which would be 9:30pm.
//CheckCloud();
ReefAngel.PWM.Expansion(LEDPWM0,int(2.55*PWMChannel[LEDPWM0]));
ReefAngel.PWM.Expansion(LEDPWM1,int(2.55*PWMChannel[LEDPWM1]));
ReefAngel.PWM.Expansion(LEDPWM2,int(2.55*PWMChannel[LEDPWM2]));
ReefAngel.PWM.Expansion(LEDPWM3,int(2.55*PWMChannel[LEDPWM3]));
//End of PWM Expansion Code for Slope
//*********************************************************************************************************************************


    ReefAngel.ShowInterface();
}
As you can see, I copy/pasted from some stuff I found on these forums to get the basic functions I needed, then tweaked them to match my setup.

I was able to test 1 of my LED lights with the modified PWM module (Roberto made one Analog for me) and that seemed to work fine with my code above. I did a test run with the PWM slope to make it ramp up quickly for each channel... just to see it brighten in real time as if time were going by faster. Worked great! After the test, I changed the slope back to what I have in the .ino above. I also temporarily changed the On Hour and On Minutes for standard and MH Light ports to match my test PWM slope times via WiFi and the Android App... and that worked like a champ too! As with the the other test, I then reset those internal memory settings back to what my internal memory file above shows.

I didn't try both LED's (and therefore didn't test the other 2 PWM channels) but I'm pretty confident that they will all work based on what I saw with the tests. Roberto, I want to do a few more tests before sending my old PWM module back to you if you don't mind but everything looks great so far. Should be going back to you by monday. **NOTE TO SELF** I still need to check if 1% - 9% signal turns lights on instead of needing 10% signal (now that I have modified analog signal for PWM module).

Now, some issues I'm having that keep this topic's thread open....running out of code space and I need more functions. :cry:

1. If you noticed, there's a menu item for "Force Cloud", along with some variables needed for that function. However, when I added the code I found to make that function happen, it made my file too big. Looks like I'm going to have to remove that from the menu and remove the variables associated with it.

2. As with the cloud function, I don't think there's any way I'll be able to have any storm functions either.

3. When I was about passing out at my computer, I tried to add some code for the RF Module (that I just got yesterday too). Do I need to do anything other than enable it in RAGen? I see there are memory seetings I can change in the Android App, but since my controller isn't live on my tank yet I didn't set my MP40 to slave to test any of them. I'm hoping I don't need any other code for this as that would take up more space I don't have.

4. I still need to add lines in the code to set FEED MODE (I want 2 automatic runs during the day for 15 minutes each, and then use the Android App to enter that mode when I feed manually. I'm guessing this should be a few simple IF/ELSE lines but I'm running out of room fast.

5. Not sure about my moonlights. I think they came on when both Standard and MH lights were off, so I probably don't need to do much else for them. I did assign them to the appropriate relay ports in my code, so is that enough to have them come on automatically? I don't see any moonlight memory settings in the Android App, so I'm guessing they operate opposite the MH/Standard ON/OFF times? I still may want to select a specified OFF time for moonlights though, and that will need to fit in regardless.

6. Not really a file size issue, but something that I need help with. Is there any way to change the PWMChannel slope settings via WiFi (via Android App or Client) so that I don't have to re-upload code when I want to adjust the settings? I know Curt said it's on the todo list for the Android App. Can I even just do it on my PC via the WiFi default page or something? If/when this gets added to Android App, it may save me a few lines of code that I used assigning the PWMChannel labels, etc.

7. I know this is on the todo list for Curt too, but it would really be helpful to see/change status of the expansion relay box ports on Android.

Even though that's a lot of questions, I think I made great progress last night. Unfortunately, I'm sure I'll have more to resolve after trying to tackle more of the above tonight. :lol:
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Another "sketch too big" error. Need help trimming it

Post by rimai »

You are hardcore!!! :o
Having fun yet??
Unfortunatelly, there is so much you can pack and squeeze on the standard RA.
There is the RA+ that is sold on special order basis.
It has basically 256K of memory size compared to 32K of the standard RA.
You can enable all the features and still have tons of memory left.
http://forum.reefangel.com/viewtopic.php?f=2&t=778
http://i761.photobucket.com/albums/xx25 ... 191741.jpg
Roberto.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Another "sketch too big" error. Need help trimming it

Post by TanksNStuff »

Haha, yea, I'm just beginning to get this puppy the way I want it. That's why I chose this controller because I can customize it the way I want.

Wish I knew about the RA+ before I bought the regular model... I would have gotten that for sure. Do you take trade ins on a barely used one Roberto? :P

With all the expansion modules I have, I may need the bigger memory just to get the basics I need, let alone all the toys I want.

Can you PM me info on price and availability please?
Mike S
Posts: 82
Joined: Tue Dec 27, 2011 7:26 pm

Re: Another "sketch too big" error. Need help trimming it

Post by Mike S »

Your cranking away at it George. I'd like to check out the RF unit when you get it working. I'm thinking about one down the road for my mp40s. Did you ever figure out when your lights are cutting off? I think I'm at about 9% but I can't tell for sure until I get my android app working again.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Another "sketch too big" error. Need help trimming it

Post by TanksNStuff »

No, I didn't get a chance to test anything tonight. Sadly, I fell asleep on the couch watching tv with the wife... and I'm too tired to pull everything out now. I think I've had too many late nights with this stuff and need a break. I'll be back at it tomorrow night I guess.

Yea, when I get the RF unit working, you can stop by and check it out if you want.
Post Reply