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 GetSampleOffset(void) { return soffset; };
89
90 void SetTimeScaleAndOffset(float tscale_, float toffset_);
91
92 int GetRun(void) { return run; };
93 void SetRun(int r) { run = r; };
94
95 void SetTriggerLevel(double tl) { triggerlv = tl; };
96
97 void SetVMax(float vm) { vmax = vm; };
98
99 double GetRT(void) { return Rt; };
100 double GetDT(void) { return Dt; };
101 double Getxz(void) { return xz; };
102
103 void Reset(void);
104
105 void SetBaseTimer(void);
106
107 void WritePreferences(void);
108 void ReadPreferences(char* name, char* value);
109
110 std::vector<std::string> WritePreferencesList(void);
111 void ReadPreferencesList(std::vector<std::string>& pl);
112
113 static int WindowCmd(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
114 void* ReturnBuff = NULL);
115
116 int (*OnWindowCmd)(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
117 void* ReturnBuff);
118
119private:
120 board* pboard;
121 double Dt; // Delta T
122 double Rt; // Relative delta T
123 int usetrigger;
124 double triggerlv;
125 int tch; // trigger channel
126 int soffset;
127 int chpin[2];
128 double databuffer[2][2][NPOINTS]; // flip buffers + 2 channels + 700 points
129 int fp; // actual flip buffer
130 double* ch[2]; // actual channel data (pointer to databuffer)
131 ch_status_t ch_status[2]; // channel measurament status
132 double pins_[2]; // last value of input pins
133 int is; // input samples
134 double t; // time
135 int tr; // trigger
136 int run;
137 int update;
138 int measures[5];
139 float vmax;
140 double xz;
141 float tscale;
142 float toffset;
143};
144
145extern COscilloscope Oscilloscope;
146
147#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