2023-08-11 03:37:33 +08: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.
|
|
|
|
*/
|
|
|
|
|
2023-08-14 06:27:35 +08:00
|
|
|
#include <string.h>
|
2023-08-11 00:51:57 +08:00
|
|
|
#include "misc.h"
|
|
|
|
|
|
|
|
const uint32_t *gUpperLimitFrequencyBandTable;
|
|
|
|
const uint32_t *gLowerLimitFrequencyBandTable;
|
|
|
|
|
|
|
|
bool gSetting_350TX;
|
|
|
|
bool gSetting_KILLED;
|
|
|
|
bool gSetting_200TX;
|
|
|
|
bool gSetting_500TX;
|
|
|
|
bool gSetting_350EN;
|
2023-08-15 05:26:27 +08:00
|
|
|
uint8_t gSetting_F_LOCK;
|
2023-08-11 00:51:57 +08:00
|
|
|
bool gSetting_ScrambleEnable;
|
|
|
|
uint8_t gSetting_F_LOCK;
|
|
|
|
|
2023-08-11 21:06:33 +08:00
|
|
|
uint32_t gCustomPasswordKey[4];
|
2023-08-11 00:51:57 +08:00
|
|
|
|
|
|
|
bool bIsCheckExistingPassword;
|
|
|
|
|
|
|
|
uint8_t gEEPROM_1EC0_0[8];
|
|
|
|
uint8_t gEEPROM_1EC0_1[8];
|
|
|
|
uint8_t gEEPROM_1EC0_2[8];
|
|
|
|
uint8_t gEEPROM_1EC0_3[8];
|
|
|
|
|
2023-08-15 21:04:17 +08:00
|
|
|
uint8_t gEEPROM_RSSI_CALIB[3][4];
|
2023-08-11 00:51:57 +08:00
|
|
|
|
|
|
|
uint16_t gEEPROM_1F8A;
|
|
|
|
uint16_t gEEPROM_1F8C;
|
|
|
|
|
|
|
|
uint8_t gMR_ChannelParameters[207];
|
|
|
|
|
2023-08-15 06:38:59 +08:00
|
|
|
uint8_t g_2000032D;
|
|
|
|
volatile uint16_t g_2000032E;
|
|
|
|
volatile uint16_t g_2000033A;
|
|
|
|
volatile uint16_t g_2000033E = 1000;
|
|
|
|
volatile uint16_t g_20000342;
|
|
|
|
volatile uint16_t g_2000034C;
|
|
|
|
volatile uint16_t g_20000356;
|
2023-08-11 22:41:23 +08:00
|
|
|
uint8_t g_2000036B;
|
2023-08-15 05:26:27 +08:00
|
|
|
uint8_t g_2000036D;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint8_t g_2000036E;
|
2023-08-11 18:51:17 +08:00
|
|
|
uint8_t g_2000036F;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint8_t g_20000370;
|
2023-08-15 05:26:27 +08:00
|
|
|
uint8_t g_20000371[2];
|
|
|
|
uint8_t g_20000373;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint8_t g_20000375;
|
|
|
|
uint8_t g_20000376;
|
|
|
|
uint8_t g_20000377;
|
|
|
|
uint8_t g_20000378;
|
|
|
|
uint8_t g_20000379;
|
|
|
|
uint8_t g_2000037E;
|
2023-08-15 06:38:59 +08:00
|
|
|
volatile uint8_t g_20000381;
|
2023-08-15 00:30:30 +08:00
|
|
|
uint8_t g_20000383;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint16_t g_2000038E;
|
|
|
|
uint8_t g_200003A9;
|
2023-08-14 05:40:33 +08:00
|
|
|
uint8_t g_200003AA;
|
|
|
|
uint8_t g_200003AB;
|
|
|
|
uint8_t g_200003AD;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint8_t g_200003AE;
|
2023-08-14 05:40:33 +08:00
|
|
|
uint8_t g_200003AF;
|
|
|
|
uint8_t g_200003B0;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint16_t g_200003B6;
|
|
|
|
uint8_t g_200003BC;
|
2023-08-15 05:26:27 +08:00
|
|
|
uint8_t g_200003BD;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint8_t g_200003BE;
|
2023-08-15 05:26:27 +08:00
|
|
|
uint8_t g_200003C3;
|
|
|
|
uint8_t g_200003FD;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint8_t g_20000400;
|
2023-08-15 05:26:27 +08:00
|
|
|
uint8_t g_2000041F;
|
2023-08-15 00:30:30 +08:00
|
|
|
uint8_t g_20000420;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint8_t g_2000042F;
|
2023-08-15 00:30:30 +08:00
|
|
|
uint8_t g_20000438;
|
2023-08-14 06:27:35 +08:00
|
|
|
uint8_t g_2000044C;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint8_t g_20000458;
|
|
|
|
uint8_t g_2000045A;
|
|
|
|
uint8_t g_2000045B;
|
|
|
|
uint8_t g_2000045C;
|
|
|
|
uint8_t g_20000461;
|
|
|
|
uint8_t g_20000464;
|
2023-08-14 05:40:33 +08:00
|
|
|
uint8_t g_20000D0C[16];
|
|
|
|
|
2023-08-14 19:28:09 +08:00
|
|
|
bool gIs_A_Scan;
|
2023-08-11 22:41:23 +08:00
|
|
|
bool gIsNoaaMode;
|
2023-08-15 18:14:43 +08:00
|
|
|
volatile bool gNextTimeslice;
|
2023-08-11 22:41:23 +08:00
|
|
|
bool gNoaaChannel;
|
2023-08-14 19:28:09 +08:00
|
|
|
bool gUpdateDisplay;
|
|
|
|
uint8_t gA_Scan_Channel;
|
|
|
|
uint8_t gDebounceCounter;
|
|
|
|
uint8_t gDTMF_AUTO_RESET_TIME;
|
|
|
|
uint8_t gF_LOCK;
|
|
|
|
char gNumberForPrintf[8];
|
2023-08-14 06:27:35 +08:00
|
|
|
uint8_t gNumberOffset;
|
2023-08-14 19:28:09 +08:00
|
|
|
uint8_t gScanChannel;
|
|
|
|
uint32_t gScanFrequency;
|
|
|
|
uint8_t gScanState;
|
|
|
|
uint8_t gShowChPrefix;
|
2023-08-15 06:38:59 +08:00
|
|
|
volatile uint16_t gSystickCountdown2;
|
|
|
|
volatile uint8_t gSystickCountdown3;
|
|
|
|
volatile uint8_t gSystickCountdown4;
|
|
|
|
volatile uint16_t gSystickCountdown11;
|
|
|
|
volatile bool gSystickFlag0;
|
|
|
|
volatile bool gSystickFlag1;
|
|
|
|
volatile bool gSystickFlag5;
|
2023-08-15 18:14:43 +08:00
|
|
|
volatile bool gBatterySaveCountdownExpired;
|
2023-08-15 06:38:59 +08:00
|
|
|
volatile bool gSystickFlag7;
|
|
|
|
volatile bool gSystickFlag8;
|
|
|
|
volatile bool gSystickFlag9;
|
|
|
|
volatile bool gSystickFlag10;
|
|
|
|
volatile bool gSystickFlag11;
|
|
|
|
|
|
|
|
volatile uint16_t ScanPauseDelayIn10msec;
|
2023-08-14 05:40:33 +08:00
|
|
|
|
2023-08-14 19:28:09 +08:00
|
|
|
// --------
|
2023-08-14 06:27:35 +08:00
|
|
|
|
2023-08-14 19:28:09 +08:00
|
|
|
void NUMBER_Append(char Digit)
|
2023-08-14 06:27:35 +08:00
|
|
|
{
|
|
|
|
if (gNumberOffset == 0) {
|
2023-08-14 07:08:50 +08:00
|
|
|
memset(gNumberForPrintf, 10, sizeof(gNumberForPrintf));
|
2023-08-14 06:54:06 +08:00
|
|
|
} else if (gNumberOffset >= sizeof(gNumberForPrintf)) {
|
2023-08-14 06:27:35 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
gNumberForPrintf[gNumberOffset++] = Digit;
|
|
|
|
}
|
|
|
|
|
2023-08-14 19:28:09 +08:00
|
|
|
void NUMBER_Get(char *pDigits, uint32_t *pInteger)
|
2023-08-14 06:27:35 +08:00
|
|
|
{
|
|
|
|
uint32_t Value;
|
|
|
|
uint32_t Multiplier;
|
|
|
|
uint8_t i;
|
|
|
|
|
|
|
|
Multiplier = 10000000;
|
|
|
|
Value = 0;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
if (pDigits[i] > 9) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Value += pDigits[i] * Multiplier;
|
|
|
|
Multiplier /= 10U;
|
|
|
|
}
|
|
|
|
*pInteger = Value;
|
|
|
|
}
|
|
|
|
|
2023-08-14 19:28:09 +08:00
|
|
|
void NUMBER_ToDigits(uint32_t Value, char *pDigits)
|
|
|
|
{
|
|
|
|
uint8_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
uint32_t Result = Value / 10U;
|
|
|
|
|
|
|
|
pDigits[7 - i] = Value - (Result * 10U);
|
|
|
|
Value = Result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|