A few new functions in librademo. Fixed the digital output.

This commit is contained in:
Chris Esposito 2018-04-07 11:50:25 +10:00
parent 55eec0aa6d
commit ebab7f8370
7 changed files with 239 additions and 24 deletions

View File

@ -73,7 +73,7 @@ void MainWindow::on_pushButton_4_clicked()
void MainWindow::on_pushButton_5_clicked()
{
QVector<double> yaxis = QVector<double>::fromStdVector(*(librador_get_iso_data(75000, 1, 750000, 0)));
QVector<double> yaxis = QVector<double>::fromStdVector(*(librador_get_iso_data(75000, 1, 1500, 0)));
qDebug() << yaxis;
@ -97,3 +97,38 @@ void MainWindow::on_pushButton_6_clicked()
{
qDebug() << librador_reset_usb();
}
void MainWindow::on_pushButton_7_clicked()
{
qDebug() << librador_get_device_firmware_version();
}
void MainWindow::on_pushButton_8_clicked()
{
qDebug() << librador_get_device_firmware_variant();
}
void MainWindow::on_pushButton_9_clicked()
{
qDebug() << librador_set_power_supply_voltage(ui->powerSupplySpinBox->value());
}
void MainWindow::on_checkBox_stateChanged(int arg1)
{
qDebug() << librador_set_digital_out(1, arg1);
}
void MainWindow::on_checkBox_2_stateChanged(int arg1)
{
qDebug() << librador_set_digital_out(2, arg1);
}
void MainWindow::on_checkBox_3_stateChanged(int arg1)
{
qDebug() << librador_set_digital_out(3, arg1);
}
void MainWindow::on_checkBox_4_stateChanged(int arg1)
{
qDebug() << librador_set_digital_out(4, arg1);
}

View File

@ -29,6 +29,20 @@ private slots:
void on_pushButton_6_clicked();
void on_pushButton_7_clicked();
void on_pushButton_8_clicked();
void on_pushButton_9_clicked();
void on_checkBox_stateChanged(int arg1);
void on_checkBox_2_stateChanged(int arg1);
void on_checkBox_3_stateChanged(int arg1);
void on_checkBox_4_stateChanged(int arg1);
private:
Ui::MainWindow *ui;
};

View File

@ -52,6 +52,69 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_7">
<property name="text">
<string>Get Firmware Version</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_8">
<property name="text">
<string>Get Firmware Variant</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="pushButton_9">
<property name="text">
<string>Send Power Supply Voltage</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="powerSupplySpinBox">
<property name="minimum">
<double>5.000000000000000</double>
</property>
<property name="maximum">
<double>12.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Digital Out 1</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>Digital Out 2</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>Digital Out 3</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string>Digital Out 4</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_5">
<property name="text">

View File

