'button list' only prints the state once and exits which makes it impractical to verify a button mapping on a mobile device.
Patch 1 moves the state printing into a shared helper. Patch 2 adds a 'monitor' subcommand which redraws the state of all buttons every 100ms until Ctrl-C is pressed or a timeout expires (default 5s, 0 for none). Patch 3 documents the new subcommand. Patch 4 adds test for the monitor. Signed-off-by: Petr Hodina <[email protected]> --- Changes in v3: - Split the show_button_status() refactor out of the monitor patch - Reword commit messages: mention Ctrl-C and the zero timeout - Link to v2: https://patch.msgid.link/[email protected] Changes in v2: - Add Ctrl-C handling. Timeout of 0 now runs until Ctrl-C - Use ANSI_* macros from ansi.h and plain \n instead of raw escapes - Share state printing with "button list" (on/off/<inactive>/Error N) and probe all buttons once before the loop - Match "monitor" with strcmp() and reject an invalid timeout - Add documentation and sandbox tests - Link to v1: https://patch.msgid.link/[email protected] --- Petr Hodina (4): cmd: button: factor out state printing from 'button list' cmd: button: add live monitor subcommand doc: button: document monitor subcommand test: button: add test for monitor subcommand cmd/button.c | 104 +++++++++++++++++++++++++++++++++++++++---- doc/usage/cmd/button.rst | 16 +++++++ test/py/tests/test_button.py | 20 +++++++++ 3 files changed, 131 insertions(+), 9 deletions(-) --- base-commit: ece349ade2973e220f524ce59e59711cc919263f change-id: 20261002-b4-button-live-monitor-87b27d864cb6 Best regards, -- Petr Hodina <[email protected]>
