Compare commits
2 Commits
9c58191722
...
d1e44539d5
Author | SHA1 | Date | |
---|---|---|---|
d1e44539d5 | |||
2a8f137034 |
21
camera.py
21
camera.py
|
@ -168,15 +168,18 @@ class Camera:
|
|||
time.sleep(1)
|
||||
print('presets loaded')
|
||||
|
||||
def hour_changed(self):
|
||||
return self.hour is not None and time.gmtime().tm_hour != self.hour:
|
||||
|
||||
def sleep(self, seconds):
|
||||
n = float(seconds)
|
||||
if self.abort:
|
||||
if self.abort or self.hour_changed():
|
||||
return
|
||||
while n > 0:
|
||||
step = min(n, 0.5)
|
||||
time.sleep(step)
|
||||
n -= step
|
||||
if self.abort:
|
||||
if self.abort or self.hour_changed():
|
||||
return
|
||||
|
||||
def sequence(self, steps=[], speed=12, goto_first=True, loop=False, hour_loop=False):
|
||||
|
@ -185,7 +188,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 +205,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()
|
||||
|
@ -243,7 +250,7 @@ class Camera:
|
|||
last = self.status()
|
||||
|
||||
def goto_preset(self, id, pan, tilt, zoom=1, zoom_last=False):
|
||||
if self.abort:
|
||||
if self.abort or self.hour_changed():
|
||||
return
|
||||
presets = self.get_presets(True)
|
||||
if isinstance(id, str):
|
||||
|
@ -361,7 +368,7 @@ class Camera:
|
|||
self.continuous(move)
|
||||
if sum(map(abs, move.values())) and not self.abort:
|
||||
time.sleep(0.1)
|
||||
if self.abort:
|
||||
if self.abort or self.hour_changed():
|
||||
self.continuous(self.STOP)
|
||||
return
|
||||
self.continuous(self.STOP)
|
||||
|
|
Loading…
Reference in New Issue
Block a user