Refactor
This commit is contained in:
2
misc.c
2
misc.c
@@ -111,7 +111,7 @@ uint16_t gEEPROM_RSSI_CALIB[7][4];
|
|||||||
uint16_t gEEPROM_1F8A;
|
uint16_t gEEPROM_1F8A;
|
||||||
uint16_t gEEPROM_1F8C;
|
uint16_t gEEPROM_1F8C;
|
||||||
|
|
||||||
uint8_t gMR_ChannelAttributes[FREQ_CHANNEL_LAST + 1];
|
ChannelAttributes_t gMR_ChannelAttributes[FREQ_CHANNEL_LAST + 1];
|
||||||
|
|
||||||
volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms;
|
volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms;
|
||||||
|
|
||||||
|
13
misc.h
13
misc.h
@@ -176,7 +176,18 @@ extern uint16_t gEEPROM_RSSI_CALIB[7][4];
|
|||||||
extern uint16_t gEEPROM_1F8A;
|
extern uint16_t gEEPROM_1F8A;
|
||||||
extern uint16_t gEEPROM_1F8C;
|
extern uint16_t gEEPROM_1F8C;
|
||||||
|
|
||||||
extern uint8_t gMR_ChannelAttributes[207];
|
typedef union {
|
||||||
|
struct {
|
||||||
|
uint8_t
|
||||||
|
band : 4,
|
||||||
|
compander : 2,
|
||||||
|
scanlist2 : 1,
|
||||||
|
scanlist1 : 1;
|
||||||
|
};
|
||||||
|
uint8_t __val;
|
||||||
|
} ChannelAttributes_t;
|
||||||
|
|
||||||
|
extern ChannelAttributes_t gMR_ChannelAttributes[207];
|
||||||
|
|
||||||
extern volatile uint16_t gBatterySaveCountdown_10ms;
|
extern volatile uint16_t gBatterySaveCountdown_10ms;
|
||||||
|
|
||||||
|
311
radio.c
311
radio.c
@@ -56,24 +56,22 @@ const char gModulationStr[][4] =
|
|||||||
bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
|
bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
|
||||||
{ // return true if the channel appears valid
|
{ // return true if the channel appears valid
|
||||||
|
|
||||||
uint8_t Attributes;
|
ChannelAttributes_t att;
|
||||||
uint8_t PriorityCh1;
|
uint8_t PriorityCh1;
|
||||||
uint8_t PriorityCh2;
|
uint8_t PriorityCh2;
|
||||||
|
|
||||||
if (!IS_MR_CHANNEL(Channel))
|
if (!IS_MR_CHANNEL(Channel))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Attributes = gMR_ChannelAttributes[Channel];
|
att = gMR_ChannelAttributes[Channel];
|
||||||
|
|
||||||
if ((Attributes & MR_CH_BAND_MASK) > BAND7_470MHz)
|
if (att.band > BAND7_470MHz)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (bCheckScanList)
|
if (bCheckScanList) {
|
||||||
{
|
switch (VFO) {
|
||||||
switch (VFO)
|
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
if ((Attributes & MR_CH_SCANLIST1) == 0)
|
if (!att.scanlist1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[0];
|
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[0];
|
||||||
@@ -81,7 +79,7 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if ((Attributes & MR_CH_SCANLIST2) == 0)
|
if (!att.scanlist2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[1];
|
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[1];
|
||||||
@@ -128,8 +126,8 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t
|
|||||||
memset(pInfo, 0, sizeof(*pInfo));
|
memset(pInfo, 0, sizeof(*pInfo));
|
||||||
|
|
||||||
pInfo->Band = FREQUENCY_GetBand(Frequency);
|
pInfo->Band = FREQUENCY_GetBand(Frequency);
|
||||||
pInfo->SCANLIST1_PARTICIPATION = true;
|
pInfo->SCANLIST1_PARTICIPATION = false;
|
||||||
pInfo->SCANLIST2_PARTICIPATION = true;
|
pInfo->SCANLIST2_PARTICIPATION = false;
|
||||||
pInfo->STEP_SETTING = STEP_12_5kHz;
|
pInfo->STEP_SETTING = STEP_12_5kHz;
|
||||||
pInfo->StepFrequency = gStepFrequencyTable[pInfo->STEP_SETTING];
|
pInfo->StepFrequency = gStepFrequencyTable[pInfo->STEP_SETTING];
|
||||||
pInfo->CHANNEL_SAVE = ChannelSave;
|
pInfo->CHANNEL_SAVE = ChannelSave;
|
||||||
@@ -149,31 +147,23 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t
|
|||||||
|
|
||||||
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure)
|
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure)
|
||||||
{
|
{
|
||||||
uint8_t Channel;
|
VFO_Info_t *pVfo = &gEeprom.VfoInfo[VFO];
|
||||||
uint8_t Attributes;
|
|
||||||
uint8_t Band;
|
|
||||||
bool bParticipation2;
|
|
||||||
uint16_t Base;
|
|
||||||
uint32_t Frequency;
|
|
||||||
VFO_Info_t *pRadio = &gEeprom.VfoInfo[VFO];
|
|
||||||
|
|
||||||
if (!gSetting_350EN)
|
if (!gSetting_350EN) {
|
||||||
{
|
if (gEeprom.FreqChannel[VFO] == FREQ_CHANNEL_FIRST + BAND5_350MHz)
|
||||||
if (gEeprom.FreqChannel[VFO] == (FREQ_CHANNEL_LAST - 2))
|
gEeprom.FreqChannel[VFO] = FREQ_CHANNEL_FIRST + BAND6_400MHz;
|
||||||
gEeprom.FreqChannel[VFO] = FREQ_CHANNEL_LAST - 1;
|
|
||||||
|
|
||||||
if (gEeprom.ScreenChannel[VFO] == (FREQ_CHANNEL_LAST - 2))
|
if (gEeprom.ScreenChannel[VFO] == FREQ_CHANNEL_FIRST + BAND5_350MHz)
|
||||||
gEeprom.ScreenChannel[VFO] = FREQ_CHANNEL_LAST - 1;
|
gEeprom.ScreenChannel[VFO] = FREQ_CHANNEL_FIRST + BAND6_400MHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel = gEeprom.ScreenChannel[VFO];
|
uint8_t channel = gEeprom.ScreenChannel[VFO];
|
||||||
|
|
||||||
if (IS_VALID_CHANNEL(Channel))
|
if (IS_VALID_CHANNEL(channel)) {
|
||||||
{
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (Channel >= NOAA_CHANNEL_FIRST)
|
if (channel >= NOAA_CHANNEL_FIRST)
|
||||||
{
|
{
|
||||||
RADIO_InitInfo(pRadio, gEeprom.ScreenChannel[VFO], NoaaFrequencyTable[Channel - NOAA_CHANNEL_FIRST]);
|
RADIO_InitInfo(pVfo, gEeprom.ScreenChannel[VFO], NoaaFrequencyTable[channel - NOAA_CHANNEL_FIRST]);
|
||||||
|
|
||||||
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF)
|
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF)
|
||||||
return;
|
return;
|
||||||
@@ -185,248 +175,235 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(Channel))
|
if (IS_MR_CHANNEL(channel)) {
|
||||||
{
|
channel = RADIO_FindNextChannel(channel, RADIO_CHANNEL_UP, false, VFO);
|
||||||
Channel = RADIO_FindNextChannel(Channel, RADIO_CHANNEL_UP, false, VFO);
|
if (channel == 0xFF) {
|
||||||
if (Channel == 0xFF)
|
channel = gEeprom.FreqChannel[VFO];
|
||||||
{
|
|
||||||
Channel = gEeprom.FreqChannel[VFO];
|
|
||||||
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO];
|
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
gEeprom.ScreenChannel[VFO] = channel;
|
||||||
gEeprom.ScreenChannel[VFO] = Channel;
|
gEeprom.MrChannel[VFO] = channel;
|
||||||
gEeprom.MrChannel[VFO] = Channel;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Channel = FREQ_CHANNEL_LAST - 1;
|
channel = FREQ_CHANNEL_LAST - 1;
|
||||||
|
|
||||||
Attributes = gMR_ChannelAttributes[Channel];
|
ChannelAttributes_t att = gMR_ChannelAttributes[channel];
|
||||||
if (Attributes == 0xFF)
|
if (att.__val == 0xFF) { // invalid/unused channel
|
||||||
{ // invalid/unused channel
|
if (IS_MR_CHANNEL(channel)) {
|
||||||
|
channel = gEeprom.FreqChannel[VFO];
|
||||||
uint8_t Index;
|
gEeprom.ScreenChannel[VFO] = channel;
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(Channel))
|
|
||||||
{
|
|
||||||
Channel = gEeprom.FreqChannel[VFO];
|
|
||||||
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Index = Channel - FREQ_CHANNEL_FIRST;
|
uint8_t bandIdx = channel - FREQ_CHANNEL_FIRST;
|
||||||
|
RADIO_InitInfo(pVfo, channel, frequencyBandTable[bandIdx].lower);
|
||||||
RADIO_InitInfo(pRadio, Channel, frequencyBandTable[Index].lower);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Band = Attributes & MR_CH_BAND_MASK;
|
uint8_t band = att.band;
|
||||||
if (Band > BAND7_470MHz)
|
if (band > BAND7_470MHz) {
|
||||||
{
|
band = BAND6_400MHz;
|
||||||
Band = BAND6_400MHz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(Channel))
|
bool bParticipation1;
|
||||||
{
|
bool bParticipation2;
|
||||||
gEeprom.VfoInfo[VFO].Band = Band;
|
if (IS_MR_CHANNEL(channel)) {
|
||||||
gEeprom.VfoInfo[VFO].SCANLIST1_PARTICIPATION = !!(Attributes & MR_CH_SCANLIST1);
|
bParticipation1 = att.scanlist1;
|
||||||
bParticipation2 = !!(Attributes & MR_CH_SCANLIST2);
|
bParticipation2 = att.scanlist2;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
band = channel - FREQ_CHANNEL_FIRST;
|
||||||
Band = Channel - FREQ_CHANNEL_FIRST;
|
bParticipation1 = true;
|
||||||
gEeprom.VfoInfo[VFO].Band = Band;
|
|
||||||
bParticipation2 = true;
|
bParticipation2 = true;
|
||||||
gEeprom.VfoInfo[VFO].SCANLIST1_PARTICIPATION = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gEeprom.VfoInfo[VFO].SCANLIST2_PARTICIPATION = bParticipation2;
|
pVfo->Band = band;
|
||||||
gEeprom.VfoInfo[VFO].CHANNEL_SAVE = Channel;
|
pVfo->SCANLIST1_PARTICIPATION = bParticipation1;
|
||||||
|
pVfo->SCANLIST2_PARTICIPATION = bParticipation2;
|
||||||
|
pVfo->CHANNEL_SAVE = channel;
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(Channel))
|
uint16_t base;
|
||||||
Base = Channel * 16;
|
if (IS_MR_CHANNEL(channel))
|
||||||
|
base = channel * 16;
|
||||||
else
|
else
|
||||||
Base = 0x0C80 + ((Channel - FREQ_CHANNEL_FIRST) * 32) + (VFO * 16);
|
base = 0x0C80 + ((channel - FREQ_CHANNEL_FIRST) * 32) + (VFO * 16);
|
||||||
|
|
||||||
if (configure == VFO_CONFIGURE_RELOAD || Channel >= FREQ_CHANNEL_FIRST)
|
if (configure == VFO_CONFIGURE_RELOAD || IS_FREQ_CHANNEL(channel))
|
||||||
{
|
{
|
||||||
uint8_t Tmp;
|
uint8_t tmp;
|
||||||
uint8_t Data[8];
|
uint8_t data[8];
|
||||||
|
|
||||||
// ***************
|
// ***************
|
||||||
|
|
||||||
EEPROM_ReadBuffer(Base + 8, Data, sizeof(Data));
|
EEPROM_ReadBuffer(base + 8, data, sizeof(data));
|
||||||
|
|
||||||
Tmp = Data[3] & 0x0F;
|
tmp = data[3] & 0x0F;
|
||||||
if (Tmp > TX_OFFSET_FREQUENCY_DIRECTION_SUB)
|
if (tmp > TX_OFFSET_FREQUENCY_DIRECTION_SUB)
|
||||||
Tmp = 0;
|
tmp = 0;
|
||||||
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = Tmp;
|
pVfo->TX_OFFSET_FREQUENCY_DIRECTION = tmp;
|
||||||
gEeprom.VfoInfo[VFO].Modulation = (Data[3] >> 4);
|
pVfo->Modulation = (data[3] >> 4);
|
||||||
|
|
||||||
Tmp = Data[6];
|
tmp = data[6];
|
||||||
if (Tmp >= ARRAY_SIZE(gStepFrequencyTable))
|
if (tmp >= ARRAY_SIZE(gStepFrequencyTable))
|
||||||
Tmp = STEP_12_5kHz;
|
tmp = STEP_12_5kHz;
|
||||||
gEeprom.VfoInfo[VFO].STEP_SETTING = Tmp;
|
pVfo->STEP_SETTING = tmp;
|
||||||
gEeprom.VfoInfo[VFO].StepFrequency = gStepFrequencyTable[Tmp];
|
pVfo->StepFrequency = gStepFrequencyTable[tmp];
|
||||||
|
|
||||||
Tmp = Data[7];
|
tmp = data[7];
|
||||||
if (Tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1))
|
if (tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1))
|
||||||
Tmp = 0;
|
tmp = 0;
|
||||||
gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = Tmp;
|
pVfo->SCRAMBLING_TYPE = tmp;
|
||||||
|
|
||||||
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = (Data[2] >> 0) & 0x0F;
|
pVfo->freq_config_RX.CodeType = (data[2] >> 0) & 0x0F;
|
||||||
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = (Data[2] >> 4) & 0x0F;
|
pVfo->freq_config_TX.CodeType = (data[2] >> 4) & 0x0F;
|
||||||
|
|
||||||
Tmp = Data[0];
|
tmp = data[0];
|
||||||
switch (gEeprom.VfoInfo[VFO].freq_config_RX.CodeType)
|
switch (pVfo->freq_config_RX.CodeType)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case CODE_TYPE_OFF:
|
case CODE_TYPE_OFF:
|
||||||
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = CODE_TYPE_OFF;
|
pVfo->freq_config_RX.CodeType = CODE_TYPE_OFF;
|
||||||
Tmp = 0;
|
tmp = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_TYPE_CONTINUOUS_TONE:
|
case CODE_TYPE_CONTINUOUS_TONE:
|
||||||
if (Tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
|
if (tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
|
||||||
Tmp = 0;
|
tmp = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_TYPE_DIGITAL:
|
case CODE_TYPE_DIGITAL:
|
||||||
case CODE_TYPE_REVERSE_DIGITAL:
|
case CODE_TYPE_REVERSE_DIGITAL:
|
||||||
if (Tmp > (ARRAY_SIZE(DCS_Options) - 1))
|
if (tmp > (ARRAY_SIZE(DCS_Options) - 1))
|
||||||
Tmp = 0;
|
tmp = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gEeprom.VfoInfo[VFO].freq_config_RX.Code = Tmp;
|
pVfo->freq_config_RX.Code = tmp;
|
||||||
|
|
||||||
Tmp = Data[1];
|
tmp = data[1];
|
||||||
switch (gEeprom.VfoInfo[VFO].freq_config_TX.CodeType)
|
switch (pVfo->freq_config_TX.CodeType)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case CODE_TYPE_OFF:
|
case CODE_TYPE_OFF:
|
||||||
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF;
|
pVfo->freq_config_TX.CodeType = CODE_TYPE_OFF;
|
||||||
Tmp = 0;
|
tmp = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_TYPE_CONTINUOUS_TONE:
|
case CODE_TYPE_CONTINUOUS_TONE:
|
||||||
if (Tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
|
if (tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
|
||||||
Tmp = 0;
|
tmp = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_TYPE_DIGITAL:
|
case CODE_TYPE_DIGITAL:
|
||||||
case CODE_TYPE_REVERSE_DIGITAL:
|
case CODE_TYPE_REVERSE_DIGITAL:
|
||||||
if (Tmp > (ARRAY_SIZE(DCS_Options) - 1))
|
if (tmp > (ARRAY_SIZE(DCS_Options) - 1))
|
||||||
Tmp = 0;
|
tmp = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gEeprom.VfoInfo[VFO].freq_config_TX.Code = Tmp;
|
pVfo->freq_config_TX.Code = tmp;
|
||||||
|
|
||||||
if (Data[4] == 0xFF)
|
if (data[4] == 0xFF)
|
||||||
{
|
{
|
||||||
gEeprom.VfoInfo[VFO].FrequencyReverse = false;
|
pVfo->FrequencyReverse = false;
|
||||||
gEeprom.VfoInfo[VFO].CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE;
|
pVfo->CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE;
|
||||||
gEeprom.VfoInfo[VFO].OUTPUT_POWER = OUTPUT_POWER_LOW;
|
pVfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
|
||||||
gEeprom.VfoInfo[VFO].BUSY_CHANNEL_LOCK = false;
|
pVfo->BUSY_CHANNEL_LOCK = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const uint8_t d4 = Data[4];
|
const uint8_t d4 = data[4];
|
||||||
gEeprom.VfoInfo[VFO].FrequencyReverse = !!((d4 >> 0) & 1u);
|
pVfo->FrequencyReverse = !!((d4 >> 0) & 1u);
|
||||||
gEeprom.VfoInfo[VFO].CHANNEL_BANDWIDTH = !!((d4 >> 1) & 1u);
|
pVfo->CHANNEL_BANDWIDTH = !!((d4 >> 1) & 1u);
|
||||||
gEeprom.VfoInfo[VFO].OUTPUT_POWER = ((d4 >> 2) & 3u);
|
pVfo->OUTPUT_POWER = ((d4 >> 2) & 3u);
|
||||||
gEeprom.VfoInfo[VFO].BUSY_CHANNEL_LOCK = !!((d4 >> 4) & 1u);
|
pVfo->BUSY_CHANNEL_LOCK = !!((d4 >> 4) & 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Data[5] == 0xFF)
|
if (data[5] == 0xFF)
|
||||||
{
|
{
|
||||||
gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false;
|
pVfo->DTMF_DECODING_ENABLE = false;
|
||||||
gEeprom.VfoInfo[VFO].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF;
|
pVfo->DTMF_PTT_ID_TX_MODE = PTT_ID_OFF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = ((Data[5] >> 0) & 1u) ? true : false;
|
pVfo->DTMF_DECODING_ENABLE = ((data[5] >> 0) & 1u) ? true : false;
|
||||||
gEeprom.VfoInfo[VFO].DTMF_PTT_ID_TX_MODE = ((Data[5] >> 1) & 7u);
|
pVfo->DTMF_PTT_ID_TX_MODE = ((data[5] >> 1) & 7u);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************
|
// ***************
|
||||||
|
|
||||||
struct
|
struct {
|
||||||
{
|
|
||||||
uint32_t Frequency;
|
uint32_t Frequency;
|
||||||
uint32_t Offset;
|
uint32_t Offset;
|
||||||
} __attribute__((packed)) Info;
|
} __attribute__((packed)) info;
|
||||||
|
EEPROM_ReadBuffer(base, &info, sizeof(info));
|
||||||
|
|
||||||
EEPROM_ReadBuffer(Base, &Info, sizeof(Info));
|
pVfo->freq_config_RX.Frequency = info.Frequency;
|
||||||
|
|
||||||
pRadio->freq_config_RX.Frequency = Info.Frequency;
|
if (info.Offset >= 100000000)
|
||||||
|
info.Offset = 1000000;
|
||||||
if (Info.Offset >= 100000000)
|
pVfo->TX_OFFSET_FREQUENCY = info.Offset;
|
||||||
Info.Offset = 1000000;
|
|
||||||
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = Info.Offset;
|
|
||||||
|
|
||||||
// ***************
|
// ***************
|
||||||
}
|
}
|
||||||
|
|
||||||
Frequency = pRadio->freq_config_RX.Frequency;
|
uint32_t frequency = pVfo->freq_config_RX.Frequency;
|
||||||
|
|
||||||
// fix previously set incorrect band
|
// fix previously set incorrect band
|
||||||
Band = FREQUENCY_GetBand(Frequency);
|
band = FREQUENCY_GetBand(frequency);
|
||||||
|
|
||||||
if (Frequency < frequencyBandTable[Band].lower)
|
if (frequency < frequencyBandTable[band].lower)
|
||||||
Frequency = frequencyBandTable[Band].lower;
|
frequency = frequencyBandTable[band].lower;
|
||||||
else
|
else if (frequency > frequencyBandTable[band].upper)
|
||||||
if (Frequency > frequencyBandTable[Band].upper)
|
frequency = frequencyBandTable[band].upper;
|
||||||
Frequency = frequencyBandTable[Band].upper;
|
else if (channel >= FREQ_CHANNEL_FIRST)
|
||||||
else
|
frequency = FREQUENCY_RoundToStep(frequency, pVfo->StepFrequency);
|
||||||
if (Channel >= FREQ_CHANNEL_FIRST)
|
|
||||||
Frequency = FREQUENCY_RoundToStep(Frequency, gEeprom.VfoInfo[VFO].StepFrequency);
|
|
||||||
|
|
||||||
pRadio->freq_config_RX.Frequency = Frequency;
|
pVfo->freq_config_RX.Frequency = frequency;
|
||||||
|
|
||||||
if (Frequency >= frequencyBandTable[BAND2_108MHz].upper && Frequency < frequencyBandTable[BAND2_108MHz].upper)
|
if (frequency >= frequencyBandTable[BAND2_108MHz].upper && frequency < frequencyBandTable[BAND2_108MHz].upper)
|
||||||
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF;
|
pVfo->TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF;
|
||||||
else if (!IS_MR_CHANNEL(Channel))
|
else if (!IS_MR_CHANNEL(channel))
|
||||||
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = FREQUENCY_RoundToStep(gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY, gEeprom.VfoInfo[VFO].StepFrequency);
|
pVfo->TX_OFFSET_FREQUENCY = FREQUENCY_RoundToStep(pVfo->TX_OFFSET_FREQUENCY, pVfo->StepFrequency);
|
||||||
|
|
||||||
RADIO_ApplyOffset(pRadio);
|
RADIO_ApplyOffset(pVfo);
|
||||||
|
|
||||||
memset(gEeprom.VfoInfo[VFO].Name, 0, sizeof(gEeprom.VfoInfo[VFO].Name));
|
memset(pVfo->Name, 0, sizeof(pVfo->Name));
|
||||||
if (IS_MR_CHANNEL(Channel))
|
if (IS_MR_CHANNEL(channel))
|
||||||
{ // 16 bytes allocated to the channel name but only 10 used, the rest are 0's
|
{ // 16 bytes allocated to the channel name but only 10 used, the rest are 0's
|
||||||
EEPROM_ReadBuffer(0x0F50 + (Channel * 16), gEeprom.VfoInfo[VFO].Name + 0, 8);
|
EEPROM_ReadBuffer(0x0F50 + (channel * 16), pVfo->Name + 0, 8);
|
||||||
EEPROM_ReadBuffer(0x0F58 + (Channel * 16), gEeprom.VfoInfo[VFO].Name + 8, 2);
|
EEPROM_ReadBuffer(0x0F58 + (channel * 16), pVfo->Name + 8, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gEeprom.VfoInfo[VFO].FrequencyReverse)
|
if (!pVfo->FrequencyReverse)
|
||||||
{
|
{
|
||||||
gEeprom.VfoInfo[VFO].pRX = &gEeprom.VfoInfo[VFO].freq_config_RX;
|
pVfo->pRX = &pVfo->freq_config_RX;
|
||||||
gEeprom.VfoInfo[VFO].pTX = &gEeprom.VfoInfo[VFO].freq_config_TX;
|
pVfo->pTX = &pVfo->freq_config_TX;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gEeprom.VfoInfo[VFO].pRX = &gEeprom.VfoInfo[VFO].freq_config_TX;
|
pVfo->pRX = &pVfo->freq_config_TX;
|
||||||
gEeprom.VfoInfo[VFO].pTX = &gEeprom.VfoInfo[VFO].freq_config_RX;
|
pVfo->pTX = &pVfo->freq_config_RX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gSetting_350EN)
|
if (!gSetting_350EN)
|
||||||
{
|
{
|
||||||
FREQ_Config_t *pConfig = gEeprom.VfoInfo[VFO].pRX;
|
FREQ_Config_t *pConfig = pVfo->pRX;
|
||||||
if (pConfig->Frequency >= 35000000 && pConfig->Frequency < 40000000)
|
if (pConfig->Frequency >= 35000000 && pConfig->Frequency < 40000000)
|
||||||
pConfig->Frequency = 43300000;
|
pConfig->Frequency = 43300000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gEeprom.VfoInfo[VFO].Modulation != MODULATION_FM)
|
if (pVfo->Modulation != MODULATION_FM)
|
||||||
{ // freq/chan is in AM mode
|
{ // freq/chan is in AM mode
|
||||||
gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = 0;
|
pVfo->SCRAMBLING_TYPE = 0;
|
||||||
// gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; // no reason to disable DTMF decoding, aircraft use it on SSB
|
// pVfo->DTMF_DECODING_ENABLE = false; // no reason to disable DTMF decoding, aircraft use it on SSB
|
||||||
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = CODE_TYPE_OFF;
|
pVfo->freq_config_RX.CodeType = CODE_TYPE_OFF;
|
||||||
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF;
|
pVfo->freq_config_TX.CodeType = CODE_TYPE_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
gEeprom.VfoInfo[VFO].Compander = (Attributes & MR_CH_COMPAND) >> 4;
|
pVfo->Compander = att.compander;
|
||||||
|
|
||||||
RADIO_ConfigureSquelchAndOutputPower(pRadio);
|
RADIO_ConfigureSquelchAndOutputPower(pVfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
|
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
|
||||||
|
7
radio.h
7
radio.h
@@ -23,13 +23,6 @@
|
|||||||
#include "dcs.h"
|
#include "dcs.h"
|
||||||
#include "frequencies.h"
|
#include "frequencies.h"
|
||||||
|
|
||||||
enum {
|
|
||||||
MR_CH_BAND_MASK = 0x0F << 0,
|
|
||||||
MR_CH_COMPAND = 3u << 4, // new
|
|
||||||
MR_CH_SCANLIST2 = 1u << 6,
|
|
||||||
MR_CH_SCANLIST1 = 1u << 7
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
RADIO_CHANNEL_UP = 0x01u,
|
RADIO_CHANNEL_UP = 0x01u,
|
||||||
RADIO_CHANNEL_DOWN = 0xFFu,
|
RADIO_CHANNEL_DOWN = 0xFFu,
|
||||||
|
68
settings.c
68
settings.c
@@ -263,55 +263,45 @@ void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration)
|
|||||||
EEPROM_WriteBuffer(0x1F48, buf);
|
EEPROM_WriteBuffer(0x1F48, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
|
void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (!IS_NOAA_CHANNEL(Channel))
|
if (!IS_NOAA_CHANNEL(channel))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint8_t State[8];
|
uint8_t state[8];
|
||||||
uint8_t Attributes = 0xFF; // default attributes
|
ChannelAttributes_t att = {
|
||||||
uint16_t Offset = 0x0D60 + (Channel & ~7u);
|
.band = 0xf,
|
||||||
|
.compander = 0,
|
||||||
|
.scanlist1 = 0,
|
||||||
|
.scanlist2 = 0,
|
||||||
|
}; // default attributes
|
||||||
|
|
||||||
Attributes &= (uint8_t)(~MR_CH_COMPAND); // default to '0' = compander disabled
|
uint16_t offset = 0x0D60 + (channel & ~7u);
|
||||||
|
EEPROM_ReadBuffer(offset, state, sizeof(state));
|
||||||
|
|
||||||
EEPROM_ReadBuffer(Offset, State, sizeof(State));
|
if (keep) {
|
||||||
|
att.band = pVFO->Band;
|
||||||
if (keep)
|
att.scanlist1 = pVFO->SCANLIST1_PARTICIPATION;
|
||||||
{
|
att.scanlist2 = pVFO->SCANLIST2_PARTICIPATION;
|
||||||
Attributes = (pVFO->SCANLIST1_PARTICIPATION << 7) | (pVFO->SCANLIST2_PARTICIPATION << 6) | (pVFO->Compander << 4) | (pVFO->Band << 0);
|
att.compander = pVFO->Compander;
|
||||||
if (State[Channel & 7u] == Attributes)
|
if (state[channel & 7u] == att.__val)
|
||||||
return; // no change in the attributes
|
return; // no change in the attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
State[Channel & 7u] = Attributes;
|
state[channel & 7u] = att.__val;
|
||||||
|
EEPROM_WriteBuffer(offset, state);
|
||||||
|
|
||||||
EEPROM_WriteBuffer(Offset, State);
|
gMR_ChannelAttributes[channel] = att;
|
||||||
|
|
||||||
gMR_ChannelAttributes[Channel] = Attributes;
|
if (IS_MR_CHANNEL(channel)) { // it's a memory channel
|
||||||
|
const uint16_t OffsetMR = channel * 16;
|
||||||
// #ifndef ENABLE_KEEP_MEM_NAME
|
if (!keep) {
|
||||||
if (IS_MR_CHANNEL(Channel))
|
// clear/reset the channel name
|
||||||
{ // it's a memory channel
|
memset(&state, 0x00, sizeof(state));
|
||||||
|
EEPROM_WriteBuffer(0x0F50 + OffsetMR, state);
|
||||||
const uint16_t OffsetMR = Channel * 16;
|
EEPROM_WriteBuffer(0x0F58 + OffsetMR, state);
|
||||||
if (!keep)
|
|
||||||
{ // clear/reset the channel name
|
|
||||||
//memset(&State, 0xFF, sizeof(State));
|
|
||||||
memset(&State, 0x00, sizeof(State)); // follow the QS way
|
|
||||||
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
|
|
||||||
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
|
|
||||||
}
|
}
|
||||||
// else
|
|
||||||
// { // update the channel name
|
|
||||||
// memmove(State, pVFO->Name + 0, 8);
|
|
||||||
// EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
|
|
||||||
// //memset(State, 0xFF, sizeof(State));
|
|
||||||
// memset(State, 0x00, sizeof(State)); // follow the QS way
|
|
||||||
// memmove(State, pVFO->Name + 8, 2);
|
|
||||||
// EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
// #endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -127,9 +127,9 @@ enum CHANNEL_DisplayMode_t {
|
|||||||
typedef enum CHANNEL_DisplayMode_t CHANNEL_DisplayMode_t;
|
typedef enum CHANNEL_DisplayMode_t CHANNEL_DisplayMode_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t ScreenChannel[2];
|
uint8_t ScreenChannel[2]; // current channels set in the radio (memory or frequency channels)
|
||||||
uint8_t FreqChannel[2];
|
uint8_t FreqChannel[2]; // last frequency channels used
|
||||||
uint8_t MrChannel[2];
|
uint8_t MrChannel[2]; // last memory channels used
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
uint8_t NoaaChannel[2];
|
uint8_t NoaaChannel[2];
|
||||||
#endif
|
#endif
|
||||||
@@ -254,6 +254,6 @@ void SETTINGS_SaveVfoIndices(void);
|
|||||||
void SETTINGS_SaveSettings(void);
|
void SETTINGS_SaveSettings(void);
|
||||||
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode);
|
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode);
|
||||||
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration);
|
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration);
|
||||||
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep);
|
void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
ui/main.c
12
ui/main.c
@@ -457,15 +457,15 @@ void UI_DisplayMain(void)
|
|||||||
{ // it's a channel
|
{ // it's a channel
|
||||||
|
|
||||||
// show the scan list assigment symbols
|
// show the scan list assigment symbols
|
||||||
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
||||||
if (attributes & MR_CH_SCANLIST1)
|
if (att.scanlist1)
|
||||||
memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
|
memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
|
||||||
if (attributes & MR_CH_SCANLIST2)
|
if (att.scanlist2)
|
||||||
memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
|
memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
|
||||||
|
|
||||||
// compander symbol
|
// compander symbol
|
||||||
#ifndef ENABLE_BIG_FREQ
|
#ifndef ENABLE_BIG_FREQ
|
||||||
if ((attributes & MR_CH_COMPAND) > 0)
|
if (att.compander)
|
||||||
memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
|
memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
|
||||||
#else
|
#else
|
||||||
// TODO: // find somewhere else to put the symbol
|
// TODO: // find somewhere else to put the symbol
|
||||||
@@ -543,8 +543,8 @@ void UI_DisplayMain(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// show the channel symbols
|
// show the channel symbols
|
||||||
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
||||||
if ((attributes & MR_CH_COMPAND) > 0)
|
if (att.compander)
|
||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand));
|
memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand));
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user