Skip to content

Commit

Permalink
Restore wideband weak signal bandwidth (squelch more sensitive), adde…
Browse files Browse the repository at this point in the history
…d 5 sec BKLT
  • Loading branch information
OneOfEleven committed Sep 21, 2023
1 parent 653a00b commit b02d46f
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 182 deletions.
5 changes: 2 additions & 3 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@ void APP_TimeSlice500ms(void)
if (gBacklightCountdown > 0)
if (gScreenToDisplay != DISPLAY_MENU || gMenuCursor != MENU_ABR) // don't turn off backlight if user is in backlight menu option
if (--gBacklightCountdown == 0)
if (gEeprom.BACKLIGHT < 5)
if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off

#ifdef ENABLE_AIRCOPY
Expand Down Expand Up @@ -1961,7 +1961,7 @@ void APP_TimeSlice500ms(void)

ST7565_Configure_GPIO_B11();

//if (gEeprom.BACKLIGHT < 5)
//if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight off
}
#ifdef ENABLE_VOICE
Expand Down Expand Up @@ -2092,7 +2092,6 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
bool bFlag = false;

// const bool backlight_was_on = (gBacklightCountdown > 0 || gEeprom.BACKLIGHT >= 5);
const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);

if (Key == KEY_EXIT && !backlight_was_on && gEeprom.BACKLIGHT > 0)
Expand Down
59 changes: 33 additions & 26 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,32 +176,39 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
#else

// TODO: FIX ME .. not working for VFO, works for channel

switch (gTxVfo->CHANNEL_BANDWIDTH)
{
case BANDWIDTH_WIDE:
gTxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_NARROW;
break;
default:
case BANDWIDTH_NARROW:
gTxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_WIDE;
break;
}
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gRequestSaveChannel = 2;
}
else
// if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
}
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH);
gUpdateDisplay = true;
gRequestDisplayScreen = gScreenToDisplay;
#if 0
// toggle wide/narrow
// TODO: FIX ME .. not working for VFO, works for channel
switch (gTxVfo->CHANNEL_BANDWIDTH)
{
case BANDWIDTH_WIDE:
gTxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_NARROW;
break;
default:
case BANDWIDTH_NARROW:
gTxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_WIDE;
break;
}
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gRequestSaveChannel = 2;
}
else
//if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
}
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH);
gUpdateDisplay = true;
gRequestDisplayScreen = gScreenToDisplay;
#else
// toggle scanlist-1
gTxVfo->SCANLIST1_PARTICIPATION = gTxVfo->SCANLIST1_PARTICIPATION ? 0 : 1;
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE_1;
gFlagResetVfos = true;
#endif
#endif
break;

Expand Down
2 changes: 1 addition & 1 deletion app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)

case MENU_ABR:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_BACK_LIGHT) - 1;
*pMax = ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1;
break;

case MENU_F_LOCK:
Expand Down
21 changes: 16 additions & 5 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "bsp/dp32g030/saradc.h"
#include "bsp/dp32g030/syscon.h"
#include "driver/adc.h"
//#include "driver/backlight.h"
#ifdef ENABLE_FMRADIO
#include "driver/bk1080.h"
#endif
Expand All @@ -44,10 +45,7 @@
#if defined(ENABLE_OVERLAY)
#include "sram-overlay.h"
#endif

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#include "ui/menu.h"

static const uint32_t gDefaultFrequencyTable[] =
{
Expand Down Expand Up @@ -545,7 +543,7 @@ void BOARD_EEPROM_Init(void)
gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF;
gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4;
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A;
gEeprom.BACKLIGHT = (Data[5] < 6) ? Data[5] : 4;
gEeprom.BACKLIGHT = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 4;
gEeprom.TAIL_NOTE_ELIMINATION = (Data[6] < 2) ? Data[6] : false;
gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true;

Expand Down Expand Up @@ -791,6 +789,19 @@ void BOARD_EEPROM_LoadMoreSettings(void)
}
}

uint32_t BOARD_fetchChannelFrequency(const int channel)
{
struct
{
uint32_t frequency;
uint32_t offset;
} __attribute__((packed)) info;

EEPROM_ReadBuffer(channel * 16, &info, sizeof(info));

return info.frequency;
}

void BOARD_fetchChannelName(char *s, const int channel)
{
int i;
Expand Down
21 changes: 11 additions & 10 deletions board.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@

#include <stdint.h>

void BOARD_FLASH_Init(void);
void BOARD_GPIO_Init(void);
void BOARD_PORTCON_Init(void);
void BOARD_ADC_Init(void);
void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent);
void BOARD_Init(void);
void BOARD_EEPROM_Init(void);
void BOARD_EEPROM_LoadMoreSettings(void);
void BOARD_fetchChannelName(char *s, const int channel);
void BOARD_FactoryReset(bool bIsAll);
void BOARD_FLASH_Init(void);
void BOARD_GPIO_Init(void);
void BOARD_PORTCON_Init(void);
void BOARD_ADC_Init(void);
void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent);
void BOARD_Init(void);
void BOARD_EEPROM_Init(void);
void BOARD_EEPROM_LoadMoreSettings(void);
uint32_t BOARD_fetchChannelFrequency(const int channel);
void BOARD_fetchChannelName(char *s, const int channel);
void BOARD_FactoryReset(bool bIsAll);

#endif

14 changes: 8 additions & 6 deletions driver/backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ void BACKLIGHT_TurnOn(void)
switch (gEeprom.BACKLIGHT)
{
default:
case 1: // 10 sec
case 1: // 5 sec
gBacklightCountdown = 2 * 5;
break;
case 2: // 10 sec
gBacklightCountdown = 2 * 10;
break;
case 2: // 20 sec
case 3: // 20 sec
gBacklightCountdown = 2 * 20;
break;
case 3: // 40 sec
case 4: // 40 sec
gBacklightCountdown = 2 * 40;
break;
case 4: // 80 sec
case 5: // 80 sec
gBacklightCountdown = 2 * 80;
break;
case 5: // always on
case 6: // always on
gBacklightCountdown = 0;
break;
}
}

4 changes: 2 additions & 2 deletions driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ void BK4819_SetFilterBandwidth(BK4819_FilterBandwidth_t Bandwidth)
BK4819_WriteRegister(BK4819_REG_43,
(0u << 15) | // 0
(3u << 12) | // 3 RF filter bandwidth
(3u << 9) | // 0 RF filter bandwidth when signal is weak
(0u << 9) | // 0 RF filter bandwidth when signal is weak
(0u << 6) | // 0 AFTxLPF2 filter Band Width
(2u << 4) | // 2 BW Mode Selection
(1u << 3) | // 1
Expand All @@ -574,7 +574,7 @@ void BK4819_SetFilterBandwidth(BK4819_FilterBandwidth_t Bandwidth)
BK4819_WriteRegister(BK4819_REG_43, // 0x4048); // 0 100 000 001 00 1 0 00
(0u << 15) | // 0
(3u << 12) | // 4 RF filter bandwidth
(3u << 9) | // 0 RF filter bandwidth when signal is weak
(0u << 9) | // 0 RF filter bandwidth when signal is weak
(1u << 6) | // 1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection
(1u << 3) | // 1
Expand Down
Binary file modified firmware
Binary file not shown.
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void Main(void)
{
FUNCTION_Select(FUNCTION_POWER_SAVE);

if (gEeprom.BACKLIGHT < 5)
if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
else
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON
Expand Down
Loading

0 comments on commit b02d46f

Please sign in to comment.