Skip to content

Commit

Permalink
Driver for CADDX camera GM3 gimbal (betaflight#13926)
Browse files Browse the repository at this point in the history
* Driver for CADDX camera GM3 gimbal

* Update src/main/cli/settings.c

Fix copy-paste error on variable name.

Co-authored-by: Petr Ledvina <[email protected]>

* Update src/main/io/gimbal_control.c

Co-authored-by: Petr Ledvina <[email protected]>

* Update src/main/io/gimbal_control.c

Co-authored-by: Petr Ledvina <[email protected]>

* Update src/main/io/gimbal_control.c

Co-authored-by: Petr Ledvina <[email protected]>

* Only forward gimbal data with good CRC

---------

Co-authored-by: Petr Ledvina <[email protected]>
  • Loading branch information
SteveCEvans and ledvinap authored Nov 12, 2024
1 parent b70e98e commit 0de6278
Show file tree
Hide file tree
Showing 14 changed files with 502 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mk/source.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PG_SRC = \
pg/displayport_profiles.c \
pg/dyn_notch.c \
pg/flash.c \
pg/gimbal.c \
pg/gps.c \
pg/gps_lap_timer.c \
pg/gps_rescue.c \
Expand Down Expand Up @@ -248,6 +249,7 @@ COMMON_SRC = \
io/displayport_crsf.c \
io/displayport_hott.c \
io/frsky_osd.c \
io/gimbal_control.c \
io/rcdevice_cam.c \
io/rcdevice.c \
io/gps.c \
Expand Down
1 change: 1 addition & 0 deletions src/main/build/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,5 @@ const char * const debugModeNames[DEBUG_COUNT] = {
[DEBUG_S_TERM] = "S_TERM",
[DEBUG_SPA] = "SPA",
[DEBUG_TASK] = "TASK",
[DEBUG_GIMBAL] = "GIMBAL",
};
1 change: 1 addition & 0 deletions src/main/build/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ typedef enum {
DEBUG_S_TERM,
DEBUG_SPA,
DEBUG_TASK,
DEBUG_GIMBAL,
DEBUG_COUNT
} debugType_e;

Expand Down
21 changes: 21 additions & 0 deletions src/main/cli/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
#include "pg/displayport_profiles.h"
#include "pg/dyn_notch.h"
#include "pg/flash.h"
#include "pg/gimbal.h"
#include "pg/gyrodev.h"
#include "pg/max7456.h"
#include "pg/mco.h"
Expand Down Expand Up @@ -1854,6 +1855,26 @@ const clivalue_t valueTable[] = {
{ "box_user_3_name", VAR_UINT8 | HARDWARE_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_names[2]) },
{ "box_user_4_name", VAR_UINT8 | HARDWARE_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_names[3]) },
#endif

#if defined(USE_GIMBAL)
{ "gimbal_roll_rc_gain", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_roll_rc_gain) },
{ "gimbal_pitch_rc_thr_gain", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_pitch_rc_thr_gain) },
{ "gimbal_pitch_rc_low_gain", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_pitch_rc_low_gain) },
{ "gimbal_pitch_rc_high_gain", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_pitch_rc_high_gain) },
{ "gimbal_yaw_rc_gain", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_yaw_rc_gain) },
{ "gimbal_roll_gain", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_roll_gain) },
{ "gimbal_roll_offset", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_roll_offset) },
{ "gimbal_roll_limit", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_roll_limit) },
{ "gimbal_pitch_gain", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_pitch_gain) },
{ "gimbal_pitch_offset", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_pitch_offset) },
{ "gimbal_pitch_low_limit", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_pitch_low_limit) },
{ "gimbal_pitch_high_limit", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_pitch_high_limit) },
{ "gimbal_yaw_gain", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_yaw_gain) },
{ "gimbal_yaw_offset", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_yaw_offset) },
{ "gimbal_yaw_limit", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -100, 100 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_yaw_limit) },
{ "gimbal_stabilisation", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 7 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_stabilisation) },
{ "gimbal_sensitivity", VAR_INT8 | MASTER_VALUE, .config.minmaxUnsigned = { -16, 15 }, PG_GIMBAL_TRACK_CONFIG, offsetof(gimbalTrackConfig_t, gimbal_sensitivity) },
#endif
};

const uint16_t valueTableEntryCount = ARRAYLEN(valueTable);
Expand Down
5 changes: 5 additions & 0 deletions src/main/fc/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
#include "io/displayport_msp.h"
#include "io/flashfs.h"
#include "io/gimbal.h"
#include "io/gimbal_control.h"
#include "io/gps.h"
#include "io/ledstrip.h"
#include "io/pidaudio.h"
Expand Down Expand Up @@ -865,6 +866,10 @@ void init(void)

#endif // VTX_CONTROL

#ifdef USE_GIMBAL
gimbalInit();
#endif

batteryInit(); // always needs doing, regardless of features.

#ifdef USE_RCDEVICE
Expand Down
1 change: 1 addition & 0 deletions src/main/fc/rc_controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "io/beeper.h"
#include "io/usb_cdc_hid.h"
#include "io/dashboard.h"
#include "io/gimbal_control.h"
#include "io/gps.h"
#include "io/vtx_control.h"

Expand Down
8 changes: 8 additions & 0 deletions src/main/fc/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "io/beeper.h"
#include "io/dashboard.h"
#include "io/flashfs.h"
#include "io/gimbal_control.h"
#include "io/gps.h"
#include "io/ledstrip.h"
#include "io/piniobox.h"
Expand Down Expand Up @@ -452,6 +453,9 @@ task_attribute_t task_attributes[TASK_COUNT] = {
[TASK_RC_STATS] = DEFINE_TASK("RC_STATS", NULL, NULL, rcStatsUpdate, TASK_PERIOD_HZ(100), TASK_PRIORITY_LOW),
#endif

#ifdef USE_GIMBAL
[TASK_GIMBAL] = DEFINE_TASK("GIMBAL", NULL, NULL, gimbalUpdate, TASK_PERIOD_HZ(100), TASK_PRIORITY_MEDIUM),
#endif
};

task_t *getTask(unsigned taskId)
Expand Down Expand Up @@ -631,4 +635,8 @@ void tasksInit(void)
#ifdef USE_RC_STATS
setTaskEnabled(TASK_RC_STATS, true);
#endif

#ifdef USE_GIMBAL
setTaskEnabled(TASK_GIMBAL, true);
#endif
}
Loading

0 comments on commit 0de6278

Please sign in to comment.