#I2C_INCLUDE=I2C
#uncomment the line below for the platform being compiled on
-UNAME_N=raspberrypi
+#UNAME_N=raspberrypi
#UNAME_N=odroid
#UNAME_N=up
#UNAME_N=pine64
-#UNAME_N=x86
+UNAME_N=x86
CC=gcc
LINK=gcc
update.c \
store.c \
store_menu.c \
-memory.c
+memory.c \
+led.c
HEADERS= \
update.h \
store.h \
store_menu.h \
-memory.h
+memory.h \
+led.h
OBJS= \
update.o \
store.o \
store_menu.o \
-memory.o
+memory.o \
+led.o
all: prebuild $(PROGRAM) $(HEADERS) $(USBOZY_HEADERS) $(LIMESDR_HEADERS) $(FREEDV_HEADERS) $(LOCALCW_HEADERS) $(I2C_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) $(SOURCES) $(USBOZY_SOURCES) $(LIMESDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) $(PSK_SOURCES)
--- /dev/null
+/* Copyright (C)
+* 2017 - 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>
+
+static GtkWidget *led;
+
+static double red=0.0;
+static double green=1.0;
+static double blue=0.0;
+
+
+static gboolean draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data) {
+ cairo_set_source_rgb(cr, red, green, blue);
+ cairo_paint(cr);
+ return FALSE;
+}
+
+void led_set_color(double r,double g,double b) {
+ red=r;
+ green=g;
+ blue=b;
+ gtk_widget_queue_draw (led);
+}
+
+GtkWidget *create_led(int width,int height) {
+ led=gtk_drawing_area_new();
+ gtk_widget_set_size_request(led,width,height);
+
+ g_signal_connect (led, "draw", G_CALLBACK (draw_cb), NULL);
+
+ return led;
+}
--- /dev/null
+/* Copyright (C)
+* 2017 - 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.
+*
+*/
+
+
+extern GtkWidget *create_led(int width,int height);
+extern void led_set_color(double r,double g,double b);
static double bandwidth=3000000.0;
+static int lime_sample_rate=
static size_t receiver;
static SoapySDRDevice *lime_device;
static SoapySDRStream *stream;
static int running;
-void lime_protocol_init(int rx,int pixels) {
+void lime_protocol_init(int rx,int pixels,int sample_rate) {
SoapySDRKwargs args;
int rc;
-fprintf(stderr,"lime_protocol_init: receiver=%d pixels=%d\n",rx,pixels);
+fprintf(stderr,"lime_protocol_init: receiver=%d pixels=%d sample_rate=%d\n",rx,pixels,sample_rate);
receiver=(size_t)rx;
display_width=pixels;
+ lime_sample_rate=sample_rate;
outputsamples=BUFFER_SIZE/(sample_rate/48000);
/*
fprintf(stderr,"lime_protocol: forced actual_rate\n");
}
+void lime_protocol_change_sample_rate(int rate) {
+}
+
fprintf(stderr,"lime_protocol: setting bandwidth =%f\n",bandwidth);
rc=SoapySDRDevice_setBandwidth(lime_device,SOAPY_SDR_RX,receiver,bandwidth);
if(rc!=0) {
gdk_window_set_cursor(gtk_widget_get_window(top_window),gdk_cursor_new(GDK_ARROW));
for(i=0;i<MAX_VFOS;i++) {
- fprintf(stderr,"start_radio: vfo %d band=%d bandstack=%d frequency=%lld mode=%d filter=%d rit=%lld lo=%%ld offset=%lld\n",
+ fprintf(stderr,"start_radio: vfo %d band=%d bandstack=%d frequency=%lld mode=%d filter=%d rit=%lld lo=%lld offset=%lld\n",
i,
vfo[i].band,
vfo[i].bandstack,
break;
#ifdef LIMESDR
case LIMESDR_PROTOCOL:
+ lime_protocol_change_sample_rate(rate);
break;
#endif
}
}
static void vox_cb(GtkWidget *widget, gpointer data) {
- vox=vox==1?0:1;
+ vox_enabled=vox_enabled==1?0:1;
vfo_update(NULL);
}
cairo_set_font_size(cr, 12);
cairo_show_text(cr, temp_text);
- cairo_move_to(cr, 210, 15);
+ cairo_move_to(cr, 190, 15);
+ if(vox_enabled) {
+ cairo_set_source_rgb(cr, 1, 0, 0);
+ } else {
+ cairo_set_source_rgb(cr, 0.7, 0.7, 0.7);
+ }
+ cairo_show_text(cr, "VOX");
+
+ cairo_move_to(cr, 220, 15);
if(locked) {
cairo_set_source_rgb(cr, 1, 0, 0);
} else {
static double peak=0.0;
static int vox_timeout_cb(gpointer data) {
+fprintf(stderr,"vox timeout\n");
setVox(0);
g_idle_add(vfo_update,NULL);
return FALSE;
}
}
-//fprintf(stderr,"update_vox: id=%d peak=%f\n",tx->id,peak);
if(vox_enabled) {
- double threshold=vox_threshold;
-
-//fprintf(stderr,"update_vox: peak=%f threshold=%f\n",peak,threshold);
-
- if(peak>threshold) {
+fprintf(stderr,"update_vox: id=%d peak=%f threshold=%f enabled=%d\n",tx->id,peak,vox_threshold,vox_enabled);
+ if(peak>vox_threshold) {
if(previous_vox) {
g_source_remove(vox_timeout);
} else {
#include <string.h>
#include <pthread.h>
+#include "led.h"
#include "new_menu.h"
#include "radio.h"
#include "transmitter.h"
static GtkWidget *level;
-GThread *level_thread_id;
+static GtkWidget *led;
+
+static GdkRGBA white={1.0,1.0,1.0,1.0};
+static GdkRGBA red={1.0,0.0,0.0,1.0};
+static GdkRGBA green={0.0,1.0,0.1,1.0};
+
+static GThread *level_thread_id;
static int run_level=0;
static double peak=0.0;
+static gint vox_timeout;
+static int hold=0;
+
+static int vox_timeout_cb(gpointer data) {
+ hold=0;
+ return FALSE;
+}
static int level_update(void *data) {
-//fprintf(stderr,"vox peak=%f\n",peak);
+ char title[16];
+fprintf(stderr,"vox peak=%f threshold=%f\n",peak,vox_threshold);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(level),peak);
+
+ if(peak>vox_threshold) {
+ // red indicator
+ led_set_color(1.0,0.0,0.0); // red
+ if(hold==0) {
+ hold=1;
+ } else {
+ g_source_remove(vox_timeout);
+ }
+ vox_timeout=g_timeout_add((int)vox_hang,vox_timeout_cb,NULL);
+ } else {
+ // green indicator
+ if(hold==0) {
+ led_set_color(0.0,1.0,0.0); // green
+ }
+ }
return 0;
}
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);
+ gtk_widget_override_background_color(dialog,GTK_STATE_FLAG_NORMAL,&white);
GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
gtk_grid_set_column_spacing (GTK_GRID(grid),10);
gtk_grid_set_row_spacing (GTK_GRID(grid),10);
//gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
- //gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
+ gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
GtkWidget *close_b=gtk_button_new_with_label("Close VOX");
g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);
+ led=create_led(10,10);
+ gtk_grid_attach(GTK_GRID(grid),led,2,0,1,1);
+
GtkWidget *level_label=gtk_label_new("Mic Level:");
gtk_misc_set_alignment (GTK_MISC(level_label), 0, 0);
gtk_widget_show(level_label);
gtk_grid_attach(GTK_GRID(grid),level_label,0,1,1,1);
level=gtk_progress_bar_new();
- gtk_widget_set_size_request (level, 300, 25);
+// gtk_widget_set_size_request (level, 300, 25);
gtk_widget_show(level);
- gtk_grid_attach(GTK_GRID(grid),level,1,1,1,1);
+ gtk_grid_attach(GTK_GRID(grid),level,1,1,3,1);
GtkWidget *threshold_label=gtk_label_new("VOX Threshold:");
gtk_misc_set_alignment (GTK_MISC(threshold_label), 0, 0);
gtk_grid_attach(GTK_GRID(grid),threshold_label,0,2,1,1);
GtkWidget *vox_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0,1000.0,1.0);
- gtk_widget_set_size_request (vox_scale, 300, 25);
+// gtk_widget_set_size_request (vox_scale, 300, 25);
gtk_range_set_value(GTK_RANGE(vox_scale),vox_threshold*1000.0);
gtk_widget_show(vox_scale);
- gtk_grid_attach(GTK_GRID(grid),vox_scale,1,2,1,1);
+ gtk_grid_attach(GTK_GRID(grid),vox_scale,1,2,3,1);
g_signal_connect(G_OBJECT(vox_scale),"value_changed",G_CALLBACK(vox_value_changed_cb),NULL);
GtkWidget *hang_label=gtk_label_new("VOX Hang (ms):");
GtkWidget *vox_hang_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0,1000.0,1.0);
gtk_range_set_value(GTK_RANGE(vox_hang_scale),vox_hang);
gtk_widget_show(vox_hang_scale);
- gtk_grid_attach(GTK_GRID(grid),vox_hang_scale,1,4,1,1);
+ gtk_grid_attach(GTK_GRID(grid),vox_hang_scale,1,4,3,1);
g_signal_connect(G_OBJECT(vox_hang_scale),"value_changed",G_CALLBACK(vox_hang_value_changed_cb),NULL);
gtk_container_add(GTK_CONTAINER(content),grid);