On-Screen Battery Monitor Options

General GBZ-related chat goes here. Share ideas, tips and tricks, or ask questions that don't fit into the hardware/software help forums.
User avatar
infinitLoop
Posts: 536
Joined: Mon Dec 24, 2018 11:46 am
Location: Portland, OR
Has thanked: 222 times
Been thanked: 199 times
Contact:

Re: On-Screen Battery Monitor Options

Post by infinitLoop » Tue Apr 28, 2020 12:48 pm

djobbydjobba wrote:
Tue Apr 28, 2020 11:46 am
Thank you for your help. Indeed it does not work anymore. But even with your instructions that still doesn't work. I've changed the lines as mentionned, installed pip3, installed adafruit circuitpython library... Nothing shows up.
Would you mind helping me out ?
have you tried Helder's OneForAll?

https://github.com/Helder1981/OneForAll

also, it could be that it's working, but the image is off-screen. i think that happened on my 3a+ build. you could try adjusting the x&y positions in the minty script.

Lpoolm
Posts: 392
Joined: Thu Jun 09, 2016 4:17 am
Location: uk
Has thanked: 76 times
Been thanked: 51 times

Re: On-Screen Battery Monitor Options

Post by Lpoolm » Thu Apr 30, 2020 6:52 am

Hi, I read through 17 pages and found it all very interesting, it has somewhat turned into a bit of a help thread now though.
Would it be possible for someone much clever then me to write a thread that could be stickied? With the basic instructions on how to do using both boards mentioned?
I think if I was to ever try I could read through and give it a go but a lot of the info is spread across several pages and I done want to be asking loads of questions too!
Check out my modding and repair channel of retro and modern consoles:
https://www.youtube.com/channel/UCFz7yW ... GtQ/videos

User avatar
Helder
Trailblazer
Trailblazer
Posts: 2985
Joined: Thu May 05, 2016 8:33 am
Location: Rogers, AR
Has thanked: 1459 times
Been thanked: 3114 times

Re: On-Screen Battery Monitor Options

Post by Helder » Sun May 10, 2020 1:10 am

Want to compile it all into 1 post and then I can sticky it.
Chat with me and other members On Discord

Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.


Helder's Game Tech Website

We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.

carjufi
Posts: 10
Joined: Sat Jul 06, 2019 5:50 pm
Has thanked: 6 times
Been thanked: 1 time

Re: On-Screen Battery Monitor Options

Post by carjufi » Tue May 26, 2020 3:43 am

Hi guys, I am trying to implement the battery monitor in the PCB design I am doing now and I would like to confirm I have understood everything. After reading all posts here these are the conclusions (might help as well to summarise or understand for others). Sorry if some things are too basic, I am not fully experienced in some topics and I like things plain and simple to understand. If anything is wrong please tell me! Here it goes:

As the Raspberry pi does not have analogue pins and if you do not want to implement an ATMEGA chip, one option to have a battery monitor on the screen is to use the ADS1015. The wiring of the Adafruit's module is as follows (from this forum by VeteranGamer):
SpoilerShow
Image
For your build, if you are using GPIO pins for the buttons, make sure you leave the GPIO pins 2 (SDA) and 3 (SCL) free for the ADS1015 outputs. Here is a question I have about the wiring in this point:
  • What are the pins A0-A4 form the board? and why is A0 connected to the 5V input? Is this some sort of reference voltage to do the calculations on the battery level?
Next, you would need to implement these changes in the Retropie software and this is the part I am having more trouble to understand the most. I would like to implement this in a GBZ build and I understand I will need to change the configuration file and something else, right? First you will need to install the Mintippy battery monitor and, according to Merlin, change the values in line 47:

Code: Select all

monitor_btn = Button(19, hold_time=2)
You can change the 19 value for other GPIO button you would like to use to show up the battery level on the screen.
  • Here I can see the code has changed and I cannot find the lines Merlin was talking about. Does anyone has any update on this?
  • Also, will this work if safe shutdown is not present in the hardware?
For the moment that is all, hope some of you guys can answer the questions! Thanks!

User avatar
infinitLoop
Posts: 536
Joined: Mon Dec 24, 2018 11:46 am
Location: Portland, OR
Has thanked: 222 times
Been thanked: 199 times
Contact:

