reuterbal / photobooth

A flexible photobooth software
GNU Affero General Public License v3.0
316 stars 158 forks source link

Multi purpose buttons / error on trigger button #58

Open wohadu opened 5 years ago

wohadu commented 5 years ago

Hi Balthasar,

really appreciating your work. While being able to build everything up, i am not best in scripting ;)

Describe the bug I installed the photobooth as described. Activated the GPIO module, defined exit pin 22, trigger pin 17. When pressing the "trigger" Button, the "start photobooth" does not react any more, when clicking it again with the cursor. (the buttons "set date/time", "settings" and "quit" are still working fine)

To Reproduce

Steps to reproduce the behavior:

  1. Run photobooth
  2. Use "trigger" GPIO Button while on the Start Screen
  3. Click on "Start Photobooth"

--error message-- File "/home/pi/photobooth/photobooth/StateMachine.py", line 84, in handleEvent self.-state.handleEvent(event,self) File "/home/pi/photobooth/photobooth/StateMachine.py", line 343, in handleEvent raise_ValueError('Unknown GuiEvent' "{}"'.format(event.name)) ValueError: Unknown GuiEvent "countdown"

Expected behavior

Under normal circumstances, I'd expect the Photobooth to start over again.

If I had a wish, I would change the GPIO behaviour depending on what screen I am on. So on the start screen if GPIO is acitve and i push the "trigger" Button, I'd expect the photobooth to start "start photobooth". In the "Hit the button" Screen, I would expect the program to trigger the capturing.

Same with the Exit button: Wherever I push it, i'd expect to jump back to the start page. This behaviour would enable the users to have a full using capability, even if no external input device is attached.

Hope you can assist me with that issue - already preparing the success story ;)

Best,

wolf

reuterbal commented 5 years ago

Hi wolf,

could you please attach your entire photobooth.log? It seems like something produced an error already before that.

Regarding the behaviour of the trigger button: All state transitions are defined in photobooth/StateMachine.py. There is a class derived from State for every state of the photobooth. If you want to add a new state transfer (e.g. return to IdleState when pressing the trigger button at ReviewState) you simply have to add a check for GpioEvent with event.name == 'trigger' in ReviewState.handleEvent() and set context.state to IdleState(). This can be done almost everywhere else as well.

reuterbal commented 5 years ago

Any news?

See also #44 for multi purpose buttons.

wohadu80 commented 5 years ago

Hi Balthasar, sorry, busy times. Preparing already my success story. Let me give you a brief resume of findings here (please dont get it wrong - all were happy and we have tons of great pics!):

It is quite difficult to differentiate the states. So what I did is to add the GPIO for "Trigger" and "Exit" into the required IF statements to be able to navigate the menu without a touch screen and mouse. This one works not failsafe, but far enough: 1) After the first start of the Program, the GPIO does not react (maybe I did not identify the right state - will post my StateMachine.py at the bottom). It requires at least one click with the mouse to get the program running with GPIO 2) "Exit" while in Countdown or Review causes the Camera driver to run into a resource exception which requires the Photobooth software to be restartet. 3) Sometimes (the Guests caused this, I did not investigate the root cause) the software does not react on GPIO in startup state (the one with Run, Config, Exit...) 4) the space and tab sensitivity of phyton is the biggest pain... :) StateMachine.py.txt

...and one thing I experienced: When pointing the save file path to a folder which is not accessible or removed, the software goes enrage and opens ~50 error windows before crashing.

Thanks for you efforts - really appreciate that!

reuterbal commented 5 years ago

I'll add a state diagram at some point, I simply don't find the time - sorry!

Your modified StateMachine.py does not really look as if it would work: the indentations in TeardownState, StartupState etc. are wrong.

Regarding the individual issues:

  1. In WelcomeState you might hit the case where there is a GpioEvent happening but has the wrong name. Check that they send the right names or add the events individually in the if-elif-else-clause, e.g., as
    elif isinstance(event, GpioEvent) and event.name == 'trigger':
  2. Yes, that's true. they are not properly treated.
  3. see 1.

Edit: Sorry, hit the close button by accident.

reuterbal commented 5 years ago

I finally found the time to draw a state chart: https://github.com/reuterbal/photobooth/blob/master/supplementals/state-chart/state-chart.pdf

AcidCool83 commented 5 years ago

Hello,

I tried to implement the file of @Wohadu but I can not put the button by Gpio to print the photo. I do not see what can be missing. When starting I also have to press on the button to start photobooth but this does not matter to me because I will click on the button.

I leave the StateMachine file that I am using. Please, I need your help @Wohadu and @reuterbal or whoever. I need it for my best friend's wedding next week.

Thanks for everything. StateMachine.py,txt

This is the error: File "/home/pi/Desktop/fotomaton/2/photobooth/photobooth/StateMachine.py", line 490, in handleEvent raise TypeError('Unknown Event type "{}"'.format(event)) TypeError: Unknown Event type "idle"