Hi, I’m having some trouble using PROGMEM with a big static array. From the tutorials I know that any reads need to be done with the pgm_read functions, but how do those work when the array consists of structs instead of some raw datatype such as “int” or “byte”?

I’m sending a bunch of information about the current program state over a data radio one by one due to performance reasons. This is basically just a iterable list of pointers and some information about them. It works quite fine, but having it in memory is wasteful.

The current array is this:

```
const static remoteSetting toSend[] = { //This is the struct that has pointers to the plane's settings
// modifiable data type pointer to data
{O | (1 << mod) | (1 << isfloat), data : &elevator._kp},
{O | (1 << mod) | (1 << isfloat), data : &elevator._ki},
{O | (1 << mod) | (1 << isfloat), data : &elevator._kd},
{O | (0 << mod) | (1 << isfloat), data : &elevator._error},
{O | (0 << mod) | (1 << isfloat), data : &elevator._ITerm},
{O | (1 << mod) | (1 << isfloat), data : &rudder._kp},
{O | (1 << mod) | (1 << isfloat), data : &rudder._ki},
{O | (1 << mod) | (1 << isfloat), data : &rudder._kd},
{O | (0 << mod) | (1 << isfloat), data : &rudder._error},
{O | (0 << mod) | (1 << isfloat), data : &rudder._ITerm},
{O | (1 << mod) | (1 << isint), data : targetPitot},
{O | (1 << mod) | (1 << isint), data : rollSlackAngle},
{O | (1 << mod) | (1 << isint), data : rollResponse},
{O | (1 << mod) | (1 << isint), data : pitchResponse},
{O | (1 << mod) | (1 << isint), data : maxPitchAngle},
{O | (1 << mod) | (1 << isint), data : maxYawRate},
{O | (1 << mod) | (1 << isint), data : &rthAltitude},
{O | (1 << mod) | (1 << isint), data : &waypointAcceptRadius},
{O | (1 << mod) | (1 << isint), data : &lowBatt},
{O | (1 << mod) | (1 << isint), data : &critBatt},
{O | (0 << mod) | (1 << isbyte), data : &controlMode},
{O | (1 << mod) | (1 << isbyte), data : &motorOverride},
{O | (0 << mod) | (1 << isint), data : &orientation.velocity},
{O | (0 << mod) | (1 << isint), data : &orientation.yawrate},
{O | (0 << mod) | (1 << isint), data : &orientation.rollrate},
{O | (0 << mod) | (1 << isbyte), data : &system},
{O | (0 << mod) | (1 << isbyte), data : &gyro},
{O | (0 << mod) | (1 << isbyte), data : &accel},
{O | (0 << mod) | (1 << isbyte), data : &mag},
{O | (0 << mod) | (1 << isbyte), data : &motorArmed},
{O | (0 << mod) | (1 << isbyte), data : &fixStatus},
{O | (0 << mod) | (1 << isfloat), data : &lat},
{O | (0 << mod) | (1 << isfloat), data : &lon},
{O | (0 << mod) | (1 << isbyte), data : &debugByte},
{O | (0 << mod) | (1 << isint), data : &debugInt},
{O | (0 << mod) | (1 << isfloat), data : &debugFloat},
{O | (1 << mod) | (1 << isint), data : &targetpoint->altitude},
{O | (0 << mod) | (1 << isuint), data : &loopsPerTransmit},
{O | (0 << mod) | (1 << isuint), data : &loopsPerSecond},
{O | (0 << mod) | (1 << isuint), data : &distToCurrent}
};
```

The struct used is as follows:

```
struct remoteSetting{ //Determines the values that are communicated between plane and ground station
byte type; // is float | is ulong | is long | is uint | is int | is char | is byte | is modifiable
void *data; //Void pointer to whatever, type is interpreted by the type identifier byte.
};
```

I’m at a loss what would be the best way to type this out neatly and access the array from PROGMEM. As these are all static while the program runs, I’d want the structs themselves, not only the array, to reside in flash. The only way I know of involves making the (progmem) structs first, then making another (progmem) array of pointers to point there, which seems a bit superfluous.