Bring back original freq/mode restore behavior.
parent
82ce80eb89
commit
3c132eea6a
|
|
@ -315,7 +315,8 @@ bool MainFrame::OpenHamlibRig() {
|
|||
{
|
||||
wxGetApp().m_hamlib = std::make_shared<HamlibRigController>(
|
||||
rig, (const char*)port.mb_str(wxConvUTF8), serial_rate, wxGetApp().appConfiguration.rigControlConfiguration.hamlibIcomCIVAddress,
|
||||
pttType, pttType == HamlibRigController::PTT_VIA_CAT || pttType == HamlibRigController::PTT_VIA_NONE ? (const char*)port.mb_str(wxConvUTF8) : (const char*)pttPort.mb_str(wxConvUTF8));
|
||||
pttType, pttType == HamlibRigController::PTT_VIA_CAT || pttType == HamlibRigController::PTT_VIA_NONE ? (const char*)port.mb_str(wxConvUTF8) : (const char*)pttPort.mb_str(wxConvUTF8),
|
||||
wxGetApp().appConfiguration.rigControlConfiguration.hamlibEnableFreqModeChanges);
|
||||
|
||||
wxGetApp().m_hamlib->onRigError += [this](IRigController*, std::string err)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ bool HamlibRigController::RigCompare_(const struct rig_caps *rig1, const struct
|
|||
return rig1->rig_model < rig2->rig_model;
|
||||
}
|
||||
|
||||
HamlibRigController::HamlibRigController(std::string rigName, std::string serialPort, const int serialRate, const int civHex, const PttType pttType, std::string pttSerialPort)
|
||||
HamlibRigController::HamlibRigController(std::string rigName, std::string serialPort, const int serialRate, const int civHex, const PttType pttType, std::string pttSerialPort, bool restoreFreqModeOnDisconnect)
|
||||
: rigName_(rigName)
|
||||
, serialPort_(serialPort)
|
||||
, serialRate_(serialRate)
|
||||
|
|
@ -65,12 +65,15 @@ HamlibRigController::HamlibRigController(std::string rigName, std::string serial
|
|||
, pttSet_(false)
|
||||
, currFreq_(0)
|
||||
, currMode_(0)
|
||||
, restoreOnDisconnect_(restoreFreqModeOnDisconnect)
|
||||
, origFreq_(0)
|
||||
, origMode_(0)
|
||||
{
|
||||
// Perform initial load of rig list if this is our first time being created.
|
||||
InitializeHamlibLibrary();
|
||||
}
|
||||
|
||||
HamlibRigController::HamlibRigController(int rigIndex, std::string serialPort, const int serialRate, const int civHex, const PttType pttType, std::string pttSerialPort)
|
||||
HamlibRigController::HamlibRigController(int rigIndex, std::string serialPort, const int serialRate, const int civHex, const PttType pttType, std::string pttSerialPort, bool restoreFreqModeOnDisconnect)
|
||||
: rigName_(RigIndexToName(rigIndex))
|
||||
, serialPort_(serialPort)
|
||||
, serialRate_(serialRate)
|
||||
|
|
@ -80,6 +83,9 @@ HamlibRigController::HamlibRigController(int rigIndex, std::string serialPort, c
|
|||
, rig_(nullptr)
|
||||
, multipleVfos_(false)
|
||||
, pttSet_(false)
|
||||
, restoreOnDisconnect_(restoreFreqModeOnDisconnect)
|
||||
, origFreq_(0)
|
||||
, origMode_(0)
|
||||
{
|
||||
// Perform initial load of rig list if this is our first time being created.
|
||||
InitializeHamlibLibrary();
|
||||
|
|
@ -213,6 +219,9 @@ void HamlibRigController::connectImpl_()
|
|||
}
|
||||
|
||||
/* Initialise, configure and open. */
|
||||
origFreq_ = 0;
|
||||
origMode_ = 0;
|
||||
|
||||
rig_ = rig_init(RigList_[rigIndex]->rig_model);
|
||||
if (!rig_)
|
||||
{
|
||||
|
|
@ -303,6 +312,17 @@ void HamlibRigController::disconnectImpl_()
|
|||
pttImpl_(false);
|
||||
}
|
||||
|
||||
// If we're told to restore on disconnect, do so.
|
||||
if (restoreOnDisconnect_)
|
||||
{
|
||||
vfo_t currVfo = getCurrentVfo_();
|
||||
setFrequencyHelper_(currVfo, origFreq_);
|
||||
setModeHelper_(currVfo, origMode_);
|
||||
}
|
||||
|
||||
origFreq_ = 0;
|
||||
origMode_ = 0;
|
||||
|
||||
rig_close(rig_);
|
||||
rig_cleanup(rig_);
|
||||
rig_ = nullptr;
|
||||
|
|
@ -529,6 +549,14 @@ freqAttempt:
|
|||
break;
|
||||
}
|
||||
|
||||
// If this is the first time we're retrieving the current frequency/mode,
|
||||
// store it for later restore on disconnect.
|
||||
if (origFreq_ == 0)
|
||||
{
|
||||
origFreq_ = freq;
|
||||
origMode_ = mode;
|
||||
}
|
||||
|
||||
onFreqModeChange(this, freq, currMode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ public:
|
|||
PTT_VIA_NONE,
|
||||
};
|
||||
|
||||
HamlibRigController(std::string rigName, std::string serialPort, const int serialRate, const int civHex = 0, const PttType pttType = PTT_VIA_CAT, std::string pttSerialPort = std::string());
|
||||
HamlibRigController(int rigIndex, std::string serialPort, const int serialRate, const int civHex = 0, const PttType pttType = PTT_VIA_CAT, std::string pttSerialPort = std::string());
|
||||
HamlibRigController(std::string rigName, std::string serialPort, const int serialRate, const int civHex = 0, const PttType pttType = PTT_VIA_CAT, std::string pttSerialPort = std::string(), bool restoreFreqModeOnDisconnect = false);
|
||||
HamlibRigController(int rigIndex, std::string serialPort, const int serialRate, const int civHex = 0, const PttType pttType = PTT_VIA_CAT, std::string pttSerialPort = std::string(), bool restoreFreqModeOnDisconnect = false);
|
||||
virtual ~HamlibRigController();
|
||||
|
||||
virtual void connect() override;
|
||||
|
|
@ -79,6 +79,9 @@ private:
|
|||
bool pttSet_;
|
||||
uint64_t currFreq_;
|
||||
rmode_t currMode_;
|
||||
bool restoreOnDisconnect_;
|
||||
uint64_t origFreq_;
|
||||
rmode_t origMode_;
|
||||
|
||||
vfo_t getCurrentVfo_();
|
||||
void setFrequencyHelper_(vfo_t currVfo, uint64_t frequencyHz);
|
||||
|
|
|
|||
Loading…
Reference in New Issue