Compare commits
150 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7607f0a4bd | ||
|
|
f2cdf1975f | ||
|
|
eeee11cf1b | ||
|
|
1da45d5a77 | ||
|
|
1098e8c386 | ||
|
|
ce2dd10d45 | ||
|
|
a22760c0b4 | ||
|
|
aa92e93c56 | ||
|
|
dc1808b1fe | ||
|
|
dff4384dbe | ||
|
|
f85ed9440d | ||
|
|
604a5b430f | ||
|
|
ed5ebc4854 | ||
|
|
c74c0d20fc | ||
|
|
46e2d1a0fd | ||
|
|
adbc466c49 | ||
|
|
f8ff71aaa3 | ||
|
|
ea3b5b23a9 | ||
|
|
8941576887 | ||
|
|
04b0bd8c93 | ||
|
|
4efabfc2b6 | ||
|
|
9472bbb58b | ||
|
|
685ecb062b | ||
|
|
3bf993d8b8 | ||
|
|
01ccaaf212 | ||
|
|
ed5ae7842b | ||
|
|
ac8c51d605 | ||
|
|
429cffc0bc | ||
|
|
fbdaf6631d | ||
|
|
f8feef1ad5 | ||
|
|
42a45a7ef2 | ||
|
|
3f012b3afe | ||
|
|
289418f1c7 | ||
|
|
ea733115de | ||
|
|
e5cff16d98 | ||
|
|
f35ce8d789 | ||
|
|
36ecde86e9 | ||
|
|
8f6e1be5e0 | ||
|
|
cceba5a474 | ||
|
|
1882ab0cc1 | ||
|
|
995045006f | ||
|
|
38ec40b0db | ||
|
|
cbf4a7c140 | ||
|
|
7a7010da55 | ||
|
|
78a45d9bbd | ||
|
|
f8ef687026 | ||
|
|
1281bbf033 | ||
|
|
edf1f983d6 | ||
|
|
b0d131d546 | ||
|
|
ab61c4e74f | ||
|
|
986c0ce368 | ||
|
|
e929a79765 | ||
|
|
d75209bad0 | ||
|
|
ee0ba9886d | ||
|
|
084fe4dd26 | ||
|
|
a715389a8b | ||
|
|
6f1cabc807 | ||
|
|
a08420a0b7 | ||
|
|
1f4f026162 | ||
|
|
34f2168856 | ||
|
|
bc9bb489e6 | ||
|
|
7d982f1f8d | ||
|
|
2cc60da9ab | ||
|
|
39eb3e835e | ||
|
|
0d66eb8577 | ||
|
|
13b6bb06b2 | ||
|
|
88f3537af0 | ||
|
|
de8c501d65 | ||
|
|
76bbaf9442 | ||
|
|
c4d9cfc895 | ||
|
|
2a75f8a9be | ||
|
|
e7a21c470f | ||
|
|
fc679c77a4 | ||
|
|
1151cf8667 | ||
|
|
af6b542da1 | ||
|
|
cc49a5007c | ||
|
|
a99d2dd1b1 | ||
|
|
9dc79ce868 | ||
|
|
80fa310646 | ||
|
|
7f5236c44e | ||
|
|
4b583bf2bd | ||
|
|
fa5d3c1594 | ||
|
|
1a53586922 | ||
|
|
687b63abb6 | ||
|
|
06f1c651bc | ||
|
|
33e4e3c4e0 | ||
|
|
93b97eff0a | ||
|
|
8638d37431 | ||
|
|
716e9e23b8 | ||
|
|
d0ae34f9b4 | ||
|
|
bd17aea72b | ||
|
|
34d688b101 | ||
|
|
8c7f736797 | ||
|
|
a19579a888 | ||
|
|
00a2bc75b8 | ||
|
|
268c4dece3 | ||
|
|
0c2fc6184c | ||
|
|
6bdce2d0e2 | ||
|
|
42a2e16e0e | ||
|
|
2e69acbdc4 | ||
|
|
eb6a3d0867 | ||
|
|
e22cc4ccd0 | ||
|
|
a153e63be1 | ||
|
|
4322a7d8a9 | ||
|
|
1203fdf0ca | ||
|
|
cfc4763dd1 | ||
|
|
b6a49db31d | ||
|
|
82ddbcd375 | ||
|
|
335c2ec9cd | ||
|
|
4249d917f8 | ||
|
|
2164461449 | ||
|
|
c3906f42f8 | ||
|
|
d055fb0024 | ||
|
|
c4ad9c6501 | ||
|
|
4fd1ab8899 | ||
|
|
0793b68971 | ||
|
|
f7061c3195 | ||
|
|
5e78916dd3 | ||
|
|
13c17ad073 | ||
|
|
c697596806 | ||
|
|
5c1cb4f2fc | ||
|
|
754d2ce5fb | ||
|
|
c76a96c3ad | ||
|
|
cd032c39d2 | ||
|
|
103bdf212f | ||
|
|
bafe372cbc | ||
|
|
88f7b90237 | ||
|
|
66f1f545c3 | ||
|
|
e5659ad6ab | ||
|
|
c1a009cc2f | ||
|
|
e95f577074 | ||
|
|
52bdd408c4 | ||
|
|
ed395ab638 | ||
|
|
86438ef3ce | ||
|
|
f3297c29cb | ||
|
|
e039e65ee4 | ||
|
|
e2b81bf9c8 | ||
|
|
9ca3ccd744 | ||
|
|
d944ff4a34 | ||
|
|
cfa745fda0 | ||
|
|
b505f81958 | ||
|
|
235a1a2f14 | ||
|
|
a4cefe3401 | ||
|
|
5a2086fcd0 | ||
|
|
c341570838 | ||
|
|
292e2e7e7e | ||
|
|
44ff33613a | ||
|
|
f9e10da9ee | ||
|
|
5ad8229d7c | ||
|
|
90609ca5c5 |
5
.gitignore
vendored
@@ -4,3 +4,8 @@ firmware
|
|||||||
/firmware.packed.bin
|
/firmware.packed.bin
|
||||||
/firmware.bin
|
/firmware.bin
|
||||||
/compiled-firmware
|
/compiled-firmware
|
||||||
|
.cache
|
||||||
|
compile_commands.json
|
||||||
|
.vscode
|
||||||
|
/docs
|
||||||
|
k5_eeprom.raw
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM archlinux:latest
|
FROM --platform=amd64 archlinux:latest
|
||||||
RUN pacman -Syyu base-devel --noconfirm
|
RUN pacman -Syyu base-devel --noconfirm
|
||||||
RUN pacman -Syyu arm-none-eabi-gcc --noconfirm
|
RUN pacman -Syyu arm-none-eabi-gcc --noconfirm
|
||||||
RUN pacman -Syyu arm-none-eabi-newlib --noconfirm
|
RUN pacman -Syyu arm-none-eabi-newlib --noconfirm
|
||||||
|
|||||||
17
Doxyfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
OUTPUT_DIRECTORY = docs
|
||||||
|
GENERATE_LATEX = NO
|
||||||
|
GENERATE_RTF = NO
|
||||||
|
GENERATE_MAN = NO
|
||||||
|
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||||
|
HAVE_DOT = YES
|
||||||
|
EXTRACT_ALL = YES
|
||||||
|
EXTRACT_PRIVATE = YES
|
||||||
|
EXTRACT_STATIC = YES
|
||||||
|
CALL_GRAPH = YES
|
||||||
|
CALLER_GRAPH = YES
|
||||||
|
DISABLE_INDEX = YES
|
||||||
|
GENERATE_TREEVIEW = YES
|
||||||
|
RECURSIVE = YES
|
||||||
|
COLLABORATION_GRAPH = YES
|
||||||
|
GRAPHICAL_HIERARCHY = YES
|
||||||
|
DOT_MULTI_TARGETS = YES
|
||||||
155
Makefile
@@ -2,44 +2,56 @@
|
|||||||
# compile options (see README.md for descriptions)
|
# compile options (see README.md for descriptions)
|
||||||
# 0 = disable
|
# 0 = disable
|
||||||
# 1 = enable
|
# 1 = enable
|
||||||
#
|
|
||||||
ENABLE_CLANG := 0
|
# ---- STOCK QUANSHENG FERATURES ----
|
||||||
ENABLE_SWD := 0
|
ENABLE_UART ?= 1
|
||||||
ENABLE_OVERLAY := 0
|
ENABLE_AIRCOPY ?= 0
|
||||||
ENABLE_LTO := 1
|
ENABLE_FMRADIO ?= 1
|
||||||
ENABLE_UART := 1
|
ENABLE_NOAA ?= 0
|
||||||
ENABLE_AIRCOPY := 0
|
ENABLE_VOICE ?= 0
|
||||||
ENABLE_FMRADIO := 1
|
ENABLE_VOX ?= 1
|
||||||
ENABLE_NOAA := 0
|
ENABLE_ALARM ?= 0
|
||||||
ENABLE_VOICE := 0
|
ENABLE_TX1750 ?= 0
|
||||||
ENABLE_VOX := 1
|
ENABLE_PWRON_PASSWORD ?= 0
|
||||||
ENABLE_ALARM := 0
|
ENABLE_DTMF_CALLING ?= 1
|
||||||
ENABLE_TX1750 := 0
|
ENABLE_FLASHLIGHT ?= 1
|
||||||
ENABLE_PWRON_PASSWORD := 0
|
|
||||||
ENABLE_BIG_FREQ := 1
|
# ---- CUSTOM MODS ----
|
||||||
ENABLE_SMALL_BOLD := 1
|
ENABLE_BIG_FREQ ?= 1
|
||||||
ENABLE_KEEP_MEM_NAME := 1
|
ENABLE_SMALL_BOLD ?= 1
|
||||||
ENABLE_WIDE_RX := 1
|
ENABLE_CUSTOM_MENU_LAYOUT ?= 1
|
||||||
ENABLE_TX_WHEN_AM := 0
|
ENABLE_KEEP_MEM_NAME ?= 1
|
||||||
ENABLE_F_CAL_MENU := 0
|
ENABLE_WIDE_RX ?= 1
|
||||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 0
|
ENABLE_TX_WHEN_AM ?= 0
|
||||||
ENABLE_BOOT_BEEPS := 0
|
ENABLE_F_CAL_MENU ?= 0
|
||||||
ENABLE_SHOW_CHARGE_LEVEL := 1
|
ENABLE_CTCSS_TAIL_PHASE_SHIFT ?= 0
|
||||||
ENABLE_REVERSE_BAT_SYMBOL := 0
|
ENABLE_BOOT_BEEPS ?= 0
|
||||||
ENABLE_NO_CODE_SCAN_TIMEOUT := 1
|
ENABLE_SHOW_CHARGE_LEVEL ?= 0
|
||||||
ENABLE_AM_FIX := 1
|
ENABLE_REVERSE_BAT_SYMBOL ?= 0
|
||||||
ENABLE_AM_FIX_SHOW_DATA := 0
|
ENABLE_NO_CODE_SCAN_TIMEOUT ?= 1
|
||||||
ENABLE_SQUELCH_MORE_SENSITIVE := 1
|
ENABLE_AM_FIX ?= 1
|
||||||
ENABLE_FASTER_CHANNEL_SCAN := 1
|
ENABLE_SQUELCH_MORE_SENSITIVE ?= 1
|
||||||
ENABLE_RSSI_BAR := 1
|
ENABLE_FASTER_CHANNEL_SCAN ?= 1
|
||||||
ENABLE_AUDIO_BAR := 1
|
ENABLE_RSSI_BAR ?= 1
|
||||||
ENABLE_COPY_CHAN_TO_VFO := 1
|
ENABLE_AUDIO_BAR ?= 1
|
||||||
ENABLE_SPECTRUM := 1
|
ENABLE_COPY_CHAN_TO_VFO ?= 1
|
||||||
ENABLE_REDUCE_LOW_MID_TX_POWER:= 0
|
ENABLE_SPECTRUM ?= 1
|
||||||
ENABLE_BYP_RAW_DEMODULATORS := 0
|
ENABLE_REDUCE_LOW_MID_TX_POWER?= 0
|
||||||
ENABLE_BLMIN_TMP_OFF := 0
|
ENABLE_BYP_RAW_DEMODULATORS ?= 0
|
||||||
ENABLE_SCAN_RANGES := 1
|
ENABLE_BLMIN_TMP_OFF ?= 0
|
||||||
ENABLE_DTMF_CALLING := 1
|
ENABLE_SCAN_RANGES ?= 1
|
||||||
|
|
||||||
|
# ---- DEBUGGING ----
|
||||||
|
ENABLE_AM_FIX_SHOW_DATA ?= 0
|
||||||
|
ENABLE_AGC_SHOW_DATA ?= 0
|
||||||
|
ENABLE_UART_RW_BK_REGS ?= 0
|
||||||
|
|
||||||
|
# ---- COMPILER/LINKER OPTIONS ----
|
||||||
|
ENABLE_CLANG ?= 0
|
||||||
|
ENABLE_SWD ?= 0
|
||||||
|
ENABLE_OVERLAY ?= 0
|
||||||
|
ENABLE_LTO ?= 1
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
TARGET = firmware
|
TARGET = firmware
|
||||||
@@ -104,6 +116,9 @@ OBJS += app/app.o
|
|||||||
OBJS += app/chFrScanner.o
|
OBJS += app/chFrScanner.o
|
||||||
OBJS += app/common.o
|
OBJS += app/common.o
|
||||||
OBJS += app/dtmf.o
|
OBJS += app/dtmf.o
|
||||||
|
ifeq ($(ENABLE_FLASHLIGHT),1)
|
||||||
|
OBJS += app/flashlight.o
|
||||||
|
endif
|
||||||
ifeq ($(ENABLE_FMRADIO),1)
|
ifeq ($(ENABLE_FMRADIO),1)
|
||||||
OBJS += app/fm.o
|
OBJS += app/fm.o
|
||||||
endif
|
endif
|
||||||
@@ -154,38 +169,30 @@ OBJS += ui/welcome.o
|
|||||||
OBJS += version.o
|
OBJS += version.o
|
||||||
OBJS += main.o
|
OBJS += main.o
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT) # windows
|
||||||
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
else
|
|
||||||
TOP := $(shell pwd)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef OS # windows
|
|
||||||
RM = del /Q
|
RM = del /Q
|
||||||
FixPath = $(subst /,\,$1)
|
FixPath = $(subst /,\,$1)
|
||||||
WHERE = where
|
WHERE = where
|
||||||
NULL_OUTPUT = nul
|
NULL_OUTPUT = nul
|
||||||
else # unix
|
else # unix
|
||||||
ifeq ($(shell uname), Linux)
|
TOP := $(shell pwd)
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
FixPath = $1
|
FixPath = $1
|
||||||
WHERE = which
|
WHERE = which
|
||||||
NULL_OUTPUT = /dev/null
|
NULL_OUTPUT = /dev/null
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
AS = arm-none-eabi-gcc
|
AS = arm-none-eabi-gcc
|
||||||
|
|
||||||
CC =
|
|
||||||
LD = arm-none-eabi-gcc
|
LD = arm-none-eabi-gcc
|
||||||
|
|
||||||
ifeq ($(ENABLE_CLANG),0)
|
ifeq ($(ENABLE_CLANG),0)
|
||||||
CC += arm-none-eabi-gcc
|
CC = arm-none-eabi-gcc
|
||||||
# Use GCC's linker to avoid undefined symbol errors
|
# Use GCC's linker to avoid undefined symbol errors
|
||||||
# LD += arm-none-eabi-gcc
|
# LD += arm-none-eabi-gcc
|
||||||
else
|
else
|
||||||
# May need to adjust this to match your system
|
# May need to adjust this to match your system
|
||||||
CC += clang --sysroot=/usr/arm-none-eabi --target=arm-none-eabi
|
CC = clang --sysroot=/usr/arm-none-eabi --target=arm-none-eabi
|
||||||
# Bloats binaries to 512MB
|
# Bloats binaries to 512MB
|
||||||
# LD = ld.lld
|
# LD = ld.lld
|
||||||
endif
|
endif
|
||||||
@@ -193,15 +200,20 @@ endif
|
|||||||
OBJCOPY = arm-none-eabi-objcopy
|
OBJCOPY = arm-none-eabi-objcopy
|
||||||
SIZE = arm-none-eabi-size
|
SIZE = arm-none-eabi-size
|
||||||
|
|
||||||
AUTHOR_STRING := EGZUMER
|
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)
|
||||||
ifneq (, $(shell $(WHERE) git))
|
ifneq (, $(shell $(WHERE) git))
|
||||||
VERSION_STRING := $(shell git describe --tags --exact-match 2>$(NULL_OUTPUT))
|
VERSION_STRING ?= $(shell git describe --tags --exact-match 2>$(NULL_OUTPUT))
|
||||||
ifeq (, $(VERSION_STRING))
|
ifeq (, $(VERSION_STRING))
|
||||||
VERSION_STRING := $(shell git rev-parse --short HEAD)
|
VERSION_STRING := $(shell git rev-parse --short HEAD)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
# If there is still no VERSION_STRING we need to make one.
|
||||||
|
# It is needed for the firmware packing script
|
||||||
|
ifeq (, $(VERSION_STRING))
|
||||||
|
VERSION_STRING := NOGIT
|
||||||
|
endif
|
||||||
#VERSION_STRING := 230930b
|
#VERSION_STRING := 230930b
|
||||||
|
|
||||||
|
|
||||||
@@ -212,17 +224,18 @@ endif
|
|||||||
|
|
||||||
CFLAGS =
|
CFLAGS =
|
||||||
ifeq ($(ENABLE_CLANG),0)
|
ifeq ($(ENABLE_CLANG),0)
|
||||||
CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD
|
||||||
|
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
||||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
|
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
|
||||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
|
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
|
||||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
|
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
|
||||||
else
|
else
|
||||||
# Oz needed to make it fit on flash
|
# Oz needed to make it fit on flash
|
||||||
CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_LTO),1)
|
ifeq ($(ENABLE_LTO),1)
|
||||||
CFLAGS += -flto=2
|
CFLAGS += -flto=auto
|
||||||
else
|
else
|
||||||
# We get most of the space savings if LTO creates problems
|
# We get most of the space savings if LTO creates problems
|
||||||
CFLAGS += -ffunction-sections -fdata-sections
|
CFLAGS += -ffunction-sections -fdata-sections
|
||||||
@@ -305,7 +318,7 @@ ifeq ($(ENABLE_REVERSE_BAT_SYMBOL),1)
|
|||||||
CFLAGS += -DENABLE_REVERSE_BAT_SYMBOL
|
CFLAGS += -DENABLE_REVERSE_BAT_SYMBOL
|
||||||
endif
|
endif
|
||||||
ifeq ($(ENABLE_NO_CODE_SCAN_TIMEOUT),1)
|
ifeq ($(ENABLE_NO_CODE_SCAN_TIMEOUT),1)
|
||||||
CFLAGS += -DENABLE_CODE_SCAN_TIMEOUT
|
CFLAGS += -DENABLE_NO_CODE_SCAN_TIMEOUT
|
||||||
endif
|
endif
|
||||||
ifeq ($(ENABLE_AM_FIX),1)
|
ifeq ($(ENABLE_AM_FIX),1)
|
||||||
CFLAGS += -DENABLE_AM_FIX
|
CFLAGS += -DENABLE_AM_FIX
|
||||||
@@ -313,9 +326,6 @@ endif
|
|||||||
ifeq ($(ENABLE_AM_FIX_SHOW_DATA),1)
|
ifeq ($(ENABLE_AM_FIX_SHOW_DATA),1)
|
||||||
CFLAGS += -DENABLE_AM_FIX_SHOW_DATA
|
CFLAGS += -DENABLE_AM_FIX_SHOW_DATA
|
||||||
endif
|
endif
|
||||||
ifeq ($(ENABLE_AM_FIX_TEST1),1)
|
|
||||||
CFLAGS += -DENABLE_AM_FIX_TEST1
|
|
||||||
endif
|
|
||||||
ifeq ($(ENABLE_SQUELCH_MORE_SENSITIVE),1)
|
ifeq ($(ENABLE_SQUELCH_MORE_SENSITIVE),1)
|
||||||
CFLAGS += -DENABLE_SQUELCH_MORE_SENSITIVE
|
CFLAGS += -DENABLE_SQUELCH_MORE_SENSITIVE
|
||||||
endif
|
endif
|
||||||
@@ -355,23 +365,25 @@ endif
|
|||||||
ifeq ($(ENABLE_DTMF_CALLING),1)
|
ifeq ($(ENABLE_DTMF_CALLING),1)
|
||||||
CFLAGS += -DENABLE_DTMF_CALLING
|
CFLAGS += -DENABLE_DTMF_CALLING
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(ENABLE_AGC_SHOW_DATA),1)
|
||||||
|
CFLAGS += -DENABLE_AGC_SHOW_DATA
|
||||||
|
endif
|
||||||
|
ifeq ($(ENABLE_FLASHLIGHT),1)
|
||||||
|
CFLAGS += -DENABLE_FLASHLIGHT
|
||||||
|
endif
|
||||||
|
ifeq ($(ENABLE_UART_RW_BK_REGS),1)
|
||||||
|
CFLAGS += -DENABLE_UART_RW_BK_REGS
|
||||||
|
endif
|
||||||
|
ifeq ($(ENABLE_CUSTOM_MENU_LAYOUT),1)
|
||||||
|
CFLAGS += -DENABLE_CUSTOM_MENU_LAYOUT
|
||||||
|
endif
|
||||||
|
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
ifeq ($(ENABLE_CLANG),0)
|
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld -Wl,--gc-sections
|
||||||
LDFLAGS += -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
|
||||||
else
|
|
||||||
# Fix warning about implied executable stack
|
|
||||||
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Use newlib-nano instead of newlib
|
# Use newlib-nano instead of newlib
|
||||||
LDFLAGS += --specs=nano.specs
|
LDFLAGS += --specs=nano.specs
|
||||||
|
|
||||||
ifeq ($(ENABLE_LTO),0)
|
|
||||||
# Throw away unneeded func/data sections like LTO does
|
|
||||||
LDFLAGS += -Wl,--gc-sections
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(DEBUG),1)
|
ifeq ($(DEBUG),1)
|
||||||
ASFLAGS += -g
|
ASFLAGS += -g
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
@@ -442,3 +454,6 @@ bsp/dp32g030/%.h: hardware/dp32g030/%.def
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(call FixPath, $(TARGET).bin $(TARGET).packed.bin $(TARGET) $(OBJS) $(DEPS))
|
$(RM) $(call FixPath, $(TARGET).bin $(TARGET).packed.bin $(TARGET) $(OBJS) $(DEPS))
|
||||||
|
|
||||||
|
doxygen:
|
||||||
|
doxygen
|
||||||
|
|||||||
196
README.md
@@ -1,12 +1,37 @@
|
|||||||
# Main features:
|
# Open re-implementation of the Quansheng UV-K5/K6/5R v2.1.27 firmware
|
||||||
|
|
||||||
|
This repository is a merge of [OneOfEleven custom firmware](https://github.com/OneOfEleven/uv-k5-firmware-custom) with [fagci spectrum analizer](https://github.com/fagci/uv-k5-firmware-fagci-mod/tree/refactor) plus my few changes.<br>
|
||||||
|
All is a cloned and customized version of DualTachyon's open firmware found [here](https://github.com/DualTachyon/uv-k5-firmware) ... a cool achievement !
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> There is a work done by others on forks of this repository. I encourage you to take a look at those too. [SEE HERE](https://github.com/egzumer/uv-k5-firmware-custom/discussions/485)
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Use this firmware at your own risk (entirely). There is absolutely no guarantee that it will work in any way shape or form on your radio(s), it may even brick your radio(s), in which case, you'd need to buy another radio.
|
||||||
|
Anyway, have fun.
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
* [Main Features](#main-features)
|
||||||
|
* [Manual](#manual)
|
||||||
|
* [Radio Performance](#radio-performance)
|
||||||
|
* [User Customization](#user-customization)
|
||||||
|
* [Compiler](#compiler)
|
||||||
|
* [Building](#building)
|
||||||
|
* [Credits](#credits)
|
||||||
|
* [Other sources of information](#other-sources-of-information)
|
||||||
|
* [License](#license)
|
||||||
|
* [Example changes/updates](#example-changesupdates)
|
||||||
|
|
||||||
|
## Main features:
|
||||||
* many of OneOfEleven mods:
|
* many of OneOfEleven mods:
|
||||||
* AM fix, huge improvement in reception quality
|
* AM fix, huge improvement in reception quality
|
||||||
* long press buttons functions replicating F+ action
|
* long press buttons functions replicating F+ action
|
||||||
* fast scanning
|
* fast scanning
|
||||||
* channel name editing in the menu
|
* channel name editing in the menu
|
||||||
* channel name + frequency display option
|
* channel name + frequency display option
|
||||||
* shortcut for scannlist assignment (longpress `5 NOAA`)
|
* shortcut for scan-list assignment (long press `5 NOAA`)
|
||||||
* scannlist toggle (longpress `* Scan` while scanning)
|
* scan-list toggle (long press `* Scan` while scanning)
|
||||||
* configurable button function selectable from menu
|
* configurable button function selectable from menu
|
||||||
* battery percentage/voltage on status bar, selectable from menu
|
* battery percentage/voltage on status bar, selectable from menu
|
||||||
* longer backlight times
|
* longer backlight times
|
||||||
@@ -18,46 +43,22 @@
|
|||||||
* some other mods introduced by me:
|
* some other mods introduced by me:
|
||||||
* SSB demodulation (adopted from fagci)
|
* SSB demodulation (adopted from fagci)
|
||||||
* backlight dimming
|
* backlight dimming
|
||||||
* battery voltage callibration from menu
|
* battery voltage calibration 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
|
||||||
* long press MENU as another configurable button
|
* long press 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 style s-meter
|
||||||
* 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
|
||||||
* reordered and renamed menu entries
|
* reordered and renamed menu entries
|
||||||
* LCD interference crash fix
|
* LCD interference crash fix
|
||||||
|
* many others...
|
||||||
|
|
||||||
# Manual
|
## Manual
|
||||||
|
|
||||||
* [Radio operation](https://github.com/egzumer/uv-k5-firmware-custom/wiki/Radio-operation)
|
Up to date manual is available in the [Wiki section](https://github.com/egzumer/uv-k5-firmware-custom/wiki)
|
||||||
|
|
||||||
* [Menu](https://github.com/egzumer/uv-k5-firmware-custom/wiki/Menu)
|
## Radio performance
|
||||||
|
|
||||||
* [Button functions](https://github.com/egzumer/uv-k5-firmware-custom/wiki/Button-functions)
|
|
||||||
|
|
||||||
* [Spectrum analyzer](https://github.com/egzumer/uv-k5-firmware-custom/wiki/Spectrum-analyzer)
|
|
||||||
|
|
||||||
* [Flashing the firmware](https://github.com/egzumer/uv-k5-firmware-custom/wiki/Flashing-the-firmware)
|
|
||||||
|
|
||||||
<img src="images/main.jpg" width=300 /><img src="images/spectrum.jpg" width=300 /><img src="images/audiobar.jpg" width=300 /><img src="images/rssibar.jpg" width=300 />
|
|
||||||
|
|
||||||
|
|
||||||
# Open reimplementation of the Quan Sheng UV-K5 v2.1.27 firmware
|
|
||||||
|
|
||||||
This repository is a merge of OneOfEleven custom firmware with fagci spectrum analizer plus my few changes.
|
|
||||||
|
|
||||||
https://github.com/OneOfEleven/uv-k5-firmware-custom<br>
|
|
||||||
https://github.com/fagci/uv-k5-firmware-fagci-mod/tree/refactor
|
|
||||||
|
|
||||||
All is a cloned and customized version of DualTachyon's open firmware found here ..
|
|
||||||
|
|
||||||
https://github.com/DualTachyon/uv-k5-firmware .. a cool achievement !
|
|
||||||
|
|
||||||
Use this firmware at your own risk (entirely). There is absolutely no guarantee that it will work in any way shape or form on your radio(s), it may even brick your radio(s), in which case, you'd need to buy another radio.
|
|
||||||
Anyway, have fun.
|
|
||||||
|
|
||||||
# Radio performance
|
|
||||||
|
|
||||||
Please note that the Quansheng UV-Kx radios are not professional quality transceivers, their
|
Please note that the Quansheng UV-Kx radios are not professional quality transceivers, their
|
||||||
performance is strictly limited. The RX front end has no track-tuned band pass filtering
|
performance is strictly limited. The RX front end has no track-tuned band pass filtering
|
||||||
@@ -68,57 +69,68 @@ easy (AM mode will suffer far more than FM ever will), the receiver simply doesn
|
|||||||
great dynamic range, which results in distorted AM audio with stronger RX'ed signals.
|
great dynamic range, which results in distorted AM audio with stronger RX'ed signals.
|
||||||
There is nothing more anyone can do in firmware/software to improve that, once the RX gain
|
There is nothing more anyone can do in firmware/software to improve that, once the RX gain
|
||||||
adjustment I do (AM fix) reaches the hardwares limit, your AM RX audio will be all but
|
adjustment I do (AM fix) reaches the hardwares limit, your AM RX audio will be all but
|
||||||
non-existant (just like Quansheng's firmware).
|
non-existent (just like Quansheng's firmware).
|
||||||
On the other hand, FM RX audio will/should be fine.
|
On the other hand, FM RX audio will/should be fine.
|
||||||
|
|
||||||
But, they are nice toys for the price, fun to play with.
|
But, they are nice toys for the price, fun to play with.
|
||||||
|
|
||||||
# User customization
|
## User customization
|
||||||
|
|
||||||
You can customize the firmware by enabling/disabling various compile options, this allows
|
You can customize the firmware by enabling/disabling various compile options, this allows
|
||||||
us to remove certain firmware features in order to make room in the flash for others.
|
us to remove certain firmware features in order to make room in the flash for others.
|
||||||
You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) ..
|
You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) ..
|
||||||
|
|
||||||
```
|
|
||||||
ENABLE_CLANG := 0 **experimental, builds with clang instead of gcc (LTO will be disabled if you enable this)
|
|
||||||
ENABLE_SWD := 0 only needed if using CPU's SWD port (debugging/programming)
|
|
||||||
ENABLE_OVERLAY := 0 cpu FLASH stuff, not needed
|
|
||||||
ENABLE_LTO := 0 **experimental, reduces size of compiled firmware but might break EEPROM reads (OVERLAY will be disabled if you enable this)
|
|
||||||
ENABLE_UART := 1 without this you can't configure radio via PC !
|
|
||||||
ENABLE_AIRCOPY := 0 easier to just enter frequency with butts
|
|
||||||
ENABLE_FMRADIO := 0 WBFM VHF broadcast band receiver
|
|
||||||
ENABLE_NOAA := 0 everything NOAA (only of any use in the USA)
|
|
||||||
ENABLE_VOICE := 0 want to hear voices ?
|
|
||||||
ENABLE_VOX := 0
|
|
||||||
ENABLE_ALARM := 0 TX alarms
|
|
||||||
ENABLE_1750HZ := 0 side key 1750Hz TX tone (older style repeater access)
|
|
||||||
ENABLE_PWRON_PASSWORD := 1 power-on password stuff
|
|
||||||
ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware)
|
|
||||||
ENABLE_SMALL_BOLD := 1 bold channel name/no. (when name + freq channel display mode)
|
|
||||||
ENABLE_KEEP_MEM_NAME := 1 maintain channel name when (re)saving memory channel
|
|
||||||
ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though front-end/PA not designed for full range)
|
|
||||||
ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM
|
|
||||||
ENABLE_F_CAL_MENU := 0 enable the radios hidden frequency calibration menu
|
|
||||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 standard CTCSS tail phase shift rather than QS's own 55Hz tone method
|
|
||||||
ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up
|
|
||||||
ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio is on charge
|
|
||||||
ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right)
|
|
||||||
ENABLE_NO_CODE_SCAN_TIMEOUT := 1 disable 32-sec CTCSS/DCS scan timeout (press exit butt instead of time-out to end scan)
|
|
||||||
ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to helo prevent AM demodulator saturation, ignore the on-screen RSSI level (for now)
|
|
||||||
ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix (still tweaking it)
|
|
||||||
ENABLE_SQUELCH_MORE_SENSITIVE := 0 make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves
|
|
||||||
ENABLE_FASTER_CHANNEL_SCAN := 0 increases the channel scan speed, but the squelch is also made more twitchy
|
|
||||||
ENABLE_RSSI_BAR := 1 enable a dBm/Sn RSSI bar graph level inplace of the little antenna symbols
|
|
||||||
ENABLE_AUDIO_BAR := 0 experimental, display an audio bar level when TX'ing
|
|
||||||
ENABLE_COPY_CHAN_TO_VFO := 1 copy current channel into the other VFO. Long press `1 BAND` when in channel mode
|
|
||||||
ENABLE_SPECTRUM := 1 fagci spectrum analizer, activated with `F` + `5 NOAA`
|
|
||||||
ENABLE_REDUCE_LOW_MID_TX_POWER:= 0 makes medium and low power settings even lower
|
|
||||||
ENABLE_BYP_RAW_DEMODULATORS := 0 additional BYP (bypass?) and RAW demodulation options, prooved not to be very usefull, but it is there if you want to experiment
|
|
||||||
ENABLE_BLMIN_TMP_OFF := 0 additional function for configurable buttons that toggles `BLMin` on and off wihout saving it to the EEPROM
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|Build option | Description |
|
||||||
|
| --- | ---- |
|
||||||
|
|🧰 **STOCK QUANSHENG FEATURES**||
|
||||||
|
| ENABLE_UART | without this you can't configure radio via PC ! |
|
||||||
|
| ENABLE_AIRCOPY | easier to just enter frequency with butts |
|
||||||
|
| ENABLE_FMRADIO | WBFM VHF broadcast band receiver |
|
||||||
|
| ENABLE_NOAA | everything NOAA (only of any use in the USA) |
|
||||||
|
| ENABLE_VOICE | want to hear voices ? |
|
||||||
|
| ENABLE_VOX | |
|
||||||
|
| ENABLE_ALARM | TX alarms |
|
||||||
|
| ENABLE_TX1750 | side key 1750Hz TX tone (older style repeater access)|
|
||||||
|
| ENABLE_PWRON_PASSWORD | power-on password stuff |
|
||||||
|
| ENABLE_DTMF_CALLING | DTMF calling fuctionality, sending calls, receiving calls, group calls, contacts list etc. |
|
||||||
|
| ENABLE_FLASHLIGHT | enable top flashlight LED (on, blink, SOS) |
|
||||||
|
|🧰 **CUSTOM MODS**||
|
||||||
|
| ENABLE_BIG_FREQ | big font frequencies (like original QS firmware) |
|
||||||
|
| ENABLE_SMALL_BOLD | bold channel name/no. (when name + freq channel display mode) |
|
||||||
|
| ENABLE_CUSTOM_MENU_LAYOUT | changes how the menu looks like |
|
||||||
|
| ENABLE_KEEP_MEM_NAME | maintain channel name when (re)saving memory channel|
|
||||||
|
| ENABLE_WIDE_RX | full 18MHz to 1300MHz RX (though front-end/PA not designed for full range)|
|
||||||
|
| ENABLE_TX_WHEN_AM | allow TX (always FM) when RX is set to AM|
|
||||||
|
| ENABLE_F_CAL_MENU | enable the radios hidden frequency calibration menu |
|
||||||
|
| ENABLE_CTCSS_TAIL_PHASE_SHIFT | standard CTCSS tail phase shift rather than QS's own 55Hz tone method|
|
||||||
|
| ENABLE_BOOT_BEEPS | gives user audio feedback on volume knob position at boot-up |
|
||||||
|
| ENABLE_SHOW_CHARGE_LEVEL | show the charge level when the radio is on charge |
|
||||||
|
| ENABLE_REVERSE_BAT_SYMBOL | mirror the battery symbol on the status bar (+ pole on the right) |
|
||||||
|
| ENABLE_NO_CODE_SCAN_TIMEOUT | disable 32-sec CTCSS/DCS scan timeout (press exit butt instead of time-out to end scan) |
|
||||||
|
| ENABLE_AM_FIX | dynamically adjust the front end gains when in AM mode to help prevent AM demodulator saturation, ignore the on-screen RSSI level (for now) |
|
||||||
|
| ENABLE_AM_FIX_SHOW_DATA | show debug data for the AM fix |
|
||||||
|
| ENABLE_SQUELCH_MORE_SENSITIVE | make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves |
|
||||||
|
| ENABLE_FASTER_CHANNEL_SCAN | increases the channel scan speed, but the squelch is also made more twitchy |
|
||||||
|
| ENABLE_RSSI_BAR | enable a dBm/Sn RSSI bar graph level in place of the little antenna symbols |
|
||||||
|
| ENABLE_AUDIO_BAR | experimental, display an audio bar level when TX'ing |
|
||||||
|
| ENABLE_COPY_CHAN_TO_VFO | copy current channel settings into frequency mode. Long press `1 BAND` when in channel mode |
|
||||||
|
| ENABLE_SPECTRUM | fagci spectrum analyzer, activated with `F` + `5 NOAA`|
|
||||||
|
| ENABLE_REDUCE_LOW_MID_TX_POWER | makes medium and low power settings even lower |
|
||||||
|
| ENABLE_BYP_RAW_DEMODULATORS | additional BYP (bypass?) and RAW demodulation options, proved not to be very useful, but it is there if you want to experiment |
|
||||||
|
| ENABLE_BLMIN_TMP_OFF | additional function for configurable buttons that toggles `BLMin` on and off wihout saving it to the EEPROM |
|
||||||
|
| ENABLE_SCAN_RANGES | scan range mode for frequency scanning, see wiki for instructions (radio operation -> frequency scanning) |
|
||||||
|
|🧰 **DEBUGGING** ||
|
||||||
|
| ENABLE_AM_FIX_SHOW_DATA| displays settings used by AM-fix when AM transmission is received |
|
||||||
|
| ENABLE_AGC_SHOW_DATA | displays AGC settings |
|
||||||
|
| ENABLE_UART_RW_BK_REGS | adds 2 extra commands that allow to read and write BK4819 registers |
|
||||||
|
|🧰 **COMPILER/LINKER OPTIONS**||
|
||||||
|
| ENABLE_CLANG | **experimental, builds with clang instead of gcc (LTO will be disabled if you enable this) |
|
||||||
|
| ENABLE_SWD | only needed if using CPU's SWD port (debugging/programming) |
|
||||||
|
| ENABLE_OVERLAY | cpu FLASH stuff, not needed |
|
||||||
|
| ENABLE_LTO | reduces size of compiled firmware but might break EEPROM reads (OVERLAY will be disabled if you enable this) |
|
||||||
|
|
||||||
# Compiler
|
## Compiler
|
||||||
|
|
||||||
arm-none-eabi GCC version 10.3.1 is recommended, which is the current version on Ubuntu 22.04.03 LTS.
|
arm-none-eabi GCC version 10.3.1 is recommended, which is the current version on Ubuntu 22.04.03 LTS.
|
||||||
Other versions may generate a flash file that is too big.
|
Other versions may generate a flash file that is too big.
|
||||||
@@ -127,12 +139,33 @@ You can get an appropriate version from: https://developer.arm.com/downloads/-/g
|
|||||||
clang may be used but isn't fully supported. Resulting binaries may also be bigger.
|
clang may be used but isn't fully supported. Resulting binaries may also be bigger.
|
||||||
You can get it from: https://releases.llvm.org/download.html
|
You can get it from: https://releases.llvm.org/download.html
|
||||||
|
|
||||||
# Building
|
## Building
|
||||||
|
|
||||||
If you have docker installed you can use `compile-with-docker.bat`, the output files are created in `compiled-firmware` folder. This method gives significantly smaller binaries, I've seen differences up to 1kb, so it can fit more functionalities this way. The challange can be (or not) installing the docker itself.
|
### Github Codespace build method
|
||||||
|
|
||||||
|
This is the least demanding option as you don't have to install enything on your computer. All you need is Github account.
|
||||||
|
|
||||||
To compile directly in windows:
|
1. Go to https://github.com/egzumer/uv-k5-firmware-custom
|
||||||
|
1. Click green `Code` button
|
||||||
|
1. Change tab from `Local` to `Codespace`
|
||||||
|
1. Click green `Create codespace on main` button
|
||||||
|
|
||||||
|
<img src="images/codespace1.png" width=700 />
|
||||||
|
|
||||||
|
5. Open `Makefile`
|
||||||
|
1. Edit build options, save `Makefile` changes
|
||||||
|
1. Run `./compile-with-docker.sh` in terminal window
|
||||||
|
1. Open folder `compiled-firmware`
|
||||||
|
1. Right click `firmware.packed.bin`
|
||||||
|
1. Click `Download`, now you should have a firmware on your computer that you can proceed to flash on your radio. You can use [online flasher](https://egzumer.github.io/uvtools)
|
||||||
|
|
||||||
|
<img src="images/codespace2.png" width=700 />
|
||||||
|
|
||||||
|
### Docker build method
|
||||||
|
|
||||||
|
If you have docker installed you can use [compile-with-docker.bat](./compile-with-docker.bat) (Windows) or [compile-with-docker.sh](./compile-with-docker.sh) (Linux/Mac), the output files are created in `compiled-firmware` folder. This method gives significantly smaller binaries, I've seen differences up to 1kb, so it can fit more functionalities this way. The challenge can be (or not) installing docker itself.
|
||||||
|
|
||||||
|
### Windows environment build method
|
||||||
|
|
||||||
1. Open windows command line and run:
|
1. Open windows command line and run:
|
||||||
```
|
```
|
||||||
@@ -159,7 +192,7 @@ To compile directly in windows:
|
|||||||
|
|
||||||
I've left some notes in the win_make.bat file to maybe help with stuff.
|
I've left some notes in the win_make.bat file to maybe help with stuff.
|
||||||
|
|
||||||
# Credits
|
## Credits
|
||||||
|
|
||||||
Many thanks to various people on Telegram for putting up with me during this effort and helping:
|
Many thanks to various people on Telegram for putting up with me during this effort and helping:
|
||||||
|
|
||||||
@@ -177,7 +210,12 @@ Many thanks to various people on Telegram for putting up with me during this eff
|
|||||||
* @d1ced95
|
* @d1ced95
|
||||||
* and others I forget
|
* and others I forget
|
||||||
|
|
||||||
# License
|
## Other sources of information
|
||||||
|
|
||||||
|
[ludwich66 - Quansheng UV-K5 Wiki](https://github.com/ludwich66/Quansheng_UV-K5_Wiki/wiki)<br>
|
||||||
|
[amnemonic - tools and sources of information](https://github.com/amnemonic/Quansheng_UV-K5_Firmware)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
Copyright 2023 Dual Tachyon
|
Copyright 2023 Dual Tachyon
|
||||||
https://github.com/DualTachyon
|
https://github.com/DualTachyon
|
||||||
@@ -194,7 +232,7 @@ You may obtain a copy of the License at
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
# Example changes/updates
|
## Example changes/updates
|
||||||
|
|
||||||
<p float="left">
|
<p float="left">
|
||||||
<img src="/images/image1.png" width=300 />
|
<img src="/images/image1.png" width=300 />
|
||||||
|
|||||||
418
am_fix.c
@@ -29,6 +29,10 @@
|
|||||||
#include "frequencies.h"
|
#include "frequencies.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#ifdef ENABLE_AGC_SHOW_DATA
|
||||||
|
#include "ui/main.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
|
|
||||||
@@ -44,9 +48,9 @@
|
|||||||
//
|
//
|
||||||
// <9:8> = LNA Gain Short
|
// <9:8> = LNA Gain Short
|
||||||
// 3 = 0dB < original value
|
// 3 = 0dB < original value
|
||||||
// 2 = -24dB // was -11
|
// 2 = -19dB // was -11
|
||||||
// 1 = -30dB // was -16
|
// 1 = -24dB // was -16
|
||||||
// 0 = -33dB // was -19
|
// 0 = -28dB // was -19
|
||||||
//
|
//
|
||||||
// <7:5> = LNA Gain
|
// <7:5> = LNA Gain
|
||||||
// 7 = 0dB
|
// 7 = 0dB
|
||||||
@@ -81,223 +85,169 @@
|
|||||||
//
|
//
|
||||||
// these 4 tables need a measuring/calibration update
|
// these 4 tables need a measuring/calibration update
|
||||||
//
|
//
|
||||||
//
|
|
||||||
// QUESTION: why do I have to surround the negative numbers in brackets ???
|
|
||||||
// if I don't add the brackets, reading the table returns unexpected/different values !!!
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//// static const int16_t lna_short_dB[] = { -19, -16, -11, 0}; // was (but wrong)
|
//// static const int16_t lna_short_dB[] = { -19, -16, -11, 0}; // was (but wrong)
|
||||||
// static const int16_t lna_short_dB[] = { (-33), (-30), (-24), 0}; // corrected'ish
|
// static const int16_t lna_short_dB[] = { (-28), (-24), (-19), 0}; // corrected'ish
|
||||||
// static const int16_t lna_dB[] = { (-24), (-19), (-14), ( -9), (-6), (-4), (-2), 0};
|
// static const int16_t lna_dB[] = { (-24), (-19), (-14), ( -9), (-6), (-4), (-2), 0};
|
||||||
// static const int16_t mixer_dB[] = { ( -8), ( -6), ( -3), 0};
|
// static const int16_t mixer_dB[] = { ( -8), ( -6), ( -3), 0};
|
||||||
// static const int16_t pga_dB[] = { (-33), (-27), (-21), (-15), (-9), (-6), (-3), 0};
|
// static const int16_t pga_dB[] = { (-33), (-27), (-21), (-15), (-9), (-6), (-3), 0};
|
||||||
|
|
||||||
// lookup table is hugely easier than writing code to do the same
|
// lookup table is hugely easier than writing code to do the same
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#define LOOKUP_TABLE 1
|
||||||
|
|
||||||
|
#if LOOKUP_TABLE
|
||||||
static const t_gain_table gain_table[] =
|
static const t_gain_table gain_table[] =
|
||||||
{
|
{
|
||||||
{0x035E, -17}, // 0 .. 3 2 3 6 .. 0dB -14dB 0dB -3dB .. -17dB original
|
{0x03BE, -7}, // 0 .. 3 5 3 6 .. 0dB -4dB 0dB -3dB .. -7dB original
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
{0x0000,-93}, // 1 .. 0 0 0 0 .. -28dB -24dB -8dB -33dB .. -93dB
|
||||||
|
{0x0008,-91}, // 2 .. 0 0 1 0 .. -28dB -24dB -6dB -33dB .. -91dB
|
||||||
// test table that lets me manually set the lna-short register
|
{0x0010,-88}, // 3 .. 0 0 2 0 .. -28dB -24dB -3dB -33dB .. -88dB
|
||||||
// to measure it's actual dB change using an RF signal generator
|
{0x0001,-87}, // 4 .. 0 0 0 1 .. -28dB -24dB -8dB -27dB .. -87dB
|
||||||
|
{0x0009,-85}, // 5 .. 0 0 1 1 .. -28dB -24dB -6dB -27dB .. -85dB
|
||||||
{0x005E, -50}, // 1 .. 0 2 3 6 .. -33dB -14dB 0dB -3dB .. -50dB
|
{0x0011,-82}, // 6 .. 0 0 2 1 .. -28dB -24dB -3dB -27dB .. -82dB
|
||||||
{0x015E, -47}, // 2 .. 1 2 3 6 .. -30dB -14dB 0dB -3dB .. -47dB
|
{0x0002,-81}, // 7 .. 0 0 0 2 .. -28dB -24dB -8dB -21dB .. -81dB
|
||||||
{0x025E, -41}, // 3 .. 2 2 3 6 .. -24dB -14dB 0dB -3dB .. -41dB
|
{0x000A,-79}, // 8 .. 0 0 1 2 .. -28dB -24dB -6dB -21dB .. -79dB
|
||||||
{0x035E, -17} // 4 .. 3 2 3 6 .. 0dB -14dB 0dB -3dB .. -17dB original
|
{0x0012,-76}, // 9 .. 0 0 2 2 .. -28dB -24dB -3dB -21dB .. -76dB
|
||||||
|
{0x0003,-75}, // 10 .. 0 0 0 3 .. -28dB -24dB -8dB -15dB .. -75dB
|
||||||
|
{0x000B,-73}, // 11 .. 0 0 1 3 .. -28dB -24dB -6dB -15dB .. -73dB
|
||||||
|
{0x0013,-70}, // 12 .. 0 0 2 3 .. -28dB -24dB -3dB -15dB .. -70dB
|
||||||
|
{0x0004,-69}, // 13 .. 0 0 0 4 .. -28dB -24dB -8dB -9dB .. -69dB
|
||||||
|
{0x000C,-67}, // 14 .. 0 0 1 4 .. -28dB -24dB -6dB -9dB .. -67dB
|
||||||
|
{0x000D,-64}, // 15 .. 0 0 1 5 .. -28dB -24dB -6dB -6dB .. -64dB
|
||||||
|
{0x001C,-61}, // 16 .. 0 0 3 4 .. -28dB -24dB 0dB - 9dB .. -61dB
|
||||||
|
{0x001D,-58}, // 17 .. 0 0 3 5 .. -28dB -24dB 0dB -6dB .. -58dB
|
||||||
|
{0x001E,-55}, // 18 .. 0 0 3 6 .. -28dB -24dB 0dB -3dB .. -55dB
|
||||||
|
{0x001F,-52}, // 19 .. 0 0 3 7 .. -28dB -24dB 0dB 0dB .. -52dB
|
||||||
|
{0x003E,-50}, // 20 .. 0 1 3 6 .. -28dB -19dB 0dB -3dB .. -50dB
|
||||||
|
{0x003F,-47}, // 21 .. 0 1 3 7 .. -28dB -19dB 0dB 0dB .. -47dB
|
||||||
|
{0x005E,-45}, // 22 .. 0 2 3 6 .. -28dB -14dB 0dB -3dB .. -45dB
|
||||||
|
{0x005F,-42}, // 23 .. 0 2 3 7 .. -28dB -14dB 0dB 0dB .. -42dB
|
||||||
|
{0x007E,-40}, // 24 .. 0 3 3 6 .. -28dB -9dB 0dB -3dB .. -40dB
|
||||||
|
{0x007F,-37}, // 25 .. 0 3 3 7 .. -28dB -9dB 0dB 0dB .. -37dB
|
||||||
|
{0x009F,-34}, // 26 .. 0 4 3 7 .. -28dB -6dB 0dB 0dB .. -34dB
|
||||||
|
{0x00BF,-32}, // 27 .. 0 5 3 7 .. -28dB -4dB 0dB 0dB .. -32dB
|
||||||
|
{0x00DF,-30}, // 28 .. 0 6 3 7 .. -28dB -2dB 0dB 0dB .. -30dB
|
||||||
|
{0x00FF,-28}, // 29 .. 0 7 3 7 .. -28dB 0dB 0dB 0dB .. -28dB
|
||||||
|
{0x01DF,-26}, // 30 .. 1 6 3 7 .. -24dB -2dB 0dB 0dB .. -26dB
|
||||||
|
{0x01FF,-24}, // 31 .. 1 7 3 7 .. -24dB 0dB 0dB 0dB .. -24dB
|
||||||
|
{0x02BF,-23}, // 32 .. 2 5 3 7 .. -19dB -4dB 0dB 0dB .. -23dB
|
||||||
|
{0x02DF,-21}, // 33 .. 2 6 3 7 .. -19dB -2dB 0dB -0dB .. -21dB
|
||||||
|
{0x02FF,-19}, // 34 .. 2 7 3 7 .. -19dB 0dB 0dB 0dB .. -19dB
|
||||||
|
{0x035E,-17}, // 35 .. 3 2 3 6 .. 0dB -14dB 0dB -3dB .. -17dB
|
||||||
|
{0x035F,-14}, // 36 .. 3 2 3 7 .. 0dB -14dB 0dB 0dB .. -14dB
|
||||||
|
{0x037E,-12}, // 37 .. 3 3 3 6 .. 0dB -9dB 0dB -3dB .. -12dB
|
||||||
|
{0x037F,-9}, // 38 .. 3 3 3 7 .. 0dB -9dB 0dB 0dB .. -9dB
|
||||||
|
{0x038F,-6}, // 39 .. 3 4 3 7 .. 0dB - 6dB 0dB 0dB .. -6dB
|
||||||
|
{0x03BF,-4}, // 40 .. 3 5 3 7 .. 0dB -4dB 0dB 0dB .. -4dB
|
||||||
|
{0x03DF,-2}, // 41 .. 3 6 3 7 .. 0dB - 2dB 0dB 0dB .. -2dB
|
||||||
|
{0x03FF,0} // 42 .. 3 7 3 7 .. 0dB 0dB 0dB 0dB .. 0dB
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned int original_index = 1;
|
const uint8_t gain_table_size = ARRAY_SIZE(gain_table);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
{0x0000, -98}, // 1 .. 0 0 0 0 .. -33dB -24dB -8dB -33dB .. -98dB
|
t_gain_table gain_table[100] = {{0x03BE, -7}}; //original
|
||||||
{0x0008, -96}, // 2 .. 0 0 1 0 .. -33dB -24dB -6dB -33dB .. -96dB
|
uint8_t gain_table_size = 0;
|
||||||
{0x0100, -95}, // 3 .. 1 0 0 0 .. -30dB -24dB -8dB -33dB .. -95dB
|
|
||||||
{0x0020, -93}, // 4 .. 0 1 0 0 .. -33dB -19dB -8dB -33dB .. -93dB
|
void CreateTable()
|
||||||
{0x0001, -92}, // 5 .. 0 0 0 1 .. -33dB -24dB -8dB -27dB .. -92dB
|
{
|
||||||
{0x0028, -91}, // 6 .. 0 1 1 0 .. -33dB -19dB -6dB -33dB .. -91dB
|
typedef union {
|
||||||
{0x0009, -90}, // 7 .. 0 0 1 1 .. -33dB -24dB -6dB -27dB .. -90dB
|
struct {
|
||||||
{0x0101, -89}, // 8 .. 1 0 0 1 .. -30dB -24dB -8dB -27dB .. -89dB
|
uint8_t pgaIdx:3;
|
||||||
{0x0030, -88}, // 9 .. 0 1 2 0 .. -33dB -19dB -3dB -33dB .. -88dB
|
uint8_t mixerIdx:2;
|
||||||
{0x0118, -87}, // 10 .. 1 0 3 0 .. -30dB -24dB 0dB -33dB .. -87dB
|
uint8_t lnaIdx:3;
|
||||||
{0x0002, -86}, // 11 .. 0 0 0 2 .. -33dB -24dB -8dB -21dB .. -86dB
|
uint8_t lnaSIdx:2;
|
||||||
{0x0130, -85}, // 12 .. 1 1 2 0 .. -30dB -19dB -3dB -33dB .. -85dB
|
|
||||||
{0x0019, -84}, // 13 .. 0 0 3 1 .. -33dB -24dB 0dB -27dB .. -84dB
|
|
||||||
{0x0060, -83}, // 14 .. 0 3 0 0 .. -33dB -9dB -8dB -33dB .. -83dB
|
|
||||||
{0x0138, -82}, // 15 .. 1 1 3 0 .. -30dB -19dB 0dB -33dB .. -82dB
|
|
||||||
{0x0119, -81}, // 16 .. 1 0 3 1 .. -30dB -24dB 0dB -27dB .. -81dB
|
|
||||||
{0x0058, -80}, // 17 .. 0 2 3 0 .. -33dB -14dB 0dB -33dB .. -80dB
|
|
||||||
{0x0141, -79}, // 18 .. 1 2 0 1 .. -30dB -14dB -8dB -27dB .. -79dB
|
|
||||||
{0x0070, -78}, // 19 .. 0 3 2 0 .. -33dB -9dB -3dB -33dB .. -78dB
|
|
||||||
{0x0180, -77}, // 20 .. 1 4 0 0 .. -30dB -6dB -8dB -33dB .. -77dB
|
|
||||||
{0x0139, -76}, // 21 .. 1 1 3 1 .. -30dB -19dB 0dB -27dB .. -76dB
|
|
||||||
{0x0013, -75}, // 22 .. 0 0 2 3 .. -33dB -24dB -3dB -15dB .. -75dB
|
|
||||||
{0x0161, -74}, // 23 .. 1 3 0 1 .. -30dB -9dB -8dB -27dB .. -74dB
|
|
||||||
{0x01C0, -73}, // 24 .. 1 6 0 0 .. -30dB -2dB -8dB -33dB .. -73dB
|
|
||||||
{0x00E8, -72}, // 25 .. 0 7 1 0 .. -33dB 0dB -6dB -33dB .. -72dB
|
|
||||||
{0x00D0, -71}, // 26 .. 0 6 2 0 .. -33dB -2dB -3dB -33dB .. -71dB
|
|
||||||
{0x0239, -70}, // 27 .. 2 1 3 1 .. -24dB -19dB 0dB -27dB .. -70dB
|
|
||||||
{0x006A, -69}, // 28 .. 0 3 1 2 .. -33dB -9dB -6dB -21dB .. -69dB
|
|
||||||
{0x0006, -68}, // 29 .. 0 0 0 6 .. -33dB -24dB -8dB -3dB .. -68dB
|
|
||||||
{0x00B1, -67}, // 30 .. 0 5 2 1 .. -33dB -4dB -3dB -27dB .. -67dB
|
|
||||||
{0x000E, -66}, // 31 .. 0 0 1 6 .. -33dB -24dB -6dB -3dB .. -66dB
|
|
||||||
{0x015A, -65}, // 32 .. 1 2 3 2 .. -30dB -14dB 0dB -21dB .. -65dB
|
|
||||||
{0x022B, -64}, // 33 .. 2 1 1 3 .. -24dB -19dB -6dB -15dB .. -64dB
|
|
||||||
{0x01F8, -63}, // 34 .. 1 7 3 0 .. -30dB 0dB 0dB -33dB .. -63dB
|
|
||||||
{0x0163, -62}, // 35 .. 1 3 0 3 .. -30dB -9dB -8dB -15dB .. -62dB
|
|
||||||
{0x0035, -61}, // 36 .. 0 1 2 5 .. -33dB -19dB -3dB -6dB .. -61dB
|
|
||||||
{0x0214, -60}, // 37 .. 2 0 2 4 .. -24dB -24dB -3dB -9dB .. -60dB
|
|
||||||
{0x01D9, -59}, // 38 .. 1 6 3 1 .. -30dB -2dB 0dB -27dB .. -59dB
|
|
||||||
{0x0145, -58}, // 39 .. 1 2 0 5 .. -30dB -14dB -8dB -6dB .. -58dB
|
|
||||||
{0x02A2, -57}, // 40 .. 2 5 0 2 .. -24dB -4dB -8dB -21dB .. -57dB
|
|
||||||
{0x02D1, -56}, // 41 .. 2 6 2 1 .. -24dB -2dB -3dB -27dB .. -56dB
|
|
||||||
{0x00B3, -55}, // 42 .. 0 5 2 3 .. -33dB -4dB -3dB -15dB .. -55dB
|
|
||||||
{0x0216, -54}, // 43 .. 2 0 2 6 .. -24dB -24dB -3dB -3dB .. -54dB
|
|
||||||
{0x0066, -53}, // 44 .. 0 3 0 6 .. -33dB -9dB -8dB -3dB .. -53dB
|
|
||||||
{0x00C4, -52}, // 45 .. 0 6 0 4 .. -33dB -2dB -8dB -9dB .. -52dB
|
|
||||||
{0x006E, -51}, // 46 .. 0 3 1 6 .. -33dB -9dB -6dB -3dB .. -51dB
|
|
||||||
{0x015D, -50}, // 47 .. 1 2 3 5 .. -30dB -14dB 0dB -6dB .. -50dB
|
|
||||||
{0x00AD, -49}, // 48 .. 0 5 1 5 .. -33dB -4dB -6dB -6dB .. -49dB
|
|
||||||
{0x007D, -48}, // 49 .. 0 3 3 5 .. -33dB -9dB 0dB -6dB .. -48dB
|
|
||||||
{0x00D4, -47}, // 50 .. 0 6 2 4 .. -33dB -2dB -3dB -9dB .. -47dB
|
|
||||||
{0x01B4, -46}, // 51 .. 1 5 2 4 .. -30dB -4dB -3dB -9dB .. -46dB
|
|
||||||
{0x030B, -45}, // 52 .. 3 0 1 3 .. 0dB -24dB -6dB -15dB .. -45dB
|
|
||||||
{0x00CE, -44}, // 53 .. 0 6 1 6 .. -33dB -2dB -6dB -3dB .. -44dB
|
|
||||||
{0x01B5, -43}, // 54 .. 1 5 2 5 .. -30dB -4dB -3dB -6dB .. -43dB
|
|
||||||
{0x0097, -42}, // 55 .. 0 4 2 7 .. -33dB -6dB -3dB 0dB .. -42dB
|
|
||||||
{0x0257, -41}, // 56 .. 2 2 2 7 .. -24dB -14dB -3dB 0dB .. -41dB
|
|
||||||
{0x02B4, -40}, // 57 .. 2 5 2 4 .. -24dB -4dB -3dB -9dB .. -40dB
|
|
||||||
{0x027D, -39}, // 58 .. 2 3 3 5 .. -24dB -9dB 0dB -6dB .. -39dB
|
|
||||||
{0x01DD, -38}, // 59 .. 1 6 3 5 .. -30dB -2dB 0dB -6dB .. -38dB
|
|
||||||
{0x02AE, -37}, // 60 .. 2 5 1 6 .. -24dB -4dB -6dB -3dB .. -37dB
|
|
||||||
{0x0379, -36}, // 61 .. 3 3 3 1 .. 0dB -9dB 0dB -27dB .. -36dB
|
|
||||||
{0x035A, -35}, // 62 .. 3 2 3 2 .. 0dB -14dB 0dB -21dB .. -35dB
|
|
||||||
{0x02B6, -34}, // 63 .. 2 5 2 6 .. -24dB -4dB -3dB -3dB .. -34dB
|
|
||||||
{0x030E, -33}, // 64 .. 3 0 1 6 .. 0dB -24dB -6dB -3dB .. -33dB
|
|
||||||
{0x0307, -32}, // 65 .. 3 0 0 7 .. 0dB -24dB -8dB 0dB .. -32dB
|
|
||||||
{0x02BE, -31}, // 66 .. 2 5 3 6 .. -24dB -4dB 0dB -3dB .. -31dB
|
|
||||||
{0x037A, -30}, // 67 .. 3 3 3 2 .. 0dB -9dB 0dB -21dB .. -30dB
|
|
||||||
{0x02DE, -29}, // 68 .. 2 6 3 6 .. -24dB -2dB 0dB -3dB .. -29dB
|
|
||||||
{0x0345, -28}, // 69 .. 3 2 0 5 .. 0dB -14dB -8dB -6dB .. -28dB
|
|
||||||
{0x03A3, -27}, // 70 .. 3 5 0 3 .. 0dB -4dB -8dB -15dB .. -27dB
|
|
||||||
{0x0364, -26}, // 71 .. 3 3 0 4 .. 0dB -9dB -8dB -9dB .. -26dB
|
|
||||||
{0x032F, -25}, // 72 .. 3 1 1 7 .. 0dB -19dB -6dB 0dB .. -25dB
|
|
||||||
{0x0393, -24}, // 73 .. 3 4 2 3 .. 0dB -6dB -3dB -15dB .. -24dB
|
|
||||||
{0x0384, -23}, // 74 .. 3 4 0 4 .. 0dB -6dB -8dB -9dB .. -23dB
|
|
||||||
{0x0347, -22}, // 75 .. 3 2 0 7 .. 0dB -14dB -8dB 0dB .. -22dB
|
|
||||||
{0x03EB, -21}, // 76 .. 3 7 1 3 .. 0dB 0dB -6dB -15dB .. -21dB
|
|
||||||
{0x03D3, -20}, // 77 .. 3 6 2 3 .. 0dB -2dB -3dB -15dB .. -20dB
|
|
||||||
{0x03BB, -19}, // 78 .. 3 5 3 3 .. 0dB -4dB 0dB -15dB .. -19dB
|
|
||||||
{0x037C, -18}, // 79 .. 3 3 3 4 .. 0dB -9dB 0dB -9dB .. -18dB
|
|
||||||
{0x03CC, -17}, // 80 .. 3 6 1 4 .. 0dB -2dB -6dB -9dB .. -17dB
|
|
||||||
{0x03C5, -16}, // 81 .. 3 6 0 5 .. 0dB -2dB -8dB -6dB .. -16dB
|
|
||||||
{0x03EC, -15}, // 82 .. 3 7 1 4 .. 0dB 0dB -6dB -9dB .. -15dB
|
|
||||||
{0x035F, -14}, // 83 .. 3 2 3 7 .. 0dB -14dB 0dB 0dB .. -14dB
|
|
||||||
{0x03BC, -13}, // 84 .. 3 5 3 4 .. 0dB -4dB 0dB -9dB .. -13dB
|
|
||||||
{0x038F, -12}, // 85 .. 3 4 1 7 .. 0dB -6dB -6dB 0dB .. -12dB
|
|
||||||
{0x03E6, -11}, // 86 .. 3 7 0 6 .. 0dB 0dB -8dB -3dB .. -11dB
|
|
||||||
{0x03AF, -10}, // 87 .. 3 5 1 7 .. 0dB -4dB -6dB 0dB .. -10dB
|
|
||||||
{0x03F5, -9 }, // 88 .. 3 7 2 5 .. 0dB 0dB -3dB -6dB .. -9dB
|
|
||||||
{0x03D6, -8 }, // 89 .. 3 6 2 6 .. 0dB -2dB -3dB -3dB .. -8dB
|
|
||||||
{0x03BE, -7 }, // 90 .. 3 5 3 6 .. 0dB -4dB 0dB -3dB .. -7dB original
|
|
||||||
{0x03F6, -6 }, // 91 .. 3 7 2 6 .. 0dB 0dB -3dB -3dB .. -6dB
|
|
||||||
{0x03DE, -5 }, // 92 .. 3 6 3 6 .. 0dB -2dB 0dB -3dB .. -5dB
|
|
||||||
{0x03BF, -4 }, // 93 .. 3 5 3 7 .. 0dB -4dB 0dB 0dB .. -4dB
|
|
||||||
{0x03F7, -3 }, // 94 .. 3 7 2 7 .. 0dB 0dB -3dB 0dB .. -3dB
|
|
||||||
{0x03DF, -2 }, // 95 .. 3 6 3 7 .. 0dB -2dB 0dB 0dB .. -2dB
|
|
||||||
{0x03FF, 0 }, // 96 .. 3 7 3 7 .. 0dB 0dB 0dB 0dB .. 0dB
|
|
||||||
};
|
};
|
||||||
|
uint16_t __raw;
|
||||||
|
} GainData;
|
||||||
|
|
||||||
static const unsigned int original_index = 90;
|
static const int8_t lna_short_dB[] = {-28, -24, -19, 0}; // corrected'ish
|
||||||
|
static const int8_t lna_dB[] = {-24, -19, -14, -9, -6, -4, -2, 0};
|
||||||
|
static const int8_t mixer_dB[] = { -8, -6, -3, 0};
|
||||||
|
static const int8_t pga_dB[] = {-33, -27, -21, -15, -9, -6, -3, 0};
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
|
for (uint8_t lnaSIdx = 0; lnaSIdx < ARRAY_SIZE(lna_short_dB); lnaSIdx++) {
|
||||||
|
for (uint8_t lnaIdx = 0; lnaIdx < ARRAY_SIZE(lna_dB); lnaIdx++) {
|
||||||
|
for (uint8_t mixerIdx = 0; mixerIdx < ARRAY_SIZE(mixer_dB); mixerIdx++) {
|
||||||
|
for (uint8_t pgaIdx = 0; pgaIdx < ARRAY_SIZE(pga_dB); pgaIdx++) {
|
||||||
|
int16_t db = lna_short_dB[lnaSIdx] + lna_dB[lnaIdx] + mixer_dB[mixerIdx] + pga_dB[pgaIdx];
|
||||||
|
GainData gainData = {{
|
||||||
|
pgaIdx,
|
||||||
|
mixerIdx,
|
||||||
|
lnaIdx,
|
||||||
|
lnaSIdx,
|
||||||
|
}};
|
||||||
|
|
||||||
|
for (i = 1; i < ARRAY_SIZE(gain_table); i++) {
|
||||||
|
t_gain_table * gain = &gain_table[i];
|
||||||
|
if (db == gain->gain_dB)
|
||||||
|
break;
|
||||||
|
if (db > gain->gain_dB)
|
||||||
|
continue;
|
||||||
|
if (db < gain->gain_dB) {
|
||||||
|
if(gain->gain_dB)
|
||||||
|
memmove(gain + 1, gain, 100 - i);
|
||||||
|
gain->gain_dB = db;
|
||||||
|
gain->reg_val = gainData.__raw;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gain->gain_dB = db;
|
||||||
|
gain->reg_val = gainData.__raw;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gain_table_size = i+1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
// display update rate
|
// display update rate
|
||||||
static const unsigned int display_update_rate = 250 / 10; // max 250ms display update rate
|
static const unsigned int display_update_rate = 250 / 10; // max 250ms display update rate
|
||||||
unsigned int counter = 0;
|
unsigned int counter = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
unsigned int gain_table_index[2] = {0, 0};
|
||||||
// user manually sets the table index .. used to calibrate the desired dB gain table
|
|
||||||
unsigned int gain_table_index[2] = {1 + gSetting_AM_fix_test1, 1 + gSetting_AM_fix_test1};
|
|
||||||
#else
|
|
||||||
unsigned int gain_table_index[2] = {original_index, original_index};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// used simply to detect a changed gain setting
|
// used simply to detect a changed gain setting
|
||||||
unsigned int gain_table_index_prev[2] = {0, 0};
|
unsigned int gain_table_index_prev[2] = {0, 0};
|
||||||
|
|
||||||
// holds the previous RSSI level .. we do an average of old + new RSSI reading
|
// holds the previous RSSI level .. we do an average of old + new RSSI reading
|
||||||
int16_t prev_rssi[2] = {0, 0};
|
int16_t prev_rssi[2] = {0, 0};
|
||||||
|
|
||||||
// to help reduce gain hunting, peak hold count down tick
|
// to help reduce gain hunting, peak hold count down tick
|
||||||
unsigned int hold_counter[2] = {0, 0};
|
unsigned int hold_counter[2] = {0, 0};
|
||||||
|
|
||||||
// used to correct the RSSI readings after our RF gain adjustments
|
|
||||||
int16_t rssi_gain_diff[2] = {0, 0};
|
|
||||||
|
|
||||||
// used to limit the max RF gain
|
|
||||||
unsigned int max_index = ARRAY_SIZE(gain_table) - 1;
|
|
||||||
|
|
||||||
#ifndef ENABLE_AM_FIX_TEST1
|
|
||||||
// -89dBm, any higher and the AM demodulator starts to saturate/clip/distort
|
// -89dBm, any higher and the AM demodulator starts to saturate/clip/distort
|
||||||
const int16_t desired_rssi = (-89 + 160) * 2;
|
const int16_t desired_rssi = (-89 + 160) * 2;
|
||||||
#endif
|
|
||||||
|
int8_t currentGainDiff;
|
||||||
|
bool enabled = true;
|
||||||
|
|
||||||
void AM_fix_init(void)
|
void AM_fix_init(void)
|
||||||
{ // called at boot-up
|
{ // called at boot-up
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
unsigned int i;
|
gain_table_index[i] = 0; // re-start with original QS setting
|
||||||
|
}
|
||||||
for (i = 0; i < 2; i++)
|
#if !LOOKUP_TABLE
|
||||||
{
|
CreateTable();
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
gain_table_index[i] = 1 + gSetting_AM_fix_test1;
|
|
||||||
#else
|
|
||||||
gain_table_index[i] = original_index; // re-start with original QS setting
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
void AM_fix_reset(const unsigned vfo)
|
||||||
{ // set a maximum gain to use
|
|
||||||
// const int16_t max_gain_dB = gain_dB[original_index];
|
|
||||||
const int16_t max_gain_dB = -10;
|
|
||||||
|
|
||||||
max_index = ARRAY_SIZE(gain_table);
|
|
||||||
while (--max_index > 1)
|
|
||||||
// if (gain_dB[max_index] <= max_gain_dB)
|
|
||||||
if (gain_table[max_index].gain_dB <= max_gain_dB)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// use the full range of available gains
|
|
||||||
max_index = ARRAY_SIZE(gain_table) - 1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void AM_fix_reset(const int vfo)
|
|
||||||
{ // reset the AM fixer upper
|
{ // reset the AM fixer upper
|
||||||
|
if (vfo > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
counter = 0;
|
counter = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
prev_rssi[vfo] = 0;
|
prev_rssi[vfo] = 0;
|
||||||
|
|
||||||
hold_counter[vfo] = 0;
|
hold_counter[vfo] = 0;
|
||||||
|
|
||||||
rssi_gain_diff[vfo] = 0;
|
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
// gain_table_index[vfo] = 1 + gSetting_AM_fix_test1;
|
|
||||||
#else
|
|
||||||
// gain_table_index[vfo] = original_index; // re-start with original QS setting
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gain_table_index_prev[vfo] = 0;
|
gain_table_index_prev[vfo] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,40 +258,34 @@
|
|||||||
// won't/don't do it for itself, we're left to bodging it ourself by
|
// won't/don't do it for itself, we're left to bodging it ourself by
|
||||||
// playing with the RF front end gain setting
|
// playing with the RF front end gain setting
|
||||||
//
|
//
|
||||||
void AM_fix_10ms(const int vfo)
|
void AM_fix_10ms(const unsigned vfo)
|
||||||
{
|
{
|
||||||
int16_t diff_dB;
|
if(!gSetting_AM_fix || !enabled || vfo > 1 )
|
||||||
int16_t rssi;
|
return;
|
||||||
|
|
||||||
switch (gCurrentFunction)
|
if (gCurrentFunction != FUNCTION_FOREGROUND && !FUNCTION_IsRx()) {
|
||||||
{
|
|
||||||
case FUNCTION_TRANSMIT:
|
|
||||||
case FUNCTION_BAND_SCOPE:
|
|
||||||
case FUNCTION_POWER_SAVE:
|
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
counter = display_update_rate; // queue up a display update as soon as we switch to RX mode
|
counter = display_update_rate; // queue up a display update as soon as we switch to RX mode
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// only adjust stuff if we're in one of these modes
|
|
||||||
case FUNCTION_FOREGROUND:
|
|
||||||
case FUNCTION_RECEIVE:
|
|
||||||
case FUNCTION_MONITOR:
|
|
||||||
case FUNCTION_INCOMING:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
if (counter > 0)
|
if (counter > 0) {
|
||||||
{
|
if (++counter >= display_update_rate) { // trigger a display update
|
||||||
if (++counter >= display_update_rate)
|
|
||||||
{ // trigger a display update
|
|
||||||
counter = 0;
|
counter = 0;
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static uint32_t lastFreq[2];
|
||||||
|
if(gEeprom.VfoInfo[vfo].pRX->Frequency != lastFreq[vfo]) {
|
||||||
|
lastFreq[vfo] = gEeprom.VfoInfo[vfo].pRX->Frequency;
|
||||||
|
AM_fix_reset(vfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t rssi;
|
||||||
{ // sample the current RSSI level
|
{ // sample the current RSSI level
|
||||||
// average it with the previous rssi (a bit of noise/spike immunity)
|
// average it with the previous rssi (a bit of noise/spike immunity)
|
||||||
const int16_t new_rssi = BK4819_GetRSSI();
|
const int16_t new_rssi = BK4819_GetRSSI();
|
||||||
@@ -349,39 +293,21 @@
|
|||||||
prev_rssi[vfo] = new_rssi;
|
prev_rssi[vfo] = new_rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the corrected RSSI level
|
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
{
|
{
|
||||||
const int16_t new_rssi = rssi - rssi_gain_diff[vfo];
|
static int16_t lastRssi;
|
||||||
if (gCurrentRSSI[vfo] != new_rssi)
|
|
||||||
{
|
|
||||||
gCurrentRSSI[vfo] = new_rssi;
|
|
||||||
|
|
||||||
if (counter == 0)
|
if (lastRssi != rssi) { // rssi changed
|
||||||
{ // trigger a display update
|
lastRssi = rssi;
|
||||||
|
|
||||||
|
if (counter == 0) {
|
||||||
counter = 1;
|
counter = 1;
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true; // trigger a display update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
gCurrentRSSI[vfo] = rssi - rssi_gain_diff[vfo];
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
// user is manually adjusting a gain register - don't do anything automatically
|
|
||||||
|
|
||||||
{
|
|
||||||
int i = 1 + (int)gSetting_AM_fix_test1;
|
|
||||||
i = (i < 1) ? 1 : (i > ((int)ARRAY_SIZE(gain_table) - 1) ? ARRAY_SIZE(gain_table) - 1 : i;
|
|
||||||
|
|
||||||
if (gain_table_index[vfo] == i)
|
|
||||||
return; // no change
|
|
||||||
|
|
||||||
gain_table_index[vfo] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
// automatically adjust the RF RX gain
|
// automatically adjust the RF RX gain
|
||||||
|
|
||||||
// update the gain hold counter
|
// update the gain hold counter
|
||||||
@@ -389,15 +315,12 @@
|
|||||||
hold_counter[vfo]--;
|
hold_counter[vfo]--;
|
||||||
|
|
||||||
// dB difference between actual and desired RSSI level
|
// dB difference between actual and desired RSSI level
|
||||||
diff_dB = (rssi - desired_rssi) / 2;
|
int16_t diff_dB = (rssi - desired_rssi) / 2;
|
||||||
|
|
||||||
if (diff_dB > 0)
|
|
||||||
{ // decrease gain
|
|
||||||
|
|
||||||
|
if (diff_dB > 0) { // decrease gain
|
||||||
unsigned int index = gain_table_index[vfo]; // current position we're at
|
unsigned int index = gain_table_index[vfo]; // current position we're at
|
||||||
|
|
||||||
if (diff_dB >= 10)
|
if (diff_dB >= 10) { // jump immediately to a new gain setting
|
||||||
{ // jump immediately to a new gain setting
|
|
||||||
// this greatly speeds up initial gain reduction (but reduces noise/spike immunity)
|
// this greatly speeds up initial gain reduction (but reduces noise/spike immunity)
|
||||||
|
|
||||||
const int16_t desired_gain_dB = (int16_t)gain_table[index].gain_dB - diff_dB + 8; // get no closer than 8dB (bit of noise/spike immunity)
|
const int16_t desired_gain_dB = (int16_t)gain_table[index].gain_dB - diff_dB + 8; // get no closer than 8dB (bit of noise/spike immunity)
|
||||||
@@ -406,20 +329,14 @@
|
|||||||
while (index > 1)
|
while (index > 1)
|
||||||
if (gain_table[--index].gain_dB <= desired_gain_dB)
|
if (gain_table[--index].gain_dB <= desired_gain_dB)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//index = (gain_table_index[vfo] + index) / 2; // easy does it
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // incrementally reduce the gain .. taking it slow improves noise/spike immunity
|
{ // incrementally reduce the gain .. taking it slow improves noise/spike immunity
|
||||||
|
|
||||||
// if (index >= (1 + 3) && diff_dB >= 3)
|
|
||||||
// index -= 3; // faster gain reduction
|
|
||||||
// else
|
|
||||||
if (index > 1)
|
if (index > 1)
|
||||||
index--; // slow step-by-step gain reduction
|
index--; // slow step-by-step gain reduction
|
||||||
}
|
}
|
||||||
|
|
||||||
index = (index < 1) ? 1 : (index > max_index) ? max_index : index;
|
index = MAX(1u, index);
|
||||||
|
|
||||||
if (gain_table_index[vfo] != index)
|
if (gain_table_index[vfo] != index)
|
||||||
{
|
{
|
||||||
@@ -434,37 +351,24 @@
|
|||||||
if (hold_counter[vfo] == 0)
|
if (hold_counter[vfo] == 0)
|
||||||
{ // hold has been released, we're free to increase gain
|
{ // hold has been released, we're free to increase gain
|
||||||
const unsigned int index = gain_table_index[vfo] + 1; // move up to next gain index
|
const unsigned int index = gain_table_index[vfo] + 1; // move up to next gain index
|
||||||
gain_table_index[vfo] = (index <= max_index) ? index : max_index; // limit the gain index
|
gain_table_index[vfo] = MIN(index, gain_table_size - 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (gain_table_index[vfo] == gain_table_index_prev[vfo])
|
|
||||||
return; // no gain change - this is to reduce writing to the BK chip on ever call
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{ // apply the new settings to the front end registers
|
{ // apply the new settings to the front end registers
|
||||||
|
|
||||||
const unsigned int index = gain_table_index[vfo];
|
const unsigned int index = gain_table_index[vfo];
|
||||||
|
|
||||||
// remember the new table index
|
// remember the new table index
|
||||||
gain_table_index_prev[vfo] = index;
|
gain_table_index_prev[vfo] = index;
|
||||||
|
currentGainDiff = gain_table[0].gain_dB - gain_table[index].gain_dB;
|
||||||
BK4819_WriteRegister(BK4819_REG_13, gain_table[index].reg_val);
|
BK4819_WriteRegister(BK4819_REG_13, gain_table[index].reg_val);
|
||||||
|
#ifdef ENABLE_AGC_SHOW_DATA
|
||||||
// offset the RSSI reading to the rest of the firmware to cancel out the gain adjustments we make
|
UI_MAIN_PrintAGC(true);
|
||||||
|
#endif
|
||||||
// RF gain difference from original QS setting
|
|
||||||
rssi_gain_diff[vfo] = ((int16_t)gain_table[index].gain_dB - gain_table[original_index].gain_dB) * 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the corrected RSSI level
|
|
||||||
gCurrentRSSI[vfo] = rssi - rssi_gain_diff[vfo];
|
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
if (counter == 0)
|
if (counter == 0) {
|
||||||
{
|
|
||||||
counter = 1;
|
counter = 1;
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
}
|
}
|
||||||
@@ -472,18 +376,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
|
void AM_fix_print_data(const unsigned vfo, char *s) {
|
||||||
void AM_fix_print_data(const int vfo, char *s)
|
if (s != NULL && vfo < ARRAY_SIZE(gain_table_index)) {
|
||||||
{
|
|
||||||
if (s != NULL && vfo >= 0 && vfo < (int)ARRAY_SIZE(gain_table_index))
|
|
||||||
{
|
|
||||||
const unsigned int index = gain_table_index[vfo];
|
const unsigned int index = gain_table_index[vfo];
|
||||||
// sprintf(s, "%2u.%u %4ddB %3u", index, ARRAY_SIZE(gain_table) - 1, gain_table[index].gain_dB, prev_rssi[vfo]);
|
|
||||||
sprintf(s, "%2u %4ddB %3u", index, gain_table[index].gain_dB, prev_rssi[vfo]);
|
sprintf(s, "%2u %4ddB %3u", index, gain_table[index].gain_dB, prev_rssi[vfo]);
|
||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int8_t AM_fix_get_gain_diff()
|
||||||
|
{
|
||||||
|
return currentGainDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AM_fix_enable(bool on)
|
||||||
|
{
|
||||||
|
enabled = on;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
10
am_fix.h
@@ -21,14 +21,14 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
extern int16_t rssi_gain_diff[2];
|
|
||||||
|
|
||||||
void AM_fix_init(void);
|
void AM_fix_init(void);
|
||||||
void AM_fix_reset(const int vfo);
|
void AM_fix_reset(const unsigned vfo);
|
||||||
void AM_fix_10ms(const int vfo);
|
void AM_fix_10ms(const unsigned vfo);
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
void AM_fix_print_data(const int vfo, char *s);
|
void AM_fix_print_data(const unsigned vfo, char *s);
|
||||||
#endif
|
#endif
|
||||||
|
int8_t AM_fix_get_gain_diff();
|
||||||
|
void AM_fix_enable(bool on);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
496
app/action.c
@@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "app/action.h"
|
#include "app/action.h"
|
||||||
@@ -21,6 +22,9 @@
|
|||||||
#include "app/chFrScanner.h"
|
#include "app/chFrScanner.h"
|
||||||
#include "app/common.h"
|
#include "app/common.h"
|
||||||
#include "app/dtmf.h"
|
#include "app/dtmf.h"
|
||||||
|
#ifdef ENABLE_FLASHLIGHT
|
||||||
|
#include "app/flashlight.h"
|
||||||
|
#endif
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
#include "app/fm.h"
|
#include "app/fm.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -39,23 +43,76 @@
|
|||||||
#include "ui/inputbox.h"
|
#include "ui/inputbox.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
static void ACTION_FlashLight(void)
|
#if defined(ENABLE_FMRADIO)
|
||||||
{
|
static void ACTION_Scan_FM(bool bRestart);
|
||||||
switch (gFlashLightState)
|
#endif
|
||||||
{
|
|
||||||
case 0:
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
gFlashLightState++;
|
static void ACTION_AlarmOr1750(bool b1750);
|
||||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
inline static void ACTION_Alarm() { ACTION_AlarmOr1750(false); }
|
||||||
break;
|
inline static void ACTION_1750() { ACTION_AlarmOr1750(true); };
|
||||||
case 1:
|
#endif
|
||||||
case 2:
|
|
||||||
gFlashLightState++;
|
#ifdef ENABLE_SPECTRUM
|
||||||
break;
|
#include "app/spectrum.h"
|
||||||
default:
|
#endif
|
||||||
gFlashLightState = 0;
|
|
||||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
inline static void ACTION_ScanRestart() { ACTION_Scan(true); };
|
||||||
}
|
|
||||||
}
|
void (*action_opt_table[])(void) = {
|
||||||
|
[ACTION_OPT_NONE] = &FUNCTION_NOP,
|
||||||
|
[ACTION_OPT_POWER] = &ACTION_Power,
|
||||||
|
[ACTION_OPT_MONITOR] = &ACTION_Monitor,
|
||||||
|
[ACTION_OPT_SCAN] = &ACTION_ScanRestart,
|
||||||
|
[ACTION_OPT_KEYLOCK] = &COMMON_KeypadLockToggle,
|
||||||
|
[ACTION_OPT_A_B] = &COMMON_SwitchVFOs,
|
||||||
|
[ACTION_OPT_VFO_MR] = &COMMON_SwitchVFOMode,
|
||||||
|
[ACTION_OPT_SWITCH_DEMODUL] = &ACTION_SwitchDemodul,
|
||||||
|
|
||||||
|
#ifdef ENABLE_FLASHLIGHT
|
||||||
|
[ACTION_OPT_FLASHLIGHT] = &ACTION_FlashLight,
|
||||||
|
#else
|
||||||
|
[ACTION_OPT_FLASHLIGHT] = &FUNCTION_NOP,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
[ACTION_OPT_VOX] = &ACTION_Vox,
|
||||||
|
#else
|
||||||
|
[ACTION_OPT_VOX] = &FUNCTION_NOP,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
[ACTION_OPT_FM] = &ACTION_FM,
|
||||||
|
#else
|
||||||
|
[ACTION_OPT_FM] = &FUNCTION_NOP,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_ALARM
|
||||||
|
[ACTION_OPT_ALARM] = &ACTION_Alarm,
|
||||||
|
#else
|
||||||
|
[ACTION_OPT_ALARM] = &FUNCTION_NOP,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_TX1750
|
||||||
|
[ACTION_OPT_1750] = &ACTION_1750,
|
||||||
|
#else
|
||||||
|
[ACTION_OPT_1750] = &FUNCTION_NOP,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||||
|
[ACTION_OPT_BLMIN_TMP_OFF] = &ACTION_BlminTmpOff,
|
||||||
|
#else
|
||||||
|
[ACTION_OPT_BLMIN_TMP_OFF] = &FUNCTION_NOP,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_SPECTRUM
|
||||||
|
[ACTION_OPT_SPECTRUM] = &APP_RunSpectrum,
|
||||||
|
#else
|
||||||
|
[ACTION_OPT_SPECTRUM] = &FUNCTION_NOP,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(ARRAY_SIZE(action_opt_table) == ACTION_OPT_LEN);
|
||||||
|
|
||||||
void ACTION_Power(void)
|
void ACTION_Power(void)
|
||||||
{
|
{
|
||||||
@@ -64,11 +121,12 @@ void ACTION_Power(void)
|
|||||||
|
|
||||||
gRequestSaveChannel = 1;
|
gRequestSaveChannel = 1;
|
||||||
|
|
||||||
|
gRequestDisplayScreen = gScreenToDisplay;
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = VOICE_ID_POWER;
|
gAnotherVoiceID = VOICE_ID_POWER;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gRequestDisplayScreen = gScreenToDisplay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACTION_Monitor(void)
|
void ACTION_Monitor(void)
|
||||||
@@ -76,11 +134,11 @@ void ACTION_Monitor(void)
|
|||||||
if (gCurrentFunction != FUNCTION_MONITOR) { // enable the monitor
|
if (gCurrentFunction != FUNCTION_MONITOR) { // enable the monitor
|
||||||
RADIO_SelectVfos();
|
RADIO_SelectVfos();
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST && gIsNoaaMode)
|
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && 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);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,57 +172,19 @@ void ACTION_Monitor(void)
|
|||||||
void ACTION_Scan(bool bRestart)
|
void ACTION_Scan(bool bRestart)
|
||||||
{
|
{
|
||||||
(void)bRestart;
|
(void)bRestart;
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFmRadioMode)
|
if (gFmRadioMode) {
|
||||||
{
|
ACTION_Scan_FM(bRestart);
|
||||||
if (gCurrentFunction != FUNCTION_RECEIVE &&
|
|
||||||
gCurrentFunction != FUNCTION_MONITOR &&
|
|
||||||
gCurrentFunction != FUNCTION_TRANSMIT)
|
|
||||||
{
|
|
||||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
|
||||||
|
|
||||||
gMonitor = false;
|
|
||||||
|
|
||||||
if (gFM_ScanState != FM_SCAN_OFF)
|
|
||||||
{
|
|
||||||
FM_PlayAndUpdate();
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uint16_t Frequency;
|
|
||||||
|
|
||||||
if (bRestart)
|
|
||||||
{
|
|
||||||
gFM_AutoScan = true;
|
|
||||||
gFM_ChannelPosition = 0;
|
|
||||||
FM_EraseChannels();
|
|
||||||
Frequency = gEeprom.FM_LowerLimit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gFM_AutoScan = false;
|
|
||||||
gFM_ChannelPosition = 0;
|
|
||||||
Frequency = gEeprom.FM_FrequencyPlaying;
|
|
||||||
}
|
|
||||||
|
|
||||||
BK1080_GetFrequencyDeviation(Frequency);
|
|
||||||
FM_Tune(Frequency, 1, bRestart);
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!SCANNER_IsScanning())
|
if (SCANNER_IsScanning()) {
|
||||||
{ // not scanning
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not scanning
|
||||||
gMonitor = false;
|
gMonitor = false;
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
@@ -176,40 +196,33 @@ void ACTION_Scan(bool bRestart)
|
|||||||
RADIO_SelectVfos();
|
RADIO_SelectVfos();
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||||
|
|
||||||
if (gScanStateDir != SCAN_OFF)
|
if (gScanStateDir != SCAN_OFF) {
|
||||||
{ // already scanning
|
// already scanning
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(gNextMrChannel))
|
if (!IS_MR_CHANNEL(gNextMrChannel)) {
|
||||||
{ // channel mode
|
CHFRSCANNER_Stop();
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// keep scanning but toggle between scan lists
|
// channel mode. Keep scanning but toggle between scan lists
|
||||||
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
|
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
|
||||||
|
|
||||||
// jump to the next channel
|
// jump to the next channel
|
||||||
CHFRSCANNER_Start(false, gScanStateDir);
|
CHFRSCANNER_Start(false, gScanStateDir);
|
||||||
gScanPauseDelayIn_10ms = 1;
|
gScanPauseDelayIn_10ms = 1;
|
||||||
gScheduleScanListen = false;
|
gScheduleScanListen = false;
|
||||||
|
} else {
|
||||||
gUpdateStatus = true;
|
// start scanning
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // stop scanning
|
|
||||||
|
|
||||||
CHFRSCANNER_Stop();
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // start scanning
|
|
||||||
|
|
||||||
CHFRSCANNER_Start(true, SCAN_FWD);
|
CHFRSCANNER_Start(true, SCAN_FWD);
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
@@ -218,141 +231,60 @@ void ACTION_Scan(bool bRestart)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clear the other vfo's rssi level (to hide the antenna symbol)
|
// clear the other vfo's rssi level (to hide the antenna symbol)
|
||||||
gVFO_RSSI_bar_level[(gEeprom.RX_VFO + 1) & 1u] = 0;
|
gVFO_RSSI_bar_level[(gEeprom.RX_VFO + 1) & 1U] = 0;
|
||||||
|
|
||||||
// let the user see DW is not active
|
// let the user see DW is not active
|
||||||
gDualWatchActive = false;
|
gDualWatchActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
void ACTION_Vox(void)
|
|
||||||
{
|
|
||||||
gEeprom.VOX_SWITCH = !gEeprom.VOX_SWITCH;
|
|
||||||
gRequestSaveSettings = true;
|
|
||||||
gFlagReconfigureVfos = true;
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
gAnotherVoiceID = VOICE_ID_VOX;
|
|
||||||
#endif
|
|
||||||
gUpdateStatus = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
|
||||||
static void ACTION_AlarmOr1750(const bool b1750)
|
|
||||||
{
|
|
||||||
(void)b1750;
|
|
||||||
gInputBoxIndex = 0;
|
|
||||||
|
|
||||||
#if defined(ENABLE_ALARM) && defined(ENABLE_TX1750)
|
|
||||||
gAlarmState = b1750 ? ALARM_STATE_TX1750 : ALARM_STATE_TXALARM;
|
|
||||||
gAlarmRunningCounter = 0;
|
|
||||||
#elif defined(ENABLE_ALARM)
|
|
||||||
gAlarmState = ALARM_STATE_TXALARM;
|
|
||||||
gAlarmRunningCounter = 0;
|
|
||||||
#else
|
|
||||||
gAlarmState = ALARM_STATE_TX1750;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gFlagPrepareTX = true;
|
|
||||||
|
|
||||||
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
void ACTION_FM(void)
|
|
||||||
{
|
|
||||||
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR)
|
|
||||||
{
|
|
||||||
if (gFmRadioMode)
|
|
||||||
{
|
|
||||||
FM_TurnOff();
|
|
||||||
|
|
||||||
gInputBoxIndex = 0;
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
gVoxResumeCountdown = 80;
|
|
||||||
#endif
|
|
||||||
gFlagReconfigureVfos = true;
|
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gMonitor = false;
|
|
||||||
|
|
||||||
RADIO_SelectVfos();
|
|
||||||
RADIO_SetupRegisters(true);
|
|
||||||
|
|
||||||
FM_Start();
|
|
||||||
|
|
||||||
gInputBoxIndex = 0;
|
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ACTION_SwitchDemodul(void)
|
void ACTION_SwitchDemodul(void)
|
||||||
{
|
{
|
||||||
|
gRequestSaveChannel = 1;
|
||||||
|
|
||||||
gTxVfo->Modulation++;
|
gTxVfo->Modulation++;
|
||||||
|
|
||||||
if(gTxVfo->Modulation == MODULATION_UKNOWN)
|
if(gTxVfo->Modulation == MODULATION_UKNOWN)
|
||||||
gTxVfo->Modulation = MODULATION_FM;
|
gTxVfo->Modulation = MODULATION_FM;
|
||||||
gRequestSaveChannel = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
|
||||||
void ACTION_BlminTmpOff(void)
|
|
||||||
{
|
|
||||||
if(++gEeprom.BACKLIGHT_MIN_STAT == BLMIN_STAT_UNKNOWN)
|
|
||||||
{
|
|
||||||
gEeprom.BACKLIGHT_MIN_STAT = BLMIN_STAT_ON;
|
|
||||||
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MIN);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
BACKLIGHT_SetBrightness(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode) // entering DTMF code
|
if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode){
|
||||||
{
|
// entering DTMF code
|
||||||
if (Key == KEY_SIDE1 && !bKeyHeld && bKeyPressed) // side1 btn pressed
|
|
||||||
{
|
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
|
||||||
|
|
||||||
if (gDTMF_InputBox_Index > 0) // DTMF codes are in the input box
|
|
||||||
{
|
|
||||||
gDTMF_InputBox[--gDTMF_InputBox_Index] = '-'; // delete one code
|
|
||||||
if (gDTMF_InputBox_Index > 0)
|
|
||||||
{
|
|
||||||
gPttWasReleased = true;
|
gPttWasReleased = true;
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
|
||||||
|
if (Key != KEY_SIDE1 || bKeyHeld || !bKeyPressed){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// side1 btn pressed
|
||||||
|
|
||||||
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
|
|
||||||
|
if (gDTMF_InputBox_Index <= 0) {
|
||||||
|
// turn off DTMF input box if no codes left
|
||||||
|
gDTMF_InputMode = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DTMF codes are in the input box
|
||||||
|
gDTMF_InputBox[--gDTMF_InputBox_Index] = '-'; // delete one code
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
|
||||||
gDTMF_InputMode = false; // turn off DTMF input box if no codes left
|
|
||||||
}
|
|
||||||
|
|
||||||
gPttWasReleased = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t funcShort = ACTION_OPT_NONE;
|
enum ACTION_OPT_t funcShort = ACTION_OPT_NONE;
|
||||||
uint8_t funcLong = ACTION_OPT_NONE;
|
enum ACTION_OPT_t funcLong = ACTION_OPT_NONE;
|
||||||
switch(Key) {
|
switch(Key) {
|
||||||
case KEY_SIDE1:
|
case KEY_SIDE1:
|
||||||
funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
||||||
@@ -389,59 +321,133 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
// held or released after short press beyond this point
|
// held or released after short press beyond this point
|
||||||
|
|
||||||
switch (funcShort)
|
action_opt_table[funcShort]();
|
||||||
{
|
}
|
||||||
default:
|
|
||||||
case ACTION_OPT_NONE:
|
|
||||||
break;
|
|
||||||
case ACTION_OPT_FLASHLIGHT:
|
|
||||||
ACTION_FlashLight();
|
|
||||||
break;
|
|
||||||
case ACTION_OPT_POWER:
|
|
||||||
ACTION_Power();
|
|
||||||
break;
|
|
||||||
case ACTION_OPT_MONITOR:
|
|
||||||
ACTION_Monitor();
|
|
||||||
break;
|
|
||||||
case ACTION_OPT_SCAN:
|
|
||||||
ACTION_Scan(true);
|
|
||||||
break;
|
|
||||||
case ACTION_OPT_VOX:
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
ACTION_Vox();
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case ACTION_OPT_ALARM:
|
|
||||||
#ifdef ENABLE_ALARM
|
|
||||||
ACTION_AlarmOr1750(false);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
case ACTION_OPT_FM:
|
void ACTION_FM(void)
|
||||||
ACTION_FM();
|
{
|
||||||
break;
|
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR)
|
||||||
|
{
|
||||||
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
|
if (gFmRadioMode) {
|
||||||
|
FM_TurnOff();
|
||||||
|
gFlagReconfigureVfos = true;
|
||||||
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
gVoxResumeCountdown = 80;
|
||||||
#endif
|
#endif
|
||||||
case ACTION_OPT_1750:
|
return;
|
||||||
#ifdef ENABLE_TX1750
|
}
|
||||||
ACTION_AlarmOr1750(true);
|
|
||||||
|
gMonitor = false;
|
||||||
|
|
||||||
|
RADIO_SelectVfos();
|
||||||
|
RADIO_SetupRegisters(true);
|
||||||
|
|
||||||
|
FM_Start();
|
||||||
|
|
||||||
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ACTION_Scan_FM(bool bRestart)
|
||||||
|
{
|
||||||
|
if (FUNCTION_IsRx())
|
||||||
|
return;
|
||||||
|
|
||||||
|
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||||
|
|
||||||
|
gMonitor = false;
|
||||||
|
|
||||||
|
if (gFM_ScanState != FM_SCAN_OFF) {
|
||||||
|
FM_PlayAndUpdate();
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||||
#endif
|
#endif
|
||||||
break;
|
return;
|
||||||
case ACTION_OPT_KEYLOCK:
|
}
|
||||||
COMMON_KeypadLockToggle();
|
|
||||||
break;
|
uint16_t freq;
|
||||||
case ACTION_OPT_A_B:
|
|
||||||
COMMON_SwitchVFOs();
|
if (bRestart) {
|
||||||
break;
|
gFM_AutoScan = true;
|
||||||
case ACTION_OPT_VFO_MR:
|
gFM_ChannelPosition = 0;
|
||||||
COMMON_SwitchVFOMode();
|
FM_EraseChannels();
|
||||||
break;
|
freq = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||||
case ACTION_OPT_SWITCH_DEMODUL:
|
} else {
|
||||||
ACTION_SwitchDemodul();
|
gFM_AutoScan = false;
|
||||||
break;
|
gFM_ChannelPosition = 0;
|
||||||
|
freq = gEeprom.FM_FrequencyPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
|
BK1080_GetFrequencyDeviation(freq);
|
||||||
|
FM_Tune(freq, 1, bRestart);
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
|
static void ACTION_AlarmOr1750(const bool b1750)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if defined(ENABLE_ALARM)
|
||||||
|
const AlarmState_t alarm_mode = (gEeprom.ALARM_MODE == ALARM_MODE_TONE) ? ALARM_STATE_TXALARM : ALARM_STATE_SITE_ALARM;
|
||||||
|
gAlarmRunningCounter = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_ALARM) && defined(ENABLE_TX1750)
|
||||||
|
gAlarmState = b1750 ? ALARM_STATE_TX1750 : alarm_mode;
|
||||||
|
#elif defined(ENABLE_ALARM)
|
||||||
|
gAlarmState = alarm_mode;
|
||||||
|
#else
|
||||||
|
gAlarmState = ALARM_STATE_TX1750;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
(void)b1750;
|
||||||
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
|
gFlagPrepareTX = gAlarmState != ALARM_STATE_OFF;
|
||||||
|
|
||||||
|
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||||
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
void ACTION_Vox(void)
|
||||||
|
{
|
||||||
|
gEeprom.VOX_SWITCH = !gEeprom.VOX_SWITCH;
|
||||||
|
gRequestSaveSettings = true;
|
||||||
|
gFlagReconfigureVfos = true;
|
||||||
|
gUpdateStatus = true;
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
gAnotherVoiceID = VOICE_ID_VOX;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||||
case ACTION_OPT_BLMIN_TMP_OFF:
|
void ACTION_BlminTmpOff(void)
|
||||||
ACTION_BlminTmpOff();
|
{
|
||||||
break;
|
if(++gEeprom.BACKLIGHT_MIN_STAT == BLMIN_STAT_UNKNOWN) {
|
||||||
|
gEeprom.BACKLIGHT_MIN_STAT = BLMIN_STAT_ON;
|
||||||
|
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MIN);
|
||||||
|
} else {
|
||||||
|
BACKLIGHT_SetBrightness(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,16 +19,13 @@
|
|||||||
|
|
||||||
#include "driver/keyboard.h"
|
#include "driver/keyboard.h"
|
||||||
|
|
||||||
//static void ACTION_FlashLight(void)
|
|
||||||
void ACTION_Power(void);
|
void ACTION_Power(void);
|
||||||
void ACTION_Monitor(void);
|
void ACTION_Monitor(void);
|
||||||
void ACTION_Scan(bool bRestart);
|
void ACTION_Scan(bool bRestart);
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
void ACTION_Vox(void);
|
void ACTION_Vox(void);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_ALARM
|
|
||||||
//static void ACTION_AlarmOr1750(bool b1750)
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
void ACTION_FM(void);
|
void ACTION_FM(void);
|
||||||
#endif
|
#endif
|
||||||
@@ -41,4 +38,3 @@ void ACTION_BlminTmpOff(void);
|
|||||||
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
132
app/aircopy.c
@@ -37,9 +37,17 @@ uint8_t gAirCopyIsSendMode;
|
|||||||
|
|
||||||
uint16_t g_FSK_Buffer[36];
|
uint16_t g_FSK_Buffer[36];
|
||||||
|
|
||||||
void AIRCOPY_SendMessage(void)
|
bool AIRCOPY_SendMessage(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
static uint8_t gAircopySendCountdown = 1;
|
||||||
|
|
||||||
|
if (gAircopyState != AIRCOPY_TRANSFER) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--gAircopySendCountdown) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
g_FSK_Buffer[1] = (gAirCopyBlockNumber & 0x3FF) << 6;
|
g_FSK_Buffer[1] = (gAirCopyBlockNumber & 0x3FF) << 6;
|
||||||
|
|
||||||
@@ -47,11 +55,13 @@ void AIRCOPY_SendMessage(void)
|
|||||||
|
|
||||||
g_FSK_Buffer[34] = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
|
g_FSK_Buffer[34] = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
|
||||||
|
|
||||||
for (i = 0; i < 34; i++)
|
for (unsigned int i = 0; i < 34; i++) {
|
||||||
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
|
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
|
||||||
|
}
|
||||||
|
|
||||||
if (++gAirCopyBlockNumber >= 0x78)
|
if (++gAirCopyBlockNumber >= 0x78) {
|
||||||
gAircopyState = AIRCOPY_COMPLETE;
|
gAircopyState = AIRCOPY_COMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
RADIO_SetTxParameters();
|
RADIO_SetTxParameters();
|
||||||
|
|
||||||
@@ -60,70 +70,70 @@ void AIRCOPY_SendMessage(void)
|
|||||||
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false);
|
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false);
|
||||||
|
|
||||||
gAircopySendCountdown = 30;
|
gAircopySendCountdown = 30;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AIRCOPY_StorePacket(void)
|
void AIRCOPY_StorePacket(void)
|
||||||
{
|
{
|
||||||
uint16_t Status;
|
if (gFSKWriteIndex < 36) {
|
||||||
|
|
||||||
if (gFSKWriteIndex < 36)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gFSKWriteIndex = 0;
|
gFSKWriteIndex = 0;
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
Status = BK4819_ReadRegister(BK4819_REG_0B);
|
uint16_t Status = BK4819_ReadRegister(BK4819_REG_0B);
|
||||||
BK4819_PrepareFSKReceive();
|
BK4819_PrepareFSKReceive();
|
||||||
|
|
||||||
// Doc says bit 4 should be 1 = CRC OK, 0 = CRC FAIL, but original firmware checks for FAIL.
|
// Doc says bit 4 should be 1 = CRC OK, 0 = CRC FAIL, but original firmware checks for FAIL.
|
||||||
|
|
||||||
if ((Status & 0x0010U) == 0 && g_FSK_Buffer[0] == 0xABCD && g_FSK_Buffer[35] == 0xDCBA)
|
if ((Status & 0x0010U) != 0 || g_FSK_Buffer[0] != 0xABCD || g_FSK_Buffer[35] != 0xDCBA) {
|
||||||
{
|
gErrorsDuringAirCopy++;
|
||||||
uint16_t CRC;
|
return;
|
||||||
unsigned int i;
|
}
|
||||||
|
|
||||||
for (i = 0; i < 34; i++)
|
for (unsigned int i = 0; i < 34; i++) {
|
||||||
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
|
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
|
||||||
|
}
|
||||||
|
|
||||||
CRC = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
|
uint16_t CRC = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
|
||||||
if (g_FSK_Buffer[34] == CRC)
|
if (g_FSK_Buffer[34] != CRC) {
|
||||||
{
|
gErrorsDuringAirCopy++;
|
||||||
const uint16_t *pData;
|
return;
|
||||||
uint16_t Offset;
|
}
|
||||||
|
|
||||||
Offset = g_FSK_Buffer[1];
|
uint16_t Offset = g_FSK_Buffer[1];
|
||||||
if (Offset < 0x1E00)
|
|
||||||
{
|
if (Offset >= 0x1E00) {
|
||||||
pData = &g_FSK_Buffer[2];
|
gErrorsDuringAirCopy++;
|
||||||
for (i = 0; i < 8; i++)
|
return;
|
||||||
{
|
}
|
||||||
|
|
||||||
|
const uint16_t *pData = &g_FSK_Buffer[2];
|
||||||
|
for (unsigned int i = 0; i < 8; i++) {
|
||||||
EEPROM_WriteBuffer(Offset, pData);
|
EEPROM_WriteBuffer(Offset, pData);
|
||||||
pData += 4;
|
pData += 4;
|
||||||
Offset += 8;
|
Offset += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Offset == 0x1E00)
|
if (Offset == 0x1E00) {
|
||||||
gAircopyState = AIRCOPY_COMPLETE;
|
gAircopyState = AIRCOPY_COMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
gAirCopyBlockNumber++;
|
gAirCopyBlockNumber++;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gErrorsDuringAirCopy++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
if (!bKeyHeld && bKeyPressed)
|
if (bKeyHeld || !bKeyPressed) {
|
||||||
{
|
return;
|
||||||
uint32_t Frequency;
|
}
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
INPUTBOX_Append(Key);
|
INPUTBOX_Append(Key);
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||||
if (gInputBoxIndex < 6)
|
|
||||||
{
|
if (gInputBoxIndex < 6) {
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
@@ -131,17 +141,23 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
|
uint32_t Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < BAND_N_ELEM; i++) {
|
||||||
|
if (Frequency < frequencyBandTable[i].lower || Frequency >= frequencyBandTable[i].upper) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TX_freq_check(Frequency)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(frequencyBandTable); i++)
|
|
||||||
{
|
|
||||||
if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
gRxVfo->Band = i;
|
|
||||||
Frequency = FREQUENCY_RoundToStep(Frequency, gRxVfo->StepFrequency);
|
Frequency = FREQUENCY_RoundToStep(Frequency, gRxVfo->StepFrequency);
|
||||||
|
gRxVfo->Band = i;
|
||||||
gRxVfo->freq_config_RX.Frequency = Frequency;
|
gRxVfo->freq_config_RX.Frequency = Frequency;
|
||||||
gRxVfo->freq_config_TX.Frequency = Frequency;
|
gRxVfo->freq_config_TX.Frequency = Frequency;
|
||||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||||
@@ -151,39 +167,39 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
BK4819_ResetFSK();
|
BK4819_ResetFSK();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
if (!bKeyHeld && bKeyPressed)
|
if (bKeyHeld || !bKeyPressed) {
|
||||||
{
|
return;
|
||||||
if (gInputBoxIndex == 0)
|
}
|
||||||
{
|
|
||||||
|
if (gInputBoxIndex == 0) {
|
||||||
gFSKWriteIndex = 0;
|
gFSKWriteIndex = 0;
|
||||||
gAirCopyBlockNumber = 0;
|
gAirCopyBlockNumber = 0;
|
||||||
gErrorsDuringAirCopy = 0;
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
gErrorsDuringAirCopy = 0;
|
||||||
gAirCopyIsSendMode = 0;
|
gAirCopyIsSendMode = 0;
|
||||||
|
|
||||||
BK4819_PrepareFSKReceive();
|
BK4819_PrepareFSKReceive();
|
||||||
|
|
||||||
gAircopyState = AIRCOPY_TRANSFER;
|
gAircopyState = AIRCOPY_TRANSFER;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
gInputBox[--gInputBoxIndex] = 10;
|
gInputBox[--gInputBoxIndex] = 10;
|
||||||
|
}
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld)
|
static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
if (!bKeyHeld && bKeyPressed)
|
if (bKeyHeld || !bKeyPressed) {
|
||||||
{
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gFSKWriteIndex = 0;
|
gFSKWriteIndex = 0;
|
||||||
gAirCopyBlockNumber = 0;
|
gAirCopyBlockNumber = 0;
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
@@ -192,18 +208,14 @@ static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld)
|
|||||||
g_FSK_Buffer[1] = 0;
|
g_FSK_Buffer[1] = 0;
|
||||||
g_FSK_Buffer[35] = 0xDCBA;
|
g_FSK_Buffer[35] = 0xDCBA;
|
||||||
|
|
||||||
AIRCOPY_SendMessage();
|
|
||||||
|
|
||||||
GUI_DisplayScreen();
|
GUI_DisplayScreen();
|
||||||
|
|
||||||
gAircopyState = AIRCOPY_TRANSFER;
|
gAircopyState = AIRCOPY_TRANSFER;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
switch (Key)
|
switch (Key) {
|
||||||
{
|
|
||||||
case KEY_0:
|
case KEY_0:
|
||||||
case KEY_1:
|
case KEY_1:
|
||||||
case KEY_2:
|
case KEY_2:
|
||||||
|
|||||||
@@ -37,11 +37,10 @@ extern uint8_t gAirCopyIsSendMode;
|
|||||||
|
|
||||||
extern uint16_t g_FSK_Buffer[36];
|
extern uint16_t g_FSK_Buffer[36];
|
||||||
|
|
||||||
void AIRCOPY_SendMessage(void);
|
bool AIRCOPY_SendMessage(void);
|
||||||
void AIRCOPY_StorePacket(void);
|
void AIRCOPY_StorePacket(void);
|
||||||
void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
|
|
||||||
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);
|
||||||
uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper);
|
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);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ bool gScanPauseMode;
|
|||||||
|
|
||||||
#ifdef ENABLE_SCAN_RANGES
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
uint32_t gScanRangeStart;
|
uint32_t gScanRangeStart;
|
||||||
|
uint32_t gScanRangeStop;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -71,14 +72,14 @@ void CHFRSCANNER_ContinueScanning(void)
|
|||||||
if (IS_FREQ_CHANNEL(gNextMrChannel))
|
if (IS_FREQ_CHANNEL(gNextMrChannel))
|
||||||
{
|
{
|
||||||
if (gCurrentFunction == FUNCTION_INCOMING)
|
if (gCurrentFunction == FUNCTION_INCOMING)
|
||||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
|
||||||
else
|
else
|
||||||
NextFreqChannel(); // switch to next frequency
|
NextFreqChannel(); // switch to next frequency
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gCurrentCodeType == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING)
|
if (gCurrentCodeType == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING)
|
||||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
|
||||||
else
|
else
|
||||||
NextMemChannel(); // switch to next channel
|
NextMemChannel(); // switch to next channel
|
||||||
}
|
}
|
||||||
@@ -157,9 +158,7 @@ static void NextFreqChannel(void)
|
|||||||
{
|
{
|
||||||
#ifdef ENABLE_SCAN_RANGES
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
if(gScanRangeStart) {
|
if(gScanRangeStart) {
|
||||||
uint32_t start = gScanRangeStart;
|
gRxVfo->freq_config_RX.Frequency = APP_SetFreqByStepAndLimits(gRxVfo, gScanStateDir, gScanRangeStart, gScanRangeStop);
|
||||||
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
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ extern bool gScanPauseMode;
|
|||||||
|
|
||||||
#ifdef ENABLE_SCAN_RANGES
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
extern uint32_t gScanRangeStart;
|
extern uint32_t gScanRangeStart;
|
||||||
|
extern uint32_t gScanRangeStop;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void CHFRSCANNER_Found(void);
|
void CHFRSCANNER_Found(void);
|
||||||
|
|||||||
89
app/dtmf.c
@@ -78,6 +78,38 @@ void DTMF_clear_RX(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void DTMF_SendEndOfTransmission(void)
|
||||||
|
{
|
||||||
|
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO)
|
||||||
|
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE);
|
||||||
|
else if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)
|
||||||
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|
&& gDTMF_CallState == DTMF_CALL_STATE_NONE
|
||||||
|
#endif
|
||||||
|
) { // end-of-tx
|
||||||
|
if (gEeprom.DTMF_SIDE_TONE) {
|
||||||
|
AUDIO_AudioPathOn();
|
||||||
|
gEnableSpeaker = true;
|
||||||
|
SYSTEM_DelayMs(60);
|
||||||
|
}
|
||||||
|
|
||||||
|
BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE);
|
||||||
|
|
||||||
|
BK4819_PlayDTMFString(
|
||||||
|
gEeprom.DTMF_DOWN_CODE,
|
||||||
|
0,
|
||||||
|
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME,
|
||||||
|
gEeprom.DTMF_HASH_CODE_PERSIST_TIME,
|
||||||
|
gEeprom.DTMF_CODE_PERSIST_TIME,
|
||||||
|
gEeprom.DTMF_CODE_INTERVAL_TIME);
|
||||||
|
|
||||||
|
AUDIO_AudioPathOff();
|
||||||
|
gEnableSpeaker = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BK4819_ExitDTMF_TX(true);
|
||||||
|
}
|
||||||
|
|
||||||
bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
|
bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -103,34 +135,28 @@ bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
|
|||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
bool DTMF_GetContact(const int Index, char *pContact)
|
bool DTMF_GetContact(const int Index, char *pContact)
|
||||||
{
|
{
|
||||||
int i = -1;
|
if (Index < 0 || Index >= MAX_DTMF_CONTACTS || pContact == NULL) {
|
||||||
if (Index >= 0 && Index < MAX_DTMF_CONTACTS && pContact != NULL)
|
return false;
|
||||||
{
|
|
||||||
EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
|
|
||||||
i = (int)pContact[0] - ' ';
|
|
||||||
}
|
}
|
||||||
return (i < 0 || i >= 95) ? false : true;
|
|
||||||
|
EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
|
||||||
|
|
||||||
|
// check whether the first character is printable or not
|
||||||
|
return (pContact[0] >= ' ' && pContact[0] < 127);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DTMF_FindContact(const char *pContact, char *pResult)
|
bool DTMF_FindContact(const char *pContact, char *pResult)
|
||||||
{
|
{
|
||||||
|
pResult[0] = 0;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < MAX_DTMF_CONTACTS; i++) {
|
||||||
char Contact[16];
|
char Contact[16];
|
||||||
unsigned int i;
|
if (!DTMF_GetContact(i, Contact)) {
|
||||||
|
|
||||||
for (i = 0; i < MAX_DTMF_CONTACTS; i++)
|
|
||||||
{
|
|
||||||
unsigned int j;
|
|
||||||
|
|
||||||
if (!DTMF_GetContact(i, Contact))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (j = 0; j < 3; j++)
|
if (memcmp(pContact, Contact + 8, 3) == 0) {
|
||||||
if (pContact[j] != Contact[j + 8])
|
memcpy(pResult, Contact, 8);
|
||||||
break;
|
|
||||||
|
|
||||||
if (j == 3)
|
|
||||||
{
|
|
||||||
memmove(pResult, Contact, 8);
|
|
||||||
pResult[8] = 0;
|
pResult[8] = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -183,12 +209,12 @@ static bool CompareMessage(const char *pMsg, const char *pTemplate, const unsign
|
|||||||
|
|
||||||
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size)
|
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
for (unsigned int i = 0; i < size; i++)
|
||||||
for (i = 0; i < size; i++)
|
if (pMsg[i] == gEeprom.DTMF_GROUP_CALL_CODE) {
|
||||||
if (pMsg[i] == gEeprom.DTMF_GROUP_CALL_CODE)
|
return DTMF_CALL_MODE_GROUP;
|
||||||
break;
|
}
|
||||||
|
|
||||||
return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP;
|
return DTMF_CALL_MODE_NOT_GROUP;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -303,13 +329,12 @@ void DTMF_HandleRequest(void)
|
|||||||
|
|
||||||
if (gDTMF_RX_index >= 2)
|
if (gDTMF_RX_index >= 2)
|
||||||
{ // look for ACK reply
|
{ // look for ACK reply
|
||||||
|
char *pPrintStr = "AB";
|
||||||
|
|
||||||
strcpy(String, "AB");
|
Offset = gDTMF_RX_index - strlen(pPrintStr);
|
||||||
|
|
||||||
Offset = gDTMF_RX_index - strlen(String);
|
if (CompareMessage(gDTMF_RX + Offset, pPrintStr, strlen(pPrintStr), true)) {
|
||||||
|
// ends with "AB"
|
||||||
if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true))
|
|
||||||
{ // ends with "AB"
|
|
||||||
|
|
||||||
if (gDTMF_ReplyState != DTMF_REPLY_NONE) // 1of11
|
if (gDTMF_ReplyState != DTMF_REPLY_NONE) // 1of11
|
||||||
// if (gDTMF_CallState != DTMF_CALL_STATE_NONE) // 1of11
|
// if (gDTMF_CallState != DTMF_CALL_STATE_NONE) // 1of11
|
||||||
@@ -361,8 +386,8 @@ void DTMF_HandleRequest(void)
|
|||||||
|
|
||||||
memset(gDTMF_Callee, 0, sizeof(gDTMF_Callee));
|
memset(gDTMF_Callee, 0, sizeof(gDTMF_Callee));
|
||||||
memset(gDTMF_Caller, 0, sizeof(gDTMF_Caller));
|
memset(gDTMF_Caller, 0, sizeof(gDTMF_Caller));
|
||||||
memmove(gDTMF_Callee, gDTMF_RX + Offset + 0, 3);
|
memcpy(gDTMF_Callee, gDTMF_RX + Offset + 0, 3);
|
||||||
memmove(gDTMF_Caller, gDTMF_RX + Offset + 4, 3);
|
memcpy(gDTMF_Caller, gDTMF_RX + Offset + 4, 3);
|
||||||
|
|
||||||
DTMF_clear_RX();
|
DTMF_clear_RX();
|
||||||
|
|
||||||
|
|||||||
20
app/dtmf.h
@@ -78,7 +78,17 @@ extern uint8_t gDTMF_PreviousIndex;
|
|||||||
extern char gDTMF_RX_live[20];
|
extern char gDTMF_RX_live[20];
|
||||||
extern uint8_t gDTMF_RX_live_timeout;
|
extern uint8_t gDTMF_RX_live_timeout;
|
||||||
|
|
||||||
|
extern DTMF_ReplyState_t gDTMF_ReplyState;
|
||||||
|
|
||||||
|
bool DTMF_ValidateCodes(char *pCode, const unsigned int size);
|
||||||
|
char DTMF_GetCharacter(const unsigned int code);
|
||||||
|
void DTMF_clear_input_box(void);
|
||||||
|
void DTMF_Append(const char code);
|
||||||
|
void DTMF_Reply(void);
|
||||||
|
void DTMF_SendEndOfTransmission(void);
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#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;
|
||||||
@@ -97,21 +107,13 @@ extern DTMF_CallState_t gDTMF_CallState;
|
|||||||
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;
|
|
||||||
|
|
||||||
bool DTMF_ValidateCodes(char *pCode, const unsigned int size);
|
|
||||||
char DTMF_GetCharacter(const unsigned int code);
|
|
||||||
void DTMF_clear_input_box(void);
|
|
||||||
void DTMF_Append(const char vode);
|
|
||||||
void DTMF_Reply(void);
|
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
|
||||||
void DTMF_clear_RX(void);
|
void DTMF_clear_RX(void);
|
||||||
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size);
|
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size);
|
||||||
bool DTMF_GetContact(const int Index, char *pContact);
|
bool DTMF_GetContact(const int Index, char *pContact);
|
||||||
bool DTMF_FindContact(const char *pContact, char *pResult);
|
bool DTMF_FindContact(const char *pContact, char *pResult);
|
||||||
void DTMF_HandleRequest(void);
|
void DTMF_HandleRequest(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
66
app/flashlight.c
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#ifdef ENABLE_FLASHLIGHT
|
||||||
|
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "bsp/dp32g030/gpio.h"
|
||||||
|
|
||||||
|
#include "flashlight.h"
|
||||||
|
|
||||||
|
enum FlashlightMode_t gFlashLightState;
|
||||||
|
|
||||||
|
void FlashlightTimeSlice()
|
||||||
|
{
|
||||||
|
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) {
|
||||||
|
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gFlashLightState == FLASHLIGHT_SOS) {
|
||||||
|
const uint16_t u = 15;
|
||||||
|
static uint8_t c;
|
||||||
|
static uint16_t next;
|
||||||
|
|
||||||
|
if (gFlashLightBlinkCounter - next > 7 * u) {
|
||||||
|
c = 0;
|
||||||
|
next = gFlashLightBlinkCounter + 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gFlashLightBlinkCounter == next) {
|
||||||
|
if (c==0) {
|
||||||
|
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
} else {
|
||||||
|
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c >= 18) {
|
||||||
|
next = gFlashLightBlinkCounter + 7 * u;
|
||||||
|
c = 0;
|
||||||
|
} else if(c==7 || c==9 || c==11) {
|
||||||
|
next = gFlashLightBlinkCounter + 3 * u;
|
||||||
|
} else {
|
||||||
|
next = gFlashLightBlinkCounter + u;
|
||||||
|
}
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACTION_FlashLight(void)
|
||||||
|
{
|
||||||
|
switch (gFlashLightState) {
|
||||||
|
case FLASHLIGHT_OFF:
|
||||||
|
gFlashLightState++;
|
||||||
|
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
break;
|
||||||
|
case FLASHLIGHT_ON:
|
||||||
|
case FLASHLIGHT_BLINK:
|
||||||
|
gFlashLightState++;
|
||||||
|
break;
|
||||||
|
case FLASHLIGHT_SOS:
|
||||||
|
default:
|
||||||
|
gFlashLightState = 0;
|
||||||
|
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
23
app/flashlight.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef APP_FLASHLIGHT_H
|
||||||
|
#define APP_FLASHLIGHT_H
|
||||||
|
|
||||||
|
#ifdef ENABLE_FLASHLIGHT
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
enum FlashlightMode_t {
|
||||||
|
FLASHLIGHT_OFF = 0,
|
||||||
|
FLASHLIGHT_ON,
|
||||||
|
FLASHLIGHT_BLINK,
|
||||||
|
FLASHLIGHT_SOS
|
||||||
|
};
|
||||||
|
|
||||||
|
extern enum FlashlightMode_t gFlashLightState;
|
||||||
|
extern volatile uint16_t gFlashLightBlinkCounter;
|
||||||
|
|
||||||
|
void FlashlightTimeSlice(void);
|
||||||
|
void ACTION_FlashLight(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
222
app/fm.c
@@ -62,19 +62,17 @@ 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] >= BK1080_GetFreqLoLimit(gEeprom.FM_Band) &&
|
||||||
|
gFM_Channels[Channel] < BK1080_GetFreqHiLimit(gEeprom.FM_Band);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
|
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
for (unsigned i = 0; i < ARRAY_SIZE(gFM_Channels); i++) {
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(gFM_Channels); i++)
|
|
||||||
{
|
|
||||||
if (Channel == 0xFF)
|
if (Channel == 0xFF)
|
||||||
Channel = ARRAY_SIZE(gFM_Channels) - 1;
|
Channel = ARRAY_SIZE(gFM_Channels) - 1;
|
||||||
else
|
else if (Channel >= ARRAY_SIZE(gFM_Channels))
|
||||||
if (Channel >= ARRAY_SIZE(gFM_Channels))
|
|
||||||
Channel = 0;
|
Channel = 0;
|
||||||
if (FM_CheckValidChannel(Channel))
|
if (FM_CheckValidChannel(Channel))
|
||||||
return Channel;
|
return Channel;
|
||||||
@@ -88,11 +86,9 @@ int FM_ConfigureChannelState(void)
|
|||||||
{
|
{
|
||||||
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
|
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
|
||||||
|
|
||||||
if (gEeprom.FM_IsMrMode)
|
if (gEeprom.FM_IsMrMode) {
|
||||||
{
|
|
||||||
const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel, FM_CHANNEL_UP);
|
const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel, FM_CHANNEL_UP);
|
||||||
if (Channel == 0xFF)
|
if (Channel == 0xFF) {
|
||||||
{
|
|
||||||
gEeprom.FM_IsMrMode = false;
|
gEeprom.FM_IsMrMode = false;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -110,21 +106,19 @@ void FM_TurnOff(void)
|
|||||||
gFM_RestoreCountdown_10ms = 0;
|
gFM_RestoreCountdown_10ms = 0;
|
||||||
|
|
||||||
AUDIO_AudioPathOff();
|
AUDIO_AudioPathOff();
|
||||||
|
|
||||||
gEnableSpeaker = false;
|
gEnableSpeaker = false;
|
||||||
|
|
||||||
BK1080_Init(0, false);
|
BK1080_Init0();
|
||||||
|
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FM_EraseChannels(void)
|
void FM_EraseChannels(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
uint8_t Template[8];
|
uint8_t Template[8];
|
||||||
|
|
||||||
memset(Template, 0xFF, sizeof(Template));
|
memset(Template, 0xFF, sizeof(Template));
|
||||||
for (i = 0; i < 5; i++)
|
|
||||||
|
for (unsigned i = 0; i < 5; i++)
|
||||||
EEPROM_WriteBuffer(0x0E40 + (i * 8), Template);
|
EEPROM_WriteBuffer(0x0E40 + (i * 8), Template);
|
||||||
|
|
||||||
memset(gFM_Channels, 0xFF, sizeof(gFM_Channels));
|
memset(gFM_Channels, 0xFF, sizeof(gFM_Channels));
|
||||||
@@ -144,35 +138,32 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
|
|||||||
gAskToDelete = false;
|
gAskToDelete = false;
|
||||||
gEeprom.FM_FrequencyPlaying = Frequency;
|
gEeprom.FM_FrequencyPlaying = Frequency;
|
||||||
|
|
||||||
if (!bFlag)
|
if (!bFlag) {
|
||||||
{
|
|
||||||
Frequency += Step;
|
Frequency += Step;
|
||||||
if (Frequency < gEeprom.FM_LowerLimit)
|
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band))
|
||||||
Frequency = gEeprom.FM_UpperLimit;
|
Frequency = BK1080_GetFreqHiLimit(gEeprom.FM_Band);
|
||||||
else
|
else if (Frequency > BK1080_GetFreqHiLimit(gEeprom.FM_Band))
|
||||||
if (Frequency > gEeprom.FM_UpperLimit)
|
Frequency = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||||
Frequency = gEeprom.FM_LowerLimit;
|
|
||||||
|
|
||||||
gEeprom.FM_FrequencyPlaying = Frequency;
|
gEeprom.FM_FrequencyPlaying = Frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
gFM_ScanState = Step;
|
gFM_ScanState = Step;
|
||||||
|
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FM_PlayAndUpdate(void)
|
void FM_PlayAndUpdate(void)
|
||||||
{
|
{
|
||||||
gFM_ScanState = FM_SCAN_OFF;
|
gFM_ScanState = FM_SCAN_OFF;
|
||||||
|
|
||||||
if (gFM_AutoScan)
|
if (gFM_AutoScan) {
|
||||||
{
|
|
||||||
gEeprom.FM_IsMrMode = true;
|
gEeprom.FM_IsMrMode = true;
|
||||||
gEeprom.FM_SelectedChannel = 0;
|
gEeprom.FM_SelectedChannel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FM_ConfigureChannelState();
|
FM_ConfigureChannelState();
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
SETTINGS_SaveFM();
|
SETTINGS_SaveFM();
|
||||||
|
|
||||||
gFmPlayCountdown_10ms = 0;
|
gFmPlayCountdown_10ms = 0;
|
||||||
@@ -193,41 +184,35 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
|
|||||||
// This is supposed to be a signed value, but above function is unsigned
|
// This is supposed to be a signed value, but above function is unsigned
|
||||||
const uint16_t Deviation = BK1080_REG_07_GET_FREQD(Test2);
|
const uint16_t Deviation = BK1080_REG_07_GET_FREQD(Test2);
|
||||||
|
|
||||||
if (BK1080_REG_07_GET_SNR(Test2) >= 2)
|
if (BK1080_REG_07_GET_SNR(Test2) <= 2) {
|
||||||
{
|
|
||||||
const uint16_t Status = BK1080_ReadRegister(BK1080_REG_10);
|
|
||||||
if ((Status & BK1080_REG_10_MASK_AFCRL) == BK1080_REG_10_AFCRL_NOT_RAILED && BK1080_REG_10_GET_RSSI(Status) >= 10)
|
|
||||||
{
|
|
||||||
//if (Deviation > -281 && Deviation < 280)
|
|
||||||
if (Deviation < 280 || Deviation > 3815)
|
|
||||||
{
|
|
||||||
// not BLE(less than or equal)
|
|
||||||
|
|
||||||
if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1)
|
|
||||||
{
|
|
||||||
if (BK1080_FrequencyDeviation & 0x800)
|
|
||||||
goto Bail;
|
goto Bail;
|
||||||
|
}
|
||||||
|
|
||||||
if (BK1080_FrequencyDeviation < 20)
|
const uint16_t Status = BK1080_ReadRegister(BK1080_REG_10);
|
||||||
|
|
||||||
|
if ((Status & BK1080_REG_10_MASK_AFCRL) != BK1080_REG_10_AFCRL_NOT_RAILED || BK1080_REG_10_GET_RSSI(Status) < 10) {
|
||||||
|
goto Bail;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (Deviation > -281 && Deviation < 280)
|
||||||
|
if (Deviation >= 280 && Deviation <= 3815) {
|
||||||
|
goto Bail;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not BLE(less than or equal)
|
||||||
|
if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1) {
|
||||||
|
if (BK1080_FrequencyDeviation & 0x800 || (BK1080_FrequencyDeviation < 20))
|
||||||
goto Bail;
|
goto Bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// not BLT(less than)
|
// not BLT(less than)
|
||||||
|
|
||||||
if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1)
|
if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1) {
|
||||||
{
|
if ((BK1080_FrequencyDeviation & 0x800) == 0 || (BK1080_FrequencyDeviation > 4075))
|
||||||
if ((BK1080_FrequencyDeviation & 0x800) == 0)
|
|
||||||
goto Bail;
|
|
||||||
|
|
||||||
// if (BK1080_FrequencyDeviation > -21)
|
|
||||||
if (BK1080_FrequencyDeviation > 4075)
|
|
||||||
goto Bail;
|
goto Bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Bail:
|
Bail:
|
||||||
BK1080_FrequencyDeviation = Deviation;
|
BK1080_FrequencyDeviation = Deviation;
|
||||||
@@ -278,7 +263,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
|
|||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
Frequency = StrToUL(INPUTBOX_GetAscii());
|
Frequency = StrToUL(INPUTBOX_GetAscii());
|
||||||
|
|
||||||
if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) {
|
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band) || BK1080_GetFreqHiLimit(gEeprom.FM_Band) < Frequency) {
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
return;
|
return;
|
||||||
@@ -289,7 +274,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
|
|||||||
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, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -307,7 +292,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
|
|||||||
#endif
|
#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, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -336,8 +321,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
|
|||||||
|
|
||||||
static void Key_FUNC(KEY_Code_t Key, uint8_t state)
|
static void Key_FUNC(KEY_Code_t Key, uint8_t state)
|
||||||
{
|
{
|
||||||
if (state == BUTTON_EVENT_SHORT || state == BUTTON_EVENT_HELD)
|
if (state == BUTTON_EVENT_SHORT || state == BUTTON_EVENT_HELD) {
|
||||||
{
|
|
||||||
bool autoScan = gWasFKeyPressed || (state == BUTTON_EVENT_HELD);
|
bool autoScan = gWasFKeyPressed || (state == BUTTON_EVENT_HELD);
|
||||||
|
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
@@ -350,12 +334,21 @@ static void Key_FUNC(KEY_Code_t Key, uint8_t state)
|
|||||||
ACTION_FM();
|
ACTION_FM();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case KEY_1:
|
||||||
|
gEeprom.FM_Band++;
|
||||||
|
gRequestSaveFM = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// case KEY_2:
|
||||||
|
// gEeprom.FM_Space = (gEeprom.FM_Space + 1) % 3;
|
||||||
|
// gRequestSaveFM = true;
|
||||||
|
// break;
|
||||||
|
|
||||||
case KEY_3:
|
case KEY_3:
|
||||||
gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode;
|
gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode;
|
||||||
|
|
||||||
if (!FM_ConfigureChannelState())
|
if (!FM_ConfigureChannelState()) {
|
||||||
{
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -380,12 +373,9 @@ static void Key_EXIT(uint8_t state)
|
|||||||
|
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
|
|
||||||
if (gFM_ScanState == FM_SCAN_OFF)
|
if (gFM_ScanState == FM_SCAN_OFF) {
|
||||||
{
|
if (gInputBoxIndex == 0) {
|
||||||
if (gInputBoxIndex == 0)
|
if (!gAskToSave && !gAskToDelete) {
|
||||||
{
|
|
||||||
if (!gAskToSave && !gAskToDelete)
|
|
||||||
{
|
|
||||||
ACTION_FM();
|
ACTION_FM();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -393,25 +383,20 @@ static void Key_EXIT(uint8_t state)
|
|||||||
gAskToSave = false;
|
gAskToSave = false;
|
||||||
gAskToDelete = false;
|
gAskToDelete = false;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
gInputBox[--gInputBoxIndex] = 10;
|
gInputBox[--gInputBoxIndex] = 10;
|
||||||
|
|
||||||
if (gInputBoxIndex)
|
if (gInputBoxIndex) {
|
||||||
{
|
if (gInputBoxIndex != 1) {
|
||||||
if (gInputBoxIndex != 1)
|
|
||||||
{
|
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gInputBox[0] != 0)
|
if (gInputBox[0] != 0) {
|
||||||
{
|
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,8 +404,7 @@ static void Key_EXIT(uint8_t state)
|
|||||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
FM_PlayAndUpdate();
|
FM_PlayAndUpdate();
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||||
@@ -439,52 +423,38 @@ static void Key_MENU(uint8_t state)
|
|||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
|
|
||||||
if (gFM_ScanState == FM_SCAN_OFF)
|
if (gFM_ScanState == FM_SCAN_OFF) {
|
||||||
{
|
if (!gEeprom.FM_IsMrMode) {
|
||||||
if (!gEeprom.FM_IsMrMode)
|
if (gAskToSave) {
|
||||||
{
|
|
||||||
if (gAskToSave)
|
|
||||||
{
|
|
||||||
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying;
|
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying;
|
||||||
gAskToSave = false;
|
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
}
|
}
|
||||||
else
|
gAskToSave = !gAskToSave;
|
||||||
gAskToSave = true;
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (gAskToDelete) {
|
||||||
if (gAskToDelete)
|
|
||||||
{
|
|
||||||
gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF;
|
gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF;
|
||||||
|
|
||||||
FM_ConfigureChannelState();
|
FM_ConfigureChannelState();
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
|
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
gAskToDelete = false;
|
|
||||||
}
|
}
|
||||||
else
|
gAskToDelete = !gAskToDelete;
|
||||||
gAskToDelete = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (gFM_AutoScan || !gFM_FoundFrequency) {
|
||||||
if (gFM_AutoScan || !gFM_FoundFrequency)
|
|
||||||
{
|
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gAskToSave)
|
if (gAskToSave) {
|
||||||
{
|
|
||||||
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying;
|
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying;
|
||||||
gAskToSave = false;
|
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
}
|
}
|
||||||
else
|
gAskToSave = !gAskToSave;
|
||||||
gAskToSave = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,9 +467,7 @@ static void Key_UP_DOWN(uint8_t state, int8_t Step)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
}
|
} else if (gInputBoxIndex || state!=BUTTON_EVENT_HELD) {
|
||||||
else {
|
|
||||||
if (gInputBoxIndex || state!=BUTTON_EVENT_HELD)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,11 +498,11 @@ static void Key_UP_DOWN(uint8_t state, int8_t Step)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step;
|
uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step;
|
||||||
if (Frequency < gEeprom.FM_LowerLimit)
|
|
||||||
Frequency = gEeprom.FM_UpperLimit;
|
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band))
|
||||||
else
|
Frequency = BK1080_GetFreqHiLimit(gEeprom.FM_Band);
|
||||||
if (Frequency > gEeprom.FM_UpperLimit)
|
else if (Frequency > BK1080_GetFreqHiLimit(gEeprom.FM_Band))
|
||||||
Frequency = gEeprom.FM_LowerLimit;
|
Frequency = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||||
|
|
||||||
gEeprom.FM_FrequencyPlaying = Frequency;
|
gEeprom.FM_FrequencyPlaying = Frequency;
|
||||||
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
|
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
|
||||||
@@ -543,7 +511,7 @@ static void Key_UP_DOWN(uint8_t state, int8_t Step)
|
|||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
|
|
||||||
Bail:
|
Bail:
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
}
|
}
|
||||||
@@ -552,20 +520,8 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
{
|
{
|
||||||
uint8_t state = bKeyPressed + 2 * bKeyHeld;
|
uint8_t state = bKeyPressed + 2 * bKeyHeld;
|
||||||
|
|
||||||
|
switch (Key) {
|
||||||
|
case KEY_0...KEY_9:
|
||||||
switch (Key)
|
|
||||||
{
|
|
||||||
case KEY_0:
|
|
||||||
case KEY_1:
|
|
||||||
case KEY_2:
|
|
||||||
case KEY_3:
|
|
||||||
case KEY_4:
|
|
||||||
case KEY_5:
|
|
||||||
case KEY_6:
|
|
||||||
case KEY_7:
|
|
||||||
case KEY_8:
|
|
||||||
case KEY_9:
|
|
||||||
Key_DIGITS(Key, state);
|
Key_DIGITS(Key, state);
|
||||||
break;
|
break;
|
||||||
case KEY_STAR:
|
case KEY_STAR:
|
||||||
@@ -573,7 +529,7 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
break;
|
break;
|
||||||
case KEY_MENU:
|
case KEY_MENU:
|
||||||
Key_MENU(state);
|
Key_MENU(state);
|
||||||
return;
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
Key_UP_DOWN(state, 1);
|
Key_UP_DOWN(state, 1);
|
||||||
break;
|
break;
|
||||||
@@ -598,10 +554,8 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
void FM_Play(void)
|
void FM_Play(void)
|
||||||
{
|
{
|
||||||
if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, gEeprom.FM_LowerLimit))
|
if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, BK1080_GetFreqLoLimit(gEeprom.FM_Band))) {
|
||||||
{
|
if (!gFM_AutoScan) {
|
||||||
if (!gFM_AutoScan)
|
|
||||||
{
|
|
||||||
gFmPlayCountdown_10ms = 0;
|
gFmPlayCountdown_10ms = 0;
|
||||||
gFM_FoundFrequency = true;
|
gFM_FoundFrequency = true;
|
||||||
|
|
||||||
@@ -618,15 +572,14 @@ void FM_Play(void)
|
|||||||
if (gFM_ChannelPosition < 20)
|
if (gFM_ChannelPosition < 20)
|
||||||
gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying;
|
gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying;
|
||||||
|
|
||||||
if (gFM_ChannelPosition >= 20)
|
if (gFM_ChannelPosition >= 20) {
|
||||||
{
|
|
||||||
FM_PlayAndUpdate();
|
FM_PlayAndUpdate();
|
||||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= gEeprom.FM_UpperLimit)
|
if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= BK1080_GetFreqHiLimit(1))
|
||||||
FM_PlayAndUpdate();
|
FM_PlayAndUpdate();
|
||||||
else
|
else
|
||||||
FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false);
|
FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false);
|
||||||
@@ -636,11 +589,12 @@ void FM_Play(void)
|
|||||||
|
|
||||||
void FM_Start(void)
|
void FM_Start(void)
|
||||||
{
|
{
|
||||||
|
gDualWatchActive = false;
|
||||||
gFmRadioMode = true;
|
gFmRadioMode = true;
|
||||||
gFM_ScanState = FM_SCAN_OFF;
|
gFM_ScanState = FM_SCAN_OFF;
|
||||||
gFM_RestoreCountdown_10ms = 0;
|
gFM_RestoreCountdown_10ms = 0;
|
||||||
|
|
||||||
BK1080_Init(gEeprom.FM_FrequencyPlaying, true);
|
BK1080_Init(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
|
|
||||||
AUDIO_AudioPathOn();
|
AUDIO_AudioPathOn();
|
||||||
|
|
||||||
|
|||||||
3
app/fm.h
@@ -38,10 +38,10 @@ extern uint8_t gFM_ChannelPosition;
|
|||||||
// Doubts about whether this should be signed or not
|
// Doubts about whether this should be signed or not
|
||||||
extern uint16_t gFM_FrequencyDeviation;
|
extern uint16_t gFM_FrequencyDeviation;
|
||||||
extern bool gFM_FoundFrequency;
|
extern bool gFM_FoundFrequency;
|
||||||
extern bool gFM_AutoScan;
|
|
||||||
extern uint16_t gFM_RestoreCountdown_10ms;
|
extern uint16_t gFM_RestoreCountdown_10ms;
|
||||||
|
|
||||||
bool FM_CheckValidChannel(uint8_t Channel);
|
bool FM_CheckValidChannel(uint8_t Channel);
|
||||||
|
// returns first valid channel starting at Channel
|
||||||
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction);
|
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction);
|
||||||
int FM_ConfigureChannelState(void);
|
int FM_ConfigureChannelState(void);
|
||||||
void FM_TurnOff(void);
|
void FM_TurnOff(void);
|
||||||
@@ -59,4 +59,3 @@ void FM_Start(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -39,17 +39,14 @@
|
|||||||
|
|
||||||
void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
|
void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
if (gInputBoxIndex > 0)
|
if (gInputBoxIndex > 0) {
|
||||||
{
|
|
||||||
if (!bKeyHeld && bKeyPressed) // short pressed
|
if (!bKeyHeld && bKeyPressed) // short pressed
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bKeyHeld || !bKeyPressed) // held or released
|
if (bKeyHeld || !bKeyPressed) { // held or released
|
||||||
{
|
if (bKeyHeld || bKeyPressed) { // held or pressed (cannot be held and not pressed I guess, so it checks only if HELD?)
|
||||||
if (bKeyHeld || bKeyPressed) // held or pressed (cannot be held and not pressed I guess, so it checks only if HELD?)
|
|
||||||
{
|
|
||||||
if (!bKeyHeld) // won't ever pass
|
if (!bKeyHeld) // won't ever pass
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -58,8 +55,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
COMMON_KeypadLockToggle();
|
COMMON_KeypadLockToggle();
|
||||||
}
|
}
|
||||||
else // released
|
else { // released
|
||||||
{
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
|
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
|
||||||
return;
|
return;
|
||||||
@@ -77,28 +73,25 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
|
|||||||
if (!gWasFKeyPressed)
|
if (!gWasFKeyPressed)
|
||||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // short pressed
|
else { // short pressed
|
||||||
{
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gScreenToDisplay != DISPLAY_FM)
|
if (gScreenToDisplay != DISPLAY_FM)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFM_ScanState == FM_SCAN_OFF) // not scanning
|
if (gFM_ScanState == FM_SCAN_OFF) { // not scanning
|
||||||
{
|
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gBeepToPlay = BEEP_440HZ_500MS;
|
gBeepToPlay = BEEP_440HZ_500MS;
|
||||||
|
|
||||||
gPttWasReleased = true;
|
gPttWasReleased = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,31 +100,26 @@ void GENERIC_Key_PTT(bool bKeyPressed)
|
|||||||
{
|
{
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
if (!bKeyPressed || gSerialConfigCountDown_500ms > 0)
|
if (!bKeyPressed || SerialConfigInProgress())
|
||||||
{ // PTT released
|
{ // PTT released
|
||||||
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
if (gCurrentFunction == FUNCTION_TRANSMIT) {
|
||||||
{ // we are transmitting .. stop
|
// we are transmitting .. stop
|
||||||
|
if (gFlagEndTransmission) {
|
||||||
if (gFlagEndTransmission)
|
|
||||||
{
|
|
||||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
APP_EndTransmission();
|
APP_EndTransmission();
|
||||||
|
|
||||||
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
|
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
|
||||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||||
else
|
else
|
||||||
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
|
gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
gFlagEndTransmission = false;
|
gFlagEndTransmission = false;
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
gVOX_NoiseDetected = false;
|
gVOX_NoiseDetected = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RADIO_SetVfoState(VFO_STATE_NORMAL);
|
RADIO_SetVfoState(VFO_STATE_NORMAL);
|
||||||
|
|
||||||
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||||
@@ -144,23 +132,20 @@ void GENERIC_Key_PTT(bool bKeyPressed)
|
|||||||
// PTT pressed
|
// PTT pressed
|
||||||
|
|
||||||
|
|
||||||
if (SCANNER_IsScanning())
|
if (SCANNER_IsScanning()) {
|
||||||
{ // CTCSS/CDCSS scanning .. stop
|
SCANNER_Stop(); // CTCSS/CDCSS scanning .. stop
|
||||||
SCANNER_Stop();
|
|
||||||
goto cancel_tx;
|
goto cancel_tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gScanStateDir != SCAN_OFF)
|
if (gScanStateDir != SCAN_OFF) {
|
||||||
{ // frequency/channel scanning . .stop
|
CHFRSCANNER_Stop(); // frequency/channel scanning . .stop
|
||||||
CHFRSCANNER_Stop();
|
|
||||||
goto cancel_tx;
|
goto cancel_tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFM_ScanState != FM_SCAN_OFF)
|
if (gFM_ScanState != FM_SCAN_OFF) { // FM radio is scanning .. stop
|
||||||
{ // FM radio is scanning .. stop
|
|
||||||
FM_PlayAndUpdate();
|
FM_PlayAndUpdate();
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||||
@@ -175,8 +160,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
|
|||||||
goto start_tx; // listening to the FM radio .. start TX'ing
|
goto start_tx; // listening to the FM radio .. start TX'ing
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0)
|
if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown_10ms == 0) {// already transmitting
|
||||||
{ // already transmitting
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -190,9 +174,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
|
|||||||
|
|
||||||
// was entering a DTMF string
|
// was entering a DTMF string
|
||||||
|
|
||||||
if (gDTMF_InputBox_Index > 0 || gDTMF_PreviousIndex > 0)
|
if (gDTMF_InputBox_Index > 0 || gDTMF_PreviousIndex > 0) { // going to transmit a DTMF string
|
||||||
{ // going to transmit a DTMF string
|
|
||||||
|
|
||||||
if (gDTMF_InputBox_Index == 0 && gDTMF_PreviousIndex > 0)
|
if (gDTMF_InputBox_Index == 0 && gDTMF_PreviousIndex > 0)
|
||||||
gDTMF_InputBox_Index = gDTMF_PreviousIndex; // use the previous DTMF string
|
gDTMF_InputBox_Index = gDTMF_PreviousIndex; // use the previous DTMF string
|
||||||
|
|
||||||
@@ -223,15 +205,21 @@ start_tx:
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
cancel_tx:
|
cancel_tx:
|
||||||
if (gPttIsPressed)
|
if (gPttIsPressed) {
|
||||||
{
|
|
||||||
gPttWasPressed = true;
|
gPttWasPressed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gPttDebounceCounter = 0;
|
gPttDebounceCounter = 0;
|
||||||
if (gScreenToDisplay != DISPLAY_MENU && gRequestDisplayScreen != DISPLAY_FM) // 1of11 .. don't close the menu
|
if (gScreenToDisplay != DISPLAY_MENU
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
&& gRequestDisplayScreen != DISPLAY_FM
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
// 1of11 .. don't close the menu
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
|
}
|
||||||
|
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
}
|
}
|
||||||
|
|||||||
307
app/main.c
@@ -52,23 +52,17 @@ void toggle_chan_scanlist(void)
|
|||||||
if(!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
|
if(!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
|
||||||
#ifdef ENABLE_SCAN_RANGES
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
|
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
|
||||||
|
gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency;
|
||||||
|
if(gScanRangeStart > gScanRangeStop)
|
||||||
|
SWAP(gScanRangeStart, gScanRangeStop);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gTxVfo->SCANLIST1_PARTICIPATION)
|
if (gTxVfo->SCANLIST1_PARTICIPATION ^ gTxVfo->SCANLIST2_PARTICIPATION){
|
||||||
{
|
gTxVfo->SCANLIST2_PARTICIPATION = gTxVfo->SCANLIST1_PARTICIPATION;
|
||||||
if (gTxVfo->SCANLIST2_PARTICIPATION)
|
} else {
|
||||||
gTxVfo->SCANLIST1_PARTICIPATION = 0;
|
gTxVfo->SCANLIST1_PARTICIPATION = !gTxVfo->SCANLIST1_PARTICIPATION;
|
||||||
else
|
|
||||||
gTxVfo->SCANLIST2_PARTICIPATION = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (gTxVfo->SCANLIST2_PARTICIPATION)
|
|
||||||
gTxVfo->SCANLIST2_PARTICIPATION = 0;
|
|
||||||
else
|
|
||||||
gTxVfo->SCANLIST1_PARTICIPATION = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true);
|
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true);
|
||||||
@@ -79,30 +73,19 @@ void toggle_chan_scanlist(void)
|
|||||||
|
|
||||||
static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
||||||
{
|
{
|
||||||
uint8_t Band;
|
|
||||||
uint8_t Vfo = gEeprom.TX_VFO;
|
uint8_t Vfo = gEeprom.TX_VFO;
|
||||||
|
|
||||||
if (gScreenToDisplay == DISPLAY_MENU)
|
if (gScreenToDisplay == DISPLAY_MENU) {
|
||||||
{
|
|
||||||
// if (beep)
|
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (beep)
|
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
|
|
||||||
switch (Key)
|
switch (Key) {
|
||||||
{
|
|
||||||
case KEY_0:
|
case KEY_0:
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
ACTION_FM();
|
ACTION_FM();
|
||||||
#else
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: make use of this function key
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -113,11 +96,12 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
|
|
||||||
#ifdef ENABLE_COPY_CHAN_TO_VFO
|
#ifdef ENABLE_COPY_CHAN_TO_VFO
|
||||||
if (gEeprom.VFO_OPEN && !gCssBackgroundScan)
|
if (!gEeprom.VFO_OPEN || gCssBackgroundScan) {
|
||||||
{
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (gScanStateDir != SCAN_OFF)
|
if (gScanStateDir != SCAN_OFF) {
|
||||||
{
|
|
||||||
if (gCurrentFunction != FUNCTION_INCOMING ||
|
if (gCurrentFunction != FUNCTION_INCOMING ||
|
||||||
gRxReceptionMode == RX_MODE_NONE ||
|
gRxReceptionMode == RX_MODE_NONE ||
|
||||||
gScanPauseDelayIn_10ms == 0)
|
gScanPauseDelayIn_10ms == 0)
|
||||||
@@ -131,10 +115,8 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
|
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
|
||||||
{ // copy channel to VFO, then swap to the VFO
|
{ // copy channel to VFO, then swap to the VFO
|
||||||
|
|
||||||
const unsigned int channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;
|
gEeprom.ScreenChannel[vfo] = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;
|
||||||
|
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = gEeprom.ScreenChannel[vfo];
|
||||||
gEeprom.ScreenChannel[vfo] = channel;
|
|
||||||
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel;
|
|
||||||
|
|
||||||
RADIO_SelectVfos();
|
RADIO_SelectVfos();
|
||||||
RADIO_ApplyOffset(gRxVfo);
|
RADIO_ApplyOffset(gRxVfo);
|
||||||
@@ -145,34 +127,29 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
|
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gTxVfo->Band == 6 && gTxVfo->pRX->Frequency < 100000000) {
|
#ifdef ENABLE_WIDE_RX
|
||||||
gTxVfo->pRX->Frequency = 100000000;
|
if(gTxVfo->Band == BAND7_470MHz && gTxVfo->pRX->Frequency < _1GHz_in_KHz) {
|
||||||
|
gTxVfo->pRX->Frequency = _1GHz_in_KHz;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
Band = gTxVfo->Band + 1;
|
gTxVfo->Band += 1;
|
||||||
if (gSetting_350EN || Band != BAND5_350MHz) {
|
|
||||||
if (Band > BAND7_470MHz)
|
|
||||||
Band = BAND1_50MHz;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Band = BAND6_400MHz;
|
|
||||||
|
|
||||||
gTxVfo->Band = Band;
|
if (gTxVfo->Band == BAND5_350MHz && !gSetting_350EN) {
|
||||||
|
// skip if not enabled
|
||||||
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
|
gTxVfo->Band += 1;
|
||||||
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
|
} else if (gTxVfo->Band >= BAND_N_ELEM){
|
||||||
|
// go arround if overflowed
|
||||||
|
gTxVfo->Band = BAND1_50MHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + gTxVfo->Band;
|
||||||
|
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + gTxVfo->Band;
|
||||||
|
|
||||||
gRequestSaveVFO = true;
|
gRequestSaveVFO = true;
|
||||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||||
|
|
||||||
@@ -214,13 +191,10 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
case KEY_5:
|
case KEY_5:
|
||||||
if(beep) {
|
if(beep) {
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
|
if (!IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
|
||||||
if (!IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
|
||||||
{
|
|
||||||
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_VFO];
|
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_VFO];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
|
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
|
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
|
||||||
@@ -259,8 +233,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_9:
|
case KEY_9:
|
||||||
if (RADIO_CheckValidChannel(gEeprom.CHAN_1_CALL, false, 0))
|
if (RADIO_CheckValidChannel(gEeprom.CHAN_1_CALL, false, 0)) {
|
||||||
{
|
|
||||||
gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL;
|
gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL;
|
||||||
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL;
|
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL;
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
@@ -289,15 +262,10 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
|
|
||||||
static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
if (bKeyHeld)
|
if (bKeyHeld) { // key held down
|
||||||
{ // key held down
|
if (bKeyPressed) {
|
||||||
|
if (gScreenToDisplay == DISPLAY_MAIN) {
|
||||||
if (bKeyPressed)
|
if (gInputBoxIndex > 0) { // delete any inputted chars
|
||||||
{
|
|
||||||
if (gScreenToDisplay == DISPLAY_MAIN)
|
|
||||||
{
|
|
||||||
if (gInputBoxIndex > 0)
|
|
||||||
{ // delete any inputted chars
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
}
|
}
|
||||||
@@ -308,7 +276,6 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
processFKeyFunction(Key, false);
|
processFKeyFunction(Key, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,24 +285,15 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
return; // don't use the key till it's released
|
return; // don't use the key till it's released
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gWasFKeyPressed)
|
if (!gWasFKeyPressed) { // F-key wasn't pressed
|
||||||
{ // F-key wasn't pressed
|
|
||||||
|
|
||||||
const uint8_t Vfo = gEeprom.TX_VFO;
|
const uint8_t Vfo = gEeprom.TX_VFO;
|
||||||
|
|
||||||
gKeyInputCountdown = key_input_timeout_500ms;
|
gKeyInputCountdown = key_input_timeout_500ms;
|
||||||
|
|
||||||
INPUTBOX_Append(Key);
|
INPUTBOX_Append(Key);
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering channel number
|
||||||
{ // user is entering channel number
|
|
||||||
|
|
||||||
uint16_t Channel;
|
if (gInputBoxIndex != 3) {
|
||||||
|
|
||||||
if (gInputBoxIndex != 3)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
@@ -345,10 +303,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
const uint16_t Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
||||||
|
|
||||||
if (!RADIO_CheckValidChannel(Channel, false, 0))
|
if (!RADIO_CheckValidChannel(Channel, false, 0)) {
|
||||||
{
|
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -371,46 +328,32 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||||
{ // user is entering a frequency
|
{ // user is entering a frequency
|
||||||
|
|
||||||
uint32_t Frequency;
|
|
||||||
bool isGigaF = gTxVfo->pRX->Frequency >= 100000000;
|
|
||||||
if (gInputBoxIndex < 6 + isGigaF)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
|
bool isGigaF = gTxVfo->pRX->Frequency >= _1GHz_in_KHz;
|
||||||
|
if (gInputBoxIndex < 6 + isGigaF) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
|
uint32_t Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
|
||||||
|
|
||||||
// clamp the frequency entered to some valid value
|
// clamp the frequency entered to some valid value
|
||||||
if (Frequency < frequencyBandTable[0].lower)
|
if (Frequency < frequencyBandTable[0].lower) {
|
||||||
{
|
|
||||||
Frequency = frequencyBandTable[0].lower;
|
Frequency = frequencyBandTable[0].lower;
|
||||||
}
|
}
|
||||||
else
|
else if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) {
|
||||||
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
|
|
||||||
{
|
|
||||||
const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2;
|
const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2;
|
||||||
Frequency = (Frequency < center) ? BX4819_band1.upper : BX4819_band2.lower;
|
Frequency = (Frequency < center) ? BX4819_band1.upper : BX4819_band2.lower;
|
||||||
}
|
}
|
||||||
else
|
else if (Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper) {
|
||||||
if (Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper)
|
Frequency = frequencyBandTable[BAND_N_ELEM - 1].upper;
|
||||||
{
|
|
||||||
Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
|
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
if (gTxVfo->Band != band) {
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gTxVfo->Band != band)
|
|
||||||
{
|
|
||||||
gTxVfo->Band = band;
|
gTxVfo->Band = band;
|
||||||
gEeprom.ScreenChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
gEeprom.ScreenChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||||
gEeprom.FreqChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
gEeprom.FreqChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||||
@@ -432,18 +375,13 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
gRequestSaveChannel = 1;
|
gRequestSaveChannel = 1;
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
else
|
else
|
||||||
if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||||
{ // user is entering NOAA channel
|
{ // user is entering NOAA channel
|
||||||
|
if (gInputBoxIndex != 2) {
|
||||||
uint8_t Channel;
|
|
||||||
|
|
||||||
if (gInputBoxIndex != 2)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
@@ -453,9 +391,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
Channel = (gInputBox[0] * 10) + gInputBox[1];
|
uint8_t Channel = (gInputBox[0] * 10) + gInputBox[1];
|
||||||
if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable))
|
if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable)) {
|
||||||
{
|
|
||||||
Channel += NOAA_CHANNEL_FIRST;
|
Channel += NOAA_CHANNEL_FIRST;
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
@@ -482,9 +419,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
if (!bKeyHeld && bKeyPressed)
|
if (!bKeyHeld && bKeyPressed) { // exit key pressed
|
||||||
{ // exit key pressed
|
|
||||||
|
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
@@ -500,8 +435,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
|||||||
if (!gFmRadioMode)
|
if (!gFmRadioMode)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (gScanStateDir == SCAN_OFF)
|
if (gScanStateDir == SCAN_OFF) {
|
||||||
{
|
|
||||||
if (gInputBoxIndex == 0)
|
if (gInputBoxIndex == 0)
|
||||||
return;
|
return;
|
||||||
gInputBox[--gInputBoxIndex] = 10;
|
gInputBox[--gInputBoxIndex] = 10;
|
||||||
@@ -513,8 +447,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
|||||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
gScanKeepResult = false;
|
gScanKeepResult = false;
|
||||||
CHFRSCANNER_Stop();
|
CHFRSCANNER_Stop();
|
||||||
|
|
||||||
@@ -530,13 +463,10 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
|||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
ACTION_FM();
|
ACTION_FM();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bKeyHeld && bKeyPressed)
|
if (bKeyHeld && bKeyPressed) { // exit key held down
|
||||||
{ // exit key held down
|
|
||||||
|
|
||||||
if (gInputBoxIndex > 0 || gDTMF_InputBox_Index > 0 || gDTMF_InputMode)
|
if (gInputBoxIndex > 0 || gDTMF_InputBox_Index > 0 || gDTMF_InputMode)
|
||||||
{ // cancel key input mode (channel/frequency entry)
|
{ // cancel key input mode (channel/frequency entry)
|
||||||
gDTMF_InputMode = false;
|
gDTMF_InputMode = false;
|
||||||
@@ -551,22 +481,16 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
||||||
{
|
{
|
||||||
if (bKeyPressed && !bKeyHeld)
|
if (bKeyPressed && !bKeyHeld) // menu key pressed
|
||||||
// menu key pressed
|
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
|
|
||||||
if (bKeyHeld)
|
if (bKeyHeld) { // menu key held down (long press)
|
||||||
{ // menu key held down (long press)
|
if (bKeyPressed) { // long press MENU key
|
||||||
|
|
||||||
if (bKeyPressed)
|
|
||||||
{ // long press MENU key
|
|
||||||
|
|
||||||
gWasFKeyPressed = false;
|
gWasFKeyPressed = false;
|
||||||
|
|
||||||
if (gScreenToDisplay == DISPLAY_MAIN)
|
if (gScreenToDisplay == DISPLAY_MAIN) {
|
||||||
{
|
if (gInputBoxIndex > 0) { // delete any inputted chars
|
||||||
if (gInputBoxIndex > 0)
|
|
||||||
{ // delete any inputted chars
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
}
|
}
|
||||||
@@ -581,13 +505,11 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bKeyPressed && !gDTMF_InputMode)
|
if (!bKeyPressed && !gDTMF_InputMode) { // menu key released
|
||||||
{ // menu key released
|
const bool bFlag = !gInputBoxIndex;
|
||||||
const bool bFlag = (gInputBoxIndex == 0);
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
if (bFlag)
|
if (bFlag) {
|
||||||
{
|
|
||||||
if (gScanStateDir != SCAN_OFF) {
|
if (gScanStateDir != SCAN_OFF) {
|
||||||
CHFRSCANNER_Stop();
|
CHFRSCANNER_Stop();
|
||||||
return;
|
return;
|
||||||
@@ -599,8 +521,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
|||||||
gAnotherVoiceID = VOICE_ID_MENU;
|
gAnotherVoiceID = VOICE_ID_MENU;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -611,15 +532,13 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
|||||||
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gInputBoxIndex)
|
if (gInputBoxIndex) {
|
||||||
{
|
|
||||||
if (!bKeyHeld && bKeyPressed)
|
if (!bKeyHeld && bKeyPressed)
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bKeyHeld && !gWasFKeyPressed) // long press
|
if (bKeyHeld && !gWasFKeyPressed){ // long press
|
||||||
{
|
|
||||||
if (!bKeyPressed) // released
|
if (!bKeyPressed) // released
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -629,10 +548,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bKeyPressed) // just pressed
|
if (bKeyPressed) { // just pressed
|
||||||
{
|
|
||||||
// gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
|
||||||
gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,15 +556,17 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
if (!gWasFKeyPressed) // pressed without the F-key
|
if (!gWasFKeyPressed) // pressed without the F-key
|
||||||
{
|
{
|
||||||
|
if (gScanStateDir == SCAN_OFF
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (gScanStateDir == SCAN_OFF && !IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
&& !IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)
|
||||||
#else
|
|
||||||
if (gScanStateDir == SCAN_OFF)
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
&& gScanRangeStart == 0
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{ // start entering a DTMF string
|
{ // start entering a DTMF string
|
||||||
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
memmove(gDTMF_InputBox, gDTMF_String, MIN(sizeof(gDTMF_InputBox), sizeof(gDTMF_String) - 1));
|
memcpy(gDTMF_InputBox, gDTMF_String, MIN(sizeof(gDTMF_InputBox), sizeof(gDTMF_String) - 1));
|
||||||
gDTMF_InputBox_Index = 0;
|
gDTMF_InputBox_Index = 0;
|
||||||
gDTMF_InputMode = true;
|
gDTMF_InputMode = true;
|
||||||
|
|
||||||
@@ -656,6 +574,8 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // with the F-key
|
{ // with the F-key
|
||||||
@@ -667,7 +587,6 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// scan the CTCSS/DCS code
|
// scan the CTCSS/DCS code
|
||||||
gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
|
gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
|
||||||
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
|
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
|
||||||
@@ -676,7 +595,6 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gPttWasReleased = true;
|
gPttWasReleased = true;
|
||||||
|
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,58 +602,45 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
|||||||
{
|
{
|
||||||
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
|
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
|
||||||
|
|
||||||
if (bKeyHeld || !bKeyPressed)
|
if (bKeyHeld || !bKeyPressed) { // key held or released
|
||||||
{
|
|
||||||
if (gInputBoxIndex > 0)
|
if (gInputBoxIndex > 0)
|
||||||
return;
|
return; // leave if input box active
|
||||||
|
|
||||||
if (!bKeyPressed)
|
if (!bKeyPressed) {
|
||||||
{
|
if (!bKeyHeld || IS_FREQ_CHANNEL(Channel))
|
||||||
if (!bKeyHeld)
|
|
||||||
return;
|
return;
|
||||||
|
// if released long button press and not in freq mode
|
||||||
if (IS_FREQ_CHANNEL(Channel))
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
AUDIO_SetDigitVoice(0, gTxVfo->CHANNEL_SAVE + 1);
|
AUDIO_SetDigitVoice(0, gTxVfo->CHANNEL_SAVE + 1); // say channel number
|
||||||
gAnotherVoiceID = (VOICE_ID_t)0xFE;
|
gAnotherVoiceID = (VOICE_ID_t)0xFE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else { // short pressed
|
||||||
{
|
if (gInputBoxIndex > 0) {
|
||||||
if (gInputBoxIndex > 0)
|
|
||||||
{
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gScanStateDir == SCAN_OFF)
|
if (gScanStateDir == SCAN_OFF) {
|
||||||
{
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (!IS_NOAA_CHANNEL(Channel))
|
if (!IS_NOAA_CHANNEL(Channel))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint8_t Next;
|
uint8_t Next;
|
||||||
|
if (IS_FREQ_CHANNEL(Channel)) { // step/down in frequency
|
||||||
if (IS_FREQ_CHANNEL(Channel))
|
|
||||||
{ // step/down in frequency
|
|
||||||
const uint32_t frequency = APP_SetFrequencyByStep(gTxVfo, Direction);
|
const uint32_t frequency = APP_SetFrequencyByStep(gTxVfo, Direction);
|
||||||
|
|
||||||
if (RX_freq_check(frequency) < 0)
|
if (RX_freq_check(frequency) < 0) { // frequency not allowed
|
||||||
{ // frequency not allowed
|
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gTxVfo->freq_config_RX.Frequency = frequency;
|
gTxVfo->freq_config_RX.Frequency = frequency;
|
||||||
|
BK4819_SetFrequency(frequency);
|
||||||
|
BK4819_RX_TurnOn();
|
||||||
gRequestSaveChannel = 1;
|
gRequestSaveChannel = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -743,15 +648,12 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
|||||||
Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0);
|
Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0);
|
||||||
if (Next == 0xFF)
|
if (Next == 0xFF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Channel == Next)
|
if (Channel == Next)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gEeprom.MrChannel[gEeprom.TX_VFO] = Next;
|
gEeprom.MrChannel[gEeprom.TX_VFO] = Next;
|
||||||
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Next;
|
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Next;
|
||||||
|
|
||||||
if (!bKeyHeld)
|
if (!bKeyHeld) {
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
AUDIO_SetDigitVoice(0, Next + 1);
|
AUDIO_SetDigitVoice(0, Next + 1);
|
||||||
gAnotherVoiceID = (VOICE_ID_t)0xFE;
|
gAnotherVoiceID = (VOICE_ID_t)0xFE;
|
||||||
@@ -759,8 +661,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_VFO] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
|
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_VFO] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
|
||||||
gEeprom.NoaaChannel[gEeprom.TX_VFO] = Channel;
|
gEeprom.NoaaChannel[gEeprom.TX_VFO] = Channel;
|
||||||
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel;
|
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel;
|
||||||
@@ -783,16 +684,14 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
|||||||
void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT)
|
if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT) {
|
||||||
{
|
|
||||||
if (!bKeyHeld && bKeyPressed)
|
if (!bKeyHeld && bKeyPressed)
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gDTMF_InputMode && bKeyPressed && !bKeyHeld)
|
if (gDTMF_InputMode && bKeyPressed && !bKeyHeld) {
|
||||||
{
|
|
||||||
const char Character = DTMF_GetCharacter(Key);
|
const char Character = DTMF_GetCharacter(Key);
|
||||||
if (Character != 0xFF)
|
if (Character != 0xFF)
|
||||||
{ // add key to DTMF string
|
{ // add key to DTMF string
|
||||||
@@ -811,18 +710,8 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
// Key = KEY_SIDE2; // what's this doing ???
|
// Key = KEY_SIDE2; // what's this doing ???
|
||||||
// }
|
// }
|
||||||
|
|
||||||
switch (Key)
|
switch (Key) {
|
||||||
{
|
case KEY_0...KEY_9:
|
||||||
case KEY_0:
|
|
||||||
case KEY_1:
|
|
||||||
case KEY_2:
|
|
||||||
case KEY_3:
|
|
||||||
case KEY_4:
|
|
||||||
case KEY_5:
|
|
||||||
case KEY_6:
|
|
||||||
case KEY_7:
|
|
||||||
case KEY_8:
|
|
||||||
case KEY_9:
|
|
||||||
MAIN_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
|
MAIN_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
|
||||||
break;
|
break;
|
||||||
case KEY_MENU:
|
case KEY_MENU:
|
||||||
|
|||||||
193
app/menu.c
@@ -40,7 +40,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "ui/inputbox.h"
|
#include "ui/inputbox.h"
|
||||||
#include "ui/menu.h"
|
#include "ui/menu.h"
|
||||||
#include "ui/menu.h"
|
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
#ifndef ARRAY_SIZE
|
#ifndef ARRAY_SIZE
|
||||||
@@ -123,7 +122,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
|
|||||||
|
|
||||||
case MENU_STEP:
|
case MENU_STEP:
|
||||||
*pMin = 0;
|
*pMin = 0;
|
||||||
*pMax = ARRAY_SIZE(gStepFrequencyTable) - 1;
|
*pMax = STEP_N_ELEM - 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MENU_ABR:
|
case MENU_ABR:
|
||||||
@@ -198,7 +197,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
|
|||||||
case MENU_R_CTCS:
|
case MENU_R_CTCS:
|
||||||
case MENU_T_CTCS:
|
case MENU_T_CTCS:
|
||||||
*pMin = 0;
|
*pMin = 0;
|
||||||
*pMax = ARRAY_SIZE(CTCSS_Options) - 1;
|
*pMax = ARRAY_SIZE(CTCSS_Options);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MENU_W_N:
|
case MENU_W_N:
|
||||||
@@ -224,13 +223,6 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
|
|||||||
*pMax = ARRAY_SIZE(gSubMenu_RX_TX) - 1;
|
*pMax = ARRAY_SIZE(gSubMenu_RX_TX) - 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
case MENU_AM_FIX_TEST1:
|
|
||||||
*pMin = 0;
|
|
||||||
*pMax = ARRAY_SIZE(gSubMenu_AM_fix_test1) - 1;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
case MENU_AM_FIX:
|
case MENU_AM_FIX:
|
||||||
#endif
|
#endif
|
||||||
@@ -382,7 +374,6 @@ void MENU_AcceptSetting(void)
|
|||||||
{
|
{
|
||||||
int32_t Min;
|
int32_t Min;
|
||||||
int32_t Max;
|
int32_t Max;
|
||||||
uint8_t Code;
|
|
||||||
FREQ_Config_t *pConfig = &gTxVfo->freq_config_RX;
|
FREQ_Config_t *pConfig = &gTxVfo->freq_config_RX;
|
||||||
|
|
||||||
if (!MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max))
|
if (!MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max))
|
||||||
@@ -421,62 +412,45 @@ void MENU_AcceptSetting(void)
|
|||||||
|
|
||||||
// Fallthrough
|
// Fallthrough
|
||||||
|
|
||||||
case MENU_R_DCS:
|
case MENU_R_DCS: {
|
||||||
if (gSubMenuSelection == 0)
|
if (gSubMenuSelection == 0) {
|
||||||
{
|
if (pConfig->CodeType == CODE_TYPE_CONTINUOUS_TONE) {
|
||||||
if (pConfig->CodeType != CODE_TYPE_DIGITAL && pConfig->CodeType != CODE_TYPE_REVERSE_DIGITAL)
|
|
||||||
{
|
|
||||||
gRequestSaveChannel = 1;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Code = 0;
|
pConfig->Code = 0;
|
||||||
pConfig->CodeType = CODE_TYPE_OFF;
|
pConfig->CodeType = CODE_TYPE_OFF;
|
||||||
}
|
}
|
||||||
else
|
else if (gSubMenuSelection < 105) {
|
||||||
if (gSubMenuSelection < 105)
|
|
||||||
{
|
|
||||||
pConfig->CodeType = CODE_TYPE_DIGITAL;
|
pConfig->CodeType = CODE_TYPE_DIGITAL;
|
||||||
Code = gSubMenuSelection - 1;
|
pConfig->Code = gSubMenuSelection - 1;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
pConfig->CodeType = CODE_TYPE_REVERSE_DIGITAL;
|
pConfig->CodeType = CODE_TYPE_REVERSE_DIGITAL;
|
||||||
Code = gSubMenuSelection - 105;
|
pConfig->Code = gSubMenuSelection - 105;
|
||||||
}
|
}
|
||||||
|
|
||||||
pConfig->Code = Code;
|
|
||||||
gRequestSaveChannel = 1;
|
gRequestSaveChannel = 1;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case MENU_T_CTCS:
|
case MENU_T_CTCS:
|
||||||
pConfig = &gTxVfo->freq_config_TX;
|
pConfig = &gTxVfo->freq_config_TX;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case MENU_R_CTCS:
|
case MENU_R_CTCS: {
|
||||||
if (gSubMenuSelection == 0)
|
if (gSubMenuSelection == 0) {
|
||||||
{
|
if (pConfig->CodeType != CODE_TYPE_CONTINUOUS_TONE) {
|
||||||
if (pConfig->CodeType != CODE_TYPE_CONTINUOUS_TONE)
|
|
||||||
{
|
|
||||||
gRequestSaveChannel = 1;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Code = 0;
|
pConfig->Code = 0;
|
||||||
pConfig->Code = Code;
|
|
||||||
pConfig->CodeType = CODE_TYPE_OFF;
|
pConfig->CodeType = CODE_TYPE_OFF;
|
||||||
|
|
||||||
BK4819_ExitSubAu();
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
pConfig->Code = gSubMenuSelection - 1;
|
||||||
pConfig->CodeType = CODE_TYPE_CONTINUOUS_TONE;
|
pConfig->CodeType = CODE_TYPE_CONTINUOUS_TONE;
|
||||||
Code = gSubMenuSelection - 1;
|
|
||||||
pConfig->Code = Code;
|
|
||||||
|
|
||||||
BK4819_SetCTCSSFrequency(CTCSS_Options[Code]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gRequestSaveChannel = 1;
|
gRequestSaveChannel = 1;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case MENU_SFT_D:
|
case MENU_SFT_D:
|
||||||
gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION = gSubMenuSelection;
|
gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION = gSubMenuSelection;
|
||||||
gRequestSaveChannel = 1;
|
gRequestSaveChannel = 1;
|
||||||
@@ -521,20 +495,13 @@ void MENU_AcceptSetting(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case MENU_MEM_NAME:
|
case MENU_MEM_NAME:
|
||||||
{ // trailing trim
|
for (int i = 9; i >= 0; i--) {
|
||||||
for (int i = 9; i >= 0; i--)
|
|
||||||
{
|
|
||||||
if (edit[i] != ' ' && edit[i] != '_' && edit[i] != 0x00 && edit[i] != 0xff)
|
if (edit[i] != ' ' && edit[i] != '_' && edit[i] != 0x00 && edit[i] != 0xff)
|
||||||
break;
|
break;
|
||||||
edit[i] = ' ';
|
edit[i] = ' ';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// save the channel name
|
SETTINGS_SaveChannelName(gSubMenuSelection, edit);
|
||||||
memset(gTxVfo->Name, 0, sizeof(gTxVfo->Name));
|
|
||||||
memmove(gTxVfo->Name, edit, 10);
|
|
||||||
SETTINGS_SaveChannel(gSubMenuSelection, gEeprom.TX_VFO, gTxVfo, 3);
|
|
||||||
gFlagReconfigureVfos = true;
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MENU_SAVE:
|
case MENU_SAVE:
|
||||||
@@ -546,7 +513,7 @@ void MENU_AcceptSetting(void)
|
|||||||
gEeprom.VOX_SWITCH = gSubMenuSelection != 0;
|
gEeprom.VOX_SWITCH = gSubMenuSelection != 0;
|
||||||
if (gEeprom.VOX_SWITCH)
|
if (gEeprom.VOX_SWITCH)
|
||||||
gEeprom.VOX_LEVEL = gSubMenuSelection - 1;
|
gEeprom.VOX_LEVEL = gSubMenuSelection - 1;
|
||||||
BOARD_EEPROM_LoadCalibration();
|
SETTINGS_LoadCalibration();
|
||||||
gFlagReconfigureVfos = true;
|
gFlagReconfigureVfos = true;
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
break;
|
break;
|
||||||
@@ -630,7 +597,7 @@ void MENU_AcceptSetting(void)
|
|||||||
|
|
||||||
case MENU_MIC:
|
case MENU_MIC:
|
||||||
gEeprom.MIC_SENSITIVITY = gSubMenuSelection;
|
gEeprom.MIC_SENSITIVITY = gSubMenuSelection;
|
||||||
BOARD_EEPROM_LoadCalibration();
|
SETTINGS_LoadCalibration();
|
||||||
gFlagReconfigureVfos = true;
|
gFlagReconfigureVfos = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -714,7 +681,7 @@ void MENU_AcceptSetting(void)
|
|||||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||||
gDTMF_InputMode = true;
|
gDTMF_InputMode = true;
|
||||||
gDTMF_InputBox_Index = 3;
|
gDTMF_InputBox_Index = 3;
|
||||||
memmove(gDTMF_InputBox, gDTMF_ID, 4);
|
memcpy(gDTMF_InputBox, gDTMF_ID, 4);
|
||||||
gRequestDisplayScreen = DISPLAY_INVALID;
|
gRequestDisplayScreen = DISPLAY_INVALID;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -740,14 +707,6 @@ void MENU_AcceptSetting(void)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
case MENU_AM_FIX_TEST1:
|
|
||||||
gSetting_AM_fix_test1 = gSubMenuSelection;
|
|
||||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
|
||||||
gFlagResetVfos = true;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
case MENU_NOAA_S:
|
case MENU_NOAA_S:
|
||||||
gEeprom.NOAA_AUTO_SCAN = gSubMenuSelection;
|
gEeprom.NOAA_AUTO_SCAN = gSubMenuSelection;
|
||||||
@@ -762,7 +721,7 @@ void MENU_AcceptSetting(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case MENU_RESET:
|
case MENU_RESET:
|
||||||
BOARD_FactoryReset(gSubMenuSelection);
|
SETTINGS_FactoryReset(gSubMenuSelection);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MENU_350TX:
|
case MENU_350TX:
|
||||||
@@ -1124,13 +1083,6 @@ void MENU_ShowCurrentSetting(void)
|
|||||||
gSubMenuSelection = gSetting_AM_fix;
|
gSubMenuSelection = gSetting_AM_fix;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
case MENU_AM_FIX_TEST1:
|
|
||||||
gSubMenuSelection = gSetting_AM_fix_test1;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
case MENU_NOAA_S:
|
case MENU_NOAA_S:
|
||||||
gSubMenuSelection = gEeprom.NOAA_AUTO_SCAN;
|
gSubMenuSelection = gEeprom.NOAA_AUTO_SCAN;
|
||||||
@@ -1187,8 +1139,7 @@ void MENU_ShowCurrentSetting(void)
|
|||||||
case MENU_F1LONG:
|
case MENU_F1LONG:
|
||||||
case MENU_F2SHRT:
|
case MENU_F2SHRT:
|
||||||
case MENU_F2LONG:
|
case MENU_F2LONG:
|
||||||
case MENU_MLONG:
|
case MENU_MLONG: {
|
||||||
{
|
|
||||||
uint8_t * fun[]= {
|
uint8_t * fun[]= {
|
||||||
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
|
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
|
||||||
&gEeprom.KEY_1_LONG_PRESS_ACTION,
|
&gEeprom.KEY_1_LONG_PRESS_ACTION,
|
||||||
@@ -1250,17 +1201,14 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_MENU;
|
gRequestDisplayScreen = DISPLAY_MENU;
|
||||||
|
|
||||||
if (!gIsInSubMenu)
|
if (!gIsInSubMenu) {
|
||||||
{
|
switch (gInputBoxIndex) {
|
||||||
switch (gInputBoxIndex)
|
|
||||||
{
|
|
||||||
case 2:
|
case 2:
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
Value = (gInputBox[0] * 10) + gInputBox[1];
|
Value = (gInputBox[0] * 10) + gInputBox[1];
|
||||||
|
|
||||||
if (Value > 0 && Value <= gMenuListCount)
|
if (Value > 0 && Value <= gMenuListCount) {
|
||||||
{
|
|
||||||
gMenuCursor = Value - 1;
|
gMenuCursor = Value - 1;
|
||||||
gFlagRefreshSetting = true;
|
gFlagRefreshSetting = true;
|
||||||
return;
|
return;
|
||||||
@@ -1274,8 +1222,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case 1:
|
case 1:
|
||||||
Value = gInputBox[0];
|
Value = gInputBox[0];
|
||||||
if (Value > 0 && Value <= gMenuListCount)
|
if (Value > 0 && Value <= gMenuListCount) {
|
||||||
{
|
|
||||||
gMenuCursor = Value - 1;
|
gMenuCursor = Value - 1;
|
||||||
gFlagRefreshSetting = true;
|
gFlagRefreshSetting = true;
|
||||||
return;
|
return;
|
||||||
@@ -1289,12 +1236,10 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET)
|
if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET) {
|
||||||
{
|
|
||||||
uint32_t Frequency;
|
uint32_t Frequency;
|
||||||
|
|
||||||
if (gInputBoxIndex < 6)
|
if (gInputBoxIndex < 6) { // invalid frequency
|
||||||
{ // invalid frequency
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
@@ -1318,8 +1263,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
|
UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
|
||||||
{ // enter 3-digit channel number
|
{ // enter 3-digit channel number
|
||||||
|
|
||||||
if (gInputBoxIndex < 3)
|
if (gInputBoxIndex < 3) {
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
@@ -1331,8 +1275,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(Value))
|
if (IS_MR_CHANNEL(Value)) {
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
@@ -1344,8 +1287,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max))
|
if (MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max)) {
|
||||||
{
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
@@ -1353,8 +1295,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1;
|
Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1;
|
||||||
|
|
||||||
switch (gInputBoxIndex)
|
switch (gInputBoxIndex) {
|
||||||
{
|
|
||||||
case 1:
|
case 1:
|
||||||
Value = gInputBox[0];
|
Value = gInputBox[0];
|
||||||
break;
|
break;
|
||||||
@@ -1369,8 +1310,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
if (Offset == gInputBoxIndex)
|
if (Offset == gInputBoxIndex)
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
if (Value <= Max)
|
if (Value <= Max) {
|
||||||
{
|
|
||||||
gSubMenuSelection = Value;
|
gSubMenuSelection = Value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1387,6 +1327,10 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
if (!gCssBackgroundScan)
|
if (!gCssBackgroundScan)
|
||||||
{
|
{
|
||||||
|
/* Backlight related menus set full brightness. Set it back to the configured value,
|
||||||
|
just in case we are exiting from one of them. */
|
||||||
|
BACKLIGHT_TurnOn();
|
||||||
|
|
||||||
if (gIsInSubMenu)
|
if (gIsInSubMenu)
|
||||||
{
|
{
|
||||||
if (gInputBoxIndex == 0 || UI_MENU_GetCurrentMenuId() != MENU_OFFSET)
|
if (gInputBoxIndex == 0 || UI_MENU_GetCurrentMenuId() != MENU_OFFSET)
|
||||||
@@ -1448,7 +1392,13 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
|||||||
if (UI_MENU_GetCurrentMenuId() != MENU_SCR)
|
if (UI_MENU_GetCurrentMenuId() != MENU_SCR)
|
||||||
gAnotherVoiceID = MenuList[gMenuCursor].voice_id;
|
gAnotherVoiceID = MenuList[gMenuCursor].voice_id;
|
||||||
#endif
|
#endif
|
||||||
|
if (UI_MENU_GetCurrentMenuId() == MENU_UPCODE
|
||||||
|
|| UI_MENU_GetCurrentMenuId() == MENU_DWCODE
|
||||||
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|
|| UI_MENU_GetCurrentMenuId() == MENU_ANI_ID
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
return;
|
||||||
#if 1
|
#if 1
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
|
if (UI_MENU_GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
|
||||||
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
|
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
|
||||||
@@ -1474,7 +1424,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
|||||||
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
|
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BOARD_fetchChannelName(edit, gSubMenuSelection);
|
SETTINGS_FetchChannelName(edit, gSubMenuSelection);
|
||||||
|
|
||||||
// pad the channel name out with '_'
|
// pad the channel name out with '_'
|
||||||
edit_index = strlen(edit);
|
edit_index = strlen(edit);
|
||||||
@@ -1484,7 +1434,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
|||||||
edit_index = 0; // 'edit_index' is going to be used as the cursor position
|
edit_index = 0; // 'edit_index' is going to be used as the cursor position
|
||||||
|
|
||||||
// make a copy so we can test for change when exiting the menu item
|
// make a copy so we can test for change when exiting the menu item
|
||||||
memmove(edit_original, edit, sizeof(edit_original));
|
memcpy(edit_original, edit, sizeof(edit_original));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1496,16 +1446,11 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
|||||||
return; // next char
|
return; // next char
|
||||||
|
|
||||||
// exit
|
// exit
|
||||||
if (memcmp(edit_original, edit, sizeof(edit_original)) == 0)
|
|
||||||
{ // no change - drop it
|
|
||||||
gFlagAcceptSetting = false;
|
gFlagAcceptSetting = false;
|
||||||
|
gAskForConfirmation = 0;
|
||||||
|
if (memcmp(edit_original, edit, sizeof(edit_original)) == 0) {
|
||||||
|
// no change - drop it
|
||||||
gIsInSubMenu = false;
|
gIsInSubMenu = false;
|
||||||
gAskForConfirmation = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gFlagAcceptSetting = false;
|
|
||||||
gAskForConfirmation = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1656,23 +1601,23 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
|||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else if (!bKeyPressed)
|
||||||
if (!bKeyPressed)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (SCANNER_IsScanning()) {
|
if (SCANNER_IsScanning())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!gIsInSubMenu)
|
if (!gIsInSubMenu) {
|
||||||
{
|
|
||||||
gMenuCursor = NUMBER_AddWithWraparound(gMenuCursor, -Direction, 0, gMenuListCount - 1);
|
gMenuCursor = NUMBER_AddWithWraparound(gMenuCursor, -Direction, 0, gMenuListCount - 1);
|
||||||
|
|
||||||
gFlagRefreshSetting = true;
|
gFlagRefreshSetting = true;
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_MENU;
|
gRequestDisplayScreen = DISPLAY_MENU;
|
||||||
|
|
||||||
if (UI_MENU_GetCurrentMenuId() != MENU_ABR && gEeprom.BACKLIGHT_TIME == 0) // backlight always off and not in the backlight menu
|
if (UI_MENU_GetCurrentMenuId() != MENU_ABR
|
||||||
|
&& UI_MENU_GetCurrentMenuId() != MENU_ABR_MIN
|
||||||
|
&& UI_MENU_GetCurrentMenuId() != MENU_ABR_MAX
|
||||||
|
&& gEeprom.BACKLIGHT_TIME == 0) // backlight always off and not in the backlight menu
|
||||||
{
|
{
|
||||||
BACKLIGHT_TurnOff();
|
BACKLIGHT_TurnOff();
|
||||||
}
|
}
|
||||||
@@ -1680,11 +1625,9 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET)
|
if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET) {
|
||||||
{
|
|
||||||
int32_t Offset = (Direction * gTxVfo->StepFrequency) + gSubMenuSelection;
|
int32_t Offset = (Direction * gTxVfo->StepFrequency) + gSubMenuSelection;
|
||||||
if (Offset < 99999990)
|
if (Offset < 99999990) {
|
||||||
{
|
|
||||||
if (Offset < 0)
|
if (Offset < 0)
|
||||||
Offset = 99999990;
|
Offset = 99999990;
|
||||||
}
|
}
|
||||||
@@ -1728,18 +1671,8 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
|||||||
|
|
||||||
void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
switch (Key)
|
switch (Key) {
|
||||||
{
|
case KEY_0...KEY_9:
|
||||||
case KEY_0:
|
|
||||||
case KEY_1:
|
|
||||||
case KEY_2:
|
|
||||||
case KEY_3:
|
|
||||||
case KEY_4:
|
|
||||||
case KEY_5:
|
|
||||||
case KEY_6:
|
|
||||||
case KEY_7:
|
|
||||||
case KEY_8:
|
|
||||||
case KEY_9:
|
|
||||||
MENU_Key_0_to_9(Key, bKeyPressed, bKeyHeld);
|
MENU_Key_0_to_9(Key, bKeyPressed, bKeyHeld);
|
||||||
break;
|
break;
|
||||||
case KEY_MENU:
|
case KEY_MENU:
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ void SCANNER_TimeSlice500ms(void)
|
|||||||
{
|
{
|
||||||
if (SCANNER_IsScanning() && gScannerSaveState == SCAN_SAVE_NO_PROMPT && gScanCssState < SCAN_CSS_STATE_FOUND) {
|
if (SCANNER_IsScanning() && gScannerSaveState == SCAN_SAVE_NO_PROMPT && gScanCssState < SCAN_CSS_STATE_FOUND) {
|
||||||
gScanProgressIndicator++;
|
gScanProgressIndicator++;
|
||||||
#ifdef ENABLE_NO_CODE_SCAN_TIMEOUT
|
#ifndef ENABLE_NO_CODE_SCAN_TIMEOUT
|
||||||
if (gScanProgressIndicator > 32) {
|
if (gScanProgressIndicator > 32) {
|
||||||
if (gScanCssState == SCAN_CSS_STATE_SCANNING && !gScanSingleFrequency)
|
if (gScanCssState == SCAN_CSS_STATE_SCANNING && !gScanSingleFrequency)
|
||||||
gScanCssState = SCAN_CSS_STATE_FOUND;
|
gScanCssState = SCAN_CSS_STATE_FOUND;
|
||||||
|
|||||||
305
app/spectrum.c
@@ -13,11 +13,19 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "app/spectrum.h"
|
#include "app/spectrum.h"
|
||||||
#include "driver/backlight.h"
|
#include "am_fix.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
#include "chFrScanner.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "driver/backlight.h"
|
||||||
|
#include "frequencies.h"
|
||||||
#include "ui/helper.h"
|
#include "ui/helper.h"
|
||||||
|
#include "ui/main.h"
|
||||||
|
|
||||||
struct FrequencyBandInfo {
|
struct FrequencyBandInfo {
|
||||||
uint32_t lower;
|
uint32_t lower;
|
||||||
@@ -26,11 +34,10 @@ struct FrequencyBandInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define F_MIN frequencyBandTable[0].lower
|
#define F_MIN frequencyBandTable[0].lower
|
||||||
#define F_MAX frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper
|
#define F_MAX frequencyBandTable[BAND_N_ELEM - 1].upper
|
||||||
|
|
||||||
const uint16_t RSSI_MAX_VALUE = 65535;
|
const uint16_t RSSI_MAX_VALUE = 65535;
|
||||||
|
|
||||||
static uint16_t R30, R37, R3D, R43, R47, R48, R7E;
|
|
||||||
static uint32_t initialFreq;
|
static uint32_t initialFreq;
|
||||||
static char String[32];
|
static char String[32];
|
||||||
|
|
||||||
@@ -42,6 +49,7 @@ bool redrawScreen = false;
|
|||||||
bool newScanStart = true;
|
bool newScanStart = true;
|
||||||
bool preventKeypress = true;
|
bool preventKeypress = true;
|
||||||
bool audioState = true;
|
bool audioState = true;
|
||||||
|
bool lockAGC = false;
|
||||||
|
|
||||||
State currentState = SPECTRUM, previousState = SPECTRUM;
|
State currentState = SPECTRUM, previousState = SPECTRUM;
|
||||||
|
|
||||||
@@ -49,26 +57,31 @@ PeakInfo peak;
|
|||||||
ScanInfo scanInfo;
|
ScanInfo scanInfo;
|
||||||
KeyboardState kbd = {KEY_INVALID, KEY_INVALID, 0};
|
KeyboardState kbd = {KEY_INVALID, KEY_INVALID, 0};
|
||||||
|
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
static uint16_t blacklistFreqs[15];
|
||||||
|
static uint8_t blacklistFreqsIdx;
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *bwOptions[] = {" 25k", "12.5k", "6.25k"};
|
const char *bwOptions[] = {" 25k", "12.5k", "6.25k"};
|
||||||
const uint8_t modulationTypeTuneSteps[] = {100, 50, 10};
|
const uint8_t modulationTypeTuneSteps[] = {100, 50, 10};
|
||||||
const uint8_t modTypeReg47Values[] = {1, 7, 5};
|
const uint8_t modTypeReg47Values[] = {1, 7, 5};
|
||||||
|
|
||||||
SpectrumSettings settings = {stepsCount: STEPS_64,
|
SpectrumSettings settings = {.stepsCount = STEPS_64,
|
||||||
scanStepIndex: S_STEP_25_0kHz,
|
.scanStepIndex = S_STEP_25_0kHz,
|
||||||
frequencyChangeStep: 80000,
|
.frequencyChangeStep = 80000,
|
||||||
scanDelay: 3200,
|
.scanDelay = 3200,
|
||||||
rssiTriggerLevel: 150,
|
.rssiTriggerLevel = 150,
|
||||||
backlightState: true,
|
.backlightState = true,
|
||||||
bw: BK4819_FILTER_BW_WIDE,
|
.bw = BK4819_FILTER_BW_WIDE,
|
||||||
listenBw: BK4819_FILTER_BW_WIDE,
|
.listenBw = BK4819_FILTER_BW_WIDE,
|
||||||
modulationType: false,
|
.modulationType = false,
|
||||||
dbMin: -130,
|
.dbMin = -130,
|
||||||
dbMax: -50};
|
.dbMax = -50};
|
||||||
|
|
||||||
uint32_t fMeasure = 0;
|
uint32_t fMeasure = 0;
|
||||||
uint32_t currentFreq, tempFreq;
|
uint32_t currentFreq, tempFreq;
|
||||||
uint16_t rssiHistory[128];
|
uint16_t rssiHistory[128];
|
||||||
|
int vfo;
|
||||||
uint8_t freqInputIndex = 0;
|
uint8_t freqInputIndex = 0;
|
||||||
uint8_t freqInputDotIndex = 0;
|
uint8_t freqInputDotIndex = 0;
|
||||||
KEY_Code_t freqInputArr[10];
|
KEY_Code_t freqInputArr[10];
|
||||||
@@ -99,17 +112,28 @@ static uint8_t DBm2S(int dbm) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Rssi2DBm(uint16_t rssi) { return (rssi >> 1) - 160; }
|
static int Rssi2DBm(uint16_t rssi) {
|
||||||
|
return (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band];
|
||||||
|
}
|
||||||
|
|
||||||
static uint16_t GetRegMenuValue(uint8_t st) {
|
static uint16_t GetRegMenuValue(uint8_t st) {
|
||||||
RegisterSpec s = registerSpecs[st];
|
RegisterSpec s = registerSpecs[st];
|
||||||
return (BK4819_ReadRegister(s.num) >> s.offset) & s.mask;
|
return (BK4819_ReadRegister(s.num) >> s.offset) & s.mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LockAGC()
|
||||||
|
{
|
||||||
|
RADIO_SetupAGC(settings.modulationType==MODULATION_AM, lockAGC);
|
||||||
|
lockAGC = true;
|
||||||
|
}
|
||||||
|
|
||||||
static void SetRegMenuValue(uint8_t st, bool add) {
|
static void SetRegMenuValue(uint8_t st, bool add) {
|
||||||
uint16_t v = GetRegMenuValue(st);
|
uint16_t v = GetRegMenuValue(st);
|
||||||
RegisterSpec s = registerSpecs[st];
|
RegisterSpec s = registerSpecs[st];
|
||||||
|
|
||||||
|
if(s.num == BK4819_REG_13)
|
||||||
|
LockAGC();
|
||||||
|
|
||||||
uint16_t reg = BK4819_ReadRegister(s.num);
|
uint16_t reg = BK4819_ReadRegister(s.num);
|
||||||
if (add && v <= s.mask - s.inc) {
|
if (add && v <= s.mask - s.inc) {
|
||||||
v += s.inc;
|
v += s.inc;
|
||||||
@@ -197,24 +221,29 @@ static void ToggleAFBit(bool on) {
|
|||||||
BK4819_WriteRegister(BK4819_REG_47, reg);
|
BK4819_WriteRegister(BK4819_REG_47, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const BK4819_REGISTER_t registers_to_save[] ={
|
||||||
|
BK4819_REG_30,
|
||||||
|
BK4819_REG_37,
|
||||||
|
BK4819_REG_3D,
|
||||||
|
BK4819_REG_43,
|
||||||
|
BK4819_REG_47,
|
||||||
|
BK4819_REG_48,
|
||||||
|
BK4819_REG_7E,
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint16_t registers_stack [sizeof(registers_to_save)];
|
||||||
|
|
||||||
static void BackupRegisters() {
|
static void BackupRegisters() {
|
||||||
R30 = BK4819_ReadRegister(BK4819_REG_30);
|
for (uint32_t i = 0; i < ARRAY_SIZE(registers_to_save); i++){
|
||||||
R37 = BK4819_ReadRegister(BK4819_REG_37);
|
registers_stack[i] = BK4819_ReadRegister(registers_to_save[i]);
|
||||||
R3D = BK4819_ReadRegister(BK4819_REG_3D);
|
}
|
||||||
R43 = BK4819_ReadRegister(BK4819_REG_43);
|
|
||||||
R47 = BK4819_ReadRegister(BK4819_REG_47);
|
|
||||||
R48 = BK4819_ReadRegister(BK4819_REG_48);
|
|
||||||
R7E = BK4819_ReadRegister(BK4819_REG_7E);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RestoreRegisters() {
|
static void RestoreRegisters() {
|
||||||
BK4819_WriteRegister(BK4819_REG_30, R30);
|
|
||||||
BK4819_WriteRegister(BK4819_REG_37, R37);
|
for (uint32_t i = 0; i < ARRAY_SIZE(registers_to_save); i++){
|
||||||
BK4819_WriteRegister(BK4819_REG_3D, R3D);
|
BK4819_WriteRegister(registers_to_save[i], registers_stack[i]);
|
||||||
BK4819_WriteRegister(BK4819_REG_43, R43);
|
}
|
||||||
BK4819_WriteRegister(BK4819_REG_47, R47);
|
|
||||||
BK4819_WriteRegister(BK4819_REG_48, R48);
|
|
||||||
BK4819_WriteRegister(BK4819_REG_7E, R7E);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ToggleAFDAC(bool on) {
|
static void ToggleAFDAC(bool on) {
|
||||||
@@ -245,12 +274,24 @@ static void ResetPeak() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IsCenterMode() { return settings.scanStepIndex < S_STEP_2_5kHz; }
|
bool IsCenterMode() { return settings.scanStepIndex < S_STEP_2_5kHz; }
|
||||||
uint8_t GetStepsCount() { return 128 >> settings.stepsCount; }
|
// scan step in 0.01khz
|
||||||
uint16_t GetScanStep() { return scanStepValues[settings.scanStepIndex]; }
|
uint16_t GetScanStep() { return scanStepValues[settings.scanStepIndex]; }
|
||||||
|
|
||||||
|
uint16_t GetStepsCount()
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(gScanRangeStart) {
|
||||||
|
return (gScanRangeStop - gScanRangeStart) / GetScanStep();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 128 >> settings.stepsCount;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t GetBW() { return GetStepsCount() * GetScanStep(); }
|
uint32_t GetBW() { return GetStepsCount() * GetScanStep(); }
|
||||||
uint32_t GetFStart() {
|
uint32_t GetFStart() {
|
||||||
return IsCenterMode() ? currentFreq - (GetBW() >> 1) : currentFreq;
|
return IsCenterMode() ? currentFreq - (GetBW() >> 1) : currentFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GetFEnd() { return currentFreq + GetBW(); }
|
uint32_t GetFEnd() { return currentFreq + GetBW(); }
|
||||||
|
|
||||||
static void TuneToPeak() {
|
static void TuneToPeak() {
|
||||||
@@ -276,7 +317,12 @@ uint16_t GetRssi() {
|
|||||||
while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255) {
|
while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255) {
|
||||||
SYSTICK_DelayUs(100);
|
SYSTICK_DelayUs(100);
|
||||||
}
|
}
|
||||||
return BK4819_GetRSSI();
|
uint16_t rssi = BK4819_GetRSSI();
|
||||||
|
#ifdef ENABLE_AM_FIX
|
||||||
|
if(settings.modulationType==MODULATION_AM && gSetting_AM_fix)
|
||||||
|
rssi += AM_fix_get_gain_diff()*2;
|
||||||
|
#endif
|
||||||
|
return rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ToggleAudio(bool on) {
|
static void ToggleAudio(bool on) {
|
||||||
@@ -294,6 +340,7 @@ static void ToggleAudio(bool on) {
|
|||||||
static void ToggleRX(bool on) {
|
static void ToggleRX(bool on) {
|
||||||
isListening = on;
|
isListening = on;
|
||||||
|
|
||||||
|
RADIO_SetupAGC(on, lockAGC);
|
||||||
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, on);
|
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, on);
|
||||||
|
|
||||||
ToggleAudio(on);
|
ToggleAudio(on);
|
||||||
@@ -331,6 +378,10 @@ static void ResetBlacklist() {
|
|||||||
if (rssiHistory[i] == RSSI_MAX_VALUE)
|
if (rssiHistory[i] == RSSI_MAX_VALUE)
|
||||||
rssiHistory[i] = 0;
|
rssiHistory[i] = 0;
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
memset(blacklistFreqs, 0, sizeof(blacklistFreqs));
|
||||||
|
blacklistFreqsIdx = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RelaunchScan() {
|
static void RelaunchScan() {
|
||||||
@@ -377,18 +428,36 @@ static void UpdatePeakInfo() {
|
|||||||
UpdatePeakInfoForce();
|
UpdatePeakInfoForce();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Measure() { rssiHistory[scanInfo.i] = scanInfo.rssi = GetRssi(); }
|
static void SetRssiHistory(uint16_t idx, uint16_t rssi)
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(scanInfo.measurementsCount > 128) {
|
||||||
|
uint8_t i = (uint32_t)ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * idx / 1000;
|
||||||
|
if(rssiHistory[i] < rssi || isListening)
|
||||||
|
rssiHistory[i] = rssi;
|
||||||
|
rssiHistory[(i+1)%128] = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
rssiHistory[idx] = rssi;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Measure()
|
||||||
|
{
|
||||||
|
uint16_t rssi = scanInfo.rssi = GetRssi();
|
||||||
|
SetRssiHistory(scanInfo.i, rssi);
|
||||||
|
}
|
||||||
|
|
||||||
// Update things by keypress
|
// Update things by keypress
|
||||||
|
|
||||||
static uint16_t dbm2rssi(int dBm)
|
static uint16_t dbm2rssi(int dBm) {
|
||||||
{
|
return (dBm + 160 - dBmCorrTable[gRxVfo->Band]) * 2;
|
||||||
return (dBm + 160)*2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClampRssiTriggerLevel()
|
static void ClampRssiTriggerLevel() {
|
||||||
{
|
settings.rssiTriggerLevel =
|
||||||
settings.rssiTriggerLevel = clamp(settings.rssiTriggerLevel, dbm2rssi(settings.dbMin), dbm2rssi(settings.dbMax));
|
clamp(settings.rssiTriggerLevel, dbm2rssi(settings.dbMin),
|
||||||
|
dbm2rssi(settings.dbMax));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateRssiTriggerLevel(bool inc) {
|
static void UpdateRssiTriggerLevel(bool inc) {
|
||||||
@@ -406,7 +475,7 @@ static void UpdateRssiTriggerLevel(bool inc) {
|
|||||||
static void UpdateDBMax(bool inc) {
|
static void UpdateDBMax(bool inc) {
|
||||||
if (inc && settings.dbMax < 10) {
|
if (inc && settings.dbMax < 10) {
|
||||||
settings.dbMax += 1;
|
settings.dbMax += 1;
|
||||||
} else if (!inc && settings.dbMax > settings.dbMin) {
|
} else if (!inc && settings.dbMax > 12+settings.dbMin) {
|
||||||
settings.dbMax -= 1;
|
settings.dbMax -= 1;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@@ -419,13 +488,12 @@ static void UpdateDBMax(bool inc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateScanStep(bool inc) {
|
static void UpdateScanStep(bool inc) {
|
||||||
if (inc && settings.scanStepIndex < S_STEP_100_0kHz) {
|
if (inc) {
|
||||||
settings.scanStepIndex++;
|
settings.scanStepIndex = settings.scanStepIndex != S_STEP_100_0kHz ? settings.scanStepIndex + 1 : 0;
|
||||||
} else if (!inc && settings.scanStepIndex > 0) {
|
|
||||||
settings.scanStepIndex--;
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
settings.scanStepIndex = settings.scanStepIndex != 0 ? settings.scanStepIndex - 1 : S_STEP_100_0kHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.frequencyChangeStep = GetBW() >> 1;
|
settings.frequencyChangeStep = GetBW() >> 1;
|
||||||
RelaunchScan();
|
RelaunchScan();
|
||||||
ResetBlacklist();
|
ResetBlacklist();
|
||||||
@@ -475,6 +543,8 @@ static void ToggleModulation() {
|
|||||||
settings.modulationType = MODULATION_FM;
|
settings.modulationType = MODULATION_FM;
|
||||||
}
|
}
|
||||||
RADIO_SetModulation(settings.modulationType);
|
RADIO_SetModulation(settings.modulationType);
|
||||||
|
|
||||||
|
RelaunchScan();
|
||||||
redrawScreen = true;
|
redrawScreen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,12 +642,26 @@ static void UpdateFreqInput(KEY_Code_t key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Blacklist() {
|
static void Blacklist() {
|
||||||
rssiHistory[peak.i] = RSSI_MAX_VALUE;
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
blacklistFreqs[blacklistFreqsIdx++ % ARRAY_SIZE(blacklistFreqs)] = peak.i;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SetRssiHistory(peak.i, RSSI_MAX_VALUE);
|
||||||
ResetPeak();
|
ResetPeak();
|
||||||
ToggleRX(false);
|
ToggleRX(false);
|
||||||
newScanStart = true;
|
ResetScanStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
static bool IsBlacklisted(uint16_t idx)
|
||||||
|
{
|
||||||
|
for(uint8_t i = 0; i < ARRAY_SIZE(blacklistFreqs); i++)
|
||||||
|
if(blacklistFreqs[i] == idx)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Draw things
|
// Draw things
|
||||||
|
|
||||||
// applied x2 to prevent initial rounding
|
// applied x2 to prevent initial rounding
|
||||||
@@ -588,7 +672,7 @@ uint8_t Rssi2PX(uint16_t rssi, uint8_t pxMin, uint8_t pxMax) {
|
|||||||
|
|
||||||
const uint8_t PX_RANGE = pxMax - pxMin;
|
const uint8_t PX_RANGE = pxMax - pxMin;
|
||||||
|
|
||||||
int dbm = clamp(rssi - (160 << 1), DB_MIN, DB_MAX);
|
int dbm = clamp(Rssi2DBm(rssi) << 1, DB_MIN, DB_MAX);
|
||||||
|
|
||||||
return ((dbm - DB_MIN) * PX_RANGE + DB_RANGE / 2) / DB_RANGE + pxMin;
|
return ((dbm - DB_MIN) * PX_RANGE + DB_RANGE / 2) / DB_RANGE + pxMin;
|
||||||
}
|
}
|
||||||
@@ -615,10 +699,11 @@ static void DrawStatus() {
|
|||||||
#endif
|
#endif
|
||||||
GUI_DisplaySmallest(String, 0, 1, true, true);
|
GUI_DisplaySmallest(String, 0, 1, true, true);
|
||||||
|
|
||||||
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryCheckCounter++ % 4], &gBatteryCurrent);
|
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryCheckCounter++ % 4],
|
||||||
|
&gBatteryCurrent);
|
||||||
|
|
||||||
uint16_t voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] +
|
uint16_t voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] +
|
||||||
gBatteryVoltages[3]) /
|
gBatteryVoltages[2] + gBatteryVoltages[3]) /
|
||||||
4 * 760 / gBatteryCalibration[3];
|
4 * 760 / gBatteryCalibration[3];
|
||||||
|
|
||||||
unsigned perc = BATTERY_VoltsToPercent(voltage);
|
unsigned perc = BATTERY_VoltsToPercent(voltage);
|
||||||
@@ -641,7 +726,7 @@ static void DrawStatus() {
|
|||||||
|
|
||||||
static void DrawF(uint32_t f) {
|
static void DrawF(uint32_t f) {
|
||||||
sprintf(String, "%u.%05u", f / 100000, f % 100000);
|
sprintf(String, "%u.%05u", f / 100000, f % 100000);
|
||||||
UI_PrintStringSmall(String, 8, 127, 0);
|
UI_PrintStringSmallNormal(String, 8, 127, 0);
|
||||||
|
|
||||||
sprintf(String, "%3s", gModulationStr[settings.modulationType]);
|
sprintf(String, "%3s", gModulationStr[settings.modulationType]);
|
||||||
GUI_DisplaySmallest(String, 116, 1, false, true);
|
GUI_DisplaySmallest(String, 116, 1, false, true);
|
||||||
@@ -686,9 +771,11 @@ static void DrawRssiTriggerLevel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void DrawTicks() {
|
static void DrawTicks() {
|
||||||
uint32_t f = GetFStart() % 100000;
|
uint32_t f = GetFStart();
|
||||||
uint32_t step = GetScanStep();
|
uint32_t span = GetFEnd() - GetFStart();
|
||||||
for (uint8_t i = 0; i < 128; i += (1 << settings.stepsCount), f += step) {
|
uint32_t step = span / 128;
|
||||||
|
for (uint8_t i = 0; i < 128; i += (1 << settings.stepsCount)) {
|
||||||
|
f = GetFStart() + span * i / 128;
|
||||||
uint8_t barValue = 0b00000001;
|
uint8_t barValue = 0b00000001;
|
||||||
(f % 10000) < step && (barValue |= 0b00000010);
|
(f % 10000) < step && (barValue |= 0b00000010);
|
||||||
(f % 50000) < step && (barValue |= 0b00000100);
|
(f % 50000) < step && (barValue |= 0b00000100);
|
||||||
@@ -740,9 +827,15 @@ static void OnKeyDown(uint8_t key) {
|
|||||||
UpdateFreqChangeStep(false);
|
UpdateFreqChangeStep(false);
|
||||||
break;
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(!gScanRangeStart)
|
||||||
|
#endif
|
||||||
UpdateCurrentFreq(true);
|
UpdateCurrentFreq(true);
|
||||||
break;
|
break;
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(!gScanRangeStart)
|
||||||
|
#endif
|
||||||
UpdateCurrentFreq(false);
|
UpdateCurrentFreq(false);
|
||||||
break;
|
break;
|
||||||
case KEY_SIDE1:
|
case KEY_SIDE1:
|
||||||
@@ -755,6 +848,9 @@ static void OnKeyDown(uint8_t key) {
|
|||||||
UpdateRssiTriggerLevel(false);
|
UpdateRssiTriggerLevel(false);
|
||||||
break;
|
break;
|
||||||
case KEY_5:
|
case KEY_5:
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(!gScanRangeStart)
|
||||||
|
#endif
|
||||||
FreqInput();
|
FreqInput();
|
||||||
break;
|
break;
|
||||||
case KEY_0:
|
case KEY_0:
|
||||||
@@ -764,6 +860,9 @@ static void OnKeyDown(uint8_t key) {
|
|||||||
ToggleListeningBW();
|
ToggleListeningBW();
|
||||||
break;
|
break;
|
||||||
case KEY_4:
|
case KEY_4:
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(!gScanRangeStart)
|
||||||
|
#endif
|
||||||
ToggleStepsCount();
|
ToggleStepsCount();
|
||||||
break;
|
break;
|
||||||
case KEY_SIDE2:
|
case KEY_SIDE2:
|
||||||
@@ -886,6 +985,7 @@ void OnKeyDownStill(KEY_Code_t key) {
|
|||||||
case KEY_EXIT:
|
case KEY_EXIT:
|
||||||
if (!menuState) {
|
if (!menuState) {
|
||||||
SetState(SPECTRUM);
|
SetState(SPECTRUM);
|
||||||
|
lockAGC = false;
|
||||||
monitorMode = false;
|
monitorMode = false;
|
||||||
RelaunchScan();
|
RelaunchScan();
|
||||||
break;
|
break;
|
||||||
@@ -897,9 +997,7 @@ void OnKeyDownStill(KEY_Code_t key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RenderFreqInput() {
|
static void RenderFreqInput() { UI_PrintString(freqInputString, 2, 127, 0, 8); }
|
||||||
UI_PrintString(freqInputString, 2, 127, 0, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void RenderStatus() {
|
static void RenderStatus() {
|
||||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||||
@@ -909,7 +1007,7 @@ static void RenderStatus() {
|
|||||||
|
|
||||||
static void RenderSpectrum() {
|
static void RenderSpectrum() {
|
||||||
DrawTicks();
|
DrawTicks();
|
||||||
DrawArrow(peak.i << settings.stepsCount);
|
DrawArrow(128u * peak.i / GetStepsCount());
|
||||||
DrawSpectrum();
|
DrawSpectrum();
|
||||||
DrawRssiTriggerLevel();
|
DrawRssiTriggerLevel();
|
||||||
DrawF(peak.f);
|
DrawF(peak.f);
|
||||||
@@ -921,14 +1019,14 @@ static void RenderStill() {
|
|||||||
|
|
||||||
const uint8_t METER_PAD_LEFT = 3;
|
const uint8_t METER_PAD_LEFT = 3;
|
||||||
|
|
||||||
for (int i = 0; i < 121; i++) {
|
memset(&gFrameBuffer[2][METER_PAD_LEFT], 0b00010000, 121);
|
||||||
if (i % 10 == 0) {
|
|
||||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b01110000;
|
for (int i = 0; i < 121; i+=5) {
|
||||||
} else if (i % 5 == 0) {
|
|
||||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00110000;
|
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00110000;
|
||||||
} else {
|
|
||||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00010000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 121; i+=10) {
|
||||||
|
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b01110000;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t x = Rssi2PX(scanInfo.rssi, 0, 121);
|
uint8_t x = Rssi2PX(scanInfo.rssi, 0, 121);
|
||||||
@@ -977,7 +1075,7 @@ static void RenderStill() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Render() {
|
static void Render() {
|
||||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
UI_DisplayClear();
|
||||||
|
|
||||||
switch (currentState) {
|
switch (currentState) {
|
||||||
case SPECTRUM:
|
case SPECTRUM:
|
||||||
@@ -1004,8 +1102,7 @@ bool HandleUserInput() {
|
|||||||
else
|
else
|
||||||
kbd.counter -= 3;
|
kbd.counter -= 3;
|
||||||
SYSTEM_DelayMs(20);
|
SYSTEM_DelayMs(20);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
kbd.counter = 0;
|
kbd.counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1027,7 +1124,11 @@ bool HandleUserInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Scan() {
|
static void Scan() {
|
||||||
if (rssiHistory[scanInfo.i] != RSSI_MAX_VALUE) {
|
if (rssiHistory[scanInfo.i] != RSSI_MAX_VALUE
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
&& !IsBlacklisted(scanInfo.i)
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
SetF(scanInfo.f);
|
SetF(scanInfo.f);
|
||||||
Measure();
|
Measure();
|
||||||
UpdateScanInfo();
|
UpdateScanInfo();
|
||||||
@@ -1048,6 +1149,10 @@ static void UpdateScan() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(scanInfo.measurementsCount < 128)
|
||||||
|
memset(&rssiHistory[scanInfo.measurementsCount], 0,
|
||||||
|
sizeof(rssiHistory) - scanInfo.measurementsCount*sizeof(rssiHistory[0]));
|
||||||
|
|
||||||
redrawScreen = true;
|
redrawScreen = true;
|
||||||
preventKeypress = false;
|
preventKeypress = false;
|
||||||
|
|
||||||
@@ -1100,10 +1205,39 @@ static void UpdateListening() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ToggleRX(false);
|
ToggleRX(false);
|
||||||
newScanStart = true;
|
ResetScanStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Tick() {
|
static void Tick() {
|
||||||
|
#ifdef ENABLE_AM_FIX
|
||||||
|
if (gNextTimeslice) {
|
||||||
|
gNextTimeslice = false;
|
||||||
|
if(settings.modulationType == MODULATION_AM && !lockAGC) {
|
||||||
|
AM_fix_10ms(vfo); //allow AM_Fix to apply its AGC action
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if (gNextTimeslice_500ms) {
|
||||||
|
gNextTimeslice_500ms = false;
|
||||||
|
|
||||||
|
// if a lot of steps then it takes long time
|
||||||
|
// we don't want to wait for whole scan
|
||||||
|
// listening has it's own timer
|
||||||
|
if(GetStepsCount()>128 && !isListening) {
|
||||||
|
UpdatePeakInfo();
|
||||||
|
if (IsPeakOverLevel()) {
|
||||||
|
ToggleRX(true);
|
||||||
|
TuneToPeak();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
redrawScreen = true;
|
||||||
|
preventKeypress = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!preventKeypress) {
|
if (!preventKeypress) {
|
||||||
HandleUserInput();
|
HandleUserInput();
|
||||||
}
|
}
|
||||||
@@ -1133,25 +1267,40 @@ static void Tick() {
|
|||||||
|
|
||||||
void APP_RunSpectrum() {
|
void APP_RunSpectrum() {
|
||||||
// TX here coz it always? set to active VFO
|
// TX here coz it always? set to active VFO
|
||||||
currentFreq = initialFreq =
|
vfo = gEeprom.TX_VFO;
|
||||||
gEeprom.VfoInfo[gEeprom.TX_VFO].pRX->Frequency;
|
// set the current frequency in the middle of the display
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(gScanRangeStart) {
|
||||||
|
currentFreq = initialFreq = gScanRangeStart;
|
||||||
|
for(uint8_t i = 0; i < ARRAY_SIZE(scanStepValues); i++) {
|
||||||
|
if(scanStepValues[i] >= gTxVfo->StepFrequency) {
|
||||||
|
settings.scanStepIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings.stepsCount = STEPS_128;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
currentFreq = initialFreq = gTxVfo->pRX->Frequency -
|
||||||
|
((GetStepsCount() / 2) * GetScanStep());
|
||||||
|
|
||||||
BackupRegisters();
|
BackupRegisters();
|
||||||
|
|
||||||
isListening = true; // to turn off RX later
|
isListening = true; // to turn off RX later
|
||||||
redrawStatus = true;
|
redrawStatus = true;
|
||||||
redrawScreen = false; // we will wait until scan done
|
redrawScreen = true;
|
||||||
newScanStart = true;
|
newScanStart = true;
|
||||||
|
|
||||||
|
|
||||||
ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off
|
ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off
|
||||||
RADIO_SetModulation(settings.modulationType = MODULATION_FM);
|
RADIO_SetModulation(settings.modulationType = gTxVfo->Modulation);
|
||||||
|
|
||||||
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
|
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
|
||||||
|
|
||||||
RelaunchScan();
|
RelaunchScan();
|
||||||
|
|
||||||
for (int i = 0; i < 128; ++i) {
|
memset(rssiHistory, 0, sizeof(rssiHistory));
|
||||||
rssiHistory[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#include "../driver/systick.h"
|
#include "../driver/systick.h"
|
||||||
#include "../external/printf/printf.h"
|
#include "../external/printf/printf.h"
|
||||||
#include "../font.h"
|
#include "../font.h"
|
||||||
#include "../frequencies.h"
|
|
||||||
#include "../helper/battery.h"
|
#include "../helper/battery.h"
|
||||||
#include "../misc.h"
|
#include "../misc.h"
|
||||||
#include "../radio.h"
|
#include "../radio.h"
|
||||||
@@ -46,9 +45,8 @@ static const uint8_t U8RssiMap[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const uint16_t scanStepValues[] = {
|
static const uint16_t scanStepValues[] = {
|
||||||
1, 10, 50, 100,
|
1, 10, 50, 100, 250, 500, 625, 833,
|
||||||
|
1000, 1250, 1500, 2000, 2500, 5000, 10000,
|
||||||
250, 500, 625, 833, 1000, 1250, 2500, 10000,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint16_t scanStepBWRegValues[] = {
|
static const uint16_t scanStepBWRegValues[] = {
|
||||||
@@ -111,7 +109,10 @@ typedef enum ScanStep {
|
|||||||
S_STEP_8_33kHz,
|
S_STEP_8_33kHz,
|
||||||
S_STEP_10_0kHz,
|
S_STEP_10_0kHz,
|
||||||
S_STEP_12_5kHz,
|
S_STEP_12_5kHz,
|
||||||
|
S_STEP_15_0kHz,
|
||||||
|
S_STEP_20_0kHz,
|
||||||
S_STEP_25_0kHz,
|
S_STEP_25_0kHz,
|
||||||
|
S_STEP_50_0kHz,
|
||||||
S_STEP_100_0kHz,
|
S_STEP_100_0kHz,
|
||||||
} ScanStep;
|
} ScanStep;
|
||||||
|
|
||||||
@@ -137,17 +138,17 @@ typedef struct KeyboardState {
|
|||||||
|
|
||||||
typedef struct ScanInfo {
|
typedef struct ScanInfo {
|
||||||
uint16_t rssi, rssiMin, rssiMax;
|
uint16_t rssi, rssiMin, rssiMax;
|
||||||
uint8_t i, iPeak;
|
uint16_t i, iPeak;
|
||||||
uint32_t f, fPeak;
|
uint32_t f, fPeak;
|
||||||
uint16_t scanStep;
|
uint16_t scanStep;
|
||||||
uint8_t measurementsCount;
|
uint16_t measurementsCount;
|
||||||
} ScanInfo;
|
} ScanInfo;
|
||||||
|
|
||||||
typedef struct PeakInfo {
|
typedef struct PeakInfo {
|
||||||
uint16_t t;
|
uint16_t t;
|
||||||
uint16_t rssi;
|
uint16_t rssi;
|
||||||
uint32_t f;
|
uint32_t f;
|
||||||
uint8_t i;
|
uint16_t i;
|
||||||
} PeakInfo;
|
} PeakInfo;
|
||||||
|
|
||||||
void APP_RunSpectrum(void);
|
void APP_RunSpectrum(void);
|
||||||
|
|||||||
73
app/uart.c
@@ -36,10 +36,12 @@
|
|||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
#if defined(ENABLE_OVERLAY)
|
#if defined(ENABLE_OVERLAY)
|
||||||
#include "sram-overlay.h"
|
#include "sram-overlay.h"
|
||||||
#endif
|
#endif
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
#define DMA_INDEX(x, y) (((x) + (y)) % sizeof(UART_DMA_Buffer))
|
#define DMA_INDEX(x, y) (((x) + (y)) % sizeof(UART_DMA_Buffer))
|
||||||
|
|
||||||
@@ -226,6 +228,8 @@ static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// session init, sends back version info and state
|
||||||
|
// timestamp is a session id really
|
||||||
static void CMD_0514(const uint8_t *pBuffer)
|
static void CMD_0514(const uint8_t *pBuffer)
|
||||||
{
|
{
|
||||||
const CMD_0514_t *pCmd = (const CMD_0514_t *)pBuffer;
|
const CMD_0514_t *pCmd = (const CMD_0514_t *)pBuffer;
|
||||||
@@ -244,6 +248,7 @@ static void CMD_0514(const uint8_t *pBuffer)
|
|||||||
SendVersion();
|
SendVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read eeprom
|
||||||
static void CMD_051B(const uint8_t *pBuffer)
|
static void CMD_051B(const uint8_t *pBuffer)
|
||||||
{
|
{
|
||||||
const CMD_051B_t *pCmd = (const CMD_051B_t *)pBuffer;
|
const CMD_051B_t *pCmd = (const CMD_051B_t *)pBuffer;
|
||||||
@@ -274,6 +279,7 @@ static void CMD_051B(const uint8_t *pBuffer)
|
|||||||
SendReply(&Reply, pCmd->Size + 8);
|
SendReply(&Reply, pCmd->Size + 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// write eeprom
|
||||||
static void CMD_051D(const uint8_t *pBuffer)
|
static void CMD_051D(const uint8_t *pBuffer)
|
||||||
{
|
{
|
||||||
const CMD_051D_t *pCmd = (const CMD_051D_t *)pBuffer;
|
const CMD_051D_t *pCmd = (const CMD_051D_t *)pBuffer;
|
||||||
@@ -314,12 +320,13 @@ static void CMD_051D(const uint8_t *pBuffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bReloadEeprom)
|
if (bReloadEeprom)
|
||||||
BOARD_EEPROM_Init();
|
SETTINGS_InitEEPROM();
|
||||||
}
|
}
|
||||||
|
|
||||||
SendReply(&Reply, sizeof(Reply));
|
SendReply(&Reply, sizeof(Reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read RSSI
|
||||||
static void CMD_0527(void)
|
static void CMD_0527(void)
|
||||||
{
|
{
|
||||||
REPLY_0527_t Reply;
|
REPLY_0527_t Reply;
|
||||||
@@ -333,6 +340,7 @@ static void CMD_0527(void)
|
|||||||
SendReply(&Reply, sizeof(Reply));
|
SendReply(&Reply, sizeof(Reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read ADC
|
||||||
static void CMD_0529(void)
|
static void CMD_0529(void)
|
||||||
{
|
{
|
||||||
REPLY_0529_t Reply;
|
REPLY_0529_t Reply;
|
||||||
@@ -387,6 +395,11 @@ static void CMD_052D(const uint8_t *pBuffer)
|
|||||||
SendReply(&Reply, sizeof(Reply));
|
SendReply(&Reply, sizeof(Reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// session init, sends back version info and state
|
||||||
|
// timestamp is a session id really
|
||||||
|
// this command also disables dual watch, crossband,
|
||||||
|
// DTMF side tones, freq reverse, PTT ID, DTMF decoding, frequency offset
|
||||||
|
// exits power save, sets main VFO to upper,
|
||||||
static void CMD_052F(const uint8_t *pBuffer)
|
static void CMD_052F(const uint8_t *pBuffer)
|
||||||
{
|
{
|
||||||
const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer;
|
const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer;
|
||||||
@@ -421,6 +434,44 @@ static void CMD_052F(const uint8_t *pBuffer)
|
|||||||
SendVersion();
|
SendVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UART_RW_BK_REGS
|
||||||
|
static void CMD_0601_ReadBK4819Reg(const uint8_t *pBuffer)
|
||||||
|
{
|
||||||
|
typedef struct __attribute__((__packed__)) {
|
||||||
|
Header_t header;
|
||||||
|
uint8_t reg;
|
||||||
|
} CMD_0601_t;
|
||||||
|
|
||||||
|
CMD_0601_t *cmd = (CMD_0601_t*) pBuffer;
|
||||||
|
|
||||||
|
struct __attribute__((__packed__)) {
|
||||||
|
Header_t header;
|
||||||
|
struct __attribute__((__packed__)) {
|
||||||
|
uint8_t reg;
|
||||||
|
uint16_t value;
|
||||||
|
} data;
|
||||||
|
} reply;
|
||||||
|
|
||||||
|
reply.header.ID = 0x0601;
|
||||||
|
reply.header.Size = sizeof(reply.data);
|
||||||
|
reply.data.reg = cmd->reg;
|
||||||
|
reply.data.value = BK4819_ReadRegister(cmd->reg);
|
||||||
|
SendReply(&reply, sizeof(reply));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CMD_0602_WriteBK4819Reg(const uint8_t *pBuffer)
|
||||||
|
{
|
||||||
|
typedef struct __attribute__((__packed__)) {
|
||||||
|
Header_t header;
|
||||||
|
uint8_t reg;
|
||||||
|
uint16_t value;
|
||||||
|
} CMD_0602_t;
|
||||||
|
|
||||||
|
CMD_0602_t *cmd = (CMD_0602_t*) pBuffer;
|
||||||
|
BK4819_WriteRegister(cmd->reg, cmd->value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool UART_IsCommandAvailable(void)
|
bool UART_IsCommandAvailable(void)
|
||||||
{
|
{
|
||||||
uint16_t Index;
|
uint16_t Index;
|
||||||
@@ -479,11 +530,11 @@ bool UART_IsCommandAvailable(void)
|
|||||||
if (TailIndex < Index)
|
if (TailIndex < Index)
|
||||||
{
|
{
|
||||||
const uint16_t ChunkSize = sizeof(UART_DMA_Buffer) - Index;
|
const uint16_t ChunkSize = sizeof(UART_DMA_Buffer) - Index;
|
||||||
memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize);
|
memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize);
|
||||||
memmove(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex);
|
memcpy(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index);
|
memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index);
|
||||||
|
|
||||||
TailIndex = DMA_INDEX(TailIndex, 2);
|
TailIndex = DMA_INDEX(TailIndex, 2);
|
||||||
if (TailIndex < gUART_WriteIndex)
|
if (TailIndex < gUART_WriteIndex)
|
||||||
@@ -552,12 +603,22 @@ void UART_HandleCommand(void)
|
|||||||
CMD_052F(UART_Command.Buffer);
|
CMD_052F(UART_Command.Buffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x05DD:
|
case 0x05DD: // reset
|
||||||
#if defined(ENABLE_OVERLAY)
|
#if defined(ENABLE_OVERLAY)
|
||||||
overlay_FLASH_RebootToBootloader();
|
overlay_FLASH_RebootToBootloader();
|
||||||
#else
|
#else
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef ENABLE_UART_RW_BK_REGS
|
||||||
|
case 0x0601:
|
||||||
|
CMD_0601_ReadBK4819Reg(UART_Command.Buffer);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x0602:
|
||||||
|
CMD_0602_WriteBK4819Reg(UART_Command.Buffer);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
300
audio.c
@@ -31,6 +31,144 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
|
|
||||||
|
BEEP_Type_t gBeepToPlay = BEEP_NONE;
|
||||||
|
|
||||||
|
void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Beep != BEEP_880HZ_60MS_TRIPLE_BEEP &&
|
||||||
|
Beep != BEEP_500HZ_60MS_DOUBLE_BEEP &&
|
||||||
|
Beep != BEEP_440HZ_500MS &&
|
||||||
|
Beep != BEEP_880HZ_200MS &&
|
||||||
|
Beep != BEEP_880HZ_500MS &&
|
||||||
|
!gEeprom.BEEP_CONTROL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef ENABLE_AIRCOPY
|
||||||
|
if (gScreenToDisplay == DISPLAY_AIRCOPY)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_RECEIVE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_MONITOR)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
if (gFmRadioMode)
|
||||||
|
BK1080_Mute(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AUDIO_AudioPathOff();
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
||||||
|
BK4819_RX_TurnOn();
|
||||||
|
|
||||||
|
SYSTEM_DelayMs(20);
|
||||||
|
|
||||||
|
uint16_t ToneConfig = BK4819_ReadRegister(BK4819_REG_71);
|
||||||
|
|
||||||
|
uint16_t ToneFrequency;
|
||||||
|
switch (Beep)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case BEEP_NONE:
|
||||||
|
ToneFrequency = 220;
|
||||||
|
break;
|
||||||
|
case BEEP_1KHZ_60MS_OPTIONAL:
|
||||||
|
ToneFrequency = 1000;
|
||||||
|
break;
|
||||||
|
case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL:
|
||||||
|
case BEEP_500HZ_60MS_DOUBLE_BEEP:
|
||||||
|
ToneFrequency = 500;
|
||||||
|
break;
|
||||||
|
case BEEP_440HZ_40MS_OPTIONAL:
|
||||||
|
case BEEP_440HZ_500MS:
|
||||||
|
ToneFrequency = 440;
|
||||||
|
break;
|
||||||
|
case BEEP_880HZ_40MS_OPTIONAL:
|
||||||
|
case BEEP_880HZ_60MS_TRIPLE_BEEP:
|
||||||
|
case BEEP_880HZ_200MS:
|
||||||
|
case BEEP_880HZ_500MS:
|
||||||
|
ToneFrequency = 880;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BK4819_PlayTone(ToneFrequency, true);
|
||||||
|
|
||||||
|
SYSTEM_DelayMs(2);
|
||||||
|
|
||||||
|
AUDIO_AudioPathOn();
|
||||||
|
|
||||||
|
SYSTEM_DelayMs(60);
|
||||||
|
|
||||||
|
uint16_t Duration;
|
||||||
|
switch (Beep)
|
||||||
|
{
|
||||||
|
case BEEP_880HZ_60MS_TRIPLE_BEEP:
|
||||||
|
BK4819_ExitTxMute();
|
||||||
|
SYSTEM_DelayMs(60);
|
||||||
|
BK4819_EnterTxMute();
|
||||||
|
SYSTEM_DelayMs(20);
|
||||||
|
[[fallthrough]];
|
||||||
|
case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL:
|
||||||
|
case BEEP_500HZ_60MS_DOUBLE_BEEP:
|
||||||
|
BK4819_ExitTxMute();
|
||||||
|
SYSTEM_DelayMs(60);
|
||||||
|
BK4819_EnterTxMute();
|
||||||
|
SYSTEM_DelayMs(20);
|
||||||
|
[[fallthrough]];
|
||||||
|
case BEEP_1KHZ_60MS_OPTIONAL:
|
||||||
|
BK4819_ExitTxMute();
|
||||||
|
Duration = 60;
|
||||||
|
break;
|
||||||
|
case BEEP_880HZ_40MS_OPTIONAL:
|
||||||
|
case BEEP_440HZ_40MS_OPTIONAL:
|
||||||
|
BK4819_ExitTxMute();
|
||||||
|
Duration = 40;
|
||||||
|
break;
|
||||||
|
case BEEP_880HZ_200MS:
|
||||||
|
BK4819_ExitTxMute();
|
||||||
|
Duration = 200;
|
||||||
|
break;
|
||||||
|
case BEEP_440HZ_500MS:
|
||||||
|
case BEEP_880HZ_500MS:
|
||||||
|
default:
|
||||||
|
BK4819_ExitTxMute();
|
||||||
|
Duration = 500;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SYSTEM_DelayMs(Duration);
|
||||||
|
BK4819_EnterTxMute();
|
||||||
|
SYSTEM_DelayMs(20);
|
||||||
|
|
||||||
|
AUDIO_AudioPathOff();
|
||||||
|
|
||||||
|
SYSTEM_DelayMs(5);
|
||||||
|
BK4819_TurnsOffTones_TurnsOnRX();
|
||||||
|
SYSTEM_DelayMs(5);
|
||||||
|
BK4819_WriteRegister(BK4819_REG_71, ToneConfig);
|
||||||
|
|
||||||
|
if (gEnableSpeaker)
|
||||||
|
AUDIO_AudioPathOn();
|
||||||
|
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
if (gFmRadioMode)
|
||||||
|
BK1080_Mute(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
||||||
|
BK4819_Sleep();
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
gVoxResumeCountdown = 80;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
|
|
||||||
static const uint8_t VoiceClipLengthChinese[58] =
|
static const uint8_t VoiceClipLengthChinese[58] =
|
||||||
@@ -66,151 +204,8 @@
|
|||||||
volatile bool gFlagPlayQueuedVoice;
|
volatile bool gFlagPlayQueuedVoice;
|
||||||
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID;
|
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BEEP_Type_t gBeepToPlay = BEEP_NONE;
|
static void AUDIO_PlayVoice(uint8_t VoiceID)
|
||||||
|
|
||||||
void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|
||||||
{
|
|
||||||
uint16_t ToneConfig;
|
|
||||||
uint16_t ToneFrequency;
|
|
||||||
uint16_t Duration;
|
|
||||||
|
|
||||||
if (Beep != BEEP_880HZ_60MS_TRIPLE_BEEP &&
|
|
||||||
Beep != BEEP_500HZ_60MS_DOUBLE_BEEP &&
|
|
||||||
Beep != BEEP_440HZ_500MS &&
|
|
||||||
Beep != BEEP_880HZ_200MS &&
|
|
||||||
Beep != BEEP_880HZ_500MS &&
|
|
||||||
!gEeprom.BEEP_CONTROL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef ENABLE_AIRCOPY
|
|
||||||
if (gScreenToDisplay == DISPLAY_AIRCOPY)
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_MONITOR)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ToneConfig = BK4819_ReadRegister(BK4819_REG_71);
|
|
||||||
|
|
||||||
AUDIO_AudioPathOff();
|
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
|
||||||
BK4819_RX_TurnOn();
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
if (gFmRadioMode)
|
|
||||||
BK1080_Mute(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SYSTEM_DelayMs(20);
|
|
||||||
|
|
||||||
switch (Beep)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case BEEP_NONE:
|
|
||||||
ToneFrequency = 220;
|
|
||||||
break;
|
|
||||||
case BEEP_1KHZ_60MS_OPTIONAL:
|
|
||||||
ToneFrequency = 1000;
|
|
||||||
break;
|
|
||||||
case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL:
|
|
||||||
case BEEP_500HZ_60MS_DOUBLE_BEEP:
|
|
||||||
ToneFrequency = 500;
|
|
||||||
break;
|
|
||||||
case BEEP_440HZ_40MS_OPTIONAL:
|
|
||||||
case BEEP_440HZ_500MS:
|
|
||||||
ToneFrequency = 440;
|
|
||||||
break;
|
|
||||||
case BEEP_880HZ_40MS_OPTIONAL:
|
|
||||||
case BEEP_880HZ_60MS_TRIPLE_BEEP:
|
|
||||||
case BEEP_880HZ_200MS:
|
|
||||||
case BEEP_880HZ_500MS:
|
|
||||||
ToneFrequency = 880;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
BK4819_PlayTone(ToneFrequency, true);
|
|
||||||
|
|
||||||
SYSTEM_DelayMs(2);
|
|
||||||
|
|
||||||
AUDIO_AudioPathOn();
|
|
||||||
|
|
||||||
SYSTEM_DelayMs(60);
|
|
||||||
|
|
||||||
switch (Beep)
|
|
||||||
{
|
|
||||||
case BEEP_880HZ_60MS_TRIPLE_BEEP:
|
|
||||||
BK4819_ExitTxMute();
|
|
||||||
SYSTEM_DelayMs(60);
|
|
||||||
BK4819_EnterTxMute();
|
|
||||||
SYSTEM_DelayMs(20);
|
|
||||||
[[fallthrough]];
|
|
||||||
case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL:
|
|
||||||
case BEEP_500HZ_60MS_DOUBLE_BEEP:
|
|
||||||
BK4819_ExitTxMute();
|
|
||||||
SYSTEM_DelayMs(60);
|
|
||||||
BK4819_EnterTxMute();
|
|
||||||
SYSTEM_DelayMs(20);
|
|
||||||
[[fallthrough]];
|
|
||||||
case BEEP_1KHZ_60MS_OPTIONAL:
|
|
||||||
BK4819_ExitTxMute();
|
|
||||||
Duration = 60;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BEEP_880HZ_40MS_OPTIONAL:
|
|
||||||
case BEEP_440HZ_40MS_OPTIONAL:
|
|
||||||
BK4819_ExitTxMute();
|
|
||||||
Duration = 40;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BEEP_880HZ_200MS:
|
|
||||||
BK4819_ExitTxMute();
|
|
||||||
Duration = 200;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BEEP_440HZ_500MS:
|
|
||||||
case BEEP_880HZ_500MS:
|
|
||||||
default:
|
|
||||||
BK4819_ExitTxMute();
|
|
||||||
Duration = 500;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SYSTEM_DelayMs(Duration);
|
|
||||||
BK4819_EnterTxMute();
|
|
||||||
SYSTEM_DelayMs(20);
|
|
||||||
|
|
||||||
AUDIO_AudioPathOff();
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
gVoxResumeCountdown = 80;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SYSTEM_DelayMs(5);
|
|
||||||
BK4819_TurnsOffTones_TurnsOnRX();
|
|
||||||
SYSTEM_DelayMs(5);
|
|
||||||
BK4819_WriteRegister(BK4819_REG_71, ToneConfig);
|
|
||||||
|
|
||||||
if (gEnableSpeaker)
|
|
||||||
AUDIO_AudioPathOn();
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
if (gFmRadioMode)
|
|
||||||
BK1080_Mute(false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
|
||||||
BK4819_Sleep();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
|
|
||||||
void AUDIO_PlayVoice(uint8_t VoiceID)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@@ -260,9 +255,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
VoiceID += VOICE_ID_ENG_BASE;
|
VoiceID += VOICE_ID_ENG_BASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
if (FUNCTION_IsRx()) // 1of11
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
|
||||||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
|
|
||||||
BK4819_SetAF(BK4819_AF_MUTE);
|
BK4819_SetAF(BK4819_AF_MUTE);
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
@@ -286,9 +279,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
{
|
{
|
||||||
SYSTEM_DelayMs(Delay * 10);
|
SYSTEM_DelayMs(Delay * 10);
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
if (FUNCTION_IsRx()) // 1of11
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
|
||||||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
|
|
||||||
RADIO_SetModulation(gRxVfo->Modulation);
|
RADIO_SetModulation(gRxVfo->Modulation);
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
@@ -427,10 +418,10 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
if (FUNCTION_IsRx())
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
{
|
||||||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
|
RADIO_SetModulation(gRxVfo->Modulation); // 1of11
|
||||||
RADIO_SetModulation(gRxVfo->Modulation);
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFmRadioMode)
|
if (gFmRadioMode)
|
||||||
@@ -449,4 +440,3 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
2
audio.h
@@ -149,7 +149,6 @@ static inline void AUDIO_AudioPathOff(void) {
|
|||||||
extern volatile bool gFlagPlayQueuedVoice;
|
extern volatile bool gFlagPlayQueuedVoice;
|
||||||
extern VOICE_ID_t gAnotherVoiceID;
|
extern VOICE_ID_t gAnotherVoiceID;
|
||||||
|
|
||||||
void AUDIO_PlayVoice(uint8_t VoiceID);
|
|
||||||
void AUDIO_PlaySingleVoice(bool bFlag);
|
void AUDIO_PlaySingleVoice(bool bFlag);
|
||||||
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID);
|
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID);
|
||||||
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value);
|
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value);
|
||||||
@@ -157,4 +156,3 @@ static inline void AUDIO_AudioPathOff(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
78
bitmaps.c
@@ -6,17 +6,6 @@
|
|||||||
|
|
||||||
const uint8_t BITMAP_POWERSAVE[8] =
|
const uint8_t BITMAP_POWERSAVE[8] =
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
// "S"
|
|
||||||
0b00000000,
|
|
||||||
0b00100110,
|
|
||||||
0b01001001,
|
|
||||||
0b01001001,
|
|
||||||
0b01001001,
|
|
||||||
0b01001001,
|
|
||||||
0b01001001,
|
|
||||||
0b00110010
|
|
||||||
#else
|
|
||||||
// "PS"
|
// "PS"
|
||||||
0b00000000,
|
0b00000000,
|
||||||
0b01111111,
|
0b01111111,
|
||||||
@@ -26,7 +15,7 @@ const uint8_t BITMAP_POWERSAVE[8] =
|
|||||||
0b01000110,
|
0b01000110,
|
||||||
0b01001001,
|
0b01001001,
|
||||||
0b00110001
|
0b00110001
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t BITMAP_TX[8] =
|
const uint8_t BITMAP_TX[8] =
|
||||||
@@ -53,6 +42,20 @@ const uint8_t BITMAP_RX[8] =
|
|||||||
0b00000000
|
0b00000000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const uint8_t BITMAP_FM[10] =
|
||||||
|
{ // "FM"
|
||||||
|
0b00000000,
|
||||||
|
0b01111111,
|
||||||
|
0b00001001,
|
||||||
|
0b00000001,
|
||||||
|
0b00000000,
|
||||||
|
0b01111111,
|
||||||
|
0b00000010,
|
||||||
|
0b00001100,
|
||||||
|
0b00000010,
|
||||||
|
0b01111111
|
||||||
|
};
|
||||||
|
|
||||||
const uint8_t BITMAP_BatteryLevel[2] =
|
const uint8_t BITMAP_BatteryLevel[2] =
|
||||||
{
|
{
|
||||||
0b01011101,
|
0b01011101,
|
||||||
@@ -162,23 +165,7 @@ const uint8_t BITMAP_F_Key[6] =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
const uint8_t BITMAP_WX[12] =
|
|
||||||
{ // "WX"
|
|
||||||
0b00000000,
|
|
||||||
0b01111111,
|
|
||||||
0b00100000,
|
|
||||||
0b00011000,
|
|
||||||
0b00100000,
|
|
||||||
0b01111111,
|
|
||||||
0b00000000,
|
|
||||||
0b01100011,
|
|
||||||
0b00010100,
|
|
||||||
0b00001000,
|
|
||||||
0b00010100,
|
|
||||||
0b01100011
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
// 'XB' (cross-band/cross-VFO)
|
// 'XB' (cross-band/cross-VFO)
|
||||||
const uint8_t BITMAP_XB[12] =
|
const uint8_t BITMAP_XB[12] =
|
||||||
{ // "XB"
|
{ // "XB"
|
||||||
@@ -195,10 +182,11 @@ const uint8_t BITMAP_F_Key[6] =
|
|||||||
0b01001001,
|
0b01001001,
|
||||||
0b00110110
|
0b00110110
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
const uint8_t BITMAP_TDR1[15] =
|
|
||||||
|
const uint8_t BITMAP_TDR1[16] =
|
||||||
{ // "DWR"
|
{ // "DWR"
|
||||||
|
0b00000000,
|
||||||
0b01111111,
|
0b01111111,
|
||||||
0b01000001,
|
0b01000001,
|
||||||
0b01000001,
|
0b01000001,
|
||||||
@@ -216,8 +204,9 @@ const uint8_t BITMAP_TDR1[15] =
|
|||||||
0b01000110
|
0b01000110
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t BITMAP_TDR2[9] =
|
const uint8_t BITMAP_TDR2[10] =
|
||||||
{ // "><" .. DW on hold
|
{ // "><" .. DW on hold
|
||||||
|
0b00000000,
|
||||||
0b00100010,
|
0b00100010,
|
||||||
0b00110110,
|
0b00110110,
|
||||||
0b00011100,
|
0b00011100,
|
||||||
@@ -270,18 +259,6 @@ const uint8_t BITMAP_Antenna[5] =
|
|||||||
0b00000011
|
0b00000011
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t BITMAP_MARKER[8] =
|
|
||||||
{
|
|
||||||
0b11111111,
|
|
||||||
0b11111111,
|
|
||||||
0b01111110,
|
|
||||||
0b01111110,
|
|
||||||
0b00111100,
|
|
||||||
0b00111100,
|
|
||||||
0b00011000,
|
|
||||||
0b00011000
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint8_t BITMAP_VFO_Default[8] =
|
const uint8_t BITMAP_VFO_Default[8] =
|
||||||
{
|
{
|
||||||
0b00000000,
|
0b00000000,
|
||||||
@@ -335,3 +312,16 @@ const uint8_t BITMAP_compand[6] =
|
|||||||
0b01000010,
|
0b01000010,
|
||||||
0b00100100
|
0b00100100
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef ENABLE_CUSTOM_MENU_LAYOUT
|
||||||
|
const uint8_t BITMAP_CurrentIndicator[8] = {
|
||||||
|
0xFF,
|
||||||
|
0xFF,
|
||||||
|
0x7E,
|
||||||
|
0x7E,
|
||||||
|
0x3C,
|
||||||
|
0x3C,
|
||||||
|
0x18,
|
||||||
|
0x18
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|||||||
11
bitmaps.h
@@ -7,7 +7,7 @@
|
|||||||
extern const uint8_t BITMAP_POWERSAVE[8];
|
extern const uint8_t BITMAP_POWERSAVE[8];
|
||||||
extern const uint8_t BITMAP_TX[8];
|
extern const uint8_t BITMAP_TX[8];
|
||||||
extern const uint8_t BITMAP_RX[8];
|
extern const uint8_t BITMAP_RX[8];
|
||||||
|
extern const uint8_t BITMAP_FM[10];
|
||||||
extern const uint8_t BITMAP_BatteryLevel[2];
|
extern const uint8_t BITMAP_BatteryLevel[2];
|
||||||
extern const uint8_t BITMAP_BatteryLevel1[17];
|
extern const uint8_t BITMAP_BatteryLevel1[17];
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@ extern const uint8_t BITMAP_F_Key[6];
|
|||||||
|
|
||||||
extern const uint8_t BITMAP_XB[12];
|
extern const uint8_t BITMAP_XB[12];
|
||||||
|
|
||||||
extern const uint8_t BITMAP_TDR1[15];
|
extern const uint8_t BITMAP_TDR1[16];
|
||||||
extern const uint8_t BITMAP_TDR2[9];
|
extern const uint8_t BITMAP_TDR2[10];
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
extern const uint8_t BITMAP_VoicePrompt[9];
|
extern const uint8_t BITMAP_VoicePrompt[9];
|
||||||
@@ -36,8 +36,6 @@ extern const uint8_t BITMAP_TDR2[9];
|
|||||||
|
|
||||||
extern const uint8_t BITMAP_Antenna[5];
|
extern const uint8_t BITMAP_Antenna[5];
|
||||||
|
|
||||||
extern const uint8_t BITMAP_MARKER[8];
|
|
||||||
|
|
||||||
extern const uint8_t BITMAP_VFO_Default[8];
|
extern const uint8_t BITMAP_VFO_Default[8];
|
||||||
extern const uint8_t BITMAP_VFO_NotDefault[8];
|
extern const uint8_t BITMAP_VFO_NotDefault[8];
|
||||||
|
|
||||||
@@ -46,5 +44,8 @@ extern const uint8_t BITMAP_ScanList2[6];
|
|||||||
|
|
||||||
extern const uint8_t BITMAP_compand[6];
|
extern const uint8_t BITMAP_compand[6];
|
||||||
|
|
||||||
|
#ifndef ENABLE_CUSTOM_MENU_LAYOUT
|
||||||
|
extern const uint8_t BITMAP_CurrentIndicator[8];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
405
board.c
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "app/dtmf.h"
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
#include "app/fm.h"
|
#include "app/fm.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -30,7 +29,7 @@
|
|||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
#include "driver/bk1080.h"
|
#include "driver/bk1080.h"
|
||||||
#endif
|
#endif
|
||||||
#include "driver/bk4819.h"
|
|
||||||
#include "driver/crc.h"
|
#include "driver/crc.h"
|
||||||
#include "driver/eeprom.h"
|
#include "driver/eeprom.h"
|
||||||
#include "driver/flash.h"
|
#include "driver/flash.h"
|
||||||
@@ -44,16 +43,6 @@
|
|||||||
#if defined(ENABLE_OVERLAY)
|
#if defined(ENABLE_OVERLAY)
|
||||||
#include "sram-overlay.h"
|
#include "sram-overlay.h"
|
||||||
#endif
|
#endif
|
||||||
#include "ui/menu.h"
|
|
||||||
|
|
||||||
static const uint32_t gDefaultFrequencyTable[] =
|
|
||||||
{
|
|
||||||
14500000, //
|
|
||||||
14550000, //
|
|
||||||
43300000, //
|
|
||||||
43320000, //
|
|
||||||
43350000 //
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(ENABLE_OVERLAY)
|
#if defined(ENABLE_OVERLAY)
|
||||||
void BOARD_FLASH_Init(void)
|
void BOARD_FLASH_Init(void)
|
||||||
@@ -504,397 +493,13 @@ void BOARD_Init(void)
|
|||||||
BOARD_GPIO_Init();
|
BOARD_GPIO_Init();
|
||||||
BACKLIGHT_InitHardware();
|
BACKLIGHT_InitHardware();
|
||||||
BOARD_ADC_Init();
|
BOARD_ADC_Init();
|
||||||
ST7565_Init(true);
|
ST7565_Init();
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
BK1080_Init(0, false);
|
BK1080_Init0();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_UART) || defined(ENABLED_AIRCOPY)
|
||||||
CRC_Init();
|
CRC_Init();
|
||||||
}
|
|
||||||
|
|
||||||
void BOARD_EEPROM_Init(void)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
uint8_t Data[16];
|
|
||||||
|
|
||||||
memset(Data, 0, sizeof(Data));
|
|
||||||
|
|
||||||
// 0E70..0E77
|
|
||||||
EEPROM_ReadBuffer(0x0E70, Data, 8);
|
|
||||||
gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST;
|
|
||||||
gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1;
|
|
||||||
gEeprom.TX_TIMEOUT_TIMER = (Data[2] < 11) ? Data[2] : 1;
|
|
||||||
#ifdef ENABLE_NOAA
|
|
||||||
gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false;
|
|
||||||
#endif
|
|
||||||
gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false;
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false;
|
|
||||||
gEeprom.VOX_LEVEL = (Data[6] < 10) ? Data[6] : 1;
|
|
||||||
#endif
|
|
||||||
gEeprom.MIC_SENSITIVITY = (Data[7] < 5) ? Data[7] : 4;
|
|
||||||
|
|
||||||
// 0E78..0E7F
|
|
||||||
EEPROM_ReadBuffer(0x0E78, Data, 8);
|
|
||||||
gEeprom.BACKLIGHT_MAX = (Data[0] & 0xF) <= 10 ? (Data[0] & 0xF) : 10;
|
|
||||||
gEeprom.BACKLIGHT_MIN = (Data[0] >> 4) < gEeprom.BACKLIGHT_MAX ? (Data[0] >> 4) : 0;
|
|
||||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
|
||||||
gEeprom.BACKLIGHT_MIN_STAT = BLMIN_STAT_ON;
|
|
||||||
#endif
|
|
||||||
gEeprom.CHANNEL_DISPLAY_MODE = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode
|
|
||||||
gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF;
|
|
||||||
gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4;
|
|
||||||
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A;
|
|
||||||
gEeprom.BACKLIGHT_TIME = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 3;
|
|
||||||
gEeprom.TAIL_TONE_ELIMINATION = (Data[6] < 2) ? Data[6] : false;
|
|
||||||
gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true;
|
|
||||||
|
|
||||||
// 0E80..0E87
|
|
||||||
EEPROM_ReadBuffer(0x0E80, Data, 8);
|
|
||||||
gEeprom.ScreenChannel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
|
||||||
gEeprom.ScreenChannel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
|
||||||
gEeprom.MrChannel[0] = IS_MR_CHANNEL(Data[1]) ? Data[1] : MR_CHANNEL_FIRST;
|
|
||||||
gEeprom.MrChannel[1] = IS_MR_CHANNEL(Data[4]) ? Data[4] : MR_CHANNEL_FIRST;
|
|
||||||
gEeprom.FreqChannel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
|
||||||
gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
|
||||||
#ifdef ENABLE_NOAA
|
|
||||||
gEeprom.NoaaChannel[0] = IS_NOAA_CHANNEL(Data[6]) ? Data[6] : NOAA_CHANNEL_FIRST;
|
|
||||||
gEeprom.NoaaChannel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
{ // 0E88..0E8F
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
uint16_t SelectedFrequency;
|
|
||||||
uint8_t SelectedChannel;
|
|
||||||
uint8_t IsMrMode;
|
|
||||||
uint8_t Padding[8];
|
|
||||||
} __attribute__((packed)) FM;
|
|
||||||
|
|
||||||
EEPROM_ReadBuffer(0x0E88, &FM, 8);
|
|
||||||
gEeprom.FM_LowerLimit = 760;
|
|
||||||
gEeprom.FM_UpperLimit = 1080;
|
|
||||||
if (FM.SelectedFrequency < gEeprom.FM_LowerLimit || FM.SelectedFrequency > gEeprom.FM_UpperLimit)
|
|
||||||
gEeprom.FM_SelectedFrequency = 960;
|
|
||||||
else
|
|
||||||
gEeprom.FM_SelectedFrequency = FM.SelectedFrequency;
|
|
||||||
|
|
||||||
gEeprom.FM_SelectedChannel = FM.SelectedChannel;
|
|
||||||
gEeprom.FM_IsMrMode = (FM.IsMrMode < 2) ? FM.IsMrMode : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 0E40..0E67
|
|
||||||
EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels));
|
|
||||||
FM_ConfigureChannelState();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 0E90..0E97
|
|
||||||
EEPROM_ReadBuffer(0x0E90, Data, 8);
|
|
||||||
gEeprom.BEEP_CONTROL = Data[0] & 1;
|
|
||||||
gEeprom.KEY_M_LONG_PRESS_ACTION = ((Data[0] >> 1) < ACTION_OPT_LEN) ? (Data[0] >> 1) : ACTION_OPT_NONE;
|
|
||||||
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
|
|
||||||
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT;
|
|
||||||
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
|
|
||||||
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE;
|
|
||||||
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
|
|
||||||
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false;
|
|
||||||
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE;
|
|
||||||
|
|
||||||
// 0E98..0E9F
|
|
||||||
EEPROM_ReadBuffer(0x0E98, Data, 8);
|
|
||||||
memmove(&gEeprom.POWER_ON_PASSWORD, Data, 4);
|
|
||||||
|
|
||||||
// 0EA0..0EA7
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
EEPROM_ReadBuffer(0x0EA0, Data, 8);
|
|
||||||
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 0EA8..0EAF
|
|
||||||
EEPROM_ReadBuffer(0x0EA8, Data, 8);
|
|
||||||
#ifdef ENABLE_ALARM
|
|
||||||
gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true;
|
|
||||||
#endif
|
|
||||||
gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF;
|
|
||||||
gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0;
|
|
||||||
gEeprom.TX_VFO = (Data[3] < 2) ? Data[3] : 0;
|
|
||||||
gEeprom.BATTERY_TYPE = (Data[4] < BATTERY_TYPE_UNKNOWN) ? Data[4] : BATTERY_TYPE_1600_MAH;
|
|
||||||
|
|
||||||
// 0ED0..0ED7
|
|
||||||
EEPROM_ReadBuffer(0x0ED0, Data, 8);
|
|
||||||
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_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#';
|
|
||||||
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;
|
|
||||||
#endif
|
|
||||||
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_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100;
|
|
||||||
|
|
||||||
// 0ED8..0EDF
|
|
||||||
EEPROM_ReadBuffer(0x0ED8, Data, 8);
|
|
||||||
gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 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;
|
|
||||||
|
|
||||||
// 0EE0..0EE7
|
|
||||||
|
|
||||||
EEPROM_ReadBuffer(0x0EE0, Data, 8);
|
|
||||||
if (DTMF_ValidateCodes((char *)Data, 8))
|
|
||||||
memmove(gEeprom.ANI_DTMF_ID, Data, 8);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memset(gEeprom.ANI_DTMF_ID, 0, sizeof(gEeprom.ANI_DTMF_ID));
|
|
||||||
strcpy(gEeprom.ANI_DTMF_ID, "123");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 0EE8..0EEF
|
|
||||||
EEPROM_ReadBuffer(0x0EE8, Data, 8);
|
|
||||||
if (DTMF_ValidateCodes((char *)Data, 8))
|
|
||||||
memmove(gEeprom.KILL_CODE, Data, 8);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memset(gEeprom.KILL_CODE, 0, sizeof(gEeprom.KILL_CODE));
|
|
||||||
strcpy(gEeprom.KILL_CODE, "ABCD9");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 0EF0..0EF7
|
|
||||||
EEPROM_ReadBuffer(0x0EF0, Data, 8);
|
|
||||||
if (DTMF_ValidateCodes((char *)Data, 8))
|
|
||||||
memmove(gEeprom.REVIVE_CODE, Data, 8);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memset(gEeprom.REVIVE_CODE, 0, sizeof(gEeprom.REVIVE_CODE));
|
|
||||||
strcpy(gEeprom.REVIVE_CODE, "9DCBA");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 0EF8..0F07
|
|
||||||
EEPROM_ReadBuffer(0x0EF8, Data, 16);
|
|
||||||
if (DTMF_ValidateCodes((char *)Data, 16))
|
|
||||||
memmove(gEeprom.DTMF_UP_CODE, Data, 16);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memset(gEeprom.DTMF_UP_CODE, 0, sizeof(gEeprom.DTMF_UP_CODE));
|
|
||||||
strcpy(gEeprom.DTMF_UP_CODE, "12345");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 0F08..0F17
|
|
||||||
EEPROM_ReadBuffer(0x0F08, Data, 16);
|
|
||||||
if (DTMF_ValidateCodes((char *)Data, 16))
|
|
||||||
memmove(gEeprom.DTMF_DOWN_CODE, Data, 16);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memset(gEeprom.DTMF_DOWN_CODE, 0, sizeof(gEeprom.DTMF_DOWN_CODE));
|
|
||||||
strcpy(gEeprom.DTMF_DOWN_CODE, "54321");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 0F18..0F1F
|
|
||||||
EEPROM_ReadBuffer(0x0F18, Data, 8);
|
|
||||||
// gEeprom.SCAN_LIST_DEFAULT = (Data[0] < 2) ? Data[0] : false;
|
|
||||||
gEeprom.SCAN_LIST_DEFAULT = (Data[0] < 3) ? Data[0] : false; // we now have 'all' channel scan option
|
|
||||||
for (i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
const unsigned int j = 1 + (i * 3);
|
|
||||||
gEeprom.SCAN_LIST_ENABLED[i] = (Data[j + 0] < 2) ? Data[j] : false;
|
|
||||||
gEeprom.SCANLIST_PRIORITY_CH1[i] = Data[j + 1];
|
|
||||||
gEeprom.SCANLIST_PRIORITY_CH2[i] = Data[j + 2];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 0F40..0F47
|
|
||||||
EEPROM_ReadBuffer(0x0F40, Data, 8);
|
|
||||||
gSetting_F_LOCK = (Data[0] < F_LOCK_LEN) ? Data[0] : F_LOCK_DEF;
|
|
||||||
gSetting_350TX = (Data[1] < 2) ? Data[1] : false; // was true
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
|
||||||
gSetting_KILLED = (Data[2] < 2) ? Data[2] : false;
|
|
||||||
#endif
|
|
||||||
gSetting_200TX = (Data[3] < 2) ? Data[3] : false;
|
|
||||||
gSetting_500TX = (Data[4] < 2) ? Data[4] : false;
|
|
||||||
gSetting_350EN = (Data[5] < 2) ? Data[5] : true;
|
|
||||||
gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true;
|
|
||||||
//gSetting_TX_EN = (Data[7] & (1u << 0)) ? true : false;
|
|
||||||
gSetting_live_DTMF_decoder = (Data[7] & (1u << 1)) ? true : false;
|
|
||||||
gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2;
|
|
||||||
#ifdef ENABLE_AUDIO_BAR
|
|
||||||
gSetting_mic_bar = (Data[7] & (1u << 4)) ? true : false;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_AM_FIX
|
|
||||||
gSetting_AM_fix = (Data[7] & (1u << 5)) ? true : false;
|
|
||||||
#endif
|
|
||||||
gSetting_backlight_on_tx_rx = (Data[7] >> 6) & 3u;
|
|
||||||
|
|
||||||
if (!gEeprom.VFO_OPEN)
|
|
||||||
{
|
|
||||||
gEeprom.ScreenChannel[0] = gEeprom.MrChannel[0];
|
|
||||||
gEeprom.ScreenChannel[1] = gEeprom.MrChannel[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 0D60..0E27
|
|
||||||
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
|
|
||||||
EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey));
|
|
||||||
bHasCustomAesKey = false;
|
|
||||||
for (i = 0; i < ARRAY_SIZE(gCustomAesKey); i++)
|
|
||||||
{
|
|
||||||
if (gCustomAesKey[i] != 0xFFFFFFFFu)
|
|
||||||
{
|
|
||||||
bHasCustomAesKey = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BOARD_EEPROM_LoadCalibration(void)
|
|
||||||
{
|
|
||||||
// uint8_t Mic;
|
|
||||||
|
|
||||||
EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[3], 8);
|
|
||||||
memcpy(gEEPROM_RSSI_CALIB[4], gEEPROM_RSSI_CALIB[3], 8);
|
|
||||||
memcpy(gEEPROM_RSSI_CALIB[5], gEEPROM_RSSI_CALIB[3], 8);
|
|
||||||
memcpy(gEEPROM_RSSI_CALIB[6], gEEPROM_RSSI_CALIB[3], 8);
|
|
||||||
|
|
||||||
EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[0], 8);
|
|
||||||
memcpy(gEEPROM_RSSI_CALIB[1], gEEPROM_RSSI_CALIB[0], 8);
|
|
||||||
memcpy(gEEPROM_RSSI_CALIB[2], gEEPROM_RSSI_CALIB[0], 8);
|
|
||||||
|
|
||||||
EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12);
|
|
||||||
if (gBatteryCalibration[0] >= 5000)
|
|
||||||
{
|
|
||||||
gBatteryCalibration[0] = 1900;
|
|
||||||
gBatteryCalibration[1] = 2000;
|
|
||||||
}
|
|
||||||
gBatteryCalibration[5] = 2300;
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
EEPROM_ReadBuffer(0x1F50 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX1_THRESHOLD, 2);
|
|
||||||
EEPROM_ReadBuffer(0x1F68 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX0_THRESHOLD, 2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//EEPROM_ReadBuffer(0x1F80 + gEeprom.MIC_SENSITIVITY, &Mic, 1);
|
|
||||||
//gEeprom.MIC_SENSITIVITY_TUNING = (Mic < 32) ? Mic : 15;
|
|
||||||
gEeprom.MIC_SENSITIVITY_TUNING = gMicGain_dB2[gEeprom.MIC_SENSITIVITY];
|
|
||||||
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
int16_t BK4819_XtalFreqLow;
|
|
||||||
uint16_t EEPROM_1F8A;
|
|
||||||
uint16_t EEPROM_1F8C;
|
|
||||||
uint8_t VOLUME_GAIN;
|
|
||||||
uint8_t DAC_GAIN;
|
|
||||||
} __attribute__((packed)) Misc;
|
|
||||||
|
|
||||||
// radio 1 .. 04 00 46 00 50 00 2C 0E
|
|
||||||
// radio 2 .. 05 00 46 00 50 00 2C 0E
|
|
||||||
EEPROM_ReadBuffer(0x1F88, &Misc, 8);
|
|
||||||
|
|
||||||
gEeprom.BK4819_XTAL_FREQ_LOW = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) ? Misc.BK4819_XtalFreqLow : 0;
|
|
||||||
gEEPROM_1F8A = Misc.EEPROM_1F8A & 0x01FF;
|
|
||||||
gEEPROM_1F8C = Misc.EEPROM_1F8C & 0x01FF;
|
|
||||||
gEeprom.VOLUME_GAIN = (Misc.VOLUME_GAIN < 64) ? Misc.VOLUME_GAIN : 58;
|
|
||||||
gEeprom.DAC_GAIN = (Misc.DAC_GAIN < 16) ? Misc.DAC_GAIN : 8;
|
|
||||||
|
|
||||||
BK4819_WriteRegister(BK4819_REG_3B, 22656 + gEeprom.BK4819_XTAL_FREQ_LOW);
|
|
||||||
// BK4819_WriteRegister(BK4819_REG_3C, gEeprom.BK4819_XTAL_FREQ_HIGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t BOARD_fetchChannelFrequency(const int channel)
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
uint32_t frequency;
|
|
||||||
uint32_t offset;
|
|
||||||
} __attribute__((packed)) info;
|
|
||||||
|
|
||||||
EEPROM_ReadBuffer(channel * 16, &info, sizeof(info));
|
|
||||||
|
|
||||||
return info.frequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BOARD_fetchChannelName(char *s, const int channel)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (s == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
memset(s, 0, 11); // 's' had better be large enough !
|
|
||||||
|
|
||||||
if (channel < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!RADIO_CheckValidChannel(channel, false, 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
EEPROM_ReadBuffer(0x0F50 + (channel * 16), s + 0, 8);
|
|
||||||
EEPROM_ReadBuffer(0x0F58 + (channel * 16), s + 8, 2);
|
|
||||||
|
|
||||||
for (i = 0; i < 10; i++)
|
|
||||||
if (s[i] < 32 || s[i] > 127)
|
|
||||||
break; // invalid char
|
|
||||||
|
|
||||||
s[i--] = 0; // null term
|
|
||||||
|
|
||||||
while (i >= 0 && s[i] == 32) // trim trailing spaces
|
|
||||||
s[i--] = 0; // null term
|
|
||||||
}
|
|
||||||
|
|
||||||
void BOARD_FactoryReset(bool bIsAll)
|
|
||||||
{
|
|
||||||
uint16_t i;
|
|
||||||
uint8_t Template[8];
|
|
||||||
|
|
||||||
memset(Template, 0xFF, sizeof(Template));
|
|
||||||
|
|
||||||
for (i = 0x0C80; i < 0x1E00; i += 8)
|
|
||||||
{
|
|
||||||
if (
|
|
||||||
!(i >= 0x0EE0 && i < 0x0F18) && // ANI ID + DTMF codes
|
|
||||||
!(i >= 0x0F30 && i < 0x0F50) && // AES KEY + F LOCK + Scramble Enable
|
|
||||||
!(i >= 0x1C00 && i < 0x1E00) && // DTMF contacts
|
|
||||||
!(i >= 0x0EB0 && i < 0x0ED0) && // Welcome strings
|
|
||||||
!(i >= 0x0EA0 && i < 0x0EA8) && // Voice Prompt
|
|
||||||
(bIsAll ||
|
|
||||||
(
|
|
||||||
!(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes
|
|
||||||
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
|
|
||||||
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names
|
|
||||||
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
|
|
||||||
!(i >= 0x0E88 && i < 0x0E90) // FM settings
|
|
||||||
))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EEPROM_WriteBuffer(i, Template);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bIsAll)
|
|
||||||
{
|
|
||||||
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_FIRST + BAND6_400MHz, 43350000);
|
|
||||||
|
|
||||||
// set the first few memory channels
|
|
||||||
for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++)
|
|
||||||
{
|
|
||||||
const uint32_t Frequency = gDefaultFrequencyTable[i];
|
|
||||||
gRxVfo->freq_config_RX.Frequency = Frequency;
|
|
||||||
gRxVfo->freq_config_TX.Frequency = Frequency;
|
|
||||||
gRxVfo->Band = FREQUENCY_GetBand(Frequency);
|
|
||||||
SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
5
board.h
@@ -26,11 +26,6 @@ void BOARD_PORTCON_Init(void);
|
|||||||
void BOARD_ADC_Init(void);
|
void BOARD_ADC_Init(void);
|
||||||
void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent);
|
void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent);
|
||||||
void BOARD_Init(void);
|
void BOARD_Init(void);
|
||||||
void BOARD_EEPROM_Init(void);
|
|
||||||
void BOARD_EEPROM_LoadCalibration(void);
|
|
||||||
uint32_t BOARD_fetchChannelFrequency(const int channel);
|
|
||||||
void BOARD_fetchChannelName(char *s, const int channel);
|
|
||||||
void BOARD_FactoryReset(bool bIsAll);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
36
debugging.h
@@ -1,18 +1,48 @@
|
|||||||
#ifndef DEBUGGING_H
|
#ifndef DEBUGGING_H
|
||||||
#define DEBUGGING_H
|
#define DEBUGGING_H
|
||||||
|
|
||||||
|
#ifdef ENABLE_UART
|
||||||
|
|
||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
|
#include "driver/bk4819.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "external/printf/printf.h"
|
#include "external/printf/printf.h"
|
||||||
|
#include "am_fix.h"
|
||||||
|
|
||||||
|
static inline void LogUart(const char *const str)
|
||||||
static inline void LogUart(char * str)
|
|
||||||
{
|
{
|
||||||
UART_Send(str, strlen(str));
|
UART_Send(str, strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void LogUartf(const char* format, ...)
|
||||||
|
{
|
||||||
|
char buffer[128];
|
||||||
|
va_list va;
|
||||||
|
va_start(va, format);
|
||||||
|
vsnprintf(buffer, (size_t)-1, format, va);
|
||||||
|
va_end(va);
|
||||||
|
UART_Send(buffer, strlen(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void LogRegUart(uint16_t reg)
|
||||||
|
{
|
||||||
|
uint16_t regVal = BK4819_ReadRegister(reg);
|
||||||
|
char buf[32];
|
||||||
|
sprintf(buf, "reg%02X: %04X\n", reg, regVal);
|
||||||
|
LogUart(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void LogPrint()
|
||||||
|
{
|
||||||
|
uint16_t rssi = BK4819_GetRSSI();
|
||||||
|
uint16_t reg7e = BK4819_ReadRegister(0x7E);
|
||||||
|
char buf[32];
|
||||||
|
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", (reg7e >> 15),
|
||||||
|
(reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111,
|
||||||
|
(reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
|
||||||
|
LogUart(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
// this is decremented once every 500ms
|
// this is decremented once every 500ms
|
||||||
uint16_t gBacklightCountdown = 0;
|
uint16_t gBacklightCountdown_500ms = 0;
|
||||||
bool backlightOn;
|
bool backlightOn;
|
||||||
|
|
||||||
void BACKLIGHT_InitHardware()
|
void BACKLIGHT_InitHardware()
|
||||||
@@ -54,42 +54,30 @@ void BACKLIGHT_InitHardware()
|
|||||||
|
|
||||||
void BACKLIGHT_TurnOn(void)
|
void BACKLIGHT_TurnOn(void)
|
||||||
{
|
{
|
||||||
if (gEeprom.BACKLIGHT_TIME != 0) {
|
if (gEeprom.BACKLIGHT_TIME == 0) {
|
||||||
backlightOn = true;
|
|
||||||
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MAX);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
BACKLIGHT_TurnOff();
|
BACKLIGHT_TurnOff();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (gEeprom.BACKLIGHT_TIME)
|
backlightOn = true;
|
||||||
{
|
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MAX);
|
||||||
|
|
||||||
|
switch (gEeprom.BACKLIGHT_TIME) {
|
||||||
default:
|
default:
|
||||||
case 1: // 5 sec
|
case 1: // 5 sec
|
||||||
gBacklightCountdown = 5;
|
|
||||||
break;
|
|
||||||
case 2: // 10 sec
|
case 2: // 10 sec
|
||||||
gBacklightCountdown = 10;
|
|
||||||
break;
|
|
||||||
case 3: // 20 sec
|
case 3: // 20 sec
|
||||||
gBacklightCountdown = 20;
|
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 1)) * 5;
|
||||||
break;
|
break;
|
||||||
case 4: // 1 min
|
case 4: // 1 min
|
||||||
gBacklightCountdown = 60;
|
|
||||||
break;
|
|
||||||
case 5: // 2 min
|
case 5: // 2 min
|
||||||
gBacklightCountdown = 60 * 2;
|
|
||||||
break;
|
|
||||||
case 6: // 4 min
|
case 6: // 4 min
|
||||||
gBacklightCountdown = 60 * 4;
|
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 4)) * 60;
|
||||||
break;
|
break;
|
||||||
case 7: // always on
|
case 7: // always on
|
||||||
gBacklightCountdown = 0;
|
gBacklightCountdown_500ms = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gBacklightCountdown *= 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BACKLIGHT_TurnOff()
|
void BACKLIGHT_TurnOff()
|
||||||
@@ -106,7 +94,7 @@ void BACKLIGHT_TurnOff()
|
|||||||
#else
|
#else
|
||||||
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MIN);
|
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MIN);
|
||||||
#endif
|
#endif
|
||||||
gBacklightCountdown = 0;
|
gBacklightCountdown_500ms = 0;
|
||||||
backlightOn = false;
|
backlightOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,8 +103,16 @@ bool BACKLIGHT_IsOn()
|
|||||||
return backlightOn;
|
return backlightOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t currentBrightness;
|
||||||
|
|
||||||
void BACKLIGHT_SetBrightness(uint8_t brigtness)
|
void BACKLIGHT_SetBrightness(uint8_t brigtness)
|
||||||
{
|
{
|
||||||
|
currentBrightness = brigtness;
|
||||||
PWM_PLUS0_CH0_COMP = (1 << brigtness) - 1;
|
PWM_PLUS0_CH0_COMP = (1 << brigtness) - 1;
|
||||||
//PWM_PLUS0_SWLOAD = 1;
|
//PWM_PLUS0_SWLOAD = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t BACKLIGHT_GetBrightness(void)
|
||||||
|
{
|
||||||
|
return currentBrightness;
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
extern uint16_t gBacklightCountdown;
|
extern uint16_t gBacklightCountdown_500ms;
|
||||||
extern uint8_t gBacklightBrightness;
|
extern uint8_t gBacklightBrightness;
|
||||||
|
|
||||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||||
@@ -36,6 +36,6 @@ void BACKLIGHT_TurnOn();
|
|||||||
void BACKLIGHT_TurnOff();
|
void BACKLIGHT_TurnOff();
|
||||||
bool BACKLIGHT_IsOn();
|
bool BACKLIGHT_IsOn();
|
||||||
void BACKLIGHT_SetBrightness(uint8_t brigtness);
|
void BACKLIGHT_SetBrightness(uint8_t brigtness);
|
||||||
|
uint8_t BACKLIGHT_GetBrightness(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -39,16 +39,19 @@ static bool gIsInitBK1080;
|
|||||||
uint16_t BK1080_BaseFrequency;
|
uint16_t BK1080_BaseFrequency;
|
||||||
uint16_t BK1080_FrequencyDeviation;
|
uint16_t BK1080_FrequencyDeviation;
|
||||||
|
|
||||||
void BK1080_Init(uint16_t Frequency, bool bDoScan)
|
void BK1080_Init0(void)
|
||||||
|
{
|
||||||
|
BK1080_Init(0,0/*,0*/);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BK1080_Init(uint16_t freq, uint8_t band/*, uint8_t space*/)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (bDoScan)
|
if (freq) {
|
||||||
{
|
|
||||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
||||||
|
|
||||||
if (!gIsInitBK1080)
|
if (!gIsInitBK1080) {
|
||||||
{
|
|
||||||
for (i = 0; i < ARRAY_SIZE(BK1080_RegisterTable); i++)
|
for (i = 0; i < ARRAY_SIZE(BK1080_RegisterTable); i++)
|
||||||
BK1080_WriteRegister(i, BK1080_RegisterTable[i]);
|
BK1080_WriteRegister(i, BK1080_RegisterTable[i]);
|
||||||
|
|
||||||
@@ -61,20 +64,14 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
|
|||||||
|
|
||||||
gIsInitBK1080 = true;
|
gIsInitBK1080 = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201);
|
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201);
|
||||||
}
|
}
|
||||||
|
|
||||||
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A5F);
|
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A1F);
|
||||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
|
BK1080_SetFrequency(freq, band/*, space*/);
|
||||||
|
|
||||||
SYSTEM_DelayMs(10);
|
|
||||||
|
|
||||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | 0x8000);
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0241);
|
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0241);
|
||||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
||||||
}
|
}
|
||||||
@@ -108,11 +105,22 @@ void BK1080_Mute(bool Mute)
|
|||||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, Mute ? 0x4201 : 0x0201);
|
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, Mute ? 0x4201 : 0x0201);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK1080_SetFrequency(uint16_t Frequency)
|
void BK1080_SetFrequency(uint16_t frequency, uint8_t band/*, uint8_t space*/)
|
||||||
{
|
{
|
||||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
|
//uint8_t spacings[] = {20,10,5};
|
||||||
|
//space %= 3;
|
||||||
|
|
||||||
|
uint16_t channel = (frequency - BK1080_GetFreqLoLimit(band))/* * 10 / spacings[space]*/;
|
||||||
|
|
||||||
|
uint16_t regval = BK1080_ReadRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2);
|
||||||
|
regval = (regval & ~(0b11 << 6)) | ((band & 0b11) << 6);
|
||||||
|
//regval = (regval & ~(0b11 << 4)) | ((space & 0b11) << 4);
|
||||||
|
|
||||||
|
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, regval);
|
||||||
|
|
||||||
|
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel);
|
||||||
SYSTEM_DelayMs(10);
|
SYSTEM_DelayMs(10);
|
||||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | 0x8000);
|
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel | 0x8000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK1080_GetFrequencyDeviation(uint16_t Frequency)
|
void BK1080_GetFrequencyDeviation(uint16_t Frequency)
|
||||||
@@ -120,3 +128,17 @@ void BK1080_GetFrequencyDeviation(uint16_t Frequency)
|
|||||||
BK1080_BaseFrequency = Frequency;
|
BK1080_BaseFrequency = Frequency;
|
||||||
BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) / 16;
|
BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) / 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t BK1080_GetFreqLoLimit(uint8_t band)
|
||||||
|
{
|
||||||
|
uint16_t lim[] = {875, 760, 760, 640};
|
||||||
|
return lim[band % 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t BK1080_GetFreqHiLimit(uint8_t band)
|
||||||
|
{
|
||||||
|
band %= 4;
|
||||||
|
uint16_t lim[] = {1080, 1080, 900, 760};
|
||||||
|
return lim[band % 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,14 @@
|
|||||||
extern uint16_t BK1080_BaseFrequency;
|
extern uint16_t BK1080_BaseFrequency;
|
||||||
extern uint16_t BK1080_FrequencyDeviation;
|
extern uint16_t BK1080_FrequencyDeviation;
|
||||||
|
|
||||||
void BK1080_Init(uint16_t Frequency, bool bDoScan);
|
void BK1080_Init0(void);
|
||||||
|
void BK1080_Init(uint16_t Frequency, uint8_t band/*, uint8_t space*/);
|
||||||
uint16_t BK1080_ReadRegister(BK1080_Register_t Register);
|
uint16_t BK1080_ReadRegister(BK1080_Register_t Register);
|
||||||
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
|
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
|
||||||
void BK1080_Mute(bool Mute);
|
void BK1080_Mute(bool Mute);
|
||||||
void BK1080_SetFrequency(uint16_t Frequency);
|
uint16_t BK1080_GetFreqLoLimit(uint8_t band);
|
||||||
|
uint16_t BK1080_GetFreqHiLimit(uint8_t band);
|
||||||
|
void BK1080_SetFrequency(uint16_t frequency, uint8_t band/*, uint8_t space*/);
|
||||||
void BK1080_GetFrequencyDeviation(uint16_t Frequency);
|
void BK1080_GetFrequencyDeviation(uint16_t Frequency);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#ifndef BK4819_REGS_H
|
#ifndef BK4819_REGS_H
|
||||||
#define BK4819_REGS_H
|
#define BK4819_REGS_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
@@ -41,10 +42,15 @@ enum BK4819_REGISTER_t {
|
|||||||
BK4819_REG_0C = 0x0CU,
|
BK4819_REG_0C = 0x0CU,
|
||||||
BK4819_REG_0D = 0x0DU,
|
BK4819_REG_0D = 0x0DU,
|
||||||
BK4819_REG_0E = 0x0EU,
|
BK4819_REG_0E = 0x0EU,
|
||||||
|
// RX AGC Gain Table[0]
|
||||||
BK4819_REG_10 = 0x10U,
|
BK4819_REG_10 = 0x10U,
|
||||||
|
// RX AGC Gain Table[1]
|
||||||
BK4819_REG_11 = 0x11U,
|
BK4819_REG_11 = 0x11U,
|
||||||
|
// RX AGC Gain Table[2]
|
||||||
BK4819_REG_12 = 0x12U,
|
BK4819_REG_12 = 0x12U,
|
||||||
|
// RX AGC Gain Table[3]
|
||||||
BK4819_REG_13 = 0x13U,
|
BK4819_REG_13 = 0x13U,
|
||||||
|
// RX AGC Gain Table[-1]
|
||||||
BK4819_REG_14 = 0x14U,
|
BK4819_REG_14 = 0x14U,
|
||||||
BK4819_REG_19 = 0x19U,
|
BK4819_REG_19 = 0x19U,
|
||||||
BK4819_REG_1F = 0x1FU,
|
BK4819_REG_1F = 0x1FU,
|
||||||
@@ -72,6 +78,12 @@ enum BK4819_REGISTER_t {
|
|||||||
BK4819_REG_46 = 0x46U,
|
BK4819_REG_46 = 0x46U,
|
||||||
BK4819_REG_47 = 0x47U,
|
BK4819_REG_47 = 0x47U,
|
||||||
BK4819_REG_48 = 0x48U,
|
BK4819_REG_48 = 0x48U,
|
||||||
|
// REG_49<15:14> 0b00; High/Low Lo selection:
|
||||||
|
// 0X: Auto High/Low Lo
|
||||||
|
// 10: Low Lo
|
||||||
|
// 11: High Lo
|
||||||
|
// REG_49<13:7> 0x50; RF AGC high threshold, 1 dB/LSB
|
||||||
|
// REG_49<6:0> 0x30; RF AGC low threshold, 1 dB/LSB
|
||||||
BK4819_REG_49 = 0x49U,
|
BK4819_REG_49 = 0x49U,
|
||||||
BK4819_REG_4D = 0x4DU,
|
BK4819_REG_4D = 0x4DU,
|
||||||
BK4819_REG_4E = 0x4EU,
|
BK4819_REG_4E = 0x4EU,
|
||||||
@@ -100,9 +112,22 @@ enum BK4819_REGISTER_t {
|
|||||||
BK4819_REG_78 = 0x78U,
|
BK4819_REG_78 = 0x78U,
|
||||||
BK4819_REG_79 = 0x79U,
|
BK4819_REG_79 = 0x79U,
|
||||||
BK4819_REG_7A = 0x7AU,
|
BK4819_REG_7A = 0x7AU,
|
||||||
|
// REG_7B<15:0> 0xae34 RSSI table
|
||||||
BK4819_REG_7B = 0x7BU,
|
BK4819_REG_7B = 0x7BU,
|
||||||
|
// REG_7C<15:0> 0x8000 RSSI table
|
||||||
BK4819_REG_7C = 0x7CU,
|
BK4819_REG_7C = 0x7CU,
|
||||||
BK4819_REG_7D = 0x7DU,
|
BK4819_REG_7D = 0x7DU,
|
||||||
|
// REG_7E<15> 0; AGC fix mode:
|
||||||
|
// 1: Fix
|
||||||
|
// 0: Auto
|
||||||
|
// REG_7E<14:12> 0b011; AGC fix index:
|
||||||
|
// 011: Max.
|
||||||
|
// …
|
||||||
|
// 100: Min.
|
||||||
|
// REG_7E<5:3> 0b101; DC filter bandwidth for TX (MIC in):
|
||||||
|
// 000: Bypass DC filter
|
||||||
|
// REG_7E<2:0> 0b110; DC filter bandwidth for RX (IF in):
|
||||||
|
// 000: Bypass DC filter
|
||||||
BK4819_REG_7E = 0x7EU,
|
BK4819_REG_7E = 0x7EU,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -363,4 +388,3 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
408
driver/bk4819.c
@@ -14,15 +14,20 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h> // NULL
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include "../audio.h"
|
||||||
|
#include "../bsp/dp32g030/gpio.h"
|
||||||
|
#include "../bsp/dp32g030/portcon.h"
|
||||||
|
|
||||||
#include "audio.h"
|
|
||||||
#include "bk4819.h"
|
#include "bk4819.h"
|
||||||
#include "bsp/dp32g030/gpio.h"
|
#include "gpio.h"
|
||||||
#include "bsp/dp32g030/portcon.h"
|
#include "system.h"
|
||||||
#include "driver/gpio.h"
|
#include "systick.h"
|
||||||
#include "driver/system.h"
|
|
||||||
#include "driver/systick.h"
|
|
||||||
|
|
||||||
#ifndef ARRAY_SIZE
|
#ifndef ARRAY_SIZE
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||||
@@ -55,8 +60,8 @@ void BK4819_Init(void)
|
|||||||
BK4819_WriteRegister(BK4819_REG_37, 0x1D0F);
|
BK4819_WriteRegister(BK4819_REG_37, 0x1D0F);
|
||||||
BK4819_WriteRegister(BK4819_REG_36, 0x0022);
|
BK4819_WriteRegister(BK4819_REG_36, 0x0022);
|
||||||
|
|
||||||
BK4819_DisableAGC();
|
BK4819_InitAGC(false);
|
||||||
// BK4819_EnableAGC();
|
BK4819_SetAGC(true);
|
||||||
|
|
||||||
BK4819_WriteRegister(BK4819_REG_19, 0b0001000001000001); // <15> MIC AGC 1 = disable 0 = enable
|
BK4819_WriteRegister(BK4819_REG_19, 0b0001000001000001); // <15> MIC AGC 1 = disable 0 = enable
|
||||||
|
|
||||||
@@ -127,7 +132,6 @@ static uint16_t BK4819_ReadU16(void)
|
|||||||
PORTCON_PORTC_IE = (PORTCON_PORTC_IE & ~PORTCON_PORTC_IE_C2_MASK) | PORTCON_PORTC_IE_C2_BITS_ENABLE;
|
PORTCON_PORTC_IE = (PORTCON_PORTC_IE & ~PORTCON_PORTC_IE_C2_MASK) | PORTCON_PORTC_IE_C2_BITS_ENABLE;
|
||||||
GPIOC->DIR = (GPIOC->DIR & ~GPIO_DIR_2_MASK) | GPIO_DIR_2_BITS_INPUT;
|
GPIOC->DIR = (GPIOC->DIR & ~GPIO_DIR_2_MASK) | GPIO_DIR_2_BITS_INPUT;
|
||||||
SYSTICK_DelayUs(1);
|
SYSTICK_DelayUs(1);
|
||||||
|
|
||||||
Value = 0;
|
Value = 0;
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
@@ -236,19 +240,46 @@ void BK4819_WriteU16(uint16_t Data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_DisableAGC()
|
void BK4819_SetAGC(bool enable)
|
||||||
{
|
{
|
||||||
// REG_10
|
uint16_t regVal = BK4819_ReadRegister(BK4819_REG_7E);
|
||||||
|
if(!(regVal & (1 << 15)) == enable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BK4819_WriteRegister(BK4819_REG_7E, (regVal & ~(1 << 15) & ~(0b111 << 12))
|
||||||
|
| (!enable << 15) // 0 AGC fix mode
|
||||||
|
| (3u << 12) // 3 AGC fix index
|
||||||
|
);
|
||||||
|
|
||||||
|
// if(enable) {
|
||||||
|
// BK4819_WriteRegister(BK4819_REG_7B, 0x8420);
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// BK4819_WriteRegister(BK4819_REG_7B, 0x318C);
|
||||||
|
|
||||||
|
// BK4819_WriteRegister(BK4819_REG_7C, 0x595E);
|
||||||
|
// BK4819_WriteRegister(BK4819_REG_20, 0x8DEF);
|
||||||
|
|
||||||
|
// for (uint8_t i = 0; i < 8; i++) {
|
||||||
|
// //BK4819_WriteRegister(BK4819_REG_06, ((i << 13) | 0x2500u) + 0x036u);
|
||||||
|
// BK4819_WriteRegister(BK4819_REG_06, (i & 7) << 13 | 0x4A << 7 | 0x36);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void BK4819_InitAGC(bool amModulation)
|
||||||
|
{
|
||||||
|
// REG_10, REG_11, REG_12 REG_13, REG_14
|
||||||
//
|
//
|
||||||
// 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1)
|
// Rx AGC Gain Table[]. (Index Max->Min is 3,2,1,0,-1)
|
||||||
//
|
//
|
||||||
// <15:10> ???
|
// <15:10> ???
|
||||||
//
|
//
|
||||||
// <9:8> LNA Gain Short
|
// <9:8> LNA Gain Short
|
||||||
// 3 = 0dB <<<
|
// 3 = 0dB <<< 1o11 read from spectrum reference manual
|
||||||
// 2 = -24dB // was -11
|
// 2 = -24dB -19 -11
|
||||||
// 1 = -30dB // was -16
|
// 1 = -30dB -24 -16
|
||||||
// 0 = -33dB // was -19
|
// 0 = -33dB -28 -19
|
||||||
//
|
//
|
||||||
// <7:5> LNA Gain
|
// <7:5> LNA Gain
|
||||||
// 7 = 0dB
|
// 7 = 0dB
|
||||||
@@ -276,74 +307,60 @@ void BK4819_DisableAGC()
|
|||||||
// 1 = -27dB
|
// 1 = -27dB
|
||||||
// 0 = -33dB
|
// 0 = -33dB
|
||||||
//
|
//
|
||||||
BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (5u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110
|
|
||||||
|
|
||||||
BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 000000 11 011 11 011
|
BK4819_WriteRegister(BK4819_REG_13, 0x03BE); // 0x03BE / 000000 11 101 11 110 / -7dB
|
||||||
BK4819_WriteRegister(BK4819_REG_11, 0x027B); // 000000 10 011 11 011
|
BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 0x037B / 000000 11 011 11 011 / -24dB
|
||||||
BK4819_WriteRegister(BK4819_REG_10, 0x007A); // 000000 00 011 11 010
|
BK4819_WriteRegister(BK4819_REG_11, 0x027B); // 0x027B / 000000 10 011 11 011 / -43dB
|
||||||
BK4819_WriteRegister(BK4819_REG_14, 0x0019); // 000000 00 000 11 001
|
BK4819_WriteRegister(BK4819_REG_10, 0x007A); // 0x007A / 000000 00 011 11 010 / -58dB
|
||||||
|
if(amModulation) {
|
||||||
|
BK4819_WriteRegister(BK4819_REG_14, 0x0000);
|
||||||
|
BK4819_WriteRegister(BK4819_REG_49, (0 << 14) | (50 << 7) | (32 << 0));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
BK4819_WriteRegister(BK4819_REG_14, 0x0019); // 0x0019 / 000000 00 000 11 001 / -79dB
|
||||||
|
BK4819_WriteRegister(BK4819_REG_49, (0 << 14) | (84 << 7) | (56 << 0)); //0x2A38 / 00 1010100 0111000 / 84, 56
|
||||||
|
}
|
||||||
|
|
||||||
BK4819_WriteRegister(BK4819_REG_49, 0x2A38);
|
|
||||||
BK4819_WriteRegister(BK4819_REG_7B, 0x8420);
|
BK4819_WriteRegister(BK4819_REG_7B, 0x8420);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_EnableAGC()
|
int8_t BK4819_GetRxGain_dB(void)
|
||||||
{
|
{
|
||||||
// REG_10
|
union {
|
||||||
//
|
struct {
|
||||||
// 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1)
|
uint16_t pga:3;
|
||||||
//
|
uint16_t mixer:2;
|
||||||
// (15:10> ???
|
uint16_t lna:3;
|
||||||
//
|
uint16_t lnaS:2;
|
||||||
// <9:8> LNA Gain Short
|
};
|
||||||
// 3 = 0dB << original
|
uint16_t __raw;
|
||||||
// 2 = -24dB // was -11
|
} agcGainReg;
|
||||||
// 1 = -30dB // was -16
|
|
||||||
// 0 = -33dB // was -19
|
|
||||||
//
|
|
||||||
// <7:5> LNA Gain
|
|
||||||
// 7 = 0dB
|
|
||||||
// 6 = -2dB
|
|
||||||
// 5 = -4dB
|
|
||||||
// 4 = -6dB
|
|
||||||
// 3 = -9dB
|
|
||||||
// 2 = -14dB << original
|
|
||||||
// 1 = -19dB
|
|
||||||
// 0 = -24dB
|
|
||||||
//
|
|
||||||
// <4:3> MIXER Gain
|
|
||||||
// 3 = 0dB << original
|
|
||||||
// 2 = -3dB
|
|
||||||
// 1 = -6dB
|
|
||||||
// 0 = -8dB
|
|
||||||
//
|
|
||||||
// <2:0> PGA Gain
|
|
||||||
// 7 = 0dB
|
|
||||||
// 6 = -3dB << original
|
|
||||||
// 5 = -6dB
|
|
||||||
// 4 = -9dB
|
|
||||||
// 3 = -15dB
|
|
||||||
// 2 = -21dB
|
|
||||||
// 1 = -27dB
|
|
||||||
// 0 = -33dB
|
|
||||||
//
|
|
||||||
BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (5u << 5) | (3u << 3) | (6u << 0));
|
|
||||||
|
|
||||||
BK4819_WriteRegister(BK4819_REG_12, 0x037C); // 000000 11 011 11 100
|
union {
|
||||||
BK4819_WriteRegister(BK4819_REG_11, 0x027B); // 000000 10 011 11 011
|
struct {
|
||||||
BK4819_WriteRegister(BK4819_REG_10, 0x007A); // 000000 00 011 11 010
|
uint16_t _ : 5;
|
||||||
BK4819_WriteRegister(BK4819_REG_14, 0x0018); // 000000 00 000 11 000
|
uint16_t agcSigStrength : 7;
|
||||||
|
int16_t gainIdx : 3;
|
||||||
|
uint16_t agcEnab : 1;
|
||||||
|
};
|
||||||
|
uint16_t __raw;
|
||||||
|
} reg7e;
|
||||||
|
|
||||||
BK4819_WriteRegister(BK4819_REG_49, 0x2A38);
|
reg7e.__raw = BK4819_ReadRegister(BK4819_REG_7E);
|
||||||
BK4819_WriteRegister(BK4819_REG_7B, 0x318C);
|
uint8_t gainAddr = reg7e.gainIdx < 0 ? BK4819_REG_14 : BK4819_REG_10 + reg7e.gainIdx;
|
||||||
|
agcGainReg.__raw = BK4819_ReadRegister(gainAddr);
|
||||||
BK4819_WriteRegister(BK4819_REG_7C, 0x595E);
|
int8_t lnaShortTab[] = {-28, -24, -19, 0};
|
||||||
BK4819_WriteRegister(BK4819_REG_20, 0x8DEF);
|
int8_t lnaTab[] = {-24, -19, -14, -9, -6, -4, -2, 0};
|
||||||
|
int8_t mixerTab[] = {-8, -6, -3, 0};
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
int8_t pgaTab[] = {-33, -27, -21, -15, -9, -6, -3, 0};
|
||||||
//BK4819_WriteRegister(BK4819_REG_06, ((i << 13) | 0x2500u) + 0x036u);
|
return lnaShortTab[agcGainReg.lnaS] + lnaTab[agcGainReg.lna] + mixerTab[agcGainReg.mixer] + pgaTab[agcGainReg.pga];
|
||||||
BK4819_WriteRegister(BK4819_REG_06, (i & 7) << 13 | 0x4A << 7 | 0x36);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t BK4819_GetRSSI_dBm(void)
|
||||||
|
{
|
||||||
|
uint16_t rssi = BK4819_GetRSSI();
|
||||||
|
return (rssi / 2) - 160;// - BK4819_GetRxGain_dB();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet)
|
void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet)
|
||||||
@@ -591,89 +608,54 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b
|
|||||||
//
|
//
|
||||||
// <1:0> 0 ???
|
// <1:0> 0 ???
|
||||||
|
|
||||||
uint16_t val;
|
uint16_t val = 0;
|
||||||
|
|
||||||
switch (Bandwidth)
|
switch (Bandwidth)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case BK4819_FILTER_BW_WIDE: // 25kHz
|
case BK4819_FILTER_BW_WIDE: // 25kHz
|
||||||
if (weak_no_different)
|
val = (4u << 12) | // *3 RF filter bandwidth
|
||||||
{ // make the RX bandwidth the same with weak signals
|
|
||||||
val =
|
|
||||||
(0u << 15) | // 0
|
|
||||||
(4u << 12) | // *3 RF filter bandwidth
|
|
||||||
(4u << 9) | // *0 RF filter bandwidth when signal is weak
|
|
||||||
(6u << 6) | // *0 AFTxLPF2 filter Band Width
|
(6u << 6) | // *0 AFTxLPF2 filter Band Width
|
||||||
(2u << 4) | // 2 BW Mode Selection
|
(2u << 4) | // 2 BW Mode Selection
|
||||||
(1u << 3) | // 1
|
(1u << 3) | // 1
|
||||||
(0u << 2) | // 0 Gain after FM Demodulation
|
(0u << 2); // 0 Gain after FM Demodulation
|
||||||
(0u << 0); // 0
|
|
||||||
}
|
if (weak_no_different) {
|
||||||
else
|
// make the RX bandwidth the same with weak signals
|
||||||
{ // with weak RX signals the RX bandwidth is reduced
|
val |= (4u << 9); // *0 RF filter bandwidth when signal is weak
|
||||||
val = // 0x3028); // 0 011 000 000 10 1 0 00
|
} else {
|
||||||
(0u << 15) | // 0
|
/// with weak RX signals the RX bandwidth is reduced
|
||||||
(4u << 12) | // *3 RF filter bandwidth
|
val |= (2u << 9); // *0 RF filter bandwidth when signal is weak
|
||||||
(2u << 9) | // *0 RF filter bandwidth when signal is weak
|
|
||||||
(6u << 6) | // *0 AFTxLPF2 filter Band Width
|
|
||||||
(2u << 4) | // 2 BW Mode Selection
|
|
||||||
(1u << 3) | // 1
|
|
||||||
(0u << 2) | // 0 Gain after FM Demodulation
|
|
||||||
(0u << 0); // 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BK4819_FILTER_BW_NARROW: // 12.5kHz
|
case BK4819_FILTER_BW_NARROW: // 12.5kHz
|
||||||
if (weak_no_different)
|
val = (4u << 12) | // *4 RF filter bandwidth
|
||||||
{
|
|
||||||
val =
|
|
||||||
(0u << 15) | // 0
|
|
||||||
(4u << 12) | // *4 RF filter bandwidth
|
|
||||||
(4u << 9) | // *0 RF filter bandwidth when signal is weak
|
|
||||||
(0u << 6) | // *1 AFTxLPF2 filter Band Width
|
(0u << 6) | // *1 AFTxLPF2 filter Band Width
|
||||||
(0u << 4) | // 0 BW Mode Selection
|
(0u << 4) | // 0 BW Mode Selection
|
||||||
(1u << 3) | // 1
|
(1u << 3) | // 1
|
||||||
(0u << 2) | // 0 Gain after FM Demodulation
|
(0u << 2); // 0 Gain after FM Demodulation
|
||||||
(0u << 0); // 0
|
|
||||||
}
|
if (weak_no_different) {
|
||||||
else
|
val |= (4u << 9); // *0 RF filter bandwidth when signal is weak
|
||||||
{
|
} else {
|
||||||
val = // 0x4048); // 0 100 000 001 00 1 0 00
|
val |= (2u << 9);
|
||||||
(0u << 15) | // 0
|
|
||||||
(4u << 12) | // *4 RF filter bandwidth
|
|
||||||
(2u << 9) | // *0 RF filter bandwidth when signal is weak
|
|
||||||
(0u << 6) | // *1 AFTxLPF2 filter Band Width
|
|
||||||
(0u << 4) | // 0 BW Mode Selection
|
|
||||||
(1u << 3) | // 1
|
|
||||||
(0u << 2) | // 0 Gain after FM Demodulation
|
|
||||||
(0u << 0); // 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BK4819_FILTER_BW_NARROWER: // 6.25kHz
|
case BK4819_FILTER_BW_NARROWER: // 6.25kHz
|
||||||
if (weak_no_different)
|
val = (3u << 12) | // 3 RF filter bandwidth
|
||||||
{
|
|
||||||
val =
|
|
||||||
(0u << 15) | // 0
|
|
||||||
(3u << 12) | // 3 RF filter bandwidth
|
|
||||||
(3u << 9) | // *0 RF filter bandwidth when signal is weak
|
(3u << 9) | // *0 RF filter bandwidth when signal is weak
|
||||||
(1u << 6) | // 1 AFTxLPF2 filter Band Width
|
(1u << 6) | // 1 AFTxLPF2 filter Band Width
|
||||||
(1u << 4) | // 1 BW Mode Selection
|
(1u << 4) | // 1 BW Mode Selection
|
||||||
(1u << 3) | // 1
|
(1u << 3) | // 1
|
||||||
(0u << 2) | // 0 Gain after FM Demodulation
|
(0u << 2); // 0 Gain after FM Demodulation
|
||||||
(0u << 0); // 0
|
|
||||||
}
|
if (weak_no_different) {
|
||||||
else
|
val |= (3u << 9);
|
||||||
{
|
} else {
|
||||||
val =
|
val |= (0u << 9); // 0 RF filter bandwidth when signal is weak
|
||||||
(0u << 15) | // 0
|
|
||||||
(3u << 12) | // 3 RF filter bandwidth
|
|
||||||
(0u << 9) | // 0 RF filter bandwidth when signal is weak
|
|
||||||
(1u << 6) | // 1 AFTxLPF2 filter Band Width
|
|
||||||
(1u << 4) | // 1 BW Mode Selection
|
|
||||||
(1u << 3) | // 1
|
|
||||||
(0u << 2) | // 1 Gain after FM Demodulation
|
|
||||||
(0u << 0); // 0
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -699,7 +681,7 @@ void BK4819_SetupPowerAmplifier(const uint8_t bias, const uint32_t frequency)
|
|||||||
// 7 = max
|
// 7 = max
|
||||||
// 0 = min
|
// 0 = min
|
||||||
//
|
//
|
||||||
// 280MHz gain 1 = 1 gain 2 = 0 gain 1 = 4 gain 2 = 2
|
// 280MHz g1=1 g2=0 (-14.9dBm), g1=4 g2=2 (0.13dBm)
|
||||||
const uint8_t gain = (frequency < 28000000) ? (1u << 3) | (0u << 0) : (4u << 3) | (2u << 0);
|
const uint8_t gain = (frequency < 28000000) ? (1u << 3) | (0u << 0) : (4u << 3) | (2u << 0);
|
||||||
const uint8_t enable = 1;
|
const uint8_t enable = 1;
|
||||||
BK4819_WriteRegister(BK4819_REG_36, (bias << 8) | (enable << 7) | (gain << 0));
|
BK4819_WriteRegister(BK4819_REG_36, (bias << 8) | (enable << 7) | (gain << 0));
|
||||||
@@ -828,16 +810,18 @@ void BK4819_RX_TurnOn(void)
|
|||||||
// Turn off everything
|
// Turn off everything
|
||||||
BK4819_WriteRegister(BK4819_REG_30, 0);
|
BK4819_WriteRegister(BK4819_REG_30, 0);
|
||||||
|
|
||||||
// Enable VCO Calibration
|
|
||||||
// Enable RX Link
|
BK4819_WriteRegister(BK4819_REG_30,
|
||||||
// Enable AF DAC
|
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||||
// Enable PLL/VCO
|
BK4819_REG_30_DISABLE_UNKNOWN |
|
||||||
// Disable PA Gain
|
BK4819_REG_30_ENABLE_RX_LINK |
|
||||||
// Disable MIC ADC
|
BK4819_REG_30_ENABLE_AF_DAC |
|
||||||
// Disable TX DSP
|
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||||
// Enable RX DSP
|
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||||
//
|
BK4819_REG_30_DISABLE_PA_GAIN |
|
||||||
BK4819_WriteRegister(BK4819_REG_30, 0b1011111111110001); // 1 0 1111 1 1 1111 0 0 0 1
|
BK4819_REG_30_DISABLE_MIC_ADC |
|
||||||
|
BK4819_REG_30_DISABLE_TX_DSP |
|
||||||
|
BK4819_REG_30_ENABLE_RX_DSP );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_PickRXFilterPathBasedOnFrequency(uint32_t Frequency)
|
void BK4819_PickRXFilterPathBasedOnFrequency(uint32_t Frequency)
|
||||||
@@ -1130,11 +1114,15 @@ void BK4819_ExitBypass(void)
|
|||||||
// 0 ~ 7
|
// 0 ~ 7
|
||||||
// 0 = bypass DC filter
|
// 0 = bypass DC filter
|
||||||
//
|
//
|
||||||
BK4819_WriteRegister(BK4819_REG_7E, // 0x302E); // 0 011 000000 101 110
|
|
||||||
(0u << 15) | // 0 AGC fix mode
|
uint16_t regVal = BK4819_ReadRegister(BK4819_REG_7E);
|
||||||
(3u << 12) | // 3 AGC fix index
|
|
||||||
(5u << 3) | // 5 DC Filter band width for Tx (MIC In)
|
// 0x302E / 0 011 000000 101 110
|
||||||
(6u << 0)); // 6 DC Filter band width for Rx (I.F In)
|
BK4819_WriteRegister(BK4819_REG_7E, (regVal & ~(0b111 << 3))
|
||||||
|
|
||||||
|
| (5u << 3) // 5 DC Filter band width for Tx (MIC In)
|
||||||
|
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_PrepareTransmit(void)
|
void BK4819_PrepareTransmit(void)
|
||||||
@@ -1246,33 +1234,46 @@ void BK4819_EnableTXLink(void)
|
|||||||
|
|
||||||
void BK4819_PlayDTMF(char Code)
|
void BK4819_PlayDTMF(char Code)
|
||||||
{
|
{
|
||||||
uint16_t tone1 = 0;
|
|
||||||
uint16_t tone2 = 0;
|
|
||||||
|
|
||||||
|
struct DTMF_TonePair {
|
||||||
|
uint16_t tone1;
|
||||||
|
uint16_t tone2;
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct DTMF_TonePair tones[] = {
|
||||||
|
{941, 1336},
|
||||||
|
{697, 1209},
|
||||||
|
{697, 1336},
|
||||||
|
{697, 1477},
|
||||||
|
{770, 1209},
|
||||||
|
{770, 1336},
|
||||||
|
{770, 1477},
|
||||||
|
{852, 1209},
|
||||||
|
{852, 1336},
|
||||||
|
{852, 1477},
|
||||||
|
{697, 1633},
|
||||||
|
{770, 1633},
|
||||||
|
{852, 1633},
|
||||||
|
{941, 1633},
|
||||||
|
{941, 1209},
|
||||||
|
{941, 1477},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const struct DTMF_TonePair *pSelectedTone = NULL;
|
||||||
switch (Code)
|
switch (Code)
|
||||||
{
|
{
|
||||||
case '0': tone1 = 941; tone2 = 1336; break;
|
case '0'...'9': pSelectedTone = &tones[0 + Code - '0']; break;
|
||||||
case '1': tone1 = 697; tone2 = 1209; break;
|
case 'A'...'D': pSelectedTone = &tones[10 + Code - 'A']; break;
|
||||||
case '2': tone1 = 697; tone2 = 1336; break;
|
case '*': pSelectedTone = &tones[14]; break;
|
||||||
case '3': tone1 = 697; tone2 = 1477; break;
|
case '#': pSelectedTone = &tones[15]; break;
|
||||||
case '4': tone1 = 770; tone2 = 1209; break;
|
default: pSelectedTone = NULL;
|
||||||
case '5': tone1 = 770; tone2 = 1336; break;
|
|
||||||
case '6': tone1 = 770; tone2 = 1477; break;
|
|
||||||
case '7': tone1 = 852; tone2 = 1209; break;
|
|
||||||
case '8': tone1 = 852; tone2 = 1336; break;
|
|
||||||
case '9': tone1 = 852; tone2 = 1477; break;
|
|
||||||
case 'A': tone1 = 697; tone2 = 1633; break;
|
|
||||||
case 'B': tone1 = 770; tone2 = 1633; break;
|
|
||||||
case 'C': tone1 = 852; tone2 = 1633; break;
|
|
||||||
case 'D': tone1 = 941; tone2 = 1633; break;
|
|
||||||
case '*': tone1 = 941; tone2 = 1209; break;
|
|
||||||
case '#': tone1 = 941; tone2 = 1477; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tone1 > 0)
|
if (pSelectedTone) {
|
||||||
BK4819_WriteRegister(BK4819_REG_71, (((uint32_t)tone1 * 103244) + 5000) / 10000); // with rounding
|
BK4819_WriteRegister(BK4819_REG_71, (((uint32_t)pSelectedTone->tone1 * 103244) + 5000) / 10000); // with rounding
|
||||||
if (tone2 > 0)
|
BK4819_WriteRegister(BK4819_REG_72, (((uint32_t)pSelectedTone->tone2 * 103244) + 5000) / 10000); // with rounding
|
||||||
BK4819_WriteRegister(BK4819_REG_72, (((uint32_t)tone2 * 103244) + 5000) / 10000); // with rounding
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t FirstCodePersistTime, uint16_t HashCodePersistTime, uint16_t CodePersistTime, uint16_t CodeInternalTime)
|
void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t FirstCodePersistTime, uint16_t HashCodePersistTime, uint16_t CodePersistTime, uint16_t CodeInternalTime)
|
||||||
@@ -1394,18 +1395,16 @@ void BK4819_GenTail(uint8_t Tail)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_EnableCDCSS(void)
|
void BK4819_PlayCDCSSTail(void)
|
||||||
{
|
{
|
||||||
BK4819_GenTail(0); // CTC134
|
BK4819_GenTail(0); // CTC134
|
||||||
BK4819_WriteRegister(BK4819_REG_51, 0x804A);
|
BK4819_WriteRegister(BK4819_REG_51, 0x804A); // 1 0 0 0 0 0 0 0 0 1001010
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_EnableCTCSS(void)
|
void BK4819_PlayCTCSSTail(void)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
#ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||||
//BK4819_GenTail(1); // 120° phase shift
|
|
||||||
BK4819_GenTail(2); // 180° phase shift
|
BK4819_GenTail(2); // 180° phase shift
|
||||||
//BK4819_GenTail(3); // 240° phase shift
|
|
||||||
#else
|
#else
|
||||||
BK4819_GenTail(4); // 55Hz tone freq
|
BK4819_GenTail(4); // 55Hz tone freq
|
||||||
#endif
|
#endif
|
||||||
@@ -1687,7 +1686,7 @@ void BK4819_PrepareFSKReceive(void)
|
|||||||
BK4819_WriteRegister(BK4819_REG_59, 0x3068);
|
BK4819_WriteRegister(BK4819_REG_59, 0x3068);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_PlayRoger(void)
|
static void BK4819_PlayRogerNormal(void)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
const uint32_t tone1_Hz = 500;
|
const uint32_t tone1_Hz = 500;
|
||||||
@@ -1698,6 +1697,7 @@ void BK4819_PlayRoger(void)
|
|||||||
const uint32_t tone2_Hz = 1310;
|
const uint32_t tone2_Hz = 1310;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
BK4819_EnterTxMute();
|
BK4819_EnterTxMute();
|
||||||
BK4819_SetAF(BK4819_AF_MUTE);
|
BK4819_SetAF(BK4819_AF_MUTE);
|
||||||
|
|
||||||
@@ -1722,30 +1722,41 @@ void BK4819_PlayRoger(void)
|
|||||||
BK4819_WriteRegister(BK4819_REG_30, 0xC1FE); // 1 1 0000 0 1 1111 1 1 1 0
|
BK4819_WriteRegister(BK4819_REG_30, 0xC1FE); // 1 1 0000 0 1 1111 1 1 1 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BK4819_PlayRogerMDC(void)
|
void BK4819_PlayRogerMDC(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
struct reg_value {
|
||||||
|
BK4819_REGISTER_t reg;
|
||||||
|
uint16_t value;
|
||||||
|
};
|
||||||
|
|
||||||
BK4819_SetAF(BK4819_AF_MUTE);
|
struct reg_value RogerMDC_Configuration [] = {
|
||||||
|
{ BK4819_REG_58, 0x37C3 }, // FSK Enable,
|
||||||
BK4819_WriteRegister(BK4819_REG_58, 0x37C3); // FSK Enable,
|
|
||||||
// RX Bandwidth FFSK 1200/1800
|
// RX Bandwidth FFSK 1200/1800
|
||||||
// 0xAA or 0x55 Preamble
|
// 0xAA or 0x55 Preamble
|
||||||
// 11 RX Gain,
|
// 11 RX Gain,
|
||||||
// 101 RX Mode
|
// 101 RX Mode
|
||||||
// TX FFSK 1200/1800
|
// TX FFSK 1200/1800
|
||||||
BK4819_WriteRegister(BK4819_REG_72, 0x3065); // Set Tone-2 to 1200Hz
|
{ BK4819_REG_72, 0x3065 }, // Set Tone-2 to 1200Hz
|
||||||
BK4819_WriteRegister(BK4819_REG_70, 0x00E0); // Enable Tone-2 and Set Tone2 Gain
|
{ BK4819_REG_70, 0x00E0 }, // Enable Tone-2 and Set Tone2 Gain
|
||||||
BK4819_WriteRegister(BK4819_REG_5D, 0x0D00); // Set FSK data length to 13 bytes
|
{ BK4819_REG_5D, 0x0D00 }, // Set FSK data length to 13 bytes
|
||||||
BK4819_WriteRegister(BK4819_REG_59, 0x8068); // 4 byte sync length, 6 byte preamble, clear TX FIFO
|
{ BK4819_REG_59, 0x8068 }, // 4 byte sync length, 6 byte preamble, clear TX FIFO
|
||||||
BK4819_WriteRegister(BK4819_REG_59, 0x0068); // Same, but clear TX FIFO is now unset (clearing done)
|
{ BK4819_REG_59, 0x0068 }, // Same, but clear TX FIFO is now unset (clearing done)
|
||||||
BK4819_WriteRegister(BK4819_REG_5A, 0x5555); // First two sync bytes
|
{ BK4819_REG_5A, 0x5555 }, // First two sync bytes
|
||||||
BK4819_WriteRegister(BK4819_REG_5B, 0x55AA); // End of sync bytes. Total 4 bytes: 555555aa
|
{ BK4819_REG_5B, 0x55AA }, // End of sync bytes. Total 4 bytes: 555555aa
|
||||||
BK4819_WriteRegister(BK4819_REG_5C, 0xAA30); // Disable CRC
|
{ BK4819_REG_5C, 0xAA30 }, // Disable CRC
|
||||||
|
};
|
||||||
|
|
||||||
|
BK4819_SetAF(BK4819_AF_MUTE);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < ARRAY_SIZE(RogerMDC_Configuration); i++) {
|
||||||
|
BK4819_WriteRegister(RogerMDC_Configuration[i].reg, RogerMDC_Configuration[i].value);
|
||||||
|
}
|
||||||
|
|
||||||
// Send the data from the roger table
|
// Send the data from the roger table
|
||||||
for (i = 0; i < 7; i++)
|
for (unsigned int i = 0; i < ARRAY_SIZE(FSK_RogerTable); i++) {
|
||||||
BK4819_WriteRegister(BK4819_REG_5F, FSK_RogerTable[i]);
|
BK4819_WriteRegister(BK4819_REG_5F, FSK_RogerTable[i]);
|
||||||
|
}
|
||||||
|
|
||||||
SYSTEM_DelayMs(20);
|
SYSTEM_DelayMs(20);
|
||||||
|
|
||||||
@@ -1760,6 +1771,15 @@ void BK4819_PlayRogerMDC(void)
|
|||||||
BK4819_WriteRegister(BK4819_REG_58, 0x0000);
|
BK4819_WriteRegister(BK4819_REG_58, 0x0000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BK4819_PlayRoger(void)
|
||||||
|
{
|
||||||
|
if (gEeprom.ROGER == ROGER_MODE_ROGER) {
|
||||||
|
BK4819_PlayRogerNormal();
|
||||||
|
} else if (gEeprom.ROGER == ROGER_MODE_MDC) {
|
||||||
|
BK4819_PlayRogerMDC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BK4819_Enable_AfDac_DiscMode_TxDsp(void)
|
void BK4819_Enable_AfDac_DiscMode_TxDsp(void)
|
||||||
{
|
{
|
||||||
BK4819_WriteRegister(BK4819_REG_30, 0x0000);
|
BK4819_WriteRegister(BK4819_REG_30, 0x0000);
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ void BK4819_SetRegValue(RegisterSpec s, uint16_t v);
|
|||||||
void BK4819_WriteU8(uint8_t Data);
|
void BK4819_WriteU8(uint8_t Data);
|
||||||
void BK4819_WriteU16(uint16_t Data);
|
void BK4819_WriteU16(uint16_t Data);
|
||||||
|
|
||||||
void BK4819_EnableAGC();
|
void BK4819_SetAGC(bool enable);
|
||||||
void BK4819_DisableAGC();
|
void BK4819_InitAGC(bool amModulation);
|
||||||
|
|
||||||
void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet);
|
void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet);
|
||||||
|
|
||||||
@@ -132,10 +132,12 @@ void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t F
|
|||||||
void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency);
|
void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency);
|
||||||
|
|
||||||
void BK4819_GenTail(uint8_t Tail);
|
void BK4819_GenTail(uint8_t Tail);
|
||||||
void BK4819_EnableCDCSS(void);
|
void BK4819_PlayCDCSSTail(void);
|
||||||
void BK4819_EnableCTCSS(void);
|
void BK4819_PlayCTCSSTail(void);
|
||||||
|
|
||||||
uint16_t BK4819_GetRSSI(void);
|
uint16_t BK4819_GetRSSI(void);
|
||||||
|
int8_t BK4819_GetRxGain_dB(void);
|
||||||
|
int16_t BK4819_GetRSSI_dBm(void);
|
||||||
uint8_t BK4819_GetGlitchIndicator(void);
|
uint8_t BK4819_GetGlitchIndicator(void);
|
||||||
uint8_t BK4819_GetExNoiceIndicator(void);
|
uint8_t BK4819_GetExNoiceIndicator(void);
|
||||||
uint16_t BK4819_GetVoiceAmplitudeOut(void);
|
uint16_t BK4819_GetVoiceAmplitudeOut(void);
|
||||||
@@ -161,7 +163,6 @@ void BK4819_SendFSKData(uint16_t *pData);
|
|||||||
void BK4819_PrepareFSKReceive(void);
|
void BK4819_PrepareFSKReceive(void);
|
||||||
|
|
||||||
void BK4819_PlayRoger(void);
|
void BK4819_PlayRoger(void);
|
||||||
void BK4819_PlayRogerMDC(void);
|
|
||||||
|
|
||||||
void BK4819_Enable_AfDac_DiscMode_TxDsp(void);
|
void BK4819_Enable_AfDac_DiscMode_TxDsp(void);
|
||||||
|
|
||||||
@@ -170,4 +171,3 @@ void BK4819_SetScrambleFrequencyControlWord(uint32_t Frequency);
|
|||||||
void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code);
|
void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bsp/dp32g030/crc.h"
|
#include "../bsp/dp32g030/crc.h"
|
||||||
#include "driver/crc.h"
|
#include "crc.h"
|
||||||
|
|
||||||
void CRC_Init(void)
|
void CRC_Init(void)
|
||||||
{
|
{
|
||||||
@@ -47,4 +47,3 @@ uint16_t CRC_Calculate(const void *pBuffer, uint16_t Size)
|
|||||||
|
|
||||||
return Crc;
|
return Crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,15 +47,16 @@ void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer)
|
|||||||
|
|
||||||
uint8_t buffer[8];
|
uint8_t buffer[8];
|
||||||
EEPROM_ReadBuffer(Address, buffer, 8);
|
EEPROM_ReadBuffer(Address, buffer, 8);
|
||||||
if (memcmp(pBuffer, buffer, 8) != 0)
|
if (memcmp(pBuffer, buffer, 8) == 0) {
|
||||||
{
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
I2C_Start();
|
I2C_Start();
|
||||||
I2C_Write(0xA0);
|
I2C_Write(0xA0);
|
||||||
I2C_Write((Address >> 8) & 0xFF);
|
I2C_Write((Address >> 8) & 0xFF);
|
||||||
I2C_Write((Address >> 0) & 0xFF);
|
I2C_Write((Address >> 0) & 0xFF);
|
||||||
I2C_WriteBuffer(pBuffer, 8);
|
I2C_WriteBuffer(pBuffer, 8);
|
||||||
I2C_Stop();
|
I2C_Stop();
|
||||||
}
|
|
||||||
|
|
||||||
// give the EEPROM time to burn the data in (apparently takes 5ms)
|
// give the EEPROM time to burn the data in (apparently takes 5ms)
|
||||||
SYSTEM_DelayMs(8);
|
SYSTEM_DelayMs(8);
|
||||||
|
|||||||
@@ -137,18 +137,13 @@ int I2C_ReadBuffer(void *pBuffer, uint8_t Size)
|
|||||||
uint8_t *pData = (uint8_t *)pBuffer;
|
uint8_t *pData = (uint8_t *)pBuffer;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
if (Size == 1) {
|
|
||||||
*pData = I2C_Read(true);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < Size - 1; i++) {
|
for (i = 0; i < Size - 1; i++) {
|
||||||
SYSTICK_DelayUs(1);
|
SYSTICK_DelayUs(1);
|
||||||
pData[i] = I2C_Read(false);
|
pData[i] = I2C_Read(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSTICK_DelayUs(1);
|
SYSTICK_DelayUs(1);
|
||||||
pData[i++] = I2C_Read(true);
|
pData[i] = I2C_Read(true);
|
||||||
|
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,19 +117,13 @@ KEY_Code_t KEYBOARD_Poll(void)
|
|||||||
GPIOA->DATA &= keyboard[j].set_to_zero_mask;
|
GPIOA->DATA &= keyboard[j].set_to_zero_mask;
|
||||||
|
|
||||||
// Read all 4 GPIO pins at once .. with de-noise, max of 8 sample loops
|
// Read all 4 GPIO pins at once .. with de-noise, max of 8 sample loops
|
||||||
for (i = 0, k = 0, reg = 0; i < 3 && k < 8; i++, k++)
|
for (i = 0, k = 0, reg = 0; i < 3 && k < 8; i++, k++) {
|
||||||
{
|
|
||||||
uint16_t reg2;
|
|
||||||
|
|
||||||
SYSTICK_DelayUs(1);
|
SYSTICK_DelayUs(1);
|
||||||
|
uint16_t reg2 = GPIOA->DATA;
|
||||||
reg2 = GPIOA->DATA;
|
i *= reg == reg2;
|
||||||
if (reg != reg2)
|
|
||||||
{ // noise
|
|
||||||
reg = reg2;
|
reg = reg2;
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < 3)
|
if (i < 3)
|
||||||
break; // noise is too bad
|
break; // noise is too bad
|
||||||
|
|
||||||
|
|||||||
114
driver/st7565.c
@@ -25,118 +25,59 @@
|
|||||||
#include "driver/system.h"
|
#include "driver/system.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
uint8_t gStatusLine[128];
|
uint8_t gStatusLine[LCD_WIDTH];
|
||||||
uint8_t gFrameBuffer[7][128];
|
uint8_t gFrameBuffer[FRAME_LINES][LCD_WIDTH];
|
||||||
|
|
||||||
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap)
|
static void DrawLine(uint8_t column, uint8_t line, const uint8_t * lineBuffer, unsigned size_defVal)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
ST7565_SelectColumnAndLine(column + 4, line);
|
||||||
|
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
|
||||||
|
|
||||||
ST7565_SelectColumnAndLine(Column + 4U, Line);
|
|
||||||
|
|
||||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
||||||
|
for (unsigned i = 0; i < size_defVal; i++) {
|
||||||
if (pBitmap != NULL)
|
|
||||||
{
|
|
||||||
for (i = 0; i < Size; i++)
|
|
||||||
{
|
|
||||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
||||||
SPI0->WDR = pBitmap[i];
|
SPI0->WDR = lineBuffer ? lineBuffer[i] : size_defVal;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (i = 0; i < Size; i++)
|
|
||||||
{
|
|
||||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
|
||||||
SPI0->WDR = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const uint8_t *pBitmap, const unsigned int Size)
|
||||||
|
{
|
||||||
|
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||||
|
DrawLine(Column, Line, pBitmap, Size);
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST7565_BlitFullScreen(void)
|
void ST7565_BlitFullScreen(void)
|
||||||
{
|
{
|
||||||
unsigned int Line;
|
|
||||||
|
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||||
|
|
||||||
ST7565_WriteByte(0x40);
|
ST7565_WriteByte(0x40);
|
||||||
|
for (unsigned line = 0; line < FRAME_LINES; line++) {
|
||||||
for (Line = 0; Line < ARRAY_SIZE(gFrameBuffer); Line++)
|
DrawLine(0, line+1, gFrameBuffer[line], LCD_WIDTH);
|
||||||
{
|
|
||||||
unsigned int Column;
|
|
||||||
ST7565_SelectColumnAndLine(4, Line + 1);
|
|
||||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
|
||||||
for (Column = 0; Column < ARRAY_SIZE(gFrameBuffer[0]); Column++)
|
|
||||||
{
|
|
||||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
|
||||||
SPI0->WDR = gFrameBuffer[Line][Column];
|
|
||||||
}
|
}
|
||||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
void ST7565_BlitLine(unsigned line)
|
||||||
// whats the delay for I wonder, it holds things up :(
|
{
|
||||||
SYSTEM_DelayMs(20);
|
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||||
#else
|
ST7565_WriteByte(0x40); // start line ?
|
||||||
// SYSTEM_DelayMs(1);
|
DrawLine(0, line+1, gFrameBuffer[line], LCD_WIDTH);
|
||||||
#endif
|
|
||||||
|
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST7565_BlitStatusLine(void)
|
void ST7565_BlitStatusLine(void)
|
||||||
{ // the top small text line on the display
|
{ // the top small text line on the display
|
||||||
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||||
|
|
||||||
ST7565_WriteByte(0x40); // start line ?
|
ST7565_WriteByte(0x40); // start line ?
|
||||||
|
DrawLine(0, 0, gStatusLine, LCD_WIDTH);
|
||||||
ST7565_SelectColumnAndLine(4, 0);
|
|
||||||
|
|
||||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(gStatusLine); i++)
|
|
||||||
{
|
|
||||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
|
||||||
SPI0->WDR = gStatusLine[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
|
||||||
|
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST7565_FillScreen(uint8_t Value)
|
void ST7565_FillScreen(uint8_t value)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
// reset some of the displays settings to try and overcome the radios hardware problem - RF corrupting the display
|
|
||||||
ST7565_Init(false);
|
|
||||||
|
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||||
|
for (unsigned i = 0; i < 8; i++) {
|
||||||
for (i = 0; i < 8; i++)
|
DrawLine(0, i, NULL, value);
|
||||||
{
|
|
||||||
unsigned int j;
|
|
||||||
ST7565_SelectColumnAndLine(0, i);
|
|
||||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
|
||||||
for (j = 0; j < 132; j++)
|
|
||||||
{
|
|
||||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
|
||||||
SPI0->WDR = Value;
|
|
||||||
}
|
}
|
||||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
|
||||||
}
|
|
||||||
|
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,22 +146,17 @@ uint8_t cmds[] = {
|
|||||||
ST7565_CMD_DISPLAY_ON_OFF | 1, // Display ON/OFF: ON
|
ST7565_CMD_DISPLAY_ON_OFF | 1, // Display ON/OFF: ON
|
||||||
};
|
};
|
||||||
|
|
||||||
void ST7565_Init(const bool full)
|
void ST7565_Init(void)
|
||||||
{
|
{
|
||||||
if (full) {
|
|
||||||
SPI0_Init();
|
SPI0_Init();
|
||||||
ST7565_HardwareReset();
|
ST7565_HardwareReset();
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||||
ST7565_WriteByte(ST7565_CMD_SOFTWARE_RESET); // software reset
|
ST7565_WriteByte(ST7565_CMD_SOFTWARE_RESET); // software reset
|
||||||
SYSTEM_DelayMs(120);
|
SYSTEM_DelayMs(120);
|
||||||
}
|
|
||||||
else
|
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
|
||||||
|
|
||||||
for(uint8_t i = 0; i < 8; i++)
|
for(uint8_t i = 0; i < 8; i++)
|
||||||
ST7565_WriteByte(cmds[i]);
|
ST7565_WriteByte(cmds[i]);
|
||||||
|
|
||||||
if (full) {
|
|
||||||
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b011); // VB=0 VR=1 VF=1
|
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b011); // VB=0 VR=1 VF=1
|
||||||
SYSTEM_DelayMs(1);
|
SYSTEM_DelayMs(1);
|
||||||
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b110); // VB=1 VR=1 VF=0
|
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b110); // VB=1 VR=1 VF=0
|
||||||
@@ -230,14 +166,12 @@ void ST7565_Init(const bool full)
|
|||||||
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b111); // VB=1 VR=1 VF=1
|
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b111); // VB=1 VR=1 VF=1
|
||||||
|
|
||||||
SYSTEM_DelayMs(40);
|
SYSTEM_DelayMs(40);
|
||||||
}
|
|
||||||
|
|
||||||
ST7565_WriteByte(ST7565_CMD_SET_START_LINE | 0); // line 0
|
ST7565_WriteByte(ST7565_CMD_SET_START_LINE | 0); // line 0
|
||||||
ST7565_WriteByte(ST7565_CMD_DISPLAY_ON_OFF | 1); // D=1
|
ST7565_WriteByte(ST7565_CMD_DISPLAY_ON_OFF | 1); // D=1
|
||||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||||
|
|
||||||
if (full)
|
|
||||||
ST7565_FillScreen(0x00);
|
ST7565_FillScreen(0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,15 +22,17 @@
|
|||||||
|
|
||||||
#define LCD_WIDTH 128
|
#define LCD_WIDTH 128
|
||||||
#define LCD_HEIGHT 64
|
#define LCD_HEIGHT 64
|
||||||
|
#define FRAME_LINES 7
|
||||||
|
|
||||||
extern uint8_t gStatusLine[128];
|
extern uint8_t gStatusLine[LCD_WIDTH];
|
||||||
extern uint8_t gFrameBuffer[7][128];
|
extern uint8_t gFrameBuffer[FRAME_LINES][LCD_WIDTH];
|
||||||
|
|
||||||
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap);
|
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const uint8_t *pBitmap, const unsigned int Size);
|
||||||
void ST7565_BlitFullScreen(void);
|
void ST7565_BlitFullScreen(void);
|
||||||
|
void ST7565_BlitLine(unsigned line);
|
||||||
void ST7565_BlitStatusLine(void);
|
void ST7565_BlitStatusLine(void);
|
||||||
void ST7565_FillScreen(uint8_t Value);
|
void ST7565_FillScreen(uint8_t Value);
|
||||||
void ST7565_Init(const bool full);
|
void ST7565_Init(void);
|
||||||
void ST7565_FixInterfGlitch(void);
|
void ST7565_FixInterfGlitch(void);
|
||||||
void ST7565_HardwareReset(void);
|
void ST7565_HardwareReset(void);
|
||||||
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
|
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bsp/dp32g030/pmu.h"
|
#include "../bsp/dp32g030/pmu.h"
|
||||||
#include "bsp/dp32g030/syscon.h"
|
#include "../bsp/dp32g030/syscon.h"
|
||||||
#include "driver/system.h"
|
#include "system.h"
|
||||||
#include "driver/systick.h"
|
#include "systick.h"
|
||||||
|
|
||||||
void SYSTEM_DelayMs(uint32_t Delay)
|
void SYSTEM_DelayMs(uint32_t Delay)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ARMCM0.h"
|
#include "ARMCM0.h"
|
||||||
#include "driver/systick.h"
|
#include "systick.h"
|
||||||
#include "misc.h"
|
#include "../misc.h"
|
||||||
|
|
||||||
// 0x20000324
|
// 0x20000324
|
||||||
static uint32_t gTickMultiplier;
|
static uint32_t gTickMultiplier;
|
||||||
@@ -30,16 +30,20 @@ void SYSTICK_Init(void)
|
|||||||
void SYSTICK_DelayUs(uint32_t Delay)
|
void SYSTICK_DelayUs(uint32_t Delay)
|
||||||
{
|
{
|
||||||
const uint32_t ticks = Delay * gTickMultiplier;
|
const uint32_t ticks = Delay * gTickMultiplier;
|
||||||
uint32_t i = 0;
|
uint32_t elapsed_ticks = 0;
|
||||||
uint32_t Start = SysTick->LOAD;
|
uint32_t Start = SysTick->LOAD;
|
||||||
uint32_t Previous = SysTick->VAL;
|
uint32_t Previous = SysTick->VAL;
|
||||||
do {
|
do {
|
||||||
uint32_t Current;
|
uint32_t Current;
|
||||||
uint32_t Delta;
|
|
||||||
while ((Current = SysTick->VAL) == Previous) {}
|
|
||||||
Delta = (Current < Previous) ? -Current : Start - Current;
|
|
||||||
i += Delta + Previous;
|
|
||||||
Previous = Current;
|
|
||||||
} while (i < ticks);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
do {
|
||||||
|
Current = SysTick->VAL;
|
||||||
|
} while (Current == Previous);
|
||||||
|
|
||||||
|
uint32_t Delta = ((Current < Previous) ? - Current : Start - Current);
|
||||||
|
|
||||||
|
elapsed_ticks += Delta + Previous;
|
||||||
|
|
||||||
|
Previous = Current;
|
||||||
|
} while (elapsed_ticks < ticks);
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,32 +17,32 @@
|
|||||||
#include "frequencies.h"
|
#include "frequencies.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
// the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz
|
// the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz
|
||||||
const freq_band_table_t BX4819_band1 = { 1800000, 63000000};
|
|
||||||
const freq_band_table_t BX4819_band2 = {84000000, 130000000};
|
|
||||||
|
|
||||||
const freq_band_table_t frequencyBandTable[7] =
|
#define BX4819_band1_lower 1800000
|
||||||
|
#define BX4819_band2_upper 130000000
|
||||||
|
|
||||||
|
const freq_band_table_t BX4819_band1 = {BX4819_band1_lower, 63000000};
|
||||||
|
const freq_band_table_t BX4819_band2 = {84000000, BX4819_band2_upper};
|
||||||
|
|
||||||
|
const freq_band_table_t frequencyBandTable[] =
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_WIDE_RX
|
#ifndef ENABLE_WIDE_RX
|
||||||
// QS original
|
// QS original
|
||||||
{.lower = 5000000, .upper = 7600000},
|
[BAND1_50MHz ]={.lower = 5000000, .upper = 7600000},
|
||||||
{.lower = 10800000, .upper = 13700000},
|
[BAND7_470MHz]={.lower = 47000000, .upper = 60000000},
|
||||||
{.lower = 13700000, .upper = 17400000},
|
|
||||||
{.lower = 17400000, .upper = 35000000},
|
|
||||||
{.lower = 35000000, .upper = 40000000},
|
|
||||||
{.lower = 40000000, .upper = 47000000},
|
|
||||||
{.lower = 47000000, .upper = 60000000}
|
|
||||||
#else
|
#else
|
||||||
// extended range
|
// extended range
|
||||||
{.lower = BX4819_band1.lower, .upper = 10800000},
|
[BAND1_50MHz ]={.lower = BX4819_band1_lower, .upper = 10800000},
|
||||||
{.lower = 10800000, .upper = 13700000},
|
[BAND7_470MHz]={.lower = 47000000, .upper = BX4819_band2_upper},
|
||||||
{.lower = 13700000, .upper = 17400000},
|
|
||||||
{.lower = 17400000, .upper = 35000000},
|
|
||||||
{.lower = 35000000, .upper = 40000000},
|
|
||||||
{.lower = 40000000, .upper = 47000000},
|
|
||||||
{.lower = 47000000, .upper = BX4819_band2.upper}
|
|
||||||
#endif
|
#endif
|
||||||
|
[BAND2_108MHz]={.lower = 10800000, .upper = 13700000},
|
||||||
|
[BAND3_137MHz]={.lower = 13700000, .upper = 17400000},
|
||||||
|
[BAND4_174MHz]={.lower = 17400000, .upper = 35000000},
|
||||||
|
[BAND5_350MHz]={.lower = 35000000, .upper = 40000000},
|
||||||
|
[BAND6_400MHz]={.lower = 40000000, .upper = 47000000}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
@@ -62,22 +62,49 @@ const freq_band_table_t frequencyBandTable[7] =
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// this order of steps has to be preserved for backwards compatibility with other/stock firmwares
|
||||||
const uint16_t gStepFrequencyTable[] = {
|
const uint16_t gStepFrequencyTable[] = {
|
||||||
250, 500, 625, 1000, 1250, 2500, 833,
|
// standard steps
|
||||||
1, 5, 10, 25, 50, 100, 125, 1500, 3000, 5000, 10000, 12500, 25000, 50000
|
[STEP_2_5kHz] = 250,
|
||||||
|
[STEP_5kHz] = 500,
|
||||||
|
[STEP_6_25kHz] = 625,
|
||||||
|
[STEP_10kHz] = 1000,
|
||||||
|
[STEP_12_5kHz] = 1250,
|
||||||
|
[STEP_25kHz] = 2500,
|
||||||
|
[STEP_8_33kHz] = 833,
|
||||||
|
// custom steps
|
||||||
|
[STEP_0_01kHz] = 1,
|
||||||
|
[STEP_0_05kHz] = 5,
|
||||||
|
[STEP_0_1kHz] = 10,
|
||||||
|
[STEP_0_25kHz] = 25,
|
||||||
|
[STEP_0_5kHz] = 50,
|
||||||
|
[STEP_1kHz] = 100,
|
||||||
|
[STEP_1_25kHz] = 125,
|
||||||
|
[STEP_9kHz] = 900,
|
||||||
|
[STEP_15kHz] = 1500,
|
||||||
|
[STEP_20kHz] = 2000,
|
||||||
|
[STEP_30kHz] = 3000,
|
||||||
|
[STEP_50kHz] = 5000,
|
||||||
|
[STEP_100kHz] = 10000,
|
||||||
|
[STEP_125kHz] = 12500,
|
||||||
|
[STEP_200kHz] = 20000,
|
||||||
|
[STEP_250kHz] = 25000,
|
||||||
|
[STEP_500kHz] = 50000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const uint8_t StepSortedIndexes[] = {
|
const STEP_Setting_t StepSortedIndexes[] = {
|
||||||
STEP_0_01kHz, STEP_0_05kHz, STEP_0_1kHz, STEP_0_25kHz, STEP_0_5kHz, STEP_1kHz, STEP_1_25kHz, STEP_2_5kHz, STEP_5kHz, STEP_6_25kHz,
|
STEP_0_01kHz, STEP_0_05kHz, STEP_0_1kHz, STEP_0_25kHz, STEP_0_5kHz, STEP_1kHz, STEP_1_25kHz, STEP_2_5kHz, STEP_5kHz, STEP_6_25kHz,
|
||||||
STEP_8_33kHz, STEP_10kHz, STEP_12_5kHz, STEP_15kHz, STEP_25kHz, STEP_30kHz, STEP_50kHz, STEP_100kHz,
|
STEP_8_33kHz, STEP_9kHz, STEP_10kHz, STEP_12_5kHz, STEP_15kHz, STEP_20kHz, STEP_25kHz, STEP_30kHz, STEP_50kHz, STEP_100kHz,
|
||||||
STEP_125kHz, STEP_250kHz, STEP_500kHz
|
STEP_125kHz, STEP_200kHz, STEP_250kHz, STEP_500kHz
|
||||||
};
|
};
|
||||||
uint8_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx)
|
|
||||||
|
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx)
|
||||||
{
|
{
|
||||||
return StepSortedIndexes[sortedIdx];
|
return StepSortedIndexes[sortedIdx];
|
||||||
}
|
}
|
||||||
uint8_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t stepIdx)
|
|
||||||
|
uint32_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t stepIdx)
|
||||||
{
|
{
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE(gStepFrequencyTable); i++)
|
for(uint8_t i = 0; i < ARRAY_SIZE(gStepFrequencyTable); i++)
|
||||||
if(StepSortedIndexes[i] == stepIdx)
|
if(StepSortedIndexes[i] == stepIdx)
|
||||||
@@ -85,16 +112,16 @@ uint8_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t stepIdx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assert(ARRAY_SIZE(gStepFrequencyTable) == STEP_N_ELEM);
|
||||||
|
|
||||||
|
|
||||||
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
||||||
{
|
{
|
||||||
int band;
|
for (int32_t band = BAND_N_ELEM - 1; band >= 0; band--)
|
||||||
for (band = ARRAY_SIZE(frequencyBandTable) - 1; band >= 0; band--)
|
|
||||||
if (Frequency >= frequencyBandTable[band].lower)
|
if (Frequency >= frequencyBandTable[band].lower)
|
||||||
// if (Frequency < frequencyBandTable[band].upper)
|
|
||||||
return (FREQUENCY_Band_t)band;
|
return (FREQUENCY_Band_t)band;
|
||||||
|
|
||||||
return BAND1_50MHz;
|
return BAND1_50MHz;
|
||||||
// return BAND_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency)
|
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency)
|
||||||
@@ -124,17 +151,20 @@ uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step)
|
|||||||
int chno = (freq - base) / 700; // convert entered aviation 8.33Khz channel number scheme to actual frequency.
|
int chno = (freq - base) / 700; // convert entered aviation 8.33Khz channel number scheme to actual frequency.
|
||||||
return base + (chno * 833) + (chno == 3);
|
return base + (chno * 833) + (chno == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(step == 1)
|
if(step == 1)
|
||||||
return freq;
|
return freq;
|
||||||
|
if(step >= 1000)
|
||||||
|
step = step/2;
|
||||||
return (freq + (step + 1) / 2) / step * step;
|
return (freq + (step + 1) / 2) / step * step;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TX_freq_check(const uint32_t Frequency)
|
int32_t TX_freq_check(const uint32_t Frequency)
|
||||||
{ // return '0' if TX frequency is allowed
|
{ // return '0' if TX frequency is allowed
|
||||||
// otherwise return '-1'
|
// otherwise return '-1'
|
||||||
|
|
||||||
if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper)
|
if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper)
|
||||||
return -1; // not allowed outside this range
|
return 1; // not allowed outside this range
|
||||||
|
|
||||||
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
|
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
|
||||||
return -1; // BX chip does not work in this range
|
return -1; // BX chip does not work in this range
|
||||||
@@ -196,7 +226,7 @@ int TX_freq_check(const uint32_t Frequency)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case F_LOCK_NONE:
|
case F_LOCK_NONE:
|
||||||
for (uint8_t i = 0; i < ARRAY_SIZE(frequencyBandTable); i++)
|
for (uint32_t i = 0; i < ARRAY_SIZE(frequencyBandTable); i++)
|
||||||
if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper)
|
if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper)
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
@@ -206,11 +236,11 @@ int TX_freq_check(const uint32_t Frequency)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RX_freq_check(const uint32_t Frequency)
|
int32_t RX_freq_check(const uint32_t Frequency)
|
||||||
{ // return '0' if RX frequency is allowed
|
{ // return '0' if RX frequency is allowed
|
||||||
// otherwise return '-1'
|
// otherwise return '-1'
|
||||||
|
|
||||||
if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper)
|
if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
|
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define _1GHz_in_KHz 100000000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const uint32_t lower;
|
const uint32_t lower;
|
||||||
const uint32_t upper;
|
const uint32_t upper;
|
||||||
@@ -27,8 +29,6 @@ typedef struct {
|
|||||||
extern const freq_band_table_t BX4819_band1;
|
extern const freq_band_table_t BX4819_band1;
|
||||||
extern const freq_band_table_t BX4819_band2;
|
extern const freq_band_table_t BX4819_band2;
|
||||||
|
|
||||||
extern const freq_band_table_t frequencyBandTable[7];
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BAND_NONE = -1,
|
BAND_NONE = -1,
|
||||||
BAND1_50MHz = 0,
|
BAND1_50MHz = 0,
|
||||||
@@ -37,11 +37,14 @@ typedef enum {
|
|||||||
BAND4_174MHz,
|
BAND4_174MHz,
|
||||||
BAND5_350MHz,
|
BAND5_350MHz,
|
||||||
BAND6_400MHz,
|
BAND6_400MHz,
|
||||||
BAND7_470MHz
|
BAND7_470MHz,
|
||||||
|
BAND_N_ELEM
|
||||||
} FREQUENCY_Band_t;
|
} FREQUENCY_Band_t;
|
||||||
|
|
||||||
|
extern const freq_band_table_t frequencyBandTable[];
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
// standard steps
|
||||||
STEP_2_5kHz,
|
STEP_2_5kHz,
|
||||||
STEP_5kHz,
|
STEP_5kHz,
|
||||||
STEP_6_25kHz,
|
STEP_6_25kHz,
|
||||||
@@ -49,6 +52,7 @@ typedef enum {
|
|||||||
STEP_12_5kHz,
|
STEP_12_5kHz,
|
||||||
STEP_25kHz,
|
STEP_25kHz,
|
||||||
STEP_8_33kHz,
|
STEP_8_33kHz,
|
||||||
|
// custom steps
|
||||||
STEP_0_01kHz,
|
STEP_0_01kHz,
|
||||||
STEP_0_05kHz,
|
STEP_0_05kHz,
|
||||||
STEP_0_1kHz,
|
STEP_0_1kHz,
|
||||||
@@ -56,17 +60,21 @@ typedef enum {
|
|||||||
STEP_0_5kHz,
|
STEP_0_5kHz,
|
||||||
STEP_1kHz,
|
STEP_1kHz,
|
||||||
STEP_1_25kHz,
|
STEP_1_25kHz,
|
||||||
|
STEP_9kHz,
|
||||||
STEP_15kHz,
|
STEP_15kHz,
|
||||||
|
STEP_20kHz,
|
||||||
STEP_30kHz,
|
STEP_30kHz,
|
||||||
STEP_50kHz,
|
STEP_50kHz,
|
||||||
STEP_100kHz,
|
STEP_100kHz,
|
||||||
STEP_125kHz,
|
STEP_125kHz,
|
||||||
|
STEP_200kHz,
|
||||||
STEP_250kHz,
|
STEP_250kHz,
|
||||||
STEP_500kHz,
|
STEP_500kHz,
|
||||||
|
STEP_N_ELEM
|
||||||
} STEP_Setting_t;
|
} STEP_Setting_t;
|
||||||
|
|
||||||
|
|
||||||
extern const uint16_t gStepFrequencyTable[21];
|
extern const uint16_t gStepFrequencyTable[];
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
extern const uint32_t NoaaFrequencyTable[10];
|
extern const uint32_t NoaaFrequencyTable[10];
|
||||||
@@ -76,10 +84,10 @@ FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency);
|
|||||||
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency);
|
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency);
|
||||||
uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step);
|
uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step);
|
||||||
|
|
||||||
uint8_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx);
|
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx);
|
||||||
uint8_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t step);
|
uint32_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t step);
|
||||||
|
|
||||||
int TX_freq_check(const uint32_t Frequency);
|
int32_t TX_freq_check(uint32_t Frequency);
|
||||||
int RX_freq_check(const uint32_t Frequency);
|
int32_t RX_freq_check(uint32_t Frequency);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
152
functions.c
@@ -42,78 +42,64 @@
|
|||||||
|
|
||||||
FUNCTION_Type_t gCurrentFunction;
|
FUNCTION_Type_t gCurrentFunction;
|
||||||
|
|
||||||
|
bool FUNCTION_IsRx()
|
||||||
|
{
|
||||||
|
return gCurrentFunction == FUNCTION_MONITOR ||
|
||||||
|
gCurrentFunction == FUNCTION_INCOMING ||
|
||||||
|
gCurrentFunction == FUNCTION_RECEIVE;
|
||||||
|
}
|
||||||
|
|
||||||
void FUNCTION_Init(void)
|
void FUNCTION_Init(void)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_NOAA
|
|
||||||
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
gCurrentCodeType = (gRxVfo->Modulation != MODULATION_FM) ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_NOAA
|
|
||||||
else
|
|
||||||
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
|
||||||
DTMF_clear_RX();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_CxCSS_TAIL_Found = false;
|
g_CxCSS_TAIL_Found = false;
|
||||||
g_CDCSS_Lost = false;
|
g_CDCSS_Lost = false;
|
||||||
g_CTCSS_Lost = false;
|
g_CTCSS_Lost = false;
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
g_VOX_Lost = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_SquelchLost = false;
|
g_SquelchLost = false;
|
||||||
|
|
||||||
gFlagTailNoteEliminationComplete = false;
|
gFlagTailToneEliminationComplete = false;
|
||||||
gTailNoteEliminationCountdown_10ms = 0;
|
gTailToneEliminationCountdown_10ms = 0;
|
||||||
gFoundCTCSS = false;
|
gFoundCTCSS = false;
|
||||||
gFoundCDCSS = false;
|
gFoundCDCSS = false;
|
||||||
gFoundCTCSSCountdown_10ms = 0;
|
gFoundCTCSSCountdown_10ms = 0;
|
||||||
gFoundCDCSSCountdown_10ms = 0;
|
gFoundCDCSSCountdown_10ms = 0;
|
||||||
gEndOfRxDetectedMaybe = false;
|
gEndOfRxDetectedMaybe = false;
|
||||||
|
|
||||||
|
gCurrentCodeType = (gRxVfo->Modulation != MODULATION_FM) ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
g_VOX_Lost = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|
DTMF_clear_RX();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
gNOAACountdown_10ms = 0;
|
gNOAACountdown_10ms = 0;
|
||||||
|
|
||||||
|
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) {
|
||||||
|
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FUNCTION_Select(FUNCTION_Type_t Function)
|
void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction)
|
||||||
{
|
{
|
||||||
const FUNCTION_Type_t PreviousFunction = gCurrentFunction;
|
|
||||||
const bool bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE);
|
|
||||||
|
|
||||||
gCurrentFunction = Function;
|
|
||||||
|
|
||||||
if (bWasPowerSave && Function != FUNCTION_POWER_SAVE)
|
|
||||||
{
|
|
||||||
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
|
|
||||||
gRxIdleMode = false;
|
|
||||||
UI_DisplayStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Function)
|
|
||||||
{
|
|
||||||
case FUNCTION_FOREGROUND:
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
if (gDTMF_ReplyState != DTMF_REPLY_NONE)
|
if (gDTMF_ReplyState != DTMF_REPLY_NONE)
|
||||||
RADIO_PrepareCssTX();
|
RADIO_PrepareCssTX();
|
||||||
#endif
|
#endif
|
||||||
if (PreviousFunction == FUNCTION_TRANSMIT)
|
|
||||||
{
|
if (PreviousFunction == FUNCTION_TRANSMIT) {
|
||||||
ST7565_FixInterfGlitch();
|
ST7565_FixInterfGlitch();
|
||||||
gVFO_RSSI_bar_level[0] = 0;
|
gVFO_RSSI_bar_level[0] = 0;
|
||||||
gVFO_RSSI_bar_level[1] = 0;
|
gVFO_RSSI_bar_level[1] = 0;
|
||||||
|
} else if (PreviousFunction != FUNCTION_RECEIVE) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if (PreviousFunction != FUNCTION_RECEIVE)
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if defined(ENABLE_FMRADIO)
|
#if defined(ENABLE_FMRADIO)
|
||||||
if (gFmRadioMode)
|
if (gFmRadioMode)
|
||||||
@@ -129,17 +115,9 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
return;
|
}
|
||||||
|
|
||||||
case FUNCTION_MONITOR:
|
void FUNCTION_PowerSave() {
|
||||||
gMonitor = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FUNCTION_INCOMING:
|
|
||||||
case FUNCTION_RECEIVE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FUNCTION_POWER_SAVE:
|
|
||||||
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
|
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
|
||||||
gPowerSaveCountdownExpired = false;
|
gPowerSaveCountdownExpired = false;
|
||||||
|
|
||||||
@@ -156,11 +134,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
|||||||
|
|
||||||
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
void FUNCTION_Transmit()
|
||||||
|
{
|
||||||
case FUNCTION_TRANSMIT:
|
|
||||||
|
|
||||||
// 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();
|
||||||
|
|
||||||
@@ -171,19 +148,16 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
|||||||
|
|
||||||
// clear the DTMF RX live decoder buffer
|
// clear the DTMF RX live decoder buffer
|
||||||
gDTMF_RX_live_timeout = 0;
|
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));
|
||||||
|
|
||||||
#if defined(ENABLE_FMRADIO)
|
#if defined(ENABLE_FMRADIO)
|
||||||
if (gFmRadioMode)
|
if (gFmRadioMode)
|
||||||
BK1080_Init(0, false);
|
BK1080_Init0();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_ALARM
|
#ifdef ENABLE_ALARM
|
||||||
if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE)
|
if (gAlarmState == ALARM_STATE_SITE_ALARM)
|
||||||
{
|
{
|
||||||
gAlarmState = ALARM_STATE_ALARM;
|
|
||||||
|
|
||||||
GUI_DisplayScreen();
|
GUI_DisplayScreen();
|
||||||
|
|
||||||
AUDIO_AudioPathOff();
|
AUDIO_AudioPathOff();
|
||||||
@@ -200,7 +174,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
|||||||
BK4819_ExitTxMute();
|
BK4819_ExitTxMute();
|
||||||
|
|
||||||
gAlarmToneCounter = 0;
|
gAlarmToneCounter = 0;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -219,23 +193,24 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
|||||||
BK4819_PlaySingleTone(2525, 250, 0, gEeprom.DTMF_SIDE_TONE);
|
BK4819_PlaySingleTone(2525, 250, 0, gEeprom.DTMF_SIDE_TONE);
|
||||||
|
|
||||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
if (gAlarmState != ALARM_STATE_OFF)
|
if (gAlarmState != ALARM_STATE_OFF) {
|
||||||
{
|
|
||||||
#ifdef ENABLE_TX1750
|
#ifdef ENABLE_TX1750
|
||||||
if (gAlarmState == ALARM_STATE_TX1750)
|
if (gAlarmState == ALARM_STATE_TX1750)
|
||||||
BK4819_TransmitTone(true, 1750);
|
BK4819_TransmitTone(true, 1750);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_ALARM
|
#ifdef ENABLE_ALARM
|
||||||
if (gAlarmState == ALARM_STATE_TXALARM)
|
if (gAlarmState == ALARM_STATE_TXALARM)
|
||||||
BK4819_TransmitTone(true, 500);
|
BK4819_TransmitTone(true, 500);
|
||||||
#endif
|
|
||||||
SYSTEM_DelayMs(2);
|
|
||||||
AUDIO_AudioPathOn();
|
|
||||||
#ifdef ENABLE_ALARM
|
|
||||||
gAlarmToneCounter = 0;
|
gAlarmToneCounter = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SYSTEM_DelayMs(2);
|
||||||
|
AUDIO_AudioPathOn();
|
||||||
gEnableSpeaker = true;
|
gEnableSpeaker = true;
|
||||||
break;
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -244,13 +219,47 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
|||||||
else
|
else
|
||||||
BK4819_DisableScramble();
|
BK4819_DisableScramble();
|
||||||
|
|
||||||
if (gSetting_backlight_on_tx_rx == BACKLIGHT_ON_TR_TX ||
|
if (gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX) {
|
||||||
gSetting_backlight_on_tx_rx == BACKLIGHT_ON_TR_TXRX)
|
|
||||||
BACKLIGHT_TurnOn();
|
BACKLIGHT_TurnOn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void FUNCTION_Select(FUNCTION_Type_t Function)
|
||||||
|
{
|
||||||
|
const FUNCTION_Type_t PreviousFunction = gCurrentFunction;
|
||||||
|
const bool bWasPowerSave = PreviousFunction == FUNCTION_POWER_SAVE;
|
||||||
|
|
||||||
|
gCurrentFunction = Function;
|
||||||
|
|
||||||
|
if (bWasPowerSave && Function != FUNCTION_POWER_SAVE) {
|
||||||
|
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
|
||||||
|
gRxIdleMode = false;
|
||||||
|
UI_DisplayStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Function) {
|
||||||
|
case FUNCTION_FOREGROUND:
|
||||||
|
FUNCTION_Foreground(PreviousFunction);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case FUNCTION_POWER_SAVE:
|
||||||
|
FUNCTION_PowerSave();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case FUNCTION_TRANSMIT:
|
||||||
|
FUNCTION_Transmit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FUNCTION_MONITOR:
|
||||||
|
gMonitor = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FUNCTION_INCOMING:
|
||||||
|
case FUNCTION_RECEIVE:
|
||||||
case FUNCTION_BAND_SCOPE:
|
case FUNCTION_BAND_SCOPE:
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,6 +267,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
|||||||
gSchedulePowerSave = false;
|
gSchedulePowerSave = false;
|
||||||
|
|
||||||
#if defined(ENABLE_FMRADIO)
|
#if defined(ENABLE_FMRADIO)
|
||||||
|
if(Function != FUNCTION_INCOMING)
|
||||||
gFM_RestoreCountdown_10ms = 0;
|
gFM_RestoreCountdown_10ms = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ enum FUNCTION_Type_t
|
|||||||
FUNCTION_INCOMING, // receiving a signal (squelch is open)
|
FUNCTION_INCOMING, // receiving a signal (squelch is open)
|
||||||
FUNCTION_RECEIVE, // RX mode, squelch closed
|
FUNCTION_RECEIVE, // RX mode, squelch closed
|
||||||
FUNCTION_POWER_SAVE, // sleeping
|
FUNCTION_POWER_SAVE, // sleeping
|
||||||
FUNCTION_BAND_SCOPE // bandscope mode (panadpter/spectrum) .. not yet implemented
|
FUNCTION_BAND_SCOPE, // bandscope mode (panadpter/spectrum) .. not yet implemented
|
||||||
|
FUNCTION_N_ELEM
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum FUNCTION_Type_t FUNCTION_Type_t;
|
typedef enum FUNCTION_Type_t FUNCTION_Type_t;
|
||||||
@@ -36,6 +37,6 @@ extern FUNCTION_Type_t gCurrentFunction;
|
|||||||
|
|
||||||
void FUNCTION_Init(void);
|
void FUNCTION_Init(void);
|
||||||
void FUNCTION_Select(FUNCTION_Type_t Function);
|
void FUNCTION_Select(FUNCTION_Type_t Function);
|
||||||
|
bool FUNCTION_IsRx();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
#include "driver/backlight.h"
|
#include "driver/backlight.h"
|
||||||
#include "driver/st7565.h"
|
#include "driver/st7565.h"
|
||||||
@@ -49,48 +51,45 @@ const uint16_t lowBatteryPeriod = 30;
|
|||||||
volatile uint16_t gPowerSave_10ms;
|
volatile uint16_t gPowerSave_10ms;
|
||||||
|
|
||||||
|
|
||||||
unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV)
|
const uint16_t Voltage2PercentageTable[][7][2] = {
|
||||||
{
|
[BATTERY_TYPE_1600_MAH] = {
|
||||||
const uint16_t crv1600[][2] = {
|
|
||||||
{828, 100},
|
{828, 100},
|
||||||
{814, 97 },
|
{814, 97 },
|
||||||
{760, 25 },
|
{760, 25 },
|
||||||
{729, 6 },
|
{729, 6 },
|
||||||
{630, 0 },
|
{630, 0 },
|
||||||
{0, 0 }
|
{0, 0 },
|
||||||
};
|
{0, 0 },
|
||||||
|
},
|
||||||
|
|
||||||
const uint16_t crv2200[][2] = {
|
[BATTERY_TYPE_2200_MAH] = {
|
||||||
{832, 100},
|
{832, 100},
|
||||||
{813, 95 },
|
{813, 95 },
|
||||||
{740, 60 },
|
{740, 60 },
|
||||||
{707, 21 },
|
{707, 21 },
|
||||||
{682, 5 },
|
{682, 5 },
|
||||||
{630, 0 },
|
{630, 0 },
|
||||||
{0, 0 }
|
{0, 0 },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const BATTERY_Type_t type = gEeprom.BATTERY_TYPE;
|
static_assert(ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_1600_MAH]) ==
|
||||||
const uint16_t(*crv)[2];
|
ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_2200_MAH]));
|
||||||
uint8_t size;
|
|
||||||
if (type == BATTERY_TYPE_2200_MAH) {
|
|
||||||
crv = crv2200;
|
|
||||||
size = ARRAY_SIZE(crv2200);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
crv = crv1600;
|
|
||||||
size = ARRAY_SIZE(crv1600);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV)
|
||||||
|
{
|
||||||
|
const uint16_t (*crv)[2] = Voltage2PercentageTable[gEeprom.BATTERY_TYPE];
|
||||||
const int mulipl = 1000;
|
const int mulipl = 1000;
|
||||||
for (int i = 1; i < size; i++) {
|
for (unsigned int i = 1; i < ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_2200_MAH]); i++) {
|
||||||
if (voltage_10mV > crv[i][0]) {
|
if (voltage_10mV > crv[i][0]) {
|
||||||
int a = (crv[i - 1][1] - crv[i][1]) * mulipl / (crv[i - 1][0] - crv[i][0]);
|
const int a = (crv[i - 1][1] - crv[i][1]) * mulipl / (crv[i - 1][0] - crv[i][0]);
|
||||||
int b = crv[i][1] - a * crv[i][0] / mulipl;
|
const int b = crv[i][1] - a * crv[i][0] / mulipl;
|
||||||
int p = a * voltage_10mV / mulipl + b;
|
const int p = a * voltage_10mV / mulipl + b;
|
||||||
return MIN(p, 100);
|
return MIN(p, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,8 +98,6 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
|
|||||||
const uint8_t PreviousBatteryLevel = gBatteryDisplayLevel;
|
const uint8_t PreviousBatteryLevel = gBatteryDisplayLevel;
|
||||||
const uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4;
|
const uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3];
|
gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3];
|
||||||
|
|
||||||
if(gBatteryVoltageAverage > 890)
|
if(gBatteryVoltageAverage > 890)
|
||||||
@@ -170,54 +167,59 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
|
|||||||
|
|
||||||
void BATTERY_TimeSlice500ms(void)
|
void BATTERY_TimeSlice500ms(void)
|
||||||
{
|
{
|
||||||
if (gLowBattery)
|
if (!gLowBattery) {
|
||||||
{
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gLowBatteryBlink = ++lowBatteryCountdown & 1;
|
gLowBatteryBlink = ++lowBatteryCountdown & 1;
|
||||||
|
|
||||||
UI_DisplayBattery(0, gLowBatteryBlink);
|
UI_DisplayBattery(0, gLowBatteryBlink);
|
||||||
|
|
||||||
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
if (gCurrentFunction == FUNCTION_TRANSMIT) {
|
||||||
{ // not transmitting
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (lowBatteryCountdown < lowBatteryPeriod)
|
// not transmitting
|
||||||
{
|
|
||||||
if (lowBatteryCountdown == lowBatteryPeriod-1 && !gChargingWithTypeC && !gLowBatteryConfirmed)
|
if (lowBatteryCountdown < lowBatteryPeriod) {
|
||||||
|
if (lowBatteryCountdown == lowBatteryPeriod-1 && !gChargingWithTypeC && !gLowBatteryConfirmed) {
|
||||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
||||||
}
|
}
|
||||||
else
|
return;
|
||||||
{
|
}
|
||||||
|
|
||||||
lowBatteryCountdown = 0;
|
lowBatteryCountdown = 0;
|
||||||
|
|
||||||
if (!gChargingWithTypeC)
|
if (gChargingWithTypeC) {
|
||||||
{ // not on charge
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not on charge
|
||||||
if (!gLowBatteryConfirmed) {
|
if (!gLowBatteryConfirmed) {
|
||||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE);
|
AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (gBatteryDisplayLevel == 0)
|
|
||||||
{
|
if (gBatteryDisplayLevel != 0) {
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
AUDIO_PlaySingleVoice(false);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
AUDIO_PlaySingleVoice(true);
|
AUDIO_PlaySingleVoice(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gReducedService = true;
|
gReducedService = true;
|
||||||
|
|
||||||
//if (gCurrentFunction != FUNCTION_POWER_SAVE)
|
|
||||||
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
||||||
|
|
||||||
ST7565_HardwareReset();
|
ST7565_HardwareReset();
|
||||||
|
|
||||||
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
|
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) {
|
||||||
BACKLIGHT_TurnOff(); // turn the backlight off
|
BACKLIGHT_TurnOff();
|
||||||
}
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
else
|
|
||||||
AUDIO_PlaySingleVoice(false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,9 +40,9 @@ typedef enum {
|
|||||||
BATTERY_TYPE_UNKNOWN
|
BATTERY_TYPE_UNKNOWN
|
||||||
} BATTERY_Type_t;
|
} BATTERY_Type_t;
|
||||||
|
|
||||||
unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV);
|
|
||||||
void BATTERY_GetReadings(const bool bDisplayBatteryLevel);
|
unsigned int BATTERY_VoltsToPercent(unsigned int voltage_10mV);
|
||||||
|
void BATTERY_GetReadings(bool bDisplayBatteryLevel);
|
||||||
void BATTERY_TimeSlice500ms(void);
|
void BATTERY_TimeSlice500ms(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 9.7 KiB |
BIN
images/codespace1.png
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
images/codespace2.png
Normal file
|
After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
BIN
images/main.jpg
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 9.4 KiB |
9
init.c
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
extern uint32_t __bss_start__[];
|
extern uint32_t __bss_start__[];
|
||||||
extern uint32_t __bss_end__[];
|
extern uint32_t __bss_end__[];
|
||||||
@@ -29,18 +30,18 @@ void DATA_Init(void);
|
|||||||
|
|
||||||
void BSS_Init(void)
|
void BSS_Init(void)
|
||||||
{
|
{
|
||||||
uint32_t *pBss;
|
for (uint32_t *pBss = __bss_start__; pBss < __bss_end__; pBss++) {
|
||||||
for (pBss = __bss_start__; pBss < __bss_end__; pBss++)
|
|
||||||
*pBss = 0;
|
*pBss = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DATA_Init(void)
|
void DATA_Init(void)
|
||||||
{
|
{
|
||||||
volatile uint32_t *pDataRam = (volatile uint32_t *)sram_data_start;
|
volatile uint32_t *pDataRam = (volatile uint32_t *)sram_data_start;
|
||||||
volatile uint32_t *pDataFlash = (volatile uint32_t *)flash_data_start;
|
volatile uint32_t *pDataFlash = (volatile uint32_t *)flash_data_start;
|
||||||
uint32_t Size = (uint32_t)sram_data_end - (uint32_t)sram_data_start;
|
uint32_t Size = (uint32_t)sram_data_end - (uint32_t)sram_data_start;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < (Size / 4); i++)
|
for (unsigned int i = 0; i < (Size / 4); i++) {
|
||||||
*pDataRam++ = *pDataFlash++;
|
*pDataRam++ = *pDataFlash++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
70
main.c
@@ -14,44 +14,52 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h> // NULL
|
#include <stdio.h> // NULL
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
#include "am_fix.h"
|
#include "am_fix.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "audio.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "radio.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/dtmf.h"
|
#include "app/dtmf.h"
|
||||||
#include "audio.h"
|
|
||||||
#include "bsp/dp32g030/gpio.h"
|
#include "bsp/dp32g030/gpio.h"
|
||||||
#include "bsp/dp32g030/syscon.h"
|
#include "bsp/dp32g030/syscon.h"
|
||||||
#include "board.h"
|
|
||||||
#include "driver/backlight.h"
|
#include "driver/backlight.h"
|
||||||
#include "driver/bk4819.h"
|
#include "driver/bk4819.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "driver/system.h"
|
#include "driver/system.h"
|
||||||
#include "driver/systick.h"
|
#include "driver/systick.h"
|
||||||
|
#ifdef ENABLE_UART
|
||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "helper/battery.h"
|
#include "helper/battery.h"
|
||||||
#include "helper/boot.h"
|
#include "helper/boot.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "radio.h"
|
|
||||||
#include "settings.h"
|
|
||||||
#include "ui/lock.h"
|
#include "ui/lock.h"
|
||||||
#include "ui/welcome.h"
|
#include "ui/welcome.h"
|
||||||
#include "ui/menu.h"
|
#include "ui/menu.h"
|
||||||
#include "version.h"
|
void _putchar(__attribute__((unused)) char c)
|
||||||
|
|
||||||
void _putchar(char c)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef ENABLE_UART
|
||||||
UART_Send((uint8_t *)&c, 1);
|
UART_Send((uint8_t *)&c, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main(void)
|
void Main(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
BOOT_Mode_t BootMode;
|
|
||||||
|
|
||||||
// Enable clock gating of blocks we need
|
// Enable clock gating of blocks we need
|
||||||
SYSCON_DEV_CLK_GATE = 0
|
SYSCON_DEV_CLK_GATE = 0
|
||||||
| SYSCON_DEV_CLK_GATE_GPIOA_BITS_ENABLE
|
| SYSCON_DEV_CLK_GATE_GPIOA_BITS_ENABLE
|
||||||
@@ -64,18 +72,19 @@ void Main(void)
|
|||||||
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE
|
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE
|
||||||
| SYSCON_DEV_CLK_GATE_PWM_PLUS0_BITS_ENABLE;
|
| SYSCON_DEV_CLK_GATE_PWM_PLUS0_BITS_ENABLE;
|
||||||
|
|
||||||
|
|
||||||
SYSTICK_Init();
|
SYSTICK_Init();
|
||||||
BOARD_Init();
|
BOARD_Init();
|
||||||
UART_Init();
|
|
||||||
|
|
||||||
boot_counter_10ms = 250; // 2.5 sec
|
boot_counter_10ms = 250; // 2.5 sec
|
||||||
|
|
||||||
|
#ifdef ENABLE_UART
|
||||||
|
UART_Init();
|
||||||
UART_Send(UART_Version, strlen(UART_Version));
|
UART_Send(UART_Version, strlen(UART_Version));
|
||||||
|
#endif
|
||||||
|
|
||||||
// Not implementing authentic device checks
|
// Not implementing authentic device checks
|
||||||
|
|
||||||
memset(&gEeprom, 0, sizeof(gEeprom));
|
|
||||||
|
|
||||||
memset(gDTMF_String, '-', sizeof(gDTMF_String));
|
memset(gDTMF_String, '-', sizeof(gDTMF_String));
|
||||||
gDTMF_String[sizeof(gDTMF_String) - 1] = 0;
|
gDTMF_String[sizeof(gDTMF_String) - 1] = 0;
|
||||||
|
|
||||||
@@ -83,9 +92,9 @@ void Main(void)
|
|||||||
|
|
||||||
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);
|
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);
|
||||||
|
|
||||||
BOARD_EEPROM_Init();
|
SETTINGS_InitEEPROM();
|
||||||
|
SETTINGS_WriteBuildOptions();
|
||||||
BOARD_EEPROM_LoadCalibration();
|
SETTINGS_LoadCalibration();
|
||||||
|
|
||||||
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
|
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
|
||||||
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
|
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
|
||||||
@@ -94,7 +103,7 @@ void Main(void)
|
|||||||
|
|
||||||
RADIO_SetupRegisters(true);
|
RADIO_SetupRegisters(true);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(gBatteryVoltages); i++)
|
for (unsigned int i = 0; i < ARRAY_SIZE(gBatteryVoltages); i++)
|
||||||
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent);
|
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent);
|
||||||
|
|
||||||
BATTERY_GetReadings(false);
|
BATTERY_GetReadings(false);
|
||||||
@@ -103,7 +112,7 @@ void Main(void)
|
|||||||
AM_fix_init();
|
AM_fix_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BootMode = BOOT_GetMode();
|
const BOOT_Mode_t BootMode = BOOT_GetMode();
|
||||||
|
|
||||||
if (BootMode == BOOT_MODE_F_LOCK)
|
if (BootMode == BOOT_MODE_F_LOCK)
|
||||||
{
|
{
|
||||||
@@ -126,8 +135,9 @@ void Main(void)
|
|||||||
{ // keys are pressed
|
{ // keys are pressed
|
||||||
UI_DisplayReleaseKeys();
|
UI_DisplayReleaseKeys();
|
||||||
BACKLIGHT_TurnOn();
|
BACKLIGHT_TurnOn();
|
||||||
i = 0;
|
|
||||||
while (i < 50) // 500ms
|
// 500ms
|
||||||
|
for (int i = 0; i < 50;)
|
||||||
{
|
{
|
||||||
i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0;
|
i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0;
|
||||||
SYSTEM_DelayMs(10);
|
SYSTEM_DelayMs(10);
|
||||||
@@ -207,24 +217,18 @@ void Main(void)
|
|||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
RADIO_ConfigureNOAA();
|
RADIO_ConfigureNOAA();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ******************
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1)
|
while (true) {
|
||||||
{
|
|
||||||
APP_Update();
|
APP_Update();
|
||||||
|
|
||||||
if (gNextTimeslice)
|
if (gNextTimeslice) {
|
||||||
{
|
|
||||||
APP_TimeSlice10ms();
|
|
||||||
gNextTimeslice = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gNextTimeslice_500ms)
|
APP_TimeSlice10ms();
|
||||||
{
|
|
||||||
|
if (gNextTimeslice_500ms) {
|
||||||
APP_TimeSlice500ms();
|
APP_TimeSlice500ms();
|
||||||
gNextTimeslice_500ms = false;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
misc.c
@@ -89,14 +89,12 @@ bool gSetting_350EN;
|
|||||||
uint8_t gSetting_F_LOCK;
|
uint8_t gSetting_F_LOCK;
|
||||||
bool gSetting_ScrambleEnable;
|
bool gSetting_ScrambleEnable;
|
||||||
|
|
||||||
uint8_t gSetting_backlight_on_tx_rx;
|
enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
bool gSetting_AM_fix;
|
bool gSetting_AM_fix;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
uint8_t gSetting_AM_fix_test1 = 0;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_AUDIO_BAR
|
#ifdef ENABLE_AUDIO_BAR
|
||||||
bool gSetting_mic_bar;
|
bool gSetting_mic_bar;
|
||||||
#endif
|
#endif
|
||||||
@@ -134,7 +132,7 @@ volatile bool gNextTimeslice_500ms;
|
|||||||
volatile uint16_t gTxTimerCountdown_500ms;
|
volatile uint16_t gTxTimerCountdown_500ms;
|
||||||
volatile bool gTxTimeoutReached;
|
volatile bool gTxTimeoutReached;
|
||||||
|
|
||||||
volatile uint16_t gTailNoteEliminationCountdown_10ms;
|
volatile uint16_t gTailToneEliminationCountdown_10ms;
|
||||||
|
|
||||||
volatile uint8_t gVFOStateResumeCountdown_500ms;
|
volatile uint8_t gVFOStateResumeCountdown_500ms;
|
||||||
|
|
||||||
@@ -145,7 +143,7 @@ volatile uint8_t gVFOStateResumeCountdown_500ms;
|
|||||||
bool gEnableSpeaker;
|
bool gEnableSpeaker;
|
||||||
uint8_t gKeyInputCountdown = 0;
|
uint8_t gKeyInputCountdown = 0;
|
||||||
uint8_t gKeyLockCountdown;
|
uint8_t gKeyLockCountdown;
|
||||||
uint8_t gRTTECountdown;
|
uint8_t gRTTECountdown_10ms;
|
||||||
bool bIsInLockScreen;
|
bool bIsInLockScreen;
|
||||||
uint8_t gUpdateStatus;
|
uint8_t gUpdateStatus;
|
||||||
uint8_t gFoundCTCSS;
|
uint8_t gFoundCTCSS;
|
||||||
@@ -162,7 +160,6 @@ bool gCssBackgroundScan;
|
|||||||
volatile bool gScheduleScanListen = true;
|
volatile bool gScheduleScanListen = true;
|
||||||
volatile uint16_t gScanPauseDelayIn_10ms;
|
volatile uint16_t gScanPauseDelayIn_10ms;
|
||||||
|
|
||||||
bool gUpdateRSSI;
|
|
||||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
AlarmState_t gAlarmState;
|
AlarmState_t gAlarmState;
|
||||||
#endif
|
#endif
|
||||||
@@ -184,9 +181,6 @@ bool gFlagPrepareTX;
|
|||||||
bool gFlagAcceptSetting;
|
bool gFlagAcceptSetting;
|
||||||
bool gFlagRefreshSetting;
|
bool gFlagRefreshSetting;
|
||||||
|
|
||||||
bool gFlagSaveVfo;
|
|
||||||
bool gFlagSaveSettings;
|
|
||||||
bool gFlagSaveChannel;
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
bool gFlagSaveFM;
|
bool gFlagSaveFM;
|
||||||
#endif
|
#endif
|
||||||
@@ -201,8 +195,9 @@ bool g_CxCSS_TAIL_Found;
|
|||||||
uint16_t gVoxPauseCountdown;
|
uint16_t gVoxPauseCountdown;
|
||||||
#endif
|
#endif
|
||||||
bool g_SquelchLost;
|
bool g_SquelchLost;
|
||||||
uint8_t gFlashLightState;
|
|
||||||
volatile uint16_t gFlashLightBlinkCounter;
|
volatile uint16_t gFlashLightBlinkCounter;
|
||||||
|
|
||||||
bool gFlagEndTransmission;
|
bool gFlagEndTransmission;
|
||||||
uint8_t gNextMrChannel;
|
uint8_t gNextMrChannel;
|
||||||
ReceptionMode_t gRxReceptionMode;
|
ReceptionMode_t gRxReceptionMode;
|
||||||
@@ -218,9 +213,6 @@ uint8_t gPttDebounceCounter;
|
|||||||
uint8_t gMenuListCount;
|
uint8_t gMenuListCount;
|
||||||
uint8_t gBackup_CROSS_BAND_RX_TX;
|
uint8_t gBackup_CROSS_BAND_RX_TX;
|
||||||
uint8_t gScanDelay_10ms;
|
uint8_t gScanDelay_10ms;
|
||||||
#ifdef ENABLE_AIRCOPY
|
|
||||||
uint8_t gAircopySendCountdown;
|
|
||||||
#endif
|
|
||||||
uint8_t gFSKWriteIndex;
|
uint8_t gFSKWriteIndex;
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
@@ -245,18 +237,18 @@ volatile bool gNextTimeslice40ms;
|
|||||||
volatile uint16_t gNOAACountdown_10ms = 0;
|
volatile uint16_t gNOAACountdown_10ms = 0;
|
||||||
volatile bool gScheduleNOAA = true;
|
volatile bool gScheduleNOAA = true;
|
||||||
#endif
|
#endif
|
||||||
volatile bool gFlagTailNoteEliminationComplete;
|
volatile bool gFlagTailToneEliminationComplete;
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
volatile bool gScheduleFM;
|
volatile bool gScheduleFM;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
volatile uint8_t boot_counter_10ms;
|
volatile uint8_t boot_counter_10ms;
|
||||||
|
|
||||||
int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO
|
|
||||||
|
|
||||||
uint8_t gIsLocked = 0xFF;
|
uint8_t gIsLocked = 0xFF;
|
||||||
|
|
||||||
|
|
||||||
|
inline void FUNCTION_NOP() { ; }
|
||||||
|
|
||||||
|
|
||||||
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit)
|
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit)
|
||||||
{
|
{
|
||||||
|
|||||||
44
misc.h
@@ -32,6 +32,10 @@
|
|||||||
#define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
|
#define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SWAP
|
||||||
|
#define SWAP(a, b) ({ __typeof__ (a) _c = (a); a = b; b = _c; })
|
||||||
|
#endif
|
||||||
|
|
||||||
#define IS_MR_CHANNEL(x) ((x) <= MR_CHANNEL_LAST)
|
#define IS_MR_CHANNEL(x) ((x) <= MR_CHANNEL_LAST)
|
||||||
#define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
|
#define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
|
||||||
#define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL)
|
#define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL)
|
||||||
@@ -47,13 +51,6 @@ enum {
|
|||||||
LAST_CHANNEL
|
LAST_CHANNEL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
FLASHLIGHT_OFF = 0,
|
|
||||||
FLASHLIGHT_ON,
|
|
||||||
FLASHLIGHT_BLINK,
|
|
||||||
FLASHLIGHT_SOS
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
VFO_CONFIGURE_NONE = 0,
|
VFO_CONFIGURE_NONE = 0,
|
||||||
VFO_CONFIGURE,
|
VFO_CONFIGURE,
|
||||||
@@ -63,7 +60,7 @@ enum {
|
|||||||
enum AlarmState_t {
|
enum AlarmState_t {
|
||||||
ALARM_STATE_OFF = 0,
|
ALARM_STATE_OFF = 0,
|
||||||
ALARM_STATE_TXALARM,
|
ALARM_STATE_TXALARM,
|
||||||
ALARM_STATE_ALARM,
|
ALARM_STATE_SITE_ALARM,
|
||||||
ALARM_STATE_TX1750
|
ALARM_STATE_TX1750
|
||||||
};
|
};
|
||||||
typedef enum AlarmState_t AlarmState_t;
|
typedef enum AlarmState_t AlarmState_t;
|
||||||
@@ -153,14 +150,12 @@ extern bool gSetting_350EN;
|
|||||||
extern uint8_t gSetting_F_LOCK;
|
extern uint8_t gSetting_F_LOCK;
|
||||||
extern bool gSetting_ScrambleEnable;
|
extern bool gSetting_ScrambleEnable;
|
||||||
|
|
||||||
extern uint8_t gSetting_backlight_on_tx_rx;
|
extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
extern bool gSetting_AM_fix;
|
extern bool gSetting_AM_fix;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
extern uint8_t gSetting_AM_fix_test1;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_AUDIO_BAR
|
#ifdef ENABLE_AUDIO_BAR
|
||||||
extern bool gSetting_mic_bar;
|
extern bool gSetting_mic_bar;
|
||||||
#endif
|
#endif
|
||||||
@@ -210,18 +205,15 @@ extern volatile bool gNextTimeslice_500ms;
|
|||||||
extern volatile uint16_t gTxTimerCountdown_500ms;
|
extern volatile uint16_t gTxTimerCountdown_500ms;
|
||||||
extern volatile bool gTxTimeoutReached;
|
extern volatile bool gTxTimeoutReached;
|
||||||
|
|
||||||
extern volatile uint16_t gTailNoteEliminationCountdown_10ms;
|
extern volatile uint16_t gTailToneEliminationCountdown_10ms;
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
extern volatile uint16_t gFmPlayCountdown_10ms;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
extern volatile uint16_t gNOAA_Countdown_10ms;
|
extern volatile uint16_t gNOAA_Countdown_10ms;
|
||||||
#endif
|
#endif
|
||||||
extern bool gEnableSpeaker;
|
extern bool gEnableSpeaker;
|
||||||
extern uint8_t gKeyInputCountdown;
|
extern uint8_t gKeyInputCountdown;
|
||||||
extern uint8_t gKeyLockCountdown;
|
extern uint8_t gKeyLockCountdown;
|
||||||
extern uint8_t gRTTECountdown;
|
extern uint8_t gRTTECountdown_10ms;
|
||||||
extern bool bIsInLockScreen;
|
extern bool bIsInLockScreen;
|
||||||
extern uint8_t gUpdateStatus;
|
extern uint8_t gUpdateStatus;
|
||||||
extern uint8_t gFoundCTCSS;
|
extern uint8_t gFoundCTCSS;
|
||||||
@@ -249,7 +241,6 @@ enum
|
|||||||
extern volatile bool gScheduleScanListen;
|
extern volatile bool gScheduleScanListen;
|
||||||
extern volatile uint16_t gScanPauseDelayIn_10ms;
|
extern volatile uint16_t gScanPauseDelayIn_10ms;
|
||||||
|
|
||||||
extern bool gUpdateRSSI;
|
|
||||||
extern AlarmState_t gAlarmState;
|
extern AlarmState_t gAlarmState;
|
||||||
extern uint16_t gMenuCountdown;
|
extern uint16_t gMenuCountdown;
|
||||||
extern bool gPttWasReleased;
|
extern bool gPttWasReleased;
|
||||||
@@ -269,9 +260,6 @@ extern bool gFlagPrepareTX;
|
|||||||
extern bool gFlagAcceptSetting; // accept menu setting
|
extern bool gFlagAcceptSetting; // accept menu setting
|
||||||
extern bool gFlagRefreshSetting; // refresh menu display
|
extern bool gFlagRefreshSetting; // refresh menu display
|
||||||
|
|
||||||
extern bool gFlagSaveVfo;
|
|
||||||
extern bool gFlagSaveSettings;
|
|
||||||
extern bool gFlagSaveChannel;
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
extern bool gFlagSaveFM;
|
extern bool gFlagSaveFM;
|
||||||
#endif
|
#endif
|
||||||
@@ -288,8 +276,9 @@ extern bool g_CxCSS_TAIL_Found;
|
|||||||
|
|
||||||
// true means we are receiving signal
|
// true means we are receiving signal
|
||||||
extern bool g_SquelchLost;
|
extern bool g_SquelchLost;
|
||||||
extern uint8_t gFlashLightState;
|
|
||||||
extern volatile uint16_t gFlashLightBlinkCounter;
|
extern volatile uint16_t gFlashLightBlinkCounter;
|
||||||
|
|
||||||
extern bool gFlagEndTransmission;
|
extern bool gFlagEndTransmission;
|
||||||
extern uint8_t gNextMrChannel;
|
extern uint8_t gNextMrChannel;
|
||||||
extern ReceptionMode_t gRxReceptionMode;
|
extern ReceptionMode_t gRxReceptionMode;
|
||||||
@@ -304,9 +293,6 @@ extern uint8_t gPttDebounceCounter;
|
|||||||
extern uint8_t gMenuListCount;
|
extern uint8_t gMenuListCount;
|
||||||
extern uint8_t gBackup_CROSS_BAND_RX_TX;
|
extern uint8_t gBackup_CROSS_BAND_RX_TX;
|
||||||
extern uint8_t gScanDelay_10ms;
|
extern uint8_t gScanDelay_10ms;
|
||||||
#ifdef ENABLE_AIRCOPY
|
|
||||||
extern uint8_t gAircopySendCountdown;
|
|
||||||
#endif
|
|
||||||
extern uint8_t gFSKWriteIndex;
|
extern uint8_t gFSKWriteIndex;
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
extern bool gIsNoaaMode;
|
extern bool gIsNoaaMode;
|
||||||
@@ -329,17 +315,19 @@ extern volatile bool gNextTimeslice40ms;
|
|||||||
extern volatile uint16_t gNOAACountdown_10ms;
|
extern volatile uint16_t gNOAACountdown_10ms;
|
||||||
extern volatile bool gScheduleNOAA;
|
extern volatile bool gScheduleNOAA;
|
||||||
#endif
|
#endif
|
||||||
extern volatile bool gFlagTailNoteEliminationComplete;
|
extern volatile bool gFlagTailToneEliminationComplete;
|
||||||
extern volatile uint8_t gVFOStateResumeCountdown_500ms;
|
extern volatile uint8_t gVFOStateResumeCountdown_500ms;
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
extern volatile bool gScheduleFM;
|
extern volatile bool gScheduleFM;
|
||||||
#endif
|
#endif
|
||||||
extern int16_t gCurrentRSSI[2]; // now one per VFO
|
|
||||||
extern uint8_t gIsLocked;
|
extern uint8_t gIsLocked;
|
||||||
extern volatile uint8_t boot_counter_10ms;
|
extern volatile uint8_t boot_counter_10ms;
|
||||||
|
|
||||||
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
||||||
unsigned long StrToUL(const char * str);
|
unsigned long StrToUL(const char * str);
|
||||||
|
|
||||||
#endif
|
void FUNCTION_NOP();
|
||||||
|
|
||||||
|
inline bool SerialConfigInProgress() { return gSerialConfigCountDown_500ms != 0; }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
385
radio.c
@@ -14,8 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "driver/bk4819-regs.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "am_fix.h"
|
||||||
#include "app/dtmf.h"
|
#include "app/dtmf.h"
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
#include "app/fm.h"
|
#include "app/fm.h"
|
||||||
@@ -41,81 +43,54 @@ VFO_Info_t *gCurrentVfo;
|
|||||||
DCS_CodeType_t gCurrentCodeType;
|
DCS_CodeType_t gCurrentCodeType;
|
||||||
VfoState_t VfoState[2];
|
VfoState_t VfoState[2];
|
||||||
|
|
||||||
const char gModulationStr[][4] =
|
const char gModulationStr[MODULATION_UKNOWN][4] = {
|
||||||
{
|
[MODULATION_FM]="FM",
|
||||||
"FM",
|
[MODULATION_AM]="AM",
|
||||||
"AM",
|
[MODULATION_USB]="USB",
|
||||||
"USB",
|
|
||||||
|
|
||||||
#ifdef ENABLE_BYP_RAW_DEMODULATORS
|
#ifdef ENABLE_BYP_RAW_DEMODULATORS
|
||||||
"BYP",
|
[MODULATION_BYP]="BYP",
|
||||||
"RAW"
|
[MODULATION_RAW]="RAW"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
|
|
||||||
{ // return true if the channel appears valid
|
|
||||||
|
|
||||||
ChannelAttributes_t att;
|
|
||||||
uint8_t PriorityCh1;
|
|
||||||
uint8_t PriorityCh2;
|
|
||||||
|
|
||||||
if (!IS_MR_CHANNEL(Channel))
|
bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanList)
|
||||||
|
{
|
||||||
|
// return true if the channel appears valid
|
||||||
|
if (!IS_MR_CHANNEL(channel))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
att = gMR_ChannelAttributes[Channel];
|
const ChannelAttributes_t att = gMR_ChannelAttributes[channel];
|
||||||
|
|
||||||
if (att.band > BAND7_470MHz)
|
if (att.band > BAND7_470MHz)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (bCheckScanList) {
|
if (!checkScanList || scanList > 1)
|
||||||
switch (VFO) {
|
|
||||||
case 0:
|
|
||||||
if (!att.scanlist1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[0];
|
|
||||||
PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[0];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (!att.scanlist2)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[1];
|
|
||||||
PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[1];
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
if (PriorityCh1 == Channel)
|
if (scanList ? !att.scanlist2 : !att.scanlist1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (PriorityCh2 == Channel)
|
const uint8_t PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[scanList];
|
||||||
return false;
|
const uint8_t PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[scanList];
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return PriorityCh1 != channel && PriorityCh2 != channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScanList, uint8_t VFO)
|
uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScanList, uint8_t VFO)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
for (unsigned int i = 0; IS_MR_CHANNEL(i); i++, Channel += Direction) {
|
||||||
|
if (Channel == 0xFF) {
|
||||||
for (i = 0; IS_MR_CHANNEL(i); i++)
|
|
||||||
{
|
|
||||||
if (Channel == 0xFF)
|
|
||||||
Channel = MR_CHANNEL_LAST;
|
Channel = MR_CHANNEL_LAST;
|
||||||
else
|
} else if (!IS_MR_CHANNEL(Channel)) {
|
||||||
if (!IS_MR_CHANNEL(Channel))
|
|
||||||
Channel = MR_CHANNEL_FIRST;
|
Channel = MR_CHANNEL_FIRST;
|
||||||
|
}
|
||||||
|
|
||||||
if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO))
|
if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO)) {
|
||||||
return Channel;
|
return Channel;
|
||||||
|
}
|
||||||
Channel += Direction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
@@ -163,7 +138,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||||||
|
|
||||||
if (IS_VALID_CHANNEL(channel)) {
|
if (IS_VALID_CHANNEL(channel)) {
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (channel >= NOAA_CHANNEL_FIRST)
|
if (IS_NOAA_CHANNEL(channel))
|
||||||
{
|
{
|
||||||
RADIO_InitInfo(pVfo, gEeprom.ScreenChannel[VFO], NoaaFrequencyTable[channel - NOAA_CHANNEL_FIRST]);
|
RADIO_InitInfo(pVfo, gEeprom.ScreenChannel[VFO], NoaaFrequencyTable[channel - NOAA_CHANNEL_FIRST]);
|
||||||
|
|
||||||
@@ -251,7 +226,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||||||
pVfo->Modulation = tmp;
|
pVfo->Modulation = tmp;
|
||||||
|
|
||||||
tmp = data[6];
|
tmp = data[6];
|
||||||
if (tmp >= ARRAY_SIZE(gStepFrequencyTable))
|
if (tmp >= STEP_N_ELEM)
|
||||||
tmp = STEP_12_5kHz;
|
tmp = STEP_12_5kHz;
|
||||||
pVfo->STEP_SETTING = tmp;
|
pVfo->STEP_SETTING = tmp;
|
||||||
pVfo->StepFrequency = gStepFrequencyTable[tmp];
|
pVfo->StepFrequency = gStepFrequencyTable[tmp];
|
||||||
@@ -336,7 +311,8 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
pVfo->DTMF_DECODING_ENABLE = ((data[5] >> 0) & 1u) ? true : false;
|
pVfo->DTMF_DECODING_ENABLE = ((data[5] >> 0) & 1u) ? true : false;
|
||||||
#endif
|
#endif
|
||||||
pVfo->DTMF_PTT_ID_TX_MODE = ((data[5] >> 1) & 7u);
|
uint8_t pttId = ((data[5] >> 1) & 7u);
|
||||||
|
pVfo->DTMF_PTT_ID_TX_MODE = pttId < ARRAY_SIZE(gSubMenu_PTT_ID) ? pttId : PTT_ID_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************
|
// ***************
|
||||||
@@ -351,8 +327,9 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||||||
else
|
else
|
||||||
pVfo->freq_config_RX.Frequency = info.Frequency;
|
pVfo->freq_config_RX.Frequency = info.Frequency;
|
||||||
|
|
||||||
if (info.Offset >= 100000000)
|
if (info.Offset >= _1GHz_in_KHz)
|
||||||
info.Offset = 1000000;
|
info.Offset = _1GHz_in_KHz / 100;
|
||||||
|
|
||||||
pVfo->TX_OFFSET_FREQUENCY = info.Offset;
|
pVfo->TX_OFFSET_FREQUENCY = info.Offset;
|
||||||
|
|
||||||
// ***************
|
// ***************
|
||||||
@@ -379,11 +356,9 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||||||
|
|
||||||
RADIO_ApplyOffset(pVfo);
|
RADIO_ApplyOffset(pVfo);
|
||||||
|
|
||||||
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), pVfo->Name + 0, 8);
|
SETTINGS_FetchChannelName(pVfo->Name, channel);
|
||||||
EEPROM_ReadBuffer(0x0F58 + (channel * 16), pVfo->Name + 8, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pVfo->FrequencyReverse)
|
if (!pVfo->FrequencyReverse)
|
||||||
@@ -404,14 +379,6 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||||||
pConfig->Frequency = 43300000;
|
pConfig->Frequency = 43300000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pVfo->Modulation != MODULATION_FM)
|
|
||||||
{ // freq/chan is in AM mode
|
|
||||||
pVfo->SCRAMBLING_TYPE = 0;
|
|
||||||
// pVfo->DTMF_DECODING_ENABLE = false; // no reason to disable DTMF decoding, aircraft use it on SSB
|
|
||||||
pVfo->freq_config_RX.CodeType = CODE_TYPE_OFF;
|
|
||||||
pVfo->freq_config_TX.CodeType = CODE_TYPE_OFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
pVfo->Compander = att.compander;
|
pVfo->Compander = att.compander;
|
||||||
|
|
||||||
RADIO_ConfigureSquelchAndOutputPower(pVfo);
|
RADIO_ConfigureSquelchAndOutputPower(pVfo);
|
||||||
@@ -419,13 +386,12 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||||||
|
|
||||||
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
|
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
|
||||||
{
|
{
|
||||||
uint8_t Txp[3];
|
|
||||||
FREQUENCY_Band_t Band;
|
|
||||||
|
|
||||||
// *******************************
|
// *******************************
|
||||||
// squelch
|
// squelch
|
||||||
|
|
||||||
Band = FREQUENCY_GetBand(pInfo->pRX->Frequency);
|
FREQUENCY_Band_t Band = FREQUENCY_GetBand(pInfo->pRX->Frequency);
|
||||||
uint16_t Base = (Band < BAND4_174MHz) ? 0x1E60 : 0x1E00;
|
uint16_t Base = (Band < BAND4_174MHz) ? 0x1E60 : 0x1E00;
|
||||||
|
|
||||||
if (gEeprom.SQUELCH_LEVEL == 0)
|
if (gEeprom.SQUELCH_LEVEL == 0)
|
||||||
@@ -451,41 +417,20 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
|
|||||||
EEPROM_ReadBuffer(Base + 0x40, &pInfo->SquelchCloseGlitchThresh, 1); // 90 90
|
EEPROM_ReadBuffer(Base + 0x40, &pInfo->SquelchCloseGlitchThresh, 1); // 90 90
|
||||||
EEPROM_ReadBuffer(Base + 0x50, &pInfo->SquelchOpenGlitchThresh, 1); // 100 100
|
EEPROM_ReadBuffer(Base + 0x50, &pInfo->SquelchOpenGlitchThresh, 1); // 100 100
|
||||||
|
|
||||||
uint16_t rssi_open = pInfo->SquelchOpenRSSIThresh;
|
|
||||||
uint16_t rssi_close = pInfo->SquelchCloseRSSIThresh;
|
|
||||||
uint16_t noise_open = pInfo->SquelchOpenNoiseThresh;
|
uint16_t noise_open = pInfo->SquelchOpenNoiseThresh;
|
||||||
uint16_t noise_close = pInfo->SquelchCloseNoiseThresh;
|
uint16_t noise_close = pInfo->SquelchCloseNoiseThresh;
|
||||||
uint16_t glitch_open = pInfo->SquelchOpenGlitchThresh;
|
|
||||||
uint16_t glitch_close = pInfo->SquelchCloseGlitchThresh;
|
|
||||||
|
|
||||||
#if ENABLE_SQUELCH_MORE_SENSITIVE
|
#if ENABLE_SQUELCH_MORE_SENSITIVE
|
||||||
// make squelch a little more sensitive
|
uint16_t rssi_open = pInfo->SquelchOpenRSSIThresh;
|
||||||
//
|
uint16_t rssi_close = pInfo->SquelchCloseRSSIThresh;
|
||||||
// getting the best setting here is still experimental, bare with me
|
uint16_t glitch_open = pInfo->SquelchOpenGlitchThresh;
|
||||||
//
|
uint16_t glitch_close = pInfo->SquelchCloseGlitchThresh;
|
||||||
|
// make squelch more sensitive
|
||||||
// note that 'noise' and 'glitch' values are inverted compared to 'rssi' values
|
// note that 'noise' and 'glitch' values are inverted compared to 'rssi' values
|
||||||
|
|
||||||
#if 0
|
|
||||||
rssi_open = (rssi_open * 8) / 9;
|
|
||||||
noise_open = (noise_open * 9) / 8;
|
|
||||||
glitch_open = (glitch_open * 9) / 8;
|
|
||||||
#else
|
|
||||||
// even more sensitive .. use when RX bandwidths are fixed (no weak signal auto adjust)
|
|
||||||
rssi_open = (rssi_open * 1) / 2;
|
rssi_open = (rssi_open * 1) / 2;
|
||||||
noise_open = (noise_open * 2) / 1;
|
noise_open = (noise_open * 2) / 1;
|
||||||
glitch_open = (glitch_open * 2) / 1;
|
glitch_open = (glitch_open * 2) / 1;
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
// more sensitive .. use when RX bandwidths are fixed (no weak signal auto adjust)
|
|
||||||
rssi_open = (rssi_open * 3) / 4;
|
|
||||||
noise_open = (noise_open * 4) / 3;
|
|
||||||
glitch_open = (glitch_open * 4) / 3;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rssi_close = (rssi_open * 9) / 10;
|
|
||||||
noise_close = (noise_open * 10) / 9;
|
|
||||||
glitch_close = (glitch_open * 10) / 9;
|
|
||||||
|
|
||||||
// ensure the 'close' threshold is lower than the 'open' threshold
|
// ensure the 'close' threshold is lower than the 'open' threshold
|
||||||
if (rssi_close == rssi_open && rssi_close >= 2)
|
if (rssi_close == rssi_open && rssi_close >= 2)
|
||||||
@@ -497,10 +442,12 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
|
|||||||
|
|
||||||
pInfo->SquelchOpenRSSIThresh = (rssi_open > 255) ? 255 : rssi_open;
|
pInfo->SquelchOpenRSSIThresh = (rssi_open > 255) ? 255 : rssi_open;
|
||||||
pInfo->SquelchCloseRSSIThresh = (rssi_close > 255) ? 255 : rssi_close;
|
pInfo->SquelchCloseRSSIThresh = (rssi_close > 255) ? 255 : rssi_close;
|
||||||
pInfo->SquelchOpenNoiseThresh = (noise_open > 127) ? 127 : noise_open;
|
|
||||||
pInfo->SquelchCloseNoiseThresh = (noise_close > 127) ? 127 : noise_close;
|
|
||||||
pInfo->SquelchOpenGlitchThresh = (glitch_open > 255) ? 255 : glitch_open;
|
pInfo->SquelchOpenGlitchThresh = (glitch_open > 255) ? 255 : glitch_open;
|
||||||
pInfo->SquelchCloseGlitchThresh = (glitch_close > 255) ? 255 : glitch_close;
|
pInfo->SquelchCloseGlitchThresh = (glitch_close > 255) ? 255 : glitch_close;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pInfo->SquelchOpenNoiseThresh = (noise_open > 127) ? 127 : noise_open;
|
||||||
|
pInfo->SquelchCloseNoiseThresh = (noise_close > 127) ? 127 : noise_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
// *******************************
|
// *******************************
|
||||||
@@ -508,9 +455,9 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
|
|||||||
|
|
||||||
Band = FREQUENCY_GetBand(pInfo->pTX->Frequency);
|
Band = FREQUENCY_GetBand(pInfo->pTX->Frequency);
|
||||||
|
|
||||||
|
uint8_t Txp[3];
|
||||||
EEPROM_ReadBuffer(0x1ED0 + (Band * 16) + (pInfo->OUTPUT_POWER * 3), Txp, 3);
|
EEPROM_ReadBuffer(0x1ED0 + (Band * 16) + (pInfo->OUTPUT_POWER * 3), Txp, 3);
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_REDUCE_LOW_MID_TX_POWER
|
#ifdef ENABLE_REDUCE_LOW_MID_TX_POWER
|
||||||
// make low and mid even lower
|
// make low and mid even lower
|
||||||
if (pInfo->OUTPUT_POWER == OUTPUT_POWER_LOW) {
|
if (pInfo->OUTPUT_POWER == OUTPUT_POWER_LOW) {
|
||||||
@@ -553,12 +500,6 @@ void RADIO_ApplyOffset(VFO_Info_t *pInfo)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Frequency < frequencyBandTable[0].lower)
|
|
||||||
Frequency = frequencyBandTable[0].lower;
|
|
||||||
else
|
|
||||||
if (Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper)
|
|
||||||
Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper;
|
|
||||||
|
|
||||||
pInfo->freq_config_TX.Frequency = Frequency;
|
pInfo->freq_config_TX.Frequency = Frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,8 +526,6 @@ void RADIO_SelectVfos(void)
|
|||||||
void RADIO_SetupRegisters(bool switchToForeground)
|
void RADIO_SetupRegisters(bool switchToForeground)
|
||||||
{
|
{
|
||||||
BK4819_FilterBandwidth_t Bandwidth = gRxVfo->CHANNEL_BANDWIDTH;
|
BK4819_FilterBandwidth_t Bandwidth = gRxVfo->CHANNEL_BANDWIDTH;
|
||||||
uint16_t InterruptMask;
|
|
||||||
uint32_t Frequency;
|
|
||||||
|
|
||||||
AUDIO_AudioPathOff();
|
AUDIO_AudioPathOff();
|
||||||
|
|
||||||
@@ -630,6 +569,7 @@ void RADIO_SetupRegisters(bool switchToForeground)
|
|||||||
// mic gain 0.5dB/step 0 to 31
|
// mic gain 0.5dB/step 0 to 31
|
||||||
BK4819_WriteRegister(BK4819_REG_7D, 0xE940 | (gEeprom.MIC_SENSITIVITY_TUNING & 0x1f));
|
BK4819_WriteRegister(BK4819_REG_7D, 0xE940 | (gEeprom.MIC_SENSITIVITY_TUNING & 0x1f));
|
||||||
|
|
||||||
|
uint32_t Frequency;
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) || !gIsNoaaMode)
|
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) || !gIsNoaaMode)
|
||||||
Frequency = gRxVfo->pRX->Frequency;
|
Frequency = gRxVfo->pRX->Frequency;
|
||||||
@@ -659,7 +599,7 @@ void RADIO_SetupRegisters(bool switchToForeground)
|
|||||||
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
|
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
|
||||||
|
|
||||||
|
|
||||||
InterruptMask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
uint16_t InterruptMask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
||||||
@@ -734,52 +674,30 @@ void RADIO_SetupRegisters(bool switchToForeground)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
|
if (gEeprom.VOX_SWITCH && gCurrentVfo->Modulation == MODULATION_FM
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
|
&& !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE)
|
||||||
|
#endif
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gEeprom.VOX_SWITCH && !gFmRadioMode && !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->Modulation == MODULATION_FM)
|
&& !gFmRadioMode
|
||||||
#else
|
|
||||||
if (gEeprom.VOX_SWITCH && !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->Modulation == MODULATION_FM)
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
){
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
if (gEeprom.VOX_SWITCH && !gFmRadioMode && gCurrentVfo->Modulation == MODULATION_FM)
|
|
||||||
#else
|
|
||||||
if (gEeprom.VOX_SWITCH && gCurrentVfo->Modulation == MODULATION_FM)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
|
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
|
||||||
InterruptMask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST;
|
InterruptMask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
BK4819_DisableVox();
|
BK4819_DisableVox();
|
||||||
|
}
|
||||||
|
|
||||||
// RX expander
|
// RX expander
|
||||||
BK4819_SetCompander((gRxVfo->Modulation == MODULATION_FM && gRxVfo->Compander >= 2) ? gRxVfo->Compander : 0);
|
BK4819_SetCompander((gRxVfo->Modulation == MODULATION_FM && gRxVfo->Compander >= 2) ? gRxVfo->Compander : 0);
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED)
|
|
||||||
{
|
|
||||||
BK4819_DisableDTMF();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BK4819_EnableDTMF();
|
BK4819_EnableDTMF();
|
||||||
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||||
}
|
|
||||||
#else
|
RADIO_SetupAGC(gRxVfo->Modulation == MODULATION_AM, false);
|
||||||
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
|
||||||
{
|
|
||||||
BK4819_DisableDTMF();
|
|
||||||
BK4819_EnableDTMF();
|
|
||||||
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BK4819_DisableDTMF();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// enable/disable BK4819 selected interrupts
|
// enable/disable BK4819 selected interrupts
|
||||||
BK4819_WriteRegister(BK4819_REG_3F, InterruptMask);
|
BK4819_WriteRegister(BK4819_REG_3F, InterruptMask);
|
||||||
@@ -820,7 +738,7 @@ void RADIO_SetupRegisters(bool switchToForeground)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST)
|
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
||||||
{
|
{
|
||||||
gIsNoaaMode = true;
|
gIsNoaaMode = true;
|
||||||
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
|
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
|
||||||
@@ -924,38 +842,61 @@ void RADIO_SetModulation(ModulationMode_t modulation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BK4819_SetAF(mod);
|
BK4819_SetAF(mod);
|
||||||
|
|
||||||
BK4819_SetRegValue(afDacGainRegSpec, 0xF);
|
BK4819_SetRegValue(afDacGainRegSpec, 0xF);
|
||||||
BK4819_WriteRegister(BK4819_REG_3D, modulation == MODULATION_USB ? 0 : 0x2AAB);
|
BK4819_WriteRegister(BK4819_REG_3D, modulation == MODULATION_USB ? 0 : 0x2AAB);
|
||||||
BK4819_SetRegValue(afcDisableRegSpec, modulation != MODULATION_FM);
|
BK4819_SetRegValue(afcDisableRegSpec, modulation != MODULATION_FM);
|
||||||
|
|
||||||
|
RADIO_SetupAGC(modulation == MODULATION_AM, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RADIO_SetupAGC(bool listeningAM, bool disable)
|
||||||
|
{
|
||||||
|
static uint8_t lastSettings;
|
||||||
|
uint8_t newSettings = (listeningAM << 1) | (disable << 1);
|
||||||
|
if(lastSettings == newSettings)
|
||||||
|
return;
|
||||||
|
lastSettings = newSettings;
|
||||||
|
|
||||||
|
|
||||||
|
if(!listeningAM) { // if not actively listening AM we don't need any AM specific regulation
|
||||||
|
BK4819_SetAGC(!disable);
|
||||||
|
BK4819_InitAGC(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#ifdef ENABLE_AM_FIX
|
||||||
|
if(gSetting_AM_fix) { // if AM fix active lock AGC so AM-fix can do it's job
|
||||||
|
BK4819_SetAGC(0);
|
||||||
|
AM_fix_enable(!disable);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
BK4819_SetAGC(!disable);
|
||||||
|
BK4819_InitAGC(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RADIO_SetVfoState(VfoState_t State)
|
void RADIO_SetVfoState(VfoState_t State)
|
||||||
{
|
{
|
||||||
if (State == VFO_STATE_NORMAL)
|
if (State == VFO_STATE_NORMAL) {
|
||||||
{
|
|
||||||
VfoState[0] = VFO_STATE_NORMAL;
|
VfoState[0] = VFO_STATE_NORMAL;
|
||||||
VfoState[1] = VFO_STATE_NORMAL;
|
VfoState[1] = VFO_STATE_NORMAL;
|
||||||
gVFOStateResumeCountdown_500ms = 0;
|
} else if (State == VFO_STATE_VOLTAGE_HIGH) {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (State == VFO_STATE_VOLTAGE_HIGH)
|
|
||||||
{
|
|
||||||
VfoState[0] = VFO_STATE_VOLTAGE_HIGH;
|
VfoState[0] = VFO_STATE_VOLTAGE_HIGH;
|
||||||
VfoState[1] = VFO_STATE_TX_DISABLE;
|
VfoState[1] = VFO_STATE_TX_DISABLE;
|
||||||
}
|
} else {
|
||||||
else
|
// 1of11
|
||||||
{ // 1of11
|
|
||||||
const unsigned int vfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
|
const unsigned int vfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
|
||||||
VfoState[vfo] = State;
|
VfoState[vfo] = State;
|
||||||
}
|
}
|
||||||
|
|
||||||
gVFOStateResumeCountdown_500ms = vfo_state_resume_countdown_500ms;
|
gVFOStateResumeCountdown_500ms = (State == VFO_STATE_NORMAL) ? 0 : vfo_state_resume_countdown_500ms;
|
||||||
}
|
|
||||||
|
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RADIO_PrepareTX(void)
|
void RADIO_PrepareTX(void)
|
||||||
{
|
{
|
||||||
VfoState_t State = VFO_STATE_NORMAL; // default to OK to TX
|
VfoState_t State = VFO_STATE_NORMAL; // default to OK to TX
|
||||||
@@ -980,47 +921,35 @@ void RADIO_PrepareTX(void)
|
|||||||
|
|
||||||
RADIO_SelectCurrentVfo();
|
RADIO_SelectCurrentVfo();
|
||||||
|
|
||||||
#if defined(ENABLE_ALARM) && defined(ENABLE_TX1750)
|
if(TX_freq_check(gCurrentVfo->pTX->Frequency) != 0
|
||||||
if (gAlarmState == ALARM_STATE_OFF ||
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
gAlarmState == ALARM_STATE_TX1750 ||
|
&& gAlarmState != ALARM_STATE_SITE_ALARM
|
||||||
(gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE))
|
|
||||||
#elif defined(ENABLE_ALARM)
|
|
||||||
if (gAlarmState == ALARM_STATE_OFF ||
|
|
||||||
(gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE))
|
|
||||||
#elif defined(ENABLE_TX1750)
|
|
||||||
if (gAlarmState == ALARM_STATE_OFF ||
|
|
||||||
gAlarmState == ALARM_STATE_TX1750)
|
|
||||||
#endif
|
#endif
|
||||||
{
|
){
|
||||||
|
// TX frequency not allowed
|
||||||
|
State = VFO_STATE_TX_DISABLE;
|
||||||
|
} else if (SerialConfigInProgress()) {
|
||||||
|
// TX is disabled or config upload/download in progress
|
||||||
|
State = VFO_STATE_TX_DISABLE;
|
||||||
|
} else if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE) {
|
||||||
|
// busy RX'ing a station
|
||||||
|
State = VFO_STATE_BUSY;
|
||||||
|
} else if (gBatteryDisplayLevel == 0) {
|
||||||
|
// charge your battery !git co
|
||||||
|
State = VFO_STATE_BAT_LOW;
|
||||||
|
} else if (gBatteryDisplayLevel > 6) {
|
||||||
|
// over voltage .. this is being a pain
|
||||||
|
State = VFO_STATE_VOLTAGE_HIGH;
|
||||||
|
}
|
||||||
#ifndef ENABLE_TX_WHEN_AM
|
#ifndef ENABLE_TX_WHEN_AM
|
||||||
if (gCurrentVfo->Modulation != MODULATION_FM)
|
else if (gCurrentVfo->Modulation != MODULATION_FM) {
|
||||||
{ // not allowed to TX if in AM mode
|
// not allowed to TX if in AM mode
|
||||||
State = VFO_STATE_TX_DISABLE;
|
State = VFO_STATE_TX_DISABLE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
if (gSerialConfigCountDown_500ms > 0)
|
|
||||||
{ // TX is disabled or config upload/download in progress
|
|
||||||
State = VFO_STATE_TX_DISABLE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0)
|
|
||||||
{ // TX frequency is allowed
|
|
||||||
if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE)
|
|
||||||
State = VFO_STATE_BUSY; // busy RX'ing a station
|
|
||||||
else
|
|
||||||
if (gBatteryDisplayLevel == 0)
|
|
||||||
State = VFO_STATE_BAT_LOW; // charge your battery !
|
|
||||||
else
|
|
||||||
if (gBatteryDisplayLevel > 6)
|
|
||||||
State = VFO_STATE_VOLTAGE_HIGH; // over voltage .. this is being a pain
|
|
||||||
}
|
|
||||||
else
|
|
||||||
State = VFO_STATE_TX_DISABLE; // TX frequency not allowed
|
|
||||||
}
|
|
||||||
|
|
||||||
if (State != VFO_STATE_NORMAL)
|
if (State != VFO_STATE_NORMAL) {
|
||||||
{ // TX not allowed
|
// TX not allowed
|
||||||
RADIO_SetVfoState(State);
|
RADIO_SetVfoState(State);
|
||||||
|
|
||||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
@@ -1039,16 +968,13 @@ void RADIO_PrepareTX(void)
|
|||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
if (gDTMF_ReplyState == DTMF_REPLY_ANI)
|
if (gDTMF_ReplyState == DTMF_REPLY_ANI)
|
||||||
{
|
{
|
||||||
if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF)
|
gDTMF_IsTx = gDTMF_CallMode == DTMF_CALL_MODE_DTMF;
|
||||||
{
|
|
||||||
gDTMF_IsTx = true;
|
if (gDTMF_IsTx) {
|
||||||
gDTMF_CallState = DTMF_CALL_STATE_NONE;
|
gDTMF_CallState = DTMF_CALL_STATE_NONE;
|
||||||
gDTMF_TxStopCountdown_500ms = DTMF_txstop_countdown_500ms;
|
gDTMF_TxStopCountdown_500ms = DTMF_txstop_countdown_500ms;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
gDTMF_CallState = DTMF_CALL_STATE_CALL_OUT;
|
gDTMF_CallState = DTMF_CALL_STATE_CALL_OUT;
|
||||||
gDTMF_IsTx = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1063,85 +989,54 @@ void RADIO_PrepareTX(void)
|
|||||||
{
|
{
|
||||||
if (gEeprom.TX_TIMEOUT_TIMER == 0)
|
if (gEeprom.TX_TIMEOUT_TIMER == 0)
|
||||||
gTxTimerCountdown_500ms = 60; // 30 sec
|
gTxTimerCountdown_500ms = 60; // 30 sec
|
||||||
else
|
else if (gEeprom.TX_TIMEOUT_TIMER < (ARRAY_SIZE(gSubMenu_TOT) - 1))
|
||||||
if (gEeprom.TX_TIMEOUT_TIMER < (ARRAY_SIZE(gSubMenu_TOT) - 1))
|
|
||||||
gTxTimerCountdown_500ms = 120 * gEeprom.TX_TIMEOUT_TIMER; // minutes
|
gTxTimerCountdown_500ms = 120 * gEeprom.TX_TIMEOUT_TIMER; // minutes
|
||||||
else
|
else
|
||||||
gTxTimerCountdown_500ms = 120 * 15; // 15 minutes
|
gTxTimerCountdown_500ms = 120 * 15; // 15 minutes
|
||||||
}
|
}
|
||||||
gTxTimeoutReached = false;
|
|
||||||
|
|
||||||
|
gTxTimeoutReached = false;
|
||||||
gFlagEndTransmission = false;
|
gFlagEndTransmission = false;
|
||||||
gRTTECountdown = 0;
|
gRTTECountdown_10ms = 0;
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
gDTMF_ReplyState = DTMF_REPLY_NONE;
|
gDTMF_ReplyState = DTMF_REPLY_NONE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void RADIO_EnableCxCSS(void)
|
void RADIO_SendCssTail(void)
|
||||||
{
|
{
|
||||||
switch (gCurrentVfo->pTX->CodeType) {
|
switch (gCurrentVfo->pTX->CodeType) {
|
||||||
case CODE_TYPE_DIGITAL:
|
case CODE_TYPE_DIGITAL:
|
||||||
case CODE_TYPE_REVERSE_DIGITAL:
|
case CODE_TYPE_REVERSE_DIGITAL:
|
||||||
BK4819_EnableCDCSS();
|
BK4819_PlayCDCSSTail();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BK4819_EnableCTCSS();
|
BK4819_PlayCTCSSTail();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSTEM_DelayMs(200);
|
SYSTEM_DelayMs(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RADIO_SendEndOfTransmission(void)
|
||||||
|
{
|
||||||
|
BK4819_PlayRoger();
|
||||||
|
DTMF_SendEndOfTransmission();
|
||||||
|
|
||||||
|
// send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
|
||||||
|
if(gEeprom.TAIL_TONE_ELIMINATION)
|
||||||
|
RADIO_SendCssTail();
|
||||||
|
RADIO_SetupRegisters(false);
|
||||||
|
}
|
||||||
|
|
||||||
void RADIO_PrepareCssTX(void)
|
void RADIO_PrepareCssTX(void)
|
||||||
{
|
{
|
||||||
RADIO_PrepareTX();
|
RADIO_PrepareTX();
|
||||||
|
|
||||||
SYSTEM_DelayMs(200);
|
SYSTEM_DelayMs(200);
|
||||||
|
|
||||||
RADIO_EnableCxCSS();
|
if(gEeprom.TAIL_TONE_ELIMINATION)
|
||||||
|
RADIO_SendCssTail();
|
||||||
RADIO_SetupRegisters(true);
|
RADIO_SetupRegisters(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RADIO_SendEndOfTransmission(void)
|
|
||||||
{
|
|
||||||
if (gEeprom.ROGER == ROGER_MODE_ROGER)
|
|
||||||
BK4819_PlayRoger();
|
|
||||||
else
|
|
||||||
if (gEeprom.ROGER == ROGER_MODE_MDC)
|
|
||||||
BK4819_PlayRogerMDC();
|
|
||||||
|
|
||||||
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO)
|
|
||||||
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE);
|
|
||||||
|
|
||||||
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_BOTH))
|
|
||||||
{ // end-of-tx
|
|
||||||
if (gEeprom.DTMF_SIDE_TONE)
|
|
||||||
{
|
|
||||||
AUDIO_AudioPathOn();
|
|
||||||
gEnableSpeaker = true;
|
|
||||||
SYSTEM_DelayMs(60);
|
|
||||||
}
|
|
||||||
|
|
||||||
BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE);
|
|
||||||
|
|
||||||
BK4819_PlayDTMFString(
|
|
||||||
gEeprom.DTMF_DOWN_CODE,
|
|
||||||
0,
|
|
||||||
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME,
|
|
||||||
gEeprom.DTMF_HASH_CODE_PERSIST_TIME,
|
|
||||||
gEeprom.DTMF_CODE_PERSIST_TIME,
|
|
||||||
gEeprom.DTMF_CODE_INTERVAL_TIME);
|
|
||||||
|
|
||||||
AUDIO_AudioPathOff();
|
|
||||||
gEnableSpeaker = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BK4819_ExitDTMF_TX(true);
|
|
||||||
}
|
|
||||||
|
|||||||
11
radio.h
@@ -50,7 +50,8 @@ enum VfoState_t
|
|||||||
VFO_STATE_TX_DISABLE,
|
VFO_STATE_TX_DISABLE,
|
||||||
VFO_STATE_TIMEOUT,
|
VFO_STATE_TIMEOUT,
|
||||||
VFO_STATE_ALARM,
|
VFO_STATE_ALARM,
|
||||||
VFO_STATE_VOLTAGE_HIGH
|
VFO_STATE_VOLTAGE_HIGH,
|
||||||
|
_VFO_STATE_LAST_ELEMENT
|
||||||
};
|
};
|
||||||
typedef enum VfoState_t VfoState_t;
|
typedef enum VfoState_t VfoState_t;
|
||||||
|
|
||||||
@@ -147,24 +148,24 @@ extern DCS_CodeType_t gCurrentCodeType;
|
|||||||
|
|
||||||
extern VfoState_t VfoState[2];
|
extern VfoState_t VfoState[2];
|
||||||
|
|
||||||
bool RADIO_CheckValidChannel(uint16_t ChNum, bool bCheckScanList, uint8_t RadioNum);
|
bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanList);
|
||||||
uint8_t RADIO_FindNextChannel(uint8_t ChNum, int8_t Direction, bool bCheckScanList, uint8_t RadioNum);
|
uint8_t RADIO_FindNextChannel(uint8_t ChNum, int8_t Direction, bool bCheckScanList, uint8_t RadioNum);
|
||||||
void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency);
|
void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency);
|
||||||
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure);
|
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure);
|
||||||
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo);
|
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo);
|
||||||
void RADIO_ApplyOffset(VFO_Info_t *pInfo);
|
void RADIO_ApplyOffset(VFO_Info_t *pInfo);
|
||||||
void RADIO_SelectVfos(void);
|
void RADIO_SelectVfos(void);
|
||||||
void RADIO_SetupRegisters(bool bSwitchToFunction0);
|
void RADIO_SetupRegisters(bool switchToForeground);
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
void RADIO_ConfigureNOAA(void);
|
void RADIO_ConfigureNOAA(void);
|
||||||
#endif
|
#endif
|
||||||
void RADIO_SetTxParameters(void);
|
void RADIO_SetTxParameters(void);
|
||||||
|
void RADIO_SetupAGC(bool listeningAM, bool disable);
|
||||||
void RADIO_SetModulation(ModulationMode_t modulation);
|
void RADIO_SetModulation(ModulationMode_t modulation);
|
||||||
void RADIO_SetVfoState(VfoState_t State);
|
void RADIO_SetVfoState(VfoState_t State);
|
||||||
void RADIO_PrepareTX(void);
|
void RADIO_PrepareTX(void);
|
||||||
void RADIO_EnableCxCSS(void);
|
void RADIO_SendCssTail(void);
|
||||||
void RADIO_PrepareCssTX(void);
|
void RADIO_PrepareCssTX(void);
|
||||||
void RADIO_SendEndOfTransmission(void);
|
void RADIO_SendEndOfTransmission(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ void SystickHandler(void)
|
|||||||
|
|
||||||
gNextTimeslice = true;
|
gNextTimeslice = true;
|
||||||
|
|
||||||
if ((gGlobalSysTickCounter % 50) == 0)
|
if ((gGlobalSysTickCounter % 50) == 0) {
|
||||||
{
|
|
||||||
gNextTimeslice_500ms = true;
|
gNextTimeslice_500ms = true;
|
||||||
|
|
||||||
DECREMENT_AND_TRIGGER(gTxTimerCountdown_500ms, gTxTimeoutReached);
|
DECREMENT_AND_TRIGGER(gTxTimerCountdown_500ms, gTxTimeoutReached);
|
||||||
@@ -93,7 +92,7 @@ void SystickHandler(void)
|
|||||||
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||||
DECREMENT_AND_TRIGGER(gScanPauseDelayIn_10ms, gScheduleScanListen);
|
DECREMENT_AND_TRIGGER(gScanPauseDelayIn_10ms, gScheduleScanListen);
|
||||||
|
|
||||||
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown_10ms, gFlagTailNoteEliminationComplete);
|
DECREMENT_AND_TRIGGER(gTailToneEliminationCountdown_10ms, gFlagTailToneEliminationComplete);
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice_10ms, gFlagPlayQueuedVoice);
|
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice_10ms, gFlagPlayQueuedVoice);
|
||||||
|
|||||||
568
settings.c
@@ -16,36 +16,431 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "app/dtmf.h"
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
#include "app/fm.h"
|
#include "app/fm.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "driver/bk1080.h"
|
||||||
|
#include "driver/bk4819.h"
|
||||||
#include "driver/eeprom.h"
|
#include "driver/eeprom.h"
|
||||||
#include "driver/uart.h"
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "ui/menu.h"
|
||||||
|
|
||||||
EEPROM_Config_t gEeprom;
|
static const uint32_t gDefaultFrequencyTable[] =
|
||||||
|
{
|
||||||
|
14500000, //
|
||||||
|
14550000, //
|
||||||
|
43300000, //
|
||||||
|
43320000, //
|
||||||
|
43350000 //
|
||||||
|
};
|
||||||
|
|
||||||
|
EEPROM_Config_t gEeprom = { 0 };
|
||||||
|
|
||||||
|
void SETTINGS_InitEEPROM(void)
|
||||||
|
{
|
||||||
|
uint8_t Data[16] = {0};
|
||||||
|
// 0E70..0E77
|
||||||
|
EEPROM_ReadBuffer(0x0E70, Data, 8);
|
||||||
|
gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST;
|
||||||
|
gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1;
|
||||||
|
gEeprom.TX_TIMEOUT_TIMER = (Data[2] < 11) ? Data[2] : 1;
|
||||||
|
#ifdef ENABLE_NOAA
|
||||||
|
gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false;
|
||||||
|
#endif
|
||||||
|
gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false;
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false;
|
||||||
|
gEeprom.VOX_LEVEL = (Data[6] < 10) ? Data[6] : 1;
|
||||||
|
#endif
|
||||||
|
gEeprom.MIC_SENSITIVITY = (Data[7] < 5) ? Data[7] : 4;
|
||||||
|
|
||||||
|
// 0E78..0E7F
|
||||||
|
EEPROM_ReadBuffer(0x0E78, Data, 8);
|
||||||
|
gEeprom.BACKLIGHT_MAX = (Data[0] & 0xF) <= 10 ? (Data[0] & 0xF) : 10;
|
||||||
|
gEeprom.BACKLIGHT_MIN = (Data[0] >> 4) < gEeprom.BACKLIGHT_MAX ? (Data[0] >> 4) : 0;
|
||||||
|
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||||
|
gEeprom.BACKLIGHT_MIN_STAT = BLMIN_STAT_ON;
|
||||||
|
#endif
|
||||||
|
gEeprom.CHANNEL_DISPLAY_MODE = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode
|
||||||
|
gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF;
|
||||||
|
gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4;
|
||||||
|
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A;
|
||||||
|
gEeprom.BACKLIGHT_TIME = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 3;
|
||||||
|
gEeprom.TAIL_TONE_ELIMINATION = (Data[6] < 2) ? Data[6] : false;
|
||||||
|
gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true;
|
||||||
|
|
||||||
|
// 0E80..0E87
|
||||||
|
EEPROM_ReadBuffer(0x0E80, Data, 8);
|
||||||
|
gEeprom.ScreenChannel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||||
|
gEeprom.ScreenChannel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||||
|
gEeprom.MrChannel[0] = IS_MR_CHANNEL(Data[1]) ? Data[1] : MR_CHANNEL_FIRST;
|
||||||
|
gEeprom.MrChannel[1] = IS_MR_CHANNEL(Data[4]) ? Data[4] : MR_CHANNEL_FIRST;
|
||||||
|
gEeprom.FreqChannel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||||
|
gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||||
|
#ifdef ENABLE_NOAA
|
||||||
|
gEeprom.NoaaChannel[0] = IS_NOAA_CHANNEL(Data[6]) ? Data[6] : NOAA_CHANNEL_FIRST;
|
||||||
|
gEeprom.NoaaChannel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
{ // 0E88..0E8F
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint16_t selFreq;
|
||||||
|
uint8_t selChn;
|
||||||
|
uint8_t isMrMode:1;
|
||||||
|
uint8_t band:2;
|
||||||
|
//uint8_t space:2;
|
||||||
|
} __attribute__((packed)) fmCfg;
|
||||||
|
EEPROM_ReadBuffer(0x0E88, &fmCfg, 4);
|
||||||
|
|
||||||
|
gEeprom.FM_Band = fmCfg.band;
|
||||||
|
//gEeprom.FM_Space = fmCfg.space;
|
||||||
|
gEeprom.FM_SelectedFrequency =
|
||||||
|
(fmCfg.selFreq >= BK1080_GetFreqLoLimit(gEeprom.FM_Band) && fmCfg.selFreq <= BK1080_GetFreqHiLimit(gEeprom.FM_Band)) ?
|
||||||
|
fmCfg.selFreq : BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||||
|
|
||||||
|
gEeprom.FM_SelectedChannel = fmCfg.selChn;
|
||||||
|
gEeprom.FM_IsMrMode = fmCfg.isMrMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0E40..0E67
|
||||||
|
EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels));
|
||||||
|
FM_ConfigureChannelState();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 0E90..0E97
|
||||||
|
EEPROM_ReadBuffer(0x0E90, Data, 8);
|
||||||
|
gEeprom.BEEP_CONTROL = Data[0] & 1;
|
||||||
|
gEeprom.KEY_M_LONG_PRESS_ACTION = ((Data[0] >> 1) < ACTION_OPT_LEN) ? (Data[0] >> 1) : ACTION_OPT_NONE;
|
||||||
|
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
|
||||||
|
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_NONE;
|
||||||
|
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
|
||||||
|
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE;
|
||||||
|
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
|
||||||
|
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false;
|
||||||
|
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE;
|
||||||
|
|
||||||
|
// 0E98..0E9F
|
||||||
|
EEPROM_ReadBuffer(0x0E98, Data, 8);
|
||||||
|
memcpy(&gEeprom.POWER_ON_PASSWORD, Data, 4);
|
||||||
|
|
||||||
|
// 0EA0..0EA7
|
||||||
|
EEPROM_ReadBuffer(0x0EA0, Data, 8);
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_RSSI_BAR
|
||||||
|
if((Data[1] < 200 && Data[1] > 90) && (Data[2] < Data[1]-9 && Data[1] < 160 && Data[2] > 50)) {
|
||||||
|
gEeprom.S0_LEVEL = Data[1];
|
||||||
|
gEeprom.S9_LEVEL = Data[2];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gEeprom.S0_LEVEL = 130;
|
||||||
|
gEeprom.S9_LEVEL = 76;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 0EA8..0EAF
|
||||||
|
EEPROM_ReadBuffer(0x0EA8, Data, 8);
|
||||||
|
#ifdef ENABLE_ALARM
|
||||||
|
gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true;
|
||||||
|
#endif
|
||||||
|
gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF;
|
||||||
|
gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0;
|
||||||
|
gEeprom.TX_VFO = (Data[3] < 2) ? Data[3] : 0;
|
||||||
|
gEeprom.BATTERY_TYPE = (Data[4] < BATTERY_TYPE_UNKNOWN) ? Data[4] : BATTERY_TYPE_1600_MAH;
|
||||||
|
|
||||||
|
// 0ED0..0ED7
|
||||||
|
EEPROM_ReadBuffer(0x0ED0, Data, 8);
|
||||||
|
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_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#';
|
||||||
|
gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0;
|
||||||
|
gEeprom.DTMF_auto_reset_time = (Data[4] < 61 && Data[4] >= 5) ? Data[4] : 10;
|
||||||
|
#endif
|
||||||
|
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_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100;
|
||||||
|
|
||||||
|
// 0ED8..0EDF
|
||||||
|
EEPROM_ReadBuffer(0x0ED8, Data, 8);
|
||||||
|
gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 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;
|
||||||
|
|
||||||
|
// 0EE0..0EE7
|
||||||
|
|
||||||
|
EEPROM_ReadBuffer(0x0EE0, Data, sizeof(gEeprom.ANI_DTMF_ID));
|
||||||
|
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.ANI_DTMF_ID))) {
|
||||||
|
memcpy(gEeprom.ANI_DTMF_ID, Data, sizeof(gEeprom.ANI_DTMF_ID));
|
||||||
|
} else {
|
||||||
|
strcpy(gEeprom.ANI_DTMF_ID, "123");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 0EE8..0EEF
|
||||||
|
EEPROM_ReadBuffer(0x0EE8, Data, sizeof(gEeprom.KILL_CODE));
|
||||||
|
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.KILL_CODE))) {
|
||||||
|
memcpy(gEeprom.KILL_CODE, Data, sizeof(gEeprom.KILL_CODE));
|
||||||
|
} else {
|
||||||
|
strcpy(gEeprom.KILL_CODE, "ABCD9");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0EF0..0EF7
|
||||||
|
EEPROM_ReadBuffer(0x0EF0, Data, sizeof(gEeprom.REVIVE_CODE));
|
||||||
|
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.REVIVE_CODE))) {
|
||||||
|
memcpy(gEeprom.REVIVE_CODE, Data, sizeof(gEeprom.REVIVE_CODE));
|
||||||
|
} else {
|
||||||
|
strcpy(gEeprom.REVIVE_CODE, "9DCBA");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 0EF8..0F07
|
||||||
|
EEPROM_ReadBuffer(0x0EF8, Data, sizeof(gEeprom.DTMF_UP_CODE));
|
||||||
|
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.DTMF_UP_CODE))) {
|
||||||
|
memcpy(gEeprom.DTMF_UP_CODE, Data, sizeof(gEeprom.DTMF_UP_CODE));
|
||||||
|
} else {
|
||||||
|
strcpy(gEeprom.DTMF_UP_CODE, "12345");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0F08..0F17
|
||||||
|
EEPROM_ReadBuffer(0x0F08, Data, sizeof(gEeprom.DTMF_DOWN_CODE));
|
||||||
|
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.DTMF_DOWN_CODE))) {
|
||||||
|
memcpy(gEeprom.DTMF_DOWN_CODE, Data, sizeof(gEeprom.DTMF_DOWN_CODE));
|
||||||
|
} else {
|
||||||
|
strcpy(gEeprom.DTMF_DOWN_CODE, "54321");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0F18..0F1F
|
||||||
|
EEPROM_ReadBuffer(0x0F18, Data, 8);
|
||||||
|
gEeprom.SCAN_LIST_DEFAULT = (Data[0] < 3) ? Data[0] : 0; // we now have 'all' channel scan option
|
||||||
|
for (unsigned int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
const unsigned int j = 1 + (i * 3);
|
||||||
|
gEeprom.SCAN_LIST_ENABLED[i] = (Data[j + 0] < 2) ? Data[j] : false;
|
||||||
|
gEeprom.SCANLIST_PRIORITY_CH1[i] = Data[j + 1];
|
||||||
|
gEeprom.SCANLIST_PRIORITY_CH2[i] = Data[j + 2];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0F40..0F47
|
||||||
|
EEPROM_ReadBuffer(0x0F40, Data, 8);
|
||||||
|
gSetting_F_LOCK = (Data[0] < F_LOCK_LEN) ? Data[0] : F_LOCK_DEF;
|
||||||
|
gSetting_350TX = (Data[1] < 2) ? Data[1] : false; // was true
|
||||||
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|
gSetting_KILLED = (Data[2] < 2) ? Data[2] : false;
|
||||||
|
#endif
|
||||||
|
gSetting_200TX = (Data[3] < 2) ? Data[3] : false;
|
||||||
|
gSetting_500TX = (Data[4] < 2) ? Data[4] : false;
|
||||||
|
gSetting_350EN = (Data[5] < 2) ? Data[5] : true;
|
||||||
|
gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true;
|
||||||
|
//gSetting_TX_EN = (Data[7] & (1u << 0)) ? true : false;
|
||||||
|
gSetting_live_DTMF_decoder = !!(Data[7] & (1u << 1));
|
||||||
|
gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2;
|
||||||
|
#ifdef ENABLE_AUDIO_BAR
|
||||||
|
gSetting_mic_bar = !!(Data[7] & (1u << 4));
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_AM_FIX
|
||||||
|
gSetting_AM_fix = !!(Data[7] & (1u << 5));
|
||||||
|
#endif
|
||||||
|
gSetting_backlight_on_tx_rx = (Data[7] >> 6) & 3u;
|
||||||
|
|
||||||
|
if (!gEeprom.VFO_OPEN)
|
||||||
|
{
|
||||||
|
gEeprom.ScreenChannel[0] = gEeprom.MrChannel[0];
|
||||||
|
gEeprom.ScreenChannel[1] = gEeprom.MrChannel[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0D60..0E27
|
||||||
|
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
|
||||||
|
EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey));
|
||||||
|
bHasCustomAesKey = false;
|
||||||
|
for (unsigned int i = 0; i < ARRAY_SIZE(gCustomAesKey); i++)
|
||||||
|
{
|
||||||
|
if (gCustomAesKey[i] != 0xFFFFFFFFu)
|
||||||
|
{
|
||||||
|
bHasCustomAesKey = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SETTINGS_LoadCalibration(void)
|
||||||
|
{
|
||||||
|
// uint8_t Mic;
|
||||||
|
|
||||||
|
EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[3], 8);
|
||||||
|
memcpy(gEEPROM_RSSI_CALIB[4], gEEPROM_RSSI_CALIB[3], 8);
|
||||||
|
memcpy(gEEPROM_RSSI_CALIB[5], gEEPROM_RSSI_CALIB[3], 8);
|
||||||
|
memcpy(gEEPROM_RSSI_CALIB[6], gEEPROM_RSSI_CALIB[3], 8);
|
||||||
|
|
||||||
|
EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[0], 8);
|
||||||
|
memcpy(gEEPROM_RSSI_CALIB[1], gEEPROM_RSSI_CALIB[0], 8);
|
||||||
|
memcpy(gEEPROM_RSSI_CALIB[2], gEEPROM_RSSI_CALIB[0], 8);
|
||||||
|
|
||||||
|
EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12);
|
||||||
|
if (gBatteryCalibration[0] >= 5000)
|
||||||
|
{
|
||||||
|
gBatteryCalibration[0] = 1900;
|
||||||
|
gBatteryCalibration[1] = 2000;
|
||||||
|
}
|
||||||
|
gBatteryCalibration[5] = 2300;
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
EEPROM_ReadBuffer(0x1F50 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX1_THRESHOLD, 2);
|
||||||
|
EEPROM_ReadBuffer(0x1F68 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX0_THRESHOLD, 2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//EEPROM_ReadBuffer(0x1F80 + gEeprom.MIC_SENSITIVITY, &Mic, 1);
|
||||||
|
//gEeprom.MIC_SENSITIVITY_TUNING = (Mic < 32) ? Mic : 15;
|
||||||
|
gEeprom.MIC_SENSITIVITY_TUNING = gMicGain_dB2[gEeprom.MIC_SENSITIVITY];
|
||||||
|
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int16_t BK4819_XtalFreqLow;
|
||||||
|
uint16_t EEPROM_1F8A;
|
||||||
|
uint16_t EEPROM_1F8C;
|
||||||
|
uint8_t VOLUME_GAIN;
|
||||||
|
uint8_t DAC_GAIN;
|
||||||
|
} __attribute__((packed)) Misc;
|
||||||
|
|
||||||
|
// radio 1 .. 04 00 46 00 50 00 2C 0E
|
||||||
|
// radio 2 .. 05 00 46 00 50 00 2C 0E
|
||||||
|
EEPROM_ReadBuffer(0x1F88, &Misc, 8);
|
||||||
|
|
||||||
|
gEeprom.BK4819_XTAL_FREQ_LOW = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) ? Misc.BK4819_XtalFreqLow : 0;
|
||||||
|
gEEPROM_1F8A = Misc.EEPROM_1F8A & 0x01FF;
|
||||||
|
gEEPROM_1F8C = Misc.EEPROM_1F8C & 0x01FF;
|
||||||
|
gEeprom.VOLUME_GAIN = (Misc.VOLUME_GAIN < 64) ? Misc.VOLUME_GAIN : 58;
|
||||||
|
gEeprom.DAC_GAIN = (Misc.DAC_GAIN < 16) ? Misc.DAC_GAIN : 8;
|
||||||
|
|
||||||
|
BK4819_WriteRegister(BK4819_REG_3B, 22656 + gEeprom.BK4819_XTAL_FREQ_LOW);
|
||||||
|
// BK4819_WriteRegister(BK4819_REG_3C, gEeprom.BK4819_XTAL_FREQ_HIGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t SETTINGS_FetchChannelFrequency(const int channel)
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t frequency;
|
||||||
|
uint32_t offset;
|
||||||
|
} __attribute__((packed)) info;
|
||||||
|
|
||||||
|
EEPROM_ReadBuffer(channel * 16, &info, sizeof(info));
|
||||||
|
|
||||||
|
return info.frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SETTINGS_FetchChannelName(char *s, const int channel)
|
||||||
|
{
|
||||||
|
if (s == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
s[0] = 0;
|
||||||
|
|
||||||
|
if (channel < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!RADIO_CheckValidChannel(channel, false, 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
EEPROM_ReadBuffer(0x0F50 + (channel * 16), s, 10);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 10; i++)
|
||||||
|
if (s[i] < 32 || s[i] > 127)
|
||||||
|
break; // invalid char
|
||||||
|
|
||||||
|
s[i--] = 0; // null term
|
||||||
|
|
||||||
|
while (i >= 0 && s[i] == 32) // trim trailing spaces
|
||||||
|
s[i--] = 0; // null term
|
||||||
|
}
|
||||||
|
|
||||||
|
void SETTINGS_FactoryReset(bool bIsAll)
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
uint8_t Template[8];
|
||||||
|
|
||||||
|
memset(Template, 0xFF, sizeof(Template));
|
||||||
|
|
||||||
|
for (i = 0x0C80; i < 0x1E00; i += 8)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
!(i >= 0x0EE0 && i < 0x0F18) && // ANI ID + DTMF codes
|
||||||
|
!(i >= 0x0F30 && i < 0x0F50) && // AES KEY + F LOCK + Scramble Enable
|
||||||
|
!(i >= 0x1C00 && i < 0x1E00) && // DTMF contacts
|
||||||
|
!(i >= 0x0EB0 && i < 0x0ED0) && // Welcome strings
|
||||||
|
!(i >= 0x0EA0 && i < 0x0EA8) && // Voice Prompt
|
||||||
|
(bIsAll ||
|
||||||
|
(
|
||||||
|
!(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes
|
||||||
|
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
|
||||||
|
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names
|
||||||
|
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
|
||||||
|
!(i >= 0x0E88 && i < 0x0E90) // FM settings
|
||||||
|
))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EEPROM_WriteBuffer(i, Template);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bIsAll)
|
||||||
|
{
|
||||||
|
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_FIRST + BAND6_400MHz, 43350000);
|
||||||
|
|
||||||
|
// set the first few memory channels
|
||||||
|
for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++)
|
||||||
|
{
|
||||||
|
const uint32_t Frequency = gDefaultFrequencyTable[i];
|
||||||
|
gRxVfo->freq_config_RX.Frequency = Frequency;
|
||||||
|
gRxVfo->freq_config_TX.Frequency = Frequency;
|
||||||
|
gRxVfo->Band = FREQUENCY_GetBand(Frequency);
|
||||||
|
SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
void SETTINGS_SaveFM(void)
|
void SETTINGS_SaveFM(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
union {
|
||||||
|
struct {
|
||||||
|
uint16_t selFreq;
|
||||||
|
uint8_t selChn;
|
||||||
|
uint8_t isMrMode:1;
|
||||||
|
uint8_t band:2;
|
||||||
|
//uint8_t space:2;
|
||||||
|
};
|
||||||
|
uint8_t __raw[8];
|
||||||
|
} __attribute__((packed)) fmCfg;
|
||||||
|
|
||||||
struct
|
memset(fmCfg.__raw, 0xFF, sizeof(fmCfg.__raw));
|
||||||
{
|
fmCfg.selChn = gEeprom.FM_SelectedChannel;
|
||||||
uint16_t Frequency;
|
fmCfg.selFreq = gEeprom.FM_SelectedFrequency;
|
||||||
uint8_t Channel;
|
fmCfg.isMrMode = gEeprom.FM_IsMrMode;
|
||||||
bool IsChannelSelected;
|
fmCfg.band = gEeprom.FM_Band;
|
||||||
uint8_t Padding[4];
|
//fmCfg.space = gEeprom.FM_Space;
|
||||||
} State;
|
EEPROM_WriteBuffer(0x0E88, fmCfg.__raw);
|
||||||
|
|
||||||
memset(&State, 0xFF, sizeof(State));
|
for (unsigned i = 0; i < 5; i++)
|
||||||
State.Channel = gEeprom.FM_SelectedChannel;
|
|
||||||
State.Frequency = gEeprom.FM_SelectedFrequency;
|
|
||||||
State.IsChannelSelected = gEeprom.FM_IsMrMode;
|
|
||||||
|
|
||||||
EEPROM_WriteBuffer(0x0E88, &State);
|
|
||||||
for (i = 0; i < 5; i++)
|
|
||||||
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
|
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -126,8 +521,13 @@ void SETTINGS_SaveSettings(void)
|
|||||||
memset(State, 0xFF, sizeof(State));
|
memset(State, 0xFF, sizeof(State));
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
State[0] = gEeprom.VOICE_PROMPT;
|
State[0] = gEeprom.VOICE_PROMPT;
|
||||||
EEPROM_WriteBuffer(0x0EA0, State);
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_RSSI_BAR
|
||||||
|
State[1] = gEeprom.S0_LEVEL;
|
||||||
|
State[2] = gEeprom.S9_LEVEL;
|
||||||
|
#endif
|
||||||
|
EEPROM_WriteBuffer(0x0EA0, State);
|
||||||
|
|
||||||
|
|
||||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
State[0] = gEeprom.ALARM_MODE;
|
State[0] = gEeprom.ALARM_MODE;
|
||||||
@@ -197,70 +597,59 @@ 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)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (!IS_NOAA_CHANNEL(Channel))
|
if (IS_NOAA_CHANNEL(Channel))
|
||||||
|
return;
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
const uint16_t OffsetMR = Channel * 16;
|
|
||||||
uint16_t OffsetVFO = OffsetMR;
|
|
||||||
|
|
||||||
if (!IS_MR_CHANNEL(Channel))
|
uint16_t OffsetVFO = Channel * 16;
|
||||||
{ // it's a VFO, not a channel
|
|
||||||
|
if (IS_FREQ_CHANNEL(Channel)) { // it's a VFO, not a channel
|
||||||
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90;
|
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90;
|
||||||
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
|
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mode >= 2 || !IS_MR_CHANNEL(Channel))
|
if (Mode >= 2 || IS_FREQ_CHANNEL(Channel)) { // copy VFO to a channel
|
||||||
{ // copy VFO to a channel
|
union {
|
||||||
|
uint8_t _8[8];
|
||||||
|
uint32_t _32[2];
|
||||||
|
} State;
|
||||||
|
|
||||||
uint8_t State[8];
|
State._32[0] = pVFO->freq_config_RX.Frequency;
|
||||||
|
State._32[1] = pVFO->TX_OFFSET_FREQUENCY;
|
||||||
|
EEPROM_WriteBuffer(OffsetVFO + 0, State._32);
|
||||||
|
|
||||||
((uint32_t *)State)[0] = pVFO->freq_config_RX.Frequency;
|
State._8[0] = pVFO->freq_config_RX.Code;
|
||||||
((uint32_t *)State)[1] = pVFO->TX_OFFSET_FREQUENCY;
|
State._8[1] = pVFO->freq_config_TX.Code;
|
||||||
EEPROM_WriteBuffer(OffsetVFO + 0, State);
|
State._8[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType;
|
||||||
|
State._8[3] = (pVFO->Modulation << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION;
|
||||||
State[0] = pVFO->freq_config_RX.Code;
|
State._8[4] = 0
|
||||||
State[1] = pVFO->freq_config_TX.Code;
|
|
||||||
State[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType;
|
|
||||||
State[3] = (pVFO->Modulation << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION;
|
|
||||||
State[4] = 0
|
|
||||||
| (pVFO->BUSY_CHANNEL_LOCK << 4)
|
| (pVFO->BUSY_CHANNEL_LOCK << 4)
|
||||||
| (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)
|
State._8[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1)
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
| ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0)
|
| ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0)
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
State[6] = pVFO->STEP_SETTING;
|
State._8[6] = pVFO->STEP_SETTING;
|
||||||
State[7] = pVFO->SCRAMBLING_TYPE;
|
State._8[7] = pVFO->SCRAMBLING_TYPE;
|
||||||
EEPROM_WriteBuffer(OffsetVFO + 8, State);
|
EEPROM_WriteBuffer(OffsetVFO + 8, State._8);
|
||||||
|
|
||||||
SETTINGS_UpdateChannel(Channel, pVFO, true);
|
SETTINGS_UpdateChannel(Channel, pVFO, true);
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(Channel))
|
if (IS_MR_CHANNEL(Channel)) {
|
||||||
{ // it's a memory channel
|
|
||||||
|
|
||||||
#ifndef ENABLE_KEEP_MEM_NAME
|
#ifndef ENABLE_KEEP_MEM_NAME
|
||||||
// clear/reset the channel name
|
// clear/reset the channel name
|
||||||
//memset(&State, 0xFF, sizeof(State));
|
SETTINGS_SaveChannelName(Channel, "");
|
||||||
memset(&State, 0x00, sizeof(State)); // follow the QS way
|
|
||||||
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
|
|
||||||
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
|
|
||||||
#else
|
#else
|
||||||
if (Mode >= 3)
|
if (Mode >= 3) {
|
||||||
{ // save the channel name
|
SETTINGS_SaveChannelName(Channel, pVFO->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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration)
|
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration)
|
||||||
@@ -273,6 +662,15 @@ void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration)
|
|||||||
EEPROM_WriteBuffer(0x1F48, buf);
|
EEPROM_WriteBuffer(0x1F48, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SETTINGS_SaveChannelName(uint8_t channel, const char * name)
|
||||||
|
{
|
||||||
|
uint16_t offset = channel * 16;
|
||||||
|
uint8_t buf[16] = {0};
|
||||||
|
memcpy(buf, name, MIN(strlen(name), 10u));
|
||||||
|
EEPROM_WriteBuffer(0x0F50 + offset, buf);
|
||||||
|
EEPROM_WriteBuffer(0x0F58 + offset, buf + 8);
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -305,13 +703,63 @@ void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep)
|
|||||||
gMR_ChannelAttributes[channel] = att;
|
gMR_ChannelAttributes[channel] = att;
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(channel)) { // it's a memory channel
|
if (IS_MR_CHANNEL(channel)) { // it's a memory channel
|
||||||
const uint16_t OffsetMR = channel * 16;
|
|
||||||
if (!keep) {
|
if (!keep) {
|
||||||
// clear/reset the channel name
|
// clear/reset the channel name
|
||||||
memset(&state, 0x00, sizeof(state));
|
SETTINGS_SaveChannelName(channel, "");
|
||||||
EEPROM_WriteBuffer(0x0F50 + OffsetMR, state);
|
|
||||||
EEPROM_WriteBuffer(0x0F58 + OffsetMR, state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SETTINGS_WriteBuildOptions(void)
|
||||||
|
{
|
||||||
|
uint8_t buf[8] = {0};
|
||||||
|
buf[0] = 0
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
| (1 << 0)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_NOAA
|
||||||
|
| (1 << 1)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
| (1 << 2)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
| (1 << 3)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_ALARM
|
||||||
|
| (1 << 4)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_TX1750
|
||||||
|
| (1 << 5)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_PWRON_PASSWORD
|
||||||
|
| (1 << 6)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|
| (1 << 7)
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
buf[1] = 0
|
||||||
|
#ifdef ENABLE_FLASHLIGHT
|
||||||
|
| (1 << 0)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_WIDE_RX
|
||||||
|
| (1 << 1)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_BYP_RAW_DEMODULATORS
|
||||||
|
| (1 << 2)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||||
|
| (1 << 3)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_AM_FIX
|
||||||
|
| (1 << 4)
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_SPECTRUM
|
||||||
|
| (1 << 5)
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
EEPROM_WriteBuffer(0x1FF0, buf);
|
||||||
|
}
|
||||||
22
settings.h
@@ -33,7 +33,7 @@ enum POWER_OnDisplayMode_t {
|
|||||||
};
|
};
|
||||||
typedef enum POWER_OnDisplayMode_t POWER_OnDisplayMode_t;
|
typedef enum POWER_OnDisplayMode_t POWER_OnDisplayMode_t;
|
||||||
|
|
||||||
enum {
|
enum TxLockModes_t {
|
||||||
F_LOCK_DEF, //all default frequencies + configurable
|
F_LOCK_DEF, //all default frequencies + configurable
|
||||||
F_LOCK_FCC,
|
F_LOCK_FCC,
|
||||||
F_LOCK_CE,
|
F_LOCK_CE,
|
||||||
@@ -75,7 +75,7 @@ enum {
|
|||||||
OUTPUT_POWER_HIGH
|
OUTPUT_POWER_HIGH
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum ACTION_OPT_t {
|
||||||
ACTION_OPT_NONE = 0,
|
ACTION_OPT_NONE = 0,
|
||||||
ACTION_OPT_FLASHLIGHT,
|
ACTION_OPT_FLASHLIGHT,
|
||||||
ACTION_OPT_POWER,
|
ACTION_OPT_POWER,
|
||||||
@@ -89,9 +89,8 @@ enum {
|
|||||||
ACTION_OPT_A_B,
|
ACTION_OPT_A_B,
|
||||||
ACTION_OPT_VFO_MR,
|
ACTION_OPT_VFO_MR,
|
||||||
ACTION_OPT_SWITCH_DEMODUL,
|
ACTION_OPT_SWITCH_DEMODUL,
|
||||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
|
||||||
ACTION_OPT_BLMIN_TMP_OFF, //BackLight Minimum Temporay OFF
|
ACTION_OPT_BLMIN_TMP_OFF, //BackLight Minimum Temporay OFF
|
||||||
#endif
|
ACTION_OPT_SPECTRUM,
|
||||||
ACTION_OPT_LEN
|
ACTION_OPT_LEN
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -150,8 +149,8 @@ typedef struct {
|
|||||||
uint8_t FM_SelectedChannel;
|
uint8_t FM_SelectedChannel;
|
||||||
bool FM_IsMrMode;
|
bool FM_IsMrMode;
|
||||||
uint16_t FM_FrequencyPlaying;
|
uint16_t FM_FrequencyPlaying;
|
||||||
uint16_t FM_LowerLimit;
|
uint8_t FM_Band : 2;
|
||||||
uint16_t FM_UpperLimit;
|
//uint8_t FM_Space : 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t SQUELCH_LEVEL;
|
uint8_t SQUELCH_LEVEL;
|
||||||
@@ -249,17 +248,28 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
uint8_t BACKLIGHT_MAX;
|
uint8_t BACKLIGHT_MAX;
|
||||||
BATTERY_Type_t BATTERY_TYPE;
|
BATTERY_Type_t BATTERY_TYPE;
|
||||||
|
#ifdef ENABLE_RSSI_BAR
|
||||||
|
uint8_t S0_LEVEL;
|
||||||
|
uint8_t S9_LEVEL;
|
||||||
|
#endif
|
||||||
} EEPROM_Config_t;
|
} EEPROM_Config_t;
|
||||||
|
|
||||||
extern EEPROM_Config_t gEeprom;
|
extern EEPROM_Config_t gEeprom;
|
||||||
|
|
||||||
|
void SETTINGS_InitEEPROM(void);
|
||||||
|
void SETTINGS_LoadCalibration(void);
|
||||||
|
uint32_t SETTINGS_FetchChannelFrequency(const int channel);
|
||||||
|
void SETTINGS_FetchChannelName(char *s, const int channel);
|
||||||
|
void SETTINGS_FactoryReset(bool bIsAll);
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
void SETTINGS_SaveFM(void);
|
void SETTINGS_SaveFM(void);
|
||||||
#endif
|
#endif
|
||||||
void SETTINGS_SaveVfoIndices(void);
|
void SETTINGS_SaveVfoIndices(void);
|
||||||
void SETTINGS_SaveSettings(void);
|
void SETTINGS_SaveSettings(void);
|
||||||
|
void SETTINGS_SaveChannelName(uint8_t channel, const char * name);
|
||||||
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);
|
||||||
|
void SETTINGS_WriteBuildOptions(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
36
ui/aircopy.c
@@ -29,41 +29,41 @@
|
|||||||
|
|
||||||
void UI_DisplayAircopy(void)
|
void UI_DisplayAircopy(void)
|
||||||
{
|
{
|
||||||
char String[16];
|
char String[16] = { 0 };
|
||||||
|
char *pPrintStr = { 0 };
|
||||||
|
|
||||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
UI_DisplayClear();
|
||||||
|
|
||||||
if (gAircopyState == AIRCOPY_READY)
|
if (gAircopyState == AIRCOPY_READY) {
|
||||||
strcpy(String, "AIR COPY(RDY)");
|
pPrintStr = "AIR COPY(RDY)";
|
||||||
else
|
} else if (gAircopyState == AIRCOPY_TRANSFER) {
|
||||||
if (gAircopyState == AIRCOPY_TRANSFER)
|
pPrintStr = "AIR COPY";
|
||||||
strcpy(String, "AIR COPY");
|
} else {
|
||||||
else
|
pPrintStr = "AIR COPY(CMP)";
|
||||||
strcpy(String, "AIR COPY(CMP)");
|
}
|
||||||
UI_PrintString(String, 2, 127, 0, 8);
|
|
||||||
|
|
||||||
if (gInputBoxIndex == 0)
|
UI_PrintString(pPrintStr, 2, 127, 0, 8);
|
||||||
{
|
|
||||||
|
if (gInputBoxIndex == 0) {
|
||||||
uint32_t frequency = gRxVfo->freq_config_RX.Frequency;
|
uint32_t frequency = gRxVfo->freq_config_RX.Frequency;
|
||||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_PrintStringSmall(String + 7, 97, 0, 3);
|
UI_PrintStringSmallNormal(String + 7, 97, 0, 3);
|
||||||
String[7] = 0;
|
String[7] = 0;
|
||||||
// show the main large frequency digits
|
// show the main large frequency digits
|
||||||
UI_DisplayFrequency(String, 16, 2, false);
|
UI_DisplayFrequency(String, 16, 2, false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const char *ascii = INPUTBOX_GetAscii();
|
const char *ascii = INPUTBOX_GetAscii();
|
||||||
sprintf(String, "%.3s.%.3s", ascii, ascii + 3);
|
sprintf(String, "%.3s.%.3s", ascii, ascii + 3);
|
||||||
UI_DisplayFrequency(String, 16, 2, false);
|
UI_DisplayFrequency(String, 16, 2, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(String, 0, sizeof(String));
|
memset(String, 0, sizeof(String));
|
||||||
if (gAirCopyIsSendMode == 0)
|
if (gAirCopyIsSendMode == 0) {
|
||||||
sprintf(String, "RCV:%u E:%u", gAirCopyBlockNumber, gErrorsDuringAirCopy);
|
sprintf(String, "RCV:%u E:%u", gAirCopyBlockNumber, gErrorsDuringAirCopy);
|
||||||
else
|
} else if (gAirCopyIsSendMode == 1) {
|
||||||
if (gAirCopyIsSendMode == 1)
|
|
||||||
sprintf(String, "SND:%u", gAirCopyBlockNumber);
|
sprintf(String, "SND:%u", gAirCopyBlockNumber);
|
||||||
|
}
|
||||||
UI_PrintString(String, 2, 127, 4, 8);
|
UI_PrintString(String, 2, 127, 4, 8);
|
||||||
|
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
|
|||||||
27
ui/battery.c
@@ -21,23 +21,24 @@
|
|||||||
#include "driver/st7565.h"
|
#include "driver/st7565.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "ui/battery.h"
|
#include "ui/battery.h"
|
||||||
|
#include "../misc.h"
|
||||||
|
|
||||||
void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink)
|
void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink)
|
||||||
{
|
{
|
||||||
if (level < 2 && blink == 1) {
|
if (level < 2 && blink == 1) {
|
||||||
memset(bitmap, 0, sizeof(BITMAP_BatteryLevel1));
|
memset(bitmap, 0, sizeof(BITMAP_BatteryLevel1));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
memcpy(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
|
||||||
if (level > 2)
|
if (level <= 2) {
|
||||||
{
|
return;
|
||||||
unsigned int i;
|
}
|
||||||
uint8_t bars = level - 2;
|
|
||||||
if (bars > 4)
|
const uint8_t bars = MIN(4, level - 2);
|
||||||
bars = 4;
|
|
||||||
for (i = 0; i < bars; i++)
|
for (int i = 0; i < bars; i++) {
|
||||||
{
|
|
||||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||||
memcpy(bitmap + sizeof(BITMAP_BatteryLevel1) - 4 - (i * 3), BITMAP_BatteryLevel, 2);
|
memcpy(bitmap + sizeof(BITMAP_BatteryLevel1) - 4 - (i * 3), BITMAP_BatteryLevel, 2);
|
||||||
#else
|
#else
|
||||||
@@ -45,12 +46,10 @@ void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UI_DisplayBattery(uint8_t level, uint8_t blink)
|
void UI_DisplayBattery(uint8_t level, uint8_t blink)
|
||||||
{
|
{
|
||||||
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
|
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
|
||||||
UI_DrawBattery(bitmap, level, blink);
|
UI_DrawBattery(bitmap, level, blink);
|
||||||
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, bitmap, sizeof(bitmap));
|
||||||
}
|
}
|
||||||
|
|||||||
100
ui/fmradio.c
@@ -19,6 +19,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "app/fm.h"
|
#include "app/fm.h"
|
||||||
|
#include "driver/bk1080.h"
|
||||||
#include "driver/st7565.h"
|
#include "driver/st7565.h"
|
||||||
#include "external/printf/printf.h"
|
#include "external/printf/printf.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
@@ -30,83 +31,70 @@
|
|||||||
|
|
||||||
void UI_DisplayFM(void)
|
void UI_DisplayFM(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
char String[16] = {0};
|
||||||
char String[16];
|
char *pPrintStr = String;
|
||||||
|
UI_DisplayClear();
|
||||||
|
|
||||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
UI_PrintString("FM", 2, 0, 0, 8);
|
||||||
|
|
||||||
memset(String, 0, sizeof(String));
|
sprintf(String, "%d%s-%dM",
|
||||||
strcpy(String, "FM");
|
BK1080_GetFreqLoLimit(gEeprom.FM_Band)/10,
|
||||||
UI_PrintString(String, 0, 127, 0, 12);
|
gEeprom.FM_Band == 0 ? ".5" : "",
|
||||||
|
BK1080_GetFreqHiLimit(gEeprom.FM_Band)/10
|
||||||
|
);
|
||||||
|
|
||||||
memset(String, 0, sizeof(String));
|
UI_PrintStringSmallNormal(String, 1, 0, 6);
|
||||||
if (gAskToSave)
|
|
||||||
{
|
//uint8_t spacings[] = {20,10,5};
|
||||||
strcpy(String, "SAVE?");
|
//sprintf(String, "%d0k", spacings[gEeprom.FM_Space % 3]);
|
||||||
}
|
//UI_PrintStringSmallNormal(String, 127 - 4*7, 0, 6);
|
||||||
else
|
|
||||||
if (gAskToDelete)
|
if (gAskToSave) {
|
||||||
{
|
pPrintStr = "SAVE?";
|
||||||
strcpy(String, "DEL?");
|
} else if (gAskToDelete) {
|
||||||
}
|
pPrintStr = "DEL?";
|
||||||
else
|
} else if (gFM_ScanState == FM_SCAN_OFF) {
|
||||||
{
|
if (gEeprom.FM_IsMrMode) {
|
||||||
if (gFM_ScanState == FM_SCAN_OFF)
|
sprintf(String, "MR(CH%02u)", gEeprom.FM_SelectedChannel + 1);
|
||||||
{
|
pPrintStr = String;
|
||||||
if (!gEeprom.FM_IsMrMode)
|
} else {
|
||||||
{
|
pPrintStr = "VFO";
|
||||||
for (i = 0; i < 20; i++)
|
for (unsigned int i = 0; i < 20; i++) {
|
||||||
{
|
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i]) {
|
||||||
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i])
|
|
||||||
{
|
|
||||||
sprintf(String, "VFO(CH%02u)", i + 1);
|
sprintf(String, "VFO(CH%02u)", i + 1);
|
||||||
|
pPrintStr = String;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 20)
|
|
||||||
strcpy(String, "VFO");
|
|
||||||
}
|
}
|
||||||
else
|
} else if (gFM_AutoScan) {
|
||||||
sprintf(String, "MR(CH%02u)", gEeprom.FM_SelectedChannel + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!gFM_AutoScan)
|
|
||||||
strcpy(String, "M-SCAN");
|
|
||||||
else
|
|
||||||
sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1);
|
sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1);
|
||||||
|
pPrintStr = String;
|
||||||
|
} else {
|
||||||
|
pPrintStr = "M-SCAN";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
UI_PrintString(String, 0, 127, 2, 10);
|
UI_PrintString(pPrintStr, 0, 127, 3, 10); // memory, vfo, scan
|
||||||
|
|
||||||
memset(String, 0, sizeof(String));
|
memset(String, 0, sizeof(String));
|
||||||
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0))
|
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0)) {
|
||||||
{
|
|
||||||
UI_GenerateChannelString(String, gFM_ChannelPosition);
|
UI_GenerateChannelString(String, gFM_ChannelPosition);
|
||||||
}
|
} else if (gAskToDelete) {
|
||||||
else
|
sprintf(String, "CH-%02u", gEeprom.FM_SelectedChannel + 1);
|
||||||
if (!gAskToDelete)
|
} else {
|
||||||
{
|
if (gInputBoxIndex == 0) {
|
||||||
if (gInputBoxIndex == 0)
|
|
||||||
{
|
|
||||||
sprintf(String, "%3d.%d", gEeprom.FM_FrequencyPlaying / 10, gEeprom.FM_FrequencyPlaying % 10);
|
sprintf(String, "%3d.%d", gEeprom.FM_FrequencyPlaying / 10, gEeprom.FM_FrequencyPlaying % 10);
|
||||||
UI_DisplayFrequency(String, 32, 4, true);
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
const char * ascii = INPUTBOX_GetAscii();
|
const char * ascii = INPUTBOX_GetAscii();
|
||||||
sprintf(String, "%.3s.%.1s",ascii, ascii + 3);
|
sprintf(String, "%.3s.%.1s",ascii, ascii + 3);
|
||||||
UI_DisplayFrequency(String, 32, 4, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI_DisplayFrequency(String, 36, 1, gInputBoxIndex == 0); // frequency
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
UI_PrintString(String, 0, 127, 1, 10);
|
||||||
sprintf(String, "CH-%02u", gEeprom.FM_SelectedChannel + 1);
|
|
||||||
}
|
|
||||||
UI_PrintString(String, 0, 127, 4, 10);
|
|
||||||
|
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
}
|
}
|
||||||
|
|||||||
129
ui/helper.c
@@ -46,22 +46,37 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel)
|
|||||||
|
|
||||||
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber)
|
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber)
|
||||||
{
|
{
|
||||||
if (gInputBoxIndex > 0)
|
if (gInputBoxIndex > 0) {
|
||||||
{
|
for (unsigned int i = 0; i < 3; i++) {
|
||||||
unsigned int i;
|
|
||||||
for (i = 0; i < 3; i++)
|
|
||||||
pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
|
pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
pString[3] = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bShowPrefix)
|
if (bShowPrefix) {
|
||||||
|
// BUG here? Prefixed NULLs are allowed
|
||||||
sprintf(pString, "CH-%03u", ChannelNumber + 1);
|
sprintf(pString, "CH-%03u", ChannelNumber + 1);
|
||||||
else
|
} else if (ChannelNumber == 0xFF) {
|
||||||
if (ChannelNumber == 0xFF)
|
|
||||||
strcpy(pString, "NULL");
|
strcpy(pString, "NULL");
|
||||||
else
|
} else {
|
||||||
sprintf(pString, "%03u", ChannelNumber + 1);
|
sprintf(pString, "%03u", ChannelNumber + 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UI_PrintStringBuffer(const char *pString, uint8_t * buffer, uint32_t char_width, const uint8_t *font)
|
||||||
|
{
|
||||||
|
const size_t Length = strlen(pString);
|
||||||
|
const unsigned int char_spacing = char_width + 1;
|
||||||
|
for (size_t i = 0; i < Length; i++) {
|
||||||
|
const unsigned int index = pString[i] - ' ' - 1;
|
||||||
|
if (pString[i] > ' ' && pString[i] < 127) {
|
||||||
|
const uint32_t offset = i * char_spacing + 1;
|
||||||
|
memcpy(buffer + offset, font + index * char_width, char_width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width)
|
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width)
|
||||||
{
|
{
|
||||||
@@ -77,74 +92,57 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin
|
|||||||
if (pString[i] > ' ' && pString[i] < 127)
|
if (pString[i] > ' ' && pString[i] < 127)
|
||||||
{
|
{
|
||||||
const unsigned int index = pString[i] - ' ' - 1;
|
const unsigned int index = pString[i] - ' ' - 1;
|
||||||
memmove(gFrameBuffer[Line + 0] + ofs, &gFontBig[index][0], 7);
|
memcpy(gFrameBuffer[Line + 0] + ofs, &gFontBig[index][0], 7);
|
||||||
memmove(gFrameBuffer[Line + 1] + ofs, &gFontBig[index][7], 7);
|
memcpy(gFrameBuffer[Line + 1] + ofs, &gFontBig[index][7], 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t char_width, const uint8_t *font)
|
||||||
{
|
{
|
||||||
const size_t Length = strlen(pString);
|
const size_t Length = strlen(pString);
|
||||||
size_t i;
|
|
||||||
|
|
||||||
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)
|
if (End > Start) {
|
||||||
Start += (((End - Start) - (Length * char_spacing)) + 1) / 2;
|
Start += (((End - Start) - Length * char_spacing) + 1) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
UI_PrintStringBuffer(pString, gFrameBuffer[Line] + Start, char_width, font);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t *pFb = gFrameBuffer[Line] + Start;
|
void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
||||||
for (i = 0; i < Length; i++)
|
|
||||||
{
|
{
|
||||||
if (pString[i] > ' ')
|
UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *)gFontSmall);
|
||||||
{
|
|
||||||
const unsigned int index = (unsigned int)pString[i] - ' ' - 1;
|
|
||||||
if (index < ARRAY_SIZE(gFontSmall))
|
|
||||||
memmove(pFb + (i * char_spacing) + 1, &gFontSmall[index], char_width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_SMALL_BOLD
|
|
||||||
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
||||||
{
|
{
|
||||||
const size_t Length = strlen(pString);
|
#ifdef ENABLE_SMALL_BOLD
|
||||||
size_t i;
|
const uint8_t *font = (uint8_t *)gFontSmallBold;
|
||||||
|
const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]);
|
||||||
if (End > Start)
|
#else
|
||||||
Start += (((End - Start) - (Length * 8)) + 1) / 2;
|
const uint8_t *font = (uint8_t *)gFontSmall;
|
||||||
|
const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||||
const unsigned int char_width = ARRAY_SIZE(gFontSmallBold[0]);
|
|
||||||
const unsigned int char_spacing = char_width + 1;
|
|
||||||
uint8_t *pFb = gFrameBuffer[Line] + Start;
|
|
||||||
for (i = 0; i < Length; i++)
|
|
||||||
{
|
|
||||||
if (pString[i] > ' ')
|
|
||||||
{
|
|
||||||
const unsigned int index = (unsigned int)pString[i] - ' ' - 1;
|
|
||||||
if (index < ARRAY_SIZE(gFontSmallBold))
|
|
||||||
memmove(pFb + (i * char_spacing) + 1, &gFontSmallBold[index], char_width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer)
|
UI_PrintStringSmall(pString, Start, End, Line, char_width, font);
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]);
|
|
||||||
const unsigned int char_spacing = char_width + 1;
|
|
||||||
for (i = 0; i < strlen(pString); i++)
|
|
||||||
{
|
|
||||||
if (pString[i] > ' ')
|
|
||||||
{
|
|
||||||
const unsigned int index = (unsigned int)pString[i] - ' ' - 1;
|
|
||||||
if (index < ARRAY_SIZE(gFontSmall))
|
|
||||||
memmove(buffer + (i * char_spacing) + 1, &gFontSmall[index], char_width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t * buffer)
|
||||||
|
{
|
||||||
|
UI_PrintStringBuffer(pString, buffer, ARRAY_SIZE(gFontSmall[0]), (uint8_t *)gFontSmall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UI_PrintStringSmallBufferBold(const char *pString, uint8_t * buffer)
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_SMALL_BOLD
|
||||||
|
const uint8_t *font = (uint8_t *)gFontSmallBold;
|
||||||
|
const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]);
|
||||||
|
#else
|
||||||
|
const uint8_t *font = (uint8_t *)gFontSmall;
|
||||||
|
const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||||
|
#endif
|
||||||
|
UI_PrintStringBuffer(pString, buffer, char_width, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
|
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
|
||||||
@@ -184,10 +182,11 @@ void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
|
|||||||
|
|
||||||
void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black)
|
void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black)
|
||||||
{
|
{
|
||||||
|
const uint8_t pattern = 1 << (y % 8);
|
||||||
if(black)
|
if(black)
|
||||||
buffer[y/8][x] |= 1 << (y%8);
|
buffer[y/8][x] |= pattern;
|
||||||
else
|
else
|
||||||
buffer[y/8][x] &= ~(1 << (y%8));
|
buffer[y/8][x] &= ~pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sort(int16_t *a, int16_t *b)
|
static void sort(int16_t *a, int16_t *b)
|
||||||
@@ -227,11 +226,10 @@ void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int1
|
|||||||
UI_DrawLineBuffer(buffer, 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)
|
||||||
{
|
{
|
||||||
for(uint8_t i = 0; i < 7; i++) {
|
UI_DisplayClear();
|
||||||
memset(gFrameBuffer[i], 0x00, 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
// for(uint8_t i = 1; i < 5; i++) {
|
// for(uint8_t i = 1; i < 5; i++) {
|
||||||
// memset(gFrameBuffer[i]+8, 0x00, 111);
|
// memset(gFrameBuffer[i]+8, 0x00, 111);
|
||||||
@@ -248,5 +246,10 @@ void UI_DisplayPopup(const char *string)
|
|||||||
// }
|
// }
|
||||||
// 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);
|
||||||
UI_PrintStringSmall("Press EXIT", 9, 118, 6);
|
UI_PrintStringSmallNormal("Press EXIT", 9, 118, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UI_DisplayClear()
|
||||||
|
{
|
||||||
|
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
||||||
}
|
}
|
||||||
11
ui/helper.h
@@ -23,13 +23,11 @@
|
|||||||
void UI_GenerateChannelString(char *pString, const uint8_t Channel);
|
void UI_GenerateChannelString(char *pString, const uint8_t Channel);
|
||||||
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber);
|
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber);
|
||||||
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width);
|
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width);
|
||||||
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||||
#ifdef ENABLE_SMALL_BOLD
|
|
||||||
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||||
#endif
|
void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t *buffer);
|
||||||
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer);
|
void UI_PrintStringSmallBufferBold(const char *pString, uint8_t * buffer);
|
||||||
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center);
|
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center);
|
||||||
#endif
|
|
||||||
|
|
||||||
void UI_DisplayPopup(const char *string);
|
void UI_DisplayPopup(const char *string);
|
||||||
|
|
||||||
@@ -37,3 +35,6 @@ void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, 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_DrawLineBuffer(uint8_t (*buffer)[128], 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);
|
void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
|
||||||
|
|
||||||
|
void UI_DisplayClear();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -35,10 +35,9 @@ static void Render(void)
|
|||||||
char String[7];
|
char String[7];
|
||||||
|
|
||||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
UI_DisplayClear();
|
||||||
|
|
||||||
strcpy(String, "LOCK");
|
UI_PrintString("LOCK", 0, 127, 1, 10);
|
||||||
UI_PrintString(String, 0, 127, 1, 10);
|
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
String[i] = (gInputBox[i] == 10) ? '-' : '*';
|
String[i] = (gInputBox[i] == 10) ? '-' : '*';
|
||||||
String[6] = 0;
|
String[6] = 0;
|
||||||
@@ -143,13 +142,14 @@ void UI_DisplayLock(void)
|
|||||||
gKeyReading0 = Key;
|
gKeyReading0 = Key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UART
|
||||||
if (UART_IsCommandAvailable())
|
if (UART_IsCommandAvailable())
|
||||||
{
|
{
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
UART_HandleCommand();
|
UART_HandleCommand();
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (gUpdateDisplay)
|
if (gUpdateDisplay)
|
||||||
{
|
{
|
||||||
Render();
|
Render();
|
||||||
|
|||||||
349
ui/main.c
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "app/chFrScanner.h"
|
#include "app/chFrScanner.h"
|
||||||
#include "app/dtmf.h"
|
#include "app/dtmf.h"
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX
|
||||||
#include "am_fix.h"
|
#include "am_fix.h"
|
||||||
#endif
|
#endif
|
||||||
#include "bitmaps.h"
|
#include "bitmaps.h"
|
||||||
@@ -39,6 +39,26 @@
|
|||||||
|
|
||||||
center_line_t center_line = CENTER_LINE_NONE;
|
center_line_t center_line = CENTER_LINE_NONE;
|
||||||
|
|
||||||
|
const int8_t dBmCorrTable[7] = {
|
||||||
|
-15, // band 1
|
||||||
|
-25, // band 2
|
||||||
|
-20, // band 3
|
||||||
|
-4, // band 4
|
||||||
|
-7, // band 5
|
||||||
|
-6, // band 6
|
||||||
|
-1 // band 7
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *VfoStateStr[] = {
|
||||||
|
[VFO_STATE_NORMAL]="",
|
||||||
|
[VFO_STATE_BUSY]="BUSY",
|
||||||
|
[VFO_STATE_BAT_LOW]="BAT LOW",
|
||||||
|
[VFO_STATE_TX_DISABLE]="TX DISABLE",
|
||||||
|
[VFO_STATE_TIMEOUT]="TIMEOUT",
|
||||||
|
[VFO_STATE_ALARM]="ALARM",
|
||||||
|
[VFO_STATE_VOLTAGE_HIGH]="VOLT HIGH"
|
||||||
|
};
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
static void DrawSmallAntennaAndBars(uint8_t *p, unsigned int level)
|
static void DrawSmallAntennaAndBars(uint8_t *p, unsigned int level)
|
||||||
@@ -140,11 +160,10 @@ void UI_DisplayAudioBar(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void DisplayRSSIBar(const int16_t rssi, const bool now)
|
void DisplayRSSIBar(const bool now)
|
||||||
{
|
{
|
||||||
#if defined(ENABLE_RSSI_BAR)
|
#if defined(ENABLE_RSSI_BAR)
|
||||||
|
|
||||||
if (center_line == CENTER_LINE_RSSI) {
|
|
||||||
const unsigned int txt_width = 7 * 8; // 8 text chars
|
const unsigned int txt_width = 7 * 8; // 8 text chars
|
||||||
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
|
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
|
||||||
|
|
||||||
@@ -162,7 +181,7 @@ static void DisplayRSSIBar(const int16_t rssi, const bool now)
|
|||||||
0b00011000,
|
0b00011000,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
|
if ((gEeprom.KEY_LOCK && gKeypadLocked > 0) || center_line != CENTER_LINE_RSSI)
|
||||||
return; // display is in use
|
return; // display is in use
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_TRANSMIT ||
|
if (gCurrentFunction == FUNCTION_TRANSMIT ||
|
||||||
@@ -176,21 +195,18 @@ static void DisplayRSSIBar(const int16_t rssi, const bool now)
|
|||||||
if (now)
|
if (now)
|
||||||
memset(p_line, 0, LCD_WIDTH);
|
memset(p_line, 0, LCD_WIDTH);
|
||||||
|
|
||||||
const int8_t dBmCorrTable[7] = {
|
|
||||||
-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 s0_dBm = -gEeprom.S0_LEVEL; // S0 .. base level
|
||||||
const int16_t rssi_dBm = (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band];
|
const int16_t rssi_dBm =
|
||||||
|
BK4819_GetRSSI_dBm()
|
||||||
|
#ifdef ENABLE_AM_FIX
|
||||||
|
+ ((gSetting_AM_fix && gRxVfo->Modulation == MODULATION_AM) ? AM_fix_get_gain_diff() : 0)
|
||||||
|
#endif
|
||||||
|
+ dBmCorrTable[gRxVfo->Band];
|
||||||
|
|
||||||
const uint8_t s_level = MIN(MAX((rssi_dBm - s0_dBm) / 6, 0), 9); // S0 - S9
|
int s0_9 = gEeprom.S0_LEVEL - gEeprom.S9_LEVEL;
|
||||||
uint8_t overS9dBm = MIN(MAX(rssi_dBm - (s0_dBm + 9*6), 0), 99);
|
const uint8_t s_level = MIN(MAX((int32_t)(rssi_dBm - s0_dBm)*100 / (s0_9*100/9), 0), 9); // S0 - S9
|
||||||
|
uint8_t overS9dBm = MIN(MAX(rssi_dBm + gEeprom.S9_LEVEL, 0), 99);
|
||||||
uint8_t overS9Bars = MIN(overS9dBm/10, 4);
|
uint8_t overS9Bars = MIN(overS9dBm/10, 4);
|
||||||
|
|
||||||
if(overS9Bars == 0) {
|
if(overS9Bars == 0) {
|
||||||
@@ -201,12 +217,12 @@ static void DisplayRSSIBar(const int16_t rssi, const bool now)
|
|||||||
memcpy(p_line + 2 + 7*5, &plus, ARRAY_SIZE(plus));
|
memcpy(p_line + 2 + 7*5, &plus, ARRAY_SIZE(plus));
|
||||||
}
|
}
|
||||||
|
|
||||||
UI_PrintStringSmall(str, 2, 0, line);
|
UI_PrintStringSmallNormal(str, 2, 0, line);
|
||||||
|
|
||||||
DrawLevelBar(bar_x, line, s_level + overS9Bars);
|
DrawLevelBar(bar_x, line, s_level + overS9Bars);
|
||||||
}
|
if (now)
|
||||||
|
ST7565_BlitLine(line);
|
||||||
#else
|
#else
|
||||||
|
int16_t rssi = BK4819_GetRSSI();
|
||||||
uint8_t Level;
|
uint8_t Level;
|
||||||
|
|
||||||
if (rssi >= gEEPROM_RSSI_CALIB[gRxVfo->Band][3]) {
|
if (rssi >= gEEPROM_RSSI_CALIB[gRxVfo->Band][3]) {
|
||||||
@@ -225,42 +241,75 @@ static void DisplayRSSIBar(const int16_t rssi, const bool now)
|
|||||||
if (now)
|
if (now)
|
||||||
memset(pLine, 0, 23);
|
memset(pLine, 0, 23);
|
||||||
DrawSmallAntennaAndBars(pLine, Level);
|
DrawSmallAntennaAndBars(pLine, Level);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (now)
|
if (now)
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_AGC_SHOW_DATA
|
||||||
void UI_UpdateRSSI(const int16_t rssi, const int vfo)
|
void UI_MAIN_PrintAGC(bool now)
|
||||||
{
|
{
|
||||||
(void)vfo; // unused
|
char buf[20];
|
||||||
|
memset(gFrameBuffer[3], 0, 128);
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint16_t _ : 5;
|
||||||
|
uint16_t agcSigStrength : 7;
|
||||||
|
int16_t gainIdx : 3;
|
||||||
|
uint16_t agcEnab : 1;
|
||||||
|
};
|
||||||
|
uint16_t __raw;
|
||||||
|
} reg7e;
|
||||||
|
reg7e.__raw = BK4819_ReadRegister(0x7E);
|
||||||
|
uint8_t gainAddr = reg7e.gainIdx < 0 ? 0x14 : 0x10 + reg7e.gainIdx;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint16_t pga:3;
|
||||||
|
uint16_t mixer:2;
|
||||||
|
uint16_t lna:3;
|
||||||
|
uint16_t lnaS:2;
|
||||||
|
};
|
||||||
|
uint16_t __raw;
|
||||||
|
} agcGainReg;
|
||||||
|
agcGainReg.__raw = BK4819_ReadRegister(gainAddr);
|
||||||
|
int8_t lnaShortTab[] = {-28, -24, -19, 0};
|
||||||
|
int8_t lnaTab[] = {-24, -19, -14, -9, -6, -4, -2, 0};
|
||||||
|
int8_t mixerTab[] = {-8, -6, -3, 0};
|
||||||
|
int8_t pgaTab[] = {-33, -27, -21, -15, -9, -6, -3, 0};
|
||||||
|
int16_t agcGain = lnaShortTab[agcGainReg.lnaS] + lnaTab[agcGainReg.lna] + mixerTab[agcGainReg.mixer] + pgaTab[agcGainReg.pga];
|
||||||
|
|
||||||
// optional larger RSSI dBm, S-point and bar level
|
sprintf(buf, "%d%2d %2d %2d %3d", reg7e.agcEnab, reg7e.gainIdx, -agcGain, reg7e.agcSigStrength, BK4819_GetRSSI());
|
||||||
|
UI_PrintStringSmallNormal(buf, 2, 0, 3);
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
if(now)
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
ST7565_BlitLine(3);
|
||||||
gCurrentFunction == FUNCTION_INCOMING)
|
|
||||||
{
|
|
||||||
|
|
||||||
DisplayRSSIBar(rssi, true);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void UI_MAIN_TimeSlice500ms(void)
|
||||||
|
{
|
||||||
|
if(gScreenToDisplay==DISPLAY_MAIN) {
|
||||||
|
#ifdef ENABLE_AGC_SHOW_DATA
|
||||||
|
UI_MAIN_PrintAGC(true);
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(FUNCTION_IsRx()) {
|
||||||
|
DisplayRSSIBar(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
void UI_DisplayMain(void)
|
void UI_DisplayMain(void)
|
||||||
{
|
{
|
||||||
const unsigned int line0 = 0; // text screen line
|
|
||||||
const unsigned int line1 = 4;
|
|
||||||
char String[22];
|
char String[22];
|
||||||
unsigned int vfo_num;
|
|
||||||
|
|
||||||
center_line = CENTER_LINE_NONE;
|
center_line = CENTER_LINE_NONE;
|
||||||
|
|
||||||
// clear the screen
|
// clear the screen
|
||||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
UI_DisplayClear();
|
||||||
|
|
||||||
if(gLowBattery && !gLowBatteryConfirmed) {
|
if(gLowBattery && !gLowBatteryConfirmed) {
|
||||||
UI_DisplayPopup("LOW BATTERY");
|
UI_DisplayPopup("LOW BATTERY");
|
||||||
@@ -278,13 +327,15 @@ void UI_DisplayMain(void)
|
|||||||
|
|
||||||
unsigned int activeTxVFO = gRxVfoIsActive ? gEeprom.RX_VFO : gEeprom.TX_VFO;
|
unsigned int activeTxVFO = gRxVfoIsActive ? gEeprom.RX_VFO : gEeprom.TX_VFO;
|
||||||
|
|
||||||
for (vfo_num = 0; vfo_num < 2; vfo_num++)
|
for (unsigned int vfo_num = 0; vfo_num < 2; vfo_num++)
|
||||||
{
|
{
|
||||||
|
const unsigned int line0 = 0; // text screen line
|
||||||
|
const unsigned int line1 = 4;
|
||||||
const unsigned int line = (vfo_num == 0) ? line0 : line1;
|
const unsigned int line = (vfo_num == 0) ? line0 : line1;
|
||||||
const bool isMainVFO = (vfo_num == gEeprom.TX_VFO);
|
const bool isMainVFO = (vfo_num == gEeprom.TX_VFO);
|
||||||
uint8_t *p_line0 = gFrameBuffer[line + 0];
|
uint8_t *p_line0 = gFrameBuffer[line + 0];
|
||||||
uint8_t *p_line1 = gFrameBuffer[line + 1];
|
uint8_t *p_line1 = gFrameBuffer[line + 1];
|
||||||
unsigned int mode = 0;
|
enum Vfo_txtr_mode mode = VFO_MODE_NONE;
|
||||||
|
|
||||||
if (activeTxVFO != vfo_num) // this is not active TX VFO
|
if (activeTxVFO != vfo_num) // this is not active TX VFO
|
||||||
{
|
{
|
||||||
@@ -292,128 +343,112 @@ void UI_DisplayMain(void)
|
|||||||
if(gScanRangeStart) {
|
if(gScanRangeStart) {
|
||||||
UI_PrintString("ScnRng", 5, 0, line, 8);
|
UI_PrintString("ScnRng", 5, 0, line, 8);
|
||||||
sprintf(String, "%3u.%05u", gScanRangeStart / 100000, gScanRangeStart % 100000);
|
sprintf(String, "%3u.%05u", gScanRangeStart / 100000, gScanRangeStart % 100000);
|
||||||
UI_PrintStringSmall(String, 56, 0, line);
|
UI_PrintStringSmallNormal(String, 56, 0, line);
|
||||||
uint32_t frq = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
|
sprintf(String, "%3u.%05u", gScanRangeStop / 100000, gScanRangeStop % 100000);
|
||||||
sprintf(String, "%3u.%05u", frq / 100000, frq % 100000);
|
UI_PrintStringSmallNormal(String, 56, 0, line + 1);
|
||||||
UI_PrintStringSmall(String, 56, 0, line + 1);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (
|
if (gDTMF_InputMode
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx ||
|
|| gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx
|
||||||
#endif
|
#endif
|
||||||
gDTMF_InputMode)
|
) {
|
||||||
{ // show DTMF stuff
|
char *pPrintStr = "";
|
||||||
|
// show DTMF stuff
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
char Contact[16];
|
char Contact[16];
|
||||||
|
if (!gDTMF_InputMode) {
|
||||||
|
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) {
|
||||||
|
pPrintStr = DTMF_FindContact(gDTMF_String, Contact) ? Contact : gDTMF_String;
|
||||||
|
} else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY){
|
||||||
|
pPrintStr = DTMF_FindContact(gDTMF_Callee, Contact) ? Contact : gDTMF_Callee;
|
||||||
|
}else if (gDTMF_IsTx) {
|
||||||
|
pPrintStr = gDTMF_String;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!gDTMF_InputMode)
|
UI_PrintString(pPrintStr, 2, 0, 2 + (vfo_num * 3), 8);
|
||||||
{
|
|
||||||
|
|
||||||
memset(Contact, 0, sizeof(Contact));
|
pPrintStr = "";
|
||||||
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT)
|
if (!gDTMF_InputMode) {
|
||||||
strcpy(String, (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT");
|
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) {
|
||||||
else
|
pPrintStr = (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT";
|
||||||
if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY)
|
} else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) {
|
||||||
sprintf(String, "CALL FRM:%s", (DTMF_FindContact(gDTMF_Caller, Contact)) ? Contact : gDTMF_Caller);
|
sprintf(String, "CALL FRM:%s", (DTMF_FindContact(gDTMF_Caller, Contact)) ? Contact : gDTMF_Caller);
|
||||||
else
|
pPrintStr = String;
|
||||||
if (gDTMF_IsTx)
|
} else if (gDTMF_IsTx) {
|
||||||
strcpy(String, (gDTMF_State == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX");
|
pPrintStr = (gDTMF_State == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
sprintf(String, ">%s", gDTMF_InputBox);
|
sprintf(String, ">%s", gDTMF_InputBox);
|
||||||
}
|
pPrintStr = String;
|
||||||
UI_PrintString(String, 2, 0, 0 + (vfo_num * 3), 8);
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
|
||||||
memset(String, 0, sizeof(String));
|
|
||||||
if (!gDTMF_InputMode) {
|
|
||||||
memset(Contact, 0, sizeof(Contact));
|
|
||||||
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT)
|
|
||||||
sprintf(String, ">%s", (DTMF_FindContact(gDTMF_String, Contact)) ? Contact : gDTMF_String);
|
|
||||||
else
|
|
||||||
if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY)
|
|
||||||
sprintf(String, ">%s", (DTMF_FindContact(gDTMF_Callee, Contact)) ? Contact : gDTMF_Callee);
|
|
||||||
else
|
|
||||||
if (gDTMF_IsTx)
|
|
||||||
sprintf(String, ">%s", gDTMF_String);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8);
|
UI_PrintString(pPrintStr, 2, 0, 0 + (vfo_num * 3), 8);
|
||||||
#endif
|
|
||||||
center_line = CENTER_LINE_IN_USE;
|
center_line = CENTER_LINE_IN_USE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// highlight the selected/used VFO with a marker
|
// highlight the selected/used VFO with a marker
|
||||||
if (isMainVFO)
|
if (isMainVFO)
|
||||||
memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
|
memcpy(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
|
||||||
}
|
}
|
||||||
else // active TX VFO
|
else // active TX VFO
|
||||||
{ // highlight the selected/used VFO with a marker
|
{ // highlight the selected/used VFO with a marker
|
||||||
if (isMainVFO)
|
if (isMainVFO)
|
||||||
memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
|
memcpy(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
|
||||||
else
|
else
|
||||||
memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault));
|
memcpy(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
||||||
{ // transmitting
|
{ // transmitting
|
||||||
|
|
||||||
#ifdef ENABLE_ALARM
|
#ifdef ENABLE_ALARM
|
||||||
if (gAlarmState == ALARM_STATE_ALARM)
|
if (gAlarmState == ALARM_STATE_SITE_ALARM)
|
||||||
mode = 2;
|
mode = VFO_MODE_RX;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (activeTxVFO == vfo_num)
|
if (activeTxVFO == vfo_num)
|
||||||
{ // show the TX symbol
|
{ // show the TX symbol
|
||||||
mode = 1;
|
mode = VFO_MODE_TX;
|
||||||
#ifdef ENABLE_SMALL_BOLD
|
|
||||||
UI_PrintStringSmallBold("TX", 14, 0, line);
|
UI_PrintStringSmallBold("TX", 14, 0, line);
|
||||||
#else
|
|
||||||
UI_PrintStringSmall("TX", 14, 0, line);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // receiving .. show the RX symbol
|
{ // receiving .. show the RX symbol
|
||||||
mode = 2;
|
mode = VFO_MODE_RX;
|
||||||
if ((gCurrentFunction == FUNCTION_RECEIVE ||
|
if (FUNCTION_IsRx() && gEeprom.RX_VFO == vfo_num) {
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
|
||||||
gCurrentFunction == FUNCTION_INCOMING) &&
|
|
||||||
gEeprom.RX_VFO == vfo_num)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_SMALL_BOLD
|
|
||||||
UI_PrintStringSmallBold("RX", 14, 0, line);
|
UI_PrintStringSmallBold("RX", 14, 0, line);
|
||||||
#else
|
|
||||||
UI_PrintStringSmall("RX", 14, 0, line);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
||||||
{ // channel mode
|
{ // channel mode
|
||||||
const unsigned int x = 2;
|
const unsigned int x = 2;
|
||||||
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) ? false : true;
|
const bool inputting = gInputBoxIndex != 0 && gEeprom.TX_VFO == vfo_num;
|
||||||
if (!inputting)
|
if (!inputting)
|
||||||
sprintf(String, "M%u", gEeprom.ScreenChannel[vfo_num] + 1);
|
sprintf(String, "M%u", gEeprom.ScreenChannel[vfo_num] + 1);
|
||||||
else
|
else
|
||||||
sprintf(String, "M%.3s", INPUTBOX_GetAscii()); // show the input text
|
sprintf(String, "M%.3s", INPUTBOX_GetAscii()); // show the input text
|
||||||
UI_PrintStringSmall(String, x, 0, line + 1);
|
UI_PrintStringSmallNormal(String, x, 0, line + 1);
|
||||||
}
|
}
|
||||||
else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
||||||
{ // frequency mode
|
{ // frequency mode
|
||||||
// show the frequency band number
|
// show the frequency band number
|
||||||
const unsigned int x = 2;
|
const unsigned int x = 2;
|
||||||
char * buf = gEeprom.VfoInfo[vfo_num].pRX->Frequency < 100000000 ? "" : "+";
|
char * buf = gEeprom.VfoInfo[vfo_num].pRX->Frequency < _1GHz_in_KHz ? "" : "+";
|
||||||
sprintf(String, "F%u%s", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST, buf);
|
sprintf(String, "F%u%s", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST, buf);
|
||||||
UI_PrintStringSmall(String, x, 0, line + 1);
|
UI_PrintStringSmallNormal(String, x, 0, line + 1);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
else
|
else
|
||||||
@@ -426,16 +461,16 @@ void UI_DisplayMain(void)
|
|||||||
{ // user entering channel number
|
{ // user entering channel number
|
||||||
sprintf(String, "N%u%u", '0' + gInputBox[0], '0' + gInputBox[1]);
|
sprintf(String, "N%u%u", '0' + gInputBox[0], '0' + gInputBox[1]);
|
||||||
}
|
}
|
||||||
UI_PrintStringSmall(String, 7, 0, line + 1);
|
UI_PrintStringSmallNormal(String, 7, 0, line + 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************
|
// ************
|
||||||
|
|
||||||
unsigned int state = VfoState[vfo_num];
|
enum VfoState_t state = VfoState[vfo_num];
|
||||||
|
|
||||||
#ifdef ENABLE_ALARM
|
#ifdef ENABLE_ALARM
|
||||||
if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) {
|
if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_SITE_ALARM) {
|
||||||
if (activeTxVFO == vfo_num)
|
if (activeTxVFO == vfo_num)
|
||||||
state = VFO_STATE_ALARM;
|
state = VFO_STATE_ALARM;
|
||||||
}
|
}
|
||||||
@@ -445,19 +480,18 @@ void UI_DisplayMain(void)
|
|||||||
|
|
||||||
if (state != VFO_STATE_NORMAL)
|
if (state != VFO_STATE_NORMAL)
|
||||||
{
|
{
|
||||||
const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"};
|
if (state < ARRAY_SIZE(VfoStateStr))
|
||||||
if (state < ARRAY_SIZE(state_list))
|
UI_PrintString(VfoStateStr[state], 31, 0, line, 8);
|
||||||
UI_PrintString(state_list[state], 31, 0, line, 8);
|
|
||||||
}
|
}
|
||||||
else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
|
else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
|
||||||
{ // user entering a frequency
|
{ // user entering a frequency
|
||||||
const char * ascii = INPUTBOX_GetAscii();
|
const char * ascii = INPUTBOX_GetAscii();
|
||||||
bool isGigaF = frequency>=100000000;
|
bool isGigaF = frequency>=_1GHz_in_KHz;
|
||||||
sprintf(String, "%.*s.%.3s", 3 + isGigaF, ascii, ascii + 3 + isGigaF);
|
sprintf(String, "%.*s.%.3s", 3 + isGigaF, ascii, ascii + 3 + isGigaF);
|
||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
if(!isGigaF) {
|
if(!isGigaF) {
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
UI_PrintStringSmallNormal(String + 7, 113, 0, line + 1);
|
||||||
String[7] = 0;
|
String[7] = 0;
|
||||||
// show the main large frequency digits
|
// show the main large frequency digits
|
||||||
UI_DisplayFrequency(String, 32, line, false);
|
UI_DisplayFrequency(String, 32, line, false);
|
||||||
@@ -485,14 +519,14 @@ void UI_DisplayMain(void)
|
|||||||
// show the scan list assigment symbols
|
// show the scan list assigment symbols
|
||||||
const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
||||||
if (att.scanlist1)
|
if (att.scanlist1)
|
||||||
memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
|
memcpy(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
|
||||||
if (att.scanlist2)
|
if (att.scanlist2)
|
||||||
memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
|
memcpy(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
|
||||||
|
|
||||||
// compander symbol
|
// compander symbol
|
||||||
#ifndef ENABLE_BIG_FREQ
|
#ifndef ENABLE_BIG_FREQ
|
||||||
if (att.compander)
|
if (att.compander)
|
||||||
memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
|
memcpy(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
|
||||||
#endif
|
#endif
|
||||||
@@ -502,9 +536,9 @@ void UI_DisplayMain(void)
|
|||||||
case MDF_FREQUENCY: // show the channel frequency
|
case MDF_FREQUENCY: // show the channel frequency
|
||||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
if(frequency < 100000000) {
|
if(frequency < _1GHz_in_KHz) {
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
UI_PrintStringSmallNormal(String + 7, 113, 0, line + 1);
|
||||||
String[7] = 0;
|
String[7] = 0;
|
||||||
// show the main large frequency digits
|
// show the main large frequency digits
|
||||||
UI_DisplayFrequency(String, 32, line, false);
|
UI_DisplayFrequency(String, 32, line, false);
|
||||||
@@ -526,7 +560,7 @@ void UI_DisplayMain(void)
|
|||||||
case MDF_NAME: // show the channel name
|
case MDF_NAME: // show the channel name
|
||||||
case MDF_NAME_FREQ: // show the channel name and frequency
|
case MDF_NAME_FREQ: // show the channel name and frequency
|
||||||
|
|
||||||
BOARD_fetchChannelName(String, gEeprom.ScreenChannel[vfo_num]);
|
SETTINGS_FetchChannelName(String, gEeprom.ScreenChannel[vfo_num]);
|
||||||
if (String[0] == 0)
|
if (String[0] == 0)
|
||||||
{ // no channel name, show the channel number instead
|
{ // no channel name, show the channel number instead
|
||||||
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
|
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
|
||||||
@@ -536,14 +570,10 @@ void UI_DisplayMain(void)
|
|||||||
UI_PrintString(String, 32, 0, line, 8);
|
UI_PrintString(String, 32, 0, line, 8);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef ENABLE_SMALL_BOLD
|
|
||||||
UI_PrintStringSmallBold(String, 32 + 4, 0, line);
|
UI_PrintStringSmallBold(String, 32 + 4, 0, line);
|
||||||
#else
|
|
||||||
UI_PrintStringSmall(String, 32 + 4, 0, line);
|
|
||||||
#endif
|
|
||||||
// show the channel frequency below the channel number/name
|
// show the channel frequency below the channel number/name
|
||||||
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
||||||
UI_PrintStringSmall(String, 32 + 4, 0, line + 1);
|
UI_PrintStringSmallNormal(String, 32 + 4, 0, line + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -554,9 +584,9 @@ void UI_DisplayMain(void)
|
|||||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||||
|
|
||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
if(frequency < 100000000) {
|
if(frequency < _1GHz_in_KHz) {
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
UI_PrintStringSmallNormal(String + 7, 113, 0, line + 1);
|
||||||
String[7] = 0;
|
String[7] = 0;
|
||||||
// show the main large frequency digits
|
// show the main large frequency digits
|
||||||
UI_DisplayFrequency(String, 32, line, false);
|
UI_DisplayFrequency(String, 32, line, false);
|
||||||
@@ -572,9 +602,9 @@ void UI_DisplayMain(void)
|
|||||||
const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
||||||
if (att.compander)
|
if (att.compander)
|
||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand));
|
memcpy(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand));
|
||||||
#else
|
#else
|
||||||
memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
|
memcpy(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -584,7 +614,7 @@ void UI_DisplayMain(void)
|
|||||||
{ // show the TX/RX level
|
{ // show the TX/RX level
|
||||||
uint8_t Level = 0;
|
uint8_t Level = 0;
|
||||||
|
|
||||||
if (mode == 1)
|
if (mode == VFO_MODE_TX)
|
||||||
{ // TX power level
|
{ // TX power level
|
||||||
switch (gRxVfo->OUTPUT_POWER)
|
switch (gRxVfo->OUTPUT_POWER)
|
||||||
{
|
{
|
||||||
@@ -594,7 +624,7 @@ void UI_DisplayMain(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (mode == 2)
|
if (mode == VFO_MODE_RX)
|
||||||
{ // RX signal level
|
{ // RX signal level
|
||||||
#ifndef ENABLE_RSSI_BAR
|
#ifndef ENABLE_RSSI_BAR
|
||||||
// bar graph
|
// bar graph
|
||||||
@@ -609,13 +639,14 @@ void UI_DisplayMain(void)
|
|||||||
// ************
|
// ************
|
||||||
|
|
||||||
String[0] = '\0';
|
String[0] = '\0';
|
||||||
|
const VFO_Info_t *vfoInfo = &gEeprom.VfoInfo[vfo_num];
|
||||||
|
|
||||||
// show the modulation symbol
|
// show the modulation symbol
|
||||||
const char * s = "";
|
const char * s = "";
|
||||||
const ModulationMode_t mod = gEeprom.VfoInfo[vfo_num].Modulation;
|
const ModulationMode_t mod = vfoInfo->Modulation;
|
||||||
switch (mod){
|
switch (mod){
|
||||||
case MODULATION_FM: {
|
case MODULATION_FM: {
|
||||||
const FREQ_Config_t *pConfig = (mode == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX;
|
const FREQ_Config_t *pConfig = (mode == VFO_MODE_TX) ? vfoInfo->pTX : vfoInfo->pRX;
|
||||||
const unsigned int code_type = pConfig->CodeType;
|
const unsigned int code_type = pConfig->CodeType;
|
||||||
const char *code_list[] = {"", "CT", "DCS", "DCR"};
|
const char *code_list[] = {"", "CT", "DCS", "DCR"};
|
||||||
if (code_type < ARRAY_SIZE(code_list))
|
if (code_type < ARRAY_SIZE(code_list))
|
||||||
@@ -626,57 +657,49 @@ void UI_DisplayMain(void)
|
|||||||
s = gModulationStr[mod];
|
s = gModulationStr[mod];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UI_PrintStringSmall(s, LCD_WIDTH + 24, 0, line + 1);
|
UI_PrintStringSmallNormal(s, LCD_WIDTH + 24, 0, line + 1);
|
||||||
|
|
||||||
if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM)
|
if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM)
|
||||||
{ // show the TX power
|
{ // show the TX power
|
||||||
const char pwr_list[] = "LMH";
|
const char pwr_list[][2] = {"L","M","H"};
|
||||||
const unsigned int i = gEeprom.VfoInfo[vfo_num].OUTPUT_POWER;
|
int i = vfoInfo->OUTPUT_POWER % 3;
|
||||||
String[0] = (i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0';
|
UI_PrintStringSmallNormal(pwr_list[i], LCD_WIDTH + 46, 0, line + 1);
|
||||||
String[1] = '\0';
|
|
||||||
UI_PrintStringSmall(String, LCD_WIDTH + 46, 0, line + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gEeprom.VfoInfo[vfo_num].freq_config_RX.Frequency != gEeprom.VfoInfo[vfo_num].freq_config_TX.Frequency)
|
if (vfoInfo->freq_config_RX.Frequency != vfoInfo->freq_config_TX.Frequency)
|
||||||
{ // show the TX offset symbol
|
{ // show the TX offset symbol
|
||||||
const char dir_list[] = "\0+-";
|
const char dir_list[][2] = {"", "+", "-"};
|
||||||
const unsigned int i = gEeprom.VfoInfo[vfo_num].TX_OFFSET_FREQUENCY_DIRECTION;
|
int i = vfoInfo->TX_OFFSET_FREQUENCY_DIRECTION % 3;
|
||||||
String[0] = (i < sizeof(dir_list)) ? dir_list[i] : '?';
|
UI_PrintStringSmallNormal(dir_list[i], LCD_WIDTH + 54, 0, line + 1);
|
||||||
String[1] = '\0';
|
|
||||||
UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, line + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// show the TX/RX reverse symbol
|
// show the TX/RX reverse symbol
|
||||||
if (gEeprom.VfoInfo[vfo_num].FrequencyReverse)
|
if (vfoInfo->FrequencyReverse)
|
||||||
UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, line + 1);
|
UI_PrintStringSmallNormal("R", LCD_WIDTH + 62, 0, line + 1);
|
||||||
|
|
||||||
{ // show the narrow band symbol
|
if (vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW)
|
||||||
String[0] = '\0';
|
UI_PrintStringSmallNormal("N", LCD_WIDTH + 70, 0, line + 1);
|
||||||
if (gEeprom.VfoInfo[vfo_num].CHANNEL_BANDWIDTH == BANDWIDTH_NARROW)
|
|
||||||
{
|
|
||||||
String[0] = 'N';
|
|
||||||
String[1] = '\0';
|
|
||||||
}
|
|
||||||
UI_PrintStringSmall(String, LCD_WIDTH + 70, 0, line + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#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 (vfoInfo->DTMF_DECODING_ENABLE || gSetting_KILLED)
|
||||||
UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1);
|
UI_PrintStringSmallNormal("DTMF", LCD_WIDTH + 78, 0, line + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// show the audio scramble symbol
|
// show the audio scramble symbol
|
||||||
if (gEeprom.VfoInfo[vfo_num].SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable)
|
if (vfoInfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable)
|
||||||
UI_PrintStringSmall("SCR", LCD_WIDTH + 106, 0, line + 1);
|
UI_PrintStringSmallNormal("SCR", LCD_WIDTH + 106, 0, line + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_AGC_SHOW_DATA
|
||||||
|
center_line = CENTER_LINE_IN_USE;
|
||||||
|
UI_MAIN_PrintAGC(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (center_line == CENTER_LINE_NONE)
|
if (center_line == CENTER_LINE_NONE)
|
||||||
{ // we're free to use the middle line
|
{ // we're free to use the middle line
|
||||||
|
|
||||||
const bool rx = (gCurrentFunction == FUNCTION_RECEIVE ||
|
const bool rx = FUNCTION_IsRx();
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
|
||||||
gCurrentFunction == FUNCTION_INCOMING);
|
|
||||||
|
|
||||||
#ifdef ENABLE_AUDIO_BAR
|
#ifdef ENABLE_AUDIO_BAR
|
||||||
if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT) {
|
if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT) {
|
||||||
@@ -698,7 +721,7 @@ void UI_DisplayMain(void)
|
|||||||
|
|
||||||
center_line = CENTER_LINE_AM_FIX_DATA;
|
center_line = CENTER_LINE_AM_FIX_DATA;
|
||||||
AM_fix_print_data(gEeprom.RX_VFO, String);
|
AM_fix_print_data(gEeprom.RX_VFO, String);
|
||||||
UI_PrintStringSmall(String, 2, 0, 3);
|
UI_PrintStringSmallNormal(String, 2, 0, 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -706,7 +729,7 @@ void UI_DisplayMain(void)
|
|||||||
#ifdef ENABLE_RSSI_BAR
|
#ifdef ENABLE_RSSI_BAR
|
||||||
if (rx) {
|
if (rx) {
|
||||||
center_line = CENTER_LINE_RSSI;
|
center_line = CENTER_LINE_RSSI;
|
||||||
DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_VFO], false);
|
DisplayRSSIBar(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -727,9 +750,8 @@ void UI_DisplayMain(void)
|
|||||||
|
|
||||||
center_line = CENTER_LINE_DTMF_DEC;
|
center_line = CENTER_LINE_DTMF_DEC;
|
||||||
|
|
||||||
strcpy(String, "DTMF ");
|
sprintf(String, "DTMF %s", gDTMF_RX_live + idx);
|
||||||
strcat(String, gDTMF_RX_live + idx);
|
UI_PrintStringSmallNormal(String, 2, 0, 3);
|
||||||
UI_PrintStringSmall(String, 2, 0, 3);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (gSetting_live_DTMF_decoder && gDTMF_RX_index > 0)
|
if (gSetting_live_DTMF_decoder && gDTMF_RX_index > 0)
|
||||||
@@ -743,9 +765,8 @@ void UI_DisplayMain(void)
|
|||||||
|
|
||||||
center_line = CENTER_LINE_DTMF_DEC;
|
center_line = CENTER_LINE_DTMF_DEC;
|
||||||
|
|
||||||
strcpy(String, "DTMF ");
|
sprintf(String, "DTMF %s", gDTMF_RX_live + idx);
|
||||||
strcat(String, gDTMF_RX + idx);
|
UI_PrintStringSmallNormal(String, 2, 0, 3);
|
||||||
UI_PrintStringSmall(String, 2, 0, 3);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -764,7 +785,7 @@ void UI_DisplayMain(void)
|
|||||||
sprintf(String, "Charge %u.%02uV %u%%",
|
sprintf(String, "Charge %u.%02uV %u%%",
|
||||||
gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100,
|
gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100,
|
||||||
BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
||||||
UI_PrintStringSmall(String, 2, 0, 3);
|
UI_PrintStringSmallNormal(String, 2, 0, 3);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
13
ui/main.h
@@ -26,13 +26,24 @@ enum center_line_t {
|
|||||||
CENTER_LINE_DTMF_DEC,
|
CENTER_LINE_DTMF_DEC,
|
||||||
CENTER_LINE_CHARGE_DATA
|
CENTER_LINE_CHARGE_DATA
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Vfo_txtr_mode{
|
||||||
|
VFO_MODE_NONE = 0,
|
||||||
|
VFO_MODE_TX = 1,
|
||||||
|
VFO_MODE_RX = 2,
|
||||||
|
};
|
||||||
|
|
||||||
typedef enum center_line_t center_line_t;
|
typedef enum center_line_t center_line_t;
|
||||||
|
|
||||||
extern center_line_t center_line;
|
extern center_line_t center_line;
|
||||||
|
extern const int8_t dBmCorrTable[7];
|
||||||
|
|
||||||
void UI_DisplayAudioBar(void);
|
void UI_DisplayAudioBar(void);
|
||||||
void UI_UpdateRSSI(const int16_t rssi, const int vfo);
|
void UI_MAIN_TimeSlice500ms(void);
|
||||||
void UI_DisplayMain(void);
|
void UI_DisplayMain(void);
|
||||||
|
|
||||||
|
#ifdef ENABLE_AGC_SHOW_DATA
|
||||||
|
void UI_MAIN_PrintAGC(bool force);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
245
ui/menu.c
@@ -15,26 +15,27 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h> // abs()
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "../app/dtmf.h"
|
||||||
|
#include "../app/menu.h"
|
||||||
|
#include "../bitmaps.h"
|
||||||
|
#include "../board.h"
|
||||||
|
#include "../dcs.h"
|
||||||
|
#include "../driver/backlight.h"
|
||||||
|
#include "../driver/bk4819.h"
|
||||||
|
#include "../driver/eeprom.h"
|
||||||
|
#include "../driver/st7565.h"
|
||||||
|
#include "../external/printf/printf.h"
|
||||||
|
#include "../frequencies.h"
|
||||||
|
#include "../helper/battery.h"
|
||||||
|
#include "../misc.h"
|
||||||
|
#include "../settings.h"
|
||||||
|
#include "helper.h"
|
||||||
|
#include "inputbox.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
#include "app/dtmf.h"
|
|
||||||
#include "app/menu.h"
|
|
||||||
#include "bitmaps.h"
|
|
||||||
#include "board.h"
|
|
||||||
#include "dcs.h"
|
|
||||||
#include "driver/backlight.h"
|
|
||||||
#include "driver/bk4819.h"
|
|
||||||
#include "driver/eeprom.h" // EEPROM_ReadBuffer()
|
|
||||||
#include "driver/st7565.h"
|
|
||||||
#include "external/printf/printf.h"
|
|
||||||
#include "frequencies.h"
|
|
||||||
#include "helper/battery.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "settings.h"
|
|
||||||
#include "ui/helper.h"
|
|
||||||
#include "ui/inputbox.h"
|
|
||||||
#include "ui/menu.h"
|
|
||||||
#include "ui/ui.h"
|
|
||||||
|
|
||||||
const t_menu_item MenuList[] =
|
const t_menu_item MenuList[] =
|
||||||
{
|
{
|
||||||
@@ -65,7 +66,6 @@ const t_menu_item MenuList[] =
|
|||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
{"NOAA-S", VOICE_ID_INVALID, MENU_NOAA_S },
|
{"NOAA-S", VOICE_ID_INVALID, MENU_NOAA_S },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{"F1Shrt", VOICE_ID_INVALID, MENU_F1SHRT },
|
{"F1Shrt", VOICE_ID_INVALID, MENU_F1SHRT },
|
||||||
{"F1Long", VOICE_ID_INVALID, MENU_F1LONG },
|
{"F1Long", VOICE_ID_INVALID, MENU_F1LONG },
|
||||||
{"F2Shrt", VOICE_ID_INVALID, MENU_F2SHRT },
|
{"F2Shrt", VOICE_ID_INVALID, MENU_F2SHRT },
|
||||||
@@ -117,9 +117,6 @@ const t_menu_item MenuList[] =
|
|||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
{"AM Fix", VOICE_ID_INVALID, MENU_AM_FIX },
|
{"AM Fix", VOICE_ID_INVALID, MENU_AM_FIX },
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
{"AM FT1", VOICE_ID_INVALID, MENU_AM_FIX_TEST1 },
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
{"VOX", VOICE_ID_VOX, MENU_VOX },
|
{"VOX", VOICE_ID_VOX, MENU_VOX },
|
||||||
#endif
|
#endif
|
||||||
@@ -197,7 +194,7 @@ const char gSubMenu_TOT[][7] =
|
|||||||
"15 min"
|
"15 min"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* gSubMenu_RXMode[] =
|
const char* const gSubMenu_RXMode[] =
|
||||||
{
|
{
|
||||||
"MAIN\nONLY", // TX and RX on main only
|
"MAIN\nONLY", // TX and RX on main only
|
||||||
"DUAL RX\nRESPOND", // Watch both and respond
|
"DUAL RX\nRESPOND", // Watch both and respond
|
||||||
@@ -221,7 +218,7 @@ const char gSubMenu_SC_REV[][8] =
|
|||||||
"STOP"
|
"STOP"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* gSubMenu_MDF[] =
|
const char* const gSubMenu_MDF[] =
|
||||||
{
|
{
|
||||||
"FREQ",
|
"FREQ",
|
||||||
"CHANNEL\nNUMBER",
|
"CHANNEL\nNUMBER",
|
||||||
@@ -247,7 +244,7 @@ const char gSubMenu_D_RSP[][11] =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* gSubMenu_PTT_ID[] =
|
const char* const gSubMenu_PTT_ID[] =
|
||||||
{
|
{
|
||||||
"OFF",
|
"OFF",
|
||||||
"UP CODE",
|
"UP CODE",
|
||||||
@@ -277,7 +274,7 @@ const char gSubMenu_RESET[][4] =
|
|||||||
"ALL"
|
"ALL"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * gSubMenu_F_LOCK[] =
|
const char * const gSubMenu_F_LOCK[] =
|
||||||
{
|
{
|
||||||
"DEFAULT+\n137-174\n400-470",
|
"DEFAULT+\n137-174\n400-470",
|
||||||
"FCC HAM\n144-148\n420-450",
|
"FCC HAM\n144-148\n420-450",
|
||||||
@@ -309,16 +306,6 @@ const char gSubMenu_RX_TX[][6] =
|
|||||||
"TX/RX"
|
"TX/RX"
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
const char gSubMenu_AM_fix_test1[][8] =
|
|
||||||
{
|
|
||||||
"LNA-S 0",
|
|
||||||
"LNA-S 1",
|
|
||||||
"LNA-S 2",
|
|
||||||
"LNA-S 3"
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char gSubMenu_BAT_TXT[][8] =
|
const char gSubMenu_BAT_TXT[][8] =
|
||||||
{
|
{
|
||||||
"NONE",
|
"NONE",
|
||||||
@@ -347,10 +334,12 @@ const char gSubMenu_SCRAMBLER[][7] =
|
|||||||
"3500Hz"
|
"3500Hz"
|
||||||
};
|
};
|
||||||
|
|
||||||
const t_sidefunction SIDEFUNCTIONS[] =
|
const t_sidefunction gSubMenu_SIDEFUNCTIONS[] =
|
||||||
{
|
{
|
||||||
{"NONE", ACTION_OPT_NONE},
|
{"NONE", ACTION_OPT_NONE},
|
||||||
|
#ifdef ENABLE_FLASHLIGHT
|
||||||
{"FLASH\nLIGHT", ACTION_OPT_FLASHLIGHT},
|
{"FLASH\nLIGHT", ACTION_OPT_FLASHLIGHT},
|
||||||
|
#endif
|
||||||
{"POWER", ACTION_OPT_POWER},
|
{"POWER", ACTION_OPT_POWER},
|
||||||
{"MONITOR", ACTION_OPT_MONITOR},
|
{"MONITOR", ACTION_OPT_MONITOR},
|
||||||
{"SCAN", ACTION_OPT_SCAN},
|
{"SCAN", ACTION_OPT_SCAN},
|
||||||
@@ -373,16 +362,19 @@ const t_sidefunction SIDEFUNCTIONS[] =
|
|||||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||||
{"BLMIN\nTMP OFF", ACTION_OPT_BLMIN_TMP_OFF}, //BackLight Minimum Temporay OFF
|
{"BLMIN\nTMP OFF", ACTION_OPT_BLMIN_TMP_OFF}, //BackLight Minimum Temporay OFF
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_SPECTRUM
|
||||||
|
{"SPECTRUM", ACTION_OPT_SPECTRUM}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
const t_sidefunction* gSubMenu_SIDEFUNCTIONS = SIDEFUNCTIONS;
|
|
||||||
const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(SIDEFUNCTIONS);
|
const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(gSubMenu_SIDEFUNCTIONS);
|
||||||
|
|
||||||
bool gIsInSubMenu;
|
bool gIsInSubMenu;
|
||||||
uint8_t gMenuCursor;
|
uint8_t gMenuCursor;
|
||||||
int UI_MENU_GetCurrentMenuId() {
|
int UI_MENU_GetCurrentMenuId() {
|
||||||
if(gMenuCursor < ARRAY_SIZE(MenuList))
|
if(gMenuCursor < ARRAY_SIZE(MenuList))
|
||||||
return MenuList[gMenuCursor].menu_id;
|
return MenuList[gMenuCursor].menu_id;
|
||||||
else
|
|
||||||
return MenuList[ARRAY_SIZE(MenuList)-1].menu_id;
|
return MenuList[ARRAY_SIZE(MenuList)-1].menu_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,12 +405,10 @@ void UI_DisplayMenu(void)
|
|||||||
char Contact[16];
|
char Contact[16];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clear the screen buffer
|
UI_DisplayClear();
|
||||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
|
||||||
|
|
||||||
#if 0
|
#ifndef ENABLE_CUSTOM_MENU_LAYOUT
|
||||||
// original menu layout
|
// original menu layout
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
if (gMenuCursor > 0 || i > 0)
|
if (gMenuCursor > 0 || i > 0)
|
||||||
if ((gMenuListCount - 1) != gMenuCursor || i != 2)
|
if ((gMenuListCount - 1) != gMenuCursor || i != 2)
|
||||||
@@ -437,28 +427,26 @@ void UI_DisplayMenu(void)
|
|||||||
|
|
||||||
// draw the little sub-menu triangle marker
|
// draw the little sub-menu triangle marker
|
||||||
if (gIsInSubMenu)
|
if (gIsInSubMenu)
|
||||||
memmove(gFrameBuffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
|
memcpy(gFrameBuffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
|
||||||
|
|
||||||
// draw the menu index number/count
|
// draw the menu index number/count
|
||||||
sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount);
|
sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount);
|
||||||
UI_PrintStringSmall(String, 2, 0, 6);
|
|
||||||
|
UI_PrintStringSmallNormal(String, 2, 0, 6);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
{ // new menu layout .. experimental & unfinished
|
{ // new menu layout .. experimental & unfinished
|
||||||
|
|
||||||
const int menu_index = gMenuCursor; // current selected menu item
|
const int menu_index = gMenuCursor; // current selected menu item
|
||||||
i = 1;
|
i = 1;
|
||||||
|
|
||||||
if (!gIsInSubMenu)
|
if (!gIsInSubMenu) {
|
||||||
{
|
|
||||||
while (i < 2)
|
while (i < 2)
|
||||||
{ // leading menu items - small text
|
{ // leading menu items - small text
|
||||||
const int k = menu_index + i - 2;
|
const int k = menu_index + i - 2;
|
||||||
if (k < 0)
|
if (k < 0)
|
||||||
UI_PrintStringSmall(MenuList[gMenuListCount + k].name, 0, 0, i); // wrap-a-round
|
UI_PrintStringSmallNormal(MenuList[gMenuListCount + k].name, 0, 0, i); // wrap-a-round
|
||||||
else
|
else if (k >= 0 && k < (int)gMenuListCount)
|
||||||
if (k >= 0 && k < (int)gMenuListCount)
|
UI_PrintStringSmallNormal(MenuList[k].name, 0, 0, i);
|
||||||
UI_PrintStringSmall(MenuList[k].name, 0, 0, i);
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,24 +459,21 @@ void UI_DisplayMenu(void)
|
|||||||
{ // trailing menu item - small text
|
{ // trailing menu item - small text
|
||||||
const int k = menu_index + i - 2;
|
const int k = menu_index + i - 2;
|
||||||
if (k >= 0 && k < (int)gMenuListCount)
|
if (k >= 0 && k < (int)gMenuListCount)
|
||||||
UI_PrintStringSmall(MenuList[k].name, 0, 0, 1 + i);
|
UI_PrintStringSmallNormal(MenuList[k].name, 0, 0, 1 + i);
|
||||||
else
|
else if (k >= (int)gMenuListCount)
|
||||||
if (k >= (int)gMenuListCount)
|
UI_PrintStringSmallNormal(MenuList[gMenuListCount - k].name, 0, 0, 1 + i); // wrap-a-round
|
||||||
UI_PrintStringSmall(MenuList[gMenuListCount - k].name, 0, 0, 1 + i); // wrap-a-round
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the menu index number/count
|
// draw the menu index number/count
|
||||||
sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount);
|
sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount);
|
||||||
UI_PrintStringSmall(String, 2, 0, 6);
|
UI_PrintStringSmallNormal(String, 2, 0, 6);
|
||||||
}
|
}
|
||||||
else
|
else if (menu_index >= 0 && menu_index < (int)gMenuListCount)
|
||||||
if (menu_index >= 0 && menu_index < (int)gMenuListCount)
|
|
||||||
{ // current menu item
|
{ // current menu item
|
||||||
strcpy(String, MenuList[menu_index].name);
|
|
||||||
// strcat(String, ":");
|
// strcat(String, ":");
|
||||||
UI_PrintString(String, 0, 0, 0, 8);
|
UI_PrintString(MenuList[menu_index].name, 0, 0, 0, 8);
|
||||||
// UI_PrintStringSmall(String, 0, 0, 0);
|
// UI_PrintStringSmallNormal(String, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -499,6 +484,12 @@ void UI_DisplayMenu(void)
|
|||||||
|
|
||||||
bool already_printed = false;
|
bool already_printed = false;
|
||||||
|
|
||||||
|
/* Brightness is set to max in some entries of this menu. Return it to the configured brightness
|
||||||
|
level the "next" time we enter here.I.e., when we move from one menu to another.
|
||||||
|
It also has to be set back to max when pressing the Exit key. */
|
||||||
|
|
||||||
|
BACKLIGHT_TurnOn();
|
||||||
|
|
||||||
switch (UI_MENU_GetCurrentMenuId())
|
switch (UI_MENU_GetCurrentMenuId())
|
||||||
{
|
{
|
||||||
case MENU_SQL:
|
case MENU_SQL:
|
||||||
@@ -595,7 +586,8 @@ void UI_DisplayMenu(void)
|
|||||||
|
|
||||||
case MENU_ABR:
|
case MENU_ABR:
|
||||||
strcpy(String, gSubMenu_BACKLIGHT[gSubMenuSelection]);
|
strcpy(String, gSubMenu_BACKLIGHT[gSubMenuSelection]);
|
||||||
BACKLIGHT_SetBrightness(-1);
|
if(BACKLIGHT_GetBrightness() < 4)
|
||||||
|
BACKLIGHT_SetBrightness(4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MENU_ABR_MIN:
|
case MENU_ABR_MIN:
|
||||||
@@ -603,21 +595,14 @@ void UI_DisplayMenu(void)
|
|||||||
sprintf(String, "%d", gSubMenuSelection);
|
sprintf(String, "%d", gSubMenuSelection);
|
||||||
if(gIsInSubMenu)
|
if(gIsInSubMenu)
|
||||||
BACKLIGHT_SetBrightness(gSubMenuSelection);
|
BACKLIGHT_SetBrightness(gSubMenuSelection);
|
||||||
else
|
else if(BACKLIGHT_GetBrightness() < 4)
|
||||||
BACKLIGHT_SetBrightness(-1);
|
BACKLIGHT_SetBrightness(4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MENU_AM:
|
case MENU_AM:
|
||||||
strcpy(String, gModulationStr[gSubMenuSelection]);
|
strcpy(String, gModulationStr[gSubMenuSelection]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
case MENU_AM_FIX_TEST1:
|
|
||||||
strcpy(String, gSubMenu_AM_fix_test1[gSubMenuSelection]);
|
|
||||||
// gSetting_AM_fix = gSubMenuSelection;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case MENU_AUTOLK:
|
case MENU_AUTOLK:
|
||||||
strcpy(String, (gSubMenuSelection == 0) ? "OFF" : "AUTO");
|
strcpy(String, (gSubMenuSelection == 0) ? "OFF" : "AUTO");
|
||||||
break;
|
break;
|
||||||
@@ -662,11 +647,13 @@ void UI_DisplayMenu(void)
|
|||||||
|
|
||||||
if (valid && !gAskForConfirmation)
|
if (valid && !gAskForConfirmation)
|
||||||
{ // show the frequency so that the user knows the channels frequency
|
{ // show the frequency so that the user knows the channels frequency
|
||||||
const uint32_t frequency = BOARD_fetchChannelFrequency(gSubMenuSelection);
|
const uint32_t frequency = SETTINGS_FetchChannelFrequency(gSubMenuSelection);
|
||||||
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000);
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
|
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SETTINGS_FetchChannelName(String, gSubMenuSelection);
|
||||||
|
UI_PrintString(String[0] ? String : "--", menu_item_x1, menu_item_x2, 2, 8);
|
||||||
already_printed = true;
|
already_printed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -680,14 +667,13 @@ void UI_DisplayMenu(void)
|
|||||||
|
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
const uint32_t frequency = BOARD_fetchChannelFrequency(gSubMenuSelection);
|
const uint32_t frequency = SETTINGS_FetchChannelFrequency(gSubMenuSelection);
|
||||||
|
|
||||||
if (!gIsInSubMenu || edit_index < 0)
|
if (!gIsInSubMenu || edit_index < 0)
|
||||||
{ // show the channel name
|
{ // show the channel name
|
||||||
BOARD_fetchChannelName(String, gSubMenuSelection);
|
SETTINGS_FetchChannelName(String, gSubMenuSelection);
|
||||||
if (String[0] == 0)
|
char *pPrintStr = String[0] ? String : "--";
|
||||||
strcpy(String, "--");
|
UI_PrintString(pPrintStr, menu_item_x1, menu_item_x2, 2, 8);
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 2, 8);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // show the channel name being edited
|
{ // show the channel name being edited
|
||||||
@@ -699,10 +685,7 @@ void UI_DisplayMenu(void)
|
|||||||
if (!gAskForConfirmation)
|
if (!gAskForConfirmation)
|
||||||
{ // show the frequency so that the user knows the channels frequency
|
{ // show the frequency so that the user knows the channels frequency
|
||||||
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000);
|
||||||
if (!gIsInSubMenu || edit_index < 0)
|
UI_PrintString(String, menu_item_x1, menu_item_x2, 4 + (gIsInSubMenu && edit_index >= 0), 8);
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
|
|
||||||
else
|
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,11 +745,11 @@ void UI_DisplayMenu(void)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case MENU_UPCODE:
|
case MENU_UPCODE:
|
||||||
strcpy(String, gEeprom.DTMF_UP_CODE);
|
sprintf(String, "%.8s\n%.8s", gEeprom.DTMF_UP_CODE, gEeprom.DTMF_UP_CODE + 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MENU_DWCODE:
|
case MENU_DWCODE:
|
||||||
strcpy(String, gEeprom.DTMF_DOWN_CODE);
|
sprintf(String, "%.8s\n%.8s", gEeprom.DTMF_DOWN_CODE, gEeprom.DTMF_DOWN_CODE + 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
@@ -796,7 +779,7 @@ void UI_DisplayMenu(void)
|
|||||||
if (!gIsDtmfContactValid)
|
if (!gIsDtmfContactValid)
|
||||||
strcpy(String, "NULL");
|
strcpy(String, "NULL");
|
||||||
else
|
else
|
||||||
memmove(String, Contact, 8);
|
memcpy(String, Contact, 8);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -898,7 +881,7 @@ void UI_DisplayMenu(void)
|
|||||||
for (i = 0; i < len && lines > 0; lines--)
|
for (i = 0; i < len && lines > 0; lines--)
|
||||||
{
|
{
|
||||||
if (small)
|
if (small)
|
||||||
UI_PrintStringSmall(String + i, menu_item_x1, menu_item_x2, y);
|
UI_PrintStringSmallNormal(String + i, menu_item_x1, menu_item_x2, y);
|
||||||
else
|
else
|
||||||
UI_PrintString(String + i, menu_item_x1, menu_item_x2, y, 8);
|
UI_PrintString(String + i, menu_item_x1, menu_item_x2, y, 8);
|
||||||
|
|
||||||
@@ -918,79 +901,47 @@ void UI_DisplayMenu(void)
|
|||||||
if (UI_MENU_GetCurrentMenuId() == MENU_SLIST1 || UI_MENU_GetCurrentMenuId() == MENU_SLIST2)
|
if (UI_MENU_GetCurrentMenuId() == MENU_SLIST1 || UI_MENU_GetCurrentMenuId() == MENU_SLIST2)
|
||||||
{
|
{
|
||||||
i = (UI_MENU_GetCurrentMenuId() == MENU_SLIST1) ? 0 : 1;
|
i = (UI_MENU_GetCurrentMenuId() == MENU_SLIST1) ? 0 : 1;
|
||||||
|
char *pPrintStr = String;
|
||||||
|
|
||||||
// if (gSubMenuSelection == 0xFF)
|
if (gSubMenuSelection < 0) {
|
||||||
if (gSubMenuSelection < 0)
|
pPrintStr = "NULL";
|
||||||
strcpy(String, "NULL");
|
} else {
|
||||||
else
|
|
||||||
UI_GenerateChannelStringEx(String, true, gSubMenuSelection);
|
UI_GenerateChannelStringEx(String, true, gSubMenuSelection);
|
||||||
|
pPrintStr = String;
|
||||||
// if (gSubMenuSelection == 0xFF || !gEeprom.SCAN_LIST_ENABLED[i])
|
|
||||||
if (gSubMenuSelection < 0 || !gEeprom.SCAN_LIST_ENABLED[i])
|
|
||||||
{
|
|
||||||
// channel number
|
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8);
|
|
||||||
|
|
||||||
// channel name
|
|
||||||
BOARD_fetchChannelName(String, gSubMenuSelection);
|
|
||||||
if (String[0] == 0)
|
|
||||||
strcpy(String, "--");
|
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 2, 8);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// channel number
|
// channel number
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8);
|
UI_PrintString(pPrintStr, menu_item_x1, menu_item_x2, 0, 8);
|
||||||
|
|
||||||
// channel name
|
SETTINGS_FetchChannelName(String, gSubMenuSelection);
|
||||||
BOARD_fetchChannelName(String, gSubMenuSelection);
|
pPrintStr = String[0] ? String : "--";
|
||||||
if (String[0] == 0)
|
|
||||||
strcpy(String, "--");
|
|
||||||
UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 2);
|
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH1[i]))
|
// channel name and scan-list
|
||||||
{
|
if (gSubMenuSelection < 0 || !gEeprom.SCAN_LIST_ENABLED[i]) {
|
||||||
sprintf(String, "PRI1:%u", gEeprom.SCANLIST_PRIORITY_CH1[i] + 1);
|
UI_PrintString(pPrintStr, menu_item_x1, menu_item_x2, 2, 8);
|
||||||
|
} else {
|
||||||
|
UI_PrintStringSmallNormal(pPrintStr, menu_item_x1, menu_item_x2, 2);
|
||||||
|
|
||||||
|
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH1[i])) {
|
||||||
|
sprintf(String, "PRI%d:%u", 1, gEeprom.SCANLIST_PRIORITY_CH1[i] + 1);
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 3, 8);
|
UI_PrintString(String, menu_item_x1, menu_item_x2, 3, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH2[i]))
|
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH2[i])) {
|
||||||
{
|
sprintf(String, "PRI%d:%u", 2, gEeprom.SCANLIST_PRIORITY_CH2[i] + 1);
|
||||||
sprintf(String, "PRI2:%u", gEeprom.SCANLIST_PRIORITY_CH2[i] + 1);
|
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);
|
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_MEM_CH ||
|
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_DEL_CH ||
|
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_1_CALL)
|
|
||||||
{ // display the channel name
|
|
||||||
char s[11];
|
|
||||||
BOARD_fetchChannelName(s, gSubMenuSelection);
|
|
||||||
if (s[0] == 0)
|
|
||||||
strcpy(s, "--");
|
|
||||||
UI_PrintString(s, menu_item_x1, menu_item_x2, 2, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS) && gCssBackgroundScan)
|
if ((UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS) && gCssBackgroundScan)
|
||||||
UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8);
|
UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8);
|
||||||
|
|
||||||
|
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_UPCODE)
|
|
||||||
if (strlen(gEeprom.DTMF_UP_CODE) > 8)
|
|
||||||
UI_PrintString(gEeprom.DTMF_UP_CODE + 8, menu_item_x1, menu_item_x2, 4, 8);
|
|
||||||
|
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_DWCODE)
|
|
||||||
if (strlen(gEeprom.DTMF_DOWN_CODE) > 8)
|
|
||||||
UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, menu_item_x1, menu_item_x2, 4, 8);
|
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#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;
|
||||||
memmove(&gDTMF_ID, Contact + 8, 4);
|
memcpy(&gDTMF_ID, Contact + 8, 4);
|
||||||
sprintf(String, "ID:%s", Contact + 8);
|
sprintf(String, "ID:%4s", gDTMF_ID);
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
|
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1002,11 +953,9 @@ void UI_DisplayMenu(void)
|
|||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|| UI_MENU_GetCurrentMenuId() == MENU_D_LIST
|
|| UI_MENU_GetCurrentMenuId() == MENU_D_LIST
|
||||||
#endif
|
#endif
|
||||||
)
|
) {
|
||||||
|
|
||||||
{
|
|
||||||
sprintf(String, "%2d", gSubMenuSelection);
|
sprintf(String, "%2d", gSubMenuSelection);
|
||||||
UI_PrintStringSmall(String, 105, 0, 0);
|
UI_PrintStringSmallNormal(String, 105, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((UI_MENU_GetCurrentMenuId() == MENU_RESET ||
|
if ((UI_MENU_GetCurrentMenuId() == MENU_RESET ||
|
||||||
@@ -1014,8 +963,8 @@ void UI_DisplayMenu(void)
|
|||||||
UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME ||
|
UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME ||
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation)
|
UI_MENU_GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation)
|
||||||
{ // display confirmation
|
{ // display confirmation
|
||||||
strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!");
|
char *pPrintStr = (gAskForConfirmation == 1) ? "SURE?" : "WAIT!";
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);
|
UI_PrintString(pPrintStr, menu_item_x1, menu_item_x2, 5, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
|
|||||||
16
ui/menu.h
@@ -104,9 +104,6 @@ enum
|
|||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
MENU_AM_FIX,
|
MENU_AM_FIX,
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
MENU_AM_FIX_TEST1,
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
MENU_NOAA_S,
|
MENU_NOAA_S,
|
||||||
#endif
|
#endif
|
||||||
@@ -138,36 +135,33 @@ extern const char gSubMenu_W_N[2][7];
|
|||||||
extern const char gSubMenu_OFF_ON[2][4];
|
extern const char gSubMenu_OFF_ON[2][4];
|
||||||
extern const char gSubMenu_SAVE[5][4];
|
extern const char gSubMenu_SAVE[5][4];
|
||||||
extern const char gSubMenu_TOT[11][7];
|
extern const char gSubMenu_TOT[11][7];
|
||||||
extern const char* gSubMenu_RXMode[4];
|
extern const char* const gSubMenu_RXMode[4];
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
extern const char gSubMenu_VOICE[3][4];
|
extern const char gSubMenu_VOICE[3][4];
|
||||||
#endif
|
#endif
|
||||||
extern const char gSubMenu_SC_REV[3][8];
|
extern const char gSubMenu_SC_REV[3][8];
|
||||||
extern const char* gSubMenu_MDF[4];
|
extern const char* const 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
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
extern const char gSubMenu_D_RSP[4][11];
|
extern const char gSubMenu_D_RSP[4][11];
|
||||||
#endif
|
#endif
|
||||||
extern const char* gSubMenu_PTT_ID[5];
|
extern const char* const 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];
|
||||||
extern const char gSubMenu_RESET[2][4];
|
extern const char gSubMenu_RESET[2][4];
|
||||||
extern const char* gSubMenu_F_LOCK[F_LOCK_LEN];
|
extern const char* const gSubMenu_F_LOCK[F_LOCK_LEN];
|
||||||
extern const char gSubMenu_BACKLIGHT[8][7];
|
extern const char gSubMenu_BACKLIGHT[8][7];
|
||||||
extern const char gSubMenu_RX_TX[4][6];
|
extern const char gSubMenu_RX_TX[4][6];
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
|
||||||
extern const char gSubMenu_AM_fix_test1[4][8];
|
|
||||||
#endif
|
|
||||||
extern const char gSubMenu_BAT_TXT[3][8];
|
extern const char gSubMenu_BAT_TXT[3][8];
|
||||||
extern const char gSubMenu_BATTYP[2][9];
|
extern const char gSubMenu_BATTYP[2][9];
|
||||||
extern const char gSubMenu_SCRAMBLER[11][7];
|
extern const char gSubMenu_SCRAMBLER[11][7];
|
||||||
|
|
||||||
typedef struct {char* name; uint8_t id;} t_sidefunction;
|
typedef struct {char* name; uint8_t id;} t_sidefunction;
|
||||||
extern const uint8_t gSubMenu_SIDEFUNCTIONS_size;
|
extern const uint8_t gSubMenu_SIDEFUNCTIONS_size;
|
||||||
extern const t_sidefunction* gSubMenu_SIDEFUNCTIONS;
|
extern const t_sidefunction gSubMenu_SIDEFUNCTIONS[];
|
||||||
|
|
||||||
extern bool gIsInSubMenu;
|
extern bool gIsInSubMenu;
|
||||||
|
|
||||||
|
|||||||
64
ui/scanner.c
@@ -26,56 +26,58 @@
|
|||||||
|
|
||||||
void UI_DisplayScanner(void)
|
void UI_DisplayScanner(void)
|
||||||
{
|
{
|
||||||
char String[16];
|
char String[16] = {0};
|
||||||
|
char *pPrintStr = String;
|
||||||
bool bCentered;
|
bool bCentered;
|
||||||
uint8_t Start;
|
uint8_t Start;
|
||||||
|
|
||||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
UI_DisplayClear();
|
||||||
|
|
||||||
memset(String, 0, sizeof(String));
|
if (gScanSingleFrequency || (gScanCssState != SCAN_CSS_STATE_OFF && gScanCssState != SCAN_CSS_STATE_FAILED)) {
|
||||||
if (gScanSingleFrequency || (gScanCssState != SCAN_CSS_STATE_OFF && gScanCssState != SCAN_CSS_STATE_FAILED))
|
|
||||||
sprintf(String, "FREQ:%u.%05u", gScanFrequency / 100000, gScanFrequency % 100000);
|
sprintf(String, "FREQ:%u.%05u", gScanFrequency / 100000, gScanFrequency % 100000);
|
||||||
else
|
pPrintStr = String;
|
||||||
strcpy(String, "FREQ:**.*****");
|
} else {
|
||||||
UI_PrintString(String, 2, 0, 1, 8);
|
pPrintStr = "FREQ:**.*****";
|
||||||
|
}
|
||||||
|
|
||||||
memset(String, 0, sizeof(String));
|
UI_PrintString(pPrintStr, 2, 0, 1, 8);
|
||||||
if (gScanCssState < SCAN_CSS_STATE_FOUND || !gScanUseCssResult)
|
|
||||||
strcpy(String, "CTC:******");
|
if (gScanCssState < SCAN_CSS_STATE_FOUND || !gScanUseCssResult) {
|
||||||
else
|
pPrintStr = "CTC:******";
|
||||||
if (gScanCssResultType == CODE_TYPE_CONTINUOUS_TONE)
|
} else if (gScanCssResultType == CODE_TYPE_CONTINUOUS_TONE) {
|
||||||
sprintf(String, "CTC:%u.%uHz", CTCSS_Options[gScanCssResultCode] / 10, CTCSS_Options[gScanCssResultCode] % 10);
|
sprintf(String, "CTC:%u.%uHz", CTCSS_Options[gScanCssResultCode] / 10, CTCSS_Options[gScanCssResultCode] % 10);
|
||||||
else
|
pPrintStr = String;
|
||||||
|
} else {
|
||||||
sprintf(String, "DCS:D%03oN", DCS_Options[gScanCssResultCode]);
|
sprintf(String, "DCS:D%03oN", DCS_Options[gScanCssResultCode]);
|
||||||
UI_PrintString(String, 2, 0, 3, 8);
|
pPrintStr = String;
|
||||||
|
}
|
||||||
|
|
||||||
|
UI_PrintString(pPrintStr, 2, 0, 3, 8);
|
||||||
memset(String, 0, sizeof(String));
|
memset(String, 0, sizeof(String));
|
||||||
if (gScannerSaveState == SCAN_SAVE_CHANNEL)
|
if (gScannerSaveState == SCAN_SAVE_CHANNEL) {
|
||||||
{
|
pPrintStr = "SAVE?";
|
||||||
strcpy(String, "SAVE?");
|
|
||||||
|
|
||||||
Start = 0;
|
Start = 0;
|
||||||
bCentered = 1;
|
bCentered = 1;
|
||||||
}
|
} else {
|
||||||
else
|
Start = 2;
|
||||||
{
|
bCentered = 0;
|
||||||
|
|
||||||
if (gScannerSaveState == SCAN_SAVE_CHAN_SEL) {
|
if (gScannerSaveState == SCAN_SAVE_CHAN_SEL) {
|
||||||
strcpy(String, "SAVE:");
|
strcpy(String, "SAVE:");
|
||||||
UI_GenerateChannelStringEx(String + 5, gShowChPrefix, gScanChannel);
|
UI_GenerateChannelStringEx(String + 5, gShowChPrefix, gScanChannel);
|
||||||
}
|
pPrintStr = String;
|
||||||
else if (gScanCssState < SCAN_CSS_STATE_FOUND) {
|
} else if (gScanCssState < SCAN_CSS_STATE_FOUND) {
|
||||||
strcpy(String, "SCAN");
|
strcpy(String, "SCAN");
|
||||||
memset(String + 4, '.', (gScanProgressIndicator & 7) + 1);
|
memset(String + 4, '.', (gScanProgressIndicator & 7) + 1);
|
||||||
|
pPrintStr = String;
|
||||||
|
} else if (gScanCssState == SCAN_CSS_STATE_FOUND) {
|
||||||
|
pPrintStr = "SCAN CMP.";
|
||||||
|
} else {
|
||||||
|
pPrintStr = "SCAN FAIL.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gScanCssState == SCAN_CSS_STATE_FOUND)
|
|
||||||
strcpy(String, "SCAN CMP.");
|
|
||||||
else
|
|
||||||
strcpy(String, "SCAN FAIL.");
|
|
||||||
|
|
||||||
Start = 2;
|
UI_PrintString(pPrintStr, Start, bCentered ? 127 : 0, 5, 8);
|
||||||
bCentered = 0;
|
|
||||||
}
|
|
||||||
UI_PrintString(String, Start, bCentered ? 127 : 0, 5, 8);
|
|
||||||
|
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
}
|
}
|
||||||
|
|||||||
137
ui/status.c
@@ -36,172 +36,139 @@
|
|||||||
|
|
||||||
void UI_DisplayStatus()
|
void UI_DisplayStatus()
|
||||||
{
|
{
|
||||||
uint8_t *line = gStatusLine;
|
|
||||||
unsigned int x = 0;
|
|
||||||
unsigned int x1 = 0;
|
|
||||||
|
|
||||||
gUpdateStatus = false;
|
gUpdateStatus = false;
|
||||||
|
|
||||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||||
|
|
||||||
|
uint8_t *line = gStatusLine;
|
||||||
|
unsigned int x = 0;
|
||||||
// **************
|
// **************
|
||||||
|
|
||||||
// POWER-SAVE indicator
|
// POWER-SAVE indicator
|
||||||
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
if (gCurrentFunction == FUNCTION_TRANSMIT) {
|
||||||
{
|
memcpy(line + x, BITMAP_TX, sizeof(BITMAP_TX));
|
||||||
memmove(line + x, BITMAP_TX, sizeof(BITMAP_TX));
|
|
||||||
x1 = x + sizeof(BITMAP_TX);
|
|
||||||
}
|
}
|
||||||
else
|
else if (FUNCTION_IsRx()) {
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
memcpy(line + x, BITMAP_RX, sizeof(BITMAP_RX));
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
|
||||||
gCurrentFunction == FUNCTION_INCOMING)
|
|
||||||
{
|
|
||||||
memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX));
|
|
||||||
x1 = x + sizeof(BITMAP_RX);
|
|
||||||
}
|
}
|
||||||
else
|
else if (gCurrentFunction == FUNCTION_POWER_SAVE) {
|
||||||
if (gCurrentFunction == FUNCTION_POWER_SAVE)
|
memcpy(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE));
|
||||||
{
|
|
||||||
memmove(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE));
|
|
||||||
x1 = x + sizeof(BITMAP_POWERSAVE);
|
|
||||||
}
|
}
|
||||||
x += sizeof(BITMAP_POWERSAVE);
|
x += 8;
|
||||||
|
unsigned int x1 = x;
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
// NOASS SCAN indicator
|
if (gIsNoaaMode) { // NOASS SCAN indicator
|
||||||
if (gIsNoaaMode)
|
memcpy(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA));
|
||||||
{
|
|
||||||
memmove(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA));
|
|
||||||
x1 = x + sizeof(BITMAP_NOAA);
|
x1 = x + sizeof(BITMAP_NOAA);
|
||||||
}
|
}
|
||||||
x += sizeof(BITMAP_NOAA);
|
x += sizeof(BITMAP_NOAA);
|
||||||
#else
|
|
||||||
// hmmm, what to put in it's place
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#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
|
#endif
|
||||||
{
|
#ifdef ENABLE_FMRADIO
|
||||||
// SCAN indicator
|
if (gFmRadioMode) { // FM indicator
|
||||||
if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning())
|
memcpy(line + x, BITMAP_FM, sizeof(BITMAP_FM));
|
||||||
{
|
x1 = x + sizeof(BITMAP_FM);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{ // SCAN indicator
|
||||||
|
if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning()) {
|
||||||
char * s = "";
|
char * s = "";
|
||||||
if (IS_MR_CHANNEL(gNextMrChannel) && !SCANNER_IsScanning())
|
if (IS_MR_CHANNEL(gNextMrChannel) && !SCANNER_IsScanning()) { // channel mode
|
||||||
{ // channel mode
|
|
||||||
switch(gEeprom.SCAN_LIST_DEFAULT) {
|
switch(gEeprom.SCAN_LIST_DEFAULT) {
|
||||||
case 0: s = "1"; break;
|
case 0: s = "1"; break;
|
||||||
case 1: s = "2"; break;
|
case 1: s = "2"; break;
|
||||||
case 2: s = "*"; break;
|
case 2: s = "*"; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else { // frequency mode
|
||||||
{ // frequency mode
|
|
||||||
s = "S";
|
s = "S";
|
||||||
}
|
}
|
||||||
UI_PrintStringSmallBuffer(s, line + x);
|
UI_PrintStringSmallBufferNormal(s, line + x + 1);
|
||||||
x1 = x + 7;
|
x1 = x + 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x += 7; // font character width
|
x += 10; // font character width
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
// VOICE indicator
|
// VOICE indicator
|
||||||
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF)
|
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF){
|
||||||
{
|
memcpy(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
|
||||||
memmove(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
|
|
||||||
x1 = x + sizeof(BITMAP_VoicePrompt);
|
x1 = x + sizeof(BITMAP_VoicePrompt);
|
||||||
}
|
}
|
||||||
x += sizeof(BITMAP_VoicePrompt) + 1;
|
x += sizeof(BITMAP_VoicePrompt);
|
||||||
#else
|
|
||||||
// hmmm, what to put in it's place
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
x++;
|
|
||||||
if(!SCANNER_IsScanning()) {
|
if(!SCANNER_IsScanning()) {
|
||||||
uint8_t dw = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2;
|
uint8_t dw = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2;
|
||||||
if(dw == 1 || dw == 3) { // DWR - dual watch + respond
|
if(dw == 1 || dw == 3) { // DWR - dual watch + respond
|
||||||
if(gDualWatchActive)
|
if(gDualWatchActive)
|
||||||
memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1) - (dw==1?0:5));
|
memcpy(line + x + (dw==1?0:2), BITMAP_TDR1, sizeof(BITMAP_TDR1) - (dw==1?0:5));
|
||||||
else
|
else
|
||||||
memmove(line + x + 3, BITMAP_TDR2, sizeof(BITMAP_TDR2));
|
memcpy(line + x + 3, BITMAP_TDR2, sizeof(BITMAP_TDR2));
|
||||||
}
|
}
|
||||||
else if(dw == 2) { // XB - crossband
|
else if(dw == 2) { // XB - crossband
|
||||||
memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB));
|
memcpy(line + x + 2, BITMAP_XB, sizeof(BITMAP_XB));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x += sizeof(BITMAP_TDR1) + 2;
|
x += sizeof(BITMAP_TDR1) + 1;
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
// VOX indicator
|
// VOX indicator
|
||||||
if (gEeprom.VOX_SWITCH)
|
if (gEeprom.VOX_SWITCH) {
|
||||||
{
|
memcpy(line + x, BITMAP_VOX, sizeof(BITMAP_VOX));
|
||||||
memmove(line + x, BITMAP_VOX, sizeof(BITMAP_VOX));
|
x1 = x + sizeof(BITMAP_VOX) + 1;
|
||||||
x1 = x + sizeof(BITMAP_VOX);
|
|
||||||
}
|
}
|
||||||
x += sizeof(BITMAP_VOX) + 2;
|
x += sizeof(BITMAP_VOX) + 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
x = MAX(x, 61u);
|
x = MAX(x1, 61u);
|
||||||
x1 = x;
|
|
||||||
|
|
||||||
// KEY-LOCK indicator
|
// KEY-LOCK indicator
|
||||||
if (gEeprom.KEY_LOCK)
|
if (gEeprom.KEY_LOCK) {
|
||||||
{
|
memcpy(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
|
||||||
memmove(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
|
|
||||||
x += sizeof(BITMAP_KeyLock);
|
x += sizeof(BITMAP_KeyLock);
|
||||||
x1 = x;
|
x1 = x;
|
||||||
}
|
}
|
||||||
else
|
else if (gWasFKeyPressed) {
|
||||||
if (gWasFKeyPressed)
|
memcpy(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key));
|
||||||
{
|
|
||||||
memmove(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key));
|
|
||||||
x += sizeof(BITMAP_F_Key);
|
x += sizeof(BITMAP_F_Key);
|
||||||
x1 = x;
|
x1 = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // battery voltage or percentage
|
{ // battery voltage or percentage
|
||||||
char s[8];
|
char s[8] = "";
|
||||||
unsigned int space_needed;
|
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 0;
|
||||||
|
|
||||||
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 3;
|
|
||||||
|
|
||||||
if (gChargingWithTypeC)
|
if (gChargingWithTypeC)
|
||||||
x2 -= sizeof(BITMAP_USB_C); // the radio is on charge
|
x2 -= sizeof(BITMAP_USB_C); // the radio is on charge
|
||||||
|
|
||||||
switch (gSetting_battery_text)
|
switch (gSetting_battery_text) {
|
||||||
{
|
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // voltage
|
case 1: { // voltage
|
||||||
{
|
|
||||||
const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V
|
const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V
|
||||||
sprintf(s, "%u.%02uV", voltage / 100, voltage % 100);
|
sprintf(s, "%u.%02uV", voltage / 100, voltage % 100);
|
||||||
space_needed = (7 * strlen(s));
|
|
||||||
if (x2 >= (x1 + space_needed))
|
|
||||||
{
|
|
||||||
UI_PrintStringSmallBuffer(s, line + x2 - space_needed);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2: // percentage
|
case 2: // percentage
|
||||||
{
|
|
||||||
sprintf(s, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
sprintf(s, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
||||||
space_needed = (7 * strlen(s));
|
|
||||||
if (x2 >= (x1 + space_needed))
|
|
||||||
UI_PrintStringSmallBuffer(s, line + x2 - space_needed);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
unsigned int space_needed = (7 * strlen(s));
|
||||||
|
if (x2 >= (x1 + space_needed))
|
||||||
|
UI_PrintStringSmallBufferNormal(s, line + x2 - space_needed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move to right side of the screen
|
// move to right side of the screen
|
||||||
@@ -209,7 +176,7 @@ void UI_DisplayStatus()
|
|||||||
|
|
||||||
// USB-C charge indicator
|
// USB-C charge indicator
|
||||||
if (gChargingWithTypeC)
|
if (gChargingWithTypeC)
|
||||||
memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
memcpy(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
||||||
x += sizeof(BITMAP_USB_C);
|
x += sizeof(BITMAP_USB_C);
|
||||||
|
|
||||||
// BATTERY LEVEL indicator
|
// BATTERY LEVEL indicator
|
||||||
|
|||||||
39
ui/ui.c
@@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "app/chFrScanner.h"
|
#include "app/chFrScanner.h"
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
#include "ui/menu.h"
|
#include "ui/menu.h"
|
||||||
#include "ui/scanner.h"
|
#include "ui/scanner.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
#include "../misc.h"
|
||||||
|
|
||||||
GUI_DisplayType_t gScreenToDisplay;
|
GUI_DisplayType_t gScreenToDisplay;
|
||||||
GUI_DisplayType_t gRequestDisplayScreen = DISPLAY_INVALID;
|
GUI_DisplayType_t gRequestDisplayScreen = DISPLAY_INVALID;
|
||||||
@@ -42,36 +44,27 @@ uint8_t gAskForConfirmation;
|
|||||||
bool gAskToSave;
|
bool gAskToSave;
|
||||||
bool gAskToDelete;
|
bool gAskToDelete;
|
||||||
|
|
||||||
void GUI_DisplayScreen(void)
|
|
||||||
{
|
void (*UI_DisplayFunctions[])(void) = {
|
||||||
switch (gScreenToDisplay)
|
[DISPLAY_MAIN] = &UI_DisplayMain,
|
||||||
{
|
[DISPLAY_MENU] = &UI_DisplayMenu,
|
||||||
case DISPLAY_MAIN:
|
[DISPLAY_SCANNER] = &UI_DisplayScanner,
|
||||||
UI_DisplayMain();
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
case DISPLAY_FM:
|
[DISPLAY_FM] = &UI_DisplayFM,
|
||||||
UI_DisplayFM();
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case DISPLAY_MENU:
|
|
||||||
UI_DisplayMenu();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DISPLAY_SCANNER:
|
|
||||||
UI_DisplayScanner();
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
case DISPLAY_AIRCOPY:
|
[DISPLAY_AIRCOPY] = &UI_DisplayAircopy,
|
||||||
UI_DisplayAircopy();
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
default:
|
static_assert(ARRAY_SIZE(UI_DisplayFunctions) == DISPLAY_N_ELEM);
|
||||||
break;
|
|
||||||
|
void GUI_DisplayScreen(void)
|
||||||
|
{
|
||||||
|
if (gScreenToDisplay != DISPLAY_INVALID) {
|
||||||
|
UI_DisplayFunctions[gScreenToDisplay]();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
ui/ui.h
@@ -23,10 +23,18 @@
|
|||||||
enum GUI_DisplayType_t
|
enum GUI_DisplayType_t
|
||||||
{
|
{
|
||||||
DISPLAY_MAIN = 0,
|
DISPLAY_MAIN = 0,
|
||||||
DISPLAY_FM,
|
|
||||||
DISPLAY_MENU,
|
DISPLAY_MENU,
|
||||||
DISPLAY_SCANNER,
|
DISPLAY_SCANNER,
|
||||||
|
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
DISPLAY_FM,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_AIRCOPY
|
||||||
DISPLAY_AIRCOPY,
|
DISPLAY_AIRCOPY,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DISPLAY_N_ELEM,
|
||||||
DISPLAY_INVALID = 0xFFu
|
DISPLAY_INVALID = 0xFFu
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,4 +51,3 @@ void GUI_DisplayScreen(void);
|
|||||||
void GUI_SelectNextDisplay(GUI_DisplayType_t Display);
|
void GUI_SelectNextDisplay(GUI_DisplayType_t Display);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
19
ui/welcome.c
@@ -30,7 +30,7 @@
|
|||||||
void UI_DisplayReleaseKeys(void)
|
void UI_DisplayReleaseKeys(void)
|
||||||
{
|
{
|
||||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
UI_DisplayClear();
|
||||||
|
|
||||||
UI_PrintString("RELEASE", 0, 127, 1, 10);
|
UI_PrintString("RELEASE", 0, 127, 1, 10);
|
||||||
UI_PrintString("ALL KEYS", 0, 127, 3, 10);
|
UI_PrintString("ALL KEYS", 0, 127, 3, 10);
|
||||||
@@ -45,19 +45,11 @@ void UI_DisplayWelcome(void)
|
|||||||
char WelcomeString1[16];
|
char WelcomeString1[16];
|
||||||
|
|
||||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
UI_DisplayClear();
|
||||||
|
|
||||||
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_NONE)
|
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_NONE || gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_FULL_SCREEN) {
|
||||||
{
|
|
||||||
ST7565_FillScreen(0xFF);
|
ST7565_FillScreen(0xFF);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_FULL_SCREEN)
|
|
||||||
{
|
|
||||||
ST7565_FillScreen(0xFF);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memset(WelcomeString0, 0, sizeof(WelcomeString0));
|
memset(WelcomeString0, 0, sizeof(WelcomeString0));
|
||||||
memset(WelcomeString1, 0, sizeof(WelcomeString1));
|
memset(WelcomeString1, 0, sizeof(WelcomeString1));
|
||||||
|
|
||||||
@@ -77,10 +69,9 @@ 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, 128, 6);
|
UI_PrintStringSmallNormal(Version, 0, 128, 6);
|
||||||
|
|
||||||
ST7565_BlitStatusLine(); // blank status line
|
ST7565_BlitStatusLine(); // blank status line
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||