Skip to content

Commit

Permalink
fix: squelch, update scan step at 16 bars count
Browse files Browse the repository at this point in the history
  • Loading branch information
fagci committed Sep 11, 2023
1 parent 2678b2a commit 9e00491
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 40 deletions.
12 changes: 6 additions & 6 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,12 @@ void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step) {
uint32_t Frequency;

Frequency = pInfo->ConfigRX.Frequency + (Step * pInfo->StepFrequency);
if (Frequency > gUpperLimitFrequencyBandTable[pInfo->Band]) {
pInfo->ConfigRX.Frequency = gLowerLimitFrequencyBandTable[pInfo->Band];
} else if (Frequency < gLowerLimitFrequencyBandTable[pInfo->Band]) {
if (Frequency > UpperLimitFrequencyBandTable[pInfo->Band]) {
pInfo->ConfigRX.Frequency = LowerLimitFrequencyBandTable[pInfo->Band];
} else if (Frequency < LowerLimitFrequencyBandTable[pInfo->Band]) {
pInfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(
gUpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency,
gLowerLimitFrequencyBandTable[pInfo->Band]);
UpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency,
LowerLimitFrequencyBandTable[pInfo->Band]);
} else {
pInfo->ConfigRX.Frequency = Frequency;
}
Expand Down Expand Up @@ -989,7 +989,7 @@ void APP_TimeSlice500ms(void) {
UI_UpdateRSSI(gCurrentRSSI);
}
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) &&
gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) {
gCssScanMode == CSS_SCAN_MODE_OFF) {
if (gBacklightCountdown) {
gBacklightCountdown--;
if (gBacklightCountdown == 0) {
Expand Down
6 changes: 3 additions & 3 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
uint8_t i;

for (i = 0; i < 7; i++) {
if (Frequency <= gUpperLimitFrequencyBandTable[i] &&
(gLowerLimitFrequencyBandTable[i] <= Frequency)) {
if (Frequency <= UpperLimitFrequencyBandTable[i] &&
(LowerLimitFrequencyBandTable[i] <= Frequency)) {
gAnotherVoiceID = (VOICE_ID_t)Key;
if (gTxVfo->Band != i) {
gTxVfo->Band = i;
Expand All @@ -98,7 +98,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
Frequency += 75;
gTxVfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(
Frequency, gTxVfo->StepFrequency,
gLowerLimitFrequencyBandTable[gTxVfo->Band]);
LowerLimitFrequencyBandTable[gTxVfo->Band]);
gRequestSaveChannel = 1;
return;
}
Expand Down
1 change: 1 addition & 0 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) {
gInputBoxIndex = 0;
gFlagRefreshSetting = true;
gAnotherVoiceID = VOICE_ID_CANCEL;
gAskForConfirmation = 0;
} else {
gInputBoxIndex--;
gInputBox[gInputBoxIndex] = 10;
Expand Down
42 changes: 27 additions & 15 deletions app/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,10 @@ static void ResetRSSIHistory() {
}
}
static void ResetPeak() {
peak.rssi = 0;
peak.f = 0;
if (!settings.isStillMode) {
peak.rssi = 0;
peak.f = 0;
}
}

bool IsCenterMode() { return settings.scanStepIndex < S_STEP_2_5kHz; }
Expand Down Expand Up @@ -605,9 +607,10 @@ static void OnKeyDown(uint8_t key) {
case KEY_4:
if (settings.stepsCount == STEPS_128) {
settings.stepsCount = STEPS_16;
break;
} else {
settings.stepsCount--;
}
settings.stepsCount--;
settings.frequencyChangeStep = GetBW() >> 1;
break;
case KEY_SIDE2:
settings.backlightState = !settings.backlightState;
Expand Down Expand Up @@ -809,7 +812,7 @@ static void Scan() {
resetBlacklist = false;
++peak.t;

if (!peak.f || peak.t >= 16) {
if (!peak.f || rssiMax > peak.rssi || peak.t >= 16) {
peak.t = 0;
peak.rssi = rssiMax;
peak.f = fPeak;
Expand All @@ -818,18 +821,27 @@ static void Scan() {
}

static void Update() {
if (settings.isStillMode || IsPeakOverLevel()) {
ToggleRX(IsPeakOverLevel());
// if (!IsBroadcastFM(peak.f)) {
for (uint8_t i = 0; i < 50 && GetKey() == 255; ++i) {
SYSTEM_DelayMs(20);
if ((!IsPeakOverLevel() && !settings.isStillMode) || rssiMin == 255) {
ToggleRX(false);
Scan();
}

if (IsPeakOverLevel()) {
ToggleRX(true);

// coz there can be already RX on
BK4819_SetFilterBandwidth(settings.listenBw);

if (!IsBroadcastFM(peak.f)) {
for (uint8_t i = 0; i < 50 && GetKey() == 255; ++i) {
SYSTEM_DelayMs(20);
}
}
// }
}
ToggleRX(false);
peak.rssi = rssiHistory[peak.i] = GetRssi();
if (rssiMin == 255 || (!settings.isStillMode && !IsPeakOverLevel())) {
Scan();

if (IsPeakOverLevel()) {
BK4819_SetFilterBandwidth(GetBWIndex());
peak.rssi = rssiHistory[peak.i] = GetRssi();
}
}

Expand Down
3 changes: 0 additions & 3 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,6 @@ void BOARD_EEPROM_Init(void)
EEPROM_ReadBuffer(0x0F40, Data, 8);
gSetting_F_LOCK = (Data[0] < 6) ? Data[0] : F_LOCK_OFF;

gUpperLimitFrequencyBandTable = UpperLimitFrequencyBandTable;
gLowerLimitFrequencyBandTable = LowerLimitFrequencyBandTable;

gSetting_ALL_TX = (Data[1] < 2) ? Data[1] : true;
gSetting_200TX = (Data[3] < 2) ? Data[3] : false;
gSetting_500TX = (Data[4] < 2) ? Data[4] : false;
Expand Down
Binary file modified firmware.packed.bin
Binary file not shown.
3 changes: 0 additions & 3 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#include <string.h>
#include "misc.h"

const uint32_t *gUpperLimitFrequencyBandTable;
const uint32_t *gLowerLimitFrequencyBandTable;

bool gSetting_ALL_TX;
bool gSetting_200TX;
bool gSetting_500TX;
Expand Down
3 changes: 0 additions & 3 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ enum CssScanMode_t {

typedef enum CssScanMode_t CssScanMode_t;

extern const uint32_t *gUpperLimitFrequencyBandTable;
extern const uint32_t *gLowerLimitFrequencyBandTable;

extern bool gSetting_ALL_TX;
extern bool gSetting_200TX;
extern bool gSetting_500TX;
Expand Down
13 changes: 6 additions & 7 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg) {
}
Index = Channel - FREQ_CHANNEL_FIRST;
RADIO_InitInfo(pRadio, Channel, Index,
gLowerLimitFrequencyBandTable[Index]);
LowerLimitFrequencyBandTable[Index]);
return;
}

Expand Down Expand Up @@ -306,16 +306,15 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg) {
}

Frequency = pRadio->ConfigRX.Frequency;
if (Frequency < gLowerLimitFrequencyBandTable[Band]) {
pRadio->ConfigRX.Frequency = gLowerLimitFrequencyBandTable[Band];
} else if (Frequency > gUpperLimitFrequencyBandTable[Band]) {
pRadio->ConfigRX.Frequency = gUpperLimitFrequencyBandTable[Band];
if (Frequency < LowerLimitFrequencyBandTable[Band]) {
pRadio->ConfigRX.Frequency = LowerLimitFrequencyBandTable[Band];
} else if (Frequency > UpperLimitFrequencyBandTable[Band]) {
pRadio->ConfigRX.Frequency = UpperLimitFrequencyBandTable[Band];
} else if (Channel >= FREQ_CHANNEL_FIRST) {
pRadio->ConfigRX.Frequency = FREQUENCY_FloorToStep(
pRadio->ConfigRX.Frequency, gEeprom.VfoInfo[VFO].StepFrequency,
gLowerLimitFrequencyBandTable[Band]);
LowerLimitFrequencyBandTable[Band]);
}
pRadio->ConfigRX.Frequency = Frequency;

if (Frequency - 10800000 < 2799991) {
gEeprom.VfoInfo[VFO].FREQUENCY_DEVIATION_SETTING =
Expand Down

0 comments on commit 9e00491

Please sign in to comment.