Skip to content

Commit 68ee06c

Browse files
committed
Cleaned up and made some behavior fixes
1 parent 1b401bf commit 68ee06c

2 files changed

Lines changed: 107 additions & 89 deletions

File tree

CircuitPython_Pyloton/code.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
"""
2-
Read heart rate data from a heart rate peripheral using the standard BLE
3-
Heart Rate service.
4-
"""
5-
61
from time import time
72
import adafruit_ble
83
import board
@@ -26,7 +21,7 @@
2621

2722
pyloton.show_splash()
2823

29-
pyloton.ams_connect()
24+
ams = pyloton.ams_connect()
3025

3126

3227
start = time()
@@ -50,18 +45,22 @@
5045
# Stop scanning whether or not we are connected.
5146
ble.stop_scan()
5247

53-
#if speed_cad_connections:
54-
# Comment out the following line and uncomment the previous line if you aren't using a
55-
# heart rate monitor
56-
if hr_connection and hr_connection.connected and speed_cad_connections:
48+
# You may need to remove some parts of the following line depending on what
49+
# devices you are using.
50+
print(type(hr_connection))
51+
print(type(speed_cad_connections))
52+
print(type(ams))
53+
if hr_connection and hr_connection.connected and speed_cad_connections[0] and speed_cad_connections[0].connected and ams and ams.connected:
5754
if heart:
5855
print("Fetch connection")
5956
hr_service = hr_connection[HeartRateService]
6057
print("Location:", hr_service.location)
6158
pyloton.setup_display()
6259
break
6360

64-
# Replace following line with while True if you aren't using a heart rate sensor
65-
while hr_connection.connected:
61+
# You may need to remove some parts of the following line depending on what devices you are using.
62+
while hr_connection.connected and speed_cad_connections[0].connected and ams.connected:
6663
pyloton.update_display()
6764
pyloton.ams_remote()
65+
66+
print("\n\nNot all sensors are connected. Please reset to try again\n\n")

0 commit comments

Comments
 (0)