diff --git a/mainwindow.h b/mainwindow.h --- a/mainwindow.h +++ b/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include +#include #include #include #include @@ -20,7 +21,19 @@ public: ~MainWindow(); private: + enum NumberFormat + { + NumberFormat_uint8, + NumberFormat_uint16, + NumberFormat_uint32, + NumberFormat_int8, + NumberFormat_int16, + NumberFormat_int32 + }; + Ui::MainWindow *ui; + QButtonGroup numberFormatButtons; + QSerialPort serialPort; unsigned int numOfSamples; @@ -29,6 +42,13 @@ private: QVector dataX; void addData(double data); + NumberFormat numberFormat; + unsigned int sampleSize; // number of bytes in the selected number format + double (MainWindow::*readSample)(); + + // note that serialPort should already have enough bytes present + template double readSampleAs(); + private slots: void loadPortList(); void loadBaudRateList(); @@ -44,6 +64,9 @@ private slots: void onAutoScaleChecked(bool checked); void onYScaleChanged(); + void onNumberFormatButtonToggled(int numberFormatId, bool checked); + void selectNumberFormat(NumberFormat numberFormatId); + signals: void portToggled(bool open); };