#include <qapplication.h>
#include <qwt_plot.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_curve.h>
#include <qwt_legend.h>
#include <qwt_data.h>
#include <qwt_text.h>
#include <qwt_math.h>
#include <math.h>
#include <QFile>
#include <QLabel>
#include <QDataStream>
#include <QTextStream>
#include <iostream>
#include <fstream>
#include <QPushButton>
#include <stdlib.h>
#include <QFont>
#include <qobject.h>
#include <QObject>
/* this is later the memory content in L3 (128kByte)*/
double fft_db[4096];
double nPoints[4096];
float val[4096];
using namespace std;
//-----------------------------------------------------------------
// simple.cpp
//
// A simple example which shows how to use QwtPlot for FFT
//-----------------------------------------------------------------
{
public:
Plot();
private slots:
void checkValues();
};
Plot::Plot()
{
setAutoReplot(false);
setTitle("Single Tone FFT_Plot");
// Set axis titles
setAxisTitle(xBottom, "Fs -->");
setAxisTitle(yLeft, "FFT Magnitude(dB) -->");
// Insert new curves
#if QT_VERSION >= 0x040000
#endif
fft
->setPen
(QPen(Qt
::blue));
fft->attach(this);
setAxisScale
(QwtPlot::xBottom,
0.0,
2048.0);
setAxisScale
(QwtPlot::yLeft,
0.0,
160.0);
system("./readwritegpp readwrite.out 0xC4F5B000 16392 1");
FILE *fin;
fin = fopen( "test.bin", "rb" ); //rb means read-binary
for (int count=0; count<4096 ; count++)
{
fread( &val[count], 1, 4, fin ); //size of float = 4 bytes
nPoints[count]=count;
fft_db[count]=val[count];
}
fclose(fin);
fft->setData(nPoints, fft_db, 2048);
// Insert markers
// ...a horizontal line at y = 0...
mY
->setLabel
(QString::fromLatin1("y = 0"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setYValue(0.0);
mY->attach(this);
// ...a vertical line at x = 2 * pi
mX
->setLabel
(QString::fromLatin1("x = 2 pi"));
mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
mX->setLabelOrientation(Qt::Vertical);
mX
->setLinePen
(QPen(Qt
::black,
0, Qt
::DashDotLine));
mX->setXValue(M_PI);
mX->attach(this);
replot();
}
void Plot:: checkValues()
{
system("./readwritegpp readwrite.out 0xC4F5B000 16392 1");
}
int main(int argc, char **argv)
{
Plot plot;
FFT.resize(75, 30);
QObject::connect(&FFT,
SIGNAL(clicked
()),
&Plot
(),
SLOT(checkValues
()));
plot.resize(600,400);
plot.show();
return a.exec();
}
#include <qapplication.h>
#include <qwt_plot.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_curve.h>
#include <qwt_legend.h>
#include <qwt_data.h>
#include <qwt_text.h>
#include <qwt_math.h>
#include <math.h>
#include <QFile>
#include <QLabel>
#include <QDataStream>
#include <QTextStream>
#include <iostream>
#include <fstream>
#include <QPushButton>
#include <stdlib.h>
#include <QFont>
#include <qobject.h>
#include <QObject>
/* this is later the memory content in L3 (128kByte)*/
double fft_db[4096];
double nPoints[4096];
float val[4096];
using namespace std;
//-----------------------------------------------------------------
// simple.cpp
//
// A simple example which shows how to use QwtPlot for FFT
//-----------------------------------------------------------------
class Plot : public QwtPlot
{
public:
Plot();
private slots:
void checkValues();
};
Plot::Plot()
{
setAutoReplot(false);
setTitle("Single Tone FFT_Plot");
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
// Set axis titles
setAxisTitle(xBottom, "Fs -->");
setAxisTitle(yLeft, "FFT Magnitude(dB) -->");
// Insert new curves
QwtPlotCurve *fft = new QwtPlotCurve("y = fft(x)");
#if QT_VERSION >= 0x040000
fft->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
fft->setPen(QPen(Qt::blue));
fft->attach(this);
setAxisScale(QwtPlot::xBottom, 0.0, 2048.0);
setAxisScale(QwtPlot::yLeft, 0.0, 160.0);
system("./readwritegpp readwrite.out 0xC4F5B000 16392 1");
FILE *fin;
fin = fopen( "test.bin", "rb" ); //rb means read-binary
for (int count=0; count<4096 ; count++)
{
fread( &val[count], 1, 4, fin ); //size of float = 4 bytes
nPoints[count]=count;
fft_db[count]=val[count];
}
fclose(fin);
fft->setData(nPoints, fft_db, 2048);
// Insert markers
// ...a horizontal line at y = 0...
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel(QString::fromLatin1("y = 0"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setLineStyle(QwtPlotMarker::HLine);
mY->setYValue(0.0);
mY->attach(this);
// ...a vertical line at x = 2 * pi
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel(QString::fromLatin1("x = 2 pi"));
mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
mX->setLabelOrientation(Qt::Vertical);
mX->setLineStyle(QwtPlotMarker::VLine);
mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine));
mX->setXValue(M_PI);
mX->attach(this);
replot();
}
void Plot:: checkValues()
{
system("./readwritegpp readwrite.out 0xC4F5B000 16392 1");
}
int main(int argc, char **argv)
{
QApplication a(argc, argv);
Plot plot;
QPushButton FFT("FFT",&plot);
FFT.resize(75, 30);
FFT.setFont(QFont("Times", 18, QFont::Bold));
QObject::connect(&FFT, SIGNAL(clicked()), &Plot(), SLOT(checkValues()));
plot.resize(600,400);
plot.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks