Commits

clach04  committed 137891e

clock time now always attempts to update on every whole second.

  • Participants
  • Parent commits 120fd81

Comments (0)

Files changed (1)

             result = callback_func(*args, **kwargs)
             if result:
                 # re-add timer
+                if not result is True:
+                    # this is not a boolean true, so assume a timer value
+                    number_of_secs = result
                 self.add(number_of_secs, callback_func, *args, **kwargs)
 
     def abort(self):
 
         display_day_text(3)
 
-        return True  # re-add to event queue
+        # Work out when to wake up for the next round/whole (non-fractional) time
+        update_display_period = 1
+        start_time = time.time()
+        future_time = floor(start_time) + update_display_period # pure float math
+        sleep_time = future_time - start_time
+        return sleep_time  # re-add to event queue
 
     def display_day_text(line_num=2):
         now = time.localtime()
         line_num = 3
         clock_str = str(datetime.datetime.now()).split('.')[0]
         d.display_text_on_line(line_num, clock_str, False, None, fg)
-        return True  # re-add to event queue
-    
+        
+        # Work out when to wake up for the next round/whole (non-fractional) time
+        update_display_period = 1
+        start_time = time.time()
+        future_time = floor(start_time) + update_display_period # pure float math
+        sleep_time = future_time - start_time
+        return sleep_time  # re-add to event queue
+
     def display_hdspace():
         line_num = 6
         num_bytes = get_free_space('/')