system
September 17, 2012, 9:33am
1
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.
system
September 17, 2012, 12:02pm
3
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
system
September 17, 2012, 1:14pm
5
Yes, it should work
But I would like writing inline configuration.
Certainly, I will predefine a dictionary… if there is no inline possibility.