Skip to content

Commit

Permalink
Merge pull request #452 from drowe67/ms-hamlib-mode-fix
Browse files Browse the repository at this point in the history
Hamlib mode changes should happen based on new frequency
  • Loading branch information
tmiw committed Jun 26, 2023
2 parents ae4f331 + 94f7bd5 commit 0a9bf60
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion USER_MANUAL.html
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ <h2 data-number="17.1" id="v1.8.12-tbd-2023"><span class="header-section-number"
<li>Clear button now clears the callsign list. (PR #436)</li>
<li>Fix bug causing the PTT button to stay red after the voice keyer finishes TX. (PR #440)</li>
<li>Fix FreeDV Reporter crash when sending RX record. (PR #443)</li>
<li>Hamlib: set mode before frequency to avoid accidental offsetting. (PR #442)</li>
<li>Hamlib: set mode before frequency to avoid accidental offsetting. (PR #442, #452)</li>
<li>Fix audio dialog plot display and lockup issues. (PR #450)</li>
<li>Disable PTT and Voice Keyer buttons if only RX devices are configured. (PR #449)</li>
</ul></li>
Expand Down
2 changes: 1 addition & 1 deletion USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
* Clear button now clears the callsign list. (PR #436)
* Fix bug causing the PTT button to stay red after the voice keyer finishes TX. (PR #440)
* Fix FreeDV Reporter crash when sending RX record. (PR #443)
* Hamlib: set mode before frequency to avoid accidental offsetting. (PR #442)
* Hamlib: set mode before frequency to avoid accidental offsetting. (PR #442, #452)
* Fix audio dialog plot display and lockup issues. (PR #450)
* Disable PTT and Voice Keyer buttons if only RX devices are configured. (PR #449)
2. Enhancements:
Expand Down
Binary file modified USER_MANUAL.pdf
Binary file not shown.
10 changes: 5 additions & 5 deletions src/hamlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ Hamlib::Hamlib() :
m_vhfUhfMode(false),
pttSet_(false),
updatesSuppressed_(false),
threadRunning_(false),
readOnly_(false) {
readOnly_(false),
threadRunning_(false)
{
/* Stop hamlib from spewing info to stderr. */
rig_set_debug(RIG_DEBUG_NONE);

Expand Down Expand Up @@ -326,7 +327,7 @@ void Hamlib::disable_mode_detection()

}

void Hamlib::setMode(bool analog)
void Hamlib::setMode(bool analog, uint64_t frequencyHz)
{
if (m_rig == nullptr || pttSet_ || readOnly_)
{
Expand All @@ -335,7 +336,6 @@ void Hamlib::setMode(bool analog)
}

// Widest 60 meter allocation is 5.250-5.450 MHz per https://en.wikipedia.org/wiki/60-meter_band.
auto frequencyHz = get_frequency();
bool is60MeterBand = frequencyHz >= 5250000 && frequencyHz <= 5450000;

// Update color based on the mode and current frequency.
Expand Down Expand Up @@ -375,7 +375,7 @@ void Hamlib::setFrequencyAndMode(uint64_t frequencyHz, bool analog)
}

vfo_t currVfo = getCurrentVfo_();
setMode(analog);
setMode(analog, frequencyHz);
setFrequencyHelper_(currVfo, frequencyHz);
}

Expand Down
2 changes: 1 addition & 1 deletion src/hamlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Hamlib {
void enable_mode_detection(wxStaticText* statusBox, wxComboBox* freqBox, bool vhfUhfMode);
void disable_mode_detection();
void setFrequencyAndMode(uint64_t frequencyHz, bool analog);
void setMode(bool analog);
void setMode(bool analog, uint64_t frequencyHz);
void readOnly(bool readOnly) { readOnly_ = readOnly; }
void suppressFrequencyModeUpdates(bool suppress);
bool isSuppressFrequencyModeUpdates() const { return updatesSuppressed_; }
Expand Down
4 changes: 3 additions & 1 deletion src/ongui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,9 @@ void MainFrame::OnTogBtnAnalogClick (wxCommandEvent& event)
wxGetApp().m_boolHamlibEnableFreqModeChanges)
{
// Request mode change on the radio side
wxGetApp().m_hamlib->setMode(wxGetApp().m_boolHamlibUseAnalogModes ? true : g_analog);
wxGetApp().m_hamlib->setMode(
wxGetApp().m_boolHamlibUseAnalogModes ? true : g_analog,
wxGetApp().m_hamlib->get_frequency());
}

g_State = g_prev_State = 0;
Expand Down

0 comments on commit 0a9bf60

Please sign in to comment.