Add time command to cli

This commit is contained in:
Oleg Kalachev 2025-01-12 19:50:00 +03:00
parent 48d21a911f
commit d4e04c46cd

View File

@ -7,7 +7,8 @@
#include "vector.h" #include "vector.h"
extern const int MOTOR_REAR_LEFT, MOTOR_REAR_RIGHT, MOTOR_FRONT_RIGHT, MOTOR_FRONT_LEFT; extern const int MOTOR_REAR_LEFT, MOTOR_REAR_RIGHT, MOTOR_FRONT_RIGHT, MOTOR_FRONT_LEFT;
extern float loopRate; extern float loopRate, dt;
extern float t;
extern int rollChannel, pitchChannel, throttleChannel, yawChannel, armedChannel, modeChannel; extern int rollChannel, pitchChannel, throttleChannel, yawChannel, armedChannel, modeChannel;
const char* motd = const char* motd =
@ -24,6 +25,7 @@ const char* motd =
"p <name> - show parameter\n" "p <name> - show parameter\n"
"p <name> <value> - set parameter\n" "p <name> <value> - set parameter\n"
"preset - reset parameters\n" "preset - reset parameters\n"
"time - show time info\n"
"ps - show pitch/roll/yaw\n" "ps - show pitch/roll/yaw\n"
"psq - show attitude quaternion\n" "psq - show attitude quaternion\n"
"imu - show IMU data\n" "imu - show IMU data\n"
@ -53,6 +55,10 @@ void doCommand(const String& command, const String& arg0, const String& arg1) {
} }
} else if (command == "preset") { } else if (command == "preset") {
resetParameters(); resetParameters();
} else if (command == "time") {
Serial.printf("Time: %f\n", t);
Serial.printf("Loop rate: %f\n", loopRate);
Serial.printf("dt: %f\n", dt);
} else if (command == "ps") { } else if (command == "ps") {
Vector a = attitude.toEulerZYX(); Vector a = attitude.toEulerZYX();
Serial.printf("roll: %f pitch: %f yaw: %f\n", degrees(a.x), degrees(a.y), degrees(a.z)); Serial.printf("roll: %f pitch: %f yaw: %f\n", degrees(a.x), degrees(a.y), degrees(a.z));