-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.py
66 lines (62 loc) · 2.05 KB
/
tools.py
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
61
62
63
64
65
66
import constants as CONST
def getNewTime(temp, type):
lowerTemp = 0
lowerTime = 0
higherTemp = 100
higherTime = 0
if type == "custom":
return 00.00
for devTemp, devTime in CONST.tempTimes[type].items():
if devTemp == temp:
return devTime
if devTemp < temp:
if devTemp > lowerTemp:
lowerTemp = devTemp
lowerTime = devTime
if devTemp > temp:
if devTemp < higherTemp:
higherTemp = devTemp
higherTime = devTime
if lowerTemp == 0:
lowerTemp = higherTemp
lowerTime = higherTime
higherTemp = 100
for devTemp, devTime in CONST.tempTimes[type].items():
if devTemp > lowerTemp:
if devTemp < higherTemp:
higherTemp = devTemp
higherTime = devTime
if higherTemp == 0:
higherTemp = lowerTemp
higherTime = lowerTime
lowerTemp = 0
for devTemp, devTime in CONST.tempTimes[type].items():
if devTemp < higherTemp:
if devTemp > lowerTemp:
lowerTemp = devTemp
lowerTime = devTime
# I don't think I need to worry about dividing by 0 here, but I'd rather be safe
if (higherTime - lowerTime) == 0:
higherTime = higherTime + 1
if (higherTemp - lowerTemp) == 0:
higherTemp = higherTemp + 1
slope = (higherTime - lowerTime) / (higherTemp - lowerTemp)
newTime = lowerTime + (slope * (temp - lowerTemp))
return round(newTime * 60 * 1000, 2)
def halfStepPushPull(steps):
pass
def convertMs(ms):
totalSeconds = ms // 1000
minutes = totalSeconds // 60
seconds = totalSeconds % 60
formattedTime = "{:02}:{:02}".format(minutes, seconds)
return formattedTime
def incrementList(listLen, currentVal, up):
if up:
if currentVal < listLen -1:
return currentVal + 1
return 0
if not up:
if currentVal >= 1:
return currentVal - 1
return listLen -1