This repository has been archived by the owner on Feb 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeek 5 Assignment 1.java
91 lines (54 loc) · 2.7 KB
/
Week 5 Assignment 1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// WildStang Fall Software Week 5 Assignment 1
// As always, edit this file while in your branch of this folder (repository)
///////////////////////////////////////
// Modeling all of the different basic buttons
///////////////////////////////////////
// Activity 1
// create the code for a "hold" button - a button that only does something when the button is held down
// In this case, boolean isButtonOn should be true if the button is held and false when it isn't
boolean isButtonOn = false;
WsJoystickButton button = (WsJoystickButton) Core().getInputManager().getInput(WsInputs.DRIVER_FACE_DOWN);
public void inputUpdate(Input source) {
// your code goes here
}
///////////////////////////////////////
// Activity 2
// Create the code for a "toggle" button - a button that changes states based on each time it's pressed
// boolean isButtonOn will start as false, change to true once the button is pressed, then change back to false
// if pressed again, then true, etc...
boolean isButtonOn = false;
WsJoystickButton button = (WsJoystickButton) Core().getInputManager().getInput(WsInputs.DRIVER_FACE_DOWN);
public void inputUpdate(Input Source) {
// your code goes here
}
///////////////////////////////////////////
// Activity 3
// Create code for a modifier by combining the previous 2. In this case, hold button button1 sets boolean1 to true,
// but sets boolean2 to true instead if button2 is held. button3 sets boolean3 to true, but boolean4 to true if button2 is held.
// In short
// button1: boolean1
// button3: boolean3
// button1 and button2: boolean2
// button3 and button2: boolean4
boolean boolean1 = false;
boolean boolean2 = false;
boolean boolean3 = false;
boolean boolean4 = false;
DigitalInput button1 = //etc;
DigitalInput button2 = //etc;
DigitalInput button3 = //etc;
public void inputUpdate(Input source) {
// your code goes here
}
///////////////////////////////////////////
// Activity 4
// create code to handle deadband in a joystick. Deadband means that when the joystick value is below
// a certain number, it reads out 0 instead (to prevent drift if the joystick doesn't rest at exactly 0).
// For the rest of the numbers, the outputs are scaled so that the results still go from 0 to 100 linearly.
// E.G. If the deadband is 10%, then up to 10% should be 0, while now the rest of the values should be
// deadbandValue = (value - deadband) * max_value / (max_value - deadband)
double deadband = 0.1;
WsJoystickAxis joystick = (WsJoystickAxis) Core().getInputManager().getInput(WsInputs.DRIVER_LEFT_JOYSTICK_Y);
public void inputUpdate(Input Source) {
// your code goes here
}