Heinrich Schuchardt | 24ceb44 | 2020-12-16 12:15:49 +0100 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | button command |
| 4 | ============== |
| 5 | |
| 6 | Synopsis |
| 7 | -------- |
| 8 | |
| 9 | :: |
| 10 | |
| 11 | button list |
| 12 | button <name> |
| 13 | |
| 14 | Description |
| 15 | ----------- |
| 16 | |
| 17 | The button command is used to retrieve the status of a button. To show the |
| 18 | status of a button with name 'button1' you would issue the command |
| 19 | |
| 20 | :: |
| 21 | |
| 22 | button button1 |
| 23 | |
| 24 | The status of the button is both written to the console as *ON* or *OFF* and |
| 25 | set in the return value variable *$?* as 0 (true) or 1 (false). To retrieve |
| 26 | the status of a button with name *button1* and to write it to environment |
| 27 | variable *status1* you would execute the commands |
| 28 | |
| 29 | :: |
| 30 | |
| 31 | button button1 |
| 32 | setenv status1 $? |
| 33 | |
| 34 | A list of all available buttons and their status can be displayed using |
| 35 | |
| 36 | :: |
| 37 | |
| 38 | button list |
| 39 | |
| 40 | If a button device has not been probed yet, its status will be shown as |
| 41 | *<inactive>* in the list. |
| 42 | |
| 43 | Configuration |
| 44 | ------------- |
| 45 | |
| 46 | To use the button command you must specify CONFIG_CMD_BUTTON=y and enable a |
| 47 | button driver. The available buttons are defined in the device-tree. |
| 48 | |
| 49 | Return value |
| 50 | ------------ |
| 51 | |
| 52 | The variable *$?* takes the following values |
| 53 | |
| 54 | +---+-----------------------------+ |
| 55 | | 0 | ON, the button is pressed | |
| 56 | +---+-----------------------------+ |
| 57 | | 1 | OFF, the button is released | |
| 58 | +---+-----------------------------+ |
| 59 | | 0 | button list was shown | |
| 60 | +---+-----------------------------+ |
| 61 | | 1 | button not found | |
| 62 | +---+-----------------------------+ |
| 63 | | 1 | invalid arguments | |
| 64 | +---+-----------------------------+ |