Compare commits
2 commits
4ac7016ea1
...
2359fe5aca
Author | SHA1 | Date | |
---|---|---|---|
|
2359fe5aca | ||
|
f3c2f5ecca |
10 changed files with 206 additions and 45 deletions
|
@ -116,6 +116,8 @@ enum MOVE_ITEMS {
|
|||
MOVE_MARKERA,
|
||||
MOVE_MARKERB,
|
||||
TIME_ZOOM,
|
||||
OFSET_A,
|
||||
OFSET_B,
|
||||
};
|
||||
enum TIME_BASE_MODE {
|
||||
TIME_BASE_TRIGERED = 0,
|
||||
|
|
|
@ -14,7 +14,9 @@ static const double TimeBaseSteps [] = {
|
|||
5.0e-1, 1.0,
|
||||
};
|
||||
static const double ChannelsSteps [] = {
|
||||
0.1, 0.2, 0.5,
|
||||
1.0, 2.0, 5.0,
|
||||
10.0,20.0,50.0,
|
||||
};
|
||||
static constexpr double REF_Y = 3.3; // maximum napětí převodníku
|
||||
static constexpr double MAX_Y = double (1 << 12); // 12. bit rozlišení - 4096 steps
|
||||
|
@ -22,14 +24,18 @@ static constexpr double STEP_Y = REF_Y / MAX_Y; // jeden krok ve Voltech
|
|||
static constexpr unsigned T_SIZE = 1u << 10;
|
||||
static constexpr unsigned T_MASK = T_SIZE - 1u;
|
||||
|
||||
DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), ACopy(), BCopy(), m_forward(), m_inverse(), background(), m_ts(nullptr),
|
||||
DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), pcol(), ACopy(), BCopy(), m_forward(), m_inverse(), background(), m_ts(nullptr),
|
||||
ChA (T_SIZE), ChB(T_SIZE), m_items (MOVE_VALUE), m_timeBase(6), m_ChBase(0), m_timeCount(0u) {
|
||||
x_lenght = T_SIZE;
|
||||
m_time.a = 200.0;
|
||||
m_time.b = 300.0;
|
||||
m_volt.a = 1.0 / STEP_Y;
|
||||
m_volt.b = 2.0 / STEP_Y;
|
||||
marker_type = MARKER_TIME;
|
||||
m_channels.a = ChannelsSteps[3];
|
||||
m_channels.b = ChannelsSteps[3];
|
||||
m_offset.a = 0.0;
|
||||
m_offset.b = 0.0;
|
||||
marker_type = MARKER_TIME;
|
||||
int n = 0;
|
||||
for (QPointF & e : ChA) { const QPointF p (n++, 0); e = p; }
|
||||
n = 0;
|
||||
|
@ -37,10 +43,15 @@ DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), ACopy(), BCopy(), m_forw
|
|||
}
|
||||
DisplayWidget::~DisplayWidget() {
|
||||
}
|
||||
void DisplayWidget::MarkerChanged (bool b) {
|
||||
// qDebug ("Marker : %s", b ? "Time" : "Volt"); // OK
|
||||
if (b) marker_type = MARKER_TIME;
|
||||
else marker_type = MARKER_VOLT;
|
||||
void DisplayWidget::MarkerChanged (int n, bool b) {
|
||||
if (!b) return;
|
||||
// qDebug ("Marker : %d -> %s", n, b ? "true" : "false"); // OK
|
||||
switch (n) {
|
||||
case 0: marker_type = MARKER_TIME; break;
|
||||
case 1: marker_type = MARKER_VOLT_A; break;
|
||||
case 2: marker_type = MARKER_VOLT_B; break;
|
||||
default : break;
|
||||
}
|
||||
drawBackground();
|
||||
update();
|
||||
}
|
||||
|
@ -129,8 +140,8 @@ void DisplayWidget::resizeEvent(QResizeEvent * event) {
|
|||
void DisplayWidget::paintEvent(QPaintEvent * event) {
|
||||
QPainter p (this);
|
||||
p.drawImage(event->rect(), background);
|
||||
QPen pa (QColor(0,255, 0,255), 2);
|
||||
QPen pb (QColor(255,64,0,255), 2);
|
||||
QPen pa (pcol.colA, 2);
|
||||
QPen pb (pcol.colB, 2);
|
||||
p.setPen(pb);
|
||||
p.drawPolyline (m_forward.map(ChB));
|
||||
p.setPen(pa);
|
||||
|
@ -241,15 +252,14 @@ void DisplayWidget::drawBackground() {
|
|||
p.drawLine (m_forward.map(mb));
|
||||
}
|
||||
// text
|
||||
p.setPen (QPen (QColor(255,255,0)));
|
||||
p.setPen (QPen (pcol.colT));
|
||||
QFont font = p.font();
|
||||
font.setPixelSize(16);
|
||||
p.setFont (font);
|
||||
QString desc;
|
||||
const double xz = TimeBaseSteps [m_timeBase];
|
||||
const double yz = STEP_Y;
|
||||
const int my = r.size().height() - 10;
|
||||
desc.sprintf("T=%ss/d; A,B=%gV/d", ing_fmt (xz * dx).c_str() , dv);
|
||||
desc.sprintf("T=%ss/d, ChA %gV, ChB %gV", ing_fmt (xz * dx).c_str(), m_channels.a, m_channels.b);
|
||||
p.drawText(10,20, desc);
|
||||
|
||||
if (marker_type == MARKER_TIME) {
|
||||
|
@ -258,12 +268,34 @@ void DisplayWidget::drawBackground() {
|
|||
desc.sprintf("Marker A: %ss, Marker B: %ss, Δ=%ss, f=%sHz", ing_fmt(xz * m_time.a).c_str(), ing_fmt(xz * m_time.b).c_str(),
|
||||
ing_fmt(delta).c_str(), ing_fmt(freq).c_str());
|
||||
} else {
|
||||
double scl = 0.0;
|
||||
if (marker_type == MARKER_VOLT_A) { p.setPen (QPen (pcol.colA)); scl = m_channels.a; }
|
||||
else { p.setPen (QPen (pcol.colB)); scl = m_channels.b; }
|
||||
// qDebug("scl = %g", scl);
|
||||
const double yz = STEP_Y * scl;
|
||||
const double delta = yz * (m_volt.b - m_volt.a);
|
||||
desc.sprintf("Marker A: %sV, Marker B: %sV, Δ=%sV", ing_fmt(yz * m_volt.a).c_str(), ing_fmt(yz * m_volt.b).c_str(),
|
||||
desc.sprintf("Marker A: %sV, Marker B: %sV, Δ=%sV", ing_fmt(yz * m_volt.a).c_str(), ing_fmt(yz * m_volt.b).c_str(),
|
||||
ing_fmt(delta).c_str());
|
||||
}
|
||||
p.drawText(10,my, desc);
|
||||
}
|
||||
void DisplayWidget::SendVoltage(int ch, int n) {
|
||||
switch (ch) {
|
||||
case 0: m_channels.a = ChannelsSteps [n]; break;
|
||||
case 1: m_channels.b = ChannelsSteps [n]; break;
|
||||
default: break;
|
||||
}
|
||||
// qDebug ("Scale: %d => %g,%g", ch, m_channels.a, m_channels.b);
|
||||
drawBackground();
|
||||
update();
|
||||
}
|
||||
void DisplayWidget::reloadChRange(int a, int b) {
|
||||
m_channels.a = ChannelsSteps [a];
|
||||
m_channels.b = ChannelsSteps [b];
|
||||
drawBackground();
|
||||
update();
|
||||
}
|
||||
|
||||
void DisplayWidget::saveSettings(QSettings & setting) {
|
||||
setting.setValue("TimeBaseIndex", m_timeBase);
|
||||
setting.setValue("TimeA", m_time.a);
|
||||
|
|
|
@ -8,14 +8,21 @@
|
|||
#include "structures.h"
|
||||
/**
|
||||
*/
|
||||
struct PaintColors {
|
||||
QColor colA;
|
||||
QColor colB;
|
||||
QColor colT;
|
||||
explicit PaintColors () : colA(QColor(0,255,0,255)),colB(QColor(255,64,0,255)),colT(QColor(255,255,0,255)) {}
|
||||
};
|
||||
class QSettings;
|
||||
class DisplayWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
QVector<int> ACopy;
|
||||
QVector<int> BCopy;
|
||||
QMatrix m_forward;
|
||||
QMatrix m_inverse;
|
||||
QImage background;
|
||||
const PaintColors pcol;
|
||||
QVector<int> ACopy;
|
||||
QVector<int> BCopy;
|
||||
QMatrix m_forward;
|
||||
QMatrix m_inverse;
|
||||
QImage background;
|
||||
TrigerSettings * m_ts;
|
||||
QPolygonF ChA, ChB;
|
||||
MOVE_ITEMS m_items;
|
||||
|
@ -25,9 +32,16 @@ class DisplayWidget : public QWidget {
|
|||
struct MarkSetting {
|
||||
double a,b;
|
||||
} m_time, m_volt;
|
||||
struct ChScale {
|
||||
double a,b;
|
||||
} m_channels;
|
||||
struct ChOfset {
|
||||
double a,b;
|
||||
} m_offset;
|
||||
enum MARKER_ENUM {
|
||||
MARKER_TIME = 0,
|
||||
MARKER_VOLT,
|
||||
MARKER_VOLT_A,
|
||||
MARKER_VOLT_B,
|
||||
} marker_type;
|
||||
unsigned m_timeCount;
|
||||
public:
|
||||
|
@ -36,7 +50,9 @@ class DisplayWidget : public QWidget {
|
|||
void setTrigger (TrigerSettings * ts);
|
||||
void TriggerValues (int n);
|
||||
void TimeBaseRange (int n);
|
||||
void MarkerChanged (bool);
|
||||
void MarkerChanged (int n, bool b);
|
||||
void SendVoltage (int ch, int n);
|
||||
void reloadChRange (int a, int b);
|
||||
void saveSettings (QSettings & setting);
|
||||
void restSettings (QSettings & setting);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ static const char * TrigerEdgeTexts [] = {
|
|||
"Rising", "Faling"
|
||||
};
|
||||
static const char * TrigerSelectTexts [] = {
|
||||
"Trig.Value", "Trig.Offset", "Marker A", "Marker B", "Time Zoom"
|
||||
"Trig.Value", "Trig.Offset", "Marker A", "Marker B", "Time Zoom", "Ofset A", "Ofset B"
|
||||
};
|
||||
static const char * TimeBaseTexts [] = {
|
||||
"2μs", "5μs", "10μs", "20μs", "50μs", "100μs", "200μs","500μs",
|
||||
|
@ -56,7 +56,9 @@ MainWindow::MainWindow (QWidget * parent)
|
|||
connect (ui->Display, SIGNAL(SettingsChanged(int)), &firmware, SLOT(SettingChanged(int)));
|
||||
connect (ui->buttonStart,SIGNAL(pressed()), this, SLOT(Started()));
|
||||
connect (ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(close()));
|
||||
connect (ui->radio_a, SIGNAL(toggled(bool)), this, SLOT(MarkerChanged(bool)));
|
||||
connect (ui->radio_a, SIGNAL(toggled(bool)), this, SLOT(MarkerChangedA(bool)));
|
||||
connect (ui->radio_b, SIGNAL(toggled(bool)), this, SLOT(MarkerChangedB(bool)));
|
||||
connect (ui->radio_c, SIGNAL(toggled(bool)), this, SLOT(MarkerChangedC(bool)));
|
||||
connect (ui->actionExport_Image, SIGNAL(triggered(bool)), this, SLOT(ExportImage (bool)));
|
||||
connect (ui->actionSaveSet, SIGNAL(triggered(bool)), this, SLOT(SaveSettings(bool)));
|
||||
connect (ui->actionRestSet, SIGNAL(triggered(bool)), this, SLOT(RestSettings(bool)));
|
||||
|
@ -88,6 +90,7 @@ void MainWindow::SetSelections(AllSettings as) {
|
|||
ui->comboVA ->setCurrentIndex(as.part.asc);
|
||||
ui->comboVB ->setCurrentIndex(as.part.bsc);
|
||||
ui->Display->TimeBaseRange(as.part.tim);
|
||||
ui->Display->reloadChRange(as.part.asc, as.part.bsc);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow () {
|
||||
|
@ -96,18 +99,25 @@ MainWindow::~MainWindow () {
|
|||
void MainWindow::Started() {
|
||||
firmware.Start();
|
||||
}
|
||||
void MainWindow::MarkerChanged(bool b) {
|
||||
ui->Display->MarkerChanged (b);
|
||||
void MainWindow::MarkerChangedA(bool b) {
|
||||
ui->Display->MarkerChanged (0,b);
|
||||
}
|
||||
void MainWindow::MarkerChangedB(bool b) {
|
||||
ui->Display->MarkerChanged (1,b);
|
||||
}
|
||||
void MainWindow::MarkerChangedC(bool b) {
|
||||
ui->Display->MarkerChanged (2,b);
|
||||
}
|
||||
|
||||
void MainWindow::TriggerValues (int n) {
|
||||
ui->Display->TriggerValues(n);
|
||||
}
|
||||
void MainWindow::SendVoltageA(int n) {
|
||||
firmware.SendVoltage (0,n);
|
||||
firmware.SendVoltage (0,n);
|
||||
ui->Display->SendVoltage(0,n);
|
||||
}
|
||||
void MainWindow::SendVoltageB(int n) {
|
||||
firmware.SendVoltage (1,n);
|
||||
firmware.SendVoltage (1,n);
|
||||
ui->Display->SendVoltage(1,n);
|
||||
}
|
||||
|
||||
void MainWindow::SendTrigerMode (int n) {
|
||||
|
|
|
@ -22,7 +22,9 @@ public slots:
|
|||
void TriggerValues (int n);
|
||||
void TimeBaseRange (int n);
|
||||
void ExportImage (bool);
|
||||
void MarkerChanged (bool);
|
||||
void MarkerChangedA (bool);
|
||||
void MarkerChangedB (bool);
|
||||
void MarkerChangedC (bool);
|
||||
void SaveSettings (bool);
|
||||
void RestSettings (bool);
|
||||
void PaketTriggered ();
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>966</width>
|
||||
<height>660</height>
|
||||
<width>910</width>
|
||||
<height>508</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -15,6 +15,21 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
@ -34,7 +49,25 @@
|
|||
<property name="title">
|
||||
<string>Channel A</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="comboVA"/>
|
||||
</item>
|
||||
|
@ -46,7 +79,25 @@
|
|||
<property name="title">
|
||||
<string>Channel B</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="comboVB"/>
|
||||
</item>
|
||||
|
@ -58,7 +109,25 @@
|
|||
<property name="title">
|
||||
<string>Trigger</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QComboBox" name="comboRissing"/>
|
||||
</item>
|
||||
|
@ -76,7 +145,25 @@
|
|||
<property name="title">
|
||||
<string>Time Base</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="comboTimeRange"/>
|
||||
</item>
|
||||
|
@ -99,7 +186,7 @@
|
|||
<item>
|
||||
<widget class="QGroupBox" name="groupMarkers">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -107,29 +194,40 @@
|
|||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>121</width>
|
||||
<height>61</height>
|
||||
<height>91</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Markers</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>106</width>
|
||||
<height>25</height>
|
||||
<x>12</x>
|
||||
<y>32</y>
|
||||
<width>96</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="radio_c">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="src.qrc">
|
||||
<normaloff>:/voltb</normaloff>:/voltb</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="radio_a">
|
||||
<property name="text">
|
||||
<string/>
|
||||
|
@ -140,14 +238,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QRadioButton" name="radio_b">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="src.qrc">
|
||||
<normaloff>:/volt</normaloff>:/volt</iconset>
|
||||
<normaloff>:/volta</normaloff>:/volta</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -186,7 +284,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>966</width>
|
||||
<width>910</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<qresource prefix="/" >
|
||||
<file alias="ico">ico.png</file>
|
||||
<file alias="time">time.png</file>
|
||||
<file alias="volt">volt.png</file>
|
||||
<file alias="volta">volta.png</file>
|
||||
<file alias="voltb">voltb.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 595 B |
BIN
V203/usb/scope/software/volta.png
Normal file
BIN
V203/usb/scope/software/volta.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
V203/usb/scope/software/voltb.png
Normal file
BIN
V203/usb/scope/software/voltb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Loading…
Reference in a new issue