User Tools

Site Tools


built_in:nxt

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
built_in:nxt [2015/03/10 15:33]
madlyr [Table]
built_in:nxt [2015/03/21 18:13]
madlyr [Methods]
Line 2: Line 2:
  
  
-The NXT object is used to manage the connection between your Android phone and the NXT brick.+The NXT object is used to manage the connection between your Android phone and the Lego Mindstorms NXT brick.
  
 ===== Description ===== ===== Description =====
Line 12: Line 12:
 | [[nxt_beep|Beep(frequency,duration)]]                  | Commands the NXT brick to play a tone of a given **frequency** for a given **duration** in milliseconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | [[nxt_beep|Beep(frequency,duration)]]                  | Commands the NXT brick to play a tone of a given **frequency** for a given **duration** in milliseconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
 | [[nxt_brake|Brake(motors)]]                            | Commands the NXT brick to Brake one or more of it's motors.\\ The **motors** parameter can be a single motor, for example just "A" or a combination of motors such as "ABC".\\ Unlike the [[nxt_stop|Stop]] function, this function actively brakes the motors using power from the battery.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | [[nxt_brake|Brake(motors)]]                            | Commands the NXT brick to Brake one or more of it's motors.\\ The **motors** parameter can be a single motor, for example just "A" or a combination of motors such as "ABC".\\ Unlike the [[nxt_stop|Stop]] function, this function actively brakes the motors using power from the battery.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
-| [[nxt_checkconnection|CheckConnection()]]              | Returns true if the NXT brick is currently connected to the phone/tablet but it will show a popup warning message and return false if no brick is currently connected.\\ This function is useful if you want to warn the user that they have no connection when they start pressing buttons etc in your program                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |+| [[nxt_checkconnection|CheckConnection()]]              | Returns true if the NXT brick is currently connected to the phone/tablet but it will show a popup warning message and return false if no brick is currently connected.\\ This function is useful if you want to warn the user that he/she have no connection.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | 
 +| [[nxt_connect|Connect( p1 )]]                          |  Connect 
 +|
 | [[nxt_disconnect|Disconnect()]]                        | Disconnects the Bluetooth link between your phone and the NXT brick.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | [[nxt_disconnect|Disconnect()]]                        | Disconnects the Bluetooth link between your phone and the NXT brick.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
 | [[nxt_drive|Drive(motors,power,rotation)]]             | Commands the NXT brick to drive one or more of it's motors with a given power and number of rotations.\\ The **motors** parameter can be a single motor, for example just "A" or a combination of motors such as "ABC".\\ **Power** is given as a percentage value and negative values make the motor reverse.\\ If the number of **rotations** is set to zero, then the motor will continue until the Stop function is called.                                                                                                                                                                                                                                                                                                                                                     | | [[nxt_drive|Drive(motors,power,rotation)]]             | Commands the NXT brick to drive one or more of it's motors with a given power and number of rotations.\\ The **motors** parameter can be a single motor, for example just "A" or a combination of motors such as "ABC".\\ **Power** is given as a percentage value and negative values make the motor reverse.\\ If the number of **rotations** is set to zero, then the motor will continue until the Stop function is called.                                                                                                                                                                                                                                                                                                                                                     |
 +| [[nxt_filefindfirst|FileFindFirst( p1 )]]              | FileFindFirst 
 +|
 +| [[nxt_filefindnext|FileFindNext( p1 )]]                | FileFindNext
 +|
 +| [[nxt_getbtaddress|GetBtAddress(obj)]]                 | Returns Bluetooth address of a connected NXT brick or NXT brick address given as optional **obj** parameter.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
 +| [[nxt_getbtname|GetBtName(obj)]]                       | Returns Bluetooth name of a connected NXT brick or NXT brick name given as optional **obj** parameter.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
 | [[nxt_getcurrentprogram|GetCurrentProgram()]]          | Gets the name of the NXT-G program currently running on the NXT brick.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | | [[nxt_getcurrentprogram|GetCurrentProgram()]]          | Gets the name of the NXT-G program currently running on the NXT brick.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
 | [[nxt_isbluetoothenabled|IsBluetoothEnabled()]]        | Checks if Bluetooth is enabled on the phone/tablet. Returns **true** if Bluetooth is enabled and **false** if it is disabled. This is alias for function IsEnabled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | [[nxt_isbluetoothenabled|IsBluetoothEnabled()]]        | Checks if Bluetooth is enabled on the phone/tablet. Returns **true** if Bluetooth is enabled and **false** if it is disabled. This is alias for function IsEnabled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
-| IsConnected()                                          | Returns true if the NXT brick is currently connected to the phone/tablet. Unlike CheckConnected method, it will **not show a popup warning message** and return false if no brick is currently connected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |+| [[nxt_isconnected|IsConnected()]]                      | Returns true if the NXT brick is currently connected to the phone/tablet. Unlike [[nxt_checkconnection|CheckConnection]] method, it will **not show a popup warning message** and return false if no brick is currently connected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
 | IsEnabled()                                            | Checks if Bluetooth is enabled on the phone/tablet. Returns **true** if Bluetooth is enabled and **false** if it is disabled. This is the same function as [[nxt_isbluetoothenabled|IsBluetoothEnabled]].                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | IsEnabled()                                            | Checks if Bluetooth is enabled on the phone/tablet. Returns **true** if Bluetooth is enabled and **false** if it is disabled. This is the same function as [[nxt_isbluetoothenabled|IsBluetoothEnabled]].                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
 | [[nxt_ismotoridle|IsMotorIdle(motor)]]                 | Checks if the specified **motor** ("A","B","C") is currently powered. This can be useful in order to check if a previously sent motor command has completed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | [[nxt_ismotoridle|IsMotorIdle(motor)]]                 | Checks if the specified **motor** ("A","B","C") is currently powered. This can be useful in order to check if a previously sent motor command has completed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
Line 31: Line 39:
 | [[nxt_setinvert|SetInvert(boolean)]]                   | Provides a convenient way to invert the direction of the motor commands.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | [[nxt_setinvert|SetInvert(boolean)]]                   | Provides a convenient way to invert the direction of the motor commands.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
 | [[nxt_setlampcolor|SetLampColor(input,color)]]         | Commands the NXT brick to set the **color** sensor lamp to one of the following: 'White', 'Red', 'Green', 'Blue', 'Off'.\\ The **input** parameter should be an NXT input port number between 1 and 4 (which the color sensor is plugged into).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | [[nxt_setlampcolor|SetLampColor(input,color)]]         | Commands the NXT brick to set the **color** sensor lamp to one of the following: 'White', 'Red', 'Green', 'Blue', 'Off'.\\ The **input** parameter should be an NXT input port number between 1 and 4 (which the color sensor is plugged into).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
 +| [[nxt_setonconnect|SetOnConnect(myfunc)]]              | The **SetOnConnect** function allows you to set the name of a function that you would like to be called when the NXT has been successfully connected via Bluetooth. Callback function returns status of connection (true if connection is successful, and false, if connection failed) and caller nxt object.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
 | [[nxt_setonconnected|SetOnConnected(myfunc)]]          | Allows you to set the name of a function that you would like to be called when the NXT has been successfully connected via Bluetooth.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | [[nxt_setonconnected|SetOnConnected(myfunc)]]          | Allows you to set the name of a function that you would like to be called when the NXT has been successfully connected via Bluetooth.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
 | [[nxt_showdevices|ShowDevices()]]                      | Shows the user a dialog box that contains a list of NXT bricks which are paired with the phone. The user can then select the brick to connect to via Bluetooth.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | [[nxt_showdevices|ShowDevices()]]                      | Shows the user a dialog box that contains a list of NXT bricks which are paired with the phone. The user can then select the brick to connect to via Bluetooth.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
built_in/nxt.txt · Last modified: 2015/04/18 18:02 (external edit)