Hardware Design: SIE
Sign in or create your account | Project List | Help
Hardware Design: SIE Git Source Tree
Root/
| 1 | #include "mainwindow.h" |
| 2 | #include "ui_mainwindow.h" |
| 3 | #include <QDebug> |
| 4 | |
| 5 | #include <QTime> |
| 6 | #include <math.h> |
| 7 | |
| 8 | MainWindow::MainWindow(QWidget *parent) |
| 9 | : QMainWindow(parent), ui(new Ui::MainWindow) |
| 10 | { |
| 11 | ui->setupUi(this); |
| 12 | connect(this,SIGNAL(refresh()),ui->Graph, SLOT(repaint())); |
| 13 | ui->Graph->setPointsPerPlot(100); |
| 14 | ui->Graph->setVoltsPerDiv(819); |
| 15 | ui->Graph->setNumSig(8); |
| 16 | |
| 17 | timer1 = new QTimer(this); |
| 18 | timer1->start(100); |
| 19 | connect(timer1, SIGNAL(timeout()), this, SLOT(updateGraph())); |
| 20 | |
| 21 | /*ADC1 = new ADCw; |
| 22 | ADC1->testADC(); |
| 23 | ADC1->setBufferLen(800); |
| 24 | |
| 25 | ADC1->setClockDiv(ADC_SPI_CLKDIV_MIN); //Max. speed 99KHz |
| 26 | ADC1->setMuxChannels(7);*/ |
| 27 | printf("\nTaking 100 samples by channel at Fs=12.37KHz (trigger~100ms)\n"); |
| 28 | } |
| 29 | |
| 30 | MainWindow::~MainWindow() |
| 31 | { |
| 32 | delete ui; |
| 33 | } |
| 34 | |
| 35 | void MainWindow::updateGraph() |
| 36 | { |
| 37 | //JZ_REG * dataADC; |
| 38 | |
| 39 | int tempD, tempIdx=0; |
| 40 | |
| 41 | //dataADC=ADC1->takeSamplesADC(0); |
| 42 | for(int i=0; i< 800/2; i++) |
| 43 | { |
| 44 | //tempD = dataADC[i]&0x0FFF; |
| 45 | tempD = sin(10*PI*i/200)*0x200+0x200; |
| 46 | ui->Graph->addPoints(tempIdx,tempD+0x3ff*tempIdx); |
| 47 | |
| 48 | //tempD = (dataADC[i]>>16)&0x0FFF; |
| 49 | tempD = cos(10*PI*i/200)*0x200+0x200; |
| 50 | ui->Graph->addPoints(tempIdx+1,tempD+0x3ff*(tempIdx+1)); |
| 51 | |
| 52 | tempIdx=(tempIdx+2)%8; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | emit refresh(); |
| 57 | } |
| 58 |
Branches:
master
