mirror of https://github.com/EspoTek/Labrador.git
All modes implemented in read/write.
This commit is contained in:
parent
aeb2d48809
commit
d535ee86d0
|
@ -73,7 +73,18 @@ void MainWindow::on_pushButton_4_clicked()
|
|||
void MainWindow::on_pushButton_5_clicked()
|
||||
{
|
||||
|
||||
QVector<double> yaxis = QVector<double>::fromStdVector(*(librador_get_iso_data(0.5, 375000, 0.1, 0)));
|
||||
std::vector<double> *from_librador = (librador_get_analog_data(current_channel, 0.5, 375000, 0.1, 0));
|
||||
if(from_librador == NULL){
|
||||
qDebug() << "from_librador NULL!";
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<double> yaxis = QVector<double>::fromStdVector(*from_librador);
|
||||
|
||||
if(yaxis.length() == 0){
|
||||
qDebug() << "NO DATA RETURNED!";
|
||||
return;
|
||||
}
|
||||
|
||||
//qDebug() << yaxis;
|
||||
|
||||
|
@ -140,6 +151,26 @@ void MainWindow::on_comboBox_activated(int index)
|
|||
|
||||
double newGain = gainValues[index];
|
||||
ymax = 1.65 + (11/newGain);
|
||||
ymin = 1.65 - (11/newGain);
|
||||
ymin = 1.65 - (14/newGain);
|
||||
qDebug() << librador_set_oscilloscope_gain(newGain);
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_10_clicked()
|
||||
{
|
||||
qDebug() << librador_reset_device();
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_11_clicked()
|
||||
{
|
||||
qDebug() << librador_jump_to_bootloader();
|
||||
}
|
||||
|
||||
void MainWindow::on_comboBox_2_activated(int index)
|
||||
{
|
||||
qDebug() << librador_set_device_mode(index);
|
||||
}
|
||||
|
||||
void MainWindow::on_comboBox_3_activated(int index)
|
||||
{
|
||||
current_channel = index + 1;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
private:
|
||||
void initialisePlot();
|
||||
double ymin = -20, ymax = 20;
|
||||
int current_channel = 1;
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
|
@ -46,6 +47,14 @@ private slots:
|
|||
|
||||
void on_comboBox_activated(int index);
|
||||
|
||||
void on_pushButton_10_clicked();
|
||||
|
||||
void on_pushButton_11_clicked();
|
||||
|
||||
void on_comboBox_2_activated(int index);
|
||||
|
||||
void on_comboBox_3_activated(int index);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
|
|
@ -66,6 +66,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_10">
|
||||
<property name="text">
|
||||
<string>Reset Labrador</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_11">
|
||||
<property name="text">
|
||||
<string>Go to bootloader</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
|
@ -126,12 +140,15 @@
|
|||
<property name="text">
|
||||
<string>Set Gain:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="currentText">
|
||||
<string>1</string>
|
||||
<string>0.5</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
|
@ -178,11 +195,98 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="text">
|
||||
<string>Get Scope Data</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Set Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_2">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Channel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_3">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="text">
|
||||
<string>Get Scope Data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
|
|
@ -21,8 +21,8 @@ QT_BEGIN_MOC_NAMESPACE
|
|||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
struct qt_meta_stringdata_MainWindow_t {
|
||||
QByteArrayData data[18];
|
||||
char stringdata0[365];
|
||||
QByteArrayData data[22];
|
||||
char stringdata0[463];
|
||||
};
|
||||
#define QT_MOC_LITERAL(idx, ofs, len) \
|
||||
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
|
||||
|
@ -48,7 +48,11 @@ QT_MOC_LITERAL(13, 256, 26), // "on_checkBox_2_stateChanged"
|
|||
QT_MOC_LITERAL(14, 283, 26), // "on_checkBox_3_stateChanged"
|
||||
QT_MOC_LITERAL(15, 310, 26), // "on_checkBox_4_stateChanged"
|
||||
QT_MOC_LITERAL(16, 337, 21), // "on_comboBox_activated"
|
||||
QT_MOC_LITERAL(17, 359, 5) // "index"
|
||||
QT_MOC_LITERAL(17, 359, 5), // "index"
|
||||
QT_MOC_LITERAL(18, 365, 24), // "on_pushButton_10_clicked"
|
||||
QT_MOC_LITERAL(19, 390, 24), // "on_pushButton_11_clicked"
|
||||
QT_MOC_LITERAL(20, 415, 23), // "on_comboBox_2_activated"
|
||||
QT_MOC_LITERAL(21, 439, 23) // "on_comboBox_3_activated"
|
||||
|
||||
},
|
||||
"MainWindow\0on_pushButton_clicked\0\0"
|
||||
|
@ -60,7 +64,10 @@ QT_MOC_LITERAL(17, 359, 5) // "index"
|
|||
"on_checkBox_2_stateChanged\0"
|
||||
"on_checkBox_3_stateChanged\0"
|
||||
"on_checkBox_4_stateChanged\0"
|
||||
"on_comboBox_activated\0index"
|
||||
"on_comboBox_activated\0index\0"
|
||||
"on_pushButton_10_clicked\0"
|
||||
"on_pushButton_11_clicked\0"
|
||||
"on_comboBox_2_activated\0on_comboBox_3_activated"
|
||||
};
|
||||
#undef QT_MOC_LITERAL
|
||||
|
||||
|
@ -70,7 +77,7 @@ static const uint qt_meta_data_MainWindow[] = {
|
|||
7, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
14, 14, // methods
|
||||
18, 14, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
|
@ -78,20 +85,24 @@ static const uint qt_meta_data_MainWindow[] = {
|
|||
0, // signalCount
|
||||
|
||||
// slots: name, argc, parameters, tag, flags
|
||||
1, 0, 84, 2, 0x08 /* Private */,
|
||||
3, 0, 85, 2, 0x08 /* Private */,
|
||||
4, 0, 86, 2, 0x08 /* Private */,
|
||||
5, 0, 87, 2, 0x08 /* Private */,
|
||||
6, 0, 88, 2, 0x08 /* Private */,
|
||||
7, 0, 89, 2, 0x08 /* Private */,
|
||||
8, 0, 90, 2, 0x08 /* Private */,
|
||||
9, 0, 91, 2, 0x08 /* Private */,
|
||||
10, 0, 92, 2, 0x08 /* Private */,
|
||||
11, 1, 93, 2, 0x08 /* Private */,
|
||||
13, 1, 96, 2, 0x08 /* Private */,
|
||||
14, 1, 99, 2, 0x08 /* Private */,
|
||||
15, 1, 102, 2, 0x08 /* Private */,
|
||||
16, 1, 105, 2, 0x08 /* Private */,
|
||||
1, 0, 104, 2, 0x08 /* Private */,
|
||||
3, 0, 105, 2, 0x08 /* Private */,
|
||||
4, 0, 106, 2, 0x08 /* Private */,
|
||||
5, 0, 107, 2, 0x08 /* Private */,
|
||||
6, 0, 108, 2, 0x08 /* Private */,
|
||||
7, 0, 109, 2, 0x08 /* Private */,
|
||||
8, 0, 110, 2, 0x08 /* Private */,
|
||||
9, 0, 111, 2, 0x08 /* Private */,
|
||||
10, 0, 112, 2, 0x08 /* Private */,
|
||||
11, 1, 113, 2, 0x08 /* Private */,
|
||||
13, 1, 116, 2, 0x08 /* Private */,
|
||||
14, 1, 119, 2, 0x08 /* Private */,
|
||||
15, 1, 122, 2, 0x08 /* Private */,
|
||||
16, 1, 125, 2, 0x08 /* Private */,
|
||||
18, 0, 128, 2, 0x08 /* Private */,
|
||||
19, 0, 129, 2, 0x08 /* Private */,
|
||||
20, 1, 130, 2, 0x08 /* Private */,
|
||||
21, 1, 133, 2, 0x08 /* Private */,
|
||||
|
||||
// slots: parameters
|
||||
QMetaType::Void,
|
||||
|
@ -107,6 +118,10 @@ static const uint qt_meta_data_MainWindow[] = {
|
|||
QMetaType::Void, QMetaType::Int, 12,
|
||||
QMetaType::Void, QMetaType::Int, 12,
|
||||
QMetaType::Void, QMetaType::Int, 12,
|
||||
QMetaType::Void, QMetaType::Int, 17,
|
||||
QMetaType::Void,
|
||||
QMetaType::Void,
|
||||
QMetaType::Void, QMetaType::Int, 17,
|
||||
QMetaType::Void, QMetaType::Int, 17,
|
||||
|
||||
0 // eod
|
||||
|
@ -132,6 +147,10 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id,
|
|||
case 11: _t->on_checkBox_3_stateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
|
||||
case 12: _t->on_checkBox_4_stateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
|
||||
case 13: _t->on_comboBox_activated((*reinterpret_cast< int(*)>(_a[1]))); break;
|
||||
case 14: _t->on_pushButton_10_clicked(); break;
|
||||
case 15: _t->on_pushButton_11_clicked(); break;
|
||||
case 16: _t->on_comboBox_2_activated((*reinterpret_cast< int(*)>(_a[1]))); break;
|
||||
case 17: _t->on_comboBox_3_activated((*reinterpret_cast< int(*)>(_a[1]))); break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
@ -162,13 +181,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
|||
if (_id < 0)
|
||||
return _id;
|
||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||
if (_id < 14)
|
||||
if (_id < 18)
|
||||
qt_static_metacall(this, _c, _id, _a);
|
||||
_id -= 14;
|
||||
_id -= 18;
|
||||
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
|
||||
if (_id < 14)
|
||||
if (_id < 18)
|
||||
*reinterpret_cast<int*>(_a[0]) = -1;
|
||||
_id -= 14;
|
||||
_id -= 18;
|
||||
}
|
||||
return _id;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
QPushButton *pushButton_4;
|
||||
QPushButton *pushButton_7;
|
||||
QPushButton *pushButton_8;
|
||||
QPushButton *pushButton_10;
|
||||
QPushButton *pushButton_11;
|
||||
QHBoxLayout *horizontalLayout_3;
|
||||
QPushButton *pushButton_9;
|
||||
QDoubleSpinBox *powerSupplySpinBox;
|
||||
|
@ -54,6 +56,13 @@ public:
|
|||
QHBoxLayout *horizontalLayout_4;
|
||||
QLabel *label;
|
||||
QComboBox *comboBox;
|
||||
QHBoxLayout *horizontalLayout_5;
|
||||
QLabel *label_2;
|
||||
QComboBox *comboBox_2;
|
||||
QHBoxLayout *horizontalLayout_6;
|
||||
QVBoxLayout *verticalLayout_2;
|
||||
QLabel *label_3;
|
||||
QComboBox *comboBox_3;
|
||||
QPushButton *pushButton_5;
|
||||
QCustomPlot *widget;
|
||||
QMenuBar *menuBar;
|
||||
|
@ -109,6 +118,16 @@ public:
|
|||
|
||||
verticalLayout->addWidget(pushButton_8);
|
||||
|
||||
pushButton_10 = new QPushButton(centralWidget);
|
||||
pushButton_10->setObjectName(QStringLiteral("pushButton_10"));
|
||||
|
||||
verticalLayout->addWidget(pushButton_10);
|
||||
|
||||
pushButton_11 = new QPushButton(centralWidget);
|
||||
pushButton_11->setObjectName(QStringLiteral("pushButton_11"));
|
||||
|
||||
verticalLayout->addWidget(pushButton_11);
|
||||
|
||||
horizontalLayout_3 = new QHBoxLayout();
|
||||
horizontalLayout_3->setSpacing(6);
|
||||
horizontalLayout_3->setObjectName(QStringLiteral("horizontalLayout_3"));
|
||||
|
@ -158,6 +177,7 @@ public:
|
|||
horizontalLayout_4->setObjectName(QStringLiteral("horizontalLayout_4"));
|
||||
label = new QLabel(centralWidget);
|
||||
label->setObjectName(QStringLiteral("label"));
|
||||
label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
|
||||
|
||||
horizontalLayout_4->addWidget(label);
|
||||
|
||||
|
@ -177,10 +197,59 @@ public:
|
|||
|
||||
verticalLayout->addLayout(horizontalLayout_4);
|
||||
|
||||
horizontalLayout_5 = new QHBoxLayout();
|
||||
horizontalLayout_5->setSpacing(6);
|
||||
horizontalLayout_5->setObjectName(QStringLiteral("horizontalLayout_5"));
|
||||
label_2 = new QLabel(centralWidget);
|
||||
label_2->setObjectName(QStringLiteral("label_2"));
|
||||
label_2->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
|
||||
|
||||
horizontalLayout_5->addWidget(label_2);
|
||||
|
||||
comboBox_2 = new QComboBox(centralWidget);
|
||||
comboBox_2->addItem(QString());
|
||||
comboBox_2->addItem(QString());
|
||||
comboBox_2->addItem(QString());
|
||||
comboBox_2->addItem(QString());
|
||||
comboBox_2->addItem(QString());
|
||||
comboBox_2->addItem(QString());
|
||||
comboBox_2->addItem(QString());
|
||||
comboBox_2->addItem(QString());
|
||||
comboBox_2->setObjectName(QStringLiteral("comboBox_2"));
|
||||
|
||||
horizontalLayout_5->addWidget(comboBox_2);
|
||||
|
||||
|
||||
verticalLayout->addLayout(horizontalLayout_5);
|
||||
|
||||
horizontalLayout_6 = new QHBoxLayout();
|
||||
horizontalLayout_6->setSpacing(6);
|
||||
horizontalLayout_6->setObjectName(QStringLiteral("horizontalLayout_6"));
|
||||
verticalLayout_2 = new QVBoxLayout();
|
||||
verticalLayout_2->setSpacing(6);
|
||||
verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2"));
|
||||
label_3 = new QLabel(centralWidget);
|
||||
label_3->setObjectName(QStringLiteral("label_3"));
|
||||
|
||||
verticalLayout_2->addWidget(label_3);
|
||||
|
||||
comboBox_3 = new QComboBox(centralWidget);
|
||||
comboBox_3->addItem(QString());
|
||||
comboBox_3->addItem(QString());
|
||||
comboBox_3->setObjectName(QStringLiteral("comboBox_3"));
|
||||
|
||||
verticalLayout_2->addWidget(comboBox_3);
|
||||
|
||||
|
||||
horizontalLayout_6->addLayout(verticalLayout_2);
|
||||
|
||||
pushButton_5 = new QPushButton(centralWidget);
|
||||
pushButton_5->setObjectName(QStringLiteral("pushButton_5"));
|
||||
|
||||
verticalLayout->addWidget(pushButton_5);
|
||||
horizontalLayout_6->addWidget(pushButton_5);
|
||||
|
||||
|
||||
verticalLayout->addLayout(horizontalLayout_6);
|
||||
|
||||
|
||||
horizontalLayout->addLayout(verticalLayout);
|
||||
|
@ -217,6 +286,8 @@ public:
|
|||
pushButton_4->setText(QApplication::translate("MainWindow", "avrDebug()", nullptr));
|
||||
pushButton_7->setText(QApplication::translate("MainWindow", "Get Firmware Version", nullptr));
|
||||
pushButton_8->setText(QApplication::translate("MainWindow", "Get Firmware Variant", nullptr));
|
||||
pushButton_10->setText(QApplication::translate("MainWindow", "Reset Labrador", nullptr));
|
||||
pushButton_11->setText(QApplication::translate("MainWindow", "Go to bootloader", nullptr));
|
||||
pushButton_9->setText(QApplication::translate("MainWindow", "Send Power Supply Voltage", nullptr));
|
||||
checkBox->setText(QApplication::translate("MainWindow", "Digital Out 1", nullptr));
|
||||
checkBox_2->setText(QApplication::translate("MainWindow", "Digital Out 2", nullptr));
|
||||
|
@ -232,7 +303,21 @@ public:
|
|||
comboBox->setItemText(6, QApplication::translate("MainWindow", "32", nullptr));
|
||||
comboBox->setItemText(7, QApplication::translate("MainWindow", "64", nullptr));
|
||||
|
||||
comboBox->setCurrentText(QApplication::translate("MainWindow", "1", nullptr));
|
||||
comboBox->setCurrentText(QApplication::translate("MainWindow", "0.5", nullptr));
|
||||
label_2->setText(QApplication::translate("MainWindow", "Set Mode", nullptr));
|
||||
comboBox_2->setItemText(0, QApplication::translate("MainWindow", "0", nullptr));
|
||||
comboBox_2->setItemText(1, QApplication::translate("MainWindow", "1", nullptr));
|
||||
comboBox_2->setItemText(2, QApplication::translate("MainWindow", "2", nullptr));
|
||||
comboBox_2->setItemText(3, QApplication::translate("MainWindow", "3", nullptr));
|
||||
comboBox_2->setItemText(4, QApplication::translate("MainWindow", "4", nullptr));
|
||||
comboBox_2->setItemText(5, QApplication::translate("MainWindow", "5", nullptr));
|
||||
comboBox_2->setItemText(6, QApplication::translate("MainWindow", "6", nullptr));
|
||||
comboBox_2->setItemText(7, QApplication::translate("MainWindow", "7", nullptr));
|
||||
|
||||
label_3->setText(QApplication::translate("MainWindow", "Channel", nullptr));
|
||||
comboBox_3->setItemText(0, QApplication::translate("MainWindow", "1", nullptr));
|
||||
comboBox_3->setItemText(1, QApplication::translate("MainWindow", "2", nullptr));
|
||||
|
||||
pushButton_5->setText(QApplication::translate("MainWindow", "Get Scope Data", nullptr));
|
||||
} // retranslateUi
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ int librador_avr_debug(){
|
|||
return internal_librador_object->usb_driver->avrDebug();
|
||||
}
|
||||
|
||||
std::vector<double> * librador_get_iso_data(double timeWindow_seconds, double sample_rate_hz, double delay_seconds, int filter_mode){
|
||||
std::vector<double> * librador_get_analog_data(int channel, double timeWindow_seconds, double sample_rate_hz, double delay_seconds, int filter_mode){
|
||||
double samples_per_second = internal_librador_object->usb_driver->get_samples_per_second();
|
||||
|
||||
if(samples_per_second == 0){
|
||||
|
@ -71,7 +71,7 @@ std::vector<double> * librador_get_iso_data(double timeWindow_seconds, double sa
|
|||
int interval_samples = round(samples_per_second / sample_rate_hz);
|
||||
int delay_samples = round(delay_seconds * samples_per_second);
|
||||
int numToGet = round(timeWindow_seconds * samples_per_second);
|
||||
return internal_librador_object->usb_driver->getMany_double(numToGet, interval_samples, delay_samples, filter_mode);
|
||||
return internal_librador_object->usb_driver->getMany_double(channel, numToGet, interval_samples, delay_samples, filter_mode);
|
||||
}
|
||||
|
||||
int librador_reset_usb(){
|
||||
|
|
|
@ -34,6 +34,6 @@ uint8_t LIBRADORSHARED_EXPORT librador_get_device_firmware_variant();
|
|||
//aa
|
||||
//int LIBRADORSHARED_EXPORT librador_kickstart_isochronous_loop();
|
||||
|
||||
std::vector<double> * LIBRADORSHARED_EXPORT librador_get_iso_data(double timeWindow_seconds, double sample_rate_hz, double delay_seconds, int filter_mode);
|
||||
std::vector<double> * LIBRADORSHARED_EXPORT librador_get_analog_data(int channel, double timeWindow_seconds, double sample_rate_hz, double delay_seconds, int filter_mode);
|
||||
|
||||
#endif // LIBRADOR_H
|
||||
|
|
|
@ -49,6 +49,26 @@ int o1buffer::addVector(char *firstElement, int numElements){
|
|||
return 0;
|
||||
}
|
||||
|
||||
int o1buffer::addVector(unsigned char *firstElement, int numElements){
|
||||
int currentAddress = mostRecentAddress;
|
||||
|
||||
for(int i=0; i< numElements; i++){
|
||||
add(firstElement[i], currentAddress);
|
||||
currentAddress = (currentAddress + 1) % NUM_SAMPLES_PER_CHANNEL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int o1buffer::addVector(short *firstElement, int numElements){
|
||||
int currentAddress = mostRecentAddress;
|
||||
|
||||
for(int i=0; i< numElements; i++){
|
||||
add(firstElement[i], currentAddress);
|
||||
currentAddress = (currentAddress + 1) % NUM_SAMPLES_PER_CHANNEL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int o1buffer::get(int address){
|
||||
//Ensure that the address is not too high.
|
||||
|
@ -68,7 +88,7 @@ inline void o1buffer::updateMostRecentAddress(int newAddress){
|
|||
|
||||
//This function places samples in a buffer than can be plotted on the streamingDisplay.
|
||||
//A small delay, is added in case the packets arrive out of order.
|
||||
std::vector<double> *o1buffer::getMany_double(int numToGet, int interval_samples, int delay_samples, int filter_mode){
|
||||
std::vector<double> *o1buffer::getMany_double(int numToGet, int interval_samples, int delay_samples, int filter_mode, double scope_gain, bool AC, bool twelve_bit_multimeter){
|
||||
//Resize the vector
|
||||
convertedStream_double.resize(numToGet);
|
||||
|
||||
|
@ -80,13 +100,13 @@ std::vector<double> *o1buffer::getMany_double(int numToGet, int interval_samples
|
|||
tempAddress += NUM_SAMPLES_PER_CHANNEL;
|
||||
}
|
||||
double *data = convertedStream_double.data();
|
||||
data[i] = get_filtered_sample(tempAddress, filter_mode, interval_samples);
|
||||
data[i] = get_filtered_sample(tempAddress, filter_mode, interval_samples, scope_gain, AC, twelve_bit_multimeter);
|
||||
//convertedStream_double.replace(i, buffer[tempAddress]);
|
||||
}
|
||||
return &convertedStream_double;
|
||||
}
|
||||
|
||||
std::vector<double> *o1buffer::getSinceLast(int feasible_window_begin, int feasible_window_end, int interval_samples, int filter_mode){
|
||||
std::vector<double> *o1buffer::getSinceLast(int feasible_window_begin, int feasible_window_end, int interval_samples, int filter_mode, double scope_gain, bool AC, bool twelve_bit_multimeter){
|
||||
|
||||
//Calculate what sample the feasible window begins at
|
||||
//printf_debugging("o1buffer::getSinceLast()\n")
|
||||
|
@ -119,7 +139,7 @@ std::vector<double> *o1buffer::getSinceLast(int feasible_window_begin, int feasi
|
|||
tempAddress -= NUM_SAMPLES_PER_CHANNEL;
|
||||
}
|
||||
double *data = convertedStream_double.data();
|
||||
data[numToGet-1-i] = get_filtered_sample(tempAddress, filter_mode, interval_samples);
|
||||
data[numToGet-1-i] = get_filtered_sample(tempAddress, filter_mode, interval_samples, scope_gain, AC, twelve_bit_multimeter);
|
||||
//convertedStream_double.replace(i, buffer[tempAddress]);
|
||||
}
|
||||
|
||||
|
@ -146,14 +166,14 @@ int o1buffer::distanceFromMostRecentAddress(int index){
|
|||
}
|
||||
|
||||
//replace with get_filtered_sample
|
||||
double o1buffer::get_filtered_sample(int index, int filter_type, int filter_size){
|
||||
double o1buffer::get_filtered_sample(int index, int filter_type, int filter_size, double scope_gain, bool AC, bool twelve_bit_multimeter){
|
||||
double accum = 0;
|
||||
int currentPos = index - (filter_size / 2);
|
||||
int end = currentPos + filter_size;
|
||||
|
||||
switch(filter_type){
|
||||
case 0: //No filter
|
||||
return sampleConvert(buffer[index]);
|
||||
return sampleConvert(buffer[index], scope_gain, AC, twelve_bit_multimeter);
|
||||
case 1: //Moving Average filter
|
||||
if(currentPos < 0){
|
||||
currentPos += NUM_SAMPLES_PER_CHANNEL;
|
||||
|
@ -165,17 +185,22 @@ double o1buffer::get_filtered_sample(int index, int filter_type, int filter_size
|
|||
accum += buffer[currentPos];
|
||||
currentPos = (currentPos + 1) % NUM_SAMPLES_PER_CHANNEL;
|
||||
}
|
||||
return sampleConvert(accum/((double)filter_size));
|
||||
return sampleConvert(accum/((double)filter_size), scope_gain, AC, twelve_bit_multimeter);
|
||||
break;
|
||||
default: //Default to "no filter"
|
||||
return buffer[index];
|
||||
}
|
||||
}
|
||||
|
||||
double o1buffer::sampleConvert(int sample){
|
||||
double o1buffer::sampleConvert(int sample, double scope_gain, bool AC, bool twelve_bit_multimeter){
|
||||
double voltageLevel;
|
||||
double TOP;
|
||||
|
||||
voltageLevel = ((double)sample * (vcc/2)) / (frontendGain*librador_scope_gain*TOP);
|
||||
if(twelve_bit_multimeter){
|
||||
TOP = 2048;
|
||||
} else TOP = 128;
|
||||
|
||||
voltageLevel = ((double)sample * (vcc/2)) / (frontendGain * scope_gain * TOP);
|
||||
if (!twelve_bit_multimeter) voltageLevel += voltage_ref;
|
||||
#ifdef MULTIMETER_INVERT
|
||||
if(twelve_bit_multimeter) voltageLevel *= -1;
|
||||
|
@ -184,6 +209,12 @@ double o1buffer::sampleConvert(int sample){
|
|||
if(AC){
|
||||
voltageLevel -= voltage_ref;
|
||||
}
|
||||
|
||||
if(twelve_bit_multimeter){
|
||||
#warning Hack here. Do not know why this line works, but it does.
|
||||
voltageLevel = voltageLevel / 16;
|
||||
}
|
||||
|
||||
return voltageLevel;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,33 +14,24 @@ public:
|
|||
void add(int value, int address);
|
||||
int addVector(int *firstElement, int numElements);
|
||||
int addVector(char *firstElement, int numElements);
|
||||
int addVector(unsigned char *firstElement, int numElements);
|
||||
int addVector(short *firstElement, int numElements);
|
||||
|
||||
int get(int address);
|
||||
int mostRecentAddress = 0;
|
||||
int stream_index_at_last_call = 0;
|
||||
int distanceFromMostRecentAddress(int index);
|
||||
std::vector<double> *getMany_double(int numToGet, int interval_samples, int delay_sample, int filter_mode);
|
||||
std::vector<double> *getSinceLast(int feasible_window_begin, int feasible_window_end, int interval_samples, int filter_mode);
|
||||
#warning Asssuming Mode 0 DC
|
||||
#warning Asssuming Mode 0 DC
|
||||
#warning Asssuming Mode 0 DC
|
||||
#warning Asssuming Mode 0 DC
|
||||
#warning Asssuming Mode 0 DC
|
||||
#warning Asssuming Mode 0 DC
|
||||
#warning Asssuming Mode 0 DC
|
||||
#warning Asssuming Mode 0 DC
|
||||
double librador_scope_gain = 1;
|
||||
std::vector<double> *getMany_double(int numToGet, int interval_samples, int delay_sample, int filter_mode, double scope_gain, bool AC, bool twelve_bit_multimeter);
|
||||
std::vector<double> *getSinceLast(int feasible_window_begin, int feasible_window_end, int interval_samples, int filter_mode, double scope_gain, bool AC, bool twelve_bit_multimeter);
|
||||
double vcc = 3.3;
|
||||
bool AC = false;
|
||||
double TOP = 128;
|
||||
double frontendGain = (75.0/1075.0);
|
||||
bool twelve_bit_multimeter = false;
|
||||
double voltage_ref = 1.65;
|
||||
private:
|
||||
int *buffer;
|
||||
std::vector<double> convertedStream_double;
|
||||
void updateMostRecentAddress(int newAddress);
|
||||
double get_filtered_sample(int index, int filter_type, int filter_size);
|
||||
double sampleConvert(int sample);
|
||||
double get_filtered_sample(int index, int filter_type, int filter_size, double scope_gain, bool AC, bool twelve_bit_multimeter);
|
||||
double sampleConvert(int sample, double scope_gain, bool AC, bool twelve_bit_multimeter);
|
||||
};
|
||||
|
||||
#endif // O1BUFFER_H
|
||||
|
|
|
@ -10,6 +10,7 @@ std::mutex usb_shutdown_mutex;
|
|||
bool usb_shutdown_requested = false;
|
||||
int usb_shutdown_remaining_transfers = NUM_FUTURE_CTX;
|
||||
bool thread_active = true;
|
||||
int deviceMode = 0;
|
||||
|
||||
int begin_usb_thread_shutdown(){
|
||||
usb_shutdown_mutex.lock();
|
||||
|
@ -48,18 +49,37 @@ o1buffer *internal_o1_buffer_750;
|
|||
|
||||
|
||||
static void LIBUSB_CALL isoCallback(struct libusb_transfer * transfer){
|
||||
|
||||
//Thread mutex??
|
||||
//printf("Copy the data...\n");
|
||||
for(int i=0;i<transfer->num_iso_packets;i++){
|
||||
unsigned char *packetPointer = libusb_get_iso_packet_buffer_simple(transfer, i);
|
||||
if(transfer->actual_length){
|
||||
//printf("Expected length is %d\n", transfer->length);
|
||||
//printf("Actual length is %d\n", transfer->actual_length);
|
||||
//printf("\n");
|
||||
}
|
||||
//TODO: a switch statement here to handle all the modes.
|
||||
internal_o1_buffer_375_CH1->addVector((char*) packetPointer, 375);
|
||||
switch(deviceMode){
|
||||
case 0:
|
||||
internal_o1_buffer_375_CH1->addVector((char*) packetPointer, 375);
|
||||
break;
|
||||
case 1:
|
||||
internal_o1_buffer_375_CH1->addVector((char*) packetPointer, 375);
|
||||
internal_o1_buffer_375_CH2->addVector((unsigned char*) &packetPointer[375], 375);
|
||||
break;
|
||||
case 2:
|
||||
internal_o1_buffer_375_CH1->addVector((char*) packetPointer, 375);
|
||||
internal_o1_buffer_375_CH2->addVector((char*) &packetPointer[375], 375);
|
||||
break;
|
||||
case 3:
|
||||
internal_o1_buffer_375_CH1->addVector((unsigned char*) packetPointer, 375);
|
||||
break;
|
||||
case 4:
|
||||
internal_o1_buffer_375_CH1->addVector((unsigned char*) packetPointer, 375);
|
||||
internal_o1_buffer_375_CH2->addVector((unsigned char*) &packetPointer[375], 375);
|
||||
break;
|
||||
case 6:
|
||||
internal_o1_buffer_750->addVector((char*) packetPointer, 750);
|
||||
break;
|
||||
case 7:
|
||||
internal_o1_buffer_375_CH1->addVector((short*) packetPointer, 375);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//printf("Re-arm the endpoint...\n");
|
||||
if(usb_iso_needs_rearming()){
|
||||
|
@ -189,7 +209,7 @@ int usbCallHandler::setup_usb_control(){
|
|||
connected = true;
|
||||
|
||||
set_device_mode(0);
|
||||
set_gain(1);
|
||||
set_gain(current_scope_gain);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -245,12 +265,7 @@ int usbCallHandler::send_control_transfer(uint8_t RequestType, uint8_t Request,
|
|||
|
||||
|
||||
int usbCallHandler::avrDebug(void){
|
||||
int error;
|
||||
error = send_control_transfer(0xc0, 0xa0, 0, 0, sizeof(unified_debug), NULL);
|
||||
|
||||
if (error < 0){
|
||||
return error;
|
||||
}
|
||||
send_control_transfer_with_error_checks(0xc0, 0xa0, 0, 0, sizeof(unified_debug), NULL);
|
||||
|
||||
printf("unified debug is of size %lu\n", sizeof(unified_debug));
|
||||
|
||||
|
@ -279,20 +294,34 @@ int usbCallHandler::avrDebug(void){
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::vector<double>* usbCallHandler::getMany_double(int numToGet, int interval_samples, int delay_sample, int filter_mode){
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
#warning ASSUMING MODE 0
|
||||
std::vector<double>* usbCallHandler::getMany_double(int channel, int numToGet, int interval_samples, int delay_sample, int filter_mode){
|
||||
|
||||
return internal_o1_buffer_375_CH1->getMany_double(numToGet, interval_samples, delay_sample, filter_mode);
|
||||
switch(deviceMode){
|
||||
case 0:
|
||||
if(channel == 1){
|
||||
return internal_o1_buffer_375_CH1->getMany_double(numToGet, interval_samples, delay_sample, filter_mode, current_scope_gain, current_AC_setting, false);
|
||||
} else return NULL;
|
||||
case 1:
|
||||
if(channel == 1){
|
||||
return internal_o1_buffer_375_CH1->getMany_double(numToGet, interval_samples, delay_sample, filter_mode, current_scope_gain, current_AC_setting, false);
|
||||
} else return NULL;
|
||||
case 2:
|
||||
if(channel == 1){
|
||||
return internal_o1_buffer_375_CH1->getMany_double(numToGet, interval_samples, delay_sample, filter_mode, current_scope_gain, current_AC_setting, false);
|
||||
} else if (channel == 2){
|
||||
return internal_o1_buffer_375_CH2->getMany_double(numToGet, interval_samples, delay_sample, filter_mode, current_scope_gain, current_AC_setting, false);
|
||||
} else return NULL;
|
||||
case 6:
|
||||
if(channel == 1){
|
||||
return internal_o1_buffer_750->getMany_double(numToGet, interval_samples, delay_sample, filter_mode, current_scope_gain, current_AC_setting, false);
|
||||
} else return NULL;
|
||||
case 7:
|
||||
if(channel == 1){
|
||||
return internal_o1_buffer_375_CH1->getMany_double(numToGet, interval_samples, delay_sample, filter_mode, current_scope_gain, current_AC_setting, true);
|
||||
} else return NULL;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int usbCallHandler::send_device_reset(){
|
||||
|
@ -306,7 +335,7 @@ int usbCallHandler::set_device_mode(int mode){
|
|||
return -1;
|
||||
}
|
||||
deviceMode = mode;
|
||||
send_control_transfer(0x40, 0xa5, (mode == 5 ? 0 : mode), gainMask, 0, NULL);
|
||||
send_control_transfer_with_error_checks(0x40, 0xa5, (mode == 5 ? 0 : mode), gainMask, 0, NULL);
|
||||
|
||||
send_function_gen_settings(1);
|
||||
send_function_gen_settings(2);
|
||||
|
@ -330,10 +359,8 @@ int usbCallHandler::set_gain(double newGain){
|
|||
|
||||
gainMask = gainMask << 2;
|
||||
gainMask |= (gainMask << 8);
|
||||
send_control_transfer(0x40, 0xa5, deviceMode, gainMask, 0, NULL);
|
||||
internal_o1_buffer_375_CH1->librador_scope_gain = newGain;
|
||||
internal_o1_buffer_375_CH2->librador_scope_gain = newGain;
|
||||
internal_o1_buffer_750->librador_scope_gain = newGain;
|
||||
send_control_transfer_with_error_checks(0x40, 0xa5, deviceMode, gainMask, 0, NULL);
|
||||
current_scope_gain = newGain;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -413,16 +440,16 @@ int usbCallHandler::send_function_gen_settings(int channel){
|
|||
if(functionGen_CH1.numSamples == 0){
|
||||
return -1; //Channel not initialised
|
||||
}
|
||||
send_control_transfer(0x40, 0xa2, functionGen_CH1.timerPeriod, functionGen_CH1.clockDividerSetting, functionGen_CH1.numSamples, functionGen_CH1.samples);
|
||||
send_control_transfer_with_error_checks(0x40, 0xa2, functionGen_CH1.timerPeriod, functionGen_CH1.clockDividerSetting, functionGen_CH1.numSamples, functionGen_CH1.samples);
|
||||
} else if (channel == 2){
|
||||
if(functionGen_CH2.numSamples == 0){
|
||||
return -1; //Channel not initialised
|
||||
}
|
||||
send_control_transfer(0x40, 0xa1, functionGen_CH1.timerPeriod, functionGen_CH1.clockDividerSetting, functionGen_CH1.numSamples, functionGen_CH1.samples);
|
||||
send_control_transfer_with_error_checks(0x40, 0xa1, functionGen_CH1.timerPeriod, functionGen_CH1.clockDividerSetting, functionGen_CH1.numSamples, functionGen_CH1.samples);
|
||||
} else {
|
||||
return -2; //Invalid channel
|
||||
}
|
||||
send_control_transfer(0x40, 0xa4, fGenTriple, 0, 0, NULL);
|
||||
send_control_transfer_with_error_checks(0x40, 0xa4, fGenTriple, 0, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -436,39 +463,27 @@ int usbCallHandler::set_psu_voltage(double voltage){
|
|||
if ((dutyPsu>106) || (dutyPsu<21)){
|
||||
return -1; //Out of range
|
||||
}
|
||||
send_control_transfer(0x40, 0xa3, dutyPsu, 0, 0, NULL);
|
||||
send_control_transfer_with_error_checks(0x40, 0xa3, dutyPsu, 0, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usbCallHandler::set_digital_state(uint8_t digState){
|
||||
send_control_transfer(0x40, 0xa6, digState, 0, 0, NULL);
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
#warning Need a macro to return on failure of send_control_transfer()
|
||||
send_control_transfer_with_error_checks(0x40, 0xa6, digState, 0, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usbCallHandler::reset_device(bool goToBootloader){
|
||||
send_control_transfer(0x40, 0xa7, (goToBootloader ? 1 : 0), 0, 0, NULL);
|
||||
send_control_transfer_with_error_checks(0x40, 0xa7, (goToBootloader ? 1 : 0), 0, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t usbCallHandler::get_firmware_version(){
|
||||
send_control_transfer(0xc0, 0xa8, 0, 0, 2, NULL);
|
||||
send_control_transfer_with_error_checks(0xc0, 0xa8, 0, 0, 2, NULL);
|
||||
return *((uint16_t *) inBuffer);
|
||||
}
|
||||
|
||||
uint8_t usbCallHandler::get_firmware_variant(){
|
||||
send_control_transfer(0xc0, 0xa9, 0, 0, 1, NULL);
|
||||
send_control_transfer_with_error_checks(0xc0, 0xa9, 0, 0, 1, NULL);
|
||||
return *((uint8_t *) inBuffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,12 @@ typedef struct fGenSettings{
|
|||
uint8_t clockDividerSetting = 0;
|
||||
} fGenSettings;
|
||||
|
||||
#define send_control_transfer_with_error_checks(A, B, C, D, E, F) \
|
||||
int temp_control_transfer_error_value = send_control_transfer(A,B,C,D,E,F); \
|
||||
if(temp_control_transfer_error_value < 0){ \
|
||||
return temp_control_transfer_error_value - 1000; \
|
||||
}
|
||||
|
||||
|
||||
class usbCallHandler
|
||||
{
|
||||
|
@ -59,11 +65,8 @@ public:
|
|||
int avrDebug(void);
|
||||
int send_device_reset();
|
||||
double get_samples_per_second();
|
||||
std::vector<double> *getMany_double(int numToGet, int interval_samples, int delay_sample, int filter_mode);
|
||||
std::vector<double> *getMany_double(int channel, int numToGet, int interval_samples, int delay_sample, int filter_mode);
|
||||
bool connected;
|
||||
//Control Command Vars
|
||||
uint16_t gainMask = 0x0000;
|
||||
int deviceMode = 0;
|
||||
//Control Commands
|
||||
int set_device_mode(int mode);
|
||||
int set_gain(double newGain);
|
||||
|
@ -91,6 +94,9 @@ private:
|
|||
fGenSettings functionGen_CH2;
|
||||
double gain_psu = 1;
|
||||
double vref_psu = 1.65;
|
||||
uint16_t gainMask = 0x0000;
|
||||
double current_scope_gain = 1;
|
||||
bool current_AC_setting = false;
|
||||
};
|
||||
|
||||
#endif // USBCALLHANDLER_H
|
||||
|
|
Loading…
Reference in New Issue