}
}
-//
-// Upon each band change, the TX mode needs be specified again.
-// For HPSDR, one also needs new RX/TX antenna and PA calibration/disable settings.
-// For TX, this must also happen when changing the active receiver or the "split" status.
-// To avoid code duplications, the necessary actions are bundled here.
-// If the attenuation is stored with the band, this should also be adjusted here
-//
-void radio_band_changed() {
+void set_alex_antennas() {
+ //
+ // Obtain band of VFO-A and transmitter, set ALEX RX/TX antennas
+ // This function is a no-op when running SOAPY.
+ // This function also takes care of updating the PA dis/enable
+ // status for P2.
+ //
BAND *band;
if (protocol == ORIGINAL_PROTOCOL || protocol == NEW_PROTOCOL) {
- //
- // Obtain band of VFO-A and transmitter, set ALEX RX/TX antennas
- //
band=band_get_band(vfo[VFO_A].band);
receiver[0]->alex_antenna=band->alexRxAntenna;
receiver[0]->alex_attenuation=band->alexAttenuation;
transmitter->alex_antenna=band->alexTxAntenna;
}
}
+ if (protocol == NEW_PROTOCOL) {
+ schedule_high_priority(); // possibly update RX/TX antennas
+ schedule_general(); // possibly update PA disable
+ }
+}
+
+void tx_vfo_changed() {
+ //
+ // When changing the active receiver or changing the split status,
+ // the VFO that controls the transmitter my flip between VFOA/VFOB.
+ // In these cases, we have to update the TX mode,
+ // and re-calculate the drive level from the band-specific PA calibration
+ // values. For SOAPY, the only thing to do is the update the TX mode.
+ //
+ // Note each time tx_vfo_changed() is called, calling set_alex_antennas()
+ // is also due.
+ //
if (can_transmit) {
tx_set_mode(transmitter,get_tx_mode());
calcDriveLevel();
}
-
if (protocol == NEW_PROTOCOL) {
schedule_high_priority(); // possibly update RX/TX antennas
schedule_general(); // possibly update PA disable
}
}
-//
-// For HPSDR, only receiver[0]->alex_attenuation has an effect
-//
void set_alex_attenuation(int v) {
+ //
+ // The value of the "old" ALEX step-attenuator is stored in
+ // the receiver[0] data structure
+ //
BAND *band;
if (protocol == ORIGINAL_PROTOCOL || protocol == NEW_PROTOCOL) {
//
}
}
-//
-// Interface to set split state
-//
void radio_set_split(int val) {
+ //
+ // "split" *must only* be set through this interface,
+ // since it may change the TX band
+ //
if (can_transmit) {
split=val;
- radio_band_changed();
+ tx_vfo_changed();
+ set_alex_antennas();
g_idle_add(ext_vfo_update, NULL);
}
}
}
break;
}
- radio_band_changed();
-
- switch(protocol) {
- case NEW_PROTOCOL:
- schedule_general();
- break;
+ tx_vfo_changed();
+ set_alex_antennas(); // This includes scheduling hiprio and general packets
#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_set_rx_frequency(active_receiver,id);
- break;
-#endif
+ //
+ // This is strange, since it already done via receiver_vfo_changed()
+ // correctly and the present code seems to be wrong if
+ // (receivers == 1 && id == 1) or (receivers == 2 && id == 0)
+ //
+ if (protocol == SOAPYSDR_PROTOCOL) {
+ soapy_protocol_set_rx_frequency(active_receiver,id);
}
+#endif
g_idle_add(ext_vfo_update,NULL);
}
}
break;
}
- //
- // I do not think the band can change within this function.
- // But out of paranoia, I consider this possiblity here
- //
- radio_band_changed();
+ tx_vfo_changed();
+ set_alex_antennas(); // This includes scheduling hiprio and general packets
g_idle_add(ext_vfo_update,NULL);
-
}
void vfo_mode_changed(int m) {
if(receivers==2) {
receiver_vfo_changed(receiver[1]);
}
- radio_band_changed();
+ tx_vfo_changed();
+ set_alex_antennas(); // This includes scheduling hiprio and general packets
g_idle_add(ext_vfo_update,NULL);
}
vfo[VFO_A].offset=vfo[VFO_B].offset;
receiver_vfo_changed(receiver[0]);
- radio_band_changed();
+ tx_vfo_changed();
+ set_alex_antennas(); // This includes scheduling hiprio and general packets
g_idle_add(ext_vfo_update,NULL);
}
if(receivers==2) {
receiver_vfo_changed(receiver[1]);
}
- radio_band_changed();
+ tx_vfo_changed();
+ set_alex_antennas(); // This includes scheduling hiprio and general packets
g_idle_add(ext_vfo_update,NULL);
}
if (receivers == 2) {
// VFO v controls a running WDSP receiver,
// need to "manually change" it.
+ // DO NOT DO IT HERE. Better add a "RECEIVER *rx" argument
+ // to setFrequency in radio.c
}
}
g_idle_add(ext_vfo_update, NULL);