1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00

D_MIN cleanup - use array for parameters; move CMS menu entries

Change to using an array of `uint8_t` for the `d_min_` axis parameters. Simplifies the code.

The CMS menu entries were incorrectly placed under the `FILTER PP` submenu. Moved to the `MISC PP` submenu.
This commit is contained in:
Bruce Luckcuck 2019-02-09 15:40:27 -05:00
parent ca98ee7df0
commit a64bd06f5a
4 changed files with 30 additions and 36 deletions

View file

@ -328,6 +328,9 @@ static uint16_t cmsx_itermAcceleratorGain;
static uint16_t cmsx_itermThrottleThreshold;
static uint8_t cmsx_motorOutputLimit;
static int8_t cmsx_autoProfileCellCount;
#ifdef USE_D_MIN
static uint8_t cmsx_d_min[XYZ_AXIS_COUNT];
#endif
static long cmsx_profileOtherOnEnter(void)
{
@ -348,6 +351,12 @@ static long cmsx_profileOtherOnEnter(void)
cmsx_motorOutputLimit = pidProfile->motor_output_limit;
cmsx_autoProfileCellCount = pidProfile->auto_profile_cell_count;
#ifdef USE_D_MIN
for (unsigned i = 0; i < XYZ_AXIS_COUNT; i++) {
cmsx_d_min[i] = pidProfile->d_min[i];
}
#endif
return 0;
}
@ -370,6 +379,12 @@ static long cmsx_profileOtherOnExit(const OSD_Entry *self)
pidProfile->motor_output_limit = cmsx_motorOutputLimit;
pidProfile->auto_profile_cell_count = cmsx_autoProfileCellCount;
#ifdef USE_D_MIN
for (unsigned i = 0; i < XYZ_AXIS_COUNT; i++) {
pidProfile->d_min[i] = cmsx_d_min[i];
}
#endif
return 0;
}
@ -392,6 +407,12 @@ static OSD_Entry cmsx_menuProfileOtherEntries[] = {
{ "AUTO CELL CNT", OME_INT8, NULL, &(OSD_INT8_t) { &cmsx_autoProfileCellCount, AUTO_PROFILE_CELL_COUNT_CHANGE, MAX_AUTO_DETECT_CELL_COUNT, 1}, 0 },
#ifdef USE_D_MIN
{ "D_MIN_ROLL", OME_UINT8, NULL, &(OSD_UINT8_t) { &cmsx_d_min[FD_ROLL], 0, 100, 1 }, 0 },
{ "D_MIN_PITCH", OME_UINT8, NULL, &(OSD_UINT8_t) { &cmsx_d_min[FD_PITCH], 0, 100, 1 }, 0 },
{ "D_MIN_YAW", OME_UINT8, NULL, &(OSD_UINT8_t) { &cmsx_d_min[FD_YAW], 0, 100, 1 }, 0 },
#endif
{ "BACK", OME_Back, NULL, NULL, 0 },
{ NULL, OME_END, NULL, NULL, 0 }
};
@ -560,11 +581,6 @@ static uint16_t cmsx_dterm_lowpass_hz;
static uint16_t cmsx_dterm_lowpass2_hz;
static uint16_t cmsx_dterm_notch_hz;
static uint16_t cmsx_dterm_notch_cutoff;
#ifdef USE_D_MIN
static uint8_t cmsx_d_min_roll;
static uint8_t cmsx_d_min_pitch;
static uint8_t cmsx_d_min_yaw;
#endif
static uint16_t cmsx_yaw_lowpass_hz;
static long cmsx_FilterPerProfileRead(void)
@ -575,11 +591,6 @@ static long cmsx_FilterPerProfileRead(void)
cmsx_dterm_lowpass2_hz = pidProfile->dterm_lowpass2_hz;
cmsx_dterm_notch_hz = pidProfile->dterm_notch_hz;
cmsx_dterm_notch_cutoff = pidProfile->dterm_notch_cutoff;
#ifdef USE_D_MIN
cmsx_d_min_roll = pidProfile->d_min_roll;
cmsx_d_min_pitch = pidProfile->d_min_pitch;
cmsx_d_min_yaw = pidProfile->d_min_yaw;
#endif
cmsx_yaw_lowpass_hz = pidProfile->yaw_lowpass_hz;
return 0;
@ -595,11 +606,6 @@ static long cmsx_FilterPerProfileWriteback(const OSD_Entry *self)
pidProfile->dterm_lowpass2_hz = cmsx_dterm_lowpass2_hz;
pidProfile->dterm_notch_hz = cmsx_dterm_notch_hz;
pidProfile->dterm_notch_cutoff = cmsx_dterm_notch_cutoff;
#ifdef USE_D_MIN
pidProfile->d_min_roll = cmsx_d_min_roll;
pidProfile->d_min_pitch = cmsx_d_min_pitch;
pidProfile->d_min_yaw = cmsx_d_min_yaw;
#endif
pidProfile->yaw_lowpass_hz = cmsx_yaw_lowpass_hz;
return 0;
@ -613,11 +619,6 @@ static OSD_Entry cmsx_menuFilterPerProfileEntries[] =
{ "DTERM LPF2", OME_UINT16, NULL, &(OSD_UINT16_t){ &cmsx_dterm_lowpass2_hz, 0, 500, 1 }, 0 },
{ "DTERM NF", OME_UINT16, NULL, &(OSD_UINT16_t){ &cmsx_dterm_notch_hz, 0, 500, 1 }, 0 },
{ "DTERM NFCO", OME_UINT16, NULL, &(OSD_UINT16_t){ &cmsx_dterm_notch_cutoff, 0, 500, 1 }, 0 },
#ifdef USE_D_MIN
{ "D_MIN_ROLL", OME_UINT8, NULL, &(OSD_UINT8_t) { &cmsx_d_min_roll, 0, 100, 1 }, 0 },
{ "D_MIN_PITCH", OME_UINT8, NULL, &(OSD_UINT8_t) { &cmsx_d_min_pitch, 0, 100, 1 }, 0 },
{ "D_MIN_YAW", OME_UINT8, NULL, &(OSD_UINT8_t) { &cmsx_d_min_yaw, 0, 100, 1 }, 0 },
#endif
{ "YAW LPF", OME_UINT16, NULL, &(OSD_UINT16_t){ &cmsx_yaw_lowpass_hz, 0, 500, 1 }, 0 },
{ "BACK", OME_Back, NULL, NULL, 0 },
{ NULL, OME_END, NULL, NULL, 0 }