]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
fixed radio microphone level. Changed FM mode to use deviation rather than filter...
authorJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Fri, 2 Dec 2016 17:32:05 +0000 (17:32 +0000)
committerJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Fri, 2 Dec 2016 17:32:05 +0000 (17:32 +0000)
Makefile
filter_menu.c
fm_menu.c [new file with mode: 0644]
fm_menu.h [new file with mode: 0644]
new_menu.c
old_protocol.c
radio.c
radio.h
vfo.c
wdsp_init.c
wdsp_init.h

index fd59865dd27c415d567e761c909a8febd8e3e1a3..5e03aea79f77abc60d95874bd80e47a4ed52a2dc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -142,6 +142,7 @@ mode_menu.c \
 filter_menu.c \
 noise_menu.c \
 agc_menu.c \
+fm_menu.c \
 rit.c \
 meter.c \
 mode.c \
@@ -196,6 +197,7 @@ mode_menu.h \
 filter_menu.h \
 noise_menu.h \
 agc_menu.h \
+fm_menu.h \
 rit.h \
 meter.h \
 mode.h \
@@ -247,6 +249,7 @@ mode_menu.o \
 filter_menu.o \
 noise_menu.o \
 agc_menu.o \
+fm_menu.o \
 rit.o \
 meter.o \
 mode.o \
index 43f5bd406ccd86d34373d9f267cdf1174f85373a..9b9b0dcfb3b92d62abd0684aaf095967789e1a98 100644 (file)
@@ -30,6 +30,7 @@
 #include "radio.h"
 #include "vfo.h"
 #include "button_text.h"
+#include "wdsp_init.h"
 
 static GtkWidget *parent_window=NULL;
 
@@ -60,6 +61,20 @@ static gboolean filter_select_cb (GtkWidget *widget, gpointer        data) {
   vfo_update(NULL);
 }
 
+static gboolean deviation_select_cb (GtkWidget *widget, gpointer        data) {
+  deviation=(int)data;
+  if(deviation==2500) {
+    setFilter(-4000,4000);
+  } else {
+    setFilter(-8000,8000);
+  }
+  wdsp_set_deviation((double)deviation);
+  set_button_text_color(last_filter,"black");
+  last_filter=widget;
+  set_button_text_color(last_filter,"orange");
+  vfo_update(NULL);
+}
+
 void filter_menu(GtkWidget *parent) {
   GtkWidget *b;
   int i;
@@ -94,18 +109,48 @@ void filter_menu(GtkWidget *parent) {
   BANDSTACK_ENTRY *entry=bandstack_entry_get_current();
   FILTER* band_filters=filters[entry->mode];
 
-  for(i=0;i<FILTERS;i++) {
-    FILTER* band_filter=&band_filters[i];
-    GtkWidget *b=gtk_button_new_with_label(band_filters[i].title);
-    if(i==entry->filter) {
-      set_button_text_color(b,"orange");
-      last_filter=b;
-    } else {
-      set_button_text_color(b,"black");
-    }
-    gtk_widget_show(b);
-    gtk_grid_attach(GTK_GRID(grid),b,i%5,1+(i/5),1,1);
-    g_signal_connect(b,"pressed",G_CALLBACK(filter_select_cb),(gpointer *)i);
+  switch(entry->mode) {
+    case modeFMN:
+      {
+      GtkWidget *l=gtk_label_new("Deviation:");
+      gtk_grid_attach(GTK_GRID(grid),l,0,1,1,1);
+
+      GtkWidget *b=gtk_button_new_with_label("2.5K");
+      if(deviation==2500) {
+        set_button_text_color(b,"orange");
+        last_filter=b;
+      } else {
+        set_button_text_color(b,"black");
+      }
+      g_signal_connect(b,"pressed",G_CALLBACK(deviation_select_cb),(gpointer *)2500);
+      gtk_grid_attach(GTK_GRID(grid),b,1,1,1,1);
+
+      b=gtk_button_new_with_label("5.0K");
+      if(deviation==5000) {
+        set_button_text_color(b,"orange");
+        last_filter=b;
+      } else {
+        set_button_text_color(b,"black");
+      }
+      g_signal_connect(b,"pressed",G_CALLBACK(deviation_select_cb),(gpointer *)5000);
+      gtk_grid_attach(GTK_GRID(grid),b,2,1,1,1);
+      }
+      break;
+
+    default:
+      for(i=0;i<FILTERS;i++) {
+        FILTER* band_filter=&band_filters[i];
+        GtkWidget *b=gtk_button_new_with_label(band_filters[i].title);
+        if(i==entry->filter) {
+          set_button_text_color(b,"orange");
+          last_filter=b;
+        } else {
+          set_button_text_color(b,"black");
+        }
+        gtk_grid_attach(GTK_GRID(grid),b,i%5,1+(i/5),1,1);
+        g_signal_connect(b,"pressed",G_CALLBACK(filter_select_cb),(gpointer *)i);
+      }
+      break;
   }
 
   gtk_container_add(GTK_CONTAINER(content),grid);
diff --git a/fm_menu.c b/fm_menu.c
new file mode 100644 (file)
index 0000000..00d1d6c
--- /dev/null
+++ b/fm_menu.c
@@ -0,0 +1,95 @@
+/* Copyright (C)
+* 2016 - John Melton, G0ORX/N6LYT
+*
+* 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 the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "new_menu.h"
+#include "fm_menu.h"
+#include "radio.h"
+#include "wdsp_init.h"
+
+static GtkWidget *parent_window=NULL;
+
+static GtkWidget *dialog=NULL;
+
+static GtkWidget *last_band;
+
+static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
+  if(dialog!=NULL) {
+    gtk_widget_destroy(dialog);
+    dialog=NULL;
+    sub_menu=NULL;
+  }
+  return TRUE;
+}
+
+static gboolean emp_cb (GtkWidget *widget, gpointer data) {
+  if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
+    pre_emphasize=1;
+  } else {
+    pre_emphasize=0;
+  }  
+  wdsp_set_pre_emphasize(pre_emphasize);
+}
+
+void fm_menu(GtkWidget *parent) {
+  GtkWidget *b;
+  int i;
+
+  parent_window=parent;
+
+  dialog=gtk_dialog_new();
+  gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent_window));
+  gtk_window_set_decorated(GTK_WINDOW(dialog),FALSE);
+
+  GdkRGBA color;
+  color.red = 1.0;
+  color.green = 1.0;
+  color.blue = 1.0;
+  color.alpha = 1.0;
+  gtk_widget_override_background_color(dialog,GTK_STATE_FLAG_NORMAL,&color);
+
+  GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+
+  GtkWidget *grid=gtk_grid_new();
+
+  gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
+  gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
+  gtk_grid_set_column_spacing (GTK_GRID(grid),5);
+  gtk_grid_set_row_spacing (GTK_GRID(grid),5);
+
+  GtkWidget *close_b=gtk_button_new_with_label("Close FM");
+  g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
+  gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);
+
+  GtkWidget *emp_b=gtk_check_button_new_with_label("FM TX Pre-emphasize before limiting");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (emp_b), pre_emphasize);
+  gtk_widget_show(emp_b);
+  gtk_grid_attach(GTK_GRID(grid),emp_b,0,1,3,1);
+  g_signal_connect(emp_b,"toggled",G_CALLBACK(emp_cb),NULL);
+
+  gtk_container_add(GTK_CONTAINER(content),grid);
+
+  sub_menu=dialog;
+
+  gtk_widget_show_all(dialog);
+
+}
diff --git a/fm_menu.h b/fm_menu.h
new file mode 100644 (file)
index 0000000..64b3015
--- /dev/null
+++ b/fm_menu.h
@@ -0,0 +1,20 @@
+/* Copyright (C)
+* 2016 - John Melton, G0ORX/N6LYT
+*
+* 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 the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+void fm_menu(GtkWidget *parent);
index 82f8a6defcd5423cf6609177652d8ff26772bd8f..8af62e58a3825c14821abda720d9ce8242680dbb 100644 (file)
@@ -46,6 +46,7 @@
 #include "filter_menu.h"
 #include "noise_menu.h"
 #include "agc_menu.h"
+#include "fm_menu.h"
 
 
 static GtkWidget *parent_window=NULL;
@@ -227,6 +228,16 @@ static gboolean agc_cb (GtkWidget *widget, GdkEventButton *event, gpointer data)
   return TRUE;
 }
 
+void start_fm() {
+  cleanup();
+  fm_menu(parent_window);
+}
+
+static gboolean fm_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
+  start_fm();
+  return TRUE;
+}
+
 static gboolean new_menu_pressed_event_cb (GtkWidget *widget,
                GdkEventButton *event,
                gpointer        data)
@@ -314,6 +325,10 @@ static gboolean new_menu_pressed_event_cb (GtkWidget *widget,
     g_signal_connect (equalizer_b, "button-press-event", G_CALLBACK(equalizer_cb), NULL);
     gtk_grid_attach(GTK_GRID(grid),equalizer_b,4,2,1,1);
 
+    GtkWidget *fm_b=gtk_button_new_with_label("FM");
+    g_signal_connect (fm_b, "button-press-event", G_CALLBACK(fm_cb), NULL);
+    gtk_grid_attach(GTK_GRID(grid),fm_b,5,2,1,1);
+
     GtkWidget *step_b=gtk_button_new_with_label("Step");
     g_signal_connect (step_b, "button-press-event", G_CALLBACK(step_cb), NULL);
     gtk_grid_attach(GTK_GRID(grid),step_b,0,3,1,1);
index 4ec91a41a38350088c2e71ea853487591456370d..68eda8a168fd3afaa8888d4a71526cb9ac40c126 100644 (file)
@@ -376,7 +376,7 @@ static void process_ozy_input_buffer(char  *buffer) {
   int last_dash;
   int left_sample[RECEIVERS];
   int right_sample[RECEIVERS];
-  short mic_sample;
+  int mic_sample;
   double left_sample_double[RECEIVERS];
   double right_sample_double[RECEIVERS];
   double mic_sample_double;
@@ -455,8 +455,8 @@ static void process_ozy_input_buffer(char  *buffer) {
         right_sample[r] += (int)((unsigned char)buffer[b++]) << 8;
         right_sample[r] += (int)((unsigned char)buffer[b++]);
       }
-      mic_sample    = (short)((signed char) buffer[b++]) << 16;
-      mic_sample   |= (short)((unsigned char)buffer[b++]);
+      mic_sample    = (int)((signed char) buffer[b++]) << 8;
+      mic_sample   |= (int)((unsigned char)buffer[b++]);
       mic_sample_double = (1.0 / 2147483648.0) * (double)(mic_sample<<16);
 
       for(r=0;r<RECEIVERS;r++) {
diff --git a/radio.c b/radio.c
index 59da964ab539ad362a84a979ee90e8349f54bc1d..e957405d4dc7036fea408a432c167b5c108eaa44 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -217,6 +217,9 @@ int tx_equalizer[4]={0,0,0,0};
 int enable_rx_equalizer=0;
 int rx_equalizer[4]={0,0,0,0};
 
+int deviation=2500;
+int pre_emphasize=0;
+
 void init_radio() {
   int rc;
   rc=sem_init(&property_sem, 0, 0);
@@ -669,6 +672,10 @@ fprintf(stderr,"radioRestoreState: %s\n",property_path);
     if(value) rx_equalizer[3]=atoi(value);
     value=getProperty("rit_increment");
     if(value) rit_increment=atoi(value);
+    value=getProperty("deviation");
+    if(value) deviation=atoi(value);
+    value=getProperty("pre_emphasize");
+    if(value) pre_emphasize=atoi(value);
 
     bandRestoreState();
 
@@ -849,6 +856,10 @@ void radioSaveState() {
     setProperty("rx_equalizer.3",value);
     sprintf(value,"%d",rit_increment);
     setProperty("rit_increment",value);
+    sprintf(value,"%d",deviation);
+    setProperty("deviation",value);
+    sprintf(value,"%d",pre_emphasize);
+    setProperty("pre_emphasize",value);
 
     bandSaveState();
 
diff --git a/radio.h b/radio.h
index 3679b0b39cc7cfd6e9b50d33f4f6b68de2abc598..63850af08c4f63e4b281d2b01c4e159845066c4f 100644 (file)
--- a/radio.h
+++ b/radio.h
@@ -227,6 +227,9 @@ extern int tx_equalizer[4];
 extern int enable_rx_equalizer;
 extern int rx_equalizer[4];
 
+extern int deviation;
+extern int pre_emphasize;
+
 extern void init_radio();
 extern void setSampleRate(int rate);
 extern int getSampleRate();
diff --git a/vfo.c b/vfo.c
index fb83b5d880c8c50b547662733e3bea4e10b47548..6a01089179d0600c4f603da8f88241e4867c4323 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -286,7 +286,15 @@ int vfo_update(void *data) {
         cairo_show_text(cr, mode_string[entry->mode]);
 
         cairo_move_to(cr, 190, 50);  
-        cairo_show_text(cr, band_filter->title);
+        if(mode==modeFMN) {
+          if(deviation==2500) {
+            cairo_show_text(cr, "8k");
+          } else {
+            cairo_show_text(cr, "16k");
+          }
+        } else {
+          cairo_show_text(cr, band_filter->title);
+        }
 
         cairo_move_to(cr, 250, 50);  
         if(nr) {
index a366212af97adcbefdf568d80356d80fac9b2c98..2ffabe3530edae9ca289114b0973fe5b03266163 100644 (file)
@@ -234,6 +234,7 @@ static void setupRX(int rx) {
     setRXMode(rx,mode);
     SetRXABandpassFreqs(rx, (double)filterLow, (double)filterHigh);
     
+    SetRXAFMDeviation(rx,(double)deviation);
     //SetRXAAGCMode(rx, agc);
     //SetRXAAGCTop(rx,agc_gain);
     wdsp_set_agc(rx, agc);
@@ -269,6 +270,9 @@ static void setupTX(int tx) {
     SetTXABandpassWindow(tx, 1);
     SetTXABandpassRun(tx, 1);
 
+    SetTXAFMDeviation(tx,(double)deviation);
+    SetTXAFMEmphPosition(tx,pre_emphasize);
+
     SetTXACFIRRun(tx, protocol==NEW_PROTOCOL?1:0); // turned in if new protocol
     if(enable_tx_equalizer) {
       SetTXAGrphEQ(tx, tx_equalizer);
@@ -300,11 +304,9 @@ static void setupTX(int tx) {
     SetTXAPostGenToneFreq(tx, 0.0);
     SetTXAPostGenRun(tx, 0);
 
-    if(protocol==NEW_PROTOCOL) {
-      double gain=pow(10.0, mic_gain / 20.0);
-      SetTXAPanelGain1(tx,gain);
-      //SetTXAPanelRun(tx, protocol==NEW_PROTOCOL?1:0);
-    }
+    double gain=pow(10.0, mic_gain / 20.0);
+    SetTXAPanelGain1(tx,gain);
+    SetTXAPanelRun(tx, 1);
 
     //SetChannelState(tx,1,0);
 }
@@ -427,6 +429,15 @@ void wdsp_new_sample_rate(int rate) {
   SetChannelState(receiver,1,0);
 }
 
+void wdsp_set_deviation(double deviation) {
+  SetRXAFMDeviation(CHANNEL_RX0, deviation);
+  SetTXAFMDeviation(CHANNEL_TX, deviation);
+}
+
+void wdsp_set_pre_emphasize(int state) {
+  SetTXAFMEmphPosition(CHANNEL_TX,state);
+}
+
 static void initAnalyzer(int channel,int buffer_size) {
     int flp[] = {0};
     double KEEP_TIME = 0.1;
index eb49fd2670864d67cf56571536fb39e2eb80b102..a61b170f265ba64bb02913a16a94f196d09f439b 100644 (file)
@@ -30,5 +30,6 @@ extern int getFilterHigh();
 extern void wdsp_init(int rx,int pixels,int protocol);
 extern void wdsp_new_sample_rate(int rate);
 extern void wdsp_set_agc(int rx, int agc);
-
+extern void wdsp_set_deviation(double deviation);
+extern void wdsp_set_pre_emphasize(int state);
 #endif