mirror of
https://github.com/kamilsss655/uv-k5-firmware-custom
synced 2024-11-22 02:08:48 +00:00
Hold down keys 0-9 to bypass F-key
This commit is contained in:
parent
84087c3d13
commit
5c664164b2
13
Makefile
13
Makefile
@ -14,14 +14,15 @@ ENABLE_CHAN_NAME_FREQ := 1
|
||||
ENABLE_WIDE_RX := 1
|
||||
ENABLE_TX_WHEN_AM := 0
|
||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
|
||||
ENABLE_MAIN_KEY_HOLD := 1
|
||||
#ENABLE_SINGLE_VFO_CHAN := 1
|
||||
#ENABLE_BAND_SCOPE := 1
|
||||
|
||||
TARGET = firmware
|
||||
|
||||
BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
|
||||
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
|
||||
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
|
||||
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
|
||||
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
|
||||
|
||||
OBJS =
|
||||
# Startup files
|
||||
@ -129,7 +130,9 @@ ifeq ($(ENABLE_OVERLAY),1)
|
||||
ASFLAGS += -DENABLE_OVERLAY
|
||||
endif
|
||||
|
||||
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
||||
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
||||
#CFLAGS = -O2 -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD -fdata-sections -ffunction-sections
|
||||
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD -fdata-sections -ffunction-sections
|
||||
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
|
||||
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
|
||||
ifeq ($(ENABLE_AIRCOPY),1)
|
||||
@ -171,6 +174,9 @@ endif
|
||||
ifeq ($(ENABLE_CTCSS_TAIL_PHASE_SHIFT),1)
|
||||
CFLAGS += -DENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
endif
|
||||
ifeq ($(ENABLE_MAIN_KEY_HOLD),1)
|
||||
CFLAGS += -DENABLE_MAIN_KEY_HOLD
|
||||
endif
|
||||
ifeq ($(ENABLE_SINGLE_VFO_CHAN),1)
|
||||
CFLAGS += -DENABLE_SINGLE_VFO_CHAN
|
||||
endif
|
||||
@ -179,6 +185,7 @@ ifeq ($(ENABLE_BAND_SCOPE),1)
|
||||
endif
|
||||
|
||||
LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
||||
#LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld,--gc-sections
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
ASFLAGS += -g
|
||||
|
@ -24,6 +24,7 @@ You can edit those changes by (currently) editing the MakeFile, look for these l
|
||||
* ENABLE_WIDE_RX := 1 enable the RX in the full 18MHz to 1300MHz (though frontend is not tuned for full range)
|
||||
* ENABLE_TX_WHEN_AM := 0 allow TX when RX set to AM
|
||||
* ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 use CTCSS tail phase shift rather than QS's 55Hz tone method
|
||||
* ENABLE_MAIN_KEY_HOLD := 1 keys 0-9 can be held down to bypass having to press the F-key
|
||||
* #ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented
|
||||
* #ENABLE_BAND_SCOPE := 1 not yet implemented
|
||||
|
||||
|
49
app/app.c
49
app/app.c
@ -1031,8 +1031,7 @@ void APP_Update(void)
|
||||
// called every 10ms
|
||||
void APP_CheckKeys(void)
|
||||
{
|
||||
const uint16_t key_repeat_delay = 60; // 600ms
|
||||
KEY_Code_t Key;
|
||||
KEY_Code_t Key;
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY))
|
||||
@ -1088,30 +1087,32 @@ void APP_CheckKeys(void)
|
||||
if (++gPttDebounceCounter >= 3) // 30ms
|
||||
{ // start transmitting
|
||||
gPttDebounceCounter = 0;
|
||||
gPttIsPressed = true;
|
||||
gPttIsPressed = true;
|
||||
APP_ProcessKey(KEY_PTT, true, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
gPttDebounceCounter = 0;
|
||||
|
||||
// *****************
|
||||
|
||||
// scan the hardware keys
|
||||
Key = KEYBOARD_Poll();
|
||||
|
||||
if (gKeyReading0 != Key)
|
||||
{
|
||||
{ // new key pressed
|
||||
|
||||
if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID)
|
||||
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld);
|
||||
|
||||
gKeyReading0 = Key;
|
||||
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key
|
||||
|
||||
gKeyReading0 = Key;
|
||||
gDebounceCounter = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
gDebounceCounter++;
|
||||
if (++gDebounceCounter == key_debounce)
|
||||
{ // debounced new key pressed
|
||||
|
||||
if (gDebounceCounter == 2)
|
||||
{
|
||||
if (Key == KEY_INVALID)
|
||||
{
|
||||
if (gKeyReading1 != KEY_INVALID)
|
||||
@ -1127,23 +1128,36 @@ void APP_CheckKeys(void)
|
||||
}
|
||||
|
||||
gKeyBeingHeld = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
// key is being held pressed
|
||||
|
||||
if (gDebounceCounter == key_repeat_delay)
|
||||
{
|
||||
if (Key == KEY_STAR || Key == KEY_F || Key == KEY_SIDE2 || Key == KEY_SIDE1 || Key == KEY_UP || Key == KEY_DOWN)
|
||||
{ // initial delay after pressed
|
||||
if (Key == KEY_STAR ||
|
||||
Key == KEY_F ||
|
||||
Key == KEY_SIDE2 ||
|
||||
Key == KEY_SIDE1 ||
|
||||
Key == KEY_UP ||
|
||||
Key == KEY_DOWN
|
||||
#ifdef ENABLE_MAIN_KEY_HOLD
|
||||
|| Key <= KEY_9 // keys 0-9 can be held down to bypass pressing the F-Key
|
||||
#endif
|
||||
)
|
||||
{
|
||||
gKeyBeingHeld = true;
|
||||
APP_ProcessKey(Key, true, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
if (gDebounceCounter > key_repeat_delay)
|
||||
{
|
||||
{ // key repeat
|
||||
if (Key == KEY_UP || Key == KEY_DOWN)
|
||||
{
|
||||
gKeyBeingHeld = true;
|
||||
if ((gDebounceCounter & 15) == 0)
|
||||
if ((gDebounceCounter % key_repeat) == 0)
|
||||
APP_ProcessKey(Key, true, true);
|
||||
}
|
||||
|
||||
@ -1151,6 +1165,7 @@ void APP_CheckKeys(void)
|
||||
return;
|
||||
|
||||
gDebounceCounter = key_repeat_delay;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1481,7 +1496,7 @@ void APP_TimeSlice500ms(void)
|
||||
{
|
||||
if (--gVoltageMenuCountdown == 0)
|
||||
{
|
||||
if (gInputBoxIndex || gDTMF_InputMode || gScreenToDisplay == DISPLAY_MENU)
|
||||
if (gInputBoxIndex > 0 || gDTMF_InputMode || gScreenToDisplay == DISPLAY_MENU)
|
||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
|
||||
|
||||
if (gScreenToDisplay == DISPLAY_SCANNER)
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (gInputBoxIndex)
|
||||
if (gInputBoxIndex > 0)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
|
303
app/main.c
303
app/main.c
@ -37,147 +37,11 @@
|
||||
// #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
//#endif
|
||||
|
||||
static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
static void processFKeyFunction(const KEY_Code_t Key)
|
||||
{
|
||||
uint8_t Band;
|
||||
uint8_t Vfo = gEeprom.TX_CHANNEL;
|
||||
|
||||
if (bKeyHeld)
|
||||
return;
|
||||
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
if (!gWasFKeyPressed)
|
||||
{
|
||||
INPUTBOX_Append(Key);
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
|
||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
{
|
||||
uint16_t Channel;
|
||||
|
||||
if (gInputBoxIndex != 3)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
||||
if (!RADIO_CheckValidChannel(Channel, false, 0))
|
||||
{
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gEeprom.MrChannel[Vfo] = (uint8_t)Channel;
|
||||
gEeprom.ScreenChannel[Vfo] = (uint8_t)Channel;
|
||||
gRequestSaveVFO = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
#endif
|
||||
{
|
||||
uint32_t Frequency;
|
||||
|
||||
if (gInputBoxIndex < 6)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
NUMBER_Get(gInputBox, &Frequency);
|
||||
|
||||
if (gSetting_350EN || Frequency < 35000000 || Frequency >= 40000000)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i])
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
|
||||
if (gTxVfo->Band != i)
|
||||
{
|
||||
gTxVfo->Band = i;
|
||||
gEeprom.ScreenChannel[Vfo] = i + FREQ_CHANNEL_FIRST;
|
||||
gEeprom.FreqChannel[Vfo] = i + FREQ_CHANNEL_FIRST;
|
||||
|
||||
SETTINGS_SaveVfoIndices();
|
||||
|
||||
RADIO_ConfigureChannel(Vfo, 2);
|
||||
}
|
||||
|
||||
Frequency += 75;
|
||||
|
||||
gTxVfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, LowerLimitFrequencyBandTable[gTxVfo->Band]);
|
||||
|
||||
gRequestSaveChannel = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_NOAA
|
||||
else
|
||||
{
|
||||
uint8_t Channel;
|
||||
|
||||
if (gInputBoxIndex != 2)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
Channel = (gInputBox[0] * 10) + gInputBox[1];
|
||||
if (Channel >= 1 && Channel <= 10)
|
||||
{
|
||||
Channel += NOAA_CHANNEL_FIRST;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gEeprom.NoaaChannel[Vfo] = Channel;
|
||||
gEeprom.ScreenChannel[Vfo] = Channel;
|
||||
gRequestSaveVFO = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
gWasFKeyPressed = false;
|
||||
gUpdateStatus = true;
|
||||
|
||||
switch (Key)
|
||||
{
|
||||
case KEY_0:
|
||||
@ -347,6 +211,171 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
}
|
||||
}
|
||||
|
||||
static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (bKeyHeld)
|
||||
{ // key held down
|
||||
|
||||
#ifdef ENABLE_MAIN_KEY_HOLD
|
||||
if (bKeyPressed)
|
||||
{
|
||||
if (gScreenToDisplay == DISPLAY_MAIN)
|
||||
{ // we're going to go straight to the function key function
|
||||
// without the F-key being first pressed
|
||||
if (gInputBoxIndex > 0)
|
||||
{ // delete last char inputted
|
||||
gInputBoxIndex = 0;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
}
|
||||
gWasFKeyPressed = false;
|
||||
gUpdateStatus = true;
|
||||
processFKeyFunction(Key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
if (!gWasFKeyPressed)
|
||||
{
|
||||
uint8_t Vfo = gEeprom.TX_CHANNEL;
|
||||
|
||||
INPUTBOX_Append(Key);
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
|
||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
{
|
||||
uint16_t Channel;
|
||||
|
||||
if (gInputBoxIndex != 3)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
||||
if (!RADIO_CheckValidChannel(Channel, false, 0))
|
||||
{
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gEeprom.MrChannel[Vfo] = (uint8_t)Channel;
|
||||
gEeprom.ScreenChannel[Vfo] = (uint8_t)Channel;
|
||||
gRequestSaveVFO = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
#endif
|
||||
{
|
||||
uint32_t Frequency;
|
||||
|
||||
if (gInputBoxIndex < 6)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
NUMBER_Get(gInputBox, &Frequency);
|
||||
|
||||
if (gSetting_350EN || Frequency < 35000000 || Frequency >= 40000000)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i])
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
|
||||
if (gTxVfo->Band != i)
|
||||
{
|
||||
gTxVfo->Band = i;
|
||||
gEeprom.ScreenChannel[Vfo] = i + FREQ_CHANNEL_FIRST;
|
||||
gEeprom.FreqChannel[Vfo] = i + FREQ_CHANNEL_FIRST;
|
||||
|
||||
SETTINGS_SaveVfoIndices();
|
||||
|
||||
RADIO_ConfigureChannel(Vfo, 2);
|
||||
}
|
||||
|
||||
Frequency += 75;
|
||||
|
||||
gTxVfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, LowerLimitFrequencyBandTable[gTxVfo->Band]);
|
||||
|
||||
gRequestSaveChannel = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_NOAA
|
||||
else
|
||||
{
|
||||
uint8_t Channel;
|
||||
|
||||
if (gInputBoxIndex != 2)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
Channel = (gInputBox[0] * 10) + gInputBox[1];
|
||||
if (Channel >= 1 && Channel <= 10)
|
||||
{
|
||||
Channel += NOAA_CHANNEL_FIRST;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gEeprom.NoaaChannel[Vfo] = Channel;
|
||||
gEeprom.ScreenChannel[Vfo] = Channel;
|
||||
gRequestSaveVFO = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
gWasFKeyPressed = false;
|
||||
gUpdateStatus = true;
|
||||
|
||||
processFKeyFunction(Key);
|
||||
}
|
||||
|
||||
static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
|
@ -977,9 +977,9 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
gInputBoxIndex = 0;
|
||||
NUMBER_Get(gInputBox, &Frequency);
|
||||
Frequency += 75;
|
||||
Frequency += 75;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
|
@ -102,7 +102,7 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (gInputBoxIndex)
|
||||
if (gInputBoxIndex > 0)
|
||||
{
|
||||
gInputBox[--gInputBoxIndex] = 10;
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
|
@ -22,8 +22,8 @@
|
||||
|
||||
KEY_Code_t gKeyReading0 = KEY_INVALID;
|
||||
KEY_Code_t gKeyReading1 = KEY_INVALID;
|
||||
uint16_t gDebounceCounter;
|
||||
bool gWasFKeyPressed;
|
||||
uint16_t gDebounceCounter;
|
||||
bool gWasFKeyPressed;
|
||||
|
||||
KEY_Code_t KEYBOARD_Poll(void)
|
||||
{
|
||||
@ -36,6 +36,7 @@ KEY_Code_t KEYBOARD_Poll(void)
|
||||
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
// *****************
|
||||
// Keys connected to gnd
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_0))
|
||||
@ -52,7 +53,9 @@ KEY_Code_t KEYBOARD_Poll(void)
|
||||
|
||||
// Original doesn't do PTT
|
||||
|
||||
// *****************
|
||||
// First row
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_4);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
@ -80,7 +83,9 @@ KEY_Code_t KEYBOARD_Poll(void)
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
// *****************
|
||||
// Second row
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_5);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
@ -111,7 +116,9 @@ KEY_Code_t KEYBOARD_Poll(void)
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
// *****************
|
||||
// Third row
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_4);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
@ -148,7 +155,9 @@ KEY_Code_t KEYBOARD_Poll(void)
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
// *****************
|
||||
// Fourth row
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_7);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
@ -179,6 +188,8 @@ KEY_Code_t KEYBOARD_Poll(void)
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
// *****************
|
||||
|
||||
Bye:
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_4);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_5);
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
11
misc.c
11
misc.c
@ -18,13 +18,16 @@
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
const uint8_t g_scan_delay = 21; // 210ms
|
||||
//const uint8_t g_scan_delay = 2; // 20ms
|
||||
const uint16_t key_repeat_delay = 40; // 400ms
|
||||
const uint16_t key_repeat = 8; // was 15 (150ms) .. MUST be less than 'key_repeat_delay'
|
||||
const uint16_t key_debounce = 2; // 20ms
|
||||
|
||||
const uint8_t g_scan_delay = 21; // 210ms
|
||||
|
||||
const uint8_t g_menu_timeout = 2 * 30; // 30 seconds
|
||||
|
||||
const uint16_t gMax_bat_v = 843; // 8.43V
|
||||
const uint16_t gMin_bat_v = 660; // 6.6V
|
||||
const uint16_t gMax_bat_v = 843; // 8.43V
|
||||
const uint16_t gMin_bat_v = 660; // 6.6V
|
||||
|
||||
const uint32_t gDefaultAesKey[4] = {0x4AA5CC60, 0x0312CC5F, 0xFFD2DABB, 0x6BBA7F92};
|
||||
|
||||
|
4
misc.h
4
misc.h
@ -74,6 +74,10 @@ enum CssScanMode_t
|
||||
|
||||
typedef enum CssScanMode_t CssScanMode_t;
|
||||
|
||||
extern const uint16_t key_repeat_delay;
|
||||
extern const uint16_t key_repeat;
|
||||
extern const uint16_t key_debounce;
|
||||
|
||||
extern const uint8_t g_scan_delay;
|
||||
|
||||
extern const uint8_t g_menu_timeout;
|
||||
|
@ -81,7 +81,7 @@ void UI_DisplayFM(void)
|
||||
UI_PrintString(String, 0, 127, 2, 10);
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex))
|
||||
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0))
|
||||
{
|
||||
UI_GenerateChannelString(String, gFM_ChannelPosition);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel)
|
||||
|
||||
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber)
|
||||
{
|
||||
if (gInputBoxIndex)
|
||||
if (gInputBoxIndex > 0)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < 3; i++)
|
||||
|
@ -15,18 +15,20 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ui/inputbox.h"
|
||||
|
||||
char gInputBox[8];
|
||||
char gInputBox[8];
|
||||
uint8_t gInputBoxIndex;
|
||||
|
||||
void INPUTBOX_Append(char Digit)
|
||||
{
|
||||
if (gInputBoxIndex == 0) {
|
||||
if (gInputBoxIndex == 0)
|
||||
memset(gInputBox, 10, sizeof(gInputBox));
|
||||
} else if (gInputBoxIndex >= sizeof(gInputBox)) {
|
||||
else
|
||||
if (gInputBoxIndex >= sizeof(gInputBox))
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBox[gInputBoxIndex++] = Digit;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern char gInputBox[8];
|
||||
extern char gInputBox[8];
|
||||
extern uint8_t gInputBoxIndex;
|
||||
|
||||
void INPUTBOX_Append(char Digit);
|
||||
|
10
ui/lock.c
10
ui/lock.c
@ -62,11 +62,12 @@ void UI_DisplayLock(void)
|
||||
// TODO: Original code doesn't do the below, but is needed for proper key debounce
|
||||
|
||||
gNextTimeslice = false;
|
||||
Key = KEYBOARD_Poll();
|
||||
|
||||
Key = KEYBOARD_Poll();
|
||||
|
||||
if (gKeyReading0 == Key)
|
||||
{
|
||||
if (++gDebounceCounter == 2)
|
||||
if (++gDebounceCounter == key_debounce)
|
||||
{
|
||||
if (Key == KEY_INVALID)
|
||||
{
|
||||
@ -89,7 +90,8 @@ void UI_DisplayLock(void)
|
||||
case KEY_8:
|
||||
case KEY_9:
|
||||
INPUTBOX_Append(Key - KEY_0);
|
||||
if (gInputBoxIndex < 6)
|
||||
|
||||
if (gInputBoxIndex < 6) // 6 frequency digits
|
||||
{
|
||||
Beep = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
}
|
||||
@ -118,7 +120,7 @@ void UI_DisplayLock(void)
|
||||
break;
|
||||
|
||||
case KEY_EXIT:
|
||||
if (gInputBoxIndex)
|
||||
if (gInputBoxIndex > 0)
|
||||
{
|
||||
gInputBox[--gInputBoxIndex] = 10;
|
||||
gUpdateDisplay = true;
|
||||
|
@ -170,11 +170,10 @@ void UI_DisplayMain(void)
|
||||
// show the memory channel symbol
|
||||
memcpy(pLine1 + x, BITMAP_M, sizeof(BITMAP_M));
|
||||
|
||||
// show the memory channel number
|
||||
if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num)
|
||||
NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String);
|
||||
NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); // show the memory channel number
|
||||
else
|
||||
memcpy(String + 5, gInputBox, 3);
|
||||
memcpy(String + 5, gInputBox, 3); // show the input text
|
||||
UI_DisplaySmallDigits(3, String + 5, x + sizeof(BITMAP_M), Line + 1, false);
|
||||
}
|
||||
else
|
||||
@ -258,7 +257,7 @@ void UI_DisplayMain(void)
|
||||
else
|
||||
{ // normal state
|
||||
|
||||
if (gInputBoxIndex && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num)
|
||||
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num)
|
||||
{ // user is entering a new frequency
|
||||
UI_DisplayFrequency(gInputBox, 31, Line, true, false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user