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()
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)