Skip to content

Commit fb31952

Browse files
Merge pull request #10405 from error414/change-gimbal-sensitivity-from-programming-framework
Change gimbal sensitivity from programming framework
2 parents 38dfe9a + bf5baf9 commit fb31952

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

docs/Programming Framework.md

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ IPF can be edited using INAV Configurator user interface, or via CLI. To use COn
101101
| 52 | LED Pin PWM | Value `Operand A` from [`0` : `100`] starts PWM generation on LED Pin. See [LED pin PWM](LED%20pin%20PWM.md). Any other value stops PWM generation (stop to allow ws2812 LEDs updates in shared modes). |
102102
| 53 | Disable GPS Sensor Fix | Disables the GNSS sensor fix. For testing GNSS failure. |
103103
| 54 | Mag calibration | Trigger a magnetometer calibration. |
104+
| 55 | Set Gimbal Sensitivity | Scales `Operand A` from [`-16` : `15`]
104105

105106
### Operands
106107

src/main/drivers/gimbal_common.c

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ bool gimbalCommonIsReady(gimbalDevice_t *gimbalDevice)
8989
return false;
9090
}
9191

92+
void setGimbalSensitivity(int16_t sensitivity)
93+
{
94+
gimbalConfigMutable()->sensitivity = sensitivity;
95+
}
96+
9297
#ifdef GIMBAL_UNIT_TEST
9398
void taskUpdateGimbal(timeUs_t currentTimeUs)
9499
{

src/main/drivers/gimbal_common.h

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ bool gimbalCommonIsEnabled(void);
9696
bool gimbalCommonHtrkIsEnabled(void);
9797

9898
int16_t gimbalCommonGetPanPwm(const gimbalDevice_t *gimbalDevice);
99+
void setGimbalSensitivity(int16_t sensitivity);
99100

100101
#ifdef __cplusplus
101102
}

src/main/fc/settings.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -4319,18 +4319,21 @@ groups:
43194319
field: sensitivity
43204320
min: -16
43214321
max: 15
4322+
type: int8_t
43224323
- name: gimbal_pan_trim
43234324
field: panTrim
43244325
description: "Trim gimbal pan center position."
43254326
default_value: 0
43264327
min: -500
43274328
max: 500
4329+
type: int16_t
43284330
- name: gimbal_tilt_trim
43294331
field: tiltTrim
43304332
description: "Trim gimbal tilt center position."
43314333
default_value: 0
43324334
min: -500
43334335
max: 500
4336+
type: int16_t
43344337
- name: gimbal_roll_trim
43354338
field: rollTrim
43364339
description: "Trim gimbal roll center position."

src/main/programming/logic_condition.c

+11
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "flight/pid.h"
4949
#include "flight/mixer_profile.h"
5050
#include "drivers/io_port_expander.h"
51+
#include "drivers/gimbal_common.h"
5152
#include "io/osd_common.h"
5253
#include "sensors/diagnostics.h"
5354

@@ -342,6 +343,16 @@ static int logicConditionCompute(
342343
break;
343344
}
344345
#endif
346+
347+
case LOGIC_CONDITION_SET_GIMBAL_SENSITIVITY:
348+
#ifdef USE_SERIAL_GIMBAL
349+
setGimbalSensitivity(constrain(operandA, SETTING_GIMBAL_SENSITIVITY_MIN, SETTING_GIMBAL_SENSITIVITY_MAX));
350+
return true;
351+
break;
352+
#else
353+
return false;
354+
#endif
355+
345356
case LOGIC_CONDITION_INVERT_ROLL:
346357
LOGIC_CONDITION_GLOBAL_FLAG_ENABLE(LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_INVERT_ROLL);
347358
return true;

src/main/programming/logic_condition.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ typedef enum {
8484
LOGIC_CONDITION_LED_PIN_PWM = 52,
8585
LOGIC_CONDITION_DISABLE_GPS_FIX = 53,
8686
LOGIC_CONDITION_RESET_MAG_CALIBRATION = 54,
87-
LOGIC_CONDITION_LAST = 55,
87+
LOGIC_CONDITION_SET_GIMBAL_SENSITIVITY = 55,
88+
LOGIC_CONDITION_LAST = 56,
8889
} logicOperation_e;
8990

9091
typedef enum logicOperandType_s {

0 commit comments

Comments
 (0)