+++ /dev/null
-/*
-
- 10/16/2016, Rick Koch / N1GP, added to give an alternative sidetone
- by using the RPi's audio output.
-
---------------------------------------------------------------------------------
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-This library 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
-Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the
-Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
-Boston, MA 02110-1301, USA.
---------------------------------------------------------------------------------
-
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <fcntl.h>
-#include <poll.h>
-#include <sched.h>
-#include <pthread.h>
-#include <signal.h>
-#include <semaphore.h>
-#include <math.h>
-#include <alsa/asoundlib.h>
-
-double beep_freq = 800; /* sinusoidal wave frequency in Hz */
-
-static char *device = "hw:0";
-static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */
-static unsigned int rate = 48000; /* stream rate */
-static unsigned int channels = 2; /* count of channels */
-static unsigned int buffer_time = 36000; /* ring buffer length in us */
-static unsigned int period_time = 6000; /* period time in us */
-static int period_event = 0; /* produce poll event after each period */
-static snd_pcm_sframes_t buffer_size;
-static snd_pcm_sframes_t period_size;
-static snd_output_t *output = NULL;
-
-static void* beep_thread(void *arg);
-static pthread_t beep_thread_id;
-
-static snd_pcm_t *handle;
-static signed short *samples;
-static snd_pcm_channel_area_t *areas;
-
-static void generate_sine(const snd_pcm_channel_area_t *areas,
- snd_pcm_uframes_t offset,
- int count, double *_phase)
-{
- static double max_phase = 2. * M_PI;
- double phase = *_phase;
- double step = max_phase*beep_freq/(double)rate;
- unsigned char *samples[channels];
- int steps[channels];
- unsigned int chn;
- int format_bits = snd_pcm_format_width(format);
- unsigned int maxval = (1 << (format_bits - 1)) - 1;
- int bps = format_bits / 8; /* bytes per sample */
- int phys_bps = snd_pcm_format_physical_width(format) / 8;
-
- /* verify and prepare the contents of areas */
- for (chn = 0; chn < channels; chn++) {
- if ((areas[chn].first % 8) != 0) {
- printf("areas[%i].first == %i, aborting...\n", chn, areas[chn].first);
- exit(EXIT_FAILURE);
- }
- samples[chn] = /*(signed short *)*/(((unsigned char *)areas[chn].addr) + (areas[chn].first / 8));
- if ((areas[chn].step % 16) != 0) {
- printf("areas[%i].step == %i, aborting...\n", chn, areas[chn].step);
- exit(EXIT_FAILURE);
- }
- steps[chn] = areas[chn].step / 8;
- samples[chn] += offset * steps[chn];
- }
- /* fill the channel areas */
- while (count-- > 0) {
- union {
- float f;
- int i;
- } fval;
- int res, i;
-
- res = sin(phase) * maxval;
- res ^= 1U << (format_bits - 1);
- for (chn = 0; chn < channels; chn++) {
- /* Generate data in native endian format */
- for (i = 0; i < bps; i++)
- *(samples[chn] + i) = (res >> i * 8) & 0xff;
- samples[chn] += steps[chn];
- }
- phase += step;
- if (phase >= max_phase)
- phase -= max_phase;
- }
- *_phase = phase;
-}
-
-static int xrun_recovery(snd_pcm_t *handle, int err)
-{
- if (err == -EPIPE) { /* under-run */
- err = snd_pcm_prepare(handle);
- if (err < 0)
- printf("Can't recovery from underrun, prepare failed: %s\n", snd_strerror(err));
- return 0;
- } else if (err == -ESTRPIPE) {
- while ((err = snd_pcm_resume(handle)) == -EAGAIN)
- sleep(1); /* wait until the suspend flag is released */
- if (err < 0) {
- err = snd_pcm_prepare(handle);
- if (err < 0)
- printf("Can't recovery from suspend, prepare failed: %s\n", snd_strerror(err));
- }
- return 0;
- }
- return err;
-}
-
-static int write_loop(snd_pcm_t *handle,
- signed short *samples,
- snd_pcm_channel_area_t *areas)
-{
- double phase = 0;
- signed short *ptr;
- int err, cptr;
-
- while (1) {
- generate_sine(areas, 0, period_size, &phase);
- ptr = samples;
- cptr = period_size;
- while (cptr > 0) {
- err = snd_pcm_writei(handle, ptr, cptr);
- if (err == -EAGAIN)
- continue;
- if (err < 0) {
- if (xrun_recovery(handle, err) < 0) {
- printf("Write error: %s\n", snd_strerror(err));
- exit(EXIT_FAILURE);
- }
- break; /* skip one period */
- }
- ptr += err * channels;
- cptr -= err;
- }
- }
-}
-
-static int set_hwparams(snd_pcm_t *handle,
- snd_pcm_hw_params_t *params,
- snd_pcm_access_t access)
-{
- unsigned int rrate;
- snd_pcm_uframes_t size;
- int err, dir;
- /* choose all parameters */
- err = snd_pcm_hw_params_any(handle, params);
- if (err < 0) {
- printf("Broken configuration for playback: no configurations available: %s\n", snd_strerror(err));
- return err;
- }
- /* set the interleaved read/write format */
- err = snd_pcm_hw_params_set_access(handle, params, access);
- if (err < 0) {
- printf("Access type not available for playback: %s\n", snd_strerror(err));
- return err;
- }
- /* set the sample format */
- err = snd_pcm_hw_params_set_format(handle, params, format);
- if (err < 0) {
- printf("Sample format not available for playback: %s\n", snd_strerror(err));
- return err;
- }
- /* set the count of channels */
- err = snd_pcm_hw_params_set_channels(handle, params, channels);
- if (err < 0) {
- printf("Channels count (%i) not available for playbacks: %s\n", channels, snd_strerror(err));
- return err;
- }
- /* set the stream rate */
- rrate = rate;
- err = snd_pcm_hw_params_set_rate_near(handle, params, &rrate, 0);
- if (err < 0) {
- printf("Rate %iHz not available for playback: %s\n", rate, snd_strerror(err));
- return err;
- }
- if (rrate != rate) {
- printf("Rate doesn't match (requested %iHz, get %iHz)\n", rate, err);
- return -EINVAL;
- }
- /* set the buffer time */
- err = snd_pcm_hw_params_set_buffer_time_near(handle, params, &buffer_time, &dir);
- if (err < 0) {
- printf("Unable to set buffer time %i for playback: %s\n", buffer_time, snd_strerror(err));
- return err;
- }
- err = snd_pcm_hw_params_get_buffer_size(params, &size);
- if (err < 0) {
- printf("Unable to get buffer size for playback: %s\n", snd_strerror(err));
- return err;
- }
- buffer_size = size;
- /* set the period time */
- err = snd_pcm_hw_params_set_period_time_near(handle, params, &period_time, &dir);
- if (err < 0) {
- printf("Unable to set period time %i for playback: %s\n", period_time, snd_strerror(err));
- return err;
- }
- err = snd_pcm_hw_params_get_period_size(params, &size, &dir);
- if (err < 0) {
- printf("Unable to get period size for playback: %s\n", snd_strerror(err));
- return err;
- }
- period_size = size;
- /* write the parameters to device */
- err = snd_pcm_hw_params(handle, params);
- if (err < 0) {
- printf("Unable to set hw params for playback: %s\n", snd_strerror(err));
- return err;
- }
- return 0;
-}
-
-static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams)
-{
- int err;
- /* get the current swparams */
- err = snd_pcm_sw_params_current(handle, swparams);
- if (err < 0) {
- printf("Unable to determine current swparams for playback: %s\n", snd_strerror(err));
- return err;
- }
- /* start the transfer when the buffer is almost full: */
- /* (buffer_size / avail_min) * avail_min */
- err = snd_pcm_sw_params_set_start_threshold(handle, swparams, (buffer_size / period_size) * period_size);
- if (err < 0) {
- printf("Unable to set start threshold mode for playback: %s\n", snd_strerror(err));
- return err;
- }
- /* allow the transfer when at least period_size samples can be processed */
- /* or disable this mechanism when period event is enabled (aka interrupt like style processing) */
- err = snd_pcm_sw_params_set_avail_min(handle, swparams, period_event ? buffer_size : period_size);
- if (err < 0) {
- printf("Unable to set avail min for playback: %s\n", snd_strerror(err));
- return err;
- }
- /* enable period events when requested */
- if (period_event) {
- err = snd_pcm_sw_params_set_period_event(handle, swparams, 1);
- if (err < 0) {
- printf("Unable to set period event: %s\n", snd_strerror(err));
- return err;
- }
- }
- /* write the parameters to the playback device */
- err = snd_pcm_sw_params(handle, swparams);
- if (err < 0) {
- printf("Unable to set sw params for playback: %s\n", snd_strerror(err));
- return err;
- }
- return 0;
-}
-
-void beep_mute(int mute)
-{
- int err;
- snd_ctl_elem_id_t *id;
- snd_hctl_elem_t *elem;
- snd_ctl_elem_value_t *control;
- snd_hctl_t *hctl;
-
- err = snd_hctl_open(&hctl, device, 0);
- err = snd_hctl_load(hctl);
- snd_ctl_elem_id_alloca(&id);
- snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
- snd_ctl_elem_id_set_name(id, "PCM Playback Switch");
-
- elem = snd_hctl_find_elem(hctl, id);
-
- snd_ctl_elem_value_alloca(&control);
- snd_ctl_elem_value_set_id(control, id);
-
- snd_ctl_elem_value_set_integer(control, 0, mute);
- err = snd_hctl_elem_write(elem, control);
- snd_hctl_close(hctl);
- if (err) fprintf(stderr, "ERROR beep_mute()\n");
-}
-
-void beep_vol(long volume)
-{
- long min, max, output;
- snd_mixer_selem_id_t *sid;
- snd_mixer_t *mhandle;
- const char *selem_name = "PCM";
- int do_once = 1;
- snd_mixer_elem_t* elem;
-
- beep_mute(1);
- if (volume > 100) volume = 100; // sounds raspy any higher
- if (volume < 0) volume = 0;
- snd_mixer_open(&mhandle, 0);
- snd_mixer_attach(mhandle, device);
- snd_mixer_selem_register(mhandle, NULL, NULL);
- snd_mixer_load(mhandle);
- snd_mixer_selem_id_alloca(&sid);
- snd_mixer_selem_id_set_index(sid, 0);
- snd_mixer_selem_id_set_name(sid, selem_name);
- elem = snd_mixer_find_selem(mhandle, sid);
- snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
- min = -2000; // PI's audio mixer range is broken
- output = (((max - min) * volume) / 100) + min;
- snd_mixer_selem_set_playback_volume_all(elem, output);
-
- beep_mute(0);
- snd_mixer_close(mhandle);
-}
-
-static void* beep_thread(void *arg) {
- int err;
- snd_pcm_hw_params_t *hwparams;
- snd_pcm_sw_params_t *swparams;
- unsigned int chn;
- snd_pcm_hw_params_alloca(&hwparams);
- snd_pcm_sw_params_alloca(&swparams);
-
- err = snd_output_stdio_attach(&output, stdout, 0);
- if (err < 0) {
- printf("Output failed: %s\n", snd_strerror(err));
- return 0;
- }
-
- if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
- printf("Playback open error: %s\n", snd_strerror(err));
- return 0;
- }
-
- if ((err = set_hwparams(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
- printf("Setting of hwparams failed: %s\n", snd_strerror(err));
- exit(EXIT_FAILURE);
- }
-
- if ((err = set_swparams(handle, swparams)) < 0) {
- printf("Setting of swparams failed: %s\n", snd_strerror(err));
- exit(EXIT_FAILURE);
- }
-
- samples = malloc((period_size * channels * snd_pcm_format_physical_width(format)) / 8);
- if (samples == NULL) {
- printf("No enough memory\n");
- exit(EXIT_FAILURE);
- }
-
- areas = calloc(channels, sizeof(snd_pcm_channel_area_t));
- if (areas == NULL) {
- printf("No enough memory\n");
- exit(EXIT_FAILURE);
- }
- for (chn = 0; chn < channels; chn++) {
- areas[chn].addr = samples;
- areas[chn].first = chn * snd_pcm_format_physical_width(format);
- areas[chn].step = channels * snd_pcm_format_physical_width(format);
- }
-
- write_loop(handle, samples, areas);
-
- free(areas);
- free(samples);
- snd_pcm_close(handle);
-
- return 0;
-}
-
-void beep_init() {
- int i = pthread_create(&beep_thread_id, NULL, beep_thread, NULL);
- if(i < 0) {
- fprintf(stderr,"pthread_create for beep_thread failed %d\n", i);
- exit(-1);
- }
-}
-
-void beep_close() {
-// beep_vol(0);
- beep_mute(1);
- pthread_cancel(beep_thread_id);
-}
+++ /dev/null
-#ifndef _BEEP_H
-#define _BEEP_H
-
-extern double beep_freq;
-
-void beep_vol(long volume);
-void beep_mute(int mute);
-void beep_init(void);
-void beep_close(void);
-
-#endif
+++ /dev/null
-/* 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 "transmitter.h"
-
-static GtkWidget *parent_window=NULL;
-
-static GtkWidget *dialog=NULL;
-
-static GtkWidget *last_band;
-
-static void cleanup() {
- if(dialog!=NULL) {
- gtk_widget_destroy(dialog);
- dialog=NULL;
- sub_menu=NULL;
- }
-}
-
-static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
- cleanup();
- return TRUE;
-}
-
-static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
- cleanup();
- return FALSE;
-}
-
-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;
- }
- tx_set_pre_emphasize(transmitter,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);
- gtk_window_set_title(GTK_WINDOW(dialog),"piHPSDR - FM");
- g_signal_connect (dialog, "delete_event", G_CALLBACK (delete_event), NULL);
-
- 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");
- 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);
-
-}
+++ /dev/null
-/* 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);
+++ /dev/null
-/* 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 <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "new_menu.h"
-#include "band.h"
-#include "filter.h"
-#include "mode.h"
-#include "radio.h"
-#include "receiver.h"
-#include "vfo.h"
-#include "button_text.h"
-#include "ext.h"
-
-static GtkWidget *parent_window=NULL;
-static GtkWidget *dialog=NULL;
-static GtkWidget *label;
-
-#define BUF_SIZE 88
-
-static char *btn_labels[] = {"1","2","3","4",
- "5","6","7","8",
- "9","0",".","BS",
- "Hz","kHz","MHz","CR"
- };
-
-static void cleanup() {
- if(dialog!=NULL) {
- gtk_widget_destroy(dialog);
- dialog=NULL;
- sub_menu=NULL;
- }
-}
-
-static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
- cleanup();
- return TRUE;
-}
-
-static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
- cleanup();
- return FALSE;
-}
-
-static gboolean freqent_select_cb (GtkWidget *widget, gpointer data) {
- char *str = (char *) data;
- const char *labelText;
- char output[BUF_SIZE], buffer[BUF_SIZE];
- int len;
- double mult;
- long long f;
- static int set = 0;
-
- if (set) {
- set = 0;
- strcpy (buffer, "0");
- sprintf(output, "<big>%s</big>", buffer);
- gtk_label_set_markup (GTK_LABEL (label), output);
- len = 1;
- } else {
- labelText = gtk_label_get_text (GTK_LABEL (label));
- strcpy (buffer, labelText);
- len = strlen (buffer);
- }
-
- if (isdigit (str[0]) || str[0] == '.') {
-
- buffer[len] = (gchar) str[0];
- buffer[len+1] = (gchar) 0;
-
- len = (buffer[0] == '0') ? 1 : 0;
-
- sprintf(output, "<big>%s</big>", buffer+len);
- gtk_label_set_markup (GTK_LABEL (label), output);
- } else {
-
- mult=0.0;
- if (strcmp (str, "BS") == 0) {
- /* --- Remove the last character on it. --- */
- if (len > 0) buffer[len-1] = (gchar) 0;
-
- /* --- Remove digit from field. --- */
- sprintf(output, "<big>%s</big>", buffer);
- gtk_label_set_markup (GTK_LABEL (label), output);
-
- /* --- clear? --- */
- } else if (strcmp (str, "CR") == 0) {
- strcpy (buffer, "0");
- sprintf(output, "<big>%s</big>", buffer);
- gtk_label_set_markup (GTK_LABEL (label), output);
- } else if(strcmp(str,"Hz")==0) {
- mult=10.0;
- } else if(strcmp(str,"kHz")==0) {
- mult=10000.0;
- } else if(strcmp(str,"MHz")==0) {
- mult=10000000.0;
- }
- if(mult!=0.0) {
- f = ((long long)(atof(buffer)*mult)+5)/10;
- sprintf(output, "<big>%lld</big>", f);
- gtk_label_set_markup (GTK_LABEL (label), output);
- if(radio_is_remote) {
- send_vfo_frequency(client_socket,active_receiver->id,f);
- } else {
- int b=get_band_from_frequency(f);
- if(b!=band_get_current()) {
- BAND *band=band_set_current(b);
- set_mode(active_receiver,entry->mode);
- FILTER* band_filters=filters[entry->mode];
- FILTER* band_filter=&band_filters[entry->filter];
- set_filter(active_receiver,band_filter->low,band_filter->high);
- if(active_receiver->id==0) {
- set_alex_rx_antenna();
- set_alex_tx_antenna();
- // set_alex_attenuation(band->alexAttenuation); // nowhere maintained
- }
- }
- setFrequency(f);
- g_idle_add(ext_vfo_update,NULL);
- }
- set = 1;
- }
- }
- g_idle_add(ext_vfo_update,NULL);
- return FALSE;
-}
-
-static GtkWidget *last_mode;
-
-void freqent_menu(GtkWidget *parent) {
- 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);
- char title[64];
- sprintf(title,"piHPSDR - Frequency Entry (RX %d VFO %s)",active_receiver->id,active_receiver->id==0?"A":"B");
- gtk_window_set_title(GTK_WINDOW(dialog),title);
- g_signal_connect (dialog, "delete_event", G_CALLBACK (delete_event), NULL);
-
- 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),4);
- gtk_grid_set_row_spacing (GTK_GRID(grid),4);
-
- GtkWidget *close_b=gtk_button_new_with_label("Close");
- g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
- gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), "<big>0</big>");
- gtk_misc_set_alignment (GTK_MISC (label), 1, .5);
- gtk_grid_attach(GTK_GRID(grid),label,1,0,2,1);
-
- GtkWidget *step_rb=NULL;
- for (i=0; i<16; i++) {
- GtkWidget *b=gtk_button_new_with_label(btn_labels[i]);
- set_button_text_color(b,"black");
- gtk_widget_show(b);
- gtk_grid_attach(GTK_GRID(grid),b,i%4,1+(i/4),1,1);
- g_signal_connect(b,"pressed",G_CALLBACK(freqent_select_cb),(gpointer *)btn_labels[i]);
- }
-
- gtk_container_add(GTK_CONTAINER(content),grid);
-
- sub_menu=dialog;
-
- gtk_widget_show_all(dialog);
-
-}
+++ /dev/null
-/* 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.
-*
-*/
-
-extern void freqent_menu(GtkWidget *parent);
+++ /dev/null
-/* Copyright (C)
-* 2015 - 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 <semaphore.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "new_menu.h"
-#include "general_menu.h"
-#include "band.h"
-#include "filter.h"
-#include "radio.h"
-#include "receiver.h"
-
-static GtkWidget *parent_window=NULL;
-
-static GtkWidget *menu_b=NULL;
-
-static GtkWidget *dialog=NULL;
-
-static void cleanup() {
- if(dialog!=NULL) {
- gtk_widget_destroy(dialog);
- dialog=NULL;
- sub_menu=NULL;
- }
-}
-
-static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
- cleanup();
- return TRUE;
-}
-
-static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
- cleanup();
- return FALSE;
-}
-
-static void vfo_divisor_value_changed_cb(GtkWidget *widget, gpointer data) {
- vfo_encoder_divisor=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
-}
-
-/*
-static void toolbar_dialog_buttons_cb(GtkWidget *widget, gpointer data) {
- toolbar_dialog_buttons=toolbar_dialog_buttons==1?0:1;
- update_toolbar_labels();
-}
-*/
-
-static void ptt_cb(GtkWidget *widget, gpointer data) {
- mic_ptt_enabled=mic_ptt_enabled==1?0:1;
-}
-
-static void ptt_ring_cb(GtkWidget *widget, gpointer data) {
- mic_ptt_tip_bias_ring=0;
-}
-
-static void ptt_tip_cb(GtkWidget *widget, gpointer data) {
- mic_ptt_tip_bias_ring=1;
-}
-
-static void bias_cb(GtkWidget *widget, gpointer data) {
- mic_bias_enabled=mic_bias_enabled==1?0:1;
-}
-
-static void apollo_cb(GtkWidget *widget, gpointer data);
-
-static void alex_cb(GtkWidget *widget, gpointer data) {
- if(filter_board==ALEX) {
- filter_board=NONE;
- } else if(filter_board==NONE) {
- filter_board=ALEX;
- } else if(filter_board==APOLLO) {
- GtkWidget *w=(GtkWidget *)data;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), FALSE);
- filter_board=ALEX;
- }
-
- if(protocol==NEW_PROTOCOL) {
- filter_board_changed();
- }
-
- if(filter_board==ALEX) {
- BAND *band=band_get_current_band();
- BANDSTACK_ENTRY* entry=bandstack_entry_get_current();
- setFrequency(entry->frequency);
- //setMode(entry->mode);
- set_mode(active_receiver,entry->mode);
- FILTER* band_filters=filters[entry->mode];
- FILTER* band_filter=&band_filters[entry->filter];
- //setFilter(band_filter->low,band_filter->high);
- set_filter(active_receiver,band_filter->low,band_filter->high);
- if(active_receiver->id==0) {
- set_alex_rx_antenna();
- set_alex_tx_antenna();
- // set_alex_attenuation(band->alexAttenuation); // nowhere maintained
- }
- }
-}
-
-static void apollo_cb(GtkWidget *widget, gpointer data) {
- if(filter_board==APOLLO) {
- filter_board=NONE;
- } else if(filter_board==NONE) {
- filter_board=APOLLO;
- } else if(filter_board==ALEX) {
- GtkWidget *w=(GtkWidget *)data;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), FALSE);
- filter_board=APOLLO;
- }
- if(protocol==NEW_PROTOCOL) {
- filter_board_changed();
- }
-
- if(filter_board==APOLLO) {
- BAND *band=band_get_current_band();
- BANDSTACK_ENTRY* entry=bandstack_entry_get_current();
- setFrequency(entry->frequency);
- //setMode(entry->mode);
- set_mode(active_receiver,entry->mode);
- FILTER* band_filters=filters[entry->mode];
- FILTER* band_filter=&band_filters[entry->filter];
- //setFilter(band_filter->low,band_filter->high);
- set_filter(active_receiver,band_filter->low,band_filter->high);
- }
-}
-
-static void sample_rate_cb(GtkWidget *widget, gpointer data) {
- radio_change_sample_rate((int)data);
-}
-
-static void rit_cb(GtkWidget *widget,gpointer data) {
- rit_increment=(int)data;
-}
-
-void general_menu(GtkWidget *parent) {
- 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);
- gtk_window_set_title(GTK_WINDOW(dialog),"piHPSDR - General");
- g_signal_connect (dialog, "delete_event", G_CALLBACK (delete_event), NULL);
-
- 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_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);
-
- GtkWidget *close_b=gtk_button_new_with_label("Close");
- g_signal_connect (close_b, "button_press_event", G_CALLBACK(close_cb), NULL);
- gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);
-
- GtkWidget *vfo_divisor_label=gtk_label_new("VFO Encoder Divisor: ");
- gtk_grid_attach(GTK_GRID(grid),vfo_divisor_label,4,1,1,1);
-
- GtkWidget *vfo_divisor=gtk_spin_button_new_with_range(1.0,60.0,1.0);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(vfo_divisor),(double)vfo_encoder_divisor);
- gtk_grid_attach(GTK_GRID(grid),vfo_divisor,4,2,1,1);
- g_signal_connect(vfo_divisor,"value_changed",G_CALLBACK(vfo_divisor_value_changed_cb),NULL);
-
- if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL){
-
- if((protocol==NEW_PROTOCOL && device==NEW_DEVICE_ORION) ||
- (protocol==NEW_PROTOCOL && device==NEW_DEVICE_ORION2) ||
- (protocol==ORIGINAL_PROTOCOL && device==DEVICE_ORION) ||
- (protocol==ORIGINAL_PROTOCOL && device==DEVICE_ORION2)) {
-
- GtkWidget *ptt_ring_b=gtk_radio_button_new_with_label(NULL,"PTT On Ring, Mic and Bias on Tip");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ptt_ring_b), mic_ptt_tip_bias_ring==0);
- gtk_grid_attach(GTK_GRID(grid),ptt_ring_b,3,1,1,1);
- g_signal_connect(ptt_ring_b,"pressed",G_CALLBACK(ptt_ring_cb),NULL);
-
- GtkWidget *ptt_tip_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(ptt_ring_b),"PTT On Tip, Mic and Bias on Ring");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ptt_tip_b), mic_ptt_tip_bias_ring==1);
- gtk_grid_attach(GTK_GRID(grid),ptt_tip_b,3,2,1,1);
- g_signal_connect(ptt_tip_b,"pressed",G_CALLBACK(ptt_tip_cb),NULL);
-
- GtkWidget *ptt_b=gtk_check_button_new_with_label("PTT Enabled");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ptt_b), mic_ptt_enabled);
- gtk_grid_attach(GTK_GRID(grid),ptt_b,3,3,1,1);
- g_signal_connect(ptt_b,"toggled",G_CALLBACK(ptt_cb),NULL);
-
- GtkWidget *bias_b=gtk_check_button_new_with_label("BIAS Enabled");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bias_b), mic_bias_enabled);
- gtk_grid_attach(GTK_GRID(grid),bias_b,3,4,1,1);
- g_signal_connect(bias_b,"toggled",G_CALLBACK(bias_cb),NULL);
- }
-
- GtkWidget *alex_b=gtk_check_button_new_with_label("ALEX");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alex_b), filter_board==ALEX);
- gtk_grid_attach(GTK_GRID(grid),alex_b,1,1,1,1);
-
- GtkWidget *apollo_b=gtk_check_button_new_with_label("APOLLO");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (apollo_b), filter_board==APOLLO);
- gtk_grid_attach(GTK_GRID(grid),apollo_b,1,2,1,1);
-
- g_signal_connect(alex_b,"toggled",G_CALLBACK(alex_cb),apollo_b);
- g_signal_connect(apollo_b,"toggled",G_CALLBACK(apollo_cb),alex_b);
- }
-
- GtkWidget *sample_rate_label=gtk_label_new("Sample Rate:");
- gtk_grid_attach(GTK_GRID(grid),sample_rate_label,0,1,1,1);
-
- if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL){
- GtkWidget *sample_rate_48=gtk_radio_button_new_with_label(NULL,"48000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_48), sample_rate==48000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_48,0,2,1,1);
- g_signal_connect(sample_rate_48,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)48000);
-
- GtkWidget *sample_rate_96=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_48),"96000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_96), sample_rate==96000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_96,0,3,1,1);
- g_signal_connect(sample_rate_96,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)96000);
-
- GtkWidget *sample_rate_192=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_96),"192000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_192), sample_rate==192000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_192,0,4,1,1);
- g_signal_connect(sample_rate_192,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)192000);
-
- GtkWidget *sample_rate_384=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_192),"384000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_384), sample_rate==384000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_384,0,5,1,1);
- g_signal_connect(sample_rate_384,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)384000);
-
- if(protocol==NEW_PROTOCOL) {
- GtkWidget *sample_rate_768=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_384),"768000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_768), sample_rate==768000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_768,0,6,1,1);
- g_signal_connect(sample_rate_768,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)768000);
-
- GtkWidget *sample_rate_1536=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_768),"1536000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_1536), sample_rate==1536000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_1536,0,7,1,1);
- g_signal_connect(sample_rate_1536,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)1536000);
-
-#ifdef GPIO
- gtk_widget_set_sensitive(sample_rate_768,FALSE);
- gtk_widget_set_sensitive(sample_rate_1536,FALSE);
-#endif
- }
-
- }
-
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- GtkWidget *sample_rate_1M=gtk_radio_button_new_with_label(NULL,"1000000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_1M), sample_rate==1000000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_1M,0,2,1,1);
- g_signal_connect(sample_rate_1M,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)1000000);
-
- GtkWidget *sample_rate_2M=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_1M),"2000000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_2M), sample_rate==2000000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_2M,0,3,1,1);
- g_signal_connect(sample_rate_2M,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)2000000);
-
- }
-#endif
-
-
- GtkWidget *rit_label=gtk_label_new("RIT step: ");
- gtk_grid_attach(GTK_GRID(grid),rit_label,5,1,1,1);
-
- GtkWidget *rit_1=gtk_radio_button_new_with_label(NULL,"1 Hz");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rit_1), rit_increment==1);
- gtk_grid_attach(GTK_GRID(grid),rit_1,5,2,1,1);
- g_signal_connect(rit_1,"pressed",G_CALLBACK(rit_cb),(gpointer *)1);
-
- GtkWidget *rit_10=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rit_1),"10");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rit_10), rit_increment==10);
- gtk_grid_attach(GTK_GRID(grid),rit_10,5,3,1,1);
- g_signal_connect(rit_10,"pressed",G_CALLBACK(rit_cb),(gpointer *)10);
-
- GtkWidget *rit_100=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rit_10),"100");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rit_100), rit_increment==100);
- gtk_grid_attach(GTK_GRID(grid),rit_100,5,4,1,1);
- g_signal_connect(rit_100,"pressed",G_CALLBACK(rit_cb),(gpointer *)100);
-
- gtk_container_add(GTK_CONTAINER(content),grid);
-
- sub_menu=dialog;
-
- gtk_widget_show_all(dialog);
-
-}
-
+++ /dev/null
-/* Copyright (C)
-* 2015 - 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 void general_menu(GtkWidget *parent);