// The following calls functions can be called usig g_idle_add
+// DL1YCF: added interface for mode change, to be used by rigctl
+// (MD command)
+int ext_vfo_mode_changed(void * data)
+{
+ vfo_mode_changed((int) (long) data);
+ return 0;
+}
+
int ext_discovery(void *data) {
discovery();
return 0;
extern int ext_ps_twotone(void *data);
#endif
int ext_vfo_step(void *data);
+int ext_vfo_mode_changed(void *data);
}
#ifdef LOCALCW
-#ifdef RADIOBERRY
#define BUTTON_STEADY_TIME_US 5000
static void setup_button(int button, gpioAlertFunc_t pAlert) {
gpioSetMode(button, PI_INPUT);
}
static void cwAlert(int gpio, int level, uint32_t tick) {
- //fprintf(stderr,"cw key at pin %d \n", gpio);
+ //fprintf(stderr,"cw key at pin %d \n", gpio);
if (cw_keyer_internal == 0 ){
- //fprintf(stderr,"call keyer_event...\n");
+ //fprintf(stderr,"call keyer_event...\n");
keyer_event(gpio, cw_active_level == 0 ? level : (level==0));
- }
+ }
}
#endif
-#endif
int gpio_init() {
int i;
#endif
#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) {
- #ifdef RADIOBERRY
- setup_button(CWL_BUTTON, cwAlert);
- setup_button(CWR_BUTTON, cwAlert);
- #endif
- }
+ 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);
+ }
#endif
return 0;
static int mic_buffer_size;
static int audio_buffer_size=256;
+//
+// compile with DummyTwoTone defined, and you will have an
+// additional "microphone" device producing a two-tone signal
+// with 700 and 1900 Hz.
+//
+#ifdef DummyTwoTone
//
// Dummy Two-tone input device
//
#define lentab 480
static float sintab[lentab];
static int tonept;
-#define twopi 6.2831853071795864769252867665590
-#define factab (twopi/480)
+#define factab 0.013089969389957471826927680763665 // 2 Pi / 480
+#endif
//
PaError err;
- // generate sine tab
- for (i=0; i< lentab; i++) sintab[i] = 0.35*(sin(7*i*factab)+sin(19*i*factab));
+#ifdef DummyTwoTone
+ // generate sine tab, 700 and 1900 Hz.
+ for (i=0; i< lentab; i++) sintab[i] = 0.45*(sin(7*i*factab)+sin(19*i*factab));
+#endif
err = Pa_Initialize();
if( err != paNoError )
inputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
inputParameters.hostApiSpecificStreamInfo = NULL;
if (Pa_IsFormatSupported(&inputParameters, NULL, 48000.0) == paFormatIsSupported) {
+#ifdef DummyTwoTone
// duplicate the first suitable device, this will become
// a dummy two-tone generator
if (n_input_devices == 0) {
input_devices[n_input_devices]="TwoTone";
in_device_no[n_input_devices++] =i;
}
+#endif
if (n_input_devices < MAXDEVICES) {
input_devices[n_input_devices]=deviceInfo->name;
in_device_no[n_input_devices++] =i;
}
mic_buffer=(unsigned char *)malloc(2*framesPerBuffer);
mic_buffer_size=framesPerBuffer;
+#ifdef DummyTwoTone
TwoTone=0;
if (transmitter->input_device == 0) {
tonept=0;
TwoTone=1;
}
+#endif
return 0;
}
//
// Convert input buffer in paFloat32 into a sequence of 16-bit
-// values in the mic buffer
+// values in the mic buffer. If using the dummy Two-Tone
+// device, mic input will be discarded and a two-tone
+// signal produced instead.
//
if (mic_buffer == NULL) return paAbort;
*p++ = 0;
*p++ = 0;
}
+#ifdef DummyTwoTone
} else if (TwoTone == 0) {
+#else
+ } else {
+#endif
for (i=0; i<framesPerBuffer; i++) {
isample=(short) (in[i]*32768.0);
- *p++ = (isample & 0xFF); // LittleEndian
- *p++ = (isample >> 8)& 0xFF;
+ *p++ = (isample & 0xFF); // LittleEndian
+ *p++ = (isample >> 8)& 0xFF;
}
+#ifdef DummyTwoTone
} else {
for (i=0; i<framesPerBuffer; i++) {
- isample=(short) (sintab[tonept++]*32768.0);
+ isample=(short) (sintab[tonept++]*32767.0);
if (tonept == lentab) tonept=0;
*p++ = (isample & 0xFF); // LittleEndian
*p++ = (isample >> 8)& 0xFF;
}
+#endif
}
//
// Call routine to send mic buffer
fprintf(stderr,"MD command Unknown\n");
#endif
}
+#if 0
// Other stuff to switch modes goes here..
// since new_mode has the interpreted command in
// in it now.
set_filter(active_receiver,band_filter->low,band_filter->high);
/* Need a way to update VFO info here..*/
g_idle_add(ext_vfo_update,NULL);
+#endif
+ // DL1YCF: I do not understand why the above code is so complicated.
+ // It is also problematic that the mode of the transmitter
+ // is not updated. I think one should simply behave as if
+ // a mode change had been selected from the menu. To this
+ // end, I added an interface for vfo_mode_changed in ext.c,
+ // to be able to call it using g_idle_add.
+ g_idle_add(ext_vfo_mode_changed, (void *) (long) new_mode);
} else { // Read Mode
int curr_mode;
switch (vfo[active_receiver->id].mode) {