Skip to content
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

Update IRremote.cpp to improve debugging #258

Conversation

ElectricRCAircraftGuy
Copy link
Contributor

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.

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
@@ -41,14 +41,19 @@
//
int MATCH (int measured, int desired)
{
DBG_PRINT("Testing: ");
DBG_PRINT(F("Testing: "));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does F("") do? I'm not a very advanced C programmer so can you please explain it to me? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it, all printed string constants take both flash and RAM memory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anything <2 chars it's a wash. Just using it takes a couple bytes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the detailed explanation. I will look into merging this soon. Once again thank you for the contribution

@z3t0 z3t0 self-assigned this Jan 26, 2016
@z3t0 z3t0 added the Enhancement Idea or request for enhancement of the library label Jan 26, 2016
DBG_PRINT(measured, DEC);
DBG_PRINT(" <= ");
DBG_PRINTLN(TICKS_HIGH(desired), DEC);
DBG_PRINT(F(" <= "));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#261

z3t0 added a commit that referenced this pull request Feb 21, 2016
…ino-IRremote into ElectricRCAircraftGuy-patch-1

merging #258
z3t0 added a commit that referenced this pull request Feb 21, 2016
z3t0 added a commit that referenced this pull request Feb 21, 2016
@z3t0 z3t0 closed this Feb 21, 2016
@reednoel4u
Copy link

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
"4. Move the "IRremote" folder that has been extracted to your libraries directory."
Sorry my english and I'm a newbie.
Rgs

@z3t0
Copy link
Collaborator

z3t0 commented May 31, 2016

@reednoel4u If you need help please create a new issue. Thanks!

Theaninova pushed a commit to Theaninova/Arduino-IRremote that referenced this pull request Dec 2, 2023
Theaninova pushed a commit to Theaninova/Arduino-IRremote that referenced this pull request Dec 2, 2023
Theaninova pushed a commit to Theaninova/Arduino-IRremote that referenced this pull request Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Idea or request for enhancement of the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants