11/*
2- LockCode 1.0.1
2+ LockCode 1.0.2
33 Rename to "! Startup.nxc" and download to protect your NXT at startup.
44 When NXT is turned on it will prompt for a code. The first time the program is run it will ask you to set a code.
55 If you enter the wrong code, the NXT will flash a message, otherwise, the program will end, allowing you to access your NXT.
1010 The NXT Generation Robotics - http://robotics.bungeshea.com
1111*/
1212
13- #download "Splash.ric"
14-
1513#define FILE "LockCode.dat" // Name of the file to store the code in
1614#define FILESIZE 8
1715
@@ -26,7 +24,7 @@ struct LockCode{
2624
2725LockCode code;
2826
29- int GetNum(int x, int y = LCD_LINE5, int value = 0){
27+ int GetNum(int x, int y = LCD_LINE5, int value = 0) {
3028 while(!ButtonPressed(BTNCENTER,0)) // Poll for button presses until the center button is pressed
3129 {
3230 NumOut(x, y, value); // Draw the number on the screen
@@ -108,6 +106,7 @@ task lockCode()
108106 while(true)
109107 {
110108 TextOut(7, LCD_LINE2, "Enter passcode:", CLEAR_SCREEN);
109+ Wait(10);
111110 LockCode input = GetCode();
112111 if(input == code) // If the code that we've just entered matches the one stored on file...
113112 Stop(true); // Stop the program, allowing the user to access the NXT
@@ -120,17 +119,6 @@ task lockCode()
120119
121120task main()
122121{
123- ClearScreen(); // Clear the screen, just in case the splash image does not exist
124- GraphicOut(0, 0, "Splash.ric"); // Show the spalsh image
125122 PlayFileEx("! Startup.rso", Volume(), 0); // Play the startup sound
126- Wait(1000); // Wait for the file to finish playing
127123 Precedes(turnOff, lockCode);
128124}
129-
130- /*
131- Changelog
132-
133- 1.0.1 (2012-05-06): The NXT cannot be turned off for 10 seconds to prevent it from locking up.
134-
135- 1.0 (2012-05-04): Initial release
136- */
0 commit comments