mirror of
https://github.com/Hamlib/Hamlib.git
synced 2024-09-23 03:17:23 +00:00
Add detection of VFO twiddling
In the case of gpredict there are times when one has to adjust the VFO to dial in a frequency while gpredict is tracking. We now detect this situation and have a 3-second delay every time VFO twiddling is detected. set_freq and set_vfo calls will be ignored during this delay. May make this a settable value if needed.
This commit is contained in:
parent
1550a04716
commit
95986b9685
@ -27,6 +27,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
|
||||
/* Rig list is in a separate file so as not to mess up w/ this one */
|
||||
#include <hamlib/riglist.h>
|
||||
@ -1784,8 +1785,8 @@ struct rig_state {
|
||||
int transmit; /*!< rig should be transmitting i.e. hard
|
||||
wired PTT asserted - used by rigs that
|
||||
don't do CAT while in Tx */
|
||||
freq_t lo_freq; /*!< Local oscillator frequency of any
|
||||
transverter */
|
||||
freq_t lo_freq; /*!< Local oscillator frequency of any transverter */
|
||||
time_t twiddling; /*!< time when vfo twiddling was detected */
|
||||
};
|
||||
|
||||
|
||||
|
38
src/rig.c
38
src/rig.c
@ -1042,6 +1042,34 @@ int HAMLIB_API rig_cleanup(RIG *rig)
|
||||
}
|
||||
|
||||
|
||||
// detect if somebody is twiddling the VFO
|
||||
// indicator is last set freq doesn't match current freq
|
||||
// so we have to query freq every time we set freq or vfo to handle this
|
||||
static int twiddling(RIG *rig)
|
||||
{
|
||||
const struct rig_caps *caps;
|
||||
|
||||
caps = rig->caps;
|
||||
|
||||
if ( caps->get_freq) { // gotta have get_freq of course
|
||||
freq_t curr_freq = 0;
|
||||
int retval2;
|
||||
int elapsed;
|
||||
|
||||
retval2 = caps->get_freq(rig, RIG_VFO_CURR, &curr_freq);
|
||||
if (retval2 == RIG_OK && rig->state.current_freq != curr_freq) {
|
||||
rig_debug(RIG_DEBUG_TRACE,"%s: Somebody twiddling the VFO? last_freq=%.0f, curr_freq=%.0f\n", __func__, rig->state.current_freq, curr_freq);
|
||||
rig->state.twiddling = time(NULL); // update last twiddle time
|
||||
}
|
||||
elapsed = time(NULL) - rig->state.twiddling;
|
||||
if (elapsed < 3) {
|
||||
rig_debug(RIG_DEBUG_TRACE,"%s: Twiddle elapsed < 3, elapsed=%d\n", __func__, elapsed);
|
||||
return 1; // would be better as error but other software won't handle it
|
||||
}
|
||||
}
|
||||
return 0; //
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set the frequency of the target VFO
|
||||
* \param rig The rig handle
|
||||
@ -1108,6 +1136,11 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
return retcode;
|
||||
}
|
||||
|
||||
if (twiddling(rig)) {
|
||||
rig_debug(RIG_DEBUG_TRACE,"%s: Ignoring set_freq due to VFO twiddling\n", __func__);
|
||||
return RIG_OK; // would be better as error but other software won't handle errors
|
||||
}
|
||||
|
||||
retcode = caps->set_freq(rig, vfo, freq);
|
||||
/* try and revert even if we had an error above */
|
||||
rc2 = caps->set_vfo(rig, curr_vfo);
|
||||
@ -1571,6 +1604,11 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
||||
return -RIG_ENAVAIL;
|
||||
}
|
||||
|
||||
if (twiddling(rig)) {
|
||||
rig_debug(RIG_DEBUG_TRACE,"%s: Ignoring set_vfo due to VFO twiddling\n", __func__);
|
||||
return RIG_OK; // would be better as error but other software won't handle errors
|
||||
}
|
||||
|
||||
retcode = caps->set_vfo(rig, vfo);
|
||||
|
||||
if (retcode == RIG_OK)
|
||||
|
Loading…
Reference in New Issue
Block a user