Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -2618,7 +2618,7 @@ Exponential value used for the YAW axis by the `MANUAL` flight mode [0-100]

| Default | Min | Max |
| --- | --- | --- |
| 20 | 0 | 100 |
| 20 | -100 | 100 |

---

Expand Down Expand Up @@ -5808,7 +5808,7 @@ Exponential value used for the YAW axis by all the stabilized flights modes (all

| Default | Min | Max |
| --- | --- | --- |
| 20 | 0 | 100 |
| 20 | -100 | 100 |

---

Expand Down
5 changes: 5 additions & 0 deletions src/main/common/streambuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ void sbufWriteU8(sbuf_t *dst, uint8_t val)
*dst->ptr++ = val;
}

void sbufWriteI8(sbuf_t *dst, int8_t val)
{
*dst->ptr++ = val;
}

void sbufWriteU16(sbuf_t *dst, uint16_t val)
{
sbufWriteU8(dst, val >> 0);
Expand Down
1 change: 1 addition & 0 deletions src/main/common/streambuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef struct sbuf_s {
sbuf_t *sbufInit(sbuf_t *sbuf, uint8_t *ptr, uint8_t *end);

void sbufWriteU8(sbuf_t *dst, uint8_t val);
void sbufWriteI8(sbuf_t *dst, int8_t val);
void sbufWriteU16(sbuf_t *dst, uint16_t val);
void sbufWriteU32(sbuf_t *dst, uint32_t val);
void sbufFill(sbuf_t *dst, uint8_t data, int len);
Expand Down
4 changes: 2 additions & 2 deletions src/main/fc/controlrate_profile_config_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ typedef struct controlRateConfig_s {

struct {
uint8_t rcExpo8;
uint8_t rcYawExpo8;
int8_t rcYawExpo8;
uint8_t rates[3];
} stabilized;

struct {
uint8_t rcExpo8;
uint8_t rcYawExpo8;
int8_t rcYawExpo8;
uint8_t rates[3];
} manual;

Expand Down
4 changes: 2 additions & 2 deletions src/main/fc/fc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ bool areSensorsCalibrating(void)
return false;
}

int16_t getAxisRcCommand(int16_t rawData, int16_t rate, int16_t deadband)
int16_t getAxisRcCommand(int16_t rawData, int8_t expo, int16_t deadband)
{
int16_t stickDeflection = 0;

Expand All @@ -195,7 +195,7 @@ int16_t getAxisRcCommand(int16_t rawData, int16_t rate, int16_t deadband)
#endif

stickDeflection = applyDeadbandRescaled(stickDeflection, deadband, -500, 500);
return rcLookup(stickDeflection, rate);
return rcLookup(stickDeflection, expo);
}

static void updateArmingStatus(void)
Expand Down
12 changes: 6 additions & 6 deletions src/main/fc/fc_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
sbufWriteU8(dst, currentControlRateProfile->throttle.rcMid8);
sbufWriteU8(dst, currentControlRateProfile->throttle.rcExpo8);
sbufWriteU16(dst, currentControlRateProfile->throttle.pa_breakpoint);
sbufWriteU8(dst, currentControlRateProfile->stabilized.rcYawExpo8);
sbufWriteI8(dst, currentControlRateProfile->stabilized.rcYawExpo8);
break;

case MSP2_INAV_RATE_PROFILE:
Expand All @@ -712,14 +712,14 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF

// stabilized
sbufWriteU8(dst, currentControlRateProfile->stabilized.rcExpo8);
sbufWriteU8(dst, currentControlRateProfile->stabilized.rcYawExpo8);
sbufWriteI8(dst, currentControlRateProfile->stabilized.rcYawExpo8);
for (uint8_t i = 0 ; i < 3; ++i) {
sbufWriteU8(dst, currentControlRateProfile->stabilized.rates[i]); // R,P,Y see flight_dynamics_index_t
}

// manual
sbufWriteU8(dst, currentControlRateProfile->manual.rcExpo8);
sbufWriteU8(dst, currentControlRateProfile->manual.rcYawExpo8);
sbufWriteI8(dst, currentControlRateProfile->manual.rcYawExpo8);
for (uint8_t i = 0 ; i < 3; ++i) {
sbufWriteU8(dst, currentControlRateProfile->manual.rates[i]); // R,P,Y see flight_dynamics_index_t
}
Expand Down Expand Up @@ -2017,7 +2017,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
((controlRateConfig_t*)currentControlRateProfile)->throttle.rcExpo8 = sbufReadU8(src);
((controlRateConfig_t*)currentControlRateProfile)->throttle.pa_breakpoint = sbufReadU16(src);
if (dataSize > 10) {
((controlRateConfig_t*)currentControlRateProfile)->stabilized.rcYawExpo8 = sbufReadU8(src);
((controlRateConfig_t*)currentControlRateProfile)->stabilized.rcYawExpo8 = sbufReadI8(src);
}

schedulePidGainsUpdate();
Expand All @@ -2038,7 +2038,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)

// stabilized
currentControlRateProfile_p->stabilized.rcExpo8 = sbufReadU8(src);
currentControlRateProfile_p->stabilized.rcYawExpo8 = sbufReadU8(src);
currentControlRateProfile_p->stabilized.rcYawExpo8 = sbufReadI8(src);
for (uint8_t i = 0; i < 3; ++i) {
tmp_u8 = sbufReadU8(src);
if (i == FD_YAW) {
Expand All @@ -2050,7 +2050,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)

// manual
currentControlRateProfile_p->manual.rcExpo8 = sbufReadU8(src);
currentControlRateProfile_p->manual.rcYawExpo8 = sbufReadU8(src);
currentControlRateProfile_p->manual.rcYawExpo8 = sbufReadI8(src);
for (uint8_t i = 0; i < 3; ++i) {
tmp_u8 = sbufReadU8(src);
if (i == FD_YAW) {
Expand Down
24 changes: 17 additions & 7 deletions src/main/fc/rc_adjustments.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,26 @@ static void applyAdjustmentU8(adjustmentFunction_e adjustmentFunction, uint8_t *
blackboxLogInflightAdjustmentEvent(adjustmentFunction, newValue);
}

static void applyAdjustmentI8(adjustmentFunction_e adjustmentFunction, int8_t *val, int delta, int low, int high)
{
int newValue = constrain((int)(*val) + delta, low, high);
*val = newValue;
blackboxLogInflightAdjustmentEvent(adjustmentFunction, newValue);
}

static void applyAdjustmentU16(adjustmentFunction_e adjustmentFunction, uint16_t *val, int delta, int low, int high)
{
int newValue = constrain((int)(*val) + delta, low, high);
*val = newValue;
blackboxLogInflightAdjustmentEvent(adjustmentFunction, newValue);
}

static void applyAdjustmentExpo(adjustmentFunction_e adjustmentFunction, uint8_t *val, int delta)
static void applyAdjustmentExpo(adjustmentFunction_e adjustmentFunction, int8_t *val, int delta, bool isYaw)
{
applyAdjustmentU8(adjustmentFunction, val, delta, SETTING_RC_EXPO_MIN, SETTING_RC_EXPO_MAX);
if (isYaw)
applyAdjustmentI8(adjustmentFunction, val, delta, SETTING_RC_YAW_EXPO_MIN, SETTING_RC_YAW_EXPO_MAX);
else
applyAdjustmentU8(adjustmentFunction, (uint8_t *)val, delta, SETTING_RC_EXPO_MIN, SETTING_RC_EXPO_MAX);
}

static void applyAdjustmentManualRate(adjustmentFunction_e adjustmentFunction, uint8_t *val, int delta)
Expand All @@ -382,19 +392,19 @@ static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t
}
switch (adjustmentFunction) {
case ADJUSTMENT_RC_EXPO:
applyAdjustmentExpo(ADJUSTMENT_RC_EXPO, &controlRateConfig->stabilized.rcExpo8, delta);
applyAdjustmentExpo(ADJUSTMENT_RC_EXPO, (int8_t *)&controlRateConfig->stabilized.rcExpo8, delta, false);
break;
case ADJUSTMENT_RC_YAW_EXPO:
applyAdjustmentExpo(ADJUSTMENT_RC_YAW_EXPO, &controlRateConfig->stabilized.rcYawExpo8, delta);
applyAdjustmentExpo(ADJUSTMENT_RC_YAW_EXPO, &controlRateConfig->stabilized.rcYawExpo8, delta, true);
break;
case ADJUSTMENT_MANUAL_RC_EXPO:
applyAdjustmentExpo(ADJUSTMENT_MANUAL_RC_EXPO, &controlRateConfig->manual.rcExpo8, delta);
applyAdjustmentExpo(ADJUSTMENT_MANUAL_RC_EXPO, (int8_t *)&controlRateConfig->manual.rcExpo8, delta, false);
break;
case ADJUSTMENT_MANUAL_RC_YAW_EXPO:
applyAdjustmentExpo(ADJUSTMENT_MANUAL_RC_YAW_EXPO, &controlRateConfig->manual.rcYawExpo8, delta);
applyAdjustmentExpo(ADJUSTMENT_MANUAL_RC_YAW_EXPO, &controlRateConfig->manual.rcYawExpo8, delta, true);
break;
case ADJUSTMENT_THROTTLE_EXPO:
applyAdjustmentExpo(ADJUSTMENT_THROTTLE_EXPO, &controlRateConfig->throttle.rcExpo8, delta);
applyAdjustmentExpo(ADJUSTMENT_THROTTLE_EXPO, (int8_t *)&controlRateConfig->throttle.rcExpo8, delta, false);
break;
case ADJUSTMENT_PITCH_ROLL_RATE:
case ADJUSTMENT_PITCH_RATE:
Expand Down
8 changes: 5 additions & 3 deletions src/main/fc/rc_curves.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ void generateThrottleCurve(const controlRateConfig_t *controlRateConfig)
}
}

int16_t rcLookup(int32_t stickDeflection, uint8_t expo)
int16_t rcLookup(int32_t stickDeflection, int8_t expo)
{
float tmpf = stickDeflection / 100.0f;
return lrintf((2500.0f + (float)expo * (tmpf * tmpf - 25.0f)) * tmpf / 25.0f);
float stk = stickDeflection / 500.0f;
float expoAdjusted = constrainf(stk * (1.0f + ((float)expo /100.0f) * (stk * stk - 1.0f)), -1.0f, 1.0f);

return (int16_t)lrintf(expoAdjusted * 500.0f);
}

uint16_t rcLookupThrottle(uint16_t absoluteDeflection)
Expand Down
2 changes: 1 addition & 1 deletion src/main/fc/rc_curves.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
struct controlRateConfig_s;
void generateThrottleCurve(const struct controlRateConfig_s *controlRateConfig);

int16_t rcLookup(int32_t stickDeflection, uint8_t expo);
int16_t rcLookup(int32_t stickDeflection, int8_t expo);
uint16_t rcLookupThrottle(uint16_t tmp);
int16_t rcLookupThrottleMid(void);
4 changes: 2 additions & 2 deletions src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ groups:
description: "Exponential value used for the YAW axis by all the stabilized flights modes (all but `MANUAL`)"
default_value: 20
field: stabilized.rcYawExpo8
min: 0
min: -100
max: 100
# New rates are in dps/10. That means, Rate of 20 means 200dps of rotation speed on given axis.
# Rate 180 (1800dps) is max. value gyro can measure reliably
Expand Down Expand Up @@ -1423,7 +1423,7 @@ groups:
description: "Exponential value used for the YAW axis by the `MANUAL` flight mode [0-100]"
default_value: 20
field: manual.rcYawExpo8
min: 0
min: -100
max: 100
- name: manual_roll_rate
description: "Servo travel multiplier for the ROLL axis in `MANUAL` flight mode [0-100]%"
Expand Down