From: c vw <dl1ycf@darc.de>
Date: Mon, 6 Aug 2018 09:03:37 +0000 (+0200)
Subject: a little cleanup
X-Git-Url: https://git.rkrishnan.org/uri/htmlfontify-example.html?a=commitdiff_plain;h=1dfa0528950f1e227fc1f13e5f597b826a11d4be;p=pihpsdr.git

a little cleanup
---

diff --git a/Makefile b/Makefile
index c2b5d51..a4147dc 100644
--- 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)
diff --git a/Makefile.mac b/Makefile.mac
index b551b64..0b8d67a 100644
--- a/Makefile.mac
+++ b/Makefile.mac
@@ -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
diff --git a/configure.h b/configure.h
index 5f3f84a..80f4830 100644
--- a/configure.h
+++ b/configure.h
@@ -21,7 +21,7 @@
 #ifndef _CONFIGURE_H
 #define _CONFIGURE_H
 
-#ifdef INCLUDE_GPIO
+#ifdef GPIO
 void configure_gpio(GtkWidget *parent);
 #endif
 
diff --git a/discovery.c b/discovery.c
index 130740c..0cadd72 100644
--- a/discovery.c
+++ b/discovery.c
@@ -44,6 +44,7 @@
 #include "stemlab_discovery.h"
 #endif
 #include "ext.h"
+#include "configure.h"
 
 static GtkWidget *discovery_dialog;
 static DISCOVERED *d;
diff --git a/exit_menu.c b/exit_menu.c
index aa3f285..3f09a72 100644
--- a/exit_menu.c
+++ b/exit_menu.c
@@ -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 8f0db75..2e6590b 100644
--- a/gpio.c
+++ b/gpio.c
@@ -56,6 +56,10 @@
 #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;
diff --git a/iambic.h b/iambic.h
index f67fac4..bf29676 100644
--- 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 ba908d4..75a7578 100644
--- 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 f0114c5..537e02b 100644
--- 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)
diff --git a/sliders.h b/sliders.h
index 991ec86..87904f7 100644
--- a/sliders.h
+++ b/sliders.h
@@ -20,6 +20,10 @@
 #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