22 Commits
v0.17 ... v0.19

Author SHA1 Message Date
Krzysiek Egzmont
59b3251713 Github actions update 2023-11-29 02:18:34 +01:00
Krzysiek Egzmont
fbb4d08b88 S-meter values readjusted according to measurements from #53 2023-11-29 01:23:20 +01:00
Krzysiek Egzmont
050e04bcfd Enable/disable DTMF calling compile option 2023-11-28 23:00:01 +01:00
Krzysiek Egzmont
7857e8ed7a Scan range function #132 2023-11-28 20:13:02 +01:00
Krzysiek Egzmont
4c3eb98e31 Refactor 2023-11-27 22:51:36 +01:00
Krzysiek Egzmont
fe49f250b0 FM radio button actions changed to be the same as in VFO mode 2023-11-27 19:36:49 +01:00
Krzysiek Egzmont
3c643208ff FIX #152: Zero digit being entered when exiting FM radio with F+0 2023-11-27 13:42:47 +01:00
Krzysiek Egzmont
dc47842892 Refactor 2023-11-27 13:33:39 +01:00
Krzysiek Egzmont
9f22e8a9df FIX #151: Use aviation channels to frequency conversion scheme for 8.33 step rounding 2023-11-27 01:43:36 +01:00
Krzysiek Egzmont
07588853e4 Versioning modified 2023-11-27 00:50:08 +01:00
Krzysiek Egzmont
199b1a27f1 Spectrum: decimal point deletion fix #148, slower buttons repeats 2023-11-26 19:06:18 +01:00
Krzysiek Egzmont
a0d052b68b Spectrum refactor 2023-11-25 19:28:21 +01:00
Krzysiek Egzmont
9a3249a667 FIX #121: Rise tones volume 2023-11-23 21:20:24 +01:00
Krzysiek Egzmont
ffdc0e03b5 FIX #114, #120: Restart monitor mode on PTT release, long press EXIT exits monitor mode 2023-11-23 21:02:47 +01:00
Krzysiek Egzmont
d8d4384b20 Refactoring 2023-11-23 19:48:47 +01:00
Krzysiek Egzmont
0ce7d7bdc3 FIX #129: Bug in radio initialization after reset. 2023-11-22 23:40:39 +01:00
Krzysiek Egzmont
fb30ec8c86 Refactor 2023-11-22 23:40:20 +01:00
Krzysiek Egzmont
67307463e2 FIX #92: Adjust s-meter values 2023-11-22 14:52:16 +01:00
Krzysiek Egzmont
fdd7fc063e Cleanup docker container after build 2023-11-22 14:51:53 +01:00
Krzysiek Egzmont
592810b7d7 FIX #125: Frequency input on the first VFO blanks the display on the second 2023-11-20 22:32:39 +01:00
Krzysiek Egzmont
6e5e7e7aef FIX #85: Equalize tones volume in DTMF codes, fix wrong DTMF frequency values 2023-11-20 21:24:09 +01:00
ErikS-web
cd0dc71de6 Update README.md
Type error corrected
2023-11-18 21:26:37 +01:00
40 changed files with 875 additions and 730 deletions

View File

@@ -4,30 +4,46 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
container:
image: archlinux:latest
steps: steps:
- name: arm-none-eabi-gcc - name: base-devel
uses: carlosperate/arm-none-eabi-gcc-action@v1 run: pacman -Syyu base-devel --noconfirm
with: - name: arm-none-eabi-gcc
release: '10.3-2021.10' run: pacman -Syyu arm-none-eabi-gcc --noconfirm
- name: arm-none-eabi-newlib
run: pacman -Syyu arm-none-eabi-newlib --noconfirm
- name: git
run: pacman -Syyu git --noconfirm
- name: python-pip
run: pacman -Syyu python-pip --noconfirm
- name: python-crcmod
run: pacman -Syyu python-crcmod --noconfirm
- name: Install Python dependencies - name: Checkout
run: python -m pip install --upgrade pip crcmod uses: actions/checkout@v3
- name: safe.directory
run: git config --global --add safe.directory /__w/uv-k5-firmware-custom/uv-k5-firmware-custom
- name: Make
run: make
- name: size
run: arm-none-eabi-size firmware
- name: Checkout - name: 'Upload Artifact'
uses: actions/checkout@v3 uses: actions/upload-artifact@v3
with:
name: firmware
path: firmware*.bin
- name: Submodules - name: Upload binaries to release
run: git submodule update --init --recursive --depth 1 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: svenstaro/upload-release-action@v2
- name: Make with:
run: make repo_token: ${{ secrets.GITHUB_TOKEN }}
file: firmware.packed.bin
- name: size asset_name: egzumer_$tag.packed.bin
run: arm-none-eabi-size firmware tag: ${{ github.ref }}
overwrite: true
- name: 'Upload Artifact' release_name: release ${{ github.ref_name }}
uses: actions/upload-artifact@v3
with:
name: firmware
path: firmware*.bin

View File

@@ -1,45 +0,0 @@
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: arm-none-eabi-gcc
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '10.3-2021.10'
- name: Install Python dependencies
run: python3 -m pip install --upgrade pip crcmod
- name: Checkout
uses: actions/checkout@v3
- name: Submodules
run: git submodule update --init --recursive --depth 1
- name: Make
run: make
- name: size
run: arm-none-eabi-size firmware
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: firmware
path: firmware*.bin
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: firmware.packed.bin
asset_name: egzumer_$tag.packed.bin
tag: ${{ github.ref }}
overwrite: true
release_name: release ${{ github.ref_name }}

View File

@@ -37,7 +37,9 @@ ENABLE_COPY_CHAN_TO_VFO := 1
ENABLE_SPECTRUM := 1 ENABLE_SPECTRUM := 1
ENABLE_REDUCE_LOW_MID_TX_POWER:= 0 ENABLE_REDUCE_LOW_MID_TX_POWER:= 0
ENABLE_BYP_RAW_DEMODULATORS := 0 ENABLE_BYP_RAW_DEMODULATORS := 0
ENABLE_BLMIN_TMP_OFF := 0 ENABLE_BLMIN_TMP_OFF := 0
ENABLE_SCAN_RANGES := 1
ENABLE_DTMF_CALLING := 1
############################################################# #############################################################
TARGET = firmware TARGET = firmware
@@ -158,6 +160,20 @@ else
TOP := $(shell pwd) TOP := $(shell pwd)
endif endif
ifdef OS # windows
RM = del /Q
FixPath = $(subst /,\,$1)
WHERE = where
NULL_OUTPUT = nul
else # unix
ifeq ($(shell uname), Linux)
RM = rm -f
FixPath = $1
WHERE = which
NULL_OUTPUT = /dev/null
endif
endif
AS = arm-none-eabi-gcc AS = arm-none-eabi-gcc
CC = CC =
@@ -177,12 +193,17 @@ endif
OBJCOPY = arm-none-eabi-objcopy OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size SIZE = arm-none-eabi-size
AUTHOR_STRING := EGZUMER
# the user might not have/want git installed # the user might not have/want git installed
# can set own version string here (max 7 chars) # can set own version string here (max 7 chars)
GIT_HASH := $(shell git rev-parse --short HEAD) ifneq (, $(shell $(WHERE) git))
#GIT_HASH := 230930b VERSION_STRING := $(shell git describe --tags --exact-match 2>$(NULL_OUTPUT))
ifeq (, $(VERSION_STRING))
VERSION_STRING := $(shell git rev-parse --short HEAD)
endif
endif
#VERSION_STRING := 230930b
$(info GIT_HASH = $(GIT_HASH))
ASFLAGS = -c -mcpu=cortex-m0 ASFLAGS = -c -mcpu=cortex-m0
ifeq ($(ENABLE_OVERLAY),1) ifeq ($(ENABLE_OVERLAY),1)
@@ -215,7 +236,7 @@ CFLAGS += -Wextra
#CFLAGS += -Wpedantic #CFLAGS += -Wpedantic
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\" CFLAGS += -DAUTHOR_STRING=\"$(AUTHOR_STRING)\" -DVERSION_STRING=\"$(VERSION_STRING)\"
ifeq ($(ENABLE_SPECTRUM),1) ifeq ($(ENABLE_SPECTRUM),1)
CFLAGS += -DENABLE_SPECTRUM CFLAGS += -DENABLE_SPECTRUM
@@ -328,6 +349,12 @@ endif
ifeq ($(ENABLE_BLMIN_TMP_OFF),1) ifeq ($(ENABLE_BLMIN_TMP_OFF),1)
CFLAGS += -DENABLE_BLMIN_TMP_OFF CFLAGS += -DENABLE_BLMIN_TMP_OFF
endif endif
ifeq ($(ENABLE_SCAN_RANGES),1)
CFLAGS += -DENABLE_SCAN_RANGES
endif
ifeq ($(ENABLE_DTMF_CALLING),1)
CFLAGS += -DENABLE_DTMF_CALLING
endif
LDFLAGS = LDFLAGS =
ifeq ($(ENABLE_CLANG),0) ifeq ($(ENABLE_CLANG),0)
@@ -360,17 +387,7 @@ LIBS =
DEPS = $(OBJS:.o=.d) DEPS = $(OBJS:.o=.d)
ifdef OS
RM = del /Q
FixPath = $(subst /,\,$1)
WHERE = where
else
ifeq ($(shell uname), Linux)
RM = rm -f
FixPath = $1
WHERE = which
endif
endif
ifneq (, $(shell $(WHERE) python)) ifneq (, $(shell $(WHERE) python))
MY_PYTHON := python MY_PYTHON := python
@@ -395,7 +412,7 @@ else ifneq (,$(HAS_CRCMOD))
$(info !!!!!!!! run: pip install crcmod) $(info !!!!!!!! run: pip install crcmod)
$(info ) $(info )
else else
-$(MY_PYTHON) fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin -$(MY_PYTHON) fw-pack.py $<.bin $(AUTHOR_STRING) $(VERSION_STRING) $<.packed.bin
endif endif
$(SIZE) $< $(SIZE) $<

View File

@@ -21,7 +21,7 @@
* battery voltage callibration from menu * battery voltage callibration from menu
* better battery percentage calculation, selectable for 1600mAh or 2200mAh * better battery percentage calculation, selectable for 1600mAh or 2200mAh
* more configurable button functions * more configurable button functions
* longpress MENU as another cofigurable button * longpress MENU as another configurable button
* better DCS/CTCSS scanning in the menu (`* SCAN` while in RX DCS/CTCSS menu item) * better DCS/CTCSS scanning in the menu (`* SCAN` while in RX DCS/CTCSS menu item)
* Piotr022 s-meter style * Piotr022 s-meter style
* restore initial freq/channel when scanning stopped with EXIT, remember last found transmission with MENU button * restore initial freq/channel when scanning stopped with EXIT, remember last found transmission with MENU button

View File

@@ -63,24 +63,22 @@ void ACTION_Power(void)
gTxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW; gTxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
//gRequestSaveChannel = 2; // auto save the channel
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_POWER; gAnotherVoiceID = VOICE_ID_POWER;
#endif #endif
gRequestDisplayScreen = gScreenToDisplay; gRequestDisplayScreen = gScreenToDisplay;
} }
void ACTION_Monitor(void) void ACTION_Monitor(void)
{ {
if (gCurrentFunction != FUNCTION_MONITOR) if (gCurrentFunction != FUNCTION_MONITOR) { // enable the monitor
{ // enable the monitor
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST && gIsNoaaMode) if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST && gIsNoaaMode)
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST; gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
#endif #endif
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
APP_StartListening(FUNCTION_MONITOR, false); APP_StartListening(FUNCTION_MONITOR, false);
return; return;
@@ -88,32 +86,29 @@ void ACTION_Monitor(void)
gMonitor = false; gMonitor = false;
if (gScanStateDir != SCAN_OFF) if (gScanStateDir != SCAN_OFF) {
{
gScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms; gScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms;
gScheduleScanListen = false; gScheduleScanListen = false;
gScanPauseMode = true; gScanPauseMode = true;
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode) if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode) {
{ gNOAA_Countdown_10ms = NOAA_countdown_10ms;
gNOAA_Countdown_10ms = NOAA_countdown_10ms; gScheduleNOAA = false;
gScheduleNOAA = false; }
} #endif
#endif
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode) if (gFmRadioMode) {
{ FM_Start();
FM_Start(); gRequestDisplayScreen = DISPLAY_FM;
gRequestDisplayScreen = DISPLAY_FM; }
} else
else #endif
#endif gRequestDisplayScreen = gScreenToDisplay;
gRequestDisplayScreen = gScreenToDisplay;
} }
void ACTION_Scan(bool bRestart) void ACTION_Scan(bool bRestart)
@@ -172,8 +167,9 @@ void ACTION_Scan(bool bRestart)
gMonitor = false; gMonitor = false;
#ifdef ENABLE_DTMF_CALLING
DTMF_clear_RX(); DTMF_clear_RX();
#endif
gDTMF_RX_live_timeout = 0; gDTMF_RX_live_timeout = 0;
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));

177
app/app.c
View File

@@ -173,14 +173,12 @@ static void HandleIncoming(void)
{ {
bool bFlag; bool bFlag;
if (!g_SquelchLost) if (!g_SquelchLost) { // squelch is closed
{ // squelch is closed #ifdef ENABLE_DTMF_CALLING
if (gDTMF_RX_index > 0) if (gDTMF_RX_index > 0)
DTMF_clear_RX(); DTMF_clear_RX();
#endif
if (gCurrentFunction != FUNCTION_FOREGROUND) if (gCurrentFunction != FUNCTION_FOREGROUND) {
{
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
gUpdateDisplay = true; gUpdateDisplay = true;
} }
@@ -189,39 +187,32 @@ static void HandleIncoming(void)
bFlag = (gScanStateDir == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF); bFlag = (gScanStateDir == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gNOAACountdown_10ms > 0) if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gNOAACountdown_10ms > 0) {
{ gNOAACountdown_10ms = 0;
gNOAACountdown_10ms = 0; bFlag = true;
bFlag = true; }
} #endif
#endif
if (g_CTCSS_Lost && gCurrentCodeType == CODE_TYPE_CONTINUOUS_TONE) if (g_CTCSS_Lost && gCurrentCodeType == CODE_TYPE_CONTINUOUS_TONE) {
{
bFlag = true; bFlag = true;
gFoundCTCSS = false; gFoundCTCSS = false;
} }
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL)) if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL)) {
{
gFoundCDCSS = false; gFoundCDCSS = false;
} }
else else if (!bFlag)
if (!bFlag)
return; return;
if (gScanStateDir == SCAN_OFF) #ifdef ENABLE_DTMF_CALLING
{ // not scanning if (gScanStateDir == SCAN_OFF) { // not scanning
if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) { // DTMF DCD is enabled
{ // DTMF DCD is enabled
DTMF_HandleRequest(); DTMF_HandleRequest();
if (gDTMF_CallState == DTMF_CALL_STATE_NONE) if (gDTMF_CallState == DTMF_CALL_STATE_NONE) {
{ if (gRxReceptionMode == RX_MODE_DETECTED) {
if (gRxReceptionMode == RX_MODE_DETECTED)
{
gDualWatchCountdown_10ms = dual_watch_count_after_1_10ms; gDualWatchCountdown_10ms = dual_watch_count_after_1_10ms;
gScheduleDualWatch = false; gScheduleDualWatch = false;
@@ -237,6 +228,7 @@ static void HandleIncoming(void)
} }
} }
} }
#endif
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, false); APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, false);
} }
@@ -457,8 +449,10 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
const unsigned int chan = gEeprom.RX_VFO; const unsigned int chan = gEeprom.RX_VFO;
// const unsigned int chan = gRxVfo->CHANNEL_SAVE; // const unsigned int chan = gRxVfo->CHANNEL_SAVE;
#ifdef ENABLE_DTMF_CALLING
if (gSetting_KILLED) if (gSetting_KILLED)
return; return;
#endif
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode) if (gFmRadioMode)
@@ -562,18 +556,23 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
gUpdateStatus = true; gUpdateStatus = true;
} }
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction) uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper)
{ {
uint32_t Frequency = FREQUENCY_RoundToStep(pInfo->freq_config_RX.Frequency + (direction * pInfo->StepFrequency), pInfo->StepFrequency); uint32_t Frequency = FREQUENCY_RoundToStep(pInfo->freq_config_RX.Frequency + (direction * pInfo->StepFrequency), pInfo->StepFrequency);
if (Frequency >= frequencyBandTable[pInfo->Band].upper) if (Frequency >= upper)
Frequency = frequencyBandTable[pInfo->Band].lower; Frequency = lower;
else if (Frequency < frequencyBandTable[pInfo->Band].lower) else if (Frequency < lower)
Frequency = FREQUENCY_RoundToStep(frequencyBandTable[pInfo->Band].upper - pInfo->StepFrequency, pInfo->StepFrequency); Frequency = FREQUENCY_RoundToStep(upper - pInfo->StepFrequency, pInfo->StepFrequency);
return Frequency; return Frequency;
} }
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction)
{
return APP_SetFreqByStepAndLimits(pInfo, direction, frequencyBandTable[pInfo->Band].lower, frequencyBandTable[pInfo->Band].upper);
}
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
static void NOAA_IncreaseChannel(void) static void NOAA_IncreaseChannel(void)
{ {
@@ -664,6 +663,7 @@ static void CheckRadioInterrupts(void)
gUpdateDisplay = true; gUpdateDisplay = true;
} }
#ifdef ENABLE_DTMF_CALLING
if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED)
{ {
if (gDTMF_RX_index >= (sizeof(gDTMF_RX) - 1)) if (gDTMF_RX_index >= (sizeof(gDTMF_RX) - 1))
@@ -678,6 +678,7 @@ static void CheckRadioInterrupts(void)
DTMF_HandleRequest(); DTMF_HandleRequest();
} }
#endif
} }
} }
} }
@@ -766,14 +767,19 @@ void APP_EndTransmission(void)
// send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash // send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
RADIO_EnableCxCSS(); RADIO_EnableCxCSS();
RADIO_SetupRegisters(false); RADIO_SetupRegisters(false);
if (gMonitor)
gFlagReconfigureVfos = true; //turn the monitor back on
} }
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
static void HandleVox(void) static void HandleVox(void)
{ {
#ifdef ENABLE_DTMF_CALLING
if (gSetting_KILLED) if (gSetting_KILLED)
return; return;
#endif
if (gVoxResumeCountdown == 0) if (gVoxResumeCountdown == 0)
{ {
if (gVoxPauseCountdown) if (gVoxPauseCountdown)
@@ -840,7 +846,9 @@ void APP_EndTransmission(void)
if (gCurrentFunction != FUNCTION_TRANSMIT && gSerialConfigCountDown_500ms == 0) if (gCurrentFunction != FUNCTION_TRANSMIT && gSerialConfigCountDown_500ms == 0)
{ {
#ifdef ENABLE_DTMF_CALLING
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;
#endif
RADIO_PrepareTX(); RADIO_PrepareTX();
gUpdateDisplay = true; gUpdateDisplay = true;
} }
@@ -922,7 +930,9 @@ void APP_Update(void)
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
!gFmRadioMode && !gFmRadioMode &&
#endif #endif
#ifdef ENABLE_DTMF_CALLING
gDTMF_CallState == DTMF_CALL_STATE_NONE && gDTMF_CallState == DTMF_CALL_STATE_NONE &&
#endif
gCurrentFunction != FUNCTION_POWER_SAVE) gCurrentFunction != FUNCTION_POWER_SAVE)
{ {
DualwatchAlternate(); // toggle between the two VFO's DualwatchAlternate(); // toggle between the two VFO's
@@ -958,7 +968,6 @@ void APP_Update(void)
if (gSchedulePowerSave) if (gSchedulePowerSave)
{ {
#ifdef ENABLE_NOAA
if ( if (
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
gFmRadioMode || gFmRadioMode ||
@@ -968,41 +977,28 @@ void APP_Update(void)
gEeprom.BATTERY_SAVE == 0 || gEeprom.BATTERY_SAVE == 0 ||
gScanStateDir != SCAN_OFF || gScanStateDir != SCAN_OFF ||
gCssBackgroundScan || gCssBackgroundScan ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN
gDTMF_CallState != DTMF_CALL_STATE_NONE) #ifdef ENABLE_DTMF_CALLING
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
#endif
)
{ {
gBatterySaveCountdown_10ms = battery_save_count_10ms; gBatterySaveCountdown_10ms = battery_save_count_10ms;
} }
else if ((!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode) else
#ifdef ENABLE_NOAA
if ((!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
#endif
{ {
//if (gCurrentFunction != FUNCTION_POWER_SAVE) //if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE); FUNCTION_Select(FUNCTION_POWER_SAVE);
} }
#ifdef ENABLE_NOAA
else else
{ {
gBatterySaveCountdown_10ms = battery_save_count_10ms; gBatterySaveCountdown_10ms = battery_save_count_10ms;
} }
#else #else
if (
#ifdef ENABLE_FMRADIO
gFmRadioMode ||
#endif
gPttIsPressed ||
gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 ||
gScanStateDir != SCAN_OFF ||
gCssBackgroundScan ||
gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
{
gBatterySaveCountdown_10ms = battery_save_count_10ms;
}
else
{
//if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE);
}
gSchedulePowerSave = false; gSchedulePowerSave = false;
#endif #endif
} }
@@ -1071,13 +1067,17 @@ void APP_Update(void)
// called every 10ms // called every 10ms
static void CheckKeys(void) static void CheckKeys(void)
{ {
#ifdef ENABLE_AIRCOPY
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)) if (0
#ifdef ENABLE_DTMF_CALLING
|| gSetting_KILLED
#endif
#ifdef ENABLE_AIRCOPY
|| (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)
#endif
)
return; return;
#else
if (gSetting_KILLED)
return;
#endif
// -------------------- PTT ------------------------ // -------------------- PTT ------------------------
if (gPttIsPressed) if (gPttIsPressed)
@@ -1406,9 +1406,11 @@ void APP_TimeSlice500ms(void)
if (--gMenuCountdown == 0) if (--gMenuCountdown == 0)
exit_menu = (gScreenToDisplay == DISPLAY_MENU); // exit menu mode exit_menu = (gScreenToDisplay == DISPLAY_MENU); // exit menu mode
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_RX_timeout > 0) if (gDTMF_RX_timeout > 0)
if (--gDTMF_RX_timeout == 0) if (--gDTMF_RX_timeout == 0)
DTMF_clear_RX(); DTMF_clear_RX();
#endif
// Skipped authentic device check // Skipped authentic device check
@@ -1583,6 +1585,7 @@ void APP_TimeSlice500ms(void)
BATTERY_TimeSlice500ms(); BATTERY_TimeSlice500ms();
SCANNER_TimeSlice500ms(); SCANNER_TimeSlice500ms();
#ifdef ENABLE_DTMF_CALLING
if (gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction != FUNCTION_TRANSMIT)
{ {
if (gDTMF_DecodeRingCountdown_500ms > 0) if (gDTMF_DecodeRingCountdown_500ms > 0)
@@ -1619,6 +1622,7 @@ void APP_TimeSlice500ms(void)
gUpdateDisplay = true; gUpdateDisplay = true;
} }
} }
#endif
} }
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
@@ -1726,11 +1730,18 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
// cancel user input // cancel user input
cancelUserInputModes(); cancelUserInputModes();
if (gMonitor)
ACTION_Monitor(); //turn off the monitor
#ifdef ENABLE_SCAN_RANGES
gScanRangeStart = 0;
#endif
} }
if (gScreenToDisplay == DISPLAY_MENU) // 1of11 if (gScreenToDisplay == DISPLAY_MENU) // 1of11
gMenuCountdown = menu_timeout_500ms; gMenuCountdown = menu_timeout_500ms;
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_DecodeRingCountdown_500ms > 0) if (gDTMF_DecodeRingCountdown_500ms > 0)
{ // cancel the ringing { // cancel the ringing
gDTMF_DecodeRingCountdown_500ms = 0; gDTMF_DecodeRingCountdown_500ms = 0;
@@ -1743,6 +1754,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
} }
#endif
} }
bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN; bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN;
@@ -1911,22 +1923,16 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
#endif #endif
} }
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2) else if (Key != KEY_SIDE1 && Key != KEY_SIDE2) {
{ switch (gScreenToDisplay) {
switch (gScreenToDisplay)
{
case DISPLAY_MAIN: case DISPLAY_MAIN:
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld); MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
// bKeyHeld = false; // allow the channel setting to be saved
break; break;
#ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO case DISPLAY_FM:
case DISPLAY_FM: FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld); break;
break; #endif
#endif
case DISPLAY_MENU: case DISPLAY_MENU:
MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld); MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break; break;
@@ -1935,12 +1941,11 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld); SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break; break;
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
case DISPLAY_AIRCOPY: case DISPLAY_AIRCOPY:
AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld); AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break; break;
#endif #endif
case DISPLAY_INVALID: case DISPLAY_INVALID:
default: default:
break; break;
@@ -2049,16 +2054,18 @@ Skip:
{ {
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
RADIO_ConfigureNOAA(); RADIO_ConfigureNOAA();
#endif #endif
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
#ifdef ENABLE_DTMF_CALLING
gDTMF_auto_reset_time_500ms = 0; gDTMF_auto_reset_time_500ms = 0;
gDTMF_CallState = DTMF_CALL_STATE_NONE; gDTMF_CallState = DTMF_CALL_STATE_NONE;
gDTMF_TxStopCountdown_500ms = 0; gDTMF_TxStopCountdown_500ms = 0;
gDTMF_IsTx = false; gDTMF_IsTx = false;
#endif
gVFO_RSSI_bar_level[0] = 0; gVFO_RSSI_bar_level[0] = 0;
gVFO_RSSI_bar_level[1] = 0; gVFO_RSSI_bar_level[1] = 0;

View File

@@ -25,6 +25,7 @@
void APP_EndTransmission(void); void APP_EndTransmission(void);
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix); void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix);
uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper);
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction); uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction);
void APP_Update(void); void APP_Update(void);
void APP_TimeSlice10ms(void); void APP_TimeSlice10ms(void);

View File

@@ -9,6 +9,10 @@ int8_t gScanStateDir;
bool gScanKeepResult; bool gScanKeepResult;
bool gScanPauseMode; bool gScanPauseMode;
#ifdef ENABLE_SCAN_RANGES
uint32_t gScanRangeStart;
#endif
typedef enum { typedef enum {
SCAN_NEXT_CHAN_SCANLIST1 = 0, SCAN_NEXT_CHAN_SCANLIST1 = 0,
SCAN_NEXT_CHAN_SCANLIST2, SCAN_NEXT_CHAN_SCANLIST2,
@@ -151,7 +155,15 @@ void CHFRSCANNER_Stop(void)
static void NextFreqChannel(void) static void NextFreqChannel(void)
{ {
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir); #ifdef ENABLE_SCAN_RANGES
if(gScanRangeStart) {
uint32_t start = gScanRangeStart;
uint32_t end = gEeprom.VfoInfo[(gEeprom.TX_VFO+1)%2].freq_config_RX.Frequency;
gRxVfo->freq_config_RX.Frequency = APP_SetFreqByStepAndLimits(gRxVfo, gScanStateDir, MIN(start, end), MAX(start, end));
}
else
#endif
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir);
RADIO_ApplyOffset(gRxVfo); RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo);

View File

@@ -10,6 +10,10 @@ extern int8_t gScanStateDir;
extern bool gScanKeepResult; extern bool gScanKeepResult;
extern bool gScanPauseMode; extern bool gScanPauseMode;
#ifdef ENABLE_SCAN_RANGES
extern uint32_t gScanRangeStart;
#endif
void CHFRSCANNER_Found(void); void CHFRSCANNER_Found(void);
void CHFRSCANNER_Stop(void); void CHFRSCANNER_Stop(void);
void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_direction); void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_direction);

View File

@@ -1,3 +1,4 @@
#include "app/chFrScanner.h"
#include "audio.h" #include "audio.h"
#include "functions.h" #include "functions.h"
#include "misc.h" #include "misc.h"
@@ -23,6 +24,9 @@ void COMMON_KeypadLockToggle()
void COMMON_SwitchVFOs() void COMMON_SwitchVFOs()
{ {
#ifdef ENABLE_SCAN_RANGES
gScanRangeStart = 0;
#endif
gEeprom.TX_VFO ^= 1; gEeprom.TX_VFO ^= 1;
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)

View File

@@ -41,14 +41,15 @@ uint8_t gDTMF_InputBox_Index = 0;
bool gDTMF_InputMode = false; bool gDTMF_InputMode = false;
uint8_t gDTMF_PreviousIndex = 0; uint8_t gDTMF_PreviousIndex = 0;
char gDTMF_RX_live[20];
uint8_t gDTMF_RX_live_timeout = 0;
#ifdef ENABLE_DTMF_CALLING
char gDTMF_RX[17]; char gDTMF_RX[17];
uint8_t gDTMF_RX_index = 0; uint8_t gDTMF_RX_index = 0;
uint8_t gDTMF_RX_timeout = 0; uint8_t gDTMF_RX_timeout = 0;
bool gDTMF_RX_pending = false; bool gDTMF_RX_pending = false;
char gDTMF_RX_live[20];
uint8_t gDTMF_RX_live_timeout = 0;
bool gIsDtmfContactValid; bool gIsDtmfContactValid;
char gDTMF_ID[4]; char gDTMF_ID[4];
char gDTMF_Caller[4]; char gDTMF_Caller[4];
@@ -58,12 +59,16 @@ uint8_t gDTMF_DecodeRingCountdown_500ms;
uint8_t gDTMF_chosen_contact; uint8_t gDTMF_chosen_contact;
uint8_t gDTMF_auto_reset_time_500ms; uint8_t gDTMF_auto_reset_time_500ms;
DTMF_CallState_t gDTMF_CallState; DTMF_CallState_t gDTMF_CallState;
DTMF_ReplyState_t gDTMF_ReplyState;
DTMF_CallMode_t gDTMF_CallMode; DTMF_CallMode_t gDTMF_CallMode;
bool gDTMF_IsTx; bool gDTMF_IsTx;
uint8_t gDTMF_TxStopCountdown_500ms; uint8_t gDTMF_TxStopCountdown_500ms;
bool gDTMF_IsGroupCall; bool gDTMF_IsGroupCall;
#endif
DTMF_ReplyState_t gDTMF_ReplyState;
#ifdef ENABLE_DTMF_CALLING
void DTMF_clear_RX(void) void DTMF_clear_RX(void)
{ {
gDTMF_RX_timeout = 0; gDTMF_RX_timeout = 0;
@@ -71,6 +76,7 @@ void DTMF_clear_RX(void)
gDTMF_RX_pending = false; gDTMF_RX_pending = false;
memset(gDTMF_RX, 0, sizeof(gDTMF_RX)); memset(gDTMF_RX, 0, sizeof(gDTMF_RX));
} }
#endif
bool DTMF_ValidateCodes(char *pCode, const unsigned int size) bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
{ {
@@ -94,6 +100,7 @@ bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
return true; return true;
} }
#ifdef ENABLE_DTMF_CALLING
bool DTMF_GetContact(const int Index, char *pContact) bool DTMF_GetContact(const int Index, char *pContact)
{ {
int i = -1; int i = -1;
@@ -132,6 +139,8 @@ bool DTMF_FindContact(const char *pContact, char *pResult)
return false; return false;
} }
#endif
char DTMF_GetCharacter(const unsigned int code) char DTMF_GetCharacter(const unsigned int code)
{ {
switch (code) switch (code)
@@ -155,8 +164,8 @@ char DTMF_GetCharacter(const unsigned int code)
default: return 0xff; default: return 0xff;
} }
} }
#ifdef ENABLE_DTMF_CALLING
bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, const unsigned int size, const bool bCheckGroup) static bool CompareMessage(const char *pMsg, const char *pTemplate, const unsigned int size, const bool bCheckGroup)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
@@ -181,6 +190,7 @@ DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size)
return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP; return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP;
} }
#endif
void DTMF_clear_input_box(void) void DTMF_clear_input_box(void)
{ {
@@ -201,6 +211,7 @@ void DTMF_Append(const char code)
gDTMF_InputBox[gDTMF_InputBox_Index++] = code; gDTMF_InputBox[gDTMF_InputBox_Index++] = code;
} }
#ifdef ENABLE_DTMF_CALLING
void DTMF_HandleRequest(void) void DTMF_HandleRequest(void)
{ // proccess the RX'ed DTMF characters { // proccess the RX'ed DTMF characters
@@ -231,7 +242,7 @@ void DTMF_HandleRequest(void)
Offset = gDTMF_RX_index - strlen(String); Offset = gDTMF_RX_index - strlen(String);
if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true))
{ // bugger { // bugger
if (gEeprom.PERMIT_REMOTE_KILL) if (gEeprom.PERMIT_REMOTE_KILL)
@@ -272,7 +283,7 @@ void DTMF_HandleRequest(void)
Offset = gDTMF_RX_index - strlen(String); Offset = gDTMF_RX_index - strlen(String);
if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true))
{ // shit, we're back ! { // shit, we're back !
gSetting_KILLED = false; gSetting_KILLED = false;
@@ -297,7 +308,7 @@ void DTMF_HandleRequest(void)
Offset = gDTMF_RX_index - strlen(String); Offset = gDTMF_RX_index - strlen(String);
if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true))
{ // ends with "AB" { // ends with "AB"
if (gDTMF_ReplyState != DTMF_REPLY_NONE) // 1of11 if (gDTMF_ReplyState != DTMF_REPLY_NONE) // 1of11
@@ -321,7 +332,7 @@ void DTMF_HandleRequest(void)
Offset = gDTMF_RX_index - strlen(String); Offset = gDTMF_RX_index - strlen(String);
if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), false)) if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), false))
{ // we got a response { // we got a response
gDTMF_State = DTMF_STATE_CALL_OUT_RSP; gDTMF_State = DTMF_STATE_CALL_OUT_RSP;
DTMF_clear_RX(); DTMF_clear_RX();
@@ -343,7 +354,7 @@ void DTMF_HandleRequest(void)
Offset = gDTMF_RX_index - strlen(String) - 3; Offset = gDTMF_RX_index - strlen(String) - 3;
if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true))
{ // it's for us ! { // it's for us !
gDTMF_CallState = DTMF_CALL_STATE_RECEIVED; gDTMF_CallState = DTMF_CALL_STATE_RECEIVED;
@@ -380,27 +391,33 @@ void DTMF_HandleRequest(void)
} }
} }
} }
#endif
void DTMF_Reply(void) void DTMF_Reply(void)
{ {
uint16_t Delay; uint16_t Delay;
#ifdef ENABLE_DTMF_CALLING
char String[23]; char String[23];
#endif
const char *pString = NULL; const char *pString = NULL;
switch (gDTMF_ReplyState) switch (gDTMF_ReplyState)
{ {
case DTMF_REPLY_ANI: case DTMF_REPLY_ANI:
if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF) #ifdef ENABLE_DTMF_CALLING
{ if (gDTMF_CallMode != DTMF_CALL_MODE_DTMF)
pString = gDTMF_String;
}
else
{ // append our ID code onto the end of the DTMF code to send { // append our ID code onto the end of the DTMF code to send
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, gEeprom.ANI_DTMF_ID); sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, gEeprom.ANI_DTMF_ID);
pString = String; pString = String;
} }
break; else
#endif
{
pString = gDTMF_String;
}
break;
#ifdef ENABLE_DTMF_CALLING
case DTMF_REPLY_AB: case DTMF_REPLY_AB:
pString = "AB"; pString = "AB";
break; break;
@@ -409,10 +426,13 @@ void DTMF_Reply(void)
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, "AAAAA"); sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, "AAAAA");
pString = String; pString = String;
break; break;
#endif
default: default:
case DTMF_REPLY_NONE: case DTMF_REPLY_NONE:
if (gDTMF_CallState != DTMF_CALL_STATE_NONE || if (
#ifdef ENABLE_DTMF_CALLING
gDTMF_CallState != DTMF_CALL_STATE_NONE ||
#endif
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO ||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_OFF || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_OFF ||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN) gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN)

View File

@@ -75,14 +75,15 @@ extern uint8_t gDTMF_InputBox_Index;
extern bool gDTMF_InputMode; extern bool gDTMF_InputMode;
extern uint8_t gDTMF_PreviousIndex; extern uint8_t gDTMF_PreviousIndex;
extern char gDTMF_RX_live[20];
extern uint8_t gDTMF_RX_live_timeout;
#ifdef ENABLE_DTMF_CALLING
extern char gDTMF_RX[17]; extern char gDTMF_RX[17];
extern uint8_t gDTMF_RX_index; extern uint8_t gDTMF_RX_index;
extern uint8_t gDTMF_RX_timeout; extern uint8_t gDTMF_RX_timeout;
extern bool gDTMF_RX_pending; extern bool gDTMF_RX_pending;
extern char gDTMF_RX_live[20];
extern uint8_t gDTMF_RX_live_timeout;
extern bool gIsDtmfContactValid; extern bool gIsDtmfContactValid;
extern char gDTMF_ID[4]; extern char gDTMF_ID[4];
extern char gDTMF_Caller[4]; extern char gDTMF_Caller[4];
@@ -92,21 +93,25 @@ extern uint8_t gDTMF_DecodeRingCountdown_500ms;
extern uint8_t gDTMF_chosen_contact; extern uint8_t gDTMF_chosen_contact;
extern uint8_t gDTMF_auto_reset_time_500ms; extern uint8_t gDTMF_auto_reset_time_500ms;
extern DTMF_CallState_t gDTMF_CallState; extern DTMF_CallState_t gDTMF_CallState;
extern DTMF_ReplyState_t gDTMF_ReplyState;
extern DTMF_CallMode_t gDTMF_CallMode; extern DTMF_CallMode_t gDTMF_CallMode;
extern bool gDTMF_IsTx; extern bool gDTMF_IsTx;
extern uint8_t gDTMF_TxStopCountdown_500ms; extern uint8_t gDTMF_TxStopCountdown_500ms;
#endif
extern DTMF_ReplyState_t gDTMF_ReplyState;
void DTMF_clear_RX(void);
bool DTMF_ValidateCodes(char *pCode, const unsigned int size); bool DTMF_ValidateCodes(char *pCode, const unsigned int size);
bool DTMF_GetContact(const int Index, char *pContact);
bool DTMF_FindContact(const char *pContact, char *pResult);
char DTMF_GetCharacter(const unsigned int code); char DTMF_GetCharacter(const unsigned int code);
bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, const unsigned int size, const bool bFlag);
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size);
void DTMF_clear_input_box(void); void DTMF_clear_input_box(void);
void DTMF_Append(const char vode); void DTMF_Append(const char vode);
void DTMF_HandleRequest(void);
void DTMF_Reply(void); void DTMF_Reply(void);
#ifdef ENABLE_DTMF_CALLING
void DTMF_clear_RX(void);
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size);
bool DTMF_GetContact(const int Index, char *pContact);
bool DTMF_FindContact(const char *pContact, char *pResult);
void DTMF_HandleRequest(void);
#endif
#endif #endif

181
app/fm.c
View File

@@ -47,6 +47,19 @@ bool gFM_FoundFrequency;
bool gFM_AutoScan; bool gFM_AutoScan;
uint16_t gFM_RestoreCountdown_10ms; uint16_t gFM_RestoreCountdown_10ms;
const uint8_t BUTTON_STATE_PRESSED = 1 << 0;
const uint8_t BUTTON_STATE_HELD = 1 << 1;
const uint8_t BUTTON_EVENT_PRESSED = BUTTON_STATE_PRESSED;
const uint8_t BUTTON_EVENT_HELD = BUTTON_STATE_PRESSED | BUTTON_STATE_HELD;
const uint8_t BUTTON_EVENT_SHORT = 0;
const uint8_t BUTTON_EVENT_LONG = BUTTON_STATE_HELD;
static void Key_FUNC(KEY_Code_t Key, uint8_t state);
bool FM_CheckValidChannel(uint8_t Channel) bool FM_CheckValidChannel(uint8_t Channel)
{ {
return (Channel < ARRAY_SIZE(gFM_Channels) && (gFM_Channels[Channel] >= 760 && gFM_Channels[Channel] < 1080)) ? true : false; return (Channel < ARRAY_SIZE(gFM_Channels) && (gFM_Channels[Channel] >= 760 && gFM_Channels[Channel] < 1080)) ? true : false;
@@ -223,32 +236,23 @@ Bail:
return ret; return ret;
} }
static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
{ {
#define STATE_FREQ_MODE 0 enum { STATE_FREQ_MODE, STATE_MR_MODE, STATE_SAVE };
#define STATE_MR_MODE 1
#define STATE_SAVE 2
if (!bKeyHeld && bKeyPressed) if (state == BUTTON_EVENT_SHORT && !gWasFKeyPressed) {
{
if (!gWasFKeyPressed)
{
uint8_t State; uint8_t State;
if (gAskToDelete) if (gAskToDelete) {
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
if (gAskToSave) if (gAskToSave) {
{
State = STATE_SAVE; State = STATE_SAVE;
} }
else else {
{ if (gFM_ScanState != FM_SCAN_OFF) {
if (gFM_ScanState != FM_SCAN_OFF)
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
@@ -260,59 +264,47 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
if (State == STATE_FREQ_MODE) if (State == STATE_FREQ_MODE) {
{ if (gInputBoxIndex == 1) {
if (gInputBoxIndex == 1) if (gInputBox[0] > 1) {
{
if (gInputBox[0] > 1)
{
gInputBox[1] = gInputBox[0]; gInputBox[1] = gInputBox[0];
gInputBox[0] = 0; gInputBox[0] = 0;
gInputBoxIndex = 2; gInputBoxIndex = 2;
} }
} }
else else if (gInputBoxIndex > 3) {
if (gInputBoxIndex > 3)
{
uint32_t Frequency; uint32_t Frequency;
gInputBoxIndex = 0; gInputBoxIndex = 0;
Frequency = StrToUL(INPUTBOX_GetAscii()); Frequency = StrToUL(INPUTBOX_GetAscii());
if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) {
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
return; return;
} }
gEeprom.FM_SelectedFrequency = (uint16_t)Frequency; gEeprom.FM_SelectedFrequency = (uint16_t)Frequency;
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key;
gAnotherVoiceID = (VOICE_ID_t)Key; #endif
#endif
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency; gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
gRequestSaveFM = true; gRequestSaveFM = true;
return; return;
} }
} }
else else if (gInputBoxIndex == 2) {
if (gInputBoxIndex == 2)
{
uint8_t Channel; uint8_t Channel;
gInputBoxIndex = 0; gInputBoxIndex = 0;
Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1; Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1;
if (State == STATE_MR_MODE) if (State == STATE_MR_MODE) {
{ if (FM_CheckValidChannel(Channel)) {
if (FM_CheckValidChannel(Channel)) #ifdef ENABLE_VOICE
{ gAnotherVoiceID = (VOICE_ID_t)Key;
#ifdef ENABLE_VOICE #endif
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gEeprom.FM_SelectedChannel = Channel; gEeprom.FM_SelectedChannel = Channel;
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
@@ -320,12 +312,10 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
} }
else else if (Channel < 20) {
if (Channel < 20) #ifdef ENABLE_VOICE
{ gAnotherVoiceID = (VOICE_ID_t)Key;
#ifdef ENABLE_VOICE #endif
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
gInputBoxIndex = 0; gInputBoxIndex = 0;
gFM_ChannelPosition = Channel; gFM_ChannelPosition = Channel;
@@ -336,25 +326,31 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; gAnotherVoiceID = (VOICE_ID_t)Key;
#endif #endif
}
else
Key_FUNC(Key, state);
}
return; static void Key_FUNC(KEY_Code_t Key, uint8_t state)
} {
if (state == BUTTON_EVENT_SHORT || state == BUTTON_EVENT_HELD)
{
bool autoScan = gWasFKeyPressed || (state == BUTTON_EVENT_HELD);
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gWasFKeyPressed = false; gWasFKeyPressed = false;
gUpdateStatus = true; gUpdateStatus = true;
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
switch (Key) switch (Key) {
{
case KEY_0: case KEY_0:
ACTION_FM(); ACTION_FM();
break; break;
case KEY_1: case KEY_3:
gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode; gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode;
if (!FM_ConfigureChannelState()) if (!FM_ConfigureChannelState())
@@ -366,12 +362,8 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break; break;
case KEY_2: case KEY_STAR:
ACTION_Scan(true); ACTION_Scan(autoScan);
break;
case KEY_3:
ACTION_Scan(false);
break; break;
default: default:
@@ -381,12 +373,9 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
} }
static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld) static void Key_EXIT(uint8_t state)
{ {
if (bKeyHeld) if (state != BUTTON_EVENT_SHORT)
return;
if (!bKeyPressed)
return; return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@@ -441,13 +430,11 @@ static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
} }
static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld) static void Key_MENU(uint8_t state)
{ {
if (bKeyHeld) if (state != BUTTON_EVENT_SHORT)
return; return;
if (!bKeyPressed)
return;
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@@ -501,38 +488,29 @@ static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld)
} }
} }
static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step) static void Key_UP_DOWN(uint8_t state, int8_t Step)
{ {
if (bKeyHeld || !bKeyPressed) if (state == BUTTON_EVENT_PRESSED) {
{ if (gInputBoxIndex) {
if (gInputBoxIndex)
return;
if (!bKeyPressed)
return;
}
else
{
if (gInputBoxIndex)
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
} }
else {
if (gInputBoxIndex || state!=BUTTON_EVENT_HELD)
return;
}
if (gAskToSave) if (gAskToSave) {
{
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19); gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19);
return; return;
} }
if (gFM_ScanState != FM_SCAN_OFF) if (gFM_ScanState != FM_SCAN_OFF) {
{ if (gFM_AutoScan) {
if (gFM_AutoScan)
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
@@ -542,8 +520,7 @@ static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step)
return; return;
} }
if (gEeprom.FM_IsMrMode) if (gEeprom.FM_IsMrMode) {
{
const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step); const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step);
if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel) if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel)
goto Bail; goto Bail;
@@ -551,8 +528,7 @@ static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step)
gEeprom.FM_SelectedChannel = Channel; gEeprom.FM_SelectedChannel = Channel;
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
} }
else else {
{
uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step; uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step;
if (Frequency < gEeprom.FM_LowerLimit) if (Frequency < gEeprom.FM_LowerLimit)
Frequency = gEeprom.FM_UpperLimit; Frequency = gEeprom.FM_UpperLimit;
@@ -574,6 +550,10 @@ Bail:
void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
uint8_t state = bKeyPressed + 2 * bKeyHeld;
switch (Key) switch (Key)
{ {
case KEY_0: case KEY_0:
@@ -586,19 +566,22 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case KEY_7: case KEY_7:
case KEY_8: case KEY_8:
case KEY_9: case KEY_9:
FM_Key_DIGITS(Key, bKeyPressed, bKeyHeld); Key_DIGITS(Key, state);
break; break;
case KEY_STAR:
Key_FUNC(Key, state);
break;
case KEY_MENU: case KEY_MENU:
FM_Key_MENU(bKeyPressed, bKeyHeld); Key_MENU(state);
return; return;
case KEY_UP: case KEY_UP:
FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); Key_UP_DOWN(state, 1);
break; break;
case KEY_DOWN: case KEY_DOWN:
FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); Key_UP_DOWN(state, -1);
break;; break;;
case KEY_EXIT: case KEY_EXIT:
FM_Key_EXIT(bKeyPressed, bKeyHeld); Key_EXIT(state);
break; break;
case KEY_F: case KEY_F:
GENERIC_Key_F(bKeyPressed, bKeyHeld); GENERIC_Key_F(bKeyPressed, bKeyHeld);

View File

@@ -184,6 +184,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
if (!gDTMF_InputMode && gDTMF_InputBox_Index == 0) if (!gDTMF_InputMode && gDTMF_InputBox_Index == 0)
goto start_tx; // wasn't entering a DTMF code .. start TX'ing (maybe) goto start_tx; // wasn't entering a DTMF code .. start TX'ing (maybe)
@@ -198,6 +199,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
if (gDTMF_InputBox_Index < sizeof(gDTMF_InputBox)) if (gDTMF_InputBox_Index < sizeof(gDTMF_InputBox))
gDTMF_InputBox[gDTMF_InputBox_Index] = 0; // NULL term the string gDTMF_InputBox[gDTMF_InputBox_Index] = 0; // NULL term the string
#ifdef ENABLE_DTMF_CALLING
// append our DTMF ID to the inputted DTMF code - // append our DTMF ID to the inputted DTMF code -
// IF the user inputted code is exactly 3 digits long and D-DCD is enabled // IF the user inputted code is exactly 3 digits long and D-DCD is enabled
if (gDTMF_InputBox_Index == 3 && gTxVfo->DTMF_DECODING_ENABLE > 0) if (gDTMF_InputBox_Index == 3 && gTxVfo->DTMF_DECODING_ENABLE > 0)
@@ -205,12 +207,12 @@ void GENERIC_Key_PTT(bool bKeyPressed)
else else
gDTMF_CallMode = DTMF_CALL_MODE_DTMF; gDTMF_CallMode = DTMF_CALL_MODE_DTMF;
gDTMF_State = DTMF_STATE_0;
#endif
// remember the DTMF string // remember the DTMF string
gDTMF_PreviousIndex = gDTMF_InputBox_Index; gDTMF_PreviousIndex = gDTMF_InputBox_Index;
strcpy(gDTMF_String, gDTMF_InputBox); strcpy(gDTMF_String, gDTMF_InputBox);
gDTMF_ReplyState = DTMF_REPLY_ANI; gDTMF_ReplyState = DTMF_REPLY_ANI;
gDTMF_State = DTMF_STATE_0;
} }
DTMF_clear_input_box(); DTMF_clear_input_box();

View File

@@ -46,9 +46,16 @@
void toggle_chan_scanlist(void) void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting { // toggle the selected channels scanlist setting
if ( SCANNER_IsScanning() || !IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) if ( SCANNER_IsScanning())
return; return;
if(!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
#ifdef ENABLE_SCAN_RANGES
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
#endif
return;
}
if (gTxVfo->SCANLIST1_PARTICIPATION) if (gTxVfo->SCANLIST1_PARTICIPATION)
{ {
if (gTxVfo->SCANLIST2_PARTICIPATION) if (gTxVfo->SCANLIST2_PARTICIPATION)
@@ -480,12 +487,14 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT) if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT)
{ // clear CALL mode being displayed { // clear CALL mode being displayed
gDTMF_CallState = DTMF_CALL_STATE_NONE; gDTMF_CallState = DTMF_CALL_STATE_NONE;
gUpdateDisplay = true; gUpdateDisplay = true;
return; return;
} }
#endif
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (!gFmRadioMode) if (!gFmRadioMode)

View File

@@ -244,7 +244,9 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_S_ADD2: case MENU_S_ADD2:
case MENU_STE: case MENU_STE:
case MENU_D_ST: case MENU_D_ST:
#ifdef ENABLE_DTMF_CALLING
case MENU_D_DCD: case MENU_D_DCD:
#endif
case MENU_D_LIVE_DEC: case MENU_D_LIVE_DEC:
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
case MENU_NOAA_S: case MENU_NOAA_S:
@@ -309,12 +311,13 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
*pMin = 0; *pMin = 0;
*pMax = 2; *pMax = 2;
break; break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_RSP: case MENU_D_RSP:
*pMin = 0; *pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_D_RSP) - 1; *pMax = ARRAY_SIZE(gSubMenu_D_RSP) - 1;
break; break;
#endif
case MENU_PTT_ID: case MENU_PTT_ID:
*pMin = 0; *pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_PTT_ID) - 1; *pMax = ARRAY_SIZE(gSubMenu_PTT_ID) - 1;
@@ -325,21 +328,23 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
*pMax = ARRAY_SIZE(gSubMenu_BAT_TXT) - 1; *pMax = ARRAY_SIZE(gSubMenu_BAT_TXT) - 1;
break; break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_HOLD: case MENU_D_HOLD:
*pMin = 5; *pMin = 5;
*pMax = 60; *pMax = 60;
break; break;
#endif
case MENU_D_PRE: case MENU_D_PRE:
*pMin = 3; *pMin = 3;
*pMax = 99; *pMax = 99;
break; break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_LIST: case MENU_D_LIST:
*pMin = 1; *pMin = 1;
*pMax = 16; *pMax = 16;
break; break;
#endif
#ifdef ENABLE_F_CAL_MENU #ifdef ENABLE_F_CAL_MENU
case MENU_F_CALI: case MENU_F_CALI:
*pMin = -50; *pMin = -50;
@@ -661,6 +666,7 @@ void MENU_AcceptSetting(void)
gEeprom.DTMF_SIDE_TONE = gSubMenuSelection; gEeprom.DTMF_SIDE_TONE = gSubMenuSelection;
break; break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_RSP: case MENU_D_RSP:
gEeprom.DTMF_DECODE_RESPONSE = gSubMenuSelection; gEeprom.DTMF_DECODE_RESPONSE = gSubMenuSelection;
break; break;
@@ -668,7 +674,7 @@ void MENU_AcceptSetting(void)
case MENU_D_HOLD: case MENU_D_HOLD:
gEeprom.DTMF_auto_reset_time = gSubMenuSelection; gEeprom.DTMF_auto_reset_time = gSubMenuSelection;
break; break;
#endif
case MENU_D_PRE: case MENU_D_PRE:
gEeprom.DTMF_PRELOAD_TIME = gSubMenuSelection * 10; gEeprom.DTMF_PRELOAD_TIME = gSubMenuSelection * 10;
break; break;
@@ -682,11 +688,13 @@ void MENU_AcceptSetting(void)
gSetting_battery_text = gSubMenuSelection; gSetting_battery_text = gSubMenuSelection;
break; break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_DCD: case MENU_D_DCD:
gTxVfo->DTMF_DECODING_ENABLE = gSubMenuSelection; gTxVfo->DTMF_DECODING_ENABLE = gSubMenuSelection;
DTMF_clear_RX(); DTMF_clear_RX();
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
#endif
case MENU_D_LIVE_DEC: case MENU_D_LIVE_DEC:
gSetting_live_DTMF_decoder = gSubMenuSelection; gSetting_live_DTMF_decoder = gSubMenuSelection;
@@ -698,6 +706,7 @@ void MENU_AcceptSetting(void)
gUpdateStatus = true; gUpdateStatus = true;
break; break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_LIST: case MENU_D_LIST:
gDTMF_chosen_contact = gSubMenuSelection - 1; gDTMF_chosen_contact = gSubMenuSelection - 1;
if (gIsDtmfContactValid) if (gIsDtmfContactValid)
@@ -709,7 +718,7 @@ void MENU_AcceptSetting(void)
gRequestDisplayScreen = DISPLAY_INVALID; gRequestDisplayScreen = DISPLAY_INVALID;
} }
return; return;
#endif
case MENU_PONMSG: case MENU_PONMSG:
gEeprom.POWER_ON_DISPLAY_MODE = gSubMenuSelection; gEeprom.POWER_ON_DISPLAY_MODE = gSubMenuSelection;
break; break;
@@ -1064,6 +1073,7 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gEeprom.DTMF_SIDE_TONE; gSubMenuSelection = gEeprom.DTMF_SIDE_TONE;
break; break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_RSP: case MENU_D_RSP:
gSubMenuSelection = gEeprom.DTMF_DECODE_RESPONSE; gSubMenuSelection = gEeprom.DTMF_DECODE_RESPONSE;
break; break;
@@ -1071,7 +1081,7 @@ void MENU_ShowCurrentSetting(void)
case MENU_D_HOLD: case MENU_D_HOLD:
gSubMenuSelection = gEeprom.DTMF_auto_reset_time; gSubMenuSelection = gEeprom.DTMF_auto_reset_time;
break; break;
#endif
case MENU_D_PRE: case MENU_D_PRE:
gSubMenuSelection = gEeprom.DTMF_PRELOAD_TIME / 10; gSubMenuSelection = gEeprom.DTMF_PRELOAD_TIME / 10;
break; break;
@@ -1084,6 +1094,7 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gSetting_battery_text; gSubMenuSelection = gSetting_battery_text;
return; return;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_DCD: case MENU_D_DCD:
gSubMenuSelection = gTxVfo->DTMF_DECODING_ENABLE; gSubMenuSelection = gTxVfo->DTMF_DECODING_ENABLE;
break; break;
@@ -1091,7 +1102,7 @@ void MENU_ShowCurrentSetting(void)
case MENU_D_LIST: case MENU_D_LIST:
gSubMenuSelection = gDTMF_chosen_contact + 1; gSubMenuSelection = gDTMF_chosen_contact + 1;
break; break;
#endif
case MENU_D_LIVE_DEC: case MENU_D_LIVE_DEC:
gSubMenuSelection = gSetting_live_DTMF_decoder; gSubMenuSelection = gSetting_live_DTMF_decoder;
break; break;

View File

@@ -347,7 +347,9 @@ void SCANNER_Start(bool singleFreq)
gUpdateStatus = true; gUpdateStatus = true;
} }
#ifdef ENABLE_DTMF_CALLING
DTMF_clear_RX(); DTMF_clear_RX();
#endif
gScanDelay_10ms = scan_delay_10ms; gScanDelay_10ms = scan_delay_10ms;
gScanCssResultCode = 0xFF; gScanCssResultCode = 0xFF;

View File

@@ -17,6 +17,7 @@
#include "app/spectrum.h" #include "app/spectrum.h"
#include "driver/backlight.h" #include "driver/backlight.h"
#include "audio.h" #include "audio.h"
#include "ui/helper.h"
struct FrequencyBandInfo { struct FrequencyBandInfo {
uint32_t lower; uint32_t lower;
@@ -125,21 +126,13 @@ static void SetRegMenuValue(uint8_t st, bool add) {
// GUI functions // GUI functions
static void PutPixel(uint8_t x, uint8_t y, bool fill) { static void PutPixel(uint8_t x, uint8_t y, bool fill) {
if (fill) { UI_DrawPixelBuffer(gFrameBuffer, x, y, fill);
gFrameBuffer[y >> 3][x] |= 1 << (y & 7);
} else {
gFrameBuffer[y >> 3][x] &= ~(1 << (y & 7));
}
} }
static void PutPixelStatus(uint8_t x, uint8_t y, bool fill) { static void PutPixelStatus(uint8_t x, uint8_t y, bool fill) {
if (fill) { UI_DrawPixelBuffer(&gStatusLine, x, y, fill);
gStatusLine[x] |= 1 << y;
} else {
gStatusLine[x] &= ~(1 << y);
}
} }
static void DrawHLine(int sy, int ey, int nx, bool fill) { static void DrawVLine(int sy, int ey, int nx, bool fill) {
for (int i = sy; i <= ey; i++) { for (int i = sy; i <= ey; i++) {
if (i < 56 && nx < 128) { if (i < 56 && nx < 128) {
PutPixel(nx, i, fill); PutPixel(nx, i, fill);
@@ -541,6 +534,8 @@ static void UpdateFreqInput(KEY_Code_t key) {
} }
if (key == KEY_EXIT) { if (key == KEY_EXIT) {
freqInputIndex--; freqInputIndex--;
if(freqInputDotIndex==freqInputIndex)
freqInputDotIndex = 0;
} else { } else {
freqInputArr[freqInputIndex++] = key; freqInputArr[freqInputIndex++] = key;
} }
@@ -606,7 +601,7 @@ static void DrawSpectrum() {
for (uint8_t x = 0; x < 128; ++x) { for (uint8_t x = 0; x < 128; ++x) {
uint16_t rssi = rssiHistory[x >> settings.stepsCount]; uint16_t rssi = rssiHistory[x >> settings.stepsCount];
if (rssi != RSSI_MAX_VALUE) { if (rssi != RSSI_MAX_VALUE) {
DrawHLine(Rssi2Y(rssi), DrawingEndY, x, true); DrawVLine(Rssi2Y(rssi), DrawingEndY, x, true);
} }
} }
} }
@@ -620,36 +615,28 @@ static void DrawStatus() {
#endif #endif
GUI_DisplaySmallest(String, 0, 1, true, true); GUI_DisplaySmallest(String, 0, 1, true, true);
for (int i = 0; i < 4; i++) { BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryCheckCounter++ % 4], &gBatteryCurrent);
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent);
}
uint16_t Voltage; uint16_t voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] +
uint8_t v = 0;
Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] +
gBatteryVoltages[3]) / gBatteryVoltages[3]) /
4; 4 * 760 / gBatteryCalibration[3];
for(uint8_t i = 5; i > 0; i--) { unsigned perc = BATTERY_VoltsToPercent(voltage);
if(Voltage > gBatteryCalibration[i - 1]) {
v = i;
break;
}
}
gStatusLine[127] = 0b01111110; // sprintf(String, "%d %d", voltage, perc);
for (int i = 126; i >= 116; i--) { // GUI_DisplaySmallest(String, 48, 1, true, true);
gStatusLine[i] = 0b01000010;
gStatusLine[116] = 0b00011100;
gStatusLine[117] = 0b00111110;
for (int i = 118; i <= 126; i++) {
gStatusLine[i] = 0b00100010;
} }
v <<= 1;
for (int i = 125; i >= 116; i--) { for (unsigned i = 127; i >= 118; i--) {
if (126 - i <= v) { if (127 - i <= (perc+5)*9/100) {
gStatusLine[i + 2] = 0b01111110; gStatusLine[i] = 0b00111110;
} }
} }
gStatusLine[117] = 0b01111110;
gStatusLine[116] = 0b00011000;
} }
static void DrawF(uint32_t f) { static void DrawF(uint32_t f) {
@@ -712,19 +699,13 @@ static void DrawTicks() {
// center // center
if (IsCenterMode()) { if (IsCenterMode()) {
gFrameBuffer[5][62] = 0x80; memset(gFrameBuffer[5] + 62, 0x80, 5);
gFrameBuffer[5][63] = 0x80;
gFrameBuffer[5][64] = 0xff; gFrameBuffer[5][64] = 0xff;
gFrameBuffer[5][65] = 0x80;
gFrameBuffer[5][66] = 0x80;
} else { } else {
memset(gFrameBuffer[5] + 1, 0x80, 3);
memset(gFrameBuffer[5] + 124, 0x80, 3);
gFrameBuffer[5][0] = 0xff; gFrameBuffer[5][0] = 0xff;
gFrameBuffer[5][1] = 0x80;
gFrameBuffer[5][2] = 0x80;
gFrameBuffer[5][3] = 0x80;
gFrameBuffer[5][124] = 0x80;
gFrameBuffer[5][125] = 0x80;
gFrameBuffer[5][126] = 0x80;
gFrameBuffer[5][127] = 0xff; gFrameBuffer[5][127] = 0xff;
} }
} }
@@ -1017,17 +998,18 @@ bool HandleUserInput() {
kbd.prev = kbd.current; kbd.prev = kbd.current;
kbd.current = GetKey(); kbd.current = GetKey();
if (kbd.current == KEY_INVALID) { if (kbd.current != KEY_INVALID && kbd.current == kbd.prev) {
kbd.counter = 0; if(kbd.counter < 16)
return true; kbd.counter++;
} else
kbd.counter-=3;
if (kbd.current == kbd.prev && kbd.counter <= 16) {
kbd.counter++;
SYSTEM_DelayMs(20); SYSTEM_DelayMs(20);
} }
else {
kbd.counter = 0;
}
if (kbd.counter == 3 || kbd.counter > 16) { if (kbd.counter == 3 || kbd.counter == 16) {
switch (currentState) { switch (currentState) {
case SPECTRUM: case SPECTRUM:
OnKeyDown(kbd.current); OnKeyDown(kbd.current);

View File

@@ -400,7 +400,9 @@ static void CMD_052F(const uint8_t *pBuffer)
gEeprom.VfoInfo[0].pTX = &gEeprom.VfoInfo[0].freq_config_TX; gEeprom.VfoInfo[0].pTX = &gEeprom.VfoInfo[0].freq_config_TX;
gEeprom.VfoInfo[0].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF; gEeprom.VfoInfo[0].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF;
gEeprom.VfoInfo[0].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF; gEeprom.VfoInfo[0].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF;
#ifdef ENABLE_DTMF_CALLING
gEeprom.VfoInfo[0].DTMF_DECODING_ENABLE = false; gEeprom.VfoInfo[0].DTMF_DECODING_ENABLE = false;
#endif
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
gIsNoaaMode = false; gIsNoaaMode = false;

20
board.c
View File

@@ -623,10 +623,13 @@ void BOARD_EEPROM_Init(void)
// 0ED0..0ED7 // 0ED0..0ED7
EEPROM_ReadBuffer(0x0ED0, Data, 8); EEPROM_ReadBuffer(0x0ED0, Data, 8);
gEeprom.DTMF_SIDE_TONE = (Data[0] < 2) ? Data[0] : true; gEeprom.DTMF_SIDE_TONE = (Data[0] < 2) ? Data[0] : true;
#ifdef ENABLE_DTMF_CALLING
gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*'; gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*';
gEeprom.DTMF_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#'; gEeprom.DTMF_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#';
gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0; gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0;
gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 5) ? Data[4] : 10; gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 5) ? Data[4] : 10;
#endif
gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300; gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300;
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 100; gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 100;
gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100; gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100;
@@ -635,9 +638,11 @@ void BOARD_EEPROM_Init(void)
EEPROM_ReadBuffer(0x0ED8, Data, 8); EEPROM_ReadBuffer(0x0ED8, Data, 8);
gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 10 : 100; gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 10 : 100;
gEeprom.DTMF_CODE_INTERVAL_TIME = (Data[1] < 101) ? Data[1] * 10 : 100; gEeprom.DTMF_CODE_INTERVAL_TIME = (Data[1] < 101) ? Data[1] * 10 : 100;
#ifdef ENABLE_DTMF_CALLING
gEeprom.PERMIT_REMOTE_KILL = (Data[2] < 2) ? Data[2] : true; gEeprom.PERMIT_REMOTE_KILL = (Data[2] < 2) ? Data[2] : true;
// 0EE0..0EE7 // 0EE0..0EE7
EEPROM_ReadBuffer(0x0EE0, Data, 8); EEPROM_ReadBuffer(0x0EE0, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(gEeprom.ANI_DTMF_ID, Data, 8); memmove(gEeprom.ANI_DTMF_ID, Data, 8);
@@ -646,7 +651,8 @@ void BOARD_EEPROM_Init(void)
memset(gEeprom.ANI_DTMF_ID, 0, sizeof(gEeprom.ANI_DTMF_ID)); memset(gEeprom.ANI_DTMF_ID, 0, sizeof(gEeprom.ANI_DTMF_ID));
strcpy(gEeprom.ANI_DTMF_ID, "123"); strcpy(gEeprom.ANI_DTMF_ID, "123");
} }
// 0EE8..0EEF // 0EE8..0EEF
EEPROM_ReadBuffer(0x0EE8, Data, 8); EEPROM_ReadBuffer(0x0EE8, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
@@ -666,7 +672,8 @@ void BOARD_EEPROM_Init(void)
memset(gEeprom.REVIVE_CODE, 0, sizeof(gEeprom.REVIVE_CODE)); memset(gEeprom.REVIVE_CODE, 0, sizeof(gEeprom.REVIVE_CODE));
strcpy(gEeprom.REVIVE_CODE, "9DCBA"); strcpy(gEeprom.REVIVE_CODE, "9DCBA");
} }
#endif
// 0EF8..0F07 // 0EF8..0F07
EEPROM_ReadBuffer(0x0EF8, Data, 16); EEPROM_ReadBuffer(0x0EF8, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16)) if (DTMF_ValidateCodes((char *)Data, 16))
@@ -703,7 +710,9 @@ void BOARD_EEPROM_Init(void)
EEPROM_ReadBuffer(0x0F40, Data, 8); EEPROM_ReadBuffer(0x0F40, Data, 8);
gSetting_F_LOCK = (Data[0] < F_LOCK_LEN) ? Data[0] : F_LOCK_DEF; gSetting_F_LOCK = (Data[0] < F_LOCK_LEN) ? Data[0] : F_LOCK_DEF;
gSetting_350TX = (Data[1] < 2) ? Data[1] : false; // was true gSetting_350TX = (Data[1] < 2) ? Data[1] : false; // was true
#ifdef ENABLE_DTMF_CALLING
gSetting_KILLED = (Data[2] < 2) ? Data[2] : false; gSetting_KILLED = (Data[2] < 2) ? Data[2] : false;
#endif
gSetting_200TX = (Data[3] < 2) ? Data[3] : false; gSetting_200TX = (Data[3] < 2) ? Data[3] : false;
gSetting_500TX = (Data[4] < 2) ? Data[4] : false; gSetting_500TX = (Data[4] < 2) ? Data[4] : false;
gSetting_350EN = (Data[5] < 2) ? Data[5] : true; gSetting_350EN = (Data[5] < 2) ? Data[5] : true;
@@ -727,6 +736,13 @@ void BOARD_EEPROM_Init(void)
// 0D60..0E27 // 0D60..0E27
EEPROM_ReadBuffer(0x0D60, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes)); EEPROM_ReadBuffer(0x0D60, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes));
for(uint16_t i = 0; i < sizeof(gMR_ChannelAttributes); i++) {
ChannelAttributes_t *att = &gMR_ChannelAttributes[i];
if(att->__val == 0xff){
att->__val = 0;
att->band = 0xf;
}
}
// 0F30..0F3F // 0F30..0F3F
EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey)); EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey));

View File

@@ -1,4 +1,4 @@
@echo off @echo off
docker build -t uvk5 . docker build -t uvk5 .
docker run -v %CD%\compiled-firmware:/app/compiled-firmware uvk5 /bin/bash -c "cd /app && make clean && make && cp firmware* compiled-firmware/" docker run --rm -v %CD%\compiled-firmware:/app/compiled-firmware uvk5 /bin/bash -c "cd /app && make clean && make && cp firmware* compiled-firmware/"
pause pause

View File

@@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
docker build -t uvk5 . docker build -t uvk5 .
docker run -v ${PWD}/compiled-firmware:/app/compiled-firmware uvk5 /bin/bash -c "cd /app && make && cp firmware* compiled-firmware/" docker run --rm -v ${PWD}/compiled-firmware:/app/compiled-firmware uvk5 /bin/bash -c "cd /app && make && cp firmware* compiled-firmware/"

View File

@@ -30,6 +30,9 @@
static const uint16_t FSK_RogerTable[7] = {0xF1A2, 0x7446, 0x61A4, 0x6544, 0x4E8A, 0xE044, 0xEA84}; static const uint16_t FSK_RogerTable[7] = {0xF1A2, 0x7446, 0x61A4, 0x6544, 0x4E8A, 0xE044, 0xEA84};
static const uint8_t DTMF_TONE1_GAIN = 65;
static const uint8_t DTMF_TONE2_GAIN = 93;
static uint16_t gBK4819_GpioOutState; static uint16_t gBK4819_GpioOutState;
bool gRxIdleMode; bool gRxIdleMode;
@@ -984,15 +987,15 @@ void BK4819_EnableDTMF(void)
void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch) void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch)
{ {
uint16_t ToneConfig; uint16_t ToneConfig = BK4819_REG_70_ENABLE_TONE1;
BK4819_EnterTxMute(); BK4819_EnterTxMute();
BK4819_SetAF(BK4819_AF_BEEP); BK4819_SetAF(BK4819_AF_BEEP);
if (bTuningGainSwitch == 0) if (bTuningGainSwitch == 0)
ToneConfig = BK4819_REG_70_ENABLE_TONE1 | (96u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN); ToneConfig |= 96u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN;
else else
ToneConfig = BK4819_REG_70_ENABLE_TONE1 | (28u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN); ToneConfig |= 28u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN;
BK4819_WriteRegister(BK4819_REG_70, ToneConfig); BK4819_WriteRegister(BK4819_REG_70, ToneConfig);
BK4819_WriteRegister(BK4819_REG_30, 0); BK4819_WriteRegister(BK4819_REG_30, 0);
@@ -1001,6 +1004,7 @@ void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch)
BK4819_WriteRegister(BK4819_REG_71, scale_freq(Frequency)); BK4819_WriteRegister(BK4819_REG_71, scale_freq(Frequency));
} }
// level 0 ~ 127
void BK4819_PlaySingleTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level, const bool play_speaker) void BK4819_PlaySingleTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level, const bool play_speaker)
{ {
BK4819_EnterTxMute(); BK4819_EnterTxMute();
@@ -1013,9 +1017,7 @@ void BK4819_PlaySingleTone(const unsigned int tone_Hz, const unsigned int delay,
else else
BK4819_SetAF(BK4819_AF_MUTE); BK4819_SetAF(BK4819_AF_MUTE);
// level 0 ~ 127
// BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_ENABLE_TONE1 | (96u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
// BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_ENABLE_TONE1 | (28u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)); BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_EnableTXLink(); BK4819_EnableTXLink();
@@ -1209,9 +1211,9 @@ void BK4819_EnterDTMF_TX(bool bLocalLoopback)
BK4819_WriteRegister(BK4819_REG_70, BK4819_WriteRegister(BK4819_REG_70,
BK4819_REG_70_MASK_ENABLE_TONE1 | BK4819_REG_70_MASK_ENABLE_TONE1 |
(83u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN) | (DTMF_TONE1_GAIN << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN) |
BK4819_REG_70_MASK_ENABLE_TONE2 | BK4819_REG_70_MASK_ENABLE_TONE2 |
(83u << BK4819_REG_70_SHIFT_TONE2_TUNING_GAIN)); (DTMF_TONE2_GAIN << BK4819_REG_70_SHIFT_TONE2_TUNING_GAIN));
BK4819_EnableTXLink(); BK4819_EnableTXLink();
} }
@@ -1250,16 +1252,16 @@ void BK4819_PlayDTMF(char Code)
switch (Code) switch (Code)
{ {
case '0': tone1 = 941; tone2 = 1336; break; case '0': tone1 = 941; tone2 = 1336; break;
case '1': tone1 = 679; tone2 = 1209; break; case '1': tone1 = 697; tone2 = 1209; break;
case '2': tone1 = 697; tone2 = 1336; break; case '2': tone1 = 697; tone2 = 1336; break;
case '3': tone1 = 679; tone2 = 1477; break; case '3': tone1 = 697; tone2 = 1477; break;
case '4': tone1 = 770; tone2 = 1209; break; case '4': tone1 = 770; tone2 = 1209; break;
case '5': tone1 = 770; tone2 = 1336; break; case '5': tone1 = 770; tone2 = 1336; break;
case '6': tone1 = 770; tone2 = 1477; break; case '6': tone1 = 770; tone2 = 1477; break;
case '7': tone1 = 852; tone2 = 1209; break; case '7': tone1 = 852; tone2 = 1209; break;
case '8': tone1 = 852; tone2 = 1336; break; case '8': tone1 = 852; tone2 = 1336; break;
case '9': tone1 = 852; tone2 = 1477; break; case '9': tone1 = 852; tone2 = 1477; break;
case 'A': tone1 = 679; tone2 = 1633; break; case 'A': tone1 = 697; tone2 = 1633; break;
case 'B': tone1 = 770; tone2 = 1633; break; case 'B': tone1 = 770; tone2 = 1633; break;
case 'C': tone1 = 852; tone2 = 1633; break; case 'C': tone1 = 852; tone2 = 1633; break;
case 'D': tone1 = 941; tone2 = 1633; break; case 'D': tone1 = 941; tone2 = 1633; break;
@@ -1320,8 +1322,7 @@ void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency)
// //
// set the tone amplitude // set the tone amplitude
// //
// BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_MASK_ENABLE_TONE1 | (96u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)); BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_MASK_ENABLE_TONE1 | (66u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_MASK_ENABLE_TONE1 | (28u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_WriteRegister(BK4819_REG_71, scale_freq(Frequency)); BK4819_WriteRegister(BK4819_REG_71, scale_freq(Frequency));
@@ -1700,8 +1701,7 @@ void BK4819_PlayRoger(void)
BK4819_EnterTxMute(); BK4819_EnterTxMute();
BK4819_SetAF(BK4819_AF_MUTE); BK4819_SetAF(BK4819_AF_MUTE);
// BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_ENABLE_TONE1 | (96u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)); BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_ENABLE_TONE1 | (66u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_ENABLE_TONE1 | (28u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_EnableTXLink(); BK4819_EnableTXLink();
SYSTEM_DelayMs(50); SYSTEM_DelayMs(50);
@@ -1782,7 +1782,12 @@ void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code)
BK4819_EnterTxMute(); BK4819_EnterTxMute();
BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE); BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE);
BK4819_WriteRegister(BK4819_REG_70, 0xD3D3);
BK4819_WriteRegister(BK4819_REG_70,
BK4819_REG_70_MASK_ENABLE_TONE1 |
(DTMF_TONE1_GAIN << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN) |
BK4819_REG_70_MASK_ENABLE_TONE2 |
(DTMF_TONE2_GAIN << BK4819_REG_70_SHIFT_TONE2_TUNING_GAIN));
BK4819_EnableTXLink(); BK4819_EnableTXLink();

View File

@@ -116,23 +116,17 @@ uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t T
return TxpMid; return TxpMid;
} }
static int32_t rnd(int32_t freq, uint16_t step)
{
if(step == 1)
return freq;
return (freq + (step + 1) / 2) / step * step;
}
uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step) uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step)
{ {
if(step == 833) { if(step == 833) {
uint32_t base = freq/2500*2500; uint32_t base = freq/2500*2500;
int f = rnd(freq - base, step); int chno = (freq - base) / 700; // convert entered aviation 8.33Khz channel number scheme to actual frequency.
int x = f / step; return base + (chno * 833) + (chno == 3);
return base + f + (x == 3);
} }
if(step == 1)
return rnd(freq, step); return freq;
return (freq + (step + 1) / 2) / step * step;
} }
int TX_freq_check(const uint32_t Frequency) int TX_freq_check(const uint32_t Frequency)

View File

@@ -55,7 +55,9 @@ void FUNCTION_Init(void)
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE; gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
#endif #endif
#ifdef ENABLE_DTMF_CALLING
DTMF_clear_RX(); DTMF_clear_RX();
#endif
g_CxCSS_TAIL_Found = false; g_CxCSS_TAIL_Found = false;
g_CDCSS_Lost = false; g_CDCSS_Lost = false;
@@ -99,9 +101,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
switch (Function) switch (Function)
{ {
case FUNCTION_FOREGROUND: case FUNCTION_FOREGROUND:
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_ReplyState != DTMF_REPLY_NONE) if (gDTMF_ReplyState != DTMF_REPLY_NONE)
RADIO_PrepareCssTX(); RADIO_PrepareCssTX();
#endif
if (PreviousFunction == FUNCTION_TRANSMIT) if (PreviousFunction == FUNCTION_TRANSMIT)
{ {
ST7565_FixInterfGlitch(); ST7565_FixInterfGlitch();
@@ -116,14 +119,15 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
if (gFmRadioMode) if (gFmRadioMode)
gFM_RestoreCountdown_10ms = fm_restore_countdown_10ms; gFM_RestoreCountdown_10ms = fm_restore_countdown_10ms;
#endif #endif
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT ||
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED ||
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY)
{ {
gDTMF_auto_reset_time_500ms = gEeprom.DTMF_auto_reset_time * 2; gDTMF_auto_reset_time_500ms = gEeprom.DTMF_auto_reset_time * 2;
} }
#endif
gUpdateStatus = true; gUpdateStatus = true;
return; return;
@@ -160,8 +164,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
// if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11 // if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11
BK4819_DisableDTMF(); BK4819_DisableDTMF();
#ifdef ENABLE_DTMF_CALLING
// clear the DTMF RX buffer // clear the DTMF RX buffer
DTMF_clear_RX(); DTMF_clear_RX();
#endif
// clear the DTMF RX live decoder buffer // clear the DTMF RX live decoder buffer
gDTMF_RX_live_timeout = 0; gDTMF_RX_live_timeout = 0;

View File

@@ -21,11 +21,10 @@ def obfuscate(fw):
return bytes([a^b for a, b in zip(fw, cycle(OBFUSCATION))]) return bytes([a^b for a, b in zip(fw, cycle(OBFUSCATION))])
plain = open(sys.argv[1], 'rb').read() plain = open(sys.argv[1], 'rb').read()
if len(sys.argv[2]) > 10:
print('Version suffix is too big!')
sys.exit(1)
version = b'*OEFW-' + bytes(sys.argv[2], 'ascii') version = b'*' + bytes(sys.argv[2], 'ascii') + b' ' + bytes(sys.argv[3], 'ascii')
version = version[0:16]
if len(version) < 16: if len(version) < 16:
version += b'\x00' * (16 - len(version)) version += b'\x00' * (16 - len(version))
@@ -36,5 +35,5 @@ crc.update(packed)
digest = crc.digest() digest = crc.digest()
digest = bytes([digest[1], digest[0]]) digest = bytes([digest[1], digest[0]])
open(sys.argv[3], 'wb').write(packed + digest) open(sys.argv[4], 'wb').write(packed + digest)

6
misc.c
View File

@@ -30,9 +30,11 @@ const uint8_t menu_timeout_500ms = 20000 / 500; // 20 second
const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes
const uint8_t DTMF_RX_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen const uint8_t DTMF_RX_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen
#ifdef ENABLE_DTMF_CALLING
const uint8_t DTMF_RX_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver const uint8_t DTMF_RX_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver
const uint8_t DTMF_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for const uint8_t DTMF_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for
const uint8_t DTMF_txstop_countdown_500ms = 3000 / 500; // 6 seconds const uint8_t DTMF_txstop_countdown_500ms = 3000 / 500; // 6 seconds
#endif
const uint8_t key_input_timeout_500ms = 8000 / 500; // 8 seconds const uint8_t key_input_timeout_500ms = 8000 / 500; // 8 seconds
@@ -78,7 +80,9 @@ const uint32_t gDefaultAesKey[4] = {0x4AA5CC60, 0x0312CC5F, 0x
const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31}; const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31};
bool gSetting_350TX; bool gSetting_350TX;
#ifdef ENABLE_DTMF_CALLING
bool gSetting_KILLED; bool gSetting_KILLED;
#endif
bool gSetting_200TX; bool gSetting_200TX;
bool gSetting_500TX; bool gSetting_500TX;
bool gSetting_350EN; bool gSetting_350EN;
@@ -111,7 +115,7 @@ uint16_t gEEPROM_RSSI_CALIB[7][4];
uint16_t gEEPROM_1F8A; uint16_t gEEPROM_1F8A;
uint16_t gEEPROM_1F8C; uint16_t gEEPROM_1F8C;
uint8_t gMR_ChannelAttributes[FREQ_CHANNEL_LAST + 1]; ChannelAttributes_t gMR_ChannelAttributes[FREQ_CHANNEL_LAST + 1];
volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms; volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms;

17
misc.h
View File

@@ -93,9 +93,11 @@ extern const uint8_t menu_timeout_500ms;
extern const uint16_t menu_timeout_long_500ms; extern const uint16_t menu_timeout_long_500ms;
extern const uint8_t DTMF_RX_live_timeout_500ms; extern const uint8_t DTMF_RX_live_timeout_500ms;
#ifdef ENABLE_DTMF_CALLING
extern const uint8_t DTMF_RX_timeout_500ms; extern const uint8_t DTMF_RX_timeout_500ms;
extern const uint8_t DTMF_decode_ring_countdown_500ms; extern const uint8_t DTMF_decode_ring_countdown_500ms;
extern const uint8_t DTMF_txstop_countdown_500ms; extern const uint8_t DTMF_txstop_countdown_500ms;
#endif
extern const uint8_t key_input_timeout_500ms; extern const uint8_t key_input_timeout_500ms;
@@ -142,7 +144,9 @@ extern const uint16_t scan_pause_delay_in_7_10ms;
extern const uint8_t gMicGain_dB2[5]; extern const uint8_t gMicGain_dB2[5];
extern bool gSetting_350TX; extern bool gSetting_350TX;
#ifdef ENABLE_DTMF_CALLING
extern bool gSetting_KILLED; extern bool gSetting_KILLED;
#endif
extern bool gSetting_200TX; extern bool gSetting_200TX;
extern bool gSetting_500TX; extern bool gSetting_500TX;
extern bool gSetting_350EN; extern bool gSetting_350EN;
@@ -176,7 +180,18 @@ extern uint16_t gEEPROM_RSSI_CALIB[7][4];
extern uint16_t gEEPROM_1F8A; extern uint16_t gEEPROM_1F8A;
extern uint16_t gEEPROM_1F8C; extern uint16_t gEEPROM_1F8C;
extern uint8_t gMR_ChannelAttributes[207]; typedef union {
struct {
uint8_t
band : 4,
compander : 2,
scanlist2 : 1,
scanlist1 : 1;
};
uint8_t __val;
} ChannelAttributes_t;
extern ChannelAttributes_t gMR_ChannelAttributes[207];
extern volatile uint16_t gBatterySaveCountdown_10ms; extern volatile uint16_t gBatterySaveCountdown_10ms;

349
radio.c
View File

@@ -56,24 +56,22 @@ const char gModulationStr[][4] =
bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO) bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
{ // return true if the channel appears valid { // return true if the channel appears valid
uint8_t Attributes; ChannelAttributes_t att;
uint8_t PriorityCh1; uint8_t PriorityCh1;
uint8_t PriorityCh2; uint8_t PriorityCh2;
if (!IS_MR_CHANNEL(Channel)) if (!IS_MR_CHANNEL(Channel))
return false; return false;
Attributes = gMR_ChannelAttributes[Channel]; att = gMR_ChannelAttributes[Channel];
if ((Attributes & MR_CH_BAND_MASK) > BAND7_470MHz) if (att.band > BAND7_470MHz)
return false; return false;
if (bCheckScanList) if (bCheckScanList) {
{ switch (VFO) {
switch (VFO)
{
case 0: case 0:
if ((Attributes & MR_CH_SCANLIST1) == 0) if (!att.scanlist1)
return false; return false;
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[0]; PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[0];
@@ -81,7 +79,7 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
break; break;
case 1: case 1:
if ((Attributes & MR_CH_SCANLIST2) == 0) if (!att.scanlist2)
return false; return false;
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[1]; PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[1];
@@ -128,8 +126,8 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t
memset(pInfo, 0, sizeof(*pInfo)); memset(pInfo, 0, sizeof(*pInfo));
pInfo->Band = FREQUENCY_GetBand(Frequency); pInfo->Band = FREQUENCY_GetBand(Frequency);
pInfo->SCANLIST1_PARTICIPATION = true; pInfo->SCANLIST1_PARTICIPATION = false;
pInfo->SCANLIST2_PARTICIPATION = true; pInfo->SCANLIST2_PARTICIPATION = false;
pInfo->STEP_SETTING = STEP_12_5kHz; pInfo->STEP_SETTING = STEP_12_5kHz;
pInfo->StepFrequency = gStepFrequencyTable[pInfo->STEP_SETTING]; pInfo->StepFrequency = gStepFrequencyTable[pInfo->STEP_SETTING];
pInfo->CHANNEL_SAVE = ChannelSave; pInfo->CHANNEL_SAVE = ChannelSave;
@@ -143,37 +141,31 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t
if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz))
pInfo->Modulation = MODULATION_AM; pInfo->Modulation = MODULATION_AM;
else
pInfo->Modulation = MODULATION_FM;
RADIO_ConfigureSquelchAndOutputPower(pInfo); RADIO_ConfigureSquelchAndOutputPower(pInfo);
} }
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure) void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure)
{ {
uint8_t Channel; VFO_Info_t *pVfo = &gEeprom.VfoInfo[VFO];
uint8_t Attributes;
uint8_t Band;
bool bParticipation2;
uint16_t Base;
uint32_t Frequency;
VFO_Info_t *pRadio = &gEeprom.VfoInfo[VFO];
if (!gSetting_350EN) if (!gSetting_350EN) {
{ if (gEeprom.FreqChannel[VFO] == FREQ_CHANNEL_FIRST + BAND5_350MHz)
if (gEeprom.FreqChannel[VFO] == (FREQ_CHANNEL_LAST - 2)) gEeprom.FreqChannel[VFO] = FREQ_CHANNEL_FIRST + BAND6_400MHz;
gEeprom.FreqChannel[VFO] = FREQ_CHANNEL_LAST - 1;
if (gEeprom.ScreenChannel[VFO] == (FREQ_CHANNEL_LAST - 2)) if (gEeprom.ScreenChannel[VFO] == FREQ_CHANNEL_FIRST + BAND5_350MHz)
gEeprom.ScreenChannel[VFO] = FREQ_CHANNEL_LAST - 1; gEeprom.ScreenChannel[VFO] = FREQ_CHANNEL_FIRST + BAND6_400MHz;
} }
Channel = gEeprom.ScreenChannel[VFO]; uint8_t channel = gEeprom.ScreenChannel[VFO];
if (IS_VALID_CHANNEL(Channel)) if (IS_VALID_CHANNEL(channel)) {
{
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (Channel >= NOAA_CHANNEL_FIRST) if (channel >= NOAA_CHANNEL_FIRST)
{ {
RADIO_InitInfo(pRadio, gEeprom.ScreenChannel[VFO], NoaaFrequencyTable[Channel - NOAA_CHANNEL_FIRST]); RADIO_InitInfo(pVfo, gEeprom.ScreenChannel[VFO], NoaaFrequencyTable[channel - NOAA_CHANNEL_FIRST]);
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF)
return; return;
@@ -185,248 +177,244 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
} }
#endif #endif
if (IS_MR_CHANNEL(Channel)) if (IS_MR_CHANNEL(channel)) {
{ channel = RADIO_FindNextChannel(channel, RADIO_CHANNEL_UP, false, VFO);
Channel = RADIO_FindNextChannel(Channel, RADIO_CHANNEL_UP, false, VFO); if (channel == 0xFF) {
if (Channel == 0xFF) channel = gEeprom.FreqChannel[VFO];
{
Channel = gEeprom.FreqChannel[VFO];
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO]; gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO];
} }
else else {
{ gEeprom.ScreenChannel[VFO] = channel;
gEeprom.ScreenChannel[VFO] = Channel; gEeprom.MrChannel[VFO] = channel;
gEeprom.MrChannel[VFO] = Channel;
} }
} }
} }
else else
Channel = FREQ_CHANNEL_LAST - 1; channel = FREQ_CHANNEL_LAST - 1;
Attributes = gMR_ChannelAttributes[Channel]; ChannelAttributes_t att = gMR_ChannelAttributes[channel];
if (Attributes == 0xFF) if (att.__val == 0xFF) { // invalid/unused channel
{ // invalid/unused channel if (IS_MR_CHANNEL(channel)) {
channel = gEeprom.FreqChannel[VFO];
uint8_t Index; gEeprom.ScreenChannel[VFO] = channel;
if (IS_MR_CHANNEL(Channel))
{
Channel = gEeprom.FreqChannel[VFO];
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO];
} }
Index = Channel - FREQ_CHANNEL_FIRST; uint8_t bandIdx = channel - FREQ_CHANNEL_FIRST;
RADIO_InitInfo(pVfo, channel, frequencyBandTable[bandIdx].lower);
RADIO_InitInfo(pRadio, Channel, frequencyBandTable[Index].lower);
return; return;
} }
Band = Attributes & MR_CH_BAND_MASK; uint8_t band = att.band;
if (Band > BAND7_470MHz) if (band > BAND7_470MHz) {
{ band = BAND6_400MHz;
Band = BAND6_400MHz;
} }
if (IS_MR_CHANNEL(Channel)) bool bParticipation1;
{ bool bParticipation2;
gEeprom.VfoInfo[VFO].Band = Band; if (IS_MR_CHANNEL(channel)) {
gEeprom.VfoInfo[VFO].SCANLIST1_PARTICIPATION = !!(Attributes & MR_CH_SCANLIST1); bParticipation1 = att.scanlist1;
bParticipation2 = !!(Attributes & MR_CH_SCANLIST2); bParticipation2 = att.scanlist2;
} }
else {
band = channel - FREQ_CHANNEL_FIRST;
bParticipation1 = true;
bParticipation2 = true;
}
pVfo->Band = band;
pVfo->SCANLIST1_PARTICIPATION = bParticipation1;
pVfo->SCANLIST2_PARTICIPATION = bParticipation2;
pVfo->CHANNEL_SAVE = channel;
uint16_t base;
if (IS_MR_CHANNEL(channel))
base = channel * 16;
else else
base = 0x0C80 + ((channel - FREQ_CHANNEL_FIRST) * 32) + (VFO * 16);
if (configure == VFO_CONFIGURE_RELOAD || IS_FREQ_CHANNEL(channel))
{ {
Band = Channel - FREQ_CHANNEL_FIRST; uint8_t tmp;
gEeprom.VfoInfo[VFO].Band = Band; uint8_t data[8];
bParticipation2 = true;
gEeprom.VfoInfo[VFO].SCANLIST1_PARTICIPATION = true;
}
gEeprom.VfoInfo[VFO].SCANLIST2_PARTICIPATION = bParticipation2;
gEeprom.VfoInfo[VFO].CHANNEL_SAVE = Channel;
if (IS_MR_CHANNEL(Channel))
Base = Channel * 16;
else
Base = 0x0C80 + ((Channel - FREQ_CHANNEL_FIRST) * 32) + (VFO * 16);
if (configure == VFO_CONFIGURE_RELOAD || Channel >= FREQ_CHANNEL_FIRST)
{
uint8_t Tmp;
uint8_t Data[8];
// *************** // ***************
EEPROM_ReadBuffer(Base + 8, Data, sizeof(Data)); EEPROM_ReadBuffer(base + 8, data, sizeof(data));
Tmp = Data[3] & 0x0F; tmp = data[3] & 0x0F;
if (Tmp > TX_OFFSET_FREQUENCY_DIRECTION_SUB) if (tmp > TX_OFFSET_FREQUENCY_DIRECTION_SUB)
Tmp = 0; tmp = 0;
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = Tmp; pVfo->TX_OFFSET_FREQUENCY_DIRECTION = tmp;
gEeprom.VfoInfo[VFO].Modulation = (Data[3] >> 4); tmp = data[3] >> 4;
if (tmp >= MODULATION_UKNOWN)
tmp = MODULATION_FM;
pVfo->Modulation = tmp;
Tmp = Data[6]; tmp = data[6];
if (Tmp >= ARRAY_SIZE(gStepFrequencyTable)) if (tmp >= ARRAY_SIZE(gStepFrequencyTable))
Tmp = STEP_12_5kHz; tmp = STEP_12_5kHz;
gEeprom.VfoInfo[VFO].STEP_SETTING = Tmp; pVfo->STEP_SETTING = tmp;
gEeprom.VfoInfo[VFO].StepFrequency = gStepFrequencyTable[Tmp]; pVfo->StepFrequency = gStepFrequencyTable[tmp];
Tmp = Data[7]; tmp = data[7];
if (Tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1)) if (tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1))
Tmp = 0; tmp = 0;
gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = Tmp; pVfo->SCRAMBLING_TYPE = tmp;
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = (Data[2] >> 0) & 0x0F; pVfo->freq_config_RX.CodeType = (data[2] >> 0) & 0x0F;
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = (Data[2] >> 4) & 0x0F; pVfo->freq_config_TX.CodeType = (data[2] >> 4) & 0x0F;
Tmp = Data[0]; tmp = data[0];
switch (gEeprom.VfoInfo[VFO].freq_config_RX.CodeType) switch (pVfo->freq_config_RX.CodeType)
{ {
default: default:
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = CODE_TYPE_OFF; pVfo->freq_config_RX.CodeType = CODE_TYPE_OFF;
Tmp = 0; tmp = 0;
break; break;
case CODE_TYPE_CONTINUOUS_TONE: case CODE_TYPE_CONTINUOUS_TONE:
if (Tmp > (ARRAY_SIZE(CTCSS_Options) - 1)) if (tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
Tmp = 0; tmp = 0;
break; break;
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
if (Tmp > (ARRAY_SIZE(DCS_Options) - 1)) if (tmp > (ARRAY_SIZE(DCS_Options) - 1))
Tmp = 0; tmp = 0;
break; break;
} }
gEeprom.VfoInfo[VFO].freq_config_RX.Code = Tmp; pVfo->freq_config_RX.Code = tmp;
Tmp = Data[1]; tmp = data[1];
switch (gEeprom.VfoInfo[VFO].freq_config_TX.CodeType) switch (pVfo->freq_config_TX.CodeType)
{ {
default: default:
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF; pVfo->freq_config_TX.CodeType = CODE_TYPE_OFF;
Tmp = 0; tmp = 0;
break; break;
case CODE_TYPE_CONTINUOUS_TONE: case CODE_TYPE_CONTINUOUS_TONE:
if (Tmp > (ARRAY_SIZE(CTCSS_Options) - 1)) if (tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
Tmp = 0; tmp = 0;
break; break;
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
if (Tmp > (ARRAY_SIZE(DCS_Options) - 1)) if (tmp > (ARRAY_SIZE(DCS_Options) - 1))
Tmp = 0; tmp = 0;
break; break;
} }
gEeprom.VfoInfo[VFO].freq_config_TX.Code = Tmp; pVfo->freq_config_TX.Code = tmp;
if (Data[4] == 0xFF) if (data[4] == 0xFF)
{ {
gEeprom.VfoInfo[VFO].FrequencyReverse = false; pVfo->FrequencyReverse = false;
gEeprom.VfoInfo[VFO].CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE; pVfo->CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE;
gEeprom.VfoInfo[VFO].OUTPUT_POWER = OUTPUT_POWER_LOW; pVfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
gEeprom.VfoInfo[VFO].BUSY_CHANNEL_LOCK = false; pVfo->BUSY_CHANNEL_LOCK = false;
} }
else else
{ {
const uint8_t d4 = Data[4]; const uint8_t d4 = data[4];
gEeprom.VfoInfo[VFO].FrequencyReverse = !!((d4 >> 0) & 1u); pVfo->FrequencyReverse = !!((d4 >> 0) & 1u);
gEeprom.VfoInfo[VFO].CHANNEL_BANDWIDTH = !!((d4 >> 1) & 1u); pVfo->CHANNEL_BANDWIDTH = !!((d4 >> 1) & 1u);
gEeprom.VfoInfo[VFO].OUTPUT_POWER = ((d4 >> 2) & 3u); pVfo->OUTPUT_POWER = ((d4 >> 2) & 3u);
gEeprom.VfoInfo[VFO].BUSY_CHANNEL_LOCK = !!((d4 >> 4) & 1u); pVfo->BUSY_CHANNEL_LOCK = !!((d4 >> 4) & 1u);
} }
if (Data[5] == 0xFF) if (data[5] == 0xFF)
{ {
gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; #ifdef ENABLE_DTMF_CALLING
gEeprom.VfoInfo[VFO].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF; pVfo->DTMF_DECODING_ENABLE = false;
#endif
pVfo->DTMF_PTT_ID_TX_MODE = PTT_ID_OFF;
} }
else else
{ {
gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = ((Data[5] >> 0) & 1u) ? true : false; #ifdef ENABLE_DTMF_CALLING
gEeprom.VfoInfo[VFO].DTMF_PTT_ID_TX_MODE = ((Data[5] >> 1) & 7u); pVfo->DTMF_DECODING_ENABLE = ((data[5] >> 0) & 1u) ? true : false;
#endif
pVfo->DTMF_PTT_ID_TX_MODE = ((data[5] >> 1) & 7u);
} }
// *************** // ***************
struct struct {
{
uint32_t Frequency; uint32_t Frequency;
uint32_t Offset; uint32_t Offset;
} __attribute__((packed)) Info; } __attribute__((packed)) info;
EEPROM_ReadBuffer(base, &info, sizeof(info));
if(info.Frequency==0xFFFFFFFF)
pVfo->freq_config_RX.Frequency = frequencyBandTable[band].lower;
else
pVfo->freq_config_RX.Frequency = info.Frequency;
EEPROM_ReadBuffer(Base, &Info, sizeof(Info)); if (info.Offset >= 100000000)
info.Offset = 1000000;
pRadio->freq_config_RX.Frequency = Info.Frequency; pVfo->TX_OFFSET_FREQUENCY = info.Offset;
if (Info.Offset >= 100000000)
Info.Offset = 1000000;
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = Info.Offset;
// *************** // ***************
} }
Frequency = pRadio->freq_config_RX.Frequency; uint32_t frequency = pVfo->freq_config_RX.Frequency;
// fix previously set incorrect band // fix previously set incorrect band
Band = FREQUENCY_GetBand(Frequency); band = FREQUENCY_GetBand(frequency);
if (Frequency < frequencyBandTable[Band].lower) if (frequency < frequencyBandTable[band].lower)
Frequency = frequencyBandTable[Band].lower; frequency = frequencyBandTable[band].lower;
else else if (frequency > frequencyBandTable[band].upper)
if (Frequency > frequencyBandTable[Band].upper) frequency = frequencyBandTable[band].upper;
Frequency = frequencyBandTable[Band].upper; else if (channel >= FREQ_CHANNEL_FIRST)
else frequency = FREQUENCY_RoundToStep(frequency, pVfo->StepFrequency);
if (Channel >= FREQ_CHANNEL_FIRST)
Frequency = FREQUENCY_RoundToStep(Frequency, gEeprom.VfoInfo[VFO].StepFrequency);
pRadio->freq_config_RX.Frequency = Frequency; pVfo->freq_config_RX.Frequency = frequency;
if (Frequency >= frequencyBandTable[BAND2_108MHz].upper && Frequency < frequencyBandTable[BAND2_108MHz].upper) if (frequency >= frequencyBandTable[BAND2_108MHz].upper && frequency < frequencyBandTable[BAND2_108MHz].upper)
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF; pVfo->TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF;
else if (!IS_MR_CHANNEL(Channel)) else if (!IS_MR_CHANNEL(channel))
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = FREQUENCY_RoundToStep(gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY, gEeprom.VfoInfo[VFO].StepFrequency); pVfo->TX_OFFSET_FREQUENCY = FREQUENCY_RoundToStep(pVfo->TX_OFFSET_FREQUENCY, pVfo->StepFrequency);
RADIO_ApplyOffset(pRadio); RADIO_ApplyOffset(pVfo);
memset(gEeprom.VfoInfo[VFO].Name, 0, sizeof(gEeprom.VfoInfo[VFO].Name)); memset(pVfo->Name, 0, sizeof(pVfo->Name));
if (IS_MR_CHANNEL(Channel)) if (IS_MR_CHANNEL(channel))
{ // 16 bytes allocated to the channel name but only 10 used, the rest are 0's { // 16 bytes allocated to the channel name but only 10 used, the rest are 0's
EEPROM_ReadBuffer(0x0F50 + (Channel * 16), gEeprom.VfoInfo[VFO].Name + 0, 8); EEPROM_ReadBuffer(0x0F50 + (channel * 16), pVfo->Name + 0, 8);
EEPROM_ReadBuffer(0x0F58 + (Channel * 16), gEeprom.VfoInfo[VFO].Name + 8, 2); EEPROM_ReadBuffer(0x0F58 + (channel * 16), pVfo->Name + 8, 2);
} }
if (!gEeprom.VfoInfo[VFO].FrequencyReverse) if (!pVfo->FrequencyReverse)
{ {
gEeprom.VfoInfo[VFO].pRX = &gEeprom.VfoInfo[VFO].freq_config_RX; pVfo->pRX = &pVfo->freq_config_RX;
gEeprom.VfoInfo[VFO].pTX = &gEeprom.VfoInfo[VFO].freq_config_TX; pVfo->pTX = &pVfo->freq_config_TX;
} }
else else
{ {
gEeprom.VfoInfo[VFO].pRX = &gEeprom.VfoInfo[VFO].freq_config_TX; pVfo->pRX = &pVfo->freq_config_TX;
gEeprom.VfoInfo[VFO].pTX = &gEeprom.VfoInfo[VFO].freq_config_RX; pVfo->pTX = &pVfo->freq_config_RX;
} }
if (!gSetting_350EN) if (!gSetting_350EN)
{ {
FREQ_Config_t *pConfig = gEeprom.VfoInfo[VFO].pRX; FREQ_Config_t *pConfig = pVfo->pRX;
if (pConfig->Frequency >= 35000000 && pConfig->Frequency < 40000000) if (pConfig->Frequency >= 35000000 && pConfig->Frequency < 40000000)
pConfig->Frequency = 43300000; pConfig->Frequency = 43300000;
} }
if (gEeprom.VfoInfo[VFO].Modulation != MODULATION_FM) if (pVfo->Modulation != MODULATION_FM)
{ // freq/chan is in AM mode { // freq/chan is in AM mode
gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = 0; pVfo->SCRAMBLING_TYPE = 0;
// gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; // no reason to disable DTMF decoding, aircraft use it on SSB // pVfo->DTMF_DECODING_ENABLE = false; // no reason to disable DTMF decoding, aircraft use it on SSB
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = CODE_TYPE_OFF; pVfo->freq_config_RX.CodeType = CODE_TYPE_OFF;
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF; pVfo->freq_config_TX.CodeType = CODE_TYPE_OFF;
} }
gEeprom.VfoInfo[VFO].Compander = (Attributes & MR_CH_COMPAND) >> 4; pVfo->Compander = att.compander;
RADIO_ConfigureSquelchAndOutputPower(pRadio); RADIO_ConfigureSquelchAndOutputPower(pVfo);
} }
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
@@ -1039,14 +1027,16 @@ void RADIO_PrepareTX(void)
gAlarmState = ALARM_STATE_OFF; gAlarmState = ALARM_STATE_OFF;
#endif #endif
#ifdef ENABLE_DTMF_CALLING
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;
#endif
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
return; return;
} }
// TX is allowed // TX is allowed
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_ReplyState == DTMF_REPLY_ANI) if (gDTMF_ReplyState == DTMF_REPLY_ANI)
{ {
if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF) if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF)
@@ -1061,6 +1051,7 @@ void RADIO_PrepareTX(void)
gDTMF_IsTx = false; gDTMF_IsTx = false;
} }
} }
#endif
FUNCTION_Select(FUNCTION_TRANSMIT); FUNCTION_Select(FUNCTION_TRANSMIT);
@@ -1082,7 +1073,10 @@ void RADIO_PrepareTX(void)
gFlagEndTransmission = false; gFlagEndTransmission = false;
gRTTECountdown = 0; gRTTECountdown = 0;
#ifdef ENABLE_DTMF_CALLING
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;
#endif
} }
void RADIO_EnableCxCSS(void) void RADIO_EnableCxCSS(void)
@@ -1121,7 +1115,10 @@ void RADIO_SendEndOfTransmission(void)
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO) if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO)
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE); BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE);
if (gDTMF_CallState == DTMF_CALL_STATE_NONE && if (
#ifdef ENABLE_DTMF_CALLING
gDTMF_CallState == DTMF_CALL_STATE_NONE &&
#endif
(gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN ||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)) gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH))
{ // end-of-tx { // end-of-tx

12
radio.h
View File

@@ -23,13 +23,6 @@
#include "dcs.h" #include "dcs.h"
#include "frequencies.h" #include "frequencies.h"
enum {
MR_CH_BAND_MASK = 0x0F << 0,
MR_CH_COMPAND = 3u << 4, // new
MR_CH_SCANLIST2 = 1u << 6,
MR_CH_SCANLIST1 = 1u << 7
};
enum { enum {
RADIO_CHANNEL_UP = 0x01u, RADIO_CHANNEL_UP = 0x01u,
RADIO_CHANNEL_DOWN = 0xFFu, RADIO_CHANNEL_DOWN = 0xFFu,
@@ -124,8 +117,9 @@ typedef struct VFO_Info_t
uint8_t SCANLIST2_PARTICIPATION; uint8_t SCANLIST2_PARTICIPATION;
uint8_t Band; uint8_t Band;
#ifdef ENABLE_DTMF_CALLING
uint8_t DTMF_DECODING_ENABLE; uint8_t DTMF_DECODING_ENABLE;
#endif
PTT_ID_t DTMF_PTT_ID_TX_MODE; PTT_ID_t DTMF_PTT_ID_TX_MODE;
uint8_t BUSY_CHANNEL_LOCK; uint8_t BUSY_CHANNEL_LOCK;
@@ -138,7 +132,7 @@ typedef struct VFO_Info_t
} VFO_Info_t; } VFO_Info_t;
// Settings of the main VFO that is selected by the user // Settings of the main VFO that is selected by the user
// The pointer follows gEeprom.RX_VFO index // The pointer follows gEeprom.TX_VFO index
extern VFO_Info_t *gTxVfo; extern VFO_Info_t *gTxVfo;
// Settings of the actual VFO that is now used for RX, // Settings of the actual VFO that is now used for RX,

View File

@@ -141,10 +141,12 @@ void SETTINGS_SaveSettings(void)
EEPROM_WriteBuffer(0x0EA8, State); EEPROM_WriteBuffer(0x0EA8, State);
State[0] = gEeprom.DTMF_SIDE_TONE; State[0] = gEeprom.DTMF_SIDE_TONE;
#ifdef ENABLE_DTMF_CALLING
State[1] = gEeprom.DTMF_SEPARATE_CODE; State[1] = gEeprom.DTMF_SEPARATE_CODE;
State[2] = gEeprom.DTMF_GROUP_CALL_CODE; State[2] = gEeprom.DTMF_GROUP_CALL_CODE;
State[3] = gEeprom.DTMF_DECODE_RESPONSE; State[3] = gEeprom.DTMF_DECODE_RESPONSE;
State[4] = gEeprom.DTMF_auto_reset_time; State[4] = gEeprom.DTMF_auto_reset_time;
#endif
State[5] = gEeprom.DTMF_PRELOAD_TIME / 10U; State[5] = gEeprom.DTMF_PRELOAD_TIME / 10U;
State[6] = gEeprom.DTMF_FIRST_CODE_PERSIST_TIME / 10U; State[6] = gEeprom.DTMF_FIRST_CODE_PERSIST_TIME / 10U;
State[7] = gEeprom.DTMF_HASH_CODE_PERSIST_TIME / 10U; State[7] = gEeprom.DTMF_HASH_CODE_PERSIST_TIME / 10U;
@@ -153,7 +155,9 @@ void SETTINGS_SaveSettings(void)
memset(State, 0xFF, sizeof(State)); memset(State, 0xFF, sizeof(State));
State[0] = gEeprom.DTMF_CODE_PERSIST_TIME / 10U; State[0] = gEeprom.DTMF_CODE_PERSIST_TIME / 10U;
State[1] = gEeprom.DTMF_CODE_INTERVAL_TIME / 10U; State[1] = gEeprom.DTMF_CODE_INTERVAL_TIME / 10U;
#ifdef ENABLE_DTMF_CALLING
State[2] = gEeprom.PERMIT_REMOTE_KILL; State[2] = gEeprom.PERMIT_REMOTE_KILL;
#endif
EEPROM_WriteBuffer(0x0ED8, State); EEPROM_WriteBuffer(0x0ED8, State);
State[0] = gEeprom.SCAN_LIST_DEFAULT; State[0] = gEeprom.SCAN_LIST_DEFAULT;
@@ -169,7 +173,9 @@ void SETTINGS_SaveSettings(void)
memset(State, 0xFF, sizeof(State)); memset(State, 0xFF, sizeof(State));
State[0] = gSetting_F_LOCK; State[0] = gSetting_F_LOCK;
State[1] = gSetting_350TX; State[1] = gSetting_350TX;
#ifdef ENABLE_DTMF_CALLING
State[2] = gSetting_KILLED; State[2] = gSetting_KILLED;
#endif
State[3] = gSetting_200TX; State[3] = gSetting_200TX;
State[4] = gSetting_500TX; State[4] = gSetting_500TX;
State[5] = gSetting_350EN; State[5] = gSetting_350EN;
@@ -221,7 +227,11 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
| (pVFO->OUTPUT_POWER << 2) | (pVFO->OUTPUT_POWER << 2)
| (pVFO->CHANNEL_BANDWIDTH << 1) | (pVFO->CHANNEL_BANDWIDTH << 1)
| (pVFO->FrequencyReverse << 0); | (pVFO->FrequencyReverse << 0);
State[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1) | ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0); State[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1)
#ifdef ENABLE_DTMF_CALLING
| ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0)
#endif
;
State[6] = pVFO->STEP_SETTING; State[6] = pVFO->STEP_SETTING;
State[7] = pVFO->SCRAMBLING_TYPE; State[7] = pVFO->SCRAMBLING_TYPE;
EEPROM_WriteBuffer(OffsetVFO + 8, State); EEPROM_WriteBuffer(OffsetVFO + 8, State);
@@ -263,55 +273,45 @@ void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration)
EEPROM_WriteBuffer(0x1F48, buf); EEPROM_WriteBuffer(0x1F48, buf);
} }
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep)
{ {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (!IS_NOAA_CHANNEL(Channel)) if (!IS_NOAA_CHANNEL(channel))
#endif #endif
{ {
uint8_t State[8]; uint8_t state[8];
uint8_t Attributes = 0xFF; // default attributes ChannelAttributes_t att = {
uint16_t Offset = 0x0D60 + (Channel & ~7u); .band = 0xf,
.compander = 0,
Attributes &= (uint8_t)(~MR_CH_COMPAND); // default to '0' = compander disabled .scanlist1 = 0,
.scanlist2 = 0,
}; // default attributes
EEPROM_ReadBuffer(Offset, State, sizeof(State)); uint16_t offset = 0x0D60 + (channel & ~7u);
EEPROM_ReadBuffer(offset, state, sizeof(state));
if (keep) if (keep) {
{ att.band = pVFO->Band;
Attributes = (pVFO->SCANLIST1_PARTICIPATION << 7) | (pVFO->SCANLIST2_PARTICIPATION << 6) | (pVFO->Compander << 4) | (pVFO->Band << 0); att.scanlist1 = pVFO->SCANLIST1_PARTICIPATION;
if (State[Channel & 7u] == Attributes) att.scanlist2 = pVFO->SCANLIST2_PARTICIPATION;
att.compander = pVFO->Compander;
if (state[channel & 7u] == att.__val)
return; // no change in the attributes return; // no change in the attributes
} }
State[Channel & 7u] = Attributes; state[channel & 7u] = att.__val;
EEPROM_WriteBuffer(offset, state);
EEPROM_WriteBuffer(Offset, State); gMR_ChannelAttributes[channel] = att;
gMR_ChannelAttributes[Channel] = Attributes; if (IS_MR_CHANNEL(channel)) { // it's a memory channel
const uint16_t OffsetMR = channel * 16;
// #ifndef ENABLE_KEEP_MEM_NAME if (!keep) {
if (IS_MR_CHANNEL(Channel)) // clear/reset the channel name
{ // it's a memory channel memset(&state, 0x00, sizeof(state));
EEPROM_WriteBuffer(0x0F50 + OffsetMR, state);
const uint16_t OffsetMR = Channel * 16; EEPROM_WriteBuffer(0x0F58 + OffsetMR, state);
if (!keep)
{ // clear/reset the channel name
//memset(&State, 0xFF, sizeof(State));
memset(&State, 0x00, sizeof(State)); // follow the QS way
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
}
// else
// { // update the channel name
// memmove(State, pVFO->Name + 0, 8);
// EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
// //memset(State, 0xFF, sizeof(State));
// memset(State, 0x00, sizeof(State)); // follow the QS way
// memmove(State, pVFO->Name + 8, 2);
// EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
// }
} }
// #endif }
} }
} }

View File

@@ -127,9 +127,9 @@ enum CHANNEL_DisplayMode_t {
typedef enum CHANNEL_DisplayMode_t CHANNEL_DisplayMode_t; typedef enum CHANNEL_DisplayMode_t CHANNEL_DisplayMode_t;
typedef struct { typedef struct {
uint8_t ScreenChannel[2]; uint8_t ScreenChannel[2]; // current channels set in the radio (memory or frequency channels)
uint8_t FreqChannel[2]; uint8_t FreqChannel[2]; // last frequency channels used
uint8_t MrChannel[2]; uint8_t MrChannel[2]; // last memory channels used
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
uint8_t NoaaChannel[2]; uint8_t NoaaChannel[2];
#endif #endif
@@ -196,9 +196,11 @@ typedef struct {
uint8_t MIC_SENSITIVITY; uint8_t MIC_SENSITIVITY;
uint8_t MIC_SENSITIVITY_TUNING; uint8_t MIC_SENSITIVITY_TUNING;
uint8_t CHAN_1_CALL; uint8_t CHAN_1_CALL;
#ifdef ENABLE_DTMF_CALLING
char ANI_DTMF_ID[8]; char ANI_DTMF_ID[8];
char KILL_CODE[8]; char KILL_CODE[8];
char REVIVE_CODE[8]; char REVIVE_CODE[8];
#endif
char DTMF_UP_CODE[16]; char DTMF_UP_CODE[16];
uint8_t field57_0x6c; uint8_t field57_0x6c;
@@ -209,17 +211,21 @@ typedef struct {
uint8_t field60_0x7e; uint8_t field60_0x7e;
uint8_t field61_0x7f; uint8_t field61_0x7f;
#ifdef ENABLE_DTMF_CALLING
char DTMF_SEPARATE_CODE; char DTMF_SEPARATE_CODE;
char DTMF_GROUP_CALL_CODE; char DTMF_GROUP_CALL_CODE;
uint8_t DTMF_DECODE_RESPONSE; uint8_t DTMF_DECODE_RESPONSE;
uint8_t DTMF_auto_reset_time; uint8_t DTMF_auto_reset_time;
#endif
uint16_t DTMF_PRELOAD_TIME; uint16_t DTMF_PRELOAD_TIME;
uint16_t DTMF_FIRST_CODE_PERSIST_TIME; uint16_t DTMF_FIRST_CODE_PERSIST_TIME;
uint16_t DTMF_HASH_CODE_PERSIST_TIME; uint16_t DTMF_HASH_CODE_PERSIST_TIME;
uint16_t DTMF_CODE_PERSIST_TIME; uint16_t DTMF_CODE_PERSIST_TIME;
uint16_t DTMF_CODE_INTERVAL_TIME; uint16_t DTMF_CODE_INTERVAL_TIME;
bool DTMF_SIDE_TONE; bool DTMF_SIDE_TONE;
#ifdef ENABLE_DTMF_CALLING
bool PERMIT_REMOTE_KILL; bool PERMIT_REMOTE_KILL;
#endif
int16_t BK4819_XTAL_FREQ_LOW; int16_t BK4819_XTAL_FREQ_LOW;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
bool NOAA_AUTO_SCAN; bool NOAA_AUTO_SCAN;
@@ -254,6 +260,6 @@ void SETTINGS_SaveVfoIndices(void);
void SETTINGS_SaveSettings(void); void SETTINGS_SaveSettings(void);
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode); void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode);
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration); void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration);
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep); void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep);
#endif #endif

View File

@@ -88,11 +88,13 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
const size_t Length = strlen(pString); const size_t Length = strlen(pString);
size_t i; size_t i;
if (End > Start)
Start += (((End - Start) - (Length * 8)) + 1) / 2;
const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]); const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]);
const unsigned int char_spacing = char_width + 1; const unsigned int char_spacing = char_width + 1;
if (End > Start)
Start += (((End - Start) - (Length * char_spacing)) + 1) / 2;
uint8_t *pFb = gFrameBuffer[Line] + Start; uint8_t *pFb = gFrameBuffer[Line] + Start;
for (i = 0; i < Length; i++) for (i = 0; i < Length; i++)
{ {
@@ -180,10 +182,12 @@ void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
} }
} }
void UI_DrawPixel(uint8_t x, uint8_t y, bool black) void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black)
{ {
gFrameBuffer[y/8][x] &= ~(1 << (y%8)); if(black)
gFrameBuffer[y/8][x] |= black << (y%8); buffer[y/8][x] |= 1 << (y%8);
else
buffer[y/8][x] &= ~(1 << (y%8));
} }
static void sort(int16_t *a, int16_t *b) static void sort(int16_t *a, int16_t *b)
@@ -195,12 +199,12 @@ static void sort(int16_t *a, int16_t *b)
} }
} }
void UI_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
{ {
if(x2==x1) { if(x2==x1) {
sort(&y1, &y2); sort(&y1, &y2);
for(int16_t i = y1; i <= y2; i++) { for(int16_t i = y1; i <= y2; i++) {
UI_DrawPixel(x1, i, black); UI_DrawPixelBuffer(buffer, x1, i, black);
} }
} else { } else {
const int multipl = 1000; const int multipl = 1000;
@@ -210,17 +214,17 @@ void UI_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
sort(&x1, &x2); sort(&x1, &x2);
for(int i = x1; i<= x2; i++) for(int i = x1; i<= x2; i++)
{ {
UI_DrawPixel(i, i*a/multipl +b, black); UI_DrawPixelBuffer(buffer, i, i*a/multipl +b, black);
} }
} }
} }
void UI_DrawRectangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
{ {
UI_DrawLine(x1,y1, x1,y2, black); UI_DrawLineBuffer(buffer, x1,y1, x1,y2, black);
UI_DrawLine(x1,y1, x2,y1, black); UI_DrawLineBuffer(buffer, x1,y1, x2,y1, black);
UI_DrawLine(x2,y1, x2,y2, black); UI_DrawLineBuffer(buffer, x2,y1, x2,y2, black);
UI_DrawLine(x1,y2, x2,y2, black); UI_DrawLineBuffer(buffer, x1,y2, x2,y2, black);
} }
void UI_DisplayPopup(const char *string) void UI_DisplayPopup(const char *string)
@@ -234,13 +238,13 @@ void UI_DisplayPopup(const char *string)
// } // }
// for(uint8_t x = 10; x < 118; x++) { // for(uint8_t x = 10; x < 118; x++) {
// UI_DrawPixel(x, 10, true); // UI_DrawPixelBuffer(x, 10, true);
// UI_DrawPixel(x, 46-9, true); // UI_DrawPixelBuffer(x, 46-9, true);
// } // }
// for(uint8_t y = 11; y < 37; y++) { // for(uint8_t y = 11; y < 37; y++) {
// UI_DrawPixel(10, y, true); // UI_DrawPixelBuffer(10, y, true);
// UI_DrawPixel(117, y, true); // UI_DrawPixelBuffer(117, y, true);
// } // }
// DrawRectangle(9,9, 118,38, true); // DrawRectangle(9,9, 118,38, true);
UI_PrintString(string, 9, 118, 2, 8); UI_PrintString(string, 9, 118, 2, 8);

View File

@@ -33,7 +33,7 @@ void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center);
void UI_DisplayPopup(const char *string); void UI_DisplayPopup(const char *string);
void UI_DrawPixel(uint8_t x, uint8_t y, bool black); void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black);
void UI_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black); void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
void UI_DrawRectangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black); void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);

View File

@@ -17,6 +17,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> // abs() #include <stdlib.h> // abs()
#include "app/chFrScanner.h"
#include "app/dtmf.h" #include "app/dtmf.h"
#ifdef ENABLE_AM_FIX_SHOW_DATA #ifdef ENABLE_AM_FIX_SHOW_DATA
#include "am_fix.h" #include "am_fix.h"
@@ -107,8 +108,11 @@ void UI_DisplayAudioBar(void)
const unsigned int line = 3; const unsigned int line = 3;
if (gCurrentFunction != FUNCTION_TRANSMIT || if (gCurrentFunction != FUNCTION_TRANSMIT ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN
gDTMF_CallState != DTMF_CALL_STATE_NONE) #ifdef ENABLE_DTMF_CALLING
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
#endif
)
{ {
return; // screen is in use return; // screen is in use
} }
@@ -162,15 +166,28 @@ static void DisplayRSSIBar(const int16_t rssi, const bool now)
return; // display is in use return; // display is in use
if (gCurrentFunction == FUNCTION_TRANSMIT || if (gCurrentFunction == FUNCTION_TRANSMIT ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN
gDTMF_CallState != DTMF_CALL_STATE_NONE) #ifdef ENABLE_DTMF_CALLING
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
#endif
)
return; // display is in use return; // display is in use
if (now) if (now)
memset(p_line, 0, LCD_WIDTH); memset(p_line, 0, LCD_WIDTH);
const int16_t s0_dBm = -147; // S0 .. base level const int8_t dBmCorrTable[7] = {
const int16_t rssi_dBm = (rssi / 2) - 160; -15, // band 1
-25, // band 2
-20, // band 3
-4, // band 4
-7, // band 5
-6, // band 6
-1 // band 7
};
const int16_t s0_dBm = -130; // S0 .. base level
const int16_t rssi_dBm = (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band];
const uint8_t s_level = MIN(MAX((rssi_dBm - s0_dBm) / 6, 0), 9); // S0 - S9 const uint8_t s_level = MIN(MAX((rssi_dBm - s0_dBm) / 6, 0), 9); // S0 - S9
uint8_t overS9dBm = MIN(MAX(rssi_dBm - (s0_dBm + 9*6), 0), 99); uint8_t overS9dBm = MIN(MAX(rssi_dBm - (s0_dBm + 9*6), 0), 99);
@@ -271,13 +288,31 @@ void UI_DisplayMain(void)
if (activeTxVFO != vfo_num) // this is not active TX VFO if (activeTxVFO != vfo_num) // this is not active TX VFO
{ {
if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode) #ifdef ENABLE_SCAN_RANGES
{ // show DTMF stuff if(gScanRangeStart) {
UI_PrintString("ScnRng", 5, 0, line, 8);
sprintf(String, "%3u.%05u", gScanRangeStart / 100000, gScanRangeStart % 100000);
UI_PrintStringSmall(String, 56, 0, line);
uint32_t frq = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
sprintf(String, "%3u.%05u", frq / 100000, frq % 100000);
UI_PrintStringSmall(String, 56, 0, line + 1);
continue;
}
#endif
if (
#ifdef ENABLE_DTMF_CALLING
gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx ||
#endif
gDTMF_InputMode)
{ // show DTMF stuff
#ifdef ENABLE_DTMF_CALLING
char Contact[16]; char Contact[16];
if (!gDTMF_InputMode) if (!gDTMF_InputMode)
{ {
memset(Contact, 0, sizeof(Contact)); memset(Contact, 0, sizeof(Contact));
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT)
strcpy(String, (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT"); strcpy(String, (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT");
@@ -289,14 +324,14 @@ void UI_DisplayMain(void)
strcpy(String, (gDTMF_State == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX"); strcpy(String, (gDTMF_State == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX");
} }
else else
#endif
{ {
sprintf(String, ">%s", gDTMF_InputBox); sprintf(String, ">%s", gDTMF_InputBox);
} }
UI_PrintString(String, 2, 0, 0 + (vfo_num * 3), 8); UI_PrintString(String, 2, 0, 0 + (vfo_num * 3), 8);
#ifdef ENABLE_DTMF_CALLING
memset(String, 0, sizeof(String)); memset(String, 0, sizeof(String));
if (!gDTMF_InputMode) if (!gDTMF_InputMode) {
{
memset(Contact, 0, sizeof(Contact)); memset(Contact, 0, sizeof(Contact));
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT)
sprintf(String, ">%s", (DTMF_FindContact(gDTMF_String, Contact)) ? Contact : gDTMF_String); sprintf(String, ">%s", (DTMF_FindContact(gDTMF_String, Contact)) ? Contact : gDTMF_String);
@@ -307,8 +342,9 @@ void UI_DisplayMain(void)
if (gDTMF_IsTx) if (gDTMF_IsTx)
sprintf(String, ">%s", gDTMF_String); sprintf(String, ">%s", gDTMF_String);
} }
UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8);
UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8);
#endif
center_line = CENTER_LINE_IN_USE; center_line = CENTER_LINE_IN_USE;
continue; continue;
} }
@@ -433,7 +469,7 @@ void UI_DisplayMain(void)
UI_PrintString(String, 32, 0, line, 8); UI_PrintString(String, 32, 0, line, 8);
} }
break; continue;
} }
else else
{ {
@@ -447,15 +483,15 @@ void UI_DisplayMain(void)
{ // it's a channel { // it's a channel
// show the scan list assigment symbols // show the scan list assigment symbols
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
if (attributes & MR_CH_SCANLIST1) if (att.scanlist1)
memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
if (attributes & MR_CH_SCANLIST2) if (att.scanlist2)
memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
// compander symbol // compander symbol
#ifndef ENABLE_BIG_FREQ #ifndef ENABLE_BIG_FREQ
if ((attributes & MR_CH_COMPAND) > 0) if (att.compander)
memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
#else #else
// TODO: // find somewhere else to put the symbol // TODO: // find somewhere else to put the symbol
@@ -533,8 +569,8 @@ void UI_DisplayMain(void)
} }
// show the channel symbols // show the channel symbols
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
if ((attributes & MR_CH_COMPAND) > 0) if (att.compander)
#ifdef ENABLE_BIG_FREQ #ifdef ENABLE_BIG_FREQ
memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand));
#else #else
@@ -624,9 +660,11 @@ void UI_DisplayMain(void)
UI_PrintStringSmall(String, LCD_WIDTH + 70, 0, line + 1); UI_PrintStringSmall(String, LCD_WIDTH + 70, 0, line + 1);
} }
#ifdef ENABLE_DTMF_CALLING
// show the DTMF decoding symbol // show the DTMF decoding symbol
if (gEeprom.VfoInfo[vfo_num].DTMF_DECODING_ENABLE || gSetting_KILLED) if (gEeprom.VfoInfo[vfo_num].DTMF_DECODING_ENABLE || gSetting_KILLED)
UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1); UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1);
#endif
// show the audio scramble symbol // show the audio scramble symbol
if (gEeprom.VfoInfo[vfo_num].SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) if (gEeprom.VfoInfo[vfo_num].SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable)
@@ -651,8 +689,11 @@ void UI_DisplayMain(void)
#if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA)
if (rx && gEeprom.VfoInfo[gEeprom.RX_VFO].Modulation == MODULATION_AM && gSetting_AM_fix) if (rx && gEeprom.VfoInfo[gEeprom.RX_VFO].Modulation == MODULATION_AM && gSetting_AM_fix)
{ {
if (gScreenToDisplay != DISPLAY_MAIN || if (gScreenToDisplay != DISPLAY_MAIN
gDTMF_CallState != DTMF_CALL_STATE_NONE) #ifdef ENABLE_DTMF_CALLING
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
#endif
)
return; return;
center_line = CENTER_LINE_AM_FIX_DATA; center_line = CENTER_LINE_AM_FIX_DATA;
@@ -677,8 +718,11 @@ void UI_DisplayMain(void)
const unsigned int len = strlen(gDTMF_RX_live); const unsigned int len = strlen(gDTMF_RX_live);
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars
if (gScreenToDisplay != DISPLAY_MAIN || if (gScreenToDisplay != DISPLAY_MAIN
gDTMF_CallState != DTMF_CALL_STATE_NONE) #ifdef ENABLE_DTMF_CALLING
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
#endif
)
return; return;
center_line = CENTER_LINE_DTMF_DEC; center_line = CENTER_LINE_DTMF_DEC;
@@ -708,8 +752,11 @@ void UI_DisplayMain(void)
#ifdef ENABLE_SHOW_CHARGE_LEVEL #ifdef ENABLE_SHOW_CHARGE_LEVEL
else if (gChargingWithTypeC) else if (gChargingWithTypeC)
{ // charging .. show the battery state { // charging .. show the battery state
if (gScreenToDisplay != DISPLAY_MAIN || if (gScreenToDisplay != DISPLAY_MAIN
gDTMF_CallState != DTMF_CALL_STATE_NONE) #ifdef ENABLE_DTMF_CALLING
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
#endif
)
return; return;
center_line = CENTER_LINE_CHARGE_DATA; center_line = CENTER_LINE_CHARGE_DATA;

View File

@@ -97,16 +97,22 @@ const t_menu_item MenuList[] =
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
{"AlarmT", VOICE_ID_INVALID, MENU_AL_MOD }, {"AlarmT", VOICE_ID_INVALID, MENU_AL_MOD },
#endif #endif
#ifdef ENABLE_DTMF_CALLING
{"ANI ID", VOICE_ID_ANI_CODE, MENU_ANI_ID }, {"ANI ID", VOICE_ID_ANI_CODE, MENU_ANI_ID },
#endif
{"UPCode", VOICE_ID_INVALID, MENU_UPCODE }, {"UPCode", VOICE_ID_INVALID, MENU_UPCODE },
{"DWCode", VOICE_ID_INVALID, MENU_DWCODE }, {"DWCode", VOICE_ID_INVALID, MENU_DWCODE },
{"PTT ID", VOICE_ID_INVALID, MENU_PTT_ID }, {"PTT ID", VOICE_ID_INVALID, MENU_PTT_ID },
{"D ST", VOICE_ID_INVALID, MENU_D_ST }, {"D ST", VOICE_ID_INVALID, MENU_D_ST },
#ifdef ENABLE_DTMF_CALLING
{"D Resp", VOICE_ID_INVALID, MENU_D_RSP }, {"D Resp", VOICE_ID_INVALID, MENU_D_RSP },
{"D Hold", VOICE_ID_INVALID, MENU_D_HOLD }, {"D Hold", VOICE_ID_INVALID, MENU_D_HOLD },
#endif
{"D Prel", VOICE_ID_INVALID, MENU_D_PRE }, {"D Prel", VOICE_ID_INVALID, MENU_D_PRE },
#ifdef ENABLE_DTMF_CALLING
{"D Decd", VOICE_ID_INVALID, MENU_D_DCD }, {"D Decd", VOICE_ID_INVALID, MENU_D_DCD },
{"D List", VOICE_ID_INVALID, MENU_D_LIST }, {"D List", VOICE_ID_INVALID, MENU_D_LIST },
#endif
{"D Live", VOICE_ID_INVALID, MENU_D_LIVE_DEC }, // live DTMF decoder {"D Live", VOICE_ID_INVALID, MENU_D_LIVE_DEC }, // live DTMF decoder
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
{"AM Fix", VOICE_ID_INVALID, MENU_AM_FIX }, {"AM Fix", VOICE_ID_INVALID, MENU_AM_FIX },
@@ -231,6 +237,7 @@ const char* gSubMenu_MDF[] =
}; };
#endif #endif
#ifdef ENABLE_DTMF_CALLING
const char gSubMenu_D_RSP[][11] = const char gSubMenu_D_RSP[][11] =
{ {
"DO\nNOTHING", "DO\nNOTHING",
@@ -238,6 +245,7 @@ const char gSubMenu_D_RSP[][11] =
"REPLY", "REPLY",
"BOTH" "BOTH"
}; };
#endif
const char* gSubMenu_PTT_ID[] = const char* gSubMenu_PTT_ID[] =
{ {
@@ -400,7 +408,10 @@ void UI_DisplayMenu(void)
const unsigned int menu_item_x2 = LCD_WIDTH - 1; const unsigned int menu_item_x2 = LCD_WIDTH - 1;
unsigned int i; unsigned int i;
char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char) char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char)
#ifdef ENABLE_DTMF_CALLING
char Contact[16]; char Contact[16];
#endif
// clear the screen buffer // clear the screen buffer
memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
@@ -625,7 +636,9 @@ void UI_DisplayMenu(void)
case MENU_S_ADD2: case MENU_S_ADD2:
case MENU_STE: case MENU_STE:
case MENU_D_ST: case MENU_D_ST:
#ifdef ENABLE_DTMF_CALLING
case MENU_D_DCD: case MENU_D_DCD:
#endif
case MENU_D_LIVE_DEC: case MENU_D_LIVE_DEC:
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
case MENU_NOAA_S: case MENU_NOAA_S:
@@ -743,10 +756,11 @@ void UI_DisplayMenu(void)
break; break;
#endif #endif
#ifdef ENABLE_DTMF_CALLING
case MENU_ANI_ID: case MENU_ANI_ID:
strcpy(String, gEeprom.ANI_DTMF_ID); strcpy(String, gEeprom.ANI_DTMF_ID);
break; break;
#endif
case MENU_UPCODE: case MENU_UPCODE:
strcpy(String, gEeprom.DTMF_UP_CODE); strcpy(String, gEeprom.DTMF_UP_CODE);
break; break;
@@ -755,6 +769,7 @@ void UI_DisplayMenu(void)
strcpy(String, gEeprom.DTMF_DOWN_CODE); strcpy(String, gEeprom.DTMF_DOWN_CODE);
break; break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_RSP: case MENU_D_RSP:
strcpy(String, gSubMenu_D_RSP[gSubMenuSelection]); strcpy(String, gSubMenu_D_RSP[gSubMenuSelection]);
break; break;
@@ -762,7 +777,7 @@ void UI_DisplayMenu(void)
case MENU_D_HOLD: case MENU_D_HOLD:
sprintf(String, "%ds", gSubMenuSelection); sprintf(String, "%ds", gSubMenuSelection);
break; break;
#endif
case MENU_D_PRE: case MENU_D_PRE:
sprintf(String, "%d*10ms", gSubMenuSelection); sprintf(String, "%d*10ms", gSubMenuSelection);
break; break;
@@ -775,6 +790,7 @@ void UI_DisplayMenu(void)
strcpy(String, gSubMenu_BAT_TXT[gSubMenuSelection]); strcpy(String, gSubMenu_BAT_TXT[gSubMenuSelection]);
break; break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_LIST: case MENU_D_LIST:
gIsDtmfContactValid = DTMF_GetContact((int)gSubMenuSelection - 1, Contact); gIsDtmfContactValid = DTMF_GetContact((int)gSubMenuSelection - 1, Contact);
if (!gIsDtmfContactValid) if (!gIsDtmfContactValid)
@@ -782,6 +798,7 @@ void UI_DisplayMenu(void)
else else
memmove(String, Contact, 8); memmove(String, Contact, 8);
break; break;
#endif
case MENU_PONMSG: case MENU_PONMSG:
strcpy(String, gSubMenu_PONMSG[gSubMenuSelection]); strcpy(String, gSubMenu_PONMSG[gSubMenuSelection]);
@@ -968,6 +985,7 @@ void UI_DisplayMenu(void)
if (strlen(gEeprom.DTMF_DOWN_CODE) > 8) if (strlen(gEeprom.DTMF_DOWN_CODE) > 8)
UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, menu_item_x1, menu_item_x2, 4, 8);
#ifdef ENABLE_DTMF_CALLING
if (UI_MENU_GetCurrentMenuId() == MENU_D_LIST && gIsDtmfContactValid) if (UI_MENU_GetCurrentMenuId() == MENU_D_LIST && gIsDtmfContactValid)
{ {
Contact[11] = 0; Contact[11] = 0;
@@ -975,12 +993,17 @@ void UI_DisplayMenu(void)
sprintf(String, "ID:%s", Contact + 8); sprintf(String, "ID:%s", Contact + 8);
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
} }
#endif
if (UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || if (UI_MENU_GetCurrentMenuId() == MENU_R_CTCS ||
UI_MENU_GetCurrentMenuId() == MENU_T_CTCS || UI_MENU_GetCurrentMenuId() == MENU_T_CTCS ||
UI_MENU_GetCurrentMenuId() == MENU_R_DCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS ||
UI_MENU_GetCurrentMenuId() == MENU_T_DCS || UI_MENU_GetCurrentMenuId() == MENU_T_DCS
UI_MENU_GetCurrentMenuId() == MENU_D_LIST) #ifdef ENABLE_DTMF_CALLING
|| UI_MENU_GetCurrentMenuId() == MENU_D_LIST
#endif
)
{ {
sprintf(String, "%2d", gSubMenuSelection); sprintf(String, "%2d", gSubMenuSelection);
UI_PrintStringSmall(String, 105, 0, 0); UI_PrintStringSmall(String, 105, 0, 0);

View File

@@ -79,16 +79,22 @@ enum
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
MENU_AL_MOD, MENU_AL_MOD,
#endif #endif
#ifdef ENABLE_DTMF_CALLING
MENU_ANI_ID, MENU_ANI_ID,
#endif
MENU_UPCODE, MENU_UPCODE,
MENU_DWCODE, MENU_DWCODE,
MENU_PTT_ID, MENU_PTT_ID,
MENU_D_ST, MENU_D_ST,
#ifdef ENABLE_DTMF_CALLING
MENU_D_RSP, MENU_D_RSP,
MENU_D_HOLD, MENU_D_HOLD,
#endif
MENU_D_PRE, MENU_D_PRE,
#ifdef ENABLE_DTMF_CALLING
MENU_D_DCD, MENU_D_DCD,
MENU_D_LIST, MENU_D_LIST,
#endif
MENU_D_LIVE_DEC, MENU_D_LIVE_DEC,
MENU_PONMSG, MENU_PONMSG,
MENU_ROGER, MENU_ROGER,
@@ -142,7 +148,9 @@ extern const char* gSubMenu_MDF[4];
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
extern const char gSubMenu_AL_MOD[2][5]; extern const char gSubMenu_AL_MOD[2][5];
#endif #endif
#ifdef ENABLE_DTMF_CALLING
extern const char gSubMenu_D_RSP[4][11]; extern const char gSubMenu_D_RSP[4][11];
#endif
extern const char* gSubMenu_PTT_ID[5]; extern const char* gSubMenu_PTT_ID[5];
extern const char gSubMenu_PONMSG[4][8]; extern const char gSubMenu_PONMSG[4][8];
extern const char gSubMenu_ROGER[3][6]; extern const char gSubMenu_ROGER[3][6];

View File

@@ -79,13 +79,16 @@ void UI_DisplayStatus()
#else #else
// hmmm, what to put in it's place // hmmm, what to put in it's place
#endif #endif
#ifdef ENABLE_DTMF_CALLING
if (gSetting_KILLED) if (gSetting_KILLED)
{ {
memset(line + x, 0xFF, 10); memset(line + x, 0xFF, 10);
x1 = x + 10; x1 = x + 10;
} }
else else
#endif
{
// SCAN indicator // SCAN indicator
if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning()) if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning())
{ {
@@ -105,6 +108,7 @@ void UI_DisplayStatus()
UI_PrintStringSmallBuffer(s, line + x); UI_PrintStringSmallBuffer(s, line + x);
x1 = x + 7; x1 = x + 7;
} }
}
x += 7; // font character width x += 7; // font character width
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE

View File

@@ -77,7 +77,7 @@ void UI_DisplayWelcome(void)
UI_PrintString(WelcomeString0, 0, 127, 0, 10); UI_PrintString(WelcomeString0, 0, 127, 0, 10);
UI_PrintString(WelcomeString1, 0, 127, 2, 10); UI_PrintString(WelcomeString1, 0, 127, 2, 10);
UI_PrintStringSmall(Version, 0, 0, 6); UI_PrintStringSmall(Version, 0, 128, 6);
ST7565_BlitStatusLine(); // blank status line ST7565_BlitStatusLine(); // blank status line
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();

View File

@@ -1,16 +1,11 @@
#define ONE_OF_ELEVEN_VER #ifdef VERSION_STRING
#define VER " "VERSION_STRING
#ifdef GIT_HASH
#define VER GIT_HASH
#else #else
#define VER "231004" #define VER ""
#endif #endif
#ifndef ONE_OF_ELEVEN_VER
const char Version[] = "OEFW-"VER; const char Version[] = AUTHOR_STRING VER;
const char UART_Version[] = "UV-K5 Firmware, Open Edition, OEFW-"VER"\r\n"; const char UART_Version[] = "UV-K5 Firmware, Open Edition, " AUTHOR_STRING VER "\r\n";
#else
const char Version[] = "1o11+fagci-"VER;
const char UART_Version[] = "UV-K5 Firmware, Open Edition, 1o11+fagci-"VER"\r\n";
#endif