Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/cfg/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ SOFTWARE.
MF_PARAM( mag_lp, 1e10, float, 'f') /*Magnetometer Gyro Low Pass Filter cutoff frequency in Hz (default 1e10Hz, i.e. no filtering) */ \
\
/*RCL - Remote Control Link*/ \
MF_PARAM( rcl_gizmo, 0, int32_t, 'e', mf_NONE,mf_MAVLINK,mf_CRSF,mf_SBUS,mf_SBUS_NOT_INV,mf_DSM,mf_PPM) \
MF_PARAM( rcl_gizmo, 0, int32_t, 'e', mf_NONE,mf_MAVLINK,mf_CRSF,mf_SBUS,mf_SBUS_NOT_INV,mf_DSM,mf_PPM,mf_IBUS) \
MF_PARAM( rcl_ser_bus, -1, int32_t, 'i') \
MF_PARAM( rcl_baud, 0, int32_t, 'i') \
MF_PARAM( rcl_num_ch, 8, int32_t, 'i') /*max 20*/ \
Expand Down Expand Up @@ -250,12 +250,12 @@ namespace Cfg {
#define MF_PARAM(name, defval, datatype, type, ...) + 1
const uint16_t param_cnt = 0 MF_PARAM_LIST ;
#undef MF_PARAM

//enums for madflight library parameters, generated from MF_PARAM_LIST
#define MF_PARAM(name, defval, datatype, type, ...) enum class name##_enum { __VA_ARGS__ };
MF_PARAM_LIST
#undef MF_PARAM

//list of parameters (generate from MF_PARAM_LIST)
#define MF_PARAM(name, defval, datatype, type, ...) {#name, defval, type, #__VA_ARGS__},
struct param_list_t {
Expand Down
40 changes: 40 additions & 0 deletions src/rcl/RclGizmoIbus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include "../hal/MF_Serial.h"
#include "../hal/hal.h"
#include "rcl.h"
#include "ibus/IBus.h"

class RclGizmoIbus : public RclGizmo {
private:
RclGizmoIbus(MF_Serial *ser_bus) : ser_bus(ser_bus) {}
IBus ibus;
MF_Serial *ser_bus;
uint16_t *pwm;

public:
static RclGizmoIbus* create(int ser_bus_id, uint16_t *pwm, int baud) {
if(baud==0) baud = 115200;
MF_Serial* ser_bus = hal_get_ser_bus(ser_bus_id, baud);
if(!ser_bus) return nullptr;

auto gizmo = new RclGizmoIbus(ser_bus);
gizmo->ser_bus = ser_bus;
gizmo->pwm = pwm;
gizmo->ibus.begin(*ser_bus, IBus::NO_TIMER);
return gizmo;
}

int count = 0;
bool update() override {
ibus.process_events();
if (ibus.has_new_data()) {
for (uint8_t i=0; i<IBus::MAX_CHANNELS; i++) {
pwm[i] = ibus.get_channel_value(i);
}
count++;
return true;
}
return false;
}
};
Loading