Skip to content

Please make LED_BUILTIN a macro [imported] #758

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
cmaglie opened this issue Nov 15, 2012 · 5 comments
Closed

Please make LED_BUILTIN a macro [imported] #758

cmaglie opened this issue Nov 15, 2012 · 5 comments
Labels
Component: Core Related to the code for the standard Arduino API feature request A request to make an enhancement (not a bug fix)

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 758 moved from a Google Code project.
Added by 2011-12-22T05:25:10.000Z by c...@zygomorphic.com.
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Enhancement, Priority-Medium

Original description

Please change LED_BUILTIN from a typed constant to a macro to better support boards that do not have a built-in LED.

@cmaglie cmaglie closed this as completed in 9b519f2 Nov 3, 2013
@cmaglie
Copy link
Member Author

cmaglie commented Nov 3, 2013

Fixed.

@matthijskooijman
Copy link
Collaborator

Doesn't this actually apply to all other pin definitions in arduino_pins.h (MISO, MOSI, SDA, A0, A1, etc.) as well? It doesn't matter much now, but it's possible that in the future a board without I²C, SPI or ADC is released. Making these constants macros allows checking for them with #if defined conditionals when this happens.

matthijskooijman added a commit to Pinoccio/core-pinoccio that referenced this issue Nov 20, 2013
This allows using them in #if. See also
arduino/Arduino#758
@Lauszus
Copy link
Contributor

Lauszus commented Nov 24, 2013

I agree with @matthijskooijman. They should also be macros instead.
For instance in the USB Host library we have this: https://github.com/felis/USB_Host_Shield_2.0/blob/82c52542cc522982b026bf7f6cdd9059e5064d4a/usbhost.h#L45-L53. This could easily be replaced if MOSI, MISO, SCK and SS where macros.

oriregev pushed a commit to oriregev/Arduino that referenced this issue Dec 20, 2013
@MarkusLange
Copy link

static const uint8_t LED_BUILTIN = 13;

is not declared in the \variants\leonardo\pins_arduino.h for the Leonardo in IDE 1.0.5

@cmaglie
Copy link
Member Author

cmaglie commented Jan 21, 2014

Changing the const int to #include have a subtle side effect, for example the following code:

https://github.com/adafruit/Adafruit-MAX31855-library/blob/master/Adafruit_MAX31855.h#L26

declare parameters name as "MISO", but since we #define MISO to something else, the code is screwed up, an produce errors like the following:

sketch_ac_ino:44: error: no matching function for call to 'Adafruit_MAX31855::Adafruit_MAX31855(int, int, int)'
C:\Users\JSweda\Documents\Arduino\libraries\Adafruit_MAX31855/Adafruit_MAX31855.h:24: 
   note: candidates are: Adafruit_MAX31855::Adafruit_MAX31855() 
   note: Adafruit_MAX31855::Adafruit_MAX31855(const Adafruit_MAX31855&)

The same doesn't happen with the const int declaration (since the local name "hides" the global one).

Any idea?

@per1234 per1234 added Component: Core Related to the code for the standard Arduino API feature request A request to make an enhancement (not a bug fix) labels Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Related to the code for the standard Arduino API feature request A request to make an enhancement (not a bug fix)
Projects
None yet
Development

No branches or pull requests

5 participants