kopia lustrzana https://github.com/Hamlib/Hamlib
apply astyle and add frequency rounding
rodzic
9c1cc8d4ce
commit
920e0f8c19
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "kenwood.h"
|
||||
|
@ -161,6 +162,20 @@ int thd74_open(RIG *rig)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int thd74_round_fm_freq(freq_t freq)
|
||||
{
|
||||
int64_t f;
|
||||
long double r;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
||||
|
||||
f = (int64_t)freq;
|
||||
r = round(f / 5000.0);
|
||||
r = 5000 * r;
|
||||
|
||||
return (freq_t)r;
|
||||
}
|
||||
|
||||
static int thd74_set_vfo(RIG *rig, vfo_t vfo)
|
||||
{
|
||||
const char *cmd;
|
||||
|
@ -325,6 +340,7 @@ static int thd74_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
if (priv->split == RIG_SPLIT_ON)
|
||||
{
|
||||
vfo = RIG_VFO_B;
|
||||
freq = thd74_round_fm_freq(freq);
|
||||
}
|
||||
|
||||
retval = thd74_get_freq_info(rig, vfo, buf);
|
||||
|
@ -1261,7 +1277,9 @@ int thd74_set_split_vfo (RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
||||
|
||||
if (txvfo != RIG_VFO_A)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
priv->split = split;
|
||||
|
||||
|
@ -1275,9 +1293,13 @@ int thd74_get_split_vfo (RIG *rig, vfo_t vfo, split_t *split, vfo_t *txvfo)
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
||||
|
||||
if (priv->split == RIG_SPLIT_ON)
|
||||
{
|
||||
*txvfo = RIG_VFO_A;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -1295,9 +1317,13 @@ int thd74_get_split_freq (RIG *rig, vfo_t vfo, freq_t *tx_freq)
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
||||
|
||||
if (priv->split == RIG_SPLIT_ON)
|
||||
{
|
||||
vfo = RIG_VFO_A;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
retval = thd74_get_freq_info(rig, vfo, buf);
|
||||
|
||||
|
@ -1322,17 +1348,21 @@ int thd74_set_split_freq (RIG *rig, vfo_t vfo, freq_t tx_freq)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
||||
|
||||
if (priv->split == RIG_SPLIT_ON) {
|
||||
if (priv->split == RIG_SPLIT_ON)
|
||||
{
|
||||
retval = thd74_get_freq_info(rig, RIG_VFO_A, buf);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
tx_freq = thd74_round_fm_freq(tx_freq);
|
||||
sprintf(fbuf, "%010"PRIll, (int64_t)tx_freq);
|
||||
memcpy(buf + 5, fbuf, 10);
|
||||
return kenwood_simple_transaction(rig, buf, 72);
|
||||
}
|
||||
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue