mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
lis2ds12: remove surplus accFactor coefficient
As we've established in PR #623 (adding lis3dh support), this coefficient is not needed and actually is cancelled out in calculations, so remove it. Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
This commit is contained in:
parent
6be656d5b0
commit
96bcfc9128
@ -238,40 +238,6 @@ upm_result_t lis2ds12_set_odr(const lis2ds12_context dev,
|
|||||||
if (lis2ds12_write_reg(dev, LIS2DS12_REG_CTRL1, reg))
|
if (lis2ds12_write_reg(dev, LIS2DS12_REG_CTRL1, reg))
|
||||||
return UPM_ERROR_OPERATION_FAILED;
|
return UPM_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
switch(odr)
|
|
||||||
{
|
|
||||||
case LIS2DS12_ODR_12_5HZ:
|
|
||||||
case LIS2DS12_ODR_25HZ:
|
|
||||||
case LIS2DS12_ODR_50HZ:
|
|
||||||
case LIS2DS12_ODR_100HZ:
|
|
||||||
// 14b
|
|
||||||
dev->accFactor = 4.0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// these are special - possibly HF modes. Since we've already
|
|
||||||
// stripped the HF indicator, we check the hf_mode here. HF
|
|
||||||
// modes are 12b resolution, otherwise resolution is 14b.
|
|
||||||
case LIS2DS12_ODR_200HZ:
|
|
||||||
case LIS2DS12_ODR_400HZ:
|
|
||||||
case LIS2DS12_ODR_800HZ:
|
|
||||||
if (hf_mode)
|
|
||||||
dev->accFactor = 16.0;
|
|
||||||
else
|
|
||||||
dev->accFactor = 4.0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// choose something safe
|
|
||||||
case LIS2DS12_ODR_POWER_DOWN:
|
|
||||||
dev->accFactor = 1.0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// the rest are low power modes, 10b
|
|
||||||
default:
|
|
||||||
dev->accFactor = 64.0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return UPM_SUCCESS;
|
return UPM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,16 +418,16 @@ void lis2ds12_get_accelerometer(const lis2ds12_context dev,
|
|||||||
{
|
{
|
||||||
assert(dev != NULL);
|
assert(dev != NULL);
|
||||||
|
|
||||||
float scale = (dev->accScale * dev->accFactor) / 1000.0;
|
float scale = dev->accScale / 1000.0;
|
||||||
|
|
||||||
if (x)
|
if (x)
|
||||||
*x = (dev->accX / dev->accFactor) * scale;
|
*x = dev->accX * scale;
|
||||||
|
|
||||||
if (y)
|
if (y)
|
||||||
*y = (dev->accY / dev->accFactor) * scale;
|
*y = dev->accY * scale;
|
||||||
|
|
||||||
if (z)
|
if (z)
|
||||||
*z = (dev->accZ / dev->accFactor) * scale;
|
*z = dev->accZ * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
float lis2ds12_get_temperature(const lis2ds12_context dev)
|
float lis2ds12_get_temperature(const lis2ds12_context dev)
|
||||||
|
@ -69,7 +69,6 @@ extern "C" {
|
|||||||
|
|
||||||
// acc scaling
|
// acc scaling
|
||||||
float accScale;
|
float accScale;
|
||||||
float accFactor;
|
|
||||||
} *lis2ds12_context;
|
} *lis2ds12_context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user