forked from yLeah/form_focused
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexertiontracker.py
More file actions
60 lines (46 loc) · 1.69 KB
/
exertiontracker.py
File metadata and controls
60 lines (46 loc) · 1.69 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
57
58
59
60
# user inputs
age = int(input("Enter your age: "))
target_intensity = float(input("Target intensity (0-1): "))
# calibration ??
print("\nCalibrating resting heart rate...")
resting_hr_samples = []
for i in range(40):
hr = float(input(f"Resting HR sample {i + 1}: "))
resting_hr_samples.append(hr)
resting_hr = sum(resting_hr_samples) / len(resting_hr_samples)
max_hr = 220 - age
print(f"\nResting HR = {resting_hr:.1f} bpm")
print(f"Estimated Max HR = {max_hr} bpm\n")
# functions
def karvonen_target_hr(intensity, resting_hr, max_hr):
return resting_hr + intensity * (max_hr - resting_hr)
def heart_rate_intensity(current_hr, resting_hr, max_hr):
return (current_hr - resting_hr) / (max_hr - resting_hr)
def temperature_status(current_temp, baseline_temp):
delta = current_temp - baseline_temp
if delta >= 2.5:
return "DANGER"
elif delta >= 1.5:
return "WARNING"
else:
return "NORMAL"
# exercise loop
baseline_temp = float(input("Baseline wrist temperature (C): "))
current_hr = float(input("\nCurrent HR: "))
current_temp = float(input("Current wrist temp (C): "))
target_hr = karvonen_target_hr(target_intensity, resting_hr, max_hr)
intensity = heart_rate_intensity(current_hr, resting_hr, max_hr)
temp_state = temperature_status(current_temp, baseline_temp)
print("\nFEEDBACK")
if current_hr < target_hr * 0.9:
print("Increase intensity!")
elif current_hr > target_hr * 1.1:
print("Ease up slightly")
else:
print("You are in your target zone")
if current_hr >= max_hr:
print("WARNING: HR exceeds estimated max")
if temp_state == "WARNING":
print("Temp rising fast")
elif temp_state == "DANGER":
print("STOP: Overexertion risk")