-
Notifications
You must be signed in to change notification settings - Fork 45
/
radio_info.c
150 lines (119 loc) · 4.57 KB
/
radio_info.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* Copyright (C)
* 2018 - 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 <math.h>
#include <wdsp.h>
#include "discovered.h"
#include "bpsk.h"
#include "adc.h"
#include "dac.h"
#include "receiver.h"
#include "transmitter.h"
#include "wideband.h"
#include "radio.h"
#include "radio_info.h"
#include "main.h"
#include "vfo.h"
#include "configure_dialog.h"
#ifdef MIDI
static gboolean midi_b_press_cb(GtkWidget *widget,GdkEvent *event,gpointer data) {
RECEIVER *rx=(RECEIVER *)data;
if(radio->dialog==NULL) {
int tab=rx_base+radio->receivers+(radio->can_transmit?4:0);
radio->dialog=create_configure_dialog(radio,tab);
}
return TRUE;
}
#endif
GtkWidget *create_radio_info_visual(RECEIVER *rx) {
RADIO_INFO *info=g_new(RADIO_INFO,1);
info->radio_info=gtk_layout_new(NULL,NULL);
gtk_widget_set_name(info->radio_info,"info");
int x=0;
int y=10;
// ********** WARNINGS ****************************
// HL2 Buffer over/underflow
if (radio->discovered->device == DEVICE_HERMES_LITE2) {
info->buffer_overflow_underflow_b=gtk_toggle_button_new_with_label("BUF");
gtk_widget_set_name(info->buffer_overflow_underflow_b,"info-warning");
gtk_layout_put(GTK_LAYOUT(info->radio_info),info->buffer_overflow_underflow_b,x,y);
x+=40;
}
// HERMES/HL2 ADC Clipping
info->adc_overload_b=gtk_toggle_button_new_with_label("ADC");
gtk_widget_set_name(info->adc_overload_b,"info-warning");
gtk_layout_put(GTK_LAYOUT(info->radio_info),info->adc_overload_b,x,y);
x+=40;
// SWR is above a threshold
info->swr_b=gtk_toggle_button_new_with_label("SWR");
gtk_widget_set_name(info->swr_b,"info-warning");
gtk_layout_put(GTK_LAYOUT(info->radio_info),info->swr_b,x,y);
x+=40;
if (radio->discovered->device == DEVICE_HERMES_LITE2) {
info->temp_b=gtk_toggle_button_new_with_label("TEMP");
gtk_widget_set_name(info->temp_b,"info-warning");
gtk_layout_put(GTK_LAYOUT(info->radio_info),info->temp_b,x,y);
x+=40;
}
x=0;
y=36;
// CAT
info->cat_b=gtk_toggle_button_new_with_label("CAT");
gtk_widget_set_name(info->cat_b,"info-button");
gtk_layout_put(GTK_LAYOUT(info->radio_info),info->cat_b,x,y);
x+=40;
#ifdef MIDI
// MIDI
info->midi_b=gtk_toggle_button_new_with_label("MIDI");
gtk_widget_set_name(info->midi_b,"info-button");
g_signal_connect(info->midi_b, "button_press_event", G_CALLBACK(midi_b_press_cb),rx);
gtk_layout_put(GTK_LAYOUT(info->radio_info),info->midi_b,x,y);
x+=40;
#endif
#ifdef CWDAEMON
info->cwdaemon_b=gtk_toggle_button_new_with_label("CWX");
gtk_widget_set_name(info->cwdaemon_b,"info-button");
gtk_layout_put(GTK_LAYOUT(info->radio_info),info->cwdaemon_b,x,y);
#endif
g_object_set_data ((GObject *)info->radio_info,"info_data",info);
return info->radio_info;
}
extern int midi_rx;
void update_radio_info(RECEIVER *rx) {
RADIO_INFO *info=(RADIO_INFO *)g_object_get_data((GObject *)rx->radio_info,"info_data");
if(info==NULL) return;
if (radio->discovered->device == DEVICE_HERMES_LITE2) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(info->adc_overload_b),radio->adc_overload && (!isTransmitting(radio)));
}
if (radio->discovered->device == DEVICE_HERMES_LITE2) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(info->temp_b),radio->transmitter->temperature>radio->temperature_alarm_value);
}
if (radio->transmitter!=NULL) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(info->swr_b),radio->transmitter->swr>radio->swr_alarm_value);
}
#ifdef MIDI
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(info->midi_b),radio->midi_enabled && (radio->receiver[midi_rx]->channel==rx->channel));
#endif
#ifdef CWDAEMON
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(info->cwdaemon_b),radio->cwdaemon);
#endif
if (radio->discovered->device == DEVICE_HERMES_LITE2) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(info->temp_b),radio->transmitter->temperature>radio->temperature_alarm_value);
}
}