Folgendes verbraucht mehr Speicher (44 Bytes statt 28 Bytes für ein struct vom Typ RMC), aber die Variablen sind jeweils immer 4-Byte-Schritte voneinander entfernt. Man kann also einen Pointer auf das Struct hernehmen und immer um 4 inkrementieren, dann zeigt der Pointer nacheinander auf die Variablen.
Code:
struct RMC
{
uint16_t UTC_TIME __attribute__ ((aligned (4)));
uint8_t STATUS __attribute__ ((aligned (4)));
float LAT __attribute__ ((aligned (4)));
uint8_t LATIND __attribute__ ((aligned (4)));
float LON __attribute__ ((aligned (4)));
uint8_t LONIND __attribute__ ((aligned (4)));
float SOG __attribute__ ((aligned (4)));
float COG __attribute__ ((aligned (4)));
uint16_t DATE __attribute__ ((aligned (4)));
float MAGVAR __attribute__ ((aligned (4)));
uint8_t MVDIR __attribute__ ((aligned (4)));
};
Lesezeichen