#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())); 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(); }