]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
software level control as a Makefile option
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 31 Dec 2022 14:49:51 +0000 (20:19 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 31 Dec 2022 14:49:51 +0000 (20:19 +0530)
Makefile
old_protocol.c
transmitter.c

index 09cda291873b9ea05c0f3e69a1155d49b3a24a0b..6178e8da6b483b15144b83617c617089e45779da 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,9 @@ GIT_VERSION := $(shell git describe --abbrev=0 --tags --always)
 #
 GPIO_INCLUDE=GPIO
 
+# uncomment if level control (power output) is software based
+LEVEL_CTRL=SW_LEVEL_CTRL
+
 # uncomment the line below to include Pure Signal support
 #PURESIGNAL_INCLUDE=PURESIGNAL
 
@@ -42,6 +45,10 @@ LOCALCW_INCLUDE=LOCALCW
 CC=gcc
 LINK=gcc
 
+ifeq ($(LEVEL_CTRL),SW_LEVEL_CTRL)
+LEVEL_OPTIONS=-D SW_LEVEL_CTRL
+endif
+
 ifeq ($(MIDI_INCLUDE),MIDI)
 MIDI_OPTIONS=-D MIDI
 MIDI_HEADERS= midi.h midi_menu.h
@@ -157,7 +164,7 @@ endif
 
 CFLAGS=        -Wno-deprecated-declarations -O3
 # CFLAGS=      -Wno-deprecated-declarations -O3 -mcpu=cortex-a72 -mfloat-abi=hard -mfpu=neon-fp-armv8 -mneon-for-64bits
-OPTIONS=$(SMALL_SCREEN_OPTIONS) $(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \
+OPTIONS=$(SMALL_SCREEN_OPTIONS) $(MIDI_OPTIONS) $(LEVEL_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \
        $(GPIO_OPTIONS) $(GPIOD_OPTIONS) $(LOCALCW_OPTIONS) \
         $(PTT_OPTIONS) \
        $(SERVER_OPTIONS) \
index b87b15198b0c77d44d8add0e7445c75d9fe9f6bd..ede3788d1b96cb24682955136075ccf4c61e902b 100644 (file)
@@ -1728,7 +1728,13 @@ void ozy_send_buffer() {
        /* } */
 
         output_buffer[C0]=0x12; /* addr[6:1] = 001001b */
+#ifdef SW_LEVEL_CTRL
+        // highest power from hardware, but use software scaling to
+        // scale the level
+        output_buffer[C1]=255 & 0xFF;
+#else
         output_buffer[C1]=power & 0xFF;
+#endif
         output_buffer[C2]=0x00;
         output_buffer[C3]=0x00;
         output_buffer[C4]=0x00;
index ac2052027ebc0a6b9c4b536e5393e51189f89e1f..7520e7596b643fead64666b07be538eca793c397 100644 (file)
@@ -1028,8 +1028,12 @@ static void full_tx_buffer(TRANSMITTER *tx) {
   }
 
   if (isTransmitting()) {
-
+#ifdef SW_LEVEL_CTRL
+    if((radio->device==NEW_DEVICE_ATLAS && atlas_penelope) ||
+       (radio->device == DEVICE_HERMES_LITE2)) {
+#else
     if(radio->device==NEW_DEVICE_ATLAS && atlas_penelope) {
+#endif
       //
       // On these boards, drive level changes are performed by
       // scaling the TX IQ samples. In the other cases, DriveLevel
@@ -1086,6 +1090,10 @@ static void full_tx_buffer(TRANSMITTER *tx) {
              ramp=cw_shape_buffer48[j];                    // between 0.0 and 1.0
              qsample=floor(gain*ramp+0.5);         // always non-negative, isample is just the pulse envelope
              sidetone=sidevol * ramp * getNextInternalSideToneSample();
+
+              isample = isample >= 0.0 ? (long)floor(isample * gain + 0.5) : (long)ceil(isample * gain - 0.5);
+              qsample = qsample >= 0.0 ? (long)floor(qsample * gain + 0.5) : (long)ceil(qsample * gain - 0.5);
+
              old_protocol_iq_samples_with_sidetone(isample,qsample,sidetone);
            }
            break;
@@ -1098,6 +1106,10 @@ static void full_tx_buffer(TRANSMITTER *tx) {
             for(j=0;j<tx->output_samples;j++) {
              ramp=cw_shape_buffer192[j];                       // between 0.0 and 1.0
              qsample=floor(gain*ramp+0.5);                     // always non-negative, isample is just the pulse envelope
+
+              isample = isample >= 0.0 ? (long)floor(isample * gain + 0.5) : (long)ceil(isample * gain - 0.5);
+              qsample = qsample >= 0.0 ? (long)floor(qsample * gain + 0.5) : (long)ceil(qsample * gain - 0.5);
+
              new_protocol_iq_samples(isample,qsample);
            }
            break;
@@ -1115,8 +1127,8 @@ static void full_tx_buffer(TRANSMITTER *tx) {
              is=tx->iq_output_buffer[j*2];
              qs=tx->iq_output_buffer[(j*2)+1];
             }
-           isample=is>=0.0?(long)floor(is*gain+0.5):(long)ceil(is*gain-0.5);
-           qsample=qs>=0.0?(long)floor(qs*gain+0.5):(long)ceil(qs*gain-0.5);
+           isample = is >= 0.0 ? (long)floor(is * gain + 0.5) : (long)ceil(is * gain - 0.5);
+           qsample = qs >= 0.0 ? (long)floor(qs * gain + 0.5) : (long)ceil(qs * gain - 0.5);
            switch(protocol) {
                case ORIGINAL_PROTOCOL:
                    old_protocol_iq_samples(isample,qsample);