Skip to content

Commit

Permalink
fix: rm noise when entering spectrum when squlch open, signal level o…
Browse files Browse the repository at this point in the history
…n main screen, STE(try2); feat: makefile disable automatic trigger level
  • Loading branch information
fagci committed Sep 30, 2023
1 parent 43c802f commit 60d0e04
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 43 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ENABLE_NOSCANTIMEOUT := 1
ENABLE_KEEPNAMEONSAVE := 1
ENABLE_RSSIBAR := 1

SPECTRUM_AUTOMATIC_SQUELCH := 1

BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
Expand Down
17 changes: 15 additions & 2 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,20 @@ void APP_CheckRadioInterrupts(void)
void APP_EndTransmission(void)
{
RADIO_SendEndOfTransmission();
RADIO_EnableCxCSS();
if (gCurrentVfo->pTX->CodeType != CODE_TYPE_OFF)
{ // CTCSS/CDCSS is enabled

//if (gEeprom.TAIL_NOTE_ELIMINATION && gEeprom.REPEATER_TAIL_TONE_ELIMINATION > 0)
if (gEeprom.TAIL_NOTE_ELIMINATION)
{ // send the tail tone
RADIO_EnableCxCSS();
}
else
{ // TX a short blank carrier - gives the receivers time to mute RX audio before we drop carrier
BK4819_ExitSubAu();
SYSTEM_DelayMs(200);
}
}
RADIO_SetupRegisters(false);
}

Expand Down Expand Up @@ -962,7 +975,7 @@ void APP_TimeSlice10ms(void)
}
}
#endif
if (gRTTECountdown) {
if (gRTTECountdown > 0) {
gRTTECountdown--;
if (gRTTECountdown == 0) {
FUNCTION_Select(FUNCTION_FOREGROUND);
Expand Down
10 changes: 3 additions & 7 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;
}
Band = gTxVfo->Band + 1;
if (gSetting_ALL_TX || Band != BAND5_350MHz) {
if (BAND7_470MHz < Band) {
Band = BAND1_50MHz;
}
} else {
Band = BAND6_400MHz;
}
if (BAND7_470MHz < Band) {
Band = BAND1_50MHz;
}
gTxVfo->Band = Band;
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
Expand Down
3 changes: 2 additions & 1 deletion app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax)
case MENU_VOICE: case MENU_SC_REV:
case MENU_PONMSG:
case MENU_ROGER:
case MENU_ALL_TX:
*pMin = 0;
*pMax = 2;
break;
Expand All @@ -171,7 +172,7 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax)
#endif
case MENU_RESET: case MENU_350TX:
case MENU_200TX: case MENU_500TX:
case MENU_ALL_TX: case MENU_SCREN:
case MENU_SCREN:
*pMin = 0;
*pMax = 1;
break;
Expand Down
4 changes: 3 additions & 1 deletion app/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ static void RelaunchScan() {
InitScan();
ResetPeak();
ToggleRX(false);
#ifdef SPECTRUM_AUTOMATIC_SQUELCH
settings.rssiTriggerLevel = RSSI_MAX_VALUE;
#endif
preventKeypress = true;
scanInfo.rssiMin = RSSI_MAX_VALUE;
}
Expand Down Expand Up @@ -1150,7 +1152,7 @@ void APP_RunSpectrum() {
redrawScreen = false; // we will wait until scan done
newScanStart = true;

ToggleRX(false);
ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off
SetModulation(settings.modulationType = MOD_FM);
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE);

Expand Down
2 changes: 1 addition & 1 deletion board.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ void BOARD_EEPROM_Init(void)
gSetting_KILLED = (Data[2] < 2) ? Data[2] : false;
gSetting_200TX = (Data[3] < 2) ? Data[3] : false;
gSetting_500TX = (Data[4] < 2) ? Data[4] : false;
gSetting_ALL_TX = (Data[5] < 2) ? Data[5] : true;
gSetting_ALL_TX = (Data[5] < 2) ? Data[5] : 2;
gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true;

if (!gEeprom.VFO_OPEN) {
Expand Down
9 changes: 6 additions & 3 deletions frequencies.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "settings.h"

const struct FrequencyBandInfo FrequencyBandTable[7] = {
[BAND1_50MHz ] = {.lower = 1600000, .middle = 6500000, .upper = 7600000},
[BAND2_108MHz] = {.lower = 10800000, .middle = 12200000, .upper = 13599990},
[BAND1_50MHz ] = {.lower = 1600000, .middle = 6500000, .upper = 7599990},
[BAND2_108MHz] = {.lower = 7600000, .middle = 12200000, .upper = 13599990},
[BAND3_136MHz] = {.lower = 13600000, .middle = 15000000, .upper = 17399990},
[BAND4_174MHz] = {.lower = 17400000, .middle = 26000000, .upper = 34999990},
[BAND5_350MHz] = {.lower = 35000000, .middle = 37000000, .upper = 39999990},
Expand Down Expand Up @@ -110,8 +110,11 @@ int FREQUENCY_Check(VFO_Info_t *pInfo)
return -1;
}
Frequency = pInfo->pTX->Frequency;
if (gSetting_ALL_TX) {
if (gSetting_ALL_TX == 1) {
return 0;
}
if (gSetting_ALL_TX == 2) {
return -1;
}
switch (gSetting_F_LOCK) {
case F_LOCK_FCC:
Expand Down
2 changes: 1 addition & 1 deletion misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bool gSetting_350TX;
bool gSetting_KILLED;
bool gSetting_200TX;
bool gSetting_500TX;
bool gSetting_ALL_TX;
uint8_t gSetting_ALL_TX;
uint8_t gSetting_F_LOCK;
bool gSetting_ScrambleEnable;

Expand Down
2 changes: 1 addition & 1 deletion misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ extern bool gSetting_350TX;
extern bool gSetting_KILLED;
extern bool gSetting_200TX;
extern bool gSetting_500TX;
extern bool gSetting_ALL_TX;
extern uint8_t gSetting_ALL_TX;
extern uint8_t gSetting_F_LOCK;
extern bool gSetting_ScrambleEnable;
extern uint8_t gSetting_F_LOCK;
Expand Down
34 changes: 14 additions & 20 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,25 @@
#if defined(ENABLE_RSSIBAR)
void UI_DisplayRSSIBar(int16_t rssi)
{
if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME_FREQ)
{
char String[16];
char String[16];
const int16_t dBm = (rssi / 2) - 160;

const unsigned int line = 3;
const unsigned int lcd_width = sizeof(gFrameBuffer[line]) - 25;
const unsigned int line = 3;
const unsigned int bar_width = 92;

const unsigned int max = 350;
const unsigned int min = 80;
const unsigned int adjusted_max = max - min;
const unsigned int level = (((rssi - min) * lcd_width) + (adjusted_max / 2)) / adjusted_max;
const unsigned int len = (level <= lcd_width) ? level : 0;
const int16_t dBm = (rssi / 2) - 160;
const unsigned int max = 350;
const unsigned int min = 80;
const unsigned int adjusted_max = max - min;
const unsigned int level = (((rssi - min) * bar_width) + (adjusted_max / 2)) / adjusted_max;
const unsigned int len = level < bar_width ? level : bar_width;

uint8_t *pLine = gFrameBuffer[line];
memset(pLine, 0, lcd_width);
uint8_t *pLine = gFrameBuffer[line];

for (unsigned int i = 34; i < (len+35); i += 2)
pLine[i] = 0x3e;
for (unsigned int i = 34; i < (len+35); i += 2)
pLine[i] = 0x3e;

ST7565_BlitFullScreen();

sprintf(String, "%d", dBm);
UI_PrintStringSmall(String, 0, 0, 3);
}
sprintf(String, "%d", dBm);
UI_PrintStringSmall(String, 0, 0, 3);
}
#endif

Expand Down
9 changes: 3 additions & 6 deletions ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ static const char gSubMenu_W_N[2][7] = {
"NARROW",
};

static const char gSubMenu_OFF_ON[2][4] = {
"OFF",
"ON",
};

static const char gSubMenu_SAVE[5][4] = {
"OFF",
"1:1",
Expand Down Expand Up @@ -173,6 +168,8 @@ static const char gSubMenu_F_LOCK[6][4] = {
"438",
};

static const char *defaultEnableDisable[3] = {"DEFAULT", "ENABLE", "DISABLE"};

bool gIsInSubMenu;

uint8_t gMenuCursor;
Expand Down Expand Up @@ -306,7 +303,7 @@ void UI_DisplayMenu(void)
case MENU_500TX:
case MENU_ALL_TX:
case MENU_SCREN:
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
strcpy(String, defaultEnableDisable[gSubMenuSelection]);
break;

case MENU_MEM_CH:
Expand Down

1 comment on commit 60d0e04

@afuxl
Copy link

@afuxl afuxl commented on 60d0e04 Oct 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug when Enter in Spectrum mode, and press Key-F. The squelch or noise reduction level or RSSITriggerLevel show many number. And MDF Name it's not shown when no available name.

Please sign in to comment.