From 2a8f137034858b79d814f07a9e526653a5cd2970 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 23 Nov 2021 12:36:23 +0100 Subject: [PATCH] faster hour --- camera.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/camera.py b/camera.py index ec51d13..d14b350 100644 --- a/camera.py +++ b/camera.py @@ -178,6 +178,8 @@ class Camera: n -= step if self.abort: return + if self.hour is not None and time.gmtime().tm_hour != self.hour: + return def sequence(self, steps=[], speed=12, goto_first=True, loop=False, hour_loop=False): self.sequence_start = 0 @@ -185,7 +187,11 @@ class Camera: #self.goto_preset(steps[0], pan=100, tilt=100, zoom=100) first = steps[0] steps = steps[1:] - hour = time.gmtime().tm_hour + if hour_loop: + self.hour = time.gmtime().tm_hour + else: + self.hour = None + while True: if goto_first: if isinstance(first, dict): @@ -198,8 +204,8 @@ class Camera: self.sequence_start = t0 = time.time() for step in steps: next_hour = time.gmtime().tm_hour - if hour_loop and next_hour != hour: - hour = next_hour + if hour_loop and next_hour != self.hour: + self.hour = next_hour break self.next_target = step segment_t0 = time.time()