Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 127 lines (83 sloc) 3.386 kB
4670ee1 forst commit
Johan authored
1 import controlP5.*;
2 ControlP5 controlP5;
3
4 Range[] thresholdRanges = new Range[group_num];
5
7231d78 Added color pickers.
Johan authored
6 ColorPicker peakCP;
7 ColorPicker normalCP;
8
4670ee1 forst commit
Johan authored
9 void setupControlInterface() {
10 controlP5 = new ControlP5(this);
11
12 ControlGroup calibration = controlP5.addGroup("Calibration", 10, 20);
13 controlP5.begin(0,10);
14
15 Toggle autoCal = controlP5.addToggle("autoCalibrate");
16 autoCal.setGroup(calibration);
17 autoCal.setLabel("Auto");
18
19 Button resetBtn = controlP5.addButton("resetCalibration");
20 resetBtn.setGroup(calibration);
21 resetBtn.setLabel("Reset");
22
f04c93f Added slew.
Johan authored
23 Toggle slewToggle = controlP5.addToggle("slewSwitch");
24 slewToggle.setGroup(calibration);
25 slewToggle.setLabel("Slew");
26
27 Slider slewSlider = controlP5.addSlider("slew",60.0,99.99,slew,0,50,200,10);
28 slewSlider.setGroup(calibration);
29
4670ee1 forst commit
Johan authored
30 controlP5.end();
31
32 ControlGroup[] lampControlGroups = new ControlGroup[group_num];
33
34 for(int i = 0; i < group_num; i++)
35 {
36 lampControlGroups[i] = controlP5.addGroup("Lamp group " + i, (width/(group_num+1))*(i+1), 20);
37 controlP5.begin(0,10);
38
39 Textfield lowInputField = controlP5.addTextfield("low " + i, 0,10,200,20);
40 lowInputField.setGroup(lampControlGroups[i]);
41 lowInputField.setId(i);
42
43 Textfield highInputField = controlP5.addTextfield("high " + i, 0,50,200,20);
44 highInputField.setGroup(lampControlGroups[i]);
45 highInputField.setId(i);
46
47 float m = sqrt(groupsMax[i] - groupsMin[i])/8;
48
49 thresholdRanges[i] = controlP5.addRange("thresholds " + i, 0, 400, avgsMin[i]*m, avgsMax[i]*m, 0,90,200,20);
50 thresholdRanges[i].setGroup(lampControlGroups[i]);
51 thresholdRanges[i].setId(i);
52
53
54 controlP5.end();
55 }
56
7231d78 Added color pickers.
Johan authored
57
f04c93f Added slew.
Johan authored
58 ControlGroup peakOut = controlP5.addGroup("Peak Output", 10, 110);
7231d78 Added color pickers.
Johan authored
59 controlP5.begin(0,10);
60
61 peakCP = controlP5.addColorPicker("peak color",0,10,255,20);
f04c93f Added slew.
Johan authored
62 peakCP.setColorValue(color(0,0,255,255));
7231d78 Added color pickers.
Johan authored
63 peakCP.setGroup(peakOut);
64
65 controlP5.end();
66
f04c93f Added slew.
Johan authored
67 ControlGroup normalOut = controlP5.addGroup("Normal Output", 10, 200);
7231d78 Added color pickers.
Johan authored
68 controlP5.begin(0,10);
69
70 normalCP = controlP5.addColorPicker("normal color",0,10,255,20);
f04c93f Added slew.
Johan authored
71 normalCP.setColorValue(color(255,0,0,200));
7231d78 Added color pickers.
Johan authored
72 normalCP.setGroup(normalOut);
73
74 controlP5.end();
75
4670ee1 forst commit
Johan authored
76 }
77
78 void controlEvent(ControlEvent theEvent) {
79 int newVal;
80
81 int id = theEvent.controller().id();
82
83 if(theEvent.controller().name().equals("low " + id)) {
84
85 try {
86
87 newVal = Integer.parseInt(theEvent.controller().stringValue());
88 groupsMin[id] = newVal;
89
90 if (newVal >= groupsMax[id]) {
91 groupsMax[id] = newVal + 1;
92 }
93
94
95 } catch(Exception e) {
96 e.printStackTrace();
97 }
98
99 } else if (theEvent.controller().name().equals("high " + id)) {
100
101 try {
102
103 newVal = Integer.parseInt(theEvent.controller().stringValue());
104 groupsMax[id] = newVal;
105
106 if (newVal <= groupsMin[id]) {
107 groupsMin[id] = newVal - 1;
108 }
109
110 } catch(Exception e) {
111 e.printStackTrace();
112 }
113
114 } else if (theEvent.controller().name().equals("thresholds " + id)) {
115
116 if (!uiThresholdForceUpdate) {
117
118 float m = sqrt(groupsMax[id] - groupsMin[id])/8;
119 avgsMin[id] = theEvent.controller().arrayValue()[0]/m;
120 avgsMax[id] = theEvent.controller().arrayValue()[1]/m;
121 }
122
123 uiThresholdForceUpdate = false;
124 }
125
126 }
Something went wrong with that request. Please try again.