Skip to content

Commit

Permalink
more timelapse!
Browse files Browse the repository at this point in the history
  • Loading branch information
ladyada committed Jan 27, 2024
1 parent 40ff754 commit ad34c6c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
6 changes: 4 additions & 2 deletions adafruit_pycamera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,13 @@ def make_camera_ui(self):

self._timelapsebar = displayio.Group(x=0, y=180)

Check failure on line 290 in adafruit_pycamera/__init__.py

View workflow job for this annotation

GitHub Actions / test

Attribute '_timelapsebar' defined outside __init__
self._timelapse_rate_label = label.Label(

Check failure on line 291 in adafruit_pycamera/__init__.py

View workflow job for this annotation

GitHub Actions / test

Attribute '_timelapse_rate_label' defined outside __init__
terminalio.FONT, text="Time", color=0xFFFFFF, x=150, y=10, scale=2
terminalio.FONT, text="Time", color=0xFFFFFF,x=90, y=10, scale=2
)
self._timelapse_rate_label.background_color = None
self._timelapsestatus_label = label.Label(

Check failure on line 295 in adafruit_pycamera/__init__.py

View workflow job for this annotation

GitHub Actions / test

Attribute '_timelapsestatus_label' defined outside __init__
terminalio.FONT, text="Status", color=0xFFFFFF, x=0, y=10, scale=2
)
self._timelapsestatus_label.background_color = None
self._timelapsebar.append(self._timelapse_rate_label)
self._timelapsebar.append(self._timelapsestatus_label)

Expand Down Expand Up @@ -493,7 +495,7 @@ def select_setting(self, setting_name):
self._mode_label.color = 0xFFFFFF
self._mode_label.background_color = 0x0
self._timelapse_rate_label.color = 0xFFFFFF
self._timelapse_rate_label.background_color = 0x0
self._timelapse_rate_label.background_color = None

if setting_name == "effect":
self._effect_label.color = 0x0
Expand Down
27 changes: 24 additions & 3 deletions examples/camera/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Unlicense

import time

import math
import bitmaptools
import displayio
import gifio
Expand All @@ -22,6 +22,7 @@
last_frame = displayio.Bitmap(pycam.camera.width, pycam.camera.height, 65535)
onionskin = displayio.Bitmap(pycam.camera.width, pycam.camera.height, 65535)
timelapse_remaining = None
timelapse_timestamp = None

while True:
if pycam.mode_text == "STOP" and pycam.stop_motion_frame != 0:
Expand All @@ -41,10 +42,24 @@
pycam._timelapse_rate_label.text = pycam._timelapse_rate_label.text
if timelapse_remaining is None:
pycam._timelapsestatus_label.text = "STOP"
#pycam.display_message("Timelapse\nNot Running\nPress Select to set timing")
else:
pycam.display_message("%d Seconds left", timelapse_remaining)
timelapse_remaining = timelapse_timestamp - time.time()
pycam._timelapsestatus_label.text = f"{timelapse_remaining}s / "
pycam.display.refresh()

if timelapse_remaining is not None and timelapse_remaining <= 0:

Check failure on line 50 in examples/camera/code.py

View workflow job for this annotation

GitHub Actions / test

Access to a protected member _timelapse_rate_label of a client class

Check failure on line 50 in examples/camera/code.py

View workflow job for this annotation

GitHub Actions / test

Access to a protected member _timelapse_rate_label of a client class
#pycam.tone(200, 0.1) # uncomment to add a beep when a photo is taken
try:
pycam.display_message("Snap!", color=0x0000FF)
pycam.capture_jpeg()
except TypeError as e:
pycam.display_message("Failed", color=0xFF0000)
time.sleep(0.5)
except RuntimeError as e:
pycam.display_message("Error\nNo SD Card", color=0xFF0000)
time.sleep(0.5)
pycam.live_preview_mode()
timelapse_timestamp = time.time() + pycam.timelapse_rates[pycam.timelapse_rate] + 1
else:
pycam.blit(pycam.continuous_capture())
# print("\t\t", capture_time, blit_time)
Expand Down Expand Up @@ -193,3 +208,9 @@
print("SEL")
if pycam.ok.fell:
print("OK")
if pycam.mode_text == "LAPS":
if timelapse_remaining is None: # stopped
timelapse_remaining = pycam.timelapse_rates[pycam.timelapse_rate]
timelapse_timestamp = time.time() + timelapse_remaining + 1
else: # is running, turn off
timelapse_remaining = None

0 comments on commit ad34c6c

Please sign in to comment.