File indexing completed on 2024-04-28 15:09:53
0001 /* 0002 SPDX-FileCopyrightText: 2023 Jasem Mutlaq <mutlaqja@ikarustech.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "manualpulse.h" 0008 0009 namespace Ekos 0010 { 0011 ManualPulse::ManualPulse(QWidget *parent) : QDialog(parent) 0012 { 0013 setupUi(this); 0014 0015 connect(northPulseB, &QPushButton::clicked, this, [this]() 0016 { 0017 emit newSinglePulse(DEC_INC_DIR, pulseDuration->value(), DontCaptureAfterPulses); 0018 northPulseB->setEnabled(false); 0019 QTimer::singleShot(pulseDuration->value(), this, [this]() 0020 { 0021 northPulseB->setEnabled(true); 0022 }); 0023 }); 0024 0025 connect(southPulseB, &QPushButton::clicked, this, [this]() 0026 { 0027 emit newSinglePulse(DEC_DEC_DIR, pulseDuration->value(), DontCaptureAfterPulses); 0028 southPulseB->setEnabled(false); 0029 QTimer::singleShot(pulseDuration->value(), this, [this]() 0030 { 0031 southPulseB->setEnabled(true); 0032 }); 0033 }); 0034 0035 connect(westPulseB, &QPushButton::clicked, this, [this]() 0036 { 0037 emit newSinglePulse(RA_INC_DIR, pulseDuration->value(), DontCaptureAfterPulses); 0038 westPulseB->setEnabled(false); 0039 QTimer::singleShot(pulseDuration->value(), this, [this]() 0040 { 0041 westPulseB->setEnabled(true); 0042 }); 0043 }); 0044 0045 connect(eastPulseB, &QPushButton::clicked, this, [this]() 0046 { 0047 emit newSinglePulse(RA_DEC_DIR, pulseDuration->value(), DontCaptureAfterPulses); 0048 eastPulseB->setEnabled(false); 0049 QTimer::singleShot(pulseDuration->value(), this, [this]() 0050 { 0051 eastPulseB->setEnabled(true); 0052 }); 0053 }); 0054 0055 connect(resetB, &QPushButton::clicked, this, &ManualPulse::reset); 0056 } 0057 0058 void ManualPulse::reset() 0059 { 0060 m_LastCoord = SkyPoint(); 0061 raOffset->setText("0"); 0062 raOffset->setStyleSheet(QString()); 0063 deOffset->setText("0"); 0064 deOffset->setStyleSheet(QString()); 0065 } 0066 0067 void ManualPulse::setMountCoords(const SkyPoint &position) 0068 { 0069 if (m_LastCoord.ra().Degrees() < 0) 0070 { 0071 m_LastCoord = position; 0072 return; 0073 } 0074 0075 auto raDiff = position.ra().deltaAngle(m_LastCoord.ra()).Degrees() * 3600; 0076 auto deDiff = position.dec().deltaAngle(m_LastCoord.dec()).Degrees() * 3600; 0077 0078 if (raDiff > 0) 0079 raOffset->setStyleSheet("color:green"); 0080 else if (raDiff < 0) 0081 raOffset->setStyleSheet("color:red"); 0082 0083 if (deDiff > 0) 0084 deOffset->setStyleSheet("color:green"); 0085 else if (deDiff < 0) 0086 deOffset->setStyleSheet("color:red"); 0087 0088 raOffset->setText(QString::number(raDiff, 'f', 2)); 0089 deOffset->setText(QString::number(deDiff, 'f', 2)); 0090 } 0091 }