2010-04-09 18:39:15 +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(120);
|
|
|
|
ui->Graph->setVoltsPerDiv(205);
|
|
|
|
|
|
|
|
timer1 = new QTimer(this);
|
|
|
|
timer1->start(50);
|
|
|
|
connect(timer1, SIGNAL(timeout()), this, SLOT(updateGraph()));
|
|
|
|
|
|
|
|
ADC1 = new ADCw;
|
|
|
|
ADC1->testADC();
|
2010-04-13 05:26:26 +03:00
|
|
|
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");
|
2010-04-09 18:39:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::updateGraph()
|
|
|
|
{
|
|
|
|
JZ_REG * dataADC;
|
|
|
|
|
|
|
|
int tempD;
|
|
|
|
|
|
|
|
dataADC=ADC1->takeSamplesADC(0);
|
2010-04-13 05:26:26 +03:00
|
|
|
for(int i=0; i< 240/2; i++)
|
|
|
|
{
|
|
|
|
tempD = dataADC[i]&0x0FFF;
|
2010-04-09 18:39:15 +03:00
|
|
|
ui->Graph->addPoint1(tempD+0x3ff);
|
2010-04-13 05:26:26 +03:00
|
|
|
tempD = (dataADC[i]>>16)&0x0FFF;
|
2010-04-09 18:39:15 +03:00
|
|
|
ui->Graph->addPoint2(tempD);
|
|
|
|
}
|
|
|
|
|
|
|
|
emit refresh();
|
|
|
|
}
|