Tackling Graceful Shutdowns on the GBZ

Various user-contributed guides for software-related things
Post Reply
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 » Fri May 13, 2016 9:24 pm

@Popcorn
Thanks for sharing the wiring diagram!

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 » Sat May 14, 2016 3:39 am

Masato wrote:After further thought, I think that having the Low Bat signal directly shutting down the RPI might be a bad idea. Nothing more frustrating than not having saved in awhile and your game turns off without notice! Still having a visible indicator light is absolutely necessary in this case.
These are all great points. Thanks for sharing. Can definitely try to solve them with programming. I'm doing more reading. Apparently on the Powerboost, absolutely dead is at 3.0v. So the warning level at 3.2v is good and a good time to kill. Not sure you want to wait another 30 minutes. And apparently there's no way to poll the actual power level on the Powerboost so this is our only indicator.

Since we are listening for this condition with a daemon, we can make it launch a different routine. Perhaps, perform an auto save for you and display a low battery / powering down message on the screen prior to the actual shutdown. We could maybe even make it turn on an LED mapped to a GPIO pin and put the thing in a 5 minute timer before shutdown.

I'll work this all into the daemon I'm working on. Thanks!

As an aside, there's also a way to enable auto saving which looks really interesting. Thought I'd share.

http://blog.petrockblock.com/forums/top ... retroarch/

Also this gem, looks like we can enable auto save upon RetroArch closing, and then auto loading of that save state when we boot back up. Gonna play around with this.
Automatically saves a savestate at the end of RetroArch lifetime.
The path is $SRAM_PATH.auto.

RetroArch will automatically load any savestate with this path on startup if
savestate_auto_load is set.

savestate_auto_save = false
savestate_auto_load = true

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 » Sat May 14, 2016 7:32 am

I had another brainstorm about providing an LED status display and had another eureka moment. I think we are looking at it in the wrong way and making it overly complicated. Let's make it simple and use what we have instead of soldering more LEDs and stuff.

Why don't we get some Fiber Optic strands and attach/heat shrink/glue them directly to the onboard LEDs of the Powerboost, then drill a hole in the case, and mount the fiber optics inside that, which exposes the light status of the Powerboost. Just shave off the PVC coating at the end when you put it in the case so it looks clean from the other side.

I measured the dimensions of the on board LED, and it's 2mm by 1mm, so we can use a 1mm strand like this one:

http://www.ebay.com/itm/10M-1mm-end-glo ... Sw8-tWZpRo

PS: That was just a quick search. We probably don't need 10 metres of the stuff. :) Even 10cm would do.

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 » Sat May 14, 2016 7:39 am

Ganreizu wrote:Is that the original on/off switch that you got wired up to that? So hyped for this.
Yes, the original switch will work in this config.

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 » Sat May 14, 2016 4:54 pm

So tonight I've learned how Retropie and Emulationstation work. And how they are set up and running.

Using an external trigger, say a low battery condition over GPIO, I've been able to gracefully shutdown Emulationstation, and then display an image of a message saying "Game Over. Battery extremely low. Shutting down now. Please recharge.". It waits 7 seconds, and then shuts down gracefully, cutting UART TX which kills the power. Exactly what we want. We are completely good to go for this Low Battery warning.

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.

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 » Sat May 14, 2016 6:33 pm

Wow @Popcorn! You're miles ahead of us in this shutdown thing!

Regarding the shutting down message graphic file... I think you can whip up a simple graphic file and just describe how anyone can customize the file.

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:32 am

chiz wrote:Wow @Popcorn! You're miles ahead of us in this shutdown thing!

Regarding the shutting down message graphic file... I think you can whip up a simple graphic file and just describe how anyone can customize the file.
You rock, Chiz. And further to that, today I figured out how to play a video before shutdown. Sky is the limit now. It works the same way that Retropie is set up to trigger an optional custom video on bootup.

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 3:49 pm

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!

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 » Sun May 15, 2016 4:30 pm

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.

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 6:00 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest