-
Notifications
You must be signed in to change notification settings - Fork 56
Conversation
7e5df8e
to
8ea83dc
Compare
Modify the main.cpp to understand the new "abstract" buttons in mbed OS. Prevoius buttons were applicable only to K64F, but since mbed OS has BUTTON1 and BUTTON2, you can check for those in a board independent manner. Add instructions how to figure out which button is which one.
// to change resource value and unregister | ||
#ifdef TARGET_K64F | ||
// If board has a button_1, use it to update the counter. | ||
#ifdef BUTTON1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the BUTTON1 and BUTTON2 identifiers are actually enum values (see PinNames.h:208 for TARGET_K64F) , so the preprocessor has no knowledge of them. Maybe they should be behind a macro where we could collect other standard definitions like the buttons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One solution - perhaps we can add the button resource run-time, IF the button is available AND always add a timer resource?
Or alternatively - do the buttons.h -header that defines the #ifdefds per board.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some boards seem to define buttons that do not exist, see: https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303x8/TARGET_NUCLEO_F303K8/PinNames.h#L106
The same enum contains a "not connected" value too. If we could rely on some enum value indicating that a button is not available (like the example), we could check that at runtime. But then there's still the issue of missing enum names that cause compile errors.
<shell: mbed-os-example-client/> cd mbed-os | ||
<shell: mbed-os-example-client/mbed-os>$ git grep BUTTON1 |grep -i K64F | ||
targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PinNames.h: BUTTON1 = SW2, | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the idea of having to dive into the hidden places of the source code to identify a button, that's not a great UX! However, I I know it's a pain to identify buttons, as boards vendors use different names.
@senthilr have you come across this situation with other examples apps?
I'd suggest pointing at the platform pages to find out where buttons are located:
https://developer.mbed.org/platforms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one will not work straight out of the box, because the buttons were ENUMs... We need to figure out an alternative solution.
As long as the SW compiles with the boards WE claim we support - that's OK. Then the responsible board owners need to fix their SW (or we can make PR to mbed OS as well). |
#290 supercedes this PR, closing this one out. |
Status
NOT READY
Migrations
NO
Description
Support other boards than K64F also with buttons.