avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] pgmspace with arrays of structs with strings


From: Ron Kreymborg
Subject: Re: [avr-chat] pgmspace with arrays of structs with strings
Date: Mon, 2 May 2011 23:01:57 +1000

> address@hidden wrote:
> 
> > Thanks for this suggestion.  It certainly works:
> 
> You're welcome.  I'm pretty sure that I learned this myself from
> discussion
> on this list so it only makes sense to pass the knowledge on.
> 
> > Is there any way make it tidier ( without declaring identifiers like
> > _PC6)?
> 
> I don't think so, but maybe someone else knows how to do this.  I am as
> interested in the answer as you.
> 
> Graham.

This may not be exactly what you want, but it does show you do not need the
identifiers.

typedef struct
{
   struct
   {
      uint8       x:4;
      uint8       y:4;
   } v;
   char        name[4];
} PIN;

PIN Pin[] PROGMEM =
{
   { { 1, 2 }, "PC6" },
   { { 3, 4 }, "PD0" }
};

int main(void)
{
   PIN local;
   uint8 a;

   memcpy_P(&local, &Pin[0], sizeof(PIN));
   a = local.v.x;
   memcpy_P(&local, &Pin[1], sizeof(PIN));
   a = local.v.y;

Ron.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]