Skip to main content
26 events
when toggle format what by license comment
Oct 21, 2020 at 6:43 comment added Nick Gammon And you other guys.
Oct 21, 2020 at 6:43 comment added Nick Gammon @Delta_G You too. This isn't a forum. The whole idea here is that you make an actual answer. Then people can vote on it and it can be accepted. Bonus feature - you get reputation from this. Not from answering in comments.
Oct 21, 2020 at 6:41 comment added Nick Gammon @KIIV Please do not answer questions in a comment. See How do comments work?. They are not for answering a question.
May 21, 2020 at 15:10 answer added user47164 timeline score: 5
May 19, 2020 at 22:35 history edited Casey CC BY-SA 4.0
Added update text
May 19, 2020 at 22:30 history edited Casey CC BY-SA 4.0
Added update text
May 17, 2020 at 16:37 answer added DataFiddler timeline score: 2
May 17, 2020 at 9:00 history tweeted twitter.com/StackArduino/status/1261944570721587200
May 17, 2020 at 4:52 history edited Juraj
edited tags
May 17, 2020 at 4:50 comment added Juraj everything in this question, comments and answers assumes classic AVR. it is different for esp8266 and the Arduino megaavr boards package
May 17, 2020 at 3:34 history became hot network question
May 16, 2020 at 22:30 answer added Michel Keijzers timeline score: 4
May 16, 2020 at 21:57 comment added Casey @Delta_G Thanks. I've messed up the using or not using the pgm thing enough times that I was hoping there was a way to solve it once and for all (anticipating that I'll do it again). Oh well, more hardware testing. If you write that up as a solution I can accept it.
May 16, 2020 at 21:49 comment added Delta_G That's what you end up having to do. You release with two versions of the code and a note that if the user wants to use PROGMEM they can but they have to call the _P version of the function or however you name it differently. Often that's easier than trying to have it both ways because it reminds the user right in the name of the function and that sort of forces them back to the docs to see how it needs to be set up.
May 16, 2020 at 21:39 comment added Casey After digging through WString.h and pgmspace.h, this looks beyond my c++ chops. It also would seem to force the caller to use an F() type macro, which if I can be sure they will do that, then I can be sure it will use PROGMEM. I guess I can add some notation, likely including the word "PROGMEM" in the function name as well as in the input name for the flash const array and just hope all callers remember the PROGMEM contract.
May 16, 2020 at 21:27 comment added KIIV Or, you can use arduino based on Atmega4809 as there is flash address space mapped into memory address space with 0x4000 start offset (and compiler takes care about it if it's const variable)
May 16, 2020 at 21:18 comment added Edgar Bonet You would have to create your own dummy class, analogous to __FlashStringHelper, for each type that you want to store in flash. Not very convenient to say the least...
May 16, 2020 at 21:17 comment added Delta_G Not exactly, but if you go look at the Arduino core at how that whole thing works it is possible to do something similar. You can do that or you can have two different functions. But you can't make it where the user doesn't have to know the difference. They'll either have to declare their data with your specific data type that you create for your overload, or they'll have to cast to it, or they'll have to know to call a different function. You can't take that decision off of them either way.
May 16, 2020 at 21:16 answer added Edgar Bonet timeline score: 7
May 16, 2020 at 21:14 comment added Casey But the input is an array of uint8_t not a string. Does it still work?
May 16, 2020 at 21:13 comment added KIIV void someFunction(const __FlashStringHelper *str); and call it like someFunction(F("soometning"));
May 16, 2020 at 21:12 comment added Delta_G Go look at the Print class in the Arduino core.
May 16, 2020 at 21:12 comment added Casey @KIIV That sounds very promising. Can you show me what the function declaration would look like or give some references on how to do that?
May 16, 2020 at 21:03 comment added KIIV You can use the same trick as the Arduino classes are using. class __FlashStringHelper; #define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal))) and function overloading
May 16, 2020 at 19:32 review First posts
May 16, 2020 at 20:40
May 16, 2020 at 19:31 history asked Casey CC BY-SA 4.0