Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware switch? #57

Open
gskips opened this issue Jan 17, 2023 · 1 comment
Open

Hardware switch? #57

gskips opened this issue Jan 17, 2023 · 1 comment

Comments

@gskips
Copy link

gskips commented Jan 17, 2023

Hi there.

Relative newbie here. Thanks for this app, it's just what I needed, but I was wondering if there was a way of making a hardware non latching switch trigger the toggle on/off cmd? I realise this is a bit off topic for issues with this code...but I'd love any help or pointers anyone might have please. I have a hifiberry hat on, so my GPIO pins are slightly limited?

Thanks very much

gskips

@NekoCoaster
Copy link

Assuming that you're looking for a way to toggle the screen on/off with a non-latching (momentary) switch, you might wanna have a look at the python API documentations here.

There are example python codes in the documentations showing you how you can interact with the display by including the library in your python script. And assuming that it satisfies your needs, you'll then need to look up on how to write your python script to be able to read inputs from your switch and on how you would want the code to behave whenever your button is pressed.

Although you did mention that you have a hifiberry hat installed, this usually means that most, if not all the pi's GPIO pins would be occupied by the hat itself.

A janky idea off the top of my head on how to work around this issue is to have a look online for the schematic of the hat that you have, compare that against the raspberry pi's GPIO pin out, and try to work out which pins on the hat itself is a GPIO capable pin, that is also not electrically connected or in-use by the hat itself.

Once you find an appropriate GPIO pins that are not in-use by the hat, you can then soldier a pair of wire that connects to that GPIO pin, which then connects to your button, and then from the other switching side of the button, soldier it to GND.

Once you have the wires connected to the GPIO pin and GND, you can then start working on your python script to read the input signal from the GPIO pin that you have soldiered your button to. But since the side of the button is connected to GND, that means you'll need to pull-up the GPIO Pin that's connected to your button, so that you can detect when the button is being pressed by observing a voltage drop. I highly recommend looking up what pull-up and pull-down means in the context of electrical circuits to get a better idea on what you're doing.

That said, do also keep in mind that with all hardware switches, you will also need to factor in the possibility of button-bouncing causing multiple inputs to be registered by your raspberry pi, when writing the python script.

These are just some of the starting pointers I can recommend off the top of my head, if I were to design a similar functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants