]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
a little cleanup
authorc vw <dl1ycf@darc.de>
Mon, 6 Aug 2018 09:03:37 +0000 (11:03 +0200)
committerc vw <dl1ycf@darc.de>
Mon, 6 Aug 2018 09:03:37 +0000 (11:03 +0200)
Makefile
Makefile.mac
configure.h
discovery.c
exit_menu.c
gpio.c
iambic.h
main.c
radio.c
sliders.h

index c2b5d51d836e06d98047065178d4236c2b170fde..a4147dc1669805f9248b2fd87e1c5fcaf5d0eaba 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -27,9 +27,12 @@ GIT_VERSION := $(shell git describe --abbrev=0 --tags)
 # uncomment the line to below include support local CW keyer
 #LOCALCW_INCLUDE=LOCALCW
 
-# uncomment the line below to include support for STEMlab discovery
+# uncomment the line below to include support for STEMlab discovery (with avahi)
 #STEMLAB_DISCOVERY=STEMLAB_DISCOVERY
 
+# uncomment the line below to include support for STEMlab discovery WITHOUT AVAHI
+#STEMLAB_DISCOVERY=STEMLAB_DISCOVERY_NOAVAHI
+
 # uncommment this line for activate work-around some RedPitaty HPSDR bugs
 #STEMLAB_FIX_OPTION=-DSTEMLAB_FIX
 
@@ -40,12 +43,20 @@ UNAME_N=raspberrypi
 #UNAME_N=pine64
 #UNAME_N=jetsen
 
+# Additional options that can be chosen at compile time:
+# -DDIGI_MODES          wide filters and no noise reduction in DIGU/DIGL
+# -DSPLIT_RXTX          if there is more than one receiver, TX panel only "hides" the first one
+# -DPROTOCOL_DEBUG      logs (on stderr) all state changes sent to the SDR (only old protocol)
+# -DDEBUG               activate debug output
+#
+# leave the list empty if no such option should be used
+
+ADDITIONAL_OPTIONS=
+
+
 CC=gcc
 LINK=gcc
 
-# uncomment the line below for various debug facilities
-#DEBUG_OPTION=-D DEBUG
-
 ifeq ($(PURESIGNAL_INCLUDE),PURESIGNAL)
 PURESIGNAL_OPTIONS=-D PURESIGNAL
 PURESIGNAL_SOURCES= \
@@ -84,7 +95,7 @@ endif
 #LIMESDR_INCLUDE=LIMESDR
 
 # uncomment the line below when Radioberry radio cape is plugged in (for now use emulator and old protocol)
-RADIOBERRY_INCLUDE=RADIOBERRY
+#RADIOBERRY_INCLUDE=RADIOBERRY
 ifeq ($(RADIOBERRY_INCLUDE),RADIOBERRY)
 RADIOBERRY_OPTIONS=-D RADIOBERRY
 endif
@@ -166,6 +177,10 @@ ifeq ($(I2C_INCLUDE),I2C)
   I2C_OBJS=i2c.o
 endif
 
+#
+# We have two versions here, the second one has to be used
+# if you do not have the avahi libraries
+#
 ifeq ($(STEMLAB_DISCOVERY), STEMLAB_DISCOVERY)
 STEMLAB_OPTIONS=-D STEMLAB_DISCOVERY \
   `pkg-config --cflags avahi-gobject` \
@@ -176,6 +191,14 @@ STEMLAB_HEADERS=stemlab_discovery.h
 STEMLAB_OBJS=stemlab_discovery.o
 endif
 
+ifeq ($(STEMLAB_DISCOVERY), STEMLAB_DISCOVERY_NOAVAHI)
+STEMLAB_OPTIONS=-D STEMLAB_DISCOVERY -D NO_AVAHI `pkg-config --cflags libcurl`
+STEMLAB_LIBS=`pkg-config --libs libcurl`
+STEMLAB_SOURCES=stemlab_discovery.c
+STEMLAB_HEADERS=stemlab_discovery.h
+STEMLAB_OBJS=stemlab_discovery.o
+endif
+
 GTKINCLUDES=`pkg-config --cflags gtk+-3.0`
 GTKLIBS=`pkg-config --libs gtk+-3.0`
 
@@ -184,7 +207,7 @@ AUDIO_LIBS=-lasound
 
 OPTIONS=-g -Wno-deprecated-declarations $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) $(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) \
                $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(RADIOBERRY_OPTIONS) $(PSK_OPTIONS) $(STEMLAB_OPTIONS) $(STEMLAB_FIX_OPTION) \
-               -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -O3
+               -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(ADDITIONAL_OPTIONS) -O3
 
 LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS)
 INCLUDES=$(GTKINCLUDES)
index b551b64d3af0c0bd5cd14baf99176de6d93e5569..0b8d67a171e3fabed4aa3ce2e56b0b9741ddc61f 100644 (file)
@@ -3,9 +3,6 @@
 GIT_DATE := $(firstword $(shell git --no-pager show --date=short --format="%ai" --name-only))
 GIT_VERSION := $(shell git describe --abbrev=0 --tags)
 
-# un-commment this line for activate work-around some RedPitaty HPSDR bugs
-STEMLAB_FIX_OPTION=-DSTEMLAB_FIX
-
 # uncomment the line below to include GPIO
 #GPIO_INCLUDE=GPIO
 
@@ -30,12 +27,17 @@ STEMLAB_FIX_OPTION=-DSTEMLAB_FIX
 # uncomment the line to below include support local CW keyer
 #LOCALCW_INCLUDE=LOCALCW
 
-# uncomment the line below to include support for STEMlab discovery
-STEMLAB_DISCOVERY=STEMLAB_DISCOVERY
+# uncomment the line below to include support for STEMlab discovery (with avahi)
+#STEMLAB_DISCOVERY=STEMLAB_DISCOVERY
+
+# uncomment the line below to include support for STEMlab discovery WITHOUT AVAHI
+STEMLAB_DISCOVERY=STEMLAB_DISCOVERY_NOAVAHI
+
+# un-commment this line for activate work-around some RedPitaty HPSDR bugs
+STEMLAB_FIX_OPTION=-DSTEMLAB_FIX
 
 #uncomment the line below for the platform being compiled on
-UNAME_N=MacOS
-#UNAME_N=raspberrypi
+UNAME_N=raspberrypi
 #UNAME_N=odroid
 #UNAME_N=up
 #UNAME_N=pine64
@@ -45,25 +47,14 @@ UNAME_N=MacOS
 # -DDIGI_MODES         wide filters and no noise reduction in DIGU/DIGL
 # -DSPLIT_RXTX          if there is more than one receiver, TX panel only "hides" the first one
 # -DPROTOCOL_DEBUG     logs (on stderr) all state changes sent to the SDR (only old protocol)
+# -DDEBUG              activate debug output
 #
 # leave the list empty if no such option should be used
 
 ADDITIONAL_OPTIONS= -DDIGI_MODES -DSPLIT_RXTX
 
 CC=gcc
-
-ifeq ($(UNAME_N),MacOS)
-#
-# This is only necessary for "make app", since the "patched"
-# library names are longer
-#
-LINK=gcc -headerpad_max_install_names
-else
 LINK=gcc
-endif
-
-# uncomment the line below for various debug facilities
-#DEBUG_OPTION=-D DEBUG
 
 ifeq ($(PURESIGNAL_INCLUDE),PURESIGNAL)
 PURESIGNAL_OPTIONS=-D PURESIGNAL
@@ -102,7 +93,7 @@ endif
 # uncomment the line below for LimeSDR (uncomment line below)
 #LIMESDR_INCLUDE=LIMESDR
 
-# uncomment the line below when Radioberry radio cape is plugged in
+# uncomment the line below when Radioberry radio cape is plugged in (for now use emulator and old protocol)
 #RADIOBERRY_INCLUDE=RADIOBERRY
 
 ifeq ($(RADIOBERRY_INCLUDE),RADIOBERRY)
@@ -187,9 +178,20 @@ ifeq ($(I2C_INCLUDE),I2C)
 endif
 
 #
-# Here in Makefile.mac, we use the version that does not need avahi
+# We have two versions here, the second one has to be used
+# if you do not have the avahi libraries
 #
 ifeq ($(STEMLAB_DISCOVERY), STEMLAB_DISCOVERY)
+STEMLAB_OPTIONS=-D STEMLAB_DISCOVERY \
+  `pkg-config --cflags avahi-gobject` \
+  `pkg-config --cflags libcurl`
+STEMLAB_LIBS=`pkg-config --libs avahi-gobject` `pkg-config --libs libcurl`
+STEMLAB_SOURCES=stemlab_discovery.c
+STEMLAB_HEADERS=stemlab_discovery.h
+STEMLAB_OBJS=stemlab_discovery.o
+endif
+
+ifeq ($(STEMLAB_DISCOVERY), STEMLAB_DISCOVERY_NOAVAHI)
 STEMLAB_OPTIONS=-D STEMLAB_DISCOVERY -D NO_AVAHI `pkg-config --cflags libcurl`
 STEMLAB_LIBS=`pkg-config --libs libcurl`
 STEMLAB_SOURCES=stemlab_discovery.c
@@ -207,15 +209,11 @@ GTKLIBS=`pkg-config --libs gtk+-3.0`
 PORTAUDIO_OPTIONS=-DPORTAUDIO
 AUDIO_LIBS=-lportaudio
 
-OPTIONS=-g -Wno-deprecated-declarations $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(RADIOBERRY_OPTIONS) \
-       $(USBOZY_OPTIONS)  $(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) $(FREEDV_OPTIONS) \
-       $(LOCALCW_OPTIONS) $(PSK_OPTIONS)  $(STEMLAB_OPTIONS) $(STEMLAB_FIX_OPTION) \
-       $(PORTAUDIO_OPTIONS) $(ADDITIONAL_OPTIONS) \
-       -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -O3
-
-LIBS=   $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) \
-       $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS) -lwdsp -lm -pthread
+OPTIONS=-g -Wno-deprecated-declarations $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) $(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) \
+                $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(RADIOBERRY_OPTIONS) $(PSK_OPTIONS) $(STEMLAB_OPTIONS) $(STEMLAB_FIX_OPTION) \
+                -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(PORTAUDIO_OPTIONS) $(ADDITIONAL_OPTIONS) -O3
 
+LIBS=-lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS)
 INCLUDES=$(GTKINCLUDES)
 
 COMPILE=$(CC) $(OPTIONS) $(INCLUDES)
@@ -480,7 +478,13 @@ release: $(PROGRAM)
 #       this is then stored *within* the app bundle.
 #
 #############################################################################
-app:  pihpsdr
+app:   $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) \
+               $(LOCALCW_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(PSK_OBJS) \
+               $(PURESIGNAL_OBJS) $(STEMLAB_OBJS)
+       $(LINK) -headerpad_max_install_names -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) \
+               $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(LIMESDR_OBJS) \
+               $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) \
+               $(STEMLAB_OBJS) $(LIBS)
        @rm -rf pihpsdr.app
        @mkdir -p pihpsdr.app/Contents/MacOS
        @mkdir -p pihpsdr.app/Contents/Frameworks
index 5f3f84aff7afdebee11a7ee9e0ce9b2ad9b05e41..80f48302a2aa6c9414352d7221304de8747c081e 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef _CONFIGURE_H
 #define _CONFIGURE_H
 
-#ifdef INCLUDE_GPIO
+#ifdef GPIO
 void configure_gpio(GtkWidget *parent);
 #endif
 
index 130740cbf6951235197f7ff77b7de2eaf8f1fe32..0cadd72388b2adcf1bfb7ba1fb548570636ec28d 100644 (file)
@@ -44,6 +44,7 @@
 #include "stemlab_discovery.h"
 #endif
 #include "ext.h"
+#include "configure.h"
 
 static GtkWidget *discovery_dialog;
 static DISCOVERED *d;
index aa3f2857b4d70eaf4b1bb9ac02ce9034af3fd27e..3f09a72b1c559a769cd09e3b51d10511ba2e8da4 100644 (file)
@@ -27,6 +27,9 @@
 #include "radio.h"
 #include "new_protocol.h"
 #include "old_protocol.h"
+#ifdef GPIO
+#include "gpio.h"
+#endif
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/gpio.c b/gpio.c
index 8f0db753aa2b27c623571e3f1b1a75a1813803e8..2e6590b40f6468f266f16d05e0aab5ccdcf259bb 100644 (file)
--- a/gpio.c
+++ b/gpio.c
 #endif
 #include "ext.h"
 #include "sliders.h"
+#include "new_protocol.h"
+#ifdef LOCALCW
+#include "iambic.h"
+#endif
 
 // debounce settle time in ms
 #define DEFAULT_SETTLE_TIME 150
@@ -969,23 +973,31 @@ fprintf(stderr,"setup_encoder_pin: pin=%d updown=%d\n",pin,up_down);
 }
 
 #ifdef LOCALCW
-#define BUTTON_STEADY_TIME_US 5000
-static void setup_button(int button, gpioAlertFunc_t pAlert) {
-  gpioSetMode(button, PI_INPUT);
-  gpioSetPullUpDown(button,PI_PUD_UP);
-  // give time to settle to avoid false triggers
-  usleep(10000);
-  gpioSetAlertFunc(button, pAlert);
-  gpioGlitchFilter(button, BUTTON_STEADY_TIME_US);
+
+static void setup_cw_pin(int pin, void(*pAlert)(void)) {
+fprintf(stderr,"setup_cw_pin: pin=%d \n",pin);
+   pinMode(pin,INPUT);
+   pullUpDnControl(pin,PUD_UP);
+   usleep(10000);
+   wiringPiISR(pin,INT_EDGE_BOTH,pAlert);
 }
 
-static void cwAlert(int gpio, int level, uint32_t tick) {
-    //fprintf(stderr,"cw key at pin %d \n", gpio);
-    if (cw_keyer_internal == 0 ){
-       //fprintf(stderr,"call keyer_event...\n");
-       keyer_event(gpio, cw_active_level == 0 ? level : (level==0));
-    }
+static void cwAlert_left() {
+       int level=digitalRead(CWL_BUTTON);
+       //fprintf(stderr,"cwl button : level=%d \n",level);
+   if (cw_keyer_internal == 0 ){
+      keyer_event(CWL_BUTTON, cw_active_level == 0 ? level : (level==0));
+   }
+}
+
+static void cwAlert_right() {
+       int level=digitalRead(CWR_BUTTON);
+       //fprintf(stderr,"cwr button : level=%d \n",level);
+   if (cw_keyer_internal == 0 ){
+      keyer_event(CWR_BUTTON, cw_active_level == 0 ? level : (level==0));
+   }
 }
+
 #endif
 
 int gpio_init() {
@@ -1115,8 +1127,8 @@ int gpio_init() {
 #ifdef LOCALCW
   fprintf(stderr,"GPIO: ENABLE_CW_BUTTONS=%d  CWL_BUTTON=%d CWR_BUTTON=%d\n", ENABLE_CW_BUTTONS, CWL_BUTTON, CWR_BUTTON);
   if(ENABLE_CW_BUTTONS) {      
-    setup_button(CWL_BUTTON, cwAlert);
-    setup_button(CWR_BUTTON, cwAlert);
+    setup_cw_pin(CWL_BUTTON, cwAlert_left);
+    setup_cw_pin(CWR_BUTTON, cwAlert_right);
   }
 #endif
 
@@ -1220,7 +1232,7 @@ static int vfo_encoder_changed(void *data) {
   return 0;
 }
 
-static encoder_changed(int action,int pos) {
+static void encoder_changed(int action,int pos) {
   double value;
   int mode;
   int id;
index f67fac421b68d98410dde517c5982ae9de35da41..bf29676c5095671770147cce9c144e1124968e7e 100644 (file)
--- a/iambic.h
+++ b/iambic.h
@@ -26,5 +26,6 @@ extern int *kdash;
 void keyer_event(int gpio, int level);
 void keyer_update();
 void keyer_close();
+int  keyer_init();
 
 #endif
diff --git a/main.c b/main.c
index ba908d4ec8ec6f2fbb19aaf270b75af169e8a8b1..75a757836b3eee6d1d9cc54d46c757ced113f8ee 100644 (file)
--- a/main.c
+++ b/main.c
@@ -203,7 +203,6 @@ static void activate_pihpsdr(GtkApplication *app, gpointer data) {
 
 fprintf(stderr,"width=%d height=%d\n", display_width, display_height);
 
-  // DL1YCF: use define'd constants here
   if(display_width>MAX_DISPLAY_WIDTH || display_height>MAX_DISPLAY_HEIGHT) {
     display_width=MAX_DISPLAY_WIDTH;
     display_height=MAX_DISPLAY_HEIGHT;
diff --git a/radio.c b/radio.c
index f0114c5384cb7d02b93aca2e069e09272031da09..537e02b3df7b900b590bc33a81608935bb442c5f 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -66,6 +66,9 @@
 #include "toolbar.h"
 #include "rigctl.h"
 #include "ext.h"
+#ifdef LOCALCW
+#include "iambic.h"
+#endif
 
 #define min(x,y) (x<y?x:y)
 #define max(x,y) (x<y?y:x)
index 991ec86f9a6cb372de1a4d14f75d0eb4003199b4..87904f74119d630b0c10764570a4ee72253439c9 100644 (file)
--- a/sliders.h
+++ b/sliders.h
 #ifndef _SLIDERS_H
 #define _SLIDERS_H
 
+// include these since we are using RECEIVER and TRANSMITTER
+#include "receiver.h"
+#include "transmitter.h"
+
 extern void att_type_changed(void);
 extern void update_att_preamp(void);
 
@@ -40,5 +44,6 @@ extern GtkWidget *sliders_init(int my_width, int my_height);
 extern void sliders_update();
 
 extern void set_squelch(RECEIVER* rx);
+extern void set_compression(TRANSMITTER *tx);
 
 #endif