Button
This file contains a procedures to read EV3 or Powered Up buttons.
Constants
The button module.
Source: lib/modules/button.whl, line: 9
Module call to read a button.
Source: lib/modules/button.whl, line: 12
BUTTON_READ | 0 |
BUTTON_WAIT_FOR_PRESS | 1 |
The possible EV3 button values.
Source: lib/modules/button.whl, line: 16
BUTTON_NONE | 0 |
BUTTON_UP | 1 |
BUTTON_CENTER | 2 |
BUTTON_DOWN | 3 |
BUTTON_RIGHT | 4 |
BUTTON_LEFT | 5 |
The Powered Up button bits.
Source: lib/modules/button.whl, line: 24
BUTTON_PU_LEFT_MIN | 1 |
BUTTON_PU_LEFT_CENTER | 2 |
BUTTON_PU_LEFT_RIGHT | 4 |
BUTTON_PU_RIGHT_MIN | 8 |
BUTTON_PU_RIGHT_CENTER | 16 |
BUTTON_PU_RIGHT_PLUS | 32 |
Spike connect button.
Source: lib/modules/button.whl, line: 32
Procedures
buttonLayer
Source: lib/modules/button.whl, line: 35
Read a button value from a given layer, the layer only applies to Powered Up and Spike devices.
proc buttonLayer(number layer)
Parameters:
Name | Type | Description |
layer | number | The layer, the device of which you want to read the buttons. |
Return: In case of EV3 then button pressed value -if any-: BUTTON_NONE, BUTTON_LEFT, BUTTON_CENTER, BUTTON_RIGHT,
BUTTON_UP or BUTTON_DOWN.
In case of Powered Up then the value can contain one or more bits:
BUTTON_PU_LEFT_MIN, BUTTON_PU_LEFT_CENTER, BUTTON_PU_LEFT_RIGHT, BUTTON_PU_LEFT_MIN,
BUTTON_PU_LEFT_CENTER or BUTTON_PU_LEFT_RIGHT.
For Spike the button value can be BUTTON_LEFT, BUTTON_CENTER BUTTON_RIGHT or BUTTON_SPIKE_CONNECT.
button
Source: lib/modules/button.whl, line: 48
Read a button value from a given layer, the layer only applies to Powered Up and Spike devices.
proc button()
Return: In case of EV3 then button pressed value -if any-: BUTTON_NONE, BUTTON_LEFT, BUTTON_CENTER, BUTTON_RIGHT,
BUTTON_UP or BUTTON_DOWN.
In case of Powered Up then the value can contain one or more bits:
BUTTON_PU_LEFT_MIN, BUTTON_PU_LEFT_CENTER, BUTTON_PU_LEFT_RIGHT, BUTTON_PU_LEFT_MIN,
BUTTON_PU_LEFT_CENTER or BUTTON_PU_LEFT_RIGHT.
For Spike the button value can be BUTTON_LEFT, BUTTON_CENTER BUTTON_RIGHT or BUTTON_SPIKE_CONNECT.
With the button module you can read the state of the EV3 buttons.
#include "lib/modules/button.whl"
#include "lib/modules/screen.whl"
proc main()
number b
setTextSize(2)
repeat
b = button()
drawNumber(73, 56, b)
end
end
waitForPress
Source: lib/modules/button.whl, line: 59
Wait until a button is pressed.
proc waitForPress()