diff --git a/photobooth/Photobooth.py b/photobooth/Photobooth.py index 3dd2830..47ed253 100644 --- a/photobooth/Photobooth.py +++ b/photobooth/Photobooth.py @@ -49,7 +49,7 @@ class Photobooth: self._lampOff = lambda : self._gpio.lampOff(lamp) self._gpio.setButton(config.getInt('Gpio', 'trigger_pin'), self.gpioTrigger) - self._gpio.setButton(config.getInt('Gpio', 'exit_pin'), self.teardown) + self._gpio.setButton(config.getInt('Gpio', 'exit_pin'), self.gpioExit) else: self._lampOn = lambda : None self._lampOff = lambda : None @@ -119,6 +119,9 @@ class Photobooth: print('Camera already started') self.initRun() continue + elif str(event) == 'teardown': + self.teardown() + return -1 elif str(event) != 'triggered': print('Unknown event received: ' + str(event)) raise RuntimeError('Unknown event received', str(event)) @@ -270,6 +273,11 @@ class Photobooth: self._gpioTrigger() + def gpioExit(self): + + self._send.send(gui.TeardownState()) + + def triggerOff(self): self._lampOff() diff --git a/photobooth/gui/PyQt5Gui.py b/photobooth/gui/PyQt5Gui.py index fa5d993..2494a7e 100644 --- a/photobooth/gui/PyQt5Gui.py +++ b/photobooth/gui/PyQt5Gui.py @@ -80,8 +80,10 @@ class PyQt5Gui(Gui): if isinstance(state, IdleState): self.showIdle() + elif isinstance(state, TriggerState): self._transport.send('triggered') + elif isinstance(state, GreeterState): global cfg self._p.handleKeypressEvent = self.handleKeypressEventNoTrigger @@ -101,16 +103,24 @@ class PyQt5Gui(Gui): elif isinstance(state, PoseState): self._p.setCentralWidget(PyQt5PictureMessage('Pose!')) + elif isinstance(state, AssembleState): self._p.setCentralWidget(PyQt5WaitMessage('Processing picture...')) + elif isinstance(state, PictureState): img = ImageQt.ImageQt(state.picture) self._p.setCentralWidget(PyQt5PictureMessage('', img)) QTimer.singleShot(cfg.getInt('Photobooth', 'display_time') * 1000, lambda : self._transport.send('ack')) self._printer.print(state.picture) + + elif isinstance(state, TeardownState): + self._transport.send('teardown') + self.showStart() + elif isinstance(state, ErrorState): self.showError(state.title, state.message) + else: raise ValueError('Unknown state') diff --git a/photobooth/gui/__init__.py b/photobooth/gui/__init__.py index 792df6d..7b2da02 100644 --- a/photobooth/gui/__init__.py +++ b/photobooth/gui/__init__.py @@ -155,3 +155,9 @@ class PreviewState(MessageState, PictureState): def __init__(self, **kwargs): super().__init__(**kwargs) + +class TeardownState(GuiState): + + def __init__(self, **kwargs): + + super().__init__(**kwargs)