19 lines
544 B
Python
19 lines
544 B
Python
|
|
||
|
import time
|
||
|
import datetime
|
||
|
|
||
|
def get_timestamp():
|
||
|
return datetime.datetime \
|
||
|
.fromtimestamp(time.time()) \
|
||
|
.strftime('%Y.%m.%d-%H:%M:%S')
|
||
|
|
||
|
def mapRange(in_value, in_min, in_max, out_min, out_max, clamp=False):
|
||
|
output = out_min + ((out_max - out_min) / (in_max - in_min)) * (in_value - in_min)
|
||
|
if clamp:
|
||
|
if out_min < out_max:
|
||
|
return min(out_max, max(out_min, output))
|
||
|
else:
|
||
|
return max(out_max, min(out_min, output))
|
||
|
else:
|
||
|
return output
|