Private
Public Access
1
0

improving long step description

This commit is contained in:
Sander Roosendaal
2021-03-23 15:11:22 +01:00
parent da5611005a
commit a7b46ed28d
3 changed files with 38 additions and 65 deletions

View File

@@ -105,6 +105,17 @@ info_calls = [
import random
def to_pace(pace):
minutes, seconds = divmod(pace,60)
seconds, rest = divmod(seconds, 1)
tenths = int(rest*10)
s = '{m:0>2}:{s:0>2}.{t:0>1}'.format(
m=int(minutes),
s=int(seconds),
t=int(tenths)
)
return s
def get_call():
call1 = random.choice(coxes_calls)
call2 = random.choice(info_calls)
@@ -784,6 +795,7 @@ def step_to_string(step,short=False):
unit = ''
target = ''
repeat = ''
notes = ''
durationtype = step['durationType']
if step['durationValue'] == 0:
@@ -854,9 +866,7 @@ def step_to_string(step,short=False):
duration = 'until > {targetvalue} W'.format(targetvalue=targetvalue)
elif durationtype == 'RepeatUntilStepsCmplt':
type = 'RepeatStep'
ntimes = str(step['targetValue'])+' times:'
if short:
ntimes = ': {v}x'.format(v=step['targetValue'])
ntimes = ': {v}x'.format(v=step['targetValue'])
repeatID = step['durationValue']
duration =ntimes
repeatValue = step['targetValue']
@@ -868,7 +878,7 @@ def step_to_string(step,short=False):
targetvalue=targetvalue
)
if short:
duration = ': until HR>{targervalue} % of max'.format(targetvalue=targetvalue)
duration = ': until HR>{targetvalue} % of max'.format(targetvalue=targetvalue)
else:
duration = 'Repeat until Heart Rate is greater than {targetvalue}:'.format(
targetvalue=targetvalue-100.
@@ -916,27 +926,15 @@ def step_to_string(step,short=False):
valuehigh = 0
if value < 10 and value>0:
target = 'Target: Heart Rate in zone {v}'.format(v=value)
if short:
target = '@ HR zone {v}'.format(v=value)
target = '@ HR zone {v}'.format(v=value)
else:
if valuelow < 100:
target = 'Target: Heart Rate between {l} and {h} % of max'.format(
l = valuelow,
h = valuehigh
)
if short:
target = '@ HR {l} - {h} % of max'.format(
target = '@ HR {l} - {h} % of max'.format(
l = valuelow,
h = valuehigh,
)
else:
target = 'Target: Heart Rate between {l} and {h}'.format(
l = valuelow-100,
h = valuehigh+100
)
if short:
target = '@ HR {l} - {h}'.format(
target = '@ HR {l} - {h}'.format(
l = valuelow - 100,
h = valuehigh - 100,
)
@@ -955,35 +953,19 @@ def step_to_string(step,short=False):
valuehigh = 0
if value < 10 and value>0:
target = 'Target: Power in zone {v}'.format(v=value)
if short:
target = '@ Power zone {v}'.format(v=value)
target = '@ Power zone {v}'.format(v=value)
elif value > 10 and value < 1000:
target = 'Target: Power at {v} % of FTP'.format(v=value)
if short:
target = '@ {v}% of FTP'.format(v=value)
target = '@ {v}% of FTP'.format(v=value)
elif value > 1000:
target = 'Target: Power at {v} Watt'.format(v=value-1000)
if short:
target = '@ {v} W'.format(v=value-1000)
target = '@ {v} W'.format(v=value-1000)
elif valuelow > 0 and valuehigh > 0:
if valuelow < 1000:
target = 'Target: Power between {l} and {h} % of FTP'.format(
l = valuelow,
h = valuehigh
)
if short:
target = '@ {l} - {h} % of FTP'.format(
target = '@ {l} - {h} % of FTP'.format(
l = valuelow,
h = valuehigh,
)
else:
target = 'Target: Power between {l} and {h} W'.format(
l = valuelow-1000,
h = valuehigh-1000
)
if short:
target = '@ {l} - {h} W'.format(
target = '@ {l} - {h} W'.format(
l = valuelow-1000,
h = valuehigh-1000,
)
@@ -1005,7 +987,7 @@ def step_to_string(step,short=False):
v = value/1000.
pace = 500./v
pacestring = to_pace(pace)
target = 'Target: Speed at {v} m/s {p} per 500m'.format(
target = '@ {v} m/s {p}, per 500m'.format(
v=value/1000.,
p=pacestring)
if short:
@@ -1019,7 +1001,7 @@ def step_to_string(step,short=False):
pace = 500./v
pacestringhigh = to_pace(pace)
target = 'Target: Speed between {l:1.2f} and {h:1.2f} m/s ({ph} to {pl} per 500m)'.format(
target = '@ {l:1.2f} and {h:1.2f} m/s, ({ph} to {pl} per 500m)'.format(
l = valuelow/1000.,
h = valuehigh/1000.,
pl = pacestringlow,
@@ -1045,16 +1027,9 @@ def step_to_string(step,short=False):
valuehigh = 0
if value != 0:
target = 'Target: Cadence at {v} SPM'.format(v=value)
if short:
target = '@ {v} SPM'.format(v=value)
target = '@ {v} SPM'.format(v=value)
elif valuelow != 0 and valuehigh != 0:
target = 'Target: Cadence between {l} and {h} SPM'.format(
l = valuelow,
h = valuehigh
)
if short:
target = '@ {l} - {h} SPM'.format(
target = '@ {l} - {h} SPM'.format(
l = valuelow,
h = valuehigh
)
@@ -1076,7 +1051,7 @@ def step_to_string(step,short=False):
except KeyError:
intensity = 0
s = '{name} {intensity} {duration} {unit} {target} {repeat} {notes}'.format(
s = '{duration} {unit} {target} {repeat} {notes}'.format(
nr = nr,
name = name,
unit=unit,
@@ -1103,10 +1078,17 @@ def step_to_string(step,short=False):
repeat = repeat,
unit = unit
)
elif intensity in ['Warmup','Cooldown','Rest']:
s = '{intensity} {duration} {unit} {target} {repeat} {notes}'.format(
intensity = intensity,
duration = duration,
target = target,
repeat = repeat,
unit = unit,
notes = notes,
)
if type == 'RepeatStep':
s = 'Repeat {duration}'.format(duration=duration)
if short:
s = 'Repeat {duration}'.format(duration=duration)
return s,type, nr, repeatID, repeatValue