Skip to content

Commit

Permalink
Scan range function
Browse files Browse the repository at this point in the history
  • Loading branch information
egzumer committed Nov 27, 2023
1 parent 4c3eb98 commit b5c564f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 9 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ENABLE_TX_WHEN_AM := 0
ENABLE_F_CAL_MENU := 0
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 0
ENABLE_BOOT_BEEPS := 0
ENABLE_SHOW_CHARGE_LEVEL := 1
ENABLE_SHOW_CHARGE_LEVEL := 0
ENABLE_REVERSE_BAT_SYMBOL := 0
ENABLE_NO_CODE_SCAN_TIMEOUT := 1
ENABLE_AM_FIX := 1
Expand All @@ -37,7 +37,8 @@ ENABLE_COPY_CHAN_TO_VFO := 1
ENABLE_SPECTRUM := 1
ENABLE_REDUCE_LOW_MID_TX_POWER:= 0
ENABLE_BYP_RAW_DEMODULATORS := 0
ENABLE_BLMIN_TMP_OFF := 0
ENABLE_BLMIN_TMP_OFF := 0
ENABLE_SCAN_RANGES := 1
#############################################################

TARGET = firmware
Expand Down Expand Up @@ -347,6 +348,9 @@ endif
ifeq ($(ENABLE_BLMIN_TMP_OFF),1)
CFLAGS += -DENABLE_BLMIN_TMP_OFF
endif
ifeq ($(ENABLE_SCAN_RANGES),1)
CFLAGS += -DENABLE_SCAN_RANGES
endif

LDFLAGS =
ifeq ($(ENABLE_CLANG),0)
Expand Down
15 changes: 10 additions & 5 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,18 +551,23 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
gUpdateStatus = true;
}

uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction)
uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper)
{
uint32_t Frequency = FREQUENCY_RoundToStep(pInfo->freq_config_RX.Frequency + (direction * pInfo->StepFrequency), pInfo->StepFrequency);

if (Frequency >= frequencyBandTable[pInfo->Band].upper)
Frequency = frequencyBandTable[pInfo->Band].lower;
else if (Frequency < frequencyBandTable[pInfo->Band].lower)
Frequency = FREQUENCY_RoundToStep(frequencyBandTable[pInfo->Band].upper - pInfo->StepFrequency, pInfo->StepFrequency);
if (Frequency >= upper)
Frequency = lower;
else if (Frequency < lower)
Frequency = FREQUENCY_RoundToStep(upper - pInfo->StepFrequency, pInfo->StepFrequency);

return Frequency;
}

uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction)
{
return APP_SetFreqByStepAndLimits(pInfo, direction, frequencyBandTable[pInfo->Band].lower, frequencyBandTable[pInfo->Band].upper);
}

#ifdef ENABLE_NOAA
static void NOAA_IncreaseChannel(void)
{
Expand Down
1 change: 1 addition & 0 deletions app/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

void APP_EndTransmission(void);
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix);
uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper);
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction);
void APP_Update(void);
void APP_TimeSlice10ms(void);
Expand Down
14 changes: 13 additions & 1 deletion app/chFrScanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ int8_t gScanStateDir;
bool gScanKeepResult;
bool gScanPauseMode;

#ifdef ENABLE_SCAN_RANGES
uint32_t gScanRangeStart;
#endif

typedef enum {
SCAN_NEXT_CHAN_SCANLIST1 = 0,
SCAN_NEXT_CHAN_SCANLIST2,
Expand Down Expand Up @@ -151,7 +155,15 @@ void CHFRSCANNER_Stop(void)

static void NextFreqChannel(void)
{
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir);
#ifdef ENABLE_SCAN_RANGES
if(gScanRangeStart) {
uint32_t start = gScanRangeStart;
uint32_t end = gEeprom.VfoInfo[(gEeprom.TX_VFO+1)%2].freq_config_RX.Frequency;
gRxVfo->freq_config_RX.Frequency = APP_SetFreqByStepAndLimits(gRxVfo, gScanStateDir, MIN(start, end), MAX(start, end));
}
else
#endif
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir);

RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
Expand Down
4 changes: 4 additions & 0 deletions app/chFrScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ extern int8_t gScanStateDir;
extern bool gScanKeepResult;
extern bool gScanPauseMode;

#ifdef ENABLE_SCAN_RANGES
extern uint32_t gScanRangeStart;
#endif

void CHFRSCANNER_Found(void);
void CHFRSCANNER_Stop(void);
void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_direction);
Expand Down
4 changes: 4 additions & 0 deletions app/common.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "app/chFrScanner.h"
#include "audio.h"
#include "functions.h"
#include "misc.h"
Expand All @@ -23,6 +24,9 @@ void COMMON_KeypadLockToggle()

void COMMON_SwitchVFOs()
{
#ifdef ENABLE_SCAN_RANGES
gScanRangeStart = 0;
#endif
gEeprom.TX_VFO ^= 1;

if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
Expand Down
9 changes: 8 additions & 1 deletion app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@
void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting

if ( SCANNER_IsScanning() || !IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
if ( SCANNER_IsScanning())
return;

if(!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
#ifdef ENABLE_SCAN_RANGES
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
#endif
return;
}

if (gTxVfo->SCANLIST1_PARTICIPATION)
{
if (gTxVfo->SCANLIST2_PARTICIPATION)
Expand Down
12 changes: 12 additions & 0 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <string.h>
#include <stdlib.h> // abs()

#include "app/chFrScanner.h"
#include "app/dtmf.h"
#ifdef ENABLE_AM_FIX_SHOW_DATA
#include "am_fix.h"
Expand Down Expand Up @@ -281,6 +282,17 @@ void UI_DisplayMain(void)

if (activeTxVFO != vfo_num) // this is not active TX VFO
{
#ifdef ENABLE_SCAN_RANGES
if(gScanRangeStart) {
UI_PrintString("ScnRng", 5, 0, line, 8);
sprintf(String, "%3u.%05u", gScanRangeStart / 100000, gScanRangeStart % 100000);
UI_PrintStringSmall(String, 56, 0, line);
uint32_t frq = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
sprintf(String, "%3u.%05u", frq / 100000, frq % 100000);
UI_PrintStringSmall(String, 56, 0, line + 1);
continue;
}
#endif
if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode)
{ // show DTMF stuff

Expand Down

0 comments on commit b5c564f

Please sign in to comment.