Sketch too big

Do you have a question on how to do something.
Ask in here.
Post Reply
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

Sketch too big

Post by dtzreef »

Hey everyone....after a bunch of cutting and pasting, I came up with this code but it is a little too big and I cannot figure out what else I can cut out. Please help. Also, I plan on setting my wifi up soon, will this be a problem with a sketch this size? I really haven't learned the wifi stuff yet but thought I would ask. Thanks for the help!

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

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


#include <avr/pgmspace.h>
prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "ATO Clear";
prog_char menu4_label[] PROGMEM = "Overheat Clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "Lights On";
prog_char menu7_label[] PROGMEM = "Lights Off";
prog_char menu8_label[] PROGMEM = "Date/Time";

PROGMEM const char *menu_items[] = {
menu1_label, menu2_label, menu3_label, menu4_label, menu5_label, menu6_label, menu7_label, menu8_label };

void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.ATOClear();
ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.Relay.RelayMaskOn = ReefAngel.LightsOnPorts;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE = ReefAngel.LightsOnPortsE;
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
void MenuEntry7()
{
ReefAngel.Relay.RelayMaskOn = 0;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE = 0;
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
void MenuEntry8()
{
ReefAngel.SetupDateTime();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void DrawCustomMain()
{
ReefAngel.LCD.DrawDate(6, 120);
ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 4, 4 , "DTZ 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, 118, 119, 118);
pingSerial();

ReefAngel.LCD.DrawText(COLOR_GOLDENROD, COLOR_WHITE, 8, 15, "Main Tank:");
char text[7];
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
pingSerial();
ReefAngel.LCD.DrawText(COLOR_GOLDENROD, DefaultBGColor, 88, 15, text);
pingSerial();

ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 50, 46, "pH:");
ConvertNumToString(text, ReefAngel.Params.PH, 100);

ReefAngel.LCD.DrawText(PHColor, DefaultBGColor, 88, 46, text);
pingSerial();

ReefAngel.LCD.DrawText(COLOR_RED, COLOR_WHITE,8,25,"Room Temp:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_RED, 88, 25, 10);

ReefAngel.LCD.DrawText(COLOR_DARKORCHID, COLOR_WHITE,8,36,"Refugium:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 88, 36, 10);

pingSerial();
// Display arrows for Wavemaker
ReefAngel.LCD.DrawText(DPColor,DefaultBGColor, 38, 57,"WAVE FLOW:");
if (bitRead(ReefAngel.Relay.RelayData,Port5-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 49, 67,"----->"); //port 5 on
else if (bitRead(ReefAngel.Relay.RelayData,Port6-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 49, 67,"<-----"); //port 6 on
else ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 49, 67," 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,105,64,t);
pingSerial();

byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}
void DrawCustomGraph()
{
// ReefAngel.LCD.DrawGraph(5, 5);
}

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


void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port2Bit | Port5Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
randomSeed(analogRead(0));
ReefAngel.Timer[1].SetInterval(random(30,45));
ReefAngel.Timer[1].Start();
ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 805 );
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.On(Port2);
ReefAngel.Relay.On(Port8);

////// Place additional initialization code below here


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

void loop()
{
ReefAngel.StandardATO( Port1,600 );
ReefAngel.Relay.DelayedOn( Port2,5 );
ReefAngel.StandardLights( Port3,9,0,21,0 );
ReefAngel.StandardLights( Port4,10,0,20,0 );
ReefAngel.StandardHeater( Port7,770,790 );
ReefAngel.PWM.SetDaylight( MoonPhase() );
ReefAngel.PWM.SetActinic( MoonPhase() );
////// Place your custom code below here
//wavemaker timers and slow down at night
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);
}
}

ReefAngel.Portal( "Dtzreef" );
ReefAngel.ShowInterface();
ReefAngel.LCD.BacklightOn();
}
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Sketch too big

Post by alexwbush »

Is this from the RA wizard? I'm not sure because I've never used wavemaker functions. If it's not, I'd recommend trying to replicate using the wizard and see how large the file is. I don't remember so much menu coding on standard setup.
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

Re: Sketch too big

Post by dtzreef »

It has a custom main screen from Psyrob and a custom menu with Roberto's help. I tweaked and adjusted both parts using RA wizard and other posts as a guide. I am definitely still learning with everyones help.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Sketch too big

Post by rimai »

get rid of setup date time
Roberto.
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

Re: Sketch too big

Post by dtzreef »

So I'm guessing there isn't much else I could remove because how then, would I adjust the date and time? Do I need the upgraded RA board because I haven't even tackled the wifi stuff yet?
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Sketch too big

Post by alexwbush »

You shouldn't have to mess with the date and time much. Only time I ever did was for daylight savings... but I think that might be fixed now.
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

Re: Sketch too big

Post by dtzreef »

You are right, I would have to only change it twice a year for DST. Not too bad. I am worried that I should have got the RA+ since I am already getting "sketch too big" messages. I guess after all these years of reefing I still haven't learned that lesson. Spend more because you're gonna want to upgrade later anyway.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Sketch too big

Post by rimai »

Also, with the wifi, you can sync the time with android or portal. One click and you are done.
Roberto.
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

Re: Sketch too big

Post by dtzreef »

Perfect
Post Reply