Skip to content

Commit

Permalink
@AvSquirrel changes - configurable yaw mix rate/refresh + quat setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyoung committed Jan 11, 2016
1 parent aa27515 commit af55080
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions libimu.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ void close_mpu(void)



int init_mpu(void)
int init_mpu(int sample_rate, int yaw_mix_factor)
{
int ret;
verbose = 1;
i2c_bus = DEFAULT_I2C_BUS;
sample_rate = DEFAULT_SAMPLE_RATE_HZ;
yaw_mix_factor = DEFAULT_YAW_MIX_FACTOR;
// sample_rate = DEFAULT_SAMPLE_RATE_HZ;
// yaw_mix_factor = DEFAULT_YAW_MIX_FACTOR;

mpu9150_set_debug(verbose);
if ((ret = mpu9150_init(i2c_bus, sample_rate, yaw_mix_factor)) != 0) {
Expand Down
11 changes: 4 additions & 7 deletions libimu.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@
#define DEFAULT_I2C_BUS (1)

// platform independent
#define DEFAULT_SAMPLE_RATE_HZ (10)
#ifdef MPU6050
#define DEFAULT_YAW_MIX_FACTOR (0)
#else
#define DEFAULT_YAW_MIX_FACTOR (4)
#endif
//#define DEFAULT_SAMPLE_RATE_HZ (10)
//#define DEFAULT_YAW_MIX_FACTOR (0)

#ifdef __cplusplus
extern "C" {
#endif

extern void close_mpu(void);
extern int init_mpu(void);
//extern int init_mpu(void);
extern int init_mpu(int sample_rate, int yaw_mix_factor);
extern int read_mpu(float *pitch, float *roll, float *heading);
extern int set_cal(int mag, char *cal_file);

Expand Down
4 changes: 2 additions & 2 deletions mpu/mpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import (
var PackageVersion = "v0.1"

// InitMPU
func InitMPU() int {
return int(C.init_mpu())
func InitMPU(sample_rate, yaw_mix_factor int) int {
return int(C.init_mpu(C.int(sample_rate), C.int(yaw_mix_factor)))
}

// CloseMPU
Expand Down
2 changes: 1 addition & 1 deletion mpu9150/mpu9150.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int mpu9150_init(int i2c_bus, int sample_rate, int mix_factor)
printf(".");
fflush(stdout);

if (dmp_enable_feature(DMP_FEATURE_6X_LP_QUAT | DMP_FEATURE_SEND_RAW_ACCEL
if (dmp_enable_feature(/*DMP_FEATURE_6X_LP_QUAT*/ DMP_FEATURE_LP_QUAT | DMP_FEATURE_SEND_RAW_ACCEL
| DMP_FEATURE_SEND_CAL_GYRO | DMP_FEATURE_GYRO_CAL)) {
printf("\ndmp_enable_feature() failed\n");
return -1;
Expand Down

0 comments on commit af55080

Please sign in to comment.