0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

Ignore all long-press/function keys whilst in menu

This commit is contained in:
OneOfEleven 2023-10-05 09:17:38 +01:00
parent e042b21e65
commit 609df5f279
14 changed files with 132 additions and 99 deletions

View File

@ -13,7 +13,7 @@ ENABLE_NOAA := 0
ENABLE_VOICE := 0 ENABLE_VOICE := 0
ENABLE_VOX := 0 ENABLE_VOX := 0
ENABLE_ALARM := 0 ENABLE_ALARM := 0
ENABLE_TX1750 := 1 ENABLE_TX1750 := 0
ENABLE_BIG_FREQ := 0 ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1 ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1 ENABLE_KEEP_MEM_NAME := 1
@ -31,7 +31,7 @@ ENABLE_AM_FIX_SHOW_DATA := 1
ENABLE_SQUELCH_MORE_SENSITIVE := 1 ENABLE_SQUELCH_MORE_SENSITIVE := 1
ENABLE_FASTER_CHANNEL_SCAN := 0 ENABLE_FASTER_CHANNEL_SCAN := 0
ENABLE_RSSI_BAR := 1 ENABLE_RSSI_BAR := 1
ENABLE_AUDIO_BAR := 1 ENABLE_AUDIO_BAR := 0
ENABLE_COPY_CHAN_TO_VFO := 1 ENABLE_COPY_CHAN_TO_VFO := 1
#ENABLE_SINGLE_VFO_CHAN := 1 #ENABLE_SINGLE_VFO_CHAN := 1
#ENABLE_BAND_SCOPE := 1 #ENABLE_BAND_SCOPE := 1

View File

