Skip to content

Commit 9fa832c

Browse files
committed
Get short & long presses on the shutter button
short+long: focus, then capture long: focus only short: capture only sel is now free for another use, such as adjusting LEDs
1 parent 98dd683 commit 9fa832c

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

adafruit_pycamera.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import struct
55
import board
66
from digitalio import DigitalInOut, Direction, Pull
7-
from adafruit_debouncer import Debouncer
7+
from adafruit_debouncer import Debouncer, Button
88
import bitmaptools
99
import busio
1010
import adafruit_lis3dh
@@ -177,7 +177,7 @@ def __init__(self) -> None:
177177

178178
self.shutter_button = DigitalInOut(board.BUTTON)
179179
self.shutter_button.switch_to_input(Pull.UP)
180-
self.shutter = Debouncer(self.shutter_button)
180+
self.shutter = Button(self.shutter_button)
181181

182182
print("reset camera")
183183
self._cam_reset = DigitalInOut(board.CAMERA_RESET)

examples/camera/code.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
3-
4-
51
import os
62
import sys
73
import time
@@ -37,9 +33,13 @@
3733

3834
pycam.keys_debounce()
3935
# test shutter button
40-
if pycam.shutter.fell:
41-
print("Shutter pressed")
42-
36+
if pycam.shutter.long_press:
37+
print("FOCUS")
38+
print(pycam.autofocus_status)
39+
pycam.autofocus()
40+
print(pycam.autofocus_status)
41+
if pycam.shutter.short_count:
42+
print("Shutter released")
4343
if pycam.mode_text == "STOP":
4444
pycam.capture_into_bitmap(last_frame)
4545
pycam.stop_motion_frame += 1
@@ -98,9 +98,6 @@
9898
except RuntimeError as e:
9999
pycam.display_message("Error\nNo SD Card", color=0xFF0000)
100100
time.sleep(0.5)
101-
if pycam.shutter.rose:
102-
print("Shutter released")
103-
104101
if pycam.card_detect.fell:
105102
print("SD card removed")
106103
pycam.unmount_sd_card()
@@ -148,8 +145,5 @@
148145
#pycam.set_resolution(pycam.resolutions[new_res])
149146
if pycam.select.fell:
150147
print("SEL")
151-
print(pycam.autofocus_status)
152-
pycam.autofocus()
153-
print(pycam.autofocus_status)
154148
if pycam.ok.fell:
155149
print("OK")

0 commit comments

Comments
 (0)