From 1ae85ff11810928a1ab0367e51ceafe60ec2a751 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Thu, 2 Jul 2026 22:22:33 +0300 Subject: [PATCH] Add argument to motor testing commands for specifying thrust --- flix/cli.ino | 10 +++++----- flix/motors.ino | 4 ++-- gazebo/flix.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/flix/cli.ino b/flix/cli.ino index 9eaa12c..4926243 100644 --- a/flix/cli.ino +++ b/flix/cli.ino @@ -51,7 +51,7 @@ const char* motd = "espnow [] - configure ESP-NOW peer\n" "mot - show motor output\n" "log [dump] - print log header [and data]\n" -"mfr, mfl, mrr, mrl - test motor (remove props)\n" +"mfr/mfl/mrr/mrl [] - test motor (remove props)\n" "sys - show system info\n" "reset - reset drone's state\n" "reboot - reboot the drone\n"; @@ -161,13 +161,13 @@ void doCommand(String str, bool echo = false) { } else if (command == "ca") { calibrateAccel(); } else if (command == "mfr") { - testMotor(MOTOR_FRONT_RIGHT); + testMotor(MOTOR_FRONT_RIGHT, arg0.isEmpty() ? 0.2 : arg0.toFloat()); } else if (command == "mfl") { - testMotor(MOTOR_FRONT_LEFT); + testMotor(MOTOR_FRONT_LEFT, arg0.isEmpty() ? 0.2 : arg0.toFloat()); } else if (command == "mrr") { - testMotor(MOTOR_REAR_RIGHT); + testMotor(MOTOR_REAR_RIGHT, arg0.isEmpty() ? 0.2 : arg0.toFloat()); } else if (command == "mrl") { - testMotor(MOTOR_REAR_LEFT); + testMotor(MOTOR_REAR_LEFT, arg0.isEmpty() ? 0.2 : arg0.toFloat()); } else if (command == "sys") { #ifdef ESP32 print("Chip: %s\n", ESP.getChipModel()); diff --git a/flix/motors.ino b/flix/motors.ino index 9654eec..6b808b1 100644 --- a/flix/motors.ino +++ b/flix/motors.ino @@ -51,9 +51,9 @@ bool motorsActive() { return motors[0] != 0 || motors[1] != 0 || motors[2] != 0 || motors[3] != 0; } -void testMotor(int n) { +void testMotor(int n, float thrust) { print("Testing motor %d\n", n); - motors[n] = 0.2; + motors[n] = thrust; delay(50); // ESP32 may need to wait until the end of the current cycle to change duty https://github.com/espressif/arduino-esp32/issues/5306 sendMotors(); pause(3); diff --git a/gazebo/flix.h b/gazebo/flix.h index e0ba9ab..a6f36fb 100644 --- a/gazebo/flix.h +++ b/gazebo/flix.h @@ -38,7 +38,7 @@ const char* getModeName(); void sendMotors(); int getDutyCycle(float value); bool motorsActive(); -void testMotor(int n); +void testMotor(int, float); void print(const char* format, ...); void pause(float duration); void doCommand(String str, bool echo);