0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

Added Copy-channel-to-VFO - long press 'M' key (menu key)

This commit is contained in:
OneOfEleven
2023-10-03 23:33:01 +01:00
parent 8fb9825ad8
commit 4d808de2ac
10 changed files with 235 additions and 224 deletions

View File

@ -519,6 +519,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
gRxVfo->pRX->Frequency = NoaaFrequencyTable[gNoaaChannel];
gRxVfo->pTX->Frequency = NoaaFrequencyTable[gNoaaChannel];
gEeprom.ScreenChannel[chan] = gRxVfo->CHANNEL_SAVE;
gNOAA_Countdown_10ms = 500; // 5 sec
gScheduleNOAA = false;
}
@ -630,7 +631,7 @@ static void FREQ_NextChannel(void)
RADIO_SetupRegisters(true);
// ScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms;
ScanPauseDelayIn_10ms = 10; // 100ms
ScanPauseDelayIn_10ms = 10; // 100ms .. it don't like any faster :(
bScanKeepFrequency = false;
gUpdateDisplay = true;
@ -671,9 +672,7 @@ static void MR_NextChannel(void)
// if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
// chan = (gEeprom.RX_CHANNEL + 1) & 1u;
// chan = gEeprom.MrChannel[chan];
// chan = gEeprom.ScreenChannel[chan];
// chan = gEeprom.VfoInfo[chan].CHANNEL_SAVE;
// chan = 14;
// if (RADIO_CheckValidChannel(chan, false, 0))
// {
@ -1214,7 +1213,9 @@ void APP_Update(void)
if (gEeprom.VOX_SWITCH)
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF &&
gScanState == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF)
{ // dual watch mode, toggle between the two VFO's
DUALWATCH_Alternate();

View File

@ -25,6 +25,7 @@
#include "app/main.h"
#include "app/scanner.h"
#include "audio.h"
#include "board.h"
#include "driver/bk4819.h"
#include "dtmf.h"
#include "frequencies.h"
@ -98,11 +99,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_A;
else
gEeprom.TX_CHANNEL = (Vfo == 0);
gEeprom.TX_CHANNEL = (Vfo + 1) & 1u;
gRequestSaveSettings = 1;
gFlagReconfigureVfos = true;
gRequestDisplayScreen = DISPLAY_MAIN;
if (beep)
@ -120,7 +121,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
uint8_t Channel;
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
{ // swap to frequency mode
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_CHANNEL];
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
@ -132,7 +133,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
Channel = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_CHANNEL], 1, false, 0);
if (Channel != 0xFF)
{
{ // swap to channel mode
gEeprom.ScreenChannel[Vfo] = Channel;
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
@ -298,7 +299,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // user is entering channel number
uint16_t Channel;
if (gInputBoxIndex != 3)
@ -337,7 +338,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
// #endif
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // user is entering frequency
uint32_t Frequency;
if (gInputBoxIndex < 6)
@ -369,7 +370,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper;
}
{
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
@ -382,35 +383,35 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gTxVfo->Band = band;
gEeprom.ScreenChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
gEeprom.FreqChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
SETTINGS_SaveVfoIndices();
RADIO_ConfigureChannel(Vfo, VFO_CONFIGURE_RELOAD);
}
// Frequency += 75; // is this meant to be rounding ?
Frequency += gTxVfo->StepFrequency / 2; // no idea, but this is
Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, frequencyBandTable[gTxVfo->Band].lower);
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
{ // clamp the frequency to the limit
const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2;
Frequency = (Frequency < center) ? BX4819_band1.upper - gTxVfo->StepFrequency : BX4819_band2.lower;
}
gTxVfo->freq_config_RX.Frequency = Frequency;
gRequestSaveChannel = 1;
return;
}
}
#ifdef ENABLE_NOAA
else
if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // user is entering NOAA channel
uint8_t Channel;
if (gInputBoxIndex != 2)
@ -523,7 +524,8 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
{ // menu key held down (long press)
if (bKeyPressed)
{
{ // long press MENU key
if (gScreenToDisplay == DISPLAY_MAIN)
{
if (gInputBoxIndex > 0)
@ -535,34 +537,28 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gWasFKeyPressed = false;
gUpdateStatus = true;
// TODO: long press M-key
#ifdef ENABLE_COPY_CHAN_TO_VFO
if (gEeprom.VFO_OPEN &&
gEeprom.DUAL_WATCH == DUAL_WATCH_OFF &&
gScanState == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF)
{ // copy channel to VFO
int channel = -1;
int vfo = -1;
//int selected = -1;
if (IS_FREQ_CHANNEL(gRxVfo->CHANNEL_SAVE))
{ // VFO mode
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // other VFO is in channel mode
channel = gTxVfo->CHANNEL_SAVE;
vfo = gRxVfo->CHANNEL_SAVE;
}
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[0]) &&
IS_MR_CHANNEL(gEeprom.ScreenChannel[1]))
{
channel = gEeprom.ScreenChannel[1];
vfo = 0;
}
else
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // VFO mode
if (IS_MR_CHANNEL(gRxVfo->CHANNEL_SAVE))
{ // other VFO is in channel mode
channel = gRxVfo->CHANNEL_SAVE;
vfo = gTxVfo->CHANNEL_SAVE;
}
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[1]) &&
IS_MR_CHANNEL(gEeprom.ScreenChannel[0]))
{
channel = gEeprom.ScreenChannel[0];
vfo = 1;
}
if (channel >= 0 && vfo >= 0)
@ -570,15 +566,29 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gEeprom.MrChannel[vfo] = channel;
gEeprom.ScreenChannel[vfo] = channel;
RADIO_ConfigureChannel(vfo, VFO_CONFIGURE_RELOAD);
// TODO: finish this
channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;
gEeprom.MrChannel[vfo] = channel;
gEeprom.ScreenChannel[vfo] = channel;
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel;
//gEeprom.RX_CHANNEL = () & 1; // swap to the VFO
// swap to the VFO
gEeprom.TX_CHANNEL = vfo;
gEeprom.RX_CHANNEL = vfo;
RADIO_SelectVfos();
RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
// gRequestSaveVFO = true;
// gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
// gRequestDisplayScreen = DISPLAY_MAIN;
RADIO_SetupRegisters(true);
// SETTINGS_SaveChannel(gRxVfo->CHANNEL_SAVE, gEeprom.RX_CHANNEL, gRxVfo, 1);
gUpdateStatus = true;
gUpdateDisplay = true;
}
}
#endif
@ -595,7 +605,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gInputBoxIndex = 0;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (bFlag)
{
gFlagRefreshSetting = true;
@ -646,7 +656,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
gDTMF_InputMode = true;
memmove(gDTMF_InputBox, gDTMF_String, sizeof(gDTMF_InputBox));
gDTMF_InputIndex = 0;
gRequestDisplayScreen = DISPLAY_MAIN;
return;
}
@ -741,7 +751,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
}
gTxVfo->freq_config_RX.Frequency = frequency;
gRequestSaveChannel = 1;
return;
}