#include "mainwindow.h" #include "ui_mainwindow.h" #include #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(this,SIGNAL(refresh()),ui->Graph, SLOT(repaint())); ui->Graph->setPointsPerPlot(300); 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(300, 0x08, 1); int tempD; for(int i=1; i< 300/2+1; i++) { //printf("[%08X]",dataADC[i]); tempD = dataADC[i]&0xFFFF; ui->Graph->addPoint(tempD); tempD = dataADC[i]>>16; ui->Graph->addPoint(tempD); } //printf("\n \n *************************************************************** \n\n"); //fflush (stdout); /*for(int i = 0; i<100;i++) ui->Graph->addPoint(20*sin(6.2832*i/100)+20);*/ emit refresh(); }