Skip to content

Commit

Permalink
Merge pull request iNavFlight#9957 from iNavFlight/dzikuvx-ez-tune-sn…
Browse files Browse the repository at this point in the history
…appiness

Ez Tune snappiness
  • Loading branch information
DzikuVx authored Apr 21, 2024
2 parents 1ef428e + b317a66 commit 8d970cc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
10 changes: 10 additions & 0 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,16 @@ EzTune response

---

### ez_snappiness

EzTune snappiness

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

---

### ez_stability

EzTune stability
Expand Down
31 changes: 18 additions & 13 deletions src/main/fc/fc_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
sbufWriteU8(dst, ezTune()->aggressiveness);
sbufWriteU8(dst, ezTune()->rate);
sbufWriteU8(dst, ezTune()->expo);
sbufWriteU8(dst, ezTune()->snappiness);
}
break;
#endif
Expand Down Expand Up @@ -3256,21 +3257,25 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)

case MSP2_INAV_EZ_TUNE_SET:
{
if (dataSize == 10) {
ezTuneMutable()->enabled = sbufReadU8(src);
ezTuneMutable()->filterHz = sbufReadU16(src);
ezTuneMutable()->axisRatio = sbufReadU8(src);
ezTuneMutable()->response = sbufReadU8(src);
ezTuneMutable()->damping = sbufReadU8(src);
ezTuneMutable()->stability = sbufReadU8(src);
ezTuneMutable()->aggressiveness = sbufReadU8(src);
ezTuneMutable()->rate = sbufReadU8(src);
ezTuneMutable()->expo = sbufReadU8(src);

ezTuneUpdate();
} else {

if (dataSize < 10 || dataSize > 11) {
return MSP_RESULT_ERROR;
}

ezTuneMutable()->enabled = sbufReadU8(src);
ezTuneMutable()->filterHz = sbufReadU16(src);
ezTuneMutable()->axisRatio = sbufReadU8(src);
ezTuneMutable()->response = sbufReadU8(src);
ezTuneMutable()->damping = sbufReadU8(src);
ezTuneMutable()->stability = sbufReadU8(src);
ezTuneMutable()->aggressiveness = sbufReadU8(src);
ezTuneMutable()->rate = sbufReadU8(src);
ezTuneMutable()->expo = sbufReadU8(src);

if (dataSize == 11) {
ezTuneMutable()->snappiness = sbufReadU8(src);
}
ezTuneUpdate();
}
break;

Expand Down
6 changes: 6 additions & 0 deletions src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,12 @@ groups:
field: expo
min: 0
max: 200
- name: ez_snappiness
description: "EzTune snappiness"
default_value: 0
field: snappiness
min: 0
max: 100

- name: PG_RPM_FILTER_CONFIG
headers: ["flight/rpm_filter.h"]
Expand Down
6 changes: 5 additions & 1 deletion src/main/flight/ez_tune.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "rx/rx.h"

PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(ezTuneSettings_t, ezTune, PG_EZ_TUNE, 0);
PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(ezTuneSettings_t, ezTune, PG_EZ_TUNE, 1);

PG_RESET_TEMPLATE(ezTuneSettings_t, ezTune,
.enabled = SETTING_EZ_ENABLED_DEFAULT,
Expand All @@ -48,6 +48,7 @@ PG_RESET_TEMPLATE(ezTuneSettings_t, ezTune,
.aggressiveness = SETTING_EZ_AGGRESSIVENESS_DEFAULT,
.rate = SETTING_EZ_RATE_DEFAULT,
.expo = SETTING_EZ_EXPO_DEFAULT,
.snappiness = SETTING_EZ_SNAPPINESS_DEFAULT,
);

#define EZ_TUNE_PID_RP_DEFAULT { 40, 75, 23, 100 }
Expand Down Expand Up @@ -142,5 +143,8 @@ void ezTuneUpdate(void) {
((controlRateConfig_t*)currentControlRateProfile)->stabilized.rcExpo8 = scaleRange(ezTune()->rate, 0, 200, 40, 100);
((controlRateConfig_t*)currentControlRateProfile)->stabilized.rcYawExpo8 = scaleRange(ezTune()->rate, 0, 200, 40, 100);

//D-Boost snappiness
pidProfileMutable()->dBoostMin = scaleRangef(ezTune()->snappiness, 0, 100, 1.0f, 0.0f);

}
}
1 change: 1 addition & 0 deletions src/main/flight/ez_tune.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ typedef struct ezTuneSettings_s {
uint8_t aggressiveness;
uint8_t rate;
uint8_t expo;
uint8_t snappiness;
} ezTuneSettings_t;

PG_DECLARE_PROFILE(ezTuneSettings_t, ezTune);
Expand Down

0 comments on commit 8d970cc

Please sign in to comment.