Author: gwadavel
Date: 2008-12-19 23:37:24 +0100 (Fri, 19 Dec 2008)
New Revision: 3268
Added:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
Removed:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/TuxMaxLight.py
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/fr.po
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
Log:
rename script - add tgp variables for language
Deleted:
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 22:37:03 UTC (rev 3267)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/TuxMaxLight.py
2008-12-19 22:37:24 UTC (rev 3268)
@@ -1,172 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# -----------------------------------------------------------------------------
-# Tux search and stop at the maximum light
-#
-# 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
-=======
-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:
- - Add charger test
-
-2008/10/03 - version 0.3:
- - Function stop modified by ks156
-
-2008/10/02 - version 0.2:
- - add DEBUG
-
-2008/10/02 - version 0.1:
- - Initial version
-
-TODO LIST
-=========
-- Add comments
-
-
-"""
-
-__author__ = " Eric Lescaudron AKA Gwadavel http://gwadatux.free.fr"
-__appname__ = "TuxMaxLight"
-__version__ = "0.5"
-__date__ = "2008/12/19"
-__license__ = "GPL"
-
-
-
-from tuxisalive.api import *
-import os
-from time import sleep
-
-DEBUG = False
-LANGUAGE = ""
-
-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 """
-
- global LANGUAGE
- if DEBUG: print os.environ['LANG']
- if "fr_" in os.environ['LANG']: # french
- locutor = "Julie " # Modifiez mettre "Bruno" si vous voulez
- pitch = 95
- LANGUAGE = FR
- else: # english for other, change your language
- locutor = "Ryan" #you can use "Heather"
- pitch = 100
- LANGUAGE = EN
- tux.tts.setLocutor(locutor)
- tux.tts.setPitch(pitch)
-
-def message(mes):
- """ get message from langage dictionary """
-
- text = LANGUAGE[mes]
- speak(text)
-
-def speak(text):
- """ Tux talks """
-
- 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)
-
-def search():
- """ Search maximum light """
-
- l_max = 0 # Light Max
- message("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
- lum = float(tux.status.requestOne('light_level')[0]) # Light
- if DEBUG: print("Fonction search, Light : ", l)
- 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:
- tux.spinning.leftOnDuring(0.1, 2)
- sleep(0.1)
- lum = float(tux.status.requestOne('light_level')[0])
- if DEBUG: print("Fonction stop, Light : ", l)
- if lum >= l_stop:
- tux.spinning.off()
- break
- if DEBUG: print("I stop at : ", tux.status.requestOne('light_level')[0])
- 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():
- tux.tts.setEncoding(encoding='utf-8')
- lang()
- # Test if charger are plugged
- if tux.status.requestOne('charger_state')[0] == 'UNPLUGGED':
- tux.eyes.open()
- tux.flippers.up()
- light = search() # search light up
- stop(light) # stop
- tux.flippers.down()
- else:
- if DEBUG: print("Unplugged the charger and restart")
- message("charger")
-tux.access.release()
-tux.server.disconnect()
-tux.destroy()
Added:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
===================================================================
---
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
(rev 0)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
2008-12-19 22:37:24 UTC (rev 3268)
@@ -0,0 +1,179 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# -----------------------------------------------------------------------------
+# Tux search and stop at the maximum light
+#
+# 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
+=======
+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:
+ - Add charger test
+
+2008/10/03 - version 0.3:
+ - Function stop modified by ks156
+
+2008/10/02 - version 0.2:
+ - add DEBUG
+
+2008/10/02 - version 0.1:
+ - Initial version
+
+TODO LIST
+=========
+- Add comments
+
+
+"""
+
+__author__ = " Eric Lescaudron AKA Gwadavel http://gwadatux.free.fr"
+__appname__ = "TuxMaxLight"
+__version__ = "0.5"
+__date__ = "2008/12/19"
+__license__ = "GPL"
+
+
+
+from tuxisalive.api import *
+import os
+from time import sleep
+
+DEBUG = False
+LANGUAGE = ""
+
+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 """
+
+ global LANGUAGE
+ if DEBUG:
+ print os.environ['tgp_language']
+
+ if "fr" == os.environ['tgp_language']:
+ locutor = os.environ['tgp_locutor']
+ pitch = os.environ['tgp_pitch']
+ LANGUAGE = FR
+ elif "en" == os.environ['tgp_language']:
+ locutor = os.environ['tgp_locutor']
+ pitch = os.environ['tgp_pitch']
+ LANGUAGE = EN
+ else: # for other language
+ locutor = "Ryan"
+ pitch = 100
+ LANGUAGE = EN
+ tux.tts.setLocutor(locutor)
+ tux.tts.setPitch(pitch)
+
+def message(mes):
+ """ get message from langage dictionary """
+
+ text = LANGUAGE[mes]
+ speak(text)
+
+def speak(text):
+ """ Tux talks """
+
+ 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)
+
+def search():
+ """ Search maximum light """
+
+ l_max = 0 # Light Max
+ message("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
+ lum = float(tux.status.requestOne('light_level')[0]) # Light
+ if DEBUG: print("Fonction search, Light : ", l)
+ 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:
+ tux.spinning.leftOnDuring(0.1, 2)
+ sleep(0.1)
+ lum = float(tux.status.requestOne('light_level')[0])
+ if DEBUG: print("Fonction stop, Light : ", l)
+ if lum >= l_stop:
+ tux.spinning.off()
+ break
+ if DEBUG: print("I stop at : ", tux.status.requestOne('light_level')[0])
+ 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():
+ tux.tts.setEncoding(encoding='utf-8')
+ lang()
+
+ # Test if charger are plugged
+ if tux.status.requestOne('charger_state')[0] == 'UNPLUGGED':
+ tux.eyes.open()
+ tux.flippers.up()
+ light = search() # search light up
+ stop(light) # stop
+ tux.flippers.down()
+ else:
+ if DEBUG: print("Unplugged the charger and restart")
+ message("charger")
+tux.access.release()
+tux.server.disconnect()
+tux.destroy()
Property changes on:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
___________________________________________________________________
Name: svn:executable
+ *
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/fr.po
===================================================================
---
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/fr.po
2008-12-19 22:37:03 UTC (rev 3267)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/fr.po
2008-12-19 22:37:24 UTC (rev 3268)
@@ -1,5 +1,5 @@
-msgid "Max light"
-msgstr "Lumière maximum"
+msgid "Gadget Max light"
+msgstr "Gadget Lumière maximum"
msgid "Tux seeks maximum light"
msgstr "Tux cherche la lumière maximum"
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
===================================================================
---
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
2008-12-19 22:37:03 UTC (rev 3267)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
2008-12-19 22:37:24 UTC (rev 3268)
@@ -1,4 +1,4 @@
-msgid "Max light"
+msgid "Gadget Max light"
msgstr ""
msgid "Tux seeks maximum light"
------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn