From fa3cfb1b71dca6a76ec55b6a24588c7d7faa521e Mon Sep 17 00:00:00 2001 From: Ludovic BALMONT <20644950-ludovic.balmont@users.noreply.gitlab.com> Date: Tue, 26 Mar 2024 18:38:11 +0000 Subject: [PATCH 1/2] fix(system): change from FALLING to RISING to detect correctly the on/off from active to shutdown --- board/recalbox/fsoverlay/recalbox/scripts/rpi-pin356-power.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/board/recalbox/fsoverlay/recalbox/scripts/rpi-pin356-power.py b/board/recalbox/fsoverlay/recalbox/scripts/rpi-pin356-power.py index 672e7c2703..27c6d5966c 100644 --- a/board/recalbox/fsoverlay/recalbox/scripts/rpi-pin356-power.py +++ b/board/recalbox/fsoverlay/recalbox/scripts/rpi-pin356-power.py @@ -168,7 +168,8 @@ if mode == "onoff" : # Allow Nespi+ to detect the end of the shutdown for proper power-off GPIO.setup(POWEREN, GPIO.OUT) GPIO.output(POWEREN, True) - GPIO.add_event_detect(POWERPLUS, GPIO.FALLING, callback=onoff_mode, bouncetime=2) + # Change from FALLING to RISING to detect correctly the on/off from active to shutdown + GPIO.add_event_detect(POWERPLUS, GPIO.RISING, callback=onoff_mode, bouncetime=2) GPIO.add_event_detect(RESETPLUS, GPIO.BOTH, callback=onoff_mode, bouncetime=2) elif mode == "push": GPIO.add_event_detect(POWERPLUS, GPIO.BOTH, callback=push_mode, bouncetime=2) -- GitLab From 2636dcfc29de12a25942d72cc52bdcdd3b4f551a Mon Sep 17 00:00:00 2001 From: Ludovic BALMONT <20644950-ludovic.balmont@users.noreply.gitlab.com> Date: Thu, 28 Mar 2024 17:40:01 +0000 Subject: [PATCH 2/2] fix(system): add little time sleep after POWEREN and add bouncetime to workaround floating states --- .../fsoverlay/recalbox/scripts/rpi-pin356-power.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/board/recalbox/fsoverlay/recalbox/scripts/rpi-pin356-power.py b/board/recalbox/fsoverlay/recalbox/scripts/rpi-pin356-power.py index 27c6d5966c..fe1f44633e 100644 --- a/board/recalbox/fsoverlay/recalbox/scripts/rpi-pin356-power.py +++ b/board/recalbox/fsoverlay/recalbox/scripts/rpi-pin356-power.py @@ -168,12 +168,13 @@ if mode == "onoff" : # Allow Nespi+ to detect the end of the shutdown for proper power-off GPIO.setup(POWEREN, GPIO.OUT) GPIO.output(POWEREN, True) + time.sleep(0.2) # Change from FALLING to RISING to detect correctly the on/off from active to shutdown - GPIO.add_event_detect(POWERPLUS, GPIO.RISING, callback=onoff_mode, bouncetime=2) - GPIO.add_event_detect(RESETPLUS, GPIO.BOTH, callback=onoff_mode, bouncetime=2) + GPIO.add_event_detect(POWERPLUS, GPIO.RISING, callback=onoff_mode, bouncetime=200) + GPIO.add_event_detect(RESETPLUS, GPIO.BOTH, callback=onoff_mode, bouncetime=200) elif mode == "push": - GPIO.add_event_detect(POWERPLUS, GPIO.BOTH, callback=push_mode, bouncetime=2) - GPIO.add_event_detect(RESETPLUS, GPIO.BOTH, callback=push_mode, bouncetime=2) + GPIO.add_event_detect(POWERPLUS, GPIO.BOTH, callback=push_mode, bouncetime=200) + GPIO.add_event_detect(RESETPLUS, GPIO.BOTH, callback=push_mode, bouncetime=200) while True: time.sleep(0.2) -- GitLab