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

Change gimbal sensitivity from programming framework #10405

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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/Programming Framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ IPF can be edited using INAV Configurator user interface, or via CLI. To use COn
| 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). |
| 53 | Disable GPS Sensor Fix | Disables the GNSS sensor fix. For testing GNSS failure. |
| 54 | Mag calibration | Trigger a magnetometer calibration. |
| 55 | Set Gimbal Sensitivity | Scales `Operand A` from [`-16` : `15`]

### Operands

Expand Down
5 changes: 5 additions & 0 deletions src/main/drivers/gimbal_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ bool gimbalCommonIsReady(gimbalDevice_t *gimbalDevice)
return false;
}

void setGimbalSensitivity(int16_t sensitivity)
{
gimbalConfigMutable()->sensitivity = sensitivity;
}

#ifdef GIMBAL_UNIT_TEST
void taskUpdateGimbal(timeUs_t currentTimeUs)
{
Expand Down
10 changes: 6 additions & 4 deletions src/main/drivers/gimbal_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ typedef struct gimbalConfig_s {
uint8_t panChannel;
uint8_t tiltChannel;
uint8_t rollChannel;
uint8_t sensitivity;
uint16_t panTrim;
uint16_t tiltTrim;
uint16_t rollTrim;
int8_t sensitivity;
int16_t panTrim;
int16_t tiltTrim;
int16_t rollTrim;
} gimbalConfig_t;

PG_DECLARE(gimbalConfig_t, gimbalConfig);
Expand Down Expand Up @@ -97,6 +97,8 @@ bool gimbalCommonHtrkIsEnabled(void);

int16_t gimbalCommonGetPanPwm(const gimbalDevice_t *gimbalDevice);

void setGimbalSensitivity(int16_t sensitivity);

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4287,18 +4287,21 @@ groups:
field: sensitivity
min: -16
max: 15
type: int8_t
- name: gimbal_pan_trim
field: panTrim
description: "Trim gimbal pan center position."
default_value: 0
min: -500
max: 500
type: int16_t
- name: gimbal_tilt_trim
field: tiltTrim
description: "Trim gimbal tilt center position."
default_value: 0
min: -500
max: 500
type: int16_t
- name: gimbal_roll_trim
field: rollTrim
description: "Trim gimbal roll center position."
Expand Down
11 changes: 11 additions & 0 deletions src/main/programming/logic_condition.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "flight/pid.h"
#include "flight/mixer_profile.h"
#include "drivers/io_port_expander.h"
#include "drivers/gimbal_common.h"
#include "io/osd_common.h"
#include "sensors/diagnostics.h"

Expand Down Expand Up @@ -337,6 +338,16 @@ static int logicConditionCompute(
}
break;
#endif

case LOGIC_CONDITION_SET_GIMBAL_SENSITIVITY:
#ifdef USE_SERIAL_GIMBAL
setGimbalSensitivity(constrain(operandA, SETTING_GIMBAL_SENSITIVITY_MIN, SETTING_GIMBAL_SENSITIVITY_MAX));
return true;
break;
#else
return false;
#endif

case LOGIC_CONDITION_INVERT_ROLL:
LOGIC_CONDITION_GLOBAL_FLAG_ENABLE(LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_INVERT_ROLL);
return true;
Expand Down
3 changes: 2 additions & 1 deletion src/main/programming/logic_condition.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ typedef enum {
LOGIC_CONDITION_LED_PIN_PWM = 52,
LOGIC_CONDITION_DISABLE_GPS_FIX = 53,
LOGIC_CONDITION_RESET_MAG_CALIBRATION = 54,
LOGIC_CONDITION_LAST = 55,
LOGIC_CONDITION_SET_GIMBAL_SENSITIVITY = 55,
LOGIC_CONDITION_LAST = 56,
} logicOperation_e;

typedef enum logicOperandType_s {
Expand Down
Loading