Sfoglia il codice sorgente

switched to polar for heart rate

Marcel Zickler 3 anni fa
parent
commit
d25b41a728

+ 5 - 1
Assets/Scripts/Display/BikeDataDisplay.cs

@@ -7,6 +7,8 @@ namespace Display
 {
     public class BikeDataDisplay : MonoBehaviour
     {
+        public bool usePolarForHeartRate = true;
+
         public TextMeshProUGUI cadenceDisplay;
         public TextMeshProUGUI heartRateDisplay;
 
@@ -53,7 +55,9 @@ namespace Display
 
             if (torqueDisplayAvailable) torqueDisplay.text = $"{sensorData.PowermeterData?.CrankTorque ?? 0f:F2} Nm";
 
-            if (heartRateDisplayAvailable) heartRateDisplay.text = $"{sensorData.HrData?.HeartRate ?? 0:0} bpm";
+            if (heartRateDisplayAvailable)
+                heartRateDisplay.text =
+                    $"{(usePolarForHeartRate ? sensorData.PolarData?.Hr : sensorData.HrData?.HeartRate) ?? 0:0} bpm";
         }
     }
 }

+ 2 - 1
Assets/Scripts/Sensors/ListenToSensors.cs

@@ -13,7 +13,8 @@ namespace Sensors
 
         private void Start()
         {
-            BikeSensorData.Instance.StartListening(speedSensorConfig, polarSensorConfig, powerMeterId, hrAntId);
+            BikeSensorData.Instance.StartListening(speedSensorConfig, polarSensorConfig, powerMeterId,
+                hrAntId < 0 ? null : new int?(hrAntId));
         }
 
         private void OnDestroy()

+ 1 - 1
Assets/Scripts/Sensors/SensorStatus.cs

@@ -57,7 +57,7 @@ namespace Sensors
                 ? $"Power/Cadence: Connected ({powerData?.InstantaneousPower})"
                 : "Power/Cadence: Disconnected";
             polarStatusText.text = PolarReady
-                ? $"Polar: Connected ({polarData?.Acc}, {polarData?.EcgValue})"
+                ? $"Polar: Connected ({polarData?.Acc}, {polarData?.EcgValue}, {polarData?.Hr})"
                 : "Polar: Disconnected";
             if (waitForMqtt)
                 mqttStatusText.text = mqttReady