#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(120); ui->Graph->setVoltsPerDiv(205); timer1 = new QTimer(this); timer1->start(50); connect(timer1, SIGNAL(timeout()), this, SLOT(updateGraph())); ADC1 = new ADCw; ADC1->testADC(); ADC1->setBufferLen(240); ADC1->setClockDiv(ADC_SPI_CLKDIV_MIN); //Max. speed ADC1->setMuxChannels(1); printf("\nTaking 120 samples by channel at Fs=99KHz (trigger=50ms)\n"); } MainWindow::~MainWindow() { delete ui; } void MainWindow::updateGraph() { JZ_REG * dataADC; int tempD; dataADC=ADC1->takeSamplesADC(0); for(int i=0; i< 240/2; i++) { tempD = dataADC[i]&0x0FFF; ui->Graph->addPoint1(tempD+0x3ff); tempD = (dataADC[i]>>16)&0x0FFF; ui->Graph->addPoint2(tempD); } emit refresh(); }