forked from wemakewaves/PyRow
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstatshow.py
More file actions
executable file
·56 lines (44 loc) · 2.18 KB
/
statshow.py
File metadata and controls
executable file
·56 lines (44 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
#Copyright (c) 2011, Sam Gambrell
#Licensed under the Simplified BSD License.
#This is an example file to show how to make use of pyrow
#Have the rowing machine on and plugged into the computer before starting the program
#The program will display any changes to the machine status, stroke state, or workout state
#NOTE: This code has not been thoroughly tested and may not function as advertised.
#Please report and findings to the author so that they may be addressed in a stable release.
import pyrow
import time
if __name__ == '__main__':
#Connecting to erg
ergs = list(pyrow.find())
if len(ergs) == 0:
exit("No ergs found.")
erg = pyrow.pyrow(ergs[0])
print("Connected to erg.")
#Create a dictionary of the different status states
state = ['Error', 'Ready', 'Idle', 'Have ID', 'N/A', 'In Use',
'Pause', 'Finished', 'Manual', 'Offline']
stroke = ['Wait for min speed', 'Wait for acceleration', 'Drive', 'Dwelling', 'Recovery']
workout = ['Waiting begin', 'Workout row', 'Countdown pause', 'Interval rest',
'Work time inverval', 'Work distance interval', 'Rest end time', 'Rest end distance',
'Time end rest', 'Distance end rest', 'Workout end', 'Workout terminate',
'Workout logged', 'Workout rearm']
command = ['CSAFE_GETSTATUS_CMD', 'CSAFE_PM_GET_STROKESTATE', 'CSAFE_PM_GET_WORKOUTSTATE']
#prime status number
cstate = -1
cstroke = -1
cworkout = -1
erg.set_workout(distance=2000, split=100, pace=120)
#Inf loop
while 1:
results = erg.send(command)
if cstate != (results['CSAFE_GETSTATUS_CMD'][0] & 0xF):
cstate = results['CSAFE_GETSTATUS_CMD'][0] & 0xF
print("State " + str(cstate) + ": " + state[cstate])
if cstroke != results['CSAFE_PM_GET_STROKESTATE'][0]:
cstroke = results['CSAFE_PM_GET_STROKESTATE'][0]
print("Stroke " + str(cstroke) + ": " + stroke[cstroke])
if cworkout != results['CSAFE_PM_GET_WORKOUTSTATE'][0]:
cworkout = results['CSAFE_PM_GET_WORKOUTSTATE'][0]
print("Workout " + str(cworkout) + ": " + workout[cworkout])
time.sleep(1)