Skip to content

Commit fc5b0d6

Browse files
committed
update
so much stuff
1 parent 6153845 commit fc5b0d6

22 files changed

+683
-304
lines changed

README.txt

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@ Setup lines: 1-5
33
1: robot name
44
2: ip
55
3: port
6-
4: name of gamepad/joystick
6+
4: telemetry data
7+
5: free line
78

8-
Object lines: 5-
9+
Object lines: 6-
910
list groups of objects in order:
1011
1:Buttons
1112
2:Axes
1213
3:UIButtons
13-
4:UIJoysticks
14-
5:UISliders
14+
4:UIIndicators
15+
5:UIJoysticks
16+
6:UISliders
1517
leave a blank line between groups
1618

19+
-Variables-
20+
Imput Variables: (0-7)
21+
variables that you send to the bot
22+
-variables 1,2,3,4 are always forwards,strafe,turn,intake
23+
Output Variables: (8-15)
24+
variables that you recieve from the bot
25+
-variable 8 is always battery voltage
26+
1727
-Object Descriptions-
1828
Imput Objects:
1929
Buttons:
@@ -26,6 +36,10 @@ UI Objects:
2636
UIButtons:
2737
-controlled by a keyboard key and/or a gamepad button
2838
-draws a button that can be pressed
39+
UIIndicators:
40+
-controlled by a variable
41+
-activates when variable is within set range
42+
-draws a circle that changes color when activated
2943
UIJoysticks:
3044
-controlled by two outputs, one for x and one for y
3145
-draws a square with a circle inside that moves in 2 dimensions
@@ -34,13 +48,17 @@ UI Objects:
3448
-draws a rectangle with another rectangle inside that moves in one dimension
3549

3650
-Object Variables-
37-
Buttons: variable,keyboardkey,gamepadbutton,onHold,onPressed,onReleased,onOff
51+
Buttons: variable,keyboardKey,gamepadButton,type,onHold,onPressed,onReleased,onOff
3852
variable: int [0 to 7]
3953
determines which variable is being modified
4054
keyboardKey: letter or number
4155
determines which key activates button
4256
gamepadButton: (look up documentation)
4357
determines which gamepad button activates button
58+
type: int [1 or 2]
59+
determines the behavior of button
60+
1: standard button
61+
2: toggle button
4462
onHold: float [-1 to 1]
4563
determines what number to set the specified output to while button is activated
4664
onPressed: float [-1 to 1]
@@ -50,7 +68,7 @@ Buttons: variable,keyboardkey,gamepadbutton,onHold,onPressed,onReleased,onOff
5068
onOff: float [-1 to 1]
5169
determines what number to set the specified output to while button is not activated
5270

53-
Axes: variable,keyboardkey1,keyboardkey2,gamepadAxis,type,step,min,max,inverted
71+
Axes: variable,keyboardKey1,keyboardKey2,gamepadAxis,type,step,min,max,inverted
5472
variable: int [0 to 7]
5573
determines which output is being modified
5674
keyboardKey1: letter or number
@@ -59,7 +77,7 @@ Axes: variable,keyboardkey1,keyboardkey2,gamepadAxis,type,step,min,max,inverted
5977
determines the positive key
6078
gamepadAxis: (look up documentation)
6179
determines which gamepad axis controls the axis
62-
type: int 1 or 2 (or more if we add more modes)
80+
type: int [1 or 2] (or more if we add more modes)
6381
determines the behavior of axis
6482
1: returns to 0
6583
2: stays on value
@@ -72,26 +90,48 @@ Axes: variable,keyboardkey1,keyboardkey2,gamepadAxis,type,step,min,max,inverted
7290
inverted: boolean
7391
determines whether gamepad axis is flipped or not
7492

