Skip to content

Commit

Permalink
a little cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dl1ycf committed Aug 6, 2018
1 parent 4efaf1b commit 1dfa052
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 55 deletions.
35 changes: 29 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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= \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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` \
Expand All @@ -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`

Expand All @@ -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)
Expand Down
64 changes: 34 additions & 30 deletions Makefile.mac
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef _CONFIGURE_H
#define _CONFIGURE_H

#ifdef INCLUDE_GPIO
#ifdef GPIO
void configure_gpio(GtkWidget *parent);
#endif

Expand Down
1 change: 1 addition & 0 deletions discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "stemlab_discovery.h"
#endif
#include "ext.h"
#include "configure.h"

static GtkWidget *discovery_dialog;
static DISCOVERED *d;
Expand Down
3 changes: 3 additions & 0 deletions exit_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
46 changes: 29 additions & 17 deletions gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions iambic.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ extern int *kdash;
void keyer_event(int gpio, int level);
void keyer_update();
void keyer_close();
int keyer_init();

#endif
1 change: 0 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions sliders.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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

0 comments on commit 1dfa052

Please sign in to comment.