Add third list

This commit is contained in:
Armel FAUVEAU
2024-06-24 00:24:47 +02:00
parent 0235d26326
commit 2deff09d47
15 changed files with 179 additions and 21 deletions

View File

@@ -4,7 +4,7 @@
# 1 = enable
# ---- STOCK QUANSHENG FERATURES ----
ENABLE_FMRADIO ?= 0
ENABLE_FMRADIO ?= 1
ENABLE_UART ?= 1
ENABLE_AIRCOPY ?= 0
ENABLE_NOAA ?= 0

View File

@@ -219,7 +219,7 @@ void ACTION_Scan(bool bRestart)
}
// channel mode. Keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 4;
// jump to the next channel
CHFRSCANNER_Start(false, gScanStateDir);

View File

@@ -17,6 +17,7 @@ uint32_t gScanRangeStop;
typedef enum {
SCAN_NEXT_CHAN_SCANLIST1 = 0,
SCAN_NEXT_CHAN_SCANLIST2,
SCAN_NEXT_CHAN_SCANLIST3,
SCAN_NEXT_CHAN_DUAL_WATCH,
SCAN_NEXT_CHAN_MR,
SCAN_NEXT_NUM
@@ -194,9 +195,10 @@ static void NextFreqChannel(void)
static void NextMemChannel(void)
{
static unsigned 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 bool enabled = (gEeprom.SCAN_LIST_DEFAULT < 3) ? gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT] : true;
const int chan1 = -1;
const int chan2 = -1;
const int chan3 = -1;
const unsigned int prev_chan = gNextMrChannel;
unsigned int chan = 0;
@@ -228,7 +230,17 @@ static void NextMemChannel(void)
}
}
[[fallthrough]];
case SCAN_NEXT_CHAN_SCANLIST3:
if (chan3 >= 0)
{
if (RADIO_CheckValidChannel(chan3, false, 0))
{
currentScanList = SCAN_NEXT_CHAN_SCANLIST3;
gNextMrChannel = chan3;
break;
}
}
[[fallthrough]];
// this bit doesn't yet work if the other VFO is a frequency
case SCAN_NEXT_CHAN_DUAL_WATCH:
// dual watch is enabled - include the other VFO in the scan
@@ -255,7 +267,7 @@ static void NextMemChannel(void)
if (!enabled || chan == 0xff)
{
chan = RADIO_FindNextChannel(gNextMrChannel + gScanStateDir, gScanStateDir, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT);
chan = RADIO_FindNextChannel(gNextMrChannel + gScanStateDir, gScanStateDir, (gEeprom.SCAN_LIST_DEFAULT < 3) ? true : false, gEeprom.SCAN_LIST_DEFAULT);
if (chan == 0xFF)
{ // no valid channel found
chan = MR_CHANNEL_FIRST;

View File

@@ -59,11 +59,32 @@ static void toggle_chan_scanlist(void)
return;
}
/*
if (gTxVfo->SCANLIST1_PARTICIPATION ^ gTxVfo->SCANLIST2_PARTICIPATION){
gTxVfo->SCANLIST2_PARTICIPATION = gTxVfo->SCANLIST1_PARTICIPATION;
} else {
gTxVfo->SCANLIST1_PARTICIPATION = !gTxVfo->SCANLIST1_PARTICIPATION;
}
*/
if(gTxVfo->SCANLIST1_PARTICIPATION == 1)
{
gTxVfo->SCANLIST1_PARTICIPATION = 0;
gTxVfo->SCANLIST2_PARTICIPATION = 1;
gTxVfo->SCANLIST3_PARTICIPATION = 0;
}
else if(gTxVfo->SCANLIST2_PARTICIPATION == 1)
{
gTxVfo->SCANLIST1_PARTICIPATION = 0;
gTxVfo->SCANLIST2_PARTICIPATION = 0;
gTxVfo->SCANLIST3_PARTICIPATION = 1;
}
else if(gTxVfo->SCANLIST3_PARTICIPATION == 1)
{
gTxVfo->SCANLIST1_PARTICIPATION = 1;
gTxVfo->SCANLIST2_PARTICIPATION = 0;
gTxVfo->SCANLIST3_PARTICIPATION = 0;
}
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, true, true);
@@ -547,12 +568,13 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
if (bKeyPressed) { // long press MENU key
#ifdef ENABLE_FEAT_F4HWN
if(gScanStateDir != SCAN_OFF && gEeprom.SCAN_LIST_DEFAULT < 2)
if(gScanStateDir != SCAN_OFF && gEeprom.SCAN_LIST_DEFAULT < 3)
{
if(FUNCTION_IsRx())
{
gTxVfo->SCANLIST1_PARTICIPATION = 0;
gTxVfo->SCANLIST2_PARTICIPATION = 0;
gTxVfo->SCANLIST3_PARTICIPATION = 0;
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, true, false);

View File

@@ -238,6 +238,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_AUTOLK:
case MENU_S_ADD1:
case MENU_S_ADD2:
case MENU_S_ADD3:
case MENU_STE:
case MENU_D_ST:
#ifdef ENABLE_DTMF_CALLING
@@ -293,6 +294,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_SLIST1:
case MENU_SLIST2:
case MENU_SLIST3:
*pMin = -1;
*pMax = MR_CHANNEL_LAST;
break;
@@ -309,7 +311,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_S_LIST:
//*pMin = 0;
*pMax = 2;
*pMax = 3;
break;
#ifdef ENABLE_DTMF_CALLING
@@ -638,6 +640,13 @@ void MENU_AcceptSetting(void)
gFlagResetVfos = true;
return;
case MENU_S_ADD3:
gTxVfo->SCANLIST3_PARTICIPATION = gSubMenuSelection;
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, false, true);
gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true;
return;
case MENU_STE:
gEeprom.TAIL_TONE_ELIMINATION = gSubMenuSelection;
break;
@@ -1087,6 +1096,10 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gTxVfo->SCANLIST2_PARTICIPATION;
break;
case MENU_S_ADD3:
gSubMenuSelection = gTxVfo->SCANLIST3_PARTICIPATION;
break;
case MENU_STE:
gSubMenuSelection = gEeprom.TAIL_TONE_ELIMINATION;
break;
@@ -1125,6 +1138,10 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = RADIO_FindNextChannel(0, 1, true, 1);
break;
case MENU_SLIST3:
gSubMenuSelection = RADIO_FindNextChannel(0, 1, true, 2);
break;
#ifdef ENABLE_ALARM
case MENU_AL_MOD:
gSubMenuSelection = gEeprom.ALARM_MODE;
@@ -1804,10 +1821,16 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
bCheckScanList = false;
break;
case MENU_SLIST3:
bCheckScanList = true;
VFO = 2;
break;
case MENU_SLIST2:
bCheckScanList = true;
VFO = 1;
[[fallthrough]];
break;
case MENU_SLIST1:
VFO = 0;
bCheckScanList = true;
break;

View File

@@ -173,7 +173,7 @@ const uint8_t BITMAP_VFO_NotDefault[8] =
};
const uint8_t BITMAP_ScanList1[7] =
{ // 'I' symbol
{ // '1' symbol
0b01111111,
0b01111111,
0b01111011,
@@ -184,7 +184,7 @@ const uint8_t BITMAP_ScanList1[7] =
};
const uint8_t BITMAP_ScanList2[7] =
{ // 'II' symbol
{ // '2' symbol
0b01111111,
0b01111111,
0b01001101,
@@ -194,6 +194,17 @@ const uint8_t BITMAP_ScanList2[7] =
0b01111111,
};
const uint8_t BITMAP_ScanList3[7] =
{ // '3' symbol
0b01111111,
0b01111111,
0b01011101,
0b01010101,
0b01101011,
0b01111111,
0b01111111,
};
const uint8_t BITMAP_compand[6] =
{
0b00000000,

View File

@@ -33,6 +33,7 @@ extern const uint8_t BITMAP_VFO_Default[8];
extern const uint8_t BITMAP_VFO_NotDefault[8];
extern const uint8_t BITMAP_ScanList1[7];
extern const uint8_t BITMAP_ScanList2[7];
extern const uint8_t BITMAP_ScanList3[7];
extern const uint8_t BITMAP_compand[6];
#ifndef ENABLE_CUSTOM_MENU_LAYOUT

3
misc.h
View File

@@ -195,8 +195,9 @@ extern uint16_t gEEPROM_1F8C;
typedef union {
struct {
uint8_t
band : 4,
band : 3,
compander : 2,
scanlist3 : 1,
scanlist2 : 1,
scanlist1 : 1;
};

41
radio.c
View File

@@ -36,6 +36,7 @@
#include "radio.h"
#include "settings.h"
#include "ui/menu.h"
#include "debugging.h"
VFO_Info_t *gTxVfo;
VFO_Info_t *gRxVfo;
@@ -58,6 +59,11 @@ const char gModulationStr[MODULATION_UKNOWN][4] = {
bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanList)
{
//char str[64] = "";
//sprintf(str, "RADIO_CheckValidChannel channel %d / checkScanList %d / scanList %d\n", channel, checkScanList, scanList);
//LogUart(str);
// return true if the channel appears valid
if (!IS_MR_CHANNEL(channel))
return false;
@@ -67,11 +73,30 @@ bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanL
if (att.band > BAND7_470MHz)
return false;
if (!checkScanList || scanList > 1)
if (!checkScanList || scanList > 2)
return true;
if (scanList ? !att.scanlist2 : !att.scanlist1)
//sprintf(str, "scanList %d / att.scanlist1 %d / att.scanlist2 %d / att.scanlist3 %d\n", scanList, att.scanlist1, att.scanlist2, att.scanlist3);
//LogUart(str);
if(scanList == 0 && att.scanlist1 != 1)
{
return false;
}
else if(scanList == 1 && att.scanlist2 != 1)
{
return false;
}
else if(scanList == 2 && att.scanlist3 != 1)
{
return false;
}
//sprintf(str, ">>> %d\n", scanList);
//LogUart(str);
return true;
const uint8_t PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[scanList];
const uint8_t PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[scanList];
@@ -81,6 +106,10 @@ bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanL
uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScanList, uint8_t VFO)
{
//char str[64] = "";
//sprintf(str, "RADIO_FindNextChannel Channel %d / VFO %d\n", Channel, VFO);
//LogUart(str);
for (unsigned int i = 0; IS_MR_CHANNEL(i); i++, Channel += Direction) {
if (Channel == 0xFF) {
Channel = MR_CHANNEL_LAST;
@@ -91,6 +120,8 @@ uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScan
if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO)) {
return Channel;
}
//sprintf(str, "VFO %d...\n", VFO);
//LogUart(str);
}
return 0xFF;
@@ -103,6 +134,7 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t
pInfo->Band = FREQUENCY_GetBand(Frequency);
pInfo->SCANLIST1_PARTICIPATION = false;
pInfo->SCANLIST2_PARTICIPATION = false;
pInfo->SCANLIST3_PARTICIPATION = false;
pInfo->STEP_SETTING = STEP_12_5kHz;
pInfo->StepFrequency = gStepFrequencyTable[pInfo->STEP_SETTING];
pInfo->CHANNEL_SAVE = ChannelSave;
@@ -186,19 +218,24 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
bool bParticipation1;
bool bParticipation2;
bool bParticipation3;
if (IS_MR_CHANNEL(channel)) {
bParticipation1 = att.scanlist1;
bParticipation2 = att.scanlist2;
bParticipation3 = att.scanlist3;
}
else {
band = channel - FREQ_CHANNEL_FIRST;
bParticipation1 = true;
bParticipation2 = true;
bParticipation3 = true;
}
pVfo->Band = band;
pVfo->SCANLIST1_PARTICIPATION = bParticipation1;
pVfo->SCANLIST2_PARTICIPATION = bParticipation2;
pVfo->SCANLIST3_PARTICIPATION = bParticipation3;
pVfo->CHANNEL_SAVE = channel;
uint16_t base;

View File

@@ -116,6 +116,7 @@ typedef struct VFO_Info_t
uint8_t SCANLIST1_PARTICIPATION;
uint8_t SCANLIST2_PARTICIPATION;
uint8_t SCANLIST3_PARTICIPATION;
uint8_t Band;
#ifdef ENABLE_DTMF_CALLING

View File

@@ -276,7 +276,7 @@ void SETTINGS_InitEEPROM(void)
ChannelAttributes_t *att = &gMR_ChannelAttributes[i];
if(att->__val == 0xff){
att->__val = 0;
att->band = 0xf;
att->band = 0x7;
}
}
@@ -770,10 +770,11 @@ void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep,
{
uint8_t state[8];
ChannelAttributes_t att = {
.band = 0xf,
.band = 0x7,
.compander = 0,
.scanlist1 = 0,
.scanlist2 = 0,
.scanlist3 = 0,
}; // default attributes
uint16_t offset = 0x0D60 + (channel & ~7u);
@@ -783,6 +784,7 @@ void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep,
att.band = pVFO->Band;
att.scanlist1 = pVFO->SCANLIST1_PARTICIPATION;
att.scanlist2 = pVFO->SCANLIST2_PARTICIPATION;
att.scanlist3 = pVFO->SCANLIST3_PARTICIPATION;
att.compander = pVFO->Compander;
if (check && state[channel & 7u] == att.__val)
return; // no change in the attributes

View File

@@ -892,12 +892,44 @@ void UI_DisplayMain(void)
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ // it's a channel
uint8_t countList = 0;
uint8_t shiftList = 0;
// show the scan list assigment symbols
const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
if (att.scanlist1)
memcpy(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
countList++;
if (att.scanlist2)
memcpy(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
countList++;
if (att.scanlist3)
countList++;
shiftList = countList;
if (att.scanlist1)
{
memcpy(p_line0 + 128 - (shiftList * 7), BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
shiftList--;
}
if (att.scanlist2)
{
memcpy(p_line0 + 128 - (shiftList * 7), BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
shiftList--;
}
if (att.scanlist3)
{
memcpy(p_line0 + 128 - (shiftList * 7), BITMAP_ScanList3, sizeof(BITMAP_ScanList3));
}
/*
if (att.scanlist1)
memcpy(p_line0 + 107, BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
if (att.scanlist2)
memcpy(p_line0 + 114, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
if (att.scanlist3)
memcpy(p_line0 + 121, BITMAP_ScanList3, sizeof(BITMAP_ScanList3));
*/
// compander symbol
#ifndef ENABLE_BIG_FREQ
@@ -941,6 +973,14 @@ void UI_DisplayMain(void)
{ // no channel name, show the channel number instead
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
}
else
{
// Too many list, so remove last character name
if(String[9] != 0 && countList == 3)
{
String[9] = 0;
}
}
if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) {
UI_PrintString(String, 32, 0, line, 8);

View File

@@ -57,6 +57,7 @@ const t_menu_item MenuList[] =
{"Mode", MENU_AM }, // was "AM"
{"ScAdd1", MENU_S_ADD1 },
{"ScAdd2", MENU_S_ADD2 },
{"ScAdd3", MENU_S_ADD3 },
{"ChSave", MENU_MEM_CH }, // was "MEM-CH"
{"ChDele", MENU_DEL_CH }, // was "DEL-CH"
{"ChName", MENU_MEM_NAME },
@@ -64,6 +65,7 @@ const t_menu_item MenuList[] =
{"SList", MENU_S_LIST },
{"SList1", MENU_SLIST1 },
{"SList2", MENU_SLIST2 },
{"SList3", MENU_SLIST3 },
{"ScnRev", MENU_SC_REV },
#ifdef ENABLE_NOAA
{"NOAA-S", MENU_NOAA_S },
@@ -695,6 +697,7 @@ void UI_DisplayMenu(void)
case MENU_BEEP:
case MENU_S_ADD1:
case MENU_S_ADD2:
case MENU_S_ADD3:
case MENU_STE:
case MENU_D_ST:
#ifdef ENABLE_DTMF_CALLING
@@ -805,7 +808,7 @@ void UI_DisplayMenu(void)
break;
case MENU_S_LIST:
if (gSubMenuSelection < 2)
if (gSubMenuSelection < 3)
sprintf(String, "LIST%u", 1 + gSubMenuSelection);
else
strcpy(String, "ALL");
@@ -1021,7 +1024,7 @@ void UI_DisplayMenu(void)
}
}
if (UI_MENU_GetCurrentMenuId() == MENU_SLIST1 || UI_MENU_GetCurrentMenuId() == MENU_SLIST2)
if (UI_MENU_GetCurrentMenuId() == MENU_SLIST1 || UI_MENU_GetCurrentMenuId() == MENU_SLIST2 || UI_MENU_GetCurrentMenuId() == MENU_SLIST3)
{
i = (UI_MENU_GetCurrentMenuId() == MENU_SLIST1) ? 0 : 1;
char *pPrintStr = String;

View File

@@ -66,6 +66,7 @@ enum
MENU_AUTOLK,
MENU_S_ADD1,
MENU_S_ADD2,
MENU_S_ADD3,
MENU_STE,
MENU_RP_STE,
MENU_MIC,
@@ -77,6 +78,7 @@ enum
MENU_S_LIST,
MENU_SLIST1,
MENU_SLIST2,
MENU_SLIST3,
#ifdef ENABLE_ALARM
MENU_AL_MOD,
#endif

View File

@@ -102,6 +102,9 @@ void UI_DisplayStatus()
memcpy(line + x + 2, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
break;
case 2:
memcpy(line + x + 2, BITMAP_ScanList3, sizeof(BITMAP_ScanList3));
break;
case 3:
memcpy(line + x, gFontScanAll, sizeof(gFontScanAll));
break;
}