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