I have a sketch that has maxed out memory. I'm using a 4 x 40 LCD display and I don't use all the "features" in the library. I made a copy of the library and deleted some of the things that I don't use like scrolllefttoright and scrollrighttoleft, etc. thinking that would give me more useable memory. Instead it actually takes up just a little bit more memory than before.
What memory is too much, is it flash or is it SRAM ?
Removing functions will not alter SRAM requirements you have to reduce the number if variables that are defined. You can always get a few more bytes by reducing the serial buffer size if you are not using serial.
Duemilanove w/ATmega328. Code is too large to fit in the code window. This is the first part of it.
#include <EEPROM.h>
#include <floatToString.h>
#include <LiquidCrystal440.h>
#include "OneWire.h"
#include <stdlib.h>
#include <wdt.h> // watchdog
#include <Wire.h>
#define BluePin 9 // pin for blue LEDs
#define doggieTickle() resetTime = millis(); // This macro will reset the timer
#define DS1307_I2C_ADDRESS 0x68 // hardware address of clock
#define MixedPin 10 // pin for mixed LEDs
#define PH_READ_PIN 3 // analog pin to poll PH
#define RelayBoardAddress 0x20 // relay board I2C address
#define TempChangeValue 3 // after a change based on temp wait for this many minutes to prevent turning something off and on "rattling" the relay
#define TIMEOUTPERIOD 10000 // 10 seconds - for watchdog. You can make this time as long as you want, it's not limited to 8 seconds like the normal watchdog
#define WhitePin 11 // pin for white LEDs
void(* resetFunc) (void) = 0; //declare reset function @ address 0 - part of watchdog
LiquidCrystal lcd(5,255,6,4,3,2,8,7);
OneWire ds(12); // DS18B20 Temparature chip on pin 12
OneWire dsLED(13); // DS18B20 Temparature chip on pin 13 for LED temp
byte addr[8];
byte data[12];
byte Data[4];
byte control = 0b00000000; // control byte for relay strip
byte dayOfMonth;
byte dayOfWeek;
byte Exit;
byte FirstPass = true;
byte hour;
byte ManualLightOn = false;
byte MenuOneFlag;
byte Midnight = false;
byte minute;
byte month;
byte present = 0;
byte second;
byte year;
char ampm;
char c; // keypress from slave
char field;
char buffer4[4];
char buffer12[12];
char buffer18[18];
char Hibuffer[9];
char Lobuffer[9];
double DayOfMonth;
double sum;
float HeaterOnTemp; // temp for heater on
float HiTemp;
float HistHiTemp;
float HistLoTemp;
float HoodFanOnTemp;
float LastTemp;
float LEDFanOnTemp;
float LEDTemp;
float LoTemp;
float pH;
float pHtrigger;
float SumpFanOnTemp;
float temp;
float Temp;
float WorkFloat1;
float WorkFloat2;
int BlueFade;
int BlueMax;
int BluePeriod;
int BlueStart;
int BMax;
int CP; // cursor position
int DisplayHour;
int Fract;
int HighByte;
int Hour;
int i = 0;
int LowByte;
int ManualLightOffTime;
int MinutesPastMidnight;
int MixedFade;
int MixedMax;
int MixedPeriod;
int MixedStart;
int MMax;
int nColumns = 40; //number of columns
int nRows = 4; //number of rows on LCD
int samples;
int SignBit;
int SlaveAddr = 4; // slave at I2C address 4
int Tc_100;
int TempChangeMinute;
int TReading;
int WhiteFade;
int WhiteMax;
int WhitePeriod;
int WhiteStart;
int Whole;
int WMax;
int WorkHour;
int WorkMinute;
int x;
int y;
long BlueVal;
long MixedVal;
long WhiteVal;
unsigned long resetTime = 0;
/////////////////////////////////////////////////////////////////
// EEPROM map
////////////////////////////////////////////////////////////////
// note 9/30/12 - expand hi and lo buffers to 9 char
// note 10/14/12 - put a lot of empty space between addresses to attempt to eliminate problems that might be caused by overruns on reads or writes
int HiTempAddr = 0; // 0 - 3
int HiBufferAddr = 10; // 4 - 12
int LoTempAddr = 30; // 13 - 16
int LoBufferAddr = 40; // 17 - 25
int HistHiTempAddr = 60; // 26 - 29
int HistHiBufferAddr = 70; // 30 - 47
int HistLoTempAddr = 100; // 48 - 51
int HistLoBufferAddr = 110; // 52 - 69
// skipping one byte because sometimes when low temp is reset it corrupts light on interval
int ManualLightOnIntervalAddr = 140; // 71 - 72
int HoodFanTempAddr = 150; // 73 - 76
int SumpFanTempAddr = 160; // 77 - 80
int HeaterTempAddr = 170; // 81 - 84
int LEDTempAddr = 180; // 85 - 88
int ManualLightOffAddr = 190; // 89 - 90
int CaRXpHAddr = 200; // 91 - 94
int BlueStartAddr = 210; // 95 - 98
int BlueDurationAddr = 220; // 99 - 102
int BlueFadeAddr = 230; // 103 - 106
int BlueMaxAddr = 240; // 107 - 108
int MixedStartAddr = 250; // 109 - 110
int MixedDurationAddr = 260; // 111 - 112
int MixedFadeAddr = 270; // 113 - 114
int MixedMaxAddr = 280; // 115 - 116
int WhiteStartAddr = 290; // 117 - 118
int WhiteDurationAddr = 300; // 119 - 120
int WhiteFadeAddr = 310; // 121 - 122
int WhiteMaxAddr = 320; // 123 - 124
////////////////////////////////////////////////////////////////////////////
void setup()
////////////////////////////////////////////////////////////////////////////
{
lcd.begin(nColumns,nRows);
Wire.begin();
Wire.beginTransmission(RelayBoardAddress); // start talking to the device
Wire.send(0x00); // select the IODIR register
Wire.send(0x00); // set register value-all high, sets all pins as outputs on MCP23008
Wire.endTransmission(); // stop talking to the device
watchdogSetup();
ReadFromEEPROM();
getTemp();
}
////////////////////////////////////////////////////////////////////////////
void loop()
////////////////////////////////////////////////////////////////////////////
{
getDate(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
displayDate();
// the getTemp and getPH functions have delays that may prevent the keystrokes from being
// captured when a key on the keypad is pressed. this code limits that functions to once every
// 8 and 6 seconds to allow for all keystores to be recognized.
if (int(second / 8.0) == (second / 8.0))
{
getTemp();
}
if (int(second / 8.0) == (second / 8.0))
{
getLEDTemp();
}
c = poll_slave(SlaveAddr,1);
switch (c)
{
case '0':
DisplayTempHist();
break;
case '*':
LightsOn();
break;
case '#':
MenuOne();
break;
}
if (int(second / 6.0) == (second / 6.0))
{
getPH();
}
relays();
LEDs();
c = poll_slave(SlaveAddr,1);
switch (c)
{
case '0':
DisplayTempHist();
break;
case '*':
LightsOn();
break;
case '#':
MenuOne();
break;
}
doggieTickle(); // reset the timer.
}
////////////////////////////////////////////////////////////////////////////
// Accept a digits Parms:: cursor, low, high
// Returns an int
////////////////////////////////////////////////////////////////////////////
int AcceptDigit(int cur, int low, int high)
{
Exit = false;
lcd.setCursor(0,3);
lcd.print("Enter ");
lcd.print(low);
lcd.print(" - ");
lcd.print(high);
lcd.blink();
lcd.setCursor(cur,2);
do
{
c = poll_slave(SlaveAddr,1);
if (c == '#')
{
Exit = true;
}
if ((c - 48 >= low) && (c - 48 <= high))
{
lcd.print(c);
Exit = true;
}
doggieTickle(); // reset the timer.
} while (Exit == false);
lcd.noBlink();
return c;
}