Browse Source

_scaleFactor as int16_t instead float

Juraj Ďuďák 1 year ago
parent
commit
acb82f70b6
2 changed files with 5 additions and 5 deletions
  1. 3 3
      src/icm20948.cpp
  2. 2 2
      src/icm20948.h

+ 3 - 3
src/icm20948.cpp

@@ -323,7 +323,7 @@ uint8_t Icm20948::GetIndex(void)
 Sensor::Sensor(IcmSpiManager *spi, int8_t activeDevice){
 	_spi = spi;
 	_activeDevice = activeDevice;
-	_scaleFactor = 1.0f;
+	_scaleFactor = 1;
 	offset_x = 0;
 	offset_y = 0;
 	offset_z = 0;
@@ -356,7 +356,7 @@ SensorMag::SensorMag(IcmSpiManager *spi, int8_t activeDevice):Sensor(spi, active
 
 }
 
-void Sensor::SetScaleFactor(float sf){
+void Sensor::SetScaleFactor(int16_t sf){
 	_scaleFactor = sf;
 }
 
@@ -492,7 +492,7 @@ void SensorAccel::SetRange(accel_full_scale full_scale)
 {
 	uint8_t new_val = _spi->read_single_reg(_activeDevice, ub_2, B2_ACCEL_CONFIG);
 	new_val = new_val & 0xF9;	// remova ACCEL_FS_SEL bites [1-2]
-	float accel_scale_factor;
+	int16_t accel_scale_factor;
 	switch(full_scale)
 	{
 		case ACCEL_FS_2g :

+ 2 - 2
src/icm20948.h

@@ -22,14 +22,14 @@ protected:
 	int8_t _activeDevice;
 	IcmSpiManager *_spi;
 public:
-	float _scaleFactor;
+	uint16_t _scaleFactor;
 	axisesI data;
 	int16_t offset_x;
 	int16_t offset_y;
 	int16_t offset_z;
 
 	Sensor(IcmSpiManager *spi, int8_t _activeDevice);
-	void SetScaleFactor(float sf);
+	void SetScaleFactor(int16_t sf);
 	void SetRange();
 	void SetLowPassFilter();
 	uint8_t SetSampleRate();