Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/3208 otcamera consumes too much energy outside of recording time window #153

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions OTCamera/hardware/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def start_recording(self):
log.write("started recording")
led.rec_on()
status.recording = True
status.html_updated_after_recording = False
self._wait_recording(2)
self.capture()

Expand Down
28 changes: 12 additions & 16 deletions OTCamera/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,15 @@ def loop(self) -> None:
self._try_capture_preview()
else:
self._camera.stop_recording()
self._html_updater.update_info(
status.get_status_data(),
self._get_config_settings(),
status.recording,
status.hour_button_pressed,
status.external_power_connected,
)
if not status.html_updated_after_recording:
self._html_updater.update_info(
status.get_status_data(),
self._get_config_settings(),
status.recording,
status.hour_button_pressed,
status.external_power_connected,
)
status.html_updated_after_recording = True
sleep(0.5)

def _send_alive_signal(self) -> None:
Expand All @@ -145,9 +147,7 @@ def _send_alive_signal(self) -> None:
log.write("reset power_led_blinked", level=log.LogLevel.DEBUG)
status.power_led_blinked = False

def _try_capture_preview(
self,
) -> None:
def _try_capture_preview(self) -> None:
"""Tries capturing a preview image.

Captures a new preview image, if the current second matches the preview interval
Expand Down Expand Up @@ -181,9 +181,7 @@ def _try_capture_preview(
log.write("reset preview_taken", level=log.LogLevel.DEBUG)
status.preview_taken = False

def record(
self,
) -> None:
def record(self) -> None:
"""Run init and record loop.

Initializes the LEDs and Wifi AP.
Expand Down Expand Up @@ -216,9 +214,7 @@ def record(
finally:
self._execute_shutdown()

def _register_shutdown_action(
self,
) -> None:
def _register_shutdown_action(self) -> None:
"""Register call backs to be executed on a signal interrupt or terminate."""
# Code to execute once terminate or interrupt signal occurs
log.write("Register callbacks on SIGINT and SIGTERM", log.LogLevel.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions OTCamera/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
recording: bool = False
power_button_pressed_time: Union[dt, None] = None
wifi_button_pressed_time: Union[dt, None] = None
html_updated_after_recording: bool = False

# Button statuses
power_button_pressed: bool = False
Expand Down