Jump to content

The ole power-off button using gpio question - AML-S905X-CC


pezmaker
Go to solution Solved by usual user,

Recommended Posts

Hello.  I've searched here, the Libre computer forums, even tried "cheating" with asking chatgpt.  Using a "Le Potato" AML-S905X-CC with Armbian Jammy 22.04.2 LTS.

I've gotten far enough to be able to read the switch on the GPIO with pulled to 0 reading as 1.
 

button untouched:
~$ sudo gpioget --active-low gpiochip1 97
0
button pressed:
:~$ sudo gpioget --active-low gpiochip1 97
1

 

From here though, I can't seem to figure out what to do next.  I've seen suggestions to use a python script with a sleep to using device overlays.  The device overlay examples I see using armbian are typically for orange Pis and I can't seem to extrapolate to the le potato gpio, or are Libre's support saying how to do it with their custom kernels and device tree overlay tools, which I (in my foolishness? long term wisdom?) chose not to use over Armbian.

If anyone has some input on what to throw at this next I'd love it.  I am using this le potato as a klipper server with Fluidd and would love to be able to hit my pretty led backed power button to power down the server board and a second led lit power switch to power down the printer.  In the end it's no big deal if I can't get this working, I can just shutdown the pi via Klipperscreen and then use the modified power switch on the 3d printer.  But that's not as much fun as changing everything.

 

Thank you!

Link to comment
Share on other sites

Good input.  I did have to add  option " -B pull-down" or it gave me syntax errors.

 

sudo gpiomon --num-events=1 -B pull-down -f gpiochip0 9 && halt

 

I also couldn't get it to register the button press immediately.  I'd need to do more testing but it seemed I needed to hold it down for seconds before it'd register.  I also wasn't sure how to get a wall message and 5 second wait in there, so in the end I went with a script that loads on startup. 

 

That said, what you said was a perfectly solid answer so you get the solution.

 

Thank you for the response!

Link to comment
Share on other sites

7 hours ago, pezmaker said:

I did have to add  option " -B pull-down"

 

7 hours ago, pezmaker said:

I also couldn't get it to register the button press immediately.  I'd need to do more testing but it seemed I needed to hold it down for seconds before it'd register.

The necessity of the "-B" parameter with the observed gpio behavior is probably due to how the gpio is wired up in the DT and how its pin control is set up there.

 

7 hours ago, pezmaker said:

I also wasn't sure how to get a wall message and 5 second wait in there, so in the end I went with a script that loads on startup. 

Since I didn't know the exact use case, I only presented the basic command and left it to the user's imagination how it would ultimately be used. It's general shell usage, and if I understand the use case correctly, I'd have e.g. used something like this in a script that loads on startup:

gpiomon --num-events=1 -B pull-down -f gpiochip0 9 && wall power off initiated && sleep 5 && halt

 

7 hours ago, pezmaker said:

Thank you for the response!

You're welcome.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines