from mangobox import Mango
import random
from threading import Lock

m = Mango(mode="hardware")
round_lock = Lock()
def play():
    with round_lock:
        numbers = [random.randint(1, 7) for _ in range(3)]
        won = numbers == [7, 7, 7]
        m.clear()
        m.text(" ".join(map(str, numbers)), 10, 20)
        m.led_all("#00FF00" if won else "#FF7A00")
        m.beep()

m.clear()
m.text("Press to play", 0, 0)
m.when_pressed("button", play)
m.start_button(100)
m.run_forever()
