1
0
mirror of git://projects.qi-hardware.com/nn-usb-fpga.git synced 2025-01-10 23:30:15 +02:00
nn-usb-fpga/Examples/ADC/QT_src/mainwindow.cpp

48 lines
1.0 KiB
C++
Raw Normal View History

2010-04-05 22:06:50 +03:00
#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(250);
ui->Graph->setVoltsPerDiv(102);
timer1 = new QTimer(this);
timer1->start(50);
connect(timer1, SIGNAL(timeout()), this, SLOT(updateGraph()));
ADC1 = new ADCw;
ADC1->testADC();
printf("\nTaking 250 samples each 50ms from Channel 0 at Fs=9.8KHz \n");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::updateGraph()
{
JZ_REG * dataADC =ADC1->takeSamplesADC(250, 0xFF, 1);
int tempD;
for(int i=1; i< 250/2+1; i++)
{
tempD = dataADC[i]&0xFFFF; //printf("[%08X]",tempD);
ui->Graph->addPoint(tempD);
tempD = dataADC[i]>>16; //printf("[%08X]",tempD);
ui->Graph->addPoint(tempD);
}
//fflush (stdout);
/*for(int i = 0; i<100;i++)
ui->Graph->addPoint(20*sin(6.2832*i/100)+20);*/
emit refresh();
}