button.rst 1.4 KB

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