[Pychord-commits] r65 - trunk/pychord2

danilo at garage.maemo.org danilo at garage.maemo.org
Sun Mar 23 01:27:16 EET 2008


Author: danilo
Date: 2008-03-23 01:27:15 +0200 (Sun, 23 Mar 2008)
New Revision: 65

Modified:
   trunk/pychord2/__init__.py
Log:
- fixing backlight

Modified: trunk/pychord2/__init__.py
===================================================================
--- trunk/pychord2/__init__.py	2008-03-22 23:00:04 UTC (rev 64)
+++ trunk/pychord2/__init__.py	2008-03-22 23:27:15 UTC (rev 65)
@@ -28,11 +28,14 @@
         
         self.pyc = pyc
         
-        if fullscreen or True:  
-            m = Maemolight()
-            m.start()
+        if fullscreen:  
+            self.lightThread = Maemolight()
+
         
+        self.fullscreen = fullscreen
         
+        
+        
     def loop(self):
         """
             This is application main loop
@@ -44,16 +47,29 @@
         del(window)
         
 
-from threading import Thread
+    def __del__(self):
+        self.lightThread.cancel()
 
-class Maemolight(Thread):
+from threading import Timer
+
     
-    def run ( self ):
-        
+class Maemolight ():
+    
+    def __init__(self):
         import osso, time
         osso_c = osso.Context("osso_test_device_on", "0.0.1", False)
-        device = osso.DeviceState(osso_c)
-        while True:
-            device.display_state_on()
-            time.sleep(15)
+        self.device = osso.DeviceState(osso_c)
+        
+        self.t = Timer(9.0, self.run)
+        self.t.start() # after 30 seconds, "hello, world" will be printed
+    
+    def run(self):
+        print "Light!"
+        self.device.display_state_on()
+
+            
+    def cancel(self):
+        self.t.cancel()
+        print "Cancelando"
+    
                 
\ No newline at end of file



More information about the Pychord-commits mailing list