Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cliCMix can not handle neg. mot. number #274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ static void cliAux(char *cmdline)
static void cliCMix(char *cmdline)
{
int i, check = 0;
int num_motors = 0;
int num_motors;
uint8_t len;
char buf[16];
float mixsum[3];
Expand All @@ -523,13 +523,13 @@ static void cliCMix(char *cmdline)
for (i = 0; i < MAX_MOTORS; i++) {
if (mcfg.customMixer[i].throttle == 0.0f)
break;
num_motors++;
printf("#%d:\t", i + 1);
printf("%s\t", ftoa(mcfg.customMixer[i].throttle, buf));
printf("%s\t", ftoa(mcfg.customMixer[i].roll, buf));
printf("%s\t", ftoa(mcfg.customMixer[i].pitch, buf));
printf("%s\r\n", ftoa(mcfg.customMixer[i].yaw, buf));
}
num_motors = i;
mixsum[0] = mixsum[1] = mixsum[2] = 0.0f;
for (i = 0; i < num_motors; i++) {
mixsum[0] += mcfg.customMixer[i].roll;
Expand Down Expand Up @@ -564,8 +564,8 @@ static void cliCMix(char *cmdline)
}
} else {
ptr = cmdline;
i = atoi(ptr); // get motor number
if (--i < MAX_MOTORS) {
i = atoi(ptr) - 1; // get motor number
if (i >= 0 && i < MAX_MOTORS) {
ptr = strchr(ptr, ' ');
if (ptr) {
mcfg.customMixer[i].throttle = _atof(++ptr);
Expand Down