PICSimLab - Programmable IC Simulator Laboratory 0.9.3
PICSimLab - API
Loading...
Searching...
No Matches
oscilloscope.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2010-2026 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
51class COscilloscope {
52public:
53 COscilloscope();
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);
84
85 void SetUpdate(int up) { update = up; };
86
87 void SetChannelPin(int ch_, int pin) { chpin[ch_] = pin; };
88
89 int GetSampleOffset(void) { return soffset; };
90
91 void SetTimeScaleAndOffset(float tscale_, float toffset_);
92
93 int GetRun(void) { return run; };
94 void SetRun(int r) { run = r; };
95
96 void SetSingle(int s) { single = s; };
97
98 void SetTriggerLevel(double tl) { triggerlv = tl; };
99
100 void SetVMax(float vm) { vmax = vm; };
101
102 double GetRT(void) { return Rt; };
103 double GetDT(void) { return Dt; };
104 double Getxz(void) { return xz; };
105
106 void Reset(void);
107
108 void UpdatePinList(void);
109
110 void SetBaseTimer(void);
111
112 void WritePreferences(void);
113 void ReadPreferences(char* name, char* value);
114
115 std::vector<std::string> WritePreferencesList(void);
116 void ReadPreferencesList(std::vector<std::string>& pl);
117
118 static int WindowCmd(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
119 void* ReturnBuff = NULL);
120
121 int (*OnWindowCmd)(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
122 void* ReturnBuff);
123
124private:
125 board* pboard;
126 double Dt; // Delta T
127 double Rt; // Relative delta T
128 int usetrigger;
129 double triggerlv;
130 int tch; // trigger channel
131 int soffset;
132 int chpin[2];
133 double databuffer[2][2][NPOINTS]; // flip buffers + 2 channels + 700 points
134 int fp; // actual flip buffer
135 double* ch[2]; // actual channel data (pointer to databuffer)
136 ch_status_t ch_status[2]; // channel measurament status
137 ch_status_t ch_status_[2]; // channel measurament status mirror
138 double pins_[2]; // last value of input pins
139 int is; // input samples
140 double t; // time
141 int tr; // trigger
142 int run;
143 int update;
144 int measures[5];
145 float vmax;
146 double xz;
147 float tscale;
148 float toffset;
149 int single;
150 int update_stop;
151};
152
153extern COscilloscope Oscilloscope;
154
155#endif // OSCILLOSCOPE
Definition oscilloscope.h:51
void SetSample(void)
Sample and update oscilloscope data aquisition.
Definition oscilloscope.cc:65
Board class.
Definition board.h:114
Definition oscilloscope.h:40