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

Simple powered up led #387

Merged
merged 41 commits into from
Feb 8, 2020
Merged

Conversation

topas-rec
Copy link
Contributor

In my opinion a good addition to find out if usb power connection can be safely disconnected between Raspberry Pi and the Power bank using an external switch.
Led is turned on, when Pi is running, when pushing power button is blinks two times to indicate shutdown initiated. Then is stays on until Pi loses power. Now one can disconnect power safely.

Led uses free GPIO 3.
Can be ignored if led is not used.

Renamed GPIO buttons file because it now also controls led.

I made video of the functionality, but need to upload it somewhere.

topas-rec added 19 commits November 29, 2018 21:52
I think other stores are better than supporting amazon.
All needed items entered and added a status and if possible a link to
exact part
Adopted shopping list in terms of
- buttons
- led including resistor
- power pack
- RJ45 adapter
- USB charging outlet
- Jumper cables for buttons
- Visaton speaker and amp
Status led shows if phoniebox ist in service to an LED connected to GPIO
2
Install script no longer deletes old gpio-button service but already
more general gpio service.
Small code improvements to LED script.
GPIO service still called old gpio-buttons script
Now gpio gets removed instead of gpio-buttons
- Returning USB speakers
- Received components
Led blinks for half a second off and half a second on after pressing and
during shutdown.
Led blinks two times and stays on until shutdown completes.
This fixes that the led randomly goes off caused by continued blinking
and shutdown.
Conflicts:
	misc/sampleconfigs/gpio-buttons.py.sample

	Merged into gpio.py.sample
Imported comment from upstream.
Commented led behavior when shutting down.
Some changes from fork master were in the led only change branch. Fixed
it. Now just the led change should be in this branch.
Conflicts:
	README.md
	scripts/installscripts/stretch-install-default.sh
@topas-rec
Copy link
Contributor Author

I think this will not destroy the "no soldering" solution, because one can easily ignore the led like the gpio buttons.

@topas-rec
Copy link
Contributor Author

I have not checked the update conditions in detail. I fyou want to merge we should concider the renamed file (gio-buttons.py to gpio.py) in the install script(s).

@topas-rec
Copy link
Contributor Author

This is a small video of the functionality.

VID_20181215_105739.m4v.zip

@@ -482,30 +482,30 @@ echo "### Deleting older versions of service daemons. This might throw errors, i
sudo systemctl disable idle-watchdog
sudo systemctl disable rfid-reader
sudo systemctl disable startup-sound
sudo systemctl disable gpio-buttons
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should stay for a while I guess right?

sudo rm /etc/systemd/system/rfid-reader.service
sudo rm /etc/systemd/system/startup-sound.service
sudo rm /etc/systemd/system/gpio-buttons.service
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should stay for a while I guess right?

@martinclausen2
Copy link

Hi @topas-rec, GPIO 3 is not free, it is currently GPIO to power up and down and can not be chnaged to other pins (wake-up is special pin requirement).
Please find a suitable pin by considering the new pinout

@MiczFlor
Copy link
Owner

Hi @topas-rec @martinclausen2
thanks for the contribution and thanks for pointing out the conflict. Is there a way to modify the code to follow the GPIO "best practice" ideas?

@martinclausen2
Copy link

Hi @topas-rec , a suggestion GPIO 7 is free.

@topas-rec
Copy link
Contributor Author

topas-rec commented Dec 23, 2018

Can you confirm that and then tell me if this gpio is free?
This gpio.py script works on my phoniebox together with the gpio buttons exactly implemented according to the wiki suggestion: https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/Using-GPIO-hardware-buttons

That's why I didn't believe there is a conflict between the led and the shutdown button, because I use them together.

@topas-rec
Copy link
Contributor Author

OK found out that the gpio 2 is a conflict for the i2c protocol for the hifiberry. Correct?
So changing to gpio 7 is still necessary right?

@MiczFlor
Copy link
Owner

Hi @topas-rec
this is still pending for two reasons. The first one I can not solve: I have not GPIO installed at the moment and can not test nor verify which pin should be used.
Secondly, you are right, the name of the script should change, because it's not only about buttons anymore. However, I do not want to deal with the disappointed parents after a git pull - which is why I would like to leave the filename as it is now.
All the best, micz

@topas-rec
Copy link
Contributor Author

topas-rec commented Jan 28, 2020

If I remember correctly renaming of next was already done in develop branch.

Jepp. Thats why I changed to the develop branch. Getting this fix into this PR can be done in one shot instead of doing it later when merging develop in master.

@topas-rec
Copy link
Contributor Author

This PR was targeted to master. In master the next changes are not merged.

simple_powered_up_led

Conflicts:
	misc/sampleconfigs/gpio-buttons.py.sample
	misc/sampleconfigs/phoniebox-rfid-reader.service.stretch-default.sample
	scripts/RegisterDevice.py
	scripts/installscripts/buster-install-default.sh

All files taken over except of gpio-buttons.py.sample
@topas-rec
Copy link
Contributor Author

  • LED changed to GPIO 12
  • Renaming next variables done

