Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Improved button support #289

Closed
wants to merge 1 commit into from
Closed

Improved button support #289

wants to merge 1 commit into from

Conversation

JanneKiiskila
Copy link
Contributor

@JanneKiiskila JanneKiiskila commented Aug 9, 2017

Status

NOT READY

Migrations

NO

Description

Support other boards than K64F also with buttons.

@JanneKiiskila JanneKiiskila changed the title Button 1 Improved button support Aug 9, 2017
@JanneKiiskila JanneKiiskila force-pushed the button-1 branch 2 times, most recently from 7e5df8e to 8ea83dc Compare August 9, 2017 12:59
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
Copy link
Contributor

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?

Copy link
Contributor Author

@JanneKiiskila JanneKiiskila Aug 10, 2017

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.

Copy link
Contributor

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,
```
Copy link
Contributor

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

Copy link
Contributor Author

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.

@JanneKiiskila
Copy link
Contributor Author

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).

@JanneKiiskila
Copy link
Contributor Author

JanneKiiskila commented Aug 11, 2017

#290 supercedes this PR, closing this one out.

@JanneKiiskila JanneKiiskila deleted the button-1 branch August 11, 2017 11:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants