WIP support for digits in main. Only 0+3 for now.

This commit is contained in:
Dual Tachyon 2023-08-28 01:24:32 +01:00
parent 43379587bf
commit b0b09a2e6a
3 changed files with 140 additions and 1 deletions

View File

@ -1610,7 +1610,7 @@ static void APP_ProcessKey_MAIN(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case KEY_0: case KEY_1: case KEY_2: case KEY_3:
case KEY_4: case KEY_5: case KEY_6: case KEY_7:
case KEY_8: case KEY_9:
//MAIN_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
MAIN_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
break;
case KEY_MENU:
MAIN_Key_MENU(bKeyPressed, bKeyHeld);

View File

@ -1,6 +1,7 @@
#include "app/main.h"
#include "audio.h"
#include "fm.h"
#include "frequencies.h"
#include "gui.h"
#include "misc.h"
#include "radio.h"
@ -11,6 +12,142 @@ extern void FUN_0000773c(void);
extern void APP_AddStepToFrequency(VFO_Info_t *pInfo, uint8_t Step);
extern void APP_ChangeStepDirectionMaybe(bool bFlag, uint8_t Direction);
void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
uint8_t Vfo;
Vfo = gEeprom.TX_CHANNEL;
if (bKeyHeld) {
return;
}
if (!bKeyPressed) {
return;
}
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (!gWasFKeyPressed) {
NUMBER_Append(Key);
gRequestDisplayScreen = DISPLAY_MAIN;
if (gTxRadioInfo->CHANNEL_SAVE < 200) {
uint16_t Channel;
if (gNumberOffset != 3) {
gAnotherVoiceID = (VOICE_ID_t)Key;
gRequestDisplayScreen = DISPLAY_MAIN;
return;
}
gNumberOffset = 0;
Channel = ((gNumberForPrintf[0] * 100) + (gNumberForPrintf[1] * 10) + gNumberForPrintf[2]) - 1;
if (!RADIO_CheckValidChannel(Channel, false, 0)) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
gAnotherVoiceID = (VOICE_ID_t)Key;
gEeprom.EEPROM_0E81_0E84[Vfo] = (uint8_t)Channel;
gEeprom.VfoChannel[Vfo] = Channel;
gRequestSaveVFO = true;
g_2000039A = 2;
return;
}
if (gTxRadioInfo->CHANNEL_SAVE < 207) {
uint32_t Frequency;
if (gNumberOffset < 6) {
gAnotherVoiceID = Key;
return;
}
gNumberOffset = 0;
NUMBER_Get(gNumberForPrintf, &Frequency);
if (gSetting_350EN || (4999990 < (Frequency - 35000000))) {
uint8_t i;
for (i = 0; i < 7; i++) {
if (Frequency <= gUpperLimitFrequencyBandTable[i] && (gLowerLimitFrequencyBandTable[i] <= Frequency)) {
if (i < 7) {
gAnotherVoiceID = (VOICE_ID_t)Key;
if (gTxRadioInfo->Band != i) {
gTxRadioInfo->Band = i;
gEeprom.VfoChannel[Vfo] = i + 200;
gEeprom.EEPROM_0E82_0E85[Vfo] = i + 200;
SETTINGS_SaveVfoIndices();
RADIO_ConfigureChannel(Vfo, 2);
}
Frequency += 75;
gTxRadioInfo->DCS[0].Frequency = FREQUENCY_FloorToStep(
Frequency,
gTxRadioInfo->StepFrequency,
gLowerLimitFrequencyBandTable[gTxRadioInfo->Band]
);
gRequestSaveChannel = 1;
return;
}
break;
}
}
}
} else {
uint8_t Channel;
if (gNumberOffset != 2) {
gAnotherVoiceID = Key;
gRequestDisplayScreen = DISPLAY_MAIN;
return;
}
gNumberOffset = 0;
Channel = (gNumberForPrintf[0] * 10) + gNumberForPrintf[1];
if ((Channel - 1) < 10) {
Channel += 207;
gAnotherVoiceID = (VOICE_ID_t)Key;
gEeprom.EEPROM_0E86_0E87[Vfo] = Channel;
gEeprom.VfoChannel[Vfo] = Channel;
gRequestSaveVFO = true;
g_2000039A = 2;
return;
}
}
gRequestDisplayScreen = DISPLAY_MAIN;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
gWasFKeyPressed = false;
g_2000036F = 1;
switch (Key) {
case KEY_0:
APP_SwitchToFM();
break;
case KEY_3:
if ((gEeprom.VFO_OPEN) && (gTxRadioInfo->CHANNEL_SAVE < 207)) {
uint8_t Channel;
if (gTxRadioInfo->CHANNEL_SAVE < 200) {
gEeprom.VfoChannel[Vfo] = gEeprom.EEPROM_0E82_0E85[gEeprom.TX_CHANNEL];
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
gRequestSaveVFO = true;
g_2000039A = 2;
break;
}
Channel = RADIO_FindNextChannel(gEeprom.EEPROM_0E81_0E84[gEeprom.TX_CHANNEL], 1, false, 0);
if (Channel != 0xFF) {
gEeprom.VfoChannel[Vfo] = Channel;
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, Channel + 1);
gAnotherVoiceID = 0xFE;
gRequestSaveVFO = true;
g_2000039A = 2;
break;
}
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
default:
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
g_2000036F = 1;
gWasFKeyPressed = false;
}
}
void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{
if (!bKeyHeld && bKeyPressed) {

View File

@ -3,7 +3,9 @@
#include <stdbool.h>
#include <stdint.h>
#include "driver/keyboard.h"
void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld);
void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld);
void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction);