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)
|
time.sleep(1)
|
||||||
print('presets loaded')
|
print('presets loaded')
|
||||||
|
|
||||||
def hour_changed(self):
|
|
||||||
return self.hour is not None and time.gmtime().tm_hour != self.hour:
|
|
||||||
|
|
||||||
def sleep(self, seconds):
|
def sleep(self, seconds):
|
||||||
n = float(seconds)
|
n = float(seconds)
|
||||||
if self.abort or self.hour_changed():
|
if self.abort:
|
||||||
return
|
return
|
||||||
while n > 0:
|
while n > 0:
|
||||||
step = min(n, 0.5)
|
step = min(n, 0.5)
|
||||||
time.sleep(step)
|
time.sleep(step)
|
||||||
n -= step
|
n -= step
|
||||||
if self.abort or self.hour_changed():
|
if self.abort:
|
||||||
return
|
return
|
||||||
|
|
||||||
def sequence(self, steps=[], speed=12, goto_first=True, loop=False, hour_loop=False):
|
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)
|
#self.goto_preset(steps[0], pan=100, tilt=100, zoom=100)
|
||||||
first = steps[0]
|
first = steps[0]
|
||||||
steps = steps[1:]
|
steps = steps[1:]
|
||||||
if hour_loop:
|
hour = time.gmtime().tm_hour
|
||||||
self.hour = time.gmtime().tm_hour
|
|
||||||
else:
|
|
||||||
self.hour = None
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if goto_first:
|
if goto_first:
|
||||||
if isinstance(first, dict):
|
if isinstance(first, dict):
|
||||||
|
@ -205,8 +198,8 @@ class Camera:
|
||||||
self.sequence_start = t0 = time.time()
|
self.sequence_start = t0 = time.time()
|
||||||
for step in steps:
|
for step in steps:
|
||||||
next_hour = time.gmtime().tm_hour
|
next_hour = time.gmtime().tm_hour
|
||||||
if hour_loop and next_hour != self.hour:
|
if hour_loop and next_hour != hour:
|
||||||
self.hour = next_hour
|
hour = next_hour
|
||||||
break
|
break
|
||||||
self.next_target = step
|
self.next_target = step
|
||||||
segment_t0 = time.time()
|
segment_t0 = time.time()
|
||||||
|
@ -250,7 +243,7 @@ class Camera:
|
||||||
last = self.status()
|
last = self.status()
|
||||||
|
|
||||||
def goto_preset(self, id, pan, tilt, zoom=1, zoom_last=False):
|
def goto_preset(self, id, pan, tilt, zoom=1, zoom_last=False):
|
||||||
if self.abort or self.hour_changed():
|
if self.abort:
|
||||||
return
|
return
|
||||||
presets = self.get_presets(True)
|
presets = self.get_presets(True)
|
||||||
if isinstance(id, str):
|
if isinstance(id, str):
|
||||||
|
@ -368,7 +361,7 @@ class Camera:
|
||||||
self.continuous(move)
|
self.continuous(move)
|
||||||
if sum(map(abs, move.values())) and not self.abort:
|
if sum(map(abs, move.values())) and not self.abort:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
if self.abort or self.hour_changed():
|
if self.abort:
|
||||||
self.continuous(self.STOP)
|
self.continuous(self.STOP)
|
||||||
return
|
return
|
||||||
self.continuous(self.STOP)
|
self.continuous(self.STOP)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user