Ok, trick question. From what I read Const is stored in Flash and SRAM where as PROGMEM is in flash only.
I've used FreeMemory() to give an idea of memory usage and constructed an array that is declared in 3 different ways, PROGMEM float array, const float array and just float array. Memory usage does not seem to agree with what I have learnt regarding Const and PROGMEM. Here is the code each declaration of the array there is a comment with what the run code reported free memory as. PROGMEM & Const are the same, I think they shouldn't be... can anyone clear up my miss understanding?
float vpd_table[5][15][2] = { // 1204 SRAM free, expected lower ram
//const float vpd_table[5][15][2] = { // 1808 SRAM free, I expected this to be the same as just a float but it's freed up memory!
//PROGMEM prog_float_t vpd_table[5][15][2] = { // 1804 SRAM free as expected
Full code:
#include <MemoryFree.h> // tells us what SRAM memory is free
#include <avr/pgmspace.h> // So we cna use PROGMEM
typedef float PROGMEM prog_float_t; // Need to define this type before use
float vpd_table[5][15][2] = { // 1204 SRAM free, expected lower ram
//const float vpd_table[5][15][2] = { // 1808 SRAM free, I expected this to be the same as just a float but it's freed up memory!
//PROGMEM prog_float_t vpd_table[5][15][2] = { // 1804 SRAM free as expected
//30% 35% 40% 45% 50% 55% 60% 65% 70% 75% 80% 85% 90% 95% 100%
/*10 degC*/{ {1.98,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00} },
/*15 degC*/{ {00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,90},{00,00},{00,00},{00,00},{00,00} },
/*20 degC*/{ {00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00} },
/*25 degC*/{ {00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00} },
/*30 degC*/{ {00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00},{00,00} }};
void setup() // run once, when the sketch starts
{
Serial.begin(9600);
}
void loop() // run over and over again
{
//float absHumidity = pgm_read_float_near(&vpd_table[0][0][0]); // grab a value from progmem
float absHumidity = vpd_table[0][0][0]; // grab a value to use
Serial.print("freeMemory() reports ");
Serial.print( freeMemory() );Serial.print( " VPD:" );Serial.println( absHumidity);
}