> > Can structs be kept in program memory even when those structs include 
> > strings?
> Try defining and initializing your strings (in program memory) at the top 
> level, i.e. outside of the structure definition, and then using their names 
> to initialize the structure.

Thanks for this suggestion.  It certainly works:

    #include <avr/pgmspace.h>

    typedef struct
    {
      uint8_t  x:4, y:4;
      char     *name;
    }
    Pin;

    char  PROGMEM  _PC6[] = "PC6";
    char  PROGMEM  _PD0[] = "PD0";

    Pin  PROGMEM  pin[] =
    {
      { 0,  0, _PC6},
      { 0,  1, _PD0},
    };

    int main( void)
    {
      while ( 1)
      {
      }
    }

Gives:

    flash: 90 bytes
    RAM:   0 bytes

Is there any way make it tidier ( without declaring identifiers like _PC6)?

- neil


_______________________________________________
AVR-chat mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-chat

Reply via email to