Skip to content

Commit

Permalink
Merge pull request #36 from kamilsss655/rc16.4
Browse files Browse the repository at this point in the history
Rc16.4
  • Loading branch information
kamilsss655 committed Jan 4, 2024
2 parents 7cf8131 + 82bcd3d commit 9a9393d
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 61 deletions.
24 changes: 24 additions & 0 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "settings.h"
#include "ui/inputbox.h"
#include "ui/ui.h"
#include "spectrum.h"

static void ACTION_FlashLight(void)
{
Expand Down Expand Up @@ -311,6 +312,22 @@ void ACTION_SwitchDemodul(void)
gRequestSaveChannel = 1;
}

BK4819_FilterBandwidth_t ACTION_NextBandwidth(BK4819_FilterBandwidth_t currentBandwidth, const bool dynamic)
{
BK4819_FilterBandwidth_t nextBandwidth;
if (currentBandwidth == BK4819_FILTER_BW_NARROWEST)
{
nextBandwidth = BK4819_FILTER_BW_WIDE;
}
else
{
nextBandwidth = currentBandwidth + 1;
}

BK4819_SetFilterBandwidth(nextBandwidth, dynamic);
return nextBandwidth;
}

#ifdef ENABLE_BLMIN_TMP_OFF
void ACTION_BlminTmpOff(void)
{
Expand Down Expand Up @@ -443,6 +460,13 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case ACTION_OPT_SWITCH_DEMODUL:
ACTION_SwitchDemodul();
break;
case ACTION_OPT_BANDWIDTH:
gTxVfo->CHANNEL_BANDWIDTH =
ACTION_NextBandwidth(gTxVfo->CHANNEL_BANDWIDTH, gTxVfo->Modulation != MODULATION_AM);
break;
case ACTION_OPT_SPECTRUM:
APP_RunSpectrum(IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE));
break;
#ifdef ENABLE_BLMIN_TMP_OFF
case ACTION_OPT_BLMIN_TMP_OFF:
ACTION_BlminTmpOff();
Expand Down
2 changes: 2 additions & 0 deletions app/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define APP_ACTION_H

#include "driver/keyboard.h"
#include "driver/bk4819.h"

//static void ACTION_FlashLight(void)
void ACTION_Power(void);
Expand All @@ -42,3 +43,4 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);

#endif

BK4819_FilterBandwidth_t ACTION_NextBandwidth(BK4819_FilterBandwidth_t currentBandwidth, const bool dynamic);
10 changes: 1 addition & 9 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,8 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
#elif defined(ENABLE_SPECTRUM)
#ifdef ENABLE_SPECTRUM_CHANNEL_SCAN
// if we are in channel mode then enter spectrum in channel mode
if(IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
APP_RunSpectrum(CHANNEL_MODE);
}
// otherwise enter spectrum in frequency mode
else
{
APP_RunSpectrum(FREQUENCY_MODE);
}

APP_RunSpectrum(IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE));
#elif
APP_RunSpectrum();
#endif
Expand Down
15 changes: 2 additions & 13 deletions app/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifdef ENABLE_SPECTRUM_COPY_VFO
#include "common.h"
#endif
#include "action.h"

struct FrequencyBandInfo {
uint32_t lower;
Expand Down Expand Up @@ -313,15 +314,8 @@ static void ExitAndCopyToVfo() {
else
// frequency mode
{
//if we entered spectrum from the channel mode
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)){
// swap to frequency mode
COMMON_SwitchToVFOMode();
}

gTxVfo->STEP_SETTING = FREQUENCY_GetStepIdxFromStepFrequency(GetScanStep());
gTxVfo->Modulation = settings.modulationType;
// TODO: Add support for NARROW- bandwidth in VFO (settings etc)
gTxVfo->CHANNEL_BANDWIDTH = settings.listenBw;

SETTINGS_SetVfoFrequency(peak.f);
Expand Down Expand Up @@ -601,12 +595,7 @@ static void ToggleModulation() {
}

static void ToggleListeningBW() {
if (settings.listenBw == BK4819_FILTER_BW_NARROWEST) {
settings.listenBw = BK4819_FILTER_BW_WIDE;
} else {
settings.listenBw++;
}
BK4819_SetFilterBandwidth(settings.listenBw, false);
settings.listenBw = ACTION_NextBandwidth(settings.listenBw, false);
redrawScreen = true;
}

Expand Down
74 changes: 37 additions & 37 deletions driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,49 +516,49 @@ void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold,
BK4819_WriteRegister(BK4819_REG_31, REG_31_Value | (1u << 2)); // VOX Enable
}

//1o11
// // filter bandwidth lowers when signal is low
// const uint16_t listenBWRegDynamicValues[5] = {
// 0x45a8, // 25
// 0x4408, // 12.5
// 0x1148, // 8.33
// 0x4458, // 6.25
// 0x0058 // 5
// };

// // filter bandwidth stays the same when signal is low
// const uint16_t listenBWRegValues[5] = {
// 0x49a8, // 25
// 0x4808, // 12.5
// 0x1348, // 8.33
// 0x4858, // 6.25
// 0x0058 // 5
// };
//fagci (narrower 25, 12.5)
// filter bandwidth lowers when signal is low
const uint16_t listenBWRegDynamicValues[5] = {
0x3428, // 25
0x7B08, // 12.5
0x4458, // 8.33
0x1148, // 6.25
0x0058 // 5
};

// filter bandwidth stays the same when signal is low
const uint16_t listenBWRegValues[5] = {
0x3628, // 25
0x7F08, // 12.5
0x4858, // 8.33
0x1348, // 6.25
0x0058 // 5
};

/*
Sets filter bandwidth
dynamic: if set to true, it will use dynamic filters that lower bandwidth when signal is low
*/
void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const bool dynamic)
{
//1o11
// // filter bandwidth lowers when signal is low
// const uint16_t listenBWRegDynamicValues[5] = {
// 0x45a8, // 25
// 0x4408, // 12.5
// 0x1148, // 8.33
// 0x4458, // 6.25
// 0x0058 // 5
// };

// // filter bandwidth stays the same when signal is low
// const uint16_t listenBWRegValues[5] = {
// 0x49a8, // 25
// 0x4808, // 12.5
// 0x1348, // 8.33
// 0x4858, // 6.25
// 0x0058 // 5
// };
//fagci (narrower 25, 12.5)
// filter bandwidth lowers when signal is low
const uint16_t listenBWRegDynamicValues[5] = {
0x3428, // 25
0x7B08, // 12.5
0x4458, // 8.33
0x1148, // 6.25
0x0058 // 5
};

// filter bandwidth stays the same when signal is low
const uint16_t listenBWRegValues[5] = {
0x3628, // 25
0x7F08, // 12.5
0x4858, // 8.33
0x1348, // 6.25
0x0058 // 5
};

BK4819_WriteRegister(BK4819_REG_43, dynamic==true ? listenBWRegDynamicValues[Bandwidth] : listenBWRegValues[Bandwidth]);
}

Expand Down
9 changes: 7 additions & 2 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,7 @@ void RADIO_SetTxParameters(void)

BK4819_FilterBandwidth_t Bandwidth = gCurrentVfo->CHANNEL_BANDWIDTH;

BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->Modulation != MODULATION_AM);

BK4819_SetFilterBandwidth(Bandwidth, gTxVfo->Modulation != MODULATION_AM);

BK4819_SetFrequency(gCurrentVfo->pTX->Frequency);

Expand Down Expand Up @@ -970,6 +969,12 @@ void RADIO_PrepareTX(void)
State = VFO_STATE_TX_DISABLE;
}
else
if(gEeprom.RX_OFFSET!=0)
{
// disable TX when using RX_OFFSET to protect the upconverter
State = VFO_STATE_TX_DISABLE;
}
else
if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0)
{ // TX frequency is allowed
if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE)
Expand Down
2 changes: 2 additions & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ enum {
#ifdef ENABLE_BLMIN_TMP_OFF
ACTION_OPT_BLMIN_TMP_OFF, //BackLight Minimum Temporay OFF
#endif
ACTION_OPT_BANDWIDTH,
ACTION_OPT_SPECTRUM,
ACTION_OPT_LEN
};

Expand Down
2 changes: 2 additions & 0 deletions ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ const t_sidefunction SIDEFUNCTIONS[] =
{"SWITCH\nVFO", ACTION_OPT_A_B},
{"VFO/MR", ACTION_OPT_VFO_MR},
{"SWITCH\nDEMODUL", ACTION_OPT_SWITCH_DEMODUL},
{"SWITCH\nBANDWID", ACTION_OPT_BANDWIDTH},
{"SPECTRUM", ACTION_OPT_SPECTRUM},
#ifdef ENABLE_BLMIN_TMP_OFF
{"BLMIN\nTMP OFF", ACTION_OPT_BLMIN_TMP_OFF}, //BackLight Minimum Temporay OFF
#endif
Expand Down

0 comments on commit 9a9393d

Please sign in to comment.