Skip to content

Commit 32a38b6

Browse files
authored
Merge pull request #8028 from iNavFlight/MrD_Add-fixed-wing-level-trim-to-adjustments
Added FW level trim to in flight adjustments
2 parents 4fbc0f2 + 2e9bf6b commit 32a38b6

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

docs/Inflight Adjustments.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ this reason ensure that you define enough ranges to cover the range channel's us
159159
| 55 | TPA_BREAKPOINT |
160160
| 56 | NAV_FW_CONTROL_SMOOTHNESS |
161161
| 57 | FW_TPA_TIME_CONSTANT |
162+
| 58 | FW_LEVEL_TRIM |
162163

163164
## Examples
164165

src/main/fc/rc_adjustments.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
293293
.adjustmentFunction = ADJUSTMENT_FW_TPA_TIME_CONSTANT,
294294
.mode = ADJUSTMENT_MODE_STEP,
295295
.data = { .stepConfig = { .step = 5 }}
296+
}, {
297+
.adjustmentFunction = ADJUSTMENT_FW_LEVEL_TRIM,
298+
.mode = ADJUSTMENT_MODE_STEP,
299+
.data = { .stepConfig = { .step = 1 }}
296300
}
297301
};
298302

@@ -607,6 +611,15 @@ static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t
607611
case ADJUSTMENT_NAV_FW_CONTROL_SMOOTHNESS:
608612
applyAdjustmentU8(ADJUSTMENT_NAV_FW_CONTROL_SMOOTHNESS, &navConfigMutable()->fw.control_smoothness, delta, SETTING_NAV_FW_CONTROL_SMOOTHNESS_MIN, SETTING_NAV_FW_CONTROL_SMOOTHNESS_MAX);
609613
break;
614+
case ADJUSTMENT_FW_LEVEL_TRIM:
615+
{
616+
float newValue = pidProfileMutable()->fixedWingLevelTrim + (delta / 10.0f);
617+
if (newValue > SETTING_FW_LEVEL_PITCH_TRIM_MAX) {newValue = (float)SETTING_FW_LEVEL_PITCH_TRIM_MAX;}
618+
else if (newValue < SETTING_FW_LEVEL_PITCH_TRIM_MIN) {newValue = (float)SETTING_FW_LEVEL_PITCH_TRIM_MIN;}
619+
pidProfileMutable()->fixedWingLevelTrim = newValue;
620+
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_FW_LEVEL_TRIM, (int)(newValue * 10.0f));
621+
break;
622+
}
610623
default:
611624
break;
612625
};

src/main/fc/rc_adjustments.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ typedef enum {
8383
ADJUSTMENT_TPA_BREAKPOINT = 55,
8484
ADJUSTMENT_NAV_FW_CONTROL_SMOOTHNESS = 56,
8585
ADJUSTMENT_FW_TPA_TIME_CONSTANT = 57,
86+
ADJUSTMENT_FW_LEVEL_TRIM = 58,
8687
ADJUSTMENT_FUNCTION_COUNT // must be last
8788
} adjustmentFunction_e;
8889

src/main/io/osd.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3019,24 +3019,14 @@ static bool osdDrawSingleElement(uint8_t item)
30193019
}
30203020
case OSD_TPA_TIME_CONSTANT:
30213021
{
3022-
/* char buff[7];
3023-
textAttributes_t attr;
3024-
3025-
if (isAdjustmentFunctionSelected(ADJUSTMENT_FW_TPA_TIME_CONSTANT)) {
3026-
displayWrite(osdDisplayPort, elemPosX, elemPosY, "TC OK");
3027-
} else {
3028-
displayWrite(osdDisplayPort, elemPosX, elemPosY, "TPA TC");
3029-
}
3030-
3031-
attr = TEXT_ATTRIBUTES_NONE;
3032-
tfp_sprintf(buff, "%4d", currentControlRateProfile->throttle.fixedWingTauMs);
3033-
if (isAdjustmentFunctionSelected(ADJUSTMENT_FW_TPA_TIME_CONSTANT)) {
3034-
TEXT_ATTRIBUTES_ADD_BLINK(attr);
3035-
}
3036-
displayWriteWithAttr(osdDisplayPort, elemPosX + 7, elemPosY, buff, attr);*/
30373022
osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "TPA TC", 0, currentControlRateProfile->throttle.fixedWingTauMs, 4, 0, ADJUSTMENT_FW_TPA_TIME_CONSTANT);
30383023
return true;
30393024
}
3025+
case OSD_FW_LEVEL_TRIM:
3026+
{
3027+
osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "LEVEL", 0, pidProfileMutable()->fixedWingLevelTrim, 3, 1, ADJUSTMENT_FW_LEVEL_TRIM);
3028+
return true;
3029+
}
30403030

30413031
case OSD_NAV_FW_CONTROL_SMOOTHNESS:
30423032
osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "CTL S", 0, navConfig()->fw.control_smoothness, 1, 0, ADJUSTMENT_NAV_FW_CONTROL_SMOOTHNESS);

src/main/io/osd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ typedef enum {
258258
OSD_SWITCH_INDICATOR_2,
259259
OSD_SWITCH_INDICATOR_3,
260260
OSD_TPA_TIME_CONSTANT,
261+
OSD_FW_LEVEL_TRIM,
261262
OSD_ITEM_COUNT // MUST BE LAST
262263
} osd_items_e;
263264

0 commit comments

Comments
 (0)