Compare commits
No commits in common. "d1e44539d5a3d292a0c5574fa24f74332c36c128" and "9c581917227f104aeccf8b7f0d899a60cbed79c2" have entirely different histories.
d1e44539d5
...
9c58191722
21
camera.py
21
camera.py
|
@ -168,18 +168,15 @@ 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 or self.hour_changed():
|
||||
if self.abort:
|
||||
return
|
||||
while n > 0:
|
||||
step = min(n, 0.5)
|
||||
time.sleep(step)
|
||||
n -= step
|
||||
if self.abort or self.hour_changed():
|
||||
if self.abort:
|
||||
return
|
||||
|
||||
def sequence(self, steps=[], speed=12, goto_first=True, loop=False, hour_loop=False):
|
||||
|
@ -188,11 +185,7 @@ class Camera:
|
|||
#self.goto_preset(steps[0], pan=100, tilt=100, zoom=100)
|
||||
first = steps[0]
|
||||
steps = steps[1:]
|
||||
if hour_loop:
|
||||
self.hour = time.gmtime().tm_hour
|
||||
else:
|
||||
self.hour = None
|
||||
|
||||
hour = time.gmtime().tm_hour
|
||||
while True:
|
||||
if goto_first:
|
||||
if isinstance(first, dict):
|
||||
|
@ -205,8 +198,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 != self.hour:
|
||||
self.hour = next_hour
|
||||
if hour_loop and next_hour != hour:
|
||||
hour = next_hour
|
||||
break
|
||||
self.next_target = step
|
||||
segment_t0 = time.time()
|
||||
|
@ -250,7 +243,7 @@ class Camera:
|
|||
last = self.status()
|
||||
|
||||
def goto_preset(self, id, pan, tilt, zoom=1, zoom_last=False):
|
||||
if self.abort or self.hour_changed():
|
||||
if self.abort:
|
||||
return
|
||||
presets = self.get_presets(True)
|
||||
if isinstance(id, str):
|
||||
|
@ -368,7 +361,7 @@ class Camera:
|
|||
self.continuous(move)
|
||||
if sum(map(abs, move.values())) and not self.abort:
|
||||
time.sleep(0.1)
|
||||
if self.abort or self.hour_changed():
|
||||
if self.abort:
|
||||
self.continuous(self.STOP)
|
||||
return
|
||||
self.continuous(self.STOP)
|
||||
|
|
Loading…
Reference in New Issue
Block a user