Skip to content

Commit

Permalink
Merge pull request #67 from blckmn/combining_use_pwm_rate
Browse files Browse the repository at this point in the history
Combine oneshot and multishot into single use of "use_pwm_rate"
  • Loading branch information
rs2k committed Jan 25, 2016
2 parents 345fa9d + c939609 commit b1a843c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/main/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ typedef enum {
FEATURE_BLACKBOX = 1 << 19,
FEATURE_CHANNEL_FORWARDING = 1 << 20,
FEATURE_MULTISHOT = 1 << 21,
FEATURE_ONESHOT_PWM_RATE = 1 << 22,
FEATURE_MULTISHOT_PWM_RATE = 1 << 23,
FEATURE_USE_PWM_RATE = 1 << 22,
FEATURE_RESERVED = 1 << 23,
FEATURE_TX_STYLE_EXPO = 1 << 24,
FEATURE_SBUS_INVERTER = 1 << 25,
} features_e;
Expand Down
4 changes: 2 additions & 2 deletions src/main/drivers/pwm_mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ if (init->useBuzzerP6) {
}
else
{
if (init->useOneshotPwmRate)
if (init->usePwmRate)
{
pwmOneshotPwmRateMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount, init->motorPwmRate, init->idlePulse);
}
Expand All @@ -1168,7 +1168,7 @@ if (init->useBuzzerP6) {
pwmOutputConfiguration.portConfigurations[pwmOutputConfiguration.outputCount].flags = PWM_PF_MOTOR | PWM_PF_OUTPUT_PROTOCOL_ONESHOT|PWM_PF_OUTPUT_PROTOCOL_PWM ;
}
else if (init->useMultiShot) {
if (init->useMultiShotPwmRate)
if (init->usePwmRate)
{
pwmMultiShotPwmRateMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount, init->motorPwmRate, init->idlePulse);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/drivers/pwm_mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ typedef struct drv_pwm_config_s {
#endif
bool useVbat;
bool useOneshot;
bool useOneshotPwmRate;
bool useMultiShot;
bool useMultiShotPwmRate;
bool usePwmRate;
bool useFastPWM;
bool useSoftSerial;
bool useLEDStrip;
Expand Down
2 changes: 1 addition & 1 deletion src/main/flight/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void writeMotors(void)
pwmWriteMotor(i, motor[i]);

if (feature(FEATURE_MULTISHOT) || (feature(FEATURE_ONESHOT125))) {
if ( feature(FEATURE_MULTISHOT_PWM_RATE) || feature(FEATURE_ONESHOT_PWM_RATE) ) { } else {
if (!feature(FEATURE_USE_PWM_RATE)) {
pwmCompleteOneshotMotorUpdate(motorCount);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/io/serial_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ static const char * const featureNames[] = {
"SERVO_TILT", "SOFTSERIAL", "GPS", "FAILSAFE",
"SONAR", "TELEMETRY", "CURRENT_METER", "3D", "RX_PARALLEL_PWM",
"RX_MSP", "RSSI_ADC", "LED_STRIP", "DISPLAY", "ONESHOT125",
"BLACKBOX", "CHANNEL_FORWARDING", "MULTISHOT", "ONESHOT_PWM_RATE",
"MULTISHOT_PWM_RATE", "TX_STYLE_EXPO", "SBUS_INVERTER", NULL
"BLACKBOX", "CHANNEL_FORWARDING", "MULTISHOT", "USE_PWM_RATE",
"RESERVED", "TX_STYLE_EXPO", "SBUS_INVERTER", NULL
};

// sync this with rxFailsafeChannelMode_e
Expand Down
10 changes: 4 additions & 6 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,8 @@ void init(void)
#endif

pwm_params.useOneshot = feature(FEATURE_ONESHOT125);
pwm_params.useOneshotPwmRate = feature(FEATURE_ONESHOT_PWM_RATE);
pwm_params.useMultiShot = feature(FEATURE_MULTISHOT);
pwm_params.useMultiShotPwmRate = feature(FEATURE_MULTISHOT_PWM_RATE);
pwm_params.usePwmRate = feature(FEATURE_USE_PWM_RATE);
pwm_params.useFastPWM = masterConfig.use_fast_pwm ? true : false;
pwm_params.motorPwmRate = masterConfig.motor_pwm_rate;
if (feature(FEATURE_3D))
Expand All @@ -287,20 +286,19 @@ void init(void)
}
else
{
if ((pwm_params.motorPwmRate > 500 && !masterConfig.use_fast_pwm) && !feature(FEATURE_ONESHOT_PWM_RATE) && !feature(FEATURE_MULTISHOT_PWM_RATE))
if ((pwm_params.motorPwmRate > 500 && !masterConfig.use_fast_pwm) && !feature(FEATURE_USE_PWM_RATE))
{
pwm_params.idlePulse = 0; // brushed motors
}
else
{
if (feature(FEATURE_MULTISHOT_PWM_RATE)) {
if (feature(FEATURE_USE_PWM_RATE)) {
pwm_params.idlePulse = (uint16_t)((float)(masterConfig.escAndServoConfig.mincommand-1000) / 4.1666f)+60;
} else {
pwm_params.idlePulse = (uint16_t)((float)masterConfig.escAndServoConfig.mincommand*1.5f);
}
}
}

}

pwmOutputConfiguration_t *pwmOutputConfiguration = pwmInit(&pwm_params);

Expand Down

0 comments on commit b1a843c

Please sign in to comment.