Skip to content

Commit af4eacd

Browse files
committed
Reset camera control to automatic at a specified time
1 parent 78ec229 commit af4eacd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

occameracontrol/__main__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

1717
import argparse
18+
import datetime
1819
import logging
1920
import sys
2021
import time
@@ -50,7 +51,7 @@ def update_agents(agents: list[Agent]):
5051
time.sleep(update_frequency)
5152

5253

53-
def control_camera(camera: Camera):
54+
def control_camera(camera: Camera, reset_hour=3):
5455
'''Control loop to trigger updating the camera position based on currently
5556
active events.
5657
'''
@@ -59,6 +60,14 @@ def control_camera(camera: Camera):
5960
f'Failed to communicate with camera {camera}')
6061
while True:
6162
with error_handler:
63+
# Reset camera to automatic control at the hour
64+
# specified in reset_hour
65+
now = datetime.datetime.now()
66+
if now.hour == reset_hour and now.minute < 1:
67+
logger.info(f'It\'s {reset_hour} o\'clock ==> Reset camera'
68+
f' control to \'automatic\'')
69+
camera.control = "automatic"
70+
camera.position = -1
6271
if camera.control == "automatic":
6372
camera.update_position()
6473
else:

0 commit comments

Comments
 (0)