Re: On-Screen Battery Monitor Options

Post by infinitLoop » Tue May 26, 2020 7:45 am

another good practice is to also run the battery line that goes to the ADS through the power switch (using a DPST type), so you don't leak power while off.

carjufi wrote:
Tue May 26, 2020 3:43 am
What are the pins A0-A4 form the board? and why is A0 connected to the 5V input? Is this some sort of reference voltage to do the calculations on the battery level?
those are "Analog" pins (opposed to "Digital" pins). it just means they can accept a range of voltage (where digital is on/off). The choice of which one is arbitrary i think. A0 is just the first one (and you only need one)

carjufi wrote:
Tue May 26, 2020 3:43 am
  • Here I can see the code has changed and I cannot find the lines Merlin was talking about. Does anyone has any update on this?
  • Also, will this work if safe shutdown is not present in the hardware?
so, what you are doing is editing the script that watches for a button (or buttons) to be pressed, to hide and show the icon, or trigger a shutdown. you don't have to wire anything else for the shutdown (aside from the button that triggers it). you can also adjust the "hold" time. or you can comment those lines out and not use that at all. it's at the very bottom of the file, so just scroll all the way down to find it. then set the GPIO pin(s) you used.

pocket adventures' guide is a pretty good general guide:

http://www.pocketadventures.com/guide_c ... ds1015.asp

.

carjufi
Posts: 10
Joined: Sat Jul 06, 2019 5:50 pm
Has thanked: 6 times
Been thanked: 1 time

Re: On-Screen Battery Monitor Options

Post by carjufi » Tue May 26, 2020 10:24 am

infinitLoop wrote:
Tue May 26, 2020 7:45 am
another good practice is to also run the battery line that goes to the ADS through the power switch (using a DPST type), so you don't leak power while off.
Do you mean this? Here, from Talc:
SpoilerShow
Image
I do not understand this. So, when the button is OFF, the button cuts the battery voltage and the boost converter (and the Pi) won't start up. But, what it is exactly happening with the other wires?
infinitLoop wrote:
Tue May 26, 2020 7:45 am
so, what you are doing is editing the script that watches for a button (or buttons) to be pressed, to hide and show the icon, or trigger a shutdown. you don't have to wire anything else for the shutdown (aside from the button that triggers it). you can also adjust the "hold" time. or you can comment those lines out and not use that at all. it's at the very bottom of the file, so just scroll all the way down to find it. then set the GPIO pin(s) you used.

pocket adventures' guide is a pretty good general guide:

http://www.pocketadventures.com/guide_c ... ds1015.asp

.
Thanks for this! The thing is that I want as well to implement a safe shutdown function in the PCB design, but I cannot find how to do it. A good schematic and/or understand how the safe shutdown works would allow me to include this feature in the final PCB. Do you know how to do it?

In the case I do not implement the safe shutdown in the PCB, I still want the ADC1015 for the battery monitoring and I am not sure this piece of software would work for it to function. Might just leave uncommented the lines only for the battery level? In the code MintyShutdown.py there is as well the feature for safe shutdown (I think) in the same sript, so I just remove/comment it?

User avatar
infinitLoop
Posts: 536
Joined: Mon Dec 24, 2018 11:46 am
Location: Portland, OR
Has thanked: 222 times
Been thanked: 199 times
Contact:

Re: On-Screen Battery Monitor Options

Post by infinitLoop » Tue May 26, 2020 10:45 am

carjufi wrote:
Tue May 26, 2020 10:24 am
Do you mean this? Here, from Talc:

I do not understand this. So, when the button is OFF, the button cuts the battery voltage and the boost converter (and the Pi) won't start up. But, what it is exactly happening with the other wires?
sort of... the adafruit powerboost has an "engage" switch, so thatt turns it on and off. your original diagram just had the power running through to cut on and off. either way tho, the way that you hook up the battery monitor, the power line runs from the battery directly to the ADS, so that will still be connected, even if your main power is off, and could continue to leak power there.

this might help: https://github.com/infinitLoop/gbz_tools#hardware-notes
carjufi wrote:
Tue May 26, 2020 10:24 am

Thanks for this! The thing is that I want as well to implement a safe shutdown function in the PCB design, but I cannot find how to do it. A good schematic and/or understand how the safe shutdown works would allow me to include this feature in the final PCB. Do you know how to do it?
no, there is no easy way. most people that make a circuit use a "logic gate" to control it. unless you have that, or knowledge to do it already, it's going to be outside of what you're going to be able to handle. your best best if you are doing it yourself, and don't have something with a circuit, is to have the button that initiates the software shutdown, using the minty script.
carjufi wrote:
Tue May 26, 2020 10:24 am
In the case I do not implement the safe shutdown in the PCB, I still want the ADC1015 for the battery monitoring and I am not sure this piece of software would work for it to function. Might just leave uncommented the lines only for the battery level? In the code MintyShutdown.py there is as well the feature for safe shutdown (I think) in the same sript, so I just remove/comment it?
yeah, like i said, the two lines that register the button are at the bottom of script. you can change the values, comment them out, or remove them altogether. i think you can clear out that whole "mintyshutdown" script if you dont want the hide/show and safe shutdown functionality on a button. that's all that does. the battery monitor functionality is in a different script - the MintyBatteryMonitor.py file.

.
Last edited by infinitLoop on Thu May 28, 2020 9:42 pm, edited 1 time in total.

carjufi
Posts: 10
Joined: Sat Jul 06, 2019 5:50 pm
Has thanked: 6 times
Been thanked: 1 time

Re: On-Screen Battery Monitor Options

Post by carjufi » Thu May 28, 2020 3:06 pm

infinitLoop wrote:
Tue May 26, 2020 10:45 am
no, there is no easy way. most people that make a circuit use a "logic gate" to control it. unless you have that, or knowledge to do it already, it's going to be outside of what you're going to be able to handle. your best best if you are doing it yourself, and don't have something with a circuit, is to have the button that initiates the software shutdown, using the minty script.
carjufi wrote:
Tue May 26, 2020 10:24 am
In the case I do not implement the safe shutdown in the PCB, I still want the ADC1015 for the battery monitoring and I am not sure this piece of software would work for it to function. Might just leave uncommented the lines only for the battery level? In the code MintyShutdown.py there is as well the feature for safe shutdown (I think) in the same sript, so I just remove/comment it?
yeah, like i said, the two lines that register the button are at the bottom of script. you can change the values, comment them out, or remove them altogether. i think you can clear out that whole "mintyshutdown" script if you dont want the hide/show and safe shutdown functionality on a button. that's all that does. the battery monitor functionality is in a different script - the MintyBatteryMonitor.sh file.

.
Thanks! I think I am going to go for the simple button and software shutdown. My question now if this can be done without adding an additional button to the PCB. For example, can I trigger the software shutdown with a combination of other buttons? I guess that would mean modifying the software bit by adding another line. Like this?

Code: Select all


# Interrupts

shutdown_btn = Button(7, hold_time=1)
shutdown_btn2 = Button(XX, hold_time=1) # Replace XX for whichever GPIO
monitor_btn = Button(19, hold_time=2)

if shutdown_btn == True and shutdown_btn2 == True:
    shutdown

monitor_btn.when_held = togglestate
pause()

I don't even know if this is correct syntax for the button functions, sorry about that :roll:

User avatar
infinitLoop
Posts: 536
Joined: Mon Dec 24, 2018 11:46 am
Location: Portland, OR
Has thanked: 222 times
Been thanked: 199 times
Contact:

Re: On-Screen Battery Monitor Options

Post by infinitLoop » Thu May 28, 2020 3:35 pm

carjufi wrote:
Thu May 28, 2020 3:06 pm

Thanks! I think I am going to go for the simple button and software shutdown. My question now if this can be done without adding an additional button to the PCB. For example, can I trigger the software shutdown with a combination of other buttons? I guess that would mean modifying the software bit by adding another line. Like this?

...

I don't even know if this is correct syntax for the button functions, sorry about that :roll:
yeah, you can do it, but not exactly like that. take a look at hoolyhoo's "combo" script for some guidance on that:

https://github.com/HoolyHoo/MintyComboS ... tyCombo.py

.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest