Logo Search packages:      
Sourcecode: hamlib version File versions

static int tt565_set_level ( RIG rig,
vfo_t  vfo,
setting_t  level,
value_t  val 
)

Sets any of Orion's "Level" adjustments.

Parameters:
rig must != NULL
vfo 
level A level id token, e.g. RIG_LEVEL_AF
val Value for the level, on a scale or via a token
Returns:
RIG_OK or < 0 Unfortunately, "val" type is not well defined. Sometimes it is a float (AF gain), an integer (RF Atten.), or an enum (RIG_AGC_FAST)...
Supported Levels and Units
-RIG_LEVEL_RFPOWER, float 0.0 - 1.0
-RIG_LEVEL_AGC, int RIG_AGC_x, x= OFF, FAST, MEDIUM, SLOW, USER
-RIG_LEVEL_AF, float 0.0 - 1.0
-RIG_LEVEL_IF, passband tuning, int Hz
-RIG_LEVEL_RF, IF gain (!), float 0.0 - 1.0
-RIG_LEVEL_ATT, Atten. setting, int dB (we pick 0, 6, 12, or 18 dB)
-RIG_LEVEL_PREAMP, Preamp on/off, 0-1 (main Rx only)
-RIG_LEVEL_SQL, squelch, float 0.0 - 1.0
-RIG_LEVEL_MICGAIN, float 0.0 - 1.0
-RIG_LEVEL_COMP, speech compression, float 0.0 - 1.0
-RIG_LEVEL_CWPITCH, int Hz
-RIG_LEVEL_KEYSPD, int wpm
-RIG_LEVEL_NR, noise reduction/blank, float 0.0 - 1.0
-RIG_LEVEL_VOX, vox delay, float x 1/10 second
-RIG_LEVEL_VOXGAIN, float 0.0 - 1.0
-RIG_LEVEL_ANTIVOX, float 0.0 - 1.0


FIXME: cannot support PREAMP and ATT both at same time (make sens though)

Definition at line 930 of file orion.c.

References rig_caps::attenuator, rig::caps, EOM, value_t::f, value_t::i, RIG_AGC_USER, rig_debug(), RIG_DEBUG_ERR, RIG_EINVAL, RIG_LEVEL_AF, RIG_LEVEL_AGC, RIG_LEVEL_ANTIVOX, RIG_LEVEL_ATT, RIG_LEVEL_COMP, RIG_LEVEL_CWPITCH, RIG_LEVEL_IF, RIG_LEVEL_KEYSPD, RIG_LEVEL_MICGAIN, RIG_LEVEL_NR, RIG_LEVEL_PREAMP, RIG_LEVEL_RF, RIG_LEVEL_RFPOWER, RIG_LEVEL_SQL, RIG_LEVEL_VOX, RIG_LEVEL_VOXGAIN, TT565_CW_MAX, TT565_CW_MIN, TT565_TONE_MAX, TT565_TONE_MIN, tt565_transaction(), and which_receiver().

{
      int retval, cmd_len=0, ii;
      char cmdbuf[TT565_BUFSIZE], cc;

      switch (level) {
      case RIG_LEVEL_RFPOWER:
            cmd_len = sprintf(cmdbuf, "*TP%d" EOM, 
                        (int)(val.f*100));
            break;

      case RIG_LEVEL_AGC:
            switch(val.i) {
            case RIG_AGC_OFF:    cc = 'O'; break;
            case RIG_AGC_FAST:   cc = 'F'; break;
            case RIG_AGC_MEDIUM: cc = 'M'; break;
            case RIG_AGC_SLOW:   cc = 'S'; break;
            case RIG_AGC_USER:   cc = 'P'; break;
            default: cc = 'M';
            }
            cmd_len = sprintf(cmdbuf, "*R%cA%c" EOM,
                  which_receiver(rig, vfo),
                  cc);
            break;

      case RIG_LEVEL_AF:
        /* AF Gain, float 0.0 - 1.0 */
            cmd_len = sprintf(cmdbuf, "*U%c%d" EOM,
                        which_receiver(rig, vfo),
                        (int)(val.f*255));
            break;

      case RIG_LEVEL_IF:
        /* This is passband tuning int Hz */
            cmd_len = sprintf(cmdbuf, "*R%cP%d" EOM,
                        which_receiver(rig, vfo),
                        val.i);
            break;

      case RIG_LEVEL_RF:
        /* This is IF Gain, float 0.0 - 1.0 */
            cmd_len = sprintf(cmdbuf, "*R%cG%d" EOM,
                        which_receiver(rig, vfo),
                        (int)(val.f*100));
            break;

      case RIG_LEVEL_ATT:
        /* RF Attenuator, int dB */
            ii = -1;    /* Request 0-5 dB -> 0, 6-11 dB -> 6, etc. */
            while ( rig->caps->attenuator[++ii] != RIG_DBLST_END ) {
                  if (rig->caps->attenuator[ii] > val.i) break;
            }
            
            cmd_len = sprintf(cmdbuf, "*R%cT%d" EOM,
                        which_receiver(rig, vfo),
                        ii);
            break;

      case RIG_LEVEL_PREAMP:
            /* Sub receiver does not contain a Preamp */
            if (which_receiver(rig, vfo) == 'S') {
                  return -RIG_EINVAL;
            }
        /* RF Preamp (main Rx), int 0 or 1 */
            cmd_len = sprintf(cmdbuf, "*RME%d" EOM,
                        val.i==0 ? 0 : 1);
            break;

      case RIG_LEVEL_SQL:
        /* Squelch level, float 0.0 - 1.0 */
            cmd_len = sprintf(cmdbuf, "*R%cS%d" EOM,
                        which_receiver(rig, vfo),
                        (int)((val.f*127)-127));
            break;

      case RIG_LEVEL_MICGAIN:
        /* Mic gain, float 0.0 - 1.0 */
            cmd_len = sprintf(cmdbuf, "*TM%d" EOM, 
                        (int)(val.f*100));
            break;

      case RIG_LEVEL_COMP:
        /* Speech Processor, float 0.0 - 1.0 */
            cmd_len = sprintf(cmdbuf, "*TS%d" EOM, 
                        (int)(val.f*9));
            break;

      case RIG_LEVEL_CWPITCH:
            /* "CWPITCH" is the "Tone" button on the Orion.
               Manual menu adjustment works down to 100 Hz, but not via
               computer. int Hz.
            */
            if (val.i > TT565_TONE_MAX) val.i = TT565_TONE_MAX;
            else if (val.i < TT565_TONE_MIN) val.i = TT565_TONE_MIN;
            cmd_len = sprintf(cmdbuf, "*CT%d" EOM, 
                val.i);
            break;

      case RIG_LEVEL_KEYSPD:
            /* Keyer speed setting does not imply Keyer = "on".  That is a
               command which should be a hamlib function, but is not.
               Keyer speed determines the rate of computer sent CW also.
            */
            if (val.i > TT565_CW_MAX) val.i = TT565_CW_MAX;
            else if (val.i < TT565_CW_MIN) val.i = TT565_CW_MIN;
            cmd_len = sprintf(cmdbuf, "*CS%d" EOM,
                        val.i);
            break;

      case RIG_LEVEL_NR:
            /* Noise Reduction (blanking) Float 0.0 - 1.0
            For some reason NB setting is supported in 1.372, but
               NR, NOTCH, and AN are not. 
               FOR NOW -- RIG_LEVEL_NR controls the Orion NB setting 
            */
            cmd_len = sprintf(cmdbuf, "*R%cNB%d" EOM,
                        which_receiver(rig, vfo),
                        (int)(val.f*9));
            break;

      case RIG_LEVEL_VOX:     
        /* VOX delay, float tenths of seconds */
            cmd_len = sprintf(cmdbuf, "*TH%4.2f" EOM, 0.1*val.f);
            break;

      case RIG_LEVEL_VOXGAIN: 
        /* Float, 0.0 - 1.0 */
            cmd_len = sprintf(cmdbuf, "*TG%d" EOM, (int)(100.0*val.f));
            break;

      case RIG_LEVEL_ANTIVOX:
        /* Float, 0.0 - 1.0 */
            cmd_len = sprintf(cmdbuf, "*TA%d" EOM, (int)(100.0*val.f));
            break;

      default:
            rig_debug(RIG_DEBUG_ERR,"%s: unsupported level %d\n",
                        __FUNCTION__, level);
            return -RIG_EINVAL;
      }

      retval = tt565_transaction (rig, cmdbuf, cmd_len, NULL,NULL);
      return retval;
}


Generated by  Doxygen 1.6.0   Back to index