forked from ardyesp/DLO-138
-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.ino
82 lines (63 loc) · 1.52 KB
/
control.ino
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
enum { TRIGGER_AUTO, TRIGGER_NORM, TRIGGER_SINGLE };
uint8_t triggerType;
// ------------------------
void setTriggerType(uint8_t tType) {
// ------------------------
triggerType = tType;
// break any running capture loop
keepSampling = false;
}
// ------------------------
void controlLoop() {
// ------------------------
// start by reading the state of analog system
readInpSwitches();
if(triggerType == TRIGGER_AUTO) {
captureDisplayCycle(true);
}
else if(triggerType == TRIGGER_NORM) {
captureDisplayCycle(false);
}
else {
// single trigger
clearWaves();
indicateCapturing();
// blocking call - until trigger
sampleWaves(false);
indicateCapturingDone();
hold = true;
// request repainting of screen labels in next draw cycle
repaintLabels();
// draw the waveform
drawWaves();
blinkLED();
// dump captured data on serial port
dumpSamples();
// freeze display
while(hold);
// update display indicating hold released
drawLabels();
}
// process any long pending operations which cannot be serviced in ISR
}
// ------------------------
void captureDisplayCycle(boolean wTimeOut) {
// ------------------------
indicateCapturing();
// blocking call - until timeout or trigger
sampleWaves(wTimeOut);
// draw the waveform
indicateCapturingDone();
drawWaves();
// inter wait before next sampling
if(triggered)
blinkLED();
if(hold) {
// update UI labels
drawLabels();
// dump captured data on serial port
dumpSamples();
}
// freeze display if requested
while(hold);
}