@ -99,10 +99,10 @@ To compile directly in windows without the need of a linux virtual machine:
1. Download and install "gcc-arm-none-eabi-10.3-2021.10-win32.exe" from https://developer.arm.com/downloads/-/gnu-rm 1. Download and install "gcc-arm-none-eabi-10.3-2021.10-win32.exe" from https://developer.arm.com/downloads/-/gnu-rm
2. Download and install "gnu_make-3.81.exe" from https://gnuwin32.sourceforge.net/packages/make.htm 2. Download and install "gnu_make-3.81.exe" from https://gnuwin32.sourceforge.net/packages/make.htm
3. You may (or not) need to manualy add gcc path to you OS environment PATH. 3. You may need to (I didn't) manualy add gcc path to your OS environment PATH.
ie add C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin ie add C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin
4. You may (or not) need to reboot your PC after installing the above 4. You may need to reboot your PC after installing the above
``` ```
Then you can run 'win_make.bat' from the directory you saved this source code too. Then you can run 'win_make.bat' from the directory you saved this source code too.

View File

@ -677,17 +677,17 @@ static void MR_NextChannel(void)
// this bit doesn't yet work if the other VFO is a frequency // this bit doesn't yet work if the other VFO is a frequency
case SCAN_NEXT_CHAN_DUAL_WATCH: case SCAN_NEXT_CHAN_DUAL_WATCH:
// dual watch is enabled - include the other VFO in the scan // dual watch is enabled - include the other VFO in the scan
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) // if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{ // {
chan = (gEeprom.RX_VFO + 1) & 1u; // chan = (gEeprom.RX_VFO + 1) & 1u;
chan = gEeprom.ScreenChannel[chan]; // chan = gEeprom.ScreenChannel[chan];
if (IS_MR_CHANNEL(chan)) // if (IS_MR_CHANNEL(chan))
{ // {
gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH; // gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
gNextMrChannel = chan; // gNextMrChannel = chan;
break; // break;
} // }
} // }
default: default:
case SCAN_NEXT_CHAN_MR: case SCAN_NEXT_CHAN_MR:
@ -2163,8 +2163,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
if (!bKeyHeld) if (!bKeyHeld)
{ { // keypad is locked, tell the user
// keypad is locked, tell the user
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
gKeypadLocked = 4; // 2 seconds gKeypadLocked = 4; // 2 seconds
gUpdateDisplay = true; gUpdateDisplay = true;

View File

@ -52,13 +52,23 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
if (!bKeyPressed) if (!bKeyPressed)
return; return;
if (gScreenToDisplay != DISPLAY_MENU &&
gScreenToDisplay != DISPLAY_FM &&
#ifdef ENABLE_FMRADIO
!gFmRadioMode &&
#endif
gCurrentFunction != FUNCTION_TRANSMIT)
{ // toggle the keyboad lock
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK; gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
#endif #endif
gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK; gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK;
gRequestSaveSettings = true; gRequestSaveSettings = true;
} }
}
else else
{ {
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO

View File

@ -40,6 +40,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
uint8_t Band; uint8_t Band;
uint8_t Vfo = gEeprom.TX_VFO; uint8_t Vfo = gEeprom.TX_VFO;
if (gScreenToDisplay == DISPLAY_MENU)
return;
switch (Key) switch (Key)
{ {
case KEY_0: case KEY_0:
@ -560,21 +563,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gCssScanMode == CSS_SCAN_MODE_OFF) gCssScanMode == CSS_SCAN_MODE_OFF)
{ // copy channel to VFO { // copy channel to VFO
//const unsigned int vfo = (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO; const unsigned int vfo = get_rx_VFO();
unsigned int vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
vfo = 1;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
vfo = 0;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
vfo = 0;
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
vfo = (vfo + 1) & 1u;
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo])) if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
{ // swap to the VFO { // swap to the VFO

View File

@ -509,7 +509,7 @@ void BOARD_Init(void)
BOARD_PORTCON_Init(); BOARD_PORTCON_Init();
BOARD_GPIO_Init(); BOARD_GPIO_Init();
BOARD_ADC_Init(); BOARD_ADC_Init();
ST7565_Init(); ST7565_Init(true);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
BK1080_Init(0, false); BK1080_Init(0, false);
#endif #endif

View File

@ -82,10 +82,10 @@ void ST7565_BlitFullScreen(void)
} }
#if 0 #if 0
// whats the delay for I wonder ? .. it slows down scanning :( // whats the delay for I wonder, it holds things up :(
SYSTEM_DelayMs(20); SYSTEM_DelayMs(20);
#else #else
SYSTEM_DelayMs(1); // SYSTEM_DelayMs(1);
#endif #endif
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
@ -119,6 +119,9 @@ void ST7565_FillScreen(uint8_t Value)
{ {
unsigned int i; unsigned int i;
// reset some of the displays settings to try and overcome the radios hardware problem - RF corrupting the display
ST7565_Init(false);
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
@ -135,8 +138,10 @@ void ST7565_FillScreen(uint8_t Value)
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
} }
void ST7565_Init(void) void ST7565_Init(const bool full)
{ {
if (full)
{
SPI0_Init(); SPI0_Init();
ST7565_Configure_GPIO_B11(); ST7565_Configure_GPIO_B11();
@ -146,6 +151,7 @@ void ST7565_Init(void)
ST7565_WriteByte(0xE2); // internal reset ST7565_WriteByte(0xE2); // internal reset
SYSTEM_DelayMs(120); SYSTEM_DelayMs(120);
}
ST7565_WriteByte(0xA2); // bias 9 ST7565_WriteByte(0xA2); // bias 9
ST7565_WriteByte(0xC0); // com normal ST7565_WriteByte(0xC0); // com normal
@ -157,6 +163,9 @@ void ST7565_Init(void)
ST7565_WriteByte(0xA4); // all points normal ST7565_WriteByte(0xA4); // all points normal
ST7565_WriteByte(0x24); // ST7565_WriteByte(0x24); //
ST7565_WriteByte(0x81); // volume first ? ST7565_WriteByte(0x81); // volume first ?
if (full)
{
ST7565_WriteByte(0x1f); // contrast ? ST7565_WriteByte(0x1f); // contrast ?
ST7565_WriteByte(0x2B); // power control ? ST7565_WriteByte(0x2B); // power control ?
@ -175,11 +184,13 @@ void ST7565_Init(void)
ST7565_WriteByte(0x40); // start line ? ST7565_WriteByte(0x40); // start line ?
ST7565_WriteByte(0xAF); // display on ? ST7565_WriteByte(0xAF); // display on ?
}
SPI_WaitForUndocumentedTxFifoStatusBit(); SPI_WaitForUndocumentedTxFifoStatusBit();
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
if (full)
ST7565_FillScreen(0x00); ST7565_FillScreen(0x00);
} }

View File

@ -30,7 +30,7 @@ void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const u
void ST7565_BlitFullScreen(void); void ST7565_BlitFullScreen(void);
void ST7565_BlitStatusLine(void); void ST7565_BlitStatusLine(void);
void ST7565_FillScreen(uint8_t Value); void ST7565_FillScreen(uint8_t Value);
void ST7565_Init(void); void ST7565_Init(const bool full);
void ST7565_Configure_GPIO_B11(void); void ST7565_Configure_GPIO_B11(void);
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line); void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
void ST7565_WriteByte(uint8_t Value); void ST7565_WriteByte(uint8_t Value);

