Compare commits

..

2 commits

Author SHA1 Message Date
Kizarm
2359fe5aca edit software 2024-11-10 15:39:03 +01:00
Kizarm
f3c2f5ecca ui 2024-11-10 09:44:23 +01:00
10 changed files with 206 additions and 45 deletions

View file

@ -116,6 +116,8 @@ enum MOVE_ITEMS {
MOVE_MARKERA, MOVE_MARKERA,
MOVE_MARKERB, MOVE_MARKERB,
TIME_ZOOM, TIME_ZOOM,
OFSET_A,
OFSET_B,
}; };
enum TIME_BASE_MODE { enum TIME_BASE_MODE {
TIME_BASE_TRIGERED = 0, TIME_BASE_TRIGERED = 0,

View file

@ -14,7 +14,9 @@ static const double TimeBaseSteps [] = {
5.0e-1, 1.0, 5.0e-1, 1.0,
}; };
static const double ChannelsSteps [] = { static const double ChannelsSteps [] = {
0.1, 0.2, 0.5,
1.0, 2.0, 5.0, 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 REF_Y = 3.3; // maximum napětí převodníku
static constexpr double MAX_Y = double (1 << 12); // 12. bit rozlišení - 4096 steps 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_SIZE = 1u << 10;
static constexpr unsigned T_MASK = T_SIZE - 1u; 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) { ChA (T_SIZE), ChB(T_SIZE), m_items (MOVE_VALUE), m_timeBase(6), m_ChBase(0), m_timeCount(0u) {
x_lenght = T_SIZE; x_lenght = T_SIZE;
m_time.a = 200.0; m_time.a = 200.0;
m_time.b = 300.0; m_time.b = 300.0;
m_volt.a = 1.0 / STEP_Y; m_volt.a = 1.0 / STEP_Y;
m_volt.b = 2.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; int n = 0;
for (QPointF & e : ChA) { const QPointF p (n++, 0); e = p; } for (QPointF & e : ChA) { const QPointF p (n++, 0); e = p; }
n = 0; n = 0;
@ -37,10 +43,15 @@ DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), ACopy(), BCopy(), m_forw
} }
DisplayWidget::~DisplayWidget() { DisplayWidget::~DisplayWidget() {
} }
void DisplayWidget::MarkerChanged (bool b) { void DisplayWidget::MarkerChanged (int n, bool b) {
// qDebug ("Marker : %s", b ? "Time" : "Volt"); // OK if (!b) return;
if (b) marker_type = MARKER_TIME; // qDebug ("Marker : %d -> %s", n, b ? "true" : "false"); // OK
else marker_type = MARKER_VOLT; 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(); drawBackground();
update(); update();
} }
@ -129,8 +140,8 @@ void DisplayWidget::resizeEvent(QResizeEvent * event) {
void DisplayWidget::paintEvent(QPaintEvent * event) { void DisplayWidget::paintEvent(QPaintEvent * event) {
QPainter p (this); QPainter p (this);
p.drawImage(event->rect(), background); p.drawImage(event->rect(), background);
QPen pa (QColor(0,255, 0,255), 2); QPen pa (pcol.colA, 2);
QPen pb (QColor(255,64,0,255), 2); QPen pb (pcol.colB, 2);
p.setPen(pb); p.setPen(pb);
p.drawPolyline (m_forward.map(ChB)); p.drawPolyline (m_forward.map(ChB));
p.setPen(pa); p.setPen(pa);
@ -241,15 +252,14 @@ void DisplayWidget::drawBackground() {
p.drawLine (m_forward.map(mb)); p.drawLine (m_forward.map(mb));
} }
// text // text
p.setPen (QPen (QColor(255,255,0))); p.setPen (QPen (pcol.colT));
QFont font = p.font(); QFont font = p.font();
font.setPixelSize(16); font.setPixelSize(16);
p.setFont (font); p.setFont (font);
QString desc; QString desc;
const double xz = TimeBaseSteps [m_timeBase]; const double xz = TimeBaseSteps [m_timeBase];
const double yz = STEP_Y;
const int my = r.size().height() - 10; 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); p.drawText(10,20, desc);
if (marker_type == MARKER_TIME) { 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(), 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()); ing_fmt(delta).c_str(), ing_fmt(freq).c_str());
} else { } 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); 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()); ing_fmt(delta).c_str());
} }
p.drawText(10,my, desc); 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) { void DisplayWidget::saveSettings(QSettings & setting) {
setting.setValue("TimeBaseIndex", m_timeBase); setting.setValue("TimeBaseIndex", m_timeBase);
setting.setValue("TimeA", m_time.a); setting.setValue("TimeA", m_time.a);

View file

@ -8,14 +8,21 @@
#include "structures.h" #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 QSettings;
class DisplayWidget : public QWidget { class DisplayWidget : public QWidget {
Q_OBJECT Q_OBJECT
QVector<int> ACopy; const PaintColors pcol;
QVector<int> BCopy; QVector<int> ACopy;
QMatrix m_forward; QVector<int> BCopy;
QMatrix m_inverse; QMatrix m_forward;
QImage background; QMatrix m_inverse;
QImage background;
TrigerSettings * m_ts; TrigerSettings * m_ts;
QPolygonF ChA, ChB; QPolygonF ChA, ChB;
MOVE_ITEMS m_items; MOVE_ITEMS m_items;
@ -25,9 +32,16 @@ class DisplayWidget : public QWidget {
struct MarkSetting { struct MarkSetting {
double a,b; double a,b;
} m_time, m_volt; } m_time, m_volt;
struct ChScale {
double a,b;
} m_channels;
struct ChOfset {
double a,b;
} m_offset;
enum MARKER_ENUM { enum MARKER_ENUM {
MARKER_TIME = 0, MARKER_TIME = 0,
MARKER_VOLT, MARKER_VOLT_A,
MARKER_VOLT_B,
} marker_type; } marker_type;
unsigned m_timeCount; unsigned m_timeCount;
public: public:
@ -36,7 +50,9 @@ class DisplayWidget : public QWidget {
void setTrigger (TrigerSettings * ts); void setTrigger (TrigerSettings * ts);
void TriggerValues (int n); void TriggerValues (int n);
void TimeBaseRange (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 saveSettings (QSettings & setting);
void restSettings (QSettings & setting); void restSettings (QSettings & setting);

View file

@ -18,7 +18,7 @@ static const char * TrigerEdgeTexts [] = {
"Rising", "Faling" "Rising", "Faling"
}; };
static const char * TrigerSelectTexts [] = { 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 [] = { static const char * TimeBaseTexts [] = {
"2μs", "5μs", "10μs", "20μs", "50μs", "100μs", "200μs","500μs", "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->Display, SIGNAL(SettingsChanged(int)), &firmware, SLOT(SettingChanged(int)));
connect (ui->buttonStart,SIGNAL(pressed()), this, SLOT(Started())); connect (ui->buttonStart,SIGNAL(pressed()), this, SLOT(Started()));
connect (ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(close())); 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->actionExport_Image, SIGNAL(triggered(bool)), this, SLOT(ExportImage (bool)));
connect (ui->actionSaveSet, SIGNAL(triggered(bool)), this, SLOT(SaveSettings(bool))); connect (ui->actionSaveSet, SIGNAL(triggered(bool)), this, SLOT(SaveSettings(bool)));
connect (ui->actionRestSet, SIGNAL(triggered(bool)), this, SLOT(RestSettings(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->comboVA ->setCurrentIndex(as.part.asc);
ui->comboVB ->setCurrentIndex(as.part.bsc); ui->comboVB ->setCurrentIndex(as.part.bsc);
ui->Display->TimeBaseRange(as.part.tim); ui->Display->TimeBaseRange(as.part.tim);
ui->Display->reloadChRange(as.part.asc, as.part.bsc);
} }
MainWindow::~MainWindow () { MainWindow::~MainWindow () {
@ -96,18 +99,25 @@ MainWindow::~MainWindow () {
void MainWindow::Started() { void MainWindow::Started() {
firmware.Start(); firmware.Start();
} }
void MainWindow::MarkerChanged(bool b) { void MainWindow::MarkerChangedA(bool b) {
ui->Display->MarkerChanged (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) { void MainWindow::TriggerValues (int n) {
ui->Display->TriggerValues(n); ui->Display->TriggerValues(n);
} }
void MainWindow::SendVoltageA(int n) { void MainWindow::SendVoltageA(int n) {
firmware.SendVoltage (0,n); firmware.SendVoltage (0,n);
ui->Display->SendVoltage(0,n);
} }
void MainWindow::SendVoltageB(int n) { void MainWindow::SendVoltageB(int n) {
firmware.SendVoltage (1,n); firmware.SendVoltage (1,n);
ui->Display->SendVoltage(1,n);
} }
void MainWindow::SendTrigerMode (int n) { void MainWindow::SendTrigerMode (int n) {

View file

@ -22,7 +22,9 @@ public slots:
void TriggerValues (int n); void TriggerValues (int n);
void TimeBaseRange (int n); void TimeBaseRange (int n);
void ExportImage (bool); void ExportImage (bool);
void MarkerChanged (bool); void MarkerChangedA (bool);
void MarkerChangedB (bool);
void MarkerChangedC (bool);
void SaveSettings (bool); void SaveSettings (bool);
void RestSettings (bool); void RestSettings (bool);
void PaketTriggered (); void PaketTriggered ();

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>966</width> <width>910</width>
<height>660</height> <height>508</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,6 +15,21 @@
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_6"> <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"> <item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
@ -34,7 +49,25 @@
<property name="title"> <property name="title">
<string>Channel A</string> <string>Channel A</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_4"> <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"> <item row="0" column="0">
<widget class="QComboBox" name="comboVA"/> <widget class="QComboBox" name="comboVA"/>
</item> </item>
@ -46,7 +79,25 @@
<property name="title"> <property name="title">
<string>Channel B</string> <string>Channel B</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_5"> <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"> <item row="0" column="0">
<widget class="QComboBox" name="comboVB"/> <widget class="QComboBox" name="comboVB"/>
</item> </item>
@ -58,7 +109,25 @@
<property name="title"> <property name="title">
<string>Trigger</string> <string>Trigger</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout"> <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"> <item row="2" column="0">
<widget class="QComboBox" name="comboRissing"/> <widget class="QComboBox" name="comboRissing"/>
</item> </item>
@ -76,7 +145,25 @@
<property name="title"> <property name="title">
<string>Time Base</string> <string>Time Base</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_2"> <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"> <item row="0" column="0">
<widget class="QComboBox" name="comboTimeRange"/> <widget class="QComboBox" name="comboTimeRange"/>
</item> </item>
@ -99,7 +186,7 @@
<item> <item>
<widget class="QGroupBox" name="groupMarkers"> <widget class="QGroupBox" name="groupMarkers">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -107,29 +194,40 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>121</width> <width>121</width>
<height>61</height> <height>91</height>
</size> </size>
</property> </property>
<property name="title"> <property name="title">
<string>Markers</string> <string>Markers</string>
</property> </property>
<widget class="QWidget" name="layoutWidget"> <property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<widget class="QWidget" name="">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>12</x>
<y>30</y> <y>32</y>
<width>106</width> <width>96</width>
<height>25</height> <height>50</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="spacing"> <property name="spacing">
<number>0</number> <number>1</number>
</property> </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"> <widget class="QRadioButton" name="radio_a">
<property name="text"> <property name="text">
<string/> <string/>
@ -140,14 +238,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="1" column="1">
<widget class="QRadioButton" name="radio_b"> <widget class="QRadioButton" name="radio_b">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="src.qrc"> <iconset resource="src.qrc">
<normaloff>:/volt</normaloff>:/volt</iconset> <normaloff>:/volta</normaloff>:/volta</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -186,7 +284,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>966</width> <width>910</width>
<height>22</height> <height>22</height>
</rect> </rect>
</property> </property>

View file

@ -3,6 +3,7 @@
<qresource prefix="/" > <qresource prefix="/" >
<file alias="ico">ico.png</file> <file alias="ico">ico.png</file>
<file alias="time">time.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> </qresource>
</RCC> </RCC>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB