-
Couldn't load subscription status.
- Fork 22
doc: lib: add bm_buttons documentation #422
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
Open
eivindj-nordic
wants to merge
1
commit into
nrfconnect:main
Choose a base branch
from
eivindj-nordic:doc_buttons
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+69
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| .. _lib_bm_buttons: | ||
|
|
||
| Button handling library | ||
| ####################### | ||
|
|
||
| .. contents:: | ||
| :local: | ||
| :depth: 2 | ||
|
|
||
| The button handling library uses the GPIOTE to detect button presses. | ||
|
|
||
| Overview | ||
| ******** | ||
|
|
||
| The library initiates a timer within the GPIOTE event handler to manage debouncing. | ||
| The button is only reported to the application as pressed if the corresponding pin is still active when the timer expires. | ||
|
|
||
| Configuration | ||
| ************* | ||
|
|
||
| The library is enabled using the Kconfig system. | ||
| Set the :kconfig:option:`CONFIG_BM_BUTTONS` Kconfig option to enable the library. | ||
|
|
||
| Use the :kconfig:option:`CONFIG_BM_BUTTONS_NUM_PINS` Kconfig option to configure the number of pins available to the library. | ||
|
|
||
| Initialization | ||
| ============== | ||
|
|
||
| Initialize the library by calling the :c:func:`bm_buttons_init` function. | ||
| This function requires an array of button configurations (:c:struct:`bm_buttons_config`). | ||
| You must also provide the detection delay time used for the debouncing. | ||
|
|
||
| Each button configuration is associated with a separate :c:type:`bm_buttons_handler_t` function. | ||
| The event handler receives the button pin number and state during a button event. | ||
| In this way, all configurations can use the same event handler. | ||
|
|
||
| Usage | ||
| ***** | ||
|
|
||
| After initialization, enable the buttons by calling the :c:func:`bm_buttons_enable` function. | ||
| They can be disabled by calling the :c:func:`bm_buttons_disable` function. | ||
|
|
||
| Once a button is pressed and the debouncing process succeeds (the button state has not changed during the detection delay period), its configured event handler function is triggered. | ||
|
|
||
| When a button is enabled, you can call the :c:func:`bm_buttons_is_pressed` function to check whether it is pressed or not. | ||
|
|
||
| To deinitialize the library, call the :c:func:`bm_buttons_deinit` function. | ||
|
|
||
| Dependencies | ||
| ************ | ||
|
|
||
| This library uses the following |BMshort| libraries: | ||
|
|
||
| * Timer - :kconfig:option:`CONFIG_BM_TIMER` | ||
|
|
||
| API documentation | ||
| ***************** | ||
|
|
||
| | Header file: :file:`include/bm/bm_buttons.h` | ||
| | Source files: :file:`lib/bm_buttons/` | ||
|
|
||
| :ref:`Button handling library API reference <api_bm_buttons>` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.