Author: gwadavel
Date: 2008-12-19 16:05:28 +0100 (Fri, 19 Dec 2008)
New Revision: 3265
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/TuxMaxLight.py
Log:
says % of light at the end
test if "tgp_ip" and "tgp_port" exist
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 13:27:04 UTC (rev 3264)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/TuxMaxLight.py
2008-12-19 15:05:28 UTC (rev 3265)
@@ -25,7 +25,11 @@
"""
CHANGES
=======
-2008/10/03 - version 0.4.0:
+2008/12/19 - version 0.5:
+ - Add says the % of light at the end
+ - Test if tgp_ip and tgp_port exist
+
+2008/10/03 - version 0.4:
- Add TTS + Internalization TTS
2008/10/03 - version 0.3.1:
@@ -47,10 +51,10 @@
"""
-__author__ = " Eric Lescaudron AKA Gwadavel irc.freenode.net #tuxdroid"
+__author__ = " Eric Lescaudron AKA Gwadavel http://gwadatux.free.fr"
__appname__ = "TuxMaxLight"
-__version__ = "0.4"
-__date__ = "2008/16/03"
+__version__ = "0.5"
+__date__ = "2008/12/19"
__license__ = "GPL"
@@ -59,9 +63,6 @@
import os
from time import sleep
-tgp_ip = "127.0.0.1"
-tgp_port = 270
-
DEBUG = False
LANGUAGE = ""
@@ -79,19 +80,24 @@
if DEBUG: print os.environ['LANG']
if "fr_" in os.environ['LANG']: # french
locutor = "Julie " # Modifiez mettre "Bruno" si vous voulez
- pitch = 105
+ pitch = 95
LANGUAGE = FR
else: # english for other, change your language
locutor = "Ryan" #you can use "Heather"
- pitch = 110
+ pitch = 100
LANGUAGE = EN
tux.tts.setLocutor(locutor)
tux.tts.setPitch(pitch)
-def speak(mes):
+def message(mes):
+ """ get message from langage dictionary """
+
+ text = LANGUAGE[mes]
+ speak(text)
+
+def speak(text):
""" Tux talks """
- text = LANGUAGE[mes]
tux.mouth.open()
tux.tts.speak(text)
tux.mouth.close()
@@ -109,7 +115,7 @@
""" Search maximum light """
l_max = 0 # Light Max
- speak("search")
+ message("search")
tux.spinning.leftOnAsync((2.0), 4)
# Turn on left 2 turns, asynchrone mode
sleep(1) # wait Tux began to turn
@@ -131,14 +137,21 @@
while 1:
tux.spinning.leftOnDuring(0.1, 2)
sleep(0.1)
- l = float(tux.status.requestOne('light_level')[0])
+ lum = float(tux.status.requestOne('light_level')[0])
if DEBUG: print("Fonction stop, Light : ", l)
- if l >= l_stop:
+ if lum >= l_stop:
tux.spinning.off()
break
if DEBUG: print("I stop at : ", tux.status.requestOne('light_level')[0])
- speak("stop")
+ message("stop")
+ speak(str(int(lum)) + "%%")
+# Test if tgp_ip and tgp_port exist
+if "tgp_ip" not in os.environ:
+ tgp_ip = "127.0.0.1"
+if "tgp_port" not in os.environ:
+ tgp_port = 270
+
tux = TuxAPI(tgp_ip, tgp_port)
if tuxConnect():
@@ -153,7 +166,7 @@
tux.flippers.down()
else:
if DEBUG: print("Unplugged the charger and restart")
- speak("charger")
+ message("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