Skip to content

Commit ec740ac

Browse files
authored
Merge pull request adafruit#1280 from kattni/move-timing-inline
Remove function, move time math inline.
2 parents eb241a0 + 400362c commit ec740ac

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

QT_Py_Timer/QT_Py_Activity_Timer.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@
4242
RED_ALERT = "Red Alert"
4343

4444

45-
def minutes_to_seconds(minutes):
46-
"""
47-
Convert minutes to seconds for use with time.monotonic().
48-
49-
:param minutes: The number of minutes. Can be a float, e.g. 0.5 for half a minute.
50-
"""
51-
seconds = minutes * 60
52-
return seconds
53-
54-
5545
def gradient(color_one, color_two, blend_weight):
5646
"""
5747
Blend between two colors with a given ratio.
@@ -131,9 +121,9 @@ def timing():
131121
state_from_orientation()
132122

133123
if current_orientation == 'up':
134-
activity_duration = minutes_to_seconds(activity_one)
124+
activity_duration = activity_one * 60 # Converts seconds to minutes.
135125
elif current_orientation == 'down':
136-
activity_duration = minutes_to_seconds(activity_two)
126+
activity_duration = activity_two * 60 # Converts seconds to minutes.
137127
else:
138128
return
139129

@@ -155,7 +145,7 @@ def timing_complete():
155145

156146
elapsed = time.monotonic() - state_changed
157147

158-
if elapsed >= minutes_to_seconds(red_alert_delay):
148+
if elapsed >= (red_alert_delay * 60): # Converts seconds to minutes.
159149
set_state(RED_ALERT)
160150
return
161151

QT_Py_Timer/QT_Py_Hydration_Reminder.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
RED_ALERT = "Red Alert"
4242

4343

44-
def minutes_to_seconds(minutes):
45-
"""
46-
Convert minutes to seconds for use with time.monotonic().
47-
48-
:param minutes: The number of minutes. Can be a float, e.g. 0.5 for half a minute.
49-
"""
50-
seconds = minutes * 60
51-
return seconds
52-
53-
5444
def gradient(color_one, color_two, blend_weight):
5545
"""
5646
Blend between two colors with a given ratio.
@@ -129,7 +119,7 @@ def timing():
129119
"""The timing active state."""
130120
state_from_orientation()
131121

132-
activity_duration = minutes_to_seconds(hydration_reminder)
122+
activity_duration = hydration_reminder * 60 # Converts minutes to seconds.
133123

134124
elapsed = time.monotonic() - state_changed
135125

@@ -149,7 +139,7 @@ def timing_complete():
149139

150140
elapsed = time.monotonic() - state_changed
151141

152-
if elapsed >= minutes_to_seconds(red_alert_delay):
142+
if elapsed >= (red_alert_delay * 60): # Converts minutes to seconds.
153143
set_state(RED_ALERT)
154144
return
155145

0 commit comments

Comments
 (0)