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

Bugfix flapper power distribution #1136

Merged
merged 2 commits into from
Oct 13, 2022
Merged
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
25 changes: 18 additions & 7 deletions src/modules/src/power_distribution_flapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ static float pitch_ampl = 0.4f; // 1 = full servo stroke

#if CONFIG_POWER_DISTRIBUTION_FLAPPER_REVB
uint32_t idPitch = 1;
uint32_t idYaw = 4;
uint32_t idYaw = 2;
#else
uint32_t idPitch = 2;
uint32_t idYaw = 4;
uint32_t idPitch = 0;
uint32_t idYaw = 2;
#endif

static uint8_t limitServoNeutral(uint8_t value)
Expand Down Expand Up @@ -102,16 +102,27 @@ static int8_t limitRollBias(uint8_t value)

int powerDistributionMotorType(uint32_t id)
{
int type = 0;
if (id == (idPitch || idYaw)) type = 1;
int type = 1;
if (id == idPitch || id == idYaw)
{
type = 0;
}

return type;
}

uint16_t powerDistributionStopRatio(uint32_t id)
{
uint16_t stopRatio = 0;
if (id==idPitch) stopRatio = flapperConfig.pitchServoNeutral*act_max/100.0f;
else if (id==idYaw) stopRatio = flapperConfig.yawServoNeutral*act_max/100.0f;
if (id == idPitch)
{
stopRatio = flapperConfig.pitchServoNeutral*act_max/100.0f;
}
else if (id == idYaw)
{
stopRatio = flapperConfig.yawServoNeutral*act_max/100.0f;
}

return stopRatio;
}

Expand Down