Size of the sketch its killing me

Do you have a question on how to do something.
Ask in here.
Post Reply
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Size of the sketch its killing me

Post by Bo0sted_Rafi »

I need if someone can do a miracle in this sketch to fit in my RA.

I know its too big because my ph coding its complicate but im trying to add the PWM codes and that adds 1800 bytes more than i without control my lights!!! Í think my custom screen its killing my memory too but if someone let me know what can i do to resolve this, let me know.

This its my code

Code: Select all

 #define SIMPLE_MENU
    #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 <InternalEEPROM.h>
    #include <RA_Colors.h>
    #include <RA_CustomColors.h>
    #include <Salinity.h>
    #include <RF.h>
    #include <IO.h>
    #include <ORP.h>
    #include <AI.h>
    #include <PH.h>
    #include <WaterLevel.h>
    #include <ReefAngel.h>

    ////// Place global variable code below here
    int avgph[10];
    unsigned long totalavgph=0;
    byte avgindex=0;

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


    void setup()
    {
      // This must be the first line
      ReefAngel.Init(); //Initialize controller
      // Ports toggled in Feeding Mode
      ReefAngel.UseFlexiblePhCalibration();
      ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port3Bit;
      // Ports toggled in Water Change Mode
      ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port6Bit;
      // Ports toggled when Lights On / Off menu entry selected
      ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port6Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
      // Ports turned off when Overheat temperature exceeded
      ReefAngel.OverheatShutoffPorts = 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( 830 );

      // Ports that are always on
      ReefAngel.Relay.On( Port1 );
      ReefAngel.Relay.On( Port5 );

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

      for (int a=0;a<10;a++) avgph[a]=analogRead(PHPin);

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

    void loop()
    {
      totalavgph=0;
      avgph[avgindex]=analogRead(PHPin);
      avgindex++;
      if (avgindex==10) avgindex=0;
      for (int a=0;a<10;a++)
        totalavgph+=avgph[a];
      totalavgph/=10;

      totalavgph=map(totalavgph, ReefAngel.PHMin, ReefAngel.PHMax, 700, 1000); // apply the calibration to the sensor reading
      totalavgph=constrain(totalavgph,100,1400);

      if (totalavgph <= 644) ReefAngel.Relay.Off(Port3); 
      if (totalavgph >= 656) ReefAngel.Relay.On(Port3); 

      ReefAngel.Relay.DelayedOn( Port2 );
      //    ReefAngel.CO2Control( Port3,644,655 );
      ReefAngel.StandardFan( Port4,780,788 );
      ReefAngel.WavemakerRandom( Port6,1200,240 );
      ReefAngel.StandardLights( Port7,0,30,12,30 );
      ReefAngel.StandardLights( Port8,12,0,2,0 );
      ReefAngel.PWM.SetDaylight(PWMSlope(17,0,0,3,0,12,3,0));
      ReefAngel.PWM.SetDaylight(PWMSlope(18,30,22,33,12,45,3,ReefAngel.PWM.GetDaylightValue())); 
      ReefAngel.PWM.SetActinic( PWMSlope(15,0,1,0,9,60,30,9) );
      ////// Place your custom code below here
      ////// Place your custom code above here

      // This should always be the last line
      ReefAngel.Portal( "Bo0sted_Rafi" );
      ReefAngel.ShowInterface();
  }
     void DrawCustomMain()
    {
      byte x;
      byte y = 2;
      char text[7];

      // *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
      int TempColor;        // Color for drawing temperature
      boolean FanOn = ReefAngel.Relay.Status(Port4);    // Get the status of the fan relay
      boolean HeatOn = ReefAngel.Relay.Status(Port7);   // Get the status of the heater relay
      if (HeatOn) 
      {
        TempColor = COLOR_NAVY;    // Blue text, too cold, heater is on
      }
      if (FanOn)   
      {
          TempColor = COLOR_RED;   // Red text, too warm, fan is on
      }
      if (!HeatOn && !FanOn) 
      {
          TempColor = COLOR_GREEN;  // Green text, no fan or heater on
      }
      // ***********************************************************************************
     
      ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Rafi's Reef");       // Put a banner at the top
      ReefAngel.LCD.DrawDate(6, 119);                                                      // Put the date and time at the bottom
      ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);                                    // Draw a black line under the banner
      x = 12;
      y += MENU_START_ROW+1;                                                               // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
      ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp     pH");
      ConvertNumToString(text, ReefAngel.Params.PH, 100);                                  // Get pH reading and convert
      ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text, Font8x16);    // Put pH on the screen
      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);                       // Get T1 temp and convert
      y += MENU_START_ROW*2;
      x = 10;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, TempColor, x, y, text);                   // Draw the temperature, white numbers on a colored background
      x += (16*4) + 8;
      
      // Code for drawing the relay box
      byte TempRelay = ReefAngel.Relay.RelayData;
      TempRelay &= ReefAngel.Relay.RelayMaskOff;
      TempRelay |= ReefAngel.Relay.RelayMaskOn;
      ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);
    }
void DrawCustomGraph()
{
}
Any help or just change the custom screen for another one more simple? i think im gonna get the same problem with the preloaded one.
Image
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Size of the sketch its killing me

Post by DrewPalmer04 »

If you can live without custom colors that will save you a ton of space.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Size of the sketch its killing me

Post by Bo0sted_Rafi »

DrewPalmer04 wrote:If you can live without custom colors that will save you a ton of space.
Yes, I can live without that! The custom screen it's from another user in the screen thread but if I can make a new one with only the temp on big numbers, ph and relay box it's ok for me!

The custom color just remove that line?
Image
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Size of the sketch its killing me

Post by DrewPalmer04 »

See below:
Last edited by DrewPalmer04 on Fri May 10, 2013 11:56 am, edited 1 time in total.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Size of the sketch its killing me

Post by DrewPalmer04 »

But at the same time all your space is being used by that custom graph, which uses custom colors. What's your goal here?
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Size of the sketch its killing me

Post by DrewPalmer04 »

Try getting rid of large numbers first and see if you can fit it...
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Size of the sketch its killing me

Post by Bo0sted_Rafi »

I removed the custom screen and still too big when I compiled the sketch.
Image
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Size of the sketch its killing me

Post by binder »

the large fonts really take up a lot of space. so make sure you remove the drawhuge and drawlarge text functions. plus remove the define number line at the top.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Size of the sketch its killing me

Post by Bo0sted_Rafi »

Can you help me with that! I just know the basics and most of time I erase something give me an error. I'm a noob in coding or mosofyins a clde
Image
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Size of the sketch its killing me

Post by cosmith71 »

I can't help with the code, but consider an upgrade to the RA+ board. I did, and it's saved me a lot of headaches.

--Colin
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Size of the sketch its killing me

Post by binder »

Bo0sted_Rafi wrote:Can you help me with that! I just know the basics and most of time I erase something give me an error. I'm a noob in coding or mosofyins a clde
Yes, I'm working on it right now. Give me a few minutes to make sure it's coded properly.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Size of the sketch its killing me

Post by binder »

Ok, I made a change by removing the huge and large fonts (this takes up a lot of space). If it still does not upload due to large size, then you will need to remove the custom temperature colors. I added comments to the code on what to remove and change. I doubt you will need to do this, but I wanted to mention it anyways.
Here's the code:

Code: Select all

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

////// Place global variable code below here
int avgph[10];
unsigned long totalavgph=0;
byte avgindex=0;

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


void setup()
{
	// This must be the first line
	ReefAngel.Init(); //Initialize controller
	// Ports toggled in Feeding Mode
	ReefAngel.UseFlexiblePhCalibration();
	ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port3Bit;
	// Ports toggled in Water Change Mode
	ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port6Bit;
	// Ports toggled when Lights On / Off menu entry selected
	ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port6Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
	// Ports turned off when Overheat temperature exceeded
	ReefAngel.OverheatShutoffPorts = 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( 830 );

	// Ports that are always on
	ReefAngel.Relay.On( Port1 );
	ReefAngel.Relay.On( Port5 );

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

	for (int a=0;a<10;a++) avgph[a]=analogRead(PHPin);

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

void loop()
{
	totalavgph=0;
	avgph[avgindex]=analogRead(PHPin);
	avgindex++;
	if (avgindex==10) avgindex=0;
	for (int a=0;a<10;a++)
	totalavgph+=avgph[a];
	totalavgph/=10;

	totalavgph=map(totalavgph, ReefAngel.PHMin, ReefAngel.PHMax, 700, 1000); // apply the calibration to the sensor reading
	totalavgph=constrain(totalavgph,100,1400);

	if (totalavgph <= 644) ReefAngel.Relay.Off(Port3); 
	if (totalavgph >= 656) ReefAngel.Relay.On(Port3); 

	ReefAngel.Relay.DelayedOn( Port2 );
	//    ReefAngel.CO2Control( Port3,644,655 );
	ReefAngel.StandardFan( Port4,780,788 );
	ReefAngel.WavemakerRandom( Port6,1200,240 );
	ReefAngel.StandardLights( Port7,0,30,12,30 );
	ReefAngel.StandardLights( Port8,12,0,2,0 );
	ReefAngel.PWM.SetDaylight(PWMSlope(17,0,0,3,0,12,3,0));
	ReefAngel.PWM.SetDaylight(PWMSlope(18,30,22,33,12,45,3,ReefAngel.PWM.GetDaylightValue())); 
	ReefAngel.PWM.SetActinic( PWMSlope(15,0,1,0,9,60,30,9) );
	////// Place your custom code below here
	////// Place your custom code above here

	// This should always be the last line
	ReefAngel.Portal( "Bo0sted_Rafi" );
	ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
	byte x;
	byte y = 2;
	char text[7];

	// IF the code size is too big, delete all the lines between the 
	// next line and the //****** line below (the lines in reference to TempColor
	// *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
	int TempColor;        // Color for drawing temperature
	boolean FanOn = ReefAngel.Relay.Status(Port4);    // Get the status of the fan relay
	boolean HeatOn = ReefAngel.Relay.Status(Port7);   // Get the status of the heater relay
	if (HeatOn) 
	{
		TempColor = COLOR_NAVY;    // Blue text, too cold, heater is on
	}
	if (FanOn)   
	{
		TempColor = COLOR_RED;   // Red text, too warm, fan is on
	}
	if (!HeatOn && !FanOn) 
	{
		TempColor = COLOR_GREEN;  // Green text, no fan or heater on
	}
	// ***********************************************************************************

	// Put a banner at the top
	ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Rafi's Reef");
	// Put the date and time at the bottom
	ReefAngel.LCD.DrawDate(6, 119);
	// Draw a black line under the banner
	ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
	x = 12;
	// MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
	y += MENU_START_ROW+1;
	ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp     pH");
	// Get pH reading and convert
	ConvertNumToString(text, ReefAngel.Params.PH, 100);
	// Put pH on the screen
	ReefAngel.LCD.DrawText(PHColor, DefaultBGColor, x+75, y+18, text);
	// Get T1 temp and convert
	ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
	y += MENU_START_ROW*2;
	x = 10;

	// Draw the temperature
	// IF you removed the other lines mentioned, you need to uncomment out
	// this next line in order to display your temperature on the screen
	// Do so by removing the double // in front of ReefAngel
	//ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x, y, text);

	// Draw the temperature, white numbers on a colored background
	// IF the code size is still too big, comment out the next line by placing
	// 2 forward slashes in front of the ReefAngel or delete the line completely
	ReefAngel.LCD.DrawText(COLOR_WHITE, TempColor, x, y, text);

	// Code for drawing the relay box
	byte TempRelay = ReefAngel.Relay.RelayData;
	TempRelay &= ReefAngel.Relay.RelayMaskOff;
	TempRelay |= ReefAngel.Relay.RelayMaskOn;
	ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);
}
void DrawCustomGraph()
{
}
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Size of the sketch its killing me

Post by binder »

Just compiled the code I posted using libraries 1.0.7 and it compiled in at 30,228. I'm using an older version of Arduino (1.0.1) and on Linux, so you should be good.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Size of the sketch its killing me