I'll test this soon. If someone can test it that would help.
I saw the rfid switch off function and adopted it to work with RPi.GPIO. @tobias-snapit might want to test that. (It is commented out - as it was before)

I think this can be merged already since the GPIO and LED code was already tested before.

@topas-rec
Copy link
Contributor Author

Tested with current buster install script (develop branch) and with GPIO 12.

Works right after install and works as expected.

Please merge.

@veloxidSchweiz
Copy link
Contributor

Hi @topas-rec ,
I am wondering why you removed the gpiozero module?
Isn't it possible to implement it with gpiozero?
actually another nice way to do this would be to use a
dtoverlay:
dtoverlay=gpio-poweroff,gpiopin=13
would power on gpiopin 13 (if i remember correctly BCM) as soon as power is down and the rpi can be put off.
It can als be used in inverted mode by using ,active_low="y"....

@martinclausen2
Copy link

Hi @veloxidSchweiz a year oago I removed carefully gpio.zero for performance reasons:
#387 (comment)
As you noticed here #763 it is advisable to use less different libs for the same task. So we agreed on dropping gpiozero at the time to my understanding. If you use a RPi 4 you will likely not notice, but for a Pi Zero it is a different story.

@veloxidSchweiz
Copy link
Contributor

Hi @martinclausen2 ,
Thanks for the explanation, I wasn't aware of that.
I am usually not using the Pi Zero nor a RPi4 but RPI 3 therefore i probably haven't recognized it.
At the end i think it is the best at least to agree on one interface.
After reading the discussions here, I am asking me if the idea of the common base class goes somehow in the same direction I am suggesting in #763 ...

@topas-rec
Copy link
Contributor Author

Can someone of the maintainers please explain to me why this is not going to be merged or rejected? I see a lot of discussion going on around config files and reorganizing the project. I think that is all great. Does it has to do with this PR? Is that the reason that this PR is not merged? Are there other reasons?

This PR is open for a year now and I am afraid someday I find a whole different project and my changes do not fit anymore and I can rewrite this (small) change. I don't have so much time so I am not sure to be able to keep up with the projects speed.

@MiczFlor
Copy link
Owner

MiczFlor commented Feb 7, 2020

Hi @topas-rec
you are absolutely right. Did you rebase your work to the latest version of the script? I will merge it immediately. I am not super up to date with the status of your contribution. Apologies!
All the best, micz

@topas-rec
Copy link
Contributor Author

I did not rebase but I merged your development branch into this branch just now.
So yes, in my branch are the latest changes of the script.

@topas-rec
Copy link
Contributor Author

@MiczFlor everything is up to date - please merge.

@MiczFlor MiczFlor merged commit 7a67b58 into MiczFlor:develop Feb 8, 2020
@narf0815
Copy link

is there a way to simply implement this in stable?
as mentioned here i have some trouble with developer...

(am i supposed to post here?)

@topas-rec
Copy link
Contributor Author

It has to be merged by a maintainer.

You can copy the file gpio-buttons.py from develop to your box manually until it is merged.

@narf0815
Copy link

narf0815 commented Apr 15, 2020

i tried my working develop gpio-buttons.py file on my stable version but LED does still not work on stable.

@topas-rec
Copy link
Contributor Author

@narf0815
Copy link

yes. and it's working on my "develop-sdcard"

@topas-rec
Copy link
Contributor Author

topas-rec commented Apr 15, 2020

So just not working when copying the develop file gpio-buttons.py into the stable (master) branch?

I don't have an idea why. For me this file was always like an atomic thing. Works when present.

Can you put a debug printf in that file to see what that code does and why the led doesn't light up?

You can see these printf by looking in the /var/log/syslog file.
You can use the tail command for automatically refreshing through SSH session.

@narf0815
Copy link

So just not working when copying the file gpio-buttons.py into the stable (master) branch?

exactly

Can you put a debug printf in that file to see what that code does and why the led doesn't light up?

huh. if you tell me where to put what i shure could.

@topas-rec
Copy link
Contributor Author

General printing of messages in python:
https://www.w3schools.com/python/ref_func_print.asp

@topas-rec
Copy link
Contributor Author

@MiczFlor let us know if this should better be discussed in an issue rather than in a merged PR.

@narf0815
Copy link

narf0815 commented Apr 15, 2020

i'm afraid this is (far) above my "potential".
hope this comes to stable soon so i/my kids can have volume rotary encoder and LED.

thanks for your effort however!

edit: oh my, this is truly way above me... with just changing the gpio-buttons.py none of the buttons work anymore as before. (yes - with correct gpios)

@s-martin
Copy link
Collaborator

We're working on releasing 2.0 "soon" although I can't give you a date. Please see #890 for coordination of the release.

@topas-rec topas-rec mentioned this pull request Apr 16, 2020
8 tasks
@topas-rec topas-rec deleted the simple_powered_up_led branch March 18, 2023 07:32
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

Successfully merging this pull request may close these issues.