/Designs/Oscilloscope/SW/PC_side/qscope/main.cpp
27,7 → 27,7
{
QApplication app(argc, argv);
Window window;
window.setGeometry(500, 100, 460, 740);
window.setGeometry(500, 200, 460, 760);
window.show();
return app.exec();
}
/Designs/Oscilloscope/SW/PC_side/qscope/moc_scope.cpp
1,7 → 1,7
/****************************************************************************
** Meta object code from reading C++ file 'scope.h'
**
** Created: Mon Aug 15 00:34:35 2011
** Created: Sun Aug 14 13:57:52 2011
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.2)
**
** WARNING! All changes made in this file will be lost!
/Designs/Oscilloscope/SW/PC_side/qscope/qscope
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/Designs/Oscilloscope/SW/PC_side/qscope/scope.cpp
8,7 → 8,6
 
using namespace std;
 
void UI(void);
 
Scope::Scope(QWidget *parent) { // CONSTRUCTOR, graphic stuff
dataAquired=0;
28,7 → 27,7
connect(scaleSlider, SIGNAL(valueChanged(int)), this, SLOT(setScale(int)));
shiftSlider = new QSlider(Qt::Horizontal,this);
shiftSlider->setRange(0, +60000);
shiftSlider->setRange(-60000, +60000);
shiftSlider->setValue(DEF_SHIFT);
connect(shiftSlider, SIGNAL(valueChanged(int)), this, SLOT(setShift(int)));
 
36,49 → 35,18
updateTimer->start(TICK);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(getData()));
labels[1] = new QLabel(this);
/*QString tempStr;
tempStr.setNum(shift);
labels[1]->setText("Zero level: " + tempStr);
labels[1]->setGeometry (20, 550, 200, 20);
labels[1]->show();
shiftSlider->setGeometry(QRect(20,580,400,60));
shiftSlider->show();*/
QLabel ( const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0 )
scaleSlider->setGeometry(QRect(20,600,400,60));
scaleSlider->show();
 
shiftSlider->setGeometry(QRect(20,680,400,60));
shiftSlider->show();
 
labels[2] = new QLabel(this);
this->UI();/*
tempStr.setNum(scale);
labels[2]->setText("Divisor: " + tempStr);
labels[2]->setGeometry (20, 630, 400, 20);
labels[2]->show();
scaleSlider->setGeometry(QRect(20,660,400,60));
scaleSlider->show();*/
// getData();
}
 
void Scope::UI(void) {
QString tempStr;
tempStr.setNum(shift);
labels[1]->setText("Zero level: " + tempStr);
labels[1]->setGeometry (20, 550, 200, 20);
labels[1]->show();
shiftSlider->setGeometry(QRect(20,580,400,60));
shiftSlider->show();
 
tempStr.setNum(scale);
labels[2]->setText("Divisor: " + tempStr);
labels[2]->setGeometry (20, 630, 400, 20);
labels[2]->show();
scaleSlider->setGeometry(QRect(20,660,400,60));
scaleSlider->show();
}
 
 
 
 
 
 
Scope::~Scope() {
delete [] data;
}
99,13 → 67,13
int i;
for(i=0;i<LEN;i++) {
data[i] = (data[i] - shift)/scale;
data[i] = (data[i] + shift)/scale;
}
 
for(i=0;i<LEN-1;i++) {
painter.drawLine(PIXPT_X*i+LEFT,TOP+HEIGHT/2-PIXPT_Y*data[i],PIXPT_X*(i+1)+LEFT,TOP+HEIGHT/2-data[i+1]*PIXPT_Y);
}
//cout << "Screen updated"<<endl;
cout << "Screen updated"<<endl;
}
}
 
119,12 → 87,10
if (serial==NULL) {
cout << "Serial port error."<<endl;
} else {
//cout << "Serial port open."<<endl;
cout << "Serial port open."<<endl;
fwrite(&c,sizeof(char),1,serial); // poprosime o data
fread(buffer,sizeof(uint8_t),2*LEN,serial); // a berem je
// cout << "Serial transfer completed."<<endl;
cout << "Serial transfer completed."<<endl;
fclose(serial);
int i;
132,8 → 98,7
data[i]=buffer[2*i]*256+buffer[2*i+1];
// cout << 1*data[i] <<endl;
}
// cout << "Screen updating...."<<endl;
cout << "Screen updating...."<<endl;
dataAquired=1;
update();
}
142,10 → 107,8
 
void Scope::setScale(int val) {
scale=val;
UI();
}
 
void Scope::setShift(int val) {
shift=val;
UI();
}
}
/Designs/Oscilloscope/SW/PC_side/qscope/scope.h
5,13 → 5,12
#include <QTimer>
#include <QSlider>
#include <stdint.h>
#include <QLabel>
 
#define TICK 250 // time in ms for one sample (LEN values)
#define TICK 150 // time in ms for one sampling (of LEN values)
#define LEN 100 // number of sampled values
 
#define DEF_SCALE 128 //divisor
#define DEF_SHIFT 37203
#define DEF_SCALE 256 //divisor
#define DEF_SHIFT 0
 
#define LEFT 10
#define TOP 10
37,19 → 36,15
void paintEvent(QPaintEvent *event);
 
private:
uint8_t buffer[2*LEN];
int data[LEN];
char dataAquired;
void UI(void);
int shift, scale;
long shift, scale;
 
QTimer *updateTimer;
QSlider *shiftSlider;
QSlider *scaleSlider;
 
QLabel * labels[5];
};
 
#endif