forked from analogdevicesinc/scopy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdigitalio.hpp
129 lines (109 loc) · 2.83 KB
/
digitalio.hpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* Copyright (c) 2019 Analog Devices Inc.
*
* This file is part of Scopy
* (see http://www.github.com/analogdevicesinc/scopy).
*
* 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DIGITAL_IO_H
#define DIGITAL_IO_H
#include <QWidget>
#include <QPushButton>
#include <QVector>
#include <vector>
#include <string>
#include <QList>
#include <QPair>
#include <QTimer>
#include "filter.hpp"
#include "digitalchannel_manager.hpp"
#include "apiObject.hpp"
#include "tool.hpp"
extern "C" {
struct iio_context;
struct iio_device;
struct iio_channel;
struct iio_buffer;
}
namespace Ui {
class DigitalIO;
class DigitalIoMenu;
class dioElement;
class dioGroup;
class dioChannel;
}
namespace adiscope {
class DigitalIO;
class DigitalIO_API;
class DigitalIoGroup : public QWidget
{
friend class DigitalIO_API;
Q_OBJECT
int nr_of_channels;
int ch_mask;
int io_mask;
DigitalIO *dio;
public:
DigitalIoGroup(QString label, int ch_mask, int io_mask, DigitalIO *dio,
QWidget *parent=0);
~DigitalIoGroup();
Ui::dioElement *ui;
QList<QPair<QWidget *,Ui::dioChannel *>*> chui;
Q_SIGNALS:
void slider(int val);
private Q_SLOTS:
void on_lineEdit_editingFinished();
void on_horizontalSlider_valueChanged(int value);
void on_comboBox_activated(int index);
void changeDirection();
};
class DigitalIO : public Tool
{
friend class DigitalIO_API;
friend class ToolLauncher_API;
Q_OBJECT
private:
Ui::DigitalIO *ui;
Filter *filt;
bool offline_mode;
QList<DigitalIoGroup *> groups;
QTimer *poll;
DIOManager *diom;
int polling_rate = 500; // ms
QPair<QWidget *,Ui::dioChannel *> *findIndividualUi(int ch);
private Q_SLOTS:
void readPreferences();
public:
explicit DigitalIO(struct iio_context *ctx, Filter *filt, ToolMenuItem *toolMenuItem,
DIOManager *diom, QJSEngine *engine,
ToolLauncher *parent, bool offline_mode = 0);
~DigitalIO();
void setDirection(int ch, int direction);
void setOutput(int ch, int out);
void setVisible(bool visible);
public Q_SLOTS:
void run() override;
void stop() override;
void updateUi();
void setDirection();
void setOutput();
void setSlider(int val);
void lockUi();
void startStop(bool);
Q_SIGNALS:
void showTool();
};
} /* namespace adiscope */
#endif // DIGITAL_IO_H