F() macro & PROGMEM question

Google isn’t coming back with a lot on Spark Core regarding those two topics, and I apologize if this has been asked and answered already.

Do I need to force string literals into FLASH with the F() macro, or does SparkCore’s compiler do that for me. I tried messing about with the compiler’s feedback, it seems like it doesn’t matter if I use F() of not.

Is there a PROGMEM functionality? Compiler complains but I thought it may be syntax. Cannot find in the IDE.

thanks for your assistance and patience with a noob coming from the arduino paradigm.

For progmem you’ll find some here


and here

As for F() I guess it’s not needed since string literals are placed in flash anyhow, but you could do something like this

#define F(x) ((const char*)(x))
1 Like

@ScruffR, I believe the F() macro is already included in the production environment, as is possibley PROGMEM. For sure they are included in the locally compilable firmware master repo. :smile:

2 Likes

@peekay123, where did you find a #define PROGMEM?
I only found it in unit-test.h which I wouldn’t have seen as inherent part of the actual firmware.

And when @BulldogLowell mentioned PROGMEM I didn’t only think of this keyword but also about the Arduino functions/makros to access PROGMEM variables.

Edit: :blush: I just noticed production environmen in your post :blush:
But even so where could one find what’s already there and what not. That would be some useful info to place in @harrisonhjones ’ porting hint repo.
(@Dave ???)

@ScruffR and @BulldogLowell, you should also check out:

https://community.particle.io/t/some-reusable-macros-and-stuff/8846?redirected=true

:smile:

@peekay123, that’s my own thread :wink: and I’m not sure if it is visible to every community member

3 Likes

So F() is defined in spark_wiring_string.h as this, which is just a pass through

#define F(X) (X)

I thought that PROGMEM was also defined someplace other than unit-test.h but I don’t see it.

The concept of PROGMEM is handled by const on Spark.

1 Like

@ScruffR, I did not think about the thread visibility!

As for PROGMEM, it needs to be defined as null. The code that it applies to, however, must be specified as “const” to go to flash, as @bko pointed out. :smile:

2 Likes

so… what I did with arduino:

 PROGMEM prog_int8_t fadeLedValue [6][2][104] = {...

I’ll do like this with Spark Core:

const int8_t fadeLedValue [6][2][104] = {...

and I do not need to force string literals to FLASH with F(), the compiler handles that already…

very helpful… thanks guys!

3 Likes