From 8155b08707173b3c9fa93b9131ba73023848b25a Mon Sep 17 00:00:00 2001
From: c vw <dl1ycf@darc.de>
Date: Wed, 11 Mar 2020 11:51:23 +0100
Subject: [PATCH] different PS DAC feeback peak value for HL2

---
 hpsdrsim.c | 10 ++++++++--
 radio.c    | 17 ++++++++++++++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/hpsdrsim.c b/hpsdrsim.c
index 2f588d6..ca54bf5 100644
--- a/hpsdrsim.c
+++ b/hpsdrsim.c
@@ -17,6 +17,7 @@
  * RF1 and RF2 signal strenght vary according to Preamp and Attenuator settings
  * RF3 signal strength varies according to TX-drive and TX-ATT settings
  * RF4 signal strength is normalized to amplitude of 0.407 (old protocol) or 0.2899 (new protocol)
+ *     note HERMESLITEV2 old protocol: 0.23
  *
  * The connection with the ADCs are:
  * ADC0: RF1 upon receive, RF3 upon transmit
@@ -1286,8 +1287,13 @@ void *handler_ep6(void *arg)
 			//
 			// TX signal with peak=0.407
 			//
-			dacisample= isample[rxptr] * 0.407 * 8388607.0;
-			dacqsample= qsample[rxptr] * 0.407 * 8388607.0;
+                        if (OLDDEVICE == DEVICE_HERMES_LITE2) {
+			  dacisample= isample[rxptr] * 0.230 * 8388607.0;
+			  dacqsample= qsample[rxptr] * 0.230 * 8388607.0;
+                        } else {
+			  dacisample= isample[rxptr] * 0.407 * 8388607.0;
+			  dacqsample= qsample[rxptr] * 0.407 * 8388607.0;
+                        }
 
 			for (k=0; k< receivers; k++) {
 			    myisample=0;
diff --git a/radio.c b/radio.c
index 08d37e6..893c30b 100644
--- a/radio.c
+++ b/radio.c
@@ -992,6 +992,7 @@ void start_radio() {
 
   //g_print("Create transmitter\n");
   if(can_transmit) {
+    double pk;
     if(duplex) {
       transmitter=create_transmitter(CHANNEL_TX, buffer_size, fft_size, updates_per_second, display_width/4, display_height/2);
     } else {
@@ -1009,7 +1010,21 @@ void start_radio() {
     tx_set_ps_sample_rate(transmitter,protocol==NEW_PROTOCOL?192000:active_receiver->sample_rate);
     receiver[PS_TX_FEEDBACK]=create_pure_signal_receiver(PS_TX_FEEDBACK, buffer_size,protocol==ORIGINAL_PROTOCOL?active_receiver->sample_rate:192000,display_width);
     receiver[PS_RX_FEEDBACK]=create_pure_signal_receiver(PS_RX_FEEDBACK, buffer_size,protocol==ORIGINAL_PROTOCOL?active_receiver->sample_rate:192000,display_width);
-    SetPSHWPeak(transmitter->id, protocol==ORIGINAL_PROTOCOL? 0.4067 : 0.2899);
+    switch (protocol) {
+      case NEW_PROTOCOL:
+	pk = 0.2899;
+	break;
+      case ORIGINAL_PROTOCOL:
+        switch (device) {
+	  case DEVICE_HERMES_LITE2:
+	    pk = 0.2300;
+            break;
+	  default:
+	    pk = 0.4067;
+            break;
+        }
+    }
+    SetPSHWPeak(transmitter->id, pk);
 #endif
 
   }
-- 
2.45.2