1 /****************************************************************************
3 ** OpenXsensor Configurator: GUI for generating oxs_config.h file **
4 ** Copyright (C) 2014 David LABURTHE **
6 ** This program is free software: you can redistribute it and/or modify **
7 ** it under the terms of the GNU General Public License as published by **
8 ** the Free Software Foundation, either version 3 of the License, or **
9 ** (at your option) any later version. **
11 ** This program is distributed in the hope that it will be useful, **
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
14 ** GNU General Public License for more details. **
16 ** You should have received a copy of the GNU General Public License **
17 ** along with this program. If not, see <http://www.gnu.org/licenses/>. **
19 *****************************************************************************
20 ** Author: David LABURTHE **
21 ** Contact: dlaburthe@free.fr **
22 ** Date: 20.08.2014 **
23 *****************************************************************************/
27 boolean tempActive = false ; // Define temperature sensor availability
29 String oxsVersion = "v1.x" ;
30 String oxsCversion = "v1.0" ;
32 String day = (day() < 10) ? "0" + day() : "" + day() ;
33 String month = (month() < 10) ? "0" + month() : "" + month() ;
35 String oxsDirectory = "" ;
37 String outputConfigDir = "" ;
39 int blueAct = color(15, 165, 255) ;
40 int orangeAct = color(255, 128, 0) ;
41 int grayedColor = color(155, 155, 155) ;
46 PFont fontLabel ; //= createFont("arial.ttf", 12, false) ;
47 PFont fontItalic ; //= createFont("arial italic", 12, false) ;
48 PFont fontCells ; //= createFont("arial bold", 12, false) ;
49 PFont font16 ; //= createFont("arial", 16, false) ;
50 PFont font20 ; //= createFont("arial", 20, false) ;
54 ControlGroup messageBox;
63 DropdownList serialPin ;
64 Textlabel serialPinL ;
69 Textlabel sensitivity ;
72 DropdownList climbPin ;
76 DropdownList ddlNbrCells ;
79 int dataSentFieldNbr = 8 ;
81 String[] analogPins = new String[8] ; // Analogic pins
83 StringList messageList = new StringList() ;
85 boolean numPinsValid ;
86 boolean analogPinsValid ;
88 boolean oxsMeasureValid ;
94 int myColorBackground = 150 ;
106 int varioHysteresis ;
107 int outClimbRateMinMax ;
109 // *************************************************************************
110 // ******************************** SETUP ********************************
111 // *************************************************************************
117 cp5 = new ControlP5(this) ;
119 //Alt+mouseDragged to move controllers on the screen
120 //Alt+Shift+h to show/hide controllers
121 //Alt+Shift+s to save properties (what are properties? have a look at the properties examples)
122 //Alt+Shift+l to load properties
123 //cp5.enableShortcuts();
125 oxsI = loadShape("OXSc_Icon.svg") ;
126 oxsL = loadShape("OXSc_Logo.svg") ;
128 PGraphics icon = createGraphics(64, 64, JAVA2D) ;
130 icon.shape(oxsI, 0, 0, 64, 64) ;
132 frame.setIconImage(icon.image) ;
134 fontLabel = createFont("arial.ttf", 12, false) ;
135 fontItalic = createFont("ariali.ttf", 12, false) ;
136 fontCells = createFont("arialbd.ttf", 12, false) ;
137 font16 = createFont("arial.ttf", 16, false) ;
138 font20 = createFont("arial.ttf", 20, false) ;
140 for ( int i = 0; i < analogPins.length; i++ ) {
141 analogPins[i] = ("A" + i );
144 cp5.setControlFont(fontLabel, 12);
147 // ------------------------ TABS definition ------------------------
148 // By default all controllers are stored inside Tab 'default'
149 cp5.window().setPositionOfTabs(0, 80);
152 cp5.addButton("about")
154 .setPosition(355, 14) // Other positions (5, 14) (355, 38)
156 .setColorLabel(#000000)
157 .setColorBackground(color(150))
158 .setColorForeground(blueAct)
159 .setColorActive(orangeAct)
162 cp5.getController("about").captionLabel().toUpperCase(false) ;
164 // ----------------------- First tab: GENERAL SETTINGS ----------------------
165 general = cp5.getTab("default")
167 .setColorLabel(color(255))
168 .setColorForeground(color(200))
169 .setColorBackground(color(70))
170 .setColorActive(orangeAct)
171 .setLabel("GENERAL Settings")
174 general.captionLabel().toUpperCase(false) ;
177 oxsDir = cp5.addTextfield("oxsDirectory")
178 .setLabel("OXS directory ")
179 .setPosition(100, 110)
180 .setColorLabel(color(0))
184 oxsDir.getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER) ;
185 oxsDir.captionLabel().toUpperCase(false) ;
186 cp5.getTooltip().register("oxsDirectory", "Choose OXS source directory");
188 cp5.addButton("oxsDirButton")
189 .setColorForeground(blueAct)
191 .setPosition(365, 111)
194 cp5.getTooltip().register("oxsDirButton", "Choose OXS source directory");
197 protocol = cp5.addTextlabel("protocol")
198 .setText("FrSky Protocol ")
199 .setPosition(10, 141)
200 .setColorValue(#000000)
203 //protocol.captionLabel().toUpperCase(false) ;
204 cp5.getProperties().remove(cp5.getController("protocol")) ;
205 cp5.getTooltip().register("protocol", "Choose protocol");
207 prot = cp5.addDropdownList("protocolChoice")
208 .setPosition(100, 160)
210 .setColorForeground(blueAct)
211 .setBackgroundColor(color(190))
215 prot.captionLabel().set("Choose");
216 prot.captionLabel().style().marginTop = 2 ;
217 prot.addItem("HUB - D rx", 1);
218 prot.addItem("Smart Port - X rx", 2);
219 prot.toUpperCase(false) ;
220 cp5.getProperties().remove(cp5.getGroup("protocolChoice"), "ListBoxItems") ;
223 serialPinL = cp5.addTextlabel("serialPinlabel")
224 .setText("Serial output PIN number ")
225 .setPosition(215, 141)
226 .setColorValue(#000000)
228 cp5.getProperties().remove(cp5.getController("serialPinlabel")) ;
229 cp5.getTooltip().register("serialPinlabel", "Choose the serial output PIN number - Default: 4 -");
232 serialPin = cp5.addDropdownList("serialPin")
233 .setPosition(365, 160)
235 .setColorForeground(blueAct)
236 .setBackgroundColor(color(190))
240 serialPin.captionLabel().set(" ") ;
241 serialPin.captionLabel().style().marginTop = 2 ;
242 serialPin.addItem("2", 2) ;
243 serialPin.addItem("4", 4) ;
244 serialPin.setValue(4) ;
245 cp5.getProperties().remove(cp5.getGroup("serialPin"), "ListBoxItems") ;
247 // Internal reference 1.1v
248 cp5.addToggle("intRef")
249 .setPosition(190, 173)
250 .setLabel("Internal voltage reference (1.1v) ")
252 customizeToggleSensor(cp5.getController("intRef")) ;
253 cp5.getTooltip().register("intRef", "Voltage measurement reference");
258 aVcc = cp5.addTextfield("arduinoVCC")
259 .setLabel("Arduino VCC volts")
260 .setPosition(330, 170)
261 .setColorLabel(color(0))
262 .setColorValueLabel(color(255))
267 aVcc.getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER) ;
268 aVcc.captionLabel().toUpperCase(false) ;
269 //aVcc.getValueLabel().align(ControlP5.RIGHT, ControlP5.CENTER) ;
270 aVcc.setInputFilter(ControlP5.FLOAT);
273 cp5.addNumberbox("arduinoVccNb")
274 .setPosition(325, 170)
277 .setMultiplier(0.01) // set the sensitifity of the numberbox
278 .setDecimalPrecision(2)
279 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
281 .setLabel("Arduino VCC volts")
282 .setColorLabel(color(0))
284 cp5.getController("arduinoVccNb").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(-65) ;
285 cp5.getController("arduinoVccNb").captionLabel().toUpperCase(false) ;
286 cp5.getTooltip().register("arduinoVccNb", "Arduino alimentation source");
289 cp5.addToggle("resetButton")
290 .setPosition(190, 203)
291 .setLabel("Reset button")
293 customizeToggleSensor(cp5.getController("resetButton")) ;
294 cp5.getController("resetButton").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(8) ;
297 cp5.addTextlabel("resetButtonPinLabel")
298 .setText("Reset button PIN number ")
299 .setPosition(215, 202)
300 .setColorValue(#000000)
302 cp5.getProperties().remove(cp5.getController("resetButtonPinLabel")) ;
303 cp5.getTooltip().register("resetButtonPinLabel", "- Default: 10 -");
305 cp5.addDropdownList("resetButtonPin")
306 .setPosition(360, 220)
308 .setColorForeground(blueAct)
309 .setBackgroundColor(color(190))
313 cp5.get(DropdownList.class, "resetButtonPin").captionLabel().set(" ") ;
314 cp5.get(DropdownList.class, "resetButtonPin").captionLabel().style().marginTop = 2 ;
315 for ( int i = 2; i <= 12; i++ ) {
316 cp5.get(DropdownList.class, "resetButtonPin").addItem("" + i, i) ;
318 cp5.getGroup("resetButtonPin").setValue(10) ;
319 cp5.getProperties().remove(cp5.getGroup("resetButtonPin"), "ListBoxItems") ;
322 cp5.addToggle("saveEprom")
323 .setPosition(190, 233)
324 .setLabel("Save data to EEPROM")
326 customizeToggleSensor(cp5.getController("saveEprom")) ;
327 cp5.getController("saveEprom").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(8) ;
328 //cp5.getTooltip().register("saveEprom", "...");
331 sensors = cp5.addTextlabel("sensors")
334 .setColorValue(#FFFFFF)
336 cp5.getProperties().remove(cp5.getController("sensors")) ;
337 cp5.getTooltip().register("sensors", "Sensors settings");
340 cp5.addToggle("vario")
341 .setPosition(85, 285)
344 customizeToggleSensor(cp5.getController("vario")) ;
346 cp5.addToggle("voltage")
347 .setPosition(220, 285)
348 .setLabel("Voltage / Other ")
350 customizeToggleSensor(cp5.getController("voltage")) ;
352 cp5.addToggle("current")
353 .setPosition(355, 285)
354 .setLabel("Current ")
356 customizeToggleSensor(cp5.getController("current")) ;
359 cp5.addToggle("temperature")
360 .setPosition(85, 315)
361 .setLabel("Temperature ")
363 customizeToggleSensor(cp5.getController("temperature")) ;
365 cp5.getController("temperature").lock() ;
369 .setPosition(220, 315)
372 customizeToggleSensor(cp5.getController("rpm")) ;
374 // ---------------------------- Tab 2 : Vario settings ------------------------------
377 .setColorForeground(color(200))
378 .setColorBackground(color(70))
379 .setColorActive(blueAct)
384 cp5.getTab("vario").captionLabel().toUpperCase(false) ;
386 // Vario sensitivity range
387 cp5.addTextlabel("sensitivityRange")
388 .setText("Sensitivity Min.")
389 .setPosition(10, 110)
390 .setColorValue(#000000)
393 cp5.getProperties().remove(cp5.getController("sensitivityRange")) ;
395 cp5.addRange("sensMinMax")
396 .setPosition(138, 108)
397 .setCaptionLabel("Max.")
401 .setRangeValues(50.9, 50.9)
403 //cp5.getController("sensMinMax").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER) ;
404 customizeRange(cp5.getController("sensMinMax")) ;
405 cp5.getTooltip().register("sensMinMax", "Sensitivity based on vertical speed - Default: 50:50 -");
407 // Vario Vertical speed sensitivity range
408 cp5.addTextlabel("vSpeedSensitivityRng")
409 .setText("Vertical speed sensibility (cm/s) ")
410 .setPosition(10, 135)
411 .setColorValue(#000000)
414 cp5.getProperties().remove(cp5.getController("vSpeedSensitivityRng")) ;
415 cp5.getTooltip().register("vSpeedSensitivityRng", "Vertical speed threshold sensitivity - Default: 20:100 -");
417 cp5.addNumberbox("vSpeedMin")
418 .setPosition(230, 134)
420 .setColorActive(blueAct)
422 .setMultiplier(0.5) // set the sensitifity of the numberbox
423 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
426 .setColorLabel(color(0))
429 cp5.getController("vSpeedMin").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(5) ;
430 cp5.getController("vSpeedMin").captionLabel().toUpperCase(false) ;
432 cp5.addNumberbox("vSpeedMax")
433 .setPosition(293, 134)
435 .setColorActive(blueAct)
437 .setMultiplier(0.5) // set the sensitifity of the numberbox
438 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
441 .setColorLabel(color(0))
444 cp5.getController("vSpeedMax").getCaptionLabel().align(ControlP5.RIGHT_OUTSIDE, ControlP5.CENTER).setPaddingX(5) ;
445 cp5.getController("vSpeedMax").captionLabel().toUpperCase(false) ;
447 cp5.getController("vSpeedMin").setBroadcast(true) ;
448 cp5.getController("vSpeedMax").setBroadcast(true) ;
450 // RC Remote PPM pin and settings
452 .setLabel("RC Remote sensitivity")
453 .setPosition(138, 175)
456 customizeToggle(cp5.getController("ppm")) ;
458 ppmPinL = cp5.addTextlabel("ppmPinL")
460 .setPosition(246, 175)
461 .setColorValue(#000000)
464 cp5.getProperties().remove(cp5.getController("ppmPinL")) ;
465 cp5.getTooltip().register("ppmPinL", "- Default: 2 -");
467 ppmPin = cp5.addDropdownList("ppmPin")
468 .setPosition(303, 194)
470 .setColorForeground(orangeAct)
471 .setColorActive(blueAct)
472 .setBackgroundColor(color(190))
477 ppmPin.captionLabel().set(" ");
478 ppmPin.captionLabel().style().marginTop = 2 ;
479 ppmPin.addItem("2", 2);
480 ppmPin.addItem("3", 3);
482 ppmPin.toUpperCase(false) ;
483 cp5.getProperties().remove(cp5.getGroup("ppmPin"), "ListBoxItems") ;
486 cp5.addTextlabel("ppmRngL")
487 .setText("PPM range (us) ")
489 .setColorValue(#000000)
492 cp5.getProperties().remove(cp5.getController("ppmRngL")) ;
493 cp5.getTooltip().register("ppmRngL", "RC control range - Default: 988:2012 -");
495 cp5.addNumberbox("ppmRngMin")
496 .setPosition(230, 199)
498 .setColorActive(blueAct)
500 .setMultiplier(0.5) // set the sensitifity of the numberbox
501 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
504 .setColorLabel(color(0))
507 cp5.getController("ppmRngMin").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(5) ;
508 cp5.getController("ppmRngMin").captionLabel().toUpperCase(false) ;
510 cp5.addNumberbox("ppmRngMax")
511 .setPosition(293, 199)
513 .setColorActive(blueAct)
514 .setRange(1912, 2112)
515 .setMultiplier(0.5) // set the sensitifity of the numberbox
516 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
519 .setColorLabel(color(0))
522 cp5.getController("ppmRngMax").getCaptionLabel().align(ControlP5.RIGHT_OUTSIDE, ControlP5.CENTER).setPaddingX(5) ;
523 cp5.getController("ppmRngMax").captionLabel().toUpperCase(false) ;
525 // PPM sensitivity range
526 cp5.addTextlabel("ppmSensRngL")
527 .setText("PPM sensitivity Min.")
529 .setColorValue(#000000)
532 cp5.getProperties().remove(cp5.getController("ppmSensRngL")) ;
534 cp5.addRange("ppmSensMinMax")
535 .setPosition(138, 223)
537 .setCaptionLabel("Max.")
540 .setRangeValues(20, 100.5)
542 customizeRange(cp5.getController("ppmSensMinMax")) ;
543 cp5.getTooltip().register("ppmSensMinMax", "RC control sensitivity range - Default: 20:100 -");
546 cp5.addSlider("varioHysteresis")
547 .setPosition(138, 260)
549 .setLabel("Hysteresis (cm/s)")
550 .setColorForeground(blueAct)
551 .setColorLabel(#000000)
552 .setColorValue(#000000)
557 // reposition the Labels for controller 'slider'
558 cp5.getController("varioHysteresis").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
559 cp5.getController("varioHysteresis").getValueLabel().align(ControlP5.RIGHT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
560 cp5.getController("varioHysteresis").captionLabel().toUpperCase(false) ;
561 cp5.getTooltip().register("varioHysteresis", "Minimum measurement difference - Default: 5 -");
563 // Analog climb rate pin and settings
564 cp5.addToggle("analogClimb")
565 .setLabel("Analog climb rate")
566 .setPosition(138, 288)
569 customizeToggle(cp5.getController("analogClimb")) ;
571 cp5.addTextlabel("climbPinL")
572 .setText("Climb rate Pin ")
573 .setPosition(218, 288)
574 .setColorValue(#000000)
577 cp5.getProperties().remove(cp5.getController("climbPinL")) ;
578 cp5.getTooltip().register("climbPinL", "- Default: 3 -");
580 climbPin = cp5.addDropdownList("climbPin")
581 .setPosition(303, 307)
583 .setColorForeground(orangeAct)
584 .setColorActive(blueAct)
585 .setBackgroundColor(color(190))
590 climbPin.captionLabel().set(" ");
591 climbPin.captionLabel().style().marginTop = 2 ;
592 climbPin.addItem("3", 3);
593 climbPin.addItem("11", 11);
594 climbPin.setValue(3);
595 climbPin.toUpperCase(false) ;
596 cp5.getProperties().remove(cp5.getGroup("climbPin"), "ListBoxItems") ;
598 // Output climb rate range
599 cp5.addTextlabel("outClimbRateRngL")
600 .setText("Climb rate Min.")
601 .setPosition(10, 315)
602 .setColorValue(#000000)
605 cp5.getProperties().remove(cp5.getController("outClimbRateRngL")) ;
607 cp5.addRange("outClimbRateMinMax")
608 .setPosition(138, 312)
610 .setCaptionLabel("Max.")
613 .setRangeValues(-3, 3.3)
615 //cp5.getController("outClimbRateMinMax").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER) ;
616 customizeRange(cp5.getController("outClimbRateMinMax")) ;
617 cp5.getTooltip().register("outClimbRateMinMax", "Analog climb rate range - Default: -3:3 -");
620 // ------------------------------ Tab 3 : Voltage settings ------------------------------
621 cp5.getTab("voltage")
623 .setColorForeground(color(200))
624 .setColorBackground(color(70))
625 .setColorActive(blueAct)
626 .setLabel("Voltage...")
630 cp5.getTab("voltage").captionLabel().toUpperCase(false) ;
632 // Voltage 1-6 toggle
633 cp5.addTextlabel("voltages")
634 .setText("Voltage number")
635 .setPosition(10, 138)
636 .setColorValue(#000000)
639 cp5.getProperties().remove(cp5.getController("voltages")) ;
641 for ( int i = 1; i <= voltNbr; i++ ) {
642 cp5.addToggle("volt" + i)
644 .setPosition(127 + 45 * (i-1), 140)
647 customizeToggleVolt(cp5.getController("volt" + i)) ;
651 cp5.addTextlabel("voltPin")
652 .setText("Pin number")
653 .setPosition(10, 165)
654 .setColorValue(#000000)
657 cp5.getProperties().remove(cp5.getController("voltPin")) ;
659 for ( int i = 1; i <= voltNbr; i++ ) {
660 cp5.addDropdownList("ddlVolt" + i)
661 .setPosition(120 + 45 * (i-1), 185)
664 customizeDdlVpin(cp5.get(DropdownList.class, "ddlVolt" + i)) ;
665 cp5.get(DropdownList.class, "ddlVolt" + i).setValue(-1) ;
666 cp5.getProperties().remove(cp5.getGroup("ddlVolt" + i), "ListBoxItems") ;
669 // Voltage 1-6 divider factor
670 cp5.addTextlabel("voltDivider")
671 .setText("Divider factor ")
672 .setPosition(10, 196)
673 .setColorValue(#000000)
676 cp5.getProperties().remove(cp5.getController("voltDivider")) ;
677 cp5.getTooltip().register("voltDivider", "- Default: 1 -");
679 for ( int i = 1; i <= voltNbr; i++ ) {
680 cp5.addNumberbox("dividerVolt" +i)
681 .setPosition(115 + 45 * (i-1), 195)
683 .setColorActive(blueAct)
684 .setDecimalPrecision(2)
686 .setMultiplier(0.01) // set the sensitifity of the numberbox
687 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
693 cp5.addTextfield("dividerVolt" + i)
694 .setPosition(120 + 45 * (i-1), 195)
696 .setCaptionLabel(" ")
698 .setColorActive(blueAct)
705 // Voltage 1-6 Offset
706 cp5.addTextlabel("voltOffset")
707 .setText("Offset (mV) ")
708 .setPosition(10, 225)
709 .setColorValue(#000000)
712 cp5.getProperties().remove(cp5.getController("voltOffset")) ;
713 cp5.getTooltip().register("voltOffset", "- Default: 0 -");
715 for ( int i = 1; i <= voltNbr; i++ ) {
716 cp5.addNumberbox("offsetVolt" +i)
717 .setPosition(114 + 45 * (i-1), 224)
719 .setColorActive(blueAct)
720 .setDecimalPrecision(0)
721 .setRange(-5000, 5000)
722 .setMultiplier(1) // set the sensitifity of the numberbox
723 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
730 // Cells monitoring -> Number of Cells
731 cp5.addToggle("cells")
732 .setPosition(148, 280)
733 .setLabel("Battery cells monitoring")
734 .setColorForeground(orangeAct)
735 .setColorBackground(color(70))
736 .setColorActive(blueAct)
737 .setColorLabel(#000000)
741 cp5.getController("cells").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
742 cp5.getController("cells").captionLabel().toUpperCase(false) ;
744 cp5.addTextlabel("NbrCells")
745 .setText("Number of Cells")
746 .setPosition(183, 279)
747 .setColorValue(#000000)
750 cp5.getProperties().remove(cp5.getController("NbrCells")) ;
752 ddlNbrCells = cp5.addDropdownList("ddlNbrCells")
753 .setColorForeground(orangeAct)
754 .setColorBackground(color(70))
755 .setColorActive(blueAct)
756 .setPosition(283, 299)
762 for ( int i = 1; i <= 6; i++ ) {
763 ddlNbrCells.addItem("" + i, i);
765 ddlNbrCells.setValue(1) ;
766 ddlNbrCells.captionLabel().style().marginTop = 2 ;
767 ddlNbrCells.toUpperCase(false) ;
768 cp5.getProperties().remove(cp5.getGroup("ddlNbrCells"), "ListBoxItems") ;
771 // ------------------------------ Tab 4 : Current settings ------------------------------
772 cp5.getTab("current")
774 .setColorForeground(color(200))
775 .setColorBackground(color(70))
776 .setColorActive(blueAct)
781 cp5.getTab("current").captionLabel().toUpperCase(false) ;
784 cp5.addTextlabel("currentPinL")
785 .setText("Current sensor pin number")
786 .setPosition(10, 120)
787 .setColorValue(#000000)
790 cp5.getProperties().remove(cp5.getController("currentPinL")) ;
792 cp5.addDropdownList("currentPin")
793 .setColorForeground(orangeAct)
794 .setColorBackground(color(70))
795 .setColorActive(blueAct)
796 .setPosition(165, 139)
802 cp5.get(DropdownList.class, "currentPin").addItem("--", -1) ;
803 cp5.get(DropdownList.class, "currentPin").addItems(analogPins) ;
804 cp5.getGroup("currentPin").captionLabel().style().marginTop = 2 ;
805 cp5.get(DropdownList.class, "currentPin").setValue(-1) ;
806 cp5.get(DropdownList.class, "currentPin").toUpperCase(false) ;
807 cp5.getProperties().remove(cp5.getGroup("currentPin"), "ListBoxItems") ;
809 // Current sensor output sensitivity
810 cp5.addNumberbox("currentOutSensNb")
811 .setColorActive(blueAct)
812 .setPosition(165, 154)
815 .setMultiplier(0.5) // set the sensitifity of the numberbox
816 .setDecimalPrecision(0)
817 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
818 .setLabel("Output sensitivity (mV/A)")
819 .setColorLabel(color(0))
822 cp5.getController("currentOutSensNb").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(8) ;
823 cp5.getController("currentOutSensNb").captionLabel().toUpperCase(false) ;
825 // Current sensor offset
826 cp5.addNumberbox("currentOutOffsetNb")
827 .setColorActive(blueAct)
828 .setPosition(165, 189)
830 .setRange(-5000, 5000)
831 .setMultiplier(1) // set the sensitifity of the numberbox
832 .setDecimalPrecision(0)
833 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
834 .setLabel("Output offset (mV)")
835 .setColorLabel(color(0))
838 cp5.getController("currentOutOffsetNb").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(8) ;
839 cp5.getController("currentOutOffsetNb").captionLabel().toUpperCase(false) ;
840 //cp5.getTooltip().register("currentOutOffsetNb", "...");
842 // Current sensor divider factor
843 cp5.addNumberbox("currentDivNb")
844 .setColorActive(blueAct)
845 .setPosition(165, 224)
848 .setMultiplier(0.01) // set the sensitifity of the numberbox
849 .setDecimalPrecision(2)
850 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
852 .setLabel("Divider factor")
853 .setColorLabel(color(0))
856 cp5.getController("currentDivNb").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(8) ;
857 cp5.getController("currentDivNb").captionLabel().toUpperCase(false) ;
858 cp5.getTooltip().register("currentDivNb", "- Default: 1 -");
861 // Current sensor Vcc
862 cp5.addNumberbox("currentVccNb")
863 .setColorActive(blueAct)
864 .setPosition(330, 118)
867 .setMultiplier(0.05) // set the sensitifity of the numberbox
868 .setDecimalPrecision(1)
869 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
871 .setLabel("Current sensor Vcc volts")
872 .setColorLabel(color(0))
875 cp5.getController("currentVccNb").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(-59) ;
876 cp5.getController("currentVccNb").captionLabel().toUpperCase(false) ;
877 cp5.getTooltip().register("currentVccNb", "Current sensor alimentation source value");
880 // Current sensor direction
881 cp5.addTextlabel("currentDirL")
882 .setText("Unidirectional")
883 .setPosition(10, 157)
884 .setColorValue(#000000)
887 cp5.getProperties().remove(cp5.getController("currentDirL")) ;
889 cp5.addToggle("currentDir")
890 .setColorForeground(orangeAct)
891 .setColorBackground(color(70))
892 .setColorActive(blueAct)
893 .setColorLabel(#000000)
894 .setPosition(98, 155)
896 .setLabel("Bidirectional")
897 .setMode(ControlP5.SWITCH)
900 cp5.getController("currentDir").getCaptionLabel().align(ControlP5.RIGHT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
901 cp5.getController("currentDir").captionLabel().toUpperCase(false) ;
904 // ------------------------------ Tab 5 : Temperature settings ------------------------------
905 cp5.getTab("temperature")
907 .setColorForeground(color(200))
908 .setColorBackground(color(70))
909 .setColorActive(blueAct)
910 .setLabel("Temperature")
914 cp5.getTab("temperature").captionLabel().toUpperCase(false) ;
917 cp5.addToggle("vTemp")
918 .setPosition(142, 120)
919 .setLabel("Use vario temperature")
920 .setColorForeground(orangeAct)
921 .setColorBackground(color(70))
922 .setColorActive(blueAct)
923 .setColorLabel(#000000)
925 .setTab("temperature")
927 cp5.getController("vTemp").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
928 cp5.getController("vTemp").captionLabel().toUpperCase(false) ;
930 // Temperature sensor pin
931 cp5.addTextlabel("tempPinL")
932 .setText("Temperature sensor pin number")
933 .setPosition(10, 157)
934 .setColorValue(#000000)
935 .setTab("temperature")
937 cp5.getProperties().remove(cp5.getController("tempPinL")) ;
939 cp5.addDropdownList("tempPin")
940 .setColorForeground(orangeAct)
941 .setColorBackground(color(70))
942 .setColorActive(blueAct)
943 .setPosition(193, 176)
947 .setTab("temperature")
949 cp5.get(DropdownList.class, "tempPin").addItem("--", -1) ;
950 cp5.get(DropdownList.class, "tempPin").addItems(analogPins) ;
951 cp5.get(DropdownList.class, "tempPin").setValue(-1) ;
952 cp5.getGroup("tempPin").captionLabel().style().marginTop = 2 ;
953 cp5.get(DropdownList.class, "tempPin").toUpperCase(false) ;
954 cp5.getProperties().remove(cp5.getGroup("tempPin"), "ListBoxItems") ;
956 // Temperature sensor offset
957 cp5.addTextfield("tempOffset")
958 .setLabel("Temperature sensor offset")
959 .setPosition(164, 192)
960 .setColorLabel(color(0))
961 .setColorValueLabel(color(255))
962 .setColorActive(blueAct)
966 .setTab("temperature")
968 cp5.getController("tempOffset").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
969 cp5.getController("tempOffset").captionLabel().toUpperCase(false) ;
972 // ------------------------------ Tab 6 : RPM settings ------------------------------ needed ?
975 .setColorForeground(color(200))
976 .setColorBackground(color(70))
977 .setColorActive(blueAct)
982 cp5.getTab("rpm").captionLabel().toUpperCase(false) ;
984 // ------------------------------ Tab 7 : DATA to send ------------------------------
987 .setColorForeground(color(200))
988 .setColorBackground(color(40, 90, 40))
989 .setColorActive(color(60, 190, 60))
990 .setLabel("DATA sent")
994 cp5.getTab("data").captionLabel().toUpperCase(false) ;
997 cp5.addTextlabel("sentData")
998 .setText("OXS measurement")
999 .setPosition(12, 105)
1000 .setColorValue(#000000)
1003 cp5.getProperties().remove(cp5.getController("sentData")) ;
1005 cp5.addTextlabel("DataFS")
1006 .setText("Telemetry data field")
1007 .setPosition(139, 105)
1008 .setColorValue(#000000)
1011 cp5.getProperties().remove(cp5.getController("DataFS")) ;
1013 cp5.addTextlabel("multiplierL")
1014 .setText("Multiplier")
1015 .setPosition(256, 105)
1016 .setColorValue(#000000)
1019 cp5.getProperties().remove(cp5.getController("multiplierL")) ;
1021 cp5.addTextlabel("dividerL")
1023 .setPosition(308, 105)
1024 .setColorValue(#000000)
1027 cp5.getProperties().remove(cp5.getController("dividerL")) ;
1029 cp5.addTextlabel("offsetL")
1031 .setPosition(356, 105)
1032 .setColorValue(#000000)
1035 cp5.getProperties().remove(cp5.getController("offsetL")) ;
1037 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1038 // Transmitted DATA field
1039 cp5.addDropdownList("sentDataField" + i)
1040 .setColorForeground(orangeAct)
1041 .setColorBackground(color(70))
1042 .setColorActive(blueAct)
1043 .setPosition(5, 148 - 25 + i * 25)
1044 .setSize(127, 180 - 11 * i)
1049 for (int j = 0; j < sentDataList.length; j++ ) {
1050 cp5.get(DropdownList.class, "sentDataField" + i).addItem("" + sentDataList[j][1], j) ;
1052 cp5.get(DropdownList.class, "sentDataField" + i).setValue(0) ;
1053 cp5.getGroup("sentDataField" + i).captionLabel().style().marginTop = 2 ;
1054 cp5.get(DropdownList.class, "sentDataField" + i).toUpperCase(false) ;
1055 cp5.getProperties().remove(cp5.getGroup("sentDataField" + i), "ListBoxItems") ;
1058 cp5.addDropdownList("hubDataField" + i)
1059 .setColorForeground(orangeAct)
1060 .setColorBackground(color(70))
1061 .setColorActive(blueAct)
1062 .setPosition(137, 148 - 25 + i * 25)
1063 .setSize(120, 180 - 11 * i)
1068 for (int j = 0; j < hubDataList.length; j++ ) {
1069 cp5.get(DropdownList.class, "hubDataField" + i).addItem("" + hubDataList[j][1], j) ;
1071 cp5.getGroup("hubDataField" + i).captionLabel().style().marginTop = 2 ;
1072 cp5.get(DropdownList.class, "hubDataField" + i).toUpperCase(false) ;
1073 cp5.get(DropdownList.class, "hubDataField" + i).setValue(0) ;
1074 cp5.getGroup("hubDataField" + i).hide() ;
1075 cp5.getProperties().remove(cp5.getGroup("hubDataField" + i), "ListBoxItems") ;
1077 // SMART PORT DATA field
1078 cp5.addDropdownList("sPortDataField" + i)
1079 .setColorForeground(orangeAct)
1080 .setColorBackground(color(70))
1081 .setColorActive(blueAct)
1082 .setPosition(137, 148 - 25 + i * 25)
1083 .setSize(120, 180 - 11 * i)
1088 for (int j = 0; j < sPortDataList.length; j++ ) {
1089 cp5.get(DropdownList.class, "sPortDataField" + i).addItem("" + sPortDataList[j][1], j) ;
1091 cp5.getGroup("sPortDataField" + i).captionLabel().style().marginTop = 2 ;
1092 cp5.get(DropdownList.class, "sPortDataField" + i).toUpperCase(false) ;
1093 cp5.get(DropdownList.class, "sPortDataField" + i).setValue(0) ;
1094 cp5.getGroup("sPortDataField" + i).hide() ;
1095 cp5.getProperties().remove(cp5.getGroup("sPortDataField" + i), "ListBoxItems") ;
1097 // Data sent multiplier
1098 cp5.addNumberbox("dataMultiplier" + i)
1099 .setColorActive(blueAct)
1100 .setPosition(265, 128 - 25 + i * 25)
1102 .setRange(-1000, 1000)
1103 .setMultiplier(0.5) // set the sensitifity of the numberbox
1104 .setDecimalPrecision(0)
1105 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
1110 cp5.getTooltip().register("dataMultiplier" + i, "- Default: 1 -");
1112 // Data sent divider
1113 cp5.addNumberbox("dataDivider" + i)
1114 .setColorActive(blueAct)
1115 .setPosition(311, 128 - 25 + i * 25)
1118 .setMultiplier(0.5) // set the sensitifity of the numberbox
1119 .setDecimalPrecision(0)
1120 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
1125 cp5.getTooltip().register("dataDivider" + i, "- Default: 1 -");
1128 cp5.addNumberbox("dataOffset" + i)
1129 .setColorActive(blueAct)
1130 .setPosition(357, 128 - 25 + i * 25)
1132 .setRange(-999, 999)
1133 .setMultiplier(0.5) // set the sensitifity of the numberbox
1134 .setDecimalPrecision(0)
1135 .setDirection(Controller.HORIZONTAL) // change the control direction to left/right
1140 cp5.getTooltip().register("dataOffset" + i, "- Default: 0 -");
1143 prot.setValue(1); // Set the protocol ddl value after telemetry fields creation
1145 // ------------------------------ File dialog ------------------------------
1147 // Load preset button
1148 cp5.addButton("loadButton")
1149 .setColorForeground(blueAct)
1150 .setLabel("Load Preset")
1151 .setPosition(10, 369)
1155 cp5.getController("loadButton").captionLabel().setFont(font16) ;
1156 cp5.getController("loadButton").captionLabel().toUpperCase(false) ;
1157 cp5.getController("loadButton").getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER) ;
1159 // Save preset button
1160 cp5.addButton("saveButton")
1161 .setColorForeground(orangeAct)
1162 .setColorActive(blueAct)
1163 .setLabel("Save Preset")
1164 .setPosition(120, 369)
1168 cp5.getController("saveButton").captionLabel().setFont(font16) ;
1169 cp5.getController("saveButton").captionLabel().toUpperCase(false) ;
1170 cp5.getController("saveButton").getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER) ;
1174 cp5.addButton("writeConfButton")
1175 .setColorForeground(orangeAct)
1176 .setColorActive(blueAct)
1177 .setLabel("Write Config")
1178 .setPosition(260, 367)
1182 cp5.getController("writeConfButton").captionLabel().setFont(font20) ;
1183 cp5.getController("writeConfButton").captionLabel().toUpperCase(false) ;
1184 cp5.getController("writeConfButton").getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER) ;
1186 // --------------------------------------------------------------------------
1188 // dropdownlist overlap
1189 prot.bringToFront() ;
1190 cp5.getGroup("resetButtonPin").bringToFront() ;
1191 serialPin.bringToFront() ;
1192 climbPin.bringToFront() ;
1193 ppmPin.bringToFront() ;
1194 ddlNbrCells.bringToFront();
1195 for ( int i = 1; i <= voltNbr; i++ ) {
1196 cp5.getGroup("ddlVolt" + i).bringToFront() ;
1198 cp5.getGroup("currentPin").bringToFront() ;
1199 cp5.getGroup("tempPin").bringToFront() ;
1200 for ( int i = dataSentFieldNbr; i >= 1; i-- ) {
1201 cp5.getGroup("sentDataField" + i).bringToFront() ;
1202 cp5.getGroup("hubDataField" + i).bringToFront() ;
1203 cp5.getGroup("sPortDataField" + i).bringToFront() ;
1206 // Tooltips general settings
1207 cp5.getTooltip().setDelay(1000) ;
1208 cp5.getTooltip().getLabel().toUpperCase(false) ;
1210 createMessageBox() ; // Message box creation
1212 // *************************************************************************
1213 } // ***************************** END SETUP *******************************
1214 // *************************************************************************
1216 // *************************************************************************
1217 // ******************************** DRAW *******************************
1218 // *************************************************************************
1220 background(myColorBackground);
1221 // Main screen background
1223 rect(0, 100, width, 300);
1225 rect(0, 97, width, 3);
1227 // Compatibility subtitle
1229 textFont(fontLabel) ;
1230 text("For OXS " + oxsVersion, 50, 65) ;
1232 // OXS Configurator version display
1233 textFont(fontItalic) ;
1234 text(oxsCversion, 352, 68) ;
1238 shape(oxsL, width/2, 38, 300, 300);
1241 fill(myColorBackground);
1242 rect(0, height, width, -60);
1244 rect(0, height-60, width, 3);
1246 // Show preset buttons
1247 cp5.getController("loadButton").show() ;
1248 cp5.getController("saveButton").show() ;
1250 // ------------ Tabs specific display ------------
1252 int ctid = cp5.window(this).currentTab().id();
1256 case 0 : // TAB GENERAL Settings
1259 rect(0, 255, 68, 18);
1260 rect(0, 270, 180, 3);
1261 rect(0, 271, 290, 2);
1262 rect(0, 272, width, 1);
1264 if ( cp5.getController("intRef").value() == 1 ) {
1265 cp5.getController("arduinoVccNb").lock() ;
1266 cp5.getController("arduinoVccNb").setColorBackground(grayedColor) ;
1267 cp5.getController("arduinoVccNb").setColorValueLabel(grayedColor) ;
1268 cp5.getController("arduinoVccNb").setColorLabel(grayedColor) ;
1270 cp5.getController("arduinoVccNb").unlock() ;
1271 cp5.getController("arduinoVccNb").setColorBackground(color(70)) ;
1272 cp5.getController("arduinoVccNb").setColorValueLabel(color(255)) ;
1273 cp5.getController("arduinoVccNb").setColorLabel(color(0)) ;
1276 if ( cp5.getController("resetButton").value() == 0 ) {
1277 cp5.getController("resetButtonPinLabel").setColorValue(grayedColor) ;
1278 cp5.getGroup("resetButtonPin").hide() ;
1280 rect(360, 199, 30, 20) ;
1282 cp5.getController("resetButtonPinLabel").setColorValue(color(0)) ;
1283 cp5.getGroup("resetButtonPin").show() ;
1286 if ( !tempActive ) {
1287 cp5.getController("temperature").setColorLabel(grayedColor) ;
1288 cp5.getController("temperature").setColorBackground(grayedColor) ;
1292 case 1 : // TAB Vario
1293 if ( cp5.getController("ppm").value() == 0 ) { // RC remote sensitivity
1294 cp5.getGroup("ppmPin").hide() ;
1296 rect(303, 174, 30, 20) ;
1297 cp5.getController("ppmPinL").setColorValue(grayedColor) ;
1299 cp5.getController("ppmRngL").setColorValue(grayedColor) ;
1300 cp5.getController("ppmRngMin").lock() ;
1301 cp5.getController("ppmRngMin").setColorBackground(grayedColor) ;
1302 cp5.getController("ppmRngMin").setColorValueLabel(grayedColor) ;
1303 cp5.getController("ppmRngMin").setColorLabel(grayedColor) ;
1305 cp5.getController("ppmRngMax").lock() ;
1306 cp5.getController("ppmRngMax").setColorBackground(grayedColor) ;
1307 cp5.getController("ppmRngMax").setColorValueLabel(grayedColor) ;
1308 cp5.getController("ppmRngMax").setColorLabel(grayedColor) ;
1310 cp5.getController("ppmSensRngL").setColorValue(grayedColor) ;
1311 cp5.getController("ppmSensMinMax").lock() ;
1312 cp5.getController("ppmSensMinMax").setColorForeground(grayedColor) ;
1313 cp5.getController("ppmSensMinMax").setColorBackground(grayedColor) ;
1314 cp5.getController("ppmSensMinMax").setColorValueLabel(grayedColor) ;
1315 cp5.getController("ppmSensMinMax").setColorLabel(grayedColor) ;
1317 cp5.getGroup("ppmPin").show() ;
1318 cp5.getController("ppmPinL").setColorValue(color(0)) ;
1320 cp5.getController("ppmRngL").setColorValue(color(0)) ;
1321 cp5.getController("ppmRngMin").unlock() ;
1322 cp5.getController("ppmRngMin").setColorBackground(color(70)) ;
1323 cp5.getController("ppmRngMin").setColorValueLabel(color(255)) ;
1324 cp5.getController("ppmRngMin").setColorLabel(color(0)) ;
1326 cp5.getController("ppmRngMax").unlock() ;
1327 cp5.getController("ppmRngMax").setColorBackground(color(70)) ;
1328 cp5.getController("ppmRngMax").setColorValueLabel(color(255)) ;
1329 cp5.getController("ppmRngMax").setColorLabel(color(0)) ;
1331 cp5.getController("ppmSensRngL").setColorValue(color(0)) ;
1332 cp5.getController("ppmSensMinMax").unlock() ;
1333 cp5.getController("ppmSensMinMax").setColorForeground(blueAct) ;
1334 cp5.getController("ppmSensMinMax").setColorBackground(color(70)) ;
1335 cp5.getController("ppmSensMinMax").setColorValueLabel(color(255)) ;
1336 cp5.getController("ppmSensMinMax").setColorLabel(color(0)) ;
1339 if ( cp5.getController("analogClimb").value() == 0 ) { // Analog climb rate
1340 cp5.getController("climbPinL").setColorValue(grayedColor) ;
1341 cp5.getGroup("climbPin").hide() ;
1343 rect(303, 287, 30, 20) ;
1345 cp5.getController("outClimbRateRngL").setColorValue(grayedColor) ;
1346 cp5.getController("outClimbRateMinMax").lock() ;
1347 cp5.getController("outClimbRateMinMax").setColorForeground(grayedColor) ;
1348 cp5.getController("outClimbRateMinMax").setColorBackground(grayedColor) ;
1349 cp5.getController("outClimbRateMinMax").setColorValueLabel(grayedColor) ;
1350 cp5.getController("outClimbRateMinMax").setColorLabel(grayedColor) ;
1352 cp5.getController("climbPinL").setColorValue(color(0)) ;
1353 cp5.getGroup("climbPin").show() ;
1355 cp5.getController("outClimbRateRngL").setColorValue(color(0)) ;
1356 cp5.getController("outClimbRateMinMax").unlock() ;
1357 cp5.getController("outClimbRateMinMax").setColorForeground(blueAct) ;
1358 cp5.getController("outClimbRateMinMax").setColorBackground(color(70)) ;
1359 cp5.getController("outClimbRateMinMax").setColorValueLabel(color(255)) ;
1360 cp5.getController("outClimbRateMinMax").setColorLabel(color(0)) ;
1364 case 2 : // TAB Voltage / Other
1366 for ( int i = 1; i <= voltNbr; i++ ) { // Voltage tab grayed items
1367 if ( cp5.getController("volt" + i).value() == 0 ) {
1368 cp5.getGroup("ddlVolt" + i).hide() ;
1370 rect(120 - 45 + i * 45, 165, 30, 20) ;
1371 cp5.getController("dividerVolt" + i).lock() ;
1372 cp5.getController("dividerVolt" + i).setColorBackground(color(165)) ;
1373 cp5.getController("dividerVolt" + i).setColorForeground(color(195)) ;
1374 cp5.getController("dividerVolt" + i).setColorValueLabel(color(165)) ;
1375 cp5.getController("offsetVolt" + i).lock() ;
1376 cp5.getController("offsetVolt" + i).setColorBackground(color(175)) ;
1377 cp5.getController("offsetVolt" + i).setColorForeground(color(195)) ;
1378 cp5.getController("offsetVolt" + i).setColorValueLabel(color(175)) ;
1380 cp5.getGroup("ddlVolt" + i).show() ;
1381 cp5.getController("dividerVolt" + i).unlock() ;
1382 cp5.getController("dividerVolt" + i).setColorBackground(color(70)) ;
1383 cp5.getController("dividerVolt" + i).setColorValueLabel(color(255)) ;
1384 cp5.getController("offsetVolt" + i).unlock() ;
1385 cp5.getController("offsetVolt" + i).setColorBackground(color(70)) ;
1386 cp5.getController("offsetVolt" + i).setColorValueLabel(color(255)) ;
1390 if ( cp5.getController("volt1").value() == 0 ) { // Battery cells monitoring grayed
1391 cp5.getController("cells").setBroadcast(false) ; // deactivate continuous controller event
1392 cp5.getController("cells").setValue(0) ;
1393 cp5.getController("cells").lock() ;
1394 cp5.getController("cells").setColorBackground(grayedColor) ;
1395 cp5.getController("cells").setColorLabel(grayedColor) ;
1397 cp5.getController("cells").setBroadcast(true) ;
1398 cp5.getController("cells").unlock() ;
1399 cp5.getController("cells").setColorBackground(color(70)) ;
1400 cp5.getController("cells").setColorLabel(color(0)) ;
1403 if ( cp5.getController("cells").value() == 0 ) { // Cells number grayed
1404 cp5.getController("NbrCells").setColorValue(grayedColor) ;
1405 cp5.getGroup("ddlNbrCells").hide() ;
1407 rect(283, 278, 25, 20) ;
1409 cp5.getController("NbrCells").setColorValue(color(0)) ;
1410 cp5.getGroup("ddlNbrCells").show() ;
1413 // Voltage tab -> Cells indicator
1414 if ( cp5.getController("cells").value() == 1 && ddlNbrCells.getValue() > 0 ) {
1415 int nCells = int(ddlNbrCells.getValue()) ;
1421 textFont(fontCells) ;
1422 text("CELLS", 68, 128) ;
1423 line ( 115, 117, 115, 128 ) ;
1424 line ( 115, 117, 110 + 45 * nCells, 117 ) ;
1425 line ( 110 + 45 * nCells, 117, 110 + 45 * nCells, 128 ) ;
1431 case 3 : // TAB Current sensor
1433 if ( cp5.getController("currentDir").value() == 0 ) { // Current grayed switch
1434 cp5.getController("currentDirL").setColorValue(grayedColor) ;
1435 cp5.getController("currentDir").setColorCaptionLabel(color(0)) ;
1437 cp5.getController("currentDirL").setColorValue(color(0)) ;
1438 cp5.getController("currentDir").setColorCaptionLabel(grayedColor) ;
1443 case 6 : // TAB DATA sent
1445 rect(258, 365, 124, 34);
1446 // Load and Save preset buttons hide for ( int i = 6 ; i <= dataSentFieldNbr ; i++ ) {
1447 if ( cp5.getGroup("sentDataField" + 6 ).isOpen() || cp5.getGroup("hubDataField" + 6 ).isOpen() || cp5.getGroup("sPortDataField" + 6 ).isOpen()
1448 || cp5.getGroup("sentDataField" + 7 ).isOpen() || cp5.getGroup("hubDataField" + 7 ).isOpen() || cp5.getGroup("sPortDataField" + 7 ).isOpen()
1449 || cp5.getGroup("sentDataField" + 8 ).isOpen() || cp5.getGroup("hubDataField" + 8 ).isOpen() || cp5.getGroup("sPortDataField" + 8 ).isOpen() ) {
1450 cp5.getController("loadButton").hide() ;
1451 cp5.getController("saveButton").hide() ;
1453 cp5.getController("loadButton").show() ;
1454 cp5.getController("saveButton").show() ;
1458 // Grayed multiplier + divider + offset if Telemetry data field == DEFAULT
1459 for ( int i = 1 ; i <= dataSentFieldNbr ; i++ ) {
1460 if ( cp5.getGroup("protocolChoice").value() == 1 ) {
1461 if ( cp5.getGroup("hubDataField" + i).value() == 1 ) {
1462 cp5.getController("dataMultiplier" + i).lock() ;
1463 cp5.getController("dataMultiplier" + i).setColorBackground(grayedColor) ;
1464 cp5.getController("dataMultiplier" + i).setColorValueLabel(grayedColor) ;
1465 cp5.getController("dataDivider" + i).lock() ;
1466 cp5.getController("dataDivider" + i).setColorBackground(grayedColor) ;
1467 cp5.getController("dataDivider" + i).setColorValueLabel(grayedColor) ;
1468 cp5.getController("dataOffset" + i).lock() ;
1469 cp5.getController("dataOffset" + i).setColorBackground(grayedColor) ;
1470 cp5.getController("dataOffset" + i).setColorValueLabel(grayedColor) ;
1472 cp5.getController("dataMultiplier" + i).unlock() ;
1473 cp5.getController("dataMultiplier" + i).setColorBackground(color(70)) ;
1474 cp5.getController("dataMultiplier" + i).setColorValueLabel(color(255)) ;
1475 cp5.getController("dataDivider" + i).unlock() ;
1476 cp5.getController("dataDivider" + i).setColorBackground(color(70)) ;
1477 cp5.getController("dataDivider" + i).setColorValueLabel(color(255)) ;
1478 cp5.getController("dataOffset" + i).unlock() ;
1479 cp5.getController("dataOffset" + i).setColorBackground(color(70)) ;
1480 cp5.getController("dataOffset" + i).setColorValueLabel(color(255)) ;
1482 } else if ( cp5.getGroup("protocolChoice").value() == 2 ) {
1483 if ( cp5.getGroup("sPortDataField" + i).value() == 1 ) {
1484 cp5.getController("dataMultiplier" + i).lock() ;
1485 cp5.getController("dataMultiplier" + i).setColorBackground(grayedColor) ;
1486 cp5.getController("dataMultiplier" + i).setColorValueLabel(grayedColor) ;
1487 cp5.getController("dataDivider" + i).lock() ;
1488 cp5.getController("dataDivider" + i).setColorBackground(grayedColor) ;
1489 cp5.getController("dataDivider" + i).setColorValueLabel(grayedColor) ;
1490 cp5.getController("dataOffset" + i).lock() ;
1491 cp5.getController("dataOffset" + i).setColorBackground(grayedColor) ;
1492 cp5.getController("dataOffset" + i).setColorValueLabel(grayedColor) ;
1494 cp5.getController("dataMultiplier" + i).unlock() ;
1495 cp5.getController("dataMultiplier" + i).setColorBackground(color(70)) ;
1496 cp5.getController("dataMultiplier" + i).setColorValueLabel(color(255)) ;
1497 cp5.getController("dataDivider" + i).unlock() ;
1498 cp5.getController("dataDivider" + i).setColorBackground(color(70)) ;
1499 cp5.getController("dataDivider" + i).setColorValueLabel(color(255)) ;
1500 cp5.getController("dataOffset" + i).unlock() ;
1501 cp5.getController("dataOffset" + i).setColorBackground(color(70)) ;
1502 cp5.getController("dataOffset" + i).setColorValueLabel(color(255)) ;
1509 // ---------------- End TAB specific display ---------------
1511 // Load and Save preset buttons deco
1512 if ( cp5.getController("loadButton").isVisible() ) {
1514 rect(9, 368, 102, 27);
1516 rect(119, 368, 102, 27);
1519 // ----------------- Texfield and Numberbox mouse-over -----------------
1521 if ( cp5.isMouseOver (oxsDir) ) {
1522 oxsDir.setColorForeground(blueAct);
1524 oxsDir.setColorForeground(color(200));
1527 if ( cp5.isMouseOver ( cp5.getController("arduinoVccNb") ) ) {
1528 cp5.getController("arduinoVccNb").setColorForeground(blueAct);
1530 cp5.getController("arduinoVccNb").setColorForeground(grayedColor);
1533 if ( cp5.isMouseOver ( cp5.getController("vSpeedMin") ) ) {
1534 cp5.getController("vSpeedMin").setColorForeground(orangeAct);
1536 cp5.getController("vSpeedMin").setColorForeground(grayedColor);
1539 if ( cp5.isMouseOver ( cp5.getController("vSpeedMax") ) ) {
1540 cp5.getController("vSpeedMax").setColorForeground(orangeAct);
1542 cp5.getController("vSpeedMax").setColorForeground(grayedColor);
1545 if ( cp5.isMouseOver ( cp5.getController("ppmRngMin") ) ) {
1546 cp5.getController("ppmRngMin").setColorForeground(orangeAct);
1548 cp5.getController("ppmRngMin").setColorForeground(grayedColor);
1551 if ( cp5.isMouseOver ( cp5.getController("ppmRngMax") ) ) {
1552 cp5.getController("ppmRngMax").setColorForeground(orangeAct);
1554 cp5.getController("ppmRngMax").setColorForeground(grayedColor);
1557 for ( int i = 1; i <= voltNbr; i++ ) {
1558 if ( cp5.isMouseOver ( cp5.getController( "dividerVolt" + i ) ) ) {
1559 cp5.getController( "dividerVolt" + i ).setColorForeground(orangeAct);
1561 cp5.getController( "dividerVolt" + i ).setColorForeground(color(170));
1565 for ( int i = 1; i <= voltNbr; i++ ) {
1566 if ( cp5.isMouseOver ( cp5.getController( "offsetVolt" + i ) ) ) {
1567 cp5.getController( "offsetVolt" + i ).setColorForeground(orangeAct);
1569 cp5.getController( "offsetVolt" + i ).setColorForeground(color(170));
1573 if ( cp5.isMouseOver ( cp5.getController( "currentVccNb" ) ) ) {
1574 cp5.getController( "currentVccNb" ).setColorForeground(orangeAct);
1576 cp5.getController( "currentVccNb" ).setColorForeground(color(170));
1579 if ( cp5.isMouseOver ( cp5.getController( "currentDivNb" ) ) ) {
1580 cp5.getController( "currentDivNb" ).setColorForeground(orangeAct);
1582 cp5.getController( "currentDivNb" ).setColorForeground(color(170));
1585 if ( cp5.isMouseOver ( cp5.getController( "currentOutSensNb" ) ) ) {
1586 cp5.getController( "currentOutSensNb" ).setColorForeground(orangeAct);
1588 cp5.getController( "currentOutSensNb" ).setColorForeground(color(170));
1591 if ( cp5.isMouseOver ( cp5.getController( "currentOutOffsetNb" ) ) ) {
1592 cp5.getController( "currentOutOffsetNb" ).setColorForeground(orangeAct);
1594 cp5.getController( "currentOutOffsetNb" ).setColorForeground(color(170));
1597 if ( cp5.isMouseOver ( cp5.getController( "tempOffset" ) ) ) {
1598 cp5.getController( "tempOffset" ).setColorForeground(orangeAct);
1600 cp5.getController( "tempOffset" ).setColorForeground(color(200));
1603 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1604 if ( cp5.isMouseOver ( cp5.getController( "dataMultiplier" + i ) ) ) {
1605 cp5.getController( "dataMultiplier" + i ).setColorForeground(orangeAct);
1607 cp5.getController( "dataMultiplier" + i ).setColorForeground(grayedColor);
1611 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1612 if ( cp5.isMouseOver ( cp5.getController( "dataDivider" + i ) ) ) {
1613 cp5.getController( "dataDivider" + i ).setColorForeground(orangeAct);
1615 cp5.getController( "dataDivider" + i ).setColorForeground(grayedColor);
1619 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1620 if ( cp5.isMouseOver ( cp5.getController( "dataOffset" + i ) ) ) {
1621 cp5.getController( "dataOffset" + i ).setColorForeground(orangeAct);
1623 cp5.getController( "dataOffset" + i ).setColorForeground(grayedColor);
1627 // ----------------- Dropdownlist: mouse pressed elsewhere closes list -----------------
1629 if ( !cp5.isMouseOver ( prot ) ) {
1630 if (mousePressed == true) {
1635 if ( !cp5.isMouseOver ( serialPin ) ) {
1636 if (mousePressed == true) {
1641 if ( !cp5.isMouseOver ( cp5.getGroup( "resetButtonPin" ) ) ) {
1642 if (mousePressed == true) {
1643 cp5.getGroup( "resetButtonPin" ).close() ;
1648 if ( !cp5.isMouseOver ( ppmPin ) ) {
1649 if (mousePressed == true) {
1654 if ( !cp5.isMouseOver ( climbPin ) ) {
1655 if (mousePressed == true) {
1660 for ( int i = 1; i <= voltNbr; i++ ) {
1661 if ( !cp5.isMouseOver ( cp5.getGroup( "ddlVolt" + i ) ) ) {
1662 if (mousePressed == true) {
1663 cp5.getGroup( "ddlVolt" + i ).close() ;
1668 if ( !cp5.isMouseOver ( cp5.getGroup( "ddlNbrCells") ) ) {
1669 if (mousePressed == true) {
1670 cp5.getGroup( "ddlNbrCells" ).close() ;
1674 if ( !cp5.isMouseOver ( cp5.getGroup( "currentPin") ) ) {
1675 if (mousePressed == true) {
1676 cp5.getGroup( "currentPin" ).close() ;
1680 if ( !cp5.isMouseOver ( cp5.getGroup( "tempPin") ) ) {
1681 if (mousePressed == true) {
1682 cp5.getGroup( "tempPin" ).close() ;
1686 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1687 if ( !cp5.isMouseOver ( cp5.getGroup( "sentDataField" + i ) ) ) {
1688 if (mousePressed == true) {
1689 cp5.getGroup( "sentDataField" + i ).close() ;
1694 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1695 if ( !cp5.isMouseOver ( cp5.getGroup( "hubDataField" + i ) ) ) {
1696 if (mousePressed == true) {
1697 cp5.getGroup( "hubDataField" + i ).close() ;
1702 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1703 if ( !cp5.isMouseOver ( cp5.getGroup( "sPortDataField" + i ) ) ) {
1704 if (mousePressed == true) {
1705 cp5.getGroup( "sPortDataField" + i ).close() ;
1710 // ----------------- TAB DATA sent display -----------------
1712 if ( cp5.getController("vario").getValue() == 1 || cp5.getController("voltage").getValue() == 1 ||
1713 cp5.getController("current").getValue() == 1 || cp5.getController("temperature").getValue() == 1 ||
1714 cp5.getController("rpm").getValue() == 1 ) {
1715 cp5.getTab("data").show() ;
1717 cp5.getTab("data").hide() ;
1719 // *************************************************************************
1720 } // *************************** end DRAW ******************************
1721 // *************************************************************************
1723 void controlEvent(ControlEvent theEvent) {
1724 // DropdownList is of type ControlGroup.
1725 // A controlEvent will be triggered from inside the ControlGroup class.
1726 // therefore you need to check the originator of the Event with if (theEvent.isGroup()) to avoid an error message thrown by controlP5.
1728 if ( theEvent.isFrom(cp5.getController("vSpeedMax")) || theEvent.isFrom(cp5.getController("vSpeedMin")) ) { // V speed sensitivity range interaction
1729 cp5.getController("vSpeedMax").setBroadcast(false) ;
1730 cp5.getController("vSpeedMin").setBroadcast(false) ;
1731 cp5.get(Numberbox.class, "vSpeedMax").setRange( cp5.getController("vSpeedMin").getValue(), 1000 ) ;
1732 cp5.get(Numberbox.class, "vSpeedMin").setRange( 0, cp5.getController("vSpeedMax").getValue() ) ;
1733 cp5.getController("vSpeedMin").setBroadcast(true) ;
1734 cp5.getController("vSpeedMax").setBroadcast(true) ;
1737 if ( theEvent.isFrom(cp5.getGroup("protocolChoice")) ) { // Showing right Telemetry data list in fields
1738 switch( int(theEvent.getGroup().getValue()) ) {
1740 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1741 cp5.getGroup("hubDataField" + i).show() ;
1742 cp5.getGroup("sPortDataField" + i).hide() ;
1746 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1747 cp5.getGroup("sPortDataField" + i).show() ;
1748 cp5.getGroup("hubDataField" + i).hide() ;
1754 for ( int i = 1; i <= dataSentFieldNbr; i++ ) {
1755 if ( theEvent.isFrom(cp5.getGroup("sentDataField" + i )) ) { // Selecting DEFAULT automaticaly in Telemetry data fields
1756 switch( int(theEvent.getGroup().getValue()) ) {
1757 case 1 : // "ALTIMETER"
1758 case 2 : // "VERTICAL_SPEED"
1759 case 5 : // "CURRENTMA"
1762 cp5.getGroup("hubDataField" + i).setValue(1) ;
1763 cp5.getGroup("sPortDataField" + i).setValue(1) ;
1769 if (theEvent.isGroup()) {
1770 // check if the Event was triggered from a ControlGroup
1771 println("event from group : "+theEvent.getGroup().getValue()+" from "+theEvent.getGroup());
1772 } else if (theEvent.isController()) {
1773 println("event from controller : "+theEvent.getController().getValue()+" from "+theEvent.getController());
1778 public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) { // Mouse wheel support for scroll bars !!
1779 super.mouseWheelMoved(e);
1780 cp5.setMouseWheelRotation(e.getWheelRotation());
1783 public void oxsDirButton(int theValue) {
1784 //println("oxsDir button: "+theValue);
1785 selectFolder("Select OXS source folder:", "folderSelected");
1788 void vario(boolean theFlag) {
1789 if (theFlag==true) {
1790 cp5.getTab("vario").show() ;
1792 cp5.getTab("vario").hide() ;
1794 //println("a toggle event.");
1797 void voltage(boolean theFlag) {
1798 if (theFlag==true) {
1799 cp5.getTab("voltage").show() ;
1801 cp5.getTab("voltage").hide() ;
1803 //println("a toggle event.");
1806 void current(boolean theFlag) {
1807 if (theFlag==true) {
1808 cp5.getTab("current").show() ;
1810 cp5.getTab("current").hide() ;
1812 //println("a toggle event.");
1815 void temperature(boolean theFlag) {
1816 if (theFlag==true) {
1817 cp5.getTab("temperature").show() ;
1819 cp5.getTab("temperature").hide() ;
1821 //println("a toggle event.");
1824 /* // RPM TAB display
1825 void rpm(boolean theFlag) {
1826 if (theFlag==true) {
1827 cp5.getTab("rpm").show() ;
1829 cp5.getTab("rpm").hide() ;
1831 println("a toggle event.");
1835 void about(boolean theFlag) {
1839 messageList.clear() ;
1841 messageList.append( " OXS Configurator for OXS " + oxsVersion ) ;
1842 messageList.append( " ---" ) ;
1843 messageList.append( " -- OpenXsensor configuration file GUI " + oxsCversion + " --" ) ;
1844 messageList.append( "\n" ) ;
1845 messageList.append( "Contributors:" ) ;
1846 messageList.append( "" ) ;
1847 messageList.append( "- Rainer Schloßhan" ) ;
1848 messageList.append( "- Bertrand Songis" ) ;
1849 messageList.append( "- André Bernet" ) ;
1850 messageList.append( "- Michael Blandford" ) ;
1851 messageList.append( "- Michel Strens" ) ;
1852 messageList.append( "- David Laburthe" ) ;
1853 messageList.append( "" ) ;
1854 messageList.append( "" ) ;
1856 String[] messageListArray = messageList.array();
1858 String joinedMessageList = join(messageListArray, "\n") ;
1860 cp5.get(Textarea.class, "messageBoxLabel").setText(joinedMessageList) ;
1862 cp5.getController("buttonOK").setColorForeground(orangeAct);
1863 cp5.getController("buttonOK").setColorBackground(color(100));
1864 cp5.getController("buttonOK").setColorActive(blueAct);
1865 messageBox.setBackgroundColor(blueAct);
1869 public void loadButton(int theValue) { // Load preset button
1870 File presetDir = new File( sketchPath("Preset/...") ) ;
1871 selectInput("Select a preset file to load:", "presetLoad", presetDir);
1874 public void saveButton(int theValue) { // Save preset button
1876 validationProcess("preset") ;
1879 File presetDir = new File( sketchPath("Preset/type name") ) ;
1880 selectOutput("Type preset name to save:", "presetSave", presetDir);
1884 void presetLoad(File selection) {
1885 if (selection == null) {
1886 //println("Window was closed or the user hit cancel.");
1888 //println("User selected " + selection.getAbsolutePath());
1889 cp5.loadProperties(selection.getAbsolutePath());
1891 // Hack to keep slider labels alignement
1892 cp5.getController("varioHysteresis").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
1893 cp5.getController("varioHysteresis").getValueLabel().align(ControlP5.RIGHT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
1897 void presetSave(File selection) {
1898 if (selection == null) {
1899 //println("Window was closed or the user hit cancel.");
1901 //println("User selected " + selection.getAbsolutePath());
1902 cp5.saveProperties(selection.getAbsolutePath());
1906 public void writeConfButton(int theValue) {
1908 validationProcess("Config") ;
1914 public void validationProcess(String theString) {
1916 // Config file writing destination
1917 oxsDirectory = trim( cp5.get(Textfield.class, "oxsDirectory").getText() ) ;
1918 if ( oxsDirectory.equals("") ) {
1919 outputConfigDir = sketchPath("oxs_config.h") ;
1921 outputConfigDir = oxsDirectory + "/oxs_config.h" ;
1924 messageList.clear() ;
1925 messageList.set(0, "") ;
1926 messageList.append("") ;
1928 numPinsValid = true ;
1929 analogPinsValid = true ;
1931 oxsMeasureValid = true ;
1932 versionValid = 2 ; // 0 -> not valid 1 -> warning 2 -> valid
1935 validateAnalogPins() ;
1937 validateSentData() ;
1940 if ( numPinsValid && analogPinsValid && cellsValid && oxsMeasureValid && versionValid == 2 ) {
1941 messageList.set(0, " --- ALL IS GOOD ! ---") ;
1942 if ( theString.equals("preset") ) {
1943 messageList.append("Preset file can be saved !") ;
1945 messageList.append("Configuration file will be written to:") ;
1946 messageList.append(outputConfigDir) ;
1947 messageList.append("") ;
1948 messageList.append(" ! If the file already exists, it will be replaced !") ;
1950 messageList.append("") ;
1951 messageList.append(" -------------------") ;
1955 } else if ( numPinsValid && analogPinsValid && cellsValid && oxsMeasureValid && versionValid == 1 ) {
1956 messageList.set(0, " --- WARNING---") ;
1957 messageList.append("") ;
1958 messageList.append(" --------------------") ;
1959 messageList.append("") ;
1960 messageList.append("Configuration file will be written to:") ;
1961 messageList.append(outputConfigDir) ;
1962 messageList.append("") ;
1963 messageList.append(" ! If the file already exists, it will be replaced !") ;
1968 messageList.set(0, " --- ERROR ---") ;
1969 messageList.append("") ;
1970 messageList.append(" -------------------") ;
1971 messageList.append("") ;
1972 if ( theString.equals("preset") ) {
1973 messageList.append("Preset file can't be saved !") ;
1975 messageList.append("Config file can't be written !") ;
1977 //cp5.get(Textarea.class, "messageBoxLabel").setColor(color(255,0,0)) ;
1981 String[] messageListArray = messageList.array();
1983 String joinedMessageList = join(messageListArray, "\n") ;
1985 cp5.get(Textarea.class, "messageBoxLabel").setText(joinedMessageList) ;
1986 //println(messageList) ;
1988 messageBox.setBackgroundColor(color(240));
1989 cp5.getController("buttonOK").setColorForeground(color(blueAct));
1990 cp5.getController("buttonOK").setColorActive(color(orangeAct));
1995 void folderSelected(File selection) {
1996 if (selection == null) {
1997 //println("Window was closed or the user hit cancel.");
1999 //println("User selected " + selection.getAbsolutePath());
2000 cp5.get(Textfield.class, "oxsDirectory").setText(selection.getAbsolutePath());
2005 // default properties load/save key combinations are
2006 // alt+shift+l to load properties
2007 // alt+shift+s to save properties
2009 cp5.saveProperties(("settings.oxs"));
2010 } else if (key=='l') {
2011 cp5.loadProperties(("settings.oxs"));
2013 // Hack to keep slider labels alignement
2014 cp5.getController("varioHysteresis").getCaptionLabel().align(ControlP5.LEFT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
2015 cp5.getController("varioHysteresis").getValueLabel().align(ControlP5.RIGHT_OUTSIDE, ControlP5.CENTER).setPaddingX(10) ;
2017 cp5.getProperties().print();
2018 } else if ( key == 't' ) {
2019 println( "mAmp / step " + mAmpStep() ) ;
2020 println( "Current offset " + offsetCurrent() ) ;
2021 } else if ( key == 'v' ) {
2022 validationProcess("Config") ;
2026 float round(float number, float decimal) { // Rounding function
2027 return (float)(round((number*pow(10, decimal))))/pow(10, decimal);
2030 float mAmpStep() { // Current sensor milliAmp per ADC step calculation
2034 float currentDiv = float( cp5.getController("currentDivNb").getValueLabel().getText() ) ;
2035 float arduinoVcc = float( cp5.getController("arduinoVccNb").getValueLabel().getText() ) ;
2037 mAmpPmV = 1000 / float( cp5.getController("currentOutSensNb").getValueLabel().getText() );
2038 if ( cp5.getController("intRef").value() == 0 ) {
2039 mAmpStep = ( arduinoVcc * 1000.0 / 1024.0 ) * mAmpPmV * currentDiv ;
2041 mAmpStep = ( 1.1 * 1000.0 / 1024.0 ) * mAmpPmV ;
2046 int offsetCurrent() { // Current sensor offset calculation in ADC step
2049 //float currentVcc = float( cp5.getController("currentVccNb").getValueLabel().getText() ) ;
2050 float currentOutOffset = float( cp5.getController("currentOutOffsetNb").getValueLabel().getText() ) ;
2051 float currentDiv = float( cp5.getController("currentDivNb").getValueLabel().getText() ) ;
2052 float arduinoVcc = float( cp5.getController("arduinoVccNb").getValueLabel().getText() ) ;
2054 //if ( cp5.getController( "currentDir" ).value() == 0 ) {
2055 // offsetCurrent = int( ( currentVcc / 2.0 + currentOutOffset / 1000.0 ) / arduinoVcc * 1024.0 * currentDiv ) ;
2057 offsetCurrent = int( currentOutOffset / 1000.0 / arduinoVcc * 1024.0 * currentDiv ) ;
2060 return offsetCurrent ;