mirror of
git://projects.qi-hardware.com/nn-usb-fpga.git
synced 2025-04-21 12:27:27 +03:00
Adding dual channel to scope example, fixing logic and QT source code.
This commit is contained in:
63
Examples/ADC/Scope-QT-src/mainwindow.cpp
Executable file
63
Examples/ADC/Scope-QT-src/mainwindow.cpp
Executable file
@@ -0,0 +1,63 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include <QTime>
|
||||
#include <math.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(this,SIGNAL(refresh()),ui->Graph, SLOT(repaint()));
|
||||
ui->Graph->setPointsPerPlot(120);
|
||||
ui->Graph->setVoltsPerDiv(205);
|
||||
|
||||
timer1 = new QTimer(this);
|
||||
timer1->start(50);
|
||||
connect(timer1, SIGNAL(timeout()), this, SLOT(updateGraph()));
|
||||
|
||||
CHANNEL = 1;
|
||||
ADC1 = new ADCw;
|
||||
ADC1->testADC();
|
||||
ADC1->setBufferLen(120);
|
||||
ADC1->setClockDiv(ADC_SPI_CLKDIV_MAX); //Maximun speed
|
||||
printf("\nTaking 300 samples each 50ms from Channel 0,1 at Fs=99KHz \n");
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::updateGraph()
|
||||
{
|
||||
JZ_REG * dataADC;
|
||||
|
||||
int tempD;
|
||||
|
||||
//CHANNEL 0
|
||||
dataADC=ADC1->takeSamplesADC(0);
|
||||
for(int i=0; i< 120/2; i++)
|
||||
{
|
||||
//printf("[%08X]",dataADC[i]);
|
||||
tempD = dataADC[i]&0xFFFF;
|
||||
ui->Graph->addPoint1(tempD+0x3ff);
|
||||
tempD = dataADC[i]>>16;
|
||||
ui->Graph->addPoint1(tempD+0x3ff);
|
||||
}
|
||||
CHANNEL = 1;
|
||||
|
||||
//CHANNEL 1
|
||||
dataADC=ADC1->takeSamplesADC(1);
|
||||
for(int i=0; i< 120/2; i++)
|
||||
{
|
||||
//printf("[%08X]",dataADC[i]);
|
||||
tempD = dataADC[i]&0xFFFF;
|
||||
ui->Graph->addPoint2(tempD);
|
||||
tempD = dataADC[i]>>16;
|
||||
ui->Graph->addPoint2(tempD);
|
||||
}
|
||||
|
||||
emit refresh();
|
||||
}
|
||||
Reference in New Issue
Block a user