[Pychord-commits] r67 - in trunk: . pychord2
danilo at garage.maemo.org
danilo at garage.maemo.org
Sun Mar 23 17:16:12 EET 2008
Author: danilo
Date: 2008-03-23 17:16:12 +0200 (Sun, 23 Mar 2008)
New Revision: 67
Modified:
trunk/pychord.py
trunk/pychord2/window_show.py
Log:
- Fixing backlight problems.
- Removing backlight thread, now it stay under window.update()
Modified: trunk/pychord.py
===================================================================
--- trunk/pychord.py 2008-03-23 00:10:05 UTC (rev 66)
+++ trunk/pychord.py 2008-03-23 15:16:12 UTC (rev 67)
@@ -128,40 +128,11 @@
# main()
-from threading import Thread
+
-class Maemolight (Thread):
-
- def run(self):
-
- import osso, time
-
- osso_c = osso.Context("osso_test_device_on", "0.0.1", False)
- self.device = osso.DeviceState(osso_c)
-
- while self.Running:
- print "lights!"
- self.device.display_state_on()
+
- i = 0
- while i < 9:
- time.sleep(1)
- i +=1
- if not self.Running:
- return
-
- def cancel(self):
- self.Running = False
-
# este comando fala para o python chamar o main se estao executando o script
if __name__ == '__main__':
- lightThread = Maemolight()
- try:
- if ismaemo():
- lightThread.Running = True
- lightThread.start()
- main( sys.argv )
- except:
- print "Unspected Error"
- lightThread.cancel()
\ No newline at end of file
+ main( sys.argv )
Modified: trunk/pychord2/window_show.py
===================================================================
--- trunk/pychord2/window_show.py 2008-03-23 00:10:05 UTC (rev 66)
+++ trunk/pychord2/window_show.py 2008-03-23 15:16:12 UTC (rev 67)
@@ -64,9 +64,38 @@
pygame.event.clear()
+ self.backlight_count = 0
+ if ismaemo():
+ import osso
+ self.osso_c = osso.Context("osso_test_device_on", "0.0.1", False)
+ self.device = osso.DeviceState(self.osso_c)
+ self.device.display_state_on()
+ self.lights()
+
def onKeyPress(self, key):
if key == K_F7:
self.chordList.fontUp()
if key == K_F8:
- self.chordList.fontDown()
\ No newline at end of file
+ self.chordList.fontDown()
+
+ def update(self):
+ window.update(self)
+
+ if ismaemo():
+ # 9 seconds
+ if self.backlight_count > self.fps * 9:
+ self.lights()
+ self.backlight_count = 0
+ else:
+ self.backlight_count += 1
+
+ def lights(self):
+ print "lights!"
+ self.device.display_state_on()
+
+def ismaemo():
+ import platform
+ if platform.uname()[4] == 'armv6l':
+ return True
+ return False
\ No newline at end of file
More information about the Pychord-commits
mailing list