From 4019cd963280a2f2ddfc405f1ef3be875ead28e4 Mon Sep 17 00:00:00 2001 From: DL1YCF Date: Fri, 27 Dec 2019 14:21:35 +0100 Subject: [PATCH] Support for HermesLite --- discovered.h | 32 +++++++------ hpsdrsim.c | 53 +++++++++++++++------ hpsdrsim.h | 20 ++++---- new_discovery.c | 5 ++ newhpsdrsim.c | 1 + old_discovery.c | 10 ++-- old_protocol.c | 106 +++++++++++++++++++++++++++--------------- radio.c | 120 ++++++++++++++++++++++++++++++++---------------- radio.h | 3 +- receiver.c | 1 + sliders.c | 72 ++++++++++++++--------------- transmitter.c | 2 + 12 files changed, 269 insertions(+), 156 deletions(-) diff --git a/discovered.h b/discovered.h index 6c80b16..79e08fd 100644 --- a/discovered.h +++ b/discovered.h @@ -28,28 +28,30 @@ #define MAX_DEVICES 16 -#define DEVICE_METIS 0 -#define DEVICE_HERMES 1 -#define DEVICE_GRIFFIN 2 -#define DEVICE_ANGELIA 4 -#define DEVICE_ORION 5 -#define DEVICE_HERMES_LITE 6 // ANAN 7000DLE and 8000DLE uses 10 as the device type in old protocol -#define DEVICE_ORION2 10 // Newer STEMlab hpsdr emulators use 100 instead of 1 -#define DEVICE_STEMLAB 100 +#define DEVICE_METIS 0 +#define DEVICE_HERMES 1 +#define DEVICE_GRIFFIN 2 +#define DEVICE_ANGELIA 4 +#define DEVICE_ORION 5 +#define DEVICE_HERMES_LITE 6 +#define DEVICE_HERMES_LITE2 7 +#define DEVICE_ORION2 10 +#define DEVICE_STEMLAB 100 #ifdef USBOZY #define DEVICE_OZY 7 #endif -#define NEW_DEVICE_ATLAS 0 -#define NEW_DEVICE_HERMES 1 -#define NEW_DEVICE_HERMES2 2 -#define NEW_DEVICE_ANGELIA 3 -#define NEW_DEVICE_ORION 4 -#define NEW_DEVICE_ORION2 5 -#define NEW_DEVICE_HERMES_LITE 6 +#define NEW_DEVICE_ATLAS 0 +#define NEW_DEVICE_HERMES 1 +#define NEW_DEVICE_HERMES2 2 +#define NEW_DEVICE_ANGELIA 3 +#define NEW_DEVICE_ORION 4 +#define NEW_DEVICE_ORION2 5 +#define NEW_DEVICE_HERMES_LITE 6 +#define NEW_DEVICE_HERMES_LITE2 7 #ifdef SOAPYSDR #define SOAPYSDR_USB_DEVICE 0 diff --git a/hpsdrsim.c b/hpsdrsim.c index 9ed2bb9..005b8c1 100644 --- a/hpsdrsim.c +++ b/hpsdrsim.c @@ -205,7 +205,7 @@ int main(int argc, char *argv[]) double run,off,inc; /* - * Examples for ATLAS: ATLAS bus with Mercury/Penelope boards + * Examples for METIS: ATLAS bus with Mercury/Penelope boards * Examples for HERMES: ANAN10, ANAN100 * Examples for ANGELIA: ANAN100D * Examples for ORION: ANAN200D @@ -221,13 +221,14 @@ int main(int argc, char *argv[]) NEWDEVICE=NEW_DEVICE_ORION2; for (i=1; i> 0, MetisDB9 , "MetisDB9"); chk_data((frame[3] & 0x10) >> 4, MerTxATT1 , "Mercury Att on TX/1"); - chk_data((frame[4] & 0x1F) >> 0, rx_att[0], "RX1 ATT"); - chk_data((frame[4] & 0x20) >> 5, rx1_attE, "RX1 ATT enable"); - + if (frame[4] & 0x40) { + // Some firmware/emulators use bit6 to indicate a 6-bit format + // for a combined attenuator/preamplifier with the AD9866 chip. + // The value is between 0 and 60 and formally correspondes to + // to an RX gain of -12 to +48 dB. However the front-end hardware + // determines which is the correct "zero level", that is, the gain + // which corresponds to full-amplitude IQ samples for a 0 dBm input. + // Experimentally, we set this "zero level" to +16 dB that (that is, + // a RxGain value of 28). So the "attenuation" is (28 -G) where G + // is the RXgain value. + // NOTE: according to the AD9866 data sheet, this "calibration value" + // should be 22 instead of 28, while a value of 31 is used + // by the HermesLite firmware when bit6 is not set. + // + chk_data(28 -(frame[4] & 0x3F) , rx_att[0], "RX1 HL ATT/GAIN"); + } else { + chk_data((frame[4] & 0x1F) >> 0, rx_att[0], "RX1 ATT"); + chk_data((frame[4] & 0x20) >> 5, rx1_attE, "RX1 ATT enable"); + // + // Some hardware emulates "switching off ATT and preamp" by setting ATT + // to 20 dB, because the preamp cannot be switched. + // if (!rx1_attE) rx_att[0]=20; + } if (OLDDEVICE != DEVICE_C25) { // Set RX amplification factors. No switchable preamps available normally. rxatt_dbl[0]=pow(10.0, -0.05*(10*AlexAtt+rx_att[0])); @@ -1280,12 +1303,12 @@ void *handler_ep6(void *arg) myqsample=0; break; } - if (OLDDEVICE == DEVICE_ATLAS && ptt && (k==1)) { + if ((OLDDEVICE == DEVICE_METIS || OLDDEVICE == DEVICE_HERMES_LITE) && ptt && (k==1)) { // METIS: TX DAC signal goes to RX2 when TXing myisample=dacisample; myqsample=dacqsample; } - if ((OLDDEVICE==DEVICE_HERMES || OLDDEVICE==DEVICE_HERMES2 || OLDDEVICE==DEVICE_C25) && ptt && (k==3)) { + if ((OLDDEVICE==DEVICE_HERMES || OLDDEVICE==DEVICE_GRIFFIN || OLDDEVICE==DEVICE_C25 || OLDDEVICE==DEVICE_HERMES_LITE2) && ptt && (k==3)) { // HERMES: TX DAC signal goes to RX4 when TXing myisample=dacisample; myqsample=dacqsample; diff --git a/hpsdrsim.h b/hpsdrsim.h index e89b041..f7c16e8 100644 --- a/hpsdrsim.h +++ b/hpsdrsim.h @@ -16,22 +16,24 @@ // differes in old and new protocol // -#define DEVICE_ATLAS 0 +#define DEVICE_METIS 0 #define DEVICE_HERMES 1 -#define DEVICE_HERMES2 2 +#define DEVICE_GRIFFIN 2 #define DEVICE_ANGELIA 4 #define DEVICE_ORION 5 #define DEVICE_HERMES_LITE 6 +#define DEVICE_HERMES_LITE2 7 #define DEVICE_ORION2 10 #define DEVICE_C25 100 -#define NEW_DEVICE_ATLAS 0 -#define NEW_DEVICE_HERMES 1 -#define NEW_DEVICE_HERMES2 2 -#define NEW_DEVICE_ANGELIA 3 -#define NEW_DEVICE_ORION 4 -#define NEW_DEVICE_ORION2 5 -#define NEW_DEVICE_HERMES_LITE 6 +#define NEW_DEVICE_ATLAS 0 +#define NEW_DEVICE_HERMES 1 +#define NEW_DEVICE_HERMES2 2 +#define NEW_DEVICE_ANGELIA 3 +#define NEW_DEVICE_ORION 4 +#define NEW_DEVICE_ORION2 5 +#define NEW_DEVICE_HERMES_LITE 6 +#define NEW_DEVICE_HERMES_LITE2 7 EXTERN int OLDDEVICE; EXTERN int NEWDEVICE; diff --git a/new_discovery.c b/new_discovery.c index 41ad20f..ac0e55a 100644 --- a/new_discovery.c +++ b/new_discovery.c @@ -253,6 +253,11 @@ gpointer new_discover_receive_thread(gpointer data) { frequency_min=0.0; frequency_max=30720000.0; break; + case NEW_DEVICE_HERMES_LITE2: + strcpy(discovered[devices].name,"Hermes Lite 2"); + frequency_min=0.0; + frequency_max=30720000.0; + break; default: strcpy(discovered[devices].name,"Unknown"); frequency_min=0.0; diff --git a/newhpsdrsim.c b/newhpsdrsim.c index 17eafc2..f0b26be 100644 --- a/newhpsdrsim.c +++ b/newhpsdrsim.c @@ -714,6 +714,7 @@ void *highprio_thread(void *data) { } // rxatt0 depends both on ALEX att and Step Att, so re-calc. it each time if (NEWDEVICE == NEW_DEVICE_ORION2) { + // There is no step attenuator on ANAN7000 rxatt0_dbl=pow(10.0, -0.05*stepatt0); } else { rxatt0_dbl=pow(10.0, -0.05*(stepatt0+10*alex0[14]+20*alex0[13])); diff --git a/old_discovery.c b/old_discovery.c index d1c83c8..d63409c 100644 --- a/old_discovery.c +++ b/old_discovery.c @@ -433,11 +433,13 @@ fprintf(stderr,"discover_receive_thread\n"); discovered[devices].frequency_max=61440000.0; break; case DEVICE_HERMES_LITE: -#ifdef RADIOBERRY - strcpy(discovered[devices].name,"Radioberry"); -#else + // could also be a RadioBerry disguising itself as HermesLite strcpy(discovered[devices].name,"Hermes Lite"); -#endif + discovered[devices].frequency_min=0.0; + discovered[devices].frequency_max=30720000.0; + break; + case DEVICE_HERMES_LITE2: + strcpy(discovered[devices].name,"Hermes Lite 2"); discovered[devices].frequency_min=0.0; discovered[devices].frequency_max=30720000.0; break; diff --git a/old_protocol.c b/old_protocol.c index 6fbf533..b9df299 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -606,10 +606,12 @@ static int rx_feedback_channel() { int ret; switch (device) { case DEVICE_METIS: + case DEVICE_HERMES_LITE: ret=0; break; case DEVICE_HERMES: case DEVICE_STEMLAB: + case DEVICE_HERMES_LITE2: ret=2; break; case DEVICE_ANGELIA: @@ -631,10 +633,12 @@ static int tx_feedback_channel() { int ret; switch (device) { case DEVICE_METIS: + case DEVICE_HERMES_LITE: ret=1; break; case DEVICE_HERMES: case DEVICE_STEMLAB: + case DEVICE_HERMES_LITE2: ret=3; break; case DEVICE_ANGELIA: @@ -662,15 +666,19 @@ static int second_receiver_channel() { // Depending on the device and whether we compiled for PURESIGNAL, // return the channel number of the second receiver // + int ret=1; #ifdef PURESIGNAL - if(device==DEVICE_HERMES_LITE) { - return 1; - } else { - return 2; + switch (device) { + case DEVICE_METIS: + case DEVICE_HERMES_LITE: + ret=1; + break; + default: + ret=2; + break; } -#else - return 1; #endif + return ret; } static long long channel_freq(int chan) { @@ -767,7 +775,8 @@ static long long channel_freq(int chan) { } } else { // - // determine frequency associated with VFO #vfonum + // determine RX frequency associated with VFO #vfonum + // This is the center freq in CTUN mode. // freq=vfo[vfonum].frequency-vfo[vfonum].lo; if(vfo[vfonum].rit_enabled) { @@ -787,15 +796,9 @@ static long long channel_freq(int chan) { static int how_many_receivers() { // // Depending on how the program is compiled and which board we have, - // we use a FIXED number of receivers except for RADIOBERRY, - // where the number may be dynamically changed + // we use a FIXED number of receivers. // - int ret; -#ifdef RADIOBERRY - ret = receivers; // 1 or 2 -#else - ret = RECEIVERS; // 2 -#endif + int ret = RECEIVERS; #ifdef PURESIGNAL // for PureSignal, the number of receivers needed is hard-coded below. @@ -803,8 +806,13 @@ static int how_many_receivers() { // the TX DAC is hard-wired to RX4 for HERMES,STEMLAB and to RX5 for ANGELIA // and beyond. switch (device) { + case DEVICE_METIS: + case DEVICE_HERMES_LITE: + ret=2; // TX feedback hard-wired to RX2 + break; case DEVICE_HERMES: case DEVICE_STEMLAB: + case DEVICE_HERMES_LITE2: ret=4; // TX feedback hard-wired to RX4 break; case DEVICE_ANGELIA: @@ -813,11 +821,7 @@ static int how_many_receivers() { ret=5; // TX feedback hard-wired to RX5 break; default: - // - // older FPGAs support no more than two receivers - // then TX feedback is wired to RX2 - // - ret=2; + ret=2; // This is the minimum for PURESIGNAL break; } #endif @@ -1165,18 +1169,23 @@ void ozy_send_buffer() { if(active_receiver->random) { output_buffer[C3]|=LT2208_RANDOM_ON; } + // + // RadioBerry seems to encode the RXgain different from HERMES_LITE: + // the dither bit is hi-jacked for bit5 of RXgain + if (have_rx_gain) { #ifdef RADIOBERRY - if (rx_gain_slider[active_receiver->adc] > 31) - { - output_buffer[C3]|=LT2208_DITHER_OFF;} - else { + // adc_attenuation is in the range 28 ... -32 and maps to 0 ... 60 + if (adc_attenuation[active_receiver->adc] > 3) { // RxGain > 31 + output_buffer[C3]|=LT2208_DITHER_OFF; + } else { output_buffer[C3]|=LT2208_DITHER_ON; } -#else +#endif + } else { if(active_receiver->dither) { output_buffer[C3]|=LT2208_DITHER_ON; } -#endif + } if (filter_board == CHARLY25 && active_receiver->preamp) { output_buffer[C3]|=LT2208_GAIN_ON; } @@ -1449,20 +1458,45 @@ void ozy_send_buffer() { output_buffer[C3]=0x00; output_buffer[C4]=0x00; -#ifdef RADIOBERRY - int att = 63 - rx_gain_slider[active_receiver->adc]; - output_buffer[C4]=0x20|att; -#else - // must set bit 5 ("Att enable") all the time // upon TX, use transmitter->attenuation // Usually the firmware takes care of this, but it is no // harm to do this here as well - if (isTransmitting()) { - output_buffer[C4]=0x20 | (transmitter->attenuation & 0x1F); - } else { - output_buffer[C4]=0x20 | (adc_attenuation[0] & 0x1F); - } + if (have_rx_gain) { + // + // HERMESlite has a RXgain value in the range 0-60 that + // is stored in gx_gain_slider. The firmware uses bit 6 + // of C4 to determine this case. However RadioBerry seems + // to behave differently and stores bit5 of the gain in the + // dither bit (see above) and a 5-bit attenuation value here. + // +#ifdef RADIOBERRY + // adc_attenuation is in the range 28 ... -32 + int att = 28 + adc_attenuationctive_receiver->adc]; // RxGain: 0 ... 60 + if (att < 0) att=0; + if (att > 60) att=60; + if (att > 31) att -= 32; // high bit set above in dither + if (isTransmitting()) { + output_buffer[C4]=0x20 | (transmitter->attenuation & 0x1F); + } else { + output_buffer[C4]=0x20|att; + } +#else + int att = 28 - adc_attenuation[active_receiver->adc]; + if (att < 0) att=0; + if (att > 60) att=60; + if (isTransmitting()) { + output_buffer[C4] = 0x40 | (31 - (transmitter->attenuation & 0x1F)); + } else { + output_buffer[C4] = 0x40 | att; + } #endif + } else { + if (isTransmitting()) { + output_buffer[C4]=0x20 | (transmitter->attenuation & 0x1F); + } else { + output_buffer[C4]=0x20 | (adc_attenuation[0] & 0x1F); + } + } break; case 5: output_buffer[C0]=0x16; diff --git a/radio.c b/radio.c index acf2b8e..193ae59 100644 --- a/radio.c +++ b/radio.c @@ -258,6 +258,7 @@ int mox=0; int tune=0; int memory_tune=0; int full_tune=0; +int have_rx_gain=0; //long long displayFrequency=14250000; //long long ddsFrequency=14250000; @@ -419,7 +420,46 @@ void start_radio() { int rc; - switch(radio->protocol) { + protocol=radio->protocol; + device=radio->device; + + // + // have_rx_gain determines whether we have "ATT" or "RX Gain" Sliders + // It is set for HermesLite (and RadioBerry, for that matter) + // + have_rx_gain=0; + switch (protocol) { + case ORIGINAL_PROTOCOL: + switch (device) { + case DEVICE_HERMES_LITE: + case DEVICE_HERMES_LITE2: + have_rx_gain=1; + break; + default: + have_rx_gain=0; + break; + } + break; + case NEW_PROTOCOL: + switch (device) { + case NEW_DEVICE_HERMES_LITE: + case NEW_DEVICE_HERMES_LITE2: + have_rx_gain=1; + break; + default: + have_rx_gain=0; + break; + } + break; + default: + have_rx_gain=0; + break; + } + + // + // can_transmit decides whether we have a transmitter. + // + switch(protocol) { case ORIGINAL_PROTOCOL: case NEW_PROTOCOL: can_transmit=1; @@ -432,7 +472,9 @@ void start_radio() { #endif } - +// +// A semaphore for safely writing to the props file +// #ifdef __APPLE__ sem_unlink("PROPERTY"); property_sem=sem_open("PROPERTY", O_CREAT | O_EXCL, 0700, 0); @@ -450,18 +492,21 @@ void start_radio() { sem_post(&property_sem); #endif +// +// Create text for the top line of the piHPSDR window +// char text[256]; - switch(radio->protocol) { + switch(protocol) { case ORIGINAL_PROTOCOL: case NEW_PROTOCOL: #ifdef USBOZY - if(radio->device==DEVICE_OZY) { - sprintf(text,"%s (%s) on USB /dev/ozy\n", radio->name, radio->protocol==ORIGINAL_PROTOCOL?"Protocol 1":"Protocol 2"); + if(device==DEVICE_OZY) { + sprintf(text,"%s (%s) on USB /dev/ozy\n", radio->name, protocol==ORIGINAL_PROTOCOL?"Protocol 1":"Protocol 2"); } else { #endif sprintf(text,"Starting %s (%s v%d.%d)", radio->name, - radio->protocol==ORIGINAL_PROTOCOL?"Protocol 1":"Protocol 2", + protocol==ORIGINAL_PROTOCOL?"Protocol 1":"Protocol 2", radio->software_version/10, radio->software_version%10); #ifdef USBOZY @@ -477,7 +522,7 @@ void start_radio() { char ip[32]; char iface[32]; - switch(radio->protocol) { + switch(protocol) { case ORIGINAL_PROTOCOL: strcpy(p,"Protocol 1"); sprintf(version,"v%d.%d)", @@ -526,7 +571,7 @@ void start_radio() { case ORIGINAL_PROTOCOL: case NEW_PROTOCOL: #ifdef USBOZY - if(radio->device==DEVICE_OZY) { + if(device==DEVICE_OZY) { sprintf(text,"%s (%s) on USB /dev/ozy\n", radio->name, p); } else { #endif @@ -560,13 +605,13 @@ void start_radio() { gtk_window_set_title (GTK_WINDOW (top_window), text); - protocol=radio->protocol; - device=radio->device; - - switch(radio->protocol) { +// +// determine name of the props file +// + switch(protocol) { case ORIGINAL_PROTOCOL: case NEW_PROTOCOL: - switch(radio->device) { + switch(device) { #ifdef USBOZY case DEVICE_OZY: sprintf(property_path,"ozy.props"); @@ -590,9 +635,9 @@ void start_radio() { #endif } - switch(radio->protocol) { + switch(protocol) { case ORIGINAL_PROTOCOL: - switch(radio->device) { + switch(device) { case DEVICE_ORION2: //meter_calibration=3.0; //display_calibration=3.36; @@ -604,7 +649,7 @@ void start_radio() { } break; case NEW_PROTOCOL: - switch(radio->device) { + switch(device) { case NEW_DEVICE_ORION2: //meter_calibration=3.0; //display_calibration=3.36; @@ -617,14 +662,16 @@ void start_radio() { break; } - // Code moved here from rx_menu because n_adc is of general interest: - // Determine Number of ADCs. + // + // Determine number of ADCs in the device + // switch(protocol) { case ORIGINAL_PROTOCOL: switch(device) { case DEVICE_METIS: // No support for multiple MERCURY cards on a single ATLAS bus. case DEVICE_HERMES: case DEVICE_HERMES_LITE: + case DEVICE_HERMES_LITE2: n_adc=1; break; default: @@ -640,6 +687,7 @@ void start_radio() { case NEW_DEVICE_HERMES: case NEW_DEVICE_HERMES2: case NEW_DEVICE_HERMES_LITE: + case NEW_DEVICE_HERMES_LITE2: n_adc=1; break; default: @@ -663,7 +711,7 @@ void start_radio() { iqswap=0; #ifdef SOAPYSDR - if(radio->device==SOAPYSDR_USB_DEVICE) { + if(device==SOAPYSDR_USB_DEVICE) { iqswap=1; receivers=1; } @@ -671,8 +719,6 @@ void start_radio() { adc_attenuation[0]=0; adc_attenuation[1]=0; - rx_gain_slider[0] = 0; - rx_gain_slider[1] = 0; adc[0].antenna=ANTENNA_1; adc[0].filters=AUTOMATIC; @@ -684,7 +730,7 @@ void start_radio() { adc[0].attenuation=0; #ifdef SOAPYSDR adc[0].antenna=2; // LNAL - if(radio->device==SOAPYSDR_USB_DEVICE) { + if(device==SOAPYSDR_USB_DEVICE) { adc[0].rx_gain=malloc(radio->info.soapy.rx_gains*sizeof(gint)); for (size_t i = 0; i < radio->info.soapy.rx_gains; i++) { adc[0].rx_gain[i]=0; @@ -708,7 +754,7 @@ void start_radio() { adc[1].attenuation=0; #ifdef SOAPYSDR adc[1].antenna=3; // LNAW - if(radio->device==SOAPYSDR_USB_DEVICE) { + if(device==SOAPYSDR_USB_DEVICE) { adc[1].rx_gain=malloc(radio->info.soapy.rx_gains*sizeof(gint)); for (size_t i = 0; i < radio->info.soapy.rx_gains; i++) { adc[1].rx_gain[i]=0; @@ -828,6 +874,9 @@ void start_radio() { set_offset(receiver[i],vfo[i].offset); } + // + // Sanity check: in old protocol, all receivers must have the same sample rate + // if((protocol==ORIGINAL_PROTOCOL) && (RECEIVERS==2) && (receiver[0]->sample_rate!=receiver[1]->sample_rate)) { receiver[1]->sample_rate=receiver[0]->sample_rate; } @@ -874,7 +923,7 @@ void start_radio() { } #endif - switch(radio->protocol) { + switch(protocol) { case ORIGINAL_PROTOCOL: old_protocol_init(0,display_width,receiver[0]->sample_rate); break; @@ -996,7 +1045,8 @@ void start_radio() { // // MIDIstartup must not be called before the radio is completely set up, since - // then MIDI can asynchronously trigger actions + // then MIDI can asynchronously trigger actions which require the radio already + // running. So this is the last thing we do when starting the radio. // #ifdef MIDI MIDIstartup(); @@ -1205,7 +1255,7 @@ void frequency_changed(RECEIVER *rx) { SetRXAShiftFreq(rx->id, (double)vfo[0].offset); RXANBPSetShiftFrequency(rx->id, (double)vfo[0].offset); #ifdef SOAPYSDR - if(radio->protocol==SOAPYSDR_PROTOCOL) { + if(protocol==SOAPYSDR_PROTOCOL) { /* if(radio->can_transmit) { if(radio->transmitter!=NULL && radio->transmitter->rx==rx) { @@ -1216,10 +1266,10 @@ void frequency_changed(RECEIVER *rx) { } #endif } else { - if(radio->protocol==NEW_PROTOCOL) { + if(protocol==NEW_PROTOCOL) { schedule_high_priority(); #ifdef SOAPYSDR - } else if(radio->protocol==SOAPYSDR_PROTOCOL) { + } else if(protocol==SOAPYSDR_PROTOCOL) { soapy_protocol_set_rx_frequency(rx,VFO_A); /* if(radio->can_transmit) { @@ -1734,11 +1784,6 @@ fprintf(stderr,"radioRestoreState: %s\n",property_path); value=getProperty("adc_1_attenuation"); if(value) adc_attenuation[1]=atoi(value); - value=getProperty("rx1_gain_slider"); - if(value) rx_gain_slider[0]=atoi(value); - value=getProperty("rx2_gain_slider"); - if(value) rx_gain_slider[1]=atoi(value); - value=getProperty("split"); if(value) split=atoi(value); value=getProperty("duplex"); @@ -1747,7 +1792,7 @@ fprintf(stderr,"radioRestoreState: %s\n",property_path); if(value) sat_mode=atoi(value); #ifdef SOAPYSDR - if(radio->device==SOAPYSDR_USB_DEVICE) { + if(device==SOAPYSDR_USB_DEVICE) { char name[128]; for(int i=0;iinfo.soapy.rx_gains;i++) { sprintf(name,"radio.adc[0].rx_gain.%s",radio->info.soapy.rx_gain[i]) ; @@ -1954,13 +1999,8 @@ fprintf(stderr,"radioSaveState: %s\n",property_path); sprintf(value,"%d",adc_attenuation[1]); setProperty("adc_1_attenuation",value); - sprintf(value,"%d",rx_gain_slider[0]); - setProperty("rx1_gain_slider",value); - sprintf(value,"%d",rx_gain_slider[1]); - setProperty("rx2_gain_slider",value); - #ifdef SOAPYSDR - if(radio->device==SOAPYSDR_USB_DEVICE) { + if(device==SOAPYSDR_USB_DEVICE) { char name[128]; for(int i=0;iinfo.soapy.rx_gains;i++) { sprintf(name,"radio.adc[0].rx_gain.%s",radio->info.soapy.rx_gain[i]); diff --git a/radio.h b/radio.h index df370f9..937ee29 100644 --- a/radio.h +++ b/radio.h @@ -165,7 +165,6 @@ int receivers; ADC adc[2]; DAC dac[2]; int adc_attenuation[2]; -int rx_gain_slider[2]; int locked; @@ -278,6 +277,8 @@ extern double display_calibration; extern int can_transmit; +extern int have_rx_gain; // TRUE on HermesLite/RadioBerry + extern void radio_stop(); extern void reconfigure_radio(); extern void start_radio(); diff --git a/receiver.c b/receiver.c index 1477783..cea6ceb 100644 --- a/receiver.c +++ b/receiver.c @@ -912,6 +912,7 @@ fprintf(stderr,"create_receiver: id=%d buffer_size=%d fft_size=%d pixels=%d fps= case DEVICE_METIS: case DEVICE_HERMES: case DEVICE_HERMES_LITE: + case DEVICE_HERMES_LITE2: rx->adc=0; break; default: diff --git a/sliders.c b/sliders.c index 346b3bb..280222e 100644 --- a/sliders.c +++ b/sliders.c @@ -135,11 +135,11 @@ int sliders_active_receiver_changed(void *data) { gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]); } char title[64]; -#ifdef RADIOBERRY + if (have_rx_gain) { sprintf(title,"RX GAIN"/*,active_receiver->adc*/); -#else - sprintf(title,"ATT (dB)"/*,active_receiver->adc*/); -#endif + } else { + sprintf(title,"ATT (dB)"/*,active_receiver->adc*/); + } gtk_label_set_text(GTK_LABEL(attenuation_label),title); sliders_update(); } @@ -153,30 +153,29 @@ int scale_timeout_cb(gpointer data) { } static void attenuation_value_changed_cb(GtkWidget *widget, gpointer data) { -#ifdef RADIOBERRY - //redfined the att slider to a rx-gain slider. - //AD9866 contains a pga amplifier from -12 - 48 dB - //from -12 to 0; the rx-gain slider functions as an att slider - //from 0 - 48 db; the rx-gain slider functions as a gain slider with att = 0; - //att set to 20 for good power measurement. - int rx_gain_slider_value = (int)gtk_range_get_value(GTK_RANGE(attenuation_scale)); - rx_gain_slider[active_receiver->adc]=rx_gain_slider_value; - adc_attenuation[active_receiver->adc]= MAX((12 - rx_gain_slider_value), 0); - set_attenuation(adc_attenuation[active_receiver->adc]); -#else - adc_attenuation[active_receiver->adc]=(int)gtk_range_get_value(GTK_RANGE(attenuation_scale)); - set_attenuation(adc_attenuation[active_receiver->adc]); -#endif + if (have_rx_gain) { + //redfined the att slider to a rx-gain slider. + //AD9866 contains a pga amplifier from -12 - 48 dB + //from -12 to 0; the rx-gain slider functions as an att slider + //from 0 - 48 db; the rx-gain slider functions as a gain slider with att = 0; + //att set to 20 for good power measurement. + int rx_gain_slider_value = (int)gtk_range_get_value(GTK_RANGE(attenuation_scale)); + adc_attenuation[active_receiver->adc]= 28 - rx_gain_slider_value; + set_attenuation(adc_attenuation[active_receiver->adc]); + } else { + adc_attenuation[active_receiver->adc]=(int)gtk_range_get_value(GTK_RANGE(attenuation_scale)); + set_attenuation(adc_attenuation[active_receiver->adc]); + } } void set_attenuation_value(double value) { adc_attenuation[active_receiver->adc]=(int)value; if(display_sliders) { -#ifdef RADIOBERRY - gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)rx_gain_slider[active_receiver->adc]); -#else - gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]); -#endif + if (have_rx_gain) { + gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)(28-adc_attenuation[active_receiver->adc])); + } else { + gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]); + } } else { if(scale_status!=ATTENUATION) { if(scale_status!=NONE) { @@ -187,12 +186,12 @@ void set_attenuation_value(double value) { } if(scale_status==NONE) { char title[64]; -#ifdef RADIOBERRY + if (have_rx_gain) { sprintf(title,"RX GAIN - ADC-%d (dB)",active_receiver->adc); -#else - sprintf(title,"Attenuation - ADC-%d (dB)",active_receiver->adc); -#endif - scale_status=ATTENUATION; + } else { + sprintf(title,"Attenuation - ADC-%d (dB)",active_receiver->adc); + } + scale_status=ATTENUATION; scale_dialog=gtk_dialog_new_with_buttons(title,GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog)); attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.00); @@ -775,23 +774,24 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); g_signal_connect(G_OBJECT(agc_scale),"value_changed",G_CALLBACK(agcgain_value_changed_cb),NULL); char title[64]; -#ifdef RADIOBERRY + if (have_rx_gain) { sprintf(title,"RX-GAIN:"/*,active_receiver->adc*/); -#else - sprintf(title,"ATT (dB)"/*,active_receiver->adc*/); -#endif + } else { + sprintf(title,"ATT (dB)"/*,active_receiver->adc*/); + } attenuation_label=gtk_label_new(title); gtk_widget_override_font(attenuation_label, pango_font_description_from_string("Sans 10")); gtk_widget_show(attenuation_label); gtk_grid_attach(GTK_GRID(sliders),attenuation_label,6,0,1,1); -#ifdef RADIOBERRY + if (have_rx_gain) { attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 60.0, 1.0); - gtk_range_set_value (GTK_RANGE(attenuation_scale),rx_gain_slider[active_receiver->adc]); -#else + gtk_range_set_value (GTK_RANGE(attenuation_scale),28-adc_attenuation[active_receiver->adc]); + } else { attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.0); gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]); -#endif + } + gtk_widget_override_font(attenuation_scale, pango_font_description_from_string("Sans 10")); gtk_widget_show(attenuation_scale); diff --git a/transmitter.c b/transmitter.c index 8b01f20..e3e618b 100644 --- a/transmitter.c +++ b/transmitter.c @@ -436,6 +436,7 @@ static gboolean update_display(gpointer data) { constant2=0.108; break; case DEVICE_HERMES_LITE: + case DEVICE_HERMES_LITE2: break; } @@ -484,6 +485,7 @@ static gboolean update_display(gpointer data) { constant2=0.108; break; case NEW_DEVICE_HERMES_LITE: + case NEW_DEVICE_HERMES_LITE2: constant1=3.3; constant2=0.09; break; -- 2.45.2