gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Help with some power management code

#40543 - maniacdevnull - Wed Apr 20, 2005 4:07 am

I'm trying to write some power management code. I have something that seems to be working fine for now, I'm just looking if anyone has any suggestions / improvements for it.

Code:

uint8 xkeys = (~IPC->buttons);
bool screenOn = true;

...snip...

if (xkeys < 128 && screenOn)
   {
   POWER_CR = POWER_CR - 527;
   screenOn = false;
   }
if (xkeys >= 128 && !screenOn)
   {
   POWER_CR = POWER_CR + 527;
   screenOn = true;
   }


That code seems to work fine for now, when the lid is shut, the screens power off, when the lid opens they come back on. I just wish I knew how to make the power light blink like in real DS games :-(

#40545 - josath - Wed Apr 20, 2005 4:23 am

As well as turning the screens off, I would halt your program, make it go into a simple loop that just checks if the screen is opened, but not too fast, maybe once per second so the cpu sleeps alot.

#40550 - Theodore104 - Wed Apr 20, 2005 7:11 am

It's worth making sure you power down the arm7's subsystems as well; I'm not sure whether any of them are powered by default.

No idea on the light, though; my guess would be that there is some further power-saving measure we can do, perhaps a sleep mode for one or both CPUs, that triggers the light mode to change... the existing method seems to provide a comfortably long battery life, though.

- Theo

#40556 - TJ - Wed Apr 20, 2005 8:15 am

I think the light is probably software controlled rather than being an automatic function of the Sleep Mode.

I've played some games that the light didn't blink while in Sleep Mode, for instance.