diff --git a/gui/src/index.html b/gui/src/index.html index be0588ee..ec8976eb 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -746,11 +746,11 @@
-

RX AUDIO LEVEL - not implemented yet

+

RX AUDIO LEVEL

-
-
+
+
diff --git a/tnc/modem.py b/tnc/modem.py index 6d1c513b..a2eef5bf 100644 --- a/tnc/modem.py +++ b/tnc/modem.py @@ -843,6 +843,9 @@ class RF: # Initialize channel_busy_delay counter channel_busy_delay = 0 + # Initialize rms counter + rms_counter = 0 + while True: # time.sleep(0.01) threading.Event().wait(0.01) @@ -874,8 +877,12 @@ class RF: # Calculate audio RMS # https://stackoverflow.com/a/9763652 - d = np.frombuffer(self.fft_data, np.int16).astype(np.float) - static.AUDIO_RMS = int(np.sqrt((d * d).sum() / len(d))) + # calculate RMS every 150 cycles for reducing CPU load + rms_counter += 1 + if rms_counter > 150: + d = np.frombuffer(self.fft_data, np.int16).astype(np.float) + static.AUDIO_RMS = int(np.sqrt((d * d).sum() / len(d))) + rms_counter = 0 # Check for signals higher than average by checking for "100" # If we have a signal, increment our channel_busy delay counter