pibooth-forget-button 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: pibooth_forget_button
3
+ Version: 1.0.0
4
+ Summary: Pibooth plugin to add a third button for forgetting photos
5
+ Home-page: https://github.com/ceeeeb/pibooth-forget-button
6
+ Author: Ceeeeb
7
+ License: MIT license
8
+ Keywords: Raspberry Pi,photobooth,pibooth,button
9
+ Platform: unix
10
+ Platform: linux
11
+ Requires-Dist: pibooth>=2.0.0
12
+ Dynamic: author
13
+ Dynamic: description
14
+ Dynamic: home-page
15
+ Dynamic: keywords
16
+ Dynamic: license
17
+ Dynamic: platform
18
+ Dynamic: requires-dist
19
+ Dynamic: summary
20
+
21
+ Adds a dedicated GPIO button to move photos to the forget folder
@@ -0,0 +1,42 @@
1
+ # pibooth-forget-button
2
+
3
+ Plugin for [pibooth](https://github.com/pibooth/pibooth) adding a third button to "forget" photos.
4
+
5
+ ## Features
6
+
7
+ - Dedicated GPIO button to move photos to a "forget" folder
8
+ - LED indicator that blinks during print state
9
+ - Displays "Photo oubliee !" on screen when a photo is forgotten
10
+ - Works during both print and wait states
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install pibooth-forget-button
16
+ ```
17
+
18
+ ## Configuration
19
+
20
+ In the file `~/.config/pibooth/pibooth.cfg`, add:
21
+
22
+ ```ini
23
+ [FORGET_BUTTON]
24
+ # GPIO IN pin for the button (BOARD numbering, 0 to disable)
25
+ forget_btn_pin = 36
26
+
27
+ # GPIO OUT pin for the LED (0 to disable)
28
+ forget_led_pin = 37
29
+
30
+ # Button press duration in seconds
31
+ debounce_delay = 0.3
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ 1. Take a photo with pibooth
37
+ 2. During the print screen (when the LED blinks), press the forget button
38
+ 3. The photo will be moved to the `forget/` subfolder and "Photo oubliee !" message will be displayed
39
+
40
+ ## License
41
+
42
+ MIT
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: pibooth_forget_button
3
+ Version: 1.0.0
4
+ Summary: Pibooth plugin to add a third button for forgetting photos
5
+ Home-page: https://github.com/ceeeeb/pibooth-forget-button
6
+ Author: Ceeeeb
7
+ License: MIT license
8
+ Keywords: Raspberry Pi,photobooth,pibooth,button
9
+ Platform: unix
10
+ Platform: linux
11
+ Requires-Dist: pibooth>=2.0.0
12
+ Dynamic: author
13
+ Dynamic: description
14
+ Dynamic: home-page
15
+ Dynamic: keywords
16
+ Dynamic: license
17
+ Dynamic: platform
18
+ Dynamic: requires-dist
19
+ Dynamic: summary
20
+
21
+ Adds a dedicated GPIO button to move photos to the forget folder
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pibooth_forget_button.py
3
+ setup.py
4
+ pibooth_forget_button.egg-info/PKG-INFO
5
+ pibooth_forget_button.egg-info/SOURCES.txt
6
+ pibooth_forget_button.egg-info/dependency_links.txt
7
+ pibooth_forget_button.egg-info/entry_points.txt
8
+ pibooth_forget_button.egg-info/not-zip-safe
9
+ pibooth_forget_button.egg-info/requires.txt
10
+ pibooth_forget_button.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [pibooth]
2
+ pibooth_forget_button = pibooth_forget_button
@@ -0,0 +1 @@
1
+ pibooth_forget_button
@@ -0,0 +1,216 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """Pibooth plugin to add a third button for forgetting/deleting photos.
4
+
5
+ This plugin adds a dedicated "forget" button that moves the current photo
6
+ to the forget folder, separate from the capture and print buttons.
7
+ """
8
+
9
+ import os
10
+ import os.path as osp
11
+
12
+ import pygame
13
+ from gpiozero import Button
14
+
15
+ import pibooth
16
+ from pibooth.utils import LOGGER
17
+
18
+ __version__ = "1.0.0"
19
+
20
+ # Custom event for forget button
21
+ BUTTON_FORGET_EVENT = pygame.USEREVENT + 10
22
+
23
+
24
+ @pibooth.hookimpl
25
+ def pibooth_configure(cfg):
26
+ """Declare the new configuration options."""
27
+ cfg.add_option('FORGET_BUTTON', 'forget_btn_pin', 0,
28
+ "Physical GPIO IN pin for forget button (BOARD numbering, 0 to disable)",
29
+ "Forget Button Pin", "0")
30
+
31
+ cfg.add_option('FORGET_BUTTON', 'forget_led_pin', 0,
32
+ "Physical GPIO OUT pin to light LED when forget button is pressed (0 to disable)",
33
+ "Forget LED Pin", "0")
34
+
35
+ cfg.add_option('FORGET_BUTTON', 'debounce_delay', 0.3,
36
+ "How long to press the forget button in seconds",
37
+ "Debounce Delay", "0.3")
38
+
39
+
40
+ @pibooth.hookimpl
41
+ def pibooth_startup(app, cfg):
42
+ """Initialize the forget button."""
43
+ pin = cfg.get('FORGET_BUTTON', 'forget_btn_pin')
44
+
45
+ if pin == '0' or pin == 0:
46
+ LOGGER.info("Forget button plugin: disabled (pin = 0)")
47
+ app.forget_button = None
48
+ return
49
+
50
+ try:
51
+ debounce = cfg.getfloat('FORGET_BUTTON', 'debounce_delay')
52
+ app.forget_button = Button(
53
+ "BOARD" + str(pin),
54
+ hold_time=debounce,
55
+ pull_up=True
56
+ )
57
+
58
+ def on_forget_held():
59
+ """Called when forget button is held."""
60
+ LOGGER.debug("Forget button pressed")
61
+ event = pygame.event.Event(BUTTON_FORGET_EVENT)
62
+ pygame.event.post(event)
63
+
64
+ app.forget_button.when_held = on_forget_held
65
+
66
+ LOGGER.info("Forget button initialized on GPIO pin BOARD%s", pin)
67
+
68
+ # Initialize LED if configured
69
+ led_pin = cfg.get('FORGET_BUTTON', 'forget_led_pin')
70
+ if led_pin != '0' and led_pin != 0:
71
+ from gpiozero import LED
72
+ app.forget_led = LED("BOARD" + str(led_pin))
73
+ LOGGER.info("Forget LED initialized on GPIO pin BOARD%s", led_pin)
74
+ else:
75
+ app.forget_led = None
76
+
77
+ except Exception as e:
78
+ LOGGER.error("Failed to initialize forget button: %s", str(e))
79
+ app.forget_button = None
80
+
81
+
82
+ @pibooth.hookimpl
83
+ def pibooth_cleanup(app):
84
+ """Cleanup GPIO resources."""
85
+ if hasattr(app, 'forget_button') and app.forget_button:
86
+ app.forget_button.close()
87
+ if hasattr(app, 'forget_led') and app.forget_led:
88
+ app.forget_led.close()
89
+
90
+
91
+ def find_forget_event(events):
92
+ """Check if forget button was pressed."""
93
+ for event in events:
94
+ if event.type == BUTTON_FORGET_EVENT:
95
+ return event
96
+ return None
97
+
98
+
99
+ def _show_forget_message(win):
100
+ """Display 'Photo oubliée!' message on screen."""
101
+ import time
102
+ from pibooth import fonts
103
+
104
+ # Get window dimensions
105
+ rect = win.get_rect()
106
+
107
+ # Create font
108
+ font = pygame.font.Font(fonts.get_filename(fonts.CURRENT), rect.height // 8)
109
+
110
+ # Render text
111
+ text = font.render("Photo oubliee !", True, (255, 255, 255))
112
+ text_rect = text.get_rect(center=(rect.width * 3 // 4, rect.height // 2))
113
+
114
+ # Fill screen with dark background
115
+ win.surface.fill((50, 50, 50))
116
+
117
+ # Draw text
118
+ win.surface.blit(text, text_rect)
119
+
120
+ # Update display
121
+ pygame.display.update()
122
+
123
+ # Wait 2 seconds
124
+ time.sleep(2)
125
+
126
+
127
+ @pibooth.hookimpl
128
+ def state_print_enter(app):
129
+ """Turn on forget LED when entering print state."""
130
+ if hasattr(app, 'forget_led') and app.forget_led:
131
+ app.forget_led.blink(on_time=0.5, off_time=0.5)
132
+ LOGGER.debug("Forget LED blinking")
133
+
134
+
135
+ @pibooth.hookimpl
136
+ def state_print_exit(app):
137
+ """Turn off forget LED when exiting print state."""
138
+ if hasattr(app, 'forget_led') and app.forget_led:
139
+ app.forget_led.off()
140
+ LOGGER.debug("Forget LED off")
141
+
142
+
143
+ @pibooth.hookimpl
144
+ def state_print_do(cfg, app, win, events):
145
+ """Handle forget button press during print state."""
146
+ if not hasattr(app, 'forget_button') or not app.forget_button:
147
+ return
148
+
149
+ if find_forget_event(events) and app.previous_picture_file:
150
+ LOGGER.info("Forget button: Moving picture to forget folder")
151
+
152
+ # Turn off LED when action is taken
153
+ if hasattr(app, 'forget_led') and app.forget_led:
154
+ app.forget_led.off()
155
+
156
+ # Move picture to forget folder
157
+ for savedir in cfg.gettuple('GENERAL', 'directory', 'path'):
158
+ forgetdir = osp.join(savedir, "forget")
159
+ if not osp.isdir(forgetdir):
160
+ os.makedirs(forgetdir)
161
+
162
+ src = osp.join(savedir, osp.basename(app.previous_picture_file))
163
+ dst = osp.join(forgetdir, osp.basename(app.previous_picture_file))
164
+
165
+ if osp.exists(src):
166
+ os.rename(src, dst)
167
+ LOGGER.info("Moved %s to forget folder", osp.basename(src))
168
+
169
+ # Update counters
170
+ app.count.forgotten += 1
171
+
172
+ # Clear the picture
173
+ app.previous_picture = None
174
+ app.previous_animated = None
175
+ app.previous_picture_file = None
176
+
177
+ # Prevent printing
178
+ app.count.remaining_duplicates = 0
179
+
180
+ # Display "Photo oubliée!" message
181
+ _show_forget_message(win)
182
+
183
+
184
+ @pibooth.hookimpl
185
+ def state_wait_do(cfg, app, events):
186
+ """Handle forget button press during wait state (to delete previous photo)."""
187
+ if not hasattr(app, 'forget_button') or not app.forget_button:
188
+ return
189
+
190
+ if find_forget_event(events) and app.previous_picture_file:
191
+ LOGGER.info("Forget button: Moving previous picture to forget folder")
192
+
193
+ # Flash LED if available
194
+ if hasattr(app, 'forget_led') and app.forget_led:
195
+ app.forget_led.blink(on_time=0.1, n=3, background=True)
196
+
197
+ # Move picture to forget folder
198
+ for savedir in cfg.gettuple('GENERAL', 'directory', 'path'):
199
+ forgetdir = osp.join(savedir, "forget")
200
+ if not osp.isdir(forgetdir):
201
+ os.makedirs(forgetdir)
202
+
203
+ src = osp.join(savedir, osp.basename(app.previous_picture_file))
204
+ dst = osp.join(forgetdir, osp.basename(app.previous_picture_file))
205
+
206
+ if osp.exists(src):
207
+ os.rename(src, dst)
208
+ LOGGER.info("Moved %s to forget folder", osp.basename(src))
209
+
210
+ # Update counters
211
+ app.count.forgotten += 1
212
+
213
+ # Clear the picture
214
+ app.previous_picture = None
215
+ app.previous_animated = None
216
+ app.previous_picture_file = None
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from setuptools import setup
5
+
6
+ setup(
7
+ name='pibooth_forget_button',
8
+ version='1.0.0',
9
+ description="Pibooth plugin to add a third button for forgetting photos",
10
+ long_description="Adds a dedicated GPIO button to move photos to the forget folder",
11
+ author="Ceeeeb",
12
+ url="https://github.com/ceeeeb/pibooth-forget-button",
13
+ license='MIT license',
14
+ platforms=['unix', 'linux'],
15
+ keywords=['Raspberry Pi', 'photobooth', 'pibooth', 'button'],
16
+ py_modules=['pibooth_forget_button'],
17
+ install_requires=['pibooth>=2.0.0'],
18
+ zip_safe=False,
19
+ entry_points={'pibooth': ["pibooth_forget_button = pibooth_forget_button"]},
20
+ )