Created
December 8, 2019 22:28
-
-
Save akmadian/da2aaeb0144e60c8d46534d810489f2e to your computer and use it in GitHub Desktop.
A Gong Fu tea timer in the form of a Python script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
tea-timer.py is meant for timing tea steepings, | |
and is made specifically for gong fu style brewing. | |
It also includes a delay timer before starting the | |
steeping timer to allow time for picking up the kettle | |
or other things like that. | |
""" | |
import time | |
import os | |
from win10toast import ToastNotifier | |
toaster = ToastNotifier() | |
base = int(input('Base Time (s): ')) | |
add = int(input('Add Time (s): ')) | |
delay = int(input('Delay (s): ')) | |
priorsteeps = input('Any Prior Steepings?: ') | |
current_steep = 0 if priorsteeps == '' else int(priorsteeps) | |
cust_add = -1 | |
last_time = 0 | |
def calcTime(): | |
if cust_add != -1: | |
return last_time + cust_add | |
else: | |
return base + (add * current_steep) | |
while True: | |
for i in range(int(delay), 0, -1): # delay timer | |
print(i) | |
time.sleep(1) | |
print("Starting timer...") | |
nseconds = calcTime() | |
last_time = nseconds | |
if (nseconds % 5 != 0): | |
print(nseconds) | |
for i in range(nseconds, 0, -1): # steep timer | |
if i % 5 == 0 or i < 5: | |
print(i) | |
time.sleep(1) | |
current_steep += 1 | |
toaster.show_toast("tea-timer.py - Steeping Done", # send windows notification | |
"Total Steepings - {}\nNext Steep Duration - {}".format(str(current_steep), str(nseconds + add)), | |
duration=8, | |
threaded=True) | |
print("TIMER DONE ({}s) - Total Steepings: ".format(last_time) + str(current_steep)) | |
custadd = input('Press enter to start next steeping ({} s)\nOr, enter a number to set additional steep time.> '.format(str(nseconds + add))) | |
if (custadd != ''): | |
cust_add = int(custadd) | |
os.system('cls') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment