PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
oscilloscope.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2010-2024 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
26#ifndef OSCILLOSCOPE
27#define OSCILLOSCOPE
28
29#include <vector>
30#include "board.h"
31#include "types.h"
32
33#define WMAX 350
34#define HMAX 250
35
36#define NPOINTS (2 * WMAX)
37
38#define MAX_MEASURES 10
39
40typedef struct {
41 double Vrms;
42 double Vavr;
43 double Vmax;
44 double Vmin;
45 double Freq;
46 double FCycle_ms;
47 double PCycle_ms;
48 double Duty;
50
52public:
54
55 void Init(void);
56
60 void SetSample(void);
61
62 void SetBoard(board* b) { pboard = b; };
63
64 void NextMeasure(int mn);
65
66 int GetMeasures(int mn);
67
68 void SetMeasure(int nm, int value);
69
70 int GetUseTrigger(void) { return usetrigger; };
71 void SetUseTrigger(int utg) { usetrigger = utg; };
72
73 int GetTriggerChannel(void) { return tch; };
74 void SetTriggerChannel(int tc) { tch = tc; };
75
76 double* GetChannel(int cn) { return ch[cn]; };
77
78 void CalculateStats(int channel);
79 void ClearStats(int channel);
80
81 ch_status_t GetChannelStatus(int cn) { return ch_status[cn]; };
82
83 int GetUpdate(void) { return update; };
84 void SetUpdate(int up) { update = up; };
85
86 void SetChannelPin(int ch, int pin) { chpin[ch] = pin; };
87
88 int GetTimeOffset(void) { return toffset; };
89 void SetTimeOffset(int to) { toffset = to; };
90
91 int GetRun(void) { return run; };
92 void SetRun(int r) { run = r; };
93
94 void SetTriggerLevel(double tl) { triggerlv = tl; };
95
96 void SetVMax(float vm) { vmax = vm; };
97
98 void SetRT(double rt) { Rt = rt; };
99 double GetRT(void) { return Rt; };
100
101 void SetDT(double dt) { Dt = dt; };
102 double GetDT(void) { return Dt; };
103
104 void Setxz(double xz_) { xz = xz_; };
105 double Getxz(void) { return xz; };
106
107 void Reset(void);
108
109 void SetBaseTimer(void);
110
111 void WritePreferences(void);
112 void ReadPreferences(char* name, char* value);
113
114 std::vector<std::string> WritePreferencesList(void);
115 void ReadPreferencesList(std::vector<std::string>& pl);
116
117 static int WindowCmd(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
118 void* ReturnBuff = NULL);
119
120 int (*OnWindowCmd)(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
121 void* ReturnBuff);
122
123private:
124 board* pboard;
125 double Dt; // Delta T
126 double Rt; // Relative delta T
127 int usetrigger;
128 double triggerlv;
129 int tch; // trigger channel
130 int toffset;
131 int chpin[2];
132 double databuffer[2][2][NPOINTS]; // flip buffers + 2 channels + 700 points
133 int fp; // actual flip buffer
134 double* ch[2]; // actual channel data (pointer to databuffer)
135 ch_status_t ch_status[2]; // channel measurament status
136 double pins_[2]; // last value of input pins
137 int is; // input samples
138 double t; // time
139 int tr; // trigger
140 int run;
141 int update;
142 int measures[5];
143 float vmax;
144 double xz;
145};
146
147extern COscilloscope Oscilloscope;
148
149#endif // OSCILLOSCOPE
Definition oscilloscope.h:51
void SetSample(void)
Sample and update oscilloscope data aquisition.
Definition oscilloscope.cc:63
Board class.
Definition board.h:111
Definition oscilloscope.h:40