-
Notifications
You must be signed in to change notification settings - Fork 2
/
TouchDSOGui.hpp
1799 lines (1626 loc) · 69.3 KB
/
TouchDSOGui.hpp
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
/*
* TouchDSOGui.hpp
*
* Implements the common (GUI) parts of AVR and ARM development
*
* Copyright (C) 2017-2023 Armin Joachimsmeyer
* Email: [email protected]
*
* This file is part of Arduino-Simple-DSO https://github.com/ArminJo/Arduino-Simple-DSO.
*
* Arduino-Simple-DSO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
*
*/
#ifndef _TOUCH_DSO_GUI_HPP
#define _TOUCH_DSO_GUI_HPP
uint8_t sLastPickerValue;
#define MIN_SAMPLES_PER_PERIOD_FOR_RELIABLE_FREQUENCY_VALUE 3
/************************************************************************
* Data analysis section
************************************************************************/
#if !defined(__AVR__)
/**
* Get max and min for display and automatic triggering.
*/
void computeMinMax(void) {
uint16_t tMax, tMin;
uint16_t *tDataBufferPointer = DataBufferControl.DataBufferDisplayStart
+ adjustIntWithScaleFactor(DisplayControl.DatabufferPreTriggerDisplaySize, DisplayControl.XScale);
if (DataBufferControl.DataBufferEndPointer <= tDataBufferPointer) {
return;
}
uint16_t tAcquisitionSize = DataBufferControl.DataBufferEndPointer + 1 - tDataBufferPointer;
tMax = *tDataBufferPointer;
if (MeasurementControl.isEffectiveMinMaxMode) {
tMin = *(tDataBufferPointer + DATABUFFER_MIN_OFFSET);
} else {
tMin = *tDataBufferPointer;
}
for (int i = 0; i < tAcquisitionSize; ++i) {
/*
* get new Min and Max
*/
uint16_t tValue = *tDataBufferPointer;
if (tValue > tMax) {
tMax = tValue;
}
if (MeasurementControl.isEffectiveMinMaxMode) {
uint16_t tValueMin = *(tDataBufferPointer + DATABUFFER_MIN_OFFSET);
if (tValueMin < tMin) {
tMin = tValueMin;
}
} else {
if (tValue < tMin) {
tMin = tValue;
}
}
tDataBufferPointer++;
}
MeasurementControl.RawValueMin = tMin;
MeasurementControl.RawValueMax = tMax;
}
#endif
void computePeriodFrequency(void) {
#if defined(__AVR__)
/*
* Scan data buffer (8 Bit display (!inverted!) values) for trigger conditions.
* Assume that first value is the first valid after a trigger
* (which does not hold for fast timebases and delayed or external trigger)
*/
uint8_t *tDataBufferPointer = &DataBufferControl.DataBuffer[0];
uint8_t tValue;
int16_t tCount;
uint16_t i;
uint16_t tStartPositionForPulsPause = 0; // Start position != 0 for TRIGGER_MODE_FREE, TRIGGER_MODE_EXTERN or delayed trigger.
uint16_t tFirstEndPositionForPulsPause = 0;
uint16_t tCountPosition = 0;
uint8_t tTriggerStatus = TRIGGER_STATUS_START;
uint8_t tTriggerStatusForFirstInterval = TRIGGER_STATUS_START;
uint8_t tActualCompareValue = getDisplayFromRawInputValue(MeasurementControl.RawTriggerLevelHysteresis); // start with hysteresis
uint8_t tFirstTriggerLevel; // start with opposite hysteresis for measurement of first interval
if (MeasurementControl.TriggerSlopeRising) {
tFirstTriggerLevel = getDisplayFromRawInputValue(MeasurementControl.RawTriggerLevel + MeasurementControl.RawHysteresis);
} else {
tFirstTriggerLevel = getDisplayFromRawInputValue(MeasurementControl.RawTriggerLevel - MeasurementControl.RawHysteresis);
}
MeasurementControl.PeriodFirst = 0;
MeasurementControl.PeriodSecond = 0;
if (MeasurementControl.TriggerMode >= TRIGGER_MODE_FREE || MeasurementControl.TriggerDelayMode != TRIGGER_DELAY_NONE) {
/*
* For TRIGGER_MODE_FREE, TRIGGER_MODE_EXTERN or delayed trigger first display value is not any trigger,
* so start with search for begin of period.
*/
tCount = -1;
} else {
// First display value is the first after triggering condition so we have at least one trigger, but still no period.
tCount = 0;
}
for (i = 0; i < DISPLAY_WIDTH; ++i) {
#else
/**
* Get period and frequency and average for display
*
* Use databuffer and only post trigger area!
* For frequency use only max values!
*/
uint16_t *tDataBufferPointer = DataBufferControl.DataBufferDisplayStart
+ adjustIntWithScaleFactor(DisplayControl.DatabufferPreTriggerDisplaySize, DisplayControl.XScale);
if (DataBufferControl.DataBufferEndPointer <= tDataBufferPointer) {
return;
}
uint16_t tAcquisitionSize = DataBufferControl.DataBufferEndPointer + 1 - tDataBufferPointer;
uint16_t tValue;
uint32_t tIntegrateValue = 0;
uint32_t tIntegrateValueForTotalPeriods = 0;
int tCount = 0;
uint16_t tStartPositionForPulsPause = 0;
uint16_t tFirstEndPositionForPulsPause = 0;
int tCountPosition = 0;
int tPeriodDelta = 0;
int tPeriodMin = 1024;
int tPeriodMax = 0;
int tTriggerStatus = TRIGGER_STATUS_START;
int tTriggerStatusForFirstInterval = TRIGGER_STATUS_START;
uint16_t tActualCompareValue = MeasurementControl.RawTriggerLevelHysteresis;
uint16_t tFirstTriggerLevel; // start with opposite hysteresis for measurement of first interval
if (MeasurementControl.TriggerSlopeRising) {
tFirstTriggerLevel = MeasurementControl.RawTriggerLevel + MeasurementControl.RawHysteresis;
} else {
tFirstTriggerLevel = MeasurementControl.RawTriggerLevel - MeasurementControl.RawHysteresis;
}
bool tReliableValue = true;
/*
* Trigger condition and average taken only from entire periods
* Use only max value for period
*/
for (int i = 0; i < tAcquisitionSize; ++i) {
#endif
tValue = *tDataBufferPointer;
bool tValueGreaterCompareValue = (tValue > tActualCompareValue); // variable name is correct for rising slope!
#if defined(__AVR__)
// Since all values are inverted Display values, we have to use just the inverted condition -> toggle compare result if (TriggerSlopeRising == true)
tValueGreaterCompareValue = tValueGreaterCompareValue ^ MeasurementControl.TriggerSlopeRising;
#else
// toggle compare result if TriggerSlopeRising == false
tValueGreaterCompareValue = tValueGreaterCompareValue ^ (!MeasurementControl.TriggerSlopeRising);
#endif
/*
* First value is the first sample after triggering condition (including delay)
*/
if (tFirstEndPositionForPulsPause == 0 && tCount == 0) {
/*
* Compute time of first pulse (pause) here.
* First wait for signal to go beyond hysteresis, then check for crossing trigger level
*/
bool tValueLessThanTriggerForFirstPeriod = (tValue < tFirstTriggerLevel);
#if defined(__AVR__)
// Since all values are inverted Display values, we have to use just the inverted condition -> toggle compare result if (TriggerSlopeRising == true)
tValueLessThanTriggerForFirstPeriod = tValueLessThanTriggerForFirstPeriod ^ MeasurementControl.TriggerSlopeRising;
#else
// toggle compare result if TriggerSlopeRising == false
tValueLessThanTriggerForFirstPeriod = tValueLessThanTriggerForFirstPeriod ^ (!MeasurementControl.TriggerSlopeRising);
#endif
if (tTriggerStatusForFirstInterval == TRIGGER_STATUS_START) {
// Wait for signal to go beyond hysteresis
if (!tValueLessThanTriggerForFirstPeriod) {
tTriggerStatusForFirstInterval = TRIGGER_STATUS_AFTER_HYSTERESIS;
// BlueDisplay1.debug("trg1=", tFirstTriggerLevel);
// BlueDisplay1.debug("i=", i);
// BlueDisplay1.debug("tValue=", tValue);
tFirstTriggerLevel = getDisplayFromRawInputValue(MeasurementControl.RawTriggerLevel);
}
} else {
if (tValueLessThanTriggerForFirstPeriod) {
// signal crosses trigger -> first interval detected
tFirstEndPositionForPulsPause = i;
MeasurementControl.PeriodFirst = getMicrosFromHorizontalDisplayValue(i - tStartPositionForPulsPause, 1);
// BlueDisplay1.debug("trg2=", tFirstTriggerLevel);
// BlueDisplay1.debug("i=", i);
// BlueDisplay1.debug("tValue=", tValue);
}
}
}
if (tTriggerStatus == TRIGGER_STATUS_START) {
// rising slope - wait for value below hysteresis value
// falling slope - wait for value above hysteresis value
if (!tValueGreaterCompareValue) {
tTriggerStatus = TRIGGER_STATUS_AFTER_HYSTERESIS;
#if defined(__AVR__)
tActualCompareValue = getDisplayFromRawInputValue(MeasurementControl.RawTriggerLevel);
#else
tActualCompareValue = MeasurementControl.RawTriggerLevel;
#endif
}
} else {
/*
* TRIGGER_STATUS_AFTER_HYSTERESIS here
* rising slope - wait for inverted Display value to go below trigger value -> wait for value to rise above trigger value
* falling slope - wait for inverted Display value to rise above trigger value
*/
if (tValueGreaterCompareValue) {
#if defined(__AVR__)
tTriggerStatus = TRIGGER_STATUS_START;
tActualCompareValue = getDisplayFromRawInputValue(MeasurementControl.RawTriggerLevelHysteresis);
#else
if ((tPeriodDelta) < MIN_SAMPLES_PER_PERIOD_FOR_RELIABLE_FREQUENCY_VALUE) {
// found new trigger in less than MIN_SAMPLES_PER_PERIOD_FOR_RELIABLE_FREQUENCY_VALUE samples => no reliable value
tReliableValue = false;
} else {
// search for next slope
tTriggerStatus = TRIGGER_STATUS_START;
tActualCompareValue = MeasurementControl.RawTriggerLevelHysteresis;
if (tPeriodDelta < tPeriodMin) {
tPeriodMin = tPeriodDelta;
} else if (tPeriodDelta > tPeriodMax) {
tPeriodMax = tPeriodDelta;
}
tPeriodDelta = 0;
// found and search for next slope
tIntegrateValueForTotalPeriods = tIntegrateValue;
#endif
tCount++;
if (tCount == 0) {
// set start position for TRIGGER_MODE_FREE, TRIGGER_MODE_EXTERN or delayed trigger.
tStartPositionForPulsPause = i;
} else if (tCount == 1) {
// first complete period (pulse + pause) is detected here
MeasurementControl.PeriodSecond = getMicrosFromHorizontalDisplayValue(i - tFirstEndPositionForPulsPause, 1);
}
tCountPosition = i;
#if !defined(__AVR__)
}
#endif
}
}
#if !defined(__AVR__)
if (MeasurementControl.isEffectiveMinMaxMode) {
uint16_t tValueMin = *(tDataBufferPointer + DATABUFFER_MIN_OFFSET);
tIntegrateValue += (tValue + tValueMin) / 2;
} else {
tIntegrateValue += tValue;
}
tPeriodDelta++;
#endif
tDataBufferPointer++;
} // for
#if !defined(__AVR__)
/*
* check for plausi of period values
* allow delta of periods to be at least 1/8 period + 3
*/
tPeriodDelta = tPeriodMax - tPeriodMin;
if (((tCountPosition / (8 * tCount)) + 3) < tPeriodDelta) {
tReliableValue = false;
}
#endif
/*
* compute period and frequency
*/
#if defined(__AVR__)
if (tCount <= 0) {
#else
if (tCountPosition <= 0 || tCount <= 0 || !tReliableValue) {
MeasurementControl.FrequencyHertz = 0;
MeasurementControl.RawValueAverage = (tIntegrateValue + (tAcquisitionSize / 2)) / tAcquisitionSize;
#endif
MeasurementControl.PeriodMicros = 0;
MeasurementControl.FrequencyHertz = 0;
} else {
#if defined(__AVR__)
tCountPosition -= tStartPositionForPulsPause;
uint32_t tPeriodMicros = getMicrosFromHorizontalDisplayValue(tCountPosition, tCount);
MeasurementControl.PeriodMicros = tPeriodMicros;
#else
MeasurementControl.RawValueAverage = (tIntegrateValueForTotalPeriods + (tCountPosition / 2)) / tCountPosition;
// compute microseconds per period
float tPeriodMicros = getMicrosFromHorizontalDisplayValue(tCountPosition, tCount) + 0.0005;
#endif
MeasurementControl.PeriodMicros = tPeriodMicros;
// frequency
float tHertz = 1000000.0 / tPeriodMicros;
MeasurementControl.FrequencyHertz = tHertz + 0.5;
}
return;
}
/**
* compute new trigger value and hysteresis
* If old values are reasonable don't change them to avoid jitter
*/
void computeAutoTrigger(void) {
if (MeasurementControl.TriggerMode == TRIGGER_MODE_AUTOMATIC) {
/*
* Set auto trigger in middle between min and max
*/
uint16_t tPeakToPeak = MeasurementControl.RawValueMax - MeasurementControl.RawValueMin;
// middle between min and max
uint16_t tPeakToPeakHalf = tPeakToPeak / 2;
uint16_t tNewRawTriggerValue = MeasurementControl.RawValueMin + tPeakToPeakHalf;
//set effective hysteresis to quarter peak to peak
int tTriggerHysteresis = tPeakToPeakHalf / 2;
// keep reasonable value - avoid jitter - abs does not work, it may give negative values
// int tTriggerDelta = abs(tNewTriggerValue - MeasurementControl.RawTriggerLevel);
int tTriggerDelta = tNewRawTriggerValue - MeasurementControl.RawTriggerLevel;
if (tTriggerDelta < 0) {
tTriggerDelta = -tTriggerDelta;
}
int tOldHysteresis3Quarter = (MeasurementControl.RawHysteresis / 4) * 3;
if (tTriggerDelta > (tTriggerHysteresis / 4) || tTriggerHysteresis <= tOldHysteresis3Quarter) {
/*
* (Old - new trigger value) > tPeakToPeak / 16 - condition for value getting bigger
* or new hysteresis <= 3/4 old hysteresis - condition for value getting smaller
*/
setTriggerLevelAndHysteresis(tNewRawTriggerValue, tTriggerHysteresis);
}
}
}
void setTriggerLevelAndHysteresis(int aRawTriggerValue, int aRawTriggerHysteresis) {
MeasurementControl.RawTriggerLevel = aRawTriggerValue;
MeasurementControl.RawHysteresis = aRawTriggerHysteresis;
if (MeasurementControl.TriggerSlopeRising) {
MeasurementControl.RawTriggerLevelHysteresis = aRawTriggerValue - aRawTriggerHysteresis;
} else {
MeasurementControl.RawTriggerLevelHysteresis = aRawTriggerValue + aRawTriggerHysteresis;
}
}
/************************************************************************
* Logic section
************************************************************************/
/*
* Sets isACMode and in turn ChannelIsACMode accordingly - no AC mode for channels without attenuator
* uses MeasurementControl.DisplayRangeIndex for getRawOffsetValueFromGridCount()
*/
void setACMode(bool aNewACMode) {
#if defined(__AVR__)
if (MeasurementControl.isRunning) {
//clear old grid, since it will be changed
BlueDisplay1.clearDisplay();
}
#endif
MeasurementControl.isACMode = aNewACMode;
#if defined(__AVR__)
// Allow manual setting of AC mode
MeasurementControl.ChannelIsACMode = aNewACMode;
#else
if (MeasurementControl.ChannelHasAC_DCSwitch) {
MeasurementControl.ChannelIsACMode = aNewACMode;
} else {
MeasurementControl.ChannelIsACMode = false;
}
#endif
/*
* Handle AC hardware switching
*/
#if defined(__AVR__)
if (aNewACMode) {
/*
* AC mode here: Change AC_DC_BIAS_PIN pin to input
*/
DDRC = 0; // all analog channels set to input
// no OffsetAutomatic for AC mode
MeasurementControl.OffsetMode = OFFSET_MODE_0_VOLT;
MeasurementControl.OffsetValue = 0;
if (MeasurementControl.AttenuatorType < ATTENUATOR_TYPE_ACTIVE_ATTENUATOR) {
digitalWriteFast(AC_DC_RELAY_PIN, HIGH);
}
} else {
/*
* DC mode here: Change AC_DC_BIAS_PIN pin to output and shorten bias to 0 volt
*/
DDRC = OUTPUT_MASK_PORTC;
digitalWriteFast(AC_DC_BIAS_PIN, LOW);
if (MeasurementControl.AttenuatorType < ATTENUATOR_TYPE_ACTIVE_ATTENUATOR) {
digitalWriteFast(AC_DC_RELAY_PIN, LOW);
}
}
#else
DSO_setACMode(aNewACMode);
#endif
/*
* New Offset for AC Mode
*/
#if defined(__AVR__)
// must do it here after settings of flags and before drawing
setACModeButtonCaption();
if (DisplayControl.DisplayPage == DSO_PAGE_SETTINGS) {
// hide/show offset
drawDSOSettingsPage();
}
if (MeasurementControl.isRunning) {
drawGridLinesWithHorizLabelsAndTriggerLine();
}
resetOffset();
#else
setOffsetGridCountAccordingToACMode();
#endif
}
/************************************************************************
* Text output section
************************************************************************/
/*
* clear info line
*/
void clearInfo(uint8_t aOldMode) {
// +1 because I have seen artifacts otherwise
uint8_t tHeight = FONT_SIZE_INFO_SHORT + 1;
if (aOldMode == INFO_MODE_LONG_INFO) {
tHeight = (2 * FONT_SIZE_INFO_LONG) + 1;
}
BlueDisplay1.fillRectRel(INFO_LEFT_MARGIN, 0, DISPLAY_WIDTH, tHeight, COLOR_BACKGROUND_DSO);
}
/***********************************************************************
* GUI initialization
***********************************************************************/
#if defined(__AVR__)
BDButton TouchButtonADCReference;
const char ReferenceButtonVCC[] PROGMEM = "Ref VCC";
const char ReferenceButton1_1V[] PROGMEM = "Ref 1.1V";
#else
BDButton TouchButtonFFT;
BDButton TouchButtonShowPretriggerValuesOnOff;
BDButton TouchButtonDSOMoreSettings;
BDButton TouchButtonCalibrateVoltage;
BDButton TouchButtonMinMaxMode;
#if defined(FUTURE)
BDButton TouchButtonDrawModeTriggerLine;
#endif
#endif
#if defined(SUPPORT_LOCAL_DISPLAY)
BDButton TouchButtonDrawModeLinePixel;
const char DrawModeButtonStringLine[] = "Line";
const char DrawModeButtonStringPixel[] = "Pixel";
BDButton TouchButtonADS7846TestOnOff;
#endif
BDButton TouchButtonSingleshot;
BDButton TouchButtonStartStopDSOMeasurement;
BDButton TouchButtonTriggerMode;
const char sTriggerModeButtonStringAuto[] PROGMEM = "Trigger\nauto";
const char sTriggerModeButtonStringManualTimeout[] PROGMEM = "Trigger\nman timeout";
const char sTriggerModeButtonStringManual[] PROGMEM = "Trigger\nman";
const char sTriggerModeButtonStringFreeRunning[] PROGMEM = "Trigger\nfree";
const char sTriggerModeButtonStringExternal[] PROGMEM = "Trigger\next";
const char *const sTriggerModeButtonCaptionStringArray[] PROGMEM = {sTriggerModeButtonStringAuto,
sTriggerModeButtonStringManualTimeout, sTriggerModeButtonStringManual, sTriggerModeButtonStringFreeRunning,
sTriggerModeButtonStringExternal};
BDButton TouchButtonTriggerDelay;
BDButton TouchButtonChartHistoryOnOff;
BDButton TouchButtonSlope;
char SlopeButtonString[] = "Slope\nascending";
BDButton TouchButtonChannels[NUMBER_OF_CHANNELS_WITH_FIXED_ATTENUATOR];
BDButton TouchButtonChannelSelect;
const char StringChannel0[] PROGMEM = "Ch 0";
const char StringChannel1[] PROGMEM = "Ch 1";
const char StringChannel2[] PROGMEM = "Ch 2";
const char StringChannel3[] PROGMEM = "Ch 3";
const char StringChannel4[] PROGMEM = "Ch 4";
const char StringTemperature[] PROGMEM = "Temp";
const char StringVRefint[] PROGMEM = "VRef";
const char StringVBattDiv2[] PROGMEM = "\xBD" "VBatt";
#if defined(__AVR__)
const char *const ADCInputMUXChannelStrings[] = {StringChannel0, StringChannel1, StringChannel2, StringChannel3, StringChannel4,
StringTemperature, StringVRefint};
#else
#if defined(STM32F30X)
const char *const ADCInputMUXChannelStrings[ADC_CHANNEL_COUNT] = { StringChannel2, StringChannel3, StringChannel4,
StringTemperature, StringVBattDiv2, StringVRefint };
uint8_t const ADCInputMUXChannels[] = { ADC_CHANNEL_2, ADC_CHANNEL_3, ADC_CHANNEL_4, ADC_CHANNEL_TEMPSENSOR, ADC_CHANNEL_VBAT,
ADC_CHANNEL_VREFINT };
#else
const char * const ADCInputMUXChannelStrings[] = {StringChannel0, StringChannel1, StringChannel2, StringChannel3,
StringTemperature, StringVRefint};
const uint8_t ADCInputMUXChannels[] = {ADC_CHANNEL_0, ADC_CHANNEL_1, ADC_CHANNEL_2, ADC_CHANNEL_3,
ADC_CHANNEL_TEMPSENSOR, ADC_CHANNEL_VREFINT};
#endif
#endif
const char ChannelDivBy1ButtonString[] PROGMEM = "\xF7" "1";
const char ChannelDivBy10ButtonString[] PROGMEM = "\xF7" "10";
const char ChannelDivBy100ButtonString[] PROGMEM = "\xF7" "100";
const char *const ChannelDivByButtonStrings[] =
{ ChannelDivBy1ButtonString, ChannelDivBy10ButtonString, ChannelDivBy100ButtonString };
BDButton TouchButtonChannelMode;
BDButton TouchButtonAutoOffsetMode;
const char AutoOffsetButtonString0[] PROGMEM = "Offset\n0V";
const char AutoOffsetButtonStringAuto[] PROGMEM = "Offset\nauto";
const char AutoOffsetButtonStringMan[] PROGMEM = "Offset\nman";
const char *const sAutoOffsetButtonCaptionStringArray[] PROGMEM = {AutoOffsetButtonString0, AutoOffsetButtonStringAuto,
AutoOffsetButtonStringMan};
BDButton TouchButtonAutoRangeOnOff;
const char AutoRangeButtonStringAuto[] PROGMEM = "Range\nauto";
const char AutoRangeButtonStringManual[] PROGMEM = "Range\nman";
BDButton TouchButtonSettingsPage;
BDButton TouchButtonFrequencyPage;
BDButton TouchButtonAcDc;
/*
* Slider for trigger level and voltage picker
*/
BDSlider TouchSliderTriggerLevel;
BDSlider TouchSliderVoltagePicker;
void initDSOGUI(void) {
BDButton::setGlobalFlags (FLAG_BUTTON_GLOBAL_USE_UP_EVENTS_FOR_BUTTONS); // since swipe can start on a button
int tPosY = 0;
/***************************
* Start page
***************************/
// 1. row
// Button for Singleshot
#if defined(__AVR__)
TouchButtonSingleshot.init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_3, START_PAGE_BUTTON_HEIGHT, COLOR_GUI_CONTROL,
F("Singleshot"), TEXT_SIZE_14, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doStartSingleshot);
#else
TouchButtonSingleshot.init(BUTTON_WIDTH_6_POS_4, tPosY, BUTTON_WIDTH_3, START_PAGE_BUTTON_HEIGHT, COLOR_GUI_CONTROL,
F("Singleshot"), TEXT_SIZE_14, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doStartSingleshot);
#endif
// 2. row
tPosY += START_PAGE_ROW_INCREMENT;
#if defined(LOCAL_FILESYSTEM_EXISTS)
TouchButtonStore.init(0, tPosY, BUTTON_WIDTH_5, START_PAGE_BUTTON_HEIGHT, COLOR_GUI_SOURCE_TIMEBASE,
"Store", TEXT_SIZE_11, BUTTON_FLAG_NO_BEEP_ON_TOUCH, MODE_STORE, &doStoreLoadAcquisitionData);
TouchButtonLoad.init(BUTTON_WIDTH_5_POS_2, tPosY, BUTTON_WIDTH_5, START_PAGE_BUTTON_HEIGHT,
COLOR_GUI_SOURCE_TIMEBASE, "Load", TEXT_SIZE_11, BUTTON_FLAG_NO_BEEP_ON_TOUCH, MODE_LOAD, &doStoreLoadAcquisitionData);
#endif
// big start stop button
TouchButtonStartStopDSOMeasurement.init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_3,
(2 * START_PAGE_BUTTON_HEIGHT) + BUTTON_DEFAULT_SPACING, COLOR_GUI_CONTROL, F("Start\nStop"), TEXT_SIZE_26,
FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doStartStopDSO);
// 4. row
tPosY += 2 * START_PAGE_ROW_INCREMENT;
#if !defined(__AVR__)
// Button for show FFT - only for Start and Chart pages. Invisible if running.
TouchButtonFFT.init(0, tPosY, BUTTON_WIDTH_3, BUTTON_HEIGHT_4, 0, "FFT", TEXT_SIZE_22,
FLAG_BUTTON_DO_BEEP_ON_TOUCH | FLAG_BUTTON_TYPE_TOGGLE_RED_GREEN_MANUAL_REFRESH, DisplayControl.ShowFFT, &doShowFFT);
#endif
// Button for settings page
TouchButtonSettingsPage.init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_3, START_PAGE_BUTTON_HEIGHT, COLOR_GUI_CONTROL,
F("Settings"), TEXT_SIZE_18, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doShowSettingsPage);
/***************************
* Settings page
***************************/
// 1. row
tPosY = 0;
/*
* Button for chart history (erase color). Must be at first row since it is (hidden) active at running mode
*/
#if defined(SUPPORT_LOCAL_DISPLAY)
TouchButtonChartHistoryOnOff.init(SLIDER_DEFAULT_BAR_WIDTH + 6, tPosY, BUTTON_WIDTH_3 - (SLIDER_DEFAULT_BAR_WIDTH + 6),
SETTINGS_PAGE_BUTTON_HEIGHT, 0, "History", TEXT_SIZE_11,
FLAG_BUTTON_DO_BEEP_ON_TOUCH | FLAG_BUTTON_TYPE_TOGGLE_RED_GREEN_MANUAL_REFRESH, 0, &doChartHistory);
#else
TouchButtonChartHistoryOnOff.init(0, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, 0, F("History"), TEXT_SIZE_18,
FLAG_BUTTON_DO_BEEP_ON_TOUCH | FLAG_BUTTON_TYPE_TOGGLE_RED_GREEN_MANUAL_REFRESH, 0, &doChartHistory);
#endif
// Button for slope
TouchButtonSlope.init(BUTTON_WIDTH_3_POS_2, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR_GUI_TRIGGER, "",
TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doTriggerSlope);
setSlopeButtonCaption();
// Back button for sub pages
TouchButtonBack.init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR_GUI_CONTROL, F("Back"),
TEXT_SIZE_22, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doDefaultBackButton);
// 2. row
tPosY += SETTINGS_PAGE_ROW_INCREMENT;
#if defined(__AVR__)
// Button for delay
TouchButtonTriggerDelay.init(0, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR_GUI_TRIGGER, "", TEXT_SIZE_11,
FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doPromptForTriggerDelay);
setTriggerDelayCaption();
#endif
// Button for trigger mode
TouchButtonTriggerMode.init(BUTTON_WIDTH_3_POS_2, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR_GUI_TRIGGER, "",
TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doTriggerMode);
setTriggerModeButtonCaption();
// Button for channel 0
TouchButtonChannels[0].init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_6, SETTINGS_PAGE_BUTTON_HEIGHT,
BUTTON_AUTO_RED_GREEN_FALSE_COLOR, "", TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doChannelSelect);
// Button for channel 1
TouchButtonChannels[1].init(DISPLAY_WIDTH - BUTTON_WIDTH_6, tPosY, BUTTON_WIDTH_6, SETTINGS_PAGE_BUTTON_HEIGHT,
BUTTON_AUTO_RED_GREEN_FALSE_COLOR, "", TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 1, &doChannelSelect);
// 3. row
tPosY += SETTINGS_PAGE_ROW_INCREMENT;
#if !defined(__AVR__)
// Button for pretrigger area show
#if defined(SUPPORT_LOCAL_DISPLAY)
TouchButtonShowPretriggerValuesOnOff.init(SLIDER_DEFAULT_BAR_WIDTH + 6, tPosY, BUTTON_WIDTH_3 - (SLIDER_DEFAULT_BAR_WIDTH + 6),
SETTINGS_PAGE_BUTTON_HEIGHT, 0, "Show\nPretrigger", TEXT_SIZE_11,
FLAG_BUTTON_DO_BEEP_ON_TOUCH | FLAG_BUTTON_TYPE_TOGGLE_RED_GREEN, (DisplayControl.DatabufferPreTriggerDisplaySize != 0),
&doShowPretriggerValuesOnOff);
#else
TouchButtonShowPretriggerValuesOnOff.init(0, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, 0, "Show\nPretrigger",
TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH | FLAG_BUTTON_TYPE_TOGGLE_RED_GREEN,
(DisplayControl.DatabufferPreTriggerDisplaySize != 0), &doShowPretriggerValuesOnOff);
#endif
#endif
// Button for AutoRange on off
TouchButtonAutoRangeOnOff.init(BUTTON_WIDTH_3_POS_2, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR_GUI_TRIGGER, "",
TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doRangeMode);
setAutoRangeModeAndButtonCaption(true);
// Button for channel 2
TouchButtonChannels[2].init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_6, SETTINGS_PAGE_BUTTON_HEIGHT,
BUTTON_AUTO_RED_GREEN_FALSE_COLOR, "", TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 2, &doChannelSelect);
setChannelButtonsCaption();
// Button for channel select
TouchButtonChannelSelect.init(DISPLAY_WIDTH - BUTTON_WIDTH_6, tPosY, BUTTON_WIDTH_6, SETTINGS_PAGE_BUTTON_HEIGHT,
BUTTON_AUTO_RED_GREEN_FALSE_COLOR, reinterpret_cast<const __FlashStringHelper*>(StringChannel3), TEXT_SIZE_11,
FLAG_BUTTON_DO_BEEP_ON_TOUCH, 42, &doChannelSelect);
// 4. row
tPosY += SETTINGS_PAGE_ROW_INCREMENT;
#if !defined(__AVR__)
// Button for min/max acquisition mode
# if defined(SUPPORT_LOCAL_DISPLAY)
TouchButtonMinMaxMode.init(SLIDER_DEFAULT_BAR_WIDTH + 6, tPosY, BUTTON_WIDTH_3 - (SLIDER_DEFAULT_BAR_WIDTH + 6),
SETTINGS_PAGE_BUTTON_HEIGHT, COLOR_GUI_TRIGGER, "Min/Max\nmode", TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, true,
&doMinMaxMode);
# else
TouchButtonMinMaxMode.init(0, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR_GUI_TRIGGER, "Min/Max\nmode",
TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, true, &doMinMaxMode);
# endif
#endif
// Button for auto offset on, 0-Volt, manual
TouchButtonAutoOffsetMode.init(BUTTON_WIDTH_3_POS_2, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR_GUI_TRIGGER, "",
TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doOffsetMode);
setAutoOffsetButtonCaption();
#if defined(FUTURE)
// Button for trigger line mode
TouchButtonDrawModeTriggerLine.init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT,
0, "Trigger\nline", TEXT_SIZE_11,
FLAG_BUTTON_DO_BEEP_ON_TOUCH | FLAG_BUTTON_TYPE_TOGGLE_RED_GREEN, DisplayControl.showTriggerInfoLine,
&doDrawModeTriggerLine);
#endif
// 5. row
tPosY = DISPLAY_HEIGHT - SETTINGS_PAGE_BUTTON_HEIGHT;
// Button for selecting Frequency page.
TouchButtonFrequencyPage.init(0, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR16_RED, F("Frequency\nGenerator"),
TEXT_SIZE_14, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doShowFrequencyPage);
// Button for AC / DC
TouchButtonAcDc.init(BUTTON_WIDTH_3_POS_2, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR_GUI_TRIGGER, "",
TEXT_SIZE_22, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doAcDcMode);
setACModeButtonCaption();
#if defined(__AVR__)
// Button for reference voltage switching
TouchButtonADCReference.init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT,
COLOR_GUI_SOURCE_TIMEBASE, "", TEXT_SIZE_18, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doADCReference);
#else
// Button for more-settings pages
TouchButtonDSOMoreSettings.init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_3, BUTTON_HEIGHT_5, COLOR_GUI_CONTROL, "More",
TEXT_SIZE_22, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doShowMoreSettingsPage);
/***************************
* More Settings page
***************************/
// 1. row
tPosY = 0;
// Button for voltage calibration
TouchButtonCalibrateVoltage.init(0, tPosY, BUTTON_WIDTH_3, BUTTON_HEIGHT_4, COLOR_GUI_SOURCE_TIMEBASE, "Calibrate U",
TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doVoltageCalibration);
// 2. row
tPosY += SETTINGS_PAGE_ROW_INCREMENT;
// Button for system info
TouchButtonShowSystemInfo.init(BUTTON_WIDTH_3_POS_3, tPosY, BUTTON_WIDTH_3, SETTINGS_PAGE_BUTTON_HEIGHT, COLOR16_GREEN,
"System\ninfo", TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doShowSystemInfoPage);
#endif
/*
* SLIDER
*/
// make slider slightly visible
// slider for voltage picker
TouchSliderVoltagePicker.init(SLIDER_VPICKER_POS_X, 0, SLIDER_BAR_WIDTH, DISPLAY_HEIGHT, DISPLAY_HEIGHT, 0,
COLOR16_WHITE, COLOR_VOLTAGE_PICKER_SLIDER, FLAG_SLIDER_VALUE_BY_CALLBACK, &doVoltagePicker);
TouchSliderVoltagePicker.setBarBackgroundColor(COLOR_VOLTAGE_PICKER_SLIDER);
// slider for trigger level
TouchSliderTriggerLevel.init(SLIDER_TLEVEL_POS_X, 0, SLIDER_BAR_WIDTH, DISPLAY_HEIGHT, DISPLAY_HEIGHT, 0,
COLOR16_WHITE, COLOR_TRIGGER_SLIDER, FLAG_SLIDER_VALUE_BY_CALLBACK, &doTriggerLevel);
TouchSliderTriggerLevel.setBarBackgroundColor(COLOR_TRIGGER_SLIDER);
#if defined(SUPPORT_LOCAL_DISPLAY)
// 2. row
// Button for switching draw mode - line/pixel
TouchButtonDrawModeLinePixel.init(0, BUTTON_HEIGHT_4_LINE_2, BUTTON_WIDTH_3,
BUTTON_HEIGHT_4, COLOR_GUI_DISPLAY_CONTROL, DrawModeButtonStringLine, TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0,
&doDrawMode);
// Button for ADS7846 channel
TouchButtonADS7846TestOnOff.init(BUTTON_WIDTH_3_POS_2, BUTTON_HEIGHT_4_LINE_2, BUTTON_WIDTH_3, BUTTON_HEIGHT_4, 0, "ADS7846",
TEXT_SIZE_11, FLAG_BUTTON_DO_BEEP_ON_TOUCH | FLAG_BUTTON_TYPE_TOGGLE_RED_GREEN, MeasurementControl.ADS7846ChannelsAsDatasource,
&doADS7846TestOnOff);
/*
* Backlight slider
*/
TouchSliderBacklight.init(0, 0, SLIDER_DEFAULT_BAR_WIDTH, BACKLIGHT_MAX_BRIGHTNESS_VALUE, BACKLIGHT_MAX_BRIGHTNESS_VALUE, sCurrentBacklightPercent,
COLOR16_WHITE, COLOR16_GREEN, FLAG_SLIDER_VERTICAL_SHOW_NOTHING, &doBacklightSlider);
#endif
}
/*
* activate elements if returning from settings screen or if starting acquisition
*/
void activateChartGui(void) {
TouchButtonChartHistoryOnOff.activate();
TouchButtonSingleshot.activate();
TouchButtonStartStopDSOMeasurement.activate();
TouchButtonSettingsPage.activate();
#if !defined(ARDUINO)
TouchButtonFFT.activate();
#endif
TouchSliderVoltagePicker.drawSlider();
if (MeasurementControl.TriggerMode == TRIGGER_MODE_MANUAL_TIMEOUT || MeasurementControl.TriggerMode == TRIGGER_MODE_MANUAL) {
TouchSliderTriggerLevel.drawSlider();
}
#if !defined(ARDUINO)
TouchButtonMainHome.activate();
#endif
}
/************************************************************************
* Output and draw section
************************************************************************/
void redrawDisplay() {
clearDisplayAndDisableButtonsAndSliders();
if (MeasurementControl.isRunning) {
/*
* running mode
*/
if (DisplayControl.DisplayPage >= DSO_PAGE_SETTINGS) {
drawDSOSettingsPage();
} else {
activateChartGui();
// refresh grid - not really needed, since after MILLIS_BETWEEN_INFO_OUTPUT it is done by loop
drawGridLinesWithHorizLabelsAndTriggerLine();
printInfo();
#if !defined(__AVR__)
TouchButtonChartHistoryOnOff.activate(); //???
// initialize FFTDisplayBuffer
memset(&DisplayBufferFFT[0], DISPLAY_HEIGHT - 1, sizeof(DisplayBufferFFT));
#endif
}
} else {
/*
* analyze mode
*/
if (DisplayControl.DisplayPage == DSO_PAGE_START) {
drawStartPage();
} else if (DisplayControl.DisplayPage == DSO_PAGE_CHART) {
activateChartGui();
drawGridLinesWithHorizLabelsAndTriggerLine();
drawMinMaxLines();
// draw from last scroll position
#if defined(__AVR__)
drawDataBuffer(DataBufferControl.DataBufferDisplayStart, COLOR_DATA_HOLD, DisplayControl.EraseColor);
#else
drawDataBuffer(DataBufferControl.DataBufferDisplayStart, DISPLAY_WIDTH, COLOR_DATA_HOLD, 0, DRAW_MODE_REGULAR,
MeasurementControl.isEffectiveMinMaxMode);
#endif
printInfo();
} else if (DisplayControl.DisplayPage == DSO_PAGE_SETTINGS) {
drawDSOSettingsPage();
}
}
}
void drawStartPage(void) {
//1. Row
TouchButtonChartHistoryOnOff.drawButton();
TouchButtonSingleshot.drawButton();
//2. Row
#if defined(LOCAL_FILESYSTEM_EXISTS)
TouchButtonStore.drawButton();
TouchButtonLoad.drawButton();
#endif
TouchButtonStartStopDSOMeasurement.drawButton();
// 4. Row
#if !defined(__AVR__)
TouchButtonFFT.drawButton();
TouchButtonMainHome.drawButton();
#endif
TouchButtonSettingsPage.drawButton();
//Welcome text
BlueDisplay1.drawMLText(10, BUTTON_HEIGHT_4_LINE_2 + 34, F("Welcome to\nArduino DSO"), 32, COLOR16_BLUE, COLOR16_NO_BACKGROUND);
BlueDisplay1.drawText(10, BUTTON_HEIGHT_4_LINE_2 + (3 * 32), F("300 kSamples/s"), 22, COLOR16_BLUE, COLOR_BACKGROUND_DSO);
uint8_t
tPos = BlueDisplay1.drawText(10, BUTTON_HEIGHT_4_LINE_2 + (3 * 32) + 22, F("V" VERSION_DSO "/" VERSION_BLUE_DISPLAY),
11, COLOR16_BLUE, COLOR_BACKGROUND_DSO);
BlueDisplay1.drawText(tPos, BUTTON_HEIGHT_4_LINE_2 + (3 * 32) + 22, F(" from " __DATE__), 11, COLOR16_BLUE,
COLOR_BACKGROUND_DSO);
// Hints
#if !defined(__AVR__)
BlueDisplay1.drawText(SLIDER_DEFAULT_BAR_WIDTH + 6, BUTTON_HEIGHT_4 + TEXT_SIZE_22_ASCEND, "\xABScale\xBB", TEXT_SIZE_22, COLOR16_YELLOW, COLOR_BACKGROUND_DSO);
#endif
BlueDisplay1.drawText(BUTTON_WIDTH_3, BUTTON_HEIGHT_4_LINE_4 + BUTTON_DEFAULT_SPACING + TEXT_SIZE_22_ASCEND,
F("\xABScroll\xBB"), TEXT_SIZE_22, COLOR16_GREEN, COLOR_BACKGROUND_DSO);
}
/**
* draws elements active for settings page
*/
void drawDSOSettingsPage(void) {
//1. Row
TouchButtonChartHistoryOnOff.drawButton();
TouchButtonSlope.drawButton();
TouchButtonBack.drawButton();
//2. Row
#if defined(__AVR__)
TouchButtonTriggerDelay.drawButton();
#endif
TouchButtonTriggerMode.drawButton();
int16_t tButtonColor;
/*
* Determine colors for 3 fixed channel buttons
*/
for (int i = 0; i < NUMBER_OF_CHANNELS_WITH_FIXED_ATTENUATOR; ++i) {
if (i == MeasurementControl.ADMUXChannel) {
tButtonColor = BUTTON_AUTO_RED_GREEN_TRUE_COLOR;
} else {
tButtonColor = BUTTON_AUTO_RED_GREEN_FALSE_COLOR;
}
TouchButtonChannels[i].setButtonColorAndDraw(tButtonColor);
}
if (MeasurementControl.ADMUXChannel >= NUMBER_OF_CHANNELS_WITH_FIXED_ATTENUATOR) {
tButtonColor = BUTTON_AUTO_RED_GREEN_TRUE_COLOR;
} else {
tButtonColor = BUTTON_AUTO_RED_GREEN_FALSE_COLOR;
}
TouchButtonChannelSelect.setButtonColorAndDraw(tButtonColor);
//3. Row
#if !defined(__AVR__)
TouchButtonShowPretriggerValuesOnOff.drawButton();
#endif
TouchButtonAutoRangeOnOff.drawButton();
if (MeasurementControl.OffsetMode == OFFSET_MODE_AUTOMATIC) {
// lock button in OFFSET_MODE_AUTOMATIC
TouchButtonAutoRangeOnOff.deactivate();
}
TouchButtonChannelSelect.drawButton();
// 4. Row
#if !defined(__AVR__)
TouchButtonMinMaxMode.drawButton();
#endif
TouchButtonAutoOffsetMode.drawButton();
#if defined(FUTURE)
TouchButtonDrawModeTriggerLine.drawButton();
#endif
#if defined(SUPPORT_LOCAL_DISPLAY)
TouchSliderBacklight.drawSlider();
#endif
//5. Row
TouchButtonFrequencyPage.drawButton();
if (MeasurementControl.ChannelHasAC_DCSwitch) {
TouchButtonAcDc.drawButton();
}
#if defined(__AVR__)
setReferenceButtonCaption(); // also draws the button for this page
#else
TouchButtonDSOMoreSettings.drawButton();
#endif
}
#if !defined(__AVR__)
void drawDSOMoreSettingsPage(void) {
// do not clear screen here since gui is refreshed periodically while DSO is running
BDButton::deactivateAll();
BDSlider::deactivateAll();
//1. Row
TouchButtonCalibrateVoltage.drawButton();
TouchButtonBack.drawButton();
#if defined(SUPPORT_LOCAL_DISPLAY)
//2. Row
TouchButtonDrawModeLinePixel.drawButton();
TouchButtonADS7846TestOnOff.drawButton();
#endif
// 4. Row
TouchButtonShowSystemInfo.drawButton();
}
void startDSOMoreSettingsPage(void) {
BlueDisplay1.clearDisplay();
drawDSOMoreSettingsPage();
}
#endif
/**
* draws elements which are active while measurement is running
*/
void drawRunningOnlyPartOfGui(void) {
// if (MeasurementControl.TriggerMode == TRIGGER_MODE_MANUAL) {
// TouchSliderTriggerLevel.drawSlider();
// }
if (!MeasurementControl.RangeAutomatic || MeasurementControl.OffsetMode == OFFSET_MODE_MANUAL) {
#if defined(SUPPORT_LOCAL_DISPLAY)
BlueDisplay1.drawMLText(TEXT_SIZE_11_WIDTH, TEXT_SIZE_11_HEIGHT + TEXT_SIZE_22_ASCEND, "\xD4\nR\na\nn\ng\ne\n\xD5",
TEXT_SIZE_22, COLOR_GUI_TRIGGER, COLOR16_NO_BACKGROUND);
#else
//START_PAGE_BUTTON_HEIGHT + TEXT_SIZE_22_ASCEND is to much for 240 display
BlueDisplay1.drawText(TEXT_SIZE_11_WIDTH, START_PAGE_BUTTON_HEIGHT, F("\xD4\nR\na\nn\ng\ne\n\xD5"), TEXT_SIZE_22,
COLOR_GUI_TRIGGER, COLOR16_NO_BACKGROUND);
#endif
}