arduino-libraries / Arduino_MKRIoTCarrier

Use the features included with the Arduino MKR IoT Carrier
https://store.arduino.cc/mkr-iot-carrier
GNU Lesser General Public License v2.1
18 stars 11 forks source link

Avoid configuring the library using an extern variable #13

Closed alranel closed 2 years ago

alranel commented 4 years ago

As of now, this library must be configured by declaring a global variable after including the library:

#include <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;
bool CARRIER_CASE = false;

The variable is declared as extern in this library:

https://github.com/arduino-libraries/Arduino_MKRIoTCarrier/blob/788a4b026b55292fad8616b5354cc215b7be4d95/src/Arduino_MKRIoTCarrier.h#L80

If removed from the sketch, it will not compile.

This configuration pattern, however, might confuse users who (like me) see an unused variable and try to remove it. It's a bit obscure for basic users who don't know about extern symbols or the build process. Not really a big issue, but we should probably stick to a more explicit and Arduino-like pattern like:

carrier.begin(CARRIER_CASE);

or even:

carrier.withCase();

I wonder if there's a clever way to make this change in a retrocompatible fashion. :)

aentinger commented 4 years ago

I'd assign @marqdevx to this issue due to the fact he has effectively written the whole library.

marqdevx commented 4 years ago

I will try to find another way to make it more simple with the team, thanks.

I will contact with you soon @alranel

carterwe commented 3 years ago

What difference does false or true make for CARRIER_CASE;

marqdevx commented 3 years ago

@carterwe true means that you have the Enclosure Case attached to the Carrier false means that you DONT have the Enclosure Case attached to the Carrier

So it calibrates the touch buttons to be, in both cases, functional

carterwe commented 3 years ago

So it calibrates the touch buttons to be, in both cases, functional

Ah... this is what I was looking for! I hear you guys will have complete new project documentation soon (even mentioning how to use and connect the battery). Very good! I'm really looking forward to it. I am application programmer just trying to pick up all this board connecting, Arduino C++, and Arduino library stuff up. The better the documentation the way better for me. Thanks for your reply! :) Ed

On Fri, Dec 4, 2020 at 8:14 AM marqdevx notifications@github.com wrote:

@carterwe https://github.com/carterwe true means that you have the Enclosure Case attached to the Carrier false means that you DONT have the Enclosure Case attached to the Carrier

So it calibrates the touch buttons to be, in both cases, functional

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arduino-libraries/Arduino_MKRIoTCarrier/issues/13#issuecomment-738838395, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDHASXDXSZJ4JO4KQG6ZU3STD4DXANCNFSM4SYKUJSA .

marqdevx commented 3 years ago

@carterwe Thanks!!

Please check the Reference page to read more :) https://www.arduino.cc/reference/en/libraries/arduino_mkriotcarrier/

alranel commented 3 years ago

@marqdevx This issue is still valid :)