Sleep - a simple sleep/low power utility

Topics on software tools like TileStudio, comments on documentation and tutorials (or the lack of) should go here.
Post Reply
User avatar
ry755
Posts: 225
Joined: Mon May 22, 2017 6:01 am

Sleep - a simple sleep/low power utility

Post by ry755 »

This is a very simple program that puts the Uzebox into a low power state. It uses the ATmega's sleep mode, using an external interrupt to wake it up.

I made this because I keep my Uzebox in my TV stand, and it can be inconvenient to reach back to plug it in. And I wanted to see if I could make the "power" button a real power button. :D

How to use it: just flash the uze file from the bootloader, and after a few seconds it goes into sleep mode. To wake it up, just press the power button, or the reset button. (But if you use the reset button, you won't see the Uzebox logo when it wakes up)

Note: if you have the bootloader set to auto boot to game, it will reset right back into the sleep utility. Either set the bootloader to Menu, or hold a controller button while waking it up.

I don't know if you guys will find this program useful or not, but I thought I'd still upload it here anyways.

It only works on real hardware, not in emulators!

Source: https://github.com/ry755/Sleep
Last edited by ry755 on Tue Jan 12, 2021 7:39 am, edited 1 time in total.
User avatar
Jubatian
Posts: 1560
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Sleep - a simple sleep/low power utility

Post by Jubatian »

This, I think, would be the most useful in the bootloader so you don't age the ATMega just for going to sleep, and it is a logical, accessible place for the function (after playing, you could return to the bootloader, and ask it for sleep or just leave it there and it timed out to sleep).

The problem is that I don't think this could be ever implemented, I guess it needed at least 30 - 40 instructions (by looking at the C code), which is just too much to fit. Anyway, I will keep it in mind.
User avatar
ry755
Posts: 225
Joined: Mon May 22, 2017 6:01 am

Re: Sleep - a simple sleep/low power utility

Post by ry755 »

Yeah, that's what I originally wanted to do, but I didn't know how to fit it in the current bootloader and I certainly didn't want to have to use the old bootloader.

I guess it is a pretty bad idea to do it this way. I'm going to look around the bootloader code and see if I can squeeze it in somehow. It probably won't work, but it doesn't hurt to look I guess.
User avatar
Jubatian
Posts: 1560
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Sleep - a simple sleep/low power utility

Post by Jubatian »

ry755 wrote: Fri Feb 23, 2018 6:43 amI'm going to look around the bootloader code and see if I can squeeze it in somehow. It probably won't work, but it doesn't hurt to look I guess.
I don't think it is possible, at least not without removing something else. Currently there are 4 instructions (8 bytes) free in the bootloader space (V.5.0.10), and I already invested a lot into minimizing code.
User avatar
ry755
Posts: 225
Joined: Mon May 22, 2017 6:01 am

Re: Sleep - a simple sleep/low power utility

Post by ry755 »

Jubatian wrote: Fri Feb 23, 2018 8:12 am I don't think it is possible, at least not without removing something else. Currently there are 4 instructions (8 bytes) free in the bootloader space (V.5.0.10), and I already invested a lot into minimizing code.
:shock: 4 instructions?! I knew it was low on space, but I didn't know it was that low on space. It's definitely not possible to fit the code there.
User avatar
Jubatian
Posts: 1560
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Sleep - a simple sleep/low power utility

Post by Jubatian »

ry755 wrote: Sat Feb 24, 2018 4:47 am:shock: 4 instructions?! I knew it was low on space, but I didn't know it was that low on space. It's definitely not possible to fit the code there.
It was like that ever since the first published version (V.5.0.00), so adding everything since then involved crazy size optimizations to make space for the improvements. That's why I think there is actually very little room there (that it is very unlikely you could add, say, 10 instructions worth of new code without removing something, no matter what you tried). FAT32 + SDHC + Fragmentation support is big (and even the latter can't be dropped as no matter what you do, you will still have the root directory fragmented on FAT32, even if it could be dropped, I would score it more important than the capability of sleeping).

The only realistic drop would likely be ditching lower case support, but that would have quite deteriorating effect on the look, and may not even return that much space like excepted (new code would have to be added to convert strings to uppercase, properly constraining them into the available character set).
User avatar
D3thAdd3r
Posts: 3175
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: Sleep - a simple sleep/low power utility

Post by D3thAdd3r »

I like the sleep idea however it could work. Even costing a couple extra flashes, I think this is a nice utility to have. Beats digging the Uzebox out of it's spot and pulling the power! So I have to say this is quite nice.
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: Sleep - a simple sleep/low power utility

Post by nicksen782 »

I use this:

https://www.amazon.com/gp/product/B00G6GNREI/

It is an inline switch. That is how I turn my Uzebox on and off.
Post Reply