Compare commits

..

3 commits

Author SHA1 Message Date
Kizarm
61ffa12988 settings 2024-11-12 13:39:05 +01:00
Kizarm
ada1425d83 short vertical lines 2024-11-11 14:30:24 +01:00
Kizarm
73d4e43f97 edit colors 2024-11-11 11:42:01 +01:00
2 changed files with 25 additions and 56 deletions

View file

@ -8,10 +8,8 @@
#include "helpers.h"
static const double TimeBaseSteps [] = {
2.0e-6, 5.0e-6, 1.0e-5, 2.0e-5, 5.0e-5, 1.0e-4, 2.0e-4, 5.0e-4,
1.0e-3, 2.0e-3, 5.0e-3, 1.0e-2, 2.0e-2, 5.0e-2, 1.0e-1, 2.0e-1,
5.0e-1, 1.0,
2.0e-6, 5.0e-6, 1.0e-5, 2.0e-5, 5.0e-5, 1.0e-4, 2.0e-4, 5.0e-4, 1.0e-3,
2.0e-3, 5.0e-3, 1.0e-2, 2.0e-2, 5.0e-2, 1.0e-1, 2.0e-1, 5.0e-1, 1.0,
};
static const double ChannelsSteps [] = {
0.1, 0.2, 0.5,
@ -189,7 +187,6 @@ void DisplayWidget::reloadData () {
const QPointF pta (m_timeCount, ACopy [0]), ptb (m_timeCount, BCopy [0]);
ChA[m_timeCount] = pta;
ChB[m_timeCount] = ptb;
// printf("mode continuum\n");
m_timeCount += 1u;
m_timeCount &= T_MASK;
return;
@ -217,14 +214,6 @@ void DisplayWidget::reloadMatrix(const QSize & sz) {
m_forward = tm;
m_inverse = m_forward.inverted();
}
/*
void DisplayWidget::Refresh(int n) {
m_timeBase = n;
reloadMatrix (size());
drawBackground();
update();
}
*/
void DisplayWidget::TimeBaseRange(int n) {
m_timeBase = n;
reloadMatrix (size());
@ -262,20 +251,24 @@ void DisplayWidget::drawBackground() {
// triger
const double ofs = (m_TrgSource ? m_offset.b : m_offset.a) - HALF_Y;
QPointF trg (m_ts->offset, m_ts->value + ofs);
QPen pc (QColor(0,0,255), 1);
QPen pc (QColor(0,128,255), 1);
p.setPen(pc);
const QLineF hline (xb, trg.y(), xe, trg.y());
const QLineF vline (trg.x(), -ye, trg.x(), ye);
p.drawLine (m_forward.map(hline));
p.drawLine (m_forward.map(vline));
const qreal pos = 30.0;
const QLineF hline = m_forward.map(QLine(xb, trg.y(), xe, trg.y()));
const QLineF vline = m_forward.map(QLine(trg.x(), -ye, trg.x(), ye));
QPointF vb = vline.p1() + QPointF(0,-pos), ve = vline.p2() + QPointF(0,+pos);
p.drawLine (hline);
p.drawLine (QLineF(vb,ve));
// markers
QPen pm (QColor(255,255,0,196), 1);
p.setPen(pm);
if (marker_type == MARKER_TIME) {
const QLineF ma (m_time.a, -ye, m_time.a, ye);
const QLineF mb (m_time.b, -ye, m_time.b, ye);
p.drawLine (m_forward.map(ma));
p.drawLine (m_forward.map(mb));
const QLineF ma = m_forward.map(QLine (m_time.a, -ye, m_time.a, ye));
const QLineF mb = m_forward.map(QLine (m_time.b, -ye, m_time.b, ye));
vb = ma.p1() + QPointF(0,-pos), ve = ma.p2() + QPointF(0,+pos);
p.drawLine (QLineF(vb, ve));
vb = mb.p1() + QPointF(0,-pos), ve = mb.p2() + QPointF(0,+pos);
p.drawLine (QLineF(vb, ve));
} else {
const QLineF ma (xb, m_volt.a, xe, m_volt.a);
const QLineF mb (xb, m_volt.b, xe, m_volt.b);
@ -285,12 +278,15 @@ void DisplayWidget::drawBackground() {
// offsets
QPen ofpen(pcol.colA);
QVector<qreal>dashes;
dashes << 5 << 5 << 1 << 5;
const qreal gap = 10;
dashes << gap << gap;
ofpen.setDashPattern(dashes);
p.setPen (ofpen);
const QLineF oa (xb, m_offset.a, xe, m_offset.a);
p.drawLine (m_forward.map(oa));
ofpen.setColor(pcol.colB);
ofpen.setDashPattern(dashes);
ofpen.setDashOffset(gap);
p.setPen (ofpen);
const QLineF ob (xb, m_offset.b, xe, m_offset.b);
p.drawLine (m_forward.map(ob));
@ -341,15 +337,20 @@ void DisplayWidget::reloadChRange(int a, int b) {
}
void DisplayWidget::saveSettings(QSettings & setting) {
setting.setValue("TimeBaseIndex", m_timeBase);
setting.setValue("TimeA", m_time.a);
setting.setValue("TimeB", m_time.b);
setting.setValue("VoltA", m_volt.a);
setting.setValue("VoltB", m_volt.b);
setting.setValue("OfsA" , m_offset.a);
setting.setValue("OfsB" , m_offset.b);
}
void DisplayWidget::restSettings(QSettings & setting) {
m_time.a = setting.value("TimeA").toDouble();
m_time.b = setting.value("TimeB").toDouble();
m_volt.a = setting.value("VoltA").toDouble();
m_volt.b = setting.value("VoltB").toDouble();
m_offset.a = setting.value("OfsA").toDouble();
m_offset.b = setting.value("OfsB").toDouble();
drawBackground();
update();
}

View file

@ -124,10 +124,6 @@ void MainWindow::SendVoltageB(int n) {
void MainWindow::SendTrigerMode (int n) {
if (n == TRIGER_MODE_SINGLE) ui->buttonStart->setEnabled(true);
else ui->buttonStart->setEnabled(false);
/*
if (n == TRIGER_MODE_AUTO) ui->comboTimeRange->setEnabled(true); // BUG - jinak dojde při přepínání k chybě
else ui->comboTimeRange->setEnabled(false); // fixed
*/
firmware.SendTrigerMode(n);
}
void MainWindow::SendTrigerEdge (int n) {
@ -159,14 +155,6 @@ void MainWindow::ExportImage (bool) {
void MainWindow::SaveSettings(bool) {
qDebug ("Save Settings");
QSettings setting ("Kizarm", "Scope");
setting.beginGroup("Trigger");
const TrigerSettings * const ts = firmware.getTrigger();
setting.setValue("Value", ts->value);
setting.setValue("Offset", ts->offset);
setting.setValue("Mode", ts->mode);
setting.setValue("Channel", ts->channel);
setting.setValue("Edge", ts->rising);
setting.endGroup();
setting.beginGroup("Markers");
ui->Display->saveSettings (setting);
setting.endGroup();
@ -174,28 +162,8 @@ void MainWindow::SaveSettings(bool) {
void MainWindow::RestSettings(bool) {
qDebug ("Restore Settings");
QSettings setting ("Kizarm", "Scope");
setting.beginGroup("Trigger");
TrigerSettings ts;
ts.value = setting.value ("Value").toInt();
ts.offset = setting.value ("Offset").toInt();
ts.mode = static_cast<TRIGER_MODE> (setting.value ("Mode").toInt());
ui->comboMode->setCurrentIndex(ts.mode);
ts.channel = static_cast<ADC_CHANNELS> (setting.value ("Channel").toInt());
ui->comboChannel->setCurrentIndex(ts.channel);
ts.rising = setting.value ("Edge").toBool();
ui->comboRissing->setCurrentIndex(ts.value ? 1 : 0);
memcpy (firmware.getTrigger(), & ts, sizeof(TrigerSettings));
setting.endGroup();
SendTrigerMode (ts.mode);
firmware.SettingChanged(MOVE_VALUE);
firmware.SettingChanged(MOVE_OFSET);
setting.beginGroup("Markers");
ui->Display->restSettings (setting);
const int n = setting.value("TimeBaseIndex").toInt();
TimeBaseRange(n);
ui->comboTimeRange->setCurrentIndex(n);
setting.endGroup();
}