Browse Source

add GetRange

Juraj Ďuďák 2 years ago
parent
commit
a475ba6c18
2 changed files with 16 additions and 0 deletions
  1. 13 0
      src/icm20948.cpp
  2. 3 0
      src/icm20948.h

+ 13 - 0
src/icm20948.cpp

@@ -423,6 +423,9 @@ uint8_t Sensor::GetSampleRate(void)
 	return 0xFF;
 }
 
+uint8_t Sensor::GetRange(void){
+	return 0;
+}
 
 bool SensorGyro::Read(axises* data)
 {
@@ -730,3 +733,13 @@ uint8_t SensorAccel::GetSampleRate(void)
 	return sr_index;
 }
 
+
+uint8_t SensorAccel::GetRange(void){
+	uint8_t new_val = _spi->read_single_reg(_activeDevice, ub_2, B2_ACCEL_CONFIG);
+	return (new_val >> 1) & 0x03;
+}
+
+uint8_t SensorGyro::GetRange(void){
+	uint8_t new_val = _spi->read_single_reg(_activeDevice, ub_2, B2_GYRO_CONFIG_1);
+	return (new_val >> 1) & 0x03;
+}

+ 3 - 0
src/icm20948.h

@@ -32,6 +32,7 @@ public:
 	uint8_t SetSampleRate();
 	uint8_t GetLowPassFilter(void);
 	uint8_t GetSampleRate(void);
+	uint8_t GetRange(void);
 	uint8_t CheckLowPassInputValue(uint8_t);
 
 
@@ -55,6 +56,7 @@ public:
 
 	uint8_t GetLowPassFilter(void);
 	uint8_t GetSampleRate(void);
+	uint8_t GetRange(void);
 };
 
 
@@ -72,6 +74,7 @@ public:
 
 	uint8_t GetLowPassFilter(void);
 	uint8_t GetSampleRate(void);
+	uint8_t GetRange(void);
 };
 
 class SensorMag: public Sensor {