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 > One button On/Off help!

#150003 - jay001 - Mon Jan 28, 2008 7:31 pm

i want to make it so the start and select button control the top and bottom screen light.

i plan to have the buttons like this;
start for top on, start for top off.
select for bottom on, select for bottom off.

at first i thought this would be simple but i havnt got a clue how to do it.

i dont know how to make one button turn something on with one press and off with a second press.

sorry if this is stupid but im learning.

#150008 - eKid - Mon Jan 28, 2008 8:21 pm

In other words, you want select to toggle the bottom backlight, and start to toggle the top backlight. You can do this with a simple exclusive-or with the power management registers. Here are two example functions (I hope your using libnds).
Code:

void toggleTopBacklight()
{
    writePowerManagement( readPowerManagement(PM_CONTROL_REG) ^ PM_BACKLIGHT_TOP );
}
void toggleBottomBacklight()
{
    writePowerManagement( readPowerManagement(PM_CONTROL_REG) ^ PM_BACKLIGHT_BOTTOM );
}

The problem is that the power management functions can only be used on the ARM7. So what you need to do is read the keys on the ARM9 and somehow signal the ARM7 to call the functions.