Author: jerome
Date: 2009-04-10 14:28:31 +0200 (Fri, 10 Apr 2009)
New Revision: 4464
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
Log:
* Tux is now spinning slower for light research.
* Added a tts messages.
* Modified 'last modified' and 'version'
Modified:
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
2009-04-10 12:22:17 UTC (rev 4463)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
2009-04-10 12:28:31 UTC (rev 4464)
@@ -27,7 +27,8 @@
=======
2009/12/03 - version 0.6
- Updated the gadget to work with the control center.
-2008/12/19 - version 0.5:
+
+2008/19/12 - version 0.5:
- Add says the % of light at the end
- Test if tgp_ip and tgp_port exist
@@ -55,8 +56,8 @@
__author__ = " Eric Lescaudron AKA Gwadavel http://gwadatux.free.fr"
__appname__ = "TuxMaxLight"
-__version__ = "0.5"
-__date__ = "2008/12/19"
+__version__ = "0.6"
+__date__ = "2009/12/03"
__license__ = "GPL"
@@ -86,38 +87,48 @@
return tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL)
+
def search():
'''
Search maximum light
'''
-
+
l_max = 0 # Light Max
- tux.spinning.leftOnAsync((2.0), 4)
+ tux.spinning.leftOnAsync(2.0, speed = SPV_NORMAL)
+
# 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)
+ tux.spinning.leftOnAsync(0.25, speed=SPV_VERYSLOW)
+
sleep(1)
+
while 1:
- tux.spinning.leftOnDuring(0.1, 2)
- sleep(0.1)
+ tux.spinning.leftOnDuring(0.1, speed=1)
+ sleep(0.3)
lum = float(tux.status.requestOne('light_level')[0])
+ print lum
if lum >= l_stop:
tux.spinning.off()
break
+
message("Light up is here")
message(str(int(lum)) + "%%")
@@ -126,12 +137,14 @@
tgp_ip = "127.0.0.1"
tgp_port = 270
+
if "tgp_language" in os.environ:
tgp_language = os.environ["tgp_language"]
# Test if tgp_ip and tgp_port exist
if "tgp_ip" in os.environ:
tgp_ip = os.environ["tgp_ip"]
+
if "tgp_port" in os.environ:
tgp_port = int(os.environ["tgp_port"])
@@ -141,13 +154,16 @@
# Test if charger are plugged
if tux.status.requestOne('charger_state')[0] == 'UNPLUGGED':
+ message("I begun the research")
tux.eyes.open()
tux.flippers.up()
light = search() # search light up
stop(light) # stop
tux.flippers.down()
+
else:
- message("Unplugged the charger and restart the program")
+ message("Unplug the charger and restart the program")
+
tux.access.release()
tux.server.disconnect()
tux.destroy()
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn