|
9 | 9 | // // |
10 | 10 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
11 | 11 |
|
12 | | -class W_EmgJoystick extends Widget { |
| 12 | +class W_EmgJoystick extends WidgetWithSettings { |
13 | 13 | private ControlP5 emgCp5; |
14 | 14 | private Button emgSettingsButton; |
15 | 15 | private List<controlP5.Controller> cp5ElementsToCheck; |
@@ -46,8 +46,6 @@ class W_EmgJoystick extends Widget { |
46 | 46 |
|
47 | 47 | private String[] plotChannelLabels = new String[NUM_EMG_INPUTS]; |
48 | 48 |
|
49 | | - public EmgJoystickSmoothing joystickSmoothing = EmgJoystickSmoothing.POINT_9; |
50 | | - |
51 | 49 | private int DROPDOWN_HEIGHT = navH - 4; |
52 | 50 | private int DROPDOWN_WIDTH = 80; |
53 | 51 | private int DROPDOWN_SPACER = 10; |
@@ -96,11 +94,20 @@ class W_EmgJoystick extends Widget { |
96 | 94 | plotChannelLabels[i] = Integer.toString(emgJoystickInputs.getInput(i).getIndex() + 1); |
97 | 95 | } |
98 | 96 |
|
99 | | - List<String> joystickSmoothingList = EnumHelper.getEnumStrings(EmgJoystickSmoothing.class); |
| 97 | + createInputDropdowns(); |
| 98 | + } |
100 | 99 |
|
101 | | - addDropdown("emgJoystickSmoothingDropdown", "Smoothing", joystickSmoothingList, joystickSmoothing.getIndex()); |
| 100 | + @Override |
| 101 | + protected void initWidgetSettings() { |
| 102 | + super.initWidgetSettings(); |
| 103 | + widgetSettings.set(EmgJoystickSmoothing.class, EmgJoystickSmoothing.POINT_9); |
| 104 | + initDropdown(EmgJoystickSmoothing.class, "emgJoystickSmoothingDropdown", "Smoothing"); |
| 105 | + widgetSettings.saveDefaults(); |
| 106 | + } |
102 | 107 |
|
103 | | - createInputDropdowns(); |
| 108 | + @Override |
| 109 | + protected void applySettings() { |
| 110 | + updateDropdownLabel(EmgJoystickSmoothing.class, "emgJoystickSmoothingDropdown"); |
104 | 111 | } |
105 | 112 |
|
106 | 113 | public void update(){ |
@@ -234,7 +241,7 @@ class W_EmgJoystick extends Widget { |
234 | 241 | joystickRawX = unitCircleXY[0]; |
235 | 242 | joystickRawY = unitCircleXY[1]; |
236 | 243 | //Lerp the joystick values to smooth them out |
237 | | - float amount = 1.0f - joystickSmoothing.getValue(); |
| 244 | + float amount = 1.0f - widgetSettings.get(EmgJoystickSmoothing.class).getValue(); |
238 | 245 | joystickRawX = lerp(previousJoystickRawX, joystickRawX, amount); |
239 | 246 | joystickRawY = lerp(previousJoystickRawY, joystickRawY, amount); |
240 | 247 | } |
@@ -316,7 +323,7 @@ class W_EmgJoystick extends Widget { |
316 | 323 | } |
317 | 324 |
|
318 | 325 | public void setJoystickSmoothing(int n) { |
319 | | - joystickSmoothing = joystickSmoothing.values()[n]; |
| 326 | + widgetSettings.setByIndex(EmgJoystickSmoothing.class, n); |
320 | 327 | } |
321 | 328 |
|
322 | 329 | private void createEmgSettingsButton() { |
|
0 commit comments