Compare commits
33 Commits
v0.20
...
lowest_pow
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed5fe91d35 | ||
|
|
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 |
110
Makefile
110
Makefile
@@ -4,51 +4,51 @@
|
|||||||
# 1 = enable
|
# 1 = enable
|
||||||
|
|
||||||
# ---- COMPILER/LINKER OPTIONS ----
|
# ---- COMPILER/LINKER OPTIONS ----
|
||||||
ENABLE_CLANG := 0
|
ENABLE_CLANG ?= 0
|
||||||
ENABLE_SWD := 0
|
ENABLE_SWD ?= 0
|
||||||
ENABLE_OVERLAY := 0
|
ENABLE_OVERLAY ?= 0
|
||||||
ENABLE_LTO := 1
|
ENABLE_LTO ?= 1
|
||||||
|
|
||||||
# ---- STOCK QUANSHENG FERATURES ----
|
# ---- STOCK QUANSHENG FERATURES ----
|
||||||
ENABLE_UART := 1
|
ENABLE_UART ?= 1
|
||||||
ENABLE_AIRCOPY := 0
|
ENABLE_AIRCOPY ?= 0
|
||||||
ENABLE_FMRADIO := 1
|
ENABLE_FMRADIO ?= 1
|
||||||
ENABLE_NOAA := 0
|
ENABLE_NOAA ?= 0
|
||||||
ENABLE_VOICE := 0
|
ENABLE_VOICE ?= 0
|
||||||
ENABLE_VOX := 1
|
ENABLE_VOX ?= 1
|
||||||
ENABLE_ALARM := 0
|
ENABLE_ALARM ?= 0
|
||||||
ENABLE_TX1750 := 0
|
ENABLE_TX1750 ?= 0
|
||||||
ENABLE_PWRON_PASSWORD := 0
|
ENABLE_PWRON_PASSWORD ?= 0
|
||||||
ENABLE_DTMF_CALLING := 1
|
ENABLE_DTMF_CALLING ?= 1
|
||||||
ENABLE_FLASHLIGHT := 1
|
ENABLE_FLASHLIGHT ?= 1
|
||||||
|
|
||||||
# ---- CUSTOM MODS ----
|
# ---- CUSTOM MODS ----
|
||||||
ENABLE_BIG_FREQ := 1
|
ENABLE_BIG_FREQ ?= 1
|
||||||
ENABLE_SMALL_BOLD := 1
|
ENABLE_SMALL_BOLD ?= 1
|
||||||
ENABLE_KEEP_MEM_NAME := 1
|
ENABLE_KEEP_MEM_NAME ?= 1
|
||||||
ENABLE_WIDE_RX := 1
|
ENABLE_WIDE_RX ?= 1
|
||||||
ENABLE_TX_WHEN_AM := 0
|
ENABLE_TX_WHEN_AM ?= 0
|
||||||
ENABLE_F_CAL_MENU := 0
|
ENABLE_F_CAL_MENU ?= 0
|
||||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 0
|
ENABLE_CTCSS_TAIL_PHASE_SHIFT ?= 0
|
||||||
ENABLE_BOOT_BEEPS := 0
|
ENABLE_BOOT_BEEPS ?= 0
|
||||||
ENABLE_SHOW_CHARGE_LEVEL := 0
|
ENABLE_SHOW_CHARGE_LEVEL ?= 0
|
||||||
ENABLE_REVERSE_BAT_SYMBOL := 0
|
ENABLE_REVERSE_BAT_SYMBOL ?= 0
|
||||||
ENABLE_NO_CODE_SCAN_TIMEOUT := 1
|
ENABLE_NO_CODE_SCAN_TIMEOUT ?= 1
|
||||||
ENABLE_AM_FIX := 1
|
ENABLE_AM_FIX ?= 1
|
||||||
ENABLE_SQUELCH_MORE_SENSITIVE := 1
|
ENABLE_SQUELCH_MORE_SENSITIVE ?= 1
|
||||||
ENABLE_FASTER_CHANNEL_SCAN := 1
|
ENABLE_FASTER_CHANNEL_SCAN ?= 1
|
||||||
ENABLE_RSSI_BAR := 1
|
ENABLE_RSSI_BAR ?= 1
|
||||||
ENABLE_AUDIO_BAR := 1
|
ENABLE_AUDIO_BAR ?= 1
|
||||||
ENABLE_COPY_CHAN_TO_VFO := 1
|
ENABLE_COPY_CHAN_TO_VFO ?= 1
|
||||||
ENABLE_SPECTRUM := 1
|
ENABLE_SPECTRUM ?= 1
|
||||||
ENABLE_REDUCE_LOW_MID_TX_POWER:= 0
|
ENABLE_REDUCE_LOW_MID_TX_POWER?= 0
|
||||||
ENABLE_BYP_RAW_DEMODULATORS := 0
|
ENABLE_BYP_RAW_DEMODULATORS ?= 0
|
||||||
ENABLE_BLMIN_TMP_OFF := 0
|
ENABLE_BLMIN_TMP_OFF ?= 0
|
||||||
ENABLE_SCAN_RANGES := 1
|
ENABLE_SCAN_RANGES ?= 1
|
||||||
|
|
||||||
# ---- DEBUGGING ----
|
# ---- DEBUGGING ----
|
||||||
ENABLE_AM_FIX_SHOW_DATA := 0
|
ENABLE_AM_FIX_SHOW_DATA ?= 0
|
||||||
ENABLE_AGC_SHOW_DATA := 0
|
ENABLE_AGC_SHOW_DATA ?= 0
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
@@ -167,24 +167,18 @@ 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
|
RM = del /Q
|
||||||
TOP := $(shell pwd)
|
FixPath = $(subst /,\,$1)
|
||||||
endif
|
WHERE = where
|
||||||
|
NULL_OUTPUT = nul
|
||||||
ifdef OS # windows
|
|
||||||
RM = del /Q
|
|
||||||
FixPath = $(subst /,\,$1)
|
|
||||||
WHERE = where
|
|
||||||
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
|
||||||
@@ -204,11 +198,11 @@ 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
|
||||||
|
|||||||
55
README.md
55
README.md
@@ -1,10 +1,7 @@
|
|||||||
# Open re-implementation of the Quansheng UV-K5 v2.1.27 firmware
|
# 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.
|
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 !
|
||||||
All is a cloned and customized version of DualTachyon's open firmware found here ..
|
|
||||||
|
|
||||||
https://github.com/DualTachyon/uv-k5-firmware .. a cool achievement !
|
|
||||||
|
|
||||||
> [!WARNING]
|
> [!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.
|
> 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.
|
||||||
@@ -19,6 +16,7 @@ Anyway, have fun.
|
|||||||
* [Compiler](#compiler)
|
* [Compiler](#compiler)
|
||||||
* [Building](#building)
|
* [Building](#building)
|
||||||
* [Credits](#credits)
|
* [Credits](#credits)
|
||||||
|
* [Other sources of information](#other-sources-of-information)
|
||||||
* [License](#license)
|
* [License](#license)
|
||||||
* [Example changes/updates](#example-changesupdates)
|
* [Example changes/updates](#example-changesupdates)
|
||||||
|
|
||||||
@@ -47,24 +45,15 @@ Anyway, have fun.
|
|||||||
* 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)
|
|
||||||
|
|
||||||
* [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 />
|
|
||||||
|
|
||||||
## Radio performance
|
## Radio performance
|
||||||
|
|
||||||
@@ -143,10 +132,31 @@ You can get it from: https://releases.llvm.org/download.html
|
|||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
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.
|
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
|
||||||
To compile directly in windows:
|
|
||||||
|
|
||||||
1. Open windows command line and run:
|
1. Open windows command line and run:
|
||||||
```
|
```
|
||||||
@@ -191,6 +201,11 @@ 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
|
||||||
|
|
||||||
|
## 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
|
## License
|
||||||
|
|
||||||
Copyright 2023 Dual Tachyon
|
Copyright 2023 Dual Tachyon
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ inline static void ACTION_ScanRestart() { ACTION_Scan(true); };
|
|||||||
|
|
||||||
void (*action_opt_table[])(void) = {
|
void (*action_opt_table[])(void) = {
|
||||||
[ACTION_OPT_NONE] = &FUNCTION_NOP,
|
[ACTION_OPT_NONE] = &FUNCTION_NOP,
|
||||||
[ACTION_OPT_FLASHLIGHT] = &ACTION_FlashLight,
|
|
||||||
[ACTION_OPT_POWER] = &ACTION_Power,
|
[ACTION_OPT_POWER] = &ACTION_Power,
|
||||||
[ACTION_OPT_MONITOR] = &ACTION_Monitor,
|
[ACTION_OPT_MONITOR] = &ACTION_Monitor,
|
||||||
[ACTION_OPT_SCAN] = &ACTION_ScanRestart,
|
[ACTION_OPT_SCAN] = &ACTION_ScanRestart,
|
||||||
@@ -66,6 +65,12 @@ void (*action_opt_table[])(void) = {
|
|||||||
[ACTION_OPT_VFO_MR] = &COMMON_SwitchVFOMode,
|
[ACTION_OPT_VFO_MR] = &COMMON_SwitchVFOMode,
|
||||||
[ACTION_OPT_SWITCH_DEMODUL] = &ACTION_SwitchDemodul,
|
[ACTION_OPT_SWITCH_DEMODUL] = &ACTION_SwitchDemodul,
|
||||||
|
|
||||||
|
#ifdef ENABLE_FLASHLIGHT
|
||||||
|
[ACTION_OPT_FLASHLIGHT] = &ACTION_FlashLight,
|
||||||
|
#else
|
||||||
|
[ACTION_OPT_FLASHLIGHT] = &FUNCTION_NOP,
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
[ACTION_OPT_VOX] = &ACTION_Vox,
|
[ACTION_OPT_VOX] = &ACTION_Vox,
|
||||||
#else
|
#else
|
||||||
|
|||||||
343
app/app.c
343
app/app.c
@@ -37,7 +37,9 @@
|
|||||||
#include "app/main.h"
|
#include "app/main.h"
|
||||||
#include "app/menu.h"
|
#include "app/menu.h"
|
||||||
#include "app/scanner.h"
|
#include "app/scanner.h"
|
||||||
#include "app/uart.h"
|
#ifdef ENABLE_UART
|
||||||
|
#include "app/uart.h"
|
||||||
|
#endif
|
||||||
#include "ARMCM0.h"
|
#include "ARMCM0.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
@@ -70,8 +72,6 @@
|
|||||||
#include "ui/status.h"
|
#include "ui/status.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
#include "debugging.h"
|
|
||||||
|
|
||||||
static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||||
|
|
||||||
|
|
||||||
@@ -194,8 +194,8 @@ static void HandleIncoming(void)
|
|||||||
gFoundCTCSS = false;
|
gFoundCTCSS = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE
|
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE
|
||||||
&& (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL))
|
&& (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL))
|
||||||
{
|
{
|
||||||
gFoundCDCSS = false;
|
gFoundCDCSS = false;
|
||||||
}
|
}
|
||||||
@@ -936,17 +936,17 @@ void APP_Update(void)
|
|||||||
gEeprom.BATTERY_SAVE == 0 ||
|
gEeprom.BATTERY_SAVE == 0 ||
|
||||||
gScanStateDir != SCAN_OFF ||
|
gScanStateDir != SCAN_OFF ||
|
||||||
gCssBackgroundScan ||
|
gCssBackgroundScan ||
|
||||||
gScreenToDisplay != DISPLAY_MAIN
|
gScreenToDisplay != DISPLAY_MAIN
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
|| gFmRadioMode
|
|| gFmRadioMode
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
|
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
|
||||||
#endif
|
#endif
|
||||||
){
|
){
|
||||||
gBatterySaveCountdown_10ms = battery_save_count_10ms;
|
gBatterySaveCountdown_10ms = battery_save_count_10ms;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if ((!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
|
if ((!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
|
||||||
#endif
|
#endif
|
||||||
@@ -965,12 +965,12 @@ void APP_Update(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE
|
if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
&& gVoiceWriteIndex == 0
|
&& gVoiceWriteIndex == 0
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
static bool goToSleep;
|
static bool goToSleep;
|
||||||
// wake up, enable RX then go back to sleep
|
// wake up, enable RX then go back to sleep
|
||||||
if (gRxIdleMode)
|
if (gRxIdleMode)
|
||||||
@@ -1025,13 +1025,13 @@ void APP_Update(void)
|
|||||||
static void CheckKeys(void)
|
static void CheckKeys(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (0
|
if (0
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|| gSetting_KILLED
|
|| gSetting_KILLED
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
|| (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)
|
|| (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1074,7 +1074,7 @@ static void CheckKeys(void)
|
|||||||
boot_counter_10ms = 0; // cancel boot screen/beeps if any key pressed
|
boot_counter_10ms = 0; // cancel boot screen/beeps if any key pressed
|
||||||
|
|
||||||
if (gKeyReading0 != Key) // new key pressed
|
if (gKeyReading0 != Key) // new key pressed
|
||||||
{
|
{
|
||||||
|
|
||||||
if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID)
|
if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID)
|
||||||
ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key
|
ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key
|
||||||
@@ -1087,7 +1087,7 @@ static void CheckKeys(void)
|
|||||||
gDebounceCounter++;
|
gDebounceCounter++;
|
||||||
|
|
||||||
if (gDebounceCounter == key_debounce_10ms) // debounced new key pressed
|
if (gDebounceCounter == key_debounce_10ms) // debounced new key pressed
|
||||||
{
|
{
|
||||||
if (Key == KEY_INVALID) //all non PTT keys released
|
if (Key == KEY_INVALID) //all non PTT keys released
|
||||||
{
|
{
|
||||||
if (gKeyReading1 != KEY_INVALID) // some button was pressed before
|
if (gKeyReading1 != KEY_INVALID) // some button was pressed before
|
||||||
@@ -1110,7 +1110,7 @@ static void CheckKeys(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (gDebounceCounter == key_repeat_delay_10ms) //initial key repeat with longer delay
|
if (gDebounceCounter == key_repeat_delay_10ms) //initial key repeat with longer delay
|
||||||
{
|
{
|
||||||
if (Key != KEY_PTT)
|
if (Key != KEY_PTT)
|
||||||
{
|
{
|
||||||
gKeyBeingHeld = true;
|
gKeyBeingHeld = true;
|
||||||
@@ -1118,7 +1118,7 @@ static void CheckKeys(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //subsequent fast key repeats
|
else //subsequent fast key repeats
|
||||||
{
|
{
|
||||||
if (Key == KEY_UP || Key == KEY_DOWN) // fast key repeats for up/down buttons
|
if (Key == KEY_UP || Key == KEY_DOWN) // fast key repeats for up/down buttons
|
||||||
{
|
{
|
||||||
gKeyBeingHeld = true;
|
gKeyBeingHeld = true;
|
||||||
@@ -1135,25 +1135,28 @@ static void CheckKeys(void)
|
|||||||
|
|
||||||
void APP_TimeSlice10ms(void)
|
void APP_TimeSlice10ms(void)
|
||||||
{
|
{
|
||||||
|
gNextTimeslice = false;
|
||||||
gFlashLightBlinkCounter++;
|
gFlashLightBlinkCounter++;
|
||||||
|
|
||||||
#ifdef ENABLE_BOOT_BEEPS
|
#ifdef ENABLE_BOOT_BEEPS
|
||||||
if (boot_counter_10ms > 0)
|
if (boot_counter_10ms > 0 && (boot_counter_10ms % 25) == 0) {
|
||||||
if ((boot_counter_10ms % 25) == 0)
|
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
|
||||||
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
if (gRxVfo->Modulation == MODULATION_AM)
|
if (gRxVfo->Modulation == MODULATION_AM) {
|
||||||
AM_fix_10ms(gEeprom.RX_VFO);
|
AM_fix_10ms(gEeprom.RX_VFO);
|
||||||
#endif
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (UART_IsCommandAvailable())
|
#ifdef ENABLE_UART
|
||||||
{
|
if (UART_IsCommandAvailable()) {
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
UART_HandleCommand();
|
UART_HandleCommand();
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (gReducedService)
|
if (gReducedService)
|
||||||
return;
|
return;
|
||||||
@@ -1276,9 +1279,9 @@ void APP_TimeSlice10ms(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
SCANNER_TimeSlice10ms();
|
SCANNER_TimeSlice10ms();
|
||||||
|
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1)
|
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1)
|
||||||
{
|
{
|
||||||
@@ -1315,6 +1318,7 @@ void cancelUserInputModes(void)
|
|||||||
// this is called once every 500ms
|
// this is called once every 500ms
|
||||||
void APP_TimeSlice500ms(void)
|
void APP_TimeSlice500ms(void)
|
||||||
{
|
{
|
||||||
|
gNextTimeslice_500ms = false;
|
||||||
bool exit_menu = false;
|
bool exit_menu = false;
|
||||||
|
|
||||||
// Skipped authentic device check
|
// Skipped authentic device check
|
||||||
@@ -1419,7 +1423,7 @@ void APP_TimeSlice500ms(void)
|
|||||||
BATTERY_GetReadings(true);
|
BATTERY_GetReadings(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// regular display updates (once every 2 sec) - if need be
|
// regular display updates (once every 2 sec) - if need be
|
||||||
if ((gBatteryCheckCounter & 3) == 0)
|
if ((gBatteryCheckCounter & 3) == 0)
|
||||||
{
|
{
|
||||||
@@ -1431,23 +1435,22 @@ void APP_TimeSlice500ms(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
if (!gCssBackgroundScan
|
||||||
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && !gCssBackgroundScan)
|
#ifdef ENABLE_FMRADIO
|
||||||
#else
|
&& (gFM_ScanState == FM_SCAN_OFF || gAskToSave)
|
||||||
if (!gCssBackgroundScan)
|
#endif
|
||||||
#endif
|
) {
|
||||||
{
|
if (gScanStateDir == SCAN_OFF && !SCANNER_IsScanning()
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
if (gScanStateDir == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && !SCANNER_IsScanning())
|
&& gScreenToDisplay != DISPLAY_AIRCOPY
|
||||||
#else
|
#endif
|
||||||
if (gScanStateDir == SCAN_OFF && !SCANNER_IsScanning())
|
) {
|
||||||
#endif
|
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode && gScreenToDisplay != DISPLAY_MENU) {
|
||||||
{
|
if (--gKeyLockCountdown == 0) {
|
||||||
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode && gScreenToDisplay != DISPLAY_MENU)
|
|
||||||
{
|
|
||||||
if (--gKeyLockCountdown == 0)
|
|
||||||
gEeprom.KEY_LOCK = true; // lock the keyboard
|
gEeprom.KEY_LOCK = true; // lock the keyboard
|
||||||
gUpdateStatus = true; // lock symbol needs showing
|
gUpdateStatus = true; // lock symbol needs showing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exit_menu)
|
if (exit_menu)
|
||||||
@@ -1483,25 +1486,25 @@ void APP_TimeSlice500ms(void)
|
|||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
|
|
||||||
{
|
GUI_DisplayType_t disp = DISPLAY_INVALID;
|
||||||
GUI_DisplayType_t disp = DISPLAY_INVALID;
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFmRadioMode && ! FUNCTION_IsRx()) {
|
if (gFmRadioMode && ! FUNCTION_IsRx()) {
|
||||||
disp = DISPLAY_FM;
|
disp = DISPLAY_FM;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (disp == DISPLAY_INVALID)
|
|
||||||
{
|
|
||||||
#ifndef ENABLE_NO_CODE_SCAN_TIMEOUT
|
|
||||||
if (!SCANNER_IsScanning())
|
|
||||||
#endif
|
#endif
|
||||||
disp = DISPLAY_MAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disp != DISPLAY_INVALID)
|
if (disp == DISPLAY_INVALID) {
|
||||||
GUI_SelectNextDisplay(disp);
|
#ifndef ENABLE_NO_CODE_SCAN_TIMEOUT
|
||||||
|
if (!SCANNER_IsScanning())
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
disp = DISPLAY_MAIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disp != DISPLAY_INVALID) {
|
||||||
|
GUI_SelectNextDisplay(disp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1518,7 +1521,7 @@ void APP_TimeSlice500ms(void)
|
|||||||
FM_Start();
|
FM_Start();
|
||||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1649,7 +1652,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
!(Key == KEY_PTT && !(gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX))
|
!(Key == KEY_PTT && !(gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX))
|
||||||
// not in the backlight menu
|
// not in the backlight menu
|
||||||
&& !(gScreenToDisplay == DISPLAY_MENU && ( m == MENU_ABR || m == MENU_ABR_MAX || m == MENU_ABR_MIN))
|
&& !(gScreenToDisplay == DISPLAY_MENU && ( m == MENU_ABR || m == MENU_ABR_MAX || m == MENU_ABR_MIN))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BACKLIGHT_TurnOn();
|
BACKLIGHT_TurnOn();
|
||||||
}
|
}
|
||||||
@@ -1667,7 +1670,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
// cancel user input
|
// cancel user input
|
||||||
cancelUserInputModes();
|
cancelUserInputModes();
|
||||||
|
|
||||||
if (gMonitor)
|
if (gMonitor)
|
||||||
ACTION_Monitor(); //turn off the monitor
|
ACTION_Monitor(); //turn off the monitor
|
||||||
#ifdef ENABLE_SCAN_RANGES
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
@@ -1705,7 +1708,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Key == KEY_F)
|
if (Key == KEY_F)
|
||||||
{ // function/key-lock key
|
{ // function/key-lock key
|
||||||
@@ -1779,100 +1782,98 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bFlag)
|
if (bFlag) {
|
||||||
{
|
goto Skip;
|
||||||
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
}
|
||||||
{ // transmitting
|
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_TRANSMIT) {
|
||||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
if (gAlarmState == ALARM_STATE_OFF)
|
if (gAlarmState == ALARM_STATE_OFF)
|
||||||
#endif
|
|
||||||
{
|
|
||||||
char Code;
|
|
||||||
|
|
||||||
if (Key == KEY_PTT)
|
|
||||||
{
|
|
||||||
GENERIC_Key_PTT(bKeyPressed);
|
|
||||||
goto Skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Key == KEY_SIDE2)
|
|
||||||
{ // transmit 1750Hz tone
|
|
||||||
Code = 0xFE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Code = DTMF_GetCharacter(Key - KEY_0);
|
|
||||||
if (Code == 0xFF)
|
|
||||||
goto Skip;
|
|
||||||
|
|
||||||
// transmit DTMF keys
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bKeyPressed || bKeyHeld)
|
|
||||||
{
|
|
||||||
if (!bKeyPressed)
|
|
||||||
{
|
|
||||||
AUDIO_AudioPathOff();
|
|
||||||
|
|
||||||
gEnableSpeaker = false;
|
|
||||||
|
|
||||||
BK4819_ExitDTMF_TX(false);
|
|
||||||
|
|
||||||
if (gCurrentVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable)
|
|
||||||
BK4819_DisableScramble();
|
|
||||||
else
|
|
||||||
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (gEeprom.DTMF_SIDE_TONE)
|
|
||||||
{ // user will here the DTMF tones in speaker
|
|
||||||
AUDIO_AudioPathOn();
|
|
||||||
gEnableSpeaker = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BK4819_DisableScramble();
|
|
||||||
|
|
||||||
if (Code == 0xFE)
|
|
||||||
BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 1750);
|
|
||||||
else
|
|
||||||
BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
|
||||||
else if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed))
|
|
||||||
{
|
|
||||||
ALARM_Off();
|
|
||||||
|
|
||||||
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
|
|
||||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
|
||||||
else
|
|
||||||
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
|
|
||||||
|
|
||||||
if (Key == KEY_PTT)
|
|
||||||
gPttWasPressed = true;
|
|
||||||
else
|
|
||||||
if (!bKeyHeld)
|
|
||||||
gPttWasReleased = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) {
|
|
||||||
ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#ifdef ENABLE_AIRCOPY
|
|
||||||
if (!SCANNER_IsScanning() && gScreenToDisplay != DISPLAY_AIRCOPY)
|
|
||||||
#else
|
|
||||||
if (!SCANNER_IsScanning())
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ACTION_Handle(Key, bKeyPressed, bKeyHeld);
|
char Code;
|
||||||
|
|
||||||
|
if (Key == KEY_PTT)
|
||||||
|
{
|
||||||
|
GENERIC_Key_PTT(bKeyPressed);
|
||||||
|
goto Skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Key == KEY_SIDE2)
|
||||||
|
{ // transmit 1750Hz tone
|
||||||
|
Code = 0xFE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Code = DTMF_GetCharacter(Key - KEY_0);
|
||||||
|
if (Code == 0xFF)
|
||||||
|
goto Skip;
|
||||||
|
|
||||||
|
// transmit DTMF keys
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bKeyPressed || bKeyHeld)
|
||||||
|
{
|
||||||
|
if (!bKeyPressed)
|
||||||
|
{
|
||||||
|
AUDIO_AudioPathOff();
|
||||||
|
|
||||||
|
gEnableSpeaker = false;
|
||||||
|
|
||||||
|
BK4819_ExitDTMF_TX(false);
|
||||||
|
|
||||||
|
if (gCurrentVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable)
|
||||||
|
BK4819_DisableScramble();
|
||||||
|
else
|
||||||
|
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (gEeprom.DTMF_SIDE_TONE)
|
||||||
|
{ // user will here the DTMF tones in speaker
|
||||||
|
AUDIO_AudioPathOn();
|
||||||
|
gEnableSpeaker = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BK4819_DisableScramble();
|
||||||
|
|
||||||
|
if (Code == 0xFE)
|
||||||
|
BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 1750);
|
||||||
|
else
|
||||||
|
BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!bKeyHeld && bKeyPressed)
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
else if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed)) {
|
||||||
|
ALARM_Off();
|
||||||
|
|
||||||
|
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
|
||||||
|
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||||
|
else
|
||||||
|
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
|
||||||
|
|
||||||
|
if (Key == KEY_PTT)
|
||||||
|
gPttWasPressed = true;
|
||||||
|
else
|
||||||
|
if (!bKeyHeld)
|
||||||
|
gPttWasReleased = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) {
|
||||||
|
ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld);
|
||||||
|
}
|
||||||
|
else if (!SCANNER_IsScanning()
|
||||||
|
#ifdef ENABLE_AIRCOPY
|
||||||
|
&& gScreenToDisplay != DISPLAY_AIRCOPY
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
ACTION_Handle(Key, bKeyPressed, bKeyHeld);
|
||||||
|
}
|
||||||
|
else if (!bKeyHeld && bKeyPressed) {
|
||||||
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skip:
|
Skip:
|
||||||
@@ -1902,24 +1903,24 @@ Skip:
|
|||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gRequestSaveFM)
|
if (gRequestSaveFM)
|
||||||
{
|
{
|
||||||
if (!bKeyHeld)
|
gRequestSaveFM = false;
|
||||||
SETTINGS_SaveFM();
|
if (!bKeyHeld)
|
||||||
else
|
SETTINGS_SaveFM();
|
||||||
gFlagSaveFM = true;
|
else
|
||||||
gRequestSaveFM = false;
|
gFlagSaveFM = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gRequestSaveVFO)
|
if (gRequestSaveVFO)
|
||||||
{
|
{
|
||||||
|
gRequestSaveVFO = false;
|
||||||
if (!bKeyHeld)
|
if (!bKeyHeld)
|
||||||
SETTINGS_SaveVfoIndices();
|
SETTINGS_SaveVfoIndices();
|
||||||
else
|
else
|
||||||
gFlagSaveVfo = true;
|
gFlagSaveVfo = true;
|
||||||
gRequestSaveVFO = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gRequestSaveChannel > 0) // TODO: remove the gRequestSaveChannel, why use global variable for that??
|
if (gRequestSaveChannel > 0) // TODO: remove the gRequestSaveChannel, why use global variable for that??
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ bool DTMF_GetContact(const int Index, char *pContact)
|
|||||||
EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
|
EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
|
||||||
i = (int)pContact[0] - ' ';
|
i = (int)pContact[0] - ' ';
|
||||||
}
|
}
|
||||||
return (i < 0 || i >= 95) ? false : true;
|
return (i >= 0 && i < 95);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DTMF_FindContact(const char *pContact, char *pResult)
|
bool DTMF_FindContact(const char *pContact, char *pResult)
|
||||||
@@ -130,7 +130,7 @@ bool DTMF_FindContact(const char *pContact, char *pResult)
|
|||||||
|
|
||||||
if (j == 3)
|
if (j == 3)
|
||||||
{
|
{
|
||||||
memmove(pResult, Contact, 8);
|
memcpy(pResult, Contact, 8);
|
||||||
pResult[8] = 0;
|
pResult[8] = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -361,8 +361,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();
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,9 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
|
|||||||
}
|
}
|
||||||
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;
|
||||||
@@ -221,17 +223,24 @@ start_tx:
|
|||||||
// request start TX
|
// request start TX
|
||||||
gFlagPrepareTX = true;
|
gFlagPrepareTX = true;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -622,7 +625,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
|||||||
)
|
)
|
||||||
{ // start entering a DTMF string
|
{ // start entering a DTMF string
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
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;
|
||||||
|
|
||||||
|
|||||||
13
app/menu.c
13
app/menu.c
@@ -681,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;
|
||||||
@@ -1339,6 +1339,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)
|
||||||
@@ -1436,7 +1440,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;
|
||||||
}
|
}
|
||||||
@@ -1624,7 +1628,10 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
|||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|||||||
143
app/spectrum.c
143
app/spectrum.c
@@ -13,10 +13,14 @@
|
|||||||
* 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 "am_fix.h"
|
#include "am_fix.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
#include "chFrScanner.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "driver/backlight.h"
|
#include "driver/backlight.h"
|
||||||
#include "frequencies.h"
|
#include "frequencies.h"
|
||||||
#include "ui/helper.h"
|
#include "ui/helper.h"
|
||||||
@@ -53,6 +57,11 @@ 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};
|
||||||
@@ -260,12 +269,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() {
|
||||||
@@ -352,6 +373,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() {
|
||||||
@@ -398,7 +423,20 @@ static void UpdatePeakInfo() {
|
|||||||
UpdatePeakInfoForce();
|
UpdatePeakInfoForce();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Measure() { rssiHistory[scanInfo.i] = scanInfo.rssi = GetRssi(); }
|
static void Measure()
|
||||||
|
{
|
||||||
|
uint16_t rssi = scanInfo.rssi = GetRssi();
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(scanInfo.measurementsCount > 128) {
|
||||||
|
uint8_t idx = (uint32_t)ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * scanInfo.i / 1000;
|
||||||
|
if(rssiHistory[idx] < rssi || isListening)
|
||||||
|
rssiHistory[idx] = rssi;
|
||||||
|
rssiHistory[(idx+1)%128] = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
rssiHistory[scanInfo.i] = rssi;
|
||||||
|
}
|
||||||
|
|
||||||
// Update things by keypress
|
// Update things by keypress
|
||||||
|
|
||||||
@@ -595,12 +633,25 @@ static void UpdateFreqInput(KEY_Code_t key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Blacklist() {
|
static void Blacklist() {
|
||||||
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
blacklistFreqs[blacklistFreqsIdx++ % ARRAY_SIZE(blacklistFreqs)] = peak.i;
|
||||||
|
#endif
|
||||||
rssiHistory[peak.i] = RSSI_MAX_VALUE;
|
rssiHistory[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
|
||||||
@@ -710,9 +761,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);
|
||||||
@@ -764,10 +817,16 @@ static void OnKeyDown(uint8_t key) {
|
|||||||
UpdateFreqChangeStep(false);
|
UpdateFreqChangeStep(false);
|
||||||
break;
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
UpdateCurrentFreq(true);
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(!gScanRangeStart)
|
||||||
|
#endif
|
||||||
|
UpdateCurrentFreq(true);
|
||||||
break;
|
break;
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
UpdateCurrentFreq(false);
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(!gScanRangeStart)
|
||||||
|
#endif
|
||||||
|
UpdateCurrentFreq(false);
|
||||||
break;
|
break;
|
||||||
case KEY_SIDE1:
|
case KEY_SIDE1:
|
||||||
Blacklist();
|
Blacklist();
|
||||||
@@ -779,7 +838,10 @@ static void OnKeyDown(uint8_t key) {
|
|||||||
UpdateRssiTriggerLevel(false);
|
UpdateRssiTriggerLevel(false);
|
||||||
break;
|
break;
|
||||||
case KEY_5:
|
case KEY_5:
|
||||||
FreqInput();
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(!gScanRangeStart)
|
||||||
|
#endif
|
||||||
|
FreqInput();
|
||||||
break;
|
break;
|
||||||
case KEY_0:
|
case KEY_0:
|
||||||
ToggleModulation();
|
ToggleModulation();
|
||||||
@@ -788,7 +850,10 @@ static void OnKeyDown(uint8_t key) {
|
|||||||
ToggleListeningBW();
|
ToggleListeningBW();
|
||||||
break;
|
break;
|
||||||
case KEY_4:
|
case KEY_4:
|
||||||
ToggleStepsCount();
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
|
if(!gScanRangeStart)
|
||||||
|
#endif
|
||||||
|
ToggleStepsCount();
|
||||||
break;
|
break;
|
||||||
case KEY_SIDE2:
|
case KEY_SIDE2:
|
||||||
ToggleBacklight();
|
ToggleBacklight();
|
||||||
@@ -932,7 +997,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);
|
||||||
@@ -1049,7 +1114,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();
|
||||||
@@ -1070,6 +1139,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;
|
||||||
|
|
||||||
@@ -1122,7 +1195,7 @@ static void UpdateListening() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ToggleRX(false);
|
ToggleRX(false);
|
||||||
newScanStart = true;
|
ResetScanStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Tick() {
|
static void Tick() {
|
||||||
@@ -1135,6 +1208,26 @@ static void Tick() {
|
|||||||
}
|
}
|
||||||
#endif
|
#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();
|
||||||
}
|
}
|
||||||
@@ -1166,18 +1259,32 @@ void APP_RunSpectrum() {
|
|||||||
// TX here coz it always? set to active VFO
|
// TX here coz it always? set to active VFO
|
||||||
vfo = gEeprom.TX_VFO;
|
vfo = gEeprom.TX_VFO;
|
||||||
// set the current frequency in the middle of the display
|
// set the current frequency in the middle of the display
|
||||||
currentFreq = initialFreq = gEeprom.VfoInfo[vfo].pRX->Frequency -
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
((GetStepsCount() / 2) * GetScanStep());
|
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 = gRxVfo->Modulation);
|
RADIO_SetModulation(settings.modulationType = gTxVfo->Modulation);
|
||||||
|
|
||||||
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
|
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
|
||||||
|
|
||||||
|
|||||||
@@ -45,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[] = {
|
||||||
@@ -110,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;
|
||||||
|
|
||||||
@@ -136,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);
|
||||||
|
|||||||
@@ -487,11 +487,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)
|
||||||
|
|||||||
2
audio.c
2
audio.c
@@ -205,7 +205,7 @@ volatile bool gFlagPlayQueuedVoice;
|
|||||||
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID;
|
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID;
|
||||||
|
|
||||||
|
|
||||||
void AUDIO_PlayVoice(uint8_t VoiceID)
|
static void AUDIO_PlayVoice(uint8_t VoiceID)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
|||||||
2
audio.h
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
|
||||||
|
|
||||||
|
|||||||
14
board.c
14
board.c
@@ -50,10 +50,10 @@
|
|||||||
FLASH_Init(FLASH_READ_MODE_1_CYCLE);
|
FLASH_Init(FLASH_READ_MODE_1_CYCLE);
|
||||||
FLASH_ConfigureTrimValues();
|
FLASH_ConfigureTrimValues();
|
||||||
SYSTEM_ConfigureClocks();
|
SYSTEM_ConfigureClocks();
|
||||||
|
|
||||||
overlay_FLASH_MainClock = 48000000;
|
overlay_FLASH_MainClock = 48000000;
|
||||||
overlay_FLASH_ClockMultiplier = 48;
|
overlay_FLASH_ClockMultiplier = 48;
|
||||||
|
|
||||||
FLASH_Init(FLASH_READ_MODE_2_CYCLE);
|
FLASH_Init(FLASH_READ_MODE_2_CYCLE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -494,10 +494,12 @@ void BOARD_Init(void)
|
|||||||
BACKLIGHT_InitHardware();
|
BACKLIGHT_InitHardware();
|
||||||
BOARD_ADC_Init();
|
BOARD_ADC_Init();
|
||||||
ST7565_Init();
|
ST7565_Init();
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
BK1080_Init(0, false);
|
BK1080_Init(0, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_UART) || defined(ENABLED_AIRCOPY)
|
||||||
CRC_Init();
|
CRC_Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
33
debugging.h
33
debugging.h
@@ -1,35 +1,38 @@
|
|||||||
#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 "driver/bk4819.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "external/printf/printf.h"
|
#include "external/printf/printf.h"
|
||||||
#include "am_fix.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 LogRegUart(uint16_t reg)
|
static inline void LogRegUart(uint16_t reg)
|
||||||
{
|
{
|
||||||
uint16_t regVal = BK4819_ReadRegister(reg);
|
uint16_t regVal = BK4819_ReadRegister(reg);
|
||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf(buf, "reg%02X: %04X\n", reg, regVal);
|
sprintf(buf, "reg%02X: %04X\n", reg, regVal);
|
||||||
LogUart(buf);
|
LogUart(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void LogPrint()
|
static inline void LogPrint()
|
||||||
{
|
{
|
||||||
uint16_t rssi = BK4819_GetRSSI();
|
uint16_t rssi = BK4819_GetRSSI();
|
||||||
uint16_t reg7e = BK4819_ReadRegister(0x7E);
|
uint16_t reg7e = BK4819_ReadRegister(0x7E);
|
||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n",
|
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", (reg7e >> 15),
|
||||||
(reg7e >> 15), (reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111, (reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
|
(reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111,
|
||||||
LogUart(buf);
|
(reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
|
||||||
|
LogUart(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -67,12 +67,12 @@ void BACKLIGHT_TurnOn(void)
|
|||||||
case 1: // 5 sec
|
case 1: // 5 sec
|
||||||
case 2: // 10 sec
|
case 2: // 10 sec
|
||||||
case 3: // 20 sec
|
case 3: // 20 sec
|
||||||
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 1)) * 10;
|
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 1)) * 5;
|
||||||
break;
|
break;
|
||||||
case 4: // 1 min
|
case 4: // 1 min
|
||||||
case 5: // 2 min
|
case 5: // 2 min
|
||||||
case 6: // 4 min
|
case 6: // 4 min
|
||||||
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 4)) * 120;
|
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 4)) * 60;
|
||||||
break;
|
break;
|
||||||
case 7: // always on
|
case 7: // always on
|
||||||
gBacklightCountdown_500ms = 0;
|
gBacklightCountdown_500ms = 0;
|
||||||
@@ -103,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;
|
||||||
|
}
|
||||||
@@ -36,5 +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
|
||||||
|
|||||||
@@ -16,13 +16,15 @@
|
|||||||
|
|
||||||
#include <stdio.h> // NULL
|
#include <stdio.h> // NULL
|
||||||
|
|
||||||
#include "audio.h"
|
#include "../audio.h"
|
||||||
|
#include "../bsp/dp32g030/gpio.h"
|
||||||
|
#include "../bsp/dp32g030/portcon.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]))
|
||||||
@@ -127,7 +129,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++)
|
||||||
{
|
{
|
||||||
@@ -712,10 +713,13 @@ void BK4819_SetupPowerAmplifier(const uint8_t bias, const uint32_t frequency)
|
|||||||
// 7 = max
|
// 7 = max
|
||||||
// 0 = min
|
// 0 = min
|
||||||
//
|
//
|
||||||
// 280MHz g1=1 g2=0 (-14.9dBm), g1=4 g2=2 (0.13dBm)
|
// 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);
|
uint8_t gain = (frequency < 28000000) ? (1u << 3) | (0u << 0) : (4u << 3) | (2u << 0);
|
||||||
|
gain = 0b000010;
|
||||||
|
(void)bias;
|
||||||
|
(void)frequency;
|
||||||
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, (16 << 8) | (enable << 7) | (gain << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK4819_SetFrequency(uint32_t Frequency)
|
void BK4819_SetFrequency(uint32_t Frequency)
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
reg = reg2;
|
||||||
{ // noise
|
|
||||||
reg = reg2;
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < 3)
|
if (i < 3)
|
||||||
break; // noise is too bad
|
break; // noise is too bad
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -29,17 +29,21 @@ 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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,35 +65,38 @@ const freq_band_table_t frequencyBandTable[] =
|
|||||||
// this order of steps has to be preserved for backwards compatibility with other/stock firmwares
|
// this order of steps has to be preserved for backwards compatibility with other/stock firmwares
|
||||||
const uint16_t gStepFrequencyTable[] = {
|
const uint16_t gStepFrequencyTable[] = {
|
||||||
// standard steps
|
// standard steps
|
||||||
[STEP_2_5kHz] = 250,
|
[STEP_2_5kHz] = 250,
|
||||||
[STEP_5kHz] = 500,
|
[STEP_5kHz] = 500,
|
||||||
[STEP_6_25kHz] = 625,
|
[STEP_6_25kHz] = 625,
|
||||||
[STEP_10kHz] = 1000,
|
[STEP_10kHz] = 1000,
|
||||||
[STEP_12_5kHz] = 1250,
|
[STEP_12_5kHz] = 1250,
|
||||||
[STEP_25kHz] = 2500,
|
[STEP_25kHz] = 2500,
|
||||||
[STEP_8_33kHz] = 833,
|
[STEP_8_33kHz] = 833,
|
||||||
// custom steps
|
// custom steps
|
||||||
[STEP_0_01kHz] = 1,
|
[STEP_0_01kHz] = 1,
|
||||||
[STEP_0_05kHz] = 5,
|
[STEP_0_05kHz] = 5,
|
||||||
[STEP_0_1kHz] = 10,
|
[STEP_0_1kHz] = 10,
|
||||||
[STEP_0_25kHz] = 25,
|
[STEP_0_25kHz] = 25,
|
||||||
[STEP_0_5kHz] = 50,
|
[STEP_0_5kHz] = 50,
|
||||||
[STEP_1kHz] = 100,
|
[STEP_1kHz] = 100,
|
||||||
[STEP_1_25kHz] = 125,
|
[STEP_1_25kHz] = 125,
|
||||||
[STEP_15kHz] = 1500,
|
[STEP_9kHz] = 900,
|
||||||
[STEP_30kHz] = 3000,
|
[STEP_15kHz] = 1500,
|
||||||
[STEP_50kHz] = 5000,
|
[STEP_20kHz] = 2000,
|
||||||
[STEP_100kHz] = 10000,
|
[STEP_30kHz] = 3000,
|
||||||
[STEP_125kHz] = 12500,
|
[STEP_50kHz] = 5000,
|
||||||
[STEP_250kHz] = 25000,
|
[STEP_100kHz] = 10000,
|
||||||
|
[STEP_125kHz] = 12500,
|
||||||
|
[STEP_200kHz] = 20000,
|
||||||
|
[STEP_250kHz] = 25000,
|
||||||
[STEP_500kHz] = 50000
|
[STEP_500kHz] = 50000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const STEP_Setting_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
|
||||||
};
|
};
|
||||||
|
|
||||||
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx)
|
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx)
|
||||||
|
|||||||
@@ -45,27 +45,30 @@ extern const freq_band_table_t frequencyBandTable[];
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
// standard steps
|
// standard steps
|
||||||
STEP_2_5kHz,
|
STEP_2_5kHz,
|
||||||
STEP_5kHz,
|
STEP_5kHz,
|
||||||
STEP_6_25kHz,
|
STEP_6_25kHz,
|
||||||
STEP_10kHz,
|
STEP_10kHz,
|
||||||
STEP_12_5kHz,
|
STEP_12_5kHz,
|
||||||
STEP_25kHz,
|
STEP_25kHz,
|
||||||
STEP_8_33kHz,
|
STEP_8_33kHz,
|
||||||
// custom steps
|
// custom steps
|
||||||
STEP_0_01kHz,
|
STEP_0_01kHz,
|
||||||
STEP_0_05kHz,
|
STEP_0_05kHz,
|
||||||
STEP_0_1kHz,
|
STEP_0_1kHz,
|
||||||
STEP_0_25kHz,
|
STEP_0_25kHz,
|
||||||
STEP_0_5kHz,
|
STEP_0_5kHz,
|
||||||
STEP_1kHz,
|
STEP_1kHz,
|
||||||
STEP_1_25kHz,
|
STEP_1_25kHz,
|
||||||
|
STEP_9kHz,
|
||||||
STEP_15kHz,
|
STEP_15kHz,
|
||||||
STEP_30kHz,
|
STEP_20kHz,
|
||||||
STEP_50kHz,
|
STEP_30kHz,
|
||||||
STEP_100kHz,
|
STEP_50kHz,
|
||||||
STEP_125kHz,
|
STEP_100kHz,
|
||||||
STEP_250kHz,
|
STEP_125kHz,
|
||||||
|
STEP_200kHz,
|
||||||
|
STEP_250kHz,
|
||||||
STEP_500kHz,
|
STEP_500kHz,
|
||||||
STEP_N_ELEM
|
STEP_N_ELEM
|
||||||
} STEP_Setting_t;
|
} STEP_Setting_t;
|
||||||
|
|||||||
160
helper/battery.c
160
helper/battery.c
@@ -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;
|
|
||||||
const uint16_t(*crv)[2];
|
|
||||||
uint8_t size;
|
|
||||||
if (type == BATTERY_TYPE_2200_MAH) {
|
|
||||||
crv = crv2200;
|
|
||||||
size = ARRAY_SIZE(crv2200);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
crv = crv1600;
|
|
||||||
size = ARRAY_SIZE(crv1600);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static_assert(ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_1600_MAH]) ==
|
||||||
|
ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_2200_MAH]));
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
@@ -116,7 +113,7 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
|
|||||||
gBatteryDisplayLevel = i;
|
gBatteryDisplayLevel = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -160,7 +157,7 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
|
|||||||
if (bDisplayBatteryLevel)
|
if (bDisplayBatteryLevel)
|
||||||
UI_DisplayBattery(gBatteryDisplayLevel, gLowBatteryBlink);
|
UI_DisplayBattery(gBatteryDisplayLevel, gLowBatteryBlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!gLowBatteryConfirmed)
|
if(!gLowBatteryConfirmed)
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
|
|
||||||
@@ -168,56 +165,61 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BATTERY_TimeSlice500ms(void)
|
void BATTERY_TimeSlice500ms(void)
|
||||||
{
|
{
|
||||||
if (gLowBattery)
|
if (!gLowBattery) {
|
||||||
{
|
return;
|
||||||
gLowBatteryBlink = ++lowBatteryCountdown & 1;
|
|
||||||
|
|
||||||
UI_DisplayBattery(0, gLowBatteryBlink);
|
|
||||||
|
|
||||||
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
|
||||||
{ // not transmitting
|
|
||||||
|
|
||||||
if (lowBatteryCountdown < lowBatteryPeriod)
|
|
||||||
{
|
|
||||||
if (lowBatteryCountdown == lowBatteryPeriod-1 && !gChargingWithTypeC && !gLowBatteryConfirmed)
|
|
||||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lowBatteryCountdown = 0;
|
|
||||||
|
|
||||||
if (!gChargingWithTypeC)
|
|
||||||
{ // not on charge
|
|
||||||
if(!gLowBatteryConfirmed) {
|
|
||||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (gBatteryDisplayLevel == 0)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
AUDIO_PlaySingleVoice(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gReducedService = true;
|
|
||||||
|
|
||||||
//if (gCurrentFunction != FUNCTION_POWER_SAVE)
|
|
||||||
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
|
||||||
|
|
||||||
ST7565_HardwareReset();
|
|
||||||
|
|
||||||
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
|
|
||||||
BACKLIGHT_TurnOff(); // turn the backlight off
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
else
|
|
||||||
AUDIO_PlaySingleVoice(false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
gLowBatteryBlink = ++lowBatteryCountdown & 1;
|
||||||
|
|
||||||
|
UI_DisplayBattery(0, gLowBatteryBlink);
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_TRANSMIT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not transmitting
|
||||||
|
|
||||||
|
if (lowBatteryCountdown < lowBatteryPeriod) {
|
||||||
|
if (lowBatteryCountdown == lowBatteryPeriod-1 && !gChargingWithTypeC && !gLowBatteryConfirmed) {
|
||||||
|
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lowBatteryCountdown = 0;
|
||||||
|
|
||||||
|
if (gChargingWithTypeC) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not on charge
|
||||||
|
if (!gLowBatteryConfirmed) {
|
||||||
|
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gBatteryDisplayLevel != 0) {
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
AUDIO_PlaySingleVoice(false);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
AUDIO_PlaySingleVoice(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gReducedService = true;
|
||||||
|
|
||||||
|
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
||||||
|
|
||||||
|
ST7565_HardwareReset();
|
||||||
|
|
||||||
|
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) {
|
||||||
|
BACKLIGHT_TurnOff();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
BIN
images/codespace1.png
Normal file
BIN
images/codespace1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
BIN
images/codespace2.png
Normal file
BIN
images/codespace2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 122 KiB |
76
main.c
76
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"
|
||||||
#include "driver/uart.h"
|
#ifdef ENABLE_UART
|
||||||
|
#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;
|
||||||
|
|
||||||
@@ -94,17 +103,17 @@ 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);
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
AM_fix_init();
|
AM_fix_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const BOOT_Mode_t BootMode = BOOT_GetMode();
|
||||||
|
|
||||||
BootMode = BOOT_GetMode();
|
|
||||||
|
|
||||||
if (BootMode == BOOT_MODE_F_LOCK)
|
if (BootMode == BOOT_MODE_F_LOCK)
|
||||||
{
|
{
|
||||||
gF_LOCK = true; // flag to say include the hidden menu items
|
gF_LOCK = true; // flag to say include the hidden menu items
|
||||||
@@ -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();
|
||||||
{
|
|
||||||
APP_TimeSlice500ms();
|
if (gNextTimeslice_500ms) {
|
||||||
gNextTimeslice_500ms = false;
|
APP_TimeSlice500ms();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
misc.h
4
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)
|
||||||
|
|||||||
100
radio.c
100
radio.c
@@ -723,53 +723,45 @@ void RADIO_SetupRegisters(bool switchToForeground)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
#ifdef ENABLE_NOAA
|
if (gEeprom.VOX_SWITCH && gCurrentVfo->Modulation == MODULATION_FM
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_NOAA
|
||||||
if (gEeprom.VOX_SWITCH && !gFmRadioMode && !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->Modulation == MODULATION_FM)
|
&& !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE)
|
||||||
#else
|
#endif
|
||||||
if (gEeprom.VOX_SWITCH && !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->Modulation == MODULATION_FM)
|
#ifdef ENABLE_FMRADIO
|
||||||
#endif
|
&& !gFmRadioMode
|
||||||
#else
|
#endif
|
||||||
#ifdef ENABLE_FMRADIO
|
){
|
||||||
if (gEeprom.VOX_SWITCH && !gFmRadioMode && gCurrentVfo->Modulation == MODULATION_FM)
|
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
|
||||||
#else
|
InterruptMask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST;
|
||||||
if (gEeprom.VOX_SWITCH && gCurrentVfo->Modulation == MODULATION_FM)
|
}
|
||||||
#endif
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
|
|
||||||
InterruptMask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#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 0
|
||||||
if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED)
|
if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED)
|
||||||
{
|
{
|
||||||
BK4819_DisableDTMF();
|
BK4819_DisableDTMF();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BK4819_EnableDTMF();
|
BK4819_EnableDTMF();
|
||||||
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
BK4819_DisableDTMF();
|
||||||
{
|
|
||||||
BK4819_DisableDTMF();
|
if (gCurrentFunction != FUNCTION_TRANSMIT) {
|
||||||
BK4819_EnableDTMF();
|
BK4819_EnableDTMF();
|
||||||
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||||
}
|
}
|
||||||
else
|
#endif
|
||||||
{
|
|
||||||
BK4819_DisableDTMF();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RADIO_SetupAGC(gRxVfo->Modulation == MODULATION_AM, false);
|
RADIO_SetupAGC(gRxVfo->Modulation == MODULATION_AM, false);
|
||||||
|
|
||||||
@@ -938,7 +930,7 @@ void RADIO_SetupAGC(bool listeningAM, bool disable)
|
|||||||
BK4819_InitAGC(false);
|
BK4819_InitAGC(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
if(gSetting_AM_fix) { // if AM fix active lock AGC so AM-fix can do it's job
|
if(gSetting_AM_fix) { // if AM fix active lock AGC so AM-fix can do it's job
|
||||||
BK4819_SetAGC(0);
|
BK4819_SetAGC(0);
|
||||||
AM_fix_enable(!disable);
|
AM_fix_enable(!disable);
|
||||||
@@ -1042,15 +1034,12 @@ 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_IsTx = false;
|
|
||||||
gDTMF_CallState = DTMF_CALL_STATE_CALL_OUT;
|
gDTMF_CallState = DTMF_CALL_STATE_CALL_OUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1110,20 +1099,17 @@ void RADIO_SendEndOfTransmission(void)
|
|||||||
{
|
{
|
||||||
if (gEeprom.ROGER == ROGER_MODE_ROGER)
|
if (gEeprom.ROGER == ROGER_MODE_ROGER)
|
||||||
BK4819_PlayRoger();
|
BK4819_PlayRoger();
|
||||||
else
|
else if (gEeprom.ROGER == ROGER_MODE_MDC)
|
||||||
if (gEeprom.ROGER == ROGER_MODE_MDC)
|
|
||||||
BK4819_PlayRogerMDC();
|
BK4819_PlayRogerMDC();
|
||||||
|
|
||||||
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO)
|
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO)
|
||||||
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE);
|
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE);
|
||||||
|
|
||||||
if (
|
if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
gDTMF_CallState == DTMF_CALL_STATE_NONE &&
|
&& gDTMF_CallState == DTMF_CALL_STATE_NONE
|
||||||
#endif
|
#endif
|
||||||
(gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN ||
|
) { // end-of-tx
|
||||||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH))
|
|
||||||
{ // end-of-tx
|
|
||||||
if (gEeprom.DTMF_SIDE_TONE)
|
if (gEeprom.DTMF_SIDE_TONE)
|
||||||
{
|
{
|
||||||
AUDIO_AudioPathOn();
|
AUDIO_AudioPathOn();
|
||||||
|
|||||||
2
radio.h
2
radio.h
@@ -155,7 +155,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int confi
|
|||||||
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
|
||||||
|
|||||||
15
settings.c
15
settings.c
@@ -22,7 +22,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "driver/bk4819.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"
|
#include "ui/menu.h"
|
||||||
@@ -44,6 +43,7 @@ void SETTINGS_InitEEPROM(void)
|
|||||||
uint8_t Data[16];
|
uint8_t Data[16];
|
||||||
|
|
||||||
memset(Data, 0, sizeof(Data));
|
memset(Data, 0, sizeof(Data));
|
||||||
|
memset(&gEeprom, 0, sizeof(gEeprom));
|
||||||
|
|
||||||
// 0E70..0E77
|
// 0E70..0E77
|
||||||
EEPROM_ReadBuffer(0x0E70, Data, 8);
|
EEPROM_ReadBuffer(0x0E70, Data, 8);
|
||||||
@@ -137,8 +137,14 @@ void SETTINGS_InitEEPROM(void)
|
|||||||
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
|
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_RSSI_BAR
|
#ifdef ENABLE_RSSI_BAR
|
||||||
gEeprom.S0_LEVEL = (Data[1] < 0xFF) ? Data[1] : 130;
|
if((Data[1] < 200 && Data[1] > 90) && (Data[2] < Data[1]-9 && Data[1] < 160 && Data[2] > 50)) {
|
||||||
gEeprom.S9_LEVEL = (Data[2] < gEeprom.S0_LEVEL-9) ? Data[2] : 76;
|
gEeprom.S0_LEVEL = Data[1];
|
||||||
|
gEeprom.S9_LEVEL = Data[2];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gEeprom.S0_LEVEL = 130;
|
||||||
|
gEeprom.S9_LEVEL = 76;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 0EA8..0EAF
|
// 0EA8..0EAF
|
||||||
@@ -764,6 +770,9 @@ buf[1] = 0
|
|||||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||||
| (1 << 3)
|
| (1 << 3)
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_AM_FIX
|
||||||
|
| (1 << 4)
|
||||||
|
#endif
|
||||||
;
|
;
|
||||||
EEPROM_WriteBuffer(0x1FF0, buf);
|
EEPROM_WriteBuffer(0x1FF0, buf);
|
||||||
}
|
}
|
||||||
35
ui/battery.c
35
ui/battery.c
@@ -21,30 +21,29 @@
|
|||||||
#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
|
memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2);
|
||||||
memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2);
|
#endif
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
ui/helper.c
10
ui/helper.c
@@ -77,8 +77,8 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
|
|||||||
{
|
{
|
||||||
const unsigned int index = (unsigned int)pString[i] - ' ' - 1;
|
const unsigned int index = (unsigned int)pString[i] - ' ' - 1;
|
||||||
if (index < ARRAY_SIZE(gFontSmall))
|
if (index < ARRAY_SIZE(gFontSmall))
|
||||||
memmove(pFb + (i * char_spacing) + 1, &gFontSmall[index], char_width);
|
memcpy(pFb + (i * char_spacing) + 1, &gFontSmall[index], char_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
|
|||||||
{
|
{
|
||||||
const unsigned int index = (unsigned int)pString[i] - ' ' - 1;
|
const unsigned int index = (unsigned int)pString[i] - ' ' - 1;
|
||||||
if (index < ARRAY_SIZE(gFontSmallBold))
|
if (index < ARRAY_SIZE(gFontSmallBold))
|
||||||
memmove(pFb + (i * char_spacing) + 1, &gFontSmallBold[index], char_width);
|
memcpy(pFb + (i * char_spacing) + 1, &gFontSmallBold[index], char_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer)
|
|||||||
{
|
{
|
||||||
const unsigned int index = (unsigned int)pString[i] - ' ' - 1;
|
const unsigned int index = (unsigned int)pString[i] - ' ' - 1;
|
||||||
if (index < ARRAY_SIZE(gFontSmall))
|
if (index < ARRAY_SIZE(gFontSmall))
|
||||||
memmove(buffer + (i * char_spacing) + 1, &gFontSmall[index], char_width);
|
memcpy(buffer + (i * char_spacing) + 1, &gFontSmall[index], char_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,13 +143,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();
|
||||||
|
|||||||
23
ui/main.c
23
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"
|
||||||
@@ -37,8 +37,6 @@
|
|||||||
#include "ui/main.h"
|
#include "ui/main.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
#include "debugging.h"
|
|
||||||
|
|
||||||
center_line_t center_line = CENTER_LINE_NONE;
|
center_line_t center_line = CENTER_LINE_NONE;
|
||||||
|
|
||||||
const int8_t dBmCorrTable[7] = {
|
const int8_t dBmCorrTable[7] = {
|
||||||
@@ -350,8 +348,7 @@ void UI_DisplayMain(void)
|
|||||||
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_PrintStringSmall(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_PrintStringSmall(String, 56, 0, line + 1);
|
UI_PrintStringSmall(String, 56, 0, line + 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -408,14 +405,14 @@ void UI_DisplayMain(void)
|
|||||||
|
|
||||||
// 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)
|
||||||
@@ -537,14 +534,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
|
||||||
@@ -624,9 +621,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
ui/menu.c
19
ui/menu.c
@@ -426,7 +426,7 @@ 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);
|
||||||
@@ -488,6 +488,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:
|
||||||
@@ -584,7 +590,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:
|
||||||
@@ -592,8 +599,8 @@ 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:
|
||||||
@@ -778,7 +785,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
|
||||||
|
|
||||||
@@ -962,7 +969,7 @@ void UI_DisplayMenu(void)
|
|||||||
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:%s", Contact + 8);
|
||||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
|
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user