diff --git a/ShimmerBLE/BLE.Client/BLE.Client/Pages/DeviceListPage.xaml b/ShimmerBLE/BLE.Client/BLE.Client/Pages/DeviceListPage.xaml
index ba6ce9bb..69bc0d20 100644
--- a/ShimmerBLE/BLE.Client/BLE.Client/Pages/DeviceListPage.xaml
+++ b/ShimmerBLE/BLE.Client/BLE.Client/Pages/DeviceListPage.xaml
@@ -610,6 +610,10 @@
+
+
+
+
_StepCountEnabled;
+
+ set
+ {
+ if (_StepCountEnabled == value)
+ return;
+
+ if (!_Accel2Enabled || !_GyroEnabled)
+ {
+ RaisePropertyChanged();
+ return;
+ }
+
+ _StepCountEnabled = value;
+ RaisePropertyChanged();
+ }
+ }
+
//bool _GyroHighPerformanceEnabled;
//public bool SensorGyroHighPerformance
//{
@@ -2384,6 +2417,7 @@ private void ShimmerDevice_BLEEvent(object sender, ShimmerBLEEventData e)
SensorAccel = ((SensorLIS2DW12)VerisenseBLEDevice.GetSensor(SensorLIS2DW12.SensorName)).IsAccelEnabled();
SensorAccel2 = ((SensorLSM6DS3)VerisenseBLEDevice.GetSensor(SensorLSM6DS3.SensorName)).IsAccelEnabled();
SensorGyro = ((SensorLSM6DS3)VerisenseBLEDevice.GetSensor(SensorLSM6DS3.SensorName)).IsGyroEnabled();
+ StepCount = ((SensorLSM6DS3)VerisenseBLEDevice.GetSensor(SensorLSM6DS3.SensorName)).IsStepCountEnabled();
if (((shimmer.Sensors.SensorGSR)VerisenseBLEDevice.GetSensor(shimmer.Sensors.SensorGSR.SensorName)).GetOversamplingRate() != null)
{
SelectedGSROversamplingRate = ((shimmer.Sensors.SensorGSR)VerisenseBLEDevice.GetSensor(shimmer.Sensors.SensorGSR.SensorName)).GetOversamplingRate().GetDisplayName();
@@ -2825,6 +2859,14 @@ protected async void ConfigureSensor()
{
((SensorLSM6DS3)clone.GetSensor(SensorLSM6DS3.SensorName)).SetGyroEnabled(false);
}
+ if (StepCount)
+ {
+ ((SensorLSM6DS3)clone.GetSensor(SensorLSM6DS3.SensorName)).SetStepCountEnabled(true);
+ }
+ else
+ {
+ ((SensorLSM6DS3)clone.GetSensor(SensorLSM6DS3.SensorName)).SetStepCountEnabled(false);
+ }
((SensorLSM6DS3)clone.GetSensor(SensorLSM6DS3.SensorName)).SetAccelRange(a2range);
((SensorLSM6DS3)clone.GetSensor(SensorLSM6DS3.SensorName)).SetSamplingRate(a2gyrorate);
((SensorLSM6DS3)clone.GetSensor(SensorLSM6DS3.SensorName)).SetGyroRange(grange);
diff --git a/ShimmerBLE/ShimmerBLEAPI/Sensors/SensorLSM6DS3.cs b/ShimmerBLE/ShimmerBLEAPI/Sensors/SensorLSM6DS3.cs
index 8be981ee..3eab4c85 100644
--- a/ShimmerBLE/ShimmerBLEAPI/Sensors/SensorLSM6DS3.cs
+++ b/ShimmerBLE/ShimmerBLEAPI/Sensors/SensorLSM6DS3.cs
@@ -24,6 +24,8 @@ public SensorLSM6DS3()
//GEN_CFG_0
protected bool Accel2_Enabled = false;
protected bool Gyro_Enabled = false;
+ //GEN_CFG_2
+ protected bool StepCountEnabled;
//GYRO_ACCEL2_CFG_0
protected SensorSetting FIFOThresholdSetting = Sensor.UnknownSetting;
//GYRO_ACCEL2_CFG_1
@@ -268,6 +270,7 @@ public void SetAccelEnabled(bool enable)
{
Accel2_Enabled = enable;
}
+
///
/// Turns on/off data collection from the gyroscope
///
@@ -276,6 +279,28 @@ public void SetGyroEnabled(bool enable)
{
Gyro_Enabled = enable;
}
+
+ ///
+ /// Returns true if step count is enabled
+ ///
+ public bool IsStepCountEnabled()
+ {
+ return StepCountEnabled;
+ }
+
+ ///
+ /// Enable or disable step count
+ ///
+ ///
+ public void SetStepCountEnabled(bool enabled)
+ {
+ if(enabled && (!Accel2_Enabled || !Gyro_Enabled))
+ {
+ throw new Exception("Unable to enable step count when Accel2 or Gyro is not enabled. ");
+ }
+ StepCountEnabled = enabled;
+ }
+
///
/// Returns true if the data collection from the secondary accelerometer is enabled
///
@@ -284,6 +309,7 @@ public bool IsAccelEnabled()
{
return Accel2_Enabled;
}
+
///
/// Returns true if the data collection from the gyroscope is enabled
///
@@ -660,6 +686,15 @@ public override byte[] GenerateOperationConfig(byte[] operationalConfigBytes)
operationalConfigBytes[(int)ConfigurationBytesIndexName.GEN_CFG_0] = (byte)(operationalConfigBytes[(int)ConfigurationBytesIndexName.GEN_CFG_0] & 0b11011111);
}
+ if (StepCountEnabled)
+ {
+ operationalConfigBytes[(int)ConfigurationBytesIndexName.GEN_CFG_2] = (byte)(operationalConfigBytes[(int)ConfigurationBytesIndexName.GEN_CFG_2] | 0b00100000);
+ }
+ else
+ {
+ operationalConfigBytes[(int)ConfigurationBytesIndexName.GEN_CFG_2] = (byte)(operationalConfigBytes[(int)ConfigurationBytesIndexName.GEN_CFG_2] & 0b11011111);
+ }
+
//temp
operationalConfigBytes[(int)ConfigurationBytesIndexName.GYRO_ACCEL2_CFG_5] = (byte)((operationalConfigBytes[(int)ConfigurationBytesIndexName.GYRO_ACCEL2_CFG_5] & 0b0001111) | (SamplingRateSetting.GetConfigurationValue() << 4));
operationalConfigBytes[(int)ConfigurationBytesIndexName.GYRO_ACCEL2_CFG_5] = (byte)((operationalConfigBytes[(int)ConfigurationBytesIndexName.GYRO_ACCEL2_CFG_5] & 0b11110011) | (GyroRangeSetting.GetConfigurationValue() << 2));
@@ -902,6 +937,14 @@ public override void InitializeUsingOperationConfig(byte[] operationalConfigByte
{
Gyro_Enabled = false;
}
+ if ((operationalConfigBytes[(int)ConfigurationBytesIndexName.GEN_CFG_2] & 0b00100000) > 5)
+ {
+ StepCountEnabled = true;
+ }
+ else
+ {
+ StepCountEnabled = false;
+ }
if (((operationalConfigBytes[(int)ConfigurationBytesIndexName.GYRO_ACCEL2_CFG_1] >> 7) & 0b00000001) == 1)
{
StepCounterAndTimestampEnabled = true;