|
12 | 12 |
|
13 | 13 | HEART = True |
14 | 14 | SPEED = True |
15 | | -CAD = True |
| 15 | +CADENCE = True |
16 | 16 | AMS = True |
17 | 17 | DEBUG = False |
18 | 18 |
|
19 | 19 | # 84.229 is wheel circumference (700x23 in my case) |
20 | | -pyloton = pyloton.Pyloton(ble, display, 84.229, HEART, SPEED, CAD, AMS, DEBUG) |
| 20 | +pyloton = pyloton.Pyloton(ble, display, 84.229, HEART, SPEED, CADENCE, AMS, DEBUG) |
21 | 21 |
|
22 | 22 | pyloton.show_splash() |
23 | 23 |
|
|
26 | 26 |
|
27 | 27 | start = time() |
28 | 28 | hr_connection = None |
29 | | -speed_cad_connections = [] |
| 29 | +speed_cadence_connections = [] |
30 | 30 | radio = None |
31 | 31 | while True: |
32 | 32 | if HEART: |
33 | 33 | if not hr_connection: |
34 | 34 | print("Attempting to connect to a heart rate monitor") |
35 | 35 | hr_connection = pyloton.heart_connect() |
36 | 36 | ble.stop_scan() |
37 | | - if SPEED or CAD: |
38 | | - if not speed_cad_connections: |
| 37 | + if SPEED or CADENCE: |
| 38 | + if not speed_cadence_connections: |
39 | 39 | print("Attempting to connect to speed and cadence monitors") |
40 | | - speed_cad_connections = pyloton.speed_cad_connect() |
| 40 | + speed_cadence_connections = pyloton.speed_cadence_connect() |
41 | 41 |
|
42 | 42 | if time()-start >= CONNECTION_TIMEOUT: |
43 | 43 | pyloton.timeout() |
|
49 | 49 | # devices you are using. |
50 | 50 | # For example, remove hr_connection and hr_connection.connected if you aren't using a heart |
51 | 51 | # rate monitor. Do the same for other sensors you aren't using. |
52 | | - if hr_connection and speed_cad_connections and ams: |
53 | | - if hr_connection.connected and speed_cad_connections[0].connected and ams.connected: |
54 | | - pyloton.setup_display() |
55 | | - break |
| 52 | + if ((not HEART or (hr_connection and hr_connection.connected)) and #pylint: disable=too-many-boolean-expressions |
| 53 | + ((not SPEED and not CADENCE) or |
| 54 | + (speed_cadence_connections and speed_cadence_connections[0].connected)) and |
| 55 | + (not AMS or (ams and ams.connected))): |
| 56 | + break |
| 57 | + |
| 58 | +pyloton.setup_display() |
56 | 59 |
|
57 | 60 | # You may need to remove some parts of the following line depending on what devices you are using. |
58 | 61 | # For example, remove hr_connection and hr_connection.connected if you aren't using a heart rate |
59 | 62 | # monitor. Do the same for other sensors you aren't using. |
60 | | -while hr_connection.connected and speed_cad_connections[0].connected and ams.connected: |
| 63 | +while ((not HEART or hr_connection.connected) and |
| 64 | + ((not SPEED or not CADENCE) or speed_cadence_connections[0].connected) and |
| 65 | + (not AMS or ams.connected)): |
61 | 66 | pyloton.update_display() |
62 | 67 | pyloton.ams_remote() |
63 | 68 |
|
|
0 commit comments