]> git.rkrishnan.org Git - dttsp.git/blobdiff - jDttSP/update.c
Major changes. Added metering and power spectrum, other fixes. Rearranged headers...
[dttsp.git] / jDttSP / update.c
index cb6ae7a54c6f90df5dfe9097fd37497948c832d2..833366b80fdb3db269c72a3f24b49cacc68c080a 100644 (file)
@@ -4,7 +4,7 @@ common defs and code for parm update
    
 This file is part of a program that implements a Software-Defined Radio.
 
-Copyright (C) 2004 by Frank Brickle, AB2KT and Bob McGwier, N4HY
+Copyright (C) 2004-5 by Frank Brickle, AB2KT and Bob McGwier, N4HY
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -141,7 +141,6 @@ setFilter(int n, char **p) {
 }
 
 // setMode <mode> [TRX]
-
 PRIVATE int
 setMode(int n, char **p) {
   int mode = atoi(p[0]);
@@ -382,6 +381,8 @@ setTXSpeechCompressionGain(int n, char **p) {
 }
 
 //============================================================
+// some changes have been made to a transfer function in vec;
+// apply time-domain window to counter possible artifacts
 
 PRIVATE void
 re_window(COMPLEX *vec, int len) {
@@ -440,6 +441,7 @@ apply_txeq_band(REAL lof, REAL dB, REAL hif) {
 // 0 dB1 75 dB2 150 dB3 300 dB4 600 dB5 1200 dB6 2000 dB7 2800 dB8 3600
 // approximates W2IHY bandcenters.
 // no args, revert to no EQ.
+// NB these are shelves, not linear or other splines
 
 PRIVATE int
 setTXEQ(int n, char **p) {
@@ -655,8 +657,10 @@ PRIVATE int
 setFinished(int n, char **p) {
   top.running = FALSE;
   pthread_cancel(top.thrd.trx.id);
-  pthread_cancel(top.thrd.upd.id);
   pthread_cancel(top.thrd.mon.id);
+  pthread_cancel(top.thrd.pws.id);
+  pthread_cancel(top.thrd.mtr.id);
+  pthread_cancel(top.thrd.upd.id);
   return 0;
 }
 
@@ -755,6 +759,7 @@ setRXOff(int n, char **p) {
   }
 }
 
+// [pos]  0.0 <= pos <= 1.0
 PRIVATE int
 setRXPan(int n, char **p) {
   REAL pos, theta;
@@ -791,6 +796,7 @@ setAuxMixSt(int n, char **p) {
   }
 }
 
+// [dB] NB both channels
 PRIVATE int
 setAuxMixGain(int n, char **p) {
   if (n < 1) {
@@ -810,11 +816,104 @@ setAuxMixGain(int n, char **p) {
   }
 }
 
+//------------------------------------------------------------------------
+
+// [type]
+PRIVATE int
+setMeterType(int n, char **p) {
+  if (n < 1)
+    uni.meter.rx.type = SIGNAL_STRENGTH;
+  else {
+    METERTYPE type = (METERTYPE) atoi(p[0]);
+    if (n > 1) {
+      int trx = atoi(p[1]);
+      switch (trx) {
+      case TX: uni.meter.tx.type = type; break;
+      case RX:
+      default: uni.meter.rx.type = type; break;
+      }
+    } else
+       uni.meter.rx.type = type;
+  }
+  return 0;
+}
+
+// setSpectrumType [type [scale [rx]]]
+PRIVATE int
+setSpectrumType(int n, char **p) {
+  uni.spec.type  = SPEC_POST_FILT;
+  uni.spec.scale = SPEC_PWR;
+  uni.spec.rxk   = RL;
+  switch (n) {
+  case 3:
+    uni.spec.rxk   = atoi(p[2]);
+  case 2:
+    uni.spec.scale = atoi(p[1]);
+  case 1:
+    uni.spec.type  = atoi(p[0]);
+    break;
+  case 0:
+    return 0;
+  default:
+    return -1;
+  }
+}
+
+#if 0
+PRIVATE int
+setSpectrumType(int n, char **p) {
+  switch (n) {
+  case 3:
+    uni.spec.type = atoi(p[0]);
+    uni.spec.scale = atoi(p[1]);
+    uni.spec.rxk = atoi(p[2]);
+  case 2:
+    uni.spec.type = atoi(p[0]);
+    uni.spec.scale = atoi(p[1]);
+    uni.spec.rxk = RL;
+    break;
+  case 1:
+    uni.spec.type = atoi(p[0]);
+    uni.spec.scale = SPEC_PWR;
+    uni.spec.rxk = RL;
+    break;
+  case 0:
+    uni.spec.type = SPEC_POST_FILT;
+    uni.spec.scale = SPEC_PWR;
+    uni.spec.rxk = RL;
+    break;
+  default:
+    return -1;
+  }
+  return 0;
+}
+#endif
+
+//========================================================================
+
+// save current state while guarded by upd sem
+PRIVATE int
+reqMeter(int n, char **p) {
+  snap_meter(&uni.meter, n > 0 ? atoi(p[0]) : 0);
+  sem_post(&top.sync.mtr.sem);
+  return 0;
+}
+
+// simile modo
+PRIVATE int
+reqSpectrum(int n, char **p) {
+  snap_spectrum(&uni.spec, n > 0 ? atoi(p[0]) : 0);
+  sem_post(&top.sync.pws.sem);
+  return 0;
+}
+
 //========================================================================
 
 #include <thunk.h>
 
 CTE update_cmds[] = {
+  {"reqMeter", reqMeter},
+  {"reqSpectrum", reqSpectrum},
   {"setANF", setANF},
   {"setANFvals", setANFvals},
   {"setBIN", setBIN},
@@ -869,6 +968,8 @@ CTE update_cmds[] = {
   {"setRXPan", setRXPan},
   {"setAuxMixSt", setAuxMixSt},
   {"setAuxMixGain", setAuxMixGain},
+  {"setMeterType", setMeterType},
+  {"setSpectrumType", setSpectrumType},
   { 0, 0 }
 };