Author: gwadavel
Date: 2008-12-19 13:35:50 +0100 (Fri, 19 Dec 2008)
New Revision: 3261
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/TuxMaxLight.py
Log:
use tts.setEncoding()
dictionary for langage En and Fr
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/TuxMaxLight.py
===================================================================
---
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/TuxMaxLight.py
2008-12-19 12:09:48 UTC (rev 3260)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/TuxMaxLight.py
2008-12-19 12:35:50 UTC (rev 3261)
@@ -59,14 +59,19 @@
import os
from time import sleep
+tgp_ip = "127.0.0.1"
+tgp_port = 270
DEBUG = False
LANGUAGE = ""
-tgp_ip = "127.0.0.1"
-tgp_port = 270
+FR = {"search": "Je commence la recherche", "stop": "La lumière maximum est
ici",
+"charger": "Déconnectez le chargeur et relancez le programme"}
+EN = {"search": "I began research", "stop": "Light up is here",
+"charger": "Unplugged the charger and restart the program"}
+
def lang():
""" Search LANGUAGE in os.environ """
@@ -75,55 +80,52 @@
if "fr_" in os.environ['LANG']: # french
locutor = "Julie " # Modifiez mettre "Bruno" si vous voulez
pitch = 105
- LANGUAGE = "FR_"
+ LANGUAGE = FR
else: # english for other, change your language
locutor = "Ryan" #you can use "Heather"
pitch = 110
- LANGUAGE = "EN_"
+ LANGUAGE = EN
tux.tts.setLocutor(locutor)
tux.tts.setPitch(pitch)
def speak(mes):
- """ Tux talks """
+ """ Tux talks """
+
+ text = LANGUAGE[mes]
+ tux.mouth.open()
+ tux.tts.speak(text)
+ tux.mouth.close()
- FR_Search = "Je commence la recherche"
- FR_Stop = "La lumiere maximum est ici "
- FR_Charger = "Deconnectez le chargeur et relancez le programme "
- EN_Search = "I began research "
- EN_Stop = "Light up is here "
- EN_Charger = "Unplugged the charger and restart the program "
- text = eval(LANGUAGE + mes)
- tux.mouth.open()
- tux.tts.speak(text)
- tux.mouth.close()
-
def tuxConnect():
- """ Wait connected """
- tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxMaxLight', 'NONE')
- tux.server.waitConnected(10.0)
- tux.dongle.waitConnected(10.0)
- tux.radio.waitConnected(10.0)
- return tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL)
+ """ Wait connected """
+ tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxMaxLight', 'NONE')
+ tux.server.waitConnected(10.0)
+ tux.dongle.waitConnected(10.0)
+ tux.radio.waitConnected(10.0)
+ return tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL)
+
def search():
""" Search maximum light """
+
l_max = 0 # Light Max
- speak("Search")
+ speak("search")
tux.spinning.leftOnAsync((2.0), 4)
# Turn on left 2 turns, asynchrone mode
sleep(1) # wait Tux began to turn
while tux.spinning.getLeftMovingState():
# While tux spins
- l = float(tux.status.requestOne('light_level')[0]) # Light
+ lum = float(tux.status.requestOne('light_level')[0]) # Light
if DEBUG: print("Fonction search, Light : ", l)
- if l > l_max: # Light Max ?
- l_max = l // 1
+ if lum > l_max: # Light Max ?
+ l_max = lum // 1
if DEBUG: print("Fonction search, Light Max : ", l_max)
return l_max # Return Light Max
def stop(l_stop):
""" Tux stop when it finds light up Modified by ks156 who wrote light
monitor gadget for TuxDroid V1 Tux turn a little, wait and turn while
light < light max """
+
tux.spinning.leftOnAsync(0.25, 2)
sleep(1)
while 1:
@@ -135,11 +137,12 @@
tux.spinning.off()
break
if DEBUG: print("I stop at : ", tux.status.requestOne('light_level')[0])
- speak("Stop")
+ speak("stop")
tux = TuxAPI(tgp_ip, tgp_port)
if tuxConnect():
+ tux.tts.setEncoding(encoding='utf-8')
lang()
# Test if charger are plugged
if tux.status.requestOne('charger_state')[0] == 'UNPLUGGED':
@@ -150,7 +153,7 @@
tux.flippers.down()
else:
if DEBUG: print("Unplugged the charger and restart")
- speak("Charger")
+ speak("charger")
tux.access.release()
tux.server.disconnect()
tux.destroy()
------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn