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-11 00:51:57 +08:00
|
|
|
#ifndef MISC_H
|
|
|
|
#define MISC_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-09-18 03:10:39 +08:00
|
|
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
|
|
|
|
2023-08-29 10:24:03 +08:00
|
|
|
#define IS_MR_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= MR_CHANNEL_LAST)
|
|
|
|
#define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
|
|
|
|
#define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST)
|
|
|
|
#define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
|
|
|
|
#define IS_VALID_CHANNEL(x) ((x) <= NOAA_CHANNEL_LAST)
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MR_CHANNEL_FIRST = 0U,
|
|
|
|
MR_CHANNEL_LAST = 199U,
|
|
|
|
FREQ_CHANNEL_FIRST = 200U,
|
|
|
|
FREQ_CHANNEL_LAST = 206U,
|
|
|
|
NOAA_CHANNEL_FIRST = 207U,
|
|
|
|
NOAA_CHANNEL_LAST = 216U,
|
|
|
|
};
|
|
|
|
|
2023-08-26 18:20:06 +08:00
|
|
|
enum {
|
|
|
|
FLASHLIGHT_OFF = 0U,
|
|
|
|
FLASHLIGHT_ON = 1U,
|
|
|
|
FLASHLIGHT_BLINK = 2U,
|
|
|
|
};
|
|
|
|
|
2023-08-31 20:47:25 +08:00
|
|
|
enum {
|
|
|
|
VFO_CONFIGURE_0 = 0U,
|
|
|
|
VFO_CONFIGURE_1 = 1U,
|
|
|
|
VFO_CONFIGURE_RELOAD = 2U,
|
|
|
|
};
|
|
|
|
|
2023-09-03 05:11:03 +08:00
|
|
|
enum AlarmState_t {
|
|
|
|
ALARM_STATE_OFF = 0U,
|
|
|
|
ALARM_STATE_TXALARM = 1U,
|
|
|
|
ALARM_STATE_ALARM = 2U,
|
|
|
|
ALARM_STATE_TX1750 = 3U,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum AlarmState_t AlarmState_t;
|
|
|
|
|
2023-09-03 22:56:49 +08:00
|
|
|
enum ReceptionMode_t {
|
|
|
|
RX_MODE_NONE = 0U,
|
|
|
|
RX_MODE_DETECTED = 1U,
|
|
|
|
RX_MODE_LISTENING = 2U,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum ReceptionMode_t ReceptionMode_t;
|
|
|
|
|
|
|
|
enum CssScanMode_t {
|
|
|
|
CSS_SCAN_MODE_OFF = 0U,
|
|
|
|
CSS_SCAN_MODE_SCANNING = 1U,
|
|
|
|
CSS_SCAN_MODE_FOUND = 2U,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum CssScanMode_t CssScanMode_t;
|
|
|
|
|
2023-08-11 00:51:57 +08:00
|
|
|
extern const uint32_t *gUpperLimitFrequencyBandTable;
|
|
|
|
extern const uint32_t *gLowerLimitFrequencyBandTable;
|
|
|
|
|
|
|
|
extern bool gSetting_350TX;
|
|
|
|
extern bool gSetting_KILLED;
|
|
|
|
extern bool gSetting_200TX;
|
|
|
|
extern bool gSetting_500TX;
|
|
|
|
extern bool gSetting_350EN;
|
2023-08-15 05:26:27 +08:00
|
|
|
extern uint8_t gSetting_F_LOCK;
|
2023-08-11 00:51:57 +08:00
|
|
|
extern bool gSetting_ScrambleEnable;
|
|
|
|
extern uint8_t gSetting_F_LOCK;
|
|
|
|
|
2023-09-01 19:27:10 +08:00
|
|
|
extern const uint32_t gDefaultAesKey[4];
|
|
|
|
extern uint32_t gCustomAesKey[4];
|
2023-09-01 06:27:02 +08:00
|
|
|
extern bool bHasCustomAesKey;
|
2023-09-01 19:27:10 +08:00
|
|
|
extern uint32_t gChallenge[4];
|
|
|
|
extern uint8_t gTryCount;
|
2023-08-11 00:51:57 +08:00
|
|
|
|
|
|
|
extern uint8_t gEEPROM_1EC0_0[8];
|
|
|
|
extern uint8_t gEEPROM_1EC0_1[8];
|
|
|
|
extern uint8_t gEEPROM_1EC0_2[8];
|
|
|
|
extern uint8_t gEEPROM_1EC0_3[8];
|
|
|
|
|
2023-08-26 19:13:18 +08:00
|
|
|
extern uint16_t gEEPROM_RSSI_CALIB[3][4];
|
2023-08-11 00:51:57 +08:00
|
|
|
|
|
|
|
extern uint16_t gEEPROM_1F8A;
|
|
|
|
extern uint16_t gEEPROM_1F8C;
|
|
|
|
|
2023-08-28 19:05:15 +08:00
|
|
|
extern uint8_t gMR_ChannelAttributes[207];
|
2023-08-11 00:51:57 +08:00
|
|
|
|
2023-08-16 05:39:26 +08:00
|
|
|
extern volatile bool gNextTimeslice500ms;
|
2023-08-29 20:26:13 +08:00
|
|
|
extern volatile uint16_t gBatterySaveCountdown;
|
2023-09-03 01:11:04 +08:00
|
|
|
extern volatile uint16_t gDualWatchCountdown;
|
2023-08-16 05:39:26 +08:00
|
|
|
extern volatile uint16_t gTxTimerCountdown;
|
2023-09-06 06:47:26 +08:00
|
|
|
extern volatile uint16_t gTailNoteEliminationCountdown;
|
2023-08-29 20:26:13 +08:00
|
|
|
extern volatile uint16_t gFmPlayCountdown;
|
2023-09-14 18:30:08 +08:00
|
|
|
#if defined(ENABLE_NOAA)
|
2023-08-31 23:04:49 +08:00
|
|
|
extern volatile uint16_t gNOAA_Countdown;
|
2023-09-14 18:30:08 +08:00
|
|
|
#endif
|
2023-09-01 07:49:14 +08:00
|
|
|
extern bool gEnableSpeaker;
|
2023-08-26 18:20:06 +08:00
|
|
|
extern uint8_t gKeyLockCountdown;
|
2023-08-27 22:01:47 +08:00
|
|
|
extern uint8_t gRTTECountdown;
|
2023-09-01 06:27:02 +08:00
|
|
|
extern bool bIsInLockScreen;
|
2023-08-30 07:19:12 +08:00
|
|
|
extern uint8_t gUpdateStatus;
|
2023-08-30 20:21:07 +08:00
|
|
|
extern uint8_t gFoundCTCSS;
|
|
|
|
extern uint8_t gFoundCDCSS;
|
2023-09-03 22:56:49 +08:00
|
|
|
extern bool gEndOfRxDetectedMaybe;
|
2023-08-15 21:24:40 +08:00
|
|
|
extern uint8_t gVFO_RSSI_Level[2];
|
2023-08-31 01:06:08 +08:00
|
|
|
extern uint8_t gReducedService;
|
2023-08-26 18:20:06 +08:00
|
|
|
extern uint8_t gBatteryVoltageIndex;
|
2023-09-03 22:56:49 +08:00
|
|
|
extern CssScanMode_t gCssScanMode;
|
2023-09-05 23:45:58 +08:00
|
|
|
extern bool gUpdateRSSI;
|
2023-09-03 05:11:03 +08:00
|
|
|
extern AlarmState_t gAlarmState;
|
2023-09-06 06:47:26 +08:00
|
|
|
extern uint8_t gVoltageMenuCountdown;
|
2023-09-03 18:47:36 +08:00
|
|
|
extern bool gPttWasReleased;
|
|
|
|
extern bool gPttWasPressed;
|
2023-09-04 00:58:01 +08:00
|
|
|
extern bool gFlagReconfigureVfos;
|
2023-08-31 20:47:25 +08:00
|
|
|
extern uint8_t gVfoConfigureMode;
|
2023-09-04 00:58:01 +08:00
|
|
|
extern bool gFlagResetVfos;
|
2023-08-28 06:17:44 +08:00
|
|
|
extern bool gRequestSaveVFO;
|
2023-08-29 08:21:33 +08:00
|
|
|
extern uint8_t gRequestSaveChannel;
|
2023-08-28 06:30:42 +08:00
|
|
|
extern bool gRequestSaveSettings;
|
2023-09-14 05:55:14 +08:00
|
|
|
#if defined(ENABLE_FMRADIO)
|
2023-08-28 06:17:44 +08:00
|
|
|
extern bool gRequestSaveFM;
|
2023-09-14 05:55:14 +08:00
|
|
|
#endif
|
2023-08-24 20:55:40 +08:00
|
|
|
extern uint8_t gKeypadLocked;
|
2023-09-06 04:03:31 +08:00
|
|
|
extern bool gFlagPrepareTX;
|
2023-08-28 02:52:32 +08:00
|
|
|
extern bool gFlagAcceptSetting;
|
2023-08-28 03:47:55 +08:00
|
|
|
extern bool gFlagRefreshSetting;
|
2023-08-28 02:52:32 +08:00
|
|
|
extern bool gFlagSaveVfo;
|
2023-08-26 21:29:19 +08:00
|
|
|
extern bool gFlagSaveSettings;
|
2023-09-05 02:06:37 +08:00
|
|
|
extern bool gFlagSaveChannel;
|
2023-09-14 05:55:14 +08:00
|
|
|
#if defined(ENABLE_FMRADIO)
|
2023-08-26 21:29:19 +08:00
|
|
|
extern bool gFlagSaveFM;
|
2023-09-14 05:55:14 +08:00
|
|
|
#endif
|
2023-08-31 21:22:08 +08:00
|
|
|
extern uint8_t gDTMF_RequestPending;
|
2023-08-16 06:46:09 +08:00
|
|
|
extern bool g_CDCSS_Lost;
|
2023-08-30 20:21:07 +08:00
|
|
|
extern uint8_t gCDCSSCodeType;
|
2023-08-16 06:46:09 +08:00
|
|
|
extern bool g_CTCSS_Lost;
|
|
|
|
extern bool g_CxCSS_TAIL_Found;
|
|
|
|
extern bool g_VOX_Lost;
|
2023-08-26 19:41:11 +08:00
|
|
|
extern bool g_SquelchLost;
|
2023-08-26 18:20:06 +08:00
|
|
|
extern uint8_t gFlashLightState;
|
2023-09-03 06:38:05 +08:00
|
|
|
extern bool gVOX_NoiseDetected;
|
2023-09-06 06:47:26 +08:00
|
|
|
extern uint16_t gVoxResumeCountdown;
|
2023-09-03 18:47:36 +08:00
|
|
|
extern uint16_t gVoxPauseCountdown;
|
2023-08-26 18:20:06 +08:00
|
|
|
extern volatile uint16_t gFlashLightBlinkCounter;
|
2023-09-03 18:47:36 +08:00
|
|
|
extern bool gFlagEndTransmission;
|
2023-09-04 19:19:19 +08:00
|
|
|
extern uint16_t gLowBatteryCountdown;
|
2023-09-03 22:56:49 +08:00
|
|
|
extern uint8_t gNextMrChannel;
|
|
|
|
extern ReceptionMode_t gRxReceptionMode;
|
2023-09-03 18:47:36 +08:00
|
|
|
extern uint8_t gRestoreMrChannel;
|
|
|
|
extern uint8_t gCurrentScanList;
|
2023-09-03 22:56:49 +08:00
|
|
|
extern uint8_t gPreviousMrChannel;
|
2023-09-03 18:47:36 +08:00
|
|
|
extern uint32_t gRestoreFrequency;
|
2023-09-05 23:45:58 +08:00
|
|
|
extern uint8_t gRxVfoIsActive;
|
2023-09-14 23:32:21 +08:00
|
|
|
#if defined(ENABLE_ALARM)
|
2023-09-03 06:45:11 +08:00
|
|
|
extern uint8_t gAlarmToneCounter;
|
|
|
|
extern uint16_t gAlarmRunningCounter;
|
2023-09-14 23:32:21 +08:00
|
|
|
#endif
|
2023-08-26 08:47:17 +08:00
|
|
|
extern bool gKeyBeingHeld;
|
|
|
|
extern bool gPttIsPressed;
|
2023-08-26 18:20:06 +08:00
|
|
|
extern uint8_t gPttDebounceCounter;
|
2023-08-22 06:47:16 +08:00
|
|
|
extern uint8_t gMenuListCount;
|
2023-08-29 23:02:35 +08:00
|
|
|
extern uint8_t gBackupCROSS_BAND_RX_TX;
|
2023-09-05 23:45:58 +08:00
|
|
|
extern uint8_t gScanDelay;
|
2023-09-14 04:26:18 +08:00
|
|
|
#if defined(ENABLE_AIRCOPY)
|
2023-08-26 18:20:06 +08:00
|
|
|
extern uint8_t gAircopySendCountdown;
|
2023-09-14 04:26:18 +08:00
|
|
|
#endif
|
2023-08-16 06:46:09 +08:00
|
|
|
extern uint8_t gFSKWriteIndex;
|
2023-09-05 23:45:58 +08:00
|
|
|
extern uint8_t gNeverUsed;
|
2023-08-14 05:40:33 +08:00
|
|
|
|
2023-09-14 18:30:08 +08:00
|
|
|
#if defined(ENABLE_NOAA)
|
2023-08-11 22:41:23 +08:00
|
|
|
extern bool gIsNoaaMode;
|
2023-09-14 18:30:08 +08:00
|
|
|
#endif
|
2023-08-15 18:14:43 +08:00
|
|
|
extern volatile bool gNextTimeslice;
|
2023-09-14 18:30:08 +08:00
|
|
|
#if defined(ENABLE_NOAA)
|
2023-08-16 02:02:42 +08:00
|
|
|
extern uint8_t gNoaaChannel;
|
2023-09-14 18:30:08 +08:00
|
|
|
#endif
|
2023-08-14 19:28:09 +08:00
|
|
|
extern bool gUpdateDisplay;
|
2023-08-28 02:52:32 +08:00
|
|
|
extern bool gF_LOCK;
|
2023-08-14 19:28:09 +08:00
|
|
|
extern uint8_t gShowChPrefix;
|
2023-08-15 06:38:59 +08:00
|
|
|
extern volatile uint16_t gSystickCountdown2;
|
2023-08-30 20:21:07 +08:00
|
|
|
extern volatile uint8_t gFoundCDCSSCountdown;
|
|
|
|
extern volatile uint8_t gFoundCTCSSCountdown;
|
2023-09-03 18:47:36 +08:00
|
|
|
extern volatile uint16_t gVoxStopCountdown;
|
2023-08-29 20:26:13 +08:00
|
|
|
extern volatile bool gTxTimeoutReached;
|
2023-08-16 05:39:26 +08:00
|
|
|
extern volatile bool gNextTimeslice40ms;
|
2023-08-29 20:26:13 +08:00
|
|
|
extern volatile bool gSchedulePowerSave;
|
2023-08-15 18:14:43 +08:00
|
|
|
extern volatile bool gBatterySaveCountdownExpired;
|
2023-09-03 01:11:04 +08:00
|
|
|
extern volatile bool gScheduleDualWatch;
|
2023-09-14 18:30:08 +08:00
|
|
|
#if defined(ENABLE_NOAA)
|
2023-08-31 23:04:49 +08:00
|
|
|
extern volatile bool gScheduleNOAA;
|
2023-09-14 18:30:08 +08:00
|
|
|
#endif
|
2023-09-07 20:30:52 +08:00
|
|
|
extern volatile bool gFlagTteComplete;
|
2023-09-14 05:55:14 +08:00
|
|
|
#if defined(ENABLE_FMRADIO)
|
2023-08-29 20:26:13 +08:00
|
|
|
extern volatile bool gScheduleFM;
|
2023-09-14 05:55:14 +08:00
|
|
|
#endif
|
2023-08-15 06:38:59 +08:00
|
|
|
|
2023-08-16 06:46:09 +08:00
|
|
|
extern uint16_t gCurrentRSSI;
|
|
|
|
|
2023-09-04 19:19:19 +08:00
|
|
|
extern uint8_t gIsLocked;
|
2023-09-01 06:27:02 +08:00
|
|
|
|
2023-08-14 06:27:35 +08:00
|
|
|
// --------
|
|
|
|
|
2023-08-14 19:28:09 +08:00
|
|
|
void NUMBER_Get(char *pDigits, uint32_t *pInteger);
|
|
|
|
void NUMBER_ToDigits(uint32_t Value, char *pDigits);
|
2023-08-28 01:04:19 +08:00
|
|
|
uint8_t NUMBER_AddWithWraparound(uint8_t Base, int8_t Add, uint8_t LowerLimit, uint8_t UpperLimit);
|
2023-08-14 06:27:35 +08:00
|
|
|
|
2023-08-11 00:51:57 +08:00
|
|
|
#endif
|
|
|
|
|