Controller#
The EXP Controller allows users to control and customize behaviors for their robot or display messages on the Controller’s screen.
Below is a list of available blocks:
Controller pressed? – Returns whether a selected button is pressed.
Controller position – Returns a joystick’s position.
Controller enable/disable – Enables or disables Controller-configured actions.
when Controller button pressed – Runs the attached stack when a selected button is pressed or released.
when Controller axis is changed – Runs the attached stack when a joystick axis value changes.
Controller pressed?#
The Controller pressed? block returns a Boolean indicating whether a specific button on the controller is currently pressed.
True – The specified button on the controller is being pressed.
False – The specified button on the controller is not being pressed.
<Controller [L1 v] pressed?>
Parameter |
Description |
|---|---|
button |
Which button to check:
|
Example
when started
[Drive forward while X is pressed.]
forever
if <Controller [R1 v] pressed?> then
drive [forward v]
else
stop driving
Controller position#
The Controller position block returns how far a joystick is moved along a specific axis from -100 to 100. A value of 0 means the joystick is centered.
(Controller [1 v] position)
Parameter |
Description |
|---|---|
axis |
Which axis to check:
|
Example
when started
[Drive forward while the left joystick is pushed up.]
forever
if <(Controller [3 v] position) [math_greater_than v] [0]> then
drive [forward v]
else
stop driving
Controller enable/disable#
The Controller enable/disable block enables or disables Controller configured actions from the Devices menu for all connected controllers.
Controller [Disable v]
Parameter |
Description |
|---|---|
state |
What state to set the connected controller to:
|
when started
[Disable controller configured actions until drive is done.]
Controller [Disable v]
drive [forward v] for (6) [inches v] ▶
Controller [Enable v]
when Controller axis changed#
The when Controller axis changed block runs the attached stack of blocks whenever the value of a specified joystick axis changes.
when Controller axis [1 v] changed :: hat events
Parameter |
Description |
|---|---|
device |
Which controller to use, configured in the Devices window. |
axis |
Which axis to check:
|
Example
when Controller axis [3 v] changed :: hat events
[Move forward when left joystick is up, backwards if down.]
if <(Controller [3 v] position) [math_greater_than v] [0]> then
drive [forward v]
else if <(Controller [3 v] position) [math_less_than v] [0]> then
drive [reverse v]
else
stop driving