Changeset - bcd6b30d01d1
[Not reviewed]
default
0 2 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-04-07 05:00:45
hy@ozderya.net
implemented skip byte function
2 files changed with 22 insertions and 0 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -121,6 +121,11 @@ MainWindow::MainWindow(QWidget *parent) 
 
    QObject::connect(&(this->serialPort), &QSerialPort::readyRead,
 
                     this, &MainWindow::onDataReady);
 

	
 
    // init skip byte button
 
    skipByteRequested = false;
 
    QObject::connect(ui->pbSkipByte, &QPushButton::clicked,
 
                     this, &MainWindow::skipByte);
 

	
 
    loadPortList();
 
    loadBaudRateList();
 
    ui->cbBaudRate->setCurrentIndex(ui->cbBaudRate->findText("9600"));
 
@@ -314,6 +319,14 @@ void MainWindow::onDataReady()
 
    if (!ui->actionPause->isChecked())
 
    {
 
        int bytesAvailable = serialPort.bytesAvailable();
 

	
 
        if (bytesAvailable > 0 && skipByteRequested)
 
        {
 
            serialPort.read(1);
 
            skipByteRequested = false;
 
            bytesAvailable--;
 
        }
 

	
 
        if (bytesAvailable < sampleSize)
 
        {
 
            return;
 
@@ -360,6 +373,11 @@ void MainWindow::onPortError(QSerialPort
 

	
 
}
 

	
 
void MainWindow::skipByte()
 
{
 
    skipByteRequested = true;
 
}
 

	
 
void MainWindow::addData(QVector<double> data)
 
{
 
    int offset = numOfSamples - data.size();
mainwindow.h
Show inline comments
 
@@ -73,6 +73,8 @@ private:
 
    // note that serialPort should already have enough bytes present
 
    template<typename T> double readSampleAs();
 

	
 
    bool skipByteRequested;
 

	
 
private slots:
 
    void loadPortList();
 
    void loadBaudRateList();
 
@@ -88,6 +90,8 @@ private slots:
 
    void onDataReady();
 
    void onPortError(QSerialPort::SerialPortError error);
 

	
 
    void skipByte();
 

	
 
    void onNumOfSamplesChanged(int value);
 
    void onAutoScaleChecked(bool checked);
 
    void onYScaleChanged();
0 comments (0 inline, 0 general)