[FTC]: NXT parameter utility

I have created a nice little system for interactively setting parameters using the NXT buttons and LCD. You may find it useful. See enclosed files. Below is a summary of the utility.

/////////////////////////////////////////////////////////////////////////////
//  params.c
//
// Provides a facility for setting named parameters using the NXT LCD and buttons.
/*   
  In the user code, first each parameter and its possible values are defined using addParam()
  and addParamValue(), then getParams() is called, which starts the interactive
  parameter-setting process. getParams() returns when the user presses the
  Exit button and confirms with the Enter button.
 
    addParam( "Alliance" );    // adds one parameter
    addParamValue( "Red" );    // adds one value option to the most-recently added param
    addParamValue( "Blue" );   // adds one value option to the most-recently added param
       
    getParams();              // starts LCD/button interactive param setting process
    listParams();             // summarizes params and their values on the LCD.   
   
    getParamValueByName( "Alliance" ); // returns INDEX of the selected value option
                                       // e.g. 0 => "Red", 1 => "Blue"
    getParamValueByNumber( 0 );        // returns INDEX of the selected value option
   
 
  This facility does not support entering arbitrary values for parameters, but only
  allows choosing from a preset list of value options that are defined using addParamValue().
 
  After getParams() returns, the user code can then access the values by calling
  either getParamValueByName() or getParamValueByNumber().  Both functions return the
  INDEX of the value of the parameter. If the parameter has four possible values,
  getParamValueBy*() will return 0, 1, 2, or 3, corresponding to the order in which
  the parameter's value was added using addParamValue().

 
  The maximum number of parameters, and the maximum number or value options each
  parameter can have, are limited by two #define macros:
 
    #define MAX_PARAMS (5)        // set these no higher than
    #define MAX_PARAM_VALUES (8)  // what you need!
   
  Setting these determines how much memory is allocated for the parameters, so you
  should set these no higher than what you need.  Each parameter has one string for
  a name and MAX_PARAM_VALUES strings for the options (regardless of how many options
  are actually associated with the parameter), so the above settings would reserve
  45 strings (8+1)*5.
 
  The call to getParams() starts an interactive button-pushing process.  On the LCD,
  the first parameter is shown on one line and its first value option on the next line.
  The ">" arrow points at the parameter name to show that the arrow keys will select
  which parameter is being set.  Pressing Enter moves the ">" arrow to the parameter's
  value, showing that the arrow keys will change the value.  Pressing Enter again goes
  back to the first mode (selecting parameters).
 
  Pressing Exit will show a confirmation screen ("Params OK?").  Pressing Enter means
  "yes," and getParams() will return.  Pressing Exit means "no" and parameter setting
  continues.
 
  Usage example:
   
         task main()
         {
                  
           initParams( );
          
           addParam     ( "Color" );  // param 0
           addParamValue( "Red" );       //   value 0
           addParamValue( "Blue" );      //   value 1
         
           addParam     ( "Side" );  // param 1
           addParamValue( "Left" );      //   value 0
           addParamValue( "Right" );     //   value 1
         
           addParam     ( "Delay" );     // param 2
           addParamValue( "0 sec"  );    //   value 0
           addParamValue( "1 sec"  );    //   value 1
           addParamValue( "2 sec"  );    //   value 2
           addParamValue( "3 sec"  );    //   value 3
           addParamValue( "4 sec"  );    //   value 4
           addParamValue( "5 sec"  );    //   value 5
           addParamValue( "6 sec"  );    //   value 6
           addParamValue( "7 sec"  );    //   value 7
         
           addParam     ( "Mode" );      // param 3
           addParamValue( "ball"  );     //   value 0
           addParamValue( "park"  );     //   value 1
           addParamValue( "nada"  );     //   value 2
         
           getParams ( );  // interactive parameter selection. 
                           // Returns when user finishes selection.
          
           byte color = getParamValueByName( "Color" );
           byte side  = getParamValueByName( "Side" );
           byte delay = getParamValueByName( "Delay" );
           byte mode  = getParamValueByName( "Mode" ); 
 
 
*/
//
/////////////////////////////////////////////////////////////////////////////
	
		

```<br><br><a class='attachment' href='/uploads/default/original/3X/e/a/eafcf58414608dbc90b6be07c19a22d51548db6d.c'>params.c</a> (12.8 KB)<br><a class='attachment' href='/uploads/default/original/3X/e/6/e6c6b4001326a698043edb88857dca339f35b14b.c'>main.c</a> (3.05 KB)<br><br><br><a class='attachment' href='/uploads/default/original/3X/e/a/eafcf58414608dbc90b6be07c19a22d51548db6d.c'>params.c</a> (12.8 KB)<br><a class='attachment' href='/uploads/default/original/3X/e/6/e6c6b4001326a698043edb88857dca339f35b14b.c'>main.c</a> (3.05 KB)<br>

Very cool!!!

Thanks!

I graduated from MFS – class of 1975!