forked from SV8ARJ/spektrum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spektrum.pde
2855 lines (2316 loc) · 88.4 KB
/
spektrum.pde
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import controlP5.*;
import rtlspektrum.Rtlspektrum;
import java.io.FileWriter; // added by Dave N 24 Aug 2017
import java.util.*;
import processing.serial.*;
// The spektrum:: the SV mods -- SV1SGK and SV8ARJ UI improvements.
//
//
// Changelog :
/*
v0.9
Added: 2 Cursors for Frequency axis.
Added: 2 Cursors for Amplitude axis.
Added: Absolute and differential measurements with cursors.
Added: Zoom functionality of the cursors's defined area (gain + frequency).
Added: Mouse Wheel Frequency limits adjustment on graph (Top area for upper, low area for lower).
Added: Mouse Wheel Gain limits adjustment on graph (left area for lower frequency, right for upper).
Added: View/settings store/recall (elementary "back" operation, nice for quick zoomed in graph inspection).
Added: Left click positions primary cursors.
Added: Left Double Click positions primary cursors and moves secondary out of the way.
Added: Right Double Click zooms area defined by cursors (Amplitude + frequency).
Added: Right mouse Click and Drag on a cursor moves the cursor.
Added: Middle (mouse wheel) Double Click resets full scale for Amplitude and Frequency.
Added: Middle (mouse wheel) Click and Drag, moves the graph recalculating limits accordingly.
Added: Reset buttons to Min/Max range next to Start and Stop frequency text boxes.
Modified: Cursors on/off now operate on all 4 cursors.
Added: ZOOM and BACK buttons.
Added: Display of frequency, Amplitude and differences for all cursors.
Modified: Button layout.
Fixed: Save/Reload settings on exit/start. IMPORTANT : delete the "data" folder from the installation location if you have it.
v0.10
Added: Mouse wheel in the centrer of the graph performs symetric zoom in/out
v0.11
Modified: Mouse behavior to (LMB=Left Mouse Button, RMB=Right, etc etc ):
- _LMB Click_ : Nothing.
- _LMB Drag_ on cursor: Move cursor.
- _LMB Double Click_ : Zoom to selected area.
- _RMB Click_ : position primary cursors to pointer.
- _RMB Double Click_ : position primary pointers to mouse and send to edges secondary cursors.
- _RMB Drag_ : define area with all cursors.
- _MWheel Click_ : Nothing
- _MWheel Double Click_ : Full scales reset to max.
- _MWHeel Drag_ : Move graph refedining min/max frequency and amplitude.
- _MWHeel Up/Down_ : On Four edges of graph adjusts corresponding value (min/max freq or db).
- _MWHeel Up/Down_ : On middle of graph area zooms in/out the graph by symetrically changing all four limits.
- Added: Mouse Wheel zoom is pre-shown by rectangle on graph.
- Added: Fill or Line for graph.
v0.12
- Added: VSWR calculation for the antenna tunning guys.
- Added: Reference graph (Save a graph in memory and have on screen for comparisons).
v0.13
- Fixed: double click in controls area was doing the zoom operation.
- Added: Min Freq, Max Freq, rfGain, ifOffset ifType in config.
- Added: Averaging system based on video refresh rate.
v0.14
- Fixed: Limited cursor movement.
- UI re-arranged.
- Added: Min/Max/Med persistent display.
v0.15
- Added: Quick Help screen.
- Added: IF frequency (only Upper band displays left to right in ascending order. Todo: reverse for lower).
- Added: Average graph can be saved as reference (if active on "save reference" click).
- Added: Vertical offset for reference graph (Controlled from knob)
v0.16
- Modified: RF gain is now a knob plus 3 buttons for 1/3, 1/2 and 2/3 pre-sets.
v0.17
- Modified: Created Tabs - Made room for more controls.
- Modified: Measurements box placement logic for "always within the screen" positioning.
v0.18
- Added: 10 presets for different settings
- Added: UI controls to modify settings of presets
- Added: Preset 0 is always autosaved with last values
- Added: Button to restore zoom to preset parameters
- Modified: UI with better spacing and labels
v0.19
- Tests with crop - New rtlspektrum.jar
- Added UI for setting the crop of rtlpower
*/
String svVersion = "v0.19";
Serial myPort;
Rtlspektrum spektrumReader;
ControlP5 cp5;
DataPoint[] scaledBuffer;
boolean startingupBypassSaveConfiguration = true;
int reloadConfigurationAfterStartUp = 0;// This will be set at the end of the startup
int CONFIG_RELOAD_DELAY = 30; // 0 is disabled
interface CURSORS {
int
CUR_NONE = 0,
CUR_X_LEFT = 1,
CUR_X_RIGHT = 2,
CUR_Y_TOP = 3,
CUR_Y_BOTTOM = 4;
}
int movingCursor = CURSORS.CUR_NONE;
String tmpMessage;
String tmpMessage1;
final int NONE = 0;
// TABS
//
int tabActiveID = 1;
String tabActiveName = "default";
final int TAB_HEIGHT = 25;
final int TAB_HEIGHT_ACTIVE = 30;
final int TAB_GENERAL = 1;
final int TAB_MEASURE = 2;
final int TAB_SETTINGS = 3;
final int TAB_SARK100 = 4;
String tabLabels[] = {"global", "SETUP", "MEASURE", "SETTINGS", "NOT YET", "WHO ARE YOU"};
final int ITEM_GAIN = 1;
final int ITEM_FREQUENCY = 2;
final int ITEM_ZOOM = 3;
final int ITEM_RF_GAIN = 4;
// interface IF_TYPES {
// int
final int IF_TYPE_NONE = 0;
final int IF_TYPE_ABOVE = 1;
final int IF_TYPE_BELOW = 2;
// }
// Configuration
//
final int nrOfConfigurations = 10; // First element is used for the Autosave functionality.
final int DO_NOT_SAVE_CONFIGURATION = 0;
final int SAVE_CONFIGURATION = 1;
final int PRESET_SAVE = 1;
final int PRESET_LOAD = 2;
int configurationOperation = 0 ;
int CONFIG_SAVE_DELAY = 80; // 0 is disabled
configurationClass[] configSet = new configurationClass[10];
int configurationActive=0;
String configurationName;
DropdownList configurationDropdown;
int configurationSaveDelay = 0;
// Maybe not needed -- TBD
//
public class configurationClass {
public int startFreq;
public int stopFreq;
public int binStep;
public int scaleMin;
public int scaleMax;
public int rfGain;
public int fullRangeMin;
public int fullRangeMax;
public int ifOffset;
public int ifType;
public int activeConfig;
public String configName;
public configurationClass(int i)
{
configName = "Config" + i;
}
}
int timeToSet = 1; // GRGNICK add
int itemToSet = 0; // GRGNICK add -- 1 is Gain, 2 is Frequency
int infoText1X = 0;
int infoText1Y = 0;
int infoColor = #00FF3F;
int infoLineX = 0;
int infoLineY = 0;
int infoRectangle[] = {0, 0, 0, 0};
String infoText = "";
int lastWidth =0;
int zoomBackFreqMin = 0;
int zoomBackFreqMax = 0;
int zoomBackScalMin = 0;
int zoomBackScalMax = 0;
int fullRangeMin = 24000000;
int fullRangeMax = 1800000000;
int fullScaleMin = -110;
int fullScaleMax = 40;
int startFreq = 88000000;
int stopFreq = 108000000;
int binStep = 1000;
int binStepProtection = 200;
int vertCursorFreq = 88000000;
int tmpFreq = 0;
int rfGain = 0;
int ifOffset = 0;
int ifType = 0;
int cropPercent = 0; // RTL data chunks percentage to keep. Values 0 to 70 percent
int scaleMin = -110;
int scaleMax = 40;
int uiNextLineIndex = 0;
int[][] uiLines = new int[10][10];
final int GRAPH_DRAG_NONE = 0;
final int GRAPH_DRAG_STARTED = 1;
final int GRAPH_DRAG_ENDED = 0;
int mouseDragGraph = GRAPH_DRAG_NONE;
int dragGraphStartX;
int dragGraphStartY;
int cursorVerticalLeftX = -1;//graphX();
int cursorVerticalRightX = -1;//(graphX() + graphWidth())*hzPerPixel();
int cursorHorizontalTopY = -1;//graphY();
int cursorHorizontalBottomY = -1;//graphY() + graphHeight();
int cursorVerticalLeftX_Color = #3399ff; // Cyan
int cursorHorizontalBottomY_Color = #3399ff;
int cursorVerticalRightX_Color = #ff80d5; // Magenta
int cursorHorizontalTopY_Color = #ff80d5;
int cursorDeltaColor = #00E010;
ListBox deviceDropdown;
DropdownList gainDropdown;
DropdownList serialDropdown;
String[] devices;
int[] gains;
int relMode = 0;
double minFrequency;
double minValue;
double minScaledValue;
double maxFrequency;
double maxValue;
double maxScaledValue;
boolean minmaxDisplay = false;
boolean sweepDisplay = false;
int showInfoScreen = 0;
class DataPoint {
public int x;
public double yMin = 0;
public double yMax = 0;
public double yAvg = 0;
}
class infoScreen {
public int topY = 0;
public int leftX = 0;
public int width = 0;
public int height = 0;
public String text = "";
color colorBack;
}
infoScreen infoHelp;
//========= added by Dave N
Table table;
String fileName = "config.csv"; // config file used to save and load program setting like frequency etc.
boolean setupDone = false;
boolean frozen = true;
boolean vertCursor = false;
float minMaxTextX = 10;
float minMaxTextY = 660;
int deltaLabelsX;
int deltaLabelsY;
int deltaLabelsXWaiting;
int deltaLabelsYWaiting;
boolean overGraph = false;
boolean mouseDragLock = false;
int startDraggingThr = 5;
int lastMouseX;
color buttonColor = color(70, 70, 70);
color buttonColorText = color(255, 255, 230);
color setButtonColor = color(127, 0, 0);
color clickMeButtonColor = color(20, 200, 20);
color willSaveButtonColor = color(200, 20, 20);
boolean drawSampleToggle=false;
boolean vertCursorToggle=true;
boolean drawFill=false;
// Reference
//
boolean refShow = false; // If the reference graph is shown on screen
boolean refStoreFlag = false; // Used to flag a save in draw()
DataPoint[] refArray ; // Storage of reference graph
boolean refArrayHasData = false;
int refYoffset=0;
// Average
//
DataPoint[] avgArray ; // Storage of reference graph
boolean avgShow = false;
boolean avgArrayHasData = false;
int avgDepth = 10;
int avgNewSampleWeight = 1;
boolean avgSamples = false;
// Persistent
//
DataPoint[] perArray ; // Storage of Minimum and Maximum persiastant data graph
boolean perShowMax = false;
boolean perShowMin = false;
boolean perShowMed = false;
boolean perArrayHasData = false;
int lastScanPosition = 0;
int scanPosition = 0;
int completeCycles = 0; // How many times the scanner has finished the defined range
color tabColorBachground = color(0, 70, 80);
//=========================
void MsgBox( String Msg, String Title ) {
// Messages
javax.swing.JOptionPane.showMessageDialog ( null, Msg, Title, javax.swing.JOptionPane.ERROR_MESSAGE );
}
void setupStartControls() {
int x, y;
int width = 170;
x = 15;
y = 40;
// frameRate(30);
deviceDropdown = cp5.addListBox("deviceDropdown")
.setBarHeight(20)
.setItemHeight(20)
.setPosition(x, y)
.setSize(width, 80);
deviceDropdown.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Select device");
for (int i=0; i<devices.length; i++) {
deviceDropdown.addItem(devices[i], i);
}
scaledBuffer = new DataPoint[0];
}
void setupControls() {
int x, y;
int width = 170;
Textlabel tmpLabel;
// Setup TABS
//
// if you want to receive a controlEvent when
// a tab is clicked, use activeEvent(true)
//
cp5.addTab("default")
//.setColorBackground( tabColorBachground )
.setColorLabel(color(255))
// .setColorActive(color(255,128,0))
.activateEvent(true)
.setId(TAB_GENERAL)
.setLabel(tabLabels[TAB_GENERAL])
.setHeight(TAB_HEIGHT_ACTIVE)
;
background(color(#222324));
// cp5.getTab("default")
// .setColorBackground( tabColorBachground )
// .activateEvent(true)
// .setLabel("General")
// .setId( TAB_GENERAL )
// ;
// General tab (1) =================================================
//
x = 15;
y = 10;
uiNextLineIndex = 0;
uiLines[uiNextLineIndex++][TAB_GENERAL] = y;
// y += 50;
y+=35;
cp5.addTextlabel("receiverLabel")
.setText("RECEIVER RANGE:")
.setPosition(x-13, y)
.setColorValue(0xffffff00)
.setFont(createFont("ARIAL", 10))
;
y+=35;
cp5.addTextfield("startFreqText")
.setPosition(x, y)
.setSize(width-50, 20)
.setText(str(startFreq))
.setAutoClear(false)
.setInputFilter(1)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Start frequency [Hz]")
;
cp5.addButton("resetMin")
//.setValue(0)
.setPosition(width-30, y)
.setSize(40, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("|<< RST")
;
// --------------------------------------------------------------------
//
y += 40;
cp5.addTextfield("stopFreqText")
.setPosition(x, y)
.setSize(width-50, 20)
.setText(str(stopFreq))
.setAutoClear(false)
.setInputFilter(1)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("End frequency [Hz]")
;
cp5.addButton("resetMax")
//.setValue(0)
.setPosition(width-30, y)
.setSize(40, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("RST >>|")
;
// --------------------------------------------------------------------
//
y += 40;
cp5.addTextfield("binStepText")
.setPosition(x, y)
.setSize(60, 20)
.setText(str(binStep))
.setAutoClear(false)
.setInputFilter(1)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Bin size [Hz]")
;
cp5.addButton("setRangeButton")
.setValue(0)
.setPosition(95, y)
.setSize(width/2, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("Set range")
;
y += 10;
uiLines[uiNextLineIndex++][TAB_GENERAL] = y;
// -------------------------------------------------------------------- IF offset
//
//y += 50;
y+=35;
cp5.addTextlabel("ifLabel")
.setText("UP/DOWN CONVERTER:")
.setPosition(x-13, y)
.setColorValue(0xffffff00)
.setFont(createFont("ARIAL", 10))
;
y+=30;
cp5.addTextfield("ifOffset")
.setPosition(x, y)
.setSize(90, 20)
.setText(str(binStep))
.setAutoClear(false)
.setInputFilter(1)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("IF Frequency")
;
cp5.get(Textfield.class, "ifOffset").setText(str(ifOffset)); // Spaggeti because mouse events and code modification events have the same result on event code...
// toggle vertical sursor on or off
cp5.addToggle("ifPlusToggle")
.setPosition(x + 100, y)
.setSize(20, 20)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE).setText("Above")
;
// toggle for how samples are shown - line / dots
cp5.addToggle("ifMinusToggle")
.setPosition(x + 140, y)
.setSize(20, 20)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE).setText("Below")
;
uiLines[uiNextLineIndex++][TAB_GENERAL] = y;
// --------------------------------------------------------------------
//
// y += 60;
y+=35;
cp5.addTextlabel("optionsLabel")
.setText("VARIOUS OPTIONS:")
.setPosition(x-13, y)
.setColorValue(0xffffff00)
.setFont(createFont("ARIAL", 10))
;
y+=35;
// toggle vertical sursor on or off
cp5.addToggle("vertCursorToggle")
.setPosition(x, y)
.setSize(20, 20)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE).setText("Cursors")
;
// toggle for how samples are shown - line / dots
cp5.addToggle("drawSampleToggle")
.setPosition(x + 70, y)
.setSize(20, 20)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE).setText("Line/Dots")
;
// toggle for how samples are shown - line / dots
cp5.addToggle("drawFill")
.setPosition(x + 140, y)
.setSize(20, 20)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE).setText("Filled Graph")
;
// --------------------------------------------------------------------
//
y += 40;
cp5.addToggle("offsetToggle")
.setPosition(x, y)
.setSize(20, 20)
.setValue(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Offset tunning")
;
cp5.addToggle("minmaxToggle")
.setPosition(x + 70, y)
.setSize(20, 20)
.setValue(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Min/Max")
;
cp5.addToggle("sweepToggle")
.setPosition(x + 140, y)
.setSize(20, 20)
.setValue(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Sweep")
;
y += 40;
cp5.addTextfield("cropPrcntTxt")
.setPosition(x, y)
.setSize(60, 20)
.setText(str(cropPercent))
.setAutoClear(false)
.setInputFilter(1)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Crop percent (0-70%)")
;
uiLines[uiNextLineIndex++][TAB_GENERAL] = y;
// ---------------------------- Configurations
//
y+=35;
cp5.addTextlabel("configLabel")
.setText("CONFIGURATION PRESETS:")
.setPosition(x-13, y)
.setColorValue(0xffffff00)
.setFont(createFont("ARIAL", 10))
;
// Quick n dirty. Load from file and populate list.
//
Table tmpTable = loadTable(fileName, "header");
y+=35;
cp5.addTextfield("presetName")
.setPosition(x, y)
.setSize(100, 20)
.setText(tmpTable.getString(0, "configName"))
.setAutoClear(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Current preset")
;
configurationDropdown = cp5.addDropdownList("configurationList")
.setBarHeight(20)
.setItemHeight(20)
.setPosition(x, y)
.setSize(100, 80)
.hide();
configurationDropdown.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText(configurationName);
cp5.addButton("selectPreset")
//.setValue(0)
.setPosition(x+105, y)
.setSize(20, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("...")
;
cp5.addButton("savePreset")
//.setValue(0)
.setPosition(x+135, y)
.setSize(40, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("Save to")
;
// Populate presets dropdwon list
//
for (int i=0; i<nrOfConfigurations; i++) {
configurationDropdown.addItem( tmpTable.getString(i, "configName"), i);
}
y+=30;
// Bottom of UI area
//
y = graphHeight() - 130;
uiLines[uiNextLineIndex++][TAB_GENERAL] = y - 40;
cp5.addButton("freezeDisplay")
//.setValue(0)
.setPosition(x, y)
.setSize(width/2-5, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("Pause")
;
cp5.addButton("exitProgram")
//.setValue(0)
.setPosition(x+width/2+5, y)
.setSize(width/2-5, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("Exit")
;
uiLines[uiNextLineIndex++][TAB_GENERAL] = 0;
// TAB MEASURE =============================================================================
//
// y=40;
cp5.addTab(tabLabels[TAB_MEASURE])
.setColorBackground( tabColorBachground )
// .setColorLabel(color(255))
// .setColorActive(color(255,128,0))
.activateEvent(true)
.setId(TAB_MEASURE)
.setHeight(TAB_HEIGHT)
;
// GAIN SCALE --------------------------------------------------------------------
//
y = 10;
uiNextLineIndex = 0;
uiLines[uiNextLineIndex++][TAB_MEASURE] = y;
y+=35;
tmpLabel = cp5.addTextlabel("verticalLabel")
.setText("VERTICAL SCALE & RF GAIN:")
.setPosition(x-13, y)
.setColorValue(0xffffff00)
.setFont(createFont("ARIAL", 10))
;
tmpLabel.moveTo(tabLabels[TAB_MEASURE]);
y+=35;
//y += 50;
cp5.addTextfield("scaleMinText")
.setPosition(60, y)
.setSize(25, 20)
.setText(str(scaleMin))
.setAutoClear(false)
.setInputFilter(1)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Lower")
;
cp5.getController("scaleMinText").moveTo(tabLabels[TAB_MEASURE]);
cp5.addTextfield("scaleMaxText")
.setPosition(90, y)
.setSize(25, 20)
.setText(str(scaleMax))
.setAutoClear(false)
.setInputFilter(1)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Upper")
;
cp5.getController("scaleMaxText").moveTo(tabLabels[TAB_MEASURE]);
cp5.addButton("setScale")
//.setValue(0)
.setPosition(120, y)
.setSize(60, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("Set scale")
;
cp5.getController("setScale").moveTo(tabLabels[TAB_MEASURE]);
// Gain dropdown
//
cp5.addTextlabel("label")
.setText("GAIN")
.setPosition(x, y-12)
.setSize(20, 20);
cp5.getController("label").moveTo(tabLabels[TAB_MEASURE]);
// --------------------------------------------------------------------
//
//y += 15;
/* gainDropdown = cp5.addDropdownList("gainDropdown")
.setBarHeight(20)
.setItemHeight(20)
.setPosition(x, y)
.setSize(40, 60)
;
gainDropdown.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("");
for (int i=0; i<gains.length; i++){
gainDropdown.addItem(str(gains[i]), gains[i]);
}
//gainDropdown.setValue(0);
gainDropdown.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText(str(gains[0]));
*/
cp5.addKnob("rfGain")
.setRange(gains[0], gains[gains.length-1])
.setValue(50)
.setPosition(x, y )
.setRadius(15)
.setDragDirection(Knob.VERTICAL)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("")
;
cp5.getController("rfGain").moveTo(tabLabels[TAB_MEASURE]);
cp5.addButton("rfGain01")
.setPosition(x, y+40)
.setSize(9, 20)
.setColorLabel(buttonColorText)
.setColorBackground(buttonColor).getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("")
;
cp5.addButton("rfGain02")
.setPosition(x+10, y+40)
.setSize(9, 20)
.setColorLabel(buttonColorText)
.setColorBackground(buttonColor).getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("")
;
cp5.addButton("rfGain03")
.setPosition(x+20, y+40)
.setSize(9, 20)
.setColorLabel(buttonColorText)
.setColorBackground(buttonColor).getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("")
;
cp5.getController("rfGain01").moveTo(tabLabels[TAB_MEASURE]);
cp5.getController("rfGain02").moveTo(tabLabels[TAB_MEASURE]);
cp5.getController("rfGain03").moveTo(tabLabels[TAB_MEASURE]);
// --------------------------------------------------------------------
//
y += 40;
cp5.addButton("autoScale")
//.setValue(0)
.setPosition(60, y)
.setSize(55, 20)
.setColorLabel(buttonColorText)
.setColorBackground(buttonColor).getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("Auto scale")
;
cp5.getController("autoScale").moveTo(tabLabels[TAB_MEASURE]);
cp5.addButton("resetScale")
//.setValue(0)
.setPosition(120, y)
.setSize(60, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("Reset scale")
;
cp5.getController("resetScale").moveTo(tabLabels[TAB_MEASURE]);
uiLines[uiNextLineIndex++][TAB_MEASURE] = y;
// REF, AVG, PERSISTENT --------------------------------------------------------------------
//
// y += 50;
y+=35;
tmpLabel = cp5.addTextlabel("avgLabel")
.setText("VIDEO AVERAGING :")
.setPosition(x-13, y)
.setColorValue(0xffffff00)
.setFont(createFont("ARIAL", 10))
;
tmpLabel.moveTo(tabLabels[TAB_MEASURE]);
y+=35;
// ---------------------------
cp5.addToggle("avgShow")
.setPosition(x, y)
.setSize(20, 20)
.setValue(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("ON/OFF")
;
cp5.getController("avgShow").moveTo(tabLabels[TAB_MEASURE]);
cp5.addToggle("avgSamples")
.setPosition(x + 70, y)
.setSize(20, 20)
.setValue(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Freeze")
;
cp5.getController("avgSamples").moveTo(tabLabels[TAB_MEASURE]);
cp5.addTextfield("avgDepthTxt")
.setSize(30, 20)
.setPosition(x + 130, y)
.setText(str(avgDepth))
.setAutoClear(false)
.setInputFilter(1)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Depth")
;
cp5.getController("avgDepthTxt").moveTo(tabLabels[TAB_MEASURE]);
uiLines[uiNextLineIndex++][TAB_MEASURE] = y;
//y += 15;
// ------- REFERENCE
//
//y += 40;
y+=35;
tmpLabel = cp5.addTextlabel("refLabel")
.setText("REFERENCE GRAPH:")
.setPosition(x-13, y)
.setColorValue(0xffffff00)
.setFont(createFont("ARIAL", 10))
;
tmpLabel.moveTo(tabLabels[TAB_MEASURE]);
y+=35;
cp5.addToggle("refShow")
.setPosition(x, y)
.setSize(20, 20)
.setValue(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("Show")
;
cp5.getController("refShow").moveTo(tabLabels[TAB_MEASURE]);
cp5.addButton("refSave")
.setPosition(50, y)
.setSize(width/2-5, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("Save Reference")
;
cp5.getController("refSave").moveTo(tabLabels[TAB_MEASURE]);
cp5.addKnob("refYoffset")
.setRange(-graphHeight(), graphHeight())
.setValue(50)
.setPosition(150, y-10 )
.setRadius(15)
.setDragDirection(Knob.VERTICAL)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("")
;
cp5.getController("refYoffset").moveTo(tabLabels[TAB_MEASURE]);
// --------------------------------------------------------------------
//
uiLines[uiNextLineIndex++][TAB_MEASURE] = y;
//y += 15;
// y += 40;
y+=35;
tmpLabel = cp5.addTextlabel("persistenceLabel")
.setText("MIN, MAX, MEDIAN HOLD :")
.setPosition(x-13, y)
.setColorValue(0xffffff00)
.setFont(createFont("ARIAL", 10))
;
tmpLabel.moveTo(tabLabels[TAB_MEASURE]);
y+=35;
cp5.addToggle("perShowMaxToggle")
.setPosition(x, y)
.setSize(20, 20)
.setValue(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("MAX")
;
cp5.getController("perShowMaxToggle").moveTo(tabLabels[TAB_MEASURE]);
cp5.addToggle("perShowMedToggle")
.setPosition(x + 35, y)
.setSize(20, 20)
.setValue(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("med")
;
cp5.getController("perShowMedToggle").moveTo(tabLabels[TAB_MEASURE]);
cp5.addToggle("perShowMinToggle")
.setPosition(x + 70, y)
.setSize(20, 20)
.setValue(false)
.getCaptionLabel().align(ControlP5.LEFT, ControlP5.TOP_OUTSIDE).setText("MIN");
cp5.getController("perShowMinToggle").moveTo(tabLabels[TAB_MEASURE]);
cp5.addButton("perReset")
.setPosition(x + 130, y)
.setSize(40, 20)
.setColorBackground(buttonColor)
.setColorLabel(buttonColorText)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER).setText("RESET")
;
cp5.getController("perReset").moveTo(tabLabels[TAB_MEASURE]);
uiLines[uiNextLineIndex++][TAB_MEASURE] = y;