mirror of
https://github.com/silenty4ng/uv-k5-firmware-chinese-lts
synced 2025-01-15 14:54:40 +00:00
am-fix
This commit is contained in:
parent
8a0d2e38e8
commit
8981ea1af7
19 changed files with 910 additions and 1055 deletions
60
Makefile
60
Makefile
|
@ -34,7 +34,6 @@ ENABLE_SHOW_CHARGE_LEVEL := 0
|
|||
ENABLE_REVERSE_BAT_SYMBOL := 0
|
||||
ENABLE_NO_CODE_SCAN_TIMEOUT := 1
|
||||
ENABLE_AM_FIX := 1
|
||||
ENABLE_AM_FIX_SHOW_DATA := 0
|
||||
ENABLE_SQUELCH_MORE_SENSITIVE := 1
|
||||
ENABLE_FASTER_CHANNEL_SCAN := 1
|
||||
ENABLE_RSSI_BAR := 1
|
||||
|
@ -48,7 +47,9 @@ ENABLE_SCAN_RANGES := 1
|
|||
ENABLE_MDC1200 := 1
|
||||
ENABLE_MDC1200_SHOW_OP_ARG := 0
|
||||
ENABLE_MDC1200_SIDE_BEEP := 0
|
||||
|
||||
# ---- DEBUGGING ----
|
||||
ENABLE_AM_FIX_SHOW_DATA := 0
|
||||
ENABLE_AGC_SHOW_DATA := 0
|
||||
|
||||
#############################################################
|
||||
|
||||
|
@ -76,9 +77,7 @@ ifeq ($(ENABLE_OVERLAY),1)
|
|||
OBJS += sram-overlay.o
|
||||
endif
|
||||
OBJS += external/printf/printf.o
|
||||
ifeq ($(ENABLE_MDC1200),1)
|
||||
OBJS += app/mdc1200.o
|
||||
endif
|
||||
|
||||
# Drivers
|
||||
OBJS += driver/adc.o
|
||||
ifeq ($(ENABLE_UART),1)
|
||||
|
@ -157,6 +156,9 @@ OBJS += ui/inputbox.o
|
|||
ifeq ($(ENABLE_PWRON_PASSWORD),1)
|
||||
OBJS += ui/lock.o
|
||||
endif
|
||||
ifeq ($(ENABLE_MDC1200),1)
|
||||
OBJS += app/mdc1200.o
|
||||
endif
|
||||
OBJS += ui/main.o
|
||||
OBJS += ui/menu.o
|
||||
OBJS += ui/scanner.o
|
||||
|
@ -187,17 +189,15 @@ else # unix
|
|||
endif
|
||||
|
||||
AS = arm-none-eabi-gcc
|
||||
|
||||
CC =
|
||||
LD = arm-none-eabi-gcc
|
||||
|
||||
ifeq ($(ENABLE_CLANG),0)
|
||||
CC += arm-none-eabi-gcc
|
||||
CC = arm-none-eabi-gcc
|
||||
# Use GCC's linker to avoid undefined symbol errors
|
||||
# LD += arm-none-eabi-gcc
|
||||
else
|
||||
# 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
|
||||
# LD = ld.lld
|
||||
endif
|
||||
|
@ -224,30 +224,23 @@ endif
|
|||
|
||||
CFLAGS =
|
||||
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=gnu99 -MMD
|
||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
|
||||
else
|
||||
# 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
|
||||
|
||||
ifeq ($(ENABLE_LTO),1)
|
||||
CFLAGS += -flto=2
|
||||
CFLAGS += -flto=auto
|
||||
else
|
||||
# We get most of the space savings if LTO creates problems
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
ifeq ($(ENABLE_MDC1200),1)
|
||||
CFLAGS += -DENABLE_MDC1200
|
||||
endif
|
||||
ifeq ($(ENABLE_MDC1200_SHOW_OP_ARG),1)
|
||||
CFLAGS += -DENABLE_MDC1200_SHOW_OP_ARG
|
||||
endif
|
||||
ifeq ($(ENABLE_MDC1200_SIDE_BEEP),1)
|
||||
CFLAGS += -DENABLE_MDC1200_SIDE_BEEP
|
||||
endif
|
||||
|
||||
# May cause unhelpful build failures
|
||||
#CFLAGS += -Wpadded
|
||||
|
||||
|
@ -372,23 +365,24 @@ endif
|
|||
ifeq ($(ENABLE_DTMF_CALLING),1)
|
||||
CFLAGS += -DENABLE_DTMF_CALLING
|
||||
endif
|
||||
|
||||
LDFLAGS =
|
||||
ifeq ($(ENABLE_CLANG),0)
|
||||
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
|
||||
ifeq ($(ENABLE_AGC_SHOW_DATA),1)
|
||||
CFLAGS += -DENABLE_AGC_SHOW_DATA
|
||||
endif
|
||||
ifeq ($(ENABLE_MDC1200),1)
|
||||
CFLAGS += -DENABLE_MDC1200
|
||||
endif
|
||||
ifeq ($(ENABLE_MDC1200_SHOW_OP_ARG),1)
|
||||
CFLAGS += -DENABLE_MDC1200_SHOW_OP_ARG
|
||||
endif
|
||||
ifeq ($(ENABLE_MDC1200_SIDE_BEEP),1)
|
||||
CFLAGS += -DENABLE_MDC1200_SIDE_BEEP
|
||||
endif
|
||||
LDFLAGS =
|
||||
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld -Wl,--gc-sections
|
||||
|
||||
# Use newlib-nano instead of newlib
|
||||
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)
|
||||
ASFLAGS += -g
|
||||
CFLAGS += -g
|
||||
|
|
524
am_fix.c
524
am_fix.c
|
@ -32,316 +32,252 @@
|
|||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct
|
||||
{
|
||||
uint16_t reg_val;
|
||||
int8_t gain_dB;
|
||||
} __attribute__((packed)) t_gain_table;
|
||||
} __attribute__((packed)) t_gain_table;
|
||||
|
||||
// REG_10 AGC gain table
|
||||
//
|
||||
// <15:10> ???
|
||||
//
|
||||
// <9:8> = LNA Gain Short
|
||||
// 3 = 0dB < original value
|
||||
// 2 = -24dB // was -11
|
||||
// 1 = -30dB // was -16
|
||||
// 0 = -33dB // was -19
|
||||
//
|
||||
// <7:5> = LNA Gain
|
||||
// 7 = 0dB
|
||||
// 6 = -2dB
|
||||
// 5 = -4dB < original value
|
||||
// 4 = -6dB
|
||||
// 3 = -9dB
|
||||
// 2 = -14dB
|
||||
// 1 = -19dB
|
||||
// 0 = -24dB
|
||||
//
|
||||
// <4:3> = MIXER Gain
|
||||
// 3 = 0dB < original value
|
||||
// 2 = -3dB
|
||||
// 1 = -6dB
|
||||
// 0 = -8dB
|
||||
//
|
||||
// <2:0> = PGA Gain
|
||||
// 7 = 0dB
|
||||
// 6 = -3dB < original value
|
||||
// 5 = -6dB
|
||||
// 4 = -9dB
|
||||
// 3 = -15dB
|
||||
// 2 = -21dB
|
||||
// 1 = -27dB
|
||||
// 0 = -33dB
|
||||
// REG_10 AGC gain table
|
||||
//
|
||||
// <15:10> ???
|
||||
//
|
||||
// <9:8> = LNA Gain Short
|
||||
// 3 = 0dB < original value
|
||||
// 2 = -19dB // was -11
|
||||
// 1 = -24dB // was -16
|
||||
// 0 = -28dB // was -19
|
||||
//
|
||||
// <7:5> = LNA Gain
|
||||
// 7 = 0dB
|
||||
// 6 = -2dB
|
||||
// 5 = -4dB < original value
|
||||
// 4 = -6dB
|
||||
// 3 = -9dB
|
||||
// 2 = -14dB
|
||||
// 1 = -19dB
|
||||
// 0 = -24dB
|
||||
//
|
||||
// <4:3> = MIXER Gain
|
||||
// 3 = 0dB < original value
|
||||
// 2 = -3dB
|
||||
// 1 = -6dB
|
||||
// 0 = -8dB
|
||||
//
|
||||
// <2:0> = PGA Gain
|
||||
// 7 = 0dB
|
||||
// 6 = -3dB < original value
|
||||
// 5 = -6dB
|
||||
// 4 = -9dB
|
||||
// 3 = -15dB
|
||||
// 2 = -21dB
|
||||
// 1 = -27dB
|
||||
// 0 = -33dB
|
||||
|
||||
// front end register dB values
|
||||
//
|
||||
// these values need to be accurate for the code to properly/reliably switch
|
||||
// between table entries when adjusting the front end registers.
|
||||
//
|
||||
// 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 !!!
|
||||
//
|
||||
//
|
||||
// front end register dB values
|
||||
//
|
||||
// these values need to be accurate for the code to properly/reliably switch
|
||||
// between table entries when adjusting the front end registers.
|
||||
//
|
||||
// these 4 tables need a measuring/calibration update
|
||||
//
|
||||
//// 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 mixer_dB[] = { ( -8), ( -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
|
||||
//
|
||||
static const t_gain_table gain_table[] =
|
||||
{
|
||||
{0x035E, -17}, // 0 .. 3 2 3 6 .. 0dB -14dB 0dB -3dB .. -17dB original
|
||||
// lookup table is hugely easier than writing code to do the same
|
||||
//
|
||||
static const t_gain_table gain_table[] =
|
||||
{
|
||||
{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
|
||||
{0x0100,-89}, // 3 .. 1 0 0 0 .. -24dB -24dB -8dB -33dB .. -89dB
|
||||
{0x0020,-88}, // 4 .. 0 1 0 0 .. -28dB -19dB -8dB -33dB .. -88dB
|
||||
{0x0108,-87}, // 5 .. 1 0 1 0 .. -24dB -24dB -6dB -33dB .. -87dB
|
||||
{0x0028,-86}, // 6 .. 0 1 1 0 .. -28dB -19dB -6dB -33dB .. -86dB
|
||||
{0x0018,-85}, // 7 .. 0 0 3 0 .. -28dB -24dB 0dB -33dB .. -85dB
|
||||
{0x0200,-84}, // 8 .. 2 0 0 0 .. -19dB -24dB -8dB -33dB .. -84dB
|
||||
{0x0101,-83}, // 9 .. 1 0 0 1 .. -24dB -24dB -8dB -27dB .. -83dB
|
||||
{0x0208,-82}, // 10 .. 2 0 1 0 .. -19dB -24dB -6dB -33dB .. -82dB
|
||||
{0x0118,-81}, // 11 .. 1 0 3 0 .. -24dB -24dB 0dB -33dB .. -81dB
|
||||
{0x0038,-80}, // 12 .. 0 1 3 0 .. -28dB -19dB 0dB -33dB .. -80dB
|
||||
{0x0220,-79}, // 13 .. 2 1 0 0 .. -19dB -19dB -8dB -33dB .. -79dB
|
||||
{0x0201,-78}, // 14 .. 2 0 0 1 .. -19dB -24dB -8dB -27dB .. -78dB
|
||||
{0x0228,-77}, // 15 .. 2 1 1 0 .. -19dB -19dB -6dB -33dB .. -77dB
|
||||
{0x0218,-76}, // 16 .. 2 0 3 0 .. -19dB -24dB 0dB -33dB .. -76dB
|
||||
{0x0119,-75}, // 17 .. 1 0 3 1 .. -24dB -24dB 0dB -27dB .. -75dB
|
||||
{0x0240,-74}, // 18 .. 2 2 0 0 .. -19dB -14dB -8dB -33dB .. -74dB
|
||||
{0x0221,-73}, // 19 .. 2 1 0 1 .. -19dB -19dB -8dB -27dB .. -73dB
|
||||
{0x0248,-72}, // 20 .. 2 2 1 0 .. -19dB -14dB -6dB -33dB .. -72dB
|
||||
{0x0238,-71}, // 21 .. 2 1 3 0 .. -19dB -19dB 0dB -33dB .. -71dB
|
||||
{0x0219,-70}, // 22 .. 2 0 3 1 .. -19dB -24dB 0dB -27dB .. -70dB
|
||||
{0x0260,-69}, // 23 .. 2 3 0 0 .. -19dB -9dB -8dB -33dB .. -69dB
|
||||
{0x0241,-68}, // 24 .. 2 2 0 1 .. -19dB -14dB -8dB -27dB .. -68dB
|
||||
{0x0268,-67}, // 25 .. 2 3 1 0 .. -19dB -9dB -6dB -33dB .. -67dB
|
||||
{0x0280,-66}, // 26 .. 2 4 0 0 .. -19dB -6dB -8dB -33dB .. -66dB
|
||||
{0x0300,-65}, // 27 .. 3 0 0 0 .. 0dB -24dB -8dB -33dB .. -65dB
|
||||
{0x02A0,-64}, // 28 .. 2 5 0 0 .. -19dB -4dB -8dB -33dB .. -64dB
|
||||
{0x0308,-63}, // 29 .. 3 0 1 0 .. 0dB -24dB -6dB -33dB .. -63dB
|
||||
{0x02C0,-62}, // 30 .. 2 6 0 0 .. -19dB -2dB -8dB -33dB .. -62dB
|
||||
{0x0290,-61}, // 31 .. 2 4 2 0 .. -19dB -6dB -3dB -33dB .. -61dB
|
||||
{0x0320,-60}, // 32 .. 3 1 0 0 .. 0dB -19dB -8dB -33dB .. -60dB
|
||||
{0x0301,-59}, // 33 .. 3 0 0 1 .. 0dB -24dB -8dB -27dB .. -59dB
|
||||
{0x0328,-58}, // 34 .. 3 1 1 0 .. 0dB -19dB -6dB -33dB .. -58dB
|
||||
{0x0318,-57}, // 35 .. 3 0 3 0 .. 0dB -24dB 0dB -33dB .. -57dB
|
||||
{0x02C1,-56}, // 36 .. 2 6 0 1 .. -19dB -2dB -8dB -27dB .. -56dB
|
||||
{0x0340,-55}, // 37 .. 3 2 0 0 .. 0dB -14dB -8dB -33dB .. -55dB
|
||||
{0x0321,-54}, // 38 .. 3 1 0 1 .. 0dB -19dB -8dB -27dB .. -54dB
|
||||
{0x0348,-53}, // 39 .. 3 2 1 0 .. 0dB -14dB -6dB -33dB .. -53dB
|
||||
{0x0338,-52}, // 40 .. 3 1 3 0 .. 0dB -19dB 0dB -33dB .. -52dB
|
||||
{0x0319,-51}, // 41 .. 3 0 3 1 .. 0dB -24dB 0dB -27dB .. -51dB
|
||||
{0x0360,-50}, // 42 .. 3 3 0 0 .. 0dB -9dB -8dB -33dB .. -50dB
|
||||
{0x0341,-49}, // 43 .. 3 2 0 1 .. 0dB -14dB -8dB -27dB .. -49dB
|
||||
{0x0368,-48}, // 44 .. 3 3 1 0 .. 0dB -9dB -6dB -33dB .. -48dB
|
||||
{0x0380,-47}, // 45 .. 3 4 0 0 .. 0dB -6dB -8dB -33dB .. -47dB
|
||||
{0x0339,-46}, // 46 .. 3 1 3 1 .. 0dB -19dB 0dB -27dB .. -46dB
|
||||
{0x03A0,-45}, // 47 .. 3 5 0 0 .. 0dB -4dB -8dB -33dB .. -45dB
|
||||
{0x0361,-44}, // 48 .. 3 3 0 1 .. 0dB -9dB -8dB -27dB .. -44dB
|
||||
{0x03C0,-43}, // 49 .. 3 6 0 0 .. 0dB -2dB -8dB -33dB .. -43dB
|
||||
{0x0390,-42}, // 50 .. 3 4 2 0 .. 0dB -6dB -3dB -33dB .. -42dB
|
||||
{0x03E0,-41}, // 51 .. 3 7 0 0 .. 0dB 0dB -8dB -33dB .. -41dB
|
||||
{0x03B0,-40}, // 52 .. 3 5 2 0 .. 0dB -4dB -3dB -33dB .. -40dB
|
||||
{0x03E8,-39}, // 53 .. 3 7 1 0 .. 0dB 0dB -6dB -33dB .. -39dB
|
||||
{0x03D0,-38}, // 54 .. 3 6 2 0 .. 0dB -2dB -3dB -33dB .. -38dB
|
||||
{0x03C1,-37}, // 55 .. 3 6 0 1 .. 0dB -2dB -8dB -27dB .. -37dB
|
||||
{0x03F0,-36}, // 56 .. 3 7 2 0 .. 0dB 0dB -3dB -33dB .. -36dB
|
||||
{0x03E1,-35}, // 57 .. 3 7 0 1 .. 0dB 0dB -8dB -27dB .. -35dB
|
||||
{0x03B1,-34}, // 58 .. 3 5 2 1 .. 0dB -4dB -3dB -27dB .. -34dB
|
||||
{0x03F8,-33}, // 59 .. 3 7 3 0 .. 0dB 0dB 0dB -33dB .. -33dB
|
||||
{0x03D1,-32}, // 60 .. 3 6 2 1 .. 0dB -2dB -3dB -27dB .. -32dB
|
||||
{0x03C2,-31}, // 61 .. 3 6 0 2 .. 0dB -2dB -8dB -21dB .. -31dB
|
||||
{0x03F1,-30}, // 62 .. 3 7 2 1 .. 0dB 0dB -3dB -27dB .. -30dB
|
||||
{0x03E2,-29}, // 63 .. 3 7 0 2 .. 0dB 0dB -8dB -21dB .. -29dB
|
||||
{0x03B2,-28}, // 64 .. 3 5 2 2 .. 0dB -4dB -3dB -21dB .. -28dB
|
||||
{0x03F9,-27}, // 65 .. 3 7 3 1 .. 0dB 0dB 0dB -27dB .. -27dB
|
||||
{0x03D2,-26}, // 66 .. 3 6 2 2 .. 0dB -2dB -3dB -21dB .. -26dB
|
||||
{0x03C3,-25}, // 67 .. 3 6 0 3 .. 0dB -2dB -8dB -15dB .. -25dB
|
||||
{0x03F2,-24}, // 68 .. 3 7 2 2 .. 0dB 0dB -3dB -21dB .. -24dB
|
||||
{0x03E3,-23}, // 69 .. 3 7 0 3 .. 0dB 0dB -8dB -15dB .. -23dB
|
||||
{0x03B3,-22}, // 70 .. 3 5 2 3 .. 0dB -4dB -3dB -15dB .. -22dB
|
||||
{0x03FA,-21}, // 71 .. 3 7 3 2 .. 0dB 0dB 0dB -21dB .. -21dB
|
||||
{0x03D3,-20}, // 72 .. 3 6 2 3 .. 0dB -2dB -3dB -15dB .. -20dB
|
||||
{0x03C4,-19}, // 73 .. 3 6 0 4 .. 0dB -2dB -8dB -9dB .. -19dB
|
||||
{0x03F3,-18}, // 74 .. 3 7 2 3 .. 0dB 0dB -3dB -15dB .. -18dB
|
||||
{0x03E4,-17}, // 75 .. 3 7 0 4 .. 0dB 0dB -8dB -9dB .. -17dB
|
||||
{0x03C5,-16}, // 76 .. 3 6 0 5 .. 0dB -2dB -8dB -6dB .. -16dB
|
||||
{0x03FB,-15}, // 77 .. 3 7 3 3 .. 0dB 0dB 0dB -15dB .. -15dB
|
||||
{0x03E5,-14}, // 78 .. 3 7 0 5 .. 0dB 0dB -8dB -6dB .. -14dB
|
||||
{0x03C6,-13}, // 79 .. 3 6 0 6 .. 0dB -2dB -8dB -3dB .. -13dB
|
||||
{0x03F4,-12}, // 80 .. 3 7 2 4 .. 0dB 0dB -3dB -9dB .. -12dB
|
||||
{0x03E6,-11}, // 81 .. 3 7 0 6 .. 0dB 0dB -8dB -3dB .. -11dB
|
||||
{0x03C7,-10}, // 82 .. 3 6 0 7 .. 0dB -2dB -8dB 0dB .. -10dB
|
||||
{0x03FC, -9}, // 83 .. 3 7 3 4 .. 0dB 0dB 0dB -9dB .. -9dB
|
||||
{0x03E7, -8}, // 84 .. 3 7 0 7 .. 0dB 0dB -8dB 0dB .. -8dB
|
||||
{0x03BE, -7}, // 85 .. 3 5 3 6 .. 0dB -4dB 0dB -3dB .. -7dB original
|
||||
{0x03FD, -6}, // 86 .. 3 7 3 5 .. 0dB 0dB 0dB -6dB .. -6dB
|
||||
{0x03DE, -5}, // 87 .. 3 6 3 6 .. 0dB -2dB 0dB -3dB .. -5dB
|
||||
{0x03BF, -4}, // 88 .. 3 5 3 7 .. 0dB -4dB 0dB 0dB .. -4dB
|
||||
{0x03FE, -3}, // 89 .. 3 7 3 6 .. 0dB 0dB 0dB -3dB .. -3dB
|
||||
{0x03DF, -2}, // 90 .. 3 6 3 7 .. 0dB -2dB 0dB 0dB .. -2dB
|
||||
{0x03FF, 0}, // 91 .. 3 7 3 7 .. 0dB 0dB 0dB 0dB .. 0dB
|
||||
};
|
||||
|
||||
// test table that lets me manually set the lna-short register
|
||||
// to measure it's actual dB change using an RF signal generator
|
||||
static const unsigned int original_index = 90;
|
||||
|
||||
{0x005E, -50}, // 1 .. 0 2 3 6 .. -33dB -14dB 0dB -3dB .. -50dB
|
||||
{0x015E, -47}, // 2 .. 1 2 3 6 .. -30dB -14dB 0dB -3dB .. -47dB
|
||||
{0x025E, -41}, // 3 .. 2 2 3 6 .. -24dB -14dB 0dB -3dB .. -41dB
|
||||
{0x035E, -17} // 4 .. 3 2 3 6 .. 0dB -14dB 0dB -3dB .. -17dB original
|
||||
};
|
||||
|
||||
static const unsigned int original_index = 1;
|
||||
|
||||
#else
|
||||
|
||||
{0x0000, -98}, // 1 .. 0 0 0 0 .. -33dB -24dB -8dB -33dB .. -98dB
|
||||
{0x0008, -96}, // 2 .. 0 0 1 0 .. -33dB -24dB -6dB -33dB .. -96dB
|
||||
{0x0100, -95}, // 3 .. 1 0 0 0 .. -30dB -24dB -8dB -33dB .. -95dB
|
||||
{0x0020, -93}, // 4 .. 0 1 0 0 .. -33dB -19dB -8dB -33dB .. -93dB
|
||||
{0x0001, -92}, // 5 .. 0 0 0 1 .. -33dB -24dB -8dB -27dB .. -92dB
|
||||
{0x0028, -91}, // 6 .. 0 1 1 0 .. -33dB -19dB -6dB -33dB .. -91dB
|
||||
{0x0009, -90}, // 7 .. 0 0 1 1 .. -33dB -24dB -6dB -27dB .. -90dB
|
||||
{0x0101, -89}, // 8 .. 1 0 0 1 .. -30dB -24dB -8dB -27dB .. -89dB
|
||||
{0x0030, -88}, // 9 .. 0 1 2 0 .. -33dB -19dB -3dB -33dB .. -88dB
|
||||
{0x0118, -87}, // 10 .. 1 0 3 0 .. -30dB -24dB 0dB -33dB .. -87dB
|
||||
{0x0002, -86}, // 11 .. 0 0 0 2 .. -33dB -24dB -8dB -21dB .. -86dB
|
||||
{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
|
||||
};
|
||||
|
||||
static const unsigned int original_index = 90;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
// display update rate
|
||||
static const unsigned int display_update_rate = 250 / 10; // max 250ms display update rate
|
||||
unsigned int counter = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
// 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
|
||||
unsigned int gain_table_index[2] = {original_index, original_index};
|
||||
|
||||
// used simply to detect a changed gain setting
|
||||
unsigned int gain_table_index_prev[2] = {0, 0};
|
||||
|
||||
// holds the previous RSSI level .. we do an average of old + new RSSI reading
|
||||
int16_t prev_rssi[2] = {0, 0};
|
||||
// used simply to detect a changed gain setting
|
||||
unsigned int gain_table_index_prev[2] = {0, 0};
|
||||
|
||||
// to help reduce gain hunting, peak hold count down tick
|
||||
unsigned int hold_counter[2] = {0, 0};
|
||||
// holds the previous RSSI level .. we do an average of old + new RSSI reading
|
||||
int16_t prev_rssi[2] = {0, 0};
|
||||
|
||||
// used to correct the RSSI readings after our RF gain adjustments
|
||||
int16_t rssi_gain_diff[2] = {0, 0};
|
||||
// to help reduce gain hunting, peak hold count down tick
|
||||
unsigned int hold_counter[2] = {0, 0};
|
||||
|
||||
// used to limit the max RF gain
|
||||
unsigned int max_index = ARRAY_SIZE(gain_table) - 1;
|
||||
// used to correct the RSSI readings after our RF gain adjustments
|
||||
int16_t rssi_gain_diff[2] = {0, 0};
|
||||
|
||||
#ifndef ENABLE_AM_FIX_TEST1
|
||||
// -89dBm, any higher and the AM demodulator starts to saturate/clip/distort
|
||||
const int16_t desired_rssi = (-89 + 160) * 2;
|
||||
#endif
|
||||
// used to limit the max RF gain
|
||||
const unsigned max_index = ARRAY_SIZE(gain_table) - 1;
|
||||
|
||||
void AM_fix_init(void)
|
||||
{ // called at boot-up
|
||||
// -89dBm, any higher and the AM demodulator starts to saturate/clip/distort
|
||||
const int16_t desired_rssi = (-89 + 160) * 2;
|
||||
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
gain_table_index[i] = 1 + gSetting_AM_fix_test1;
|
||||
#else
|
||||
void AM_fix_init(void)
|
||||
{ // called at boot-up
|
||||
for (int i = 0; i < 2; i++) {
|
||||
gain_table_index[i] = original_index; // re-start with original QS setting
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
{ // 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
|
||||
void AM_fix_reset(const unsigned vfo)
|
||||
{ // reset the AM fixer upper
|
||||
if (vfo > 1)
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
counter = 0;
|
||||
#endif
|
||||
|
||||
prev_rssi[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;
|
||||
}
|
||||
}
|
||||
|
||||
// adjust the RX gain to try and prevent the AM demodulator from
|
||||
// saturating/overloading/clipping (distorted AM audio)
|
||||
//
|
||||
// we're actually doing the BK4819's job for it here, but as the chip
|
||||
// won't/don't do it for itself, we're left to bodging it ourself by
|
||||
// playing with the RF front end gain setting
|
||||
//
|
||||
void AM_fix_10ms(const int vfo)
|
||||
{
|
||||
int16_t diff_dB;
|
||||
int16_t rssi;
|
||||
// adjust the RX gain to try and prevent the AM demodulator from
|
||||
// saturating/overloading/clipping (distorted AM audio)
|
||||
//
|
||||
// we're actually doing the BK4819's job for it here, but as the chip
|
||||
// won't/don't do it for itself, we're left to bodging it ourself by
|
||||
// playing with the RF front end gain setting
|
||||
//
|
||||
void AM_fix_10ms(const unsigned vfo, bool force)
|
||||
{
|
||||
if(vfo > 1)
|
||||
return;
|
||||
|
||||
switch (gCurrentFunction)
|
||||
if(!force) switch (gCurrentFunction)
|
||||
{
|
||||
case FUNCTION_TRANSMIT:
|
||||
case FUNCTION_BAND_SCOPE:
|
||||
case FUNCTION_POWER_SAVE:
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
case FUNCTION_FOREGROUND:
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
counter = display_update_rate; // queue up a display update as soon as we switch to RX mode
|
||||
#endif
|
||||
#endif
|
||||
AM_fix_reset(vfo);
|
||||
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
|
||||
if (counter > 0)
|
||||
{
|
||||
if (++counter >= display_update_rate)
|
||||
{ // trigger a display update
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
if (counter > 0) {
|
||||
if (++counter >= display_update_rate) { // trigger a display update
|
||||
counter = 0;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int16_t rssi;
|
||||
{ // sample the current RSSI level
|
||||
// average it with the previous rssi (a bit of noise/spike immunity)
|
||||
const int16_t new_rssi = BK4819_GetRSSI();
|
||||
|
@ -349,39 +285,20 @@
|
|||
prev_rssi[vfo] = new_rssi;
|
||||
}
|
||||
|
||||
// save the corrected RSSI level
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
{
|
||||
const int16_t new_rssi = rssi - rssi_gain_diff[vfo];
|
||||
if (gCurrentRSSI[vfo] != new_rssi)
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
{
|
||||
int16_t new_rssi = rssi - rssi_gain_diff[vfo];
|
||||
if (gCurrentRSSI[vfo] != new_rssi) { // rssi changed
|
||||
gCurrentRSSI[vfo] = new_rssi;
|
||||
|
||||
if (counter == 0)
|
||||
{ // trigger a display update
|
||||
if (counter == 0) {
|
||||
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
|
||||
|
||||
// update the gain hold counter
|
||||
|
@ -389,15 +306,12 @@
|
|||
hold_counter[vfo]--;
|
||||
|
||||
// dB difference between actual and desired RSSI level
|
||||
diff_dB = (rssi - desired_rssi) / 2;
|
||||
|
||||
if (diff_dB > 0)
|
||||
{ // decrease gain
|
||||
int16_t diff_dB = (rssi - desired_rssi) / 2;
|
||||
|
||||
if (diff_dB > 0) { // decrease gain
|
||||
unsigned int index = gain_table_index[vfo]; // current position we're at
|
||||
|
||||
if (diff_dB >= 10)
|
||||
{ // jump immediately to a new gain setting
|
||||
if (diff_dB >= 10) { // jump immediately to a new gain setting
|
||||
// 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)
|
||||
|
@ -406,15 +320,9 @@
|
|||
while (index > 1)
|
||||
if (gain_table[--index].gain_dB <= desired_gain_dB)
|
||||
break;
|
||||
|
||||
//index = (gain_table_index[vfo] + index) / 2; // easy does it
|
||||
}
|
||||
else
|
||||
{ // 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)
|
||||
index--; // slow step-by-step gain reduction
|
||||
}
|
||||
|
@ -437,15 +345,8 @@
|
|||
gain_table_index[vfo] = (index <= max_index) ? index : max_index; // limit the gain index
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
const unsigned int index = gain_table_index[vfo];
|
||||
|
||||
// remember the new table index
|
||||
|
@ -462,28 +363,29 @@
|
|||
// save the corrected RSSI level
|
||||
gCurrentRSSI[vfo] = rssi - rssi_gain_diff[vfo];
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
if (counter == 0)
|
||||
{
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
if (counter == 0) {
|
||||
counter = 1;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
|
||||
void AM_fix_print_data(const int vfo, char *s)
|
||||
{
|
||||
if (s != NULL && vfo >= 0 && vfo < (int)ARRAY_SIZE(gain_table_index))
|
||||
{
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
void AM_fix_print_data(const unsigned vfo, char *s) {
|
||||
if (s != NULL && vfo < ARRAY_SIZE(gain_table_index)) {
|
||||
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]);
|
||||
counter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
int16_t AM_fix_get_rssi_gain_diff(const unsigned vfo)
|
||||
{
|
||||
if(vfo > 1)
|
||||
return 0;
|
||||
return rssi_gain_diff[vfo];
|
||||
}
|
||||
|
||||
#endif
|
10
am_fix.h
10
am_fix.h
|
@ -21,14 +21,12 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
extern int16_t rssi_gain_diff[2];
|
||||
|
||||
void AM_fix_init(void);
|
||||
void AM_fix_reset(const int vfo);
|
||||
void AM_fix_10ms(const int vfo);
|
||||
void AM_fix_init(void);
|
||||
void AM_fix_10ms(const unsigned vfo, bool force);
|
||||
#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
|
||||
int16_t AM_fix_get_rssi_gain_diff(const unsigned vfo);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ void ACTION_Monitor(void)
|
|||
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
|
||||
#endif
|
||||
RADIO_SetupRegisters(true);
|
||||
APP_StartListening(FUNCTION_MONITOR, false);
|
||||
APP_StartListening(FUNCTION_MONITOR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
55
app/app.c
55
app/app.c
|
@ -74,7 +74,7 @@ static void UpdateRSSI(const int vfo)
|
|||
#ifdef ENABLE_AM_FIX
|
||||
// add RF gain adjust compensation
|
||||
if (gEeprom.VfoInfo[vfo].Modulation == MODULATION_AM && gSetting_AM_fix)
|
||||
rssi -= rssi_gain_diff[vfo];
|
||||
rssi -= AM_fix_get_rssi_gain_diff(vfo);
|
||||
#endif
|
||||
|
||||
if (gCurrentRSSI[vfo] == rssi)
|
||||
|
@ -172,7 +172,7 @@ static void CheckForIncoming(void)
|
|||
|
||||
static void HandleIncoming(void)
|
||||
{
|
||||
bool bFlag;
|
||||
|
||||
|
||||
if (!g_SquelchLost) { // squelch is closed
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
|
@ -186,8 +186,7 @@ static void HandleIncoming(void)
|
|||
return;
|
||||
}
|
||||
|
||||
bFlag = (gScanStateDir == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF);
|
||||
|
||||
bool bFlag = (gScanStateDir == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF);
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gNOAACountdown_10ms > 0) {
|
||||
gNOAACountdown_10ms = 0;
|
||||
|
@ -200,8 +199,9 @@ static void HandleIncoming(void)
|
|||
gFoundCTCSS = false;
|
||||
}
|
||||
|
||||
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL)) {
|
||||
gFoundCDCSS = false;
|
||||
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE
|
||||
&& (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL))
|
||||
{ gFoundCDCSS = false;
|
||||
}
|
||||
else if (!bFlag)
|
||||
return;
|
||||
|
@ -231,7 +231,7 @@ static void HandleIncoming(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, false);
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
|
||||
}
|
||||
|
||||
static void HandleReceive(void)
|
||||
|
@ -445,11 +445,9 @@ static void HandleFunction(void)
|
|||
}
|
||||
}
|
||||
|
||||
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
|
||||
{
|
||||
(void)reset_am_fix;
|
||||
const unsigned int chan = gEeprom.RX_VFO;
|
||||
// const unsigned int chan = gRxVfo->CHANNEL_SAVE;
|
||||
void APP_StartListening(FUNCTION_Type_t function){
|
||||
const unsigned int vfo = gEeprom.RX_VFO;
|
||||
// const unsigned int chan = gRxVfo->CHANNEL_SAVE;
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
if (gSetting_KILLED)
|
||||
|
@ -462,8 +460,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
|
|||
#endif
|
||||
|
||||
// clear the other vfo's rssi level (to hide the antenna symbol)
|
||||
gVFO_RSSI_bar_level[(chan + 1) & 1u] = 0;
|
||||
|
||||
gVFO_RSSI_bar_level[!vfo] = 0;
|
||||
AUDIO_AudioPathOn();
|
||||
gEnableSpeaker = true;
|
||||
|
||||
|
@ -477,8 +474,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
|
|||
gRxVfo->CHANNEL_SAVE = gNoaaChannel + NOAA_CHANNEL_FIRST;
|
||||
gRxVfo->pRX->Frequency = NoaaFrequencyTable[gNoaaChannel];
|
||||
gRxVfo->pTX->Frequency = NoaaFrequencyTable[gNoaaChannel];
|
||||
gEeprom.ScreenChannel[chan] = gRxVfo->CHANNEL_SAVE;
|
||||
|
||||
gEeprom.ScreenChannel[vfo] = gRxVfo->CHANNEL_SAVE;
|
||||
gNOAA_Countdown_10ms = 500; // 5 sec
|
||||
gScheduleNOAA = false;
|
||||
}
|
||||
|
@ -500,38 +496,25 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
|
|||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if (gRxVfo->Modulation == MODULATION_AM && gSetting_AM_fix) { // AM RX mode
|
||||
if (reset_am_fix)
|
||||
AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency
|
||||
AM_fix_10ms(chan);
|
||||
}
|
||||
#endif
|
||||
|
||||
// AF gain - original QS values
|
||||
// if (gRxVfo->Modulation != MODULATION_FM){
|
||||
// BK4819_WriteRegister(BK4819_REG_48, 0xB3A8);
|
||||
// }
|
||||
// else
|
||||
{
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_48,
|
||||
(11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference
|
||||
( 0u << 10) | // AF Rx Gain-1
|
||||
(gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2
|
||||
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (gVoiceWriteIndex == 0) // AM/FM RX mode will be set when the voice has finished
|
||||
#endif
|
||||
RADIO_SetModulation(gRxVfo->Modulation); // no need, set it now
|
||||
|
||||
FUNCTION_Select(Function);
|
||||
|
||||
FUNCTION_Select(function);
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (Function == FUNCTION_MONITOR || gFmRadioMode)
|
||||
if (function == FUNCTION_MONITOR || gFmRadioMode)
|
||||
#else
|
||||
if (Function == FUNCTION_MONITOR)
|
||||
if (function == FUNCTION_MONITOR)
|
||||
#endif
|
||||
{ // squelch is disabled
|
||||
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||
|
@ -1180,7 +1163,7 @@ void APP_TimeSlice10ms(void)
|
|||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if (gRxVfo->Modulation == MODULATION_AM && gSetting_AM_fix)
|
||||
AM_fix_10ms(gEeprom.RX_VFO);
|
||||
AM_fix_10ms(gEeprom.RX_VFO, false);
|
||||
#endif
|
||||
|
||||
if (UART_IsCommandAvailable())
|
||||
|
@ -1581,7 +1564,7 @@ void APP_TimeSlice500ms(void)
|
|||
|
||||
BATTERY_TimeSlice500ms();
|
||||
SCANNER_TimeSlice500ms();
|
||||
|
||||
UI_MAIN_TimeSlice500ms();
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "radio.h"
|
||||
|
||||
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_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction);
|
||||
void APP_Update(void);
|
||||
|
|
|
@ -71,14 +71,14 @@ void CHFRSCANNER_ContinueScanning(void)
|
|||
if (IS_FREQ_CHANNEL(gNextMrChannel))
|
||||
{
|
||||
if (gCurrentFunction == FUNCTION_INCOMING)
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
|
||||
else
|
||||
NextFreqChannel(); // switch to next frequency
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gCurrentCodeType == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING)
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
|
||||
else
|
||||
NextMemChannel(); // switch to next channel
|
||||
}
|
||||
|
|
112
app/main.c
112
app/main.c
|
@ -46,24 +46,19 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
void toggle_chan_scanlist(void) { // toggle the selected channels scanlist setting
|
||||
if ( SCANNER_IsScanning())
|
||||
if (SCANNER_IsScanning())
|
||||
return;
|
||||
if(!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
|
||||
if (!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (gTxVfo->SCANLIST1_PARTICIPATION) {
|
||||
if (gTxVfo->SCANLIST2_PARTICIPATION)
|
||||
gTxVfo->SCANLIST1_PARTICIPATION = 0;
|
||||
else
|
||||
gTxVfo->SCANLIST2_PARTICIPATION = 1;
|
||||
|
||||
if (gTxVfo->SCANLIST1_PARTICIPATION ^ gTxVfo->SCANLIST2_PARTICIPATION) {
|
||||
gTxVfo->SCANLIST2_PARTICIPATION = gTxVfo->SCANLIST1_PARTICIPATION;
|
||||
} else {
|
||||
if (gTxVfo->SCANLIST2_PARTICIPATION)
|
||||
gTxVfo->SCANLIST2_PARTICIPATION = 0;
|
||||
else
|
||||
gTxVfo->SCANLIST1_PARTICIPATION = 1;
|
||||
gTxVfo->SCANLIST1_PARTICIPATION = !gTxVfo->SCANLIST1_PARTICIPATION;
|
||||
}
|
||||
|
||||
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true);
|
||||
|
@ -73,7 +68,6 @@ void toggle_chan_scanlist(void) { // toggle the selected channels scanlist se
|
|||
}
|
||||
|
||||
static void processFKeyFunction(const KEY_Code_t Key, const bool beep) {
|
||||
uint8_t Band;
|
||||
uint8_t Vfo = gEeprom.TX_VFO;
|
||||
|
||||
if (gScreenToDisplay == DISPLAY_MENU) {
|
||||
|
@ -81,8 +75,6 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) {
|
|||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
// if (beep)
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
switch (Key) {
|
||||
|
@ -106,9 +98,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) {
|
|||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
#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 (gCurrentFunction != FUNCTION_INCOMING ||
|
||||
|
@ -117,52 +111,46 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) {
|
|||
{ // scan is running (not paused)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
const uint8_t vfo = gEeprom.TX_VFO;
|
||||
|
||||
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
|
||||
{ // copy channel to VFO, then swap to the VFO
|
||||
|
||||
const unsigned int channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;
|
||||
|
||||
gEeprom.ScreenChannel[vfo] = channel;
|
||||
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel;
|
||||
gEeprom.ScreenChannel[vfo] = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;
|
||||
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = gEeprom.ScreenChannel[vfo];
|
||||
|
||||
RADIO_SelectVfos();
|
||||
RADIO_ApplyOffset(gRxVfo);
|
||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
//SETTINGS_SaveChannel(channel, gEeprom.RX_VFO, gRxVfo, 1);
|
||||
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (gTxVfo->Band == 6 && gTxVfo->pRX->Frequency < 100000000) {
|
||||
gTxVfo->pRX->Frequency = 100000000;
|
||||
#ifdef ENABLE_WIDE_RX
|
||||
if(gTxVfo->Band == BAND7_470MHz && gTxVfo->pRX->Frequency < _1GHz_in_KHz) {
|
||||
gTxVfo->pRX->Frequency = _1GHz_in_KHz;
|
||||
return;
|
||||
} else {
|
||||
Band = gTxVfo->Band + 1;
|
||||
// if (gSetting_350EN || Band != BAND5_350MHz) {
|
||||
if (Band > BAND7_470MHz)
|
||||
Band = BAND1_50MHz;
|
||||
// } else
|
||||
// Band = BAND6_400MHz;
|
||||
|
||||
gTxVfo->Band = Band;
|
||||
|
||||
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
|
||||
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
|
||||
}
|
||||
#endif
|
||||
|
||||
gTxVfo->Band += 1;
|
||||
|
||||
if (gTxVfo->Band == BAND5_350MHz && gSetting_F_LOCK != F_LOCK_NONE) {
|
||||
// skip if not enabled
|
||||
gTxVfo->Band += 1;
|
||||
} else if (gTxVfo->Band >= BAND_LAST_ELEMENT) {
|
||||
// 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;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
|
@ -315,8 +303,6 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
|
|||
|
||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering channel number
|
||||
|
||||
uint16_t Channel;
|
||||
|
||||
if (gInputBoxIndex != 3) {
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
|
@ -327,7 +313,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
|
|||
|
||||
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)) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
|
@ -351,18 +337,16 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
|
|||
// #endif
|
||||
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering a frequency
|
||||
|
||||
uint32_t Frequency;
|
||||
bool isGigaF = gTxVfo->pRX->Frequency >= 100000000;
|
||||
if (gInputBoxIndex < 6 + isGigaF) {
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
|
||||
bool isGigaF = gTxVfo->pRX->Frequency >= _1GHz_in_KHz;
|
||||
if (gInputBoxIndex < 6 + isGigaF) {
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
|
||||
uint32_t Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
|
||||
|
||||
// clamp the frequency entered to some valid value
|
||||
if (Frequency < frequencyBandTable[0].lower) {
|
||||
|
@ -374,13 +358,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
|
|||
Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper;
|
||||
}
|
||||
|
||||
{
|
||||
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
|
||||
if (gTxVfo->Band != band) {
|
||||
gTxVfo->Band = band;
|
||||
gEeprom.ScreenChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||
|
@ -403,16 +382,12 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
|
|||
|
||||
gRequestSaveChannel = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef ENABLE_NOAA
|
||||
else
|
||||
if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
{ // user is entering NOAA channel
|
||||
|
||||
uint8_t Channel;
|
||||
|
||||
if (gInputBoxIndex != 2)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
|
@ -424,7 +399,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
|
|||
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
Channel = (gInputBox[0] * 10) + gInputBox[1];
|
||||
uint8_t Channel = (gInputBox[0] * 10) + gInputBox[1];
|
||||
if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable))
|
||||
{
|
||||
Channel += NOAA_CHANNEL_FIRST;
|
||||
|
@ -540,15 +515,14 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) {
|
|||
}
|
||||
|
||||
if (!bKeyPressed && !gDTMF_InputMode) { // menu key released
|
||||
if(gWasFKeyPressed)
|
||||
{
|
||||
gWasFKeyPressed=false;
|
||||
gEeprom.BEEP_CONTROL=!gEeprom.BEEP_CONTROL;
|
||||
if (gWasFKeyPressed) {
|
||||
gWasFKeyPressed = false;
|
||||
gEeprom.BEEP_CONTROL = !gEeprom.BEEP_CONTROL;
|
||||
gRequestSaveSettings = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
const bool bFlag = (gInputBoxIndex == 0);
|
||||
const bool bFlag = !gInputBoxIndex;
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
if (bFlag) {
|
||||
|
@ -607,8 +581,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) {
|
|||
#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));
|
||||
gDTMF_InputBox_Index = 0;
|
||||
|
@ -617,8 +590,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) {
|
|||
gKeyInputCountdown = key_input_timeout_500ms;
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
}
|
||||
else
|
||||
} else
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
} else { // with the F-key
|
||||
gWasFKeyPressed = false;
|
||||
|
|
123
app/spectrum.c
123
app/spectrum.c
|
@ -15,10 +15,10 @@
|
|||
*/
|
||||
|
||||
#include "app/spectrum.h"
|
||||
#include "driver/backlight.h"
|
||||
#include "audio.h"
|
||||
#include "ui/helper.h"
|
||||
#include "am_fix.h"
|
||||
#include "audio.h"
|
||||
#include "driver/backlight.h"
|
||||
#include "ui/helper.h"
|
||||
#include "ui/main.h"
|
||||
|
||||
struct FrequencyBandInfo {
|
||||
|
@ -32,7 +32,6 @@ struct FrequencyBandInfo {
|
|||
|
||||
const uint16_t RSSI_MAX_VALUE = 65535;
|
||||
|
||||
|
||||
static uint16_t R30, R37, R3D, R43, R47, R48, R7E;
|
||||
static uint32_t initialFreq;
|
||||
static char String[32];
|
||||
|
@ -45,6 +44,7 @@ bool redrawScreen = false;
|
|||
bool newScanStart = true;
|
||||
bool preventKeypress = true;
|
||||
bool audioState = true;
|
||||
bool lockAGC = false;
|
||||
|
||||
State currentState = SPECTRUM, previousState = SPECTRUM;
|
||||
|
||||
|
@ -56,17 +56,17 @@ const char *bwOptions[] = {" 25k", "12.5k", "6.25k"};
|
|||
const uint8_t modulationTypeTuneSteps[] = {100, 50, 10};
|
||||
const uint8_t modTypeReg47Values[] = {1, 7, 5};
|
||||
|
||||
SpectrumSettings settings = {stepsCount: STEPS_64,
|
||||
scanStepIndex: S_STEP_25_0kHz,
|
||||
frequencyChangeStep: 80000,
|
||||
scanDelay: 3200,
|
||||
rssiTriggerLevel: 150,
|
||||
backlightState: true,
|
||||
bw: BK4819_FILTER_BW_WIDE,
|
||||
listenBw: BK4819_FILTER_BW_WIDE,
|
||||
modulationType: false,
|
||||
dbMin: -130,
|
||||
dbMax: -50};
|
||||
SpectrumSettings settings = {.stepsCount = STEPS_64,
|
||||
.scanStepIndex = S_STEP_25_0kHz,
|
||||
.frequencyChangeStep = 80000,
|
||||
.scanDelay = 3200,
|
||||
.rssiTriggerLevel = 150,
|
||||
.backlightState = true,
|
||||
.bw = BK4819_FILTER_BW_WIDE,
|
||||
.listenBw = BK4819_FILTER_BW_WIDE,
|
||||
.modulationType = false,
|
||||
.dbMin = -130,
|
||||
.dbMax = -50};
|
||||
|
||||
uint32_t fMeasure = 0;
|
||||
uint32_t currentFreq, tempFreq;
|
||||
|
@ -102,8 +102,7 @@ static uint8_t DBm2S(int dbm) {
|
|||
return i;
|
||||
}
|
||||
|
||||
static int Rssi2DBm(uint16_t rssi)
|
||||
{
|
||||
static int Rssi2DBm(uint16_t rssi) {
|
||||
return (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band];
|
||||
}
|
||||
|
||||
|
@ -112,10 +111,20 @@ static uint16_t GetRegMenuValue(uint8_t st) {
|
|||
return (BK4819_ReadRegister(s.num) >> s.offset) & s.mask;
|
||||
}
|
||||
|
||||
void LockAGC()
|
||||
{
|
||||
if(!lockAGC)
|
||||
BK4819_SetAGC(0);
|
||||
lockAGC = true;
|
||||
}
|
||||
|
||||
static void SetRegMenuValue(uint8_t st, bool add) {
|
||||
uint16_t v = GetRegMenuValue(st);
|
||||
RegisterSpec s = registerSpecs[st];
|
||||
|
||||
if(s.num == BK4819_REG_13)
|
||||
LockAGC();
|
||||
|
||||
uint16_t reg = BK4819_ReadRegister(s.num);
|
||||
if (add && v <= s.mask - s.inc) {
|
||||
v += s.inc;
|
||||
|
@ -282,15 +291,12 @@ uint16_t GetRssi() {
|
|||
while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255) {
|
||||
SYSTICK_DelayUs(100);
|
||||
}
|
||||
if(settings.modulationType == MODULATION_AM)
|
||||
{
|
||||
return BK4819_GetRSSI() - rssi_gain_diff[vfo]; //return the corrected RSSI to allow for AM_Fixs AGC action.
|
||||
}
|
||||
else
|
||||
{
|
||||
return BK4819_GetRSSI();
|
||||
}
|
||||
|
||||
return BK4819_GetRSSI()
|
||||
#ifdef ENABLE_AM_FIX
|
||||
- ((settings.modulationType == MODULATION_AM) ? AM_fix_get_rssi_gain_diff(vfo) : 0)
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
static void ToggleAudio(bool on) {
|
||||
|
@ -395,14 +401,14 @@ static void Measure() { rssiHistory[scanInfo.i] = scanInfo.rssi = GetRssi(); }
|
|||
|
||||
// Update things by keypress
|
||||
|
||||
static uint16_t dbm2rssi(int dBm)
|
||||
{
|
||||
return (dBm + 160 - dBmCorrTable[gRxVfo->Band])*2;
|
||||
static uint16_t dbm2rssi(int dBm) {
|
||||
return (dBm + 160 - dBmCorrTable[gRxVfo->Band]) * 2;
|
||||
}
|
||||
|
||||
static void ClampRssiTriggerLevel()
|
||||
{
|
||||
settings.rssiTriggerLevel = clamp(settings.rssiTriggerLevel, dbm2rssi(settings.dbMin), dbm2rssi(settings.dbMax));
|
||||
static void ClampRssiTriggerLevel() {
|
||||
settings.rssiTriggerLevel =
|
||||
clamp(settings.rssiTriggerLevel, dbm2rssi(settings.dbMin),
|
||||
dbm2rssi(settings.dbMax));
|
||||
}
|
||||
|
||||
static void UpdateRssiTriggerLevel(bool inc) {
|
||||
|
@ -489,6 +495,10 @@ static void ToggleModulation() {
|
|||
settings.modulationType = MODULATION_FM;
|
||||
}
|
||||
RADIO_SetModulation(settings.modulationType);
|
||||
if(settings.modulationType != MODULATION_AM) {
|
||||
BK4819_InitAGC();
|
||||
BK4819_SetAGC(1);
|
||||
}
|
||||
RelaunchScan();
|
||||
redrawScreen = true;
|
||||
}
|
||||
|
@ -549,7 +559,7 @@ static void UpdateFreqInput(KEY_Code_t key) {
|
|||
}
|
||||
if (key == KEY_EXIT) {
|
||||
freqInputIndex--;
|
||||
if(freqInputDotIndex==freqInputIndex)
|
||||
if (freqInputDotIndex == freqInputIndex)
|
||||
freqInputDotIndex = 0;
|
||||
} else {
|
||||
freqInputArr[freqInputIndex++] = key;
|
||||
|
@ -564,7 +574,7 @@ static void UpdateFreqInput(KEY_Code_t key) {
|
|||
for (int i = 0; i < 10; ++i) {
|
||||
if (i < freqInputIndex) {
|
||||
digitKey = freqInputArr[i];
|
||||
freqInputString[i] = digitKey <= KEY_9 ? '0' + digitKey-KEY_0 : '.';
|
||||
freqInputString[i] = digitKey <= KEY_9 ? '0' + digitKey - KEY_0 : '.';
|
||||
} else {
|
||||
freqInputString[i] = '-';
|
||||
}
|
||||
|
@ -572,14 +582,14 @@ static void UpdateFreqInput(KEY_Code_t key) {
|
|||
|
||||
uint32_t base = 100000; // 1MHz in BK units
|
||||
for (int i = dotIndex - 1; i >= 0; --i) {
|
||||
tempFreq += (freqInputArr[i]-KEY_0) * base;
|
||||
tempFreq += (freqInputArr[i] - KEY_0) * base;
|
||||
base *= 10;
|
||||
}
|
||||
|
||||
base = 10000; // 0.1MHz in BK units
|
||||
if (dotIndex < freqInputIndex) {
|
||||
for (int i = dotIndex + 1; i < freqInputIndex; ++i) {
|
||||
tempFreq += (freqInputArr[i]-KEY_0) * base;
|
||||
tempFreq += (freqInputArr[i] - KEY_0) * base;
|
||||
base /= 10;
|
||||
}
|
||||
}
|
||||
|
@ -630,10 +640,11 @@ static void DrawStatus() {
|
|||
#endif
|
||||
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] +
|
||||
gBatteryVoltages[3]) /
|
||||
uint16_t voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] +
|
||||
gBatteryVoltages[2] + gBatteryVoltages[3]) /
|
||||
4 * 760 / gBatteryCalibration[3];
|
||||
|
||||
unsigned perc = BATTERY_VoltsToPercent(voltage);
|
||||
|
@ -648,7 +659,7 @@ static void DrawStatus() {
|
|||
}
|
||||
|
||||
for (unsigned i = 127; i >= 118; i--) {
|
||||
if (127 - i <= (perc+5)*9/100) {
|
||||
if (127 - i <= (perc + 5) * 9 / 100) {
|
||||
gStatusLine[i] = 0b00111110;
|
||||
}
|
||||
}
|
||||
|
@ -901,6 +912,7 @@ void OnKeyDownStill(KEY_Code_t key) {
|
|||
case KEY_EXIT:
|
||||
if (!menuState) {
|
||||
SetState(SPECTRUM);
|
||||
lockAGC = false;
|
||||
monitorMode = false;
|
||||
RelaunchScan();
|
||||
break;
|
||||
|
@ -912,9 +924,7 @@ void OnKeyDownStill(KEY_Code_t key) {
|
|||
}
|
||||
}
|
||||
|
||||
static void RenderFreqInput() {
|
||||
UI_PrintStringSmall(freqInputString, 2, 127, 0);
|
||||
}
|
||||
static void RenderFreqInput() { UI_PrintStringSmall(freqInputString, 2, 127, 0); }
|
||||
|
||||
static void RenderStatus() {
|
||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||
|
@ -1014,13 +1024,12 @@ bool HandleUserInput() {
|
|||
kbd.current = GetKey();
|
||||
|
||||
if (kbd.current != KEY_INVALID && kbd.current == kbd.prev) {
|
||||
if(kbd.counter < 16)
|
||||
if (kbd.counter < 16)
|
||||
kbd.counter++;
|
||||
else
|
||||
kbd.counter-=3;
|
||||
kbd.counter -= 3;
|
||||
SYSTEM_DelayMs(20);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
kbd.counter = 0;
|
||||
}
|
||||
|
||||
|
@ -1119,11 +1128,12 @@ static void UpdateListening() {
|
|||
}
|
||||
|
||||
static void Tick() {
|
||||
|
||||
if(settings.modulationType == MODULATION_AM)
|
||||
{
|
||||
AM_fix_10ms(vfo); //allow AM_Fix to apply its AGC action
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if(settings.modulationType == MODULATION_AM) {
|
||||
AM_fix_10ms(vfo, !lockAGC); //allow AM_Fix to apply its AGC action
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!preventKeypress) {
|
||||
HandleUserInput();
|
||||
}
|
||||
|
@ -1154,8 +1164,9 @@ static void Tick() {
|
|||
void APP_RunSpectrum() {
|
||||
// TX here coz it always? set to active VFO
|
||||
vfo = gEeprom.TX_VFO;
|
||||
//set the current frequency in the middle of the display
|
||||
currentFreq = initialFreq = gEeprom.VfoInfo[vfo].pRX->Frequency - ((GetStepsCount()/2) * GetScanStep());
|
||||
// set the current frequency in the middle of the display
|
||||
currentFreq = initialFreq = gEeprom.VfoInfo[vfo].pRX->Frequency -
|
||||
((GetStepsCount() / 2) * GetScanStep());
|
||||
|
||||
BackupRegisters();
|
||||
|
||||
|
@ -1166,6 +1177,14 @@ void APP_RunSpectrum() {
|
|||
|
||||
ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off
|
||||
RADIO_SetModulation(settings.modulationType = gRxVfo->Modulation);
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if(settings.modulationType != MODULATION_AM) {
|
||||
BK4819_InitAGC();
|
||||
BK4819_SetAGC(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
|
||||
|
||||
RelaunchScan();
|
||||
|
|
2
board.c
2
board.c
|
@ -493,7 +493,7 @@ void BOARD_Init(void)
|
|||
BOARD_GPIO_Init();
|
||||
BACKLIGHT_InitHardware();
|
||||
BOARD_ADC_Init();
|
||||
ST7565_Init(true);
|
||||
ST7565_Init();
|
||||
#ifdef ENABLE_FMRADIO
|
||||
BK1080_Init(0, false);
|
||||
#endif
|
||||
|
|
118
driver/st7565.c
118
driver/st7565.c
|
@ -25,118 +25,57 @@
|
|||
#include "driver/system.h"
|
||||
#include "misc.h"
|
||||
|
||||
uint8_t gStatusLine[128];
|
||||
uint8_t gFrameBuffer[7][128];
|
||||
uint8_t gStatusLine[LCD_WIDTH];
|
||||
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;
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
ST7565_SelectColumnAndLine(Column + 4U, Line);
|
||||
|
||||
ST7565_SelectColumnAndLine(column + 4, line);
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
||||
|
||||
if (pBitmap != NULL)
|
||||
{
|
||||
for (i = 0; i < Size; i++)
|
||||
{
|
||||
for (unsigned i = 0; i < size_defVal; i++) {
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void ST7565_BlitFullScreen(void)
|
||||
{
|
||||
unsigned int Line;
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
ST7565_WriteByte(0x40);
|
||||
|
||||
for (Line = 0; Line < ARRAY_SIZE(gFrameBuffer); Line++)
|
||||
{
|
||||
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];
|
||||
for (unsigned line = 0; line < FRAME_LINES; line++) {
|
||||
DrawLine(0, line+1, gFrameBuffer[line], LCD_WIDTH);
|
||||
}
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
}
|
||||
|
||||
#if 0
|
||||
// whats the delay for I wonder, it holds things up :(
|
||||
SYSTEM_DelayMs(20);
|
||||
#else
|
||||
// SYSTEM_DelayMs(1);
|
||||
#endif
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
|
||||
void ST7565_BlitLine(unsigned line)
|
||||
{
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
ST7565_WriteByte(0x40); // start line ?
|
||||
DrawLine(0, line+1, gFrameBuffer[line], LCD_WIDTH);
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
void ST7565_BlitStatusLine(void)
|
||||
{ // the top small text line on the display
|
||||
|
||||
unsigned int i;
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
ST7565_WriteByte(0x40); // start line ?
|
||||
|
||||
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();
|
||||
|
||||
DrawLine(0, 0, gStatusLine, LCD_WIDTH);
|
||||
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);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
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;
|
||||
for (unsigned i = 0; i < 8; i++) {
|
||||
DrawLine(0, i, NULL, value);
|
||||
}
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
}
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
|
||||
|
@ -205,22 +144,17 @@ uint8_t cmds[] = {
|
|||
ST7565_CMD_DISPLAY_ON_OFF | 1, // Display ON/OFF: ON
|
||||
};
|
||||
|
||||
void ST7565_Init(const bool full)
|
||||
void ST7565_Init(void)
|
||||
{
|
||||
if (full) {
|
||||
SPI0_Init();
|
||||
ST7565_HardwareReset();
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
ST7565_WriteByte(ST7565_CMD_SOFTWARE_RESET); // software reset
|
||||
SYSTEM_DelayMs(120);
|
||||
}
|
||||
else
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
for(uint8_t i = 0; i < 8; i++)
|
||||
ST7565_WriteByte(cmds[i]);
|
||||
|
||||
if (full) {
|
||||
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b011); // VB=0 VR=1 VF=1
|
||||
SYSTEM_DelayMs(1);
|
||||
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b110); // VB=1 VR=1 VF=0
|
||||
|
@ -230,14 +164,12 @@ void ST7565_Init(const bool full)
|
|||
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b111); // VB=1 VR=1 VF=1
|
||||
|
||||
SYSTEM_DelayMs(40);
|
||||
}
|
||||
|
||||
ST7565_WriteByte(ST7565_CMD_SET_START_LINE | 0); // line 0
|
||||
ST7565_WriteByte(ST7565_CMD_DISPLAY_ON_OFF | 1); // D=1
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
|
||||
if (full)
|
||||
ST7565_FillScreen(0x00);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,19 +22,20 @@
|
|||
|
||||
#define LCD_WIDTH 128
|
||||
#define LCD_HEIGHT 64
|
||||
#define FRAME_LINES 7
|
||||
|
||||
extern uint8_t gStatusLine[128];
|
||||
extern uint8_t gFrameBuffer[7][128];
|
||||
extern uint8_t gStatusLine[LCD_WIDTH];
|
||||
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_BlitLine(unsigned line);
|
||||
void ST7565_BlitStatusLine(void);
|
||||
void ST7565_FillScreen(uint8_t Value);
|
||||
void ST7565_Init(const bool full);
|
||||
void ST7565_Init(void);
|
||||
void ST7565_FixInterfGlitch(void);
|
||||
void ST7565_HardwareReset(void);
|
||||
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
|
||||
void ST7565_WriteByte(uint8_t Value);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -19,34 +19,33 @@
|
|||
#include "settings.h"
|
||||
|
||||
// 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] =
|
||||
{
|
||||
#ifndef ENABLE_WIDE_RX
|
||||
#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
|
||||
// QS original
|
||||
{.lower = 5000000, .upper = 7600000},
|
||||
{.lower = 10800000, .upper = 13700000},
|
||||
{.lower = 13700000, .upper = 17400000},
|
||||
{.lower = 17400000, .upper = 35000000},
|
||||
{.lower = 35000000, .upper = 40000000},
|
||||
{.lower = 40000000, .upper = 47000000},
|
||||
{.lower = 47000000, .upper = 60000000}
|
||||
#else
|
||||
[BAND1_50MHz ]={.lower = 5000000, .upper = 7600000},
|
||||
[BAND7_470MHz]={.lower = 47000000, .upper = 60000000},
|
||||
#else
|
||||
// extended range
|
||||
{.lower = BX4819_band1.lower, .upper = 10800000},
|
||||
{.lower = 10800000, .upper = 13700000},
|
||||
{.lower = 13700000, .upper = 17400000},
|
||||
{.lower = 17400000, .upper = 35000000},
|
||||
{.lower = 35000000, .upper = 40000000},
|
||||
{.lower = 40000000, .upper = 47000000},
|
||||
{.lower = 47000000, .upper = BX4819_band2.upper}
|
||||
#endif
|
||||
};
|
||||
[BAND1_50MHz ]={.lower = BX4819_band1_lower, .upper = 10800000},
|
||||
[BAND7_470MHz]={.lower = 47000000, .upper = BX4819_band2_upper},
|
||||
#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
|
||||
const uint32_t NoaaFrequencyTable[10] =
|
||||
const uint32_t NoaaFrequencyTable[10] =
|
||||
{
|
||||
16255000,
|
||||
16240000,
|
||||
|
@ -65,19 +64,21 @@ const freq_band_table_t frequencyBandTable[7] =
|
|||
const uint16_t gStepFrequencyTable[] = {
|
||||
250, 500, 625, 1000, 1250, 2500, 833,
|
||||
1, 5, 10, 25, 50, 100, 125, 1500, 3000, 5000, 10000, 12500, 25000, 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_8_33kHz, STEP_10kHz, STEP_12_5kHz, STEP_15kHz, STEP_25kHz, STEP_30kHz, STEP_50kHz, STEP_100kHz,
|
||||
STEP_125kHz, STEP_250kHz, STEP_500kHz
|
||||
};
|
||||
uint8_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx)
|
||||
|
||||
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t 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++)
|
||||
if(StepSortedIndexes[i] == stepIdx)
|
||||
|
@ -87,8 +88,7 @@ uint8_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t stepIdx)
|
|||
|
||||
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
||||
{
|
||||
int band;
|
||||
for (band = ARRAY_SIZE(frequencyBandTable) - 1; band >= 0; band--)
|
||||
for (int band = ARRAY_SIZE(frequencyBandTable) - 1; band >= 0; band--)
|
||||
if (Frequency >= frequencyBandTable[band].lower)
|
||||
// if (Frequency < frequencyBandTable[band].upper)
|
||||
return (FREQUENCY_Band_t)band;
|
||||
|
@ -117,7 +117,6 @@ uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t T
|
|||
}
|
||||
|
||||
|
||||
|
||||
uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step)
|
||||
{
|
||||
if(step == 833) {
|
||||
|
@ -130,7 +129,7 @@ uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t 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
|
||||
// otherwise return '-1'
|
||||
|
||||
|
@ -146,15 +145,15 @@ int TX_freq_check(const uint32_t Frequency)
|
|||
if (Frequency >= frequencyBandTable[BAND3_137MHz].lower && Frequency < frequencyBandTable[BAND3_137MHz].upper)
|
||||
return 0;
|
||||
// if (Frequency >= frequencyBandTable[BAND4_174MHz].lower && Frequency < frequencyBandTable[BAND4_174MHz].upper)
|
||||
// if (gSetting_F_LOCK==F_LOCK_ALL)
|
||||
// if (gSetting_200TX)
|
||||
// return 0;
|
||||
// if (Frequency >= frequencyBandTable[BAND5_350MHz].lower && Frequency < frequencyBandTable[BAND5_350MHz].upper)
|
||||
// if (gSetting_F_LOCK==F_LOCK_ALL)
|
||||
// if (gSetting_350TX && gSetting_350EN)
|
||||
// return 0;
|
||||
if (Frequency >= frequencyBandTable[BAND6_400MHz].lower && Frequency < frequencyBandTable[BAND6_400MHz].upper)
|
||||
return 0;
|
||||
// if (Frequency >= frequencyBandTable[BAND7_470MHz].lower && Frequency <= 60000000)
|
||||
// if (gSetting_F_LOCK==F_LOCK_ALL)
|
||||
// if (gSetting_500TX)
|
||||
// return 0;
|
||||
break;
|
||||
|
||||
|
@ -207,7 +206,7 @@ int TX_freq_check(const uint32_t Frequency)
|
|||
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
|
||||
// otherwise return '-1'
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#define _1GHz_in_KHz 100000000
|
||||
|
||||
typedef struct {
|
||||
const uint32_t lower;
|
||||
const uint32_t upper;
|
||||
|
@ -37,7 +39,8 @@ typedef enum {
|
|||
BAND4_174MHz,
|
||||
BAND5_350MHz,
|
||||
BAND6_400MHz,
|
||||
BAND7_470MHz
|
||||
BAND7_470MHz,
|
||||
BAND_LAST_ELEMENT //keep this guard as last element
|
||||
} FREQUENCY_Band_t;
|
||||
|
||||
|
||||
|
@ -69,17 +72,17 @@ typedef enum {
|
|||
extern const uint16_t gStepFrequencyTable[21];
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
extern const uint32_t NoaaFrequencyTable[10];
|
||||
extern const uint32_t NoaaFrequencyTable[10];
|
||||
#endif
|
||||
|
||||
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);
|
||||
uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step);
|
||||
|
||||
uint8_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx);
|
||||
uint8_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t step);
|
||||
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx);
|
||||
uint32_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t step);
|
||||
|
||||
int TX_freq_check(const uint32_t Frequency);
|
||||
int RX_freq_check(const uint32_t Frequency);
|
||||
int32_t TX_freq_check(const uint32_t Frequency);
|
||||
int32_t RX_freq_check(const uint32_t Frequency);
|
||||
|
||||
#endif
|
19
radio.c
19
radio.c
|
@ -17,7 +17,7 @@
|
|||
#include <stdint.h>
|
||||
#include "app/mdc1200.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "am_fix.h"
|
||||
#include "app/dtmf.h"
|
||||
#ifdef ENABLE_FMRADIO
|
||||
#include "app/fm.h"
|
||||
|
@ -353,8 +353,8 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||
else
|
||||
pVfo->freq_config_RX.Frequency = info.Frequency;
|
||||
|
||||
if (info.Offset >= 100000000)
|
||||
info.Offset = 1000000;
|
||||
if (info.Offset >= _1GHz_in_KHz)
|
||||
info.Offset = _1GHz_in_KHz / 100;
|
||||
pVfo->TX_OFFSET_FREQUENCY = info.Offset;
|
||||
|
||||
// ***************
|
||||
|
@ -792,7 +792,8 @@ void RADIO_SetupRegisters(bool switchToForeground)
|
|||
BK4819_DisableDTMF();
|
||||
}
|
||||
#endif
|
||||
|
||||
BK4819_SetAGC(1);
|
||||
BK4819_InitAGC();
|
||||
// enable/disable BK4819 selected interrupts
|
||||
BK4819_WriteRegister(BK4819_REG_3F, InterruptMask);
|
||||
|
||||
|
@ -912,7 +913,6 @@ void RADIO_SetTxParameters(void)
|
|||
|
||||
void RADIO_SetModulation(ModulationMode_t modulation)
|
||||
{
|
||||
static ModulationMode_t m = MODULATION_UKNOWN;
|
||||
BK4819_AF_Type_t mod;
|
||||
switch(modulation) {
|
||||
default:
|
||||
|
@ -937,16 +937,15 @@ void RADIO_SetModulation(ModulationMode_t modulation)
|
|||
}
|
||||
|
||||
BK4819_SetAF(mod);
|
||||
if(m != modulation) {
|
||||
m = modulation;
|
||||
|
||||
|
||||
BK4819_SetRegValue(afDacGainRegSpec, 0xF);
|
||||
BK4819_WriteRegister(BK4819_REG_3D, modulation == MODULATION_USB ? 0 : 0x2AAB);
|
||||
BK4819_SetRegValue(afcDisableRegSpec, modulation != MODULATION_FM);
|
||||
#ifdef ENABLE_AM_FIX
|
||||
BK4819_SetAGC(gRxVfo->Modulation != MODULATION_AM || !gSetting_AM_fix);
|
||||
BK4819_InitAGC();
|
||||
if(modulation == MODULATION_AM && gSetting_AM_fix)
|
||||
BK4819_SetAGC(0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void RADIO_SetVfoState(VfoState_t State)
|
||||
|
|
30
settings.c
30
settings.c
|
@ -614,29 +614,33 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
|
|||
if (Mode >= 2 || !IS_MR_CHANNEL(Channel))
|
||||
{ // copy VFO to a channel
|
||||
|
||||
uint8_t State[8];
|
||||
|
||||
((uint32_t *)State)[0] = pVFO->freq_config_RX.Frequency;
|
||||
((uint32_t *)State)[1] = pVFO->TX_OFFSET_FREQUENCY;
|
||||
EEPROM_WriteBuffer(OffsetVFO + 0, State);
|
||||
union {
|
||||
uint8_t _8[8];
|
||||
uint32_t _32[2];
|
||||
} State;
|
||||
|
||||
State[0] = pVFO->freq_config_RX.Code;
|
||||
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
|
||||
State._32[0] = pVFO->freq_config_RX.Frequency;
|
||||
State._32[1] = pVFO->TX_OFFSET_FREQUENCY;
|
||||
EEPROM_WriteBuffer(OffsetVFO + 0, State._32);
|
||||
|
||||
State._8[0] = pVFO->freq_config_RX.Code;
|
||||
State._8[1] = pVFO->freq_config_TX.Code;
|
||||
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._8[4] = 0
|
||||
| (pVFO->BUSY_CHANNEL_LOCK << 4)
|
||||
| (pVFO->OUTPUT_POWER << 2)
|
||||
| (pVFO->CHANNEL_BANDWIDTH << 1)
|
||||
| (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
|
||||
| ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0)
|
||||
#endif
|
||||
;
|
||||
State[6] = pVFO->STEP_SETTING;
|
||||
State[7] = pVFO->SCRAMBLING_TYPE;
|
||||
EEPROM_WriteBuffer(OffsetVFO + 8, State);
|
||||
State._8[6] = pVFO->STEP_SETTING;
|
||||
State._8[7] = pVFO->SCRAMBLING_TYPE;
|
||||
EEPROM_WriteBuffer(OffsetVFO + 8, State._8);
|
||||
|
||||
SETTINGS_UpdateChannel(Channel, pVFO, true);
|
||||
|
||||
|
|
|
@ -52,5 +52,5 @@ void UI_DisplayBattery(uint8_t level, uint8_t blink)
|
|||
{
|
||||
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
|
||||
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));
|
||||
}
|
||||
|
|
58
ui/main.c
58
ui/main.c
|
@ -246,7 +246,52 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
|
|||
}
|
||||
|
||||
}
|
||||
#ifdef ENABLE_AGC_SHOW_DATA
|
||||
static void PrintAGC(bool now)
|
||||
{
|
||||
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];
|
||||
|
||||
sprintf(buf, "%d%2d %2d %2d %3d", reg7e.agcEnab, reg7e.gainIdx, -agcGain, reg7e.agcSigStrength, BK4819_GetRSSI());
|
||||
UI_PrintStringSmall(buf, 2, 0, 3);
|
||||
if(now)
|
||||
ST7565_BlitLine(3);
|
||||
}
|
||||
#endif
|
||||
|
||||
void UI_MAIN_TimeSlice500ms(void)
|
||||
{
|
||||
#ifdef ENABLE_AGC_SHOW_DATA
|
||||
if(gScreenToDisplay==DISPLAY_MAIN)
|
||||
PrintAGC(true);
|
||||
#endif
|
||||
}
|
||||
// ***************************************************************************
|
||||
|
||||
void UI_DisplayMain(void)
|
||||
|
@ -428,7 +473,7 @@ void UI_DisplayMain(void)
|
|||
{ // frequency mode
|
||||
// show the frequency band number
|
||||
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);
|
||||
UI_PrintStringSmall(String, x, 0, line + 1);
|
||||
}
|
||||
|
@ -473,7 +518,7 @@ void UI_DisplayMain(void)
|
|||
|
||||
|
||||
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);
|
||||
#ifdef ENABLE_BIG_FREQ
|
||||
if(!isGigaF) {
|
||||
|
@ -528,7 +573,7 @@ void UI_DisplayMain(void)
|
|||
case MDF_FREQUENCY: // show the channel frequency
|
||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||
#ifdef ENABLE_BIG_FREQ
|
||||
if(frequency < 100000000) {
|
||||
if(frequency < _1GHz_in_KHz) {
|
||||
// show the remaining 2 small frequency digits
|
||||
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
||||
String[7] = 0;
|
||||
|
@ -583,7 +628,7 @@ void UI_DisplayMain(void)
|
|||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||
|
||||
#ifdef ENABLE_BIG_FREQ
|
||||
if(frequency < 100000000) {
|
||||
if(frequency < _1GHz_in_KHz) {
|
||||
// show the remaining 2 small frequency digits
|
||||
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
||||
String[7] = 0;
|
||||
|
@ -702,7 +747,10 @@ void UI_DisplayMain(void)
|
|||
UI_PrintStringSmall("SCR", LCD_WIDTH + 106, 0, line + 1);
|
||||
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AGC_SHOW_DATA
|
||||
center_line = CENTER_LINE_IN_USE;
|
||||
PrintAGC(false);
|
||||
#endif
|
||||
if (center_line == CENTER_LINE_NONE)
|
||||
{ // we're free to use the middle line
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ extern center_line_t center_line;
|
|||
void UI_DisplayAudioBar(void);
|
||||
void UI_UpdateRSSI(const int16_t rssi, const int vfo);
|
||||
void UI_DisplayMain(void);
|
||||
void UI_MAIN_TimeSlice500ms(void);
|
||||
extern const int8_t dBmCorrTable[7];
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue