Skip to content

Commit

Permalink
Minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
okalachev committed Jan 10, 2025
1 parent 698cc3d commit 568f9dd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions flix/cli.ino
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void doCommand(String& command, String& arg0, String& arg1) {
resetParameters();
} else if (command == "ps") {
Vector a = attitude.toEulerZYX();
Serial.printf("roll: %f pitch: %f yaw: %f\n", a.x * RAD_TO_DEG, a.y * RAD_TO_DEG, a.z * RAD_TO_DEG);
Serial.printf("roll: %f pitch: %f yaw: %f\n", degrees(a.x), degrees(a.y), degrees(a.z));
} else if (command == "psq") {
Serial.printf("qx: %f qy: %f qz: %f qw: %f\n", attitude.x, attitude.y, attitude.z, attitude.w);
} else if (command == "imu") {
Expand All @@ -67,12 +67,12 @@ void doCommand(String& command, String& arg0, String& arg1) {
Serial.printf("Raw: throttle %d yaw %d pitch %d roll %d armed %d mode %d\n",
channels[RC_CHANNEL_THROTTLE], channels[RC_CHANNEL_YAW], channels[RC_CHANNEL_PITCH],
channels[RC_CHANNEL_ROLL], channels[RC_CHANNEL_ARMED], channels[RC_CHANNEL_MODE]);
Serial.printf("Control: throttle %f yaw %f pitch %f roll %f armed %f mode %f\n",
Serial.printf("Control: throttle %g yaw %g pitch %g roll %g armed %g mode %g\n",
controls[RC_CHANNEL_THROTTLE], controls[RC_CHANNEL_YAW], controls[RC_CHANNEL_PITCH],
controls[RC_CHANNEL_ROLL], controls[RC_CHANNEL_ARMED], controls[RC_CHANNEL_MODE]);
Serial.printf("Mode: %s\n", getModeName());
} else if (command == "mot") {
Serial.printf("MOTOR front-right %f front-left %f rear-right %f rear-left %f\n",
Serial.printf("Motors: front-right %g front-left %g rear-right %g rear-left %g\n",
motors[MOTOR_FRONT_RIGHT], motors[MOTOR_FRONT_LEFT], motors[MOTOR_REAR_RIGHT], motors[MOTOR_REAR_LEFT]);
} else if (command == "log") {
dumpLog();
Expand Down
4 changes: 2 additions & 2 deletions flix/rc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ void calibrateRC() {
}

void printRCCal() {
printArray(channelNeutral, RC_CHANNELS);
printArray(channelMax, RC_CHANNELS);
printArray(channelNeutral);
printArray(channelMax);
}
6 changes: 3 additions & 3 deletions flix/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ float wrapAngle(float angle) {
return angle;
}

template <typename T>
void printArray(T arr[], int size) {
for (uint8_t i = 0; i < size; i++) {
template <typename T, int N>
void printArray(const T (&arr)[N]) {
for (int i = 0; i < N; i++) {
Serial.printf("%g ", static_cast<float>(arr[i]));
}
Serial.println();
Expand Down

0 comments on commit 568f9dd

Please sign in to comment.