|
2009-01-08
, 00:11
|
|
Posts: 4,672 |
Thanked: 5,455 times |
Joined on Jul 2008
@ Springfield, MA, USA
|
#102
|
Syncing in user space should be simple. The following psuedo code would cost very little and makes the reasonable assumption that sleeping will take no less than 60 seconds and no more than a 120 seconds.
Code:def clock_update(): while not_done: now = get_system_time_in_seconds() update_clock (now) sleep_time = 60 - now MOD 60 sleep_for_seconds (sleep_time) clock_update_thread = threading.Thread (target=clock_update) clock_update_thread.start()
The Following User Says Thank You to danramos For This Useful Post: | ||
|
2009-01-08
, 00:24
|
|
Posts: 2,427 |
Thanked: 2,986 times |
Joined on Dec 2007
|
#103
|
Oooo.. true.. true. This would still use sleep, free up CPU cycles AND consistently keep the clock very reasonably accurate. This goes around the whole need for dillying with interrupts.
Simple and effective. I love it.
|
2009-01-08
, 14:23
|
Posts: 631 |
Thanked: 837 times |
Joined on May 2007
@ Milton, Ontario, Canada
|
#104
|
Syncing in user space should be simple. The following psuedo code would cost very little and makes the reasonable assumption that sleeping will take no less than 60 seconds and no more than a 120 seconds.
Code:def clock_update(): while not_done: now = get_system_time_in_seconds() update_clock (now) sleep_time = 60 - now MOD 60 sleep_for_seconds (sleep_time) clock_update_thread = threading.Thread (target=clock_update) clock_update_thread.start()
ctime = time.ctime() pygame.time.set_timer(DRAW_CLOCK_EVENT,(60-int(str(ctime[17])+str(ctime[18])))*1000)
if timesixty == False: pygame.time.set_timer(DRAW_CLOCK_EVENT, 60000) timesixty = True
elif event.type == DRAW_CLOCK_EVENT: #Clear the current timer pygame.time.set_timer(DRAW_CLOCK_EVENT, 0) if ci.fcmode==0: #Redraw the clock only ci_gfx.drawclock() # when is visible else: ci_gfx.drawalarm() # no need to redrawm, anyway in not cheap #recalculate time until next second and reset delay as required ctime = time.ctime() pygame.time.set_timer(DRAW_CLOCK_EVENT, (60-int(str(ctime[17])+str(ctime[18])))*1000)
def state_cb(shutdown, save_unsaved_data, memory_low, system_inactivity, message, loop): print "System Inactivity: ", system_inactivity if system_inactivity: #Clear the current timer pygame.time.set_timer(DRAW_CLOCK_EVENT, 0) else: #make the update and stuff happen now pygame.time.set_timer(DRAW_CLOCK_EVENT, 10) return False osso_c = osso.Context("flip_clock", "0.7", False) device = osso.DeviceState(osso_c) device.set_device_state_callback(state_cb, system_inactivity=True, user_data=None)
The Following User Says Thank You to jolouis For This Useful Post: | ||
|
2009-01-08
, 14:29
|
|
Posts: 334 |
Thanked: 366 times |
Joined on Nov 2008
@ Italy
|
#105
|
|
2009-01-08
, 14:41
|
Posts: 631 |
Thanked: 837 times |
Joined on May 2007
@ Milton, Ontario, Canada
|
#106
|
The Following User Says Thank You to jolouis For This Useful Post: | ||
|
2009-01-08
, 15:36
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#107
|
Since is 'real'work in progress (Im still not sure if the clock and the alarm works , and this for a clock/alarm program is probably bad...) I thinked that the app didnt deserve a debianizing (and since I write using shortcuts, tricks, weirdo technics is a pain to try to packagin it everytime (I still have no clue and since now qwerty12 made up all the packagings, and make realize that is not a so simple task. I ll try to release the long promised plain naked optimized version and ask to qwerty12 to do the job and ask to the maemo folks to promote to extra and give to everyone on the thread the credits they deserve and have the satisfaction to see the thing finally in the wild.
Peace and love, peace and love
The Following User Says Thank You to qwerty12 For This Useful Post: | ||
|
2009-01-08
, 15:59
|
|
Posts: 334 |
Thanked: 366 times |
Joined on Nov 2008
@ Italy
|
#108
|
|
2009-01-08
, 16:51
|
|
Posts: 334 |
Thanked: 366 times |
Joined on Nov 2008
@ Italy
|
#109
|
I'd found some suggestions about utilizing the power management/monitoring stuff from Kagu as well;
http://kagumedia.com/projects/kagu/b.../kagu/maemo.py
... with integrated system alarmd functionality and full power management ...
The Following User Says Thank You to ciroip For This Useful Post: | ||
|
2009-01-08
, 19:02
|
Posts: 631 |
Thanked: 837 times |
Joined on May 2007
@ Milton, Ontario, Canada
|
#110
|
I am waiting for someone came up with a comment about the advantages to use the alarmd. My (limited) experience is that the daemon is not really reliable. It hang and there is no easy way to be sure if the thing is running or whatever. My actual approach here is: if the application is running the alarm works, otherwise 'ciccia', no alarm.
N9: Go white or go home