Binary file not shown.

Binary file not shown.

35
misc.c
View File

@ -17,6 +17,7 @@
#include <string.h> #include <string.h>
#include "misc.h" #include "misc.h"
#include "settings.h"
const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds
const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds
@ -259,7 +260,39 @@ int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO
uint8_t gIsLocked = 0xFF; uint8_t gIsLocked = 0xFF;
// -------- unsigned int get_rx_VFO(void)
{
unsigned int rx_vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
rx_vfo = 0;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
rx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
rx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
rx_vfo = 0;
return rx_vfo;
}
unsigned int get_tx_VFO(void)
{
unsigned int tx_vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
tx_vfo = 1;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
tx_vfo = 0;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
tx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
tx_vfo = 0;
return tx_vfo;
}
void NUMBER_Get(char *pDigits, uint32_t *pInteger) void NUMBER_Get(char *pDigits, uint32_t *pInteger)
{ {

3
misc.h
View File

@ -322,6 +322,9 @@ extern int16_t gCurrentRSSI[2]; // now one per VFO
extern uint8_t gIsLocked; extern uint8_t gIsLocked;
extern volatile uint8_t boot_counter_10ms; extern volatile uint8_t boot_counter_10ms;
unsigned int get_tx_VFO(void);
unsigned int get_rx_VFO(void);
void NUMBER_Get(char *pDigits, uint32_t *pInteger); void NUMBER_Get(char *pDigits, uint32_t *pInteger);
void NUMBER_ToDigits(uint32_t Value, char *pDigits); void NUMBER_ToDigits(uint32_t Value, char *pDigits);
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit); int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);

33
radio.c
View File

@ -522,22 +522,8 @@ static void RADIO_SelectCurrentVfo(void)
void RADIO_SelectVfos(void) void RADIO_SelectVfos(void)
{ {
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) gEeprom.TX_VFO = get_tx_VFO();
gEeprom.TX_VFO = 1; gEeprom.RX_VFO = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.TX_VFO : (gEeprom.TX_VFO + 1) & 1u;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
gEeprom.TX_VFO = 0;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
gEeprom.TX_VFO = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
gEeprom.TX_VFO = 0;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF)
gEeprom.RX_VFO = gEeprom.TX_VFO;
else
gEeprom.RX_VFO = (gEeprom.TX_VFO == 0) ? 1 : 0;
gTxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO]; gTxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO];
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO];
@ -877,10 +863,9 @@ void RADIO_SetVfoState(VfoState_t State)
VfoState[1] = VFO_STATE_TX_DISABLE; VfoState[1] = VFO_STATE_TX_DISABLE;
} }
else else
{ { // 1of11
unsigned int chan = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) ? (gEeprom.RX_VFO + 1) & 1 : gEeprom.RX_VFO; // 1of11 const unsigned int vfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
chan = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.TX_VFO : chan; VfoState[vfo] = State;
VfoState[chan] = State;
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -901,11 +886,11 @@ void RADIO_PrepareTX(void)
gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms; gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms;
gScheduleDualWatch = false; gScheduleDualWatch = false;
if (!gRxVfoIsActive) if (gRxVfoIsActive)
{ // use the TX vfo { // use the TX vfo
gEeprom.RX_VFO = gEeprom.TX_VFO; gEeprom.RX_VFO = gEeprom.TX_VFO;
gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO]; gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO];
gRxVfoIsActive = true; // gRxVfoIsActive = true;
} }
// let the user see that DW is not active // let the user see that DW is not active
@ -939,7 +924,6 @@ void RADIO_PrepareTX(void)
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }
else else
//if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0 || gCurrentVfo->CHANNEL_SAVE <= FREQ_CHANNEL_LAST)
if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0) if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0)
{ // TX frequency is allowed { // TX frequency is allowed
if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE) if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE)
@ -958,10 +942,13 @@ void RADIO_PrepareTX(void)
if (State != VFO_STATE_NORMAL) if (State != VFO_STATE_NORMAL)
{ // TX not allowed { // TX not allowed
RADIO_SetVfoState(State); RADIO_SetVfoState(State);
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
gAlarmState = ALARM_STATE_OFF; gAlarmState = ALARM_STATE_OFF;
#endif #endif
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
return; return;
} }

View File

@ -173,6 +173,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
return; // display is in use return; // display is in use
if (gCurrentFunction == FUNCTION_TRANSMIT || if (gCurrentFunction == FUNCTION_TRANSMIT ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE) gDTMF_CallState != DTMF_CALL_STATE_NONE)