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

Added FW level trim to in flight adjustments #8028

Merged
merged 1 commit into from
May 14, 2022
Merged
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
1 change: 1 addition & 0 deletions docs/Inflight Adjustments.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ this reason ensure that you define enough ranges to cover the range channel's us
| 55 | TPA_BREAKPOINT |
| 56 | NAV_FW_CONTROL_SMOOTHNESS |
| 57 | FW_TPA_TIME_CONSTANT |
| 58 | FW_LEVEL_TRIM |

## Examples

Expand Down
13 changes: 13 additions & 0 deletions src/main/fc/rc_adjustments.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
.adjustmentFunction = ADJUSTMENT_FW_TPA_TIME_CONSTANT,
.mode = ADJUSTMENT_MODE_STEP,
.data = { .stepConfig = { .step = 5 }}
}, {
.adjustmentFunction = ADJUSTMENT_FW_LEVEL_TRIM,
.mode = ADJUSTMENT_MODE_STEP,
.data = { .stepConfig = { .step = 1 }}
}
};

Expand Down Expand Up @@ -607,6 +611,15 @@ static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t
case ADJUSTMENT_NAV_FW_CONTROL_SMOOTHNESS:
applyAdjustmentU8(ADJUSTMENT_NAV_FW_CONTROL_SMOOTHNESS, &navConfigMutable()->fw.control_smoothness, delta, SETTING_NAV_FW_CONTROL_SMOOTHNESS_MIN, SETTING_NAV_FW_CONTROL_SMOOTHNESS_MAX);
break;
case ADJUSTMENT_FW_LEVEL_TRIM:
{
float newValue = pidProfileMutable()->fixedWingLevelTrim + (delta / 10.0f);
if (newValue > SETTING_FW_LEVEL_PITCH_TRIM_MAX) {newValue = (float)SETTING_FW_LEVEL_PITCH_TRIM_MAX;}
else if (newValue < SETTING_FW_LEVEL_PITCH_TRIM_MIN) {newValue = (float)SETTING_FW_LEVEL_PITCH_TRIM_MIN;}
pidProfileMutable()->fixedWingLevelTrim = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_FW_LEVEL_TRIM, (int)(newValue * 10.0f));
break;
}
default:
break;
};
Expand Down
1 change: 1 addition & 0 deletions src/main/fc/rc_adjustments.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ typedef enum {
ADJUSTMENT_TPA_BREAKPOINT = 55,
ADJUSTMENT_NAV_FW_CONTROL_SMOOTHNESS = 56,
ADJUSTMENT_FW_TPA_TIME_CONSTANT = 57,
ADJUSTMENT_FW_LEVEL_TRIM = 58,
ADJUSTMENT_FUNCTION_COUNT // must be last
} adjustmentFunction_e;

Expand Down
20 changes: 5 additions & 15 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3019,24 +3019,14 @@ static bool osdDrawSingleElement(uint8_t item)
}
case OSD_TPA_TIME_CONSTANT:
{
/* char buff[7];
textAttributes_t attr;

if (isAdjustmentFunctionSelected(ADJUSTMENT_FW_TPA_TIME_CONSTANT)) {
displayWrite(osdDisplayPort, elemPosX, elemPosY, "TC OK");
} else {
displayWrite(osdDisplayPort, elemPosX, elemPosY, "TPA TC");
}

attr = TEXT_ATTRIBUTES_NONE;
tfp_sprintf(buff, "%4d", currentControlRateProfile->throttle.fixedWingTauMs);
if (isAdjustmentFunctionSelected(ADJUSTMENT_FW_TPA_TIME_CONSTANT)) {
TEXT_ATTRIBUTES_ADD_BLINK(attr);
}
displayWriteWithAttr(osdDisplayPort, elemPosX + 7, elemPosY, buff, attr);*/
osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "TPA TC", 0, currentControlRateProfile->throttle.fixedWingTauMs, 4, 0, ADJUSTMENT_FW_TPA_TIME_CONSTANT);
return true;
}
case OSD_FW_LEVEL_TRIM:
{
osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "LEVEL", 0, pidProfileMutable()->fixedWingLevelTrim, 3, 1, ADJUSTMENT_FW_LEVEL_TRIM);
return true;
}

case OSD_NAV_FW_CONTROL_SMOOTHNESS:
osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "CTL S", 0, navConfig()->fw.control_smoothness, 1, 0, ADJUSTMENT_NAV_FW_CONTROL_SMOOTHNESS);
Expand Down
1 change: 1 addition & 0 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ typedef enum {
OSD_SWITCH_INDICATOR_2,
OSD_SWITCH_INDICATOR_3,
OSD_TPA_TIME_CONSTANT,
OSD_FW_LEVEL_TRIM,
OSD_ITEM_COUNT // MUST BE LAST
} osd_items_e;

Expand Down