Author: gwadavel
Date: 2008-12-23 14:19:46 +0100 (Tue, 23 Dec 2008)
New Revision: 3292
Added:
software_suite_v2/software/scripts/maxLight/branches/
software_suite_v2/software/scripts/maxLight/tags/
Removed:
software_suite_v2/software/scripts/maxLight/tuxMaxLight.py
Modified:
software_suite_v2/software/scripts/maxLight/trunk/tuxMaxLight.py
Log:
test us_ LANG
Modified: software_suite_v2/software/scripts/maxLight/trunk/tuxMaxLight.py
===================================================================
--- software_suite_v2/software/scripts/maxLight/trunk/tuxMaxLight.py
2008-12-23 13:04:54 UTC (rev 3291)
+++ software_suite_v2/software/scripts/maxLight/trunk/tuxMaxLight.py
2008-12-23 13:19:46 UTC (rev 3292)
@@ -84,7 +84,7 @@
locutor = "Bruno"
pitch = 100
LANGUAGE = FR
- elif "en" in os.environ['LANG']:
+ elif ("en_" in os.environ['LANG']) or ("us_" in os.environ['LANG']):
locutor = "Ryan"
pitch = 100
LANGUAGE = EN
Deleted: software_suite_v2/software/scripts/maxLight/tuxMaxLight.py
===================================================================
--- software_suite_v2/software/scripts/maxLight/tuxMaxLight.py 2008-12-23
13:04:54 UTC (rev 3291)
+++ software_suite_v2/software/scripts/maxLight/tuxMaxLight.py 2008-12-23
13:19:46 UTC (rev 3292)
@@ -1,168 +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
-
-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"}
-
-# Address and port of Tux HTTP Server
-tgp_ip = "127.0.0.1"
-tgp_port = 270
-
-def lang():
- """ Search LANGUAGE in os.environ """
-
- global LANGUAGE
-
- if "fr" in os.environ['LANG']:
- locutor = "Bruno"
- pitch = 100
- LANGUAGE = FR
- elif "en" in os.environ['LANG']:
- locutor = "Ryan"
- pitch = 100
- 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 lum > l_max: # Light Max ?
- l_max = lum // 1
- 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 lum >= l_stop:
- tux.spinning.off()
- break
- message("stop")
- speak(str(int(lum)) + "%%")
-
-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:
- 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