From a294883dea33ea1e47b6acc679f8e8f7075fd1fb Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Wed, 27 May 2026 13:58:51 +0300 Subject: [PATCH] Make p command show all parameters starting with the arg --- flix/cli.ino | 8 +++----- flix/parameters.ino | 3 ++- gazebo/flix.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/flix/cli.ino b/flix/cli.ino index 7922f1a..faeaac3 100644 --- a/flix/cli.ino +++ b/flix/cli.ino @@ -31,7 +31,7 @@ const char* motd = "Commands:\n\n" "help - show help\n" "p - show all parameters\n" -"p - show parameter\n" +"p - show parameters starting with str\n" "p - set parameter\n" "preset - reset parameters\n" "time - show time info\n" @@ -92,10 +92,8 @@ void doCommand(String str, bool echo = false) { // execute command if (command == "help" || command == "motd") { print("%s\n", motd); - } else if (command == "p" && arg0 == "") { - printParameters(); - } else if (command == "p" && arg0 != "" && arg1 == "") { - print("%s = %g\n", arg0.c_str(), getParameter(arg0.c_str())); + } else if (command == "p" && arg1 == "") { + printParameters(arg0.c_str()); } else if (command == "p") { bool success = setParameter(arg0.c_str(), arg1.toFloat()); if (success) { diff --git a/flix/parameters.ino b/flix/parameters.ino index f1dd5df..65f3e89 100644 --- a/flix/parameters.ino +++ b/flix/parameters.ino @@ -188,8 +188,9 @@ void syncParameters() { } } -void printParameters() { +void printParameters(const char *filter) { for (auto ¶meter : parameters) { + if (strncasecmp(parameter.name, filter, strlen(filter))) continue; print("%s = %g\n", parameter.name, parameter.getValue()); } } diff --git a/gazebo/flix.h b/gazebo/flix.h index 122bdb5..8c3f1c3 100644 --- a/gazebo/flix.h +++ b/gazebo/flix.h @@ -68,7 +68,7 @@ const char *getParameterName(int index); float getParameter(int index); float getParameter(const char *name); bool setParameter(const char *name, const float value); -void printParameters(); +void printParameters(const char *filter); void resetParameters(); // mocks