@ -21,8 +21,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_MainWindow_t {
QByteArrayData data[8];
char stringdata0[154];
QByteArrayData data[16];
char stringdata0[337];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
@ -38,13 +38,26 @@ QT_MOC_LITERAL(3, 34, 23), // "on_pushButton_2_clicked"
QT_MOC_LITERAL(4, 58, 23), // "on_pushButton_3_clicked"
QT_MOC_LITERAL(5, 82, 23), // "on_pushButton_4_clicked"
QT_MOC_LITERAL(6, 106, 23), // "on_pushButton_5_clicked"
QT_MOC_LITERAL(7, 130, 23) // "on_pushButton_6_clicked"
QT_MOC_LITERAL(7, 130, 23), // "on_pushButton_6_clicked"
QT_MOC_LITERAL(8, 154, 23), // "on_pushButton_7_clicked"
QT_MOC_LITERAL(9, 178, 23), // "on_pushButton_8_clicked"
QT_MOC_LITERAL(10, 202, 23), // "on_pushButton_9_clicked"
QT_MOC_LITERAL(11, 226, 24), // "on_checkBox_stateChanged"
QT_MOC_LITERAL(12, 251, 4), // "arg1"
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"
},
"MainWindow\0on_pushButton_clicked\0\0"
"on_pushButton_2_clicked\0on_pushButton_3_clicked\0"
"on_pushButton_4_clicked\0on_pushButton_5_clicked\0"
"on_pushButton_6_clicked"
"on_pushButton_6_clicked\0on_pushButton_7_clicked\0"
"on_pushButton_8_clicked\0on_pushButton_9_clicked\0"
"on_checkBox_stateChanged\0arg1\0"
"on_checkBox_2_stateChanged\0"
"on_checkBox_3_stateChanged\0"
"on_checkBox_4_stateChanged"
};
#undef QT_MOC_LITERAL
@ -54,7 +67,7 @@ static const uint qt_meta_data_MainWindow[] = {
7, // revision
0, // classname
0, 0, // classinfo
6, 14, // methods
13, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
@ -62,12 +75,19 @@ static const uint qt_meta_data_MainWindow[] = {
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 0, 44, 2, 0x08 /* Private */,
3, 0, 45, 2, 0x08 /* Private */,
4, 0, 46, 2, 0x08 /* Private */,
5, 0, 47, 2, 0x08 /* Private */,
6, 0, 48, 2, 0x08 /* Private */,
7, 0, 49, 2, 0x08 /* Private */,
1, 0, 79, 2, 0x08 /* Private */,
3, 0, 80, 2, 0x08 /* Private */,
4, 0, 81, 2, 0x08 /* Private */,
5, 0, 82, 2, 0x08 /* Private */,
6, 0, 83, 2, 0x08 /* Private */,
7, 0, 84, 2, 0x08 /* Private */,
8, 0, 85, 2, 0x08 /* Private */,
9, 0, 86, 2, 0x08 /* Private */,
10, 0, 87, 2, 0x08 /* Private */,
11, 1, 88, 2, 0x08 /* Private */,
13, 1, 91, 2, 0x08 /* Private */,
14, 1, 94, 2, 0x08 /* Private */,
15, 1, 97, 2, 0x08 /* Private */,
// slots: parameters
QMetaType::Void,
@ -76,6 +96,13 @@ static const uint qt_meta_data_MainWindow[] = {
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void, QMetaType::Int, 12,
QMetaType::Void, QMetaType::Int, 12,
QMetaType::Void, QMetaType::Int, 12,
QMetaType::Void, QMetaType::Int, 12,
0 // eod
};
@ -92,10 +119,16 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id,
case 3: _t->on_pushButton_4_clicked(); break;
case 4: _t->on_pushButton_5_clicked(); break;
case 5: _t->on_pushButton_6_clicked(); break;
case 6: _t->on_pushButton_7_clicked(); break;
case 7: _t->on_pushButton_8_clicked(); break;
case 8: _t->on_pushButton_9_clicked(); break;
case 9: _t->on_checkBox_stateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 10: _t->on_checkBox_2_stateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
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;
default: ;
}
}
Q_UNUSED(_a);
}
const QMetaObject MainWindow::staticMetaObject = {
@ -123,13 +156,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 6)
if (_id < 13)
qt_static_metacall(this, _c, _id, _a);
_id -= 6;
_id -= 13;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 6)
if (_id < 13)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 6;
_id -= 13;
}
return _id;
}

View File

