using PROG_MEM in static struct… howto?

Hi,

I would write a structure to manipulate my connections:

struct intfPulse
{
  const byte pin;
  uint8_t value;
  const prog_char *label PROGMEM;
};

namespace Core {
  static intfPulse pulses[] = {
    { 13, 0, "LED" }
  }
}

But, I just have to write:

prog_char *test = Core::pulses[0].label;

test[0] == 'L';
// OK

pgm_read_byte_near(&test50]) == 'L';
// NOK

So I guess my string is not in flash memory…

If I add "static" before "const prog_char *label PROGMEM;", I fail:

error: too many initializers for 'intfPulse'

If I write "{ 13, 0, PSTR("LED") }", I fail:

error: statement-expressions are not allowed outside functions nor in template-argument lists

And I can combine both, and obtain a double failure…

How can I store only one element of my structure in the flash memory?

struct intfPulse
{
  const byte pin;
  uint8_t value;
  const prog_char *label PROGMEM;
};

You want part of the struct to be in PROGMEM? I would be complaining too. Do you want the pointer to be in PROGMEM or what it points to? Perhaps clarify that.

I shall store in flash memory the string which names the relative pin.
And my pointer can stay in the RAM.

I watch some code with lines as:

static const prog_char *label PROGMEM = "my string";

I would initialize my structure writing something like:

  static intfPulse pulses[] = {
    { 13, 0, "LED" }
  }

Do you see what I mean?

Not tested, but this might work:

  static const prog_char *label PROGMEM = "LED";
  static intfPulse pulses[] = {
    { 13, 0, label }
  }

Oliver

Yes, it should work :wink:
But I would like writing inline configuration.

Certainly, I will predefine a dictionary… if there is no inline possibility.