Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Martin <gary@garycmartin.com>2013-05-23 13:49:58 (GMT)
committer Gary Martin <gary@garycmartin.com>2013-05-23 13:49:58 (GMT)
commit5a6d5a22189b3adfb47a12b05f4445e55f9666b3 (patch)
treea32a96f775ded8dc390c197327aa665978a459aa
parentdbb19515d70f7c68a2d3e6a4233726aed7b7cba1 (diff)
Fix for SL#4506 Clock manual hand mode sometimes reports incorrect hours due to rounding errors
-rwxr-xr-xclock.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/clock.py b/clock.py
index e5fa5a1..8fc2211 100755
--- a/clock.py
+++ b/clock.py
@@ -976,7 +976,14 @@ font_desc="Sans Bold 40">%d</span></markup>') % (i + 1)
return self._active and not self.grab_hands_mode
def _get_time_from_hands_angles(self):
- hour = int(round((self._hand_angles['hour'] * 12) / (math.pi * 2))) % 12
+ """Uses the angles of the hands to generate hours and minute
+ time. Due to the small movement of the hour hand the minute hand
+ position must be used to correctly round/floor to the correct hour.
+ """
+ if self._hand_angles['minutes'] > math.pi / 30.0:
+ hour = int((self._hand_angles['hour'] * 12) / (math.pi * 2)) % 12
+ else:
+ hour = int(round((self._hand_angles['hour'] * 12) / (math.pi * 2))) % 12
if self._am_pm == 'PM':
hour += 12