-
Notifications
You must be signed in to change notification settings - Fork 2
/
pibooth_extra_lights.py
75 lines (55 loc) · 2.66 KB
/
pibooth_extra_lights.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- coding: utf-8 -*-
"""Pibooth plugin for extra lights management."""
import pibooth
from gpiozero import LEDBoard
__version__ = "1.0.2"
@pibooth.hookimpl
def pibooth_configure(cfg):
"""Declare the new configuration options"""
cfg.add_option('CONTROLS', 'startup_led_pin', 29,
"Physical GPIO OUT pin to light a LED at pibooth startup (list of pins accepted)")
cfg.add_option('CONTROLS', 'startup_led_active_high', True,
"If True, startup LED is lighting by setting pin(s) to HIGH else by setting to LOW")
cfg.add_option('CONTROLS', 'preview_led_pin', 31,
"Physical GPIO OUT pin to light a LED during the entire capture sequence (list of pins accepted)")
cfg.add_option('CONTROLS', 'preview_led_active_high', True,
"If True, preview LED is lighting by setting pin(s) to HIGH else by setting to LOW")
cfg.add_option('CONTROLS', 'flash_led_pin', 33,
"Physical GPIO OUT pin to light a LED when the capture is taken (list of pins accepted)")
cfg.add_option('CONTROLS', 'flash_led_active_high', True,
"If True, flash LED is lighting by setting pin(s) to HIGH else by setting to LOW")
@pibooth.hookimpl
def pibooth_startup(app, cfg):
"""Create the LED instances.
.. note:: gpiozero is configured as BCM, use a string with "BOARD" to
use BOARD pin numbering.
"""
app.led_startup = LEDBoard(*("BOARD{}".format(pin)
for pin in cfg.gettuple('CONTROLS', 'startup_led_pin', int)),
active_high=cfg.getboolean('CONTROLS', 'startup_led_active_high'))
app.led_sequence = LEDBoard(*("BOARD{}".format(pin)
for pin in cfg.gettuple('CONTROLS', 'preview_led_pin', int)),
active_high=cfg.getboolean('CONTROLS', 'preview_led_active_high'))
app.led_flash = LEDBoard(*("BOARD{}".format(pin)
for pin in cfg.gettuple('CONTROLS', 'flash_led_pin', int)),
active_high=cfg.getboolean('CONTROLS', 'flash_led_active_high'))
# Initial state
app.led_startup.on()
app.led_sequence.off()
app.led_flash.off()
@pibooth.hookimpl
def state_preview_enter(app):
"""Start a new capture sequence."""
app.led_sequence.on()
@pibooth.hookimpl
def state_capture_enter(app):
"""Ready to take a capture."""
app.led_flash.on()
@pibooth.hookimpl
def state_capture_exit(app):
"""A capture has been taken."""
app.led_flash.off()
@pibooth.hookimpl
def state_processing_enter(app):
"""The capture sequence is done."""
app.led_sequence.off()