Tackling Graceful Shutdowns on the GBZ

Various user-contributed guides for software-related things
Post Reply
User avatar
Rod2D2
Posts: 131
Joined: Thu May 05, 2016 5:08 am
Location: USA
Has thanked: 80 times
Been thanked: 17 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Rod2D2 » Sun May 15, 2016 6:38 pm

Popcorn wrote:
chiz wrote:Woah! :shock: :shock: :shock:

This is very impressive, @Popcorn!!! Very professional! Retropie or EmulationStation should include your work in future releases as it looks like it's stock! You're the one who rock, man! I'm in awe...

Note to @wermy and mods: We should have a "bow down" or "hats off" emoticon. This is one of those occasions we them.
Geez, we need a blush emoticon too then. ;) thanks man!

I'll try to polish this up and release the daemon and this low battery warning function soon.
This is really very cool. I would definitely like to incorporate this feature in my build.

User avatar
wermy
Site Admin
Posts: 1346
Joined: Tue May 03, 2016 8:51 pm
Has thanked: 620 times
Been thanked: 1322 times
Contact:

Re: Tackling Graceful Shutdowns on the GBZ

Post by wermy » Sun May 15, 2016 6:52 pm

Popcorn wrote:https://youtu.be/xsdwTefIR6o

Just wanted to show the low battery shutdown as im working on it. I'm able to get it running on an overlay like a HUD. So the user can save the game as they can still control the game underneath. Right now, I made a simple countdown using imovie but I will improve it. In this video, you can see that I close mame and then it goes to emulation station in the last ten seconds. This is just to show that the countdown appears overtop all layers. This is working really well!
That is freaking awesome @Popcorn! Which GPIO pins are you using, out of curiosity? Wondering if it will have to be tweaked at all for folks using GPIO for sound.
ImageImageImageImage

User avatar
jlane52641
Posts: 53
Joined: Fri May 06, 2016 4:00 am
Location: Southeast Iowa
Has thanked: 18 times
Been thanked: 5 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by jlane52641 » Sun May 15, 2016 7:10 pm

AMAZING!! :shock: :o

Great work popcorn!!

User avatar
Synnth3t1k
Posts: 22
Joined: Wed May 11, 2016 9:11 pm
Location: Maryland

Re: Tackling Graceful Shutdowns on the GBZ

Post by Synnth3t1k » Sun May 15, 2016 11:33 pm

Popcorn wrote:
The only thing is that I'm no graphic designer. Do we know anyone that could make a simple PNG image for this? Any designers out there? I guess I could just type text in Photoshop and save it. Or maybe I could find an image of Windows 95 shutdown message! :P

Just thought I'd let you know where I'm at.

I just sat here and read through this whole thread. Hats off to you @Popcorn! My brother-in-law is a gaming major, he knows how to do graphic designs, programming, ect. Aiming to work for Bethesda soft, since they're local to us. I can get him to whip up a shutdown display if you'd like. Just let me know what you want it to say.

User avatar
Popcorn
Trailblazer
Trailblazer
Posts: 354
Joined: Thu May 05, 2016 12:58 am
Location: Berlin
Has thanked: 29 times
Been thanked: 71 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Popcorn » Sun May 15, 2016 11:49 pm

wermy wrote:
Popcorn wrote:https://youtu.be/xsdwTefIR6o

Just wanted to show the low battery shutdown as im working on it. I'm able to get it running on an overlay like a HUD. So the user can save the game as they can still control the game underneath. Right now, I made a simple countdown using imovie but I will improve it. In this video, you can see that I close mame and then it goes to emulation station in the last ten seconds. This is just to show that the countdown appears overtop all layers. This is working really well!
That is freaking awesome @Popcorn! Which GPIO pins are you using, out of curiosity? Wondering if it will have to be tweaked at all for folks using GPIO for sound.
Hi Wermy! Thanks! Thats a compliment. Right now, I'm using PCM17/GPIO pin 0 for the low battery (and PCM27/GPIO pin 2 for power off) but this can be moved around (and has since the start of this thread). I'd like to make sure they don't conflict with people that are wiring up to the PWM audio and those using the GPIO gamepad config too. Hope that works with the audio setup. Can you recommend some safe ports to use?

EDIT: For now I'm testing with a switch which simulates Low. In the real world, we will need to add a transistor/Level Shifter IC between the LBO pin and the GPIO because LBO is pulled up to battery which can be up to 4.2V which is higher than the 3.3V of GPIO. Just one more thing to tackle. I'll post everything up once it's all 100%.

User avatar
Popcorn
Trailblazer
Trailblazer
Posts: 354
Joined: Thu May 05, 2016 12:58 am
Location: Berlin
Has thanked: 29 times
Been thanked: 71 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Popcorn » Sun May 15, 2016 11:55 pm

Synnth3t1k wrote:
Popcorn wrote:
The only thing is that I'm no graphic designer. Do we know anyone that could make a simple PNG image for this? Any designers out there? I guess I could just type text in Photoshop and save it. Or maybe I could find an image of Windows 95 shutdown message! :P

Just thought I'd let you know where I'm at.

I just sat here and read through this whole thread. Hats off to you @Popcorn! My brother-in-law is a gaming major, he knows how to do graphic designs, programming, ect. Aiming to work for Bethesda soft, since they're local to us. I can get him to whip up a shutdown display if you'd like. Just let me know what you want it to say.
Awesome. I plan to utilize the Splash screen folder system of RetroPie. Originally, it was just for organization. But now, we can place as many custom assets/videos for the lowbatt condition as we like. So we'll definitely be able to get many people creating cool screens for this. This will be good!

For now, the screen I made says the following:

WARNING: Battery Very Low!
Save your game and recharge. System shutting down...

Misel
Posts: 5
Joined: Sun May 08, 2016 1:55 pm

Re: Tackling Graceful Shutdowns on the GBZ

Post by Misel » Mon May 16, 2016 12:12 am

Just in case someone wants to get a readymade version. Sonething similar is availabe at

http://mausberry-circuits.myshopify.com/

User avatar
chiz
Posts: 228
Joined: Thu May 05, 2016 12:05 am
Has thanked: 29 times
Been thanked: 119 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by chiz » Mon May 16, 2016 12:18 am

Misel wrote:Just in case someone wants to get a readymade version. Sonething similar is availabe at

http://mausberry-circuits.myshopify.com/
I think that while the mausberry is good in terms of design, the board is big compared to the Pololu switch that Popcorn is using. As you know for the GBZ build, footprint is of utmost importance. The mausberry can fit for projects with larger cases.

@Popcorn
Can't wait for the step-by-step guide as well as the wiring diagram as I'll be basing my wiring layout considering that I will now have to add a Pololu switch to my set-up. No pressure though.

User avatar
Popcorn
Trailblazer
Trailblazer
Posts: 354
Joined: Thu May 05, 2016 12:58 am
Location: Berlin
Has thanked: 29 times
Been thanked: 71 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Popcorn » Mon May 16, 2016 4:08 am

Hey guys,

So, I hit a bit of a stumbling block this morning in getting this all setup. Full disclosure: I've been using just a regular switch set to Low to simulate the Low Battery warning, as I'm still waiting for my battery to arrive still.

While reading again through all the Powerboost documentation today about the Low Battery pin, I reread the part about the pin normally pulling it's voltage up to the Battery level, but triggers Low when it hits 3.2V. Suddenly, it dawned on me that the raw battery level can be as high as 4.2V! Which is higher than the GPIO input threshold of 3.3V. Damnit, we can't connect that directly to GPIO as that could potentially fry the Pi input. So, I spent this morning looking for a solution. Looking at using some IC or Level Shifter or something and I was pretty irked about having to add more components.

I also thought more, and since this LBO pin is a variable output depending on the battery level, ranging from 4.2V full to 3V empty, I was hoping for a better solution and to read that level somehow. I was researching how to make some type of Analog to Digital Converter. This would tell us when it's low, but could also read the exact battery level. Then, I thought, we could have an overlaying battery level icon, if we had that. But again, I didn't want to build one and add more components in. Then it dawned on me that we already have an ADC in the GBZ! And all of the channels are unused! We have one in the damn Teensy LC! And the Teensy's analog inputs accept up to 5V fine. Not problem for the 4.2V to 3V range.

https://www.pjrc.com/teensy/adc.html
http://www.pjrc.com/teensy/tutorial4.html

So now, I think we are all good to go again. We can map the LBO to one of the analog Teensy ports. Meaning we are freeing up another GPIO pin (now, we only need one for the power switch), and we can potentially have a battery level overlay on screen at all times. And no new components needed. We have everything already.

So I went from pretty bummed to super stoked today already. I'm going to be programming this with the teensy as soon as I get my battery. It's still going to take some time to get this all right. But yeah, I'll be happy to share this once I get it all working. :)

User avatar
Popcorn
Trailblazer
Trailblazer
Posts: 354
Joined: Thu May 05, 2016 12:58 am
Location: Berlin
Has thanked: 29 times
Been thanked: 71 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Popcorn » Mon May 16, 2016 4:16 am

Misel wrote:Just in case someone wants to get a readymade version. Sonething similar is availabe at

http://mausberry-circuits.myshopify.com/
Yep, I've seen that. My goal was to build something for less than $5 in parts though.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest