ReefAngel.ShowInterface() memory issue?

Do you have a question on how to do something.
Ask in here.
Post Reply
javisaman
Posts: 66
Joined: Thu Jun 30, 2011 7:27 am

ReefAngel.ShowInterface() memory issue?

Post by javisaman »

I can't seem to build any of the SketchBook code from curtbinder. All of them exceed the maximum size limit. However when I comment out the line ReefAngel.ShowInterface() the size of the source code drops by approximately 20Kb. Why does the ReefAngel.ShowInterface() function require so much memory? Am I doing something wrong?

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

Re: ReefAngel.ShowInterface() memory issue?

Post by rimai »

It's the function that takes care of everything for you, from simply drawing the interface to checking all timers and turning relays on/off.
If you are exceeding in memory usage, try not using some of the other features, for example: Date/Time setup (which uses about 2K of memory) and some other ones.
This might help you:
https://github.com/curtbinder/ReefAngel ... Features.h
http://forum.reefangel.com/viewtopic.php?f=12&t=94
Roberto.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ReefAngel.ShowInterface() memory issue?

Post by binder »

javisaman wrote:I can't seem to build any of the SketchBook code from curtbinder. All of them exceed the maximum size limit. However when I comment out the line ReefAngel.ShowInterface() the size of the source code drops by approximately 20Kb. Why does the ReefAngel.ShowInterface() function require so much memory? Am I doing something wrong?

Thanks
ShowInterface displays the main screen and draws the menu.

The way the compiler works is if a function is not called, it is stripped out of the library. If you remove ShowInterface(), the relays will not get toggled on/off, the wifi requests will not be processed, the overheat checks will not be processed, the main display will not be updated, you will not have a menu, etc.

The more functions the controller has in the PDE file, the larger the memory footprint will be. If you include the Date/Time setup, that takes up 1900 bytes (give or take a few). If you enable wifi, that takes up a lot of memory usage too. There are some ways to improve the memory size.

Could you post your complete PDE file so we can take a look at it and see what all is going on?
Also, what version of the libraries are you using?

curt
javisaman
Posts: 66
Joined: Thu Jun 30, 2011 7:27 am

Re: ReefAngel.ShowInterface() memory issue?

Post by javisaman »

It's pretty barebones.

Code: Select all

//Custom Reef Angel Code

//standard libs
/*
#include <OneWire.h>
#include <Wire.h>
#include <EEPROM.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel.h>
#include <avr/pgmspace.h>
*/


//dev libs

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>


#define WhiteLED       1
#define BlueLED        2
#define FugeLight      3
#define Vortech        4
#define ATO            5
#define Return         6
#define Heater         7
#define Chiller        8
#define KoraliaTank    9
#define KoraliaFuge    10
#define Skimmer        11
#define LiterMeter     12
#define Feeder         13
#define WaterChangePump 14
#define WaterChangeHeat 15


prog_char menu0_label[] PROGMEM = "Feed (sinking)";
prog_char menu1_label[] PROGMEM = "Feed (floating)";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Manage LED Lighting";
prog_char menu4_label[] PROGMEM = "Manage Fuge Light";
prog_char menu5_label[] PROGMEM = "Manage Temperature";
prog_char menu6_label[] PROGMEM = "Calibrate Temp Probe";
prog_char menu7_label[] PROGMEM = "Calibrate pH Probe";
prog_char menu8_label[] PROGMEM = "Date/Time";

void setup(){
  ReefAngel.Init();
  
  ReefAngel.LCD.DrawText(200, 26, 10, 10, "Reef (Beta)");
  
  ReefAngel.Relay.On(Return);
  ReefAngel.Relay.On(LiterMeter);
  ReefAngel.Relay.On(Skimmer);
  ReefAngel.Relay.On(Vortech);
  ReefAngel.Relay.On(KoraliaTank);
  ReefAngel.Relay.On(ATO);
  
}

void loop() {
  ReefAngel.ShowInterface();
  
}

void DrawCustomMain(){
  ReefAngel.LCD.DrawText(200, 26, 30, 2, "Reef");
  ReefAngel.LCD.DrawDate(6, 119);
  pingSerial();
  
  
  ReefAngel.LCD.DrawMonitor(15, 63, ReefAngel.Params, 
  //  ReefAngel.PWM.DaylightPWMValue, ReefAngel.PWM.ActinicPWMValue); //standard
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue()); //development
  pingSerial();
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay != ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
#ifdef RelayExp
  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay != ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
#endif RelayExp
}

void DrawCustomGraph(){
}
I'm using development libraries 0.8.5.15

In the ReefAngel_Features.h file I have the following defined

Code: Select all

#define DateTimeSetup
#define ATOSetup
#define StandardLightsSetup
#define DirectTempSensor
#define wifi
#define DisplayLEDPWM
#define RelayExp
#define InstalledRelayExpansionModules 1
Do I have too much enabled? At least those are all/most of the functions I want.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ReefAngel.ShowInterface() memory issue?

Post by binder »

javisaman wrote:It's pretty barebones.
Do I have too much enabled? At least those are all/most of the functions I want.
There are some things that you have that shouldn't be there. It looks like you converted your PDE from the standard libraries to the development libraries. Some stuff can be taking up memory. Here's a simpler PDE file for you (but not much simpler than what you have)

Code: Select all

//Custom Reef Angel Code

//dev libs

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>


#define WhiteLED       1
#define BlueLED        2
#define FugeLight      3
#define Vortech        4
#define ATO            5
#define Return         6
#define Heater         7
#define Chiller        8
#define KoraliaTank    9
#define KoraliaFuge    10
#define Skimmer        11
#define LiterMeter     12
#define Feeder         13
#define WaterChangePump 14
#define WaterChangeHeat 15

void setup(){
  ReefAngel.Init();
   
  ReefAngel.Relay.On(Return);
  ReefAngel.Relay.On(LiterMeter);
  ReefAngel.Relay.On(Skimmer);
  ReefAngel.Relay.On(Vortech);
  ReefAngel.Relay.On(KoraliaTank);
  ReefAngel.Relay.On(ATO);
  
}

void loop() {
  ReefAngel.ShowInterface();
  
}

void DrawCustomMain(){
  ReefAngel.LCD.DrawText(200, 26, 30, 2, "Reef");
  ReefAngel.LCD.DrawDate(6, 119);
  pingSerial();
  
  
  ReefAngel.LCD.DrawMonitor(15, 63, ReefAngel.Params, 
  //  ReefAngel.PWM.DaylightPWMValue, ReefAngel.PWM.ActinicPWMValue); //standard
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue()); //development
  pingSerial();
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay != ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
#ifdef RelayExp
  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay != ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
#endif RelayExp
}

void DrawCustomGraph(){
}
And here is an improvement for your features file too:

Code: Select all

#define ATOSetup
#define StandardLightsSetup
#define DirectTempSensor
#define wifi
#define DisplayLEDPWM
#define RelayExp
#define InstalledRelayExpansionModules 1
That has the Date/Time setup removed like Roberto suggested. You may even want to remove the ATOSetup and StandardLightsSetup simply because you are not even using those functions in your PDE file (unless you plan on using them). The ATOSetup only allows you to change the timeout value. The StandardLightsSetup lets you change the on/off time for the lights.

I know that having wifi enabled uses up a lot of memory. Also my setup menus use a lot of memory too.

Do you use Dave's Client Suite application to get data from the RA? If so, his next release will have the ability to update the memory values via wifi thus elminating the need for the setup menus. You can then enable the SIMPLE_MENU and remove out a lot of the setup screens that are not needed. It's just a suggestion.

curt
javisaman
Posts: 66
Joined: Thu Jun 30, 2011 7:27 am

Re: ReefAngel.ShowInterface() memory issue?

Post by javisaman »

Thank you curt.

I removed some stuff from the features file as you mentioned. I'm trying do make custom main and menus. I think I was using a tutorial for the standard libraries for the menus. I don't know if there is a better way using the development libraries. Comments do not contribute to the memory do they?
javisaman
Posts: 66
Joined: Thu Jun 30, 2011 7:27 am

Re: ReefAngel.ShowInterface() memory issue?

Post by javisaman »

I just realized the "CUSTOM_MENU" feature hasn't been implemented yet. I'm sticking with the SIMPLE_MENU now. There is also a compile error if you enable the DateTimeSetup feature and the SIMPLE_MENU. Directives for DateTimeSetup are need around line 1831 in ReefAngel.cpp
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ReefAngel.ShowInterface() memory issue?

Post by binder »

javisaman wrote:I just realized the "CUSTOM_MENU" feature hasn't been implemented yet. I'm sticking with the SIMPLE_MENU now. There is also a compile error if you enable the DateTimeSetup feature and the SIMPLE_MENU. Directives for DateTimeSetup are need around line 1831 in ReefAngel.cpp
Comments do not use up any space. They get stripped out by the compiler so you can add as many comments in as you would like.

RAGen is a good program to start with generating your standard PDE file for use with the development libraries. It explains what each feature and about how much memory it uses. It's not been updated in a while with some of the newer stuff, so you will have to manually add stuff in like you currently do.

Yes, CUSTOM_MENU hasn't been implemented yet. I'm trying to determine a "good" and simple way to handle it.

I'm not familiar with any errors with having DateTimeSetup and SIMPLE_MENU both enabled. That's how I'm running my unit. I'll look into it though and see what I can come up with.

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

Re: ReefAngel.ShowInterface() memory issue?

Post by binder »

You will want to update your libraries to the latest. Make sure that Arduino is closed before you update the libraries otherwise it won't recognize the changes. I have been updating the code pretty regular lately so things have been changing. Right now, line 1831 you were talking about references PWM expansion device code.

What version / commit of the master branch do you have?

curt
javisaman
Posts: 66
Joined: Thu Jun 30, 2011 7:27 am

Re: ReefAngel.ShowInterface() memory issue?

Post by javisaman »

I guess I'll try the RAGen. I don't have any problems coding, but it just takes me a while to figure out what the library functions do, like you mentioned.

Sorry I meant 1821 in ReefAngel.cpp

Code: Select all

		case MainMenu_DateTime:
		{
			SetupDateTime();
			break;
		}
i simply changed it to

Code: Select all

#ifdef DateTimeSetup
		case MainMenu_DateTime:
		{
			SetupDateTime();
			break;
		}
#endif DateTimeSetup
javisaman
Posts: 66
Joined: Thu Jun 30, 2011 7:27 am

Re: ReefAngel.ShowInterface() memory issue?

Post by javisaman »

binder wrote: What version / commit of the master branch do you have?
curt

I use the RA library updater. I'm using development libraries 0.8.5.15
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ReefAngel.ShowInterface() memory issue?

Post by binder »

javisaman wrote:
binder wrote: What version / commit of the master branch do you have?
curt

I use the RA library updater. I'm using development libraries 0.8.5.15
Ok. 0.8.5.15 hasn't "officially" been released yet, it's in my main branch and I'm getting close to calling it official. So no worries there.

curt
Post Reply