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

106 lines
2.6 KiB
C
Raw Normal View History

2023-09-09 08:03:56 +01:00
/* Copyright 2023 Dual Tachyon
* https://github.com/DualTachyon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_AIRCOPY
2023-09-09 08:03:56 +01:00
#include "app/aircopy.h"
#endif
#include "bsp/dp32g030/gpio.h"
#include "driver/bk4819.h"
#include "driver/keyboard.h"
#include "driver/gpio.h"
#include "driver/system.h"
#include "helper/boot.h"
#include "misc.h"
#include "radio.h"
#include "settings.h"
#include "ui/menu.h"
#include "ui/ui.h"
boot_mode_t BOOT_GetMode(void)
2023-09-09 08:03:56 +01:00
{
unsigned int i;
2023-10-08 17:14:13 +01:00
key_code_t Keys[2];
2023-09-09 08:03:56 +01:00
for (i = 0; i < 2; i++)
{
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
return BOOT_MODE_NORMAL; // PTT not pressed
2023-09-09 08:03:56 +01:00
Keys[i] = KEYBOARD_Poll();
SYSTEM_DelayMs(20);
}
if (Keys[0] == Keys[1])
{
if (Keys[0] == KEY_SIDE1)
return BOOT_MODE_UNHIDE_HIDDEN;
2023-09-09 08:03:56 +01:00
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_AIRCOPY
2023-09-09 08:03:56 +01:00
if (Keys[0] == KEY_SIDE2)
return BOOT_MODE_AIRCOPY;
#endif
}
return BOOT_MODE_NORMAL;
}
void BOOT_ProcessMode(boot_mode_t Mode)
2023-09-09 08:03:56 +01:00
{
if (Mode == BOOT_MODE_UNHIDE_HIDDEN)
2023-09-09 08:03:56 +01:00
{
GUI_SelectNextDisplay(DISPLAY_MENU);
}
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_AIRCOPY
2023-09-09 08:03:56 +01:00
else
if (Mode == BOOT_MODE_AIRCOPY)
{
2023-10-08 17:14:13 +01:00
g_eeprom.dual_watch = DUAL_WATCH_OFF;
g_eeprom.battery_save = 0;
#ifdef ENABLE_VOX
2023-10-08 17:14:13 +01:00
g_eeprom.vox_switch = false;
#endif
2023-10-08 17:14:13 +01:00
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
g_eeprom.auto_keypad_lock = false;
g_eeprom.key1_short_press_action = ACTION_OPT_NONE;
g_eeprom.key1_long_press_action = ACTION_OPT_NONE;
g_eeprom.key2_short_press_action = ACTION_OPT_NONE;
g_eeprom.key2_long_press_action = ACTION_OPT_NONE;
2023-09-11 00:02:57 +01:00
2023-10-12 14:55:10 +01:00
RADIO_InitInfo(g_rx_vfo, FREQ_CHANNEL_LAST - 1, g_aircopy_freq);
2023-09-11 00:02:57 +01:00
2023-10-08 20:23:37 +01:00
g_rx_vfo->channel_bandwidth = BANDWIDTH_WIDE;
g_rx_vfo->output_power = OUTPUT_POWER_LOW;
2023-09-11 00:02:57 +01:00
2023-10-08 20:23:37 +01:00
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
2023-09-11 00:02:57 +01:00
2023-10-08 20:23:37 +01:00
g_current_vfo = g_rx_vfo;
2023-09-11 00:02:57 +01:00
2023-09-09 08:03:56 +01:00
RADIO_SetupRegisters(true);
BK4819_SetupAircopy();
BK4819_ResetFSK();
2023-09-11 00:02:57 +01:00
2023-10-08 20:23:37 +01:00
g_aircopy_state = AIRCOPY_READY;
2023-09-09 08:03:56 +01:00
GUI_SelectNextDisplay(DISPLAY_AIRCOPY);
}
#endif
else
{
2023-09-09 08:03:56 +01:00
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
2023-09-09 08:03:56 +01:00
}