75-
UIButtons: keyboardkey,gamepadbutton,x,y,color1,color2,size
76-
keyboardkey: letter or number
93+
UIButtons: keyboardKey,gamepadButton,type,x,y,color1,color2,size
94+
keyboardKey: letter or number
7795
determines which key activates button
78-
gamepadbutton: (look up documentation)
96+
gamepadButton: (look up documentation)
7997
determines which gamepad button activates button
98+
type: int [1 or 2]
99+
determines the behavior of button
100+
1: standard button
101+
2: toggle button
80102
x: float [0 to 1]
81103
determines how far left/right button appears (0 is left, 1 is right)
82104
y: float [0 to 1]
83105
determines how far up/down button appears (0 is up, 1 is down)
84-
color1: ARGB hex value (alpha red green blue)
106+
color1: RGB hex value
85107
determines the color of button when activated
86-
color2: ARGB hex value (alpha red green blue)
108+
color2: RGB hex value
109+
determines the color of button when not activated
110+
size: int
111+
determines size of button
112+
113+
UIIndicator: variable,min,max,x,y,color1,color2,size
114+
variable: int [0 to 15]
115+
determines what variable to indicate
116+
min:
117+
sets minimum for indtcated range
118+
max:
119+
sets maximum for indtcated range
120+
x: float [0 to 1]
121+
determines how far left/right button appears (0 is left, 1 is right)
122+
y: float [0 to 1]
123+
determines how far up/down button appears (0 is up, 1 is down)
124+
color1: RGB hex value
125+
determines the color of button when activated
126+
color2: RGB hex value
87127
determines the color of button when not activated
88128
size: int
89129
determines size of button
90130

91-
UIJoysticks: xvariable,yvariable,x,y,color,size
92-
xvariable: int [0 to 7]
131+
UIJoysticks: xVariable,yVariable,x,y,color,size
132+
xVariable: int [0 to 15]
93133
determines which output controls x axis of joystick
94-
yvariable: int [0 to 7]
134+
yVariable: int [0 to 15]
95135
determines which output controls y axis of joystick
96136
x: float [0 to 1]
97137
determines how far left/right axis appears (0 is left, 1 is right)
@@ -102,9 +142,13 @@ UIJoysticks: xvariable,yvariable,x,y,color,size
102142
size: int
103143
determines size of joystick
104144

105-
UISliders: variable,x,y,color,orientation,size
106-
variable: int [0 to 7]
145+
UISliders: variable,min,max,x,y,color,orientation,size
146+
variable: int [0 to 15]
107147
determines which output controls slider
148+
min: float [-1 to 1]
149+
determines the min value of slider
150+
max: float [-1 to 1]
151+
determines the max value of slider
108152
x: float [0 to 1]
109153
determines how far left/right slider appears (0 is left, 1 is right)
110154
y: float [0 to 1]
@@ -116,4 +160,7 @@ UISliders: variable,x,y,color,orientation,size
116160
1: vertical
117161
2: horizontal
118162
size: int
119-
determines size of slider
163+
determines size of slider
164+
165+
window size and layout can be changed in the setup.txt file
166+
ask weston or joshua if you want to edit that

rcmds/Axis.pde

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Axis {
1111
boolean invert;
1212
Axis (String[] configData) {
1313
variable = int(configData[0]);
14-
if (configData[1].length()!=0) {
14+
if (!configData[1].equals("")) {
1515
if (configData[1].length()>1) {
1616
keyboardKey1=int(configData[1]);
1717
} else {
@@ -20,7 +20,7 @@ class Axis {
2020
} else {
2121
keyboardKey1 = 0;
2222
}
23-
if (configData[2].length()!=0) {
23+
if (!configData[2].equals("")) {
2424
if (configData[2].length()>1) {
2525
keyboardKey2=int(configData[2]);
2626
} else {
@@ -29,7 +29,7 @@ class Axis {
2929
} else {
3030
keyboardKey2 = 0;
3131
}
32-
if (configData[3].length()>0) {
32+
if (!configData[3].equals("")) {
3333
gamepadAxis = configData[3];
3434
} else {
3535
gamepadAxis = null;
@@ -44,48 +44,48 @@ class Axis {
4444

4545
//spring
4646
if (type == 1) {
47-
toSend[variable] = 0;
47+
data[variable] = 0;
4848

4949
if (keyboardCtrl.isPressed(keyboardKey1)) {
50-
toSend[variable] = min;
50+
data[variable] = min;
5151
}
5252

5353
if (keyboardCtrl.isPressed(keyboardKey2)) {
54-
toSend[variable] = max;
54+
data[variable] = max;
5555
}
5656

57-
if (toSend[variable] == 0) {
57+
if (data[variable] == 0) {
5858
if (invert) {
59-
toSend[variable] = (max-min)/2*-gamepadVal(gamepadAxis, toSend[variable])+(max+min)/2;
59+
data[variable] = (max-min)/2*-gamepadVal(gamepadAxis, data[variable])+(max+min)/2;
6060
} else {
61-
toSend[variable] = (max-min)/2*gamepadVal(gamepadAxis, toSend[variable])+(max+min)/2;
61+
data[variable] = (max-min)/2*gamepadVal(gamepadAxis, data[variable])+(max+min)/2;
6262
}
6363
}
6464
}
6565

6666
//sticky
6767
if (type == 2) {
6868
if (keyboardCtrl.isPressed(int(keyboardKey1))) {
69-
toSend[variable] -= step;
69+
data[variable] -= step;
7070
}
7171

7272
if (keyboardCtrl.isPressed(int(keyboardKey2))) {
73-
toSend[variable] += step;
73+
data[variable] += step;
7474
}
7575

7676
if (abs(gamepadVal(gamepadAxis, 0)) > 0.15) {
7777
if (invert) {
78-
toSend[variable] -= 2*step*gamepadVal(gamepadAxis, 0);
78+
data[variable] -= 2*step*gamepadVal(gamepadAxis, 0);
7979
} else {
80-
toSend[variable] += 2*step*gamepadVal(gamepadAxis, 0);
80+
data[variable] += 2*step*gamepadVal(gamepadAxis, 0);
8181
}
8282
}
8383

84-
if (toSend[variable]>max) {
85-
toSend[variable]=max;
84+
if (data[variable]>max) {
85+
data[variable]=max;
8686
}
87-
if (toSend[variable]<min) {
88-
toSend[variable]=min;
87+
if (data[variable]<min) {
88+
data[variable]=min;
8989
}
9090
}
9191

rcmds/Button.pde

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
//variable,keyboardkey,gamepadbutton,onHold,onPressed,onReleased,onOff
1+
//variable,keyboardkey,gamepadbutton,type,onHold,onPressed,onReleased,onOff
22
class Button {
33
int variable;
44
int keyboardKey;
55
String gamepadButton;
6+
int type;
67
float onHold;
78
float onPressed;
89
float onReleased;
910
float onOff;
10-
boolean pressed;
11+
boolean pressed = false;
1112
boolean wasPressed = false;
13+
boolean wasKeyPressed = false;
1214
Button (String[] configData) {
1315
variable = int(configData[0]);
14-
if (configData[1].length()!=0) {
16+
if (!configData[1].equals("")) {
1517
if (configData[1].length()>1) {
1618
keyboardKey=int(configData[1]);
1719
} else {
@@ -20,37 +22,42 @@ class Button {
2022
} else {
2123
keyboardKey = 0;
2224
}
23-
if (configData[2].length()>0) {
25+
if (!configData[2].equals("")) {
2426
gamepadButton = configData[2];
2527
} else {
2628
gamepadButton = null;
2729
}
28-
onHold = float(configData[3]);
29-
onPressed = float(configData[4]);
30-
onReleased = float(configData[5]);
31-
onOff = float(configData[6]);
30+
type = int(configData[3]);
31+
onHold = float(configData[4]);
32+
onPressed = float(configData[5]);
33+
onReleased = float(configData[6]);
34+
onOff = float(configData[7]);
3235
}
3336
boolean run() {
3437

35-
pressed = keyboardCtrl.isPressed(keyboardKey);
36-
if (!pressed) {
37-
pressed = gamepadButton(gamepadButton, pressed);
38+
if (type == 1) {
39+
pressed = keyboardCtrl.isPressed(keyboardKey) || gamepadButton(gamepadButton, false)||virtualKeyboardButton.contains(keyboardKey)||virtualGamepadButton.contains(gamepadButton);
40+
} else {
41+
if ((keyboardCtrl.isPressed(keyboardKey) || gamepadButton(gamepadButton, false)||virtualKeyboardButton.contains(keyboardKey)||virtualGamepadButton.contains(gamepadButton)) && !wasKeyPressed) {
42+
pressed = !pressed;
43+
}
44+
wasKeyPressed = keyboardCtrl.isPressed(keyboardKey) || gamepadButton(gamepadButton, false)||virtualKeyboardButton.contains(keyboardKey)||virtualGamepadButton.contains(gamepadButton);
3845
}
3946

4047
if (pressed && wasPressed && !Float.isNaN(onHold)) {
41-
toSend[variable] = onHold;
48+
data[variable] = onHold;
4249
}
4350

4451
if (pressed && !wasPressed && !Float.isNaN(onPressed)) {
45-
toSend[variable] = onPressed;
52+
data[variable] = onPressed;
4653
}
4754

4855
if (!pressed && wasPressed && !Float.isNaN(onReleased)) {
49-
toSend[variable] = onReleased;
56+
data[variable] = onReleased;
5057
}
5158

5259
if (!pressed && !wasPressed && !Float.isNaN(onOff)) {
53-
toSend[variable] = onOff;
60+
data[variable] = onOff;
5461
}
5562
wasPressed = pressed;
5663

0 commit comments

Comments
 (0)