Beispiel #1
0
static int icom_swap_bands(RIG* rig) {
    /* TODO: actually use retval! */
    int retval=0;
    rmode_t mmode, smode;        /* used to store the mode */
    pbwidth_t mwidth, swidth;    /* used to store the width */
    value_t mpreamp, spreamp;    /* used to store preamp */
    value_t matt, satt;          /* used to store attenuation */

    /* main band get values */
    icom_set_vfo(rig, RIG_VFO_MAIN);
    /* get the mode, width, preamp */
    icom_get_mode(rig, RIG_VFO_CURR, &mmode, &mwidth);
    icom_get_level(rig, RIG_VFO_CURR, RIG_LEVEL_PREAMP, &mpreamp);
    icom_get_level(rig, RIG_VFO_CURR, RIG_LEVEL_ATT, &matt);

    /* sub band get values */
    icom_set_vfo(rig, RIG_VFO_SUB);
    /* get the mode, width, preamp, att */
    icom_get_mode(rig, RIG_VFO_CURR, &smode, &swidth);
    icom_get_level(rig, RIG_VFO_CURR, RIG_LEVEL_PREAMP, &spreamp);
    icom_get_level(rig, RIG_VFO_CURR, RIG_LEVEL_ATT, &satt);

    /* now, we can exchange the bands */
    icom_vfo_op(rig, RIG_VFO_CURR, RIG_OP_XCHG);

    /* restore the sub vales NOTE: sub band is still active */
    /* set the mode, width, preamp */
    icom_set_mode(rig, RIG_VFO_CURR, smode, swidth);
    icom_set_level(rig, RIG_VFO_CURR, RIG_LEVEL_PREAMP, spreamp);
    icom_set_level(rig, RIG_VFO_CURR, RIG_LEVEL_ATT, satt);

    /* restore main band values */
    icom_set_vfo(rig, RIG_VFO_MAIN);
    /* set the mode, width, preamp */
    icom_set_mode(rig, RIG_VFO_CURR, mmode, mwidth);
    icom_set_level(rig, RIG_VFO_CURR, RIG_LEVEL_PREAMP, mpreamp);
    icom_set_level(rig, RIG_VFO_CURR, RIG_LEVEL_ATT, matt);

    return retval;
}
Beispiel #2
0
/*
 * IC-7800 has 0x11 command using index instead of backend's real dB value
 *
 * c.f. http://www.plicht.de/ekki/civ/civ-p42.html
 */
int ic7800_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
    int i;

    if (level == RIG_LEVEL_ATT && val.i != 0) {
        /* Convert dB to index */
        for (i=0; i < 7; i++) {
            if (val.i == rig->state.attenuator[i]) {
                val.i = i+1;
                break;
            }
        }
        /* TODO: Should fail when not found? */
    }

    return icom_set_level(rig, vfo, level, val);
}