Bugfix in MPU6000 driver
acceleration exceeds 1G and makes arcsin fail
This commit is contained in:
parent
3f2c9f7003
commit
e1de1ac99f
@ -72,7 +72,7 @@ bool mpu6000_spi::init(int sample_rate_div,int low_pass_filter){
|
||||
response=spi.write(0x00);
|
||||
deselect();
|
||||
|
||||
return true; // TODO
|
||||
return false; // TODO
|
||||
}
|
||||
|
||||
int mpu6000_spi::enableInterrupt()
|
||||
@ -207,7 +207,17 @@ float mpu6000_spi::read_acc(int axis){
|
||||
|
||||
float mpu6000_spi::read_acc_deg(int axis)
|
||||
{
|
||||
return asin(read_acc(axis))/PI*180;
|
||||
float g(read_acc(axis));
|
||||
|
||||
if (g > 1.0f)
|
||||
{
|
||||
g = 1.0f;
|
||||
}
|
||||
else if (g < -1.0f)
|
||||
{
|
||||
g = -1.0f;
|
||||
}
|
||||
return asin(g)/PI*180;
|
||||
}
|
||||
|
||||
float mpu6000_spi::read_rot(int axis){
|
||||
|
Loading…
x
Reference in New Issue
Block a user