Update IRremote.cpp to improve debugging#258
Update IRremote.cpp to improve debugging#258ElectricRCAircraftGuy wants to merge 3 commits intoArduino-IRremote:masterfrom
Conversation
This is a small change, and definitely an improvement. I simply improved the debugging by stating whether a check passed or failed, for easier identification in debug mode.
Further improved debug formatting, & added F macro to reduce RAM usage during prints.
very minor changes
There was a problem hiding this comment.
What does F("") do? I'm not a very advanced C programmer so can you please explain it to me? Thanks!
There was a problem hiding this comment.
It's an Arduino PROGMEM macro, to cause the string constant to take up Flash memory only but not SRAM. See here at the bottom: http://playground.arduino.cc/Learning/Memory
There was a problem hiding this comment.
Without it, all printed string constants take both flash and RAM memory
There was a problem hiding this comment.
For anything <2 chars it's a wash. Just using it takes a couple bytes.
There was a problem hiding this comment.
Thank you for the detailed explanation. I will look into merging this soon. Once again thank you for the contribution
There was a problem hiding this comment.
When using F() does the compiler optimize the exact same strings and only put them into the Flash once?
IF not, then we should look at a way to make that happen (not just here, but review throughout).
Also, using F() For all the text is a great idea. The whole Library should probably have that change applied. Kudos to @ElectricRCAircraftGuy
There was a problem hiding this comment.
Q: "When using F() does the compiler optimize the exact same strings and only put them into the Flash once?"
A: No, as far as I can tell, even if the strings are identical, they are put in the flash again each time you use the F() macro. It's not an ideal solution, just a better solution than not using F(). To put it in only once you'd have to manually do that, then manually call them out to print them using AVRLibc directly http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html.
There was a problem hiding this comment.
Since the strings are used several times each, why not put them in like this:
const char DBGtext_lteq[] PROGMEM = {" <= "};
const char DBGtext_pass[] PROGMEM = {"?; passed"};
const char DBGtext_fail[] PROGMEM = {"?; FAILED"};
Then output them like this:
DBG_PRINTLN(F(DBGtext_pass));
I am not sure if the F() should be used in the above or not.
Would this solve the duplicate string issue and gain that part of the PROGMEM back as well?
…ino-IRremote into ElectricRCAircraftGuy-patch-1 merging #258
|
Some body help me add the library, I follow the instruction but can't found the folder with name IRremote, only two file IRremote.h and IRremote.cpp |
|
@reednoel4u If you need help please create a new issue. Thanks! |
…ino-IRremote into ElectricRCAircraftGuy-patch-1 merging Arduino-IRremote#258
This is a small change, and definitely an improvement. I simply improved the debugging by stating whether a check passed or failed, for easier identification in debug mode.