]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Merged in "transverter" corrections by John,
authorc vw <dl1ycf@darc.de>
Thu, 28 Oct 2021 16:22:22 +0000 (18:22 +0200)
committerc vw <dl1ycf@darc.de>
Thu, 28 Oct 2021 16:22:22 +0000 (18:22 +0200)
"PA enable" checkbox also for non-HL2 machines,
and treat band->disablePA together with pa_enable.

12 files changed:
band.c
band_menu.c
meter.c
meter.h
old_protocol.c
pulseaudio.c
radio_menu.c
receiver.c
release/pihpsdr/install.sh
transmitter.c
tx_panadapter.c
vfo.c

diff --git a/band.c b/band.c
index de1712ec1d8761bf4dbb946a081de241d4c7f1be..7ecb68aa1200c4fd360deebe157a1f5684e3c036 100644 (file)
--- a/band.c
+++ b/band.c
@@ -297,14 +297,14 @@ BAND bands[BANDS+XVTRS] =
      {"WWV",&bandstackWWV,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
      {"GEN",&bandstackGEN,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
 // XVTRS
-     {"",&bandstack_xvtr_0,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
-     {"",&bandstack_xvtr_1,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
-     {"",&bandstack_xvtr_2,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
-     {"",&bandstack_xvtr_3,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
-     {"",&bandstack_xvtr_4,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
-     {"",&bandstack_xvtr_5,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
-     {"",&bandstack_xvtr_6,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
-     {"",&bandstack_xvtr_7,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0}
+     {"",&bandstack_xvtr_0,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,1},
+     {"",&bandstack_xvtr_1,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,1},
+     {"",&bandstack_xvtr_2,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,1},
+     {"",&bandstack_xvtr_3,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,1},
+     {"",&bandstack_xvtr_4,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,1},
+     {"",&bandstack_xvtr_5,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,1},
+     {"",&bandstack_xvtr_6,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,1},
+     {"",&bandstack_xvtr_7,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,1}
     };
 
 CHANNEL band_channels_60m_UK[UK_CHANNEL_ENTRIES] =
index 7bbb4720715fe2eeb53580466ce4b8c1da857a2d..3d8ada38679e40cf607b0adc6fd7dc02eaacd43d 100644 (file)
@@ -65,6 +65,7 @@ gboolean band_select_cb (GtkWidget *widget, gpointer        data) {
   int b=GPOINTER_TO_UINT(data);
   set_button_text_color(last_band,"black");
   last_band=widget;
+  //fprintf(stderr,"%s: %d\n",__FUNCTION__,b);
   set_button_text_color(last_band,"orange");
 #ifdef CLIENT_SERVER
   if(radio_is_remote) {
diff --git a/meter.c b/meter.c
index 77e575146ff06f32fea689094ffe0568dbaa8998..3040de24b4e373448724a528349c4a96bc868790 100644 (file)
--- a/meter.c
+++ b/meter.c
@@ -24,6 +24,7 @@
 #include <unistd.h>
 #include <math.h>
 
+#include "band.h"
 #include "receiver.h"
 #include "meter.h"
 #include "radio.h"
@@ -140,7 +141,7 @@ fprintf(stderr,"meter_init: width=%d height=%d\n",width,height);
 }
 
 
-void meter_update(RECEIVER *rx,int meter_type,double value,double reverse,double alc,double swr) {
+void meter_update(RECEIVER *rx,int meter_type,double value,double reverse,double exciter,double alc,double swr) {
   
   double level;
   char sf[32];
@@ -149,34 +150,43 @@ void meter_update(RECEIVER *rx,int meter_type,double value,double reverse,double
   char *units="W";
   double interval=10.0;
   cairo_t *cr = cairo_create (meter_surface);
+  BAND *band=band_get_current_band();
 
   if(meter_type==POWER) {
     level=value;
-    switch(pa_power) {
-      case PA_1W:
-        units="mW";
-        interval=100.0;
-        level=level*1000.0;
-        reverse=reverse*1000;  // scale reverse as well to get correct SWR
-        break;
-      case PA_10W:
-        interval=1.0;
-        break;
-      case PA_30W:
-        interval=3.0;
-        break;
-      case PA_50W:
-        interval=5.0;
-        break;
-      case PA_100W:
-        interval=10.0;
-        break;
-      case PA_200W:
-        interval=20.0;
-        break;
-      case PA_500W:
-        interval=50.0;
-        break;
+    if(level==0.0 || band->disablePA || !pa_enabled) {
+      level=exciter;
+    }
+    if(band->disablePA || !pa_enabled) {
+      units="mW";
+      interval=100.0;
+      level=level*1000.0;
+    } else {
+      switch(pa_power) {
+        case PA_1W:
+          units="mW";
+          interval=100.0;
+          level=level*1000.0;
+          break;
+        case PA_10W:
+          interval=1.0;
+          break;
+        case PA_30W:
+          interval=3.0;
+          break;
+        case PA_50W:
+          interval=5.0;
+          break;
+        case PA_100W:
+          interval=10.0;
+          break;
+        case PA_200W:
+          interval=20.0;
+          break;
+        case PA_500W:
+          interval=50.0;
+          break;
+      }
     }
   }
 
@@ -326,29 +336,35 @@ if(analog_meter) {
 
       char *units="W";
       double interval=10.0;
-      switch(pa_power) {
-        case PA_1W:
-          units="mW";
-          interval=100.0;
-          break;
-        case PA_10W:
-          interval=1.0;
-          break;
-        case PA_30W:
-          interval=3.0;
-          break;
-        case PA_50W:
-          interval=5.0;
-          break;
-        case PA_100W:
-          interval=10.0;
-          break;
-        case PA_200W:
-          interval=20.0;
-          break;
-        case PA_500W:
-          interval=50.0;
-          break;
+
+      if(band->disablePA || !pa_enabled) {
+        units="mW";
+        interval=100.0;
+      } else {
+        switch(pa_power) {
+          case PA_1W:
+            units="mW";
+            interval=100.0;
+            break;
+          case PA_10W:
+            interval=1.0;
+            break;
+          case PA_30W:
+            interval=3.0;
+            break;
+          case PA_50W:
+            interval=5.0;
+            break;
+          case PA_100W:
+            interval=10.0;
+            break;
+          case PA_200W:
+            interval=20.0;
+            break;
+          case PA_500W:
+            interval=50.0;
+            break;
+        }
       }
 
       for(i=0;i<=100;i++) {
@@ -432,7 +448,8 @@ if(analog_meter) {
 
 
       cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
-      sprintf(sf,"%0.1f %s",max_level,units);
+      //sprintf(sf,"%0.1f%s",max_level,units);
+      sprintf(sf,"%d%s",(int)max_level,units);
       cairo_move_to(cr, 80, meter_height-22);
       cairo_show_text(cr, sf);
 
@@ -663,7 +680,7 @@ if(analog_meter) {
       }
       max_count++;
 
-      sprintf(sf,"FWD: %0.1f %s",max_level,units);
+      sprintf(sf,"FWD: %d%s",(int)max_level,units);
       cairo_move_to(cr, 10, 35);
       cairo_show_text(cr, sf);
 
diff --git a/meter.h b/meter.h
index 212b479eb9cd41dae5022b020f1c4ae7f52003d2..54a85b8bf98f8d896a72b2cbced3e11d97aee48c 100644 (file)
--- a/meter.h
+++ b/meter.h
@@ -26,6 +26,6 @@
 #define POWER 1
 
 extern GtkWidget* meter_init(int width,int height,GtkWidget *parent);
-extern void meter_update(RECEIVER *rx,int meter_type,double value,double reverse,double alc,double swr);
+extern void meter_update(RECEIVER *rx,int meter_type,double value,double reverse,double exciter,double alc,double swr);
 
 #endif
index c856db593302bda4fd16e70aaa8847a651870771..02b183a168f7e5c9ba45ce3eaae574461d0d12cf 100644 (file)
@@ -1252,22 +1252,20 @@ void old_protocol_iq_samples(int isample,int qsample) {
   }
 }
 
-/*
-static void process_bandscope_buffer(char  *buffer) {
-}
-*/
-
 void ozy_send_buffer() {
 
 
   int txmode=get_tx_mode();
   int txvfo=get_tx_vfo();
   int i;
-  BAND *band;
+  int power;
   int num_hpsdr_receivers=how_many_receivers();
   int rx1channel = first_receiver_channel();
   int rx2channel = second_receiver_channel();
 
+  BAND *rxband=band_get_band(vfo[VFO_A].band);
+  BAND *txband=band_get_band(vfo[txvfo].band);
+
   output_buffer[SYNC0]=SYNC;
   output_buffer[SYNC1]=SYNC;
   output_buffer[SYNC2]=SYNC;
@@ -1329,10 +1327,8 @@ void ozy_send_buffer() {
     if(classE) {
       output_buffer[C2]|=0x01;
     }
-    band=band_get_band(vfo[VFO_A].band);
     if(isTransmitting()) {
-      band=band_get_band(vfo[txvfo].band);
-      output_buffer[C2]|=band->OCtx<<1;
+      output_buffer[C2]|=txband->OCtx<<1;
       if(tune) {
         if(OCmemory_tune_time!=0) {
           struct timeval te;
@@ -1346,7 +1342,7 @@ void ozy_send_buffer() {
         }
       }
     } else {
-      output_buffer[C2]|=band->OCrx<<1;
+      output_buffer[C2]|=rxband->OCrx<<1;
     }
 
     output_buffer[C3] = (receiver[0]->alex_attenuation) & 0x03;  // do not set higher bits
@@ -1510,9 +1506,7 @@ void ozy_send_buffer() {
         }
         break;
       case 3:
-        {
-        BAND *band=band_get_current_band();
-        int power=0;
+        power=0;
 //static int last_power=0;
        //
        // Some HPSDR apps for the RedPitaya generate CW inside the FPGA, but while
@@ -1562,6 +1556,7 @@ void ozy_send_buffer() {
 //  last_power=power;
 //}
 
+       //fprintf(stderr,"%s: TXband=%s disablePA=%d\n",__FUNCTION__,txband->title,txband->disablePA);
 
 
         output_buffer[C0]=0x12;
@@ -1578,22 +1573,15 @@ void ozy_send_buffer() {
         if((filter_board==APOLLO) && tune) {
           output_buffer[C2]|=0x10;
         }
-        if (device==DEVICE_HERMES_LITE2) {
-          // do not set any Apollo/Alex bits,
-          // ADDR=0x09 bit 19 follows "PA enable" state
-          // ADDR=0x09 bit 20 follows "TUNE" state
-          // ADDR=0x09 bit 18 always cleared (external tuner enabled)
-          output_buffer[C2]= 0x00;
-          if (pa_enabled) output_buffer[C2] |= 0x08;
-          if (tune)       output_buffer[C2] |= 0x10;
-        } 
         if(band_get_current()==band6) {
           output_buffer[C3]=output_buffer[C3]|0x40; // Alex 6M low noise amplifier
         }
-        if(band->disablePA) {
-          output_buffer[C2]=output_buffer[C2]|0x40; // Manual Filter Selection
-          output_buffer[C3]=output_buffer[C3]|0x20; // bypass all RX filters
-          output_buffer[C3]=output_buffer[C3]|0x80; // disable Alex T/R relay
+        if (txband->disablePA || !pa_enabled) {
+          output_buffer[C3]|=0x80; // disable Alex T/R relay
+          if(isTransmitting()) {
+            output_buffer[C2]|=0x40; // Manual Filter Selection
+            output_buffer[C3]|=0x20; // bypass all RX filters
+          }
         }
 #ifdef PURESIGNAL
        //
@@ -1632,6 +1620,16 @@ void ozy_send_buffer() {
          }
        }
 #endif
+        if (device==DEVICE_HERMES_LITE2) {
+          // do not set any Apollo/Alex bits (ADDR=0x09 bits 0:23)
+          // ADDR=0x09 bit 19 follows "PA enable" state
+          // ADDR=0x09 bit 20 follows "TUNE" state
+          // ADDR=0x09 bit 18 always cleared (external tuner enabled)
+          output_buffer[C2]= 0x00;
+          output_buffer[C3]= 0x00;
+          output_buffer[C4]= 0x00;
+          if (pa_enabled || txband->disablePA) output_buffer[C2] |= 0x08;
+          if (tune)                            output_buffer[C2] |= 0x10;
         }
         command=4;
         break;
index 7670ed9fbd78def75dfba295f7b48d1b463f0dd7..ebf0c42b7c1a4bdf0aeda94c15b56c67b1c98c4b 100644 (file)
@@ -135,11 +135,11 @@ int audio_open_output(RECEIVER *rx) {
   int err;
 
   pa_buffer_attr attr;
-  attr.maxlength = (uint32_t) -1;
-  attr.tlength = (uint32_t) -1;
-  attr.prebuf = (uint32_t) 3072;  // about 64 msec "pre-filling"
-  attr.minreq = (uint32_t) -1;
-  attr.fragsize = (uint32_t) -1;
+  attr.maxlength = (uint32_t) 4800;
+  attr.tlength   = (uint32_t) 3800;
+  attr.prebuf    = (uint32_t) 3072;  // about 64 msec "pre-filling"
+  attr.minreq    = (uint32_t) -1;
+  attr.fragsize  = (uint32_t) -1;
 
   if(rx->audio_name==NULL) {
     result=-1;
index b55ecf3b4cc2663dc00973030be0a7511c7593a7..c0acbcb83c6486daac39b391e61b4c70af71ceb1 100644 (file)
@@ -853,13 +853,10 @@ void radio_menu(GtkWidget *parent) {
     g_signal_connect(rx_gain_calibration_b,"value_changed",G_CALLBACK(rx_gain_calibration_value_changed_cb),NULL);
     col++;
 
-    if ((protocol == ORIGINAL_PROTOCOL && device == DEVICE_HERMES_LITE2) ||
-        (protocol == NEW_PROTOCOL      && device == NEW_DEVICE_HERMES_LITE2)) {
-        GtkWidget *PA_enable_b=gtk_check_button_new_with_label("HL2 PA enable");
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (PA_enable_b), pa_enabled);
-        gtk_grid_attach(GTK_GRID(grid),PA_enable_b,col,row,1,1);
-        g_signal_connect(PA_enable_b,"toggled",G_CALLBACK(PA_enable_cb),NULL);
-    }
+    GtkWidget *PA_enable_b=gtk_check_button_new_with_label("PA enable");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (PA_enable_b), pa_enabled);
+    gtk_grid_attach(GTK_GRID(grid),PA_enable_b,col,row,1,1);
+    g_signal_connect(PA_enable_b,"toggled",G_CALLBACK(PA_enable_cb),NULL);
 
   }
   row++;
index 2707fb256aa1e1973ca580bfdac03abdc58b8262..e51d18b8c949d33f89799943535fa4f00d6bc8f5 100644 (file)
@@ -637,8 +637,7 @@ static gint update_display(gpointer data) {
       g_mutex_unlock(&rx->display_mutex);
       if(active_receiver==rx) {
         rx->meter=GetRXAMeter(rx->id,smeter)+meter_calibration;
-        // the three "unused" parameters are the TX rev, alc, and swr values
-        meter_update(rx,SMETER,rx->meter,0.0,0.0,0.0);
+        meter_update(rx,SMETER,rx->meter,0.0,0.0,0.0,0.0);
       }
       return TRUE;
     }
@@ -657,8 +656,7 @@ void receiver_remote_update_display(RECEIVER *rx) {
         waterfall_update(rx);
       }
       if(active_receiver==rx) {
-        // the three "unused" parameters are the TX rev, alc, and swr values
-        meter_update(rx,SMETER,rx->meter,0.0,0.0,0.0);
+        meter_update(rx,SMETER,rx->meter,0.0,0.0,0.0,0.0);
       }
       g_mutex_unlock(&rx->display_mutex);
     }
index 77cb1e1c019482fe3e9d3a9420994f8a2bd1fc3d..9f7121d83d2d7e090336d1f2b0a32791e38e8d0b 100755 (executable)
@@ -1,7 +1,10 @@
 echo "installing fftw"
 sudo apt-get -y install libfftw3-3
-echo "installing librtlsdr0"
-sudo apt-get -y install librtlsdr0
+echo "installing gppiod"
+sudo apt-get -y install libgpuiod2
+echo "installing pulseaudio"
+sudo apt-get -y install libpulse0
+sudo apt-get -y install libpulse-mainloop-glib0
 echo "removing old versions of pihpsdr"
 sudo rm -rf /usr/local/bin/pihpsdr
 echo "creating start script"
@@ -35,11 +38,7 @@ fi
 cp pihpsdr.desktop ~/.local/share/applications
 echo "removing old versions of shared libraries"
 sudo rm -rf /usr/local/lib/libwdsp.so
-sudo rm -rf /usr/local/lib/libLimeSuite*
-sudo rm -rf /usr/local/lib/libSoapySDR*
-sudo rm -rf /usr/local/lib/SoapySDR
 echo "copying udev rules"
-sudo cp 64-limesuite.rules /etc/udev/rules.d/
 sudo cp 90-ozy.rules /etc/udev/rules.d/
 sudo udevadm control --reload-rules
 sudo udevadm trigger
@@ -47,13 +46,18 @@ echo "installing pihpsdr"
 sudo cp pihpsdr /usr/local/bin
 echo "installing shared libraries"
 sudo cp libwdsp.so /usr/local/lib
-sudo cp libLimeSuite.so.19.04.1 /usr/local/lib
-sudo cp libSoapySDR.so.0.8.0 /usr/local/lib
-sudo cp -R SoapySDR /usr/local/lib
 cd /usr/local/lib
-sudo ln -s libLimeSuite.so.19.04.1 libLimeSuite.so.19.04-1
-sudo ln -s libLimeSuite.so.19.04-1 libLimeSuite.so
-sudo ln -s libSoapySDR.so.0.8.0 libSoapySDR.so.0.8
-sudo ln -s libSoapySDR.so.0.8 libSoapySDR.so
 sudo ldconfig
-
+if test -f "/boot/config.txt"; then
+  if grep -q "gpio=4-13,16-27=ip,pu" /boot/config.txt; then
+    echo "/boot/config.txt already contains gpio setup."
+  else
+    echo "/boot/config.txt does not contain gpio setup - adding it."
+    echo "Please reboot system for this to take effect."
+    cat <<EGPIO | sudo tee -a /boot/config.txt > /dev/null
+[all]
+# setup GPIO for pihpsdr controllers
+gpio=4-13,16-27=ip,pu
+EGPIO
+  fi
+fi
index 7e89244c4cc31c75b5d0ae98f597f575e49272ce..525dfd7b99c9363f905e9537f272d425f8d68649 100644 (file)
@@ -659,6 +659,7 @@ static gboolean update_display(gpointer data) {
     //
     tx->fwd=compute_power(tx->fwd);
     tx->rev=compute_power(tx->rev);
+    tx->exciter=compute_power(tx->exciter);
 
     //
     // Calculate SWR and store as tx->swr.
@@ -699,7 +700,7 @@ static gboolean update_display(gpointer data) {
     }
 
     if(!duplex) {
-      meter_update(active_receiver,POWER,tx->fwd,tx->rev,tx->alc,tx->swr);
+      meter_update(active_receiver,POWER,tx->fwd,tx->rev,tx->exciter,tx->alc,tx->swr);
     }
 
     return TRUE; // keep going
index 8c272c69cbb401a09c9476a7dc78349812932e3b..19b94eb55c0a2e0f5e50d5defec1f0a98ed71aa9 100644 (file)
@@ -405,7 +405,7 @@ void tx_panadapter_update(TRANSMITTER *tx) {
     cairo_set_source_rgb(cr,1.0,0.2,0.0);
     cairo_set_font_size(cr, DISPLAY_FONT_SIZE3);
 
-    if(transmitter->fwd<0.0001) {
+    if(transmitter->fwd<0.0001 || band->disablePA || !pa_enabled) {
       sprintf(text,"FWD %0.3f W",transmitter->exciter);
     } else {
       static int max_count=0;
@@ -431,15 +431,6 @@ void tx_panadapter_update(TRANSMITTER *tx) {
     cairo_move_to(cr,10,45);
     cairo_show_text(cr, text);
 
-/*
-    sprintf(text,"FWD: %0.8f",transmitter->fwd);
-    cairo_move_to(cr,10,60);
-    cairo_show_text(cr, text);
-
-    sprintf(text,"EXC: %0.3f",transmitter->exciter);
-    cairo_move_to(cr,10,75);
-    cairo_show_text(cr, text);
-*/
   }
   //
   // If the SWR protection has been triggered, display message for three seconds
diff --git a/vfo.c b/vfo.c
index 15479b01ea711dc49f320c6dd8c0af67512c9260..9cc296d954a9eb0a4ccaab5f4bc5aa31cd84ee26 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -384,6 +384,7 @@ void vfo_apply_mode_settings(int id) {
 void vfo_band_changed(int id,int b) {
   BANDSTACK *bandstack;
 
+  //fprintf(stderr,"%s: %d\n",__FUNCTION__,b);
 #ifdef CLIENT_SERVER
   if(radio_is_remote) {
     send_band(client_socket,id,b);
@@ -407,7 +408,7 @@ void vfo_band_changed(int id,int b) {
     vfo[id].bandstack=bandstack->current_entry;
   }
 
-  BAND *band=band_get_band(b);
+  BAND *band=band_set_current(b);
   BANDSTACK_ENTRY *entry=&bandstack->entry[vfo[id].bandstack];
   vfo[id].band=b;
   vfo[id].frequency=entry->frequency;