Floating point PROGMEM

Hello and thanks for looking at my post. I am stumped on implementing PROGMEM in a certain context. My code follows below.

#include <inttypes.h>
#include <avr/pgmspace.h>

// sketch is based on an API
// it retrieves floats from large tables
// PROGMEM is needed as the tables are very large
// progmem_read_float function was tested to read floats properly
// but I am having problems with implementation here, see below

  // descriptions
  static char def1[6] = {'o','n','e', 0,  0,  0};
  static char def2[6] = {'t','w','o', 0,  0,  0};
  static char def3[6] = {'t','h','r','e','e', 0};
  static char def4[6] = {'f','o','u','r', 0,  0};

  // float tables
  static float Table1[] PROGMEM = {1.1, 2.1, 3.1};
  static float Table2[] PROGMEM = {2.2, 3.2, 4.2};
  static float Table3[] PROGMEM = {3.3, 4.3, 5.3};
  static float Table4[] PROGMEM = {4.4, 5.4, 6.4};

// a structure to hold the tables and definitions
struct objdef
{
  char  *definition; // holds object definition
  float *tbl; // holds object float table
};

// create structures with pointers to table and definitions
objdef t1 = {def1, Table1};
objdef t2 = {def2, Table2};
objdef t3 = {def3, Table3};
objdef t4 = {def4, Table4};

// make an array of the structures
objdef *Objects[] =
{
    &t1,
    &t2,
    &t3,
    &t4,
};

// retrieve floats from PROGMEM
// function from http://www.8051projects.net/lofiversion/t22383/avr-gcc-tutorial.html
inline float progmem_read_float(const float *addr)
{
union{
  uint16_t i[2];
  float f;
} u;

  u.i[0]=pgm_read_word((PGM_P) addr);
  u.i[1]=pgm_read_word((PGM_P) addr + 2);
  return(u.f);
}  
  
void setup()
{
  Serial.begin(9600);
}

void loop()
{
float *flptr;
float fl;  // float value
int i;
int j;

  // show retrieved float tables
  for (i=0; i<4; i++)
  {   
    // show object definition
    Serial.println((String) Objects[i]->definition);
    
    // get pointer to table
    // Problem Here
    flptr = progmem_read_float(Objects[i]->tbl);
    
    // show float table for object
    for (j=0; j<3; j++)
    {
      Serial.print(" j[");
      Serial.print(j);
      Serial.print("]=");
      
      // Problem Here
      fl = progmem_read_float(*flptr++);
      
      Serial.println(fl, 2);
    }    
    Serial.println("");
  }
}

In the two lines following 'Problem Here' I have tried all kinds of things, casting (float ), passing the pointer to a temporary variable, etc without any luck, so I left it as-is (the compiler will throw an error about float and float not being happy with each-other. I would really appreciate it if someone could show me how this should be done.

Muchos Gracias and Merry Christmas !

J

edit: i accidentally a word, a few clarifications

float *flptr;

This defines a pointer to a float, but does not make that pointer point to anything.

    flptr = progmem_read_float(Objects[i]->tbl);

The progmem_read_float funtion returns a float. Pointers point to integer locations. There is no memory address 3.7.

So,the value being returned by the function is being truncated to an int, and then treated as a memory address.

      fl = progmem_read_float(*flptr++);

Now, you are trying to use that pointer to float where the function wants an integer address.

The function itself is poorly written. Memory is integer based. It makes no sense to store a memory location in a float.

What are you trying to do? It looks like you are trying to store a value in PROGMEM, and then use that value as an address. That doesn't make sense, to me, especially in light of the float address.

i figured it out.. too many hours at the screen.

thanks anyway.