Author: remi
Date: 2009-03-12 12:09:30 +0100 (Thu, 12 Mar 2009)
New Revision: 3986

Added:
   
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/tuxdroid/Light.py
Modified:
   
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/TuxAPI.py
Log:
* added light class to interact with the light level

Modified: 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/TuxAPI.py
===================================================================
--- 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/TuxAPI.py
  2009-03-12 11:08:54 UTC (rev 3985)
+++ 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/TuxAPI.py
  2009-03-12 11:09:30 UTC (rev 3986)
@@ -29,6 +29,7 @@
 from tuxdroid.Flippers import Flippers
 from tuxdroid.Spinning import Spinning
 from tuxdroid.Framework import Framework
+from tuxdroid.Light import Light
 
 # 
------------------------------------------------------------------------------
 # Tux Droid API.
@@ -80,6 +81,8 @@
         self.flippers = Flippers(self, self.server)
         # Create the spinning object
         self.spinning = Spinning(self, self.server)
+        # Create the light object
+        self.light = Light(self, self.server)
         # Create the framework object
         self.framework = Framework(self, self.server)
         # Initialize the helper

Added: 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/tuxdroid/Light.py
===================================================================
--- 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/tuxdroid/Light.py
                          (rev 0)
+++ 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/tuxdroid/Light.py
  2009-03-12 11:09:30 UTC (rev 3986)
@@ -0,0 +1,68 @@
+# -*- coding: latin1 -*-
+
+#    Copyright (C) 2009 C2ME Sa
+#    Remi Jocaille <[email protected]>
+#    Distributed under the terms of the GNU General Public License
+#    http://www.gnu.org/copyleft/gpl.html
+
+from base.ApiBaseChildResource import ApiBaseChildResource
+from base.const.ConstClient import *
+from const.ConstTuxDriver import *
+
+# 
------------------------------------------------------------------------------
+# Class to interact with the light sensor.
+# 
------------------------------------------------------------------------------
+class Light(ApiBaseChildResource):
+    """Class to interact with the light sensor.
+    """
+
+    # 
--------------------------------------------------------------------------
+    # Constructor of the class.
+    # 
--------------------------------------------------------------------------
+    def __init__(self, apiBase, apiBaseServer):
+        """Constructor of the class.
+        @param apiBase: ApiBase parent object.
+        @param apiBaseServer: ApiBaseServer object.
+        """
+        ApiBaseChildResource.__init__(self, apiBase, apiBaseServer)
+
+    # 
--------------------------------------------------------------------------
+    # Register a callback on the light level event.
+    # 
--------------------------------------------------------------------------
+    def registerEventOnLightChange(self, funct, idx = None):
+        """Register a callback on the light level event.
+        Not available for CLIENT_LEVEL_ANONYME level.
+        @param funct: pointer to the function.
+        @param idx: index from a previous register.
+        @return: the new index of the callback in the handler.
+        """
+        if self.getServer().getClientLevel() == CLIENT_LEVEL_ANONYME:
+            return -1
+        self._syndicateEvent(ST_NAME_LIGHT_LEVEL)
+        nIdx = self._registerEvent(ST_NAME_LIGHT_LEVEL, None, funct, idx)
+        return nIdx
+
+    # 
--------------------------------------------------------------------------
+    # Unregister a callback from the the light level event.
+    # 
--------------------------------------------------------------------------
+    def unregisterEventOnLightChange(self, idx):
+        """Unregister a callback from the light level event.
+        Not available for CLIENT_LEVEL_ANONYME level.
+        @param idx: index from a previous register.
+        """
+        if self.getServer().getClientLevel() == CLIENT_LEVEL_ANONYME:
+            return
+        self._unregisterEvent(ST_NAME_LIGHT_LEVEL, idx)
+
+    # 
--------------------------------------------------------------------------
+    # Return the current level of the light.
+    # 
--------------------------------------------------------------------------
+    def getLevel(self):
+        """Return the current level of the light.
+        @return: A float.
+        """
+        self._syndicateEvent(ST_NAME_LIGHT_LEVEL)
+        value = self._requestOne(ST_NAME_LIGHT_LEVEL)
+        if value != None:
+            return eval(value)
+        return 0.0


Property changes on: 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/tuxdroid/Light.py
___________________________________________________________________
Name: svn:keywords
   + Id


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to