kopia lustrzana https://gitlab.com/eliggett/wfview
Calibration UI has basic functions. Reference set/get methods are good.
Still need to connect sliders to spinboxes so that the user can sense the value change.merge-requests/2/head
rodzic
fa50414138
commit
7b32bc97e6
|
@ -6,6 +6,12 @@ calibrationWindow::calibrationWindow(QWidget *parent) :
|
|||
ui(new Ui::calibrationWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->calCourseSlider->setDisabled(true);
|
||||
ui->calCourseSpinbox->setDisabled(true);
|
||||
|
||||
ui->calFineSlider->setDisabled(true);
|
||||
ui->calFineSpinbox->setDisabled(true);
|
||||
|
||||
}
|
||||
|
||||
calibrationWindow::~calibrationWindow()
|
||||
|
@ -15,10 +21,56 @@ calibrationWindow::~calibrationWindow()
|
|||
|
||||
void calibrationWindow::handleCurrentFreq(double tunedFreq)
|
||||
{
|
||||
|
||||
(void)tunedFreq;
|
||||
}
|
||||
|
||||
void calibrationWindow::handleSpectrumPeak(double peakFreq)
|
||||
{
|
||||
|
||||
(void)peakFreq;
|
||||
}
|
||||
|
||||
void calibrationWindow::handleRefAdjustCourse(unsigned char value)
|
||||
{
|
||||
ui->calCourseSlider->setDisabled(false);
|
||||
ui->calCourseSpinbox->setDisabled(false);
|
||||
|
||||
ui->calCourseSlider->blockSignals(true);
|
||||
ui->calCourseSpinbox->blockSignals(true);
|
||||
|
||||
ui->calCourseSlider->setValue((int) value);
|
||||
ui->calCourseSpinbox->setValue((int) value);
|
||||
|
||||
ui->calCourseSlider->blockSignals(false);
|
||||
ui->calCourseSpinbox->blockSignals(false);
|
||||
}
|
||||
|
||||
void calibrationWindow::handleRefAdjustFine(unsigned char value)
|
||||
{
|
||||
ui->calFineSlider->setDisabled(false);
|
||||
ui->calFineSpinbox->setDisabled(false);
|
||||
|
||||
ui->calFineSlider->blockSignals(true);
|
||||
ui->calFineSpinbox->blockSignals(true);
|
||||
|
||||
ui->calFineSlider->setValue((int) value);
|
||||
ui->calFineSpinbox->setValue((int) value);
|
||||
|
||||
ui->calFineSlider->blockSignals(false);
|
||||
ui->calFineSpinbox->blockSignals(false);
|
||||
}
|
||||
|
||||
void calibrationWindow::on_calReadRigCalBtn_clicked()
|
||||
{
|
||||
emit requestRefAdjustCourse();
|
||||
emit requestRefAdjustFine();
|
||||
}
|
||||
|
||||
void calibrationWindow::on_calCourseSlider_valueChanged(int value)
|
||||
{
|
||||
emit setRefAdjustCourse((unsigned char) value);
|
||||
}
|
||||
|
||||
void calibrationWindow::on_calFineSlider_valueChanged(int value)
|
||||
{
|
||||
emit setRefAdjustFine((unsigned char) value);
|
||||
}
|
||||
|
|
|
@ -18,10 +18,23 @@ public:
|
|||
public slots:
|
||||
void handleSpectrumPeak(double peakFreq);
|
||||
void handleCurrentFreq(double tunedFreq);
|
||||
void handleRefAdjustCourse(unsigned char);
|
||||
void handleRefAdjustFine(unsigned char);
|
||||
|
||||
signals:
|
||||
void requestSpectrumPeak(double peakFreq);
|
||||
void requestCurrentFreq(double tunedFreq);
|
||||
void requestRefAdjustCourse();
|
||||
void requestRefAdjustFine();
|
||||
void setRefAdjustCourse(unsigned char);
|
||||
void setRefAdjustFine(unsigned char);
|
||||
|
||||
private slots:
|
||||
void on_calReadRigCalBtn_clicked();
|
||||
|
||||
void on_calCourseSlider_valueChanged(int value);
|
||||
|
||||
void on_calFineSlider_valueChanged(int value);
|
||||
|
||||
private:
|
||||
Ui::calibrationWindow *ui;
|
||||
|
|
|
@ -130,6 +130,9 @@
|
|||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QSlider" name="calCourseSlider">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -137,6 +140,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="calFineSlider">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -186,10 +192,13 @@
|
|||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="calSaveSlotBtn">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Save the calibration data to the indicated slot in the preference file. </p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
|
@ -197,6 +206,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="calLoadSlotBtn">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Load the calibration data fromthe indicated slot in the preference file. </p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
|
|
101
rigcommander.cpp
101
rigcommander.cpp
|
@ -858,6 +858,26 @@ void rigCommander::setAfGain(unsigned char level)
|
|||
sendLevelCmd(0x01, level);
|
||||
}
|
||||
|
||||
void rigCommander::setRefAdjustCourse(unsigned char level)
|
||||
{
|
||||
// 1A 05 00 72 0000-0255
|
||||
QByteArray payload;
|
||||
payload.setRawData("\x1A\x05\x00\x72", 4);
|
||||
payload.append(bcdEncodeInt((unsigned int)level));
|
||||
prepDataAndSend(payload);
|
||||
|
||||
}
|
||||
|
||||
void rigCommander::setRefAdjustFine(unsigned char level)
|
||||
{
|
||||
qDebug() << __FUNCTION__ << " level: " << level;
|
||||
// 1A 05 00 73 0000-0255
|
||||
QByteArray payload;
|
||||
payload.setRawData("\x1A\x05\x00\x73", 4);
|
||||
payload.append(bcdEncodeInt((unsigned int)level));
|
||||
prepDataAndSend(payload);
|
||||
}
|
||||
|
||||
void rigCommander::sendLevelCmd(unsigned char levAddr, unsigned char level)
|
||||
{
|
||||
QByteArray payload("\x14");
|
||||
|
@ -876,6 +896,22 @@ void rigCommander::sendLevelCmd(unsigned char levAddr, unsigned char level)
|
|||
prepDataAndSend(payload);
|
||||
}
|
||||
|
||||
void rigCommander::getRefAdjustCourse()
|
||||
{
|
||||
// 1A 05 00 72
|
||||
QByteArray payload;
|
||||
payload.setRawData("\x1A\x05\x00\x72", 4);
|
||||
prepDataAndSend(payload);
|
||||
}
|
||||
|
||||
void rigCommander::getRefAdjustFine()
|
||||
{
|
||||
// 1A 05 00 73
|
||||
QByteArray payload;
|
||||
payload.setRawData("\x1A\x05\x00\x73", 4);
|
||||
prepDataAndSend(payload);
|
||||
}
|
||||
|
||||
void rigCommander::parseRegisters1C()
|
||||
{
|
||||
// PTT lives here
|
||||
|
@ -996,6 +1032,28 @@ void rigCommander::parseBandStackReg()
|
|||
void rigCommander::parseDetailedRegisters1A05()
|
||||
{
|
||||
// It seems a lot of misc stuff is under this command and subcommand.
|
||||
// 1A 05 ...
|
||||
// 00 01 02 03 04 ...
|
||||
|
||||
// 02 and 03 make up a BCD'd number:
|
||||
// 0001, 0002, 0003, ... 0101, 0102, 0103...
|
||||
|
||||
int subcmd = bcdHexToDecimal(payloadIn[3]) + (10*bcdHexToDecimal(payloadIn[2]));
|
||||
|
||||
switch(subcmd)
|
||||
{
|
||||
case 72:
|
||||
// course reference
|
||||
emit haveRefAdjustCourse( bcdHexToDecimal(payloadIn[5]) + (10*bcdHexToDecimal(payloadIn[6])) );
|
||||
break;
|
||||
case 73:
|
||||
// fine reference
|
||||
emit haveRefAdjustFine( bcdHexToDecimal(payloadIn[5]) + (10*bcdHexToDecimal(payloadIn[6])) );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void rigCommander::parseWFData()
|
||||
|
@ -1275,6 +1333,49 @@ unsigned char rigCommander::bcdHexToDecimal(unsigned char in)
|
|||
return out;
|
||||
}
|
||||
|
||||
unsigned char rigCommander::bcdHexToDecimal(unsigned char hundreds, unsigned char tensunits)
|
||||
{
|
||||
// convert:
|
||||
// hex data: 0x01 0x23
|
||||
// convert to uchar:
|
||||
// uchar: 123
|
||||
|
||||
// unsigned char thousands = hundreds / 100;
|
||||
unsigned char rtnVal;
|
||||
rtnVal = (hundreds & 0x0f)*100;
|
||||
rtnVal += ((tensunits & 0xf0)>>4)*10;
|
||||
rtnVal += (tensunits & 0x0f);
|
||||
|
||||
return rtnVal;
|
||||
}
|
||||
|
||||
QByteArray rigCommander::bcdEncodeInt(unsigned int num)
|
||||
{
|
||||
if(num > 9999)
|
||||
{
|
||||
qDebug() << __FUNCTION__ << "Error, number is too big for four-digit conversion: " << num;
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
char thousands = num / 1000;
|
||||
char hundreds = (num - (1000*thousands)) / 100;
|
||||
char tens = (num - (1000*thousands) - (100*hundreds)) / 10;
|
||||
char units = (num - (1000*thousands) - (100*hundreds) - (10*tens));
|
||||
|
||||
char b0 = hundreds | (thousands << 4);
|
||||
char b1 = units | (tens << 4);
|
||||
|
||||
qDebug() << __FUNCTION__ << " encoding value " << num << " as hex:";
|
||||
//printHex(QByteArray(b0), false, true);
|
||||
//printHex(QByteArray(b1), false, true);
|
||||
|
||||
|
||||
QByteArray result;
|
||||
result.append(b0).append(b1);
|
||||
qDebug() << "Result: " << result;
|
||||
return result;
|
||||
}
|
||||
|
||||
void rigCommander::parseFrequency()
|
||||
{
|
||||
// process payloadIn, which is stripped.
|
||||
|
|
|
@ -64,6 +64,10 @@ public slots:
|
|||
void getRigID();
|
||||
void findRigs();
|
||||
void setCIVAddr(unsigned char civAddr);
|
||||
void getRefAdjustCourse();
|
||||
void getRefAdjustFine();
|
||||
void setRefAdjustCourse(unsigned char level);
|
||||
void setRefAdjustFine(unsigned char level);
|
||||
void handleNewData(const QByteArray &data);
|
||||
void handleSerialPortError(const QString port, const QString errorText);
|
||||
void handleStatusUpdate(const QString text);
|
||||
|
@ -92,6 +96,9 @@ signals:
|
|||
void haveAfGain(unsigned char level);
|
||||
void haveSql(unsigned char level);
|
||||
void haveTxPower(unsigned char level);
|
||||
void thing();
|
||||
void haveRefAdjustCourse(unsigned char level);
|
||||
void haveRefAdjustFine(unsigned char level);
|
||||
void dataForComm(const QByteArray &outData);
|
||||
void getMoreDebug();
|
||||
void finished();
|
||||
|
@ -106,6 +113,8 @@ private:
|
|||
void parseData(QByteArray data); // new data come here
|
||||
void parseCommand();
|
||||
unsigned char bcdHexToDecimal(unsigned char in);
|
||||
unsigned char bcdHexToDecimal(unsigned char hundreds, unsigned char tensunits);
|
||||
QByteArray bcdEncodeInt(unsigned int);
|
||||
void parseFrequency();
|
||||
float parseFrequency(QByteArray data, unsigned char lastPosition); // supply index where Mhz is found
|
||||
QByteArray makeFreqPayload(double frequency);
|
||||
|
|
|
@ -292,6 +292,15 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
|||
connect(this, SIGNAL(sayFrequency()), rig, SLOT(sayFrequency()));
|
||||
connect(this, SIGNAL(sayMode()), rig, SLOT(sayMode()));
|
||||
|
||||
// calibration window:
|
||||
connect(cal, SIGNAL(requestRefAdjustCourse()), rig, SLOT(getRefAdjustCourse()));
|
||||
connect(cal, SIGNAL(requestRefAdjustFine()), rig, SLOT(getRefAdjustFine()));
|
||||
connect(rig, SIGNAL(haveRefAdjustCourse(unsigned char)), cal, SLOT(handleRefAdjustCourse(unsigned char)));
|
||||
connect(rig, SIGNAL(haveRefAdjustFine(unsigned char)), cal, SLOT(handleRefAdjustFine(unsigned char)));
|
||||
connect(cal, SIGNAL(setRefAdjustCourse(unsigned char)), rig, SLOT(setRefAdjustCourse(unsigned char)));
|
||||
connect(cal, SIGNAL(setRefAdjustFine(unsigned char)), rig, SLOT(setRefAdjustFine(unsigned char)));
|
||||
|
||||
|
||||
// Plot user interaction
|
||||
connect(plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(handlePlotDoubleClick(QMouseEvent*)));
|
||||
connect(wf, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(handleWFDoubleClick(QMouseEvent*)));
|
||||
|
|
Ładowanie…
Reference in New Issue