Skip to content

Redefine F() as no-op #54

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

Closed
wants to merge 1 commit into from
Closed

Redefine F() as no-op #54

wants to merge 1 commit into from

Conversation

MCUdude
Copy link
Contributor

@MCUdude MCUdude commented Sep 16, 2019

See #11 and #53 for details

@facchinm
Copy link
Member

Manually merged as d316aa6 , thanks!

@facchinm facchinm closed this Sep 16, 2019
@MCUdude
Copy link
Contributor Author

MCUdude commented Sep 16, 2019

So how about the digital_pin_to arrays where pgm_read_byte? We can save some memory (a couple of hundred bytes actually!) and clock cycles by removing all this.

@facchinm
Copy link
Member

If you want to target it I'll be glad to merge the PR 😉

@MCUdude
Copy link
Contributor Author

MCUdude commented Sep 16, 2019

Sure! But I'll have to do some proper testing first, so give me a few days.

@facchinm
Copy link
Member

Agree, thank you!

@matthijskooijman
Copy link
Collaborator

I wonder if this is really the cleanest way to fix this. I'm actually a bit surprised that the F macro is defined by ArduinoCore-API, since it is rather target-specific. I would have expected each target to define it as a no-op or functional depending on what the target needs. Instead, it seems there is now AVR-specific code (guarded by an #ifdef __AVR__) in the generic API repo (https://github.com/arduino/ArduinoCore-API/blob/master/api/String.h#L29-L42), which is a bit smelly. In addition to the definition of F(), it seems the API repo also defines AVR-specific handling of FlashStringHelper (e.g. how to print it: https://github.com/arduino/ArduinoCore-API/blob/master/api/Print.cpp#L41-L53

I wonder if this should somehow be done differently? Maybe the Print::print(__FlashStringHelper*) should be declared by API but defined by the core? Or should the core and API communicate using macros somehow (so the API can define default nop versions for cores that do not need this, and leave things undefined for cores that do need it)? Hm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants