Page 1 of 1
NXC ForceOff to turn off the NXT
Posted: 25 Jan 2012, 19:38
by mattallen37
Is the ForceOff command the best way to power off an NXT while tasks are running? I made a program execute at startup by naming it "! Startup", and I made the NXT shut off by pressing the exit button. I just want to be sure that ForceOff is the best way to do this.
Re: NXC ForceOff to turn off the NXT
Posted: 26 Jan 2012, 00:48
by afanofosc
I would use PowerDown() or SleepNow() from the IOCtrl module:
http://bricxcc.sourceforge.net/nbc/nxcd ... tions.html
I doubt there is any significant difference in what the firmware does when you turn off the NXT via the IOCtrl module vs turning it off via the UI module (which is where ForceOff lives).
John Hansen
Re: NXC ForceOff to turn off the NXT
Posted: 26 Jan 2012, 01:58
by mattallen37
Okay, thank you.
Edit: is it fine that I see pixel lines appear and then disappear when turning off the NXT this way (any of the three ways)? How/why does the FW's user menu shut-off not do that?
Re: NXC ForceOff to turn off the NXT
Posted: 26 Jan 2012, 15:46
by afanofosc
I don't know whether the abrupt shutoff is at all harmful. I'd be surprised if it was but I'm not a hardware guy. Do you see the lines when you use ForceOff?
In c_ui.c there is code like this:
Code: Select all
// Check for "force" off
if (IOMapUi.ForceOff != FALSE)
{
IOMapUi.ForceOff = FALSE;
VarsUi.Function = FUNC_NO_OFF;
VarsUi.Parameter = MENU_INIT;
VarsUi.State = 0;
IOMapUi.State = DRAW_MENU;
}
This causes the firmware to call cUiOff() in Functions.inl:
So you could do something to the display flags before calling PowerDown().
Code: Select all
SetDisplayFlags(0); // should turn off the display, disable refresh, use normal memory
Wait(MS_1); // give firmware a chance to process the previous IOMap change
PowerDown(); // turn off
I am pretty sure that the display will be properly reset to default values when you turn the NXT back on.
John Hansen
Re: NXC ForceOff to turn off the NXT
Posted: 26 Jan 2012, 22:53
by mattallen37
That makes no difference, even waiting 5ms.
Re: NXC ForceOff to turn off the NXT
Posted: 27 Jan 2012, 07:58
by mightor
I am not sure why you are worried
Considering the NXT doesn't get messed up if you yank the batteries out, I doubt the firmware will do anything worse than that.
- Xander
Re: NXC ForceOff to turn off the NXT
Posted: 27 Jan 2012, 21:40
by mattallen37
At this point, it's not so much that I am worried, as I am curious how the FW user menu doesn't make the lines on the screen.