-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PROGMEM support? #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It doesn't work with the current version of ArduinoJson. I'll try to add that feature in 5.x but I don't make any promise yet because I fear that it will increase the code size significantly. |
I think maybe is easier to support PSTR() rather than F(). |
in my sketch, I have a struct which has a type and a pointer... if the type is 'P' (or whatever), it reads the pointer thru the pgm_read_byte(), otherwise, normal string/int/bool/etc. this adds little overhead. |
In the meantime until this is implemented I have been using the following macro to reduce memory usage.
|
Sorry if I'm a little offtopic, but I just wanted to note that in ARM Arduinos there's no PROGMEM stuff. Instead, we can use some libraries to do the trick (https://github.com/cmaglie/FlashStorage is one example). Maybe this should be taken into account. |
I just realize that this feature is partially supported since v5.0, thanks to an implicit conversion to This is supported: root[F("sensor")] = "gps"; This is not supported: root[F("sensor")] = F("gps"); but can be made to work like this: root[F("sensor")] = String(F("gps")); However, I do not recommend to use this because it's terribly inefficient. Each flash string has to be first copied to the heap (this is done by the |
Support for PROGMEM has been added in ArduinoJson 5.7.1. @q2dg, I took your comment into account: I concentrated the logic for handling strings in a very small area so that support for other types of string can be added easily in the future. |
I'm pretty low on memory in one of my projects so I'm trying to scrape a few bytes together by moving strings into PROGMEM. Would it be possible to add support for this or should it work and I'm doing it wrong?
The text was updated successfully, but these errors were encountered: