Skip to content

Commit

Permalink
Scanlist now 1, 2 or all channels
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Oct 4, 2023
1 parent fe949d2 commit 1cfb59f
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 43 deletions.
4 changes: 2 additions & 2 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void ACTION_Scan(bool bRestart)
{
#if 1
// keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) & 1u;
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
gUpdateStatus = true;
#else
SCANNER_Stop();
Expand Down Expand Up @@ -217,7 +217,7 @@ void ACTION_Scan(bool bRestart)
else
if (!bRestart)
{ // keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) & 1u;
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
gUpdateStatus = true;
}
else
Expand Down
41 changes: 24 additions & 17 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,34 +639,41 @@ static void FREQ_NextChannel(void)

static void MR_NextChannel(void)
{
static unsigned int prev_mr_chan = 0;
const bool enabled = gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT];
const unsigned int chan1 = gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT];
const unsigned int chan2 = gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT];
const unsigned int prev_chan = gNextMrChannel;
unsigned int chan = 0;
static int prev_mr_chan = 0;
const bool enabled = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT] : true;
const int chan1 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT] : -1;
const int chan2 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT] : -1;
const int prev_chan = gNextMrChannel;
int chan = 0;

if (enabled)
{
switch (gCurrentScanList)
{
case SCAN_NEXT_CHAN_SCANLIST1:
prev_mr_chan = gNextMrChannel;
if (RADIO_CheckValidChannel(chan1, false, 0))

if (chan1 >= 0)
{
//gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gNextMrChannel = chan1;
break;
if (RADIO_CheckValidChannel(chan1, false, 0))
{
//gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gNextMrChannel = chan1;
break;
}
}

case SCAN_NEXT_CHAN_SCANLIST2:
if (RADIO_CheckValidChannel(chan2, false, 0))
if (chan2 >= 0)
{
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST2;
gNextMrChannel = chan2;
break;
if (RADIO_CheckValidChannel(chan2, false, 0))
{
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST2;
gNextMrChannel = chan2;
break;
}
}

// this bit doesn't work at all - yet :(
case SCAN_NEXT_CHAN_DUAL_WATCH:
// if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
Expand All @@ -693,7 +700,7 @@ static void MR_NextChannel(void)

if (!enabled || chan == 0xffffffff)
{
chan = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, true, gEeprom.SCAN_LIST_DEFAULT);
chan = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT);
if (chan == 0xFF)
return;

Expand Down
38 changes: 24 additions & 14 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,20 +555,30 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
int channel = -1;
int vfo = -1;

if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[0]) &&
IS_MR_CHANNEL(gEeprom.ScreenChannel[1]))
{
channel = gEeprom.ScreenChannel[1];
vfo = 0;
}
else
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[1]) &&
IS_MR_CHANNEL(gEeprom.ScreenChannel[0]))
{
channel = gEeprom.ScreenChannel[0];
vfo = 1;
}

#if 0
// copy channel to opposite VFO
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[0]) &&
IS_MR_CHANNEL(gEeprom.ScreenChannel[1]))
{
channel = gEeprom.ScreenChannel[1];
vfo = 0;
}
else
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[1]) &&
IS_MR_CHANNEL(gEeprom.ScreenChannel[0]))
{
channel = gEeprom.ScreenChannel[0];
vfo = 1;
}
#else
// copy channel to same VFO
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[gEeprom.RX_CHANNEL]))
{
channel = gEeprom.ScreenChannel[gEeprom.RX_CHANNEL];
vfo = gEeprom.RX_CHANNEL;
}
#endif

if (channel >= 0 && vfo >= 0)
{ // copy the channel into the VFO

Expand Down
7 changes: 4 additions & 3 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
break;

case MENU_S_LIST:
*pMin = 1;
*pMin = 0;
// *pMax = 1;
*pMax = 2;
break;

Expand Down Expand Up @@ -612,7 +613,7 @@ void MENU_AcceptSetting(void)
break;

case MENU_S_LIST:
gEeprom.SCAN_LIST_DEFAULT = gSubMenuSelection - 1;
gEeprom.SCAN_LIST_DEFAULT = gSubMenuSelection;
break;

#ifdef ENABLE_ALARM
Expand Down Expand Up @@ -1018,7 +1019,7 @@ void MENU_ShowCurrentSetting(void)
break;

case MENU_S_LIST:
gSubMenuSelection = gEeprom.SCAN_LIST_DEFAULT + 1;
gSubMenuSelection = gEeprom.SCAN_LIST_DEFAULT;
break;

case MENU_SLIST1:
Expand Down
2 changes: 1 addition & 1 deletion board.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void BOARD_EEPROM_Init(void)
gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*';
gEeprom.DTMF_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#';
gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0;
gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 10) ? Data[4] : 10;
gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 5) ? Data[4] : 10;
gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300;
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 100;
gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100;
Expand Down
2 changes: 1 addition & 1 deletion driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ void BK4819_EnableDTMF(void)
// REG_24 <3:0> 14 Max symbol number for SelCall detection

// const uint16_t threshold = 24; // doesn't decode non-QS radios
const uint16_t threshold = 200; // but 128 ~ 247 does
const uint16_t threshold = 160; // but 128 ~ 247 does
BK4819_WriteRegister(BK4819_REG_24, // 1 00011000 1 1 1 1110
(1u << BK4819_REG_24_SHIFT_UNKNOWN_15)
| (threshold << BK4819_REG_24_SHIFT_THRESHOLD) // 0 ~ 255
Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
33 changes: 29 additions & 4 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
#if 1
// TX audio level

if (gCurrentFunction != FUNCTION_TRANSMIT)
return;

if (gCurrentFunction != FUNCTION_TRANSMIT ||
gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
return; // screen is in use

#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState != ALARM_STATE_OFF)
return;
Expand Down Expand Up @@ -170,7 +172,9 @@ void UI_drawBars(uint8_t *p, const unsigned int level)

if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
return; // display is in use
if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN)
if (gCurrentFunction == FUNCTION_TRANSMIT ||
gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
return; // display is in use

if (now)
Expand Down Expand Up @@ -719,6 +723,10 @@ void UI_DisplayMain(void)
#if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA)
if (rx && gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix)
{
if (gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
return;

center_line = CENTER_LINE_AM_FIX_DATA;
AM_fix_print_data(gEeprom.RX_CHANNEL, String);
UI_PrintStringSmall(String, 2, 0, 3);
Expand All @@ -742,7 +750,13 @@ void UI_DisplayMain(void)
{ // show live DTMF decode
const unsigned int len = strlen(gDTMF_RX_live);
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars

if (gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
return;

center_line = CENTER_LINE_DTMF_DEC;

strcpy(String, "DTMF ");
strcat(String, gDTMF_RX_live + idx);
UI_PrintStringSmall(String, 2, 0, 3);
Expand All @@ -752,7 +766,13 @@ void UI_DisplayMain(void)
{ // show live DTMF decode
const unsigned int len = gDTMF_RX_index;
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars

if (gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
return;

center_line = CENTER_LINE_DTMF_DEC;

strcpy(String, "DTMF ");
strcat(String, gDTMF_RX + idx);
UI_PrintStringSmall(String, 2, 0, 3);
Expand All @@ -763,7 +783,12 @@ void UI_DisplayMain(void)
else
if (gChargingWithTypeC)
{ // charging .. show the battery state
if (gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
return;

center_line = CENTER_LINE_CHARGE_DATA;

sprintf(String, "Charge %u.%02uV %u%%",
gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100,
BATTERY_VoltsToPercent(gBatteryVoltageAverage));
Expand Down
5 changes: 4 additions & 1 deletion ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,10 @@ void UI_DisplayMenu(void)
break;

case MENU_S_LIST:
sprintf(String, "LIST%u", gSubMenuSelection);
if (gSubMenuSelection < 2)
sprintf(String, "LIST%u", 1 + gSubMenuSelection);
else
strcpy(String, "ALL");
break;

#ifdef ENABLE_ALARM
Expand Down
5 changes: 5 additions & 0 deletions ui/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ void UI_DisplayStatus(const bool test_display)
// memmove(line + x, BITMAP_SC1, sizeof(BITMAP_SC1));
UI_PrintStringSmallBuffer("1", line + x);
else
if (gEeprom.SCAN_LIST_DEFAULT == 1)
// memmove(line + x, BITMAP_SC2, sizeof(BITMAP_SC2));
UI_PrintStringSmallBuffer("2", line + x);
else
if (gEeprom.SCAN_LIST_DEFAULT == 2)
// memmove(line + x, BITMAP_SCA, sizeof(BITMAP_SCA));
UI_PrintStringSmallBuffer("*", line + x);
// x1 = x + sizeof(BITMAP_SC1);
x1 = x + 7;
}
Expand Down

0 comments on commit 1cfb59f

Please sign in to comment.