-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Imports go at the top | ||
import random | ||
|
||
from microbit import * | ||
|
||
|
||
class MyImages: | ||
hourglass_start: Image = Image("99999:" "09990:" "00900:" "09090:" "90009:") | ||
|
||
hourglass_end: Image = Image("90009:" "09090:" "00900:" "09990:" "99999:") | ||
|
||
hourglass_progress_0: Image = Image("99999:" "09990:" "00900:" "09690:" "90009:") | ||
|
||
hourglass_progress_1: Image = Image("99999:" "09990:" "00900:" "09090:" "90609:") | ||
|
||
|
||
myimages = MyImages() | ||
|
||
print("INFO: Random Hourglass Timer") | ||
|
||
# Code in a 'while True:' loop repeats forever | ||
while True: | ||
seconds: int = random.randint(10, 90) | ||
display.show(myimages.hourglass_start) | ||
sleep(1000) | ||
|
||
print("INFO: starting " + str(seconds) + " second timer") | ||
for i in range(0, seconds): | ||
display.show(getattr(myimages, "hourglass_progress_" + str(i % 2))) | ||
sleep(1000) | ||
|
||
print("INFO: timer has completed") | ||
display.show(myimages.hourglass_end) | ||
sleep(1000) |