@ -13,6 +13,8 @@
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QDoubleSpinBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QMainWindow>
@ -37,6 +39,15 @@ public:
QPushButton *pushButton_3;
QPushButton *pushButton_6;
QPushButton *pushButton_4;
QPushButton *pushButton_7;
QPushButton *pushButton_8;
QHBoxLayout *horizontalLayout_3;
QPushButton *pushButton_9;
QDoubleSpinBox *powerSupplySpinBox;
QCheckBox *checkBox;
QCheckBox *checkBox_2;
QCheckBox *checkBox_3;
QCheckBox *checkBox_4;
QPushButton *pushButton_5;
QCustomPlot *widget;
QMenuBar *menuBar;
@ -82,6 +93,54 @@ public:
verticalLayout->addWidget(pushButton_4);
pushButton_7 = new QPushButton(centralWidget);
pushButton_7->setObjectName(QStringLiteral("pushButton_7"));
verticalLayout->addWidget(pushButton_7);
pushButton_8 = new QPushButton(centralWidget);
pushButton_8->setObjectName(QStringLiteral("pushButton_8"));
verticalLayout->addWidget(pushButton_8);
horizontalLayout_3 = new QHBoxLayout();
horizontalLayout_3->setSpacing(6);
horizontalLayout_3->setObjectName(QStringLiteral("horizontalLayout_3"));
pushButton_9 = new QPushButton(centralWidget);
pushButton_9->setObjectName(QStringLiteral("pushButton_9"));
horizontalLayout_3->addWidget(pushButton_9);
powerSupplySpinBox = new QDoubleSpinBox(centralWidget);
powerSupplySpinBox->setObjectName(QStringLiteral("powerSupplySpinBox"));
powerSupplySpinBox->setMinimum(5);
powerSupplySpinBox->setMaximum(12);
horizontalLayout_3->addWidget(powerSupplySpinBox);
verticalLayout->addLayout(horizontalLayout_3);
checkBox = new QCheckBox(centralWidget);
checkBox->setObjectName(QStringLiteral("checkBox"));
verticalLayout->addWidget(checkBox);
checkBox_2 = new QCheckBox(centralWidget);
checkBox_2->setObjectName(QStringLiteral("checkBox_2"));
verticalLayout->addWidget(checkBox_2);
checkBox_3 = new QCheckBox(centralWidget);
checkBox_3->setObjectName(QStringLiteral("checkBox_3"));
verticalLayout->addWidget(checkBox_3);
checkBox_4 = new QCheckBox(centralWidget);
checkBox_4->setObjectName(QStringLiteral("checkBox_4"));
verticalLayout->addWidget(checkBox_4);
pushButton_5 = new QPushButton(centralWidget);
pushButton_5->setObjectName(QStringLiteral("pushButton_5"));
@ -120,6 +179,13 @@ public:
pushButton_3->setText(QApplication::translate("MainWindow", "Setup USB", nullptr));
pushButton_6->setText(QApplication::translate("MainWindow", "Reset USB", nullptr));
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_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));
checkBox_3->setText(QApplication::translate("MainWindow", "Digital Out 3", nullptr));
checkBox_4->setText(QApplication::translate("MainWindow", "Digital Out 4", nullptr));
pushButton_5->setText(QApplication::translate("MainWindow", "Get Scope Data", nullptr));
} // retranslateUi

View File

@ -99,6 +99,10 @@ int librador_set_oscilloscope_gain(double gain){
int librador_set_digital_out(int channel, bool state_on){
CHECK_API_INITIALISED
static uint8_t channelStates[4] = {0, 0, 0, 0};
channel--;
if((channel < 0) || (channel > 3)){
return -1000; //Invalid Channel
}
channelStates[channel] = state_on ? 1 : 0;
return internal_librador_object->usb_driver->set_digital_state((channelStates [0] | channelStates[1] << 1 | channelStates[2] << 2 | channelStates[3] << 3));
@ -119,7 +123,7 @@ uint16_t librador_get_device_firmware_version(){
return internal_librador_object->usb_driver->get_firmware_version();
}
uint8_t librador_get_device_firmware_variand(){
uint8_t librador_get_device_firmware_variant(){
CHECK_API_INITIALISED
return internal_librador_object->usb_driver->get_firmware_variant();
}

View File

@ -47,18 +47,18 @@ o1buffer *internal_o1_buffer;
static void LIBUSB_CALL isoCallback(struct libusb_transfer * transfer){
//Thread mutex??
printf("Copy the data...\n");
//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");
//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->addVector(packetPointer, 375);
}
printf("Re-arm the endpoint...\n");
//printf("Re-arm the endpoint...\n");
if(usb_iso_needs_rearming()){
int error = libusb_submit_transfer(transfer);
if(error){
@ -80,7 +80,7 @@ void usb_polling_function(libusb_context *ctx){
tv.tv_sec = 1;
tv.tv_usec = 0;//ISO_PACKETS_PER_CTX*4000;
while(!safe_to_exit_thread()){
printf("usb_polling_function begin loop\n");
//printf("usb_polling_function begin loop\n");
if(libusb_event_handling_ok(ctx)){
libusb_handle_events_timeout(ctx, &tv);
}