#!/usr/bin/python
# -*- coding: UTF8 -*-

# Say time fr
#Un programme qui vous rappelera l'heure toutes les 30 minutes ou en appuyant sur le bouton de la tête.
#Pour l'arrêter il suffit d'utiliser le bouton marche/arrêt de la télécommande.
#
#This small script will remind you not to work to late by saying current time every 30 minutes or when you push
#tux head button.
#To stop the script, simply push the  start/stop button (the red one) on the remote controler.



# -----------------------------------------------------------------------------
# Tux Droid - Saytime
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# -----------------------------------------------------------------------------
# $Id: $
# -----------------------------------------------------------------------------

"""
CHANGES
=======
2007/06/28 - version 0.0.1:
    - Initial version
      -tux say current time when launching the script
      -tux say current time every 30 minutes
      -tux say current time when head button pressed
      -you can stop it by using the start/stop button of the IR remote
"""

__author__  = "Oswald-p <oswaldpp@yahoo.fr>"
__appname__ = "Say_time_fr"
__version__ = "0.0.1"
__date__    = "2007/06/28"
__license__ = "GPL"



# -----------------------------------------------
# Initalization of modules
# uses objects "tux" and "tss"
# -----------------------------------------------
import sys
sys.path.append('/opt/tuxdroid/api/python')
from tux import *
import time

# -----------------------------------------------
# Script
# -----------------------------------------------

# initialization
tux.cmd.mouth_close()
tux.cmd.eyes_open()
tux.cmd.leds_off()
minute = 0
sayit = 0

# time read
def saytime():
	tux.tts.select_voice_fr_male_tuxed();
	tux.cmd.mouth_open();
	tux.tts.speak("Il est %d heure et %d minutes."%(time.localtime()[3],time.localtime()[4]));
	tux.cmd.mouth_close();

# body
saytime()
tux.event.on_head_bt_pushed=saytime
tux.sys.add_time_event(CT_FUNCTION,saytime,9999,99,99,99,30,0)
tux.sys.add_time_event(CT_FUNCTION,saytime,9999,99,99,99,60,0)

# -----------------------------------------------
# End of script
# -----------------------------------------------
tux.event.wait_remote_bt(K_STANDBY,9999)
tux.destroy()
