Compare commits
No commits in common. "2359fe5aca510dea5d32951509281713e62e28b9" and "4ac7016ea1c4842f796bd5aa40ddf92532357828" have entirely different histories.
2359fe5aca
...
4ac7016ea1
10 changed files with 46 additions and 207 deletions
|
@ -116,8 +116,6 @@ enum MOVE_ITEMS {
|
|||
MOVE_MARKERA,
|
||||
MOVE_MARKERB,
|
||||
TIME_ZOOM,
|
||||
OFSET_A,
|
||||
OFSET_B,
|
||||
};
|
||||
enum TIME_BASE_MODE {
|
||||
TIME_BASE_TRIGERED = 0,
|
||||
|
|
|
@ -14,9 +14,7 @@ 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
|
||||
|
@ -24,18 +22,14 @@ 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), pcol(), ACopy(), BCopy(), m_forward(), m_inverse(), background(), m_ts(nullptr),
|
||||
DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), 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;
|
||||
m_channels.a = ChannelsSteps[3];
|
||||
m_channels.b = ChannelsSteps[3];
|
||||
m_offset.a = 0.0;
|
||||
m_offset.b = 0.0;
|
||||
marker_type = MARKER_TIME;
|
||||
marker_type = MARKER_TIME;
|
||||
int n = 0;
|
||||
for (QPointF & e : ChA) { const QPointF p (n++, 0); e = p; }
|
||||
n = 0;
|
||||
|
@ -43,15 +37,10 @@ DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), pcol(), ACopy(), BCopy()
|
|||
}
|
||||
DisplayWidget::~DisplayWidget() {
|
||||
}
|
||||
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;
|
||||
}
|
||||
void DisplayWidget::MarkerChanged (bool b) {
|
||||
// qDebug ("Marker : %s", b ? "Time" : "Volt"); // OK
|
||||
if (b) marker_type = MARKER_TIME;
|
||||
else marker_type = MARKER_VOLT;
|
||||
drawBackground();
|
||||
update();
|
||||
}
|
||||
|
@ -140,8 +129,8 @@ void DisplayWidget::resizeEvent(QResizeEvent * event) {
|
|||
void DisplayWidget::paintEvent(QPaintEvent * event) {
|
||||
QPainter p (this);
|
||||
p.drawImage(event->rect(), background);
|
||||
QPen pa (pcol.colA, 2);
|
||||
QPen pb (pcol.colB, 2);
|
||||
QPen pa (QColor(0,255, 0,255), 2);
|
||||
QPen pb (QColor(255,64,0,255), 2);
|
||||
p.setPen(pb);
|
||||
p.drawPolyline (m_forward.map(ChB));
|
||||
p.setPen(pa);
|
||||
|
@ -252,14 +241,15 @@ void DisplayWidget::drawBackground() {
|
|||
p.drawLine (m_forward.map(mb));
|
||||
}
|
||||
// text
|
||||
p.setPen (QPen (pcol.colT));
|
||||
p.setPen (QPen (QColor(255,255,0)));
|
||||
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, ChA %gV, ChB %gV", ing_fmt (xz * dx).c_str(), m_channels.a, m_channels.b);
|
||||
desc.sprintf("T=%ss/d; A,B=%gV/d", ing_fmt (xz * dx).c_str() , dv);
|
||||
p.drawText(10,20, desc);
|
||||
|
||||
if (marker_type == MARKER_TIME) {
|
||||
|
@ -268,34 +258,12 @@ 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,21 +8,14 @@
|
|||
#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
|
||||
const PaintColors pcol;
|
||||
QVector<int> ACopy;
|
||||
QVector<int> BCopy;
|
||||
QMatrix m_forward;
|
||||
QMatrix m_inverse;
|
||||
QImage background;
|
||||
QVector<int> ACopy;
|
||||
QVector<int> BCopy;
|
||||
QMatrix m_forward;
|
||||
QMatrix m_inverse;
|
||||
QImage background;
|
||||
TrigerSettings * m_ts;
|
||||
QPolygonF ChA, ChB;
|
||||
MOVE_ITEMS m_items;
|
||||
|
@ -32,16 +25,9 @@ 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_A,
|
||||
MARKER_VOLT_B,
|
||||
MARKER_VOLT,
|
||||
} marker_type;
|
||||
unsigned m_timeCount;
|
||||
public:
|
||||
|
@ -50,9 +36,7 @@ class DisplayWidget : public QWidget {
|
|||
void setTrigger (TrigerSettings * ts);
|
||||
void TriggerValues (int n);
|
||||
void TimeBaseRange (int n);
|
||||
void MarkerChanged (int n, bool b);
|
||||
void SendVoltage (int ch, int n);
|
||||
void reloadChRange (int a, int b);
|
||||
void MarkerChanged (bool);
|
||||
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", "Ofset A", "Ofset B"
|
||||
"Trig.Value", "Trig.Offset", "Marker A", "Marker B", "Time Zoom"
|
||||
};
|
||||
static const char * TimeBaseTexts [] = {
|
||||
"2μs", "5μs", "10μs", "20μs", "50μs", "100μs", "200μs","500μs",
|
||||
|
@ -56,9 +56,7 @@ 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(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->radio_a, SIGNAL(toggled(bool)), this, SLOT(MarkerChanged(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)));
|
||||
|
@ -90,7 +88,6 @@ 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 () {
|
||||
|
@ -99,25 +96,18 @@ MainWindow::~MainWindow () {
|
|||
void MainWindow::Started() {
|
||||
firmware.Start();
|
||||
}
|
||||
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::MarkerChanged(bool b) {
|
||||
ui->Display->MarkerChanged (b);
|
||||
}
|
||||
|
||||
void MainWindow::TriggerValues (int n) {
|
||||
ui->Display->TriggerValues(n);
|
||||
}
|
||||
void MainWindow::SendVoltageA(int n) {
|
||||
firmware.SendVoltage (0,n);
|
||||
ui->Display->SendVoltage(0,n);
|
||||
firmware.SendVoltage (0,n);
|
||||
}
|
||||
void MainWindow::SendVoltageB(int n) {
|
||||
firmware.SendVoltage (1,n);
|
||||
ui->Display->SendVoltage(1,n);
|
||||
firmware.SendVoltage (1,n);
|
||||
}
|
||||
|
||||
void MainWindow::SendTrigerMode (int n) {
|
||||
|
|
|
@ -22,9 +22,7 @@ public slots:
|
|||
void TriggerValues (int n);
|
||||
void TimeBaseRange (int n);
|
||||
void ExportImage (bool);
|
||||
void MarkerChangedA (bool);
|
||||
void MarkerChangedB (bool);
|
||||
void MarkerChangedC (bool);
|
||||
void MarkerChanged (bool);
|
||||
void SaveSettings (bool);
|
||||
void RestSettings (bool);
|
||||
void PaketTriggered ();
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>910</width>
|
||||
<height>508</height>
|
||||
<width>966</width>
|
||||
<height>660</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -15,21 +15,6 @@
|
|||
</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>
|
||||
|
@ -49,25 +34,7 @@
|
|||
<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>
|
||||
|
@ -79,25 +46,7 @@
|
|||
<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>
|
||||
|
@ -109,25 +58,7 @@
|
|||
<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>
|
||||
|
@ -145,25 +76,7 @@
|
|||
<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>
|
||||
|
@ -186,7 +99,7 @@
|
|||
<item>
|
||||
<widget class="QGroupBox" name="groupMarkers">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -194,40 +107,29 @@
|
|||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>121</width>
|
||||
<height>91</height>
|
||||
<height>61</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Markers</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>12</x>
|
||||
<y>32</y>
|
||||
<width>96</width>
|
||||
<height>50</height>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>106</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<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">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radio_a">
|
||||
<property name="text">
|
||||
<string/>
|
||||
|
@ -238,14 +140,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="radio_b">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="src.qrc">
|
||||
<normaloff>:/volta</normaloff>:/volta</iconset>
|
||||
<normaloff>:/volt</normaloff>:/volt</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -284,7 +186,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>910</width>
|
||||
<width>966</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<qresource prefix="/" >
|
||||
<file alias="ico">ico.png</file>
|
||||
<file alias="time">time.png</file>
|
||||
<file alias="volta">volta.png</file>
|
||||
<file alias="voltb">voltb.png</file>
|
||||
<file alias="volt">volt.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
V203/usb/scope/software/volt.png
Normal file
BIN
V203/usb/scope/software/volt.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 595 B |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Loading…
Reference in a new issue