diff --git a/ShimmerBluetooth/ShimmerBluetooth/HighGAccelSensor.swift b/ShimmerBluetooth/ShimmerBluetooth/HighGAccelSensor.swift index 132dab9..e223be6 100644 --- a/ShimmerBluetooth/ShimmerBluetooth/HighGAccelSensor.swift +++ b/ShimmerBluetooth/ShimmerBluetooth/HighGAccelSensor.swift @@ -26,10 +26,20 @@ public class HighGAccelSensor : IMUSensor , SensorProcessing{ let x = Array(sensorPacket[packetIndexHighGAccelX.. [Double] { + let objectCluster = highGAccelCluster(hwid: hwid, packet: packet, calibrationEnabled: false) + return [HighGAccelSensor.HIGHG_ACCEL_X, HighGAccelSensor.HIGHG_ACCEL_Y, HighGAccelSensor.HIGHG_ACCEL_Z].map { axis in + let name = [axis, Sensor.SensorFormats.Raw.rawValue, Sensor.SensorUnits.meterPerSecondSquared.rawValue].joined(separator: "_") + return objectCluster.SignalData[objectCluster.SignalNames.firstIndex(of: name)!] + } + } + + private func highGAccelCluster(hwid: Int, packet: [UInt8], calibrationEnabled: Bool) -> ObjectCluster { + let sensor = HighGAccelSensor(hwid: hwid) + sensor.calibrationEnabled = calibrationEnabled + sensor.packetIndexHighGAccelX = 0 + sensor.packetIndexHighGAccelY = 2 + sensor.packetIndexHighGAccelZ = 4 + return sensor.processData(sensorPacket: packet, objectCluster: ObjectCluster(deviceName: "test")) + } }