Skip to content

Commit 9eafb4d

Browse files
authored
Add files via upload
1 parent 7e1e5b7 commit 9eafb4d

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

avdweb_scope.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Publ
1313
Version 1-1-2016
1414
Version 14-1-2016 sample0_us
1515
Version 10-2-2017 1, 2, 3, 4 channels
16+
Version 10-2-2017 sampleA sampleB sampleABC sampleABCD to avoid mistakes
17+
all unsigned int -> int
18+
added stop()
1619
1720
start ___|____________________________________|________
1821
@@ -44,6 +47,10 @@ void Scope::start(byte _channels, int _preSamples, unsigned int _recordLenght)
4447
if(abs(_preSamples) <= recordLenght) preSamples = _preSamples;
4548
}
4649

50+
void Scope::stop()
51+
{ stopPtr = calcPtr(ptr+1);
52+
}
53+
4754
void Scope::show()
4855
{ unsigned long stop_us = micros(); // to avoid delay, start with this
4956
unsigned long usPerDiv = samples > 1 ? (stop_us - sample0_us)/(samples-1) : 0;
@@ -64,22 +71,22 @@ void Scope::show()
6471
stopPtr = 32767;
6572
}
6673

67-
void Scope::sample(int valueA) // 1 channel
74+
void Scope::sampleA(int valueA) // 1 channel
6875
{ if(samplingOn)
6976
{ ringBuffer.chA[ptr] = valueA;
7077
sampleControl();
7178
}
7279
}
7380

74-
void Scope::sample(int valueA, int valueB) // 2 channels
81+
void Scope::sampleAB(int valueA, int valueB) // 2 channels
7582
{ if(samplingOn)
7683
{ ringBuffer.chAB[ptr][0] = valueA;
7784
ringBuffer.chAB[ptr][1] = valueB;
7885
sampleControl();
7986
}
8087
}
8188

82-
void Scope::sample(int valueA, int valueB, int valueC) // 3 channels
89+
void Scope::sampleABC(int valueA, int valueB, int valueC) // 3 channels
8390
{ if(samplingOn)
8491
{ ringBuffer.chABC[ptr][0] = valueA;
8592
ringBuffer.chABC[ptr][1] = valueB;
@@ -88,7 +95,7 @@ void Scope::sample(int valueA, int valueB, int valueC) // 3 channels
8895
}
8996
}
9097

91-
void Scope::sample(int valueA, int valueB, int valueC, int valueD) // 4 channels
98+
void Scope::sampleABCD(int valueA, int valueB, int valueC, int valueD) // 4 channels
9299
{ if(samplingOn)
93100
{ ringBuffer.chABCD[ptr][0] = valueA;
94101
ringBuffer.chABCD[ptr][1] = valueB;
@@ -99,7 +106,7 @@ void Scope::sample(int valueA, int valueB, int valueC, int valueD) // 4 channels
99106
}
100107

101108
void Scope::sampleControl()
102-
{ if(samples == 0) sample0_us = micros(); // doen werkt niet als er meerdere testen lopen
109+
{ if(samples == 0) sample0_us = micros();
103110
samples++;
104111
ptr = calcPtr(ptr+1);
105112
if(ptr==stopPtr) show();
@@ -123,7 +130,7 @@ void Scope::testBuffer()
123130
{ start(1);
124131
for(int i=0; i<25000; i++)
125132
{ if(i==0) trigger();
126-
sample(i);
133+
sampleA(i);
127134
}
128135
}
129136

avdweb_scope.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Publ
1313

1414
#include <Arduino.h>
1515

16+
#if defined(__arm__)
1617
const unsigned int maxBytes = 2000; // SAMD21: max ~ 7000
17-
//const int maxBytes = 700; // AVR: max ~ 780
18+
#else
19+
const int maxBytes = 700; // AVR: max ~ 780
20+
#endif
1821

1922
class Scope
2023
{
2124
public:
2225
void start(byte _channels, int _preSamples=0, unsigned int _recordLenght=65535);
23-
void sample(int valueA);
24-
void sample(int valueA, int valueB);
25-
void sample(int valueA, int valueB, int valueC);
26-
void sample(int valueA, int valueB, int valueC, int valueD);
26+
void sampleA(int valueA);
27+
void sampleAB(int valueA, int valueB);
28+
void sampleABC(int valueA, int valueB, int valueC);
29+
void sampleABCD(int valueA, int valueB, int valueC, int valueD);
2730
void trigger();
31+
void stop();
2832
void testBuffer();
2933

3034
protected:
@@ -40,8 +44,7 @@ class Scope
4044
unsigned long sample0_us;
4145
bool triggered, samplingOn;
4246
byte channels; // 1, 2, 3, 4 channels
43-
unsigned int recordLenght, ptr, samples, triggerPtr, stopPtr;
44-
int preSamples;
47+
int recordLenght, preSamples, ptr, samples, triggerPtr, stopPtr;
4548
};
4649

4750
#endif

0 commit comments

Comments
 (0)