Added timer script
This commit is contained in:
38
rpi/lcd-screen/main.py
Normal file
38
rpi/lcd-screen/main.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#import lcd
|
||||
import time
|
||||
|
||||
whiteTime = 5 * 60
|
||||
blackTime = 5 * 60
|
||||
current = "white"
|
||||
|
||||
def compute_seconds(total_seconds):
|
||||
return total_seconds % 60
|
||||
|
||||
def compute_minutes(total_seconds):
|
||||
return total_seconds // 60
|
||||
|
||||
def update_timer(whiteSeconds, blackSeconds):
|
||||
white_minutes = compute_minutes(whiteSeconds)
|
||||
white_seconds = compute_seconds(whiteSeconds)
|
||||
|
||||
black_minutes = compute_minutes(blackSeconds)
|
||||
black_seconds = compute_seconds(blackSeconds)
|
||||
|
||||
print(f"W {white_minutes:02d}:{white_seconds:02d} || B {black_minutes:02d}:{black_seconds:02d}")
|
||||
#lcd.setText(f"W {white_minutes:02d}:{white_seconds:02d} || B {black_minutes:02d}:{black_seconds:02d}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
while whiteTime > 0 and blackTime > 0:
|
||||
currentTime = 0
|
||||
if current == "white":
|
||||
current = "black"
|
||||
whiteTime -= 1
|
||||
else:
|
||||
current = "white"
|
||||
blackTime -= 1
|
||||
|
||||
update_timer(whiteTime, blackTime)
|
||||
time.sleep(1)
|
||||
|
||||
#lcd.setText("Time up!")
|
||||
Reference in New Issue
Block a user