From 2a46050a196dac5d1a97f198e48bdc33c5cc446e Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Fri, 19 Jul 2024 14:25:18 +0200 Subject: [PATCH] Add compile options --- Makefile | 4 ++++ app/spectrum.c | 38 ++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 5f923b9..7615778 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ ENABLE_SCAN_RANGES ?= 1 ENABLE_FEAT_F4HWN ?= 1 ENABLE_FEAT_F4HWN_SCREENSHOT ?= 0 ENABLE_FEAT_F4HWN_PMR ?= 1 +ENABLE_FEAT_F4HWN_SPECTRUM ?= 1 # ---- DEBUGGING ---- ENABLE_AM_FIX_SHOW_DATA ?= 0 @@ -407,6 +408,9 @@ endif ifeq ($(ENABLE_FEAT_F4HWN_PMR),1) CFLAGS += -DENABLE_FEAT_F4HWN_PMR endif +ifeq ($(ENABLE_FEAT_F4HWN_SPECTRUM),1) + CFLAGS += -DENABLE_FEAT_F4HWN_SPECTRUM +endif LDFLAGS = LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld -Wl,--gc-sections diff --git a/app/spectrum.c b/app/spectrum.c index b9bdfa7..a305f8a 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -23,7 +23,6 @@ #endif #include "driver/backlight.h" -#include "driver/eeprom.h" #include "frequencies.h" #include "ui/helper.h" #include "ui/main.h" @@ -32,6 +31,10 @@ #include "screenshot.h" #endif +#ifdef ENABLE_FEAT_F4HWN_SPECTRUM + #include "driver/eeprom.h" +#endif + struct FrequencyBandInfo { uint32_t lower; uint32_t upper; @@ -106,9 +109,9 @@ RegisterSpec registerSpecs[] = { uint16_t statuslineUpdateTimer = 0; -static void LoadSettings() -{ - #ifdef ENABLE_FEAT_F4HWN +#ifdef ENABLE_FEAT_F4HWN_SPECTRUM + static void LoadSettings() + { uint8_t Data[8] = {0}; // 1FF0..0x1FF7 EEPROM_ReadBuffer(0x1FF0, Data, 8); @@ -133,13 +136,10 @@ static void LoadSettings() { settings.listenBw = BK4819_FILTER_BW_WIDE; } + } - #endif -} - -static void SaveSettings() -{ - #ifdef ENABLE_FEAT_F4HWN + static void SaveSettings() + { uint8_t Data[8] = {0}; // 1FF0..0x1FF7 EEPROM_ReadBuffer(0x1FF0, Data, 8); @@ -147,9 +147,8 @@ static void SaveSettings() Data[4] = (settings.scanStepIndex << 4) | (settings.stepsCount << 2) | settings.listenBw; EEPROM_WriteBuffer(0x1FF0, Data); - - #endif -} + } +#endif static uint8_t DBm2S(int dbm) { uint8_t i = 0; @@ -978,7 +977,9 @@ static void OnKeyDown(uint8_t key) { menuState = 0; break; } - SaveSettings(); + #ifdef ENABLE_FEAT_F4HWN_SPECTRUM + SaveSettings(); + #endif DeInitSpectrum(); break; default: @@ -1368,7 +1369,9 @@ static void Tick() { void APP_RunSpectrum() { // TX here coz it always? set to active VFO vfo = gEeprom.TX_VFO; +#ifdef ENABLE_FEAT_F4HWN_SPECTRUM LoadSettings(); +#endif // set the current frequency in the middle of the display #ifdef ENABLE_SCAN_RANGES if(gScanRangeStart) { @@ -1393,11 +1396,14 @@ void APP_RunSpectrum() { redrawScreen = true; newScanStart = true; - ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off RADIO_SetModulation(settings.modulationType = gTxVfo->Modulation); - BK4819_SetFilterBandwidth(settings.listenBw, false); + #ifdef ENABLE_FEAT_F4HWN_SPECTRUM + BK4819_SetFilterBandwidth(settings.listenBw, false); + #else + BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false); + #endif RelaunchScan();