From 7fbe97bc7c2f523a38e036e8daf6edc85e936315 Mon Sep 17 00:00:00 2001 From: JongChern Date: Tue, 21 Jan 2025 13:35:04 +0800 Subject: [PATCH] gyro update --- Shimmer32FeetAPI/ShimmerSDBT32Feet.cs | 2 +- ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs | 40 +++++--------------- ShimmerAPI/ShimmerAPI/ShimmerLogAndStream.cs | 2 +- ShimmerAPI/ShimmerAPI/ShimmerSDBT.cs | 2 +- 4 files changed, 13 insertions(+), 33 deletions(-) diff --git a/Shimmer32FeetAPI/ShimmerSDBT32Feet.cs b/Shimmer32FeetAPI/ShimmerSDBT32Feet.cs index 6931f6c..fb632bb 100644 --- a/Shimmer32FeetAPI/ShimmerSDBT32Feet.cs +++ b/Shimmer32FeetAPI/ShimmerSDBT32Feet.cs @@ -890,7 +890,7 @@ public void SdConfigWrite() file.WriteLine("gs_range=" + GetGSRRange()); file.WriteLine("exp_power=" + (GetExpPower() ? 1 : 0)); file.WriteLine("gyro_range=" + GetGyroRange()); - file.WriteLine("gyro_samplingrate=" + GetMpu9150SamplingRate()); + file.WriteLine("gyro_samplingrate=" + GetGyroSamplingRate()); file.WriteLine("acc_range=" + GetAccelRange()); file.WriteLine("acc_lpm=" + GetAccelLPBit()); file.WriteLine("acc_hrm=" + GetAccelHRBit()); diff --git a/ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs b/ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs index ae51c9a..f05028d 100644 --- a/ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs +++ b/ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs @@ -129,7 +129,7 @@ public abstract class ShimmerBluetooth : ShimmerDevice protected int MagGain; protected int LNAccelRange; protected int AccelSamplingRate; - protected int Mpu9150SamplingRate; + protected int GyroSamplingRate; protected int AltAccelSamplingRate; protected int AltMagSamplingRate; protected long ConfigSetupByte0; // for Shimmer2 @@ -2239,7 +2239,7 @@ public void InterpretInquiryResponseShimmer3R(List packet) GyroRange = (int)((ConfigSetupByte0 >> 16) & 0x03); MagGain = (int)((ConfigSetupByte0 >> 21) & 0x07); AccelSamplingRate = (int)((ConfigSetupByte0 >> 4) & 0xF); - Mpu9150SamplingRate = (int)((ConfigSetupByte0 >> 8) & 0xFF); + GyroSamplingRate = (int)((ConfigSetupByte0 >> 8) & 0xFF); magSamplingRate = (int)((ConfigSetupByte0 >> 18) & 0x07); PressureResolution = (int)((ConfigSetupByte0 >> 28) & 0x03); GSRRange = (int)((ConfigSetupByte0 >> 25) & 0x07); @@ -2275,12 +2275,12 @@ public void InterpretInquiryResponseShimmer3R(List packet) { LowPowerAccelEnabled = true; } - /* - if ((Mpu9150SamplingRate == 0xFF && ADCRawSamplingRateValue < 3200)) + + if (GyroSamplingRate == 0x01) { LowPowerGyroEnabled = true; } - */ + } @@ -2313,7 +2313,7 @@ public void InterpretInquiryResponseShimmer3(List packet) GyroRange = (int)((ConfigSetupByte0 >> 16) & 0x03); MagGain = (int)((ConfigSetupByte0 >> 21) & 0x07); AccelSamplingRate = (int)((ConfigSetupByte0 >> 4) & 0xF); - Mpu9150SamplingRate = (int)((ConfigSetupByte0 >> 8) & 0xFF); + GyroSamplingRate = (int)((ConfigSetupByte0 >> 8) & 0xFF); magSamplingRate = (int)((ConfigSetupByte0 >> 18) & 0x07); PressureResolution = (int)((ConfigSetupByte0 >> 28) & 0x03); GSRRange = (int)((ConfigSetupByte0 >> 25) & 0x07); @@ -2332,32 +2332,12 @@ public void InterpretInquiryResponseShimmer3(List packet) LowPowerAccelEnabled = true; } - if ((Mpu9150SamplingRate == 0xFF && ADCRawSamplingRateValue < 3200)) + if ((GyroSamplingRate == 0xFF && ADCRawSamplingRateValue < 3200)) { LowPowerGyroEnabled = true; } } - if (HardwareVersion == (int)ShimmerBluetooth.ShimmerVersion.SHIMMER3R) - { - if (magSamplingRate == 0) //3200 us the raw ADC value and not in HZ - { - LowPowerMagEnabled = true; - } - - if ((AccelSamplingRate == 1)) - { - LowPowerAccelEnabled = true; - } - /* - if ((Mpu9150SamplingRate == 0xFF && ADCRawSamplingRateValue < 3200)) - { - LowPowerGyroEnabled = true; - } - */ - } - - NumberofChannels = (int)packet[6]; BufferSize = (int)packet[7]; ListofSensorChannels.Clear(); @@ -5414,9 +5394,9 @@ public int GetMpu9150AccelRange() { return Mpu9150AccelRange; } - public int GetMpu9150SamplingRate() + public int GetGyroSamplingRate() { - return Mpu9150SamplingRate; + return GyroSamplingRate; } public int GetAccelRange() @@ -6376,7 +6356,7 @@ protected void WriteGyroSamplingRate(int rate) { if (HardwareVersion == (int)ShimmerVersion.SHIMMER3 || HardwareVersion == (int)ShimmerVersion.SHIMMER3R) { - Mpu9150SamplingRate = rate; + GyroSamplingRate = rate; mTempIntValue = rate; WriteBytes(new byte[2] { (byte)PacketTypeShimmer3.SET_MPU9150_SAMPLING_RATE_COMMAND, (byte)rate }, 0, 2); System.Threading.Thread.Sleep(200); diff --git a/ShimmerAPI/ShimmerAPI/ShimmerLogAndStream.cs b/ShimmerAPI/ShimmerAPI/ShimmerLogAndStream.cs index 3c0ca73..f6e80a3 100644 --- a/ShimmerAPI/ShimmerAPI/ShimmerLogAndStream.cs +++ b/ShimmerAPI/ShimmerAPI/ShimmerLogAndStream.cs @@ -1207,7 +1207,7 @@ public void SdConfigWrite() file.WriteLine("gs_range=" + GetGSRRange()); file.WriteLine("exp_power=" + (GetExpPower() ? 1 : 0)); file.WriteLine("gyro_range=" + GetGyroRange()); - file.WriteLine("gyro_samplingrate=" + GetMpu9150SamplingRate()); + file.WriteLine("gyro_samplingrate=" + GetGyroSamplingRate()); file.WriteLine("acc_range=" + GetAccelRange()); file.WriteLine("acc_lpm=" + GetAccelLPBit()); file.WriteLine("acc_hrm=" + GetAccelHRBit()); diff --git a/ShimmerAPI/ShimmerAPI/ShimmerSDBT.cs b/ShimmerAPI/ShimmerAPI/ShimmerSDBT.cs index 3ebc212..92c269f 100644 --- a/ShimmerAPI/ShimmerAPI/ShimmerSDBT.cs +++ b/ShimmerAPI/ShimmerAPI/ShimmerSDBT.cs @@ -976,7 +976,7 @@ public void SdConfigWrite() file.WriteLine("gs_range=" + GetGSRRange()); file.WriteLine("exp_power=" + (GetExpPower() ? 1 : 0)); file.WriteLine("gyro_range=" + GetGyroRange()); - file.WriteLine("gyro_samplingrate=" + GetMpu9150SamplingRate()); + file.WriteLine("gyro_samplingrate=" + GetGyroSamplingRate()); file.WriteLine("acc_range=" + GetAccelRange()); file.WriteLine("acc_lpm=" + GetAccelLPBit()); file.WriteLine("acc_hrm=" + GetAccelHRBit());