Added bw: 8.33k, 6.25k, 5k.

This commit is contained in:
Nunu 2024-01-01 18:00:12 +01:00
parent 03be9bb862
commit b32e76fd12
8 changed files with 44 additions and 167 deletions

View File

@ -203,7 +203,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_W_N:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_W_N) - 1;
*pMax = ARRAY_SIZE(bwNames) - 1;
break;
#ifdef ENABLE_ALARM

View File

@ -600,7 +600,7 @@ static void ToggleModulation() {
}
static void ToggleListeningBW() {
if (settings.listenBw == BK4819_FILTER_BW_NARROWER) {
if (settings.listenBw == BK4819_FILTER_BW_NARROWEST) {
settings.listenBw = BK4819_FILTER_BW_WIDE;
} else {
settings.listenBw++;
@ -802,7 +802,7 @@ static void DrawF(uint32_t f) {
sprintf(String, "%3s", gModulationStr[settings.modulationType]);
GUI_DisplaySmallest(String, 116, 1, false, true);
sprintf(String, "%s", bwOptions[settings.listenBw]);
sprintf(String, "%s", bwNames[settings.listenBw]);
GUI_DisplaySmallest(String, 108, 7, false, true);
}
#ifdef ENABLE_SPECTRUM_SHOW_CHANNEL_NAME
@ -1473,11 +1473,11 @@ void APP_RunSpectrum() {
ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off
#ifdef ENABLE_SPECTRUM_COPY_VFO
RADIO_SetModulation(settings.modulationType = gTxVfo->Modulation);
BK4819_SetFilterBandwidth(settings.listenBw = gTxVfo->CHANNEL_BANDWIDTH, false);
BK4819_SetFilterBandwidth(settings.listenBw = gTxVfo->CHANNEL_BANDWIDTH);
settings.scanStepIndex = GetScanStepFromStepFrequency(gTxVfo->StepFrequency);
#elif
RADIO_SetModulation(settings.modulationType = MODULATION_FM);
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE);
#endif
RelaunchScan();

View File

@ -516,144 +516,18 @@ void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold,
BK4819_WriteRegister(BK4819_REG_31, REG_31_Value | (1u << 2)); // VOX Enable
}
void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const bool weak_no_different)
const uint16_t listenBWRegValues[5] = {
0x3028, // 25
0x4048, // 12.5
0x0349, // 8.33
0x205C, // 6.25
0x01F4 // 5
};
void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth)
{
// REG_43
// <15> 0 ???
//
// <14:12> 4 RF filter bandwidth
// 0 = 1.7 kHz
// 1 = 2.0 kHz
// 2 = 2.5 kHz
// 3 = 3.0 kHz
// 4 = 3.75 kHz
// 5 = 4.0 kHz
// 6 = 4.25 kHz
// 7 = 4.5 kHz
// if <5> == 1, RF filter bandwidth * 2
//
// <11:9> 0 RF filter bandwidth when signal is weak
// 0 = 1.7 kHz
// 1 = 2.0 kHz
// 2 = 2.5 kHz
// 3 = 3.0 kHz
// 4 = 3.75 kHz
// 5 = 4.0 kHz
// 6 = 4.25 kHz
// 7 = 4.5 kHz
// if <5> == 1, RF filter bandwidth * 2
//
// <8:6> 1 AFTxLPF2 filter Band Width
// 1 = 2.5 kHz (for 12.5k channel space)
// 2 = 2.75 kHz
// 0 = 3.0 kHz (for 25k channel space)
// 3 = 3.5 kHz
// 4 = 4.5 kHz
// 5 = 4.25 kHz
// 6 = 4.0 kHz
// 7 = 3.75 kHz
//
// <5:4> 0 BW Mode Selection
// 0 = 12.5k
// 1 = 6.25k
// 2 = 25k/20k
//
// <3> 1 ???
//
// <2> 0 Gain after FM Demodulation
// 0 = 0dB
// 1 = 6dB
//
// <1:0> 0 ???
uint16_t val;
switch (Bandwidth)
{
default:
case BK4819_FILTER_BW_WIDE: // 25kHz
if (weak_no_different)
{ // make the RX bandwidth the same with weak signals
val =
(0u << 15) | // 0
(4u << 12) | // *3 RF filter bandwidth
(4u << 9) | // *0 RF filter bandwidth when signal is weak
(6u << 6) | // *0 AFTxLPF2 filter Band Width
(2u << 4) | // 2 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation
(0u << 0); // 0
}
else
{ // with weak RX signals the RX bandwidth is reduced
val = // 0x3028); // 0 011 000 000 10 1 0 00
(0u << 15) | // 0
(4u << 12) | // *3 RF filter bandwidth
(2u << 9) | // *0 RF filter bandwidth when signal is weak
(6u << 6) | // *0 AFTxLPF2 filter Band Width
(2u << 4) | // 2 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation
(0u << 0); // 0
}
break;
case BK4819_FILTER_BW_NARROW: // 12.5kHz
if (weak_no_different)
{
val =
(0u << 15) | // 0
(4u << 12) | // *4 RF filter bandwidth
(4u << 9) | // *0 RF filter bandwidth when signal is weak
(0u << 6) | // *1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation
(0u << 0); // 0
}
else
{
val = // 0x4048); // 0 100 000 001 00 1 0 00
(0u << 15) | // 0
(4u << 12) | // *4 RF filter bandwidth
(2u << 9) | // *0 RF filter bandwidth when signal is weak
(0u << 6) | // *1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation
(0u << 0); // 0
}
break;
case BK4819_FILTER_BW_NARROWER: // 6.25kHz
if (weak_no_different)
{
val =
(0u << 15) | // 0
(3u << 12) | // 3 RF filter bandwidth
(3u << 9) | // *0 RF filter bandwidth when signal is weak
(1u << 6) | // 1 AFTxLPF2 filter Band Width
(1u << 4) | // 1 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation
(0u << 0); // 0
}
else
{
val =
(0u << 15) | // 0
(3u << 12) | // 3 RF filter bandwidth
(0u << 9) | // 0 RF filter bandwidth when signal is weak
(1u << 6) | // 1 AFTxLPF2 filter Band Width
(1u << 4) | // 1 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 1 Gain after FM Demodulation
(0u << 0); // 0
}
break;
}
BK4819_WriteRegister(BK4819_REG_43, val);
BK4819_WriteRegister(BK4819_REG_43, listenBWRegValues[Bandwidth]);
// UART_printf("\n Bandwidth : %i | %04x", Bandwidth, listenBWRegValues[Bandwidth]);
}
void BK4819_SetupPowerAmplifier(uint8_t Bias, uint32_t Frequency) {

View File

@ -46,9 +46,11 @@ typedef enum BK4819_AF_Type_t BK4819_AF_Type_t;
enum BK4819_FilterBandwidth_t
{
BK4819_FILTER_BW_WIDE = 0,
BK4819_FILTER_BW_NARROW,
BK4819_FILTER_BW_NARROWER
BK4819_FILTER_BW_WIDE = 0U,
BK4819_FILTER_BW_NARROW = 1U,
BK4819_FILTER_BW_NARROWAVIATION = 2U,
BK4819_FILTER_BW_NARROWER = 3U,
BK4819_FILTER_BW_NARROWEST = 4U
};
typedef enum BK4819_FilterBandwidth_t BK4819_FilterBandwidth_t;
@ -81,7 +83,7 @@ void BK4819_SetCDCSSCodeWord(uint32_t CodeWord);
void BK4819_SetCTCSSFrequency(uint32_t BaudRate);
void BK4819_SetTailDetection(const uint32_t freq_10Hz);
void BK4819_EnableVox(uint16_t Vox1Threshold, uint16_t Vox0Threshold, uint8_t VoxDelay);
void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const bool weak_no_different);
void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth);
void BK4819_SetupPowerAmplifier(const uint8_t bias, const uint32_t frequency);
void BK4819_SetDefaultAmplifierSettings();
void BK4819_SetFrequency(uint32_t Frequency);

13
radio.c
View File

@ -54,6 +54,8 @@ const char gModulationStr[][4] =
#endif
};
const char *bwNames[5] = {" 25k", "12.5k", "8.33k", "6.25k", " 5k"};
bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
{ // return true if the channel appears valid
@ -219,7 +221,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
else
base = 0x0C80 + ((channel - FREQ_CHANNEL_FIRST) * 32) + (VFO * 16);
if (configure == VFO_CONFIGURE_RELOAD || IS_FREQ_CHANNEL(channel))
if (configure == VFO_CONFIGURE_RELOAD)
{
uint8_t tmp;
uint8_t data[8];
@ -309,7 +311,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
pVfo->CHANNEL_BANDWIDTH = !!((d4 >> 1) & 1u);
pVfo->OUTPUT_POWER = ((d4 >> 2) & 3u);
pVfo->BUSY_CHANNEL_LOCK = !!((d4 >> 4) & 1u);
}
}
if (data[5] == 0xFF)
{
@ -572,8 +574,7 @@ void RADIO_SetupRegisters(bool switchToForeground)
BK4819_FilterBandwidth_t Bandwidth = gRxVfo->CHANNEL_BANDWIDTH;
// lower filters bandwidth for weak signals for all modulations except AM
BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->Modulation == MODULATION_AM);
BK4819_SetFilterBandwidth(Bandwidth);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);
@ -812,8 +813,8 @@ void RADIO_SetTxParameters(void)
BK4819_FilterBandwidth_t Bandwidth = gCurrentVfo->CHANNEL_BANDWIDTH;
// lower filters bandwidth for weak signals for all modulations except AM
BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->Modulation == MODULATION_AM);
BK4819_SetFilterBandwidth(Bandwidth);
BK4819_SetFrequency(gCurrentVfo->pTX->Frequency);

View File

@ -29,8 +29,11 @@ enum {
};
enum {
BANDWIDTH_WIDE = 0,
BANDWIDTH_NARROW
BANDWIDTH_WIDE = 0U,
BANDWIDTH_NARROW = 1U,
BANDWIDTH_NARROWAVIATION = 2U,
BANDWIDTH_NARROWER = 3U,
BANDWIDTH_NARROWEST = 4U
};
enum PTT_ID_t {
@ -69,6 +72,8 @@ typedef enum {
extern const char gModulationStr[MODULATION_UKNOWN][4];
extern const char *bwNames[5];
typedef struct
{
uint32_t Frequency;

View File

@ -640,12 +640,13 @@ void UI_DisplayMain(void)
{ // show the narrow band symbol
String[0] = '\0';
if (gEeprom.VfoInfo[vfo_num].CHANNEL_BANDWIDTH == BANDWIDTH_NARROW)
{
String[0] = 'N';
String[1] = '\0';
}
UI_PrintStringSmall(String, LCD_WIDTH + 70, 0, line + 1);
// if (gEeprom.VfoInfo[vfo_num].CHANNEL_BANDWIDTH == BANDWIDTH_NARROW)
// {
// String[0] = 'N';
// String[1] = '\0';
// }
// UI_PrintStringSmall(String, LCD_WIDTH + 70, 0, line + 1);
UI_PrintStringSmall(bwNames[gEeprom.VfoInfo[vfo_num].CHANNEL_BANDWIDTH], LCD_WIDTH + 62, 0, line + 1);
}
#ifdef ENABLE_DTMF_CALLING

View File

@ -166,12 +166,6 @@ const char gSubMenu_SFT_D[][4] =
"-"
};
const char gSubMenu_W_N[][7] =
{
"WIDE",
"NARROW"
};
const char gSubMenu_OFF_ON[][4] =
{
"OFF",
@ -577,7 +571,7 @@ void UI_DisplayMenu(void)
break;
case MENU_W_N:
strcpy(String, gSubMenu_W_N[gSubMenuSelection]);
strcpy(String, bwNames[gSubMenuSelection]);
break;
case MENU_SCR: