-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathavdweb_SWscope.h
56 lines (47 loc) · 1.67 KB
/
avdweb_SWscope.h
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
/*
Copyright (C) 2016 Albert van Dalen http://www.avdweb.nl
This program 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 at
http://www.gnu.org/licenses .
*/
#ifndef avdweb_SWscope_H
#define avdweb_SWscope_H
#include <Arduino.h>
#if defined(__arm__)
const unsigned int maxScopeBytes = 7000; // SAMD21: max ~ 7000
#else
const int maxScopeBytes =
100; // ATTENTION SET HERE, AVR ATmega328: max ~ 780 ATmega168: max ~ 320
#endif
class SWscope {
public:
void start(byte _channels, int _preSamples = 0,
unsigned int _recordLenght = 65535);
void probeA(short valueA);
void probeAB(short valueA, short valueB);
void probeABC(short valueA, short valueB, short valueC);
void probeABCD(short valueA, short valueB, short valueC, short valueD);
void trigger();
void stop();
void showIfReady();
void testBuffer();
bool canShow;
protected:
void sampleControl();
unsigned int calcPtr(int ptr);
union {
short chA[maxScopeBytes / 2];
short chAB[maxScopeBytes / 4][2];
short chABC[maxScopeBytes / 3][3];
short chABCD[maxScopeBytes / 8][4];
} ringBuffer;
unsigned long sample0_us, usPerDiv;
bool triggered, samplingOn;
byte channels; // 1, 2, 3, 4 channels
int recordLenght, preSamples, ptr, samples, triggerPtr, stopPtr;
};
#endif /* avdweb_SWscope_H */