Post by Bo0sted_Rafi »

I want to remove the colors because i dont need them. just i dont know what im doing worng editing the colors that shows me an error. i will try to upload this code because im at work now. what do i need to erase in the temperature colors to make it work?
Image
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Size of the sketch its killing me

Post by Bo0sted_Rafi »

binder wrote:Just compiled the code I posted using libraries 1.0.7 and it compiled in at 30,228. I'm using an older version of Arduino (1.0.1) and on Linux, so you should be good.
thanks Binder, i will check this.
Image
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Size of the sketch its killing me

Post by binder »

Here's the same code without the changing temperature colors:

Code: Select all

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

////// Place global variable code below here
int avgph[10];
unsigned long totalavgph=0;
byte avgindex=0;

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


void setup()
{
   // This must be the first line
   ReefAngel.Init(); //Initialize controller
   // Ports toggled in Feeding Mode
   ReefAngel.UseFlexiblePhCalibration();
   ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port3Bit;
   // Ports toggled in Water Change Mode
   ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port6Bit;
   // Ports toggled when Lights On / Off menu entry selected
   ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port6Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
   // Ports turned off when Overheat temperature exceeded
   ReefAngel.OverheatShutoffPorts = 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( 830 );

   // Ports that are always on
   ReefAngel.Relay.On( Port1 );
   ReefAngel.Relay.On( Port5 );

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

   for (int a=0;a<10;a++) avgph[a]=analogRead(PHPin);

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

void loop()
{
   totalavgph=0;
   avgph[avgindex]=analogRead(PHPin);
   avgindex++;
   if (avgindex==10) avgindex=0;
   for (int a=0;a<10;a++)
   totalavgph+=avgph[a];
   totalavgph/=10;

   totalavgph=map(totalavgph, ReefAngel.PHMin, ReefAngel.PHMax, 700, 1000); // apply the calibration to the sensor reading
   totalavgph=constrain(totalavgph,100,1400);

   if (totalavgph <= 644) ReefAngel.Relay.Off(Port3); 
   if (totalavgph >= 656) ReefAngel.Relay.On(Port3); 

   ReefAngel.Relay.DelayedOn( Port2 );
   //    ReefAngel.CO2Control( Port3,644,655 );
   ReefAngel.StandardFan( Port4,780,788 );
   ReefAngel.WavemakerRandom( Port6,1200,240 );
   ReefAngel.StandardLights( Port7,0,30,12,30 );
   ReefAngel.StandardLights( Port8,12,0,2,0 );
   ReefAngel.PWM.SetDaylight(PWMSlope(17,0,0,3,0,12,3,0));
   ReefAngel.PWM.SetDaylight(PWMSlope(18,30,22,33,12,45,3,ReefAngel.PWM.GetDaylightValue())); 
   ReefAngel.PWM.SetActinic( PWMSlope(15,0,1,0,9,60,30,9) );
   ////// Place your custom code below here
   ////// Place your custom code above here

   // This should always be the last line
   ReefAngel.Portal( "Bo0sted_Rafi" );
   ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
   byte x;
   byte y = 2;
   char text[7];

   // Put a banner at the top
   ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Rafi's Reef");
   // Put the date and time at the bottom
   ReefAngel.LCD.DrawDate(6, 119);
   // Draw a black line under the banner
   ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
   x = 12;
   // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
   y += MENU_START_ROW+1;
   ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp     pH");
   // Get pH reading and convert
   ConvertNumToString(text, ReefAngel.Params.PH, 100);
   // Put pH on the screen
   ReefAngel.LCD.DrawText(PHColor, DefaultBGColor, x+75, y+18, text);
   // Get T1 temp and convert
   ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
   y += MENU_START_ROW*2;
   x = 10;

   // Draw the temperature
   ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x, y, text);

   // Code for drawing the relay box
   byte TempRelay = ReefAngel.Relay.RelayData;
   TempRelay &= ReefAngel.Relay.RelayMaskOff;
   TempRelay |= ReefAngel.Relay.RelayMaskOn;
   ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);
}
void DrawCustomGraph()
{
}
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Size of the sketch its killing me

Post by Bo0sted_Rafi »

cosmith71 wrote:I can't help with the code, but consider an upgrade to the RA+ board. I did, and it's saved me a lot of headaches.

--Colin
thanks Colin. I will need to do this soon when i add some gadgets to my system like an Wp40 or when the wp25 gets to the market.
Image
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Size of the sketch its killing me

Post by Bo0sted_Rafi »

binder wrote:Here's the same code without the changing temperature colors:

Code: Select all

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

////// Place global variable code below here
int avgph[10];
unsigned long totalavgph=0;
byte avgindex=0;

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


void setup()
{
   // This must be the first line
   ReefAngel.Init(); //Initialize controller
   // Ports toggled in Feeding Mode
   ReefAngel.UseFlexiblePhCalibration();
   ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port3Bit;
   // Ports toggled in Water Change Mode
   ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port6Bit;
   // Ports toggled when Lights On / Off menu entry selected
   ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port6Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
   // Ports turned off when Overheat temperature exceeded
   ReefAngel.OverheatShutoffPorts = 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( 830 );

   // Ports that are always on
   ReefAngel.Relay.On( Port1 );
   ReefAngel.Relay.On( Port5 );

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

   for (int a=0;a<10;a++) avgph[a]=analogRead(PHPin);

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

void loop()
{
   totalavgph=0;
   avgph[avgindex]=analogRead(PHPin);
   avgindex++;
   if (avgindex==10) avgindex=0;
   for (int a=0;a<10;a++)
   totalavgph+=avgph[a];
   totalavgph/=10;

   totalavgph=map(totalavgph, ReefAngel.PHMin, ReefAngel.PHMax, 700, 1000); // apply the calibration to the sensor reading
   totalavgph=constrain(totalavgph,100,1400);

   if (totalavgph <= 644) ReefAngel.Relay.Off(Port3); 
   if (totalavgph >= 656) ReefAngel.Relay.On(Port3); 

   ReefAngel.Relay.DelayedOn( Port2 );
   //    ReefAngel.CO2Control( Port3,644,655 );
   ReefAngel.StandardFan( Port4,780,788 );
   ReefAngel.WavemakerRandom( Port6,1200,240 );
   ReefAngel.StandardLights( Port7,0,30,12,30 );
   ReefAngel.StandardLights( Port8,12,0,2,0 );
   ReefAngel.PWM.SetDaylight(PWMSlope(17,0,0,3,0,12,3,0));
   ReefAngel.PWM.SetDaylight(PWMSlope(18,30,22,33,12,45,3,ReefAngel.PWM.GetDaylightValue())); 
   ReefAngel.PWM.SetActinic( PWMSlope(15,0,1,0,9,60,30,9) );
   ////// Place your custom code below here
   ////// Place your custom code above here

   // This should always be the last line
   ReefAngel.Portal( "Bo0sted_Rafi" );
   ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
   byte x;
   byte y = 2;
   char text[7];

   // Put a banner at the top
   ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Rafi's Reef");
   // Put the date and time at the bottom
   ReefAngel.LCD.DrawDate(6, 119);
   // Draw a black line under the banner
   ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
   x = 12;
   // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
   y += MENU_START_ROW+1;
   ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp     pH");
   // Get pH reading and convert
   ConvertNumToString(text, ReefAngel.Params.PH, 100);
   // Put pH on the screen
   ReefAngel.LCD.DrawText(PHColor, DefaultBGColor, x+75, y+18, text);
   // Get T1 temp and convert
   ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
   y += MENU_START_ROW*2;
   x = 10;

   // Draw the temperature
   ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x, y, text);

   // Code for drawing the relay box
   byte TempRelay = ReefAngel.Relay.RelayData;
   TempRelay &= ReefAngel.Relay.RelayMaskOff;
   TempRelay |= ReefAngel.Relay.RelayMaskOn;
   ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);
}
void DrawCustomGraph()
{
}
Thanks Curt. Works great.
Image
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Post by binder »

awesome.
Post Reply