Skip to content

Commit

Permalink
Merge pull request #264 from schugabe/livesmixupdate
Browse files Browse the repository at this point in the history
Adding live update of Servomixer rules
  • Loading branch information
trollcop committed Mar 21, 2015
2 parents 7762490 + a3976b5 commit 38afba6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,24 @@ int servoDirection(int nr, int lr)
return 1;
}

void loadCustomServoMixer(void)
{
uint8_t i;

// reset settings
numberRules = 0;
memset(currentServoMixer, 0, sizeof(currentServoMixer));

// load custom mixer into currentServoMixer
for (i = 0; i < MAX_SERVO_RULES; i++) {
// check if done
if (mcfg.customServoMixer[i].rate == 0)
break;
currentServoMixer[i] = mcfg.customServoMixer[i];
numberRules++;
}
}

void mixerInit(void)
{
int i;
Expand Down Expand Up @@ -310,16 +328,8 @@ void mixerInit(void)
if (mcfg.mixerConfiguration == MULTITYPE_FLYING_WING || mcfg.mixerConfiguration == MULTITYPE_AIRPLANE || mcfg.mixerConfiguration == MULTITYPE_CUSTOM_PLANE) {
f.FIXED_WING = 1;

if (mcfg.mixerConfiguration == MULTITYPE_CUSTOM_PLANE) {
// load custom mixer into currentServoMixer
for (i = 0; i < MAX_SERVO_RULES; i++) {
// check if done
if (mcfg.customServoMixer[i].rate == 0)
break;
currentServoMixer[i] = mcfg.customServoMixer[i];
numberRules++;
}
}
if (mcfg.mixerConfiguration == MULTITYPE_CUSTOM_PLANE)
loadCustomServoMixer();
} else
f.FIXED_WING = 0;

Expand Down
1 change: 1 addition & 0 deletions src/mw.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ void writeServos(void);
void writeMotors(void);
void writeAllMotors(int16_t mc);
void mixTable(void);
void loadCustomServoMixer(void);

// Serial
void serialInit(uint32_t baudrate);
Expand Down
1 change: 1 addition & 0 deletions src/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ static void evaluateCommand(void)
mcfg.customServoMixer[i].max = read8();
mcfg.customServoMixer[i].box = read8();
}
loadCustomServoMixer();
break;
case MSP_MOTOR:
s_struct((uint8_t *)motor, 16);
Expand Down

0 comments on commit 38afba6

Please sign in to comment.