#!/usr/bin/python

import time, sys
sys.path.append('/opt/tuxdroid/api/python')
from tux import *
from random import randrange

# Tux speak the text   
def tux_speak(text):
    tux.cmd.mouth_open()
    tux.tts.speak(text)
    tux.cmd.mouth_close()

tux.cmd.eyes_open()
tux.cmd.leds_off()
tux.cmd.mouth_close()

while (1 == 1):
	tux.cmd.leds_off()
	tux_speak("c'est parti")
	rand = randrange(10)
	bouton = tux.event.wait_head_bt_pushed(rand)
	if (str(bouton) == "True"):
		tux_speak("trop tot")
	else:
		heure = time.clock()
		tux.cmd.leds_on()
		bouton = tux.event.wait_head_bt_pushed(9999)
		heure = time.clock() - heure
		tux_speak("Vous avez mis " + str(heure))

tux.destroy()
