Taillieu.Info

More Than a Hobby..

MemoryTest PROGMEM

/* ************************************************************************
* *** ProjectName = WebComProject2013 ***
* *** SubProjectName = Memory Test ***
* *** ***
* *** Francis Taillieu, 05/2014. More at: http://taillieu.info ***
* ************************************************************************
*
* Sketch name = MemoryTest_01.ino
* Targer Device = Arduino Uno
* Options =
* IDE = Arduino For VisualStudio 2012 & VisualMicroDebugUpgrade1211_11
*
* This SubProjectScoop:
* -
* -
* -
* -
*
* ************************************************************************
*/
#include <MemoryFree.h>
#include <avr/pgmspace.h>

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#include <SoftwareSerial.h>
#include <EEPROM.h>
#include <EEPROMAnything.h>

//############################################
// Strings stored in flash mem for the Header (saves ram)
prog_char strVersion[] PROGMEM = "RS433 MemTest V01.00";
prog_char strInitStart[] PROGMEM = "<<< Start initialization >>>";
prog_char strInitCompleted[] PROGMEM = "<<< initialize Completed >>>";
prog_char strFreeMemory[] PROGMEM = "freeMemory=";

// A table of pointers to the flash memory strings for the header
PROGMEM const char *VerboseTable[] = {
strVersion,
strInitStart,
strInitCompleted,
strFreeMemory
};

// VerboseText
typedef enum {
Version,
InitStart,
InitCompleted,
FreeMemory } eVerbose;

void PrintVerbose( eVerbose vbText , bool bCRLF = true ) {
char strBuffer[30]; //A character array to hold the strings from the flash mem
strcpy_P( strBuffer, (char*)pgm_read_word( &( VerboseTable[ vbText ] ) ) );
Serial.print( strBuffer );
if ( bCRLF ) Serial.println();
}

//############################################
//
#define pinBusyLed 13
#define BusyLed_ON digitalWrite( pinBusyLed, HIGH ) // Turn of BusyLED
#define BusyLed_OFF digitalWrite( pinBusyLed, LOW ) // Turn on BusyLED

void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600); // 9600, 115200
while (!Serial) { ;} // wait for serial port to connect. Needed for Leonardo only

PrintVerbose( Version ); // Report Application Name & Version

PrintVerbose( InitStart );

PrintVerbose( InitCompleted );

PrintVerbose( FreeMemory, false );
Serial.println( freeMemory() );
}

void loop() {
BusyLed_ON;
delay(500);
BusyLed_OFF;
delay(500);
PrintVerbose( FreeMemory, false );
Serial.println( freeMemory() );
}