Compare commits
408 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f85ed9440d | ||
|
|
604a5b430f | ||
|
|
ed5ebc4854 | ||
|
|
c74c0d20fc | ||
|
|
46e2d1a0fd | ||
|
|
adbc466c49 | ||
|
|
f8ff71aaa3 | ||
|
|
ea3b5b23a9 | ||
|
|
8941576887 | ||
|
|
04b0bd8c93 | ||
|
|
4efabfc2b6 | ||
|
|
9472bbb58b | ||
|
|
685ecb062b | ||
|
|
3bf993d8b8 | ||
|
|
01ccaaf212 | ||
|
|
ed5ae7842b | ||
|
|
ac8c51d605 | ||
|
|
429cffc0bc | ||
|
|
fbdaf6631d | ||
|
|
f8feef1ad5 | ||
|
|
42a45a7ef2 | ||
|
|
3f012b3afe | ||
|
|
289418f1c7 | ||
|
|
ea733115de | ||
|
|
e5cff16d98 | ||
|
|
f35ce8d789 | ||
|
|
36ecde86e9 | ||
|
|
8f6e1be5e0 | ||
|
|
cceba5a474 | ||
|
|
1882ab0cc1 | ||
|
|
995045006f | ||
|
|
38ec40b0db | ||
|
|
cbf4a7c140 | ||
|
|
7a7010da55 | ||
|
|
78a45d9bbd | ||
|
|
f8ef687026 | ||
|
|
1281bbf033 | ||
|
|
edf1f983d6 | ||
|
|
b0d131d546 | ||
|
|
ab61c4e74f | ||
|
|
986c0ce368 | ||
|
|
e929a79765 | ||
|
|
d75209bad0 | ||
|
|
ee0ba9886d | ||
|
|
084fe4dd26 | ||
|
|
a715389a8b | ||
|
|
6f1cabc807 | ||
|
|
a08420a0b7 | ||
|
|
1f4f026162 | ||
|
|
34f2168856 | ||
|
|
bc9bb489e6 | ||
|
|
7d982f1f8d | ||
|
|
2cc60da9ab | ||
|
|
39eb3e835e | ||
|
|
0d66eb8577 | ||
|
|
13b6bb06b2 | ||
|
|
88f3537af0 | ||
|
|
de8c501d65 | ||
|
|
76bbaf9442 | ||
|
|
c4d9cfc895 | ||
|
|
2a75f8a9be | ||
|
|
e7a21c470f | ||
|
|
fc679c77a4 | ||
|
|
1151cf8667 | ||
|
|
af6b542da1 | ||
|
|
cc49a5007c | ||
|
|
a99d2dd1b1 | ||
|
|
9dc79ce868 | ||
|
|
80fa310646 | ||
|
|
7f5236c44e | ||
|
|
4b583bf2bd | ||
|
|
fa5d3c1594 | ||
|
|
1a53586922 | ||
|
|
687b63abb6 | ||
|
|
06f1c651bc | ||
|
|
33e4e3c4e0 | ||
|
|
93b97eff0a | ||
|
|
8638d37431 | ||
|
|
716e9e23b8 | ||
|
|
d0ae34f9b4 | ||
|
|
bd17aea72b | ||
|
|
34d688b101 | ||
|
|
8c7f736797 | ||
|
|
a19579a888 | ||
|
|
00a2bc75b8 | ||
|
|
268c4dece3 | ||
|
|
0c2fc6184c | ||
|
|
6bdce2d0e2 | ||
|
|
42a2e16e0e | ||
|
|
2e69acbdc4 | ||
|
|
eb6a3d0867 | ||
|
|
e22cc4ccd0 | ||
|
|
a153e63be1 | ||
|
|
4322a7d8a9 | ||
|
|
1203fdf0ca | ||
|
|
cfc4763dd1 | ||
|
|
b6a49db31d | ||
|
|
82ddbcd375 | ||
|
|
335c2ec9cd | ||
|
|
4249d917f8 | ||
|
|
2164461449 | ||
|
|
c3906f42f8 | ||
|
|
d055fb0024 | ||
|
|
c4ad9c6501 | ||
|
|
4fd1ab8899 | ||
|
|
0793b68971 | ||
|
|
f7061c3195 | ||
|
|
5e78916dd3 | ||
|
|
13c17ad073 | ||
|
|
c697596806 | ||
|
|
5c1cb4f2fc | ||
|
|
754d2ce5fb | ||
|
|
c76a96c3ad | ||
|
|
cd032c39d2 | ||
|
|
103bdf212f | ||
|
|
bafe372cbc | ||
|
|
88f7b90237 | ||
|
|
66f1f545c3 | ||
|
|
e5659ad6ab | ||
|
|
c1a009cc2f | ||
|
|
e95f577074 | ||
|
|
52bdd408c4 | ||
|
|
ed395ab638 | ||
|
|
86438ef3ce | ||
|
|
f3297c29cb | ||
|
|
e039e65ee4 | ||
|
|
e2b81bf9c8 | ||
|
|
9ca3ccd744 | ||
|
|
d944ff4a34 | ||
|
|
cfa745fda0 | ||
|
|
b505f81958 | ||
|
|
235a1a2f14 | ||
|
|
a4cefe3401 | ||
|
|
5a2086fcd0 | ||
|
|
c341570838 | ||
|
|
292e2e7e7e | ||
|
|
44ff33613a | ||
|
|
f9e10da9ee | ||
|
|
5ad8229d7c | ||
|
|
90609ca5c5 | ||
|
|
59b3251713 | ||
|
|
fbb4d08b88 | ||
|
|
050e04bcfd | ||
|
|
7857e8ed7a | ||
|
|
4c3eb98e31 | ||
|
|
fe49f250b0 | ||
|
|
3c643208ff | ||
|
|
dc47842892 | ||
|
|
9f22e8a9df | ||
|
|
07588853e4 | ||
|
|
199b1a27f1 | ||
|
|
a0d052b68b | ||
|
|
9a3249a667 | ||
|
|
ffdc0e03b5 | ||
|
|
d8d4384b20 | ||
|
|
0ce7d7bdc3 | ||
|
|
fb30ec8c86 | ||
|
|
67307463e2 | ||
|
|
fdd7fc063e | ||
|
|
592810b7d7 | ||
|
|
6e5e7e7aef | ||
|
|
cd0dc71de6 | ||
|
|
a43a3f949f | ||
|
|
d7b6cdf444 | ||
|
|
7916d79ff1 | ||
|
|
49cec54cd3 | ||
|
|
f154aebd38 | ||
|
|
aaa55c5742 | ||
|
|
345f1444f5 | ||
|
|
7e91d67b53 | ||
|
|
ba29176f33 | ||
|
|
05feff432e | ||
|
|
cf4f85cb22 | ||
|
|
a0c2181197 | ||
|
|
b4abf369e1 | ||
|
|
be0636d69b | ||
|
|
23986a8648 | ||
|
|
b1d3a95ca2 | ||
|
|
1238bf090c | ||
|
|
5987e03141 | ||
|
|
c5e34c4be9 | ||
|
|
b0a01cd8cf | ||
|
|
21535c9ca0 | ||
|
|
8c9bdaacbc | ||
|
|
388c3dadf1 | ||
|
|
72fc4bf52f | ||
|
|
def555678d | ||
|
|
16e79bee7d | ||
|
|
9777b5df8b | ||
|
|
c057f8a097 | ||
|
|
034139d7d5 | ||
|
|
03a51525b6 | ||
|
|
f074114d13 | ||
|
|
8a60535f9d | ||
|
|
c2be853ef1 | ||
|
|
9f1e6ab91f | ||
|
|
25334823e5 | ||
|
|
2796973ad3 | ||
|
|
2344478301 | ||
|
|
61527d1281 | ||
|
|
140b5f4b4a | ||
|
|
3e0ea6f7de | ||
|
|
ed64c7fb49 | ||
|
|
d70fa1b7b4 | ||
|
|
a41628410e | ||
|
|
f7c25b482d | ||
|
|
ac3cd08163 | ||
|
|
c1657a37f2 | ||
|
|
a2580d5d8d | ||
|
|
5d4f7529ed | ||
|
|
20a3e3b605 | ||
|
|
f3cc0f5acf | ||
|
|
2086bd6aaa | ||
|
|
3b3db88e5e | ||
|
|
f6791395cc | ||
|
|
8739996668 | ||
|
|
1740583ccc | ||
|
|
b12244e352 | ||
|
|
e6ac0d1d8d | ||
|
|
eda199d47a | ||
|
|
012c375f2e | ||
|
|
4a96dfa6ce | ||
|
|
ec10aec0c4 | ||
|
|
49c2c6b405 | ||
|
|
38b1e5cbaa | ||
|
|
9a64a18010 | ||
|
|
72eddd009b | ||
|
|
77d58eb8f5 | ||
|
|
856dbe083d | ||
|
|
50cc34ad9b | ||
|
|
c996577a0b | ||
|
|
e877820594 | ||
|
|
8ab123c927 | ||
|
|
a510b89c6a | ||
|
|
8b41a1fa66 | ||
|
|
99fc8a8311 | ||
|
|
5c3eea2fcb | ||
|
|
ffb26a1f86 | ||
|
|
a8ae1b7739 | ||
|
|
b59df11bd6 | ||
|
|
146c8dede4 | ||
|
|
c2090676d8 | ||
|
|
b29bae88f1 | ||
|
|
c55a40481d | ||
|
|
a37a1ca6ef | ||
|
|
8629b1b867 | ||
|
|
f7c0d4149b | ||
|
|
87fd5c19d0 | ||
|
|
d132969c91 | ||
|
|
a5fa0b1e4b | ||
|
|
a21c8a62ac | ||
|
|
9fd3701f46 | ||
|
|
1d95737088 | ||
|
|
2f7042056a | ||
|
|
13b41abce6 | ||
|
|
b9f9566158 | ||
|
|
710a417e12 | ||
|
|
f11d0fbcda | ||
|
|
96144af9e9 | ||
|
|
4dd2445833 | ||
|
|
6172d942be | ||
|
|
0c0cbb232c | ||
|
|
298ff29cf4 | ||
|
|
f70707e17f | ||
|
|
f1fc04591c | ||
|
|
a26c397417 | ||
|
|
d3a2a7bee9 | ||
|
|
d817ff7e6a | ||
|
|
ec4bec5b1f | ||
|
|
d7c458839c | ||
|
|
cff2f25e56 | ||
|
|
63ac84883e | ||
|
|
f8252df281 | ||
|
|
be00bb99ad | ||
|
|
7e6a78ab6c | ||
|
|
06c2ddf543 | ||
|
|
47f1e80252 | ||
|
|
64bc29d362 | ||
|
|
8d17f5922c | ||
|
|
063dc61e65 | ||
|
|
60ccd3372f | ||
|
|
149a0f5bdc | ||
|
|
c7da7cf725 | ||
|
|
4b9147327a | ||
|
|
43f4790f5b | ||
|
|
43ccce33da | ||
|
|
b2839de2a5 | ||
|
|
5397b3ee88 | ||
|
|
9a0a75446a | ||
|
|
f25e0230f0 | ||
|
|
16c908f0bf | ||
|
|
9c7d6a38e5 | ||
|
|
ec5e9dde66 | ||
|
|
5c346c8466 | ||
|
|
40d09591b3 | ||
|
|
bd9f337a5b | ||
|
|
cb05a5881f | ||
|
|
6b44659419 | ||
|
|
81f18aa281 | ||
|
|
410c0e47cb | ||
|
|
2372949eb9 | ||
|
|
0cf4e1fe36 | ||
|
|
9b2ce88a72 | ||
|
|
a23f359735 | ||
|
|
b343993a72 | ||
|
|
4d8db8f0b9 | ||
|
|
609df5f279 | ||
|
|
e042b21e65 | ||
|
|
d632698428 | ||
|
|
eba4bf9c80 | ||
|
|
56fc929921 | ||
|
|
2cff29e6db | ||
|
|
ced053ba63 | ||
|
|
a6324ffcf8 | ||
|
|
6e7f8b1877 | ||
|
|
74a9adcdbd | ||
|
|
4a05e69e19 | ||
|
|
1cfb59fa38 | ||
|
|
bee4a8c41a | ||
|
|
fe949d2ae3 | ||
|
|
292181a9a6 | ||
|
|
654145bd07 | ||
|
|
5900d46edb | ||
|
|
1dbe874240 | ||
|
|
eea1756dc0 | ||
|
|
32fad129cc | ||
|
|
6a8c7d5b37 | ||
|
|
efca16088b | ||
|
|
814e5edb07 | ||
|
|
abfcf15aca | ||
|
|
a113d41c1a | ||
|
|
b26b1fab95 | ||
|
|
2242c4097a | ||
|
|
74c37451bf | ||
|
|
59c4c4dcd3 | ||
|
|
eec8e22e41 | ||
|
|
429ac36ffe | ||
|
|
567b0cfa83 | ||
|
|
f4b637b51a | ||
|
|
5f2e069437 | ||
|
|
9d990f7e67 | ||
|
|
eaccdab1d4 | ||
|
|
6e2ba5c214 | ||
|
|
4d808de2ac | ||
|
|
8fb9825ad8 | ||
|
|
4b17aa6d3f | ||
|
|
6d0aea4587 | ||
|
|
ec2d6e4a74 | ||
|
|
b301a8d21e | ||
|
|
339e280a27 | ||
|
|
f8aaf47374 | ||
|
|
84e174544d | ||
|
|
ac05207ef0 | ||
|
|
9d5d36cc1f | ||
|
|
c5c86d0ad0 | ||
|
|
010ea0308a | ||
|
|
b3ca095af1 | ||
|
|
6a3a26c470 | ||
|
|
2551077cef | ||
|
|
2397e3950b | ||
|
|
d11e7863dc | ||
|
|
35c7530036 | ||
|
|
87d1cf7c86 | ||
|
|
bf2564b9f5 | ||
|
|
c59e0ea06c | ||
|
|
9ac3525683 | ||
|
|
3ac330ddee | ||
|
|
af342cf904 | ||
|
|
ec33203403 | ||
|
|
3c7f496f3e | ||
|
|
174c06dfbf | ||
|
|
d86ccaafcd | ||
|
|
d826ecb0ae | ||
|
|
e0aa1a83be | ||
|
|
e64bf6bbd6 | ||
|
|
aafc93c2ee | ||
|
|
58eced120e | ||
|
|
bbf8a7061e | ||
|
|
aea80cb046 | ||
|
|
4333fdeb3a | ||
|
|
a9aa37e043 | ||
|
|
1fc1a102ea | ||
|
|
86d2dade7a | ||
|
|
6f7bb75b52 | ||
|
|
82b8f6755f | ||
|
|
8caff25b7c | ||
|
|
c644b30b2f | ||
|
|
de174d072c | ||
|
|
c3c344daec | ||
|
|
fc1bc8791c | ||
|
|
5c413eb7cd | ||
|
|
fa4ae2caa6 | ||
|
|
e092145542 | ||
|
|
5ba5b9f2eb | ||
|
|
4fb8f7b0e7 | ||
|
|
0f210ff872 | ||
|
|
b45043aab2 | ||
|
|
ba3decad78 | ||
|
|
7df7461d31 | ||
|
|
b7241f77ef | ||
|
|
ae6cf797cb | ||
|
|
618a184bf1 | ||
|
|
b0f6be2c7c | ||
|
|
aba9e435f2 | ||
|
|
6546f9d4ce | ||
|
|
1eac6018ba | ||
|
|
f32eeda636 | ||
|
|
9493f34c23 |
49
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
container:
|
||||
image: archlinux:latest
|
||||
steps:
|
||||
- name: base-devel
|
||||
run: pacman -Syyu base-devel --noconfirm
|
||||
- name: arm-none-eabi-gcc
|
||||
run: pacman -Syyu arm-none-eabi-gcc --noconfirm
|
||||
- name: arm-none-eabi-newlib
|
||||
run: pacman -Syyu arm-none-eabi-newlib --noconfirm
|
||||
- name: git
|
||||
run: pacman -Syyu git --noconfirm
|
||||
- name: python-pip
|
||||
run: pacman -Syyu python-pip --noconfirm
|
||||
- name: python-crcmod
|
||||
run: pacman -Syyu python-crcmod --noconfirm
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: safe.directory
|
||||
run: git config --global --add safe.directory /__w/uv-k5-firmware-custom/uv-k5-firmware-custom
|
||||
- name: Make
|
||||
run: make
|
||||
- name: size
|
||||
run: arm-none-eabi-size firmware
|
||||
|
||||
- name: 'Upload Artifact'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: firmware
|
||||
path: firmware*.bin
|
||||
|
||||
- name: Upload binaries to release
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: firmware.packed.bin
|
||||
asset_name: egzumer_$tag.packed.bin
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: true
|
||||
release_name: release ${{ github.ref_name }}
|
||||
|
||||
6
.gitignore
vendored
@@ -3,3 +3,9 @@
|
||||
firmware
|
||||
/firmware.packed.bin
|
||||
/firmware.bin
|
||||
/compiled-firmware
|
||||
.cache
|
||||
compile_commands.json
|
||||
.vscode
|
||||
/docs
|
||||
k5_eeprom.raw
|
||||
|
||||
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM --platform=amd64 archlinux:latest
|
||||
RUN pacman -Syyu base-devel --noconfirm
|
||||
RUN pacman -Syyu arm-none-eabi-gcc --noconfirm
|
||||
RUN pacman -Syyu arm-none-eabi-newlib --noconfirm
|
||||
RUN pacman -Syyu git --noconfirm
|
||||
RUN pacman -Syyu python-pip --noconfirm
|
||||
RUN pacman -Syyu python-crcmod --noconfirm
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
RUN git submodule update --init --recursive
|
||||
#RUN make && cp firmware* compiled-firmware/
|
||||
17
Doxyfile
Normal file
@@ -0,0 +1,17 @@
|
||||
OUTPUT_DIRECTORY = docs
|
||||
GENERATE_LATEX = NO
|
||||
GENERATE_RTF = NO
|
||||
GENERATE_MAN = NO
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
HAVE_DOT = YES
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
CALL_GRAPH = YES
|
||||
CALLER_GRAPH = YES
|
||||
DISABLE_INDEX = YES
|
||||
GENERATE_TREEVIEW = YES
|
||||
RECURSIVE = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DOT_MULTI_TARGETS = YES
|
||||
289
Makefile
@@ -2,39 +2,70 @@
|
||||
# compile options (see README.md for descriptions)
|
||||
# 0 = disable
|
||||
# 1 = enable
|
||||
#
|
||||
ENABLE_SWD := 0
|
||||
ENABLE_OVERLAY := 1
|
||||
ENABLE_UART := 1
|
||||
ENABLE_AIRCOPY := 0
|
||||
ENABLE_FMRADIO := 0
|
||||
ENABLE_NOAA := 0
|
||||
ENABLE_VOICE := 0
|
||||
ENABLE_ALARM := 1
|
||||
ENABLE_BIG_FREQ := 1
|
||||
ENABLE_SMALL_BOLD := 1
|
||||
ENABLE_KEEP_MEM_NAME := 1
|
||||
ENABLE_WIDE_RX := 1
|
||||
ENABLE_TX_WHEN_AM := 0
|
||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
|
||||
ENABLE_MAIN_KEY_HOLD := 1
|
||||
ENABLE_BOOT_BEEPS := 0
|
||||
ENABLE_COMPANDER := 1
|
||||
ENABLE_SHOW_CHARGE_LEVEL := 1
|
||||
ENABLE_REVERSE_BAT_SYMBOL := 1
|
||||
ENABLE_NO_SCAN_TIMEOUT := 1
|
||||
ENABLE_AM_FIX := 1
|
||||
ENABLE_AM_FIX_SHOW_DATA := 1
|
||||
ENABLE_SQUELCH1_LOWER := 0
|
||||
ENABLE_RSSI_BAR := 1
|
||||
ENABLE_AUDIO_BAR := 1
|
||||
ENABLE_SPECTRUM := 1
|
||||
#ENABLE_COPY_CHAN_TO_VFO := 1
|
||||
#ENABLE_SINGLE_VFO_CHAN := 1
|
||||
#ENABLE_BAND_SCOPE := 1
|
||||
|
||||
# ---- STOCK QUANSHENG FERATURES ----
|
||||
ENABLE_UART ?= 1
|
||||
ENABLE_AIRCOPY ?= 0
|
||||
ENABLE_FMRADIO ?= 1
|
||||
ENABLE_NOAA ?= 0
|
||||
ENABLE_VOICE ?= 0
|
||||
ENABLE_VOX ?= 1
|
||||
ENABLE_ALARM ?= 0
|
||||
ENABLE_TX1750 ?= 0
|
||||
ENABLE_PWRON_PASSWORD ?= 0
|
||||
ENABLE_DTMF_CALLING ?= 1
|
||||
ENABLE_FLASHLIGHT ?= 1
|
||||
|
||||
# ---- CUSTOM MODS ----
|
||||
ENABLE_BIG_FREQ ?= 1
|
||||
ENABLE_SMALL_BOLD ?= 1
|
||||
ENABLE_CUSTOM_MENU_LAYOUT ?= 1
|
||||
ENABLE_KEEP_MEM_NAME ?= 1
|
||||
ENABLE_WIDE_RX ?= 1
|
||||
ENABLE_TX_WHEN_AM ?= 0
|
||||
ENABLE_F_CAL_MENU ?= 0
|
||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT ?= 0
|
||||
ENABLE_BOOT_BEEPS ?= 0
|
||||
ENABLE_SHOW_CHARGE_LEVEL ?= 0
|
||||
ENABLE_REVERSE_BAT_SYMBOL ?= 0
|
||||
ENABLE_NO_CODE_SCAN_TIMEOUT ?= 1
|
||||
ENABLE_AM_FIX ?= 1
|
||||
ENABLE_SQUELCH_MORE_SENSITIVE ?= 1
|
||||
ENABLE_FASTER_CHANNEL_SCAN ?= 1
|
||||
ENABLE_RSSI_BAR ?= 1
|
||||
ENABLE_AUDIO_BAR ?= 1
|
||||
ENABLE_COPY_CHAN_TO_VFO ?= 1
|
||||
ENABLE_SPECTRUM ?= 1
|
||||
ENABLE_REDUCE_LOW_MID_TX_POWER?= 0
|
||||
ENABLE_BYP_RAW_DEMODULATORS ?= 0
|
||||
ENABLE_BLMIN_TMP_OFF ?= 0
|
||||
ENABLE_SCAN_RANGES ?= 1
|
||||
|
||||
# ---- DEBUGGING ----
|
||||
ENABLE_AM_FIX_SHOW_DATA ?= 0
|
||||
ENABLE_AGC_SHOW_DATA ?= 0
|
||||
ENABLE_UART_RW_BK_REGS ?= 0
|
||||
|
||||
# ---- COMPILER/LINKER OPTIONS ----
|
||||
ENABLE_CLANG ?= 0
|
||||
ENABLE_SWD ?= 0
|
||||
ENABLE_OVERLAY ?= 0
|
||||
ENABLE_LTO ?= 1
|
||||
|
||||
#############################################################
|
||||
|
||||
TARGET = firmware
|
||||
|
||||
ifeq ($(ENABLE_CLANG),1)
|
||||
# GCC's linker, ld, doesn't understand LLVM's generated bytecode
|
||||
ENABLE_LTO := 0
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_LTO),1)
|
||||
# can't have LTO and OVERLAY enabled at same time
|
||||
ENABLE_OVERLAY := 0
|
||||
endif
|
||||
|
||||
BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
|
||||
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
|
||||
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
|
||||
@@ -82,7 +113,12 @@ ifeq ($(ENABLE_AIRCOPY),1)
|
||||
OBJS += app/aircopy.o
|
||||
endif
|
||||
OBJS += app/app.o
|
||||
OBJS += app/chFrScanner.o
|
||||
OBJS += app/common.o
|
||||
OBJS += app/dtmf.o
|
||||
ifeq ($(ENABLE_FLASHLIGHT),1)
|
||||
OBJS += app/flashlight.o
|
||||
endif
|
||||
ifeq ($(ENABLE_FMRADIO),1)
|
||||
OBJS += app/fm.o
|
||||
endif
|
||||
@@ -96,7 +132,9 @@ OBJS += app/scanner.o
|
||||
ifeq ($(ENABLE_UART),1)
|
||||
OBJS += app/uart.o
|
||||
endif
|
||||
OBJS += am_fix.o
|
||||
ifeq ($(ENABLE_AM_FIX), 1)
|
||||
OBJS += am_fix.o
|
||||
endif
|
||||
OBJS += audio.o
|
||||
OBJS += bitmaps.o
|
||||
OBJS += board.o
|
||||
@@ -119,7 +157,9 @@ ifeq ($(ENABLE_FMRADIO),1)
|
||||
endif
|
||||
OBJS += ui/helper.o
|
||||
OBJS += ui/inputbox.o
|
||||
OBJS += ui/lock.o
|
||||
ifeq ($(ENABLE_PWRON_PASSWORD),1)
|
||||
OBJS += ui/lock.o
|
||||
endif
|
||||
OBJS += ui/main.o
|
||||
OBJS += ui/menu.o
|
||||
OBJS += ui/scanner.o
|
||||
@@ -129,37 +169,87 @@ OBJS += ui/welcome.o
|
||||
OBJS += version.o
|
||||
OBJS += main.o
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
else
|
||||
TOP := $(shell pwd)
|
||||
ifeq ($(OS), Windows_NT) # windows
|
||||
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
RM = del /Q
|
||||
FixPath = $(subst /,\,$1)
|
||||
WHERE = where
|
||||
NULL_OUTPUT = nul
|
||||
else # unix
|
||||
TOP := $(shell pwd)
|
||||
RM = rm -f
|
||||
FixPath = $1
|
||||
WHERE = which
|
||||
NULL_OUTPUT = /dev/null
|
||||
endif
|
||||
|
||||
AS = arm-none-eabi-gcc
|
||||
CC = arm-none-eabi-gcc
|
||||
LD = arm-none-eabi-gcc
|
||||
|
||||
ifeq ($(ENABLE_CLANG),0)
|
||||
CC = arm-none-eabi-gcc
|
||||
# Use GCC's linker to avoid undefined symbol errors
|
||||
# LD += arm-none-eabi-gcc
|
||||
else
|
||||
# May need to adjust this to match your system
|
||||
CC = clang --sysroot=/usr/arm-none-eabi --target=arm-none-eabi
|
||||
# Bloats binaries to 512MB
|
||||
# LD = ld.lld
|
||||
endif
|
||||
|
||||
OBJCOPY = arm-none-eabi-objcopy
|
||||
SIZE = arm-none-eabi-size
|
||||
|
||||
AUTHOR_STRING ?= EGZUMER
|
||||
# the user might not have/want git installed
|
||||
# can set own version string here (max 7 chars)
|
||||
GIT_HASH := $(shell git rev-parse --short HEAD)
|
||||
#GIT_HASH := 230930b
|
||||
ifneq (, $(shell $(WHERE) git))
|
||||
VERSION_STRING ?= $(shell git describe --tags --exact-match 2>$(NULL_OUTPUT))
|
||||
ifeq (, $(VERSION_STRING))
|
||||
VERSION_STRING := $(shell git rev-parse --short HEAD)
|
||||
endif
|
||||
endif
|
||||
# If there is still no VERSION_STRING we need to make one.
|
||||
# It is needed for the firmware packing script
|
||||
ifeq (, $(VERSION_STRING))
|
||||
VERSION_STRING := NOGIT
|
||||
endif
|
||||
#VERSION_STRING := 230930b
|
||||
|
||||
$(info GIT_HASH = $(GIT_HASH))
|
||||
|
||||
ASFLAGS = -c -mcpu=cortex-m0
|
||||
ifeq ($(ENABLE_OVERLAY),1)
|
||||
ASFLAGS += -DENABLE_OVERLAY
|
||||
endif
|
||||
|
||||
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
||||
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
|
||||
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
|
||||
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
|
||||
CFLAGS =
|
||||
ifeq ($(ENABLE_CLANG),0)
|
||||
CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD
|
||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
|
||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
|
||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
|
||||
else
|
||||
# Oz needed to make it fit on flash
|
||||
CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_LTO),1)
|
||||
CFLAGS += -flto=auto
|
||||
else
|
||||
# We get most of the space savings if LTO creates problems
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# May cause unhelpful build failures
|
||||
#CFLAGS += -Wpadded
|
||||
|
||||
# catch any and all warnings
|
||||
CFLAGS += -Wextra
|
||||
#CFLAGS += -Wpedantic
|
||||
|
||||
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
|
||||
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
|
||||
CFLAGS += -DAUTHOR_STRING=\"$(AUTHOR_STRING)\" -DVERSION_STRING=\"$(VERSION_STRING)\"
|
||||
|
||||
ifeq ($(ENABLE_SPECTRUM),1)
|
||||
CFLAGS += -DENABLE_SPECTRUM
|
||||
@@ -167,15 +257,15 @@ endif
|
||||
ifeq ($(ENABLE_SWD),1)
|
||||
CFLAGS += -DENABLE_SWD
|
||||
endif
|
||||
ifeq ($(ENABLE_OVERLAY),1)
|
||||
CFLAGS += -DENABLE_OVERLAY
|
||||
endif
|
||||
ifeq ($(ENABLE_AIRCOPY),1)
|
||||
CFLAGS += -DENABLE_AIRCOPY
|
||||
endif
|
||||
ifeq ($(ENABLE_FMRADIO),1)
|
||||
CFLAGS += -DENABLE_FMRADIO
|
||||
endif
|
||||
ifeq ($(ENABLE_OVERLAY),1)
|
||||
CFLAGS += -DENABLE_OVERLAY
|
||||
endif
|
||||
ifeq ($(ENABLE_UART),1)
|
||||
CFLAGS += -DENABLE_UART
|
||||
endif
|
||||
@@ -191,11 +281,20 @@ endif
|
||||
ifeq ($(ENABLE_VOICE),1)
|
||||
CFLAGS += -DENABLE_VOICE
|
||||
endif
|
||||
ifeq ($(ENABLE_VOX),1)
|
||||
CFLAGS += -DENABLE_VOX
|
||||
endif
|
||||
ifeq ($(ENABLE_ALARM),1)
|
||||
CFLAGS += -DENABLE_ALARM
|
||||
endif
|
||||
ifeq ($(ENABLE_TX1750),1)
|
||||
CFLAGS += -DENABLE_TX1750
|
||||
endif
|
||||
ifeq ($(ENABLE_PWRON_PASSWORD),1)
|
||||
CFLAGS += -DENABLE_PWRON_PASSWORD
|
||||
endif
|
||||
ifeq ($(ENABLE_KEEP_MEM_NAME),1)
|
||||
CFLAGS += -DKEEP_MEM_NAME
|
||||
CFLAGS += -DENABLE_KEEP_MEM_NAME
|
||||
endif
|
||||
ifeq ($(ENABLE_WIDE_RX),1)
|
||||
CFLAGS += -DENABLE_WIDE_RX
|
||||
@@ -203,26 +302,23 @@ endif
|
||||
ifeq ($(ENABLE_TX_WHEN_AM),1)
|
||||
CFLAGS += -DENABLE_TX_WHEN_AM
|
||||
endif
|
||||
ifeq ($(ENABLE_F_CAL_MENU),1)
|
||||
CFLAGS += -DENABLE_F_CAL_MENU
|
||||
endif
|
||||
ifeq ($(ENABLE_CTCSS_TAIL_PHASE_SHIFT),1)
|
||||
CFLAGS += -DENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
endif
|
||||
ifeq ($(ENABLE_MAIN_KEY_HOLD),1)
|
||||
CFLAGS += -DENABLE_MAIN_KEY_HOLD
|
||||
endif
|
||||
ifeq ($(ENABLE_BOOT_BEEPS),1)
|
||||
CFLAGS += -DENABLE_BOOT_BEEPS
|
||||
endif
|
||||
ifeq ($(ENABLE_COMPANDER),1)
|
||||
CFLAGS += -DENABLE_COMPANDER
|
||||
endif
|
||||
ifeq ($(ENABLE_SHOW_CHARGE_LEVEL),1)
|
||||
CFLAGS += -DENABLE_SHOW_CHARGE_LEVEL
|
||||
endif
|
||||
ifeq ($(ENABLE_REVERSE_BAT_SYMBOL),1)
|
||||
CFLAGS += -DENABLE_REVERSE_BAT_SYMBOL
|
||||
endif
|
||||
ifeq ($(ENABLE_NO_SCAN_TIMEOUT),1)
|
||||
CFLAGS += -DENABLE_NO_SCAN_TIMEOUT
|
||||
ifeq ($(ENABLE_NO_CODE_SCAN_TIMEOUT),1)
|
||||
CFLAGS += -DENABLE_NO_CODE_SCAN_TIMEOUT
|
||||
endif
|
||||
ifeq ($(ENABLE_AM_FIX),1)
|
||||
CFLAGS += -DENABLE_AM_FIX
|
||||
@@ -230,11 +326,14 @@ endif
|
||||
ifeq ($(ENABLE_AM_FIX_SHOW_DATA),1)
|
||||
CFLAGS += -DENABLE_AM_FIX_SHOW_DATA
|
||||
endif
|
||||
ifeq ($(ENABLE_AM_FIX_TEST1),1)
|
||||
CFLAGS += -DENABLE_AM_FIX_TEST1
|
||||
ifeq ($(ENABLE_SQUELCH_MORE_SENSITIVE),1)
|
||||
CFLAGS += -DENABLE_SQUELCH_MORE_SENSITIVE
|
||||
endif
|
||||
ifeq ($(ENABLE_SQUELCH1_LOWER),1)
|
||||
CFLAGS += -DENABLE_SQUELCH1_LOWER
|
||||
ifeq ($(ENABLE_FASTER_CHANNEL_SCAN),1)
|
||||
CFLAGS += -DENABLE_FASTER_CHANNEL_SCAN
|
||||
endif
|
||||
ifeq ($(ENABLE_BACKLIGHT_ON_RX),1)
|
||||
CFLAGS += -DENABLE_BACKLIGHT_ON_RX
|
||||
endif
|
||||
ifeq ($(ENABLE_RSSI_BAR),1)
|
||||
CFLAGS += -DENABLE_RSSI_BAR
|
||||
@@ -251,12 +350,43 @@ endif
|
||||
ifeq ($(ENABLE_BAND_SCOPE),1)
|
||||
CFLAGS += -DENABLE_BAND_SCOPE
|
||||
endif
|
||||
ifeq ($(ENABLE_REDUCE_LOW_MID_TX_POWER),1)
|
||||
CFLAGS += -DENABLE_REDUCE_LOW_MID_TX_POWER
|
||||
endif
|
||||
ifeq ($(ENABLE_BYP_RAW_DEMODULATORS),1)
|
||||
CFLAGS += -DENABLE_BYP_RAW_DEMODULATORS
|
||||
endif
|
||||
ifeq ($(ENABLE_BLMIN_TMP_OFF),1)
|
||||
CFLAGS += -DENABLE_BLMIN_TMP_OFF
|
||||
endif
|
||||
ifeq ($(ENABLE_SCAN_RANGES),1)
|
||||
CFLAGS += -DENABLE_SCAN_RANGES
|
||||
endif
|
||||
ifeq ($(ENABLE_DTMF_CALLING),1)
|
||||
CFLAGS += -DENABLE_DTMF_CALLING
|
||||
endif
|
||||
ifeq ($(ENABLE_AGC_SHOW_DATA),1)
|
||||
CFLAGS += -DENABLE_AGC_SHOW_DATA
|
||||
endif
|
||||
ifeq ($(ENABLE_FLASHLIGHT),1)
|
||||
CFLAGS += -DENABLE_FLASHLIGHT
|
||||
endif
|
||||
ifeq ($(ENABLE_UART_RW_BK_REGS),1)
|
||||
CFLAGS += -DENABLE_UART_RW_BK_REGS
|
||||
endif
|
||||
ifeq ($(ENABLE_CUSTOM_MENU_LAYOUT),1)
|
||||
CFLAGS += -DENABLE_CUSTOM_MENU_LAYOUT
|
||||
endif
|
||||
|
||||
LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
||||
LDFLAGS =
|
||||
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld -Wl,--gc-sections
|
||||
|
||||
# Use newlib-nano instead of newlib
|
||||
LDFLAGS += --specs=nano.specs
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
ASFLAGS += -g
|
||||
CFLAGS += -g
|
||||
CFLAGS += -g
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
@@ -269,10 +399,34 @@ LIBS =
|
||||
|
||||
DEPS = $(OBJS:.o=.d)
|
||||
|
||||
|
||||
|
||||
ifneq (, $(shell $(WHERE) python))
|
||||
MY_PYTHON := python
|
||||
else ifneq (, $(shell $(WHERE) python3))
|
||||
MY_PYTHON := python3
|
||||
endif
|
||||
|
||||
ifdef MY_PYTHON
|
||||
HAS_CRCMOD := $(shell $(MY_PYTHON) -c "import crcmod" 2>&1)
|
||||
endif
|
||||
|
||||
all: $(TARGET)
|
||||
$(OBJCOPY) -O binary $< $<.bin
|
||||
-python fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
|
||||
-python3 fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
|
||||
|
||||
ifndef MY_PYTHON
|
||||
$(info )
|
||||
$(info !!!!!!!! PYTHON NOT FOUND, *.PACKED.BIN WON'T BE BUILT)
|
||||
$(info )
|
||||
else ifneq (,$(HAS_CRCMOD))
|
||||
$(info )
|
||||
$(info !!!!!!!! CRCMOD NOT INSTALLED, *.PACKED.BIN WON'T BE BUILT)
|
||||
$(info !!!!!!!! run: pip install crcmod)
|
||||
$(info )
|
||||
else
|
||||
-$(MY_PYTHON) fw-pack.py $<.bin $(AUTHOR_STRING) $(VERSION_STRING) $<.packed.bin
|
||||
endif
|
||||
|
||||
$(SIZE) $<
|
||||
|
||||
debug:
|
||||
@@ -299,4 +453,7 @@ bsp/dp32g030/%.h: hardware/dp32g030/%.def
|
||||
-include $(DEPS)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET).bin $(TARGET).packed.bin $(TARGET) $(OBJS) $(DEPS)
|
||||
$(RM) $(call FixPath, $(TARGET).bin $(TARGET).packed.bin $(TARGET) $(OBJS) $(DEPS))
|
||||
|
||||
doxygen:
|
||||
doxygen
|
||||
|
||||
266
README.md
@@ -1,120 +1,205 @@
|
||||
# Main features:
|
||||
- OneOfEleven mods, including AM fix
|
||||
- fagci spectrum analyzer
|
||||
- better battery percentage calculation (based on real measurement)
|
||||
# Open re-implementation of the Quansheng UV-K5/K6/5R v2.1.27 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 />
|
||||
This repository is a merge of [OneOfEleven custom firmware](https://github.com/OneOfEleven/uv-k5-firmware-custom) with [fagci spectrum analizer](https://github.com/fagci/uv-k5-firmware-fagci-mod/tree/refactor) plus my few changes.<br>
|
||||
All is a cloned and customized version of DualTachyon's open firmware found [here](https://github.com/DualTachyon/uv-k5-firmware) ... a cool achievement !
|
||||
|
||||
> [!TIP]
|
||||
> There is a work done by others on forks of this repository. I encourage you to take a look at those too.
|
||||
You can use below links to see comparison between forks.<br>
|
||||
https://gitpop2.vercel.app/egzumer/uv-k5-firmware-custom<br>
|
||||
https://useful-forks.github.io/?repo=egzumer/uv-k5-firmware-custom
|
||||
|
||||
> [!WARNING]
|
||||
> Use this firmware at your own risk (entirely). There is absolutely no guarantee that it will work in any way shape or form on your radio(s), it may even brick your radio(s), in which case, you'd need to buy another radio.
|
||||
Anyway, have fun.
|
||||
|
||||
# Open reimplementation of the Quan Sheng UV-K5 v2.1.27 firmware
|
||||
## Table of Contents
|
||||
|
||||
This repository is a merge of OneOfEleven custom firmware with fagci spectrum analizer plus my few changes.
|
||||
* [Main Features](#main-features)
|
||||
* [Manual](#manual)
|
||||
* [Radio Performance](#radio-performance)
|
||||
* [User Customization](#user-customization)
|
||||
* [Compiler](#compiler)
|
||||
* [Building](#building)
|
||||
* [Credits](#credits)
|
||||
* [Other sources of information](#other-sources-of-information)
|
||||
* [License](#license)
|
||||
* [Example changes/updates](#example-changesupdates)
|
||||
|
||||
https://github.com/OneOfEleven/uv-k5-firmware-custom<br>
|
||||
https://github.com/fagci/uv-k5-firmware-fagci-mod/tree/refactor
|
||||
## Main features:
|
||||
* many of OneOfEleven mods:
|
||||
* AM fix, huge improvement in reception quality
|
||||
* long press buttons functions replicating F+ action
|
||||
* fast scanning
|
||||
* channel name editing in the menu
|
||||
* channel name + frequency display option
|
||||
* shortcut for scan-list assignment (long press `5 NOAA`)
|
||||
* scan-list toggle (long press `* Scan` while scanning)
|
||||
* configurable button function selectable from menu
|
||||
* battery percentage/voltage on status bar, selectable from menu
|
||||
* longer backlight times
|
||||
* mic bar
|
||||
* RSSI s-meter
|
||||
* more frequency steps
|
||||
* squelch more sensitive
|
||||
* fagci spectrum analyzer (**F+5** to turn on)
|
||||
* some other mods introduced by me:
|
||||
* SSB demodulation (adopted from fagci)
|
||||
* backlight dimming
|
||||
* battery voltage calibration from menu
|
||||
* better battery percentage calculation, selectable for 1600mAh or 2200mAh
|
||||
* more configurable button functions
|
||||
* long press MENU as another configurable button
|
||||
* better DCS/CTCSS scanning in the menu (`* SCAN` while in RX DCS/CTCSS menu item)
|
||||
* Piotr022 style s-meter
|
||||
* restore initial freq/channel when scanning stopped with EXIT, remember last found transmission with MENU button
|
||||
* reordered and renamed menu entries
|
||||
* LCD interference crash fix
|
||||
* many others...
|
||||
|
||||
All is a cloned and customized version of DualTachyon's open firmware found here ..
|
||||
## Manual
|
||||
|
||||
https://github.com/DualTachyon/uv-k5-firmware
|
||||
Up to date manual is available in the [Wiki section](https://github.com/egzumer/uv-k5-firmware-custom/wiki)
|
||||
|
||||
A cool achievement
|
||||
## Radio performance
|
||||
|
||||
# Radio performance
|
||||
Please note that the Quansheng UV-Kx radios are not professional quality transceivers, their
|
||||
performance is strictly limited. The RX front end has no track-tuned band pass filtering
|
||||
at all, and so are wide band/wide open to any and all signals over a large frequency range.
|
||||
|
||||
Please note that the Quansheng uv-k radios are not professional quality transceivers, their
|
||||
performance is strictly limited, somewhat below that of a decent transceiver. The RX front
|
||||
end has no track-tuned band pass filtering at all, and so are wide band/wide open to any
|
||||
and all signals over a wide frequency range. Using the radio in high intensity RF environments
|
||||
will nearly always destroy your reception, the receiver simply doesn't have a great dynamic
|
||||
range, though are quite sensitive (weak signal wise).
|
||||
Using the radio in high intensity RF environments will most likely make reception anything but
|
||||
easy (AM mode will suffer far more than FM ever will), the receiver simply doesn't have a
|
||||
great dynamic range, which results in distorted AM audio with stronger RX'ed signals.
|
||||
There is nothing more anyone can do in firmware/software to improve that, once the RX gain
|
||||
adjustment I do (AM fix) reaches the hardwares limit, your AM RX audio will be all but
|
||||
non-existent (just like Quansheng's firmware).
|
||||
On the other hand, FM RX audio will/should be fine.
|
||||
|
||||
Saying that, they are nice toys for the price, fun to play with.
|
||||
But, they are nice toys for the price, fun to play with.
|
||||
|
||||
# User customization
|
||||
## User customization
|
||||
|
||||
You can customize the firmware by enabling/disabling various compile options.
|
||||
You can customize the firmware by enabling/disabling various compile options, this allows
|
||||
us to remove certain firmware features in order to make room in the flash for others.
|
||||
You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) ..
|
||||
|
||||
```
|
||||
ENABLE_SWD := 0 only needed if using CPU's SWD port (debugging/programming)
|
||||
ENABLE_OVERLAY := 1 cpu FLASH stuff
|
||||
ENABLE_UART := 1 without this you can't configure radio via PC
|
||||
ENABLE_AIRCOPY := 0 easier to just enter frequency
|
||||
ENABLE_FMRADIO := 1 WBFM VHF band 2 RX
|
||||
ENABLE_NOAA := 0 everything NOAA
|
||||
ENABLE_VOICE := 0 want to hear voices ?
|
||||
ENABLE_ALARM := 0 TX alarms
|
||||
ENABLE_BIG_FREQ := 0 big font frequencies
|
||||
ENABLE_SMALL_BOLD := 1 bold channel name/no. (when name + freq channel display mode)
|
||||
ENABLE_KEEP_MEM_NAME := 1 maintain channel name when (re)saving memory channel
|
||||
ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though frontend not tuned over full range)
|
||||
ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM
|
||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 standard CTCSS tail phase shift rather than QS's own 55Hz tone method
|
||||
ENABLE_MAIN_KEY_HOLD := 1 initial F-key press not needed, instead hold down keys 0-9 to access the functions
|
||||
ENABLE_BOOT_BEEPS := 0 give user audio feedback on volume knob position at boot-up
|
||||
ENABLE_COMPANDER := 1 compander option (per channel)
|
||||
ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio is on charge
|
||||
ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right)
|
||||
ENABLE_NO_SCAN_TIMEOUT := 1 remove the 32 sec timeout from the CTCSS/DCS scan (press exit butt to end scan)
|
||||
ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to helo prevent AM demodulator saturation - ignore the on-screen RSSI (for now)
|
||||
ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix
|
||||
ENABLE_SQUELCH1_LOWER := 0 adjusts squelch setting '1' to be more sensitive - I plan to let user adjust it in the menu
|
||||
ENABLE_RSSI_BAR := 1 enable a dBm/Sx RSSI bar graph level
|
||||
ENABLE_AUDIO_BAR := 0 experimental, display an audo bar level when TX'ing
|
||||
#ENABLE_COPY_CHAN_TO_VFO := 1 not yet implemented - copy the channel into the VFO
|
||||
#ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented - single VFO on display when possible
|
||||
#ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter
|
||||
```
|
||||
|
||||
# Some changes made from the Quansheng firmware
|
||||
|Build option | Description |
|
||||
| --- | ---- |
|
||||
|🧰 **STOCK QUANSHENG FERATURES**||
|
||||
| ENABLE_UART | without this you can't configure radio via PC ! |
|
||||
| ENABLE_AIRCOPY | easier to just enter frequency with butts |
|
||||
| ENABLE_FMRADIO | WBFM VHF broadcast band receiver |
|
||||
| ENABLE_NOAA | everything NOAA (only of any use in the USA) |
|
||||
| ENABLE_VOICE | want to hear voices ? |
|
||||
| ENABLE_VOX | |
|
||||
| ENABLE_ALARM | TX alarms |
|
||||
| ENABLE_TX1750 | side key 1750Hz TX tone (older style repeater access)|
|
||||
| ENABLE_PWRON_PASSWORD | power-on password stuff |
|
||||
| ENABLE_DTMF_CALLING | DTMF calling fuctionality, sending calls, receiving calls, group calls, contacts list etc. |
|
||||
| ENABLE_FLASHLIGHT | enable top flashlight LED (on, blink, SOS) |
|
||||
|🧰 **CUSTOM MODS**||
|
||||
| ENABLE_BIG_FREQ | big font frequencies (like original QS firmware) |
|
||||
| ENABLE_SMALL_BOLD | bold channel name/no. (when name + freq channel display mode) |
|
||||
| ENABLE_CUSTOM_MENU_LAYOUT | changes how the menu looks like |
|
||||
| ENABLE_KEEP_MEM_NAME | maintain channel name when (re)saving memory channel|
|
||||
| ENABLE_WIDE_RX | full 18MHz to 1300MHz RX (though front-end/PA not designed for full range)|
|
||||
| ENABLE_TX_WHEN_AM | allow TX (always FM) when RX is set to AM|
|
||||
| ENABLE_F_CAL_MENU | enable the radios hidden frequency calibration menu |
|
||||
| ENABLE_CTCSS_TAIL_PHASE_SHIFT | standard CTCSS tail phase shift rather than QS's own 55Hz tone method|
|
||||
| ENABLE_BOOT_BEEPS | gives user audio feedback on volume knob position at boot-up |
|
||||
| ENABLE_SHOW_CHARGE_LEVEL | show the charge level when the radio is on charge |
|
||||
| ENABLE_REVERSE_BAT_SYMBOL | mirror the battery symbol on the status bar (+ pole on the right) |
|
||||
| ENABLE_NO_CODE_SCAN_TIMEOUT | disable 32-sec CTCSS/DCS scan timeout (press exit butt instead of time-out to end scan) |
|
||||
| ENABLE_AM_FIX | dynamically adjust the front end gains when in AM mode to help prevent AM demodulator saturation, ignore the on-screen RSSI level (for now) |
|
||||
| ENABLE_AM_FIX_SHOW_DATA | show debug data for the AM fix |
|
||||
| ENABLE_SQUELCH_MORE_SENSITIVE | make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves |
|
||||
| ENABLE_FASTER_CHANNEL_SCAN | increases the channel scan speed, but the squelch is also made more twitchy |
|
||||
| ENABLE_RSSI_BAR | enable a dBm/Sn RSSI bar graph level in place of the little antenna symbols |
|
||||
| ENABLE_AUDIO_BAR | experimental, display an audio bar level when TX'ing |
|
||||
| ENABLE_COPY_CHAN_TO_VFO | copy current channel settings into frequency mode. Long press `1 BAND` when in channel mode |
|
||||
| ENABLE_SPECTRUM | fagci spectrum analyzer, activated with `F` + `5 NOAA`|
|
||||
| ENABLE_REDUCE_LOW_MID_TX_POWER | makes medium and low power settings even lower |
|
||||
| ENABLE_BYP_RAW_DEMODULATORS | additional BYP (bypass?) and RAW demodulation options, proved not to be very useful, but it is there if you want to experiment |
|
||||
| ENABLE_BLMIN_TMP_OFF | additional function for configurable buttons that toggles `BLMin` on and off wihout saving it to the EEPROM |
|
||||
| ENABLE_SCAN_RANGES | scan range mode for frequency scanning, see wiki for instructions (radio operation -> frequency scanning) |
|
||||
|🧰 **DEBUGGING** ||
|
||||
| ENABLE_AM_FIX_SHOW_DATA| displays settings used by AM-fix when AM transmission is received |
|
||||
| ENABLE_AGC_SHOW_DATA | displays AGC settings |
|
||||
| ENABLE_UART_RW_BK_REGS | adds 2 extra commands that allow to read and write BK4819 registers |
|
||||
|🧰 **COMPILER/LINKER OPTIONS**||
|
||||
| ENABLE_CLANG | **experimental, builds with clang instead of gcc (LTO will be disabled if you enable this) |
|
||||
| ENABLE_SWD | only needed if using CPU's SWD port (debugging/programming) |
|
||||
| ENABLE_OVERLAY | cpu FLASH stuff, not needed |
|
||||
| ENABLE_LTO | reduces size of compiled firmware but might break EEPROM reads (OVERLAY will be disabled if you enable this) |
|
||||
|
||||
* Various Quansheng firmware bugs fixed
|
||||
* Added new bugs
|
||||
* Mic menu includes max gain possible
|
||||
* AM RX everywhere (left the TX as is)
|
||||
* An attempt to improve the AM RX audio (demodulator getting saturated/overloaded in Quansheng firmware)
|
||||
* keypad-5/NOAA button now toggles scanlist-1 on/off for current channel when held down - IF NOAA not used
|
||||
* Better backlight times (inc always on)
|
||||
* Live DTMF decoder option, though the decoder needs some coeff tuning changes to decode other radios it seems
|
||||
* Various menu re-wordings (trying to reduce 'WTH does that mean ?')
|
||||
* ..
|
||||
|
||||
# Compiler
|
||||
## Compiler
|
||||
|
||||
arm-none-eabi GCC version 10.3.1 is recommended, which is the current version on Ubuntu 22.04.03 LTS.
|
||||
Other versions may generate a flash file that is too big.
|
||||
You can get an appropriate version from: https://developer.arm.com/downloads/-/gnu-rm
|
||||
|
||||
# Building
|
||||
clang may be used but isn't fully supported. Resulting binaries may also be bigger.
|
||||
You can get it from: https://releases.llvm.org/download.html
|
||||
|
||||
To build the firmware, you need to fetch the submodules and then run make:
|
||||
```
|
||||
git submodule update --init --recursive --depth=1
|
||||
make
|
||||
```
|
||||
## Building
|
||||
|
||||
To compile directly in windows without the need of a linux virtual machine:
|
||||
### Github Codespace build method
|
||||
|
||||
```
|
||||
1. Download and install "gcc-arm-none-eabi-10.3-2021.10-win32.exe" from https://developer.arm.com/downloads/-/gnu-rm
|
||||
2. Download and install "gnu_make-3.81.exe" from https://gnuwin32.sourceforge.net/packages/make.htm
|
||||
This is the least demanding option as you don't have to install enything on your computer. All you need is Github account.
|
||||
|
||||
3. You may (or not) need to manualy add gcc path to you OS environment PATH.
|
||||
ie add C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin
|
||||
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
|
||||
|
||||
4. You may (or not) need to reboot your PC after installing the above
|
||||
```
|
||||
<img src="images/codespace1.png" width=700 />
|
||||
|
||||
Then you can run 'win_make.bat' from the directory you saved this source code too.
|
||||
You may need to edit the bat file (path to make.exe) depending on where you installed the above two packages too.
|
||||
5. Open `Makefile`
|
||||
1. Edit build options, save `Makefile` changes
|
||||
1. Run `./compile-with-docker.sh` in terminal window
|
||||
1. Open folder `compiled-firmware`
|
||||
1. Right click `firmware.packed.bin`
|
||||
1. Click `Download`, now you should have a firmware on your computer that you can proceed to flash on your radio. You can use [online flasher](https://egzumer.github.io/uvtools)
|
||||
|
||||
<img src="images/codespace2.png" width=700 />
|
||||
|
||||
### Docker build method
|
||||
|
||||
If you have docker installed you can use [compile-with-docker.bat](./compile-with-docker.bat) (Windows) or [compile-with-docker.sh](./compile-with-docker.sh) (Linux/Mac), the output files are created in `compiled-firmware` folder. This method gives significantly smaller binaries, I've seen differences up to 1kb, so it can fit more functionalities this way. The challenge can be (or not) installing docker itself.
|
||||
|
||||
### Windows environment build method
|
||||
|
||||
1. Open windows command line and run:
|
||||
```
|
||||
winget install -e -h git.git Python.Python.3.8 GnuWin32.Make
|
||||
winget install -e -h Arm.GnuArmEmbeddedToolchain -v "10 2021.10"
|
||||
```
|
||||
2. Close command line, open a new one and run:
|
||||
```
|
||||
pip install --user --upgrade pip
|
||||
pip install crcmod
|
||||
mkdir c:\projects & cd /D c:/projects
|
||||
git clone https://github.com/egzumer/uv-k5-firmware-custom.git
|
||||
```
|
||||
3. From now on you can build the firmware by going to `c:\projects\uv-k5-firmware-custom` and running `win_make.bat` or by running a command line:
|
||||
```
|
||||
cd /D c:\projects\uv-k5-firmware-custom
|
||||
win_make.bat
|
||||
```
|
||||
4. To reset the repository and pull new changes run (!!! it will delete all your changes !!!):
|
||||
```
|
||||
cd /D c:\projects\uv-k5-firmware-custom
|
||||
git reset --hard & git clean -fd & git pull
|
||||
```
|
||||
|
||||
I've left some notes in the win_make.bat file to maybe help with stuff.
|
||||
|
||||
# Credits
|
||||
## Credits
|
||||
|
||||
Many thanks to various people on Telegram for putting up with me during this effort and helping:
|
||||
|
||||
* [OneOfEleven](https://github.com/OneOfEleven)
|
||||
* [DualTachyon](https://github.com/DualTachyon)
|
||||
* [Mikhail](https://github.com/fagci)
|
||||
* [Andrej](https://github.com/Tunas1337)
|
||||
@@ -128,7 +213,12 @@ Many thanks to various people on Telegram for putting up with me during this eff
|
||||
* @d1ced95
|
||||
* and others I forget
|
||||
|
||||
# License
|
||||
## Other sources of information
|
||||
|
||||
[ludwich66 - Quansheng UV-K5 Wiki](https://github.com/ludwich66/Quansheng_UV-K5_Wiki/wiki)<br>
|
||||
[amnemonic - tools and sources of information](https://github.com/amnemonic/Quansheng_UV-K5_Firmware)
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2023 Dual Tachyon
|
||||
https://github.com/DualTachyon
|
||||
@@ -145,16 +235,16 @@ You may obtain a copy of the License at
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
# Example changes/updates
|
||||
## Example changes/updates
|
||||
|
||||
<p float="left">
|
||||
<img src="/image1.png" width=300 />
|
||||
<img src="/image2.png" width=300 />
|
||||
<img src="/image3.png" width=300 />
|
||||
<img src="/images/image1.png" width=300 />
|
||||
<img src="/images/image2.png" width=300 />
|
||||
<img src="/images/image3.png" width=300 />
|
||||
</p>
|
||||
|
||||
Video showing the AM fix working ..
|
||||
|
||||
<video src="/AM_fix.mp4"></video>
|
||||
<video src="/images/AM_fix.mp4"></video>
|
||||
|
||||
<video src="https://github.com/OneOfEleven/uv-k5-firmware-custom/assets/51590168/2a3a9cdc-97da-4966-bf0d-1ce6ad09779c"></video>
|
||||
|
||||
758
am_fix.c
@@ -29,467 +29,369 @@
|
||||
#include "frequencies.h"
|
||||
#include "functions.h"
|
||||
#include "misc.h"
|
||||
|
||||
// original QS front end register settings
|
||||
const uint8_t orig_lna_short = 3; // 0dB
|
||||
const uint8_t orig_lna = 2; // -14dB
|
||||
const uint8_t orig_mixer = 3; // 0dB
|
||||
const uint8_t orig_pga = 6; // -3dB
|
||||
#include "settings.h"
|
||||
#ifdef ENABLE_AGC_SHOW_DATA
|
||||
#include "ui/main.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if 1
|
||||
// bitfields take up less flash bytes
|
||||
uint8_t lna_short:2; // 0 ~ 3
|
||||
uint8_t lna:3; // 0 ~ 7
|
||||
uint8_t mixer:2; // 0 ~ 3
|
||||
uint8_t pga:3; // 0 ~ 7
|
||||
#else
|
||||
uint8_t lna_short; // 0 ~ 3
|
||||
uint8_t lna; // 0 ~ 7
|
||||
uint8_t mixer; // 0 ~ 3
|
||||
uint8_t pga; // 0 ~ 7
|
||||
#endif
|
||||
} t_gain_table;
|
||||
//} __attribute__((packed)) t_gain_table;
|
||||
typedef struct
|
||||
{
|
||||
uint16_t reg_val;
|
||||
int8_t gain_dB;
|
||||
} __attribute__((packed)) t_gain_table;
|
||||
|
||||
// REG_10 AGC gain table
|
||||
//
|
||||
// <15:10> ???
|
||||
//
|
||||
// <9:8> = LNA Gain Short
|
||||
// 3 = 0dB < original value
|
||||
// 2 = -24dB // was -11
|
||||
// 1 = -30dB // was -16
|
||||
// 0 = -33dB // was -19
|
||||
//
|
||||
// <7:5> = LNA Gain
|
||||
// 7 = 0dB
|
||||
// 6 = -2dB
|
||||
// 5 = -4dB
|
||||
// 4 = -6dB
|
||||
// 3 = -9dB
|
||||
// 2 = -14dB < original value
|
||||
// 1 = -19dB
|
||||
// 0 = -24dB
|
||||
//
|
||||
// <4:3> = MIXER Gain
|
||||
// 3 = 0dB < original value
|
||||
// 2 = -3dB
|
||||
// 1 = -6dB
|
||||
// 0 = -8dB
|
||||
//
|
||||
// <2:0> = PGA Gain
|
||||
// 7 = 0dB
|
||||
// 6 = -3dB < original value
|
||||
// 5 = -6dB
|
||||
// 4 = -9dB
|
||||
// 3 = -15dB
|
||||
// 2 = -21dB
|
||||
// 1 = -27dB
|
||||
// 0 = -33dB
|
||||
// REG_10 AGC gain table
|
||||
//
|
||||
// <15:10> ???
|
||||
//
|
||||
// <9:8> = LNA Gain Short
|
||||
// 3 = 0dB < original value
|
||||
// 2 = -19dB // was -11
|
||||
// 1 = -24dB // was -16
|
||||
// 0 = -28dB // was -19
|
||||
//
|
||||
// <7:5> = LNA Gain
|
||||
// 7 = 0dB
|
||||
// 6 = -2dB
|
||||
// 5 = -4dB < original value
|
||||
// 4 = -6dB
|
||||
// 3 = -9dB
|
||||
// 2 = -14dB
|
||||
// 1 = -19dB
|
||||
// 0 = -24dB
|
||||
//
|
||||
// <4:3> = MIXER Gain
|
||||
// 3 = 0dB < original value
|
||||
// 2 = -3dB
|
||||
// 1 = -6dB
|
||||
// 0 = -8dB
|
||||
//
|
||||
// <2:0> = PGA Gain
|
||||
// 7 = 0dB
|
||||
// 6 = -3dB < original value
|
||||
// 5 = -6dB
|
||||
// 4 = -9dB
|
||||
// 3 = -15dB
|
||||
// 2 = -21dB
|
||||
// 1 = -27dB
|
||||
// 0 = -33dB
|
||||
|
||||
// front end register dB values
|
||||
//
|
||||
// these values need to be accurate for the code to properly/reliably switch
|
||||
// between table entries when adjusting the front end registers.
|
||||
//
|
||||
// these 4 tables need a measuring/calibration update
|
||||
//
|
||||
//
|
||||
// QUESTION: why do I have to surround the negative numbers in brackets ???
|
||||
// if I don't add the brackets, reading the table returns unexpected/different values !!!
|
||||
//
|
||||
//
|
||||
// static const int16_t lna_short_dB[] = { -19, -16, -11, 0}; // was (but wrong)
|
||||
static const int16_t lna_short_dB[] = { (-33), (-30), (-24), 0}; // corrected'ish
|
||||
static const int16_t lna_dB[] = { (-24), (-19), (-14), ( -9), (-6), (-4), (-2), 0};
|
||||
static const int16_t mixer_dB[] = { ( -8), ( -6), ( -3), 0};
|
||||
static const int16_t pga_dB[] = { (-33), (-27), (-21), (-15), (-9), (-6), (-3), 0};
|
||||
// front end register dB values
|
||||
//
|
||||
// these values need to be accurate for the code to properly/reliably switch
|
||||
// between table entries when adjusting the front end registers.
|
||||
//
|
||||
// these 4 tables need a measuring/calibration update
|
||||
//
|
||||
//// static const int16_t lna_short_dB[] = { -19, -16, -11, 0}; // was (but wrong)
|
||||
// static const int16_t lna_short_dB[] = { (-28), (-24), (-19), 0}; // corrected'ish
|
||||
// static const int16_t lna_dB[] = { (-24), (-19), (-14), ( -9), (-6), (-4), (-2), 0};
|
||||
// static const int16_t mixer_dB[] = { ( -8), ( -6), ( -3), 0};
|
||||
// static const int16_t pga_dB[] = { (-33), (-27), (-21), (-15), (-9), (-6), (-3), 0};
|
||||
|
||||
// lookup table is hugely easier than writing code to do the same
|
||||
//
|
||||
static const t_gain_table gain_table[] =
|
||||
{
|
||||
{.lna_short = 3, .lna = 2, .mixer = 3, .pga = 6}, // 0 0dB -14dB 0dB -3dB .. -17dB original
|
||||
// lookup table is hugely easier than writing code to do the same
|
||||
//
|
||||
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
#define LOOKUP_TABLE 1
|
||||
|
||||
// test table that lets me manually set the lna-short register
|
||||
// to measure it's actual dB change using an RF signal generator
|
||||
#if LOOKUP_TABLE
|
||||
static const t_gain_table gain_table[] =
|
||||
{
|
||||
{0x03BE, -7}, // 0 .. 3 5 3 6 .. 0dB -4dB 0dB -3dB .. -7dB original
|
||||
|
||||
{0, 2, 3, 6}, // 1 .. -33dB -14dB 0dB -3dB .. -50dB
|
||||
{1, 2, 3, 6}, // 2 .. -30dB -14dB 0dB -3dB .. -47dB
|
||||
{2, 2, 3, 6}, // 3 .. -24dB -14dB 0dB -3dB .. -41dB
|
||||
{3, 2, 3, 6} // 4 .. 0dB -14dB 0dB -3dB .. -17dB
|
||||
};
|
||||
|
||||
const unsigned int original_index = 1;
|
||||
{0x0000,-93}, // 1 .. 0 0 0 0 .. -28dB -24dB -8dB -33dB .. -93dB
|
||||
{0x0008,-91}, // 2 .. 0 0 1 0 .. -28dB -24dB -6dB -33dB .. -91dB
|
||||
{0x0010,-88}, // 3 .. 0 0 2 0 .. -28dB -24dB -3dB -33dB .. -88dB
|
||||
{0x0001,-87}, // 4 .. 0 0 0 1 .. -28dB -24dB -8dB -27dB .. -87dB
|
||||
{0x0009,-85}, // 5 .. 0 0 1 1 .. -28dB -24dB -6dB -27dB .. -85dB
|
||||
{0x0011,-82}, // 6 .. 0 0 2 1 .. -28dB -24dB -3dB -27dB .. -82dB
|
||||
{0x0002,-81}, // 7 .. 0 0 0 2 .. -28dB -24dB -8dB -21dB .. -81dB
|
||||
{0x000A,-79}, // 8 .. 0 0 1 2 .. -28dB -24dB -6dB -21dB .. -79dB
|
||||
{0x0012,-76}, // 9 .. 0 0 2 2 .. -28dB -24dB -3dB -21dB .. -76dB
|
||||
{0x0003,-75}, // 10 .. 0 0 0 3 .. -28dB -24dB -8dB -15dB .. -75dB
|
||||
{0x000B,-73}, // 11 .. 0 0 1 3 .. -28dB -24dB -6dB -15dB .. -73dB
|
||||
{0x0013,-70}, // 12 .. 0 0 2 3 .. -28dB -24dB -3dB -15dB .. -70dB
|
||||
{0x0004,-69}, // 13 .. 0 0 0 4 .. -28dB -24dB -8dB -9dB .. -69dB
|
||||
{0x000C,-67}, // 14 .. 0 0 1 4 .. -28dB -24dB -6dB -9dB .. -67dB
|
||||
{0x000D,-64}, // 15 .. 0 0 1 5 .. -28dB -24dB -6dB -6dB .. -64dB
|
||||
{0x001C,-61}, // 16 .. 0 0 3 4 .. -28dB -24dB 0dB - 9dB .. -61dB
|
||||
{0x001D,-58}, // 17 .. 0 0 3 5 .. -28dB -24dB 0dB -6dB .. -58dB
|
||||
{0x001E,-55}, // 18 .. 0 0 3 6 .. -28dB -24dB 0dB -3dB .. -55dB
|
||||
{0x001F,-52}, // 19 .. 0 0 3 7 .. -28dB -24dB 0dB 0dB .. -52dB
|
||||
{0x003E,-50}, // 20 .. 0 1 3 6 .. -28dB -19dB 0dB -3dB .. -50dB
|
||||
{0x003F,-47}, // 21 .. 0 1 3 7 .. -28dB -19dB 0dB 0dB .. -47dB
|
||||
{0x005E,-45}, // 22 .. 0 2 3 6 .. -28dB -14dB 0dB -3dB .. -45dB
|
||||
{0x005F,-42}, // 23 .. 0 2 3 7 .. -28dB -14dB 0dB 0dB .. -42dB
|
||||
{0x007E,-40}, // 24 .. 0 3 3 6 .. -28dB -9dB 0dB -3dB .. -40dB
|
||||
{0x007F,-37}, // 25 .. 0 3 3 7 .. -28dB -9dB 0dB 0dB .. -37dB
|
||||
{0x009F,-34}, // 26 .. 0 4 3 7 .. -28dB -6dB 0dB 0dB .. -34dB
|
||||
{0x00BF,-32}, // 27 .. 0 5 3 7 .. -28dB -4dB 0dB 0dB .. -32dB
|
||||
{0x00DF,-30}, // 28 .. 0 6 3 7 .. -28dB -2dB 0dB 0dB .. -30dB
|
||||
{0x00FF,-28}, // 29 .. 0 7 3 7 .. -28dB 0dB 0dB 0dB .. -28dB
|
||||
{0x01DF,-26}, // 30 .. 1 6 3 7 .. -24dB -2dB 0dB 0dB .. -26dB
|
||||
{0x01FF,-24}, // 31 .. 1 7 3 7 .. -24dB 0dB 0dB 0dB .. -24dB
|
||||
{0x02BF,-23}, // 32 .. 2 5 3 7 .. -19dB -4dB 0dB 0dB .. -23dB
|
||||
{0x02DF,-21}, // 33 .. 2 6 3 7 .. -19dB -2dB 0dB -0dB .. -21dB
|
||||
{0x02FF,-19}, // 34 .. 2 7 3 7 .. -19dB 0dB 0dB 0dB .. -19dB
|
||||
{0x035E,-17}, // 35 .. 3 2 3 6 .. 0dB -14dB 0dB -3dB .. -17dB
|
||||
{0x035F,-14}, // 36 .. 3 2 3 7 .. 0dB -14dB 0dB 0dB .. -14dB
|
||||
{0x037E,-12}, // 37 .. 3 3 3 6 .. 0dB -9dB 0dB -3dB .. -12dB
|
||||
{0x037F,-9}, // 38 .. 3 3 3 7 .. 0dB -9dB 0dB 0dB .. -9dB
|
||||
{0x038F,-6}, // 39 .. 3 4 3 7 .. 0dB - 6dB 0dB 0dB .. -6dB
|
||||
{0x03BF,-4}, // 40 .. 3 5 3 7 .. 0dB -4dB 0dB 0dB .. -4dB
|
||||
{0x03DF,-2}, // 41 .. 3 6 3 7 .. 0dB - 2dB 0dB 0dB .. -2dB
|
||||
{0x03FF,0} // 42 .. 3 7 3 7 .. 0dB 0dB 0dB 0dB .. 0dB
|
||||
};
|
||||
|
||||
const uint8_t gain_table_size = ARRAY_SIZE(gain_table);
|
||||
#else
|
||||
|
||||
{0, 0, 0, 0}, // 1 .. -33dB -24dB -8dB -33dB .. -98dB
|
||||
{0, 0, 1, 0}, // 2 .. -33dB -24dB -6dB -33dB .. -96dB
|
||||
{1, 0, 0, 0}, // 3 .. -30dB -24dB -8dB -33dB .. -95dB
|
||||
{0, 1, 0, 0}, // 4 .. -33dB -19dB -8dB -33dB .. -93dB
|
||||
{0, 0, 0, 1}, // 5 .. -33dB -24dB -8dB -27dB .. -92dB
|
||||
{0, 1, 1, 0}, // 6 .. -33dB -19dB -6dB -33dB .. -91dB
|
||||
{0, 0, 1, 1}, // 7 .. -33dB -24dB -6dB -27dB .. -90dB
|
||||
{1, 0, 0, 1}, // 8 .. -30dB -24dB -8dB -27dB .. -89dB
|
||||
{0, 1, 2, 0}, // 9 .. -33dB -19dB -3dB -33dB .. -88dB
|
||||
{1, 0, 3, 0}, // 10 .. -30dB -24dB 0dB -33dB .. -87dB
|
||||
{0, 0, 0, 2}, // 11 .. -33dB -24dB -8dB -21dB .. -86dB
|
||||
{1, 1, 2, 0}, // 12 .. -30dB -19dB -3dB -33dB .. -85dB
|
||||
{0, 0, 3, 1}, // 13 .. -33dB -24dB 0dB -27dB .. -84dB
|
||||
{0, 3, 0, 0}, // 14 .. -33dB -9dB -8dB -33dB .. -83dB
|
||||
{1, 1, 3, 0}, // 15 .. -30dB -19dB 0dB -33dB .. -82dB
|
||||
{1, 0, 3, 1}, // 16 .. -30dB -24dB 0dB -27dB .. -81dB
|
||||
{0, 2, 3, 0}, // 17 .. -33dB -14dB 0dB -33dB .. -80dB
|
||||
{1, 2, 0, 1}, // 18 .. -30dB -14dB -8dB -27dB .. -79dB
|
||||
{0, 3, 2, 0}, // 19 .. -33dB -9dB -3dB -33dB .. -78dB
|
||||
{1, 4, 0, 0}, // 20 .. -30dB -6dB -8dB -33dB .. -77dB
|
||||
{1, 1, 3, 1}, // 21 .. -30dB -19dB 0dB -27dB .. -76dB
|
||||
{0, 0, 2, 3}, // 22 .. -33dB -24dB -3dB -15dB .. -75dB
|
||||
{1, 3, 0, 1}, // 23 .. -30dB -9dB -8dB -27dB .. -74dB
|
||||
{1, 6, 0, 0}, // 24 .. -30dB -2dB -8dB -33dB .. -73dB
|
||||
{0, 7, 1, 0}, // 25 .. -33dB 0dB -6dB -33dB .. -72dB
|
||||
{0, 6, 2, 0}, // 26 .. -33dB -2dB -3dB -33dB .. -71dB
|
||||
{2, 1, 3, 1}, // 27 .. -24dB -19dB 0dB -27dB .. -70dB
|
||||
{0, 3, 1, 2}, // 28 .. -33dB -9dB -6dB -21dB .. -69dB
|
||||
{0, 0, 0, 6}, // 29 .. -33dB -24dB -8dB -3dB .. -68dB
|
||||
{0, 5, 2, 1}, // 30 .. -33dB -4dB -3dB -27dB .. -67dB
|
||||
{0, 0, 1, 6}, // 31 .. -33dB -24dB -6dB -3dB .. -66dB
|
||||
{1, 2, 3, 2}, // 32 .. -30dB -14dB 0dB -21dB .. -65dB
|
||||
{2, 1, 1, 3}, // 33 .. -24dB -19dB -6dB -15dB .. -64dB
|
||||
{1, 7, 3, 0}, // 34 .. -30dB 0dB 0dB -33dB .. -63dB
|
||||
{1, 3, 0, 3}, // 35 .. -30dB -9dB -8dB -15dB .. -62dB
|
||||
{0, 1, 2, 5}, // 36 .. -33dB -19dB -3dB -6dB .. -61dB
|
||||
{2, 0, 2, 4}, // 37 .. -24dB -24dB -3dB -9dB .. -60dB
|
||||
{1, 6, 3, 1}, // 38 .. -30dB -2dB 0dB -27dB .. -59dB
|
||||
{1, 2, 0, 5}, // 39 .. -30dB -14dB -8dB -6dB .. -58dB
|
||||
{2, 5, 0, 2}, // 40 .. -24dB -4dB -8dB -21dB .. -57dB
|
||||
{2, 6, 2, 1}, // 41 .. -24dB -2dB -3dB -27dB .. -56dB
|
||||
{0, 5, 2, 3}, // 42 .. -33dB -4dB -3dB -15dB .. -55dB
|
||||
{2, 0, 2, 6}, // 43 .. -24dB -24dB -3dB -3dB .. -54dB
|
||||
{0, 3, 0, 6}, // 44 .. -33dB -9dB -8dB -3dB .. -53dB
|
||||
{0, 6, 0, 4}, // 45 .. -33dB -2dB -8dB -9dB .. -52dB
|
||||
{0, 3, 1, 6}, // 46 .. -33dB -9dB -6dB -3dB .. -51dB
|
||||
{1, 2, 3, 5}, // 47 .. -30dB -14dB 0dB -6dB .. -50dB
|
||||
{0, 5, 1, 5}, // 48 .. -33dB -4dB -6dB -6dB .. -49dB
|
||||
{0, 3, 3, 5}, // 49 .. -33dB -9dB 0dB -6dB .. -48dB
|
||||
{0, 6, 2, 4}, // 50 .. -33dB -2dB -3dB -9dB .. -47dB
|
||||
{1, 5, 2, 4}, // 51 .. -30dB -4dB -3dB -9dB .. -46dB
|
||||
{3, 0, 1, 3}, // 52 .. 0dB -24dB -6dB -15dB .. -45dB
|
||||
{0, 6, 1, 6}, // 53 .. -33dB -2dB -6dB -3dB .. -44dB
|
||||
{1, 5, 2, 5}, // 54 .. -30dB -4dB -3dB -6dB .. -43dB
|
||||
{0, 4, 2, 7}, // 55 .. -33dB -6dB -3dB 0dB .. -42dB
|
||||
{2, 2, 2, 7}, // 56 .. -24dB -14dB -3dB 0dB .. -41dB
|
||||
{2, 5, 2, 4}, // 57 .. -24dB -4dB -3dB -9dB .. -40dB
|
||||
{2, 3, 3, 5}, // 58 .. -24dB -9dB 0dB -6dB .. -39dB
|
||||
{1, 6, 3, 5}, // 59 .. -30dB -2dB 0dB -6dB .. -38dB
|
||||
{2, 5, 1, 6}, // 60 .. -24dB -4dB -6dB -3dB .. -37dB
|
||||
{3, 3, 3, 1}, // 61 .. 0dB -9dB 0dB -27dB .. -36dB
|
||||
{3, 2, 3, 2}, // 62 .. 0dB -14dB 0dB -21dB .. -35dB
|
||||
{2, 5, 2, 6}, // 63 .. -24dB -4dB -3dB -3dB .. -34dB
|
||||
{3, 0, 1, 6}, // 64 .. 0dB -24dB -6dB -3dB .. -33dB
|
||||
{3, 0, 0, 7}, // 65 .. 0dB -24dB -8dB 0dB .. -32dB
|
||||
{2, 5, 3, 6}, // 66 .. -24dB -4dB 0dB -3dB .. -31dB
|
||||
{3, 3, 3, 2}, // 67 .. 0dB -9dB 0dB -21dB .. -30dB
|
||||
{2, 6, 3, 6}, // 68 .. -24dB -2dB 0dB -3dB .. -29dB
|
||||
{3, 2, 0, 5}, // 69 .. 0dB -14dB -8dB -6dB .. -28dB
|
||||
{3, 5, 0, 3}, // 70 .. 0dB -4dB -8dB -15dB .. -27dB
|
||||
{3, 3, 0, 4}, // 71 .. 0dB -9dB -8dB -9dB .. -26dB
|
||||
{3, 1, 1, 7}, // 72 .. 0dB -19dB -6dB 0dB .. -25dB
|
||||
{3, 4, 2, 3}, // 73 .. 0dB -6dB -3dB -15dB .. -24dB
|
||||
{3, 4, 0, 4}, // 74 .. 0dB -6dB -8dB -9dB .. -23dB
|
||||
{3, 2, 0, 7}, // 75 .. 0dB -14dB -8dB 0dB .. -22dB
|
||||
{3, 7, 1, 3}, // 76 .. 0dB 0dB -6dB -15dB .. -21dB
|
||||
{3, 6, 2, 3}, // 77 .. 0dB -2dB -3dB -15dB .. -20dB
|
||||
{3, 5, 3, 3}, // 78 .. 0dB -4dB 0dB -15dB .. -19dB
|
||||
{3, 3, 3, 4}, // 79 .. 0dB -9dB 0dB -9dB .. -18dB
|
||||
{3, 2, 3, 6}, // 80 .. 0dB -14dB 0dB -3dB .. -17dB original
|
||||
{3, 6, 0, 5}, // 81 .. 0dB -2dB -8dB -6dB .. -16dB
|
||||
{3, 7, 1, 4}, // 82 .. 0dB 0dB -6dB -9dB .. -15dB
|
||||
{3, 2, 3, 7}, // 83 .. 0dB -14dB 0dB 0dB .. -14dB
|
||||
{3, 6, 0, 6}, // 84 .. 0dB -2dB -8dB -3dB .. -13dB
|
||||
{3, 3, 2, 7}, // 85 .. 0dB -9dB -3dB 0dB .. -12dB
|
||||
{3, 7, 0, 6}, // 86 .. 0dB 0dB -8dB -3dB .. -11dB
|
||||
{3, 5, 3, 5}, // 87 .. 0dB -4dB 0dB -6dB .. -10dB
|
||||
{3, 7, 2, 5}, // 88 .. 0dB 0dB -3dB -6dB .. -9dB
|
||||
{3, 6, 3, 5}, // 89 .. 0dB -2dB 0dB -6dB .. -8dB
|
||||
{3, 5, 2, 7}, // 90 .. 0dB -4dB -3dB 0dB .. -7dB
|
||||
{3, 7, 2, 6}, // 91 .. 0dB 0dB -3dB -3dB .. -6dB
|
||||
{3, 6, 2, 7}, // 92 .. 0dB -2dB -3dB 0dB .. -5dB
|
||||
{3, 5, 3, 7}, // 93 .. 0dB -4dB 0dB 0dB .. -4dB
|
||||
{3, 7, 2, 7}, // 94 .. 0dB 0dB -3dB 0dB .. -3dB
|
||||
{3, 6, 3, 7}, // 95 .. 0dB -2dB 0dB 0dB .. -2dB
|
||||
{3, 7, 3, 7} // 96 .. 0dB 0dB 0dB 0dB .. 0dB
|
||||
};
|
||||
t_gain_table gain_table[100] = {{0x03BE, -7}}; //original
|
||||
uint8_t gain_table_size = 0;
|
||||
|
||||
const unsigned int original_index = 80;
|
||||
void CreateTable()
|
||||
{
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t pgaIdx:3;
|
||||
uint8_t mixerIdx:2;
|
||||
uint8_t lnaIdx:3;
|
||||
uint8_t lnaSIdx:2;
|
||||
};
|
||||
uint16_t __raw;
|
||||
} GainData;
|
||||
|
||||
static const int8_t lna_short_dB[] = {-28, -24, -19, 0}; // corrected'ish
|
||||
static const int8_t lna_dB[] = {-24, -19, -14, -9, -6, -4, -2, 0};
|
||||
static const int8_t mixer_dB[] = { -8, -6, -3, 0};
|
||||
static const int8_t pga_dB[] = {-33, -27, -21, -15, -9, -6, -3, 0};
|
||||
|
||||
unsigned i;
|
||||
for (uint8_t lnaSIdx = 0; lnaSIdx < ARRAY_SIZE(lna_short_dB); lnaSIdx++) {
|
||||
for (uint8_t lnaIdx = 0; lnaIdx < ARRAY_SIZE(lna_dB); lnaIdx++) {
|
||||
for (uint8_t mixerIdx = 0; mixerIdx < ARRAY_SIZE(mixer_dB); mixerIdx++) {
|
||||
for (uint8_t pgaIdx = 0; pgaIdx < ARRAY_SIZE(pga_dB); pgaIdx++) {
|
||||
int16_t db = lna_short_dB[lnaSIdx] + lna_dB[lnaIdx] + mixer_dB[mixerIdx] + pga_dB[pgaIdx];
|
||||
GainData gainData = {{
|
||||
pgaIdx,
|
||||
mixerIdx,
|
||||
lnaIdx,
|
||||
lnaSIdx,
|
||||
}};
|
||||
|
||||
for (i = 1; i < ARRAY_SIZE(gain_table); i++) {
|
||||
t_gain_table * gain = &gain_table[i];
|
||||
if (db == gain->gain_dB)
|
||||
break;
|
||||
if (db > gain->gain_dB)
|
||||
continue;
|
||||
if (db < gain->gain_dB) {
|
||||
if(gain->gain_dB)
|
||||
memmove(gain + 1, gain, 100 - i);
|
||||
gain->gain_dB = db;
|
||||
gain->reg_val = gainData.__raw;
|
||||
break;
|
||||
}
|
||||
gain->gain_dB = db;
|
||||
gain->reg_val = gainData.__raw;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gain_table_size = i+1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// total RF gain for each table index
|
||||
int8_t gain_dB[ARRAY_SIZE(gain_table)] = {0};
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
// display update rate
|
||||
const unsigned int display_update_rate = 250 / 10; // max 250ms display update rate
|
||||
static const unsigned int display_update_rate = 250 / 10; // max 250ms display update rate
|
||||
unsigned int counter = 0;
|
||||
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
// user manually sets the table index .. used to calibrate the desired dB gain table
|
||||
unsigned int gain_table_index[2] = {1 + gSetting_AM_fix_test1, 1 + gSetting_AM_fix_test1};
|
||||
#else
|
||||
unsigned int gain_table_index[2] = {original_index, original_index};
|
||||
#endif
|
||||
|
||||
// used simply to detect a changed gain setting
|
||||
unsigned int gain_table_index_prev[2] = {0, 0};
|
||||
|
||||
// holds the previous RSSI level .. we do an average of old + new RSSI reading
|
||||
int16_t prev_rssi[2] = {0, 0};
|
||||
|
||||
// to help reduce gain hunting, peak hold count down tick
|
||||
unsigned int hold_counter[2] = {0, 0};
|
||||
|
||||
// used to correct the RSSI readings after our RF gain adjustments
|
||||
int16_t rssi_gain_diff[2] = {0, 0};
|
||||
|
||||
// used to limit the max RF gain
|
||||
unsigned int max_index = ARRAY_SIZE(gain_table) - 1;
|
||||
|
||||
#ifndef ENABLE_AM_FIX_TEST1
|
||||
// -89dBm, any higher and the AM demodulator starts to saturate/clip/distort
|
||||
const int16_t desired_rssi = (-89 + 160) * 2;
|
||||
#endif
|
||||
|
||||
void AM_fix_init(void)
|
||||
{ // called at boot-up
|
||||
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
gain_table_index[i] = 1 + gSetting_AM_fix_test1;
|
||||
#else
|
||||
gain_table_index[i] = original_index; // re-start with original QS setting
|
||||
#endif
|
||||
}
|
||||
|
||||
// pre-compute the total gain for each table index .. saves doing it in real time
|
||||
for (i = 0; i < ARRAY_SIZE(gain_table); i++)
|
||||
{
|
||||
const t_gain_table gains = gain_table[i];
|
||||
gain_dB[i] = lna_short_dB[gains.lna_short] + lna_dB[gains.lna] + mixer_dB[gains.mixer] + pga_dB[gains.pga];
|
||||
}
|
||||
|
||||
#if 0
|
||||
{ // set a maximum gain to use
|
||||
// const int16_t max_gain_dB = gain_dB[original_index];
|
||||
const int16_t max_gain_dB = -10;
|
||||
|
||||
max_index = ARRAY_SIZE(gain_table);
|
||||
while (--max_index > 1)
|
||||
if (gain_dB[max_index] <= max_gain_dB)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// use the full range of available gains
|
||||
max_index = ARRAY_SIZE(gain_table) - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void AM_fix_reset(const int vfo)
|
||||
{ // reset the AM fixer upper
|
||||
|
||||
counter = 0;
|
||||
|
||||
prev_rssi[vfo] = 0;
|
||||
|
||||
hold_counter[vfo] = 0;
|
||||
|
||||
rssi_gain_diff[vfo] = 0;
|
||||
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
// gain_table_index[vfo] = 1 + gSetting_AM_fix_test1;
|
||||
#else
|
||||
// gain_table_index[vfo] = original_index; // re-start with original QS setting
|
||||
#endif
|
||||
|
||||
gain_table_index_prev[vfo] = 0;
|
||||
}
|
||||
|
||||
// adjust the RX gain to try and prevent the AM demodulator from
|
||||
// saturating/overloading/clipping (distorted AM audio)
|
||||
//
|
||||
// we're actually doing the BK4819's job for it here, but as the chip
|
||||
// won't/don't do it for itself, we're left to bodging it ourself by
|
||||
// playing with the RF front end gain setting
|
||||
//
|
||||
void AM_fix_10ms(const int vfo)
|
||||
{
|
||||
int16_t diff_dB;
|
||||
int16_t rssi;
|
||||
|
||||
switch (gCurrentFunction)
|
||||
{
|
||||
case FUNCTION_TRANSMIT:
|
||||
case FUNCTION_BAND_SCOPE:
|
||||
case FUNCTION_POWER_SAVE:
|
||||
counter = display_update_rate; // queue up a display update as soon as we switch to RX mode
|
||||
return;
|
||||
|
||||
// only adjust stuff if we're in one of these modes
|
||||
case FUNCTION_FOREGROUND:
|
||||
case FUNCTION_RECEIVE:
|
||||
case FUNCTION_MONITOR:
|
||||
case FUNCTION_INCOMING:
|
||||
break;
|
||||
}
|
||||
|
||||
if (counter > 0)
|
||||
{
|
||||
if (++counter >= display_update_rate)
|
||||
{ // trigger a display update
|
||||
counter = 0;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
|
||||
{ // sample the current RSSI level
|
||||
// average it with the previous rssi (a bit of noise/spike immunity)
|
||||
const int16_t new_rssi = BK4819_GetRSSI();
|
||||
rssi = (prev_rssi[vfo] > 0) ? (prev_rssi[vfo] + new_rssi) / 2 : new_rssi;
|
||||
prev_rssi[vfo] = new_rssi;
|
||||
}
|
||||
|
||||
{ // save the corrected RSSI level
|
||||
const int16_t new_rssi = rssi - rssi_gain_diff[vfo];
|
||||
if (gCurrentRSSI[vfo] != new_rssi)
|
||||
{
|
||||
gCurrentRSSI[vfo] = new_rssi;
|
||||
if (counter == 0)
|
||||
{ // trigger a display update
|
||||
counter = 1;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
// user is manually adjusting a gain register - don't do anything automatically
|
||||
|
||||
{
|
||||
int i = 1 + (int)gSetting_AM_fix_test1;
|
||||
i = (i < 1) ? 1 : (i > ((int)ARRAY_SIZE(gain_table) - 1) ? ARRAY_SIZE(gain_table) - 1 : i;
|
||||
|
||||
if (gain_table_index[vfo] == i)
|
||||
return; // no change
|
||||
|
||||
gain_table_index[vfo] = i;
|
||||
}
|
||||
|
||||
#else
|
||||
// automatically adjust the RF RX gain
|
||||
|
||||
// update the gain hold counter
|
||||
if (hold_counter[vfo] > 0)
|
||||
hold_counter[vfo]--;
|
||||
|
||||
// dB difference between actual and desired RSSI level
|
||||
diff_dB = (rssi - desired_rssi) / 2;
|
||||
|
||||
if (diff_dB > 0)
|
||||
{ // decrease gain
|
||||
|
||||
unsigned int index = gain_table_index[vfo]; // current position we're at
|
||||
|
||||
if (diff_dB >= 10)
|
||||
{ // jump immediately to a new gain setting
|
||||
// this greatly speeds up initial gain reduction (but reduces noise/spike immunity)
|
||||
const int16_t desired_gain_dB = (int16_t)gain_dB[index] - diff_dB + 8; // get no closer than 8dB (bit of noise/spike immunity)
|
||||
// scan the table to see what index to jump straight too
|
||||
while (index > 1)
|
||||
if (gain_dB[--index] <= desired_gain_dB)
|
||||
break;
|
||||
|
||||
//index = (gain_table_index[vfo] + index) / 2; // easy does it
|
||||
}
|
||||
else
|
||||
{ // incrementally reduce the gain .. taking it slow improves noise/spike immunity
|
||||
|
||||
// if (index >= (1 + 3) && diff_dB >= 3)
|
||||
// index -= 3; // faster gain reduction
|
||||
// else
|
||||
if (index > 1)
|
||||
index--; // slow step-by-step gain reduction
|
||||
}
|
||||
|
||||
index = (index < 1) ? 1 : (index > max_index) ? max_index : index;
|
||||
|
||||
if (gain_table_index[vfo] != index)
|
||||
{
|
||||
gain_table_index[vfo] = index;
|
||||
hold_counter[vfo] = 30; // 300ms hold
|
||||
}
|
||||
}
|
||||
|
||||
if (diff_dB >= -4) // 4dB hysterisis (help reduce gain hunting)
|
||||
hold_counter[vfo] = 30; // 300ms hold
|
||||
|
||||
if (hold_counter[vfo] == 0)
|
||||
{ // hold has been released, we're free to increase gain
|
||||
const unsigned int index = gain_table_index[vfo] + 1; // move up to next gain index
|
||||
gain_table_index[vfo] = (index <= max_index) ? index : max_index; // limit the gain index
|
||||
}
|
||||
|
||||
if (gain_table_index[vfo] == gain_table_index_prev[vfo])
|
||||
return; // no gain change
|
||||
|
||||
#endif
|
||||
|
||||
{ // apply the new settings to the front end registers
|
||||
unsigned int gain_table_index[2] = {0, 0};
|
||||
// used simply to detect a changed gain setting
|
||||
unsigned int gain_table_index_prev[2] = {0, 0};
|
||||
// holds the previous RSSI level .. we do an average of old + new RSSI reading
|
||||
int16_t prev_rssi[2] = {0, 0};
|
||||
// to help reduce gain hunting, peak hold count down tick
|
||||
unsigned int hold_counter[2] = {0, 0};
|
||||
// -89dBm, any higher and the AM demodulator starts to saturate/clip/distort
|
||||
const int16_t desired_rssi = (-89 + 160) * 2;
|
||||
|
||||
const unsigned int index = gain_table_index[vfo];
|
||||
int8_t currentGainDiff;
|
||||
bool enabled = true;
|
||||
|
||||
// remember the new table index
|
||||
gain_table_index_prev[vfo] = index;
|
||||
void AM_fix_init(void)
|
||||
{ // called at boot-up
|
||||
for (int i = 0; i < 2; i++) {
|
||||
gain_table_index[i] = 0; // re-start with original QS setting
|
||||
}
|
||||
#if !LOOKUP_TABLE
|
||||
CreateTable();
|
||||
#endif
|
||||
}
|
||||
|
||||
const t_gain_table gains = gain_table[index];
|
||||
BK4819_WriteRegister(BK4819_REG_13, ((uint16_t)gains.lna_short << 8) | ((uint16_t)gains.lna << 5) | ((uint16_t)gains.mixer << 3) | ((uint16_t)gains.pga << 0));
|
||||
void AM_fix_reset(const unsigned vfo)
|
||||
{ // reset the AM fixer upper
|
||||
if (vfo > 1)
|
||||
return;
|
||||
|
||||
// offset the RSSI reading to the rest of the firmware to cancel out the gain adjustments we make
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
counter = 0;
|
||||
#endif
|
||||
|
||||
// RF gain difference from original QS setting
|
||||
rssi_gain_diff[vfo] = ((int16_t)gain_dB[index] - gain_dB[original_index]) * 2;
|
||||
}
|
||||
prev_rssi[vfo] = 0;
|
||||
hold_counter[vfo] = 0;
|
||||
gain_table_index_prev[vfo] = 0;
|
||||
}
|
||||
|
||||
// save the corrected RSSI level
|
||||
gCurrentRSSI[vfo] = rssi - rssi_gain_diff[vfo];
|
||||
// adjust the RX gain to try and prevent the AM demodulator from
|
||||
// saturating/overloading/clipping (distorted AM audio)
|
||||
//
|
||||
// we're actually doing the BK4819's job for it here, but as the chip
|
||||
// won't/don't do it for itself, we're left to bodging it ourself by
|
||||
// playing with the RF front end gain setting
|
||||
//
|
||||
void AM_fix_10ms(const unsigned vfo)
|
||||
{
|
||||
if(!gSetting_AM_fix || !enabled || vfo > 1 )
|
||||
return;
|
||||
|
||||
if (counter == 0)
|
||||
{
|
||||
counter = 1;
|
||||
if (gCurrentFunction != FUNCTION_FOREGROUND && !FUNCTION_IsRx()) {
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
counter = display_update_rate; // queue up a display update as soon as we switch to RX mode
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
if (counter > 0) {
|
||||
if (++counter >= display_update_rate) { // trigger a display update
|
||||
counter = 0;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
static uint32_t lastFreq[2];
|
||||
if(gEeprom.VfoInfo[vfo].pRX->Frequency != lastFreq[vfo]) {
|
||||
lastFreq[vfo] = gEeprom.VfoInfo[vfo].pRX->Frequency;
|
||||
AM_fix_reset(vfo);
|
||||
}
|
||||
|
||||
void AM_fix_print_data(const int vfo, char *s)
|
||||
{
|
||||
if (s != NULL)
|
||||
{
|
||||
const unsigned int index = gain_table_index[vfo];
|
||||
sprintf(s, "%2u.%u %4ddB %3u", index, ARRAY_SIZE(gain_table) - 1, gain_dB[index], prev_rssi[vfo]);
|
||||
counter = 0;
|
||||
int16_t rssi;
|
||||
{ // sample the current RSSI level
|
||||
// average it with the previous rssi (a bit of noise/spike immunity)
|
||||
const int16_t new_rssi = BK4819_GetRSSI();
|
||||
rssi = (prev_rssi[vfo] > 0) ? (prev_rssi[vfo] + new_rssi) / 2 : new_rssi;
|
||||
prev_rssi[vfo] = new_rssi;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
{
|
||||
static int16_t lastRssi;
|
||||
|
||||
if (lastRssi != rssi) { // rssi changed
|
||||
lastRssi = rssi;
|
||||
|
||||
if (counter == 0) {
|
||||
counter = 1;
|
||||
gUpdateDisplay = true; // trigger a display update
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
// automatically adjust the RF RX gain
|
||||
|
||||
// update the gain hold counter
|
||||
if (hold_counter[vfo] > 0)
|
||||
hold_counter[vfo]--;
|
||||
|
||||
// dB difference between actual and desired RSSI level
|
||||
int16_t diff_dB = (rssi - desired_rssi) / 2;
|
||||
|
||||
if (diff_dB > 0) { // decrease gain
|
||||
unsigned int index = gain_table_index[vfo]; // current position we're at
|
||||
|
||||
if (diff_dB >= 10) { // jump immediately to a new gain setting
|
||||
// this greatly speeds up initial gain reduction (but reduces noise/spike immunity)
|
||||
|
||||
const int16_t desired_gain_dB = (int16_t)gain_table[index].gain_dB - diff_dB + 8; // get no closer than 8dB (bit of noise/spike immunity)
|
||||
|
||||
// scan the table to see what index to jump straight too
|
||||
while (index > 1)
|
||||
if (gain_table[--index].gain_dB <= desired_gain_dB)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{ // incrementally reduce the gain .. taking it slow improves noise/spike immunity
|
||||
if (index > 1)
|
||||
index--; // slow step-by-step gain reduction
|
||||
}
|
||||
|
||||
index = MAX(1u, index);
|
||||
|
||||
if (gain_table_index[vfo] != index)
|
||||
{
|
||||
gain_table_index[vfo] = index;
|
||||
hold_counter[vfo] = 30; // 300ms hold
|
||||
}
|
||||
}
|
||||
|
||||
if (diff_dB >= -6) // 6dB hysterisis (help reduce gain hunting)
|
||||
hold_counter[vfo] = 30; // 300ms hold
|
||||
|
||||
if (hold_counter[vfo] == 0)
|
||||
{ // hold has been released, we're free to increase gain
|
||||
const unsigned int index = gain_table_index[vfo] + 1; // move up to next gain index
|
||||
gain_table_index[vfo] = MIN(index, gain_table_size - 1u);
|
||||
}
|
||||
|
||||
|
||||
{ // apply the new settings to the front end registers
|
||||
const unsigned int index = gain_table_index[vfo];
|
||||
|
||||
// remember the new table index
|
||||
gain_table_index_prev[vfo] = index;
|
||||
currentGainDiff = gain_table[0].gain_dB - gain_table[index].gain_dB;
|
||||
BK4819_WriteRegister(BK4819_REG_13, gain_table[index].reg_val);
|
||||
#ifdef ENABLE_AGC_SHOW_DATA
|
||||
UI_MAIN_PrintAGC(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
if (counter == 0) {
|
||||
counter = 1;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
void AM_fix_print_data(const unsigned vfo, char *s) {
|
||||
if (s != NULL && vfo < ARRAY_SIZE(gain_table_index)) {
|
||||
const unsigned int index = gain_table_index[vfo];
|
||||
sprintf(s, "%2u %4ddB %3u", index, gain_table[index].gain_dB, prev_rssi[vfo]);
|
||||
counter = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int8_t AM_fix_get_gain_diff()
|
||||
{
|
||||
return currentGainDiff;
|
||||
}
|
||||
|
||||
void AM_fix_enable(bool on)
|
||||
{
|
||||
enabled = on;
|
||||
}
|
||||
#endif
|
||||
|
||||
17
am_fix.h
@@ -20,21 +20,16 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern const uint8_t orig_lna_short;
|
||||
extern const uint8_t orig_lna;
|
||||
extern const uint8_t orig_mixer;
|
||||
extern const uint8_t orig_pga;
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
extern int16_t rssi_gain_diff[2];
|
||||
|
||||
void AM_fix_init(void);
|
||||
void AM_fix_reset(const int vfo);
|
||||
void AM_fix_10ms(const int vfo);
|
||||
void AM_fix_reset(const unsigned vfo);
|
||||
void AM_fix_10ms(const unsigned vfo);
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
void AM_fix_print_data(const int vfo, char *s);
|
||||
void AM_fix_print_data(const unsigned vfo, char *s);
|
||||
#endif
|
||||
|
||||
int8_t AM_fix_get_gain_diff();
|
||||
void AM_fix_enable(bool on);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
616
app/action.c
@@ -14,9 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "app/action.h"
|
||||
#include "app/app.h"
|
||||
#include "app/chFrScanner.h"
|
||||
#include "app/common.h"
|
||||
#include "app/dtmf.h"
|
||||
#ifdef ENABLE_FLASHLIGHT
|
||||
#include "app/flashlight.h"
|
||||
#endif
|
||||
#ifdef ENABLE_FMRADIO
|
||||
#include "app/fm.h"
|
||||
#endif
|
||||
@@ -28,28 +36,73 @@
|
||||
#endif
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/backlight.h"
|
||||
#include "functions.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
#include "ui/inputbox.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
static void ACTION_FlashLight(void)
|
||||
{
|
||||
switch (gFlashLightState)
|
||||
{
|
||||
case 0:
|
||||
gFlashLightState++;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
break;
|
||||
case 1:
|
||||
gFlashLightState++;
|
||||
break;
|
||||
default:
|
||||
gFlashLightState = 0;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
}
|
||||
}
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
static void ACTION_Scan_FM(bool bRestart);
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
static void ACTION_AlarmOr1750(bool b1750);
|
||||
inline static void ACTION_Alarm() { ACTION_AlarmOr1750(false); }
|
||||
inline static void ACTION_1750() { ACTION_AlarmOr1750(true); };
|
||||
#endif
|
||||
|
||||
inline static void ACTION_ScanRestart() { ACTION_Scan(true); };
|
||||
|
||||
void (*action_opt_table[])(void) = {
|
||||
[ACTION_OPT_NONE] = &FUNCTION_NOP,
|
||||
[ACTION_OPT_POWER] = &ACTION_Power,
|
||||
[ACTION_OPT_MONITOR] = &ACTION_Monitor,
|
||||
[ACTION_OPT_SCAN] = &ACTION_ScanRestart,
|
||||
[ACTION_OPT_KEYLOCK] = &COMMON_KeypadLockToggle,
|
||||
[ACTION_OPT_A_B] = &COMMON_SwitchVFOs,
|
||||
[ACTION_OPT_VFO_MR] = &COMMON_SwitchVFOMode,
|
||||
[ACTION_OPT_SWITCH_DEMODUL] = &ACTION_SwitchDemodul,
|
||||
|
||||
#ifdef ENABLE_FLASHLIGHT
|
||||
[ACTION_OPT_FLASHLIGHT] = &ACTION_FlashLight,
|
||||
#else
|
||||
[ACTION_OPT_FLASHLIGHT] = &FUNCTION_NOP,
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
[ACTION_OPT_VOX] = &ACTION_Vox,
|
||||
#else
|
||||
[ACTION_OPT_VOX] = &FUNCTION_NOP,
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
[ACTION_OPT_FM] = &ACTION_FM,
|
||||
#else
|
||||
[ACTION_OPT_FM] = &FUNCTION_NOP,
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
[ACTION_OPT_ALARM] = &ACTION_Alarm,
|
||||
#else
|
||||
[ACTION_OPT_ALARM] = &FUNCTION_NOP,
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_TX1750
|
||||
[ACTION_OPT_1750] = &ACTION_1750,
|
||||
#else
|
||||
[ACTION_OPT_1750] = &FUNCTION_NOP,
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||
[ACTION_OPT_BLMIN_TMP_OFF] = &ACTION_BlminTmpOff,
|
||||
#else
|
||||
[ACTION_OPT_BLMIN_TMP_OFF] = &FUNCTION_NOP,
|
||||
#endif
|
||||
};
|
||||
|
||||
static_assert(ARRAY_SIZE(action_opt_table) == ACTION_OPT_LEN);
|
||||
|
||||
void ACTION_Power(void)
|
||||
{
|
||||
@@ -57,313 +110,334 @@ void ACTION_Power(void)
|
||||
gTxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
|
||||
|
||||
gRequestSaveChannel = 1;
|
||||
//gRequestSaveChannel = 2; // auto save the channel
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_POWER;
|
||||
#endif
|
||||
|
||||
gRequestDisplayScreen = gScreenToDisplay;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_POWER;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void ACTION_Monitor(void)
|
||||
{
|
||||
if (gCurrentFunction != FUNCTION_MONITOR)
|
||||
{ // enable the monitor
|
||||
if (gCurrentFunction != FUNCTION_MONITOR) { // enable the monitor
|
||||
RADIO_SelectVfos();
|
||||
#ifdef ENABLE_NOAA
|
||||
if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST && gIsNoaaMode)
|
||||
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gIsNoaaMode)
|
||||
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
|
||||
#endif
|
||||
RADIO_SetupRegisters(true);
|
||||
APP_StartListening(FUNCTION_MONITOR, false);
|
||||
APP_StartListening(FUNCTION_MONITOR);
|
||||
return;
|
||||
}
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
if (gScanState != SCAN_OFF)
|
||||
{
|
||||
ScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms;
|
||||
gScheduleScanListen = false;
|
||||
gScanPauseMode = true;
|
||||
|
||||
if (gScanStateDir != SCAN_OFF) {
|
||||
gScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms;
|
||||
gScheduleScanListen = false;
|
||||
gScanPauseMode = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode)
|
||||
{
|
||||
gNOAA_Countdown_10ms = NOAA_countdown_10ms;
|
||||
gScheduleNOAA = false;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode) {
|
||||
gNOAA_Countdown_10ms = NOAA_countdown_10ms;
|
||||
gScheduleNOAA = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
{
|
||||
FM_Start();
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode) {
|
||||
FM_Start();
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
gRequestDisplayScreen = gScreenToDisplay;
|
||||
}
|
||||
|
||||
void ACTION_Scan(bool bRestart)
|
||||
{
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
{
|
||||
if (gCurrentFunction != FUNCTION_RECEIVE &&
|
||||
gCurrentFunction != FUNCTION_MONITOR &&
|
||||
gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
{
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
(void)bRestart;
|
||||
|
||||
gMonitor = false;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode) {
|
||||
ACTION_Scan_FM(bRestart);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gFM_ScanState != FM_SCAN_OFF)
|
||||
{
|
||||
FM_PlayAndUpdate();
|
||||
if (SCANNER_IsScanning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16_t Frequency;
|
||||
// not scanning
|
||||
gMonitor = false;
|
||||
|
||||
if (bRestart)
|
||||
{
|
||||
gFM_AutoScan = true;
|
||||
gFM_ChannelPosition = 0;
|
||||
FM_EraseChannels();
|
||||
Frequency = gEeprom.FM_LowerLimit;
|
||||
}
|
||||
else
|
||||
{
|
||||
gFM_AutoScan = false;
|
||||
gFM_ChannelPosition = 0;
|
||||
Frequency = gEeprom.FM_FrequencyPlaying;
|
||||
}
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
DTMF_clear_RX();
|
||||
#endif
|
||||
gDTMF_RX_live_timeout = 0;
|
||||
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
|
||||
|
||||
BK1080_GetFrequencyDeviation(Frequency);
|
||||
FM_Tune(Frequency, 1, bRestart);
|
||||
RADIO_SelectVfos();
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
|
||||
if (gScanStateDir != SCAN_OFF) {
|
||||
// already scanning
|
||||
|
||||
if (!IS_MR_CHANNEL(gNextMrChannel)) {
|
||||
CHFRSCANNER_Stop();
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gScreenToDisplay != DISPLAY_SCANNER)
|
||||
{ // not scanning
|
||||
// channel mode. Keep scanning but toggle between scan lists
|
||||
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
|
||||
|
||||
// jump to the next channel
|
||||
CHFRSCANNER_Start(false, gScanStateDir);
|
||||
gScanPauseDelayIn_10ms = 1;
|
||||
gScheduleScanListen = false;
|
||||
} else {
|
||||
// start scanning
|
||||
CHFRSCANNER_Start(true, SCAN_FWD);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
|
||||
AUDIO_PlaySingleVoice(true);
|
||||
#endif
|
||||
|
||||
// clear the other vfo's rssi level (to hide the antenna symbol)
|
||||
gVFO_RSSI_bar_level[(gEeprom.RX_VFO + 1) & 1U] = 0;
|
||||
|
||||
// let the user see DW is not active
|
||||
gDualWatchActive = false;
|
||||
}
|
||||
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
|
||||
void ACTION_SwitchDemodul(void)
|
||||
{
|
||||
gRequestSaveChannel = 1;
|
||||
|
||||
gTxVfo->Modulation++;
|
||||
|
||||
if(gTxVfo->Modulation == MODULATION_UKNOWN)
|
||||
gTxVfo->Modulation = MODULATION_FM;
|
||||
}
|
||||
|
||||
|
||||
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode){
|
||||
// entering DTMF code
|
||||
|
||||
gPttWasReleased = true;
|
||||
|
||||
if (Key != KEY_SIDE1 || bKeyHeld || !bKeyPressed){
|
||||
return;
|
||||
}
|
||||
|
||||
// side1 btn pressed
|
||||
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
|
||||
if (gDTMF_InputBox_Index <= 0) {
|
||||
// turn off DTMF input box if no codes left
|
||||
gDTMF_InputMode = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// DTMF codes are in the input box
|
||||
gDTMF_InputBox[--gDTMF_InputBox_Index] = '-'; // delete one code
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
enum ACTION_OPT_t funcShort = ACTION_OPT_NONE;
|
||||
enum ACTION_OPT_t funcLong = ACTION_OPT_NONE;
|
||||
switch(Key) {
|
||||
case KEY_SIDE1:
|
||||
funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
||||
funcLong = gEeprom.KEY_1_LONG_PRESS_ACTION;
|
||||
break;
|
||||
case KEY_SIDE2:
|
||||
funcShort = gEeprom.KEY_2_SHORT_PRESS_ACTION;
|
||||
funcLong = gEeprom.KEY_2_LONG_PRESS_ACTION;
|
||||
break;
|
||||
case KEY_MENU:
|
||||
funcLong = gEeprom.KEY_M_LONG_PRESS_ACTION;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bKeyHeld && bKeyPressed) // button pushed
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// held or released beyond this point
|
||||
|
||||
if(!(bKeyHeld && !bKeyPressed)) // don't beep on released after hold
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
if (bKeyHeld || bKeyPressed) // held
|
||||
{
|
||||
funcShort = funcLong;
|
||||
|
||||
if (!bKeyPressed) //ignore release if held
|
||||
return;
|
||||
}
|
||||
|
||||
// held or released after short press beyond this point
|
||||
|
||||
action_opt_table[funcShort]();
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
void ACTION_FM(void)
|
||||
{
|
||||
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR)
|
||||
{
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
if (gFmRadioMode) {
|
||||
FM_TurnOff();
|
||||
gFlagReconfigureVfos = true;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
gVoxResumeCountdown = 80;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
RADIO_SelectVfos();
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
||||
#endif
|
||||
{
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
FM_Start();
|
||||
|
||||
if (gScanState != SCAN_OFF)
|
||||
{
|
||||
SCANNER_Stop();
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
CHANNEL_Next(true, 1);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
|
||||
AUDIO_PlaySingleVoice(true);
|
||||
#endif
|
||||
|
||||
// clear the other vfo's rssi level (to hide the antenna symbol)
|
||||
gVFO_RSSI_bar_level[gEeprom.RX_CHANNEL == 0] = 0;
|
||||
|
||||
// let the user see DW is not active
|
||||
gDualWatchActive = false;
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!bRestart)
|
||||
{ // scanning
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
SCANNER_Stop();
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
}
|
||||
}
|
||||
|
||||
static void ACTION_Scan_FM(bool bRestart)
|
||||
{
|
||||
if (FUNCTION_IsRx())
|
||||
return;
|
||||
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
if (gFM_ScanState != FM_SCAN_OFF) {
|
||||
FM_PlayAndUpdate();
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t freq;
|
||||
|
||||
if (bRestart) {
|
||||
gFM_AutoScan = true;
|
||||
gFM_ChannelPosition = 0;
|
||||
FM_EraseChannels();
|
||||
freq = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||
} else {
|
||||
gFM_AutoScan = false;
|
||||
gFM_ChannelPosition = 0;
|
||||
freq = gEeprom.FM_FrequencyPlaying;
|
||||
}
|
||||
|
||||
BK1080_GetFrequencyDeviation(freq);
|
||||
FM_Tune(freq, 1, bRestart);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
static void ACTION_AlarmOr1750(const bool b1750)
|
||||
{
|
||||
|
||||
#if defined(ENABLE_ALARM)
|
||||
const AlarmState_t alarm_mode = (gEeprom.ALARM_MODE == ALARM_MODE_TONE) ? ALARM_STATE_TXALARM : ALARM_STATE_SITE_ALARM;
|
||||
gAlarmRunningCounter = 0;
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_ALARM) && defined(ENABLE_TX1750)
|
||||
gAlarmState = b1750 ? ALARM_STATE_TX1750 : alarm_mode;
|
||||
#elif defined(ENABLE_ALARM)
|
||||
gAlarmState = alarm_mode;
|
||||
#else
|
||||
gAlarmState = ALARM_STATE_TX1750;
|
||||
#endif
|
||||
|
||||
(void)b1750;
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
gFlagPrepareTX = gAlarmState != ALARM_STATE_OFF;
|
||||
|
||||
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
void ACTION_Vox(void)
|
||||
{
|
||||
gEeprom.VOX_SWITCH = !gEeprom.VOX_SWITCH;
|
||||
gRequestSaveSettings = true;
|
||||
gFlagReconfigureVfos = true;
|
||||
gUpdateStatus = true;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_VOX;
|
||||
#endif
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
static void ACTION_AlarmOr1750(bool b1750)
|
||||
{
|
||||
gInputBoxIndex = 0;
|
||||
gAlarmState = b1750 ? ALARM_STATE_TX1750 : ALARM_STATE_TXALARM;
|
||||
gAlarmRunningCounter = 0;
|
||||
gFlagPrepareTX = true;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
void ACTION_FM(void)
|
||||
{
|
||||
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR)
|
||||
{
|
||||
if (gFmRadioMode)
|
||||
{
|
||||
FM_TurnOff();
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
gVoxResumeCountdown = 80;
|
||||
gFlagReconfigureVfos = true;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
RADIO_SelectVfos();
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
FM_Start();
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||
void ACTION_BlminTmpOff(void)
|
||||
{
|
||||
uint8_t Short = ACTION_OPT_NONE;
|
||||
uint8_t Long = ACTION_OPT_NONE;
|
||||
|
||||
if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode)
|
||||
{
|
||||
if (Key == KEY_SIDE1 && !bKeyHeld && bKeyPressed)
|
||||
{
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
if (gDTMF_InputIndex > 0)
|
||||
{
|
||||
gDTMF_InputBox[--gDTMF_InputIndex] = '-';
|
||||
if (gDTMF_InputIndex > 0)
|
||||
{
|
||||
gPttWasReleased = true;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gDTMF_InputMode = false;
|
||||
}
|
||||
|
||||
gPttWasReleased = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Key == KEY_SIDE1)
|
||||
{
|
||||
Short = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
||||
Long = gEeprom.KEY_1_LONG_PRESS_ACTION;
|
||||
}
|
||||
else
|
||||
if (Key == KEY_SIDE2)
|
||||
{
|
||||
Short = gEeprom.KEY_2_SHORT_PRESS_ACTION;
|
||||
Long = gEeprom.KEY_2_LONG_PRESS_ACTION;
|
||||
}
|
||||
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
{
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bKeyHeld || bKeyPressed)
|
||||
{
|
||||
if (!bKeyHeld)
|
||||
return;
|
||||
|
||||
Short = Long;
|
||||
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
}
|
||||
|
||||
switch (Short)
|
||||
{
|
||||
default:
|
||||
case ACTION_OPT_NONE:
|
||||
break;
|
||||
case ACTION_OPT_FLASHLIGHT:
|
||||
ACTION_FlashLight();
|
||||
break;
|
||||
case ACTION_OPT_POWER:
|
||||
ACTION_Power();
|
||||
break;
|
||||
case ACTION_OPT_MONITOR:
|
||||
ACTION_Monitor();
|
||||
break;
|
||||
case ACTION_OPT_SCAN:
|
||||
ACTION_Scan(true);
|
||||
break;
|
||||
case ACTION_OPT_VOX:
|
||||
ACTION_Vox();
|
||||
break;
|
||||
case ACTION_OPT_ALARM:
|
||||
#ifdef ENABLE_ALARM
|
||||
ACTION_AlarmOr1750(false);
|
||||
#endif
|
||||
break;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
case ACTION_OPT_FM:
|
||||
ACTION_FM();
|
||||
break;
|
||||
#endif
|
||||
case ACTION_OPT_1750:
|
||||
#ifdef ENABLE_ALARM
|
||||
ACTION_AlarmOr1750(true);
|
||||
#endif
|
||||
break;
|
||||
if(++gEeprom.BACKLIGHT_MIN_STAT == BLMIN_STAT_UNKNOWN) {
|
||||
gEeprom.BACKLIGHT_MIN_STAT = BLMIN_STAT_ON;
|
||||
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MIN);
|
||||
} else {
|
||||
BACKLIGHT_SetBrightness(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
15
app/action.h
@@ -19,19 +19,22 @@
|
||||
|
||||
#include "driver/keyboard.h"
|
||||
|
||||
//static void ACTION_FlashLight(void)
|
||||
void ACTION_Power(void);
|
||||
void ACTION_Monitor(void);
|
||||
void ACTION_Scan(bool bFlag);
|
||||
void ACTION_Vox(void);
|
||||
#ifdef ENABLE_ALARM
|
||||
//static void ACTION_AlarmOr1750(bool b1750)
|
||||
void ACTION_Scan(bool bRestart);
|
||||
#ifdef ENABLE_VOX
|
||||
void ACTION_Vox(void);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
void ACTION_FM(void);
|
||||
#endif
|
||||
void ACTION_SwitchDemodul(void);
|
||||
|
||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||
void ACTION_BlminTmpOff(void);
|
||||
#endif
|
||||
|
||||
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
298
app/aircopy.c
@@ -28,18 +28,26 @@
|
||||
#include "ui/inputbox.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
static const uint16_t Obfuscation[8] = {0x6C16, 0xE614, 0x912E, 0x400D, 0x3521, 0x40D5, 0x0313, 0x80E9};
|
||||
static const uint16_t Obfuscation[8] = { 0x6C16, 0xE614, 0x912E, 0x400D, 0x3521, 0x40D5, 0x0313, 0x80E9 };
|
||||
|
||||
AIRCOPY_State_t gAircopyState;
|
||||
uint16_t gAirCopyBlockNumber;
|
||||
uint16_t gErrorsDuringAirCopy;
|
||||
uint8_t gAirCopyIsSendMode;
|
||||
uint16_t gAirCopyBlockNumber;
|
||||
uint16_t gErrorsDuringAirCopy;
|
||||
uint8_t gAirCopyIsSendMode;
|
||||
|
||||
uint16_t g_FSK_Buffer[36];
|
||||
uint16_t g_FSK_Buffer[36];
|
||||
|
||||
void AIRCOPY_SendMessage(void)
|
||||
bool AIRCOPY_SendMessage(void)
|
||||
{
|
||||
unsigned int i;
|
||||
static uint8_t gAircopySendCountdown = 1;
|
||||
|
||||
if (gAircopyState != AIRCOPY_TRANSFER) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (--gAircopySendCountdown) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_FSK_Buffer[1] = (gAirCopyBlockNumber & 0x3FF) << 6;
|
||||
|
||||
@@ -47,185 +55,187 @@ void AIRCOPY_SendMessage(void)
|
||||
|
||||
g_FSK_Buffer[34] = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
|
||||
|
||||
for (i = 0; i < 34; i++)
|
||||
for (unsigned int i = 0; i < 34; i++) {
|
||||
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
|
||||
}
|
||||
|
||||
if (++gAirCopyBlockNumber >= 0x78)
|
||||
if (++gAirCopyBlockNumber >= 0x78) {
|
||||
gAircopyState = AIRCOPY_COMPLETE;
|
||||
}
|
||||
|
||||
RADIO_SetTxParameters();
|
||||
|
||||
BK4819_SendFSKData(g_FSK_Buffer);
|
||||
BK4819_SetupPowerAmplifier(0, 0);
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, false);
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false);
|
||||
|
||||
gAircopySendCountdown = 30;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AIRCOPY_StorePacket(void)
|
||||
{
|
||||
uint16_t Status;
|
||||
|
||||
if (gFSKWriteIndex < 36)
|
||||
if (gFSKWriteIndex < 36) {
|
||||
return;
|
||||
}
|
||||
|
||||
gFSKWriteIndex = 0;
|
||||
gUpdateDisplay = true;
|
||||
Status = BK4819_ReadRegister(BK4819_REG_0B);
|
||||
uint16_t Status = BK4819_ReadRegister(BK4819_REG_0B);
|
||||
BK4819_PrepareFSKReceive();
|
||||
|
||||
// Doc says bit 4 should be 1 = CRC OK, 0 = CRC FAIL, but original firmware checks for FAIL.
|
||||
|
||||
if ((Status & 0x0010U) == 0 && g_FSK_Buffer[0] == 0xABCD && g_FSK_Buffer[35] == 0xDCBA)
|
||||
{
|
||||
uint16_t CRC;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < 34; i++)
|
||||
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
|
||||
|
||||
CRC = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
|
||||
if (g_FSK_Buffer[34] == CRC)
|
||||
{
|
||||
const uint16_t *pData;
|
||||
uint16_t Offset;
|
||||
|
||||
Offset = g_FSK_Buffer[1];
|
||||
if (Offset < 0x1E00)
|
||||
{
|
||||
pData = &g_FSK_Buffer[2];
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
EEPROM_WriteBuffer(Offset, pData);
|
||||
pData += 4;
|
||||
Offset += 8;
|
||||
}
|
||||
|
||||
if (Offset == 0x1E00)
|
||||
gAircopyState = AIRCOPY_COMPLETE;
|
||||
|
||||
gAirCopyBlockNumber++;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((Status & 0x0010U) != 0 || g_FSK_Buffer[0] != 0xABCD || g_FSK_Buffer[35] != 0xDCBA) {
|
||||
gErrorsDuringAirCopy++;
|
||||
return;
|
||||
}
|
||||
gErrorsDuringAirCopy++;
|
||||
|
||||
for (unsigned int i = 0; i < 34; i++) {
|
||||
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
|
||||
}
|
||||
|
||||
uint16_t CRC = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
|
||||
if (g_FSK_Buffer[34] != CRC) {
|
||||
gErrorsDuringAirCopy++;
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t Offset = g_FSK_Buffer[1];
|
||||
|
||||
if (Offset >= 0x1E00) {
|
||||
gErrorsDuringAirCopy++;
|
||||
return;
|
||||
}
|
||||
|
||||
const uint16_t *pData = &g_FSK_Buffer[2];
|
||||
for (unsigned int i = 0; i < 8; i++) {
|
||||
EEPROM_WriteBuffer(Offset, pData);
|
||||
pData += 4;
|
||||
Offset += 8;
|
||||
}
|
||||
|
||||
if (Offset == 0x1E00) {
|
||||
gAircopyState = AIRCOPY_COMPLETE;
|
||||
}
|
||||
|
||||
gAirCopyBlockNumber++;
|
||||
}
|
||||
|
||||
static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
{
|
||||
uint32_t Frequency;
|
||||
unsigned int i;
|
||||
|
||||
INPUTBOX_Append(Key);
|
||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||
if (gInputBoxIndex < 6)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
NUMBER_Get(gInputBox, &Frequency);
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i])
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gRxVfo->Band = i;
|
||||
Frequency += 75;
|
||||
Frequency = FREQUENCY_FloorToStep(Frequency, gRxVfo->StepFrequency, 0);
|
||||
gRxVfo->freq_config_RX.Frequency = Frequency;
|
||||
gRxVfo->freq_config_TX.Frequency = Frequency;
|
||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||
gCurrentVfo = gRxVfo;
|
||||
RADIO_SetupRegisters(true);
|
||||
BK4819_SetupAircopy();
|
||||
BK4819_ResetFSK();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||
if (bKeyHeld || !bKeyPressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
INPUTBOX_Append(Key);
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||
|
||||
if (gInputBoxIndex < 6) {
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
uint32_t Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
|
||||
|
||||
for (unsigned int i = 0; i < BAND_N_ELEM; i++) {
|
||||
if (Frequency < frequencyBandTable[i].lower || Frequency >= frequencyBandTable[i].upper) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (TX_freq_check(Frequency)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
|
||||
Frequency = FREQUENCY_RoundToStep(Frequency, gRxVfo->StepFrequency);
|
||||
gRxVfo->Band = i;
|
||||
gRxVfo->freq_config_RX.Frequency = Frequency;
|
||||
gRxVfo->freq_config_TX.Frequency = Frequency;
|
||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||
gCurrentVfo = gRxVfo;
|
||||
RADIO_SetupRegisters(true);
|
||||
BK4819_SetupAircopy();
|
||||
BK4819_ResetFSK();
|
||||
return;
|
||||
}
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||
}
|
||||
|
||||
static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
{
|
||||
if (gInputBoxIndex == 0)
|
||||
{
|
||||
gFSKWriteIndex = 0;
|
||||
gAirCopyBlockNumber = 0;
|
||||
gErrorsDuringAirCopy = 0;
|
||||
gInputBoxIndex = 0;
|
||||
gAirCopyIsSendMode = 0;
|
||||
|
||||
BK4819_PrepareFSKReceive();
|
||||
|
||||
gAircopyState = AIRCOPY_TRANSFER;
|
||||
}
|
||||
else
|
||||
gInputBox[--gInputBoxIndex] = 10;
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||
if (bKeyHeld || !bKeyPressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gInputBoxIndex == 0) {
|
||||
gFSKWriteIndex = 0;
|
||||
gAirCopyBlockNumber = 0;
|
||||
gInputBoxIndex = 0;
|
||||
gErrorsDuringAirCopy = 0;
|
||||
gAirCopyIsSendMode = 0;
|
||||
|
||||
BK4819_PrepareFSKReceive();
|
||||
|
||||
gAircopyState = AIRCOPY_TRANSFER;
|
||||
} else {
|
||||
gInputBox[--gInputBoxIndex] = 10;
|
||||
}
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||
}
|
||||
|
||||
static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
{
|
||||
gFSKWriteIndex = 0;
|
||||
gAirCopyBlockNumber = 0;
|
||||
gInputBoxIndex = 0;
|
||||
gAirCopyIsSendMode = 1;
|
||||
g_FSK_Buffer[0] = 0xABCD;
|
||||
g_FSK_Buffer[1] = 0;
|
||||
g_FSK_Buffer[35] = 0xDCBA;
|
||||
|
||||
AIRCOPY_SendMessage();
|
||||
|
||||
GUI_DisplayScreen();
|
||||
|
||||
gAircopyState = AIRCOPY_TRANSFER;
|
||||
if (bKeyHeld || !bKeyPressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
gFSKWriteIndex = 0;
|
||||
gAirCopyBlockNumber = 0;
|
||||
gInputBoxIndex = 0;
|
||||
gAirCopyIsSendMode = 1;
|
||||
g_FSK_Buffer[0] = 0xABCD;
|
||||
g_FSK_Buffer[1] = 0;
|
||||
g_FSK_Buffer[35] = 0xDCBA;
|
||||
|
||||
GUI_DisplayScreen();
|
||||
|
||||
gAircopyState = AIRCOPY_TRANSFER;
|
||||
}
|
||||
|
||||
void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
switch (Key)
|
||||
{
|
||||
case KEY_0:
|
||||
case KEY_1:
|
||||
case KEY_2:
|
||||
case KEY_3:
|
||||
case KEY_4:
|
||||
case KEY_5:
|
||||
case KEY_6:
|
||||
case KEY_7:
|
||||
case KEY_8:
|
||||
case KEY_9:
|
||||
AIRCOPY_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
case KEY_MENU:
|
||||
AIRCOPY_Key_MENU(bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
case KEY_EXIT:
|
||||
AIRCOPY_Key_EXIT(bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (Key) {
|
||||
case KEY_0:
|
||||
case KEY_1:
|
||||
case KEY_2:
|
||||
case KEY_3:
|
||||
case KEY_4:
|
||||
case KEY_5:
|
||||
case KEY_6:
|
||||
case KEY_7:
|
||||
case KEY_8:
|
||||
case KEY_9:
|
||||
AIRCOPY_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
case KEY_MENU:
|
||||
AIRCOPY_Key_MENU(bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
case KEY_EXIT:
|
||||
AIRCOPY_Key_EXIT(bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,10 @@ extern uint8_t gAirCopyIsSendMode;
|
||||
|
||||
extern uint16_t g_FSK_Buffer[36];
|
||||
|
||||
void AIRCOPY_SendMessage(void);
|
||||
bool AIRCOPY_SendMessage(void);
|
||||
void AIRCOPY_StorePacket(void);
|
||||
void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "functions.h"
|
||||
#include "frequencies.h"
|
||||
#include "radio.h"
|
||||
|
||||
void APP_EndTransmission(void);
|
||||
void CHANNEL_Next(bool bFlag, int8_t Direction);
|
||||
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix);
|
||||
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step);
|
||||
void APP_StartListening(FUNCTION_Type_t function);
|
||||
uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper);
|
||||
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction);
|
||||
void APP_Update(void);
|
||||
void APP_TimeSlice10ms(void);
|
||||
void APP_TimeSlice500ms(void);
|
||||
|
||||
273
app/chFrScanner.c
Normal file
@@ -0,0 +1,273 @@
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/chFrScanner.h"
|
||||
#include "functions.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
|
||||
int8_t gScanStateDir;
|
||||
bool gScanKeepResult;
|
||||
bool gScanPauseMode;
|
||||
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
uint32_t gScanRangeStart;
|
||||
uint32_t gScanRangeStop;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
SCAN_NEXT_CHAN_SCANLIST1 = 0,
|
||||
SCAN_NEXT_CHAN_SCANLIST2,
|
||||
SCAN_NEXT_CHAN_DUAL_WATCH,
|
||||
SCAN_NEXT_CHAN_MR,
|
||||
SCAN_NEXT_NUM
|
||||
} scan_next_chan_t;
|
||||
|
||||
scan_next_chan_t currentScanList;
|
||||
uint32_t initialFrqOrChan;
|
||||
uint8_t initialCROSS_BAND_RX_TX;
|
||||
uint32_t lastFoundFrqOrChan;
|
||||
|
||||
static void NextFreqChannel(void);
|
||||
static void NextMemChannel(void);
|
||||
|
||||
void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_direction)
|
||||
{
|
||||
if (storeBackupSettings) {
|
||||
initialCROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
|
||||
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
|
||||
gScanKeepResult = false;
|
||||
}
|
||||
|
||||
RADIO_SelectVfos();
|
||||
|
||||
gNextMrChannel = gRxVfo->CHANNEL_SAVE;
|
||||
currentScanList = SCAN_NEXT_CHAN_SCANLIST1;
|
||||
gScanStateDir = scan_direction;
|
||||
|
||||
if (IS_MR_CHANNEL(gNextMrChannel))
|
||||
{ // channel mode
|
||||
if (storeBackupSettings) {
|
||||
initialFrqOrChan = gRxVfo->CHANNEL_SAVE;
|
||||
lastFoundFrqOrChan = initialFrqOrChan;
|
||||
}
|
||||
NextMemChannel();
|
||||
}
|
||||
else
|
||||
{ // frequency mode
|
||||
if (storeBackupSettings) {
|
||||
initialFrqOrChan = gRxVfo->freq_config_RX.Frequency;
|
||||
lastFoundFrqOrChan = initialFrqOrChan;
|
||||
}
|
||||
NextFreqChannel();
|
||||
}
|
||||
|
||||
gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
|
||||
gScheduleScanListen = false;
|
||||
gRxReceptionMode = RX_MODE_NONE;
|
||||
gScanPauseMode = false;
|
||||
}
|
||||
|
||||
void CHFRSCANNER_ContinueScanning(void)
|
||||
{
|
||||
if (IS_FREQ_CHANNEL(gNextMrChannel))
|
||||
{
|
||||
if (gCurrentFunction == FUNCTION_INCOMING)
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
|
||||
else
|
||||
NextFreqChannel(); // switch to next frequency
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gCurrentCodeType == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING)
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
|
||||
else
|
||||
NextMemChannel(); // switch to next channel
|
||||
}
|
||||
|
||||
gScanPauseMode = false;
|
||||
gRxReceptionMode = RX_MODE_NONE;
|
||||
gScheduleScanListen = false;
|
||||
}
|
||||
|
||||
void CHFRSCANNER_Found(void)
|
||||
{
|
||||
switch (gEeprom.SCAN_RESUME_MODE)
|
||||
{
|
||||
case SCAN_RESUME_TO:
|
||||
if (!gScanPauseMode)
|
||||
{
|
||||
gScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms;
|
||||
gScheduleScanListen = false;
|
||||
gScanPauseMode = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCAN_RESUME_CO:
|
||||
case SCAN_RESUME_SE:
|
||||
gScanPauseDelayIn_10ms = 0;
|
||||
gScheduleScanListen = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (IS_MR_CHANNEL(gRxVfo->CHANNEL_SAVE)) { //memory scan
|
||||
lastFoundFrqOrChan = gRxVfo->CHANNEL_SAVE;
|
||||
}
|
||||
else { // frequency scan
|
||||
lastFoundFrqOrChan = gRxVfo->freq_config_RX.Frequency;
|
||||
}
|
||||
|
||||
|
||||
gScanKeepResult = true;
|
||||
}
|
||||
|
||||
void CHFRSCANNER_Stop(void)
|
||||
{
|
||||
if(initialCROSS_BAND_RX_TX != CROSS_BAND_OFF) {
|
||||
gEeprom.CROSS_BAND_RX_TX = initialCROSS_BAND_RX_TX;
|
||||
initialCROSS_BAND_RX_TX = CROSS_BAND_OFF;
|
||||
}
|
||||
|
||||
gScanStateDir = SCAN_OFF;
|
||||
|
||||
const uint32_t chFr = gScanKeepResult ? lastFoundFrqOrChan : initialFrqOrChan;
|
||||
const bool channelChanged = chFr != initialFrqOrChan;
|
||||
if (IS_MR_CHANNEL(gNextMrChannel)) {
|
||||
gEeprom.MrChannel[gEeprom.RX_VFO] = chFr;
|
||||
gEeprom.ScreenChannel[gEeprom.RX_VFO] = chFr;
|
||||
RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD);
|
||||
|
||||
if(channelChanged) {
|
||||
SETTINGS_SaveVfoIndices();
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
gRxVfo->freq_config_RX.Frequency = chFr;
|
||||
RADIO_ApplyOffset(gRxVfo);
|
||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||
if(channelChanged) {
|
||||
SETTINGS_SaveChannel(gRxVfo->CHANNEL_SAVE, gEeprom.RX_VFO, gRxVfo, 1);
|
||||
}
|
||||
}
|
||||
|
||||
RADIO_SetupRegisters(true);
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
|
||||
static void NextFreqChannel(void)
|
||||
{
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
if(gScanRangeStart) {
|
||||
gRxVfo->freq_config_RX.Frequency = APP_SetFreqByStepAndLimits(gRxVfo, gScanStateDir, gScanRangeStart, gScanRangeStop);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir);
|
||||
|
||||
RADIO_ApplyOffset(gRxVfo);
|
||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
#ifdef ENABLE_FASTER_CHANNEL_SCAN
|
||||
gScanPauseDelayIn_10ms = 9; // 90ms
|
||||
#else
|
||||
gScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms;
|
||||
#endif
|
||||
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
|
||||
static void NextMemChannel(void)
|
||||
{
|
||||
static unsigned int prev_mr_chan = 0;
|
||||
const bool enabled = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT] : true;
|
||||
const int chan1 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT] : -1;
|
||||
const int chan2 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT] : -1;
|
||||
const unsigned int prev_chan = gNextMrChannel;
|
||||
unsigned int chan = 0;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
switch (currentScanList)
|
||||
{
|
||||
case SCAN_NEXT_CHAN_SCANLIST1:
|
||||
prev_mr_chan = gNextMrChannel;
|
||||
|
||||
if (chan1 >= 0)
|
||||
{
|
||||
if (RADIO_CheckValidChannel(chan1, false, 0))
|
||||
{
|
||||
currentScanList = SCAN_NEXT_CHAN_SCANLIST1;
|
||||
gNextMrChannel = chan1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
[[fallthrough]];
|
||||
case SCAN_NEXT_CHAN_SCANLIST2:
|
||||
if (chan2 >= 0)
|
||||
{
|
||||
if (RADIO_CheckValidChannel(chan2, false, 0))
|
||||
{
|
||||
currentScanList = SCAN_NEXT_CHAN_SCANLIST2;
|
||||
gNextMrChannel = chan2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
[[fallthrough]];
|
||||
|
||||
// this bit doesn't yet work if the other VFO is a frequency
|
||||
case SCAN_NEXT_CHAN_DUAL_WATCH:
|
||||
// dual watch is enabled - include the other VFO in the scan
|
||||
// if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
|
||||
// {
|
||||
// chan = (gEeprom.RX_VFO + 1) & 1u;
|
||||
// chan = gEeprom.ScreenChannel[chan];
|
||||
// if (IS_MR_CHANNEL(chan))
|
||||
// {
|
||||
// currentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
|
||||
// gNextMrChannel = chan;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
default:
|
||||
case SCAN_NEXT_CHAN_MR:
|
||||
currentScanList = SCAN_NEXT_CHAN_MR;
|
||||
gNextMrChannel = prev_mr_chan;
|
||||
chan = 0xff;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!enabled || chan == 0xff)
|
||||
{
|
||||
chan = RADIO_FindNextChannel(gNextMrChannel + gScanStateDir, gScanStateDir, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT);
|
||||
if (chan == 0xFF)
|
||||
{ // no valid channel found
|
||||
chan = MR_CHANNEL_FIRST;
|
||||
}
|
||||
|
||||
gNextMrChannel = chan;
|
||||
}
|
||||
|
||||
if (gNextMrChannel != prev_chan)
|
||||
{
|
||||
gEeprom.MrChannel[ gEeprom.RX_VFO] = gNextMrChannel;
|
||||
gEeprom.ScreenChannel[gEeprom.RX_VFO] = gNextMrChannel;
|
||||
|
||||
RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FASTER_CHANNEL_SCAN
|
||||
gScanPauseDelayIn_10ms = 9; // 90ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ?
|
||||
#else
|
||||
gScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms;
|
||||
#endif
|
||||
|
||||
if (enabled)
|
||||
if (++currentScanList >= SCAN_NEXT_NUM)
|
||||
currentScanList = SCAN_NEXT_CHAN_SCANLIST1; // back round we go
|
||||
}
|
||||
23
app/chFrScanner.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef APP_CHFRSCANNER_H
|
||||
#define APP_CHFRSCANNER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// scan direction, if not equal SCAN_OFF indicates
|
||||
// that we are in a process of scanning channels/frequencies
|
||||
extern int8_t gScanStateDir;
|
||||
extern bool gScanKeepResult;
|
||||
extern bool gScanPauseMode;
|
||||
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
extern uint32_t gScanRangeStart;
|
||||
extern uint32_t gScanRangeStop;
|
||||
#endif
|
||||
|
||||
void CHFRSCANNER_Found(void);
|
||||
void CHFRSCANNER_Stop(void);
|
||||
void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_direction);
|
||||
void CHFRSCANNER_ContinueScanning(void);
|
||||
|
||||
#endif
|
||||
77
app/common.c
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "app/chFrScanner.h"
|
||||
#include "audio.h"
|
||||
#include "functions.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
void COMMON_KeypadLockToggle()
|
||||
{
|
||||
|
||||
if (gScreenToDisplay != DISPLAY_MENU &&
|
||||
gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
{ // toggle the keyboad lock
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
|
||||
#endif
|
||||
|
||||
gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK;
|
||||
|
||||
gRequestSaveSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
void COMMON_SwitchVFOs()
|
||||
{
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
gScanRangeStart = 0;
|
||||
#endif
|
||||
gEeprom.TX_VFO ^= 1;
|
||||
|
||||
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
|
||||
gEeprom.CROSS_BAND_RX_TX = gEeprom.TX_VFO + 1;
|
||||
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
|
||||
gEeprom.DUAL_WATCH = gEeprom.TX_VFO + 1;
|
||||
|
||||
gRequestSaveSettings = 1;
|
||||
gFlagReconfigureVfos = true;
|
||||
gScheduleDualWatch = true;
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
void COMMON_SwitchVFOMode()
|
||||
{
|
||||
#ifdef ENABLE_NOAA
|
||||
if (gEeprom.VFO_OPEN && !IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
#else
|
||||
if (gEeprom.VFO_OPEN)
|
||||
#endif
|
||||
{
|
||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
{ // swap to frequency mode
|
||||
gEeprom.ScreenChannel[gEeprom.TX_VFO] = gEeprom.FreqChannel[gEeprom.TX_VFO];
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
|
||||
#endif
|
||||
gRequestSaveVFO = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t Channel = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 0);
|
||||
if (Channel != 0xFF)
|
||||
{ // swap to channel mode
|
||||
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel;
|
||||
#ifdef ENABLE_VOICE
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
|
||||
AUDIO_SetDigitVoice(1, Channel + 1);
|
||||
gAnotherVoiceID = (VOICE_ID_t)0xFE;
|
||||
#endif
|
||||
gRequestSaveVFO = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
app/common.h
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
#ifndef APP_COMMON_H
|
||||
#define APP_COMMON_H
|
||||
|
||||
#include "functions.h"
|
||||
#include "settings.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
void COMMON_KeypadLockToggle();
|
||||
void COMMON_SwitchVFOs();
|
||||
void COMMON_SwitchVFOMode();
|
||||
|
||||
#endif
|
||||
372
app/dtmf.c
@@ -17,11 +17,13 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h> // NULL
|
||||
|
||||
#include "app/chFrScanner.h"
|
||||
#ifdef ENABLE_FMRADIO
|
||||
#include "app/fm.h"
|
||||
#endif
|
||||
#include "app/scanner.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "audio.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/eeprom.h"
|
||||
#include "driver/gpio.h"
|
||||
@@ -33,42 +35,91 @@
|
||||
#include "ui/ui.h"
|
||||
|
||||
char gDTMF_String[15];
|
||||
char gDTMF_InputBox[15];
|
||||
|
||||
char gDTMF_Received[16];
|
||||
uint8_t gDTMF_WriteIndex = 0;
|
||||
uint8_t gDTMF_PreviousIndex = 0;
|
||||
uint8_t gDTMF_RecvTimeout = 0;
|
||||
char gDTMF_InputBox[15];
|
||||
uint8_t gDTMF_InputBox_Index = 0;
|
||||
bool gDTMF_InputMode = false;
|
||||
uint8_t gDTMF_PreviousIndex = 0;
|
||||
|
||||
char gDTMF_RX_live[20];
|
||||
uint8_t gDTMF_RX_live_timeout = 0;
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
char gDTMF_RX[17];
|
||||
uint8_t gDTMF_RX_index = 0;
|
||||
uint8_t gDTMF_RX_timeout = 0;
|
||||
bool gDTMF_RX_pending = false;
|
||||
|
||||
bool gIsDtmfContactValid;
|
||||
char gDTMF_ID[4];
|
||||
char gDTMF_Caller[4];
|
||||
char gDTMF_Callee[4];
|
||||
DTMF_State_t gDTMF_State;
|
||||
bool gDTMF_DecodeRing;
|
||||
uint8_t gDTMF_DecodeRingCountdown_500ms;
|
||||
uint8_t gDTMFChosenContact;
|
||||
uint8_t gDTMF_AUTO_RESET_TIME;
|
||||
uint8_t gDTMF_InputIndex;
|
||||
bool gDTMF_InputMode;
|
||||
uint8_t gDTMF_chosen_contact;
|
||||
uint8_t gDTMF_auto_reset_time_500ms;
|
||||
DTMF_CallState_t gDTMF_CallState;
|
||||
DTMF_ReplyState_t gDTMF_ReplyState;
|
||||
DTMF_CallMode_t gDTMF_CallMode;
|
||||
|
||||
bool gDTMF_IsTx;
|
||||
|
||||
uint8_t gDTMF_TxStopCountdown_500ms;
|
||||
bool gDTMF_IsGroupCall;
|
||||
#endif
|
||||
DTMF_ReplyState_t gDTMF_ReplyState;
|
||||
|
||||
bool DTMF_ValidateCodes(char *pCode, uint8_t Size)
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
void DTMF_clear_RX(void)
|
||||
{
|
||||
gDTMF_RX_timeout = 0;
|
||||
gDTMF_RX_index = 0;
|
||||
gDTMF_RX_pending = false;
|
||||
memset(gDTMF_RX, 0, sizeof(gDTMF_RX));
|
||||
}
|
||||
#endif
|
||||
|
||||
void DTMF_SendEndOfTransmission(void)
|
||||
{
|
||||
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO) {
|
||||
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE);
|
||||
}
|
||||
|
||||
if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
&& gDTMF_CallState == DTMF_CALL_STATE_NONE
|
||||
#endif
|
||||
) { // end-of-tx
|
||||
if (gEeprom.DTMF_SIDE_TONE) {
|
||||
AUDIO_AudioPathOn();
|
||||
gEnableSpeaker = true;
|
||||
SYSTEM_DelayMs(60);
|
||||
}
|
||||
|
||||
BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE);
|
||||
|
||||
BK4819_PlayDTMFString(
|
||||
gEeprom.DTMF_DOWN_CODE,
|
||||
0,
|
||||
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME,
|
||||
gEeprom.DTMF_HASH_CODE_PERSIST_TIME,
|
||||
gEeprom.DTMF_CODE_PERSIST_TIME,
|
||||
gEeprom.DTMF_CODE_INTERVAL_TIME);
|
||||
|
||||
AUDIO_AudioPathOff();
|
||||
gEnableSpeaker = false;
|
||||
}
|
||||
|
||||
BK4819_ExitDTMF_TX(true);
|
||||
}
|
||||
|
||||
bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (pCode[0] == 0xFF || pCode[0] == 0)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < Size; i++)
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
if (pCode[i] == 0xFF || pCode[i] == 0)
|
||||
{
|
||||
@@ -83,36 +134,31 @@ bool DTMF_ValidateCodes(char *pCode, uint8_t Size)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
bool DTMF_GetContact(const int Index, char *pContact)
|
||||
{
|
||||
int i = -1;
|
||||
if (Index >= 0 && Index < MAX_DTMF_CONTACTS && pContact != NULL)
|
||||
{
|
||||
EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
|
||||
i = (int)pContact[0] - ' ';
|
||||
if (Index < 0 || Index >= MAX_DTMF_CONTACTS || pContact == NULL) {
|
||||
return false;
|
||||
}
|
||||
return (i < 0 || i >= 95) ? false : true;
|
||||
|
||||
EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
|
||||
|
||||
// check whether the first character is printable or not
|
||||
return (pContact[0] >= ' ' && pContact[0] < 127);
|
||||
}
|
||||
|
||||
bool DTMF_FindContact(const char *pContact, char *pResult)
|
||||
{
|
||||
char Contact[16];
|
||||
unsigned int i;
|
||||
pResult[0] = 0;
|
||||
|
||||
for (i = 0; i < MAX_DTMF_CONTACTS; i++)
|
||||
{
|
||||
unsigned int j;
|
||||
|
||||
if (!DTMF_GetContact(i, Contact))
|
||||
for (unsigned int i = 0; i < MAX_DTMF_CONTACTS; i++) {
|
||||
char Contact[16];
|
||||
if (!DTMF_GetContact(i, Contact)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
if (pContact[j] != Contact[j + 8])
|
||||
break;
|
||||
|
||||
if (j == 3)
|
||||
{
|
||||
memmove(pResult, Contact, 8);
|
||||
if (memcmp(pContact, Contact + 8, 3) == 0) {
|
||||
memcpy(pResult, Contact, 8);
|
||||
pResult[8] = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -121,16 +167,36 @@ bool DTMF_FindContact(const char *pContact, char *pResult)
|
||||
return false;
|
||||
}
|
||||
|
||||
char DTMF_GetCharacter(const uint8_t code)
|
||||
{
|
||||
const char list[] = "0123456789ABCD*#";
|
||||
return (code < ARRAY_SIZE(list)) ? list[code] : 0xFF;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size, bool bCheckGroup)
|
||||
char DTMF_GetCharacter(const unsigned int code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case KEY_0: return '0';
|
||||
case KEY_1: return '1';
|
||||
case KEY_2: return '2';
|
||||
case KEY_3: return '3';
|
||||
case KEY_4: return '4';
|
||||
case KEY_5: return '5';
|
||||
case KEY_6: return '6';
|
||||
case KEY_7: return '7';
|
||||
case KEY_8: return '8';
|
||||
case KEY_9: return '9';
|
||||
case KEY_MENU: return 'A';
|
||||
case KEY_UP: return 'B';
|
||||
case KEY_DOWN: return 'C';
|
||||
case KEY_EXIT: return 'D';
|
||||
case KEY_STAR: return '*';
|
||||
case KEY_F: return '#';
|
||||
default: return 0xff;
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
static bool CompareMessage(const char *pMsg, const char *pTemplate, const unsigned int size, const bool bCheckGroup)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < Size; i++)
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
if (pMsg[i] != pTemplate[i])
|
||||
{
|
||||
@@ -140,58 +206,78 @@ bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size,
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size)
|
||||
{
|
||||
for (unsigned int i = 0; i < size; i++)
|
||||
if (pMsg[i] == gEeprom.DTMF_GROUP_CALL_CODE) {
|
||||
return DTMF_CALL_MODE_GROUP;
|
||||
}
|
||||
|
||||
return DTMF_CALL_MODE_NOT_GROUP;
|
||||
}
|
||||
#endif
|
||||
|
||||
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, uint32_t Size)
|
||||
void DTMF_clear_input_box(void)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < Size; i++)
|
||||
if (pMsg[i] == gEeprom.DTMF_GROUP_CALL_CODE)
|
||||
break;
|
||||
return (i != Size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP;
|
||||
memset(gDTMF_InputBox, 0, sizeof(gDTMF_InputBox));
|
||||
gDTMF_InputBox_Index = 0;
|
||||
gDTMF_InputMode = false;
|
||||
}
|
||||
|
||||
void DTMF_Append(char Code)
|
||||
void DTMF_Append(const char code)
|
||||
{
|
||||
if (gDTMF_InputIndex == 0)
|
||||
if (gDTMF_InputBox_Index == 0)
|
||||
{
|
||||
memset(gDTMF_InputBox, '-', sizeof(gDTMF_InputBox));
|
||||
memset(gDTMF_InputBox, '-', sizeof(gDTMF_InputBox) - 1);
|
||||
gDTMF_InputBox[sizeof(gDTMF_InputBox) - 1] = 0;
|
||||
}
|
||||
else
|
||||
if (gDTMF_InputIndex >= sizeof(gDTMF_InputBox))
|
||||
return;
|
||||
|
||||
gDTMF_InputBox[gDTMF_InputIndex++] = Code;
|
||||
if (gDTMF_InputBox_Index < (sizeof(gDTMF_InputBox) - 1))
|
||||
gDTMF_InputBox[gDTMF_InputBox_Index++] = code;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
void DTMF_HandleRequest(void)
|
||||
{
|
||||
char String[20];
|
||||
uint8_t Offset;
|
||||
{ // proccess the RX'ed DTMF characters
|
||||
|
||||
if (!gDTMF_RequestPending)
|
||||
return;
|
||||
|
||||
gDTMF_RequestPending = false;
|
||||
|
||||
if (gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
|
||||
char String[21];
|
||||
unsigned int Offset;
|
||||
|
||||
if (!gDTMF_RX_pending)
|
||||
return; // nothing new received
|
||||
|
||||
if (gScanStateDir != SCAN_OFF || gCssBackgroundScan)
|
||||
{ // we're busy scanning
|
||||
DTMF_clear_RX();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED)
|
||||
{ // D-DCD is disabled or we're alive
|
||||
DTMF_clear_RX();
|
||||
return;
|
||||
}
|
||||
|
||||
gDTMF_RX_pending = false;
|
||||
|
||||
if (gDTMF_RX_index >= 9)
|
||||
{ // look for the KILL code
|
||||
|
||||
if (gDTMF_WriteIndex >= 9)
|
||||
{
|
||||
Offset = gDTMF_WriteIndex - 9;
|
||||
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.KILL_CODE);
|
||||
|
||||
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true))
|
||||
{
|
||||
Offset = gDTMF_RX_index - strlen(String);
|
||||
|
||||
if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true))
|
||||
{ // bugger
|
||||
|
||||
if (gEeprom.PERMIT_REMOTE_KILL)
|
||||
{
|
||||
gSetting_KILLED = true;
|
||||
gSetting_KILLED = true; // oooerr !
|
||||
|
||||
DTMF_clear_RX();
|
||||
|
||||
SETTINGS_SaveSettings();
|
||||
|
||||
@@ -212,82 +298,117 @@ void DTMF_HandleRequest(void)
|
||||
|
||||
gDTMF_CallState = DTMF_CALL_STATE_NONE;
|
||||
|
||||
gUpdateDisplay = true;
|
||||
gUpdateStatus = true;
|
||||
gUpdateDisplay = true;
|
||||
gUpdateStatus = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gDTMF_RX_index >= 9)
|
||||
{ // look for the REVIVE code
|
||||
|
||||
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.REVIVE_CODE);
|
||||
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true))
|
||||
{
|
||||
|
||||
Offset = gDTMF_RX_index - strlen(String);
|
||||
|
||||
if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true))
|
||||
{ // shit, we're back !
|
||||
|
||||
gSetting_KILLED = false;
|
||||
|
||||
DTMF_clear_RX();
|
||||
|
||||
SETTINGS_SaveSettings();
|
||||
|
||||
gDTMF_ReplyState = DTMF_REPLY_AB;
|
||||
gDTMF_CallState = DTMF_CALL_STATE_NONE;
|
||||
|
||||
gUpdateDisplay = true;
|
||||
gUpdateStatus = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gDTMF_WriteIndex >= 2)
|
||||
{
|
||||
if (DTMF_CompareMessage(gDTMF_Received + (gDTMF_WriteIndex - 2), "AB", 2, true))
|
||||
{
|
||||
gDTMF_State = DTMF_STATE_TX_SUCC;
|
||||
gUpdateDisplay = true;
|
||||
return;
|
||||
if (gDTMF_RX_index >= 2)
|
||||
{ // look for ACK reply
|
||||
char *pPrintStr = "AB";
|
||||
|
||||
Offset = gDTMF_RX_index - strlen(pPrintStr);
|
||||
|
||||
if (CompareMessage(gDTMF_RX + Offset, pPrintStr, strlen(pPrintStr), true)) {
|
||||
// ends with "AB"
|
||||
|
||||
if (gDTMF_ReplyState != DTMF_REPLY_NONE) // 1of11
|
||||
// if (gDTMF_CallState != DTMF_CALL_STATE_NONE) // 1of11
|
||||
// if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) // 1of11
|
||||
{
|
||||
gDTMF_State = DTMF_STATE_TX_SUCC;
|
||||
DTMF_clear_RX();
|
||||
gUpdateDisplay = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT && gDTMF_CallMode == DTMF_CALL_MODE_NOT_GROUP && gDTMF_WriteIndex >= 9)
|
||||
{
|
||||
Offset = gDTMF_WriteIndex - 9;
|
||||
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT &&
|
||||
gDTMF_CallMode == DTMF_CALL_MODE_NOT_GROUP &&
|
||||
gDTMF_RX_index >= 9)
|
||||
{ // waiting for a reply
|
||||
|
||||
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, "AAAAA");
|
||||
|
||||
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, false))
|
||||
{
|
||||
Offset = gDTMF_RX_index - strlen(String);
|
||||
|
||||
if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), false))
|
||||
{ // we got a response
|
||||
gDTMF_State = DTMF_STATE_CALL_OUT_RSP;
|
||||
DTMF_clear_RX();
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (gSetting_KILLED || gDTMF_CallState != DTMF_CALL_STATE_NONE)
|
||||
{ // we've been killed or expecting a reply
|
||||
return;
|
||||
}
|
||||
|
||||
if (gDTMF_WriteIndex >= 7)
|
||||
{
|
||||
Offset = gDTMF_WriteIndex - 7;
|
||||
|
||||
sprintf(String, "%s%c", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE);
|
||||
if (gDTMF_RX_index >= 7)
|
||||
{ // see if we're being called
|
||||
|
||||
gDTMF_IsGroupCall = false;
|
||||
|
||||
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 4, true))
|
||||
{
|
||||
sprintf(String, "%s%c", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE);
|
||||
|
||||
Offset = gDTMF_RX_index - strlen(String) - 3;
|
||||
|
||||
if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true))
|
||||
{ // it's for us !
|
||||
|
||||
gDTMF_CallState = DTMF_CALL_STATE_RECEIVED;
|
||||
|
||||
memmove(gDTMF_Callee, gDTMF_Received + Offset + 0, 3);
|
||||
memmove(gDTMF_Caller, gDTMF_Received + Offset + 4, 3);
|
||||
memset(gDTMF_Callee, 0, sizeof(gDTMF_Callee));
|
||||
memset(gDTMF_Caller, 0, sizeof(gDTMF_Caller));
|
||||
memcpy(gDTMF_Callee, gDTMF_RX + Offset + 0, 3);
|
||||
memcpy(gDTMF_Caller, gDTMF_RX + Offset + 4, 3);
|
||||
|
||||
DTMF_clear_RX();
|
||||
|
||||
gUpdateDisplay = true;
|
||||
|
||||
switch (gEeprom.DTMF_DECODE_RESPONSE)
|
||||
{
|
||||
case 3:
|
||||
gDTMF_DecodeRing = true;
|
||||
case DTMF_DEC_RESPONSE_BOTH:
|
||||
gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms;
|
||||
// Fallthrough
|
||||
case 2:
|
||||
[[fallthrough]];
|
||||
case DTMF_DEC_RESPONSE_REPLY:
|
||||
gDTMF_ReplyState = DTMF_REPLY_AAAAA;
|
||||
break;
|
||||
case 1:
|
||||
gDTMF_DecodeRing = true;
|
||||
case DTMF_DEC_RESPONSE_RING:
|
||||
gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms;
|
||||
break;
|
||||
default:
|
||||
gDTMF_DecodeRing = false;
|
||||
case DTMF_DEC_RESPONSE_NONE:
|
||||
gDTMF_DecodeRingCountdown_500ms = 0;
|
||||
gDTMF_ReplyState = DTMF_REPLY_NONE;
|
||||
break;
|
||||
}
|
||||
@@ -297,45 +418,57 @@ void DTMF_HandleRequest(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void DTMF_Reply(void)
|
||||
{
|
||||
uint16_t Delay;
|
||||
char String[20];
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
char String[23];
|
||||
#endif
|
||||
const char *pString = NULL;
|
||||
|
||||
switch (gDTMF_ReplyState)
|
||||
{
|
||||
case DTMF_REPLY_NONE:
|
||||
return;
|
||||
|
||||
case DTMF_REPLY_ANI:
|
||||
if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF)
|
||||
{
|
||||
pString = gDTMF_String;
|
||||
}
|
||||
else
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
if (gDTMF_CallMode != DTMF_CALL_MODE_DTMF)
|
||||
{ // append our ID code onto the end of the DTMF code to send
|
||||
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, gEeprom.ANI_DTMF_ID);
|
||||
pString = String;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pString = gDTMF_String;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
case DTMF_REPLY_AB:
|
||||
pString = "AB";
|
||||
break;
|
||||
|
||||
|
||||
case DTMF_REPLY_AAAAA:
|
||||
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, "AAAAA");
|
||||
pString = String;
|
||||
break;
|
||||
|
||||
#endif
|
||||
default:
|
||||
if (gDTMF_CallState != DTMF_CALL_STATE_NONE || (gCurrentVfo->DTMF_PTT_ID_TX_MODE != PTT_ID_BOT && gCurrentVfo->DTMF_PTT_ID_TX_MODE != PTT_ID_BOTH))
|
||||
case DTMF_REPLY_NONE:
|
||||
if (
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
gDTMF_CallState != DTMF_CALL_STATE_NONE ||
|
||||
#endif
|
||||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO ||
|
||||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_OFF ||
|
||||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN)
|
||||
{
|
||||
gDTMF_ReplyState = DTMF_REPLY_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
// send TX-UP DTMF
|
||||
pString = gEeprom.DTMF_UP_CODE;
|
||||
break;
|
||||
}
|
||||
@@ -344,14 +477,15 @@ void DTMF_Reply(void)
|
||||
|
||||
if (pString == NULL)
|
||||
return;
|
||||
|
||||
Delay = gEeprom.DTMF_PRELOAD_TIME;
|
||||
|
||||
Delay = (gEeprom.DTMF_PRELOAD_TIME < 200) ? 200 : gEeprom.DTMF_PRELOAD_TIME;
|
||||
|
||||
if (gEeprom.DTMF_SIDE_TONE)
|
||||
{
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
{ // the user will also hear the transmitted tones
|
||||
AUDIO_AudioPathOn();
|
||||
gEnableSpeaker = true;
|
||||
Delay = (gEeprom.DTMF_PRELOAD_TIME < 60) ? 60 : gEeprom.DTMF_PRELOAD_TIME;
|
||||
}
|
||||
|
||||
SYSTEM_DelayMs(Delay);
|
||||
|
||||
BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE);
|
||||
@@ -364,7 +498,7 @@ void DTMF_Reply(void)
|
||||
gEeprom.DTMF_CODE_PERSIST_TIME,
|
||||
gEeprom.DTMF_CODE_INTERVAL_TIME);
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOff();
|
||||
|
||||
gEnableSpeaker = false;
|
||||
|
||||
|
||||
57
app/dtmf.h
@@ -33,7 +33,15 @@ typedef enum DTMF_State_t DTMF_State_t;
|
||||
enum DTMF_CallState_t {
|
||||
DTMF_CALL_STATE_NONE = 0,
|
||||
DTMF_CALL_STATE_CALL_OUT,
|
||||
DTMF_CALL_STATE_RECEIVED
|
||||
DTMF_CALL_STATE_RECEIVED,
|
||||
DTMF_CALL_STATE_RECEIVED_STAY
|
||||
};
|
||||
|
||||
enum DTMF_DecodeResponse_t {
|
||||
DTMF_DEC_RESPONSE_NONE = 0,
|
||||
DTMF_DEC_RESPONSE_RING,
|
||||
DTMF_DEC_RESPONSE_REPLY,
|
||||
DTMF_DEC_RESPONSE_BOTH
|
||||
};
|
||||
|
||||
typedef enum DTMF_CallState_t DTMF_CallState_t;
|
||||
@@ -53,44 +61,59 @@ enum DTMF_CallMode_t {
|
||||
DTMF_CALL_MODE_DTMF
|
||||
};
|
||||
|
||||
enum { // seconds
|
||||
DTMF_HOLD_MIN = 5,
|
||||
DTMF_HOLD_MAX = 60
|
||||
};
|
||||
|
||||
typedef enum DTMF_CallMode_t DTMF_CallMode_t;
|
||||
|
||||
extern char gDTMF_String[15];
|
||||
extern char gDTMF_InputBox[15];
|
||||
|
||||
extern char gDTMF_Received[16];
|
||||
extern uint8_t gDTMF_WriteIndex;
|
||||
extern char gDTMF_InputBox[15];
|
||||
extern uint8_t gDTMF_InputBox_Index;
|
||||
extern bool gDTMF_InputMode;
|
||||
extern uint8_t gDTMF_PreviousIndex;
|
||||
extern uint8_t gDTMF_RecvTimeout;
|
||||
|
||||
extern char gDTMF_RX_live[20];
|
||||
extern uint8_t gDTMF_RX_live_timeout;
|
||||
|
||||
extern DTMF_ReplyState_t gDTMF_ReplyState;
|
||||
|
||||
bool DTMF_ValidateCodes(char *pCode, const unsigned int size);
|
||||
char DTMF_GetCharacter(const unsigned int code);
|
||||
void DTMF_clear_input_box(void);
|
||||
void DTMF_Append(const char code);
|
||||
void DTMF_Reply(void);
|
||||
void DTMF_SendEndOfTransmission(void);
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
|
||||
extern char gDTMF_RX[17];
|
||||
extern uint8_t gDTMF_RX_index;
|
||||
extern uint8_t gDTMF_RX_timeout;
|
||||
extern bool gDTMF_RX_pending;
|
||||
|
||||
extern bool gIsDtmfContactValid;
|
||||
extern char gDTMF_ID[4];
|
||||
extern char gDTMF_Caller[4];
|
||||
extern char gDTMF_Callee[4];
|
||||
extern DTMF_State_t gDTMF_State;
|
||||
extern bool gDTMF_DecodeRing;
|
||||
extern uint8_t gDTMF_DecodeRingCountdown_500ms;
|
||||
extern uint8_t gDTMFChosenContact;
|
||||
extern uint8_t gDTMF_AUTO_RESET_TIME;
|
||||
extern uint8_t gDTMF_InputIndex;
|
||||
extern bool gDTMF_InputMode;
|
||||
extern uint8_t gDTMF_chosen_contact;
|
||||
extern uint8_t gDTMF_auto_reset_time_500ms;
|
||||
extern DTMF_CallState_t gDTMF_CallState;
|
||||
extern DTMF_ReplyState_t gDTMF_ReplyState;
|
||||
|
||||
extern DTMF_CallMode_t gDTMF_CallMode;
|
||||
extern bool gDTMF_IsTx;
|
||||
extern uint8_t gDTMF_TxStopCountdown_500ms;
|
||||
|
||||
bool DTMF_ValidateCodes(char *pCode, uint8_t Size);
|
||||
void DTMF_clear_RX(void);
|
||||
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size);
|
||||
bool DTMF_GetContact(const int Index, char *pContact);
|
||||
bool DTMF_FindContact(const char *pContact, char *pResult);
|
||||
char DTMF_GetCharacter(const uint8_t code);
|
||||
bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, uint8_t Size, bool bFlag);
|
||||
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, uint32_t Size);
|
||||
void DTMF_Append(char Code);
|
||||
void DTMF_HandleRequest(void);
|
||||
void DTMF_Reply(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
66
app/flashlight.c
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifdef ENABLE_FLASHLIGHT
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
|
||||
#include "flashlight.h"
|
||||
|
||||
enum FlashlightMode_t gFlashLightState;
|
||||
|
||||
void FlashlightTimeSlice()
|
||||
{
|
||||
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) {
|
||||
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gFlashLightState == FLASHLIGHT_SOS) {
|
||||
const uint16_t u = 15;
|
||||
static uint8_t c;
|
||||
static uint16_t next;
|
||||
|
||||
if (gFlashLightBlinkCounter - next > 7 * u) {
|
||||
c = 0;
|
||||
next = gFlashLightBlinkCounter + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gFlashLightBlinkCounter == next) {
|
||||
if (c==0) {
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
} else {
|
||||
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
}
|
||||
|
||||
if (c >= 18) {
|
||||
next = gFlashLightBlinkCounter + 7 * u;
|
||||
c = 0;
|
||||
} else if(c==7 || c==9 || c==11) {
|
||||
next = gFlashLightBlinkCounter + 3 * u;
|
||||
} else {
|
||||
next = gFlashLightBlinkCounter + u;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ACTION_FlashLight(void)
|
||||
{
|
||||
switch (gFlashLightState) {
|
||||
case FLASHLIGHT_OFF:
|
||||
gFlashLightState++;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
break;
|
||||
case FLASHLIGHT_ON:
|
||||
case FLASHLIGHT_BLINK:
|
||||
gFlashLightState++;
|
||||
break;
|
||||
case FLASHLIGHT_SOS:
|
||||
default:
|
||||
gFlashLightState = 0;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
23
app/flashlight.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef APP_FLASHLIGHT_H
|
||||
#define APP_FLASHLIGHT_H
|
||||
|
||||
#ifdef ENABLE_FLASHLIGHT
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum FlashlightMode_t {
|
||||
FLASHLIGHT_OFF = 0,
|
||||
FLASHLIGHT_ON,
|
||||
FLASHLIGHT_BLINK,
|
||||
FLASHLIGHT_SOS
|
||||
};
|
||||
|
||||
extern enum FlashlightMode_t gFlashLightState;
|
||||
extern volatile uint16_t gFlashLightBlinkCounter;
|
||||
|
||||
void FlashlightTimeSlice(void);
|
||||
void ACTION_FlashLight(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
511
app/fm.c
@@ -45,24 +45,34 @@ bool gFM_AutoScan;
|
||||
uint8_t gFM_ChannelPosition;
|
||||
bool gFM_FoundFrequency;
|
||||
bool gFM_AutoScan;
|
||||
uint8_t gFM_ResumeCountdown_500ms;
|
||||
uint16_t gFM_RestoreCountdown_10ms;
|
||||
|
||||
|
||||
|
||||
const uint8_t BUTTON_STATE_PRESSED = 1 << 0;
|
||||
const uint8_t BUTTON_STATE_HELD = 1 << 1;
|
||||
|
||||
const uint8_t BUTTON_EVENT_PRESSED = BUTTON_STATE_PRESSED;
|
||||
const uint8_t BUTTON_EVENT_HELD = BUTTON_STATE_PRESSED | BUTTON_STATE_HELD;
|
||||
const uint8_t BUTTON_EVENT_SHORT = 0;
|
||||
const uint8_t BUTTON_EVENT_LONG = BUTTON_STATE_HELD;
|
||||
|
||||
|
||||
static void Key_FUNC(KEY_Code_t Key, uint8_t state);
|
||||
|
||||
bool FM_CheckValidChannel(uint8_t Channel)
|
||||
{
|
||||
return (Channel < ARRAY_SIZE(gFM_Channels) && (gFM_Channels[Channel] >= 760 && gFM_Channels[Channel] < 1080)) ? true : false;
|
||||
return Channel < ARRAY_SIZE(gFM_Channels) &&
|
||||
gFM_Channels[Channel] >= BK1080_GetFreqLoLimit(gEeprom.FM_Band) &&
|
||||
gFM_Channels[Channel] < BK1080_GetFreqHiLimit(gEeprom.FM_Band);
|
||||
}
|
||||
|
||||
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(gFM_Channels); i++)
|
||||
{
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(gFM_Channels); i++) {
|
||||
if (Channel == 0xFF)
|
||||
Channel = ARRAY_SIZE(gFM_Channels) - 1;
|
||||
else
|
||||
if (Channel >= ARRAY_SIZE(gFM_Channels))
|
||||
else if (Channel >= ARRAY_SIZE(gFM_Channels))
|
||||
Channel = 0;
|
||||
if (FM_CheckValidChannel(Channel))
|
||||
return Channel;
|
||||
@@ -76,11 +86,9 @@ int FM_ConfigureChannelState(void)
|
||||
{
|
||||
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
|
||||
|
||||
if (gEeprom.FM_IsMrMode)
|
||||
{
|
||||
if (gEeprom.FM_IsMrMode) {
|
||||
const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel, FM_CHANNEL_UP);
|
||||
if (Channel == 0xFF)
|
||||
{
|
||||
if (Channel == 0xFF) {
|
||||
gEeprom.FM_IsMrMode = false;
|
||||
return -1;
|
||||
}
|
||||
@@ -97,22 +105,20 @@ void FM_TurnOff(void)
|
||||
gFM_ScanState = FM_SCAN_OFF;
|
||||
gFM_RestoreCountdown_10ms = 0;
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
|
||||
AUDIO_AudioPathOff();
|
||||
gEnableSpeaker = false;
|
||||
|
||||
BK1080_Init(0, false);
|
||||
BK1080_Init0();
|
||||
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
void FM_EraseChannels(void)
|
||||
{
|
||||
unsigned int i;
|
||||
uint8_t Template[8];
|
||||
|
||||
memset(Template, 0xFF, sizeof(Template));
|
||||
for (i = 0; i < 5; i++)
|
||||
|
||||
for (unsigned i = 0; i < 5; i++)
|
||||
EEPROM_WriteBuffer(0x0E40 + (i * 8), Template);
|
||||
|
||||
memset(gFM_Channels, 0xFF, sizeof(gFM_Channels));
|
||||
@@ -120,7 +126,7 @@ void FM_EraseChannels(void)
|
||||
|
||||
void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOff();
|
||||
|
||||
gEnableSpeaker = false;
|
||||
|
||||
@@ -132,42 +138,39 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
|
||||
gAskToDelete = false;
|
||||
gEeprom.FM_FrequencyPlaying = Frequency;
|
||||
|
||||
if (!bFlag)
|
||||
{
|
||||
if (!bFlag) {
|
||||
Frequency += Step;
|
||||
if (Frequency < gEeprom.FM_LowerLimit)
|
||||
Frequency = gEeprom.FM_UpperLimit;
|
||||
else
|
||||
if (Frequency > gEeprom.FM_UpperLimit)
|
||||
Frequency = gEeprom.FM_LowerLimit;
|
||||
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band))
|
||||
Frequency = BK1080_GetFreqHiLimit(gEeprom.FM_Band);
|
||||
else if (Frequency > BK1080_GetFreqHiLimit(gEeprom.FM_Band))
|
||||
Frequency = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||
|
||||
gEeprom.FM_FrequencyPlaying = Frequency;
|
||||
}
|
||||
|
||||
gFM_ScanState = Step;
|
||||
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||
}
|
||||
|
||||
void FM_PlayAndUpdate(void)
|
||||
{
|
||||
gFM_ScanState = FM_SCAN_OFF;
|
||||
|
||||
if (gFM_AutoScan)
|
||||
{
|
||||
if (gFM_AutoScan) {
|
||||
gEeprom.FM_IsMrMode = true;
|
||||
gEeprom.FM_SelectedChannel = 0;
|
||||
}
|
||||
|
||||
FM_ConfigureChannelState();
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||
SETTINGS_SaveFM();
|
||||
|
||||
gFmPlayCountdown_10ms = 0;
|
||||
gScheduleFM = false;
|
||||
gAskToSave = false;
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOn();
|
||||
|
||||
gEnableSpeaker = true;
|
||||
}
|
||||
@@ -181,42 +184,36 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
|
||||
// This is supposed to be a signed value, but above function is unsigned
|
||||
const uint16_t Deviation = BK1080_REG_07_GET_FREQD(Test2);
|
||||
|
||||
if (BK1080_REG_07_GET_SNR(Test2) >= 2)
|
||||
{
|
||||
const uint16_t Status = BK1080_ReadRegister(BK1080_REG_10);
|
||||
if ((Status & BK1080_REG_10_MASK_AFCRL) == BK1080_REG_10_AFCRL_NOT_RAILED && BK1080_REG_10_GET_RSSI(Status) >= 10)
|
||||
{
|
||||
//if (Deviation > -281 && Deviation < 280)
|
||||
if (Deviation < 280 || Deviation > 3815)
|
||||
{
|
||||
// not BLE(less than or equal)
|
||||
|
||||
if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1)
|
||||
{
|
||||
if (BK1080_FrequencyDeviation & 0x800)
|
||||
goto Bail;
|
||||
|
||||
if (BK1080_FrequencyDeviation < 20)
|
||||
goto Bail;
|
||||
}
|
||||
|
||||
// not BLT(less than)
|
||||
|
||||
if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1)
|
||||
{
|
||||
if ((BK1080_FrequencyDeviation & 0x800) == 0)
|
||||
goto Bail;
|
||||
|
||||
// if (BK1080_FrequencyDeviation > -21)
|
||||
if (BK1080_FrequencyDeviation > 4075)
|
||||
goto Bail;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
if (BK1080_REG_07_GET_SNR(Test2) <= 2) {
|
||||
goto Bail;
|
||||
}
|
||||
|
||||
const uint16_t Status = BK1080_ReadRegister(BK1080_REG_10);
|
||||
|
||||
if ((Status & BK1080_REG_10_MASK_AFCRL) != BK1080_REG_10_AFCRL_NOT_RAILED || BK1080_REG_10_GET_RSSI(Status) < 10) {
|
||||
goto Bail;
|
||||
}
|
||||
|
||||
//if (Deviation > -281 && Deviation < 280)
|
||||
if (Deviation >= 280 && Deviation <= 3815) {
|
||||
goto Bail;
|
||||
}
|
||||
|
||||
// not BLE(less than or equal)
|
||||
if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1) {
|
||||
if (BK1080_FrequencyDeviation & 0x800 || (BK1080_FrequencyDeviation < 20))
|
||||
goto Bail;
|
||||
}
|
||||
|
||||
// not BLT(less than)
|
||||
|
||||
if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1) {
|
||||
if ((BK1080_FrequencyDeviation & 0x800) == 0 || (BK1080_FrequencyDeviation > 4075))
|
||||
goto Bail;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
Bail:
|
||||
BK1080_FrequencyDeviation = Deviation;
|
||||
BK1080_BaseFrequency = Frequency;
|
||||
@@ -224,156 +221,142 @@ Bail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
|
||||
{
|
||||
#define STATE_FREQ_MODE 0
|
||||
#define STATE_MR_MODE 1
|
||||
#define STATE_SAVE 2
|
||||
enum { STATE_FREQ_MODE, STATE_MR_MODE, STATE_SAVE };
|
||||
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
{
|
||||
if (!gWasFKeyPressed)
|
||||
{
|
||||
uint8_t State;
|
||||
if (state == BUTTON_EVENT_SHORT && !gWasFKeyPressed) {
|
||||
uint8_t State;
|
||||
|
||||
if (gAskToDelete)
|
||||
{
|
||||
if (gAskToDelete) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gAskToSave) {
|
||||
State = STATE_SAVE;
|
||||
}
|
||||
else {
|
||||
if (gFM_ScanState != FM_SCAN_OFF) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gAskToSave)
|
||||
{
|
||||
State = STATE_SAVE;
|
||||
State = gEeprom.FM_IsMrMode ? STATE_MR_MODE : STATE_FREQ_MODE;
|
||||
}
|
||||
|
||||
INPUTBOX_Append(Key);
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
|
||||
if (State == STATE_FREQ_MODE) {
|
||||
if (gInputBoxIndex == 1) {
|
||||
if (gInputBox[0] > 1) {
|
||||
gInputBox[1] = gInputBox[0];
|
||||
gInputBox[0] = 0;
|
||||
gInputBoxIndex = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gFM_ScanState != FM_SCAN_OFF)
|
||||
{
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
else if (gInputBoxIndex > 3) {
|
||||
uint32_t Frequency;
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
Frequency = StrToUL(INPUTBOX_GetAscii());
|
||||
|
||||
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band) || BK1080_GetFreqHiLimit(gEeprom.FM_Band) < Frequency) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
return;
|
||||
}
|
||||
|
||||
State = gEeprom.FM_IsMrMode ? STATE_MR_MODE : STATE_FREQ_MODE;
|
||||
gEeprom.FM_SelectedFrequency = (uint16_t)Frequency;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||
gRequestSaveFM = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (gInputBoxIndex == 2) {
|
||||
uint8_t Channel;
|
||||
|
||||
INPUTBOX_Append(Key);
|
||||
gInputBoxIndex = 0;
|
||||
Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1;
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
|
||||
if (State == STATE_FREQ_MODE)
|
||||
{
|
||||
if (gInputBoxIndex == 1)
|
||||
{
|
||||
if (gInputBox[0] > 1)
|
||||
{
|
||||
gInputBox[1] = gInputBox[0];
|
||||
gInputBox[0] = 0;
|
||||
gInputBoxIndex = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (gInputBoxIndex > 3)
|
||||
{
|
||||
uint32_t Frequency;
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
NUMBER_Get(gInputBox, &Frequency);
|
||||
Frequency /= 10000;
|
||||
|
||||
if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency)
|
||||
{
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
return;
|
||||
}
|
||||
|
||||
gEeprom.FM_SelectedFrequency = (uint16_t)Frequency;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
|
||||
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
||||
if (State == STATE_MR_MODE) {
|
||||
if (FM_CheckValidChannel(Channel)) {
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gEeprom.FM_SelectedChannel = Channel;
|
||||
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||
gRequestSaveFM = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (gInputBoxIndex == 2)
|
||||
{
|
||||
uint8_t Channel;
|
||||
|
||||
else if (Channel < 20) {
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
gInputBoxIndex = 0;
|
||||
Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1;
|
||||
|
||||
if (State == STATE_MR_MODE)
|
||||
{
|
||||
if (FM_CheckValidChannel(Channel))
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gEeprom.FM_SelectedChannel = Channel;
|
||||
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
||||
gRequestSaveFM = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (Channel < 20)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
gInputBoxIndex = 0;
|
||||
gFM_ChannelPosition = Channel;
|
||||
return;
|
||||
}
|
||||
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
gFM_ChannelPosition = Channel;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
Key_FUNC(Key, state);
|
||||
}
|
||||
|
||||
static void Key_FUNC(KEY_Code_t Key, uint8_t state)
|
||||
{
|
||||
if (state == BUTTON_EVENT_SHORT || state == BUTTON_EVENT_HELD) {
|
||||
bool autoScan = gWasFKeyPressed || (state == BUTTON_EVENT_HELD);
|
||||
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
gWasFKeyPressed = false;
|
||||
gUpdateStatus = true;
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
|
||||
switch (Key)
|
||||
{
|
||||
switch (Key) {
|
||||
case KEY_0:
|
||||
ACTION_FM();
|
||||
break;
|
||||
|
||||
case KEY_1:
|
||||
gEeprom.FM_Band++;
|
||||
gRequestSaveFM = true;
|
||||
break;
|
||||
|
||||
// case KEY_2:
|
||||
// gEeprom.FM_Space = (gEeprom.FM_Space + 1) % 3;
|
||||
// gRequestSaveFM = true;
|
||||
// break;
|
||||
|
||||
case KEY_3:
|
||||
gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode;
|
||||
|
||||
if (!FM_ConfigureChannelState())
|
||||
{
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
||||
if (!FM_ConfigureChannelState()) {
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||
gRequestSaveFM = true;
|
||||
}
|
||||
else
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
break;
|
||||
|
||||
case KEY_2:
|
||||
ACTION_Scan(true);
|
||||
break;
|
||||
|
||||
case KEY_3:
|
||||
ACTION_Scan(false);
|
||||
case KEY_STAR:
|
||||
ACTION_Scan(autoScan);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -383,22 +366,16 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
}
|
||||
}
|
||||
|
||||
static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
static void Key_EXIT(uint8_t state)
|
||||
{
|
||||
if (bKeyHeld)
|
||||
return;
|
||||
|
||||
if (!bKeyPressed)
|
||||
if (state != BUTTON_EVENT_SHORT)
|
||||
return;
|
||||
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
if (gFM_ScanState == FM_SCAN_OFF)
|
||||
{
|
||||
if (gInputBoxIndex == 0)
|
||||
{
|
||||
if (!gAskToSave && !gAskToDelete)
|
||||
{
|
||||
if (gFM_ScanState == FM_SCAN_OFF) {
|
||||
if (gInputBoxIndex == 0) {
|
||||
if (!gAskToSave && !gAskToDelete) {
|
||||
ACTION_FM();
|
||||
return;
|
||||
}
|
||||
@@ -406,135 +383,102 @@ static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
gAskToSave = false;
|
||||
gAskToDelete = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
gInputBox[--gInputBoxIndex] = 10;
|
||||
|
||||
if (gInputBoxIndex)
|
||||
{
|
||||
if (gInputBoxIndex != 1)
|
||||
{
|
||||
if (gInputBoxIndex) {
|
||||
if (gInputBoxIndex != 1) {
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gInputBox[0] != 0)
|
||||
{
|
||||
if (gInputBox[0] != 0) {
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
FM_PlayAndUpdate();
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
}
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
}
|
||||
|
||||
static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld)
|
||||
static void Key_MENU(uint8_t state)
|
||||
{
|
||||
if (bKeyHeld)
|
||||
if (state != BUTTON_EVENT_SHORT)
|
||||
return;
|
||||
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
if (gFM_ScanState == FM_SCAN_OFF)
|
||||
{
|
||||
if (!gEeprom.FM_IsMrMode)
|
||||
{
|
||||
if (gAskToSave)
|
||||
{
|
||||
if (gFM_ScanState == FM_SCAN_OFF) {
|
||||
if (!gEeprom.FM_IsMrMode) {
|
||||
if (gAskToSave) {
|
||||
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying;
|
||||
gAskToSave = false;
|
||||
gRequestSaveFM = true;
|
||||
gRequestSaveFM = true;
|
||||
}
|
||||
else
|
||||
gAskToSave = true;
|
||||
gAskToSave = !gAskToSave;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gAskToDelete)
|
||||
{
|
||||
else {
|
||||
if (gAskToDelete) {
|
||||
gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF;
|
||||
|
||||
FM_ConfigureChannelState();
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||
|
||||
gRequestSaveFM = true;
|
||||
gAskToDelete = false;
|
||||
}
|
||||
else
|
||||
gAskToDelete = true;
|
||||
gAskToDelete = !gAskToDelete;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gFM_AutoScan || !gFM_FoundFrequency)
|
||||
{
|
||||
else {
|
||||
if (gFM_AutoScan || !gFM_FoundFrequency) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
gInputBoxIndex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gAskToSave)
|
||||
{
|
||||
if (gAskToSave) {
|
||||
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying;
|
||||
gAskToSave = false;
|
||||
gRequestSaveFM = true;
|
||||
}
|
||||
else
|
||||
gAskToSave = true;
|
||||
gAskToSave = !gAskToSave;
|
||||
}
|
||||
}
|
||||
|
||||
static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step)
|
||||
static void Key_UP_DOWN(uint8_t state, int8_t Step)
|
||||
{
|
||||
if (bKeyHeld || !bKeyPressed)
|
||||
{
|
||||
if (gInputBoxIndex)
|
||||
return;
|
||||
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gInputBoxIndex)
|
||||
{
|
||||
if (state == BUTTON_EVENT_PRESSED) {
|
||||
if (gInputBoxIndex) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
} else if (gInputBoxIndex || state!=BUTTON_EVENT_HELD) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gAskToSave)
|
||||
{
|
||||
if (gAskToSave) {
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gFM_ScanState != FM_SCAN_OFF)
|
||||
{
|
||||
if (gFM_AutoScan)
|
||||
{
|
||||
if (gFM_ScanState != FM_SCAN_OFF) {
|
||||
if (gFM_AutoScan) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
@@ -544,8 +488,7 @@ static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step)
|
||||
return;
|
||||
}
|
||||
|
||||
if (gEeprom.FM_IsMrMode)
|
||||
{
|
||||
if (gEeprom.FM_IsMrMode) {
|
||||
const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step);
|
||||
if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel)
|
||||
goto Bail;
|
||||
@@ -553,14 +496,13 @@ static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step)
|
||||
gEeprom.FM_SelectedChannel = Channel;
|
||||
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step;
|
||||
if (Frequency < gEeprom.FM_LowerLimit)
|
||||
Frequency = gEeprom.FM_UpperLimit;
|
||||
else
|
||||
if (Frequency > gEeprom.FM_UpperLimit)
|
||||
Frequency = gEeprom.FM_LowerLimit;
|
||||
|
||||
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band))
|
||||
Frequency = BK1080_GetFreqHiLimit(gEeprom.FM_Band);
|
||||
else if (Frequency > BK1080_GetFreqHiLimit(gEeprom.FM_Band))
|
||||
Frequency = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||
|
||||
gEeprom.FM_FrequencyPlaying = Frequency;
|
||||
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
|
||||
@@ -569,38 +511,33 @@ static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step)
|
||||
gRequestSaveFM = true;
|
||||
|
||||
Bail:
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
}
|
||||
|
||||
void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
switch (Key)
|
||||
{
|
||||
case KEY_0:
|
||||
case KEY_1:
|
||||
case KEY_2:
|
||||
case KEY_3:
|
||||
case KEY_4:
|
||||
case KEY_5:
|
||||
case KEY_6:
|
||||
case KEY_7:
|
||||
case KEY_8:
|
||||
case KEY_9:
|
||||
FM_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
|
||||
uint8_t state = bKeyPressed + 2 * bKeyHeld;
|
||||
|
||||
switch (Key) {
|
||||
case KEY_0...KEY_9:
|
||||
Key_DIGITS(Key, state);
|
||||
break;
|
||||
case KEY_STAR:
|
||||
Key_FUNC(Key, state);
|
||||
break;
|
||||
case KEY_MENU:
|
||||
FM_Key_MENU(bKeyPressed, bKeyHeld);
|
||||
return;
|
||||
Key_MENU(state);
|
||||
break;
|
||||
case KEY_UP:
|
||||
FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
|
||||
Key_UP_DOWN(state, 1);
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
|
||||
Key_UP_DOWN(state, -1);
|
||||
break;;
|
||||
case KEY_EXIT:
|
||||
FM_Key_EXIT(bKeyPressed, bKeyHeld);
|
||||
Key_EXIT(state);
|
||||
break;
|
||||
case KEY_F:
|
||||
GENERIC_Key_F(bKeyPressed, bKeyHeld);
|
||||
@@ -617,17 +554,15 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
|
||||
void FM_Play(void)
|
||||
{
|
||||
if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, gEeprom.FM_LowerLimit))
|
||||
{
|
||||
if (!gFM_AutoScan)
|
||||
{
|
||||
if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, BK1080_GetFreqLoLimit(gEeprom.FM_Band))) {
|
||||
if (!gFM_AutoScan) {
|
||||
gFmPlayCountdown_10ms = 0;
|
||||
gFM_FoundFrequency = true;
|
||||
|
||||
if (!gEeprom.FM_IsMrMode)
|
||||
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOn();
|
||||
gEnableSpeaker = true;
|
||||
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
@@ -637,15 +572,14 @@ void FM_Play(void)
|
||||
if (gFM_ChannelPosition < 20)
|
||||
gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying;
|
||||
|
||||
if (gFM_ChannelPosition >= 20)
|
||||
{
|
||||
if (gFM_ChannelPosition >= 20) {
|
||||
FM_PlayAndUpdate();
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= gEeprom.FM_UpperLimit)
|
||||
if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= BK1080_GetFreqHiLimit(1))
|
||||
FM_PlayAndUpdate();
|
||||
else
|
||||
FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false);
|
||||
@@ -655,13 +589,14 @@ void FM_Play(void)
|
||||
|
||||
void FM_Start(void)
|
||||
{
|
||||
gDualWatchActive = false;
|
||||
gFmRadioMode = true;
|
||||
gFM_ScanState = FM_SCAN_OFF;
|
||||
gFM_RestoreCountdown_10ms = 0;
|
||||
|
||||
BK1080_Init(gEeprom.FM_FrequencyPlaying, true);
|
||||
BK1080_Init(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOn();
|
||||
|
||||
gEnableSpeaker = true;
|
||||
gUpdateStatus = true;
|
||||
|
||||
4
app/fm.h
@@ -38,11 +38,10 @@ extern uint8_t gFM_ChannelPosition;
|
||||
// Doubts about whether this should be signed or not
|
||||
extern uint16_t gFM_FrequencyDeviation;
|
||||
extern bool gFM_FoundFrequency;
|
||||
extern bool gFM_AutoScan;
|
||||
extern uint8_t gFM_ResumeCountdown_500ms;
|
||||
extern uint16_t gFM_RestoreCountdown_10ms;
|
||||
|
||||
bool FM_CheckValidChannel(uint8_t Channel);
|
||||
// returns first valid channel starting at Channel
|
||||
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction);
|
||||
int FM_ConfigureChannelState(void);
|
||||
void FM_TurnOff(void);
|
||||
@@ -60,4 +59,3 @@ void FM_Start(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
308
app/generic.c
@@ -17,9 +17,13 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/chFrScanner.h"
|
||||
#include "app/common.h"
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
#include "app/fm.h"
|
||||
#endif
|
||||
|
||||
#include "app/generic.h"
|
||||
#include "app/menu.h"
|
||||
#include "app/scanner.h"
|
||||
@@ -35,66 +39,58 @@
|
||||
|
||||
void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (gInputBoxIndex > 0)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
if (gInputBoxIndex > 0) {
|
||||
if (!bKeyHeld && bKeyPressed) // short pressed
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bKeyHeld || !bKeyPressed)
|
||||
{
|
||||
if (bKeyHeld || bKeyPressed)
|
||||
{
|
||||
if (!bKeyHeld)
|
||||
if (bKeyHeld || !bKeyPressed) { // held or released
|
||||
if (bKeyHeld || bKeyPressed) { // held or pressed (cannot be held and not pressed I guess, so it checks only if HELD?)
|
||||
if (!bKeyHeld) // won't ever pass
|
||||
return;
|
||||
|
||||
if (!bKeyPressed)
|
||||
if (!bKeyPressed) // won't ever pass
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
|
||||
#endif
|
||||
|
||||
gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK;
|
||||
gRequestSaveSettings = true;
|
||||
COMMON_KeypadLockToggle();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
|
||||
return;
|
||||
#else
|
||||
if (gScreenToDisplay != DISPLAY_MAIN)
|
||||
return;
|
||||
#endif
|
||||
else { // released
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
|
||||
return;
|
||||
#else
|
||||
if (gScreenToDisplay != DISPLAY_MAIN)
|
||||
return;
|
||||
#endif
|
||||
|
||||
gWasFKeyPressed = !gWasFKeyPressed;
|
||||
gWasFKeyPressed = !gWasFKeyPressed; // toggle F function
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (!gWasFKeyPressed)
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
if (gWasFKeyPressed)
|
||||
gKeyInputCountdown = key_input_timeout_500ms;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (!gWasFKeyPressed)
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else { // short pressed
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gScreenToDisplay != DISPLAY_FM)
|
||||
#endif
|
||||
{
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFM_ScanState == FM_SCAN_OFF)
|
||||
{
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFM_ScanState == FM_SCAN_OFF) { // not scanning
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
gBeepToPlay = BEEP_440HZ_500MS;
|
||||
gPttWasReleased = true;
|
||||
}
|
||||
@@ -104,154 +100,126 @@ void GENERIC_Key_PTT(bool bKeyPressed)
|
||||
{
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
if (!bKeyPressed)
|
||||
{
|
||||
if (gScreenToDisplay == DISPLAY_MAIN)
|
||||
{
|
||||
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
||||
{
|
||||
if (gFlagEndTransmission)
|
||||
{
|
||||
if (!bKeyPressed || SerialConfigInProgress())
|
||||
{ // PTT released
|
||||
if (gCurrentFunction == FUNCTION_TRANSMIT) {
|
||||
// we are transmitting .. stop
|
||||
if (gFlagEndTransmission) {
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
}
|
||||
else {
|
||||
APP_EndTransmission();
|
||||
|
||||
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
}
|
||||
else
|
||||
{
|
||||
APP_EndTransmission();
|
||||
|
||||
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
}
|
||||
else
|
||||
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
|
||||
}
|
||||
|
||||
gFlagEndTransmission = false;
|
||||
gVOX_NoiseDetected = false;
|
||||
gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
|
||||
}
|
||||
|
||||
gFlagEndTransmission = false;
|
||||
#ifdef ENABLE_VOX
|
||||
gVOX_NoiseDetected = false;
|
||||
#endif
|
||||
RADIO_SetVfoState(VFO_STATE_NORMAL);
|
||||
|
||||
// beep when you release the PTT
|
||||
//gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL; // 1of11
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// PTT pressed
|
||||
|
||||
|
||||
if (SCANNER_IsScanning()) {
|
||||
SCANNER_Stop(); // CTCSS/CDCSS scanning .. stop
|
||||
goto cancel_tx;
|
||||
}
|
||||
|
||||
if (gScanStateDir != SCAN_OFF) {
|
||||
CHFRSCANNER_Stop(); // frequency/channel scanning . .stop
|
||||
goto cancel_tx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFM_ScanState != FM_SCAN_OFF) { // FM radio is scanning .. stop
|
||||
FM_PlayAndUpdate();
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
goto cancel_tx;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gScreenToDisplay == DISPLAY_FM)
|
||||
goto start_tx; // listening to the FM radio .. start TX'ing
|
||||
#endif
|
||||
|
||||
if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown_10ms == 0) {// already transmitting
|
||||
gInputBoxIndex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gScanState != SCAN_OFF)
|
||||
{
|
||||
SCANNER_Stop();
|
||||
|
||||
gPttDebounceCounter = 0;
|
||||
gPttIsPressed = false;
|
||||
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
|
||||
|
||||
if (!gDTMF_InputMode && gDTMF_InputBox_Index == 0)
|
||||
goto start_tx; // wasn't entering a DTMF code .. start TX'ing (maybe)
|
||||
|
||||
// was entering a DTMF string
|
||||
|
||||
if (gDTMF_InputBox_Index > 0 || gDTMF_PreviousIndex > 0) { // going to transmit a DTMF string
|
||||
if (gDTMF_InputBox_Index == 0 && gDTMF_PreviousIndex > 0)
|
||||
gDTMF_InputBox_Index = gDTMF_PreviousIndex; // use the previous DTMF string
|
||||
|
||||
if (gDTMF_InputBox_Index < sizeof(gDTMF_InputBox))
|
||||
gDTMF_InputBox[gDTMF_InputBox_Index] = 0; // NULL term the string
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
// append our DTMF ID to the inputted DTMF code -
|
||||
// IF the user inputted code is exactly 3 digits long and D-DCD is enabled
|
||||
if (gDTMF_InputBox_Index == 3 && gTxVfo->DTMF_DECODING_ENABLE > 0)
|
||||
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3);
|
||||
else
|
||||
gDTMF_CallMode = DTMF_CALL_MODE_DTMF;
|
||||
|
||||
gDTMF_State = DTMF_STATE_0;
|
||||
#endif
|
||||
// remember the DTMF string
|
||||
gDTMF_PreviousIndex = gDTMF_InputBox_Index;
|
||||
strcpy(gDTMF_String, gDTMF_InputBox);
|
||||
gDTMF_ReplyState = DTMF_REPLY_ANI;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFM_ScanState == FM_SCAN_OFF)
|
||||
#endif
|
||||
{
|
||||
if (gCssScanMode == CSS_SCAN_MODE_OFF)
|
||||
{
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gScreenToDisplay == DISPLAY_MENU || gScreenToDisplay == DISPLAY_FM)
|
||||
#else
|
||||
if (gScreenToDisplay == DISPLAY_MENU)
|
||||
#endif
|
||||
{
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gInputBoxIndex = 0;
|
||||
gPttIsPressed = false;
|
||||
gPttDebounceCounter = 0;
|
||||
return;
|
||||
}
|
||||
DTMF_clear_input_box();
|
||||
|
||||
if (gScreenToDisplay != DISPLAY_SCANNER)
|
||||
{
|
||||
if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0)
|
||||
{
|
||||
gInputBoxIndex = 0;
|
||||
return;
|
||||
}
|
||||
start_tx:
|
||||
// request start TX
|
||||
gFlagPrepareTX = true;
|
||||
goto done;
|
||||
|
||||
gFlagPrepareTX = true;
|
||||
|
||||
if (gDTMF_InputMode)
|
||||
{
|
||||
if (gDTMF_InputIndex > 0 || gDTMF_PreviousIndex > 0)
|
||||
{
|
||||
if (gDTMF_InputIndex == 0)
|
||||
gDTMF_InputIndex = gDTMF_PreviousIndex;
|
||||
|
||||
gDTMF_InputBox[gDTMF_InputIndex] = 0;
|
||||
|
||||
#if 0
|
||||
// append our DTMF ID to the inputted DTMF code -
|
||||
// IF the user inputted code is exactly 3 digits long
|
||||
if (gDTMF_InputIndex == 3)
|
||||
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3);
|
||||
else
|
||||
#else
|
||||
// append our DTMF ID to the inputted DTMF code -
|
||||
// IF the user inputted code is exactly 3 digits long and D-DCD is enabled
|
||||
if (gDTMF_InputIndex == 3 && gTxVfo->DTMF_DECODING_ENABLE > 0)
|
||||
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3);
|
||||
else
|
||||
#endif
|
||||
gDTMF_CallMode = DTMF_CALL_MODE_DTMF;
|
||||
|
||||
strcpy(gDTMF_String, gDTMF_InputBox);
|
||||
|
||||
gDTMF_PreviousIndex = gDTMF_InputIndex;
|
||||
gDTMF_ReplyState = DTMF_REPLY_ANI;
|
||||
gDTMF_State = DTMF_STATE_0;
|
||||
}
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
|
||||
gDTMF_InputMode = false;
|
||||
gDTMF_InputIndex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gFlagPrepareTX = true;
|
||||
gInputBoxIndex = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gEeprom.CROSS_BAND_RX_TX = gBackupCROSS_BAND_RX_TX;
|
||||
gUpdateStatus = true;
|
||||
gFlagStopScan = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
gFlagResetVfos = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MENU_StopCssScan();
|
||||
gRequestDisplayScreen = DISPLAY_MENU;
|
||||
}
|
||||
cancel_tx:
|
||||
if (gPttIsPressed) {
|
||||
gPttWasPressed = true;
|
||||
}
|
||||
#ifdef ENABLE_FMRADIO
|
||||
else
|
||||
{
|
||||
FM_PlayAndUpdate();
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
|
||||
gPttWasPressed = true;
|
||||
done:
|
||||
gPttDebounceCounter = 0;
|
||||
if (gScreenToDisplay != DISPLAY_MENU
|
||||
#ifdef ENABLE_FMRADIO
|
||||
&& gRequestDisplayScreen != DISPLAY_FM
|
||||
#endif
|
||||
) {
|
||||
// 1of11 .. don't close the menu
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
gUpdateStatus = true;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
|
||||
|
||||
821
app/main.c
797
app/menu.c
12
app/menu.h
@@ -19,11 +19,17 @@
|
||||
|
||||
#include "driver/keyboard.h"
|
||||
|
||||
int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax);
|
||||
#ifdef ENABLE_F_CAL_MENU
|
||||
void writeXtalFreqCal(const int32_t value, const bool update_eeprom);
|
||||
#endif
|
||||
|
||||
extern uint8_t gUnlockAllTxConfCnt;
|
||||
|
||||
int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax);
|
||||
void MENU_AcceptSetting(void);
|
||||
void MENU_SelectNextCode(void);
|
||||
void MENU_ShowCurrentSetting(void);
|
||||
void MENU_StartCssScan(int8_t Direction);
|
||||
void MENU_StartCssScan(void);
|
||||
void MENU_CssScanFound(void);
|
||||
void MENU_StopCssScan(void);
|
||||
|
||||
void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||
|
||||
479
app/scanner.c
@@ -14,7 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/dtmf.h"
|
||||
#include "app/generic.h"
|
||||
#include "app/menu.h"
|
||||
#include "app/scanner.h"
|
||||
#include "audio.h"
|
||||
#include "driver/bk4819.h"
|
||||
@@ -27,52 +30,45 @@
|
||||
|
||||
DCS_CodeType_t gScanCssResultType;
|
||||
uint8_t gScanCssResultCode;
|
||||
bool gFlagStartScan;
|
||||
bool gFlagStopScan;
|
||||
bool gScanSingleFrequency;
|
||||
uint8_t gScannerEditState;
|
||||
bool gScanSingleFrequency; // scan CTCSS/DCS codes for current frequency
|
||||
SCAN_SaveState_t gScannerSaveState;
|
||||
uint8_t gScanChannel;
|
||||
uint32_t gScanFrequency;
|
||||
bool gScanPauseMode;
|
||||
SCAN_CssState_t gScanCssState;
|
||||
volatile bool gScheduleScanListen = true;
|
||||
volatile uint16_t ScanPauseDelayIn_10ms;
|
||||
uint8_t gScanProgressIndicator;
|
||||
uint8_t gScanHitCount;
|
||||
bool gScanUseCssResult;
|
||||
int8_t gScanState;
|
||||
bool bScanKeepFrequency;
|
||||
|
||||
STEP_Setting_t stepSetting;
|
||||
uint8_t scanHitCount;
|
||||
|
||||
|
||||
static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
{
|
||||
if (gScannerEditState == 1)
|
||||
{
|
||||
uint16_t Channel;
|
||||
|
||||
if (gScannerSaveState == SCAN_SAVE_CHAN_SEL) {
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
INPUTBOX_Append(Key);
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
|
||||
if (gInputBoxIndex < 3)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
if (gInputBoxIndex < 3) {
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
||||
|
||||
if (IS_MR_CHANNEL(Channel))
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gShowChPrefix = RADIO_CheckValidChannel(Channel, false, 0);
|
||||
gScanChannel = (uint8_t)Channel;
|
||||
uint16_t chan = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
||||
if (IS_MR_CHANNEL(chan)) {
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
#endif
|
||||
gShowChPrefix = RADIO_CheckValidChannel(chan, false, 0);
|
||||
gScanChannel = (uint8_t)chan;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -83,27 +79,17 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
|
||||
static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed) { // short pressed
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
switch (gScannerEditState)
|
||||
{
|
||||
case 0:
|
||||
switch (gScannerSaveState) {
|
||||
case SCAN_SAVE_NO_PROMPT:
|
||||
SCANNER_Stop();
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gEeprom.CROSS_BAND_RX_TX = gBackupCROSS_BAND_RX_TX;
|
||||
gUpdateStatus = true;
|
||||
gFlagStopScan = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
gFlagResetVfos = true;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (gInputBoxIndex > 0)
|
||||
{
|
||||
case SCAN_SAVE_CHAN_SEL:
|
||||
if (gInputBoxIndex > 0) {
|
||||
gInputBox[--gInputBoxIndex] = 10;
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
break;
|
||||
@@ -111,11 +97,11 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
|
||||
// Fallthrough
|
||||
|
||||
case 2:
|
||||
gScannerEditState = 0;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
case SCAN_SAVE_CHANNEL:
|
||||
gScannerSaveState = SCAN_SAVE_NO_PROMPT;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
break;
|
||||
}
|
||||
@@ -124,118 +110,85 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
|
||||
static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
uint8_t Channel;
|
||||
|
||||
if (bKeyHeld)
|
||||
if (bKeyHeld || !bKeyPressed) // ignore long press or release button events
|
||||
return;
|
||||
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
|
||||
if (gScanCssState == SCAN_CSS_STATE_OFF && !gScanSingleFrequency)
|
||||
{
|
||||
if (gScanCssState == SCAN_CSS_STATE_OFF && !gScanSingleFrequency) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gScanCssState == SCAN_CSS_STATE_SCANNING)
|
||||
{
|
||||
if (gScanSingleFrequency)
|
||||
{
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
if (gScanCssState == SCAN_CSS_STATE_SCANNING && gScanSingleFrequency) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gScanCssState == SCAN_CSS_STATE_FAILED)
|
||||
{
|
||||
if (gScanCssState == SCAN_CSS_STATE_FAILED) {
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
switch (gScannerEditState)
|
||||
{
|
||||
case 0:
|
||||
switch (gScannerSaveState) {
|
||||
case SCAN_SAVE_NO_PROMPT:
|
||||
if (!gScanSingleFrequency)
|
||||
{
|
||||
int16_t Delta625;
|
||||
uint32_t Freq250 = FREQUENCY_FloorToStep(gScanFrequency, 250, 0);
|
||||
uint32_t Freq625 = FREQUENCY_FloorToStep(gScanFrequency, 625, 0);
|
||||
int16_t Delta250 = (int16_t)gScanFrequency - (int16_t)Freq250;
|
||||
uint32_t freq250 = FREQUENCY_RoundToStep(gScanFrequency, 250);
|
||||
uint32_t freq625 = FREQUENCY_RoundToStep(gScanFrequency, 625);
|
||||
|
||||
if (125 < Delta250)
|
||||
{
|
||||
Delta250 = 250 - Delta250;
|
||||
Freq250 += 250;
|
||||
uint32_t diff250 = gScanFrequency > freq250 ? gScanFrequency - freq250 : freq250 - gScanFrequency;
|
||||
uint32_t diff625 = gScanFrequency > freq625 ? gScanFrequency - freq625 : freq625 - gScanFrequency;
|
||||
|
||||
if(diff250 > diff625) {
|
||||
stepSetting = STEP_6_25kHz;
|
||||
gScanFrequency = freq625;
|
||||
}
|
||||
|
||||
Delta625 = (int16_t)gScanFrequency - (int16_t)Freq625;
|
||||
|
||||
if (312 < Delta625)
|
||||
{
|
||||
Delta625 = 625 - Delta625;
|
||||
Freq625 += 625;
|
||||
}
|
||||
|
||||
if (Delta625 < Delta250)
|
||||
{
|
||||
gStepSetting = STEP_6_25kHz;
|
||||
gScanFrequency = Freq625;
|
||||
}
|
||||
else
|
||||
{
|
||||
gStepSetting = STEP_2_5kHz;
|
||||
gScanFrequency = Freq250;
|
||||
else {
|
||||
stepSetting = STEP_2_5kHz;
|
||||
gScanFrequency = freq250;
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
{
|
||||
gScannerEditState = 1;
|
||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
|
||||
gScannerSaveState = SCAN_SAVE_CHAN_SEL;
|
||||
gScanChannel = gTxVfo->CHANNEL_SAVE;
|
||||
gShowChPrefix = RADIO_CheckValidChannel(gTxVfo->CHANNEL_SAVE, false, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gScannerEditState = 2;
|
||||
else {
|
||||
gScannerSaveState = SCAN_SAVE_CHANNEL;
|
||||
}
|
||||
|
||||
gScanCssState = SCAN_CSS_STATE_FOUND;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_MEMORY_CHANNEL;
|
||||
#endif
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_MEMORY_CHANNEL;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
|
||||
gUpdateStatus = true;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (gInputBoxIndex == 0)
|
||||
{
|
||||
case SCAN_SAVE_CHAN_SEL:
|
||||
if (gInputBoxIndex == 0) {
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
gScannerEditState = 2;
|
||||
gScannerSaveState = SCAN_SAVE_CHANNEL;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (!gScanSingleFrequency)
|
||||
{
|
||||
RADIO_InitInfo(gTxVfo, gTxVfo->CHANNEL_SAVE, FREQUENCY_GetBand(gScanFrequency), gScanFrequency);
|
||||
case SCAN_SAVE_CHANNEL:
|
||||
if (!gScanSingleFrequency) {
|
||||
RADIO_InitInfo(gTxVfo, gTxVfo->CHANNEL_SAVE, gScanFrequency);
|
||||
|
||||
if (gScanUseCssResult)
|
||||
{
|
||||
if (gScanUseCssResult) {
|
||||
gTxVfo->freq_config_RX.CodeType = gScanCssResultType;
|
||||
gTxVfo->freq_config_RX.Code = gScanCssResultCode;
|
||||
}
|
||||
|
||||
gTxVfo->freq_config_TX = gTxVfo->freq_config_RX;
|
||||
gTxVfo->STEP_SETTING = gStepSetting;
|
||||
gTxVfo->STEP_SETTING = stepSetting;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
|
||||
|
||||
@@ -245,25 +198,24 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
|
||||
gTxVfo->freq_config_TX.Code = gScanCssResultCode;
|
||||
}
|
||||
|
||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
{
|
||||
Channel = gScanChannel;
|
||||
gEeprom.MrChannel[gEeprom.TX_CHANNEL] = Channel;
|
||||
uint8_t chan;
|
||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
|
||||
chan = gScanChannel;
|
||||
gEeprom.MrChannel[gEeprom.TX_VFO] = chan;
|
||||
}
|
||||
else
|
||||
{
|
||||
Channel = gTxVfo->Band + FREQ_CHANNEL_FIRST;
|
||||
gEeprom.FreqChannel[gEeprom.TX_CHANNEL] = Channel;
|
||||
else {
|
||||
chan = gTxVfo->Band + FREQ_CHANNEL_FIRST;
|
||||
gEeprom.FreqChannel[gEeprom.TX_VFO] = chan;
|
||||
}
|
||||
|
||||
gTxVfo->CHANNEL_SAVE = Channel;
|
||||
gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] = Channel;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CONFIRM;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
gRequestSaveChannel = 2;
|
||||
gScannerEditState = 0;
|
||||
gTxVfo->CHANNEL_SAVE = chan;
|
||||
gEeprom.ScreenChannel[gEeprom.TX_VFO] = chan;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CONFIRM;
|
||||
#endif
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
gRequestSaveChannel = 2;
|
||||
gScannerSaveState = SCAN_SAVE_NO_PROMPT;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -274,23 +226,20 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
|
||||
|
||||
static void SCANNER_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed) {
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
gFlagStartScan = true;
|
||||
SCANNER_Start(gScanSingleFrequency);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Direction)
|
||||
{
|
||||
if (pKeyHeld)
|
||||
{
|
||||
if (pKeyHeld) {
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
|
||||
@@ -298,8 +247,7 @@ static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Directio
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
}
|
||||
|
||||
if (gScannerEditState == 1)
|
||||
{
|
||||
if (gScannerSaveState == SCAN_SAVE_CHAN_SEL) {
|
||||
gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, MR_CHANNEL_LAST);
|
||||
gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0);
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
@@ -310,8 +258,7 @@ static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Directio
|
||||
|
||||
void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
switch (Key)
|
||||
{
|
||||
switch (Key) {
|
||||
case KEY_0:
|
||||
case KEY_1:
|
||||
case KEY_2:
|
||||
@@ -349,107 +296,233 @@ void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
}
|
||||
}
|
||||
|
||||
void SCANNER_Start(void)
|
||||
void SCANNER_Start(bool singleFreq)
|
||||
{
|
||||
uint8_t BackupStep;
|
||||
uint16_t BackupFrequency;
|
||||
gScanSingleFrequency = singleFreq;
|
||||
gMonitor = false;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
|
||||
#endif
|
||||
|
||||
BK4819_StopScan();
|
||||
|
||||
RADIO_SelectVfos();
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
||||
gRxVfo->CHANNEL_SAVE = FREQ_CHANNEL_FIRST + BAND6_400MHz;
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
||||
gRxVfo->CHANNEL_SAVE = FREQ_CHANNEL_FIRST + BAND6_400MHz;
|
||||
#endif
|
||||
|
||||
BackupStep = gRxVfo->STEP_SETTING;
|
||||
BackupFrequency = gRxVfo->StepFrequency;
|
||||
uint8_t backupStep = gRxVfo->STEP_SETTING;
|
||||
uint16_t backupFrequency = gRxVfo->StepFrequency;
|
||||
|
||||
RADIO_InitInfo(gRxVfo, gRxVfo->CHANNEL_SAVE, gRxVfo->Band, gRxVfo->pRX->Frequency);
|
||||
RADIO_InitInfo(gRxVfo, gRxVfo->CHANNEL_SAVE, gRxVfo->pRX->Frequency);
|
||||
|
||||
gRxVfo->STEP_SETTING = BackupStep;
|
||||
gRxVfo->StepFrequency = BackupFrequency;
|
||||
gRxVfo->STEP_SETTING = backupStep;
|
||||
gRxVfo->StepFrequency = backupFrequency;
|
||||
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
gIsNoaaMode = false;
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
gIsNoaaMode = false;
|
||||
#endif
|
||||
|
||||
if (gScanSingleFrequency)
|
||||
{
|
||||
if (gScanSingleFrequency) {
|
||||
gScanCssState = SCAN_CSS_STATE_SCANNING;
|
||||
gScanFrequency = gRxVfo->pRX->Frequency;
|
||||
gStepSetting = gRxVfo->STEP_SETTING;
|
||||
stepSetting = gRxVfo->STEP_SETTING;
|
||||
|
||||
BK4819_PickRXFilterPathBasedOnFrequency(gScanFrequency);
|
||||
BK4819_SetScanFrequency(gScanFrequency);
|
||||
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
gScanCssState = SCAN_CSS_STATE_OFF;
|
||||
gScanFrequency = 0xFFFFFFFF;
|
||||
|
||||
BK4819_PickRXFilterPathBasedOnFrequency(0xFFFFFFFF);
|
||||
BK4819_PickRXFilterPathBasedOnFrequency(gScanFrequency);
|
||||
BK4819_EnableFrequencyScan();
|
||||
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
DTMF_clear_RX();
|
||||
#endif
|
||||
|
||||
gScanDelay_10ms = scan_delay_10ms;
|
||||
gScanCssResultCode = 0xFF;
|
||||
gScanCssResultType = 0xFF;
|
||||
gScanHitCount = 0;
|
||||
scanHitCount = 0;
|
||||
gScanUseCssResult = false;
|
||||
gDTMF_RequestPending = false;
|
||||
g_CxCSS_TAIL_Found = false;
|
||||
g_CDCSS_Lost = false;
|
||||
gCDCSSCodeType = 0;
|
||||
g_CTCSS_Lost = false;
|
||||
g_VOX_Lost = false;
|
||||
#ifdef ENABLE_VOX
|
||||
g_VOX_Lost = false;
|
||||
#endif
|
||||
g_SquelchLost = false;
|
||||
gScannerEditState = 0;
|
||||
gScannerSaveState = SCAN_SAVE_NO_PROMPT;
|
||||
gScanProgressIndicator = 0;
|
||||
}
|
||||
|
||||
void SCANNER_Stop(void)
|
||||
{
|
||||
const uint8_t Previous = gRestoreMrChannel;
|
||||
|
||||
gScanState = SCAN_OFF;
|
||||
|
||||
if (!bScanKeepFrequency)
|
||||
{
|
||||
if (IS_MR_CHANNEL(gNextMrChannel))
|
||||
{
|
||||
gEeprom.MrChannel[gEeprom.RX_CHANNEL] = gRestoreMrChannel;
|
||||
gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = Previous;
|
||||
|
||||
RADIO_ConfigureChannel(gEeprom.RX_CHANNEL, VFO_CONFIGURE_RELOAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
gRxVfo->freq_config_RX.Frequency = gRestoreFrequency;
|
||||
RADIO_ApplyOffset(gRxVfo);
|
||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||
}
|
||||
RADIO_SetupRegisters(true);
|
||||
gUpdateDisplay = true;
|
||||
return;
|
||||
if(SCANNER_IsScanning()) {
|
||||
gEeprom.CROSS_BAND_RX_TX = gBackup_CROSS_BAND_RX_TX;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
gFlagResetVfos = true;
|
||||
gUpdateStatus = true;
|
||||
gCssBackgroundScan = false;
|
||||
gScanUseCssResult = false;
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
BK4819_StopScan();
|
||||
}
|
||||
|
||||
if (!IS_MR_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
||||
{
|
||||
RADIO_ApplyOffset(gRxVfo);
|
||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||
SETTINGS_SaveChannel(gRxVfo->CHANNEL_SAVE, gEeprom.RX_CHANNEL, gRxVfo, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
SETTINGS_SaveVfoIndices();
|
||||
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
void SCANNER_TimeSlice10ms(void)
|
||||
{
|
||||
if (!SCANNER_IsScanning())
|
||||
return;
|
||||
|
||||
if (gScanDelay_10ms > 0) {
|
||||
gScanDelay_10ms--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gScannerSaveState != SCAN_SAVE_NO_PROMPT) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (gScanCssState) {
|
||||
case SCAN_CSS_STATE_OFF: {
|
||||
// must be RF frequency scanning if we're here ?
|
||||
uint32_t result;
|
||||
if (!BK4819_GetFrequencyScanResult(&result))
|
||||
break;
|
||||
|
||||
int32_t delta = result - gScanFrequency;
|
||||
gScanFrequency = result;
|
||||
|
||||
if (delta < 0)
|
||||
delta = -delta;
|
||||
if (delta < 100)
|
||||
scanHitCount++;
|
||||
else
|
||||
scanHitCount = 0;
|
||||
|
||||
BK4819_DisableFrequencyScan();
|
||||
|
||||
if (scanHitCount < 3) {
|
||||
BK4819_EnableFrequencyScan();
|
||||
}
|
||||
else {
|
||||
BK4819_SetScanFrequency(gScanFrequency);
|
||||
gScanCssResultCode = 0xFF;
|
||||
gScanCssResultType = 0xFF;
|
||||
scanHitCount = 0;
|
||||
gScanUseCssResult = false;
|
||||
gScanProgressIndicator = 0;
|
||||
gScanCssState = SCAN_CSS_STATE_SCANNING;
|
||||
|
||||
if(!gCssBackgroundScan)
|
||||
GUI_SelectNextDisplay(DISPLAY_SCANNER);
|
||||
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
gScanDelay_10ms = scan_delay_10ms;
|
||||
//gScanDelay_10ms = 1; // 10ms
|
||||
break;
|
||||
}
|
||||
case SCAN_CSS_STATE_SCANNING: {
|
||||
uint32_t cdcssFreq;
|
||||
uint16_t ctcssFreq;
|
||||
BK4819_CssScanResult_t scanResult = BK4819_GetCxCSSScanResult(&cdcssFreq, &ctcssFreq);
|
||||
if (scanResult == BK4819_CSS_RESULT_NOT_FOUND)
|
||||
break;
|
||||
|
||||
BK4819_Disable();
|
||||
|
||||
if (scanResult == BK4819_CSS_RESULT_CDCSS) {
|
||||
const uint8_t Code = DCS_GetCdcssCode(cdcssFreq);
|
||||
if (Code != 0xFF)
|
||||
{
|
||||
gScanCssResultCode = Code;
|
||||
gScanCssResultType = CODE_TYPE_DIGITAL;
|
||||
gScanCssState = SCAN_CSS_STATE_FOUND;
|
||||
gScanUseCssResult = true;
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
}
|
||||
else if (scanResult == BK4819_CSS_RESULT_CTCSS) {
|
||||
const uint8_t Code = DCS_GetCtcssCode(ctcssFreq);
|
||||
if (Code != 0xFF) {
|
||||
if (Code == gScanCssResultCode && gScanCssResultType == CODE_TYPE_CONTINUOUS_TONE) {
|
||||
if (++scanHitCount >= 2) {
|
||||
gScanCssState = SCAN_CSS_STATE_FOUND;
|
||||
gScanUseCssResult = true;
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
scanHitCount = 0;
|
||||
|
||||
gScanCssResultType = CODE_TYPE_CONTINUOUS_TONE;
|
||||
gScanCssResultCode = Code;
|
||||
}
|
||||
}
|
||||
|
||||
if (gScanCssState < SCAN_CSS_STATE_FOUND) { // scanning or off
|
||||
BK4819_SetScanFrequency(gScanFrequency);
|
||||
gScanDelay_10ms = scan_delay_10ms;
|
||||
break;
|
||||
}
|
||||
|
||||
if(gCssBackgroundScan) {
|
||||
gCssBackgroundScan = false;
|
||||
if(gScanUseCssResult)
|
||||
MENU_CssScanFound();
|
||||
}
|
||||
else
|
||||
GUI_SelectNextDisplay(DISPLAY_SCANNER);
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
gCssBackgroundScan = false;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SCANNER_TimeSlice500ms(void)
|
||||
{
|
||||
if (SCANNER_IsScanning() && gScannerSaveState == SCAN_SAVE_NO_PROMPT && gScanCssState < SCAN_CSS_STATE_FOUND) {
|
||||
gScanProgressIndicator++;
|
||||
#ifndef ENABLE_NO_CODE_SCAN_TIMEOUT
|
||||
if (gScanProgressIndicator > 32) {
|
||||
if (gScanCssState == SCAN_CSS_STATE_SCANNING && !gScanSingleFrequency)
|
||||
gScanCssState = SCAN_CSS_STATE_FOUND;
|
||||
else
|
||||
gScanCssState = SCAN_CSS_STATE_FAILED;
|
||||
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
#endif
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
else if(gCssBackgroundScan) {
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool SCANNER_IsScanning(void)
|
||||
{
|
||||
return gCssBackgroundScan || (gScreenToDisplay == DISPLAY_SCANNER);
|
||||
}
|
||||
@@ -20,42 +20,38 @@
|
||||
#include "dcs.h"
|
||||
#include "driver/keyboard.h"
|
||||
|
||||
enum SCAN_CssState_t
|
||||
typedef enum
|
||||
{
|
||||
SCAN_CSS_STATE_OFF = 0,
|
||||
SCAN_CSS_STATE_OFF,
|
||||
SCAN_CSS_STATE_SCANNING,
|
||||
SCAN_CSS_STATE_FOUND,
|
||||
SCAN_CSS_STATE_FAILED
|
||||
};
|
||||
} SCAN_CssState_t;
|
||||
|
||||
typedef enum SCAN_CssState_t SCAN_CssState_t;
|
||||
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
SCAN_OFF = 0,
|
||||
};
|
||||
SCAN_SAVE_NO_PROMPT, // saving process not initiated
|
||||
SCAN_SAVE_CHAN_SEL, // "SAVE: ", channel select prompt, actives only in channel mode
|
||||
SCAN_SAVE_CHANNEL, // "SAVE?" prompt, waits for confirmation to save settings to channel, or current VFO
|
||||
} SCAN_SaveState_t;
|
||||
|
||||
|
||||
extern DCS_CodeType_t gScanCssResultType;
|
||||
extern uint8_t gScanCssResultCode;
|
||||
extern bool gFlagStartScan;
|
||||
extern bool gFlagStopScan;
|
||||
extern bool gScanSingleFrequency;
|
||||
extern uint8_t gScannerEditState;
|
||||
extern SCAN_SaveState_t gScannerSaveState;
|
||||
extern uint8_t gScanChannel;
|
||||
extern uint32_t gScanFrequency;
|
||||
extern bool gScanPauseMode;
|
||||
extern SCAN_CssState_t gScanCssState;
|
||||
extern volatile bool gScheduleScanListen;
|
||||
extern volatile uint16_t ScanPauseDelayIn_10ms;
|
||||
extern uint8_t gScanProgressIndicator;
|
||||
extern uint8_t gScanHitCount;
|
||||
extern bool gScanUseCssResult;
|
||||
extern int8_t gScanState;
|
||||
extern bool bScanKeepFrequency;
|
||||
|
||||
void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||
void SCANNER_Start(void);
|
||||
void SCANNER_Start(bool singleFreq);
|
||||
void SCANNER_Stop(void);
|
||||
void SCANNER_TimeSlice10ms(void);
|
||||
void SCANNER_TimeSlice500ms(void);
|
||||
bool SCANNER_IsScanning(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
539
app/spectrum.c
@@ -13,32 +13,31 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "app/spectrum.h"
|
||||
#include "am_fix.h"
|
||||
#include "audio.h"
|
||||
#include "misc.h"
|
||||
|
||||
#include "../app/spectrum.h"
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
#include "chFrScanner.h"
|
||||
#endif
|
||||
|
||||
#include "driver/backlight.h"
|
||||
#include "frequencies.h"
|
||||
#include "ui/helper.h"
|
||||
#include "ui/main.h"
|
||||
|
||||
struct FrequencyBandInfo {
|
||||
uint32_t lower;
|
||||
uint32_t upper;
|
||||
uint32_t middle;
|
||||
uint32_t lower;
|
||||
uint32_t upper;
|
||||
uint32_t middle;
|
||||
};
|
||||
|
||||
const struct FrequencyBandInfo FrequencyBandTable[7] = {
|
||||
[BAND1_50MHz ] = {.lower = 1600000, .middle = 6500000, .upper = 7600000},
|
||||
[BAND2_108MHz] = {.lower = 10800000, .middle = 12200000, .upper = 13599990},
|
||||
[BAND3_136MHz] = {.lower = 13600000, .middle = 15000000, .upper = 17399990},
|
||||
[BAND4_174MHz] = {.lower = 17400000, .middle = 26000000, .upper = 34999990},
|
||||
[BAND5_350MHz] = {.lower = 35000000, .middle = 37000000, .upper = 39999990},
|
||||
[BAND6_400MHz] = {.lower = 40000000, .middle = 43500000, .upper = 46999990},
|
||||
[BAND7_470MHz] = {.lower = 47000000, .middle = 55000000, .upper = 130000000},
|
||||
};
|
||||
|
||||
|
||||
#define F_MIN FrequencyBandTable[0].lower
|
||||
#define F_MAX FrequencyBandTable[ARRAY_SIZE(FrequencyBandTable) - 1].upper
|
||||
#define F_MIN frequencyBandTable[0].lower
|
||||
#define F_MAX frequencyBandTable[BAND_N_ELEM - 1].upper
|
||||
|
||||
const uint16_t RSSI_MAX_VALUE = 65535;
|
||||
|
||||
static uint16_t R30, R37, R3D, R43, R47, R48, R7E;
|
||||
static uint32_t initialFreq;
|
||||
static char String[32];
|
||||
|
||||
@@ -50,6 +49,7 @@ bool redrawScreen = false;
|
||||
bool newScanStart = true;
|
||||
bool preventKeypress = true;
|
||||
bool audioState = true;
|
||||
bool lockAGC = false;
|
||||
|
||||
State currentState = SPECTRUM, previousState = SPECTRUM;
|
||||
|
||||
@@ -57,41 +57,45 @@ PeakInfo peak;
|
||||
ScanInfo scanInfo;
|
||||
KeyboardState kbd = {KEY_INVALID, KEY_INVALID, 0};
|
||||
|
||||
const char *bwOptions[] = {"25k", "12.5k", "6.25k"};
|
||||
const char *modulationTypeOptions[] = {"FM", "AM", "USB"};
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
static uint16_t blacklistFreqs[15];
|
||||
static uint8_t blacklistFreqsIdx;
|
||||
#endif
|
||||
|
||||
const char *bwOptions[] = {" 25k", "12.5k", "6.25k"};
|
||||
const uint8_t modulationTypeTuneSteps[] = {100, 50, 10};
|
||||
const uint8_t modTypeReg47Values[] = {1, 7, 5};
|
||||
|
||||
SpectrumSettings settings = {STEPS_64,
|
||||
S_STEP_25_0kHz,
|
||||
80000,
|
||||
3200,
|
||||
0,
|
||||
true,
|
||||
BK4819_FILTER_BW_WIDE,
|
||||
BK4819_FILTER_BW_WIDE,
|
||||
false,
|
||||
-130,
|
||||
-50};
|
||||
SpectrumSettings settings = {.stepsCount = STEPS_64,
|
||||
.scanStepIndex = S_STEP_25_0kHz,
|
||||
.frequencyChangeStep = 80000,
|
||||
.scanDelay = 3200,
|
||||
.rssiTriggerLevel = 150,
|
||||
.backlightState = true,
|
||||
.bw = BK4819_FILTER_BW_WIDE,
|
||||
.listenBw = BK4819_FILTER_BW_WIDE,
|
||||
.modulationType = false,
|
||||
.dbMin = -130,
|
||||
.dbMax = -50};
|
||||
|
||||
uint32_t fMeasure = 0;
|
||||
uint32_t currentFreq, tempFreq;
|
||||
uint16_t rssiHistory[128] = {};
|
||||
|
||||
uint16_t rssiHistory[128];
|
||||
int vfo;
|
||||
uint8_t freqInputIndex = 0;
|
||||
uint8_t freqInputDotIndex = 0;
|
||||
KEY_Code_t freqInputArr[10];
|
||||
char freqInputString[11] = "----------\0"; // XXXX.XXXXX\0
|
||||
char freqInputString[11];
|
||||
|
||||
uint8_t menuState = 0;
|
||||
uint16_t listenT = 0;
|
||||
|
||||
RegisterSpec registerSpecs[] = {
|
||||
{},
|
||||
{"LNAs", 0x13, 8, 0b11, 1},
|
||||
{"LNA", 0x13, 5, 0b111, 1},
|
||||
{"PGA", 0x13, 0, 0b111, 1},
|
||||
{"IF", 0x3D, 0, 0xFFFF, 0x2aaa},
|
||||
{"LNAs", BK4819_REG_13, 8, 0b11, 1},
|
||||
{"LNA", BK4819_REG_13, 5, 0b111, 1},
|
||||
{"PGA", BK4819_REG_13, 0, 0b111, 1},
|
||||
{"IF", BK4819_REG_3D, 0, 0xFFFF, 0x2aaa},
|
||||
// {"MIX", 0x13, 3, 0b11, 1}, // TODO: hidden
|
||||
};
|
||||
|
||||
@@ -108,26 +112,37 @@ static uint8_t DBm2S(int dbm) {
|
||||
return i;
|
||||
}
|
||||
|
||||
static int Rssi2DBm(uint16_t rssi) { return (rssi >> 1) - 160; }
|
||||
static int Rssi2DBm(uint16_t rssi) {
|
||||
return (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band];
|
||||
}
|
||||
|
||||
static uint16_t GetRegMenuValue(uint8_t st) {
|
||||
RegisterSpec s = registerSpecs[st];
|
||||
return (BK4819_ReadRegister(s.num) >> s.offset) & s.maxValue;
|
||||
return (BK4819_ReadRegister(s.num) >> s.offset) & s.mask;
|
||||
}
|
||||
|
||||
void LockAGC()
|
||||
{
|
||||
RADIO_SetupAGC(settings.modulationType==MODULATION_AM, lockAGC);
|
||||
lockAGC = true;
|
||||
}
|
||||
|
||||
static void SetRegMenuValue(uint8_t st, bool add) {
|
||||
uint16_t v = GetRegMenuValue(st);
|
||||
RegisterSpec s = registerSpecs[st];
|
||||
|
||||
if(s.num == BK4819_REG_13)
|
||||
LockAGC();
|
||||
|
||||
uint16_t reg = BK4819_ReadRegister(s.num);
|
||||
if (add && v <= s.maxValue - s.inc) {
|
||||
if (add && v <= s.mask - s.inc) {
|
||||
v += s.inc;
|
||||
} else if (!add && v >= 0 + s.inc) {
|
||||
v -= s.inc;
|
||||
}
|
||||
// TODO: use max value for bits count in max value, or reset by additional
|
||||
// mask in spec
|
||||
reg &= ~(s.maxValue << s.offset);
|
||||
reg &= ~(s.mask << s.offset);
|
||||
BK4819_WriteRegister(s.num, reg | (v << s.offset));
|
||||
redrawScreen = true;
|
||||
}
|
||||
@@ -135,21 +150,13 @@ static void SetRegMenuValue(uint8_t st, bool add) {
|
||||
// GUI functions
|
||||
|
||||
static void PutPixel(uint8_t x, uint8_t y, bool fill) {
|
||||
if (fill) {
|
||||
gFrameBuffer[y >> 3][x] |= 1 << (y & 7);
|
||||
} else {
|
||||
gFrameBuffer[y >> 3][x] &= ~(1 << (y & 7));
|
||||
}
|
||||
UI_DrawPixelBuffer(gFrameBuffer, x, y, fill);
|
||||
}
|
||||
static void PutPixelStatus(uint8_t x, uint8_t y, bool fill) {
|
||||
if (fill) {
|
||||
gStatusLine[x] |= 1 << y;
|
||||
} else {
|
||||
gStatusLine[x] &= ~(1 << y);
|
||||
}
|
||||
UI_DrawPixelBuffer(&gStatusLine, x, y, fill);
|
||||
}
|
||||
|
||||
static void DrawHLine(int sy, int ey, int nx, bool fill) {
|
||||
static void DrawVLine(int sy, int ey, int nx, bool fill) {
|
||||
for (int i = sy; i <= ey; i++) {
|
||||
if (i < 56 && nx < 128) {
|
||||
PutPixel(nx, i, fill);
|
||||
@@ -214,35 +221,28 @@ static void ToggleAFBit(bool on) {
|
||||
BK4819_WriteRegister(BK4819_REG_47, reg);
|
||||
}
|
||||
|
||||
static const BK4819_REGISTER_t registers_to_save[] ={
|
||||
BK4819_REG_30,
|
||||
BK4819_REG_37,
|
||||
BK4819_REG_3D,
|
||||
BK4819_REG_43,
|
||||
BK4819_REG_47,
|
||||
BK4819_REG_48,
|
||||
BK4819_REG_7E,
|
||||
};
|
||||
|
||||
static uint16_t registers_stack [sizeof(registers_to_save)];
|
||||
|
||||
static void BackupRegisters() {
|
||||
R30 = BK4819_ReadRegister(0x30);
|
||||
R37 = BK4819_ReadRegister(0x37);
|
||||
R3D = BK4819_ReadRegister(0x3D);
|
||||
R43 = BK4819_ReadRegister(0x43);
|
||||
R47 = BK4819_ReadRegister(0x47);
|
||||
R48 = BK4819_ReadRegister(0x48);
|
||||
R7E = BK4819_ReadRegister(0x7E);
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(registers_to_save); i++){
|
||||
registers_stack[i] = BK4819_ReadRegister(registers_to_save[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void RestoreRegisters() {
|
||||
BK4819_WriteRegister(0x30, R30);
|
||||
BK4819_WriteRegister(0x37, R37);
|
||||
BK4819_WriteRegister(0x3D, R3D);
|
||||
BK4819_WriteRegister(0x43, R43);
|
||||
BK4819_WriteRegister(0x47, R47);
|
||||
BK4819_WriteRegister(0x48, R48);
|
||||
BK4819_WriteRegister(0x7E, R7E);
|
||||
}
|
||||
|
||||
static void SetModulation(ModulationType type) {
|
||||
RestoreRegisters();
|
||||
uint16_t reg = BK4819_ReadRegister(BK4819_REG_47);
|
||||
reg &= ~(0b111 << 8);
|
||||
BK4819_WriteRegister(BK4819_REG_47, reg | (modTypeReg47Values[type] << 8));
|
||||
if (type == MOD_USB) {
|
||||
BK4819_WriteRegister(0x3D, 0b0010101101000101);
|
||||
BK4819_WriteRegister(BK4819_REG_37, 0x160F);
|
||||
BK4819_WriteRegister(0x48, 0b0000001110101000);
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(registers_to_save); i++){
|
||||
BK4819_WriteRegister(registers_to_save[i], registers_stack[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,8 +259,9 @@ static void SetF(uint32_t f) {
|
||||
|
||||
BK4819_SetFrequency(fMeasure);
|
||||
BK4819_PickRXFilterPathBasedOnFrequency(fMeasure);
|
||||
uint16_t reg = BK4819_ReadRegister(BK4819_REG_30);
|
||||
BK4819_WriteRegister(BK4819_REG_30, 0);
|
||||
BK4819_WriteRegister(BK4819_REG_30, 0xbff1);
|
||||
BK4819_WriteRegister(BK4819_REG_30, reg);
|
||||
}
|
||||
|
||||
// Spectrum related
|
||||
@@ -273,12 +274,24 @@ static void ResetPeak() {
|
||||
}
|
||||
|
||||
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 GetStepsCount()
|
||||
{
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
if(gScanRangeStart) {
|
||||
return (gScanRangeStop - gScanRangeStart) / GetScanStep();
|
||||
}
|
||||
#endif
|
||||
return 128 >> settings.stepsCount;
|
||||
}
|
||||
|
||||
uint32_t GetBW() { return GetStepsCount() * GetScanStep(); }
|
||||
uint32_t GetFStart() {
|
||||
return IsCenterMode() ? currentFreq - (GetBW() >> 1) : currentFreq;
|
||||
}
|
||||
|
||||
uint32_t GetFEnd() { return currentFreq + GetBW(); }
|
||||
|
||||
static void TuneToPeak() {
|
||||
@@ -294,13 +307,22 @@ static void DeInitSpectrum() {
|
||||
isInitialized = false;
|
||||
}
|
||||
|
||||
uint8_t GetBWRegValueForScan() { return scanStepBWRegValues[0]; }
|
||||
uint8_t GetBWRegValueForScan() {
|
||||
return scanStepBWRegValues[settings.scanStepIndex];
|
||||
}
|
||||
|
||||
uint16_t GetRssi() {
|
||||
SYSTICK_DelayUs(settings.scanDelay);
|
||||
/* while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255)
|
||||
; */
|
||||
return BK4819_GetRSSI();
|
||||
// SYSTICK_DelayUs(800);
|
||||
// testing autodelay based on Glitch value
|
||||
while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255) {
|
||||
SYSTICK_DelayUs(100);
|
||||
}
|
||||
uint16_t rssi = BK4819_GetRSSI();
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if(settings.modulationType==MODULATION_AM && gSetting_AM_fix)
|
||||
rssi += AM_fix_get_gain_diff()*2;
|
||||
#endif
|
||||
return rssi;
|
||||
}
|
||||
|
||||
static void ToggleAudio(bool on) {
|
||||
@@ -309,16 +331,17 @@ static void ToggleAudio(bool on) {
|
||||
}
|
||||
audioState = on;
|
||||
if (on) {
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOn();
|
||||
} else {
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOff();
|
||||
}
|
||||
}
|
||||
|
||||
static void ToggleRX(bool on) {
|
||||
isListening = on;
|
||||
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, on);
|
||||
RADIO_SetupAGC(on, lockAGC);
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, on);
|
||||
|
||||
ToggleAudio(on);
|
||||
ToggleAFDAC(on);
|
||||
@@ -355,13 +378,19 @@ static void ResetBlacklist() {
|
||||
if (rssiHistory[i] == RSSI_MAX_VALUE)
|
||||
rssiHistory[i] = 0;
|
||||
}
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
memset(blacklistFreqs, 0, sizeof(blacklistFreqs));
|
||||
blacklistFreqsIdx = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void RelaunchScan() {
|
||||
InitScan();
|
||||
ResetPeak();
|
||||
ToggleRX(false);
|
||||
#ifdef SPECTRUM_AUTOMATIC_SQUELCH
|
||||
settings.rssiTriggerLevel = RSSI_MAX_VALUE;
|
||||
#endif
|
||||
preventKeypress = true;
|
||||
scanInfo.rssiMin = RSSI_MAX_VALUE;
|
||||
}
|
||||
@@ -399,16 +428,48 @@ static void UpdatePeakInfo() {
|
||||
UpdatePeakInfoForce();
|
||||
}
|
||||
|
||||
static void Measure() { rssiHistory[scanInfo.i] = scanInfo.rssi = GetRssi(); }
|
||||
static void SetRssiHistory(uint16_t idx, uint16_t rssi)
|
||||
{
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
if(scanInfo.measurementsCount > 128) {
|
||||
uint8_t i = (uint32_t)ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * idx / 1000;
|
||||
if(rssiHistory[i] < rssi || isListening)
|
||||
rssiHistory[i] = rssi;
|
||||
rssiHistory[(i+1)%128] = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
rssiHistory[idx] = rssi;
|
||||
}
|
||||
|
||||
static void Measure()
|
||||
{
|
||||
uint16_t rssi = scanInfo.rssi = GetRssi();
|
||||
SetRssiHistory(scanInfo.i, rssi);
|
||||
}
|
||||
|
||||
// Update things by keypress
|
||||
|
||||
static uint16_t dbm2rssi(int dBm) {
|
||||
return (dBm + 160 - dBmCorrTable[gRxVfo->Band]) * 2;
|
||||
}
|
||||
|
||||
static void ClampRssiTriggerLevel() {
|
||||
settings.rssiTriggerLevel =
|
||||
clamp(settings.rssiTriggerLevel, dbm2rssi(settings.dbMin),
|
||||
dbm2rssi(settings.dbMax));
|
||||
}
|
||||
|
||||
static void UpdateRssiTriggerLevel(bool inc) {
|
||||
if (inc)
|
||||
settings.rssiTriggerLevel += 2;
|
||||
else
|
||||
settings.rssiTriggerLevel -= 2;
|
||||
|
||||
ClampRssiTriggerLevel();
|
||||
|
||||
redrawScreen = true;
|
||||
redrawStatus = true;
|
||||
}
|
||||
|
||||
static void UpdateDBMax(bool inc) {
|
||||
@@ -419,23 +480,24 @@ static void UpdateDBMax(bool inc) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
// RelaunchScan();
|
||||
|
||||
ClampRssiTriggerLevel();
|
||||
redrawStatus = true;
|
||||
redrawScreen = true;
|
||||
SYSTEM_DelayMs(20);
|
||||
}
|
||||
|
||||
static void UpdateScanStep(bool inc) {
|
||||
if (inc && settings.scanStepIndex < S_STEP_100_0kHz) {
|
||||
settings.scanStepIndex++;
|
||||
} else if (!inc && settings.scanStepIndex > 0) {
|
||||
settings.scanStepIndex--;
|
||||
if (inc) {
|
||||
settings.scanStepIndex = settings.scanStepIndex != S_STEP_100_0kHz ? settings.scanStepIndex + 1 : 0;
|
||||
} else {
|
||||
return;
|
||||
settings.scanStepIndex = settings.scanStepIndex != 0 ? settings.scanStepIndex - 1 : S_STEP_100_0kHz;
|
||||
}
|
||||
|
||||
settings.frequencyChangeStep = GetBW() >> 1;
|
||||
RelaunchScan();
|
||||
ResetBlacklist();
|
||||
redrawStatus = true;
|
||||
redrawScreen = true;
|
||||
}
|
||||
|
||||
static void UpdateCurrentFreq(bool inc) {
|
||||
@@ -475,12 +537,14 @@ static void UpdateFreqChangeStep(bool inc) {
|
||||
}
|
||||
|
||||
static void ToggleModulation() {
|
||||
if (settings.modulationType < MOD_USB) {
|
||||
if (settings.modulationType < MODULATION_UKNOWN - 1) {
|
||||
settings.modulationType++;
|
||||
} else {
|
||||
settings.modulationType = MOD_FM;
|
||||
settings.modulationType = MODULATION_FM;
|
||||
}
|
||||
SetModulation(settings.modulationType);
|
||||
RADIO_SetModulation(settings.modulationType);
|
||||
|
||||
RelaunchScan();
|
||||
redrawScreen = true;
|
||||
}
|
||||
|
||||
@@ -496,9 +560,9 @@ static void ToggleListeningBW() {
|
||||
static void ToggleBacklight() {
|
||||
settings.backlightState = !settings.backlightState;
|
||||
if (settings.backlightState) {
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
||||
BACKLIGHT_TurnOn();
|
||||
} else {
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
||||
BACKLIGHT_TurnOff();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,7 +575,7 @@ static void ToggleStepsCount() {
|
||||
settings.frequencyChangeStep = GetBW() >> 1;
|
||||
RelaunchScan();
|
||||
ResetBlacklist();
|
||||
redrawStatus = true;
|
||||
redrawScreen = true;
|
||||
}
|
||||
|
||||
static void ResetFreqInput() {
|
||||
@@ -540,6 +604,8 @@ static void UpdateFreqInput(KEY_Code_t key) {
|
||||
}
|
||||
if (key == KEY_EXIT) {
|
||||
freqInputIndex--;
|
||||
if (freqInputDotIndex == freqInputIndex)
|
||||
freqInputDotIndex = 0;
|
||||
} else {
|
||||
freqInputArr[freqInputIndex++] = key;
|
||||
}
|
||||
@@ -553,7 +619,7 @@ static void UpdateFreqInput(KEY_Code_t key) {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
if (i < freqInputIndex) {
|
||||
digitKey = freqInputArr[i];
|
||||
freqInputString[i] = digitKey <= KEY_9 ? '0' + digitKey : '.';
|
||||
freqInputString[i] = digitKey <= KEY_9 ? '0' + digitKey - KEY_0 : '.';
|
||||
} else {
|
||||
freqInputString[i] = '-';
|
||||
}
|
||||
@@ -561,14 +627,14 @@ static void UpdateFreqInput(KEY_Code_t key) {
|
||||
|
||||
uint32_t base = 100000; // 1MHz in BK units
|
||||
for (int i = dotIndex - 1; i >= 0; --i) {
|
||||
tempFreq += freqInputArr[i] * base;
|
||||
tempFreq += (freqInputArr[i] - KEY_0) * base;
|
||||
base *= 10;
|
||||
}
|
||||
|
||||
base = 10000; // 0.1MHz in BK units
|
||||
if (dotIndex < freqInputIndex) {
|
||||
for (int i = dotIndex + 1; i < freqInputIndex; ++i) {
|
||||
tempFreq += freqInputArr[i] * base;
|
||||
tempFreq += (freqInputArr[i] - KEY_0) * base;
|
||||
base /= 10;
|
||||
}
|
||||
}
|
||||
@@ -576,22 +642,37 @@ static void UpdateFreqInput(KEY_Code_t key) {
|
||||
}
|
||||
|
||||
static void Blacklist() {
|
||||
rssiHistory[peak.i] = RSSI_MAX_VALUE;
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
blacklistFreqs[blacklistFreqsIdx++ % ARRAY_SIZE(blacklistFreqs)] = peak.i;
|
||||
#endif
|
||||
|
||||
SetRssiHistory(peak.i, RSSI_MAX_VALUE);
|
||||
ResetPeak();
|
||||
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
|
||||
|
||||
// applied x2 to prevent initial rounding
|
||||
uint8_t Rssi2PX(uint16_t rssi, uint8_t pxMin, uint8_t pxMax) {
|
||||
const int DB_MIN = settings.dbMin;
|
||||
const int DB_MAX = settings.dbMax;
|
||||
const int DB_MIN = settings.dbMin << 1;
|
||||
const int DB_MAX = settings.dbMax << 1;
|
||||
const int DB_RANGE = DB_MAX - DB_MIN;
|
||||
|
||||
const uint8_t PX_RANGE = pxMax - pxMin;
|
||||
|
||||
int dbm = clamp(Rssi2DBm(rssi), DB_MIN, DB_MAX);
|
||||
int dbm = clamp(Rssi2DBm(rssi) << 1, DB_MIN, DB_MAX);
|
||||
|
||||
return ((dbm - DB_MIN) * PX_RANGE + DB_RANGE / 2) / DB_RANGE + pxMin;
|
||||
}
|
||||
@@ -604,68 +685,56 @@ static void DrawSpectrum() {
|
||||
for (uint8_t x = 0; x < 128; ++x) {
|
||||
uint16_t rssi = rssiHistory[x >> settings.stepsCount];
|
||||
if (rssi != RSSI_MAX_VALUE) {
|
||||
DrawHLine(Rssi2Y(rssi), DrawingEndY, x, true);
|
||||
DrawVLine(Rssi2Y(rssi), DrawingEndY, x, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawStatus() {
|
||||
#ifdef SPECTRUM_EXTRA_VALUES
|
||||
sprintf(String, "%d/%d P:%d T:%d", settings.dbMin, settings.dbMax,
|
||||
Rssi2DBm(peak.rssi), Rssi2DBm(settings.rssiTriggerLevel));
|
||||
#else
|
||||
sprintf(String, "%d/%d", settings.dbMin, settings.dbMax);
|
||||
GUI_DisplaySmallest(String, 0, 2, true, true);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent);
|
||||
#endif
|
||||
GUI_DisplaySmallest(String, 0, 1, true, true);
|
||||
|
||||
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryCheckCounter++ % 4],
|
||||
&gBatteryCurrent);
|
||||
|
||||
uint16_t voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] +
|
||||
gBatteryVoltages[2] + gBatteryVoltages[3]) /
|
||||
4 * 760 / gBatteryCalibration[3];
|
||||
|
||||
unsigned perc = BATTERY_VoltsToPercent(voltage);
|
||||
|
||||
// sprintf(String, "%d %d", voltage, perc);
|
||||
// GUI_DisplaySmallest(String, 48, 1, true, true);
|
||||
|
||||
gStatusLine[116] = 0b00011100;
|
||||
gStatusLine[117] = 0b00111110;
|
||||
for (int i = 118; i <= 126; i++) {
|
||||
gStatusLine[i] = 0b00100010;
|
||||
}
|
||||
|
||||
uint16_t Voltage;
|
||||
uint8_t v = 0;
|
||||
|
||||
Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] +
|
||||
gBatteryVoltages[3]) /
|
||||
4;
|
||||
|
||||
if (gBatteryCalibration[5] < Voltage) {
|
||||
v = 5;
|
||||
} else if (gBatteryCalibration[4] < Voltage) {
|
||||
v = 5;
|
||||
} else if (gBatteryCalibration[3] < Voltage) {
|
||||
v = 4;
|
||||
} else if (gBatteryCalibration[2] < Voltage) {
|
||||
v = 3;
|
||||
} else if (gBatteryCalibration[1] < Voltage) {
|
||||
v = 2;
|
||||
} else if (gBatteryCalibration[0] < Voltage) {
|
||||
v = 1;
|
||||
}
|
||||
|
||||
gStatusLine[127] = 0b01111110;
|
||||
for (int i = 126; i >= 116; i--) {
|
||||
gStatusLine[i] = 0b01000010;
|
||||
}
|
||||
v <<= 1;
|
||||
for (int i = 125; i >= 116; i--) {
|
||||
if (126 - i <= v) {
|
||||
gStatusLine[i + 2] = 0b01111110;
|
||||
for (unsigned i = 127; i >= 118; i--) {
|
||||
if (127 - i <= (perc + 5) * 9 / 100) {
|
||||
gStatusLine[i] = 0b00111110;
|
||||
}
|
||||
}
|
||||
gStatusLine[117] = 0b01111110;
|
||||
gStatusLine[116] = 0b00011000;
|
||||
}
|
||||
|
||||
static void DrawF(uint32_t f) {
|
||||
sprintf(String, "%u.%05u", f / 100000, f % 100000);
|
||||
UI_PrintStringSmall(String, 0, 127, 0);
|
||||
UI_PrintStringSmallNormal(String, 8, 127, 0);
|
||||
|
||||
sprintf(String, "%s", modulationTypeOptions[settings.modulationType]);
|
||||
GUI_DisplaySmallest(String, 115, 1, false, true);
|
||||
sprintf(String, "%3s", gModulationStr[settings.modulationType]);
|
||||
GUI_DisplaySmallest(String, 116, 1, false, true);
|
||||
sprintf(String, "%s", bwOptions[settings.listenBw]);
|
||||
GUI_DisplaySmallest(String, 107, 7, false, true);
|
||||
GUI_DisplaySmallest(String, 108, 7, false, true);
|
||||
}
|
||||
|
||||
static void DrawNums() {
|
||||
sprintf(String, "P:%d", Rssi2DBm(peak.rssi));
|
||||
GUI_DisplaySmallest(String, 32, 8, false, true);
|
||||
sprintf(String, "T:%d", Rssi2DBm(settings.rssiTriggerLevel));
|
||||
GUI_DisplaySmallest(String, 64, 8, false, true);
|
||||
|
||||
if (currentState == SPECTRUM) {
|
||||
sprintf(String, "%ux", GetStepsCount());
|
||||
@@ -675,7 +744,7 @@ static void DrawNums() {
|
||||
}
|
||||
|
||||
if (IsCenterMode()) {
|
||||
sprintf(String, "%u.%05u \xB1%u.%02uk", currentFreq / 100000,
|
||||
sprintf(String, "%u.%05u \x7F%u.%02uk", currentFreq / 100000,
|
||||
currentFreq % 100000, settings.frequencyChangeStep / 100,
|
||||
settings.frequencyChangeStep % 100);
|
||||
GUI_DisplaySmallest(String, 36, 49, false, true);
|
||||
@@ -683,7 +752,7 @@ static void DrawNums() {
|
||||
sprintf(String, "%u.%05u", GetFStart() / 100000, GetFStart() % 100000);
|
||||
GUI_DisplaySmallest(String, 0, 49, false, true);
|
||||
|
||||
sprintf(String, "\xB1%u.%02uk", settings.frequencyChangeStep / 100,
|
||||
sprintf(String, "\x7F%u.%02uk", settings.frequencyChangeStep / 100,
|
||||
settings.frequencyChangeStep % 100);
|
||||
GUI_DisplaySmallest(String, 48, 49, false, true);
|
||||
|
||||
@@ -702,9 +771,11 @@ static void DrawRssiTriggerLevel() {
|
||||
}
|
||||
|
||||
static void DrawTicks() {
|
||||
uint32_t f = GetFStart() % 100000;
|
||||
uint32_t step = GetScanStep();
|
||||
for (uint8_t i = 0; i < 128; i += (1 << settings.stepsCount), f += step) {
|
||||
uint32_t f = GetFStart();
|
||||
uint32_t span = GetFEnd() - GetFStart();
|
||||
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;
|
||||
(f % 10000) < step && (barValue |= 0b00000010);
|
||||
(f % 50000) < step && (barValue |= 0b00000100);
|
||||
@@ -715,19 +786,13 @@ static void DrawTicks() {
|
||||
|
||||
// center
|
||||
if (IsCenterMode()) {
|
||||
gFrameBuffer[5][62] = 0x80;
|
||||
gFrameBuffer[5][63] = 0x80;
|
||||
memset(gFrameBuffer[5] + 62, 0x80, 5);
|
||||
gFrameBuffer[5][64] = 0xff;
|
||||
gFrameBuffer[5][65] = 0x80;
|
||||
gFrameBuffer[5][66] = 0x80;
|
||||
} else {
|
||||
memset(gFrameBuffer[5] + 1, 0x80, 3);
|
||||
memset(gFrameBuffer[5] + 124, 0x80, 3);
|
||||
|
||||
gFrameBuffer[5][0] = 0xff;
|
||||
gFrameBuffer[5][1] = 0x80;
|
||||
gFrameBuffer[5][2] = 0x80;
|
||||
gFrameBuffer[5][3] = 0x80;
|
||||
gFrameBuffer[5][124] = 0x80;
|
||||
gFrameBuffer[5][125] = 0x80;
|
||||
gFrameBuffer[5][126] = 0x80;
|
||||
gFrameBuffer[5][127] = 0xff;
|
||||
}
|
||||
}
|
||||
@@ -762,10 +827,16 @@ static void OnKeyDown(uint8_t key) {
|
||||
UpdateFreqChangeStep(false);
|
||||
break;
|
||||
case KEY_UP:
|
||||
UpdateCurrentFreq(true);
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
if(!gScanRangeStart)
|
||||
#endif
|
||||
UpdateCurrentFreq(true);
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
UpdateCurrentFreq(false);
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
if(!gScanRangeStart)
|
||||
#endif
|
||||
UpdateCurrentFreq(false);
|
||||
break;
|
||||
case KEY_SIDE1:
|
||||
Blacklist();
|
||||
@@ -777,7 +848,10 @@ static void OnKeyDown(uint8_t key) {
|
||||
UpdateRssiTriggerLevel(false);
|
||||
break;
|
||||
case KEY_5:
|
||||
FreqInput();
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
if(!gScanRangeStart)
|
||||
#endif
|
||||
FreqInput();
|
||||
break;
|
||||
case KEY_0:
|
||||
ToggleModulation();
|
||||
@@ -786,7 +860,10 @@ static void OnKeyDown(uint8_t key) {
|
||||
ToggleListeningBW();
|
||||
break;
|
||||
case KEY_4:
|
||||
ToggleStepsCount();
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
if(!gScanRangeStart)
|
||||
#endif
|
||||
ToggleStepsCount();
|
||||
break;
|
||||
case KEY_SIDE2:
|
||||
ToggleBacklight();
|
||||
@@ -894,8 +971,8 @@ void OnKeyDownStill(KEY_Code_t key) {
|
||||
break;
|
||||
case KEY_PTT:
|
||||
// TODO: start transmit
|
||||
/* BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false);
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true); */
|
||||
/* BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false);
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true); */
|
||||
break;
|
||||
case KEY_MENU:
|
||||
if (menuState == ARRAY_SIZE(registerSpecs) - 1) {
|
||||
@@ -908,6 +985,7 @@ void OnKeyDownStill(KEY_Code_t key) {
|
||||
case KEY_EXIT:
|
||||
if (!menuState) {
|
||||
SetState(SPECTRUM);
|
||||
lockAGC = false;
|
||||
monitorMode = false;
|
||||
RelaunchScan();
|
||||
break;
|
||||
@@ -919,9 +997,7 @@ void OnKeyDownStill(KEY_Code_t key) {
|
||||
}
|
||||
}
|
||||
|
||||
static void RenderFreqInput() {
|
||||
UI_PrintString(freqInputString, 2, 127, 0, 8);
|
||||
}
|
||||
static void RenderFreqInput() { UI_PrintString(freqInputString, 2, 127, 0, 8); }
|
||||
|
||||
static void RenderStatus() {
|
||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||
@@ -931,7 +1007,7 @@ static void RenderStatus() {
|
||||
|
||||
static void RenderSpectrum() {
|
||||
DrawTicks();
|
||||
DrawArrow(peak.i << settings.stepsCount);
|
||||
DrawArrow(128u * peak.i / GetStepsCount());
|
||||
DrawSpectrum();
|
||||
DrawRssiTriggerLevel();
|
||||
DrawF(peak.f);
|
||||
@@ -943,14 +1019,14 @@ static void RenderStill() {
|
||||
|
||||
const uint8_t METER_PAD_LEFT = 3;
|
||||
|
||||
for (int i = 0; i < 121; i++) {
|
||||
if (i % 10 == 0) {
|
||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b01110000;
|
||||
} else if (i % 5 == 0) {
|
||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00110000;
|
||||
} else {
|
||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00010000;
|
||||
}
|
||||
memset(&gFrameBuffer[2][METER_PAD_LEFT], 0b00010000, 121);
|
||||
|
||||
for (int i = 0; i < 121; i+=5) {
|
||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00110000;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 121; i+=10) {
|
||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b01110000;
|
||||
}
|
||||
|
||||
uint8_t x = Rssi2PX(scanInfo.rssi, 0, 121);
|
||||
@@ -966,8 +1042,6 @@ static void RenderStill() {
|
||||
GUI_DisplaySmallest(String, 4, 25, false, true);
|
||||
sprintf(String, "%d dBm", dbm);
|
||||
GUI_DisplaySmallest(String, 28, 25, false, true);
|
||||
sprintf(String, "V: %d", scanInfo.rssi);
|
||||
GUI_DisplaySmallest(String, 64, 25, false, true);
|
||||
|
||||
if (!monitorMode) {
|
||||
uint8_t x = Rssi2PX(settings.rssiTriggerLevel, 0, 121);
|
||||
@@ -1001,7 +1075,7 @@ static void RenderStill() {
|
||||
}
|
||||
|
||||
static void Render() {
|
||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
||||
UI_DisplayClear();
|
||||
|
||||
switch (currentState) {
|
||||
case SPECTRUM:
|
||||
@@ -1022,17 +1096,17 @@ bool HandleUserInput() {
|
||||
kbd.prev = kbd.current;
|
||||
kbd.current = GetKey();
|
||||
|
||||
if (kbd.current == KEY_INVALID) {
|
||||
kbd.counter = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kbd.current == kbd.prev && kbd.counter <= 16) {
|
||||
kbd.counter++;
|
||||
if (kbd.current != KEY_INVALID && kbd.current == kbd.prev) {
|
||||
if (kbd.counter < 16)
|
||||
kbd.counter++;
|
||||
else
|
||||
kbd.counter -= 3;
|
||||
SYSTEM_DelayMs(20);
|
||||
} else {
|
||||
kbd.counter = 0;
|
||||
}
|
||||
|
||||
if (kbd.counter == 3 || kbd.counter > 16) {
|
||||
if (kbd.counter == 3 || kbd.counter == 16) {
|
||||
switch (currentState) {
|
||||
case SPECTRUM:
|
||||
OnKeyDown(kbd.current);
|
||||
@@ -1050,7 +1124,11 @@ bool HandleUserInput() {
|
||||
}
|
||||
|
||||
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);
|
||||
Measure();
|
||||
UpdateScanInfo();
|
||||
@@ -1071,6 +1149,10 @@ static void UpdateScan() {
|
||||
return;
|
||||
}
|
||||
|
||||
if(scanInfo.measurementsCount < 128)
|
||||
memset(&rssiHistory[scanInfo.measurementsCount], 0,
|
||||
sizeof(rssiHistory) - scanInfo.measurementsCount*sizeof(rssiHistory[0]));
|
||||
|
||||
redrawScreen = true;
|
||||
preventKeypress = false;
|
||||
|
||||
@@ -1107,7 +1189,6 @@ static void UpdateListening() {
|
||||
}
|
||||
|
||||
if (currentState == SPECTRUM) {
|
||||
SetF(fMeasure);
|
||||
BK4819_WriteRegister(0x43, GetBWRegValueForScan());
|
||||
Measure();
|
||||
BK4819_WriteRegister(0x43, listenBWRegValues[settings.listenBw]);
|
||||
@@ -1124,10 +1205,39 @@ static void UpdateListening() {
|
||||
}
|
||||
|
||||
ToggleRX(false);
|
||||
newScanStart = true;
|
||||
ResetScanStats();
|
||||
}
|
||||
|
||||
static void Tick() {
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if (gNextTimeslice) {
|
||||
gNextTimeslice = false;
|
||||
if(settings.modulationType == MODULATION_AM && !lockAGC) {
|
||||
AM_fix_10ms(vfo); //allow AM_Fix to apply its AGC action
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
if (gNextTimeslice_500ms) {
|
||||
gNextTimeslice_500ms = false;
|
||||
|
||||
// if a lot of steps then it takes long time
|
||||
// we don't want to wait for whole scan
|
||||
// listening has it's own timer
|
||||
if(GetStepsCount()>128 && !isListening) {
|
||||
UpdatePeakInfo();
|
||||
if (IsPeakOverLevel()) {
|
||||
ToggleRX(true);
|
||||
TuneToPeak();
|
||||
return;
|
||||
}
|
||||
redrawScreen = true;
|
||||
preventKeypress = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!preventKeypress) {
|
||||
HandleUserInput();
|
||||
}
|
||||
@@ -1157,25 +1267,40 @@ static void Tick() {
|
||||
|
||||
void APP_RunSpectrum() {
|
||||
// TX here coz it always? set to active VFO
|
||||
currentFreq = initialFreq =
|
||||
gEeprom.VfoInfo[gEeprom.TX_CHANNEL].pRX->Frequency;
|
||||
vfo = gEeprom.TX_VFO;
|
||||
// set the current frequency in the middle of the display
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
if(gScanRangeStart) {
|
||||
currentFreq = initialFreq = gScanRangeStart;
|
||||
for(uint8_t i = 0; i < ARRAY_SIZE(scanStepValues); i++) {
|
||||
if(scanStepValues[i] >= gTxVfo->StepFrequency) {
|
||||
settings.scanStepIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
settings.stepsCount = STEPS_128;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
currentFreq = initialFreq = gTxVfo->pRX->Frequency -
|
||||
((GetStepsCount() / 2) * GetScanStep());
|
||||
|
||||
BackupRegisters();
|
||||
|
||||
isListening = true; // to turn off RX later
|
||||
redrawStatus = true;
|
||||
redrawScreen = false; // we will wait until scan done
|
||||
redrawScreen = true;
|
||||
newScanStart = true;
|
||||
|
||||
ToggleRX(false);
|
||||
SetModulation(settings.modulationType = MOD_FM);
|
||||
|
||||
ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off
|
||||
RADIO_SetModulation(settings.modulationType = gTxVfo->Modulation);
|
||||
|
||||
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
|
||||
|
||||
RelaunchScan();
|
||||
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
rssiHistory[i] = 0;
|
||||
}
|
||||
memset(rssiHistory, 0, sizeof(rssiHistory));
|
||||
|
||||
isInitialized = true;
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "../driver/systick.h"
|
||||
#include "../external/printf/printf.h"
|
||||
#include "../font.h"
|
||||
#include "../frequencies.h"
|
||||
#include "../helper/battery.h"
|
||||
#include "../misc.h"
|
||||
#include "../radio.h"
|
||||
@@ -46,9 +45,8 @@ static const uint8_t U8RssiMap[] = {
|
||||
};
|
||||
|
||||
static const uint16_t scanStepValues[] = {
|
||||
1, 10, 50, 100,
|
||||
|
||||
250, 500, 625, 833, 1000, 1250, 2500, 10000,
|
||||
1, 10, 50, 100, 250, 500, 625, 833,
|
||||
1000, 1250, 1500, 2000, 2500, 5000, 10000,
|
||||
};
|
||||
|
||||
static const uint16_t scanStepBWRegValues[] = {
|
||||
@@ -99,12 +97,6 @@ typedef enum StepsCount {
|
||||
STEPS_16,
|
||||
} StepsCount;
|
||||
|
||||
typedef enum ModulationType {
|
||||
MOD_FM,
|
||||
MOD_AM,
|
||||
MOD_USB,
|
||||
} ModulationType;
|
||||
|
||||
typedef enum ScanStep {
|
||||
S_STEP_0_01kHz,
|
||||
S_STEP_0_1kHz,
|
||||
@@ -117,23 +109,25 @@ typedef enum ScanStep {
|
||||
S_STEP_8_33kHz,
|
||||
S_STEP_10_0kHz,
|
||||
S_STEP_12_5kHz,
|
||||
S_STEP_15_0kHz,
|
||||
S_STEP_20_0kHz,
|
||||
S_STEP_25_0kHz,
|
||||
S_STEP_50_0kHz,
|
||||
S_STEP_100_0kHz,
|
||||
} ScanStep;
|
||||
|
||||
typedef struct SpectrumSettings {
|
||||
uint32_t frequencyChangeStep;
|
||||
StepsCount stepsCount;
|
||||
ScanStep scanStepIndex;
|
||||
uint32_t frequencyChangeStep;
|
||||
uint16_t scanDelay;
|
||||
uint16_t rssiTriggerLevel;
|
||||
|
||||
bool backlightState;
|
||||
BK4819_FilterBandwidth_t bw;
|
||||
BK4819_FilterBandwidth_t listenBw;
|
||||
ModulationType modulationType;
|
||||
int dbMin;
|
||||
int dbMax;
|
||||
int dbMax;
|
||||
ModulationMode_t modulationType;
|
||||
bool backlightState;
|
||||
} SpectrumSettings;
|
||||
|
||||
typedef struct KeyboardState {
|
||||
@@ -144,25 +138,17 @@ typedef struct KeyboardState {
|
||||
|
||||
typedef struct ScanInfo {
|
||||
uint16_t rssi, rssiMin, rssiMax;
|
||||
uint8_t i, iPeak;
|
||||
uint16_t i, iPeak;
|
||||
uint32_t f, fPeak;
|
||||
uint16_t scanStep;
|
||||
uint8_t measurementsCount;
|
||||
uint16_t measurementsCount;
|
||||
} ScanInfo;
|
||||
|
||||
typedef struct RegisterSpec {
|
||||
char *name;
|
||||
uint8_t num;
|
||||
uint8_t offset;
|
||||
uint16_t maxValue;
|
||||
uint16_t inc;
|
||||
} RegisterSpec;
|
||||
|
||||
typedef struct PeakInfo {
|
||||
uint16_t t;
|
||||
uint16_t rssi;
|
||||
uint8_t i;
|
||||
uint32_t f;
|
||||
uint16_t i;
|
||||
} PeakInfo;
|
||||
|
||||
void APP_RunSpectrum(void);
|
||||
|
||||
175
app/uart.c
@@ -27,6 +27,7 @@
|
||||
#include "bsp/dp32g030/dma.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "driver/aes.h"
|
||||
#include "driver/backlight.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/crc.h"
|
||||
#include "driver/eeprom.h"
|
||||
@@ -35,10 +36,12 @@
|
||||
#include "functions.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
#include "version.h"
|
||||
|
||||
#if defined(ENABLE_OVERLAY)
|
||||
#include "sram-overlay.h"
|
||||
#endif
|
||||
#include "version.h"
|
||||
|
||||
|
||||
#define DMA_INDEX(x, y) (((x) + (y)) % sizeof(UART_DMA_Buffer))
|
||||
|
||||
@@ -48,7 +51,7 @@ typedef struct {
|
||||
} Header_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t Padding[2];
|
||||
uint8_t Padding[2];
|
||||
uint16_t ID;
|
||||
} Footer_t;
|
||||
|
||||
@@ -60,10 +63,10 @@ typedef struct {
|
||||
typedef struct {
|
||||
Header_t Header;
|
||||
struct {
|
||||
char Version[16];
|
||||
bool bHasCustomAesKey;
|
||||
bool bIsInLockScreen;
|
||||
uint8_t Padding[2];
|
||||
char Version[16];
|
||||
bool bHasCustomAesKey;
|
||||
bool bIsInLockScreen;
|
||||
uint8_t Padding[2];
|
||||
uint32_t Challenge[4];
|
||||
} Data;
|
||||
} REPLY_0514_t;
|
||||
@@ -71,8 +74,8 @@ typedef struct {
|
||||
typedef struct {
|
||||
Header_t Header;
|
||||
uint16_t Offset;
|
||||
uint8_t Size;
|
||||
uint8_t Padding;
|
||||
uint8_t Size;
|
||||
uint8_t Padding;
|
||||
uint32_t Timestamp;
|
||||
} CMD_051B_t;
|
||||
|
||||
@@ -80,19 +83,19 @@ typedef struct {
|
||||
Header_t Header;
|
||||
struct {
|
||||
uint16_t Offset;
|
||||
uint8_t Size;
|
||||
uint8_t Padding;
|
||||
uint8_t Data[128];
|
||||
uint8_t Size;
|
||||
uint8_t Padding;
|
||||
uint8_t Data[128];
|
||||
} Data;
|
||||
} REPLY_051B_t;
|
||||
|
||||
typedef struct {
|
||||
Header_t Header;
|
||||
uint16_t Offset;
|
||||
uint8_t Size;
|
||||
bool bAllowPassword;
|
||||
uint8_t Size;
|
||||
bool bAllowPassword;
|
||||
uint32_t Timestamp;
|
||||
uint8_t Data[0];
|
||||
uint8_t Data[0];
|
||||
} CMD_051D_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -106,8 +109,8 @@ typedef struct {
|
||||
Header_t Header;
|
||||
struct {
|
||||
uint16_t RSSI;
|
||||
uint8_t ExNoiseIndicator;
|
||||
uint8_t GlitchIndicator;
|
||||
uint8_t ExNoiseIndicator;
|
||||
uint8_t GlitchIndicator;
|
||||
} Data;
|
||||
} REPLY_0527_t;
|
||||
|
||||
@@ -137,7 +140,10 @@ typedef struct {
|
||||
uint32_t Timestamp;
|
||||
} CMD_052F_t;
|
||||
|
||||
static const uint8_t Obfuscation[16] = { 0x16, 0x6C, 0x14, 0xE6, 0x2E, 0x91, 0x0D, 0x40, 0x21, 0x35, 0xD5, 0x40, 0x13, 0x03, 0xE9, 0x80 };
|
||||
static const uint8_t Obfuscation[16] =
|
||||
{
|
||||
0x16, 0x6C, 0x14, 0xE6, 0x2E, 0x91, 0x0D, 0x40, 0x21, 0x35, 0xD5, 0x40, 0x13, 0x03, 0xE9, 0x80
|
||||
};
|
||||
|
||||
static union
|
||||
{
|
||||
@@ -157,12 +163,11 @@ static void SendReply(void *pReply, uint16_t Size)
|
||||
{
|
||||
Header_t Header;
|
||||
Footer_t Footer;
|
||||
uint8_t *pBytes;
|
||||
uint16_t i;
|
||||
|
||||
if (bIsEncrypted)
|
||||
{
|
||||
pBytes = (uint8_t *)pReply;
|
||||
uint8_t *pBytes = (uint8_t *)pReply;
|
||||
unsigned int i;
|
||||
for (i = 0; i < Size; i++)
|
||||
pBytes[i] ^= Obfuscation[i % 16];
|
||||
}
|
||||
@@ -171,6 +176,7 @@ static void SendReply(void *pReply, uint16_t Size)
|
||||
Header.Size = Size;
|
||||
UART_Send(&Header, sizeof(Header));
|
||||
UART_Send(pReply, Size);
|
||||
|
||||
if (bIsEncrypted)
|
||||
{
|
||||
Footer.Padding[0] = Obfuscation[(Size + 0) % 16] ^ 0xFF;
|
||||
@@ -205,14 +211,16 @@ static void SendVersion(void)
|
||||
|
||||
static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint32_t *pResponse)
|
||||
{
|
||||
uint8_t i;
|
||||
uint32_t IV[4];
|
||||
unsigned int i;
|
||||
uint32_t IV[4];
|
||||
|
||||
IV[0] = 0;
|
||||
IV[1] = 0;
|
||||
IV[2] = 0;
|
||||
IV[3] = 0;
|
||||
|
||||
AES_Encrypt(pKey, IV, pIn, IV, true);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
if (IV[i] != pResponse[i])
|
||||
return true;
|
||||
@@ -220,18 +228,27 @@ static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint
|
||||
return false;
|
||||
}
|
||||
|
||||
// session init, sends back version info and state
|
||||
// timestamp is a session id really
|
||||
static void CMD_0514(const uint8_t *pBuffer)
|
||||
{
|
||||
const CMD_0514_t *pCmd = (const CMD_0514_t *)pBuffer;
|
||||
|
||||
Timestamp = pCmd->Timestamp;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
|
||||
#endif
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
||||
|
||||
gSerialConfigCountDown_500ms = 12; // 6 sec
|
||||
|
||||
// turn the LCD backlight off
|
||||
BACKLIGHT_TurnOff();
|
||||
|
||||
SendVersion();
|
||||
}
|
||||
|
||||
// read eeprom
|
||||
static void CMD_051B(const uint8_t *pBuffer)
|
||||
{
|
||||
const CMD_051B_t *pCmd = (const CMD_051B_t *)pBuffer;
|
||||
@@ -241,14 +258,17 @@ static void CMD_051B(const uint8_t *pBuffer)
|
||||
if (pCmd->Timestamp != Timestamp)
|
||||
return;
|
||||
|
||||
gSerialConfigCountDown_500ms = 12; // 6 sec
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
|
||||
#endif
|
||||
|
||||
memset(&Reply, 0, sizeof(Reply));
|
||||
Reply.Header.ID = 0x051C;
|
||||
Reply.Header.ID = 0x051C;
|
||||
Reply.Header.Size = pCmd->Size + 4;
|
||||
Reply.Data.Offset = pCmd->Offset;
|
||||
Reply.Data.Size = pCmd->Size;
|
||||
Reply.Data.Size = pCmd->Size;
|
||||
|
||||
if (bHasCustomAesKey)
|
||||
bLocked = gIsLocked;
|
||||
@@ -259,6 +279,7 @@ static void CMD_051B(const uint8_t *pBuffer)
|
||||
SendReply(&Reply, pCmd->Size + 8);
|
||||
}
|
||||
|
||||
// write eeprom
|
||||
static void CMD_051D(const uint8_t *pBuffer)
|
||||
{
|
||||
const CMD_051D_t *pCmd = (const CMD_051D_t *)pBuffer;
|
||||
@@ -269,11 +290,14 @@ static void CMD_051D(const uint8_t *pBuffer)
|
||||
if (pCmd->Timestamp != Timestamp)
|
||||
return;
|
||||
|
||||
gSerialConfigCountDown_500ms = 12; // 6 sec
|
||||
|
||||
bReloadEeprom = false;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
|
||||
#endif
|
||||
|
||||
Reply.Header.ID = 0x051E;
|
||||
Reply.Header.Size = sizeof(Reply.Data);
|
||||
Reply.Data.Offset = pCmd->Offset;
|
||||
@@ -282,7 +306,7 @@ static void CMD_051D(const uint8_t *pBuffer)
|
||||
|
||||
if (!bIsLocked)
|
||||
{
|
||||
uint16_t i;
|
||||
unsigned int i;
|
||||
for (i = 0; i < (pCmd->Size / 8); i++)
|
||||
{
|
||||
const uint16_t Offset = pCmd->Offset + (i * 8U);
|
||||
@@ -296,12 +320,13 @@ static void CMD_051D(const uint8_t *pBuffer)
|
||||
}
|
||||
|
||||
if (bReloadEeprom)
|
||||
BOARD_EEPROM_Init();
|
||||
SETTINGS_InitEEPROM();
|
||||
}
|
||||
|
||||
SendReply(&Reply, sizeof(Reply));
|
||||
}
|
||||
|
||||
// read RSSI
|
||||
static void CMD_0527(void)
|
||||
{
|
||||
REPLY_0527_t Reply;
|
||||
@@ -315,27 +340,30 @@ static void CMD_0527(void)
|
||||
SendReply(&Reply, sizeof(Reply));
|
||||
}
|
||||
|
||||
// read ADC
|
||||
static void CMD_0529(void)
|
||||
{
|
||||
REPLY_0529_t Reply;
|
||||
|
||||
Reply.Header.ID = 0x52A;
|
||||
Reply.Header.ID = 0x52A;
|
||||
Reply.Header.Size = sizeof(Reply.Data);
|
||||
|
||||
// Original doesn't actually send current!
|
||||
BOARD_ADC_GetBatteryInfo(&Reply.Data.Voltage, &Reply.Data.Current);
|
||||
|
||||
SendReply(&Reply, sizeof(Reply));
|
||||
}
|
||||
|
||||
static void CMD_052D(const uint8_t *pBuffer)
|
||||
{
|
||||
const CMD_052D_t *pCmd = (const CMD_052D_t *)pBuffer;
|
||||
REPLY_052D_t Reply;
|
||||
bool bIsLocked;
|
||||
REPLY_052D_t Reply;
|
||||
bool bIsLocked;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
|
||||
#endif
|
||||
Reply.Header.ID = 0x052E;
|
||||
Reply.Header.ID = 0x052E;
|
||||
Reply.Header.Size = sizeof(Reply.Data);
|
||||
|
||||
bIsLocked = bHasCustomAesKey;
|
||||
@@ -367,20 +395,27 @@ static void CMD_052D(const uint8_t *pBuffer)
|
||||
SendReply(&Reply, sizeof(Reply));
|
||||
}
|
||||
|
||||
// session init, sends back version info and state
|
||||
// timestamp is a session id really
|
||||
// this command also disables dual watch, crossband,
|
||||
// DTMF side tones, freq reverse, PTT ID, DTMF decoding, frequency offset
|
||||
// exits power save, sets main VFO to upper,
|
||||
static void CMD_052F(const uint8_t *pBuffer)
|
||||
{
|
||||
const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer;
|
||||
|
||||
gEeprom.DUAL_WATCH = DUAL_WATCH_OFF;
|
||||
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
|
||||
gEeprom.RX_CHANNEL = 0;
|
||||
gEeprom.RX_VFO = 0;
|
||||
gEeprom.DTMF_SIDE_TONE = false;
|
||||
gEeprom.VfoInfo[0].FrequencyReverse = false;
|
||||
gEeprom.VfoInfo[0].pRX = &gEeprom.VfoInfo[0].freq_config_RX;
|
||||
gEeprom.VfoInfo[0].pTX = &gEeprom.VfoInfo[0].freq_config_TX;
|
||||
gEeprom.VfoInfo[0].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF;
|
||||
gEeprom.VfoInfo[0].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
gEeprom.VfoInfo[0].DTMF_DECODING_ENABLE = false;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
gIsNoaaMode = false;
|
||||
@@ -389,24 +424,63 @@ static void CMD_052F(const uint8_t *pBuffer)
|
||||
if (gCurrentFunction == FUNCTION_POWER_SAVE)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
|
||||
gSerialConfigCountDown_500ms = 12; // 6 sec
|
||||
|
||||
Timestamp = pCmd->Timestamp;
|
||||
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
||||
// turn the LCD backlight off
|
||||
BACKLIGHT_TurnOff();
|
||||
|
||||
SendVersion();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UART_RW_BK_REGS
|
||||
static void CMD_0601_ReadBK4819Reg(const uint8_t *pBuffer)
|
||||
{
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
Header_t header;
|
||||
uint8_t reg;
|
||||
} CMD_0601_t;
|
||||
|
||||
CMD_0601_t *cmd = (CMD_0601_t*) pBuffer;
|
||||
|
||||
struct __attribute__((__packed__)) {
|
||||
Header_t header;
|
||||
struct __attribute__((__packed__)) {
|
||||
uint8_t reg;
|
||||
uint16_t value;
|
||||
} data;
|
||||
} reply;
|
||||
|
||||
reply.header.ID = 0x0601;
|
||||
reply.header.Size = sizeof(reply.data);
|
||||
reply.data.reg = cmd->reg;
|
||||
reply.data.value = BK4819_ReadRegister(cmd->reg);
|
||||
SendReply(&reply, sizeof(reply));
|
||||
}
|
||||
|
||||
static void CMD_0602_WriteBK4819Reg(const uint8_t *pBuffer)
|
||||
{
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
Header_t header;
|
||||
uint8_t reg;
|
||||
uint16_t value;
|
||||
} CMD_0602_t;
|
||||
|
||||
CMD_0602_t *cmd = (CMD_0602_t*) pBuffer;
|
||||
BK4819_WriteRegister(cmd->reg, cmd->value);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool UART_IsCommandAvailable(void)
|
||||
{
|
||||
uint16_t DmaLength;
|
||||
uint16_t CommandLength;
|
||||
uint16_t Index;
|
||||
uint16_t TailIndex;
|
||||
uint16_t Size;
|
||||
uint16_t CRC;
|
||||
uint16_t i;
|
||||
uint16_t CommandLength;
|
||||
uint16_t DmaLength = DMA_CH0->ST & 0xFFFU;
|
||||
|
||||
DmaLength = DMA_CH0->ST & 0xFFFU;
|
||||
while (1)
|
||||
{
|
||||
if (gUART_WriteIndex == DmaLength)
|
||||
@@ -435,7 +509,7 @@ bool UART_IsCommandAvailable(void)
|
||||
Index = DMA_INDEX(gUART_WriteIndex, 2);
|
||||
Size = (UART_DMA_Buffer[DMA_INDEX(Index, 1)] << 8) | UART_DMA_Buffer[Index];
|
||||
|
||||
if ((Size + 8) > sizeof(UART_DMA_Buffer))
|
||||
if ((Size + 8u) > sizeof(UART_DMA_Buffer))
|
||||
{
|
||||
gUART_WriteIndex = DmaLength;
|
||||
return false;
|
||||
@@ -456,11 +530,11 @@ bool UART_IsCommandAvailable(void)
|
||||
if (TailIndex < Index)
|
||||
{
|
||||
const uint16_t ChunkSize = sizeof(UART_DMA_Buffer) - Index;
|
||||
memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize);
|
||||
memmove(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex);
|
||||
memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize);
|
||||
memcpy(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex);
|
||||
}
|
||||
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);
|
||||
if (TailIndex < gUART_WriteIndex)
|
||||
@@ -480,9 +554,12 @@ bool UART_IsCommandAvailable(void)
|
||||
bIsEncrypted = true;
|
||||
|
||||
if (bIsEncrypted)
|
||||
for (i = 0; i < Size + 2; i++)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < (Size + 2u); i++)
|
||||
UART_Command.Buffer[i] ^= Obfuscation[i % 16];
|
||||
|
||||
}
|
||||
|
||||
CRC = UART_Command.Buffer[Size] | (UART_Command.Buffer[Size + 1] << 8);
|
||||
|
||||
return (CRC_Calculate(UART_Command.Buffer, Size) != CRC) ? false : true;
|
||||
@@ -526,12 +603,22 @@ void UART_HandleCommand(void)
|
||||
CMD_052F(UART_Command.Buffer);
|
||||
break;
|
||||
|
||||
case 0x05DD:
|
||||
case 0x05DD: // reset
|
||||
#if defined(ENABLE_OVERLAY)
|
||||
overlay_FLASH_RebootToBootloader();
|
||||
#else
|
||||
NVIC_SystemReset();
|
||||
#endif
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_UART_RW_BK_REGS
|
||||
case 0x0601:
|
||||
CMD_0601_ReadBK4819Reg(UART_Command.Buffer);
|
||||
break;
|
||||
|
||||
case 0x0602:
|
||||
CMD_0602_WriteBK4819Reg(UART_Command.Buffer);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
601
audio.c
@@ -31,79 +31,46 @@
|
||||
#include "settings.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
|
||||
static const uint8_t VoiceClipLengthChinese[58] =
|
||||
{
|
||||
0x32, 0x32, 0x32, 0x37, 0x37, 0x32, 0x32, 0x32,
|
||||
0x32, 0x37, 0x37, 0x32, 0x64, 0x64, 0x64, 0x64,
|
||||
0x64, 0x69, 0x64, 0x69, 0x5A, 0x5F, 0x5F, 0x64,
|
||||
0x64, 0x69, 0x64, 0x64, 0x69, 0x69, 0x69, 0x64,
|
||||
0x64, 0x6E, 0x69, 0x5F, 0x64, 0x64, 0x64, 0x69,
|
||||
0x69, 0x69, 0x64, 0x69, 0x64, 0x64, 0x55, 0x5F,
|
||||
0x5A, 0x4B, 0x4B, 0x46, 0x46, 0x69, 0x64, 0x6E,
|
||||
0x5A, 0x64,
|
||||
};
|
||||
|
||||
static const uint8_t VoiceClipLengthEnglish[76] =
|
||||
{
|
||||
0x50, 0x32, 0x2D, 0x2D, 0x2D, 0x37, 0x37, 0x37,
|
||||
0x32, 0x32, 0x3C, 0x37, 0x46, 0x46, 0x4B, 0x82,
|
||||
0x82, 0x6E, 0x82, 0x46, 0x96, 0x64, 0x46, 0x6E,
|
||||
0x78, 0x6E, 0x87, 0x64, 0x96, 0x96, 0x46, 0x9B,
|
||||
0x91, 0x82, 0x82, 0x73, 0x78, 0x64, 0x82, 0x6E,
|
||||
0x78, 0x82, 0x87, 0x6E, 0x55, 0x78, 0x64, 0x69,
|
||||
0x9B, 0x5A, 0x50, 0x3C, 0x32, 0x55, 0x64, 0x64,
|
||||
0x50, 0x46, 0x46, 0x46, 0x4B, 0x4B, 0x50, 0x50,
|
||||
0x55, 0x4B, 0x4B, 0x32, 0x32, 0x32, 0x32, 0x37,
|
||||
0x41, 0x32, 0x3C, 0x37,
|
||||
};
|
||||
|
||||
VOICE_ID_t gVoiceID[8];
|
||||
uint8_t gVoiceReadIndex;
|
||||
uint8_t gVoiceWriteIndex;
|
||||
volatile uint16_t gCountdownToPlayNextVoice_10ms;
|
||||
volatile bool gFlagPlayQueuedVoice;
|
||||
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID;
|
||||
|
||||
#endif
|
||||
|
||||
BEEP_Type_t gBeepToPlay = BEEP_NONE;
|
||||
|
||||
void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
||||
{
|
||||
uint16_t ToneConfig;
|
||||
uint16_t ToneFrequency;
|
||||
uint16_t Duration;
|
||||
|
||||
if (Beep != BEEP_880HZ_60MS_TRIPLE_BEEP && Beep != BEEP_500HZ_60MS_DOUBLE_BEEP && Beep != BEEP_440HZ_500MS && !gEeprom.BEEP_CONTROL)
|
||||
if (Beep != BEEP_880HZ_60MS_TRIPLE_BEEP &&
|
||||
Beep != BEEP_500HZ_60MS_DOUBLE_BEEP &&
|
||||
Beep != BEEP_440HZ_500MS &&
|
||||
Beep != BEEP_880HZ_200MS &&
|
||||
Beep != BEEP_880HZ_500MS &&
|
||||
!gEeprom.BEEP_CONTROL)
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (gScreenToDisplay == DISPLAY_AIRCOPY)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (gScreenToDisplay == DISPLAY_AIRCOPY)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (gCurrentFunction == FUNCTION_RECEIVE)
|
||||
return;
|
||||
|
||||
if (gCurrentFunction == FUNCTION_MONITOR)
|
||||
return;
|
||||
|
||||
ToneConfig = BK4819_ReadRegister(BK4819_REG_71);
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
BK1080_Mute(true);
|
||||
#endif
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOff();
|
||||
|
||||
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
||||
BK4819_RX_TurnOn();
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
BK1080_Mute(true);
|
||||
#endif
|
||||
|
||||
SYSTEM_DelayMs(20);
|
||||
|
||||
uint16_t ToneConfig = BK4819_ReadRegister(BK4819_REG_71);
|
||||
|
||||
uint16_t ToneFrequency;
|
||||
switch (Beep)
|
||||
{
|
||||
default:
|
||||
@@ -123,18 +90,21 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
||||
break;
|
||||
case BEEP_880HZ_40MS_OPTIONAL:
|
||||
case BEEP_880HZ_60MS_TRIPLE_BEEP:
|
||||
case BEEP_880HZ_200MS:
|
||||
case BEEP_880HZ_500MS:
|
||||
ToneFrequency = 880;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
BK4819_PlayTone(ToneFrequency, true);
|
||||
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOn();
|
||||
|
||||
SYSTEM_DelayMs(60);
|
||||
|
||||
uint16_t Duration;
|
||||
switch (Beep)
|
||||
{
|
||||
case BEEP_880HZ_60MS_TRIPLE_BEEP:
|
||||
@@ -142,26 +112,29 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
||||
SYSTEM_DelayMs(60);
|
||||
BK4819_EnterTxMute();
|
||||
SYSTEM_DelayMs(20);
|
||||
|
||||
[[fallthrough]];
|
||||
case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL:
|
||||
case BEEP_500HZ_60MS_DOUBLE_BEEP:
|
||||
BK4819_ExitTxMute();
|
||||
SYSTEM_DelayMs(60);
|
||||
BK4819_EnterTxMute();
|
||||
SYSTEM_DelayMs(20);
|
||||
|
||||
[[fallthrough]];
|
||||
case BEEP_1KHZ_60MS_OPTIONAL:
|
||||
BK4819_ExitTxMute();
|
||||
Duration = 60;
|
||||
break;
|
||||
|
||||
case BEEP_880HZ_40MS_OPTIONAL:
|
||||
case BEEP_440HZ_40MS_OPTIONAL:
|
||||
BK4819_ExitTxMute();
|
||||
Duration = 40;
|
||||
break;
|
||||
|
||||
case BEEP_880HZ_200MS:
|
||||
BK4819_ExitTxMute();
|
||||
Duration = 200;
|
||||
break;
|
||||
case BEEP_440HZ_500MS:
|
||||
case BEEP_880HZ_500MS:
|
||||
default:
|
||||
BK4819_ExitTxMute();
|
||||
Duration = 500;
|
||||
@@ -172,9 +145,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
||||
BK4819_EnterTxMute();
|
||||
SYSTEM_DelayMs(20);
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
|
||||
gVoxResumeCountdown = 80;
|
||||
AUDIO_AudioPathOff();
|
||||
|
||||
SYSTEM_DelayMs(5);
|
||||
BK4819_TurnsOffTones_TurnsOnRX();
|
||||
@@ -182,240 +153,290 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
||||
BK4819_WriteRegister(BK4819_REG_71, ToneConfig);
|
||||
|
||||
if (gEnableSpeaker)
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
AUDIO_AudioPathOn();
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
BK1080_Mute(false);
|
||||
#endif
|
||||
|
||||
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
||||
BK4819_Sleep();
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
gVoxResumeCountdown = 80;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
|
||||
static const uint8_t VoiceClipLengthChinese[58] =
|
||||
{
|
||||
0x32, 0x32, 0x32, 0x37, 0x37, 0x32, 0x32, 0x32,
|
||||
0x32, 0x37, 0x37, 0x32, 0x64, 0x64, 0x64, 0x64,
|
||||
0x64, 0x69, 0x64, 0x69, 0x5A, 0x5F, 0x5F, 0x64,
|
||||
0x64, 0x69, 0x64, 0x64, 0x69, 0x69, 0x69, 0x64,
|
||||
0x64, 0x6E, 0x69, 0x5F, 0x64, 0x64, 0x64, 0x69,
|
||||
0x69, 0x69, 0x64, 0x69, 0x64, 0x64, 0x55, 0x5F,
|
||||
0x5A, 0x4B, 0x4B, 0x46, 0x46, 0x69, 0x64, 0x6E,
|
||||
0x5A, 0x64,
|
||||
};
|
||||
|
||||
static const uint8_t VoiceClipLengthEnglish[76] =
|
||||
{
|
||||
0x50, 0x32, 0x2D, 0x2D, 0x2D, 0x37, 0x37, 0x37,
|
||||
0x32, 0x32, 0x3C, 0x37, 0x46, 0x46, 0x4B, 0x82,
|
||||
0x82, 0x6E, 0x82, 0x46, 0x96, 0x64, 0x46, 0x6E,
|
||||
0x78, 0x6E, 0x87, 0x64, 0x96, 0x96, 0x46, 0x9B,
|
||||
0x91, 0x82, 0x82, 0x73, 0x78, 0x64, 0x82, 0x6E,
|
||||
0x78, 0x82, 0x87, 0x6E, 0x55, 0x78, 0x64, 0x69,
|
||||
0x9B, 0x5A, 0x50, 0x3C, 0x32, 0x55, 0x64, 0x64,
|
||||
0x50, 0x46, 0x46, 0x46, 0x4B, 0x4B, 0x50, 0x50,
|
||||
0x55, 0x4B, 0x4B, 0x32, 0x32, 0x32, 0x32, 0x37,
|
||||
0x41, 0x32, 0x3C, 0x37,
|
||||
};
|
||||
|
||||
VOICE_ID_t gVoiceID[8];
|
||||
uint8_t gVoiceReadIndex;
|
||||
uint8_t gVoiceWriteIndex;
|
||||
volatile uint16_t gCountdownToPlayNextVoice_10ms;
|
||||
volatile bool gFlagPlayQueuedVoice;
|
||||
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID;
|
||||
|
||||
|
||||
static void AUDIO_PlayVoice(uint8_t VoiceID)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||
SYSTEM_DelayMs(20);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if ((VoiceID & 0x80U) == 0)
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
|
||||
else
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
|
||||
|
||||
SYSTICK_DelayUs(1000);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||
SYSTICK_DelayUs(1200);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||
VoiceID <<= 1;
|
||||
SYSTICK_DelayUs(200);
|
||||
}
|
||||
}
|
||||
|
||||
void AUDIO_PlaySingleVoice(bool bFlag)
|
||||
{
|
||||
uint8_t VoiceID;
|
||||
uint8_t Delay;
|
||||
|
||||
VoiceID = gVoiceID[0];
|
||||
|
||||
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF && gVoiceWriteIndex > 0)
|
||||
{
|
||||
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
|
||||
{ // Chinese
|
||||
if (VoiceID >= ARRAY_SIZE(VoiceClipLengthChinese))
|
||||
goto Bailout;
|
||||
|
||||
Delay = VoiceClipLengthChinese[VoiceID];
|
||||
VoiceID += VOICE_ID_CHI_BASE;
|
||||
}
|
||||
else
|
||||
{ // English
|
||||
if (VoiceID >= ARRAY_SIZE(VoiceClipLengthEnglish))
|
||||
goto Bailout;
|
||||
|
||||
Delay = VoiceClipLengthEnglish[VoiceID];
|
||||
VoiceID += VOICE_ID_ENG_BASE;
|
||||
}
|
||||
|
||||
if (FUNCTION_IsRx()) // 1of11
|
||||
BK4819_SetAF(BK4819_AF_MUTE);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
BK1080_Mute(true);
|
||||
#endif
|
||||
|
||||
AUDIO_AudioPathOn();
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
gVoxResumeCountdown = 2000;
|
||||
#endif
|
||||
|
||||
SYSTEM_DelayMs(5);
|
||||
AUDIO_PlayVoice(VoiceID);
|
||||
|
||||
if (gVoiceWriteIndex == 1)
|
||||
Delay += 3;
|
||||
|
||||
if (bFlag)
|
||||
{
|
||||
SYSTEM_DelayMs(Delay * 10);
|
||||
|
||||
if (FUNCTION_IsRx()) // 1of11
|
||||
RADIO_SetModulation(gRxVfo->Modulation);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
BK1080_Mute(false);
|
||||
#endif
|
||||
|
||||
if (!gEnableSpeaker)
|
||||
AUDIO_AudioPathOff();
|
||||
|
||||
gVoiceWriteIndex = 0;
|
||||
gVoiceReadIndex = 0;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
gVoxResumeCountdown = 80;
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gVoiceReadIndex = 1;
|
||||
gCountdownToPlayNextVoice_10ms = Delay;
|
||||
gFlagPlayQueuedVoice = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Bailout:
|
||||
gVoiceReadIndex = 0;
|
||||
gVoiceWriteIndex = 0;
|
||||
}
|
||||
|
||||
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID)
|
||||
{
|
||||
if (Index >= ARRAY_SIZE(gVoiceID))
|
||||
return;
|
||||
|
||||
if (Index == 0)
|
||||
{
|
||||
gVoiceWriteIndex = 0;
|
||||
gVoiceReadIndex = 0;
|
||||
}
|
||||
|
||||
gVoiceID[Index] = VoiceID;
|
||||
|
||||
gVoiceWriteIndex++;
|
||||
}
|
||||
|
||||
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value)
|
||||
{
|
||||
uint16_t Remainder;
|
||||
uint8_t Result;
|
||||
uint8_t Count;
|
||||
|
||||
if (Index == 0)
|
||||
{
|
||||
gVoiceWriteIndex = 0;
|
||||
gVoiceReadIndex = 0;
|
||||
}
|
||||
|
||||
Count = 0;
|
||||
Result = Value / 1000U;
|
||||
Remainder = Value % 1000U;
|
||||
if (Remainder < 100U)
|
||||
{
|
||||
if (Remainder < 10U)
|
||||
goto Skip;
|
||||
}
|
||||
else
|
||||
{
|
||||
Result = Remainder / 100U;
|
||||
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
|
||||
Count++;
|
||||
Remainder -= Result * 100U;
|
||||
}
|
||||
Result = Remainder / 10U;
|
||||
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
|
||||
Count++;
|
||||
Remainder -= Result * 10U;
|
||||
|
||||
Skip:
|
||||
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Remainder;
|
||||
|
||||
return Count + 1U;
|
||||
}
|
||||
|
||||
void AUDIO_PlayQueuedVoice(void)
|
||||
{
|
||||
uint8_t VoiceID;
|
||||
uint8_t Delay;
|
||||
bool Skip;
|
||||
|
||||
Skip = false;
|
||||
|
||||
if (gVoiceReadIndex != gVoiceWriteIndex && gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF)
|
||||
{
|
||||
VoiceID = gVoiceID[gVoiceReadIndex];
|
||||
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
|
||||
{
|
||||
if (VoiceID < ARRAY_SIZE(VoiceClipLengthChinese))
|
||||
{
|
||||
Delay = VoiceClipLengthChinese[VoiceID];
|
||||
VoiceID += VOICE_ID_CHI_BASE;
|
||||
}
|
||||
else
|
||||
Skip = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (VoiceID < ARRAY_SIZE(VoiceClipLengthEnglish))
|
||||
{
|
||||
Delay = VoiceClipLengthEnglish[VoiceID];
|
||||
VoiceID += VOICE_ID_ENG_BASE;
|
||||
}
|
||||
else
|
||||
Skip = true;
|
||||
}
|
||||
|
||||
gVoiceReadIndex++;
|
||||
|
||||
if (!Skip)
|
||||
{
|
||||
if (gVoiceReadIndex == gVoiceWriteIndex)
|
||||
Delay += 3;
|
||||
|
||||
AUDIO_PlayVoice(VoiceID);
|
||||
|
||||
gCountdownToPlayNextVoice_10ms = Delay;
|
||||
gFlagPlayQueuedVoice = false;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
gVoxResumeCountdown = 2000;
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (FUNCTION_IsRx())
|
||||
{
|
||||
RADIO_SetModulation(gRxVfo->Modulation); // 1of11
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
BK1080_Mute(false);
|
||||
#endif
|
||||
|
||||
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
||||
BK4819_Sleep();
|
||||
|
||||
if (!gEnableSpeaker)
|
||||
AUDIO_AudioPathOff();
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
gVoxResumeCountdown = 80;
|
||||
#endif
|
||||
|
||||
gVoiceWriteIndex = 0;
|
||||
gVoiceReadIndex = 0;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
|
||||
void AUDIO_PlayVoice(uint8_t VoiceID)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||
SYSTEM_DelayMs(20);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if ((VoiceID & 0x80U) == 0)
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
|
||||
else
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
|
||||
|
||||
SYSTICK_DelayUs(1000);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||
SYSTICK_DelayUs(1200);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||
VoiceID <<= 1;
|
||||
SYSTICK_DelayUs(200);
|
||||
}
|
||||
}
|
||||
|
||||
void AUDIO_PlaySingleVoice(bool bFlag)
|
||||
{
|
||||
uint8_t VoiceID;
|
||||
uint8_t Delay;
|
||||
|
||||
VoiceID = gVoiceID[0];
|
||||
|
||||
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF && gVoiceWriteIndex > 0)
|
||||
{
|
||||
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
|
||||
{ // Chinese
|
||||
if (VoiceID >= ARRAY_SIZE(VoiceClipLengthChinese))
|
||||
goto Bailout;
|
||||
|
||||
Delay = VoiceClipLengthChinese[VoiceID];
|
||||
VoiceID += VOICE_ID_CHI_BASE;
|
||||
}
|
||||
else
|
||||
{ // English
|
||||
if (VoiceID >= ARRAY_SIZE(VoiceClipLengthEnglish))
|
||||
goto Bailout;
|
||||
|
||||
Delay = VoiceClipLengthEnglish[VoiceID];
|
||||
VoiceID += VOICE_ID_ENG_BASE;
|
||||
}
|
||||
|
||||
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
|
||||
BK4819_SetAF(BK4819_AF_MUTE);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
BK1080_Mute(true);
|
||||
#endif
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
gVoxResumeCountdown = 2000;
|
||||
SYSTEM_DelayMs(5);
|
||||
AUDIO_PlayVoice(VoiceID);
|
||||
|
||||
if (gVoiceWriteIndex == 1)
|
||||
Delay += 3;
|
||||
|
||||
if (bFlag)
|
||||
{
|
||||
SYSTEM_DelayMs(Delay * 10);
|
||||
|
||||
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
|
||||
{
|
||||
if (gRxVfo->AM_mode)
|
||||
BK4819_SetAF(BK4819_AF_AM);
|
||||
else
|
||||
BK4819_SetAF(BK4819_AF_OPEN);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
BK1080_Mute(false);
|
||||
#endif
|
||||
|
||||
if (!gEnableSpeaker)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
|
||||
gVoiceWriteIndex = 0;
|
||||
gVoiceReadIndex = 0;
|
||||
gVoxResumeCountdown = 80;
|
||||
return;
|
||||
}
|
||||
|
||||
gVoiceReadIndex = 1;
|
||||
gCountdownToPlayNextVoice_10ms = Delay;
|
||||
gFlagPlayQueuedVoice = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Bailout:
|
||||
gVoiceReadIndex = 0;
|
||||
gVoiceWriteIndex = 0;
|
||||
}
|
||||
|
||||
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID)
|
||||
{
|
||||
if (Index >= ARRAY_SIZE(gVoiceID))
|
||||
return;
|
||||
|
||||
if (Index == 0)
|
||||
{
|
||||
gVoiceWriteIndex = 0;
|
||||
gVoiceReadIndex = 0;
|
||||
}
|
||||
|
||||
gVoiceID[Index] = VoiceID;
|
||||
|
||||
gVoiceWriteIndex++;
|
||||
}
|
||||
|
||||
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value)
|
||||
{
|
||||
uint16_t Remainder;
|
||||
uint8_t Result;
|
||||
uint8_t Count;
|
||||
|
||||
if (Index == 0)
|
||||
{
|
||||
gVoiceWriteIndex = 0;
|
||||
gVoiceReadIndex = 0;
|
||||
}
|
||||
|
||||
Count = 0;
|
||||
Result = Value / 1000U;
|
||||
Remainder = Value % 1000U;
|
||||
if (Remainder < 100U)
|
||||
{
|
||||
if (Remainder < 10U)
|
||||
goto Skip;
|
||||
}
|
||||
else
|
||||
{
|
||||
Result = Remainder / 100U;
|
||||
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
|
||||
Count++;
|
||||
Remainder -= Result * 100U;
|
||||
}
|
||||
Result = Remainder / 10U;
|
||||
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
|
||||
Count++;
|
||||
Remainder -= Result * 10U;
|
||||
|
||||
Skip:
|
||||
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Remainder;
|
||||
|
||||
return Count + 1U;
|
||||
}
|
||||
|
||||
void AUDIO_PlayQueuedVoice(void)
|
||||
{
|
||||
uint8_t VoiceID;
|
||||
uint8_t Delay;
|
||||
bool Skip;
|
||||
|
||||
Skip = false;
|
||||
|
||||
if (gVoiceReadIndex != gVoiceWriteIndex && gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF)
|
||||
{
|
||||
VoiceID = gVoiceID[gVoiceReadIndex];
|
||||
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
|
||||
{
|
||||
if (VoiceID < ARRAY_SIZE(VoiceClipLengthChinese))
|
||||
{
|
||||
Delay = VoiceClipLengthChinese[VoiceID];
|
||||
VoiceID += VOICE_ID_CHI_BASE;
|
||||
}
|
||||
else
|
||||
Skip = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (VoiceID < ARRAY_SIZE(VoiceClipLengthEnglish))
|
||||
{
|
||||
Delay = VoiceClipLengthEnglish[VoiceID];
|
||||
VoiceID += VOICE_ID_ENG_BASE;
|
||||
}
|
||||
else
|
||||
Skip = true;
|
||||
}
|
||||
|
||||
gVoiceReadIndex++;
|
||||
|
||||
if (!Skip)
|
||||
{
|
||||
if (gVoiceReadIndex == gVoiceWriteIndex)
|
||||
Delay += 3;
|
||||
|
||||
AUDIO_PlayVoice(VoiceID);
|
||||
|
||||
gCountdownToPlayNextVoice_10ms = Delay;
|
||||
gFlagPlayQueuedVoice = false;
|
||||
gVoxResumeCountdown = 2000;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
|
||||
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
BK1080_Mute(false);
|
||||
#endif
|
||||
|
||||
if (!gEnableSpeaker)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
|
||||
gVoxResumeCountdown = 80;
|
||||
gVoiceWriteIndex = 0;
|
||||
gVoiceReadIndex = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
15
audio.h
@@ -20,12 +20,17 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
enum BEEP_Type_t
|
||||
{
|
||||
BEEP_NONE = 0,
|
||||
BEEP_1KHZ_60MS_OPTIONAL,
|
||||
BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL,
|
||||
BEEP_440HZ_500MS,
|
||||
BEEP_880HZ_200MS,
|
||||
BEEP_880HZ_500MS,
|
||||
BEEP_500HZ_60MS_DOUBLE_BEEP,
|
||||
BEEP_440HZ_40MS_OPTIONAL,
|
||||
BEEP_880HZ_40MS_OPTIONAL,
|
||||
@@ -128,6 +133,14 @@ enum VOICE_ID_t
|
||||
|
||||
typedef enum VOICE_ID_t VOICE_ID_t;
|
||||
|
||||
static inline void AUDIO_AudioPathOn(void) {
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
}
|
||||
|
||||
static inline void AUDIO_AudioPathOff(void) {
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
extern VOICE_ID_t gVoiceID[8];
|
||||
extern uint8_t gVoiceReadIndex;
|
||||
@@ -136,7 +149,6 @@ typedef enum VOICE_ID_t VOICE_ID_t;
|
||||
extern volatile bool gFlagPlayQueuedVoice;
|
||||
extern VOICE_ID_t gAnotherVoiceID;
|
||||
|
||||
void AUDIO_PlayVoice(uint8_t VoiceID);
|
||||
void AUDIO_PlaySingleVoice(bool bFlag);
|
||||
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID);
|
||||
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value);
|
||||
@@ -144,4 +156,3 @@ typedef enum VOICE_ID_t VOICE_ID_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
300
bitmaps.c
@@ -4,29 +4,56 @@
|
||||
// all these images are on their right sides
|
||||
// turn your monitor 90-deg anti-clockwise to see the images
|
||||
|
||||
const uint8_t BITMAP_PowerSave[8] =
|
||||
const uint8_t BITMAP_POWERSAVE[8] =
|
||||
{
|
||||
#if 0
|
||||
// "S"
|
||||
0b00000000,
|
||||
0b00100110,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b00110010
|
||||
#else
|
||||
// "PS"
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b00010001,
|
||||
0b00001110,
|
||||
0b00000000,
|
||||
0b01000110,
|
||||
0b01001001,
|
||||
0b00110001
|
||||
#endif
|
||||
// "PS"
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b00010001,
|
||||
0b00001110,
|
||||
0b00000000,
|
||||
0b01000110,
|
||||
0b01001001,
|
||||
0b00110001
|
||||
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_TX[8] =
|
||||
{ // "TX"
|
||||
0b00000000,
|
||||
0b00000001,
|
||||
0b00000001,
|
||||
0b01111111,
|
||||
0b00000001,
|
||||
0b00000001,
|
||||
0b00000000,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_RX[8] =
|
||||
{ // "RX"
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b00001001,
|
||||
0b00011001,
|
||||
0b01100110,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_FM[10] =
|
||||
{ // "FM"
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b00001001,
|
||||
0b00000001,
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b00000010,
|
||||
0b00001100,
|
||||
0b00000010,
|
||||
0b01111111
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_BatteryLevel[2] =
|
||||
@@ -114,37 +141,21 @@ const uint8_t BITMAP_F_Key[6] =
|
||||
0b01000001
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_VOX[18] =
|
||||
{ // "VOX"
|
||||
0b00000000,
|
||||
0b00011111,
|
||||
0b00100000,
|
||||
0b01000000,
|
||||
0b00100000,
|
||||
0b00011111,
|
||||
0b00000000,
|
||||
0b00111110,
|
||||
0b01000001,
|
||||
0b01000001,
|
||||
0b01000001,
|
||||
0b00111110,
|
||||
0b00000000,
|
||||
0b01100011,
|
||||
0b00010100,
|
||||
0b00001000,
|
||||
0b00010100,
|
||||
0b01100011
|
||||
};
|
||||
|
||||
#if 0
|
||||
const uint8_t BITMAP_WX[12] =
|
||||
{ // "WX"
|
||||
#ifdef ENABLE_VOX
|
||||
const uint8_t BITMAP_VOX[18] =
|
||||
{ // "VOX"
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b00011111,
|
||||
0b00100000,
|
||||
0b00011000,
|
||||
0b01000000,
|
||||
0b00100000,
|
||||
0b01111111,
|
||||
0b00011111,
|
||||
0b00000000,
|
||||
0b00111110,
|
||||
0b01000001,
|
||||
0b01000001,
|
||||
0b01000001,
|
||||
0b00111110,
|
||||
0b00000000,
|
||||
0b01100011,
|
||||
0b00010100,
|
||||
@@ -152,30 +163,31 @@ const uint8_t BITMAP_VOX[18] =
|
||||
0b00010100,
|
||||
0b01100011
|
||||
};
|
||||
#else
|
||||
// 'XB' (cross-band/cross-VFO)
|
||||
const uint8_t BITMAP_XB[12] =
|
||||
{ // "XB"
|
||||
0b00000000,
|
||||
0b01100011,
|
||||
0b00010100,
|
||||
0b00001000,
|
||||
0b00010100,
|
||||
0b01100011,
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b00110110
|
||||
};
|
||||
#endif
|
||||
|
||||
const uint8_t BITMAP_TDR1[12] =
|
||||
{ // "DW"
|
||||
|
||||
// 'XB' (cross-band/cross-VFO)
|
||||
const uint8_t BITMAP_XB[12] =
|
||||
{ // "XB"
|
||||
0b00000000,
|
||||
0b01100011,
|
||||
0b00010100,
|
||||
0b00001000,
|
||||
0b00010100,
|
||||
0b01100011,
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b00110110
|
||||
};
|
||||
|
||||
|
||||
const uint8_t BITMAP_TDR1[16] =
|
||||
{ // "DWR"
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b01000001,
|
||||
0b01000001,
|
||||
0b01000001,
|
||||
0b00111110,
|
||||
@@ -184,12 +196,16 @@ const uint8_t BITMAP_TDR1[12] =
|
||||
0b00100000,
|
||||
0b00011000,
|
||||
0b00100000,
|
||||
0b01111111
|
||||
0b01111111,
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b00011001,
|
||||
0b00101001,
|
||||
0b01000110
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_TDR2[12] =
|
||||
const uint8_t BITMAP_TDR2[10] =
|
||||
{ // "><" .. DW on hold
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
0b00100010,
|
||||
0b00110110,
|
||||
@@ -200,7 +216,6 @@ const uint8_t BITMAP_TDR2[12] =
|
||||
0b00011100,
|
||||
0b00110110,
|
||||
0b00100010,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
@@ -218,27 +233,8 @@ const uint8_t BITMAP_TDR2[12] =
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
const uint8_t BITMAP_FM[12] =
|
||||
{ // "FM"
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b00001001,
|
||||
0b00001001,
|
||||
0b00001001,
|
||||
0b00000001,
|
||||
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
0b00000010,
|
||||
0b00001100,
|
||||
0b00000010,
|
||||
0b01111111
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
const uint8_t BITMAP_NOAA[12] =
|
||||
const uint8_t BITMAP_NOAA[11] =
|
||||
{ // "NS"
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
@@ -246,33 +242,14 @@ const uint8_t BITMAP_TDR2[12] =
|
||||
0b00001000,
|
||||
0b00010000,
|
||||
0b01111111,
|
||||
|
||||
0b00000000,
|
||||
0b01000110,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b00110001
|
||||
};
|
||||
#endif
|
||||
|
||||
const uint8_t BITMAP_SC[12] =
|
||||
{ // "SC"
|
||||
0b00000000,
|
||||
0b01000110,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b01001001,
|
||||
0b00110001,
|
||||
|
||||
0b00000000,
|
||||
0b00111110,
|
||||
0b01000001,
|
||||
0b01000001,
|
||||
0b01000001,
|
||||
0b00100010
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_Antenna[5] =
|
||||
{
|
||||
0b00000011,
|
||||
@@ -282,60 +259,6 @@ const uint8_t BITMAP_Antenna[5] =
|
||||
0b00000011
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_AntennaLevel1[3] =
|
||||
{
|
||||
0b01100000,
|
||||
0b01100000,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_AntennaLevel2[3] =
|
||||
{
|
||||
0b01110000,
|
||||
0b01110000,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_AntennaLevel3[3] =
|
||||
{
|
||||
0b01111000,
|
||||
0b01111000,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_AntennaLevel4[3] =
|
||||
{
|
||||
0b01111100,
|
||||
0b01111100,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_AntennaLevel5[3] =
|
||||
{
|
||||
0b01111110,
|
||||
0b01111110,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_AntennaLevel6[3] =
|
||||
{
|
||||
0b01111111,
|
||||
0b01111111,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_CurrentIndicator[8] =
|
||||
{
|
||||
0b11111111,
|
||||
0b11111111,
|
||||
0b01111110,
|
||||
0b01111110,
|
||||
0b00111100,
|
||||
0b00111100,
|
||||
0b00011000,
|
||||
0b00011000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_VFO_Default[8] =
|
||||
{
|
||||
0b00000000,
|
||||
@@ -359,17 +282,7 @@ const uint8_t BITMAP_VFO_NotDefault[8] =
|
||||
0b00010100,
|
||||
0b00001000
|
||||
};
|
||||
/*
|
||||
const uint8_t BITMAP_ScanList[6] =
|
||||
{ // diamond symbol
|
||||
0b00001000,
|
||||
0b00011100,
|
||||
0b00111110,
|
||||
0b00111110,
|
||||
0b00011100,
|
||||
0b00001000
|
||||
};
|
||||
*/
|
||||
|
||||
const uint8_t BITMAP_ScanList1[6] =
|
||||
{ // 'I' symbol
|
||||
0b00000000,
|
||||
@@ -390,14 +303,25 @@ const uint8_t BITMAP_ScanList2[6] =
|
||||
0b01000010
|
||||
};
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
const uint8_t BITMAP_compand[6] =
|
||||
{
|
||||
0b00000000,
|
||||
0b00111100,
|
||||
0b01000010,
|
||||
0b01000010,
|
||||
0b01000010,
|
||||
0b00100100
|
||||
};
|
||||
const uint8_t BITMAP_compand[6] =
|
||||
{
|
||||
0b00000000,
|
||||
0b00111100,
|
||||
0b01000010,
|
||||
0b01000010,
|
||||
0b01000010,
|
||||
0b00100100
|
||||
};
|
||||
|
||||
#ifndef ENABLE_CUSTOM_MENU_LAYOUT
|
||||
const uint8_t BITMAP_CurrentIndicator[8] = {
|
||||
0xFF,
|
||||
0xFF,
|
||||
0x7E,
|
||||
0x7E,
|
||||
0x3C,
|
||||
0x3C,
|
||||
0x18,
|
||||
0x18
|
||||
};
|
||||
#endif
|
||||
|
||||
48
bitmaps.h
@@ -4,14 +4,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern const uint8_t BITMAP_PowerSave[8];
|
||||
|
||||
extern const uint8_t BITMAP_POWERSAVE[8];
|
||||
extern const uint8_t BITMAP_TX[8];
|
||||
extern const uint8_t BITMAP_RX[8];
|
||||
extern const uint8_t BITMAP_FM[10];
|
||||
extern const uint8_t BITMAP_BatteryLevel[2];
|
||||
extern const uint8_t BITMAP_BatteryLevel1[17];
|
||||
extern const uint8_t BITMAP_BatteryLevel2[17];
|
||||
extern const uint8_t BITMAP_BatteryLevel3[17];
|
||||
extern const uint8_t BITMAP_BatteryLevel4[17];
|
||||
extern const uint8_t BITMAP_BatteryLevel5[17];
|
||||
|
||||
extern const uint8_t BITMAP_USB_C[9];
|
||||
|
||||
@@ -19,51 +17,35 @@ extern const uint8_t BITMAP_KeyLock[6];
|
||||
|
||||
extern const uint8_t BITMAP_F_Key[6];
|
||||
|
||||
extern const uint8_t BITMAP_VOX[18];
|
||||
|
||||
#if 0
|
||||
extern const uint8_t BITMAP_WX[12];
|
||||
#else
|
||||
extern const uint8_t BITMAP_XB[12];
|
||||
#ifdef ENABLE_VOX
|
||||
extern const uint8_t BITMAP_VOX[18];
|
||||
#endif
|
||||
|
||||
extern const uint8_t BITMAP_TDR1[12];
|
||||
extern const uint8_t BITMAP_TDR2[12];
|
||||
extern const uint8_t BITMAP_XB[12];
|
||||
|
||||
extern const uint8_t BITMAP_TDR1[16];
|
||||
extern const uint8_t BITMAP_TDR2[10];
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
extern const uint8_t BITMAP_VoicePrompt[9];
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
extern const uint8_t BITMAP_FM[12];
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
extern const uint8_t BITMAP_NOAA[12];
|
||||
extern const uint8_t BITMAP_NOAA[11];
|
||||
#endif
|
||||
|
||||
extern const uint8_t BITMAP_SC[12];
|
||||
|
||||
extern const uint8_t BITMAP_Antenna[5];
|
||||
extern const uint8_t BITMAP_AntennaLevel1[3];
|
||||
extern const uint8_t BITMAP_AntennaLevel2[3];
|
||||
extern const uint8_t BITMAP_AntennaLevel3[3];
|
||||
extern const uint8_t BITMAP_AntennaLevel4[3];
|
||||
extern const uint8_t BITMAP_AntennaLevel5[3];
|
||||
extern const uint8_t BITMAP_AntennaLevel6[3];
|
||||
|
||||
extern const uint8_t BITMAP_CurrentIndicator[8];
|
||||
|
||||
extern const uint8_t BITMAP_VFO_Default[8];
|
||||
extern const uint8_t BITMAP_VFO_NotDefault[8];
|
||||
|
||||
//extern const uint8_t BITMAP_ScanList[6];
|
||||
extern const uint8_t BITMAP_ScanList1[6];
|
||||
extern const uint8_t BITMAP_ScanList2[6];
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
extern const uint8_t BITMAP_compand[6];
|
||||
extern const uint8_t BITMAP_compand[6];
|
||||
|
||||
#ifndef ENABLE_CUSTOM_MENU_LAYOUT
|
||||
extern const uint8_t BITMAP_CurrentIndicator[8];
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
389
board.c
@@ -16,7 +16,6 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "app/dtmf.h"
|
||||
#ifdef ENABLE_FMRADIO
|
||||
#include "app/fm.h"
|
||||
#endif
|
||||
@@ -26,11 +25,11 @@
|
||||
#include "bsp/dp32g030/saradc.h"
|
||||
#include "bsp/dp32g030/syscon.h"
|
||||
#include "driver/adc.h"
|
||||
//#include "driver/backlight.h"
|
||||
#include "driver/backlight.h"
|
||||
#ifdef ENABLE_FMRADIO
|
||||
#include "driver/bk1080.h"
|
||||
#endif
|
||||
#include "driver/bk4819.h"
|
||||
|
||||
#include "driver/crc.h"
|
||||
#include "driver/eeprom.h"
|
||||
#include "driver/flash.h"
|
||||
@@ -44,16 +43,6 @@
|
||||
#if defined(ENABLE_OVERLAY)
|
||||
#include "sram-overlay.h"
|
||||
#endif
|
||||
#include "ui/menu.h"
|
||||
|
||||
static const uint32_t gDefaultFrequencyTable[] =
|
||||
{
|
||||
14500000, //
|
||||
14550000, //
|
||||
43300000, //
|
||||
43320000, //
|
||||
43350000 //
|
||||
};
|
||||
|
||||
#if defined(ENABLE_OVERLAY)
|
||||
void BOARD_FLASH_Init(void)
|
||||
@@ -61,10 +50,10 @@ static const uint32_t gDefaultFrequencyTable[] =
|
||||
FLASH_Init(FLASH_READ_MODE_1_CYCLE);
|
||||
FLASH_ConfigureTrimValues();
|
||||
SYSTEM_ConfigureClocks();
|
||||
|
||||
|
||||
overlay_FLASH_MainClock = 48000000;
|
||||
overlay_FLASH_ClockMultiplier = 48;
|
||||
|
||||
|
||||
FLASH_Init(FLASH_READ_MODE_2_CYCLE);
|
||||
}
|
||||
#endif
|
||||
@@ -94,8 +83,6 @@ void BOARD_GPIO_Init(void)
|
||||
| GPIO_DIR_6_MASK // INPUT
|
||||
);
|
||||
GPIOB->DIR |= 0
|
||||
// Back light
|
||||
| GPIO_DIR_6_BITS_OUTPUT
|
||||
// ST7565
|
||||
| GPIO_DIR_9_BITS_OUTPUT
|
||||
// ST7565 + SWD IO
|
||||
@@ -183,14 +170,10 @@ void BOARD_PORTCON_Init(void)
|
||||
// PORT B pin selection
|
||||
|
||||
PORTCON_PORTB_SEL0 &= ~(0
|
||||
// Back light
|
||||
| PORTCON_PORTB_SEL0_B6_MASK
|
||||
// SPI0 SSN
|
||||
| PORTCON_PORTB_SEL0_B7_MASK
|
||||
);
|
||||
PORTCON_PORTB_SEL0 |= 0
|
||||
// Back light
|
||||
| PORTCON_PORTB_SEL0_B6_BITS_GPIOB6
|
||||
// SPI0 SSN
|
||||
| PORTCON_PORTB_SEL0_B7_BITS_SPI0_SSN
|
||||
;
|
||||
@@ -508,369 +491,15 @@ void BOARD_Init(void)
|
||||
{
|
||||
BOARD_PORTCON_Init();
|
||||
BOARD_GPIO_Init();
|
||||
BACKLIGHT_InitHardware();
|
||||
BOARD_ADC_Init();
|
||||
ST7565_Init();
|
||||
#ifdef ENABLE_FMRADIO
|
||||
BK1080_Init(0, false);
|
||||
#endif
|
||||
CRC_Init();
|
||||
}
|
||||
|
||||
void BOARD_EEPROM_Init(void)
|
||||
{
|
||||
unsigned int i;
|
||||
uint8_t Data[16];
|
||||
|
||||
memset(Data, 0, sizeof(Data));
|
||||
|
||||
// 0E70..0E77
|
||||
EEPROM_ReadBuffer(0x0E70, Data, 8);
|
||||
gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST;
|
||||
gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1;
|
||||
gEeprom.TX_TIMEOUT_TIMER = (Data[2] < 11) ? Data[2] : 1;
|
||||
#ifdef ENABLE_NOAA
|
||||
gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false;
|
||||
#endif
|
||||
gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false;
|
||||
gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false;
|
||||
gEeprom.VOX_LEVEL = (Data[6] < 10) ? Data[6] : 1;
|
||||
gEeprom.MIC_SENSITIVITY = (Data[7] < 5) ? Data[7] : 4;
|
||||
|
||||
// 0E78..0E7F
|
||||
EEPROM_ReadBuffer(0x0E78, Data, 8);
|
||||
gEeprom.CHANNEL_DISPLAY_MODE = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode
|
||||
gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF;
|
||||
gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4;
|
||||
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A;
|
||||
gEeprom.BACKLIGHT = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 3;
|
||||
gEeprom.TAIL_NOTE_ELIMINATION = (Data[6] < 2) ? Data[6] : false;
|
||||
gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true;
|
||||
|
||||
// 0E80..0E87
|
||||
EEPROM_ReadBuffer(0x0E80, Data, 8);
|
||||
gEeprom.ScreenChannel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||
gEeprom.ScreenChannel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||
gEeprom.MrChannel[0] = IS_MR_CHANNEL(Data[1]) ? Data[1] : MR_CHANNEL_FIRST;
|
||||
gEeprom.MrChannel[1] = IS_MR_CHANNEL(Data[4]) ? Data[4] : MR_CHANNEL_FIRST;
|
||||
gEeprom.FreqChannel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||
gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||
#ifdef ENABLE_NOAA
|
||||
gEeprom.NoaaChannel[0] = IS_NOAA_CHANNEL(Data[6]) ? Data[6] : NOAA_CHANNEL_FIRST;
|
||||
gEeprom.NoaaChannel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
{ // 0E88..0E8F
|
||||
struct
|
||||
{
|
||||
uint16_t SelectedFrequency;
|
||||
uint8_t SelectedChannel;
|
||||
uint8_t IsMrMode;
|
||||
uint8_t Padding[8];
|
||||
} __attribute__((packed)) FM;
|
||||
|
||||
EEPROM_ReadBuffer(0x0E88, &FM, 8);
|
||||
gEeprom.FM_LowerLimit = 760;
|
||||
gEeprom.FM_UpperLimit = 1080;
|
||||
if (FM.SelectedFrequency < gEeprom.FM_LowerLimit || FM.SelectedFrequency > gEeprom.FM_UpperLimit)
|
||||
gEeprom.FM_SelectedFrequency = 960;
|
||||
else
|
||||
gEeprom.FM_SelectedFrequency = FM.SelectedFrequency;
|
||||
|
||||
gEeprom.FM_SelectedChannel = FM.SelectedChannel;
|
||||
gEeprom.FM_IsMrMode = (FM.IsMrMode < 2) ? FM.IsMrMode : false;
|
||||
}
|
||||
|
||||
// 0E40..0E67
|
||||
EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels));
|
||||
FM_ConfigureChannelState();
|
||||
BK1080_Init0();
|
||||
#endif
|
||||
|
||||
// 0E90..0E97
|
||||
EEPROM_ReadBuffer(0x0E90, Data, 8);
|
||||
gEeprom.BEEP_CONTROL = (Data[0] < 2) ? Data[0] : true;
|
||||
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
|
||||
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT;
|
||||
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
|
||||
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE;
|
||||
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
|
||||
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false;
|
||||
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE;
|
||||
#if defined(ENABLE_UART) || defined(ENABLED_AIRCOPY)
|
||||
CRC_Init();
|
||||
#endif
|
||||
|
||||
// 0E98..0E9F
|
||||
EEPROM_ReadBuffer(0x0E98, Data, 8);
|
||||
memmove(&gEeprom.POWER_ON_PASSWORD, Data, 4);
|
||||
|
||||
// 0EA0..0EA7
|
||||
#ifdef ENABLE_VOICE
|
||||
EEPROM_ReadBuffer(0x0EA0, Data, 8);
|
||||
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
|
||||
#endif
|
||||
|
||||
// 0EA8..0EAF
|
||||
EEPROM_ReadBuffer(0x0EA8, Data, 8);
|
||||
#ifdef ENABLE_ALARM
|
||||
gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true;
|
||||
#endif
|
||||
gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF;
|
||||
gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0;
|
||||
gEeprom.TX_CHANNEL = (Data[3] < 2) ? Data[3] : 0;
|
||||
|
||||
// 0ED0..0ED7
|
||||
EEPROM_ReadBuffer(0x0ED0, Data, 8);
|
||||
gEeprom.DTMF_SIDE_TONE = (Data[0] < 2) ? Data[0] : true;
|
||||
gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*';
|
||||
gEeprom.DTMF_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#';
|
||||
gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0;
|
||||
gEeprom.DTMF_AUTO_RESET_TIME = (Data[4] < 61) ? Data[4] : 5;
|
||||
gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300;
|
||||
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 100;
|
||||
gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100;
|
||||
|
||||
// 0ED8..0EDF
|
||||
EEPROM_ReadBuffer(0x0ED8, Data, 8);
|
||||
gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 10 : 100;
|
||||
gEeprom.DTMF_CODE_INTERVAL_TIME = (Data[1] < 101) ? Data[1] * 10 : 100;
|
||||
gEeprom.PERMIT_REMOTE_KILL = (Data[2] < 2) ? Data[2] : true;
|
||||
|
||||
// 0EE0..0EE7
|
||||
EEPROM_ReadBuffer(0x0EE0, Data, 8);
|
||||
if (DTMF_ValidateCodes((char *)Data, 8))
|
||||
memmove(gEeprom.ANI_DTMF_ID, Data, 8);
|
||||
else
|
||||
{
|
||||
memset(gEeprom.ANI_DTMF_ID, 0, sizeof(gEeprom.ANI_DTMF_ID));
|
||||
strcpy(gEeprom.ANI_DTMF_ID, "123");
|
||||
}
|
||||
|
||||
// 0EE8..0EEF
|
||||
EEPROM_ReadBuffer(0x0EE8, Data, 8);
|
||||
if (DTMF_ValidateCodes((char *)Data, 8))
|
||||
memmove(gEeprom.KILL_CODE, Data, 8);
|
||||
else
|
||||
{
|
||||
memset(gEeprom.KILL_CODE, 0, sizeof(gEeprom.KILL_CODE));
|
||||
strcpy(gEeprom.KILL_CODE, "ABCD9");
|
||||
}
|
||||
|
||||
// 0EF0..0EF7
|
||||
EEPROM_ReadBuffer(0x0EF0, Data, 8);
|
||||
if (DTMF_ValidateCodes((char *)Data, 8))
|
||||
memmove(gEeprom.REVIVE_CODE, Data, 8);
|
||||
else
|
||||
{
|
||||
memset(gEeprom.REVIVE_CODE, 0, sizeof(gEeprom.REVIVE_CODE));
|
||||
strcpy(gEeprom.REVIVE_CODE, "9DCBA");
|
||||
}
|
||||
|
||||
// 0EF8..0F07
|
||||
EEPROM_ReadBuffer(0x0EF8, Data, 16);
|
||||
if (DTMF_ValidateCodes((char *)Data, 16))
|
||||
memmove(gEeprom.DTMF_UP_CODE, Data, 16);
|
||||
else
|
||||
{
|
||||
memset(gEeprom.DTMF_UP_CODE, 0, sizeof(gEeprom.DTMF_UP_CODE));
|
||||
strcpy(gEeprom.DTMF_UP_CODE, "12345");
|
||||
}
|
||||
|
||||
// 0F08..0F17
|
||||
EEPROM_ReadBuffer(0x0F08, Data, 16);
|
||||
if (DTMF_ValidateCodes((char *)Data, 16))
|
||||
memmove(gEeprom.DTMF_DOWN_CODE, Data, 16);
|
||||
else
|
||||
{
|
||||
memset(gEeprom.DTMF_DOWN_CODE, 0, sizeof(gEeprom.DTMF_DOWN_CODE));
|
||||
strcpy(gEeprom.DTMF_DOWN_CODE, "54321");
|
||||
}
|
||||
|
||||
// 0F18..0F1F
|
||||
EEPROM_ReadBuffer(0x0F18, Data, 8);
|
||||
gEeprom.SCAN_LIST_DEFAULT = (Data[0] < 2) ? Data[0] : false;
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
const unsigned int j = 1 + (i * 3);
|
||||
gEeprom.SCAN_LIST_ENABLED[i] = (Data[j + 0] < 2) ? Data[j] : false;
|
||||
gEeprom.SCANLIST_PRIORITY_CH1[i] = Data[j + 1];
|
||||
gEeprom.SCANLIST_PRIORITY_CH2[i] = Data[j + 2];
|
||||
}
|
||||
|
||||
// 0F40..0F47
|
||||
EEPROM_ReadBuffer(0x0F40, Data, 8);
|
||||
gSetting_F_LOCK = (Data[0] < 6) ? Data[0] : F_LOCK_OFF;
|
||||
gSetting_350TX = (Data[1] < 2) ? Data[1] : false; // was true
|
||||
gSetting_KILLED = (Data[2] < 2) ? Data[2] : false;
|
||||
gSetting_200TX = (Data[3] < 2) ? Data[3] : false;
|
||||
gSetting_500TX = (Data[4] < 2) ? Data[4] : false;
|
||||
gSetting_350EN = (Data[5] < 2) ? Data[5] : true;
|
||||
gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true;
|
||||
gSetting_TX_EN = (Data[7] & (1u << 0)) ? true : false;
|
||||
gSetting_live_DTMF_decoder = (Data[7] & (1u << 1)) ? true : false;
|
||||
gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3: 2;
|
||||
#ifdef ENABLE_AUDIO_BAR
|
||||
gSetting_mic_bar = (Data[7] & (1u << 4)) ? true : false;
|
||||
#endif
|
||||
#ifdef ENABLE_AM_FIX
|
||||
gSetting_AM_fix = (Data[7] & (1u << 5)) ? true : false;
|
||||
#endif
|
||||
|
||||
if (!gEeprom.VFO_OPEN)
|
||||
{
|
||||
gEeprom.ScreenChannel[0] = gEeprom.MrChannel[0];
|
||||
gEeprom.ScreenChannel[1] = gEeprom.MrChannel[1];
|
||||
}
|
||||
|
||||
// 0D60..0E27
|
||||
EEPROM_ReadBuffer(0x0D60, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes));
|
||||
|
||||
// 0F30..0F3F
|
||||
EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey));
|
||||
bHasCustomAesKey = false;
|
||||
for (i = 0; i < ARRAY_SIZE(gCustomAesKey); i++)
|
||||
{
|
||||
if (gCustomAesKey[i] != 0xFFFFFFFFu)
|
||||
{
|
||||
bHasCustomAesKey = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BOARD_EEPROM_LoadMoreSettings(void)
|
||||
{
|
||||
// uint8_t Mic;
|
||||
|
||||
EEPROM_ReadBuffer(0x1EC0, gEEPROM_1EC0_0, 8);
|
||||
memmove(gEEPROM_1EC0_1, gEEPROM_1EC0_0, 8);
|
||||
memmove(gEEPROM_1EC0_2, gEEPROM_1EC0_0, 8);
|
||||
memmove(gEEPROM_1EC0_3, gEEPROM_1EC0_0, 8);
|
||||
|
||||
// 8 * 16-bit values
|
||||
EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[0], 8);
|
||||
EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[1], 8);
|
||||
|
||||
EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12);
|
||||
if (gBatteryCalibration[0] >= 5000)
|
||||
{
|
||||
gBatteryCalibration[0] = 1900;
|
||||
gBatteryCalibration[1] = 2000;
|
||||
}
|
||||
gBatteryCalibration[5] = 2300;
|
||||
|
||||
EEPROM_ReadBuffer(0x1F50 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX1_THRESHOLD, 2);
|
||||
EEPROM_ReadBuffer(0x1F68 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX0_THRESHOLD, 2);
|
||||
|
||||
//EEPROM_ReadBuffer(0x1F80 + gEeprom.MIC_SENSITIVITY, &Mic, 1);
|
||||
//gEeprom.MIC_SENSITIVITY_TUNING = (Mic < 32) ? Mic : 15;
|
||||
gEeprom.MIC_SENSITIVITY_TUNING = gMicGain_dB2[gEeprom.MIC_SENSITIVITY];
|
||||
|
||||
{
|
||||
struct
|
||||
{
|
||||
int16_t BK4819_XtalFreqLow;
|
||||
uint16_t EEPROM_1F8A;
|
||||
uint16_t EEPROM_1F8C;
|
||||
uint8_t VOLUME_GAIN;
|
||||
uint8_t DAC_GAIN;
|
||||
} __attribute__((packed)) Misc;
|
||||
|
||||
// radio 1 .. 04 00 46 00 50 00 2C 0E
|
||||
// radio 2 .. 05 00 46 00 50 00 2C 0E
|
||||
EEPROM_ReadBuffer(0x1F88, &Misc, 8);
|
||||
|
||||
gEeprom.BK4819_XTAL_FREQ_LOW = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) ? Misc.BK4819_XtalFreqLow : 0;
|
||||
gEEPROM_1F8A = Misc.EEPROM_1F8A & 0x01FF;
|
||||
gEEPROM_1F8C = Misc.EEPROM_1F8C & 0x01FF;
|
||||
gEeprom.VOLUME_GAIN = (Misc.VOLUME_GAIN < 64) ? Misc.VOLUME_GAIN : 58;
|
||||
gEeprom.DAC_GAIN = (Misc.DAC_GAIN < 16) ? Misc.DAC_GAIN : 8;
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_3B, 22656 + gEeprom.BK4819_XTAL_FREQ_LOW);
|
||||
// BK4819_WriteRegister(BK4819_REG_3C, gEeprom.BK4819_XTAL_FREQ_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t BOARD_fetchChannelFrequency(const int channel)
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t frequency;
|
||||
uint32_t offset;
|
||||
} __attribute__((packed)) info;
|
||||
|
||||
EEPROM_ReadBuffer(channel * 16, &info, sizeof(info));
|
||||
|
||||
return info.frequency;
|
||||
}
|
||||
|
||||
void BOARD_fetchChannelName(char *s, const int channel)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (s == NULL)
|
||||
return;
|
||||
|
||||
memset(s, 0, 11); // 's' had better be large enough !
|
||||
|
||||
if (channel < 0)
|
||||
return;
|
||||
|
||||
if (!RADIO_CheckValidChannel(channel, false, 0))
|
||||
return;
|
||||
|
||||
|
||||
EEPROM_ReadBuffer(0x0F50 + (channel * 16), s + 0, 8);
|
||||
EEPROM_ReadBuffer(0x0F58 + (channel * 16), s + 8, 2);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
if (s[i] < 32 || s[i] > 127)
|
||||
break; // invalid char
|
||||
|
||||
s[i--] = 0; // null term
|
||||
|
||||
while (i >= 0 && s[i] == 32) // trim trailing spaces
|
||||
s[i--] = 0; // null term
|
||||
}
|
||||
|
||||
void BOARD_FactoryReset(bool bIsAll)
|
||||
{
|
||||
uint16_t i;
|
||||
uint8_t Template[8];
|
||||
|
||||
memset(Template, 0xFF, sizeof(Template));
|
||||
|
||||
for (i = 0x0C80; i < 0x1E00; i += 8)
|
||||
{
|
||||
if (
|
||||
!(i >= 0x0EE0 && i < 0x0F18) && // ANI ID + DTMF codes
|
||||
!(i >= 0x0F30 && i < 0x0F50) && // AES KEY + F LOCK + Scramble Enable
|
||||
!(i >= 0x1C00 && i < 0x1E00) && // DTMF contacts
|
||||
!(i >= 0x0EB0 && i < 0x0ED0) && // Welcome strings
|
||||
!(i >= 0x0EA0 && i < 0x0EA8) && // Voice Prompt
|
||||
(bIsAll ||
|
||||
(
|
||||
!(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes
|
||||
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
|
||||
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names
|
||||
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
|
||||
!(i >= 0x0E88 && i < 0x0E90) // FM settings
|
||||
))
|
||||
)
|
||||
{
|
||||
EEPROM_WriteBuffer(i, Template);
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsAll)
|
||||
{
|
||||
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_FIRST + BAND6_400MHz, BAND6_400MHz, 43350000);
|
||||
|
||||
// set the first few memory channels
|
||||
for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++)
|
||||
{
|
||||
const uint32_t Frequency = gDefaultFrequencyTable[i];
|
||||
gRxVfo->freq_config_RX.Frequency = Frequency;
|
||||
gRxVfo->freq_config_TX.Frequency = Frequency;
|
||||
gRxVfo->Band = FREQUENCY_GetBand(Frequency);
|
||||
SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
board.h
@@ -26,11 +26,6 @@ void BOARD_PORTCON_Init(void);
|
||||
void BOARD_ADC_Init(void);
|
||||
void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent);
|
||||
void BOARD_Init(void);
|
||||
void BOARD_EEPROM_Init(void);
|
||||
void BOARD_EEPROM_LoadMoreSettings(void);
|
||||
uint32_t BOARD_fetchChannelFrequency(const int channel);
|
||||
void BOARD_fetchChannelName(char *s, const int channel);
|
||||
void BOARD_FactoryReset(bool bIsAll);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
146
bsp/dp32g030/pwmplus.h
Normal file
@@ -0,0 +1,146 @@
|
||||
#ifndef HARDWARE_DP32G030_PWMPLUS_H
|
||||
#define HARDWARE_DP32G030_PWMPLUS_H
|
||||
|
||||
#define PWM_PLUS0_BASE_ADDR 0x400B4000U
|
||||
|
||||
//---------------
|
||||
|
||||
#define PWMPLUS_CFG 0x00U
|
||||
|
||||
#define PWMPLUS_CFG_COUNTER_EN_SHIFT 0U
|
||||
#define PWMPLUS_CFG_COUNTER_EN_WIDTH 1U
|
||||
#define PWMPLUS_CFG_COUNTER_EN_MASK (((1U << PWMPLUS_CFG_COUNTER_EN_WIDTH) - 1U) << PWMPLUS_CFG_COUNTER_EN_SHIFT)
|
||||
#define PWMPLUS_CFG_COUNTER_EN_VALUE_ENABLE 1U
|
||||
#define PWMPLUS_CFG_COUNTER_EN_BITS_ENABLE (PWMPLUS_CFG_COUNTER_EN_VALUE_ENABLE << PWMPLUS_CFG_COUNTER_EN_SHIFT)
|
||||
|
||||
#define PWMPLUS_CFG_CNT_TYPE_SHIFT 1U
|
||||
|
||||
#define PWMPLUS_CFG_CNT_REP_SHIFT 2U
|
||||
#define PWMPLUS_CFG_CNT_REP_WIDTH 1U
|
||||
#define PWMPLUS_CFG_CNT_REP_VALUE_ENABLE 1U
|
||||
#define PWMPLUS_CFG_CNT_REP_BITS_ENABLE (PWMPLUS_CFG_CNT_REP_VALUE_ENABLE << PWMPLUS_CFG_CNT_REP_SHIFT)
|
||||
|
||||
#define PWMPLUS_CFG_OUT_MODE_SHIFT 3U
|
||||
#define PWMPLUS_CFG_OUT_MODE_VALUE_ENABLE 1U
|
||||
#define PWMPLUS_CFG_OUT_MODE_BITS_ENABLE (PWMPLUS_CFG_OUT_MODE_VALUE_ENABLE << PWMPLUS_CFG_OUT_MODE_SHIFT)
|
||||
|
||||
#define PWMPLUS_CFG_AUTO_RELOAD_SHIFT 8U
|
||||
|
||||
//---------------
|
||||
|
||||
#define PWMPLUS_GEN 0x04U
|
||||
|
||||
#define PWMPLUS_GEN_CH0_OE_SHIFT 24U
|
||||
#define PWMPLUS_GEN_CH0_OE_WIDTH 1U
|
||||
#define PWMPLUS_GEN_CH0_OE_VALUE_ENABLE 1U
|
||||
#define PWMPLUS_GEN_CH0_OE_BITS_ENABLE (PWMPLUS_GEN_CH0_OE_VALUE_ENABLE << PWMPLUS_GEN_CH0_OE_SHIFT)
|
||||
|
||||
#define PWMPLUS_GEN_CH0_OUTINV_SHIFT 16U
|
||||
#define PWMPLUS_GEN_CH0_OUTINV_WIDTH 1U
|
||||
#define PWMPLUS_GEN_CH0_OUTINV_VALUE_ENABLE 1U
|
||||
#define PWMPLUS_GEN_CH0_OUTINV_BITS_ENABLE (PWMPLUS_GEN_CH0_OUTINV_VALUE_ENABLE << PWMPLUS_GEN_CH0_OUTINV_SHIFT)
|
||||
|
||||
#define PWMPLUS_GEN_CH0_START_SHIFT 8U
|
||||
#define PWMPLUS_GEN_CH0_START_WIDTH 1U
|
||||
#define PWMPLUS_GEN_CH0_START_VALUE_ENABLE 1U
|
||||
#define PWMPLUS_GEN_CH0_START_BITS_ENABLE (PWMPLUS_GEN_CH0_START_VALUE_ENABLE << PWMPLUS_GEN_CH0_START_SHIFT)
|
||||
|
||||
#define PWMPLUS_GEN_CH0_IDLE_SHIFT 0U
|
||||
#define PWMPLUS_GEN_CH0_IDLE_WIDTH 1U
|
||||
#define PWMPLUS_GEN_CH0_IDLE_VALUE_ENABLE 1U
|
||||
#define PWMPLUS_GEN_CH0_IDLE_BITS_ENABLE (PWMPLUS_GEN_CH0_IDLE_VALUE_ENABLE << PWMPLUS_GEN_CH0_IDLE_SHIFT)
|
||||
|
||||
//---------------
|
||||
|
||||
#define PWMPLUS_CLKSRC 0x08U
|
||||
#define PWMPLUS_BRAKE_CFG 0x0CU
|
||||
#define PWMPLUS_MASK_LEV 0x10U
|
||||
#define PWMPLUS_PERIOD 0x1CU
|
||||
#define PWMPLUS_CH0_COMP 0x20U
|
||||
#define PWMPLUS_CH1_COMP 0x24U
|
||||
#define PWMPLUS_CH2_COMP 0x28U
|
||||
#define PWMPLUS_CH0_DT 0x30U
|
||||
#define PWMPLUS_CH1_DT 0x34U
|
||||
#define PWMPLUS_CH2_DT 0x38U
|
||||
#define PWMPLUS_TRIG_COMP 0x40U
|
||||
#define PWMPLUS_TRIG_CFG 0x44U
|
||||
#define PWMPLUS_IE 0x60U
|
||||
#define PWMPLUS_IF 0x64U
|
||||
#define PWMPLUS_SWLOAD 0x84U
|
||||
#define PWMPLUS_MASK_EN 0x88
|
||||
#define PWMPLUS_CNT_ST 0xE0
|
||||
#define PWMPLUS_BRAKE_ST 0xE4
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PWM_PLUS0_CFG_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_CFG)
|
||||
#define PWM_PLUS0_CFG (*(volatile uint32_t *)PWM_PLUS0_CFG_ADDR)
|
||||
|
||||
#define PWM_PLUS0_GEN_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_GEN)
|
||||
#define PWM_PLUS0_GEN (*(volatile uint32_t *)PWM_PLUS0_GEN_ADDR)
|
||||
|
||||
#define PWM_PLUS0_CLKSRC_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_CLKSRC)
|
||||
#define PWM_PLUS0_CLKSRC (*(volatile uint32_t *)PWM_PLUS0_CLKSRC_ADDR)
|
||||
|
||||
#define PWM_PLUS0_BRAKE_CFG_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_BRAKE_CFG)
|
||||
#define PWM_PLUS0_BRAKE_CFG (*(volatile uint32_t *)PWM_PLUS0_BRAKE_CFG_ADDR)
|
||||
|
||||
#define PWM_PLUS0_MASK_LEV_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_MASK_LEV)
|
||||
#define PWM_PLUS0_MASK_LEV (*(volatile uint32_t *)PWM_PLUS0_MASK_LEV_ADDR)
|
||||
|
||||
#define PWM_PLUS0_PERIOD_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_PERIOD)
|
||||
#define PWM_PLUS0_PERIOD (*(volatile uint32_t *)PWM_PLUS0_PERIOD_ADDR)
|
||||
|
||||
#define PWM_PLUS0_CH0_COMP_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_CH0_COMP)
|
||||
#define PWM_PLUS0_CH0_COMP (*(volatile uint32_t *)PWM_PLUS0_CH0_COMP_ADDR)
|
||||
|
||||
#define PWM_PLUS0_CH1_COMP_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_CH1_COMP)
|
||||
#define PWM_PLUS0_CH1_COMP (*(volatile uint32_t *)PWM_PLUS0_CH1_COMP_ADDR)
|
||||
|
||||
#define PWM_PLUS0_CH2_COMP_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_CH2_COMP)
|
||||
#define PWM_PLUS0_CH2_COMP (*(volatile uint32_t *)PWM_PLUS0_CH2_COMP_ADDR)
|
||||
|
||||
#define PWM_PLUS0_CH0_DT_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_CH0_DT)
|
||||
#define PWM_PLUS0_CH0_DT (*(volatile uint32_t *)PWM_PLUS0_CH0_DT_ADDR)
|
||||
|
||||
#define PWM_PLUS0_CH1_DT_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_CH1_DT)
|
||||
#define PWM_PLUS0_CH1_DT (*(volatile uint32_t *)PWM_PLUS0_CH1_DT_ADDR)
|
||||
|
||||
#define PWM_PLUS0_CH2_DT_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_CH2_DT)
|
||||
#define PWM_PLUS0_CH2_DT (*(volatile uint32_t *)PWM_PLUS0_CH2_DT_ADDR)
|
||||
|
||||
#define PWM_PLUS0_TRIG_COMP_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_TRIG_COMP)
|
||||
#define PWM_PLUS0_TRIG_COMP (*(volatile uint32_t *)PWM_PLUS0_TRIG_COMP_ADDR)
|
||||
|
||||
#define PWM_PLUS0_TRIG_CFG_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_TRIG_CFG)
|
||||
#define PWM_PLUS0_TRIG_CFG (*(volatile uint32_t *)PWM_PLUS0_TRIG_CFG_ADDR)
|
||||
|
||||
#define PWM_PLUS0_IE_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_IE)
|
||||
#define PWM_PLUS0_IE (*(volatile uint32_t *)PWM_PLUS0_IE_ADDR)
|
||||
|
||||
#define PWM_PLUS0_IF_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_IF)
|
||||
#define PWM_PLUS0_IF (*(volatile uint32_t *)PWM_PLUS0_IF_ADDR)
|
||||
|
||||
#define PWM_PLUS0_SWLOAD_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_SWLOAD)
|
||||
#define PWM_PLUS0_SWLOAD (*(volatile uint32_t *)PWM_PLUS0_SWLOAD_ADDR)
|
||||
|
||||
#define PWM_PLUS0_MASK_EN_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_MASK_EN)
|
||||
#define PWM_PLUS0_MASK_EN (*(volatile uint32_t *)PWM_PLUS0_MASK_EN_ADDR)
|
||||
|
||||
#define PWM_PLUS0_CNT_ST_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_CNT_ST)
|
||||
#define PWM_PLUS0_CNT_ST (*(volatile uint32_t *)PWM_PLUS0_CNT_ST_ADDR)
|
||||
|
||||
#define PWM_PLUS0_BRAKE_ST_ADDR (PWM_PLUS0_BASE_ADDR + PWMPLUS_BRAKE_ST)
|
||||
#define PWM_PLUS0_BRAKE_ST (*(volatile uint32_t *)PWM_PLUS0_BRAKE_ST_ADDR)
|
||||
|
||||
#endif
|
||||
4
compile-with-docker.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
docker build -t uvk5 .
|
||||
docker run --rm -v %CD%\compiled-firmware:/app/compiled-firmware uvk5 /bin/bash -c "cd /app && make clean && make && cp firmware* compiled-firmware/"
|
||||
pause
|
||||
3
compile-with-docker.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
docker build -t uvk5 .
|
||||
docker run --rm -v ${PWD}/compiled-firmware:/app/compiled-firmware uvk5 /bin/bash -c "cd /app && make && cp firmware* compiled-firmware/"
|
||||
2
dcs.c
@@ -91,7 +91,7 @@ uint8_t DCS_GetCdcssCode(uint32_t Code)
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
uint8_t DCS_GetCtcssCode(uint16_t Code)
|
||||
uint8_t DCS_GetCtcssCode(int Code)
|
||||
{
|
||||
unsigned int i;
|
||||
uint8_t Result = 0xFF;
|
||||
|
||||
2
dcs.h
@@ -39,7 +39,7 @@ extern const uint16_t DCS_Options[104];
|
||||
|
||||
uint32_t DCS_GetGolayCodeWord(DCS_CodeType_t CodeType, uint8_t Option);
|
||||
uint8_t DCS_GetCdcssCode(uint32_t Code);
|
||||
uint8_t DCS_GetCtcssCode(uint16_t Code);
|
||||
uint8_t DCS_GetCtcssCode(int Code);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
48
debugging.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef DEBUGGING_H
|
||||
#define DEBUGGING_H
|
||||
|
||||
#ifdef ENABLE_UART
|
||||
|
||||
#include "driver/uart.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "string.h"
|
||||
#include "external/printf/printf.h"
|
||||
#include "am_fix.h"
|
||||
|
||||
static inline void LogUart(const char *const str)
|
||||
{
|
||||
UART_Send(str, strlen(str));
|
||||
}
|
||||
|
||||
static inline void LogUartf(const char* format, ...)
|
||||
{
|
||||
char buffer[128];
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
vsnprintf(buffer, (size_t)-1, format, va);
|
||||
va_end(va);
|
||||
UART_Send(buffer, strlen(buffer));
|
||||
}
|
||||
|
||||
static inline void LogRegUart(uint16_t reg)
|
||||
{
|
||||
uint16_t regVal = BK4819_ReadRegister(reg);
|
||||
char buf[32];
|
||||
sprintf(buf, "reg%02X: %04X\n", reg, regVal);
|
||||
LogUart(buf);
|
||||
}
|
||||
|
||||
static inline void LogPrint()
|
||||
{
|
||||
uint16_t rssi = BK4819_GetRSSI();
|
||||
uint16_t reg7e = BK4819_ReadRegister(0x7E);
|
||||
char buf[32];
|
||||
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", (reg7e >> 15),
|
||||
(reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111,
|
||||
(reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
|
||||
LogUart(buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -134,9 +134,9 @@ void ADC_Configure(ADC_Config_t *pAdc)
|
||||
;
|
||||
|
||||
if (SARADC_IE == 0) {
|
||||
NVIC_DisableIRQ(DP32_SARADC_IRQn);
|
||||
NVIC_DisableIRQ((IRQn_Type)DP32_SARADC_IRQn);
|
||||
} else {
|
||||
NVIC_EnableIRQ(DP32_SARADC_IRQn);
|
||||
NVIC_EnableIRQ((IRQn_Type)DP32_SARADC_IRQn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
driver/adc.h
@@ -42,8 +42,10 @@ enum ADC_CH_MASK {
|
||||
typedef enum ADC_CH_MASK ADC_CH_MASK;
|
||||
|
||||
typedef struct {
|
||||
uint8_t CLK_SEL;
|
||||
uint16_t EXTTRIG_SEL;
|
||||
uint16_t IE_CHx_EOC;
|
||||
ADC_CH_MASK CH_SEL;
|
||||
uint8_t CLK_SEL;
|
||||
uint8_t AVG;
|
||||
uint8_t CONT;
|
||||
uint8_t MEM_MODE;
|
||||
@@ -51,13 +53,12 @@ typedef struct {
|
||||
uint8_t SMPL_SETUP;
|
||||
uint8_t SMPL_WIN;
|
||||
uint8_t ADC_TRIG;
|
||||
uint16_t EXTTRIG_SEL;
|
||||
bool CALIB_OFFSET_VALID;
|
||||
bool CALIB_KD_VALID;
|
||||
uint8_t DMA_EN;
|
||||
uint16_t IE_CHx_EOC;
|
||||
uint8_t IE_FIFO_HFULL;
|
||||
uint8_t IE_FIFO_FULL;
|
||||
bool CALIB_OFFSET_VALID;
|
||||
bool CALIB_KD_VALID;
|
||||
uint8_t _pad[1];
|
||||
} ADC_Config_t;
|
||||
|
||||
uint8_t ADC_GetChannelNumber(ADC_CH_MASK Mask);
|
||||
|
||||
@@ -24,6 +24,8 @@ static void AES_Setup_ENC_CBC(bool IsDecrypt, const void *pKey, const void *pIv)
|
||||
const uint32_t *pK = (const uint32_t *)pKey;
|
||||
const uint32_t *pI = (const uint32_t *)pIv;
|
||||
|
||||
(void)IsDecrypt; // unused
|
||||
|
||||
AES_CR = (AES_CR & ~AES_CR_EN_MASK) | AES_CR_EN_BITS_DISABLE;
|
||||
AES_CR = AES_CR_CHMOD_BITS_CBC;
|
||||
AES_KEYR3 = pK[0];
|
||||
|
||||
@@ -16,45 +16,103 @@
|
||||
|
||||
#include "backlight.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "bsp/dp32g030/pwmplus.h"
|
||||
#include "bsp/dp32g030/portcon.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "settings.h"
|
||||
|
||||
// this is decremented once every 500ms
|
||||
uint16_t gBacklightCountdown = 0;
|
||||
uint16_t gBacklightCountdown_500ms = 0;
|
||||
bool backlightOn;
|
||||
|
||||
void BACKLIGHT_InitHardware()
|
||||
{
|
||||
// 48MHz / 94 / 1024 ~ 500Hz
|
||||
const uint32_t PWM_FREQUENCY_HZ = 1000;
|
||||
PWM_PLUS0_CLKSRC |= ((48000000 / 1024 / PWM_FREQUENCY_HZ) << 16);
|
||||
PWM_PLUS0_PERIOD = 1023;
|
||||
|
||||
PORTCON_PORTB_SEL0 &= ~(0
|
||||
// Back light
|
||||
| PORTCON_PORTB_SEL0_B6_MASK
|
||||
);
|
||||
PORTCON_PORTB_SEL0 |= 0
|
||||
// Back light PWM
|
||||
| PORTCON_PORTB_SEL0_B6_BITS_PWMP0_CH0
|
||||
;
|
||||
|
||||
PWM_PLUS0_GEN =
|
||||
PWMPLUS_GEN_CH0_OE_BITS_ENABLE |
|
||||
PWMPLUS_GEN_CH0_OUTINV_BITS_ENABLE |
|
||||
0;
|
||||
|
||||
PWM_PLUS0_CFG =
|
||||
PWMPLUS_CFG_CNT_REP_BITS_ENABLE |
|
||||
PWMPLUS_CFG_COUNTER_EN_BITS_ENABLE |
|
||||
0;
|
||||
}
|
||||
|
||||
void BACKLIGHT_TurnOn(void)
|
||||
{
|
||||
if (gEeprom.BACKLIGHT == 0)
|
||||
if (gEeprom.BACKLIGHT_TIME == 0) {
|
||||
BACKLIGHT_TurnOff();
|
||||
return;
|
||||
|
||||
// turn the backlight ON
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
||||
|
||||
switch (gEeprom.BACKLIGHT)
|
||||
{
|
||||
default:
|
||||
case 1: // 5 sec
|
||||
gBacklightCountdown = 5;
|
||||
break;
|
||||
case 2: // 10 sec
|
||||
gBacklightCountdown = 10;
|
||||
break;
|
||||
case 3: // 20 sec
|
||||
gBacklightCountdown = 20;
|
||||
break;
|
||||
case 4: // 1 min
|
||||
gBacklightCountdown = 60;
|
||||
break;
|
||||
case 5: // 2 min
|
||||
gBacklightCountdown = 60 * 2;
|
||||
break;
|
||||
case 6: // 4 min
|
||||
gBacklightCountdown = 60 * 4;
|
||||
break;
|
||||
case 7: // always on
|
||||
gBacklightCountdown = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
gBacklightCountdown *= 2;
|
||||
backlightOn = true;
|
||||
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MAX);
|
||||
|
||||
switch (gEeprom.BACKLIGHT_TIME) {
|
||||
default:
|
||||
case 1: // 5 sec
|
||||
case 2: // 10 sec
|
||||
case 3: // 20 sec
|
||||
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 1)) * 5;
|
||||
break;
|
||||
case 4: // 1 min
|
||||
case 5: // 2 min
|
||||
case 6: // 4 min
|
||||
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 4)) * 60;
|
||||
break;
|
||||
case 7: // always on
|
||||
gBacklightCountdown_500ms = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BACKLIGHT_TurnOff()
|
||||
{
|
||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||
register uint8_t tmp;
|
||||
|
||||
if (gEeprom.BACKLIGHT_MIN_STAT == BLMIN_STAT_ON)
|
||||
tmp = gEeprom.BACKLIGHT_MIN;
|
||||
else
|
||||
tmp = 0;
|
||||
|
||||
BACKLIGHT_SetBrightness(tmp);
|
||||
#else
|
||||
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MIN);
|
||||
#endif
|
||||
gBacklightCountdown_500ms = 0;
|
||||
backlightOn = false;
|
||||
}
|
||||
|
||||
bool BACKLIGHT_IsOn()
|
||||
{
|
||||
return backlightOn;
|
||||
}
|
||||
|
||||
static uint8_t currentBrightness;
|
||||
|
||||
void BACKLIGHT_SetBrightness(uint8_t brigtness)
|
||||
{
|
||||
currentBrightness = brigtness;
|
||||
PWM_PLUS0_CH0_COMP = (1 << brigtness) - 1;
|
||||
//PWM_PLUS0_SWLOAD = 1;
|
||||
}
|
||||
|
||||
uint8_t BACKLIGHT_GetBrightness(void)
|
||||
{
|
||||
return currentBrightness;
|
||||
}
|
||||
@@ -18,10 +18,24 @@
|
||||
#define DRIVER_BACKLIGHT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern uint16_t gBacklightCountdown;
|
||||
|
||||
void BACKLIGHT_TurnOn(void);
|
||||
extern uint16_t gBacklightCountdown_500ms;
|
||||
extern uint8_t gBacklightBrightness;
|
||||
|
||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||
typedef enum {
|
||||
BLMIN_STAT_ON,
|
||||
BLMIN_STAT_OFF,
|
||||
BLMIN_STAT_UNKNOWN
|
||||
} BLMIN_STAT_t;
|
||||
#endif
|
||||
|
||||
void BACKLIGHT_InitHardware();
|
||||
void BACKLIGHT_TurnOn();
|
||||
void BACKLIGHT_TurnOff();
|
||||
bool BACKLIGHT_IsOn();
|
||||
void BACKLIGHT_SetBrightness(uint8_t brigtness);
|
||||
uint8_t BACKLIGHT_GetBrightness(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,16 +39,19 @@ static bool gIsInitBK1080;
|
||||
uint16_t BK1080_BaseFrequency;
|
||||
uint16_t BK1080_FrequencyDeviation;
|
||||
|
||||
void BK1080_Init(uint16_t Frequency, bool bDoScan)
|
||||
void BK1080_Init0(void)
|
||||
{
|
||||
BK1080_Init(0,0/*,0*/);
|
||||
}
|
||||
|
||||
void BK1080_Init(uint16_t freq, uint8_t band/*, uint8_t space*/)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (bDoScan)
|
||||
{
|
||||
if (freq) {
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
||||
|
||||
if (!gIsInitBK1080)
|
||||
{
|
||||
if (!gIsInitBK1080) {
|
||||
for (i = 0; i < ARRAY_SIZE(BK1080_RegisterTable); i++)
|
||||
BK1080_WriteRegister(i, BK1080_RegisterTable[i]);
|
||||
|
||||
@@ -61,20 +64,14 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
|
||||
|
||||
gIsInitBK1080 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201);
|
||||
}
|
||||
|
||||
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A5F);
|
||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
|
||||
|
||||
SYSTEM_DelayMs(10);
|
||||
|
||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | 0x8000);
|
||||
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A1F);
|
||||
BK1080_SetFrequency(freq, band/*, space*/);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0241);
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
||||
}
|
||||
@@ -108,11 +105,22 @@ void BK1080_Mute(bool Mute)
|
||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, Mute ? 0x4201 : 0x0201);
|
||||
}
|
||||
|
||||
void BK1080_SetFrequency(uint16_t Frequency)
|
||||
void BK1080_SetFrequency(uint16_t frequency, uint8_t band/*, uint8_t space*/)
|
||||
{
|
||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
|
||||
//uint8_t spacings[] = {20,10,5};
|
||||
//space %= 3;
|
||||
|
||||
uint16_t channel = (frequency - BK1080_GetFreqLoLimit(band))/* * 10 / spacings[space]*/;
|
||||
|
||||
uint16_t regval = BK1080_ReadRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2);
|
||||
regval = (regval & ~(0b11 << 6)) | ((band & 0b11) << 6);
|
||||
//regval = (regval & ~(0b11 << 4)) | ((space & 0b11) << 4);
|
||||
|
||||
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, regval);
|
||||
|
||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel);
|
||||
SYSTEM_DelayMs(10);
|
||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | 0x8000);
|
||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel | 0x8000);
|
||||
}
|
||||
|
||||
void BK1080_GetFrequencyDeviation(uint16_t Frequency)
|
||||
@@ -120,3 +128,17 @@ void BK1080_GetFrequencyDeviation(uint16_t Frequency)
|
||||
BK1080_BaseFrequency = Frequency;
|
||||
BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) / 16;
|
||||
}
|
||||
|
||||
uint16_t BK1080_GetFreqLoLimit(uint8_t band)
|
||||
{
|
||||
uint16_t lim[] = {875, 760, 760, 640};
|
||||
return lim[band % 4];
|
||||
}
|
||||
|
||||
uint16_t BK1080_GetFreqHiLimit(uint8_t band)
|
||||
{
|
||||
band %= 4;
|
||||
uint16_t lim[] = {1080, 1080, 900, 760};
|
||||
return lim[band % 4];
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,14 @@
|
||||
extern uint16_t BK1080_BaseFrequency;
|
||||
extern uint16_t BK1080_FrequencyDeviation;
|
||||
|
||||
void BK1080_Init(uint16_t Frequency, bool bDoScan);
|
||||
void BK1080_Init0(void);
|
||||
void BK1080_Init(uint16_t Frequency, uint8_t band/*, uint8_t space*/);
|
||||
uint16_t BK1080_ReadRegister(BK1080_Register_t Register);
|
||||
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
|
||||
void BK1080_Mute(bool Mute);
|
||||
void BK1080_SetFrequency(uint16_t Frequency);
|
||||
uint16_t BK1080_GetFreqLoLimit(uint8_t band);
|
||||
uint16_t BK1080_GetFreqHiLimit(uint8_t band);
|
||||
void BK1080_SetFrequency(uint16_t frequency, uint8_t band/*, uint8_t space*/);
|
||||
void BK1080_GetFrequencyDeviation(uint16_t Frequency);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,20 @@
|
||||
#ifndef BK4819_REGS_H
|
||||
#define BK4819_REGS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
uint8_t num;
|
||||
uint8_t offset;
|
||||
uint16_t mask;
|
||||
uint16_t inc;
|
||||
} RegisterSpec;
|
||||
|
||||
static const RegisterSpec afcDisableRegSpec = {"AFC Disable", 0x73, 4, 1, 1};
|
||||
static const RegisterSpec afOutRegSpec = {"AF Output Select", 0x47, 8, 0xF, 1};
|
||||
static const RegisterSpec afDacGainRegSpec = {"AF DAC Gain", 0x48, 0, 0xF, 1};
|
||||
|
||||
enum BK4819_REGISTER_t {
|
||||
BK4819_REG_00 = 0x00U,
|
||||
BK4819_REG_02 = 0x02U,
|
||||
@@ -28,10 +42,15 @@ enum BK4819_REGISTER_t {
|
||||
BK4819_REG_0C = 0x0CU,
|
||||
BK4819_REG_0D = 0x0DU,
|
||||
BK4819_REG_0E = 0x0EU,
|
||||
// RX AGC Gain Table[0]
|
||||
BK4819_REG_10 = 0x10U,
|
||||
// RX AGC Gain Table[1]
|
||||
BK4819_REG_11 = 0x11U,
|
||||
// RX AGC Gain Table[2]
|
||||
BK4819_REG_12 = 0x12U,
|
||||
// RX AGC Gain Table[3]
|
||||
BK4819_REG_13 = 0x13U,
|
||||
// RX AGC Gain Table[-1]
|
||||
BK4819_REG_14 = 0x14U,
|
||||
BK4819_REG_19 = 0x19U,
|
||||
BK4819_REG_1F = 0x1FU,
|
||||
@@ -52,12 +71,19 @@ enum BK4819_REGISTER_t {
|
||||
BK4819_REG_3A = 0x3AU,
|
||||
BK4819_REG_3B = 0x3BU,
|
||||
BK4819_REG_3C = 0x3CU,
|
||||
BK4819_REG_3D = 0x3DU,
|
||||
BK4819_REG_3E = 0x3EU,
|
||||
BK4819_REG_3F = 0x3FU,
|
||||
BK4819_REG_43 = 0x43U,
|
||||
BK4819_REG_46 = 0x46U,
|
||||
BK4819_REG_47 = 0x47U,
|
||||
BK4819_REG_48 = 0x48U,
|
||||
// REG_49<15:14> 0b00; High/Low Lo selection:
|
||||
// 0X: Auto High/Low Lo
|
||||
// 10: Low Lo
|
||||
// 11: High Lo
|
||||
// REG_49<13:7> 0x50; RF AGC high threshold, 1 dB/LSB
|
||||
// REG_49<6:0> 0x30; RF AGC low threshold, 1 dB/LSB
|
||||
BK4819_REG_49 = 0x49U,
|
||||
BK4819_REG_4D = 0x4DU,
|
||||
BK4819_REG_4E = 0x4EU,
|
||||
@@ -86,22 +112,34 @@ enum BK4819_REGISTER_t {
|
||||
BK4819_REG_78 = 0x78U,
|
||||
BK4819_REG_79 = 0x79U,
|
||||
BK4819_REG_7A = 0x7AU,
|
||||
// REG_7B<15:0> 0xae34 RSSI table
|
||||
BK4819_REG_7B = 0x7BU,
|
||||
// REG_7C<15:0> 0x8000 RSSI table
|
||||
BK4819_REG_7C = 0x7CU,
|
||||
BK4819_REG_7D = 0x7DU,
|
||||
// REG_7E<15> 0; AGC fix mode:
|
||||
// 1: Fix
|
||||
// 0: Auto
|
||||
// REG_7E<14:12> 0b011; AGC fix index:
|
||||
// 011: Max.
|
||||
// …
|
||||
// 100: Min.
|
||||
// REG_7E<5:3> 0b101; DC filter bandwidth for TX (MIC in):
|
||||
// 000: Bypass DC filter
|
||||
// REG_7E<2:0> 0b110; DC filter bandwidth for RX (IF in):
|
||||
// 000: Bypass DC filter
|
||||
BK4819_REG_7E = 0x7EU,
|
||||
};
|
||||
|
||||
typedef enum BK4819_REGISTER_t BK4819_REGISTER_t;
|
||||
|
||||
enum BK4819_GPIO_PIN_t {
|
||||
BK4819_GPIO6_PIN2 = 0,
|
||||
BK4819_GPIO5_PIN1 = 1,
|
||||
BK4819_GPIO4_PIN32 = 2,
|
||||
BK4819_GPIO3_PIN31 = 3,
|
||||
BK4819_GPIO2_PIN30 = 4,
|
||||
BK4819_GPIO1_PIN29_RED = 5,
|
||||
BK4819_GPIO0_PIN28_GREEN = 6,
|
||||
BK4819_GPIO0_PIN28_RX_ENABLE = 0,
|
||||
BK4819_GPIO1_PIN29_PA_ENABLE = 1,
|
||||
BK4819_GPIO3_PIN31_UHF_LNA = 3,
|
||||
BK4819_GPIO4_PIN32_VHF_LNA = 4,
|
||||
BK4819_GPIO5_PIN1_RED = 5,
|
||||
BK4819_GPIO6_PIN2_GREEN = 6,
|
||||
};
|
||||
|
||||
typedef enum BK4819_GPIO_PIN_t BK4819_GPIO_PIN_t;
|
||||
@@ -350,4 +388,3 @@ enum {
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
1308
driver/bk4819.c
@@ -24,22 +24,22 @@
|
||||
|
||||
enum BK4819_AF_Type_t
|
||||
{
|
||||
BK4819_AF_MUTE = 0u,
|
||||
BK4819_AF_OPEN = 1u,
|
||||
BK4819_AF_ALAM = 2u,
|
||||
BK4819_AF_BEEP = 3u,
|
||||
BK4819_AF_UNKNOWN1 = 4u,
|
||||
BK4819_AF_UNKNOWN2 = 5u,
|
||||
BK4819_AF_CTCO = 6u,
|
||||
BK4819_AF_AM = 7u,
|
||||
BK4819_AF_FSKO = 8u,
|
||||
BK4819_AF_UNKNOWN3 = 9u,
|
||||
BK4819_AF_UNKNOWN4 = 10u,
|
||||
BK4819_AF_UNKNOWN5 = 11u,
|
||||
BK4819_AF_UNKNOWN6 = 12u,
|
||||
BK4819_AF_UNKNOWN7 = 13u,
|
||||
BK4819_AF_UNKNOWN8 = 14u,
|
||||
BK4819_AF_UNKNOWN9 = 15u
|
||||
BK4819_AF_MUTE = 0u, //
|
||||
BK4819_AF_FM = 1u, // FM
|
||||
BK4819_AF_ALAM = 2u, //
|
||||
BK4819_AF_BEEP = 3u, //
|
||||
BK4819_AF_BASEBAND1 = 4u, // RAW
|
||||
BK4819_AF_BASEBAND2 = 5u, // USB
|
||||
BK4819_AF_CTCO = 6u, // strange LF audio .. maybe the CTCSS LF line ?
|
||||
BK4819_AF_AM = 7u, // AM
|
||||
BK4819_AF_FSKO = 8u, // nothing
|
||||
BK4819_AF_UNKNOWN3 = 9u, // BYP
|
||||
BK4819_AF_UNKNOWN4 = 10u, // nothing at all
|
||||
BK4819_AF_UNKNOWN5 = 11u, // distorted
|
||||
BK4819_AF_UNKNOWN6 = 12u, // distorted
|
||||
BK4819_AF_UNKNOWN7 = 13u, // interesting
|
||||
BK4819_AF_UNKNOWN8 = 14u, // interesting
|
||||
BK4819_AF_UNKNOWN9 = 15u // not a lot
|
||||
};
|
||||
|
||||
typedef enum BK4819_AF_Type_t BK4819_AF_Type_t;
|
||||
@@ -62,15 +62,18 @@ enum BK4819_CssScanResult_t
|
||||
|
||||
typedef enum BK4819_CssScanResult_t BK4819_CssScanResult_t;
|
||||
|
||||
// radio is asleep, not listening
|
||||
extern bool gRxIdleMode;
|
||||
|
||||
void BK4819_Init(void);
|
||||
uint16_t BK4819_ReadRegister(BK4819_REGISTER_t Register);
|
||||
void BK4819_WriteRegister(BK4819_REGISTER_t Register, uint16_t Data);
|
||||
void BK4819_SetRegValue(RegisterSpec s, uint16_t v);
|
||||
void BK4819_WriteU8(uint8_t Data);
|
||||
void BK4819_WriteU16(uint16_t Data);
|
||||
|
||||
void BK4819_SetAGC(uint8_t Value);
|
||||
void BK4819_SetAGC(bool enable);
|
||||
void BK4819_InitAGC(bool amModulation);
|
||||
|
||||
void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet);
|
||||
|
||||
@@ -102,6 +105,7 @@ void BK4819_DisableVox(void);
|
||||
void BK4819_DisableDTMF(void);
|
||||
void BK4819_EnableDTMF(void);
|
||||
void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch);
|
||||
void BK4819_PlaySingleTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level, const bool play_speaker);
|
||||
void BK4819_EnterTxMute(void);
|
||||
void BK4819_ExitTxMute(void);
|
||||
void BK4819_Sleep(void);
|
||||
@@ -132,6 +136,8 @@ void BK4819_EnableCDCSS(void);
|
||||
void BK4819_EnableCTCSS(void);
|
||||
|
||||
uint16_t BK4819_GetRSSI(void);
|
||||
int8_t BK4819_GetRxGain_dB(void);
|
||||
int16_t BK4819_GetRSSI_dBm(void);
|
||||
uint8_t BK4819_GetGlitchIndicator(void);
|
||||
uint8_t BK4819_GetExNoiceIndicator(void);
|
||||
uint16_t BK4819_GetVoiceAmplitudeOut(void);
|
||||
@@ -155,15 +161,13 @@ uint8_t BK4819_GetCTCType(void);
|
||||
|
||||
void BK4819_SendFSKData(uint16_t *pData);
|
||||
void BK4819_PrepareFSKReceive(void);
|
||||
|
||||
|
||||
void BK4819_PlayRoger(void);
|
||||
void BK4819_PlayRogerMDC(void);
|
||||
|
||||
|
||||
void BK4819_Enable_AfDac_DiscMode_TxDsp(void);
|
||||
|
||||
|
||||
void BK4819_GetVoxAmp(uint16_t *pResult);
|
||||
void BK4819_SetScrambleFrequencyControlWord(uint32_t Frequency);
|
||||
void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bsp/dp32g030/crc.h"
|
||||
#include "driver/crc.h"
|
||||
#include "../bsp/dp32g030/crc.h"
|
||||
#include "crc.h"
|
||||
|
||||
void CRC_Init(void)
|
||||
{
|
||||
@@ -47,4 +47,3 @@ uint16_t CRC_Calculate(const void *pBuffer, uint16_t Size)
|
||||
|
||||
return Crc;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "driver/eeprom.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "driver/system.h"
|
||||
@@ -38,16 +41,23 @@ void EEPROM_ReadBuffer(uint16_t Address, void *pBuffer, uint8_t Size)
|
||||
|
||||
void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer)
|
||||
{
|
||||
if (pBuffer == NULL || Address >= 0x2000)
|
||||
return;
|
||||
|
||||
|
||||
uint8_t buffer[8];
|
||||
EEPROM_ReadBuffer(Address, buffer, 8);
|
||||
if (memcmp(pBuffer, buffer, 8) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
I2C_Start();
|
||||
|
||||
I2C_Write(0xA0);
|
||||
|
||||
I2C_Write((Address >> 8) & 0xFF);
|
||||
I2C_Write((Address >> 0) & 0xFF);
|
||||
|
||||
I2C_WriteBuffer(pBuffer, 8);
|
||||
|
||||
I2C_Stop();
|
||||
|
||||
SYSTEM_DelayMs(10);
|
||||
// give the EEPROM time to burn the data in (apparently takes 5ms)
|
||||
SYSTEM_DelayMs(8);
|
||||
}
|
||||
|
||||
@@ -14,25 +14,5 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "driver/gpio.h"
|
||||
|
||||
void GPIO_ClearBit(volatile uint32_t *pReg, uint8_t Bit)
|
||||
{
|
||||
*pReg &= ~(1U << Bit);
|
||||
}
|
||||
|
||||
uint8_t GPIO_CheckBit(volatile uint32_t *pReg, uint8_t Bit)
|
||||
{
|
||||
return (*pReg >> Bit) & 1U;
|
||||
}
|
||||
|
||||
void GPIO_FlipBit(volatile uint32_t *pReg, uint8_t Bit)
|
||||
{
|
||||
*pReg ^= 1U << Bit;
|
||||
}
|
||||
|
||||
void GPIO_SetBit(volatile uint32_t *pReg, uint8_t Bit)
|
||||
{
|
||||
*pReg |= 1U << Bit;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,21 @@ enum GPIOC_PINS {
|
||||
GPIOC_PIN_PTT = 5
|
||||
};
|
||||
|
||||
void GPIO_ClearBit(volatile uint32_t *pReg, uint8_t Bit);
|
||||
uint8_t GPIO_CheckBit(volatile uint32_t *pReg, uint8_t Bit);
|
||||
void GPIO_FlipBit(volatile uint32_t *pReg, uint8_t Bit);
|
||||
void GPIO_SetBit(volatile uint32_t *pReg, uint8_t Bit);
|
||||
static inline void GPIO_ClearBit(volatile uint32_t *pReg, uint8_t Bit) {
|
||||
*pReg &= ~(1U << Bit);
|
||||
}
|
||||
|
||||
static inline uint8_t GPIO_CheckBit(volatile uint32_t *pReg, uint8_t Bit) {
|
||||
return (*pReg >> Bit) & 1U;
|
||||
}
|
||||
|
||||
static inline void GPIO_FlipBit(volatile uint32_t *pReg, uint8_t Bit) {
|
||||
*pReg ^= 1U << Bit;
|
||||
}
|
||||
|
||||
static inline void GPIO_SetBit(volatile uint32_t *pReg, uint8_t Bit) {
|
||||
*pReg |= 1U << Bit;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -137,18 +137,13 @@ int I2C_ReadBuffer(void *pBuffer, uint8_t Size)
|
||||
uint8_t *pData = (uint8_t *)pBuffer;
|
||||
uint8_t i;
|
||||
|
||||
if (Size == 1) {
|
||||
*pData = I2C_Read(true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < Size - 1; i++) {
|
||||
SYSTICK_DelayUs(1);
|
||||
pData[i] = I2C_Read(false);
|
||||
}
|
||||
|
||||
SYSTICK_DelayUs(1);
|
||||
pData[i++] = I2C_Read(true);
|
||||
pData[i] = I2C_Read(true);
|
||||
|
||||
return Size;
|
||||
}
|
||||
|
||||
@@ -19,182 +19,135 @@
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/keyboard.h"
|
||||
#include "driver/systick.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "misc.h"
|
||||
|
||||
KEY_Code_t gKeyReading0 = KEY_INVALID;
|
||||
KEY_Code_t gKeyReading1 = KEY_INVALID;
|
||||
uint16_t gDebounceCounter;
|
||||
bool gWasFKeyPressed;
|
||||
KEY_Code_t gKeyReading0 = KEY_INVALID;
|
||||
KEY_Code_t gKeyReading1 = KEY_INVALID;
|
||||
uint16_t gDebounceCounter = 0;
|
||||
bool gWasFKeyPressed = false;
|
||||
|
||||
static const struct {
|
||||
|
||||
// Using a 16 bit pre-calculated shift and invert is cheaper
|
||||
// than using 8 bit and doing shift and invert in code.
|
||||
uint16_t set_to_zero_mask;
|
||||
|
||||
// We are very fortunate.
|
||||
// The key and pin defines fit together in a single u8, making this very efficient
|
||||
struct {
|
||||
KEY_Code_t key : 5;
|
||||
uint8_t pin : 3; // Pin 6 is highest
|
||||
} pins[4];
|
||||
|
||||
} keyboard[] = {
|
||||
|
||||
{ // Zero row
|
||||
// Set to zero to handle special case of nothing pulled down
|
||||
.set_to_zero_mask = 0xffff,
|
||||
.pins = {
|
||||
{ .key = KEY_SIDE1, .pin = GPIOA_PIN_KEYBOARD_0},
|
||||
{ .key = KEY_SIDE2, .pin = GPIOA_PIN_KEYBOARD_1},
|
||||
|
||||
// Duplicate to fill the array with valid values
|
||||
{ .key = KEY_INVALID, .pin = GPIOA_PIN_KEYBOARD_1},
|
||||
{ .key = KEY_INVALID, .pin = GPIOA_PIN_KEYBOARD_1}
|
||||
}
|
||||
},
|
||||
{ // First row
|
||||
.set_to_zero_mask = ~(1u << GPIOA_PIN_KEYBOARD_4) & 0xffff,
|
||||
.pins = {
|
||||
{ .key = KEY_MENU, .pin = GPIOA_PIN_KEYBOARD_0},
|
||||
{ .key = KEY_1, .pin = GPIOA_PIN_KEYBOARD_1},
|
||||
{ .key = KEY_4, .pin = GPIOA_PIN_KEYBOARD_2},
|
||||
{ .key = KEY_7, .pin = GPIOA_PIN_KEYBOARD_3}
|
||||
}
|
||||
},
|
||||
{ // Second row
|
||||
.set_to_zero_mask = ~(1u << GPIOA_PIN_KEYBOARD_5) & 0xffff,
|
||||
.pins = {
|
||||
{ .key = KEY_UP, .pin = GPIOA_PIN_KEYBOARD_0},
|
||||
{ .key = KEY_2 , .pin = GPIOA_PIN_KEYBOARD_1},
|
||||
{ .key = KEY_5 , .pin = GPIOA_PIN_KEYBOARD_2},
|
||||
{ .key = KEY_8 , .pin = GPIOA_PIN_KEYBOARD_3}
|
||||
}
|
||||
},
|
||||
{ // Third row
|
||||
.set_to_zero_mask = ~(1u << GPIOA_PIN_KEYBOARD_6) & 0xffff,
|
||||
.pins = {
|
||||
{ .key = KEY_DOWN, .pin = GPIOA_PIN_KEYBOARD_0},
|
||||
{ .key = KEY_3 , .pin = GPIOA_PIN_KEYBOARD_1},
|
||||
{ .key = KEY_6 , .pin = GPIOA_PIN_KEYBOARD_2},
|
||||
{ .key = KEY_9 , .pin = GPIOA_PIN_KEYBOARD_3}
|
||||
}
|
||||
},
|
||||
{ // Fourth row
|
||||
.set_to_zero_mask = ~(1u << GPIOA_PIN_KEYBOARD_7) & 0xffff,
|
||||
.pins = {
|
||||
{ .key = KEY_EXIT, .pin = GPIOA_PIN_KEYBOARD_0},
|
||||
{ .key = KEY_STAR, .pin = GPIOA_PIN_KEYBOARD_1},
|
||||
{ .key = KEY_0 , .pin = GPIOA_PIN_KEYBOARD_2},
|
||||
{ .key = KEY_F , .pin = GPIOA_PIN_KEYBOARD_3}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
KEY_Code_t KEYBOARD_Poll(void)
|
||||
{
|
||||
KEY_Code_t Key = KEY_INVALID;
|
||||
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_4);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_5);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_6);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_7);
|
||||
|
||||
SYSTICK_DelayUs(1);
|
||||
// if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
||||
// return KEY_PTT;
|
||||
|
||||
// *****************
|
||||
// Keys connected to gnd
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_0))
|
||||
for (unsigned int j = 0; j < ARRAY_SIZE(keyboard); j++)
|
||||
{
|
||||
Key = KEY_SIDE1;
|
||||
goto Bye;
|
||||
uint16_t reg;
|
||||
unsigned int i;
|
||||
unsigned int k;
|
||||
|
||||
// Set all high
|
||||
GPIOA->DATA |= 1u << GPIOA_PIN_KEYBOARD_4 |
|
||||
1u << GPIOA_PIN_KEYBOARD_5 |
|
||||
1u << GPIOA_PIN_KEYBOARD_6 |
|
||||
1u << GPIOA_PIN_KEYBOARD_7;
|
||||
|
||||
// Clear the pin we are selecting
|
||||
GPIOA->DATA &= keyboard[j].set_to_zero_mask;
|
||||
|
||||
// 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++) {
|
||||
SYSTICK_DelayUs(1);
|
||||
uint16_t reg2 = GPIOA->DATA;
|
||||
i *= reg == reg2;
|
||||
reg = reg2;
|
||||
}
|
||||
|
||||
if (i < 3)
|
||||
break; // noise is too bad
|
||||
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(keyboard[j].pins); i++)
|
||||
{
|
||||
const uint16_t mask = 1u << keyboard[j].pins[i].pin;
|
||||
if (!(reg & mask))
|
||||
{
|
||||
Key = keyboard[j].pins[i].key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Key != KEY_INVALID)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_1))
|
||||
{
|
||||
Key = KEY_SIDE2;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
// Original doesn't do PTT
|
||||
|
||||
// *****************
|
||||
// First row
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_4);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_0))
|
||||
{
|
||||
Key = KEY_MENU;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_1))
|
||||
{
|
||||
Key = KEY_1;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_2))
|
||||
{
|
||||
Key = KEY_4;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_3))
|
||||
{
|
||||
Key = KEY_7;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
// *****************
|
||||
// Second row
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_5);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_4);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_0))
|
||||
{
|
||||
Key = KEY_UP;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_1))
|
||||
{
|
||||
Key = KEY_2;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_2))
|
||||
{
|
||||
Key = KEY_5;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_3))
|
||||
{
|
||||
Key = KEY_8;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
// *****************
|
||||
// Third row
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_4);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_5);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_4);
|
||||
SYSTICK_DelayUs(1);
|
||||
// Create I2C stop condition since we might have toggled I2C pins
|
||||
// This leaves GPIOA_PIN_KEYBOARD_4 and GPIOA_PIN_KEYBOARD_5 high
|
||||
I2C_Stop();
|
||||
|
||||
// Reset VOICE pins
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_6);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_0))
|
||||
{
|
||||
Key = KEY_DOWN;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_1))
|
||||
{
|
||||
Key = KEY_3;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_2))
|
||||
{
|
||||
Key = KEY_6;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_3))
|
||||
{
|
||||
Key = KEY_9;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
// *****************
|
||||
// Fourth row
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_7);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_6);
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_0))
|
||||
{
|
||||
Key = KEY_EXIT;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_1))
|
||||
{
|
||||
Key = KEY_STAR;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_2))
|
||||
{
|
||||
Key = KEY_0;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
if (!GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_3))
|
||||
{
|
||||
Key = KEY_F;
|
||||
goto Bye;
|
||||
}
|
||||
|
||||
// *****************
|
||||
|
||||
Bye:
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_4);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_5);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_6);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_7);
|
||||
GPIO_SetBit( &GPIOA->DATA, GPIOA_PIN_KEYBOARD_7);
|
||||
|
||||
return Key;
|
||||
}
|
||||
|
||||
@@ -21,30 +21,29 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum KEY_Code_t {
|
||||
KEY_0 = 0,
|
||||
KEY_1 = 1,
|
||||
KEY_2 = 2,
|
||||
KEY_3 = 3,
|
||||
KEY_4 = 4,
|
||||
KEY_5 = 5,
|
||||
KEY_6 = 6,
|
||||
KEY_7 = 7,
|
||||
KEY_8 = 8,
|
||||
KEY_9 = 9,
|
||||
KEY_MENU = 10,
|
||||
KEY_UP = 11,
|
||||
KEY_DOWN = 12,
|
||||
KEY_EXIT = 13,
|
||||
KEY_STAR = 14,
|
||||
KEY_F = 15,
|
||||
KEY_PTT = 21,
|
||||
KEY_SIDE2 = 22,
|
||||
KEY_SIDE1 = 23,
|
||||
KEY_INVALID = 255
|
||||
enum KEY_Code_e {
|
||||
KEY_0 = 0, // 0
|
||||
KEY_1, // 1
|
||||
KEY_2, // 2
|
||||
KEY_3, // 3
|
||||
KEY_4, // 4
|
||||
KEY_5, // 5
|
||||
KEY_6, // 6
|
||||
KEY_7, // 7
|
||||
KEY_8, // 8
|
||||
KEY_9, // 9
|
||||
KEY_MENU, // A
|
||||
KEY_UP, // B
|
||||
KEY_DOWN, // C
|
||||
KEY_EXIT, // D
|
||||
KEY_STAR, // *
|
||||
KEY_F, // #
|
||||
KEY_PTT, //
|
||||
KEY_SIDE2, //
|
||||
KEY_SIDE1, //
|
||||
KEY_INVALID //
|
||||
};
|
||||
|
||||
typedef enum KEY_Code_t KEY_Code_t;
|
||||
typedef enum KEY_Code_e KEY_Code_t;
|
||||
|
||||
extern KEY_Code_t gKeyReading0;
|
||||
extern KEY_Code_t gKeyReading1;
|
||||
|
||||
@@ -93,9 +93,9 @@ void SPI_Configure(volatile SPI_Port_t *pPort, SPI_Config_t *pConfig)
|
||||
|
||||
if (pPort->IE) {
|
||||
if (pPort == SPI0) {
|
||||
NVIC_EnableIRQ(DP32_SPI0_IRQn);
|
||||
NVIC_EnableIRQ((IRQn_Type)DP32_SPI0_IRQn);
|
||||
} else if (pPort == SPI1) {
|
||||
NVIC_EnableIRQ(DP32_SPI1_IRQn);
|
||||
NVIC_EnableIRQ((IRQn_Type)DP32_SPI1_IRQn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
225
driver/st7565.c
@@ -25,165 +25,166 @@
|
||||
#include "driver/system.h"
|
||||
#include "misc.h"
|
||||
|
||||
uint8_t gStatusLine[128];
|
||||
uint8_t gFrameBuffer[7][128];
|
||||
|
||||
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
ST7565_SelectColumnAndLine(Column + 4U, Line);
|
||||
uint8_t gStatusLine[LCD_WIDTH];
|
||||
uint8_t gFrameBuffer[FRAME_LINES][LCD_WIDTH];
|
||||
|
||||
static void DrawLine(uint8_t column, uint8_t line, const uint8_t * lineBuffer, unsigned size_defVal)
|
||||
{
|
||||
ST7565_SelectColumnAndLine(column + 4, line);
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
||||
|
||||
if (pBitmap != NULL)
|
||||
{
|
||||
for (i = 0; i < Size; i++)
|
||||
{
|
||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
||||
SPI0->WDR = pBitmap[i];
|
||||
}
|
||||
for (unsigned i = 0; i < size_defVal; i++) {
|
||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
||||
SPI0->WDR = lineBuffer ? lineBuffer[i] : size_defVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < Size; i++)
|
||||
{
|
||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
||||
SPI0->WDR = 0;
|
||||
}
|
||||
}
|
||||
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
}
|
||||
|
||||
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const uint8_t *pBitmap, const unsigned int Size)
|
||||
{
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
DrawLine(Column, Line, pBitmap, Size);
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
|
||||
void ST7565_BlitFullScreen(void)
|
||||
{
|
||||
unsigned int Line;
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
ST7565_WriteByte(0x40);
|
||||
|
||||
for (Line = 0; Line < ARRAY_SIZE(gFrameBuffer); Line++)
|
||||
{
|
||||
unsigned int Column;
|
||||
ST7565_SelectColumnAndLine(4, Line + 1);
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
||||
for (Column = 0; Column < ARRAY_SIZE(gFrameBuffer[0]); Column++)
|
||||
{
|
||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
||||
SPI0->WDR = gFrameBuffer[Line][Column];
|
||||
}
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
for (unsigned line = 0; line < FRAME_LINES; line++) {
|
||||
DrawLine(0, line+1, gFrameBuffer[line], LCD_WIDTH);
|
||||
}
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// whats the delay for I wonder ? .. it slows down scanning :(
|
||||
SYSTEM_DelayMs(20);
|
||||
#else
|
||||
SYSTEM_DelayMs(1);
|
||||
#endif
|
||||
|
||||
void ST7565_BlitLine(unsigned line)
|
||||
{
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
ST7565_WriteByte(0x40); // start line ?
|
||||
DrawLine(0, line+1, gFrameBuffer[line], LCD_WIDTH);
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
|
||||
void ST7565_BlitStatusLine(void)
|
||||
{ // the top small text line on the display
|
||||
|
||||
unsigned int i;
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
ST7565_WriteByte(0x40); // start line ?
|
||||
|
||||
ST7565_SelectColumnAndLine(4, 0);
|
||||
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(gStatusLine); i++)
|
||||
{
|
||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
||||
SPI0->WDR = gStatusLine[i];
|
||||
}
|
||||
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
|
||||
DrawLine(0, 0, gStatusLine, LCD_WIDTH);
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
|
||||
void ST7565_FillScreen(uint8_t Value)
|
||||
void ST7565_FillScreen(uint8_t value)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned int j;
|
||||
ST7565_SelectColumnAndLine(0, i);
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
|
||||
for (j = 0; j < 132; j++)
|
||||
{
|
||||
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
|
||||
SPI0->WDR = Value;
|
||||
}
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
for (unsigned i = 0; i < 8; i++) {
|
||||
DrawLine(0, i, NULL, value);
|
||||
}
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
|
||||
// Software reset
|
||||
const uint8_t ST7565_CMD_SOFTWARE_RESET = 0xE2;
|
||||
// Bias Select
|
||||
// 1 0 1 0 0 0 1 BS
|
||||
// Select bias setting 0=1/9; 1=1/7 (at 1/65 duty)
|
||||
const uint8_t ST7565_CMD_BIAS_SELECT = 0xA2;
|
||||
// COM Direction
|
||||
// 1 1 0 0 MY - - -
|
||||
// Set output direction of COM
|
||||
// MY=1, reverse direction
|
||||
// MY=0, normal direction
|
||||
const uint8_t ST7565_CMD_COM_DIRECTION = 0xC0;
|
||||
// SEG Direction
|
||||
// 1 0 1 0 0 0 0 MX
|
||||
// Set scan direction of SEG
|
||||
// MX=1, reverse direction
|
||||
// MX=0, normal direction
|
||||
const uint8_t ST7565_CMD_SEG_DIRECTION = 0xA0;
|
||||
// Inverse Display
|
||||
// 1 0 1 0 0 1 1 INV
|
||||
// INV =1, inverse display
|
||||
// INV =0, normal display
|
||||
const uint8_t ST7565_CMD_INVERSE_DISPLAY = 0xA6;
|
||||
// All Pixel ON
|
||||
// 1 0 1 0 0 1 0 AP
|
||||
// AP=1, set all pixel ON
|
||||
// AP=0, normal display
|
||||
const uint8_t ST7565_CMD_ALL_PIXEL_ON = 0xA4;
|
||||
// Regulation Ratio
|
||||
// 0 0 1 0 0 RR2 RR1 RR0
|
||||
// This instruction controls the regulation ratio of the built-in regulator
|
||||
const uint8_t ST7565_CMD_REGULATION_RATIO = 0x20;
|
||||
// Double command!! Set electronic volume (EV) level
|
||||
// Send next: 0 0 EV5 EV4 EV3 EV2 EV1 EV0 contrast 0-63
|
||||
const uint8_t ST7565_CMD_SET_EV = 0x81;
|
||||
// Control built-in power circuit ON/OFF - 0 0 1 0 1 VB VR VF
|
||||
// VB: Built-in Booster
|
||||
// VR: Built-in Regulator
|
||||
// VF: Built-in Follower
|
||||
const uint8_t ST7565_CMD_POWER_CIRCUIT = 0x28;
|
||||
// Set display start line 0-63
|
||||
// 0 0 0 1 S5 S4 S3 S2 S1 S0
|
||||
const uint8_t ST7565_CMD_SET_START_LINE = 0x40;
|
||||
// Display ON/OFF
|
||||
// 0 0 1 0 1 0 1 1 1 D
|
||||
// D=1, display ON
|
||||
// D=0, display OFF
|
||||
const uint8_t ST7565_CMD_DISPLAY_ON_OFF = 0xAE;
|
||||
|
||||
uint8_t cmds[] = {
|
||||
ST7565_CMD_BIAS_SELECT | 0, // Select bias setting: 1/9
|
||||
ST7565_CMD_COM_DIRECTION | (0 << 3), // Set output direction of COM: normal
|
||||
ST7565_CMD_SEG_DIRECTION | 1, // Set scan direction of SEG: reverse
|
||||
ST7565_CMD_INVERSE_DISPLAY | 0, // Inverse Display: false
|
||||
ST7565_CMD_ALL_PIXEL_ON | 0, // All Pixel ON: false - normal display
|
||||
ST7565_CMD_REGULATION_RATIO | (4 << 0), // Regulation Ratio 5.0
|
||||
|
||||
ST7565_CMD_SET_EV, // Set contrast
|
||||
31,
|
||||
|
||||
ST7565_CMD_POWER_CIRCUIT | 0b111, // Built-in power circuit ON/OFF: VB=1 VR=1 VF=1
|
||||
ST7565_CMD_SET_START_LINE | 0, // Set Start Line: 0
|
||||
ST7565_CMD_DISPLAY_ON_OFF | 1, // Display ON/OFF: ON
|
||||
};
|
||||
|
||||
void ST7565_Init(void)
|
||||
{
|
||||
SPI0_Init();
|
||||
|
||||
ST7565_Configure_GPIO_B11();
|
||||
|
||||
ST7565_HardwareReset();
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
ST7565_WriteByte(0xE2); // internal reset
|
||||
|
||||
ST7565_WriteByte(ST7565_CMD_SOFTWARE_RESET); // software reset
|
||||
SYSTEM_DelayMs(120);
|
||||
|
||||
ST7565_WriteByte(0xA2); // bias 9
|
||||
ST7565_WriteByte(0xC0); // com normal
|
||||
ST7565_WriteByte(0xA1); // reverse ?
|
||||
|
||||
ST7565_WriteByte(0xA6); // normal screen ?
|
||||
// ST7565_WriteByte(0xA7); // inverse screen ?
|
||||
|
||||
ST7565_WriteByte(0xA4); // all points normal
|
||||
ST7565_WriteByte(0x24); //
|
||||
ST7565_WriteByte(0x81); // volume first ?
|
||||
ST7565_WriteByte(0x1f); // contrast ?
|
||||
ST7565_WriteByte(0x2B); // power control ?
|
||||
for(uint8_t i = 0; i < 8; i++)
|
||||
ST7565_WriteByte(cmds[i]);
|
||||
|
||||
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b011); // VB=0 VR=1 VF=1
|
||||
SYSTEM_DelayMs(1);
|
||||
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b110); // VB=1 VR=1 VF=0
|
||||
SYSTEM_DelayMs(1);
|
||||
|
||||
ST7565_WriteByte(0x2E); // power control ?
|
||||
|
||||
SYSTEM_DelayMs(1);
|
||||
|
||||
ST7565_WriteByte(0x2F); //
|
||||
ST7565_WriteByte(0x2F); //
|
||||
ST7565_WriteByte(0x2F); //
|
||||
ST7565_WriteByte(0x2F); //
|
||||
for(uint8_t i = 0; i < 4; i++) // why 4 times?
|
||||
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b111); // VB=1 VR=1 VF=1
|
||||
|
||||
SYSTEM_DelayMs(40);
|
||||
|
||||
ST7565_WriteByte(0x40); // start line ?
|
||||
ST7565_WriteByte(0xAF); // display on ?
|
||||
|
||||
|
||||
ST7565_WriteByte(ST7565_CMD_SET_START_LINE | 0); // line 0
|
||||
ST7565_WriteByte(ST7565_CMD_DISPLAY_ON_OFF | 1); // D=1
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
|
||||
ST7565_FillScreen(0x00);
|
||||
}
|
||||
|
||||
void ST7565_Configure_GPIO_B11(void)
|
||||
void ST7565_FixInterfGlitch(void)
|
||||
{
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
for(uint8_t i = 0; i < ARRAY_SIZE(cmds); i++)
|
||||
ST7565_WriteByte(cmds[i]);
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
SPI_ToggleMasterMode(&SPI0->CR, true);
|
||||
}
|
||||
|
||||
void ST7565_HardwareReset(void)
|
||||
{
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_RES);
|
||||
SYSTEM_DelayMs(1);
|
||||
|
||||
@@ -22,16 +22,19 @@
|
||||
|
||||
#define LCD_WIDTH 128
|
||||
#define LCD_HEIGHT 64
|
||||
#define FRAME_LINES 7
|
||||
|
||||
extern uint8_t gStatusLine[128];
|
||||
extern uint8_t gFrameBuffer[7][128];
|
||||
extern uint8_t gStatusLine[LCD_WIDTH];
|
||||
extern uint8_t gFrameBuffer[FRAME_LINES][LCD_WIDTH];
|
||||
|
||||
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap);
|
||||
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const uint8_t *pBitmap, const unsigned int Size);
|
||||
void ST7565_BlitFullScreen(void);
|
||||
void ST7565_BlitLine(unsigned line);
|
||||
void ST7565_BlitStatusLine(void);
|
||||
void ST7565_FillScreen(uint8_t Value);
|
||||
void ST7565_Init(void);
|
||||
void ST7565_Configure_GPIO_B11(void);
|
||||
void ST7565_FixInterfGlitch(void);
|
||||
void ST7565_HardwareReset(void);
|
||||
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
|
||||
void ST7565_WriteByte(uint8_t Value);
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bsp/dp32g030/pmu.h"
|
||||
#include "bsp/dp32g030/syscon.h"
|
||||
#include "driver/system.h"
|
||||
#include "driver/systick.h"
|
||||
#include "../bsp/dp32g030/pmu.h"
|
||||
#include "../bsp/dp32g030/syscon.h"
|
||||
#include "system.h"
|
||||
#include "systick.h"
|
||||
|
||||
void SYSTEM_DelayMs(uint32_t Delay)
|
||||
{
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
#include "ARMCM0.h"
|
||||
#include "driver/systick.h"
|
||||
#include "misc.h"
|
||||
#include "systick.h"
|
||||
#include "../misc.h"
|
||||
|
||||
// 0x20000324
|
||||
static uint32_t gTickMultiplier;
|
||||
@@ -29,26 +29,21 @@ void SYSTICK_Init(void)
|
||||
|
||||
void SYSTICK_DelayUs(uint32_t Delay)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t Start;
|
||||
uint32_t Previous;
|
||||
uint32_t Current;
|
||||
uint32_t Delta;
|
||||
|
||||
i = 0;
|
||||
Start = SysTick->LOAD;
|
||||
Previous = SysTick->VAL;
|
||||
const uint32_t ticks = Delay * gTickMultiplier;
|
||||
uint32_t elapsed_ticks = 0;
|
||||
uint32_t Start = SysTick->LOAD;
|
||||
uint32_t Previous = SysTick->VAL;
|
||||
do {
|
||||
uint32_t Current;
|
||||
|
||||
do {
|
||||
Current = SysTick->VAL;
|
||||
} while (Current == Previous);
|
||||
if (Current < Previous) {
|
||||
Delta = -Current;
|
||||
} else {
|
||||
Delta = Start - Current;
|
||||
}
|
||||
i += Delta + Previous;
|
||||
Previous = Current;
|
||||
} while (i < Delay * gTickMultiplier);
|
||||
}
|
||||
|
||||
uint32_t Delta = ((Current < Previous) ? - Current : Start - Current);
|
||||
|
||||
elapsed_ticks += Delta + Previous;
|
||||
|
||||
Previous = Current;
|
||||
} while (elapsed_ticks < ticks);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ SECTIONS
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text.isr) /* .text sections of code */
|
||||
KEEP(*(.text.isr)) /* .text sections of code */
|
||||
*(.text) /* .text sections of code */
|
||||
*(.text*) /* .text* sections of code */
|
||||
*(.rodata) /* .rodata sections */
|
||||
|
||||
698
font.c
@@ -16,105 +16,204 @@
|
||||
|
||||
#include "font.h"
|
||||
|
||||
//const uint8_t gFontBig[95][16] =
|
||||
const uint8_t gFontBig[95][15] =
|
||||
// removed last and middle column which was all 0x00
|
||||
// also the space char is not needed
|
||||
const uint8_t gFontBig[95 - 1][16 - 2] =
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // ' '
|
||||
{0x00, 0x00, 0x70, 0xF8, 0xF8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00}, // , 0x00}, // '!'
|
||||
{0x00, 0x1E, 0x3E, 0x00, 0x00, 0x3E, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '"'
|
||||
{0x40, 0xF0, 0xF0, 0x40, 0xF0, 0xF0, 0x40, 0x00, 0x04, 0x1F, 0x1F, 0x04, 0x1F, 0x1F, 0x04}, // , 0x00}, // '#'
|
||||
{0x70, 0xF8, 0x88, 0x8F, 0x8F, 0x98, 0x30, 0x00, 0x06, 0x0C, 0x08, 0x38, 0x38, 0x0F, 0x07}, // , 0x00}, // '$'
|
||||
{0x60, 0x60, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x00, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x18, 0x18}, // , 0x00}, // '%'
|
||||
{0x00, 0xB0, 0xF8, 0xC8, 0x78, 0xB0, 0x80, 0x00, 0x0F, 0x1F, 0x10, 0x11, 0x0F, 0x1F, 0x10}, // , 0x00}, // '&'
|
||||
{0x00, 0x20, 0x3E, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '''
|
||||
{0x00, 0x00, 0xE0, 0xF0, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x00}, // , 0x00}, // '('
|
||||
{0x00, 0x00, 0x08, 0x18, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x10, 0x18, 0x0F, 0x07, 0x00}, // , 0x00}, // ')'
|
||||
{0x00, 0x40, 0xC0, 0x80, 0x80, 0xC0, 0x40, 0x00, 0x01, 0x05, 0x07, 0x03, 0x03, 0x07, 0x05}, // , 0x01}, // '*'
|
||||
{0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x07, 0x07, 0x01, 0x01}, // , 0x00}, // '+'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3C, 0x1C, 0x00, 0x00}, // , 0x00}, // ','
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, // , 0x00}, // '-'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00}, // , 0x00}, // '.'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x00, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00}, // , 0x00}, // '/'
|
||||
{0xF0, 0xF8, 0x08, 0x88, 0x48, 0xF8, 0xF0, 0x00, 0x0F, 0x1F, 0x12, 0x11, 0x10, 0x1F, 0x0F}, // , 0x00}, // '0'
|
||||
{0x00, 0x20, 0x30, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x10, 0x10}, // , 0x00}, // '1'
|
||||
{0x10, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x30, 0x00, 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x18}, // , 0x00}, // '2'
|
||||
{0x10, 0x18, 0x88, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x08, 0x18, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '3'
|
||||
{0x80, 0xC0, 0x60, 0x30, 0xF8, 0xF8, 0x00, 0x00, 0x01, 0x01, 0x01, 0x11, 0x1F, 0x1F, 0x11}, // , 0x00}, // '4'
|
||||
{0xF8, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x08, 0x00, 0x08, 0x18, 0x10, 0x10, 0x11, 0x1F, 0x0F}, // , 0x00}, // '5'
|
||||
{0xE0, 0xF0, 0x98, 0x88, 0x88, 0x80, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '6'
|
||||
{0x18, 0x18, 0x08, 0x08, 0x88, 0xF8, 0x78, 0x00, 0x00, 0x00, 0x1E, 0x1F, 0x01, 0x00, 0x00}, // , 0x00}, // '7'
|
||||
{0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '8'
|
||||
{0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0xF0, 0x00, 0x00, 0x10, 0x10, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // '9'
|
||||
{0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00}, // , 0x00}, // ':'
|
||||
{0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1C, 0x0C, 0x00, 0x00}, // , 0x00}, // ';'
|
||||
{0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x10}, // , 0x00}, // '<'
|
||||
{0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04}, // , 0x00}, // '='
|
||||
{0x00, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x10, 0x18, 0x0C, 0x06, 0x03, 0x01}, // , 0x00}, // '>'
|
||||
{0x30, 0x38, 0x08, 0x88, 0xC8, 0x78, 0x30, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00}, // , 0x00}, // '?'
|
||||
{0xE0, 0xF0, 0x10, 0x90, 0x90, 0xF0, 0xE0, 0x00, 0x0F, 0x1F, 0x10, 0x17, 0x17, 0x17, 0x03}, // , 0x00}, // '@'
|
||||
{0xC0, 0xE0, 0x30, 0x18, 0x30, 0xE0, 0xC0, 0x00, 0x1F, 0x1F, 0x01, 0x01, 0x01, 0x1F, 0x1F}, // , 0x00}, // 'A'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'B'
|
||||
{0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x10, 0x18, 0x0C}, // , 0x00}, // 'C'
|
||||
{0x08, 0xF8, 0xF8, 0x08, 0x18, 0xF0, 0xE0, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // 'D'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x11, 0x18, 0x1C}, // , 0x00}, // 'E'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x01, 0x00, 0x00}, // , 0x00}, // 'F'
|
||||
{0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, 0x00, 0x07, 0x0F, 0x18, 0x11, 0x11, 0x0F, 0x1F}, // , 0x00}, // 'G'
|
||||
{0xF8, 0xF8, 0x80, 0x80, 0x80, 0xF8, 0xF8, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'H'
|
||||
{0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'I'
|
||||
{0x00, 0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, 0x00, 0x0E, 0x1E, 0x10, 0x10, 0x1F, 0x0F, 0x00}, // , 0x00}, // 'J'
|
||||
{0x08, 0xF8, 0xF8, 0x80, 0xE0, 0x78, 0x18, 0x00, 0x10, 0x1F, 0x1F, 0x01, 0x03, 0x1E, 0x1C}, // , 0x00}, // 'K'
|
||||
{0x08, 0xF8, 0xF8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x18, 0x1C}, // , 0x00}, // 'L'
|
||||
{0xF8, 0xF8, 0x70, 0xE0, 0x70, 0xF8, 0xF8, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'M'
|
||||
{0xF8, 0xF8, 0x70, 0xE0, 0xC0, 0xF8, 0xF8, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x01, 0x1F, 0x1F}, // , 0x00}, // 'N'
|
||||
{0xE0, 0xF0, 0x18, 0x08, 0x18, 0xF0, 0xE0, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // 'O'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00}, // , 0x00}, // 'P'
|
||||
{0xF0, 0xF8, 0x08, 0x08, 0x08, 0xF8, 0xF0, 0x00, 0x0F, 0x1F, 0x10, 0x1C, 0x78, 0x7F, 0x4F}, // , 0x00}, // 'Q'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x10, 0x1F, 0x1F, 0x00, 0x01, 0x1F, 0x1E}, // , 0x00}, // 'R'
|
||||
{0x30, 0x78, 0xC8, 0x88, 0x88, 0x38, 0x30, 0x00, 0x0C, 0x1C, 0x10, 0x10, 0x11, 0x1F, 0x0E}, // , 0x00}, // 'S'
|
||||
{0x00, 0x38, 0x18, 0xF8, 0xF8, 0x18, 0x38, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'T'
|
||||
{0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'U'
|
||||
{0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x03, 0x07, 0x0C, 0x18, 0x0C, 0x07, 0x03}, // , 0x00}, // 'V'
|
||||
{0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x07, 0x1F, 0x1C, 0x07, 0x1C, 0x1F, 0x07}, // , 0x00}, // 'W'
|
||||
{0x18, 0x78, 0xE0, 0x80, 0xE0, 0x78, 0x18, 0x00, 0x18, 0x1E, 0x07, 0x01, 0x07, 0x1E, 0x18}, // , 0x00}, // 'X'
|
||||
{0x00, 0x78, 0xF8, 0x80, 0x80, 0xF8, 0x78, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'Y'
|
||||
{0x38, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x38, 0x00, 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x1C}, // , 0x00}, // 'Z'
|
||||
{0x00, 0x00, 0xF8, 0xF8, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x10, 0x10, 0x00}, // , 0x00}, // '['
|
||||
{0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0E, 0x1C}, // , 0x00}, // '"\'
|
||||
{0x00, 0x00, 0x08, 0x08, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x00}, // , 0x00}, // ']'
|
||||
{0x10, 0x18, 0x0E, 0x07, 0x0E, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '^'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}, // , 0x40}, // '_'
|
||||
{0x00, 0x00, 0x07, 0x0F, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '`'
|
||||
{0x00, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x0E, 0x1F, 0x11, 0x11, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'a'
|
||||
{0x08, 0xF8, 0xF8, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x10, 0x1F, 0x0F, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'b'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x18, 0x08}, // , 0x00}, // 'c'
|
||||
{0x00, 0x80, 0xC0, 0x48, 0xF8, 0xF8, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'd'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x0F, 0x1F, 0x11, 0x11, 0x11, 0x19, 0x09}, // , 0x00}, // 'e'
|
||||
{0x80, 0xF0, 0xF8, 0x88, 0x18, 0x30, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00}, // , 0x00}, // 'f'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, 0x00, 0x4F, 0xDF, 0x90, 0x90, 0xFF, 0x7F, 0x00}, // , 0x00}, // 'g'
|
||||
{0x08, 0xF8, 0xF8, 0x80, 0x40, 0xC0, 0x80, 0x00, 0x10, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'h'
|
||||
{0x00, 0x00, 0x40, 0xD8, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'i'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x40, 0xD8, 0xD8, 0x00, 0x00, 0x60, 0xE0, 0x80, 0x80, 0xFF, 0x7F}, // , 0x00}, // 'j'
|
||||
{0x08, 0xF8, 0xF8, 0x00, 0x80, 0xC0, 0x40, 0x00, 0x10, 0x1F, 0x1F, 0x03, 0x07, 0x1C, 0x18}, // , 0x00}, // 'k'
|
||||
{0x00, 0x00, 0x08, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'l'
|
||||
{0xC0, 0xC0, 0xC0, 0x80, 0xC0, 0xC0, 0x80, 0x00, 0x1F, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'm'
|
||||
{0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'n'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'o'
|
||||
{0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x80, 0xFF, 0xFF, 0x90, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'p'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, 0x00, 0x0F, 0x1F, 0x10, 0x90, 0xFF, 0xFF, 0x80}, // , 0x00}, // 'q'
|
||||
{0x40, 0xC0, 0x80, 0xC0, 0x40, 0xC0, 0x80, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x01}, // , 0x00}, // 'r'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x08, 0x19, 0x13, 0x12, 0x16, 0x1C, 0x08}, // , 0x00}, // 's'
|
||||
{0x40, 0x40, 0xF0, 0xF8, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x18, 0x08}, // , 0x00}, // 't'
|
||||
{0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'u'
|
||||
{0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x07, 0x0F, 0x18, 0x18, 0x0F, 0x07}, // , 0x00}, // 'v'
|
||||
{0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x0F, 0x1F, 0x18, 0x0E, 0x18, 0x1F, 0x0F}, // , 0x00}, // 'w'
|
||||
{0x40, 0xC0, 0x80, 0x00, 0x80, 0xC0, 0x40, 0x00, 0x10, 0x18, 0x0F, 0x07, 0x0F, 0x18, 0x10}, // , 0x00}, // 'x'
|
||||
{0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x8F, 0x9F, 0x90, 0x90, 0xD0, 0x7F, 0x3F}, // , 0x00}, // 'y'
|
||||
{0xC0, 0xC0, 0x40, 0x40, 0xC0, 0xC0, 0x40, 0x00, 0x18, 0x1C, 0x16, 0x13, 0x11, 0x18, 0x18}, // , 0x00}, // 'z'
|
||||
{0x00, 0x80, 0x80, 0xF0, 0x78, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10}, // , 0x00}, // '{'
|
||||
{0x00, 0x00, 0x00, 0x78, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00}, // , 0x00}, // '|'
|
||||
{0x00, 0x08, 0x08, 0x78, 0xF0, 0x80, 0x80, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00}, // , 0x00}, // '}'
|
||||
{0x10, 0x18, 0x08, 0x18, 0x10, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // , 0x00} // '->'
|
||||
};
|
||||
#if 0
|
||||
// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // ' '
|
||||
{0x00, 0x00, 0x70, 0xF8, 0xF8, 0x70, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00}, // , 0x00}, // '!'
|
||||
{0x00, 0x1E, 0x3E, 0x00, 0x00, 0x3E, 0x1E, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '"'
|
||||
{0x40, 0xF0, 0xF0, 0x40, 0xF0, 0xF0, 0x40, /*0x00,*/ 0x04, 0x1F, 0x1F, 0x04, 0x1F, 0x1F, 0x04}, // , 0x00}, // '#'
|
||||
{0x70, 0xF8, 0x88, 0x8F, 0x8F, 0x98, 0x30, /*0x00,*/ 0x06, 0x0C, 0x08, 0x38, 0x38, 0x0F, 0x07}, // , 0x00}, // '$'
|
||||
{0x60, 0x60, 0x00, 0x00, 0x80, 0xC0, 0x60, /*0x00,*/ 0x18, 0x0C, 0x06, 0x03, 0x01, 0x18, 0x18}, // , 0x00}, // '%'
|
||||
{0x00, 0xB0, 0xF8, 0xC8, 0x78, 0xB0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x11, 0x0F, 0x1F, 0x10}, // , 0x00}, // '&'
|
||||
{0x00, 0x20, 0x3E, 0x1E, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '''
|
||||
{0x00, 0x00, 0xE0, 0xF0, 0x18, 0x08, 0x00, /*0x00,*/ 0x00, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x00}, // , 0x00}, // '('
|
||||
{0x00, 0x00, 0x08, 0x18, 0xF0, 0xE0, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x18, 0x0F, 0x07, 0x00}, // , 0x00}, // ')'
|
||||
{0x00, 0x40, 0xC0, 0x80, 0x80, 0xC0, 0x40, /*0x00,*/ 0x01, 0x05, 0x07, 0x03, 0x03, 0x07, 0x05}, // , 0x01}, // '*'
|
||||
{0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, /*0x00,*/ 0x00, 0x01, 0x01, 0x07, 0x07, 0x01, 0x01}, // , 0x00}, // '+'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x20, 0x3C, 0x1C, 0x00, 0x00}, // , 0x00}, // ','
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, // , 0x00}, // '-'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00}, // , 0x00}, // '.'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, /*0x00,*/ 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00}, // , 0x00}, // '/'
|
||||
{0xF0, 0xF8, 0x08, 0x88, 0x48, 0xF8, 0xF0, /*0x00,*/ 0x0F, 0x1F, 0x12, 0x11, 0x10, 0x1F, 0x0F}, // , 0x00}, // '0'
|
||||
{0x00, 0x20, 0x30, 0xF8, 0xF8, 0x00, 0x00, /*0x00,*/ 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x10, 0x10}, // , 0x00}, // '1'
|
||||
{0x10, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x30, /*0x00,*/ 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x18}, // , 0x00}, // '2'
|
||||
{0x10, 0x18, 0x88, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x08, 0x18, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '3'
|
||||
{0x80, 0xC0, 0x60, 0x30, 0xF8, 0xF8, 0x00, /*0x00,*/ 0x01, 0x01, 0x01, 0x11, 0x1F, 0x1F, 0x11}, // , 0x00}, // '4'
|
||||
{0xF8, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x08, /*0x00,*/ 0x08, 0x18, 0x10, 0x10, 0x11, 0x1F, 0x0F}, // , 0x00}, // '5'
|
||||
{0xE0, 0xF0, 0x98, 0x88, 0x88, 0x80, 0x00, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '6'
|
||||
{0x18, 0x18, 0x08, 0x08, 0x88, 0xF8, 0x78, /*0x00,*/ 0x00, 0x00, 0x1E, 0x1F, 0x01, 0x00, 0x00}, // , 0x00}, // '7'
|
||||
{0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '8'
|
||||
{0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0xF0, /*0x00,*/ 0x00, 0x10, 0x10, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // '9'
|
||||
{0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00}, // , 0x00}, // ':'
|
||||
{0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1C, 0x0C, 0x00, 0x00}, // , 0x00}, // ';'
|
||||
{0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, /*0x00,*/ 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x10}, // , 0x00}, // '<'
|
||||
{0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /*0x00,*/ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04}, // , 0x00}, // '='
|
||||
{0x00, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, /*0x00,*/ 0x00, 0x10, 0x18, 0x0C, 0x06, 0x03, 0x01}, // , 0x00}, // '>'
|
||||
{0x30, 0x38, 0x08, 0x88, 0xC8, 0x78, 0x30, /*0x00,*/ 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00}, // , 0x00}, // '?'
|
||||
{0xE0, 0xF0, 0x10, 0x90, 0x90, 0xF0, 0xE0, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x17, 0x17, 0x17, 0x03}, // , 0x00}, // '@'
|
||||
{0xC0, 0xE0, 0x30, 0x18, 0x30, 0xE0, 0xC0, /*0x00,*/ 0x1F, 0x1F, 0x01, 0x01, 0x01, 0x1F, 0x1F}, // , 0x00}, // 'A'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'B'
|
||||
{0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, /*0x00,*/ 0x07, 0x0F, 0x18, 0x10, 0x10, 0x18, 0x0C}, // , 0x00}, // 'C'
|
||||
{0x08, 0xF8, 0xF8, 0x08, 0x18, 0xF0, 0xE0, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // 'D'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x11, 0x18, 0x1C}, // , 0x00}, // 'E'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x01, 0x00, 0x00}, // , 0x00}, // 'F'
|
||||
{0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, /*0x00,*/ 0x07, 0x0F, 0x18, 0x11, 0x11, 0x0F, 0x1F}, // , 0x00}, // 'G'
|
||||
{0xF8, 0xF8, 0x80, 0x80, 0x80, 0xF8, 0xF8, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'H'
|
||||
{0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'I'
|
||||
{0x00, 0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, /*0x00,*/ 0x0E, 0x1E, 0x10, 0x10, 0x1F, 0x0F, 0x00}, // , 0x00}, // 'J'
|
||||
{0x08, 0xF8, 0xF8, 0x80, 0xE0, 0x78, 0x18, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x01, 0x03, 0x1E, 0x1C}, // , 0x00}, // 'K'
|
||||
{0x08, 0xF8, 0xF8, 0x08, 0x00, 0x00, 0x00, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x18, 0x1C}, // , 0x00}, // 'L'
|
||||
{0xF8, 0xF8, 0x70, 0xE0, 0x70, 0xF8, 0xF8, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'M'
|
||||
{0xF8, 0xF8, 0x70, 0xE0, 0xC0, 0xF8, 0xF8, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x00, 0x01, 0x1F, 0x1F}, // , 0x00}, // 'N'
|
||||
{0xE0, 0xF0, 0x18, 0x08, 0x18, 0xF0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x18, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // 'O'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00}, // , 0x00}, // 'P'
|
||||
{0xF0, 0xF8, 0x08, 0x08, 0x08, 0xF8, 0xF0, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x1C, 0x78, 0x7F, 0x4F}, // , 0x00}, // 'Q'
|
||||
{0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x00, 0x01, 0x1F, 0x1E}, // , 0x00}, // 'R'
|
||||
{0x30, 0x78, 0xC8, 0x88, 0x88, 0x38, 0x30, /*0x00,*/ 0x0C, 0x1C, 0x10, 0x10, 0x11, 0x1F, 0x0E}, // , 0x00}, // 'S'
|
||||
{0x00, 0x38, 0x18, 0xF8, 0xF8, 0x18, 0x38, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'T'
|
||||
{0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'U'
|
||||
{0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, /*0x00,*/ 0x03, 0x07, 0x0C, 0x18, 0x0C, 0x07, 0x03}, // , 0x00}, // 'V'
|
||||
{0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, /*0x00,*/ 0x07, 0x1F, 0x1C, 0x07, 0x1C, 0x1F, 0x07}, // , 0x00}, // 'W'
|
||||
{0x18, 0x78, 0xE0, 0x80, 0xE0, 0x78, 0x18, /*0x00,*/ 0x18, 0x1E, 0x07, 0x01, 0x07, 0x1E, 0x18}, // , 0x00}, // 'X'
|
||||
{0x00, 0x78, 0xF8, 0x80, 0x80, 0xF8, 0x78, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'Y'
|
||||
{0x38, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x38, /*0x00,*/ 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x1C}, // , 0x00}, // 'Z'
|
||||
{0x00, 0x00, 0xF8, 0xF8, 0x08, 0x08, 0x00, /*0x00,*/ 0x00, 0x00, 0x1F, 0x1F, 0x10, 0x10, 0x00}, // , 0x00}, // '['
|
||||
{0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x01, 0x03, 0x07, 0x0E, 0x1C}, // , 0x00}, // '"\'
|
||||
{0x00, 0x00, 0x08, 0x08, 0xF8, 0xF8, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x00}, // , 0x00}, // ']'
|
||||
{0x10, 0x18, 0x0E, 0x07, 0x0E, 0x18, 0x10, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '^'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}, // , 0x40}, // '_'
|
||||
{0x00, 0x00, 0x07, 0x0F, 0x08, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '`'
|
||||
{0x00, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, /*0x00,*/ 0x0E, 0x1F, 0x11, 0x11, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'a'
|
||||
{0x08, 0xF8, 0xF8, 0x40, 0xC0, 0x80, 0x00, /*0x00,*/ 0x10, 0x1F, 0x0F, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'b'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x18, 0x08}, // , 0x00}, // 'c'
|
||||
{0x00, 0x80, 0xC0, 0x48, 0xF8, 0xF8, 0x00, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'd'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x11, 0x11, 0x11, 0x19, 0x09}, // , 0x00}, // 'e'
|
||||
{0x80, 0xF0, 0xF8, 0x88, 0x18, 0x30, 0x00, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00}, // , 0x00}, // 'f'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, /*0x00,*/ 0x4F, 0xDF, 0x90, 0x90, 0xFF, 0x7F, 0x00}, // , 0x00}, // 'g'
|
||||
{0x08, 0xF8, 0xF8, 0x80, 0x40, 0xC0, 0x80, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'h'
|
||||
{0x00, 0x00, 0x40, 0xD8, 0xD8, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'i'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x40, 0xD8, 0xD8, /*0x00,*/ 0x00, 0x60, 0xE0, 0x80, 0x80, 0xFF, 0x7F}, // , 0x00}, // 'j'
|
||||
{0x08, 0xF8, 0xF8, 0x00, 0x80, 0xC0, 0x40, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x03, 0x07, 0x1C, 0x18}, // , 0x00}, // 'k'
|
||||
{0x00, 0x00, 0x08, 0xF8, 0xF8, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'l'
|
||||
{0xC0, 0xC0, 0xC0, 0x80, 0xC0, 0xC0, 0x80, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'm'
|
||||
{0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'n'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'o'
|
||||
{0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x80, 0xFF, 0xFF, 0x90, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'p'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x90, 0xFF, 0xFF, 0x80}, // , 0x00}, // 'q'
|
||||
{0x40, 0xC0, 0x80, 0xC0, 0x40, 0xC0, 0x80, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x01}, // , 0x00}, // 'r'
|
||||
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x08, 0x19, 0x13, 0x12, 0x16, 0x1C, 0x08}, // , 0x00}, // 's'
|
||||
{0x40, 0x40, 0xF0, 0xF8, 0x40, 0x40, 0x00, /*0x00,*/ 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x18, 0x08}, // , 0x00}, // 't'
|
||||
{0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'u'
|
||||
{0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, /*0x00,*/ 0x00, 0x07, 0x0F, 0x18, 0x18, 0x0F, 0x07}, // , 0x00}, // 'v'
|
||||
{0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, /*0x00,*/ 0x0F, 0x1F, 0x18, 0x0E, 0x18, 0x1F, 0x0F}, // , 0x00}, // 'w'
|
||||
{0x40, 0xC0, 0x80, 0x00, 0x80, 0xC0, 0x40, /*0x00,*/ 0x10, 0x18, 0x0F, 0x07, 0x0F, 0x18, 0x10}, // , 0x00}, // 'x'
|
||||
{0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, /*0x00,*/ 0x8F, 0x9F, 0x90, 0x90, 0xD0, 0x7F, 0x3F}, // , 0x00}, // 'y'
|
||||
{0xC0, 0xC0, 0x40, 0x40, 0xC0, 0xC0, 0x40, /*0x00,*/ 0x18, 0x1C, 0x16, 0x13, 0x11, 0x18, 0x18}, // , 0x00}, // 'z'
|
||||
{0x00, 0x80, 0x80, 0xF0, 0x78, 0x08, 0x08, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10}, // , 0x00}, // '{'
|
||||
{0x00, 0x00, 0x00, 0x78, 0x78, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00}, // , 0x00}, // '|'
|
||||
{0x00, 0x08, 0x08, 0x78, 0xF0, 0x80, 0x80, /*0x00,*/ 0x00, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00}, // , 0x00}, // '}'
|
||||
{0x10, 0x18, 0x08, 0x18, 0x10, 0x18, 0x08, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // , 0x00} // '->'
|
||||
#else
|
||||
// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ' '
|
||||
{0x00, 0x00, 0x00, 0xFC, 0xFC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00}, // '!'
|
||||
{0x00, 0x0F, 0x1F, 0x00, 0x00, 0x1F, 0x0F, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '"'
|
||||
{0x20, 0xF8, 0xF8, 0x20, 0xF8, 0xF8, 0x20, /*0x00,*/ 0x02, 0x0F, 0x0F, 0x02, 0x0F, 0x0F, 0x02}, // '#'
|
||||
{0x70, 0xF8, 0x88, 0x8E, 0x8E, 0x98, 0x10, /*0x00,*/ 0x04, 0x0C, 0x08, 0x38, 0x38, 0x0F, 0x07}, // '$'
|
||||
{0x30, 0x30, 0x00, 0x80, 0xC0, 0x60, 0x30, /*0x00,*/ 0x0C, 0x06, 0x03, 0x01, 0x00, 0x0C, 0x0C}, // '%'
|
||||
{0x80, 0xD8, 0x7C, 0xE4, 0xBC, 0xD8, 0x40, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x07, 0x0F, 0x08}, // '&'
|
||||
{0x00, 0x10, 0x1F, 0x0F, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '''
|
||||
{0x00, 0x00, 0xF0, 0xF8, 0x0C, 0x04, 0x00, /*0x00,*/ 0x00, 0x00, 0x03, 0x07, 0x0C, 0x08, 0x00}, // '('
|
||||
{0x00, 0x00, 0x04, 0x0C, 0xF8, 0xF0, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0C, 0x07, 0x03, 0x00}, // ')'
|
||||
{0x00, 0x80, 0xA0, 0xE0, 0xC0, 0xE0, 0xA0, /*0x80,*/ 0x00, 0x00, 0x02, 0x03, 0x01, 0x03, 0x02}, // '*'
|
||||
{0x00, 0x80, 0x80, 0xE0, 0xE0, 0x80, 0x80, /*0x00,*/ 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00}, // '+'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1E, 0x0E, 0x00, 0x00}, // ','
|
||||
{0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '-'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00}, // '.'
|
||||
{0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, /*0x00,*/ 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x00}, // '/'
|
||||
{0xF8, 0xFC, 0x84, 0xC4, 0x64, 0xFC, 0xF8, /*0x00,*/ 0x07, 0x0F, 0x09, 0x08, 0x08, 0x0F, 0x07}, // '0'
|
||||
{0x00, 0x10, 0x18, 0xFC, 0xFC, 0x00, 0x00, /*0x00,*/ 0x00, 0x08, 0x08, 0x0F, 0x0F, 0x08, 0x08}, // '1'
|
||||
{0x18, 0x1C, 0x04, 0x84, 0xC4, 0x7C, 0x38, /*0x00,*/ 0x0C, 0x0E, 0x0B, 0x09, 0x08, 0x08, 0x08}, // '2'
|
||||
{0x18, 0x1C, 0x44, 0x44, 0x44, 0xFC, 0xB8, /*0x00,*/ 0x06, 0x0E, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '3'
|
||||
{0x80, 0xC0, 0x60, 0x30, 0x18, 0xFC, 0xFC, /*0x00,*/ 0x01, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x0F}, // '4'
|
||||
{0x7C, 0x7C, 0x44, 0x44, 0x44, 0xC4, 0x84, /*0x00,*/ 0x04, 0x0C, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '5'
|
||||
{0xF0, 0xF8, 0x4C, 0x44, 0x44, 0xC4, 0x80, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '6'
|
||||
{0x04, 0x04, 0x04, 0x84, 0xE4, 0x7C, 0x1C, /*0x00,*/ 0x00, 0x00, 0x0E, 0x0F, 0x01, 0x00, 0x00}, // '7'
|
||||
{0xB8, 0xFC, 0x44, 0x44, 0x44, 0xFC, 0xB8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '8'
|
||||
{0x78, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0xF8, /*0x00,*/ 0x00, 0x08, 0x08, 0x08, 0x0C, 0x07, 0x03}, // '9'
|
||||
{0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00}, // ':'
|
||||
{0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0E, 0x06, 0x00, 0x00}, // ';'
|
||||
{0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x08, /*0x00,*/ 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x08}, // '<'
|
||||
{0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, /*0x00,*/ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}, // '='
|
||||
{0x00, 0x08, 0x18, 0x30, 0x60, 0xC0, 0x80, /*0x00,*/ 0x00, 0x08, 0x0C, 0x06, 0x03, 0x01, 0x00}, // '>'
|
||||
{0x38, 0x3C, 0x04, 0x84, 0xC4, 0x7C, 0x38, /*0x00,*/ 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00}, // '?'
|
||||
{0xF0, 0xF8, 0x08, 0xC8, 0xC8, 0xF8, 0xF0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x0B, 0x0B, 0x0B, 0x01}, // '@'
|
||||
{0xF8, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0xF8, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'A'
|
||||
{0xFC, 0xFC, 0x44, 0x44, 0x44, 0xFC, 0xB8, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'B'
|
||||
{0xF8, 0xFC, 0x04, 0x04, 0x04, 0x1C, 0x18, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0E, 0x06}, // 'C'
|
||||
{0xFC, 0xFC, 0x04, 0x04, 0x0C, 0xF8, 0xF0, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x0C, 0x07, 0x03}, // 'D'
|
||||
{0xFC, 0xFC, 0x44, 0x44, 0x44, 0x04, 0x04, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08}, // 'E'
|
||||
{0xFC, 0xFC, 0x44, 0x44, 0x44, 0x04, 0x04, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00}, // 'F'
|
||||
{0xF8, 0xFC, 0x04, 0x84, 0x84, 0x9C, 0x98, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'G'
|
||||
{0xFC, 0xFC, 0x40, 0x40, 0x40, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'H'
|
||||
{0x00, 0x00, 0x04, 0xFC, 0xFC, 0x04, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x00}, // 'I'
|
||||
{0x00, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x04, /*0x00,*/ 0x06, 0x0E, 0x08, 0x08, 0x0F, 0x07, 0x00}, // 'J'
|
||||
{0xFC, 0xFC, 0xE0, 0x30, 0x18, 0x0C, 0x04, /*0x00,*/ 0x0F, 0x0F, 0x01, 0x03, 0x06, 0x0C, 0x08}, // 'K'
|
||||
{0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08}, // 'L'
|
||||
{0xFC, 0xFC, 0x18, 0x70, 0x18, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'M'
|
||||
{0xFC, 0xFC, 0x60, 0xC0, 0x80, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x01, 0x0F, 0x0F}, // 'N'
|
||||
{0xF8, 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xF8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'O'
|
||||
{0xFC, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0x78, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00}, // 'P'
|
||||
{0xF8, 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xF8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x0C, 0x0C, 0x1F, 0x17}, // 'Q'
|
||||
{0xFC, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0x78, /*0x00,*/ 0x0F, 0x0F, 0x01, 0x03, 0x06, 0x0C, 0x08}, // 'R'
|
||||
{0x38, 0x7C, 0x44, 0x44, 0x44, 0xCC, 0x88, /*0x00,*/ 0x06, 0x0E, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'S'
|
||||
{0x00, 0x04, 0x04, 0xFC, 0xFC, 0x04, 0x04, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, // 'T'
|
||||
{0xFC, 0xFC, 0x00, 0x00, 0x00, 0xFC, 0xFC, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'U'
|
||||
{0x7C, 0xFC, 0x80, 0x00, 0x80, 0xFC, 0x7C, /*0x00,*/ 0x00, 0x03, 0x0F, 0x0C, 0x0F, 0x03, 0x00}, // 'V'
|
||||
{0xFC, 0xFC, 0x00, 0x80, 0x00, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x06, 0x03, 0x06, 0x0F, 0x0F}, // 'W'
|
||||
{0x0C, 0x3C, 0xF0, 0xC0, 0xF0, 0x3C, 0x0C, /*0x00,*/ 0x0C, 0x0F, 0x03, 0x00, 0x03, 0x0F, 0x0C}, // 'X'
|
||||
{0x00, 0x3C, 0x7C, 0xC0, 0xC0, 0x7C, 0x3C, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, // 'Y'
|
||||
{0x04, 0x04, 0x84, 0xC4, 0x64, 0x3C, 0x1C, /*0x00,*/ 0x0E, 0x0F, 0x09, 0x08, 0x08, 0x08, 0x08}, // 'Z'
|
||||
{0x00, 0x00, 0xFC, 0xFC, 0x04, 0x04, 0x00, /*0x00,*/ 0x00, 0x00, 0x0F, 0x0F, 0x08, 0x08, 0x00}, // '['
|
||||
{0x38, 0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0E}, // '"\'
|
||||
{0x00, 0x00, 0x04, 0x04, 0xFC, 0xFC, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x08, 0x0F, 0x0F, 0x00}, // ']'
|
||||
{0x08, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x08, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '^'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}, // '_'
|
||||
{0x00, 0x00, 0x03, 0x07, 0x04, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '`'
|
||||
{0x00, 0xA0, 0xA0, 0xA0, 0xA0, 0xE0, 0xC0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x0F}, // 'a'
|
||||
{0xFC, 0xFC, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'b'
|
||||
{0xC0, 0xE0, 0x20, 0x20, 0x20, 0x60, 0x40, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0C, 0x04}, // 'c'
|
||||
{0xC0, 0xE0, 0x20, 0x20, 0x20, 0xFC, 0xFC, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x0F}, // 'd'
|
||||
{0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x07, 0x0F, 0x09, 0x09, 0x09, 0x09, 0x01}, // 'e'
|
||||
{0x20, 0x20, 0xF8, 0xFC, 0x24, 0x24, 0x04, /*0x00,*/ 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00}, // 'f'
|
||||
{0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x4F, 0x48, 0x48, 0x48, 0x7F, 0x3F}, // 'g'
|
||||
{0xFC, 0xFC, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'h'
|
||||
{0x00, 0x00, 0x20, 0xEC, 0xEC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x00}, // 'i'
|
||||
{0x00, 0x00, 0x00, 0x00, 0x20, 0xEC, 0xEC, /*0x00,*/ 0x00, 0x30, 0x70, 0x40, 0x40, 0x7F, 0x3F}, // 'j'
|
||||
{0xFC, 0xFC, 0x00, 0x80, 0xC0, 0x60, 0x20, /*0x00,*/ 0x0F, 0x0F, 0x01, 0x03, 0x06, 0x0C, 0x08}, // 'k'
|
||||
{0x00, 0x00, 0x04, 0xFC, 0xFC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x00}, // 'l'
|
||||
{0xE0, 0xE0, 0x20, 0xE0, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x0F, 0x00, 0x0F, 0x0F}, // 'm'
|
||||
{0xE0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'n'
|
||||
{0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'o'
|
||||
{0xE0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x7F, 0x7F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'p'
|
||||
{0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x7F, 0x7F}, // 'q'
|
||||
{0xE0, 0xE0, 0x60, 0x20, 0x20, 0x20, 0x20, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00}, // 'r'
|
||||
{0xC0, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, /*0x00,*/ 0x08, 0x09, 0x09, 0x09, 0x09, 0x0F, 0x06}, // 's'
|
||||
{0x20, 0x20, 0xFC, 0xFC, 0x20, 0x20, 0x00, /*0x00,*/ 0x00, 0x00, 0x07, 0x0F, 0x08, 0x08, 0x08}, // 't'
|
||||
{0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x0F}, // 'u'
|
||||
{0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x00, 0x03, 0x0F, 0x0C, 0x0F, 0x03, 0x00}, // 'v'
|
||||
{0xE0, 0xE0, 0x00, 0x80, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x0F, 0x08, 0x0F, 0x07}, // 'w'
|
||||
{0x60, 0xE0, 0x80, 0x00, 0x80, 0xE0, 0x60, /*0x00,*/ 0x0C, 0x0E, 0x03, 0x01, 0x03, 0x0E, 0x0C}, // 'x'
|
||||
{0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x4F, 0x48, 0x48, 0x48, 0x7F, 0x3F}, // 'y'
|
||||
{0x20, 0x20, 0x20, 0xA0, 0xE0, 0x60, 0x20, /*0x00,*/ 0x0C, 0x0E, 0x0B, 0x09, 0x08, 0x08, 0x08}, // 'z'
|
||||
{0x00, 0x00, 0x40, 0xF8, 0xBC, 0x04, 0x04, /*0x00,*/ 0x00, 0x00, 0x00, 0x07, 0x0F, 0x08, 0x08}, // '{'
|
||||
{0x00, 0x00, 0x00, 0xBC, 0xBC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, // '|'
|
||||
{0x00, 0x04, 0x04, 0xBC, 0xF8, 0x40, 0x00, /*0x00,*/ 0x00, 0x08, 0x08, 0x0F, 0x07, 0x00, 0x00}, // '}'
|
||||
{0x08, 0x0C, 0x04, 0x0C, 0x08, 0x0C, 0x04, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // '->'
|
||||
#endif
|
||||
};
|
||||
|
||||
#if 0
|
||||
// original font
|
||||
@@ -132,21 +231,40 @@ const uint8_t gFontBig[95][15] =
|
||||
{0x00, 0xF0, 0xF8, 0xB8, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1C, 0xB8, 0xF0, 0xE0, 0x00, 0x11, 0x33, 0x77, 0x67, 0x66, 0x66, 0x66, 0x76, 0x33, 0x3F, 0x1F, 0x07},
|
||||
{0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00}
|
||||
};
|
||||
#else
|
||||
|
||||
// 6 Empty columns removed
|
||||
#elif 0
|
||||
// VCR font
|
||||
const uint8_t gFontBigDigits[11][26] =
|
||||
const uint8_t gFontBigDigits[11][26 - 6] =
|
||||
{
|
||||
{0x00, 0x00, 0xF8, 0xFC, 0x06, 0x86, 0xC6, 0xE6, 0xF6, 0x76, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x77, 0x67, 0x63, 0x61, 0x60, 0x70, 0x3F, 0x1F, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x18, 0x1C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x60, 0x60, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x18, 0x1C, 0x86, 0x86, 0x86, 0x86, 0x86, 0xC6, 0xFC, 0x78, 0x00, 0x00, 0x00, 0x7E, 0x7F, 0x63, 0x61, 0x61, 0x61, 0x61, 0x61, 0x60, 0x60, 0x00},
|
||||
{0x00, 0x00, 0x18, 0x1C, 0x06, 0x06, 0x86, 0x86, 0x86, 0xC6, 0xFC, 0x78, 0x00, 0x00, 0x00, 0x18, 0x38, 0x70, 0x60, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x1E, 0x00},
|
||||
{0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x7F, 0x7F, 0x06, 0x06, 0x00},
|
||||
{0x00, 0x00, 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x66, 0xE6, 0xC6, 0x86, 0x00, 0x00, 0x00, 0x18, 0x38, 0x70, 0x60, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x1F, 0x00},
|
||||
{0x00, 0x00, 0xF8, 0xFC, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x1C, 0x18, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x71, 0x61, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x1E, 0x00},
|
||||
{0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x86, 0xC6, 0xE6, 0x7E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x01, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x78, 0xFC, 0xC6, 0x86, 0x86, 0x86, 0x86, 0xC6, 0xFC, 0x78, 0x00, 0x00, 0x00, 0x1E, 0x3F, 0x73, 0x61, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x1E, 0x00},
|
||||
{0x00, 0x00, 0x78, 0xFC, 0xC6, 0x86, 0x86, 0x86, 0x86, 0x86, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x18, 0x38, 0x71, 0x61, 0x61, 0x61, 0x61, 0x71, 0x3F, 0x1F, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00}
|
||||
{/*0x00, 0x00,*/ 0xF8, 0xFC, 0x06, 0x86, 0xC6, 0xE6, 0xF6, 0x76, 0xFC, 0xF8, /*0x00,*/ /*0x00, 0x00,*/ 0x1F, 0x3F, 0x77, 0x67, 0x63, 0x61, 0x60, 0x70, 0x3F, 0x1F, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x00, 0x00, 0x18, 0x1C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x60, 0x60, 0x00, 0x00, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x18, 0x1C, 0x86, 0x86, 0x86, 0x86, 0x86, 0xC6, 0xFC, 0x78, /*0x00,*/ /*0x00, 0x00,*/ 0x7E, 0x7F, 0x63, 0x61, 0x61, 0x61, 0x61, 0x61, 0x60, 0x60, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x18, 0x1C, 0x06, 0x06, 0x86, 0x86, 0x86, 0xC6, 0xFC, 0x78, /*0x00,*/ /*0x00, 0x00,*/ 0x18, 0x38, 0x70, 0x60, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x1E, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x80, 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0xFE, 0xFE, 0x00, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x7F, 0x7F, 0x06, 0x06, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x66, 0xE6, 0xC6, 0x86, /*0x00,*/ /*0x00, 0x00,*/ 0x18, 0x38, 0x70, 0x60, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x1F, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0xF8, 0xFC, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x1C, 0x18, /*0x00,*/ /*0x00, 0x00,*/ 0x1F, 0x3F, 0x71, 0x61, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x1E, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x06, 0x06, 0x06, 0x06, 0x06, 0x86, 0xC6, 0xE6, 0x7E, 0x3E, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x01, 0x00, 0x00, 0x00, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x78, 0xFC, 0xC6, 0x86, 0x86, 0x86, 0x86, 0xC6, 0xFC, 0x78, /*0x00,*/ /*0x00, 0x00,*/ 0x1E, 0x3F, 0x73, 0x61, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x1E, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x78, 0xFC, 0xC6, 0x86, 0x86, 0x86, 0x86, 0x86, 0xFC, 0xF8, /*0x00,*/ /*0x00, 0x00,*/ 0x18, 0x38, 0x71, 0x61, 0x61, 0x61, 0x61, 0x71, 0x3F, 0x1F, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, /*0x00*/}
|
||||
};
|
||||
#else
|
||||
// Terminus font
|
||||
|
||||
const uint8_t gFontBigDigits[11][26 - 6] =
|
||||
{
|
||||
{/*0x00, 0x00,*/ 0xFC, 0xFE, 0xFE, 0x06, 0x86, 0xC6, 0xE6, 0xFE, 0xFE, 0xFC, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x67, 0x63, 0x61, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x00, 0x00, 0x18, 0x1C, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x7F, 0x60, 0x60, 0x00, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x1C, 0x1E, 0x1E, 0x06, 0x06, 0x06, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x60, 0x70, 0x78, 0x7C, 0x6E, 0x67, 0x63, 0x61, 0x60, 0x60, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x0C, 0x0E, 0x0E, 0x86, 0x86, 0x86, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x30, 0x70, 0x70, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0x3E, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x80, 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0x0E, 0xFE, 0xFE, 0xFE, /*0x00,*/ /*0x00, 0x00,*/ 0x0F, 0x0F, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x7F, 0x7F, 0x7F, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0xFE, 0xFE, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x86, /*0x00,*/ /*0x00, 0x00,*/ 0x30, 0x70, 0x70, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0xF8, 0xFC, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x80, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x0E, 0x0E, 0x0E, 0x06, 0x06, 0x86, 0xE6, 0xFE, 0x7E, 0x1E, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7F, 0x7F, 0x03, 0x00, 0x00, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x7C, 0xFE, 0xFE, 0x86, 0x86, 0x86, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0x3F, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0xFC, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0xFC, /*0x00,*/ /*0x00, 0x00,*/ 0x01, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x7F, 0x3F, 0x1F, /*0x00*/},
|
||||
{/*0x00, 0x00,*/ 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, /*0x00*/}
|
||||
};
|
||||
#endif
|
||||
/*
|
||||
@@ -165,177 +283,9 @@ const uint8_t gFontSmallDigits[11][7] =
|
||||
{0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00} // '-'
|
||||
};
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_SPECTRUM
|
||||
|
||||
const uint8_t gFont3x5[160][3] = {
|
||||
{0x00, 0x00, 0x00}, // 32 - space
|
||||
{0x00, 0x17, 0x00}, // 33 - exclam
|
||||
{0x03, 0x00, 0x03}, // 34 - quotedbl
|
||||
{0x1f, 0x0a, 0x1f}, // 35 - numbersign
|
||||
{0x0a, 0x1f, 0x05}, // 36 - dollar
|
||||
{0x09, 0x04, 0x12}, // 37 - percent
|
||||
{0x0f, 0x17, 0x1c}, // 38 - ampersand
|
||||
{0x00, 0x03, 0x00}, // 39 - quotesingle
|
||||
{0x00, 0x0e, 0x11}, // 40 - parenleft
|
||||
{0x11, 0x0e, 0x00}, // 41 - parenright
|
||||
{0x05, 0x02, 0x05}, // 42 - asterisk
|
||||
{0x04, 0x0e, 0x04}, // 43 - plus
|
||||
{0x10, 0x08, 0x00}, // 44 - comma
|
||||
{0x04, 0x04, 0x04}, // 45 - hyphen
|
||||
{0x00, 0x10, 0x00}, // 46 - period
|
||||
{0x18, 0x04, 0x03}, // 47 - slash
|
||||
{0x1e, 0x11, 0x0f}, // 48 - zero
|
||||
{0x02, 0x1f, 0x00}, // 49 - one
|
||||
{0x19, 0x15, 0x12}, // 50 - two
|
||||
{0x11, 0x15, 0x0a}, // 51 - three
|
||||
{0x07, 0x04, 0x1f}, // 52 - four
|
||||
{0x17, 0x15, 0x09}, // 53 - five
|
||||
{0x1e, 0x15, 0x1d}, // 54 - six
|
||||
{0x19, 0x05, 0x03}, // 55 - seven
|
||||
{0x1f, 0x15, 0x1f}, // 56 - eight
|
||||
{0x17, 0x15, 0x0f}, // 57 - nine
|
||||
{0x00, 0x0a, 0x00}, // 58 - colon
|
||||
{0x10, 0x0a, 0x00}, // 59 - semicolon
|
||||
{0x04, 0x0a, 0x11}, // 60 - less
|
||||
{0x0a, 0x0a, 0x0a}, // 61 - equal
|
||||
{0x11, 0x0a, 0x04}, // 62 - greater
|
||||
{0x01, 0x15, 0x03}, // 63 - question
|
||||
{0x0e, 0x15, 0x16}, // 64 - at
|
||||
{0x1e, 0x05, 0x1e}, // 65 - A
|
||||
{0x1f, 0x15, 0x0a}, // 66 - B
|
||||
{0x0e, 0x11, 0x11}, // 67 - C
|
||||
{0x1f, 0x11, 0x0e}, // 68 - D
|
||||
{0x1f, 0x15, 0x15}, // 69 - E
|
||||
{0x1f, 0x05, 0x05}, // 70 - F
|
||||
{0x0e, 0x15, 0x1d}, // 71 - G
|
||||
{0x1f, 0x04, 0x1f}, // 72 - H
|
||||
{0x11, 0x1f, 0x11}, // 73 - I
|
||||
{0x08, 0x10, 0x0f}, // 74 - J
|
||||
{0x1f, 0x04, 0x1b}, // 75 - K
|
||||
{0x1f, 0x10, 0x10}, // 76 - L
|
||||
{0x1f, 0x06, 0x1f}, // 77 - M
|
||||
{0x1f, 0x0e, 0x1f}, // 78 - N
|
||||
{0x0e, 0x11, 0x0e}, // 79 - O
|
||||
{0x1f, 0x05, 0x02}, // 80 - P
|
||||
{0x0e, 0x19, 0x1e}, // 81 - Q
|
||||
{0x1f, 0x0d, 0x16}, // 82 - R
|
||||
{0x12, 0x15, 0x09}, // 83 - S
|
||||
{0x01, 0x1f, 0x01}, // 84 - T
|
||||
{0x0f, 0x10, 0x1f}, // 85 - U
|
||||
{0x07, 0x18, 0x07}, // 86 - V
|
||||
{0x1f, 0x0c, 0x1f}, // 87 - W
|
||||
{0x1b, 0x04, 0x1b}, // 88 - X
|
||||
{0x03, 0x1c, 0x03}, // 89 - Y
|
||||
{0x19, 0x15, 0x13}, // 90 - Z
|
||||
{0x1f, 0x11, 0x11}, // 91 - bracketleft
|
||||
{0x02, 0x04, 0x08}, // 92 - backslash
|
||||
{0x11, 0x11, 0x1f}, // 93 - bracketright
|
||||
{0x02, 0x01, 0x02}, // 94 - asciicircum
|
||||
{0x10, 0x10, 0x10}, // 95 - underscore
|
||||
{0x01, 0x02, 0x00}, // 96 - grave
|
||||
{0x1a, 0x16, 0x1c}, // 97 - a
|
||||
{0x1f, 0x12, 0x0c}, // 98 - b
|
||||
{0x0c, 0x12, 0x12}, // 99 - c
|
||||
{0x0c, 0x12, 0x1f}, // 100 - d
|
||||
{0x0c, 0x1a, 0x16}, // 101 - e
|
||||
{0x04, 0x1e, 0x05}, // 102 - f
|
||||
{0x0c, 0x2a, 0x1e}, // 103 - g
|
||||
{0x1f, 0x02, 0x1c}, // 104 - h
|
||||
{0x00, 0x1d, 0x00}, // 105 - i
|
||||
{0x10, 0x20, 0x1d}, // 106 - j
|
||||
{0x1f, 0x0c, 0x12}, // 107 - k
|
||||
{0x11, 0x1f, 0x10}, // 108 - l
|
||||
{0x1e, 0x0e, 0x1e}, // 109 - m
|
||||
{0x1e, 0x02, 0x1c}, // 110 - n
|
||||
{0x0c, 0x12, 0x0c}, // 111 - o
|
||||
{0x3e, 0x12, 0x0c}, // 112 - p
|
||||
{0x0c, 0x12, 0x3e}, // 113 - q
|
||||
{0x1c, 0x02, 0x02}, // 114 - r
|
||||
{0x14, 0x1e, 0x0a}, // 115 - s
|
||||
{0x02, 0x1f, 0x12}, // 116 - t
|
||||
{0x0e, 0x10, 0x1e}, // 117 - u
|
||||
{0x0e, 0x18, 0x0e}, // 118 - v
|
||||
{0x1e, 0x1c, 0x1e}, // 119 - w
|
||||
{0x12, 0x0c, 0x12}, // 120 - x
|
||||
{0x06, 0x28, 0x1e}, // 121 - y
|
||||
{0x1a, 0x1e, 0x16}, // 122 - z
|
||||
{0x04, 0x1b, 0x11}, // 123 - braceleft
|
||||
{0x00, 0x1b, 0x00}, // 124 - bar
|
||||
{0x11, 0x1b, 0x04}, // 125 - braceright
|
||||
{0x02, 0x03, 0x01}, // 126 - asciitilde
|
||||
{0x00, 0x00, 0x00}, // 127 - empty
|
||||
{0x00, 0x00, 0x00}, // 128 - empty
|
||||
{0x00, 0x00, 0x00}, // 129 - empty
|
||||
{0x00, 0x00, 0x00}, // 130 - empty
|
||||
{0x00, 0x00, 0x00}, // 131 - empty
|
||||
{0x00, 0x00, 0x00}, // 132 - empty
|
||||
{0x00, 0x00, 0x00}, // 133 - empty
|
||||
{0x00, 0x00, 0x00}, // 134 - empty
|
||||
{0x00, 0x00, 0x00}, // 135 - empty
|
||||
{0x00, 0x00, 0x00}, // 136 - empty
|
||||
{0x00, 0x00, 0x00}, // 137 - empty
|
||||
{0x00, 0x00, 0x00}, // 138 - empty
|
||||
{0x00, 0x00, 0x00}, // 139 - empty
|
||||
{0x00, 0x00, 0x00}, // 140 - empty
|
||||
{0x00, 0x00, 0x00}, // 141 - empty
|
||||
{0x00, 0x00, 0x00}, // 142 - empty
|
||||
{0x00, 0x00, 0x00}, // 143 - empty
|
||||
{0x00, 0x00, 0x00}, // 144 - empty
|
||||
{0x00, 0x00, 0x00}, // 145 - empty
|
||||
{0x00, 0x00, 0x00}, // 146 - empty
|
||||
{0x00, 0x00, 0x00}, // 147 - empty
|
||||
{0x00, 0x00, 0x00}, // 148 - empty
|
||||
{0x00, 0x00, 0x00}, // 149 - empty
|
||||
{0x00, 0x00, 0x00}, // 150 - empty
|
||||
{0x00, 0x00, 0x00}, // 151 - empty
|
||||
{0x00, 0x00, 0x00}, // 152 - empty
|
||||
{0x00, 0x00, 0x00}, // 153 - empty
|
||||
{0x00, 0x00, 0x00}, // 154 - empty
|
||||
{0x00, 0x00, 0x00}, // 155 - empty
|
||||
{0x00, 0x00, 0x00}, // 156 - empty
|
||||
{0x00, 0x00, 0x00}, // 157 - empty
|
||||
{0x00, 0x00, 0x00}, // 158 - empty
|
||||
{0x00, 0x00, 0x00}, // 159 - empty
|
||||
{0x00, 0x00, 0x00}, // 160 - empty
|
||||
{0x00, 0x1d, 0x00}, // 161 - exclamdown
|
||||
{0x0e, 0x1b, 0x0a}, // 162 - cent
|
||||
{0x14, 0x1f, 0x15}, // 163 - sterling
|
||||
{0x15, 0x0e, 0x15}, // 164 - currency
|
||||
{0x0b, 0x1c, 0x0b}, // 165 - yen
|
||||
{0x00, 0x1b, 0x00}, // 166 - brokenbar
|
||||
{0x14, 0x1b, 0x05}, // 167 - section
|
||||
{0x01, 0x00, 0x01}, // 168 - dieresis
|
||||
{0x02, 0x05, 0x05}, // 169 - copyright
|
||||
{0x16, 0x15, 0x17}, // 170 - ordfeminine
|
||||
{0x02, 0x05, 0x00}, // 171 - guillemotleft
|
||||
{0x02, 0x02, 0x06}, // 172 - logicalnot
|
||||
{0x04, 0x04, 0x00}, // 173 - softhyphen
|
||||
{0x07, 0x03, 0x04}, // 174 - registered
|
||||
{0x01, 0x01, 0x01}, // 175 - macron
|
||||
{0x02, 0x05, 0x02}, // 176 - degree
|
||||
{0x12, 0x17, 0x12}, // 177 - plusminus
|
||||
{0x01, 0x07, 0x04}, // 178 - twosuperior
|
||||
{0x05, 0x07, 0x07}, // 179 - threesuperior
|
||||
{0x00, 0x02, 0x01}, // 180 - acute
|
||||
{0x1f, 0x08, 0x07}, // 181 - mu
|
||||
{0x02, 0x1d, 0x1f}, // 182 - paragraph
|
||||
{0x0e, 0x0e, 0x0e}, // 183 - periodcentered
|
||||
{0x10, 0x14, 0x08}, // 184 - cedilla
|
||||
{0x00, 0x07, 0x00}, // 185 - onesuperior
|
||||
{0x12, 0x15, 0x12}, // 186 - ordmasculine
|
||||
{0x00, 0x05, 0x02}, // 187 - guillemotright
|
||||
{0x03, 0x08, 0x18}, // 188 - onequarter
|
||||
{0x0b, 0x18, 0x10}, // 189 - onehalf
|
||||
{0x03, 0x0b, 0x18}, // 190 - threequarters
|
||||
{0x18, 0x15, 0x10}, // 191 - questiondown
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
const uint8_t gFontSmall[95][6] =
|
||||
const uint8_t gFontSmall[95-1][6] =
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ' '
|
||||
// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ' '
|
||||
{0x00, 0x00, 0x5E, 0x00, 0x00, 0x00}, // '!'
|
||||
{0x00, 0x06, 0x00, 0x06, 0x00, 0x00}, // '"'
|
||||
{0x14, 0x3E, 0x14, 0x3E, 0x14, 0x00}, // '#'
|
||||
@@ -433,9 +383,9 @@ const uint8_t gFontSmall[95][6] =
|
||||
};
|
||||
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
const uint8_t gFontSmallBold[95][6] =
|
||||
const uint8_t gFontSmallBold[95 - 1][6] =
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x5E, 0x5E, 0x00, 0x00},
|
||||
{0x06, 0x06, 0x00, 0x06, 0x06, 0x00},
|
||||
{0x14, 0x3E, 0x14, 0x3E, 0x14, 0x00},
|
||||
@@ -502,10 +452,10 @@ const uint8_t gFontSmall[95][6] =
|
||||
{0x00, 0x03, 0x07, 0x06, 0x00, 0x00},
|
||||
{0x20, 0x76, 0x56, 0x56, 0x7E, 0x3C},
|
||||
{0x7F, 0x7F, 0x6C, 0x6C, 0x7C, 0x38},
|
||||
{0x3C, 0x7E, 0x66, 0x66, 0x66, 0x24},
|
||||
{0x38, 0x7C, 0x6C, 0x6C, 0x6C, 0x00},
|
||||
{0x38, 0x7C, 0x6C, 0x6C, 0x7F, 0x7F},
|
||||
{0x3C, 0x7E, 0x56, 0x56, 0x5E, 0x0C},
|
||||
{0x7C, 0x7E, 0x36, 0x36, 0x06, 0x00},
|
||||
{0x7E, 0x7F, 0x1B, 0x1B, 0x02, 0x00},
|
||||
{0x0C, 0x5E, 0x56, 0x56, 0x7E, 0x3C},
|
||||
{0x7F, 0x7F, 0x0C, 0x0C, 0x7C, 0x78},
|
||||
{0x00, 0x00, 0x7A, 0x7A, 0x00, 0x00},
|
||||
@@ -516,7 +466,7 @@ const uint8_t gFontSmall[95][6] =
|
||||
{0x7C, 0x7C, 0x0C, 0x0C, 0x7C, 0x78},
|
||||
{0x3C, 0x7E, 0x66, 0x66, 0x7E, 0x3C},
|
||||
{0x7E, 0x7E, 0x36, 0x36, 0x3E, 0x1C},
|
||||
{0x1C, 0x3E, 0x36, 0x3E, 0x7E, 0x40},
|
||||
{0x1C, 0x3E, 0x36, 0x7E, 0x7E, 0x60},
|
||||
{0x7C, 0x7C, 0x0C, 0x0C, 0x18, 0x00},
|
||||
{0x4C, 0x5E, 0x56, 0x56, 0x76, 0x20},
|
||||
{0x3F, 0x7F, 0x6C, 0x6C, 0x60, 0x00},
|
||||
@@ -524,11 +474,181 @@ const uint8_t gFontSmall[95][6] =
|
||||
{0x0C, 0x3C, 0x70, 0x70, 0x3C, 0x0C},
|
||||
{0x3C, 0x7C, 0x30, 0x30, 0x7C, 0x3C},
|
||||
{0x44, 0x6C, 0x38, 0x38, 0x6C, 0x44},
|
||||
{0x06, 0x6E, 0x6C, 0x6C, 0x7E, 0x3E},
|
||||
{0x06, 0x6E, 0x68, 0x68, 0x7E, 0x3E},
|
||||
{0x66, 0x76, 0x7E, 0x6E, 0x66, 0x00},
|
||||
{0x08, 0x3E, 0x77, 0x41, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x7F, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x41, 0x77, 0x3E, 0x08, 0x00},
|
||||
{0x0C, 0x06, 0x0C, 0x18, 0x0C, 0x00},
|
||||
{0x0C, 0x06, 0x0C, 0x18, 0x0C, 0x00}
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SPECTRUM
|
||||
const uint8_t gFont3x5[][3] =
|
||||
{
|
||||
{0x00, 0x00, 0x00}, // 32 - space
|
||||
{0x00, 0x17, 0x00}, // 33 - exclam
|
||||
{0x03, 0x00, 0x03}, // 34 - quotedbl
|
||||
{0x1f, 0x0a, 0x1f}, // 35 - numbersign
|
||||
{0x0a, 0x1f, 0x05}, // 36 - dollar
|
||||
{0x09, 0x04, 0x12}, // 37 - percent
|
||||
{0x0f, 0x17, 0x1c}, // 38 - ampersand
|
||||
{0x00, 0x03, 0x00}, // 39 - quotesingle
|
||||
{0x00, 0x0e, 0x11}, // 40 - parenleft
|
||||
{0x11, 0x0e, 0x00}, // 41 - parenright
|
||||
{0x05, 0x02, 0x05}, // 42 - asterisk
|
||||
{0x04, 0x0e, 0x04}, // 43 - plus
|
||||
{0x10, 0x08, 0x00}, // 44 - comma
|
||||
{0x04, 0x04, 0x04}, // 45 - hyphen
|
||||
{0x00, 0x10, 0x00}, // 46 - period
|
||||
{0x18, 0x04, 0x03}, // 47 - slash
|
||||
{0x1e, 0x11, 0x0f}, // 48 - zero
|
||||
{0x02, 0x1f, 0x00}, // 49 - one
|
||||
{0x19, 0x15, 0x12}, // 50 - two
|
||||
{0x11, 0x15, 0x0a}, // 51 - three
|
||||
{0x07, 0x04, 0x1f}, // 52 - four
|
||||
{0x17, 0x15, 0x09}, // 53 - five
|
||||
{0x1e, 0x15, 0x1d}, // 54 - six
|
||||
{0x19, 0x05, 0x03}, // 55 - seven
|
||||
{0x1f, 0x15, 0x1f}, // 56 - eight
|
||||
{0x17, 0x15, 0x0f}, // 57 - nine
|
||||
{0x00, 0x0a, 0x00}, // 58 - colon
|
||||
{0x10, 0x0a, 0x00}, // 59 - semicolon
|
||||
{0x04, 0x0a, 0x11}, // 60 - less
|
||||
{0x0a, 0x0a, 0x0a}, // 61 - equal
|
||||
{0x11, 0x0a, 0x04}, // 62 - greater
|
||||
{0x01, 0x15, 0x03}, // 63 - question
|
||||
{0x0e, 0x15, 0x16}, // 64 - at
|
||||
{0x1e, 0x05, 0x1e}, // 65 - A
|
||||
{0x1f, 0x15, 0x0a}, // 66 - B
|
||||
{0x0e, 0x11, 0x11}, // 67 - C
|
||||
{0x1f, 0x11, 0x0e}, // 68 - D
|
||||
{0x1f, 0x15, 0x15}, // 69 - E
|
||||
{0x1f, 0x05, 0x05}, // 70 - F
|
||||
{0x0e, 0x15, 0x1d}, // 71 - G
|
||||
{0x1f, 0x04, 0x1f}, // 72 - H
|
||||
{0x11, 0x1f, 0x11}, // 73 - I
|
||||
{0x08, 0x10, 0x0f}, // 74 - J
|
||||
{0x1f, 0x04, 0x1b}, // 75 - K
|
||||
{0x1f, 0x10, 0x10}, // 76 - L
|
||||
{0x1f, 0x06, 0x1f}, // 77 - M
|
||||
{0x1f, 0x0e, 0x1f}, // 78 - N
|
||||
{0x0e, 0x11, 0x0e}, // 79 - O
|
||||
{0x1f, 0x05, 0x02}, // 80 - P
|
||||
{0x0e, 0x19, 0x1e}, // 81 - Q
|
||||
{0x1f, 0x0d, 0x16}, // 82 - R
|
||||
{0x12, 0x15, 0x09}, // 83 - S
|
||||
{0x01, 0x1f, 0x01}, // 84 - T
|
||||
{0x0f, 0x10, 0x1f}, // 85 - U
|
||||
{0x07, 0x18, 0x07}, // 86 - V
|
||||
{0x1f, 0x0c, 0x1f}, // 87 - W
|
||||
{0x1b, 0x04, 0x1b}, // 88 - X
|
||||
{0x03, 0x1c, 0x03}, // 89 - Y
|
||||
{0x19, 0x15, 0x13}, // 90 - Z
|
||||
{0x1f, 0x11, 0x11}, // 91 - bracketleft
|
||||
{0x02, 0x04, 0x08}, // 92 - backslash
|
||||
{0x11, 0x11, 0x1f}, // 93 - bracketright
|
||||
{0x02, 0x01, 0x02}, // 94 - asciicircum
|
||||
{0x10, 0x10, 0x10}, // 95 - underscore
|
||||
{0x01, 0x02, 0x00}, // 96 - grave
|
||||
{0x1a, 0x16, 0x1c}, // 97 - a
|
||||
{0x1f, 0x12, 0x0c}, // 98 - b
|
||||
{0x0c, 0x12, 0x12}, // 99 - c
|
||||
{0x0c, 0x12, 0x1f}, // 100 - d
|
||||
{0x0c, 0x1a, 0x16}, // 101 - e
|
||||
{0x04, 0x1e, 0x05}, // 102 - f
|
||||
{0x0c, 0x2a, 0x1e}, // 103 - g
|
||||
{0x1f, 0x02, 0x1c}, // 104 - h
|
||||
{0x00, 0x1d, 0x00}, // 105 - i
|
||||
{0x10, 0x20, 0x1d}, // 106 - j
|
||||
{0x1f, 0x0c, 0x12}, // 107 - k
|
||||
{0x11, 0x1f, 0x10}, // 108 - l
|
||||
{0x1e, 0x0e, 0x1e}, // 109 - m
|
||||
{0x1e, 0x02, 0x1c}, // 110 - n
|
||||
{0x0c, 0x12, 0x0c}, // 111 - o
|
||||
{0x3e, 0x12, 0x0c}, // 112 - p
|
||||
{0x0c, 0x12, 0x3e}, // 113 - q
|
||||
{0x1c, 0x02, 0x02}, // 114 - r
|
||||
{0x14, 0x1e, 0x0a}, // 115 - s
|
||||
{0x02, 0x1f, 0x12}, // 116 - t
|
||||
{0x0e, 0x10, 0x1e}, // 117 - u
|
||||
{0x0e, 0x18, 0x0e}, // 118 - v
|
||||
{0x1e, 0x1c, 0x1e}, // 119 - w
|
||||
{0x12, 0x0c, 0x12}, // 120 - x
|
||||
{0x06, 0x28, 0x1e}, // 121 - y
|
||||
{0x1a, 0x1e, 0x16}, // 122 - z
|
||||
{0x04, 0x1b, 0x11}, // 123 - braceleft
|
||||
{0x00, 0x1b, 0x00}, // 124 - bar
|
||||
{0x11, 0x1b, 0x04}, // 125 - braceright
|
||||
{0x02, 0x03, 0x01}, // 126 - asciitilde
|
||||
|
||||
{0x12, 0x17, 0x12}, // 127 - plusminus
|
||||
|
||||
|
||||
// {0x00, 0x00, 0x00}, // 127 - empty
|
||||
// {0x00, 0x00, 0x00}, // 128 - empty
|
||||
// {0x00, 0x00, 0x00}, // 129 - empty
|
||||
// {0x00, 0x00, 0x00}, // 130 - empty
|
||||
// {0x00, 0x00, 0x00}, // 131 - empty
|
||||
// {0x00, 0x00, 0x00}, // 132 - empty
|
||||
// {0x00, 0x00, 0x00}, // 133 - empty
|
||||
// {0x00, 0x00, 0x00}, // 134 - empty
|
||||
// {0x00, 0x00, 0x00}, // 135 - empty
|
||||
// {0x00, 0x00, 0x00}, // 136 - empty
|
||||
// {0x00, 0x00, 0x00}, // 137 - empty
|
||||
// {0x00, 0x00, 0x00}, // 138 - empty
|
||||
// {0x00, 0x00, 0x00}, // 139 - empty
|
||||
// {0x00, 0x00, 0x00}, // 140 - empty
|
||||
// {0x00, 0x00, 0x00}, // 141 - empty
|
||||
// {0x00, 0x00, 0x00}, // 142 - empty
|
||||
// {0x00, 0x00, 0x00}, // 143 - empty
|
||||
// {0x00, 0x00, 0x00}, // 144 - empty
|
||||
// {0x00, 0x00, 0x00}, // 145 - empty
|
||||
// {0x00, 0x00, 0x00}, // 146 - empty
|
||||
// {0x00, 0x00, 0x00}, // 147 - empty
|
||||
// {0x00, 0x00, 0x00}, // 148 - empty
|
||||
// {0x00, 0x00, 0x00}, // 149 - empty
|
||||
// {0x00, 0x00, 0x00}, // 150 - empty
|
||||
// {0x00, 0x00, 0x00}, // 151 - empty
|
||||
// {0x00, 0x00, 0x00}, // 152 - empty
|
||||
// {0x00, 0x00, 0x00}, // 153 - empty
|
||||
// {0x00, 0x00, 0x00}, // 154 - empty
|
||||
// {0x00, 0x00, 0x00}, // 155 - empty
|
||||
// {0x00, 0x00, 0x00}, // 156 - empty
|
||||
// {0x00, 0x00, 0x00}, // 157 - empty
|
||||
// {0x00, 0x00, 0x00}, // 158 - empty
|
||||
// {0x00, 0x00, 0x00}, // 159 - empty
|
||||
// {0x00, 0x00, 0x00}, // 160 - empty
|
||||
// {0x00, 0x1d, 0x00}, // 161 - exclamdown
|
||||
// {0x0e, 0x1b, 0x0a}, // 162 - cent
|
||||
// {0x14, 0x1f, 0x15}, // 163 - sterling
|
||||
// {0x15, 0x0e, 0x15}, // 164 - currency
|
||||
// {0x0b, 0x1c, 0x0b}, // 165 - yen
|
||||
// {0x00, 0x1b, 0x00}, // 166 - brokenbar
|
||||
// {0x14, 0x1b, 0x05}, // 167 - section
|
||||
// {0x01, 0x00, 0x01}, // 168 - dieresis
|
||||
// {0x02, 0x05, 0x05}, // 169 - copyright
|
||||
// {0x16, 0x15, 0x17}, // 170 - ordfeminine
|
||||
// {0x02, 0x05, 0x00}, // 171 - guillemotleft
|
||||
// {0x02, 0x02, 0x06}, // 172 - logicalnot
|
||||
// {0x04, 0x04, 0x00}, // 173 - softhyphen
|
||||
// {0x07, 0x03, 0x04}, // 174 - registered
|
||||
// {0x01, 0x01, 0x01}, // 175 - macron
|
||||
// {0x02, 0x05, 0x02}, // 176 - degree
|
||||
// {0x12, 0x17, 0x12}, // 177 - plusminus
|
||||
// {0x01, 0x07, 0x04}, // 178 - twosuperior
|
||||
// {0x05, 0x07, 0x07}, // 179 - threesuperior
|
||||
// {0x00, 0x02, 0x01}, // 180 - acute
|
||||
// {0x1f, 0x08, 0x07}, // 181 - mu
|
||||
// {0x02, 0x1d, 0x1f}, // 182 - paragraph
|
||||
// {0x0e, 0x0e, 0x0e}, // 183 - periodcentered
|
||||
// {0x10, 0x14, 0x08}, // 184 - cedilla
|
||||
// {0x00, 0x07, 0x00}, // 185 - onesuperior
|
||||
// {0x12, 0x15, 0x12}, // 186 - ordmasculine
|
||||
// {0x00, 0x05, 0x02}, // 187 - guillemotright
|
||||
// {0x03, 0x08, 0x18}, // 188 - onequarter
|
||||
// {0x0b, 0x18, 0x10}, // 189 - onehalf
|
||||
// {0x03, 0x0b, 0x18}, // 190 - threequarters
|
||||
// {0x18, 0x15, 0x10}, // 191 - questiondown
|
||||
};
|
||||
#endif
|
||||
|
||||
13
font.h
@@ -19,14 +19,13 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//extern const uint8_t gFontBig[95][16];
|
||||
extern const uint8_t gFontBig[95][15];
|
||||
extern const uint8_t gFontBigDigits[11][26];
|
||||
//extern const uint8_t gFontSmallDigits[11][7];
|
||||
extern const uint8_t gFont3x5[160][3];
|
||||
extern const uint8_t gFontSmall[95][6];
|
||||
|
||||
extern const uint8_t gFontBig[95 - 1][16 - 2];
|
||||
extern const uint8_t gFontBigDigits[11][26 - 6];
|
||||
extern const uint8_t gFont3x5[96][3];
|
||||
extern const uint8_t gFontSmall[95 - 1][6];
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
extern const uint8_t gFontSmallBold[95][6];
|
||||
extern const uint8_t gFontSmallBold[95 - 1][6];
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
224
frequencies.c
@@ -17,55 +17,32 @@
|
||||
#include "frequencies.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
#include <assert.h>
|
||||
|
||||
// the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz
|
||||
|
||||
const uint32_t bx_start1_Hz = 1800000; // 18MHz
|
||||
const uint32_t bx_stop1_Hz = 63000000; // 630MHz
|
||||
#define BX4819_band1_lower 1800000
|
||||
#define BX4819_band2_upper 130000000
|
||||
|
||||
//const uint32_t bx_start2_Hz = 76000000; // 760MHz // my one radio the BK chip managed to lock down to this frequency
|
||||
const uint32_t bx_start2_Hz = 84000000; // 840MHz // but best to go with datasheet specification really
|
||||
const uint32_t bx_stop2_Hz = 130000000; // 1300MHz
|
||||
const freq_band_table_t BX4819_band1 = {BX4819_band1_lower, 63000000};
|
||||
const freq_band_table_t BX4819_band2 = {84000000, BX4819_band2_upper};
|
||||
|
||||
const uint32_t LowerLimitFrequencyBandTable[7] =
|
||||
const freq_band_table_t frequencyBandTable[] =
|
||||
{
|
||||
#ifndef ENABLE_WIDE_RX
|
||||
5000000,
|
||||
// QS original
|
||||
[BAND1_50MHz ]={.lower = 5000000, .upper = 7600000},
|
||||
[BAND7_470MHz]={.lower = 47000000, .upper = 60000000},
|
||||
#else
|
||||
1800000,
|
||||
#endif
|
||||
10800000,
|
||||
13600000,
|
||||
17400000,
|
||||
35000000,
|
||||
40000000,
|
||||
47000000
|
||||
};
|
||||
|
||||
const uint32_t MiddleFrequencyBandTable[7] =
|
||||
{
|
||||
6500000,
|
||||
12200000,
|
||||
15000000,
|
||||
26000000,
|
||||
37000000,
|
||||
43500000,
|
||||
55000000
|
||||
};
|
||||
|
||||
const uint32_t UpperLimitFrequencyBandTable[7] =
|
||||
{
|
||||
7600000,
|
||||
13599990,
|
||||
17399990,
|
||||
34999990,
|
||||
39999990,
|
||||
46999990,
|
||||
#ifndef ENABLE_WIDE_RX
|
||||
60000000
|
||||
#else
|
||||
130000000
|
||||
// extended range
|
||||
[BAND1_50MHz ]={.lower = BX4819_band1_lower, .upper = 10800000},
|
||||
[BAND7_470MHz]={.lower = 47000000, .upper = BX4819_band2_upper},
|
||||
#endif
|
||||
[BAND2_108MHz]={.lower = 10800000, .upper = 13700000},
|
||||
[BAND3_137MHz]={.lower = 13700000, .upper = 17400000},
|
||||
[BAND4_174MHz]={.lower = 17400000, .upper = 35000000},
|
||||
[BAND5_350MHz]={.lower = 35000000, .upper = 40000000},
|
||||
[BAND6_400MHz]={.lower = 40000000, .upper = 47000000}
|
||||
};
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
@@ -84,36 +61,66 @@ const uint32_t UpperLimitFrequencyBandTable[7] =
|
||||
};
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
const uint16_t StepFrequencyTable[7] =
|
||||
{
|
||||
250,
|
||||
500,
|
||||
625,
|
||||
1000,
|
||||
1250,
|
||||
2500,
|
||||
833
|
||||
};
|
||||
#else
|
||||
const uint16_t StepFrequencyTable[7] =
|
||||
{
|
||||
125,
|
||||
250,
|
||||
625,
|
||||
1000,
|
||||
1250,
|
||||
2500,
|
||||
833
|
||||
};
|
||||
#endif
|
||||
|
||||
// this order of steps has to be preserved for backwards compatibility with other/stock firmwares
|
||||
const uint16_t gStepFrequencyTable[] = {
|
||||
// standard steps
|
||||
[STEP_2_5kHz] = 250,
|
||||
[STEP_5kHz] = 500,
|
||||
[STEP_6_25kHz] = 625,
|
||||
[STEP_10kHz] = 1000,
|
||||
[STEP_12_5kHz] = 1250,
|
||||
[STEP_25kHz] = 2500,
|
||||
[STEP_8_33kHz] = 833,
|
||||
// custom steps
|
||||
[STEP_0_01kHz] = 1,
|
||||
[STEP_0_05kHz] = 5,
|
||||
[STEP_0_1kHz] = 10,
|
||||
[STEP_0_25kHz] = 25,
|
||||
[STEP_0_5kHz] = 50,
|
||||
[STEP_1kHz] = 100,
|
||||
[STEP_1_25kHz] = 125,
|
||||
[STEP_9kHz] = 900,
|
||||
[STEP_15kHz] = 1500,
|
||||
[STEP_20kHz] = 2000,
|
||||
[STEP_30kHz] = 3000,
|
||||
[STEP_50kHz] = 5000,
|
||||
[STEP_100kHz] = 10000,
|
||||
[STEP_125kHz] = 12500,
|
||||
[STEP_200kHz] = 20000,
|
||||
[STEP_250kHz] = 25000,
|
||||
[STEP_500kHz] = 50000
|
||||
};
|
||||
|
||||
|
||||
const STEP_Setting_t StepSortedIndexes[] = {
|
||||
STEP_0_01kHz, STEP_0_05kHz, STEP_0_1kHz, STEP_0_25kHz, STEP_0_5kHz, STEP_1kHz, STEP_1_25kHz, STEP_2_5kHz, STEP_5kHz, STEP_6_25kHz,
|
||||
STEP_8_33kHz, STEP_9kHz, STEP_10kHz, STEP_12_5kHz, STEP_15kHz, STEP_20kHz, STEP_25kHz, STEP_30kHz, STEP_50kHz, STEP_100kHz,
|
||||
STEP_125kHz, STEP_200kHz, STEP_250kHz, STEP_500kHz
|
||||
};
|
||||
|
||||
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx)
|
||||
{
|
||||
return StepSortedIndexes[sortedIdx];
|
||||
}
|
||||
|
||||
uint32_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t stepIdx)
|
||||
{
|
||||
for(uint8_t i = 0; i < ARRAY_SIZE(gStepFrequencyTable); i++)
|
||||
if(StepSortedIndexes[i] == stepIdx)
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static_assert(ARRAY_SIZE(gStepFrequencyTable) == STEP_N_ELEM);
|
||||
|
||||
|
||||
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
||||
{
|
||||
int band;
|
||||
for (band = BAND7_470MHz; band >= BAND1_50MHz; band--)
|
||||
if (Frequency >= LowerLimitFrequencyBandTable[band])
|
||||
return band;
|
||||
for (int32_t band = BAND_N_ELEM - 1; band >= 0; band--)
|
||||
if (Frequency >= frequencyBandTable[band].lower)
|
||||
return (FREQUENCY_Band_t)band;
|
||||
|
||||
return BAND1_50MHz;
|
||||
}
|
||||
|
||||
@@ -136,61 +143,46 @@ uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t T
|
||||
return TxpMid;
|
||||
}
|
||||
|
||||
uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower)
|
||||
|
||||
uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step)
|
||||
{
|
||||
uint32_t Index;
|
||||
|
||||
if (Step == 833)
|
||||
{
|
||||
const uint32_t Delta = Upper - Lower;
|
||||
uint32_t Base = (Delta / 2500) * 2500;
|
||||
const uint32_t Index = ((Delta - Base) % 2500) / 833;
|
||||
|
||||
if (Index == 2)
|
||||
Base++;
|
||||
|
||||
return Lower + Base + (Index * 833);
|
||||
if(step == 833) {
|
||||
uint32_t base = freq/2500*2500;
|
||||
int chno = (freq - base) / 700; // convert entered aviation 8.33Khz channel number scheme to actual frequency.
|
||||
return base + (chno * 833) + (chno == 3);
|
||||
}
|
||||
|
||||
Index = (Upper - Lower) / Step;
|
||||
|
||||
return Lower + (Step * Index);
|
||||
if(step == 1)
|
||||
return freq;
|
||||
if(step >= 1000)
|
||||
step = step/2;
|
||||
return (freq + (step + 1) / 2) / step * step;
|
||||
}
|
||||
/*
|
||||
int TX_FREQUENCY_Check(VFO_Info_t *pInfo)
|
||||
{ // return '0' if TX frequency is allowed
|
||||
// otherwise return '-1'
|
||||
|
||||
const uint32_t Frequency = pInfo->pTX->Frequency;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (pInfo->CHANNEL_SAVE > FREQ_CHANNEL_LAST)
|
||||
return -1;
|
||||
#endif
|
||||
*/
|
||||
int TX_FREQUENCY_Check(const uint32_t Frequency)
|
||||
int32_t TX_freq_check(const uint32_t Frequency)
|
||||
{ // return '0' if TX frequency is allowed
|
||||
// otherwise return '-1'
|
||||
|
||||
if (Frequency < LowerLimitFrequencyBandTable[0] || Frequency > UpperLimitFrequencyBandTable[6])
|
||||
return -1;
|
||||
if (Frequency >= bx_stop1_Hz && Frequency < bx_start2_Hz)
|
||||
return -1;
|
||||
if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper)
|
||||
return 1; // not allowed outside this range
|
||||
|
||||
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
|
||||
return -1; // BX chip does not work in this range
|
||||
|
||||
switch (gSetting_F_LOCK)
|
||||
{
|
||||
case F_LOCK_OFF:
|
||||
if (Frequency >= 13600000 && Frequency < 17400000)
|
||||
case F_LOCK_DEF:
|
||||
if (Frequency >= frequencyBandTable[BAND3_137MHz].lower && Frequency < frequencyBandTable[BAND3_137MHz].upper)
|
||||
return 0;
|
||||
if (Frequency >= 17400000 && Frequency < 35000000)
|
||||
if (Frequency >= frequencyBandTable[BAND4_174MHz].lower && Frequency < frequencyBandTable[BAND4_174MHz].upper)
|
||||
if (gSetting_200TX)
|
||||
return 0;
|
||||
if (Frequency >= 35000000 && Frequency < 40000000)
|
||||
if (Frequency >= frequencyBandTable[BAND5_350MHz].lower && Frequency < frequencyBandTable[BAND5_350MHz].upper)
|
||||
if (gSetting_350TX && gSetting_350EN)
|
||||
return 0;
|
||||
if (Frequency >= 40000000 && Frequency < 47000000)
|
||||
if (Frequency >= frequencyBandTable[BAND6_400MHz].lower && Frequency < frequencyBandTable[BAND6_400MHz].upper)
|
||||
return 0;
|
||||
if (Frequency >= 47000000 && Frequency <= 60000000)
|
||||
if (Frequency >= frequencyBandTable[BAND7_470MHz].lower && Frequency <= 60000000)
|
||||
if (gSetting_500TX)
|
||||
return 0;
|
||||
break;
|
||||
@@ -205,6 +197,8 @@ int TX_FREQUENCY_Check(const uint32_t Frequency)
|
||||
case F_LOCK_CE:
|
||||
if (Frequency >= 14400000 && Frequency < 14600000)
|
||||
return 0;
|
||||
if (Frequency >= 43000000 && Frequency < 44000000)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case F_LOCK_GB:
|
||||
@@ -215,31 +209,41 @@ int TX_FREQUENCY_Check(const uint32_t Frequency)
|
||||
break;
|
||||
|
||||
case F_LOCK_430:
|
||||
if (Frequency >= 13600000 && Frequency < 17400000)
|
||||
if (Frequency >= frequencyBandTable[BAND3_137MHz].lower && Frequency < 17400000)
|
||||
return 0;
|
||||
if (Frequency >= 40000000 && Frequency < 43000000)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case F_LOCK_438:
|
||||
if (Frequency >= 13600000 && Frequency < 17400000)
|
||||
if (Frequency >= frequencyBandTable[BAND3_137MHz].lower && Frequency < 17400000)
|
||||
return 0;
|
||||
if (Frequency >= 40000000 && Frequency < 43800000)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case F_LOCK_ALL:
|
||||
break;
|
||||
|
||||
case F_LOCK_NONE:
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(frequencyBandTable); i++)
|
||||
if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// dis-allowed TX frequency
|
||||
return -1;
|
||||
}
|
||||
|
||||
int RX_FREQUENCY_Check(const uint32_t Frequency)
|
||||
int32_t RX_freq_check(const uint32_t Frequency)
|
||||
{ // return '0' if RX frequency is allowed
|
||||
// otherwise return '-1'
|
||||
|
||||
if (Frequency < LowerLimitFrequencyBandTable[0] || Frequency > UpperLimitFrequencyBandTable[6])
|
||||
if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper)
|
||||
return -1;
|
||||
if (Frequency >= bx_stop1_Hz && Frequency < bx_start2_Hz)
|
||||
|
||||
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
|
||||
return -1;
|
||||
|
||||
return 0; // OK frequency
|
||||
|
||||
@@ -19,45 +19,75 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "radio.h"
|
||||
#define _1GHz_in_KHz 100000000
|
||||
|
||||
extern const uint32_t bx_start1_Hz;
|
||||
extern const uint32_t bx_stop1_Hz;
|
||||
typedef struct {
|
||||
const uint32_t lower;
|
||||
const uint32_t upper;
|
||||
} freq_band_table_t;
|
||||
|
||||
extern const uint32_t bx_start2_Hz;
|
||||
extern const uint32_t bx_stop2_Hz;
|
||||
extern const freq_band_table_t BX4819_band1;
|
||||
extern const freq_band_table_t BX4819_band2;
|
||||
|
||||
enum FREQUENCY_Band_t
|
||||
{
|
||||
BAND1_NONE = -1,
|
||||
BAND1_50MHz = 0,
|
||||
typedef enum {
|
||||
BAND_NONE = -1,
|
||||
BAND1_50MHz = 0,
|
||||
BAND2_108MHz,
|
||||
BAND3_136MHz,
|
||||
BAND3_137MHz,
|
||||
BAND4_174MHz,
|
||||
BAND5_350MHz,
|
||||
BAND6_400MHz,
|
||||
BAND7_470MHz
|
||||
};
|
||||
BAND7_470MHz,
|
||||
BAND_N_ELEM
|
||||
} FREQUENCY_Band_t;
|
||||
|
||||
typedef enum FREQUENCY_Band_t FREQUENCY_Band_t;
|
||||
extern const freq_band_table_t frequencyBandTable[];
|
||||
|
||||
extern const uint32_t LowerLimitFrequencyBandTable[7];
|
||||
extern const uint32_t MiddleFrequencyBandTable[7];
|
||||
extern const uint32_t UpperLimitFrequencyBandTable[7];
|
||||
typedef enum {
|
||||
// standard steps
|
||||
STEP_2_5kHz,
|
||||
STEP_5kHz,
|
||||
STEP_6_25kHz,
|
||||
STEP_10kHz,
|
||||
STEP_12_5kHz,
|
||||
STEP_25kHz,
|
||||
STEP_8_33kHz,
|
||||
// custom steps
|
||||
STEP_0_01kHz,
|
||||
STEP_0_05kHz,
|
||||
STEP_0_1kHz,
|
||||
STEP_0_25kHz,
|
||||
STEP_0_5kHz,
|
||||
STEP_1kHz,
|
||||
STEP_1_25kHz,
|
||||
STEP_9kHz,
|
||||
STEP_15kHz,
|
||||
STEP_20kHz,
|
||||
STEP_30kHz,
|
||||
STEP_50kHz,
|
||||
STEP_100kHz,
|
||||
STEP_125kHz,
|
||||
STEP_200kHz,
|
||||
STEP_250kHz,
|
||||
STEP_500kHz,
|
||||
STEP_N_ELEM
|
||||
} STEP_Setting_t;
|
||||
|
||||
|
||||
extern const uint16_t gStepFrequencyTable[];
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
extern const uint32_t NoaaFrequencyTable[10];
|
||||
extern const uint32_t NoaaFrequencyTable[10];
|
||||
#endif
|
||||
|
||||
extern const uint16_t StepFrequencyTable[7];
|
||||
|
||||
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency);
|
||||
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency);
|
||||
uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower);
|
||||
uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step);
|
||||
|
||||
//int TX_FREQUENCY_Check(VFO_Info_t *pInfo);
|
||||
int TX_FREQUENCY_Check(const uint32_t Frequency);
|
||||
int RX_FREQUENCY_Check(const uint32_t Frequency);
|
||||
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx);
|
||||
uint32_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t step);
|
||||
|
||||
int32_t TX_freq_check(uint32_t Frequency);
|
||||
int32_t RX_freq_check(uint32_t Frequency);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
333
functions.c
@@ -20,14 +20,18 @@
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
#include "app/fm.h"
|
||||
#endif
|
||||
#include "audio.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "dcs.h"
|
||||
#include "driver/backlight.h"
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
#include "driver/bk1080.h"
|
||||
#endif
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/system.h"
|
||||
#include "driver/st7565.h"
|
||||
#include "frequencies.h"
|
||||
#include "functions.h"
|
||||
#include "helper/battery.h"
|
||||
#include "misc.h"
|
||||
@@ -38,35 +42,19 @@
|
||||
|
||||
FUNCTION_Type_t gCurrentFunction;
|
||||
|
||||
bool FUNCTION_IsRx()
|
||||
{
|
||||
return gCurrentFunction == FUNCTION_MONITOR ||
|
||||
gCurrentFunction == FUNCTION_INCOMING ||
|
||||
gCurrentFunction == FUNCTION_RECEIVE;
|
||||
}
|
||||
|
||||
void FUNCTION_Init(void)
|
||||
{
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
||||
#endif
|
||||
{
|
||||
gCurrentCodeType = gSelectedCodeType;
|
||||
if (gCssScanMode == CSS_SCAN_MODE_OFF)
|
||||
gCurrentCodeType = gRxVfo->AM_mode ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
|
||||
}
|
||||
#ifdef ENABLE_NOAA
|
||||
else
|
||||
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
|
||||
#endif
|
||||
|
||||
gDTMF_RequestPending = false;
|
||||
|
||||
gDTMF_RecvTimeout = 0;
|
||||
gDTMF_WriteIndex = 0;
|
||||
memset(gDTMF_Received, 0, sizeof(gDTMF_Received));
|
||||
|
||||
// gDTMF_RX_timeout_live = 0;
|
||||
// gDTMF_RX_timeout_live[0] = '\0';
|
||||
|
||||
g_CxCSS_TAIL_Found = false;
|
||||
g_CDCSS_Lost = false;
|
||||
g_CTCSS_Lost = false;
|
||||
|
||||
g_VOX_Lost = false;
|
||||
|
||||
g_SquelchLost = false;
|
||||
|
||||
gFlagTailNoteEliminationComplete = false;
|
||||
@@ -77,150 +65,209 @@ void FUNCTION_Init(void)
|
||||
gFoundCDCSSCountdown_10ms = 0;
|
||||
gEndOfRxDetectedMaybe = false;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
gNOAACountdown_10ms = 0;
|
||||
#endif
|
||||
gCurrentCodeType = (gRxVfo->Modulation != MODULATION_FM) ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
g_VOX_Lost = false;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
DTMF_clear_RX();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
gNOAACountdown_10ms = 0;
|
||||
|
||||
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) {
|
||||
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction)
|
||||
{
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
if (gDTMF_ReplyState != DTMF_REPLY_NONE)
|
||||
RADIO_PrepareCssTX();
|
||||
#endif
|
||||
|
||||
if (PreviousFunction == FUNCTION_TRANSMIT) {
|
||||
ST7565_FixInterfGlitch();
|
||||
gVFO_RSSI_bar_level[0] = 0;
|
||||
gVFO_RSSI_bar_level[1] = 0;
|
||||
} else if (PreviousFunction != FUNCTION_RECEIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
if (gFmRadioMode)
|
||||
gFM_RestoreCountdown_10ms = fm_restore_countdown_10ms;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT ||
|
||||
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED ||
|
||||
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY)
|
||||
{
|
||||
gDTMF_auto_reset_time_500ms = gEeprom.DTMF_auto_reset_time * 2;
|
||||
}
|
||||
#endif
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
void FUNCTION_PowerSave() {
|
||||
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
|
||||
gPowerSaveCountdownExpired = false;
|
||||
|
||||
gRxIdleMode = true;
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
BK4819_DisableVox();
|
||||
BK4819_Sleep();
|
||||
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_RX_ENABLE, false);
|
||||
|
||||
gUpdateStatus = true;
|
||||
|
||||
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
}
|
||||
|
||||
void FUNCTION_Transmit()
|
||||
{
|
||||
// if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11
|
||||
BK4819_DisableDTMF();
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
// clear the DTMF RX buffer
|
||||
DTMF_clear_RX();
|
||||
#endif
|
||||
|
||||
// clear the DTMF RX live decoder buffer
|
||||
gDTMF_RX_live_timeout = 0;
|
||||
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
|
||||
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
if (gFmRadioMode)
|
||||
BK1080_Init0();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
if (gAlarmState == ALARM_STATE_SITE_ALARM)
|
||||
{
|
||||
GUI_DisplayScreen();
|
||||
|
||||
AUDIO_AudioPathOff();
|
||||
|
||||
SYSTEM_DelayMs(20);
|
||||
BK4819_PlayTone(500, 0);
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
AUDIO_AudioPathOn();
|
||||
|
||||
gEnableSpeaker = true;
|
||||
|
||||
SYSTEM_DelayMs(60);
|
||||
BK4819_ExitTxMute();
|
||||
|
||||
gAlarmToneCounter = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
gUpdateStatus = true;
|
||||
|
||||
GUI_DisplayScreen();
|
||||
|
||||
RADIO_SetTxParameters();
|
||||
|
||||
// turn the RED LED on
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true);
|
||||
|
||||
DTMF_Reply();
|
||||
|
||||
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO)
|
||||
BK4819_PlaySingleTone(2525, 250, 0, gEeprom.DTMF_SIDE_TONE);
|
||||
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
if (gAlarmState != ALARM_STATE_OFF) {
|
||||
#ifdef ENABLE_TX1750
|
||||
if (gAlarmState == ALARM_STATE_TX1750)
|
||||
BK4819_TransmitTone(true, 1750);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
if (gAlarmState == ALARM_STATE_TXALARM)
|
||||
BK4819_TransmitTone(true, 500);
|
||||
|
||||
gAlarmToneCounter = 0;
|
||||
#endif
|
||||
|
||||
SYSTEM_DelayMs(2);
|
||||
AUDIO_AudioPathOn();
|
||||
gEnableSpeaker = true;
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gCurrentVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable)
|
||||
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
|
||||
else
|
||||
BK4819_DisableScramble();
|
||||
|
||||
if (gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX) {
|
||||
BACKLIGHT_TurnOn();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FUNCTION_Select(FUNCTION_Type_t Function)
|
||||
{
|
||||
const FUNCTION_Type_t PreviousFunction = gCurrentFunction;
|
||||
const bool bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE);
|
||||
const bool bWasPowerSave = PreviousFunction == FUNCTION_POWER_SAVE;
|
||||
|
||||
gCurrentFunction = Function;
|
||||
|
||||
if (bWasPowerSave && Function != FUNCTION_POWER_SAVE)
|
||||
{
|
||||
if (bWasPowerSave && Function != FUNCTION_POWER_SAVE) {
|
||||
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
|
||||
gRxIdleMode = false;
|
||||
UI_DisplayStatus(false);
|
||||
UI_DisplayStatus();
|
||||
}
|
||||
|
||||
switch (Function)
|
||||
{
|
||||
switch (Function) {
|
||||
case FUNCTION_FOREGROUND:
|
||||
if (gDTMF_ReplyState != DTMF_REPLY_NONE)
|
||||
RADIO_PrepareCssTX();
|
||||
|
||||
if (PreviousFunction == FUNCTION_TRANSMIT)
|
||||
{
|
||||
gVFO_RSSI_bar_level[0] = 0;
|
||||
gVFO_RSSI_bar_level[1] = 0;
|
||||
}
|
||||
else
|
||||
if (PreviousFunction != FUNCTION_RECEIVE)
|
||||
break;
|
||||
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
if (gFmRadioMode)
|
||||
gFM_RestoreCountdown_10ms = fm_restore_countdown_10ms;
|
||||
#endif
|
||||
|
||||
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED)
|
||||
gDTMF_AUTO_RESET_TIME = 1 + (gEeprom.DTMF_AUTO_RESET_TIME * 2);
|
||||
|
||||
FUNCTION_Foreground(PreviousFunction);
|
||||
return;
|
||||
|
||||
|
||||
case FUNCTION_POWER_SAVE:
|
||||
FUNCTION_PowerSave();
|
||||
return;
|
||||
|
||||
case FUNCTION_TRANSMIT:
|
||||
FUNCTION_Transmit();
|
||||
break;
|
||||
|
||||
case FUNCTION_MONITOR:
|
||||
gMonitor = true;
|
||||
break;
|
||||
|
||||
|
||||
case FUNCTION_INCOMING:
|
||||
case FUNCTION_RECEIVE:
|
||||
break;
|
||||
|
||||
case FUNCTION_POWER_SAVE:
|
||||
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
|
||||
gPowerSaveCountdownExpired = false;
|
||||
|
||||
gRxIdleMode = true;
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
BK4819_DisableVox();
|
||||
BK4819_Sleep();
|
||||
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false);
|
||||
|
||||
gUpdateStatus = true;
|
||||
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
return;
|
||||
|
||||
case FUNCTION_TRANSMIT:
|
||||
|
||||
// if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11
|
||||
BK4819_DisableDTMF();
|
||||
|
||||
gDTMF_RX_live_timeout = 0;
|
||||
gDTMF_RX_live[0] = 0;
|
||||
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
if (gFmRadioMode)
|
||||
BK1080_Init(0, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE)
|
||||
{
|
||||
gAlarmState = ALARM_STATE_ALARM;
|
||||
|
||||
GUI_DisplayScreen();
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
|
||||
SYSTEM_DelayMs(20);
|
||||
BK4819_PlayTone(500, 0);
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
|
||||
gEnableSpeaker = true;
|
||||
|
||||
SYSTEM_DelayMs(60);
|
||||
BK4819_ExitTxMute();
|
||||
|
||||
gAlarmToneCounter = 0;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
GUI_DisplayScreen();
|
||||
|
||||
RADIO_SetTxParameters();
|
||||
|
||||
// turn the LED on RED
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true);
|
||||
|
||||
DTMF_Reply();
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
if (gAlarmState != ALARM_STATE_OFF)
|
||||
{
|
||||
BK4819_TransmitTone(true, (gAlarmState == ALARM_STATE_TX1750) ? 1750 : 500);
|
||||
SYSTEM_DelayMs(2);
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
gAlarmToneCounter = 0;
|
||||
gEnableSpeaker = true;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gCurrentVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable)
|
||||
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
|
||||
else
|
||||
BK4819_DisableScramble();
|
||||
|
||||
break;
|
||||
|
||||
case FUNCTION_BAND_SCOPE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gBatterySaveCountdown_10ms = battery_save_count_10ms;
|
||||
gSchedulePowerSave = false;
|
||||
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
if(Function != FUNCTION_INCOMING)
|
||||
gFM_RestoreCountdown_10ms = 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ enum FUNCTION_Type_t
|
||||
FUNCTION_INCOMING, // receiving a signal (squelch is open)
|
||||
FUNCTION_RECEIVE, // RX mode, squelch closed
|
||||
FUNCTION_POWER_SAVE, // sleeping
|
||||
FUNCTION_BAND_SCOPE // bandscope mode (panadpter/spectrum) .. not yet implemented
|
||||
FUNCTION_BAND_SCOPE, // bandscope mode (panadpter/spectrum) .. not yet implemented
|
||||
FUNCTION_N_ELEM
|
||||
};
|
||||
|
||||
typedef enum FUNCTION_Type_t FUNCTION_Type_t;
|
||||
@@ -36,6 +37,6 @@ extern FUNCTION_Type_t gCurrentFunction;
|
||||
|
||||
void FUNCTION_Init(void);
|
||||
void FUNCTION_Select(FUNCTION_Type_t Function);
|
||||
bool FUNCTION_IsRx();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -21,11 +21,10 @@ def obfuscate(fw):
|
||||
return bytes([a^b for a, b in zip(fw, cycle(OBFUSCATION))])
|
||||
|
||||
plain = open(sys.argv[1], 'rb').read()
|
||||
if len(sys.argv[2]) > 10:
|
||||
print('Version suffix is too big!')
|
||||
sys.exit(1)
|
||||
|
||||
version = b'*OEFW-' + bytes(sys.argv[2], 'ascii')
|
||||
version = b'*' + bytes(sys.argv[2], 'ascii') + b' ' + bytes(sys.argv[3], 'ascii')
|
||||
version = version[0:16]
|
||||
|
||||
if len(version) < 16:
|
||||
version += b'\x00' * (16 - len(version))
|
||||
|
||||
@@ -36,5 +35,5 @@ crc.update(packed)
|
||||
digest = crc.digest()
|
||||
digest = bytes([digest[1], digest[0]])
|
||||
|
||||
open(sys.argv[3], 'wb').write(packed + digest)
|
||||
open(sys.argv[4], 'wb').write(packed + digest)
|
||||
|
||||
|
||||
223
helper/battery.c
@@ -14,9 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "battery.h"
|
||||
#include "driver/backlight.h"
|
||||
#include "driver/st7565.h"
|
||||
#include "functions.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
#include "ui/battery.h"
|
||||
#include "ui/menu.h"
|
||||
#include "ui/ui.h"
|
||||
@@ -28,101 +33,91 @@ uint16_t gBatteryVoltages[4];
|
||||
uint16_t gBatteryVoltageAverage;
|
||||
uint8_t gBatteryDisplayLevel;
|
||||
bool gChargingWithTypeC;
|
||||
bool gLowBattery;
|
||||
bool gLowBatteryBlink;
|
||||
bool gLowBattery;
|
||||
bool gLowBatteryConfirmed;
|
||||
uint16_t gBatteryCheckCounter;
|
||||
|
||||
typedef enum {
|
||||
BATTERY_LOW_INACTIVE,
|
||||
BATTERY_LOW_ACTIVE,
|
||||
BATTERY_LOW_CONFIRMED
|
||||
} BatteryLow_t;
|
||||
|
||||
|
||||
uint16_t lowBatteryCountdown;
|
||||
const uint16_t lowBatteryPeriod = 30;
|
||||
|
||||
volatile uint16_t gPowerSave_10ms;
|
||||
|
||||
/*
|
||||
Based on real measurement
|
||||
|
||||
Volts Percent Volts Percent Volts Percent Volts Percent
|
||||
8.28 100 7.95099 73 7.7184 46 7.48116 19
|
||||
8.22 99 7.94188 72 7.71091 45 7.46364 18
|
||||
8.17 98 7.9338 71 7.70911 44 7.44789 17
|
||||
8.13632 97 7.92684 70 7.70098 43 7.43318 16
|
||||
8.12308 96 7.9178 69 7.69619 42 7.41864 15
|
||||
8.09688 95 7.90823 68 7.69018 41 7.40579 14
|
||||
8.08124 94 7.89858 67 7.68473 40 7.39289 13
|
||||
8.06912 93 7.88667 66 7.67911 39 7.37839 12
|
||||
8.05826 92 7.87673 65 7.67087 38 7.36017 11
|
||||
8.05008 91 7.86864 64 7.66601 37 7.33704 10
|
||||
8.04192 90 7.85802 63 7.6599 36 7.3079 9
|
||||
8.03866 89 7.84816 62 7.65418 35 7.26793 8
|
||||
8.03089 88 7.83744 61 7.64775 34 7.21291 7
|
||||
8.0284 87 7.82748 60 7.64065 33 7.13416 6
|
||||
8.02044 86 7.81983 59 7.63136 32 7.02785 5
|
||||
8.01832 85 7.80929 58 7.6244 31 6.89448 4
|
||||
8.01072 84 7.79955 57 7.61636 30 6.72912 3
|
||||
8.00965 83 7.79017 56 7.60738 29 6.5164 2
|
||||
8.00333 82 7.78107 55 7.597 28 6.19272 1
|
||||
7.99973 81 7.77167 54 7.5876 27 5.63138 0
|
||||
7.99218 80 7.76509 53 7.57732 26
|
||||
7.98999 79 7.75649 52 7.56563 25
|
||||
7.98234 78 7.74939 51 7.55356 24
|
||||
7.97892 77 7.7411 50 7.54088 23
|
||||
7.97043 76 7.73648 49 7.52683 22
|
||||
7.96478 75 7.72911 48 7.51285 21
|
||||
7.95983 74 7.72097 47 7.49832 20
|
||||
*/
|
||||
uint8_t BATTERY_VoltsToPercent(uint16_t voltage_10mV)
|
||||
const uint16_t Voltage2PercentageTable[][7][2] = {
|
||||
[BATTERY_TYPE_1600_MAH] = {
|
||||
{828, 100},
|
||||
{814, 97 },
|
||||
{760, 25 },
|
||||
{729, 6 },
|
||||
{630, 0 },
|
||||
{0, 0 },
|
||||
{0, 0 },
|
||||
},
|
||||
|
||||
[BATTERY_TYPE_2200_MAH] = {
|
||||
{832, 100},
|
||||
{813, 95 },
|
||||
{740, 60 },
|
||||
{707, 21 },
|
||||
{682, 5 },
|
||||
{630, 0 },
|
||||
{0, 0 },
|
||||
},
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
if(voltage_10mV>814)
|
||||
return 100;
|
||||
else if(voltage_10mV>756)
|
||||
return 132*voltage_10mV/100-974;
|
||||
else if(voltage_10mV>729)
|
||||
return 63*voltage_10mV/100-452;
|
||||
else if(voltage_10mV>600)
|
||||
return 52*voltage_10mV/1000-31;
|
||||
else
|
||||
return 0;
|
||||
const uint16_t (*crv)[2] = Voltage2PercentageTable[gEeprom.BATTERY_TYPE];
|
||||
const int mulipl = 1000;
|
||||
for (unsigned int i = 1; i < ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_2200_MAH]); i++) {
|
||||
if (voltage_10mV > crv[i][0]) {
|
||||
const int a = (crv[i - 1][1] - crv[i][1]) * mulipl / (crv[i - 1][0] - crv[i][0]);
|
||||
const int b = crv[i][1] - a * crv[i][0] / mulipl;
|
||||
const int p = a * voltage_10mV / mulipl + b;
|
||||
return MIN(p, 100);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BATTERY_GetReadings(bool bDisplayBatteryLevel)
|
||||
void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
|
||||
{
|
||||
const uint8_t PreviousBatteryLevel = gBatteryDisplayLevel;
|
||||
const uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4;
|
||||
|
||||
gBatteryDisplayLevel = 0;
|
||||
|
||||
if (Voltage >= gBatteryCalibration[5])
|
||||
gBatteryDisplayLevel = 11;
|
||||
else
|
||||
if (Voltage >= ((gBatteryCalibration[4] + gBatteryCalibration[5]) / 2))
|
||||
gBatteryDisplayLevel = 10;
|
||||
else
|
||||
if (Voltage >= gBatteryCalibration[4])
|
||||
gBatteryDisplayLevel = 9;
|
||||
else
|
||||
if (Voltage >= ((gBatteryCalibration[3] + gBatteryCalibration[4]) / 2))
|
||||
gBatteryDisplayLevel = 8;
|
||||
else
|
||||
if (Voltage >= gBatteryCalibration[3])
|
||||
gBatteryDisplayLevel = 7;
|
||||
else
|
||||
if (Voltage >= ((gBatteryCalibration[2] + gBatteryCalibration[3]) / 2))
|
||||
gBatteryDisplayLevel = 6;
|
||||
else
|
||||
if (Voltage >= gBatteryCalibration[2])
|
||||
gBatteryDisplayLevel = 5;
|
||||
else
|
||||
if (Voltage >= ((gBatteryCalibration[1] + gBatteryCalibration[2]) / 2))
|
||||
gBatteryDisplayLevel = 4;
|
||||
else
|
||||
if (Voltage >= gBatteryCalibration[1])
|
||||
gBatteryDisplayLevel = 3;
|
||||
else
|
||||
if (Voltage >= ((gBatteryCalibration[0] + gBatteryCalibration[1]) / 2))
|
||||
gBatteryDisplayLevel = 2;
|
||||
else
|
||||
if (Voltage >= gBatteryCalibration[0])
|
||||
gBatteryDisplayLevel = 1;
|
||||
|
||||
gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3];
|
||||
|
||||
if ((gScreenToDisplay == DISPLAY_MENU) && gMenuCursor == MENU_VOL)
|
||||
if(gBatteryVoltageAverage > 890)
|
||||
gBatteryDisplayLevel = 7; // battery overvoltage
|
||||
else if(gBatteryVoltageAverage < 630)
|
||||
gBatteryDisplayLevel = 0; // battery critical
|
||||
else {
|
||||
gBatteryDisplayLevel = 1;
|
||||
const uint8_t levels[] = {5,17,41,65,88};
|
||||
uint8_t perc = BATTERY_VoltsToPercent(gBatteryVoltageAverage);
|
||||
for(uint8_t i = 6; i >= 1; i--){
|
||||
if (perc > levels[i-2]) {
|
||||
gBatteryDisplayLevel = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((gScreenToDisplay == DISPLAY_MENU) && UI_MENU_GetCurrentMenuId() == MENU_VOL)
|
||||
gUpdateDisplay = true;
|
||||
|
||||
if (gBatteryCurrent < 501)
|
||||
@@ -149,7 +144,9 @@ void BATTERY_GetReadings(bool bDisplayBatteryLevel)
|
||||
|
||||
if (PreviousBatteryLevel != gBatteryDisplayLevel)
|
||||
{
|
||||
if (gBatteryDisplayLevel < 2)
|
||||
if(gBatteryDisplayLevel > 2)
|
||||
gLowBatteryConfirmed = false;
|
||||
else if (gBatteryDisplayLevel < 2)
|
||||
{
|
||||
gLowBattery = true;
|
||||
}
|
||||
@@ -161,6 +158,68 @@ void BATTERY_GetReadings(bool bDisplayBatteryLevel)
|
||||
UI_DisplayBattery(gBatteryDisplayLevel, gLowBatteryBlink);
|
||||
}
|
||||
|
||||
gLowBatteryCountdown = 0;
|
||||
if(!gLowBatteryConfirmed)
|
||||
gUpdateDisplay = true;
|
||||
|
||||
lowBatteryCountdown = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void BATTERY_TimeSlice500ms(void)
|
||||
{
|
||||
if (!gLowBattery) {
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,22 @@ extern uint16_t gBatteryVoltages[4];
|
||||
extern uint16_t gBatteryVoltageAverage;
|
||||
extern uint8_t gBatteryDisplayLevel;
|
||||
extern bool gChargingWithTypeC;
|
||||
extern bool gLowBattery;
|
||||
extern bool gLowBatteryBlink;
|
||||
extern bool gLowBattery;
|
||||
extern bool gLowBatteryConfirmed;
|
||||
extern uint16_t gBatteryCheckCounter;
|
||||
|
||||
extern volatile uint16_t gPowerSave_10ms;
|
||||
|
||||
uint8_t BATTERY_VoltsToPercent(uint16_t voltage_10mV);
|
||||
typedef enum {
|
||||
BATTERY_TYPE_1600_MAH,
|
||||
BATTERY_TYPE_2200_MAH,
|
||||
BATTERY_TYPE_UNKNOWN
|
||||
} BATTERY_Type_t;
|
||||
|
||||
|
||||
unsigned int BATTERY_VoltsToPercent(unsigned int voltage_10mV);
|
||||
void BATTERY_GetReadings(bool bDisplayBatteryLevel);
|
||||
void BATTERY_TimeSlice500ms(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -39,15 +39,16 @@ BOOT_Mode_t BOOT_GetMode(void)
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
||||
return BOOT_MODE_NORMAL;
|
||||
return BOOT_MODE_NORMAL; // PTT not pressed
|
||||
Keys[i] = KEYBOARD_Poll();
|
||||
SYSTEM_DelayMs(20);
|
||||
}
|
||||
|
||||
if (Keys[0] == Keys[1])
|
||||
{
|
||||
gKeyReading0 = Keys[0];
|
||||
gKeyReading1 = Keys[0];
|
||||
gKeyReading0 = Keys[0];
|
||||
gKeyReading1 = Keys[0];
|
||||
|
||||
gDebounceCounter = 2;
|
||||
|
||||
if (Keys[0] == KEY_SIDE1)
|
||||
@@ -66,16 +67,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
|
||||
{
|
||||
if (Mode == BOOT_MODE_F_LOCK)
|
||||
{
|
||||
// enable all the menu items
|
||||
gMenuListCount = 0;
|
||||
// while (MenuList[gMenuListCount].name != NULL)
|
||||
while (MenuList[gMenuListCount].name[0] != '\0')
|
||||
gMenuListCount++;
|
||||
|
||||
gMenuCursor = MENU_350TX;
|
||||
gSubMenuSelection = gSetting_350TX;
|
||||
GUI_SelectNextDisplay(DISPLAY_MENU);
|
||||
gF_LOCK = true;
|
||||
}
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
else
|
||||
@@ -83,18 +75,21 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
|
||||
{
|
||||
gEeprom.DUAL_WATCH = DUAL_WATCH_OFF;
|
||||
gEeprom.BATTERY_SAVE = 0;
|
||||
gEeprom.VOX_SWITCH = false;
|
||||
#ifdef ENABLE_VOX
|
||||
gEeprom.VOX_SWITCH = false;
|
||||
#endif
|
||||
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
|
||||
gEeprom.AUTO_KEYPAD_LOCK = false;
|
||||
gEeprom.KEY_1_SHORT_PRESS_ACTION = 0;
|
||||
gEeprom.KEY_1_LONG_PRESS_ACTION = 0;
|
||||
gEeprom.KEY_2_SHORT_PRESS_ACTION = 0;
|
||||
gEeprom.KEY_2_LONG_PRESS_ACTION = 0;
|
||||
gEeprom.KEY_1_SHORT_PRESS_ACTION = ACTION_OPT_NONE;
|
||||
gEeprom.KEY_1_LONG_PRESS_ACTION = ACTION_OPT_NONE;
|
||||
gEeprom.KEY_2_SHORT_PRESS_ACTION = ACTION_OPT_NONE;
|
||||
gEeprom.KEY_2_LONG_PRESS_ACTION = ACTION_OPT_NONE;
|
||||
gEeprom.KEY_M_LONG_PRESS_ACTION = ACTION_OPT_NONE;
|
||||
|
||||
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_LAST - 1, 5, 41002500);
|
||||
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_LAST - 1, 41002500);
|
||||
|
||||
gRxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_NARROW;
|
||||
gRxVfo->OUTPUT_POWER = 0;
|
||||
gRxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_WIDE;
|
||||
gRxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
|
||||
|
||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||
|
||||
@@ -105,6 +100,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
|
||||
BK4819_ResetFSK();
|
||||
|
||||
gAircopyState = AIRCOPY_READY;
|
||||
|
||||
GUI_SelectNextDisplay(DISPLAY_AIRCOPY);
|
||||
}
|
||||
#endif
|
||||
|
||||
BIN
images/batcal.jpg
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
images/codespace1.png
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
images/codespace2.png
Normal file
|
After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
13
init.c
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
extern uint32_t __bss_start__[];
|
||||
extern uint32_t __bss_end__[];
|
||||
@@ -29,22 +30,18 @@ void DATA_Init(void);
|
||||
|
||||
void BSS_Init(void)
|
||||
{
|
||||
uint32_t *pBss;
|
||||
|
||||
for (pBss = __bss_start__; pBss < __bss_end__; pBss++) {
|
||||
for (uint32_t *pBss = __bss_start__; pBss < __bss_end__; pBss++) {
|
||||
*pBss = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DATA_Init(void)
|
||||
{
|
||||
volatile uint32_t *pDataRam = (volatile uint32_t *)sram_data_start;
|
||||
volatile uint32_t *pDataRam = (volatile uint32_t *)sram_data_start;
|
||||
volatile uint32_t *pDataFlash = (volatile uint32_t *)flash_data_start;
|
||||
uint32_t Size = (uint32_t)sram_data_end - (uint32_t)sram_data_start;
|
||||
uint32_t i;
|
||||
uint32_t Size = (uint32_t)sram_data_end - (uint32_t)sram_data_start;
|
||||
|
||||
for (i = 0; i < Size / 4; i++) {
|
||||
for (unsigned int i = 0; i < (Size / 4); i++) {
|
||||
*pDataRam++ = *pDataFlash++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
152
main.c
@@ -14,43 +14,52 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h> // NULL
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
#include "am_fix.h"
|
||||
#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/dtmf.h"
|
||||
#include "audio.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "bsp/dp32g030/syscon.h"
|
||||
#include "board.h"
|
||||
|
||||
#include "driver/backlight.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/system.h"
|
||||
#include "driver/systick.h"
|
||||
#include "driver/uart.h"
|
||||
#ifdef ENABLE_UART
|
||||
#include "driver/uart.h"
|
||||
#endif
|
||||
|
||||
#include "helper/battery.h"
|
||||
#include "helper/boot.h"
|
||||
#include "misc.h"
|
||||
#include "radio.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "ui/lock.h"
|
||||
#include "ui/welcome.h"
|
||||
#include "ui/menu.h"
|
||||
#include "version.h"
|
||||
|
||||
void _putchar(char c)
|
||||
void _putchar(__attribute__((unused)) char c)
|
||||
{
|
||||
|
||||
#ifdef ENABLE_UART
|
||||
UART_Send((uint8_t *)&c, 1);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void Main(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
// Enable clock gating of blocks we need
|
||||
SYSCON_DEV_CLK_GATE = 0
|
||||
| SYSCON_DEV_CLK_GATE_GPIOA_BITS_ENABLE
|
||||
@@ -60,20 +69,22 @@ void Main(void)
|
||||
| SYSCON_DEV_CLK_GATE_SPI0_BITS_ENABLE
|
||||
| SYSCON_DEV_CLK_GATE_SARADC_BITS_ENABLE
|
||||
| SYSCON_DEV_CLK_GATE_CRC_BITS_ENABLE
|
||||
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE;
|
||||
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE
|
||||
| SYSCON_DEV_CLK_GATE_PWM_PLUS0_BITS_ENABLE;
|
||||
|
||||
|
||||
SYSTICK_Init();
|
||||
BOARD_Init();
|
||||
UART_Init();
|
||||
|
||||
boot_counter_10ms = 250; // 2.5 sec
|
||||
|
||||
|
||||
#ifdef ENABLE_UART
|
||||
UART_Init();
|
||||
UART_Send(UART_Version, strlen(UART_Version));
|
||||
#endif
|
||||
|
||||
// Not implementing authentic device checks
|
||||
|
||||
memset(&gEeprom, 0, sizeof(gEeprom));
|
||||
|
||||
memset(gDTMF_String, '-', sizeof(gDTMF_String));
|
||||
gDTMF_String[sizeof(gDTMF_String) - 1] = 0;
|
||||
|
||||
@@ -81,9 +92,9 @@ void Main(void)
|
||||
|
||||
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);
|
||||
|
||||
BOARD_EEPROM_Init();
|
||||
|
||||
BOARD_EEPROM_LoadMoreSettings();
|
||||
SETTINGS_InitEEPROM();
|
||||
SETTINGS_WriteBuildOptions();
|
||||
SETTINGS_LoadCalibration();
|
||||
|
||||
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
|
||||
@@ -92,37 +103,65 @@ void Main(void)
|
||||
|
||||
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);
|
||||
|
||||
BATTERY_GetReadings(false);
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
AM_fix_init();
|
||||
#endif
|
||||
#ifdef ENABLE_AM_FIX
|
||||
AM_fix_init();
|
||||
#endif
|
||||
|
||||
// count the number of menu list items
|
||||
const BOOT_Mode_t BootMode = BOOT_GetMode();
|
||||
|
||||
if (BootMode == BOOT_MODE_F_LOCK)
|
||||
{
|
||||
gF_LOCK = true; // flag to say include the hidden menu items
|
||||
}
|
||||
|
||||
// count the number of menu items
|
||||
gMenuListCount = 0;
|
||||
while (MenuList[gMenuListCount].name[0] != '\0')
|
||||
while (MenuList[gMenuListCount].name[0] != '\0') {
|
||||
if(!gF_LOCK && MenuList[gMenuListCount].menu_id == FIRST_HIDDEN_MENU_ITEM)
|
||||
break;
|
||||
|
||||
gMenuListCount++;
|
||||
gMenuListCount -= 8; // disable the last 'n' items
|
||||
|
||||
if (!gChargingWithTypeC && !gBatteryDisplayLevel)
|
||||
}
|
||||
|
||||
// wait for user to release all butts before moving on
|
||||
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) ||
|
||||
KEYBOARD_Poll() != KEY_INVALID ||
|
||||
BootMode != BOOT_MODE_NORMAL)
|
||||
{ // keys are pressed
|
||||
UI_DisplayReleaseKeys();
|
||||
BACKLIGHT_TurnOn();
|
||||
|
||||
// 500ms
|
||||
for (int i = 0; i < 50;)
|
||||
{
|
||||
i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0;
|
||||
SYSTEM_DelayMs(10);
|
||||
}
|
||||
gKeyReading0 = KEY_INVALID;
|
||||
gKeyReading1 = KEY_INVALID;
|
||||
gDebounceCounter = 0;
|
||||
}
|
||||
|
||||
if (!gChargingWithTypeC && gBatteryDisplayLevel == 0)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
||||
|
||||
if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
||||
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) // backlight is not set to be always on
|
||||
BACKLIGHT_TurnOff(); // turn the backlight OFF
|
||||
else
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON
|
||||
BACKLIGHT_TurnOn(); // turn the backlight ON
|
||||
|
||||
gReducedService = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOT_Mode_t BootMode;
|
||||
|
||||
UI_DisplayWelcome();
|
||||
|
||||
BACKLIGHT_TurnOn();
|
||||
|
||||
if (gEeprom.POWER_ON_DISPLAY_MODE != POWER_ON_DISPLAY_MODE_NONE)
|
||||
@@ -131,24 +170,24 @@ void Main(void)
|
||||
{
|
||||
if (KEYBOARD_Poll() != KEY_INVALID)
|
||||
{ // halt boot beeps
|
||||
boot_counter_10ms = 0;
|
||||
boot_counter_10ms = 0;
|
||||
break;
|
||||
}
|
||||
#ifdef ENABLE_BOOT_BEEPS
|
||||
if ((boot_counter_10ms % 25) == 0)
|
||||
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
|
||||
#endif
|
||||
#ifdef ENABLE_BOOT_BEEPS
|
||||
if ((boot_counter_10ms % 25) == 0)
|
||||
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
BootMode = BOOT_GetMode();
|
||||
|
||||
#ifdef ENABLE_PWRON_PASSWORD
|
||||
if (gEeprom.POWER_ON_PASSWORD < 1000000)
|
||||
{
|
||||
bIsInLockScreen = true;
|
||||
UI_DisplayLock();
|
||||
bIsInLockScreen = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOT_ProcessMode(BootMode);
|
||||
|
||||
@@ -156,45 +195,40 @@ void Main(void)
|
||||
|
||||
gUpdateStatus = true;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
#ifdef ENABLE_VOICE
|
||||
{
|
||||
uint8_t Channel;
|
||||
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_WELCOME);
|
||||
|
||||
Channel = gEeprom.ScreenChannel[gEeprom.TX_CHANNEL];
|
||||
Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
|
||||
if (IS_MR_CHANNEL(Channel))
|
||||
{
|
||||
AUDIO_SetVoiceID(1, VOICE_ID_CHANNEL_MODE);
|
||||
AUDIO_SetDigitVoice(2, Channel + 1);
|
||||
}
|
||||
else
|
||||
if (IS_FREQ_CHANNEL(Channel))
|
||||
else if (IS_FREQ_CHANNEL(Channel))
|
||||
AUDIO_SetVoiceID(1, VOICE_ID_FREQUENCY_MODE);
|
||||
|
||||
AUDIO_PlaySingleVoice(0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
RADIO_ConfigureNOAA();
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
RADIO_ConfigureNOAA();
|
||||
#endif
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (true) {
|
||||
APP_Update();
|
||||
|
||||
if (gNextTimeslice)
|
||||
{
|
||||
APP_TimeSlice10ms();
|
||||
gNextTimeslice = false;
|
||||
}
|
||||
if (gNextTimeslice) {
|
||||
|
||||
if (gNextTimeslice_500ms)
|
||||
{
|
||||
APP_TimeSlice500ms();
|
||||
gNextTimeslice_500ms = false;
|
||||
APP_TimeSlice10ms();
|
||||
|
||||
if (gNextTimeslice_500ms) {
|
||||
APP_TimeSlice500ms();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
140
misc.c
@@ -17,19 +17,24 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
|
||||
const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds
|
||||
const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds
|
||||
const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms
|
||||
const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds
|
||||
const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds
|
||||
|
||||
const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds
|
||||
const uint8_t vfo_state_resume_countdown_500ms = 2500 / 500; // 2.5 seconds
|
||||
|
||||
const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds
|
||||
const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes
|
||||
|
||||
const uint8_t DTMF_RX_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
const uint8_t DTMF_RX_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver
|
||||
const uint8_t DTMF_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds
|
||||
const uint8_t DTMF_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for
|
||||
const uint8_t DTMF_txstop_countdown_500ms = 3000 / 500; // 6 seconds
|
||||
#endif
|
||||
|
||||
const uint8_t key_input_timeout_500ms = 8000 / 500; // 8 seconds
|
||||
|
||||
@@ -44,20 +49,27 @@ const uint16_t dual_watch_count_after_rx_10ms = 1000 / 10; // 1 sec afte
|
||||
const uint16_t dual_watch_count_after_1_10ms = 5000 / 10; // 5 sec
|
||||
const uint16_t dual_watch_count_after_2_10ms = 3600 / 10; // 3.6 sec
|
||||
const uint16_t dual_watch_count_noaa_10ms = 70 / 10; // 70ms
|
||||
const uint16_t dual_watch_count_after_vox_10ms = 200 / 10; // 200ms
|
||||
#ifdef ENABLE_VOX
|
||||
const uint16_t dual_watch_count_after_vox_10ms = 200 / 10; // 200ms
|
||||
#endif
|
||||
const uint16_t dual_watch_count_toggle_10ms = 100 / 10; // 100ms between VFO toggles
|
||||
|
||||
const uint16_t scan_pause_delay_in_1_10ms = 5000 / 10; // 5 seconds
|
||||
const uint16_t scan_pause_delay_in_2_10ms = 500 / 10; // 500ms
|
||||
const uint16_t scan_pause_delay_in_3_10ms = 200 / 10; // 200ms
|
||||
const uint16_t scan_pause_delay_in_4_10ms = 300 / 10; // 300ms
|
||||
const uint16_t scan_pause_delay_in_5_10ms = 1000 / 10; // 1 sec
|
||||
const uint16_t scan_pause_delay_in_6_10ms = 100 / 10; // 100ms
|
||||
const uint16_t scan_pause_delay_in_7_10ms = 3600 / 10; // 3.6 seconds
|
||||
|
||||
const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds
|
||||
|
||||
const uint16_t power_save1_10ms = 100 / 10; // 100ms
|
||||
const uint16_t power_save2_10ms = 200 / 10; // 200ms
|
||||
|
||||
const uint16_t vox_stop_count_down_10ms = 1000 / 10; // 1 second
|
||||
#ifdef ENABLE_VOX
|
||||
const uint16_t vox_stop_count_down_10ms = 1000 / 10; // 1 second
|
||||
#endif
|
||||
|
||||
const uint16_t NOAA_countdown_10ms = 5000 / 10; // 5 seconds
|
||||
const uint16_t NOAA_countdown_2_10ms = 500 / 10; // 500ms
|
||||
@@ -68,20 +80,21 @@ const uint32_t gDefaultAesKey[4] = {0x4AA5CC60, 0x0312CC5F, 0x
|
||||
const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31};
|
||||
|
||||
bool gSetting_350TX;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
bool gSetting_KILLED;
|
||||
#endif
|
||||
bool gSetting_200TX;
|
||||
bool gSetting_500TX;
|
||||
bool gSetting_350EN;
|
||||
bool gSetting_TX_EN;
|
||||
uint8_t gSetting_F_LOCK;
|
||||
bool gSetting_ScrambleEnable;
|
||||
|
||||
enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
bool gSetting_AM_fix;
|
||||
#endif
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
uint8_t gSetting_AM_fix_test1 = 0;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AUDIO_BAR
|
||||
bool gSetting_mic_bar;
|
||||
#endif
|
||||
@@ -95,17 +108,12 @@ bool bHasCustomAesKey;
|
||||
uint32_t gChallenge[4];
|
||||
uint8_t gTryCount;
|
||||
|
||||
uint8_t gEEPROM_1EC0_0[8];
|
||||
uint8_t gEEPROM_1EC0_1[8];
|
||||
uint8_t gEEPROM_1EC0_2[8];
|
||||
uint8_t gEEPROM_1EC0_3[8];
|
||||
|
||||
uint16_t gEEPROM_RSSI_CALIB[2][4];
|
||||
uint16_t gEEPROM_RSSI_CALIB[7][4];
|
||||
|
||||
uint16_t gEEPROM_1F8A;
|
||||
uint16_t gEEPROM_1F8C;
|
||||
|
||||
uint8_t gMR_ChannelAttributes[FREQ_CHANNEL_LAST + 1];
|
||||
ChannelAttributes_t gMR_ChannelAttributes[FREQ_CHANNEL_LAST + 1];
|
||||
|
||||
volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms;
|
||||
|
||||
@@ -115,9 +123,10 @@ volatile bool gSchedulePowerSave;
|
||||
volatile bool gScheduleDualWatch = true;
|
||||
|
||||
volatile uint16_t gDualWatchCountdown_10ms;
|
||||
volatile bool gDualWatchCountdownExpired = true;
|
||||
bool gDualWatchActive = false;
|
||||
|
||||
volatile uint8_t gSerialConfigCountDown_500ms;
|
||||
|
||||
volatile bool gNextTimeslice_500ms;
|
||||
|
||||
volatile uint16_t gTxTimerCountdown_500ms;
|
||||
@@ -125,6 +134,8 @@ volatile bool gTxTimeoutReached;
|
||||
|
||||
volatile uint16_t gTailNoteEliminationCountdown_10ms;
|
||||
|
||||
volatile uint8_t gVFOStateResumeCountdown_500ms;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
volatile uint16_t gNOAA_Countdown_10ms;
|
||||
#endif
|
||||
@@ -132,7 +143,7 @@ volatile uint16_t gTailNoteEliminationCountdown_10ms;
|
||||
bool gEnableSpeaker;
|
||||
uint8_t gKeyInputCountdown = 0;
|
||||
uint8_t gKeyLockCountdown;
|
||||
uint8_t gRTTECountdown;
|
||||
uint8_t gRTTECountdown_10ms;
|
||||
bool bIsInLockScreen;
|
||||
uint8_t gUpdateStatus;
|
||||
uint8_t gFoundCTCSS;
|
||||
@@ -144,12 +155,15 @@ uint8_t gVFO_RSSI_bar_level[2];
|
||||
|
||||
uint8_t gReducedService;
|
||||
uint8_t gBatteryVoltageIndex;
|
||||
CssScanMode_t gCssScanMode;
|
||||
bool gUpdateRSSI;
|
||||
#ifdef ENABLE_ALARM
|
||||
bool gCssBackgroundScan;
|
||||
|
||||
volatile bool gScheduleScanListen = true;
|
||||
volatile uint16_t gScanPauseDelayIn_10ms;
|
||||
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
AlarmState_t gAlarmState;
|
||||
#endif
|
||||
uint8_t gVoltageMenuCountdown;
|
||||
uint16_t gMenuCountdown;
|
||||
bool gPttWasReleased;
|
||||
bool gPttWasPressed;
|
||||
uint8_t gKeypadLocked;
|
||||
@@ -163,35 +177,32 @@ bool gRequestSaveSettings;
|
||||
bool gRequestSaveFM;
|
||||
#endif
|
||||
bool gFlagPrepareTX;
|
||||
|
||||
bool gFlagAcceptSetting;
|
||||
bool gFlagRefreshSetting;
|
||||
bool gFlagSaveVfo;
|
||||
bool gFlagSaveSettings;
|
||||
bool gFlagSaveChannel;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
bool gFlagSaveFM;
|
||||
#endif
|
||||
uint8_t gDTMF_RequestPending;
|
||||
bool g_CDCSS_Lost;
|
||||
uint8_t gCDCSSCodeType;
|
||||
bool g_CTCSS_Lost;
|
||||
bool g_CxCSS_TAIL_Found;
|
||||
bool g_VOX_Lost;
|
||||
#ifdef ENABLE_VOX
|
||||
bool g_VOX_Lost;
|
||||
bool gVOX_NoiseDetected;
|
||||
uint16_t gVoxResumeCountdown;
|
||||
uint16_t gVoxPauseCountdown;
|
||||
#endif
|
||||
bool g_SquelchLost;
|
||||
uint8_t gFlashLightState;
|
||||
bool gVOX_NoiseDetected;
|
||||
uint16_t gVoxResumeCountdown;
|
||||
uint16_t gVoxPauseCountdown;
|
||||
|
||||
volatile uint16_t gFlashLightBlinkCounter;
|
||||
|
||||
bool gFlagEndTransmission;
|
||||
uint16_t gLowBatteryCountdown;
|
||||
uint8_t gNextMrChannel;
|
||||
ReceptionMode_t gRxReceptionMode;
|
||||
uint8_t gRestoreMrChannel;
|
||||
uint8_t gCurrentScanList;
|
||||
uint8_t gPreviousMrChannel;
|
||||
uint32_t gRestoreFrequency;
|
||||
uint8_t gRxVfoIsActive;
|
||||
|
||||
bool gRxVfoIsActive;
|
||||
#ifdef ENABLE_ALARM
|
||||
uint8_t gAlarmToneCounter;
|
||||
uint16_t gAlarmRunningCounter;
|
||||
@@ -200,13 +211,9 @@ bool gKeyBeingHeld;
|
||||
bool gPttIsPressed;
|
||||
uint8_t gPttDebounceCounter;
|
||||
uint8_t gMenuListCount;
|
||||
uint8_t gBackupCROSS_BAND_RX_TX;
|
||||
uint8_t gBackup_CROSS_BAND_RX_TX;
|
||||
uint8_t gScanDelay_10ms;
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
uint8_t gAircopySendCountdown;
|
||||
#endif
|
||||
uint8_t gFSKWriteIndex;
|
||||
uint8_t gNeverUsed;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
bool gIsNoaaMode;
|
||||
@@ -214,13 +221,17 @@ uint8_t gNeverUsed;
|
||||
#endif
|
||||
|
||||
bool gUpdateDisplay;
|
||||
bool gF_LOCK;
|
||||
|
||||
bool gF_LOCK = false;
|
||||
|
||||
uint8_t gShowChPrefix;
|
||||
|
||||
volatile bool gNextTimeslice;
|
||||
volatile uint8_t gFoundCDCSSCountdown_10ms;
|
||||
volatile uint8_t gFoundCTCSSCountdown_10ms;
|
||||
volatile uint16_t gVoxStopCountdown_10ms;
|
||||
#ifdef ENABLE_VOX
|
||||
volatile uint16_t gVoxStopCountdown_10ms;
|
||||
#endif
|
||||
volatile bool gNextTimeslice40ms;
|
||||
#ifdef ENABLE_NOAA
|
||||
volatile uint16_t gNOAACountdown_10ms = 0;
|
||||
@@ -233,38 +244,11 @@ volatile bool gFlagTailNoteEliminationComplete;
|
||||
|
||||
volatile uint8_t boot_counter_10ms;
|
||||
|
||||
int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO
|
||||
|
||||
uint8_t gIsLocked = 0xFF;
|
||||
|
||||
// --------
|
||||
|
||||
void NUMBER_Get(char *pDigits, uint32_t *pInteger)
|
||||
{
|
||||
unsigned int i;
|
||||
uint32_t Multiplier = 10000000;
|
||||
uint32_t Value = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (pDigits[i] > 9)
|
||||
break;
|
||||
Value += pDigits[i] * Multiplier;
|
||||
Multiplier /= 10U;
|
||||
}
|
||||
*pInteger = Value;
|
||||
}
|
||||
inline void FUNCTION_NOP() { ; }
|
||||
|
||||
void NUMBER_ToDigits(uint32_t Value, char *pDigits)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
const uint32_t Result = Value / 10U;
|
||||
pDigits[7 - i] = Value - (Result * 10U);
|
||||
Value = Result;
|
||||
}
|
||||
pDigits[8] = 0;
|
||||
}
|
||||
|
||||
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit)
|
||||
{
|
||||
@@ -278,3 +262,15 @@ int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit,
|
||||
|
||||
return Base;
|
||||
}
|
||||
|
||||
unsigned long StrToUL(const char * str)
|
||||
{
|
||||
unsigned long ul = 0;
|
||||
for(uint8_t i = 0; i < strlen(str); i++){
|
||||
char c = str[i];
|
||||
if(c < '0' || c > '9')
|
||||
break;
|
||||
ul = ul * 10 + (uint8_t)(c-'0');
|
||||
}
|
||||
return ul;
|
||||
}
|
||||
|
||||
183
misc.h
@@ -24,33 +24,33 @@
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
#endif
|
||||
|
||||
#define IS_MR_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= MR_CHANNEL_LAST)
|
||||
#define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
|
||||
#define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL)
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
#define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST)
|
||||
#define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
|
||||
#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_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
|
||||
#define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL)
|
||||
#define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST)
|
||||
|
||||
enum {
|
||||
MR_CHANNEL_FIRST = 0,
|
||||
MR_CHANNEL_LAST = 199u,
|
||||
FREQ_CHANNEL_FIRST = 200u,
|
||||
FREQ_CHANNEL_LAST = 206u,
|
||||
#ifdef ENABLE_NOAA
|
||||
NOAA_CHANNEL_FIRST = 207u,
|
||||
NOAA_CHANNEL_LAST = 216u,
|
||||
#endif
|
||||
NOAA_CHANNEL_FIRST = 207u,
|
||||
NOAA_CHANNEL_LAST = 216u,
|
||||
LAST_CHANNEL
|
||||
};
|
||||
|
||||
enum {
|
||||
FLASHLIGHT_OFF = 0,
|
||||
FLASHLIGHT_ON,
|
||||
FLASHLIGHT_BLINK
|
||||
};
|
||||
|
||||
enum {
|
||||
VFO_CONFIGURE_NONE = 0,
|
||||
VFO_CONFIGURE,
|
||||
@@ -60,10 +60,9 @@ enum {
|
||||
enum AlarmState_t {
|
||||
ALARM_STATE_OFF = 0,
|
||||
ALARM_STATE_TXALARM,
|
||||
ALARM_STATE_ALARM,
|
||||
ALARM_STATE_SITE_ALARM,
|
||||
ALARM_STATE_TX1750
|
||||
};
|
||||
|
||||
typedef enum AlarmState_t AlarmState_t;
|
||||
|
||||
enum ReceptionMode_t {
|
||||
@@ -71,30 +70,31 @@ enum ReceptionMode_t {
|
||||
RX_MODE_DETECTED, // signal detected
|
||||
RX_MODE_LISTENING //
|
||||
};
|
||||
|
||||
typedef enum ReceptionMode_t ReceptionMode_t;
|
||||
|
||||
enum CssScanMode_t
|
||||
{
|
||||
CSS_SCAN_MODE_OFF = 0,
|
||||
CSS_SCAN_MODE_SCANNING,
|
||||
CSS_SCAN_MODE_FOUND,
|
||||
enum BacklightOnRxTx_t {
|
||||
BACKLIGHT_ON_TR_OFF,
|
||||
BACKLIGHT_ON_TR_TX,
|
||||
BACKLIGHT_ON_TR_RX,
|
||||
BACKLIGHT_ON_TR_TXRX
|
||||
};
|
||||
|
||||
typedef enum CssScanMode_t CssScanMode_t;
|
||||
|
||||
extern const uint8_t fm_resume_countdown_500ms;
|
||||
extern const uint8_t fm_radio_countdown_500ms;
|
||||
extern const uint16_t fm_play_countdown_scan_10ms;
|
||||
extern const uint16_t fm_play_countdown_noscan_10ms;
|
||||
extern const uint16_t fm_restore_countdown_10ms;
|
||||
|
||||
extern const uint8_t vfo_state_resume_countdown_500ms;
|
||||
|
||||
extern const uint8_t menu_timeout_500ms;
|
||||
extern const uint16_t menu_timeout_long_500ms;
|
||||
|
||||
extern const uint8_t DTMF_RX_live_timeout_500ms;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
extern const uint8_t DTMF_RX_timeout_500ms;
|
||||
extern const uint8_t DTMF_decode_ring_countdown_500ms;
|
||||
extern const uint8_t DTMF_txstop_countdown_500ms;
|
||||
#endif
|
||||
|
||||
extern const uint8_t key_input_timeout_500ms;
|
||||
|
||||
@@ -109,7 +109,9 @@ extern const uint16_t battery_save_count_10ms;
|
||||
extern const uint16_t power_save1_10ms;
|
||||
extern const uint16_t power_save2_10ms;
|
||||
|
||||
extern const uint16_t vox_stop_count_down_10ms;
|
||||
#ifdef ENABLE_VOX
|
||||
extern const uint16_t vox_stop_count_down_10ms;
|
||||
#endif
|
||||
|
||||
extern const uint16_t NOAA_countdown_10ms;
|
||||
extern const uint16_t NOAA_countdown_2_10ms;
|
||||
@@ -121,30 +123,39 @@ extern const uint16_t dual_watch_count_after_1_10ms;
|
||||
extern const uint16_t dual_watch_count_after_2_10ms;
|
||||
extern const uint16_t dual_watch_count_toggle_10ms;
|
||||
extern const uint16_t dual_watch_count_noaa_10ms;
|
||||
extern const uint16_t dual_watch_count_after_vox_10ms;
|
||||
#ifdef ENABLE_VOX
|
||||
extern const uint16_t dual_watch_count_after_vox_10ms;
|
||||
#endif
|
||||
|
||||
extern const uint16_t scan_pause_delay_in_1_10ms;
|
||||
extern const uint16_t scan_pause_delay_in_2_10ms;
|
||||
extern const uint16_t scan_pause_delay_in_3_10ms;
|
||||
extern const uint16_t scan_pause_delay_in_4_10ms;
|
||||
extern const uint16_t scan_pause_delay_in_5_10ms;
|
||||
extern const uint16_t scan_pause_delay_in_6_10ms;
|
||||
extern const uint16_t scan_pause_delay_in_7_10ms;
|
||||
|
||||
//extern const uint16_t gMax_bat_v;
|
||||
//extern const uint16_t gMin_bat_v;
|
||||
|
||||
extern const uint8_t gMicGain_dB2[5];
|
||||
|
||||
extern bool gSetting_350TX;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
extern bool gSetting_KILLED;
|
||||
#endif
|
||||
extern bool gSetting_200TX;
|
||||
extern bool gSetting_500TX;
|
||||
extern bool gSetting_350EN;
|
||||
extern bool gSetting_TX_EN;
|
||||
extern uint8_t gSetting_F_LOCK;
|
||||
extern bool gSetting_ScrambleEnable;
|
||||
|
||||
extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
extern bool gSetting_AM_fix;
|
||||
#endif
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
extern uint8_t gSetting_AM_fix_test1;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AUDIO_BAR
|
||||
extern bool gSetting_mic_bar;
|
||||
#endif
|
||||
@@ -159,17 +170,23 @@ extern bool bHasCustomAesKey;
|
||||
extern uint32_t gChallenge[4];
|
||||
extern uint8_t gTryCount;
|
||||
|
||||
extern uint8_t gEEPROM_1EC0_0[8];
|
||||
extern uint8_t gEEPROM_1EC0_1[8];
|
||||
extern uint8_t gEEPROM_1EC0_2[8];
|
||||
extern uint8_t gEEPROM_1EC0_3[8];
|
||||
|
||||
extern uint16_t gEEPROM_RSSI_CALIB[2][4];
|
||||
extern uint16_t gEEPROM_RSSI_CALIB[7][4];
|
||||
|
||||
extern uint16_t gEEPROM_1F8A;
|
||||
extern uint16_t gEEPROM_1F8C;
|
||||
|
||||
extern uint8_t gMR_ChannelAttributes[207];
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t
|
||||
band : 4,
|
||||
compander : 2,
|
||||
scanlist2 : 1,
|
||||
scanlist1 : 1;
|
||||
};
|
||||
uint8_t __val;
|
||||
} ChannelAttributes_t;
|
||||
|
||||
extern ChannelAttributes_t gMR_ChannelAttributes[207];
|
||||
|
||||
extern volatile uint16_t gBatterySaveCountdown_10ms;
|
||||
|
||||
@@ -179,9 +196,10 @@ extern volatile bool gSchedulePowerSave;
|
||||
extern volatile bool gScheduleDualWatch;
|
||||
|
||||
extern volatile uint16_t gDualWatchCountdown_10ms;
|
||||
extern volatile bool gDualWatchCountdownExpired;
|
||||
extern bool gDualWatchActive;
|
||||
|
||||
extern volatile uint8_t gSerialConfigCountDown_500ms;
|
||||
|
||||
extern volatile bool gNextTimeslice_500ms;
|
||||
|
||||
extern volatile uint16_t gTxTimerCountdown_500ms;
|
||||
@@ -189,16 +207,13 @@ extern volatile bool gTxTimeoutReached;
|
||||
|
||||
extern volatile uint16_t gTailNoteEliminationCountdown_10ms;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
extern volatile uint16_t gFmPlayCountdown_10ms;
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
extern volatile uint16_t gNOAA_Countdown_10ms;
|
||||
#endif
|
||||
extern bool gEnableSpeaker;
|
||||
extern uint8_t gKeyInputCountdown;
|
||||
extern uint8_t gKeyLockCountdown;
|
||||
extern uint8_t gRTTECountdown;
|
||||
extern uint8_t gRTTECountdown_10ms;
|
||||
extern bool bIsInLockScreen;
|
||||
extern uint8_t gUpdateStatus;
|
||||
extern uint8_t gFoundCTCSS;
|
||||
@@ -208,12 +223,26 @@ extern bool gEndOfRxDetectedMaybe;
|
||||
extern int16_t gVFO_RSSI[2];
|
||||
extern uint8_t gVFO_RSSI_bar_level[2];
|
||||
|
||||
// battery critical, limit functionality to minimum
|
||||
extern uint8_t gReducedService;
|
||||
extern uint8_t gBatteryVoltageIndex;
|
||||
extern CssScanMode_t gCssScanMode;
|
||||
extern bool gUpdateRSSI;
|
||||
|
||||
// we are searching CTCSS/DCS inside RX ctcss/dcs menu
|
||||
extern bool gCssBackgroundScan;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
SCAN_REV = -1,
|
||||
SCAN_OFF = 0,
|
||||
SCAN_FWD = +1
|
||||
};
|
||||
|
||||
extern volatile bool gScheduleScanListen;
|
||||
extern volatile uint16_t gScanPauseDelayIn_10ms;
|
||||
|
||||
extern AlarmState_t gAlarmState;
|
||||
extern uint8_t gVoltageMenuCountdown;
|
||||
extern uint16_t gMenuCountdown;
|
||||
extern bool gPttWasReleased;
|
||||
extern bool gPttWasPressed;
|
||||
extern bool gFlagReconfigureVfos;
|
||||
@@ -227,78 +256,78 @@ extern bool gRequestSaveSettings;
|
||||
#endif
|
||||
extern uint8_t gKeypadLocked;
|
||||
extern bool gFlagPrepareTX;
|
||||
extern bool gFlagAcceptSetting;
|
||||
extern bool gFlagRefreshSetting;
|
||||
extern bool gFlagSaveVfo;
|
||||
extern bool gFlagSaveSettings;
|
||||
extern bool gFlagSaveChannel;
|
||||
|
||||
extern bool gFlagAcceptSetting; // accept menu setting
|
||||
extern bool gFlagRefreshSetting; // refresh menu display
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
extern bool gFlagSaveFM;
|
||||
#endif
|
||||
extern uint8_t gDTMF_RequestPending;
|
||||
extern bool g_CDCSS_Lost;
|
||||
extern uint8_t gCDCSSCodeType;
|
||||
extern bool g_CTCSS_Lost;
|
||||
extern bool g_CxCSS_TAIL_Found;
|
||||
extern bool g_VOX_Lost;
|
||||
#ifdef ENABLE_VOX
|
||||
extern bool g_VOX_Lost;
|
||||
extern bool gVOX_NoiseDetected;
|
||||
extern uint16_t gVoxResumeCountdown;
|
||||
extern uint16_t gVoxPauseCountdown;
|
||||
#endif
|
||||
|
||||
// true means we are receiving signal
|
||||
extern bool g_SquelchLost;
|
||||
extern uint8_t gFlashLightState;
|
||||
extern bool gVOX_NoiseDetected;
|
||||
extern uint16_t gVoxResumeCountdown;
|
||||
extern uint16_t gVoxPauseCountdown;
|
||||
|
||||
extern volatile uint16_t gFlashLightBlinkCounter;
|
||||
|
||||
extern bool gFlagEndTransmission;
|
||||
extern uint16_t gLowBatteryCountdown;
|
||||
extern uint8_t gNextMrChannel;
|
||||
extern ReceptionMode_t gRxReceptionMode;
|
||||
extern uint8_t gRestoreMrChannel;
|
||||
extern uint8_t gCurrentScanList;
|
||||
extern uint8_t gPreviousMrChannel;
|
||||
extern uint32_t gRestoreFrequency;
|
||||
extern uint8_t gRxVfoIsActive;
|
||||
|
||||
//TRUE when dual watch is momentarly suspended and RX_VFO is locked to either last TX or RX
|
||||
extern bool gRxVfoIsActive;
|
||||
extern uint8_t gAlarmToneCounter;
|
||||
extern uint16_t gAlarmRunningCounter;
|
||||
extern bool gKeyBeingHeld;
|
||||
extern bool gPttIsPressed;
|
||||
extern uint8_t gPttDebounceCounter;
|
||||
extern uint8_t gMenuListCount;
|
||||
extern uint8_t gBackupCROSS_BAND_RX_TX;
|
||||
extern uint8_t gBackup_CROSS_BAND_RX_TX;
|
||||
extern uint8_t gScanDelay_10ms;
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
extern uint8_t gAircopySendCountdown;
|
||||
#endif
|
||||
extern uint8_t gFSKWriteIndex;
|
||||
extern uint8_t gNeverUsed;
|
||||
#ifdef ENABLE_NOAA
|
||||
extern bool gIsNoaaMode;
|
||||
extern uint8_t gNoaaChannel;
|
||||
#endif
|
||||
extern volatile bool gNextTimeslice;
|
||||
extern bool gUpdateDisplay;
|
||||
extern bool gF_LOCK;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
extern uint8_t gFM_ChannelPosition;
|
||||
#endif
|
||||
extern bool gF_LOCK;
|
||||
extern uint8_t gShowChPrefix;
|
||||
extern volatile uint8_t gFoundCDCSSCountdown_10ms;
|
||||
extern volatile uint8_t gFoundCTCSSCountdown_10ms;
|
||||
extern volatile uint16_t gVoxStopCountdown_10ms;
|
||||
#ifdef ENABLE_VOX
|
||||
extern volatile uint16_t gVoxStopCountdown_10ms;
|
||||
#endif
|
||||
extern volatile bool gNextTimeslice40ms;
|
||||
#ifdef ENABLE_NOAA
|
||||
extern volatile uint16_t gNOAACountdown_10ms;
|
||||
extern volatile bool gScheduleNOAA;
|
||||
#endif
|
||||
extern volatile bool gFlagTailNoteEliminationComplete;
|
||||
extern volatile uint8_t gVFOStateResumeCountdown_500ms;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
extern volatile bool gScheduleFM;
|
||||
#endif
|
||||
extern int16_t gCurrentRSSI[2]; // now one per VFO
|
||||
extern uint8_t gIsLocked;
|
||||
extern volatile uint8_t boot_counter_10ms;
|
||||
|
||||
void NUMBER_Get(char *pDigits, uint32_t *pInteger);
|
||||
void NUMBER_ToDigits(uint32_t Value, char *pDigits);
|
||||
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
||||
unsigned long StrToUL(const char * str);
|
||||
|
||||
void FUNCTION_NOP();
|
||||
|
||||
inline bool SerialConfigInProgress() { return gSerialConfigCountDown_500ms != 0; }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
102
radio.h
@@ -21,15 +21,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dcs.h"
|
||||
|
||||
enum {
|
||||
MR_CH_BAND_MASK = 0x0F << 0,
|
||||
#ifdef ENABLE_COMPANDER
|
||||
MR_CH_COMPAND = 3u << 4, // new
|
||||
#endif
|
||||
MR_CH_SCANLIST2 = 1u << 6,
|
||||
MR_CH_SCANLIST1 = 1u << 7
|
||||
};
|
||||
#include "frequencies.h"
|
||||
|
||||
enum {
|
||||
RADIO_CHANNEL_UP = 0x01u,
|
||||
@@ -42,40 +34,14 @@ enum {
|
||||
};
|
||||
|
||||
enum PTT_ID_t {
|
||||
PTT_ID_OFF = 0,
|
||||
PTT_ID_BOT,
|
||||
PTT_ID_EOT,
|
||||
PTT_ID_BOTH
|
||||
PTT_ID_OFF = 0, // OFF
|
||||
PTT_ID_TX_UP, // BEGIN OF TX
|
||||
PTT_ID_TX_DOWN, // END OF TX
|
||||
PTT_ID_BOTH, // BOTH
|
||||
PTT_ID_APOLLO // Apolo quindar tones
|
||||
};
|
||||
|
||||
typedef enum PTT_ID_t PTT_ID_t;
|
||||
|
||||
#if 0
|
||||
enum STEP_Setting_t
|
||||
{
|
||||
STEP_2_5kHz,
|
||||
STEP_5_0kHz,
|
||||
STEP_6_25kHz,
|
||||
STEP_10_0kHz,
|
||||
STEP_12_5kHz,
|
||||
STEP_25_0kHz,
|
||||
STEP_8_33kHz
|
||||
};
|
||||
#else
|
||||
enum STEP_Setting_t
|
||||
{
|
||||
STEP_1_25kHz,
|
||||
STEP_2_5kHz,
|
||||
STEP_6_25kHz,
|
||||
STEP_10_0kHz,
|
||||
STEP_12_5kHz,
|
||||
STEP_25_0kHz,
|
||||
STEP_8_33kHz
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef enum STEP_Setting_t STEP_Setting_t;
|
||||
|
||||
enum VfoState_t
|
||||
{
|
||||
VFO_STATE_NORMAL = 0,
|
||||
@@ -84,11 +50,26 @@ enum VfoState_t
|
||||
VFO_STATE_TX_DISABLE,
|
||||
VFO_STATE_TIMEOUT,
|
||||
VFO_STATE_ALARM,
|
||||
VFO_STATE_VOLTAGE_HIGH
|
||||
VFO_STATE_VOLTAGE_HIGH,
|
||||
_VFO_STATE_LAST_ELEMENT
|
||||
};
|
||||
|
||||
typedef enum VfoState_t VfoState_t;
|
||||
|
||||
typedef enum {
|
||||
MODULATION_FM,
|
||||
MODULATION_AM,
|
||||
MODULATION_USB,
|
||||
|
||||
#ifdef ENABLE_BYP_RAW_DEMODULATORS
|
||||
MODULATION_BYP,
|
||||
MODULATION_RAW,
|
||||
#endif
|
||||
|
||||
MODULATION_UKNOWN
|
||||
} ModulationMode_t;
|
||||
|
||||
extern const char gModulationStr[MODULATION_UKNOWN][4];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Frequency;
|
||||
@@ -101,7 +82,14 @@ typedef struct VFO_Info_t
|
||||
{
|
||||
FREQ_Config_t freq_config_RX;
|
||||
FREQ_Config_t freq_config_TX;
|
||||
|
||||
// this is for a purpose of the FrequencyReverse function
|
||||
// it points to freq_config_RX normally and to freq_config_TX if reverse function is active
|
||||
//
|
||||
FREQ_Config_t *pRX;
|
||||
|
||||
// this is for a purpose of the FrequencyReverse function
|
||||
// it points to freq_config_TX normally and to freq_config_RX if reverse function is active
|
||||
FREQ_Config_t *pTX;
|
||||
|
||||
uint32_t TX_OFFSET_FREQUENCY;
|
||||
@@ -130,46 +118,50 @@ typedef struct VFO_Info_t
|
||||
uint8_t SCANLIST2_PARTICIPATION;
|
||||
|
||||
uint8_t Band;
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
uint8_t DTMF_DECODING_ENABLE;
|
||||
#endif
|
||||
PTT_ID_t DTMF_PTT_ID_TX_MODE;
|
||||
|
||||
uint8_t BUSY_CHANNEL_LOCK;
|
||||
|
||||
uint8_t AM_mode;
|
||||
ModulationMode_t Modulation;
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
uint8_t Compander;
|
||||
#endif
|
||||
uint8_t Compander;
|
||||
|
||||
char Name[16];
|
||||
} VFO_Info_t;
|
||||
|
||||
// Settings of the main VFO that is selected by the user
|
||||
// The pointer follows gEeprom.TX_VFO index
|
||||
extern VFO_Info_t *gTxVfo;
|
||||
|
||||
// Settings of the actual VFO that is now used for RX,
|
||||
// It is being alternated by dual watch, and flipped by crossband
|
||||
// The pointer follows gEeprom.RX_VFO
|
||||
extern VFO_Info_t *gRxVfo;
|
||||
|
||||
// Equal to gTxVfo unless dual watch changes it on incomming transmition (this can only happen when XB off and DW on)
|
||||
extern VFO_Info_t *gCurrentVfo;
|
||||
|
||||
extern DCS_CodeType_t gSelectedCodeType;
|
||||
extern DCS_CodeType_t gCurrentCodeType;
|
||||
extern uint8_t gSelectedCode;
|
||||
|
||||
extern STEP_Setting_t gStepSetting;
|
||||
|
||||
extern VfoState_t VfoState[2];
|
||||
|
||||
bool RADIO_CheckValidChannel(uint16_t ChNum, bool bCheckScanList, uint8_t RadioNum);
|
||||
bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanList);
|
||||
uint8_t RADIO_FindNextChannel(uint8_t ChNum, int8_t Direction, bool bCheckScanList, uint8_t RadioNum);
|
||||
void RADIO_InitInfo(VFO_Info_t *pInfo, uint8_t ChannelSave, uint8_t ChIndex, uint32_t Frequency);
|
||||
void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency);
|
||||
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure);
|
||||
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo);
|
||||
void RADIO_ApplyOffset(VFO_Info_t *pInfo);
|
||||
void RADIO_SelectVfos(void);
|
||||
void RADIO_SetupRegisters(bool bSwitchToFunction0);
|
||||
void RADIO_SetupRegisters(bool switchToForeground);
|
||||
#ifdef ENABLE_NOAA
|
||||
void RADIO_ConfigureNOAA(void);
|
||||
#endif
|
||||
void RADIO_SetTxParameters(void);
|
||||
|
||||
void RADIO_SetupAGC(bool listeningAM, bool disable);
|
||||
void RADIO_SetModulation(ModulationMode_t modulation);
|
||||
void RADIO_SetVfoState(VfoState_t State);
|
||||
void RADIO_PrepareTX(void);
|
||||
void RADIO_EnableCxCSS(void);
|
||||
|
||||
49
scheduler.c
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "app/chFrScanner.h"
|
||||
#ifdef ENABLE_FMRADIO
|
||||
#include "app/fm.h"
|
||||
#endif
|
||||
@@ -52,19 +53,19 @@ void SystickHandler(void)
|
||||
|
||||
gNextTimeslice = true;
|
||||
|
||||
if ((gGlobalSysTickCounter % 50) == 0)
|
||||
{
|
||||
if ((gGlobalSysTickCounter % 50) == 0) {
|
||||
gNextTimeslice_500ms = true;
|
||||
|
||||
DECREMENT_AND_TRIGGER(gTxTimerCountdown_500ms, gTxTimeoutReached);
|
||||
DECREMENT(gSerialConfigCountDown_500ms);
|
||||
}
|
||||
|
||||
if ((gGlobalSysTickCounter & 3) == 0)
|
||||
gNextTimeslice40ms = true;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
DECREMENT(gNOAACountdown_10ms);
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
DECREMENT(gNOAACountdown_10ms);
|
||||
#endif
|
||||
|
||||
DECREMENT(gFoundCDCSSCountdown_10ms);
|
||||
|
||||
@@ -76,34 +77,36 @@ void SystickHandler(void)
|
||||
if (gCurrentFunction == FUNCTION_POWER_SAVE)
|
||||
DECREMENT_AND_TRIGGER(gPowerSave_10ms, gPowerSaveCountdownExpired);
|
||||
|
||||
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
|
||||
if (gScanStateDir == SCAN_OFF && !gCssBackgroundScan && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
|
||||
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
|
||||
DECREMENT_AND_TRIGGER(gDualWatchCountdown_10ms, gScheduleDualWatch);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
|
||||
if (gIsNoaaMode && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
if (gCurrentFunction != FUNCTION_RECEIVE)
|
||||
DECREMENT_AND_TRIGGER(gNOAA_Countdown_10ms, gScheduleNOAA);
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
if (gScanStateDir == SCAN_OFF && !gCssBackgroundScan && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
|
||||
if (gIsNoaaMode && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
if (gCurrentFunction != FUNCTION_RECEIVE)
|
||||
DECREMENT_AND_TRIGGER(gNOAA_Countdown_10ms, gScheduleNOAA);
|
||||
#endif
|
||||
|
||||
if (gScanState != SCAN_OFF || gCssScanMode == CSS_SCAN_MODE_SCANNING)
|
||||
if (gScanStateDir != SCAN_OFF)
|
||||
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
DECREMENT_AND_TRIGGER(ScanPauseDelayIn_10ms, gScheduleScanListen);
|
||||
DECREMENT_AND_TRIGGER(gScanPauseDelayIn_10ms, gScheduleScanListen);
|
||||
|
||||
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown_10ms, gFlagTailNoteEliminationComplete);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice_10ms, gFlagPlayQueuedVoice);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR)
|
||||
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
|
||||
DECREMENT_AND_TRIGGER(gFmPlayCountdown_10ms, gScheduleFM);
|
||||
#endif
|
||||
#ifdef ENABLE_VOICE
|
||||
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice_10ms, gFlagPlayQueuedVoice);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR)
|
||||
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
|
||||
DECREMENT_AND_TRIGGER(gFmPlayCountdown_10ms, gScheduleFM);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
DECREMENT(gVoxStopCountdown_10ms);
|
||||
#endif
|
||||
|
||||
DECREMENT(boot_counter_10ms);
|
||||
}
|
||||
|
||||
721
settings.c
@@ -16,36 +16,431 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "app/dtmf.h"
|
||||
#ifdef ENABLE_FMRADIO
|
||||
#include "app/fm.h"
|
||||
#endif
|
||||
#include "driver/bk1080.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/eeprom.h"
|
||||
#include "driver/uart.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
#include "ui/menu.h"
|
||||
|
||||
EEPROM_Config_t gEeprom;
|
||||
static const uint32_t gDefaultFrequencyTable[] =
|
||||
{
|
||||
14500000, //
|
||||
14550000, //
|
||||
43300000, //
|
||||
43320000, //
|
||||
43350000 //
|
||||
};
|
||||
|
||||
EEPROM_Config_t gEeprom = { 0 };
|
||||
|
||||
void SETTINGS_InitEEPROM(void)
|
||||
{
|
||||
uint8_t Data[16] = {0};
|
||||
// 0E70..0E77
|
||||
EEPROM_ReadBuffer(0x0E70, Data, 8);
|
||||
gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST;
|
||||
gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1;
|
||||
gEeprom.TX_TIMEOUT_TIMER = (Data[2] < 11) ? Data[2] : 1;
|
||||
#ifdef ENABLE_NOAA
|
||||
gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false;
|
||||
#endif
|
||||
gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false;
|
||||
#ifdef ENABLE_VOX
|
||||
gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false;
|
||||
gEeprom.VOX_LEVEL = (Data[6] < 10) ? Data[6] : 1;
|
||||
#endif
|
||||
gEeprom.MIC_SENSITIVITY = (Data[7] < 5) ? Data[7] : 4;
|
||||
|
||||
// 0E78..0E7F
|
||||
EEPROM_ReadBuffer(0x0E78, Data, 8);
|
||||
gEeprom.BACKLIGHT_MAX = (Data[0] & 0xF) <= 10 ? (Data[0] & 0xF) : 10;
|
||||
gEeprom.BACKLIGHT_MIN = (Data[0] >> 4) < gEeprom.BACKLIGHT_MAX ? (Data[0] >> 4) : 0;
|
||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||
gEeprom.BACKLIGHT_MIN_STAT = BLMIN_STAT_ON;
|
||||
#endif
|
||||
gEeprom.CHANNEL_DISPLAY_MODE = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode
|
||||
gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF;
|
||||
gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4;
|
||||
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A;
|
||||
gEeprom.BACKLIGHT_TIME = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 3;
|
||||
gEeprom.TAIL_TONE_ELIMINATION = (Data[6] < 2) ? Data[6] : false;
|
||||
gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true;
|
||||
|
||||
// 0E80..0E87
|
||||
EEPROM_ReadBuffer(0x0E80, Data, 8);
|
||||
gEeprom.ScreenChannel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||
gEeprom.ScreenChannel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||
gEeprom.MrChannel[0] = IS_MR_CHANNEL(Data[1]) ? Data[1] : MR_CHANNEL_FIRST;
|
||||
gEeprom.MrChannel[1] = IS_MR_CHANNEL(Data[4]) ? Data[4] : MR_CHANNEL_FIRST;
|
||||
gEeprom.FreqChannel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||
gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
|
||||
#ifdef ENABLE_NOAA
|
||||
gEeprom.NoaaChannel[0] = IS_NOAA_CHANNEL(Data[6]) ? Data[6] : NOAA_CHANNEL_FIRST;
|
||||
gEeprom.NoaaChannel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
void SETTINGS_SaveFM(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
{ // 0E88..0E8F
|
||||
struct
|
||||
{
|
||||
uint16_t Frequency;
|
||||
uint8_t Channel;
|
||||
bool IsChannelSelected;
|
||||
uint8_t Padding[4];
|
||||
} State;
|
||||
uint16_t selFreq;
|
||||
uint8_t selChn;
|
||||
uint8_t isMrMode:1;
|
||||
uint8_t band:2;
|
||||
//uint8_t space:2;
|
||||
} __attribute__((packed)) fmCfg;
|
||||
EEPROM_ReadBuffer(0x0E88, &fmCfg, 4);
|
||||
|
||||
memset(&State, 0xFF, sizeof(State));
|
||||
State.Channel = gEeprom.FM_SelectedChannel;
|
||||
State.Frequency = gEeprom.FM_SelectedFrequency;
|
||||
State.IsChannelSelected = gEeprom.FM_IsMrMode;
|
||||
gEeprom.FM_Band = fmCfg.band;
|
||||
//gEeprom.FM_Space = fmCfg.space;
|
||||
gEeprom.FM_SelectedFrequency =
|
||||
(fmCfg.selFreq >= BK1080_GetFreqLoLimit(gEeprom.FM_Band) && fmCfg.selFreq <= BK1080_GetFreqHiLimit(gEeprom.FM_Band)) ?
|
||||
fmCfg.selFreq : BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||
|
||||
gEeprom.FM_SelectedChannel = fmCfg.selChn;
|
||||
gEeprom.FM_IsMrMode = fmCfg.isMrMode;
|
||||
}
|
||||
|
||||
EEPROM_WriteBuffer(0x0E88, &State);
|
||||
for (i = 0; i < 5; i++)
|
||||
// 0E40..0E67
|
||||
EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels));
|
||||
FM_ConfigureChannelState();
|
||||
#endif
|
||||
|
||||
// 0E90..0E97
|
||||
EEPROM_ReadBuffer(0x0E90, Data, 8);
|
||||
gEeprom.BEEP_CONTROL = Data[0] & 1;
|
||||
gEeprom.KEY_M_LONG_PRESS_ACTION = ((Data[0] >> 1) < ACTION_OPT_LEN) ? (Data[0] >> 1) : ACTION_OPT_NONE;
|
||||
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
|
||||
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_NONE;
|
||||
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
|
||||
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE;
|
||||
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
|
||||
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false;
|
||||
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE;
|
||||
|
||||
// 0E98..0E9F
|
||||
EEPROM_ReadBuffer(0x0E98, Data, 8);
|
||||
memcpy(&gEeprom.POWER_ON_PASSWORD, Data, 4);
|
||||
|
||||
// 0EA0..0EA7
|
||||
EEPROM_ReadBuffer(0x0EA0, Data, 8);
|
||||
#ifdef ENABLE_VOICE
|
||||
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
|
||||
#endif
|
||||
#ifdef ENABLE_RSSI_BAR
|
||||
if((Data[1] < 200 && Data[1] > 90) && (Data[2] < Data[1]-9 && Data[1] < 160 && Data[2] > 50)) {
|
||||
gEeprom.S0_LEVEL = Data[1];
|
||||
gEeprom.S9_LEVEL = Data[2];
|
||||
}
|
||||
else {
|
||||
gEeprom.S0_LEVEL = 130;
|
||||
gEeprom.S9_LEVEL = 76;
|
||||
}
|
||||
#endif
|
||||
|
||||
// 0EA8..0EAF
|
||||
EEPROM_ReadBuffer(0x0EA8, Data, 8);
|
||||
#ifdef ENABLE_ALARM
|
||||
gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true;
|
||||
#endif
|
||||
gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF;
|
||||
gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0;
|
||||
gEeprom.TX_VFO = (Data[3] < 2) ? Data[3] : 0;
|
||||
gEeprom.BATTERY_TYPE = (Data[4] < BATTERY_TYPE_UNKNOWN) ? Data[4] : BATTERY_TYPE_1600_MAH;
|
||||
|
||||
// 0ED0..0ED7
|
||||
EEPROM_ReadBuffer(0x0ED0, Data, 8);
|
||||
gEeprom.DTMF_SIDE_TONE = (Data[0] < 2) ? Data[0] : true;
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*';
|
||||
gEeprom.DTMF_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#';
|
||||
gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0;
|
||||
gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 5) ? Data[4] : 10;
|
||||
#endif
|
||||
gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300;
|
||||
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 100;
|
||||
gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100;
|
||||
|
||||
// 0ED8..0EDF
|
||||
EEPROM_ReadBuffer(0x0ED8, Data, 8);
|
||||
gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 10 : 100;
|
||||
gEeprom.DTMF_CODE_INTERVAL_TIME = (Data[1] < 101) ? Data[1] * 10 : 100;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
gEeprom.PERMIT_REMOTE_KILL = (Data[2] < 2) ? Data[2] : true;
|
||||
|
||||
// 0EE0..0EE7
|
||||
|
||||
EEPROM_ReadBuffer(0x0EE0, Data, sizeof(gEeprom.ANI_DTMF_ID));
|
||||
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.ANI_DTMF_ID))) {
|
||||
memcpy(gEeprom.ANI_DTMF_ID, Data, sizeof(gEeprom.ANI_DTMF_ID));
|
||||
} else {
|
||||
strcpy(gEeprom.ANI_DTMF_ID, "123");
|
||||
}
|
||||
|
||||
|
||||
// 0EE8..0EEF
|
||||
EEPROM_ReadBuffer(0x0EE8, Data, sizeof(gEeprom.KILL_CODE));
|
||||
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.KILL_CODE))) {
|
||||
memcpy(gEeprom.KILL_CODE, Data, sizeof(gEeprom.KILL_CODE));
|
||||
} else {
|
||||
strcpy(gEeprom.KILL_CODE, "ABCD9");
|
||||
}
|
||||
|
||||
// 0EF0..0EF7
|
||||
EEPROM_ReadBuffer(0x0EF0, Data, sizeof(gEeprom.REVIVE_CODE));
|
||||
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.REVIVE_CODE))) {
|
||||
memcpy(gEeprom.REVIVE_CODE, Data, sizeof(gEeprom.REVIVE_CODE));
|
||||
} else {
|
||||
strcpy(gEeprom.REVIVE_CODE, "9DCBA");
|
||||
}
|
||||
#endif
|
||||
|
||||
// 0EF8..0F07
|
||||
EEPROM_ReadBuffer(0x0EF8, Data, sizeof(gEeprom.DTMF_UP_CODE));
|
||||
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.DTMF_UP_CODE))) {
|
||||
memcpy(gEeprom.DTMF_UP_CODE, Data, sizeof(gEeprom.DTMF_UP_CODE));
|
||||
} else {
|
||||
strcpy(gEeprom.DTMF_UP_CODE, "12345");
|
||||
}
|
||||
|
||||
// 0F08..0F17
|
||||
EEPROM_ReadBuffer(0x0F08, Data, sizeof(gEeprom.DTMF_DOWN_CODE));
|
||||
if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.DTMF_DOWN_CODE))) {
|
||||
memcpy(gEeprom.DTMF_DOWN_CODE, Data, sizeof(gEeprom.DTMF_DOWN_CODE));
|
||||
} else {
|
||||
strcpy(gEeprom.DTMF_DOWN_CODE, "54321");
|
||||
}
|
||||
|
||||
// 0F18..0F1F
|
||||
EEPROM_ReadBuffer(0x0F18, Data, 8);
|
||||
gEeprom.SCAN_LIST_DEFAULT = (Data[0] < 3) ? Data[0] : 0; // we now have 'all' channel scan option
|
||||
for (unsigned int i = 0; i < 2; i++)
|
||||
{
|
||||
const unsigned int j = 1 + (i * 3);
|
||||
gEeprom.SCAN_LIST_ENABLED[i] = (Data[j + 0] < 2) ? Data[j] : false;
|
||||
gEeprom.SCANLIST_PRIORITY_CH1[i] = Data[j + 1];
|
||||
gEeprom.SCANLIST_PRIORITY_CH2[i] = Data[j + 2];
|
||||
}
|
||||
|
||||
// 0F40..0F47
|
||||
EEPROM_ReadBuffer(0x0F40, Data, 8);
|
||||
gSetting_F_LOCK = (Data[0] < F_LOCK_LEN) ? Data[0] : F_LOCK_DEF;
|
||||
gSetting_350TX = (Data[1] < 2) ? Data[1] : false; // was true
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
gSetting_KILLED = (Data[2] < 2) ? Data[2] : false;
|
||||
#endif
|
||||
gSetting_200TX = (Data[3] < 2) ? Data[3] : false;
|
||||
gSetting_500TX = (Data[4] < 2) ? Data[4] : false;
|
||||
gSetting_350EN = (Data[5] < 2) ? Data[5] : true;
|
||||
gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true;
|
||||
//gSetting_TX_EN = (Data[7] & (1u << 0)) ? true : false;
|
||||
gSetting_live_DTMF_decoder = !!(Data[7] & (1u << 1));
|
||||
gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2;
|
||||
#ifdef ENABLE_AUDIO_BAR
|
||||
gSetting_mic_bar = !!(Data[7] & (1u << 4));
|
||||
#endif
|
||||
#ifdef ENABLE_AM_FIX
|
||||
gSetting_AM_fix = !!(Data[7] & (1u << 5));
|
||||
#endif
|
||||
gSetting_backlight_on_tx_rx = (Data[7] >> 6) & 3u;
|
||||
|
||||
if (!gEeprom.VFO_OPEN)
|
||||
{
|
||||
gEeprom.ScreenChannel[0] = gEeprom.MrChannel[0];
|
||||
gEeprom.ScreenChannel[1] = gEeprom.MrChannel[1];
|
||||
}
|
||||
|
||||
// 0D60..0E27
|
||||
EEPROM_ReadBuffer(0x0D60, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes));
|
||||
for(uint16_t i = 0; i < sizeof(gMR_ChannelAttributes); i++) {
|
||||
ChannelAttributes_t *att = &gMR_ChannelAttributes[i];
|
||||
if(att->__val == 0xff){
|
||||
att->__val = 0;
|
||||
att->band = 0xf;
|
||||
}
|
||||
}
|
||||
|
||||
// 0F30..0F3F
|
||||
EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey));
|
||||
bHasCustomAesKey = false;
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(gCustomAesKey); i++)
|
||||
{
|
||||
if (gCustomAesKey[i] != 0xFFFFFFFFu)
|
||||
{
|
||||
bHasCustomAesKey = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SETTINGS_LoadCalibration(void)
|
||||
{
|
||||
// uint8_t Mic;
|
||||
|
||||
EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[3], 8);
|
||||
memcpy(gEEPROM_RSSI_CALIB[4], gEEPROM_RSSI_CALIB[3], 8);
|
||||
memcpy(gEEPROM_RSSI_CALIB[5], gEEPROM_RSSI_CALIB[3], 8);
|
||||
memcpy(gEEPROM_RSSI_CALIB[6], gEEPROM_RSSI_CALIB[3], 8);
|
||||
|
||||
EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[0], 8);
|
||||
memcpy(gEEPROM_RSSI_CALIB[1], gEEPROM_RSSI_CALIB[0], 8);
|
||||
memcpy(gEEPROM_RSSI_CALIB[2], gEEPROM_RSSI_CALIB[0], 8);
|
||||
|
||||
EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12);
|
||||
if (gBatteryCalibration[0] >= 5000)
|
||||
{
|
||||
gBatteryCalibration[0] = 1900;
|
||||
gBatteryCalibration[1] = 2000;
|
||||
}
|
||||
gBatteryCalibration[5] = 2300;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
EEPROM_ReadBuffer(0x1F50 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX1_THRESHOLD, 2);
|
||||
EEPROM_ReadBuffer(0x1F68 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX0_THRESHOLD, 2);
|
||||
#endif
|
||||
|
||||
//EEPROM_ReadBuffer(0x1F80 + gEeprom.MIC_SENSITIVITY, &Mic, 1);
|
||||
//gEeprom.MIC_SENSITIVITY_TUNING = (Mic < 32) ? Mic : 15;
|
||||
gEeprom.MIC_SENSITIVITY_TUNING = gMicGain_dB2[gEeprom.MIC_SENSITIVITY];
|
||||
|
||||
{
|
||||
struct
|
||||
{
|
||||
int16_t BK4819_XtalFreqLow;
|
||||
uint16_t EEPROM_1F8A;
|
||||
uint16_t EEPROM_1F8C;
|
||||
uint8_t VOLUME_GAIN;
|
||||
uint8_t DAC_GAIN;
|
||||
} __attribute__((packed)) Misc;
|
||||
|
||||
// radio 1 .. 04 00 46 00 50 00 2C 0E
|
||||
// radio 2 .. 05 00 46 00 50 00 2C 0E
|
||||
EEPROM_ReadBuffer(0x1F88, &Misc, 8);
|
||||
|
||||
gEeprom.BK4819_XTAL_FREQ_LOW = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) ? Misc.BK4819_XtalFreqLow : 0;
|
||||
gEEPROM_1F8A = Misc.EEPROM_1F8A & 0x01FF;
|
||||
gEEPROM_1F8C = Misc.EEPROM_1F8C & 0x01FF;
|
||||
gEeprom.VOLUME_GAIN = (Misc.VOLUME_GAIN < 64) ? Misc.VOLUME_GAIN : 58;
|
||||
gEeprom.DAC_GAIN = (Misc.DAC_GAIN < 16) ? Misc.DAC_GAIN : 8;
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_3B, 22656 + gEeprom.BK4819_XTAL_FREQ_LOW);
|
||||
// BK4819_WriteRegister(BK4819_REG_3C, gEeprom.BK4819_XTAL_FREQ_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t SETTINGS_FetchChannelFrequency(const int channel)
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t frequency;
|
||||
uint32_t offset;
|
||||
} __attribute__((packed)) info;
|
||||
|
||||
EEPROM_ReadBuffer(channel * 16, &info, sizeof(info));
|
||||
|
||||
return info.frequency;
|
||||
}
|
||||
|
||||
void SETTINGS_FetchChannelName(char *s, const int channel)
|
||||
{
|
||||
if (s == NULL)
|
||||
return;
|
||||
|
||||
s[0] = 0;
|
||||
|
||||
if (channel < 0)
|
||||
return;
|
||||
|
||||
if (!RADIO_CheckValidChannel(channel, false, 0))
|
||||
return;
|
||||
|
||||
EEPROM_ReadBuffer(0x0F50 + (channel * 16), s, 10);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 10; i++)
|
||||
if (s[i] < 32 || s[i] > 127)
|
||||
break; // invalid char
|
||||
|
||||
s[i--] = 0; // null term
|
||||
|
||||
while (i >= 0 && s[i] == 32) // trim trailing spaces
|
||||
s[i--] = 0; // null term
|
||||
}
|
||||
|
||||
void SETTINGS_FactoryReset(bool bIsAll)
|
||||
{
|
||||
uint16_t i;
|
||||
uint8_t Template[8];
|
||||
|
||||
memset(Template, 0xFF, sizeof(Template));
|
||||
|
||||
for (i = 0x0C80; i < 0x1E00; i += 8)
|
||||
{
|
||||
if (
|
||||
!(i >= 0x0EE0 && i < 0x0F18) && // ANI ID + DTMF codes
|
||||
!(i >= 0x0F30 && i < 0x0F50) && // AES KEY + F LOCK + Scramble Enable
|
||||
!(i >= 0x1C00 && i < 0x1E00) && // DTMF contacts
|
||||
!(i >= 0x0EB0 && i < 0x0ED0) && // Welcome strings
|
||||
!(i >= 0x0EA0 && i < 0x0EA8) && // Voice Prompt
|
||||
(bIsAll ||
|
||||
(
|
||||
!(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes
|
||||
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
|
||||
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names
|
||||
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
|
||||
!(i >= 0x0E88 && i < 0x0E90) // FM settings
|
||||
))
|
||||
)
|
||||
{
|
||||
EEPROM_WriteBuffer(i, Template);
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsAll)
|
||||
{
|
||||
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_FIRST + BAND6_400MHz, 43350000);
|
||||
|
||||
// set the first few memory channels
|
||||
for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++)
|
||||
{
|
||||
const uint32_t Frequency = gDefaultFrequencyTable[i];
|
||||
gRxVfo->freq_config_RX.Frequency = Frequency;
|
||||
gRxVfo->freq_config_TX.Frequency = Frequency;
|
||||
gRxVfo->Band = FREQUENCY_GetBand(Frequency);
|
||||
SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
void SETTINGS_SaveFM(void)
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
uint16_t selFreq;
|
||||
uint8_t selChn;
|
||||
uint8_t isMrMode:1;
|
||||
uint8_t band:2;
|
||||
//uint8_t space:2;
|
||||
};
|
||||
uint8_t __raw[8];
|
||||
} __attribute__((packed)) fmCfg;
|
||||
|
||||
memset(fmCfg.__raw, 0xFF, sizeof(fmCfg.__raw));
|
||||
fmCfg.selChn = gEeprom.FM_SelectedChannel;
|
||||
fmCfg.selFreq = gEeprom.FM_SelectedFrequency;
|
||||
fmCfg.isMrMode = gEeprom.FM_IsMrMode;
|
||||
fmCfg.band = gEeprom.FM_Band;
|
||||
//fmCfg.space = gEeprom.FM_Space;
|
||||
EEPROM_WriteBuffer(0x0E88, fmCfg.__raw);
|
||||
|
||||
for (unsigned i = 0; i < 5; i++)
|
||||
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
|
||||
}
|
||||
#endif
|
||||
@@ -86,22 +481,28 @@ void SETTINGS_SaveSettings(void)
|
||||
State[3] = false;
|
||||
#endif
|
||||
State[4] = gEeprom.KEY_LOCK;
|
||||
State[5] = gEeprom.VOX_SWITCH;
|
||||
State[6] = gEeprom.VOX_LEVEL;
|
||||
#ifdef ENABLE_VOX
|
||||
State[5] = gEeprom.VOX_SWITCH;
|
||||
State[6] = gEeprom.VOX_LEVEL;
|
||||
#else
|
||||
State[5] = false;
|
||||
State[6] = 0;
|
||||
#endif
|
||||
State[7] = gEeprom.MIC_SENSITIVITY;
|
||||
EEPROM_WriteBuffer(0x0E70, State);
|
||||
|
||||
State[0] = 0xFF;
|
||||
State[0] = (gEeprom.BACKLIGHT_MIN << 4) + gEeprom.BACKLIGHT_MAX;
|
||||
State[1] = gEeprom.CHANNEL_DISPLAY_MODE;
|
||||
State[2] = gEeprom.CROSS_BAND_RX_TX;
|
||||
State[3] = gEeprom.BATTERY_SAVE;
|
||||
State[4] = gEeprom.DUAL_WATCH;
|
||||
State[5] = gEeprom.BACKLIGHT;
|
||||
State[6] = gEeprom.TAIL_NOTE_ELIMINATION;
|
||||
State[5] = gEeprom.BACKLIGHT_TIME;
|
||||
State[6] = gEeprom.TAIL_TONE_ELIMINATION;
|
||||
State[7] = gEeprom.VFO_OPEN;
|
||||
EEPROM_WriteBuffer(0x0E78, State);
|
||||
|
||||
State[0] = gEeprom.BEEP_CONTROL;
|
||||
State[0] |= gEeprom.KEY_M_LONG_PRESS_ACTION << 1;
|
||||
State[1] = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
||||
State[2] = gEeprom.KEY_1_LONG_PRESS_ACTION;
|
||||
State[3] = gEeprom.KEY_2_SHORT_PRESS_ACTION;
|
||||
@@ -112,30 +513,40 @@ void SETTINGS_SaveSettings(void)
|
||||
EEPROM_WriteBuffer(0x0E90, State);
|
||||
|
||||
memset(Password, 0xFF, sizeof(Password));
|
||||
Password[0] = gEeprom.POWER_ON_PASSWORD;
|
||||
EEPROM_WriteBuffer(0x0E98, State);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
memset(State, 0xFF, sizeof(State));
|
||||
State[0] = gEeprom.VOICE_PROMPT;
|
||||
EEPROM_WriteBuffer(0x0EA0, State);
|
||||
#ifdef ENABLE_PWRON_PASSWORD
|
||||
Password[0] = gEeprom.POWER_ON_PASSWORD;
|
||||
#endif
|
||||
EEPROM_WriteBuffer(0x0E98, Password);
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
memset(State, 0xFF, sizeof(State));
|
||||
#ifdef ENABLE_VOICE
|
||||
State[0] = gEeprom.VOICE_PROMPT;
|
||||
#endif
|
||||
#ifdef ENABLE_RSSI_BAR
|
||||
State[1] = gEeprom.S0_LEVEL;
|
||||
State[2] = gEeprom.S9_LEVEL;
|
||||
#endif
|
||||
EEPROM_WriteBuffer(0x0EA0, State);
|
||||
|
||||
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
State[0] = gEeprom.ALARM_MODE;
|
||||
#else
|
||||
State[0] = false;
|
||||
#endif
|
||||
State[1] = gEeprom.ROGER;
|
||||
State[2] = gEeprom.REPEATER_TAIL_TONE_ELIMINATION;
|
||||
State[3] = gEeprom.TX_CHANNEL;
|
||||
State[3] = gEeprom.TX_VFO;
|
||||
State[4] = gEeprom.BATTERY_TYPE;
|
||||
EEPROM_WriteBuffer(0x0EA8, State);
|
||||
|
||||
State[0] = gEeprom.DTMF_SIDE_TONE;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
State[1] = gEeprom.DTMF_SEPARATE_CODE;
|
||||
State[2] = gEeprom.DTMF_GROUP_CALL_CODE;
|
||||
State[3] = gEeprom.DTMF_DECODE_RESPONSE;
|
||||
State[4] = gEeprom.DTMF_AUTO_RESET_TIME;
|
||||
State[4] = gEeprom.DTMF_auto_reset_time;
|
||||
#endif
|
||||
State[5] = gEeprom.DTMF_PRELOAD_TIME / 10U;
|
||||
State[6] = gEeprom.DTMF_FIRST_CODE_PERSIST_TIME / 10U;
|
||||
State[7] = gEeprom.DTMF_HASH_CODE_PERSIST_TIME / 10U;
|
||||
@@ -144,7 +555,9 @@ void SETTINGS_SaveSettings(void)
|
||||
memset(State, 0xFF, sizeof(State));
|
||||
State[0] = gEeprom.DTMF_CODE_PERSIST_TIME / 10U;
|
||||
State[1] = gEeprom.DTMF_CODE_INTERVAL_TIME / 10U;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
State[2] = gEeprom.PERMIT_REMOTE_KILL;
|
||||
#endif
|
||||
EEPROM_WriteBuffer(0x0ED8, State);
|
||||
|
||||
State[0] = gEeprom.SCAN_LIST_DEFAULT;
|
||||
@@ -160,12 +573,14 @@ void SETTINGS_SaveSettings(void)
|
||||
memset(State, 0xFF, sizeof(State));
|
||||
State[0] = gSetting_F_LOCK;
|
||||
State[1] = gSetting_350TX;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
State[2] = gSetting_KILLED;
|
||||
#endif
|
||||
State[3] = gSetting_200TX;
|
||||
State[4] = gSetting_500TX;
|
||||
State[5] = gSetting_350EN;
|
||||
State[6] = gSetting_ScrambleEnable;
|
||||
if (!gSetting_TX_EN) State[7] &= ~(1u << 0);
|
||||
//if (!gSetting_TX_EN) State[7] &= ~(1u << 0);
|
||||
if (!gSetting_live_DTMF_decoder) State[7] &= ~(1u << 1);
|
||||
State[7] = (State[7] & ~(3u << 2)) | ((gSetting_battery_text & 3u) << 2);
|
||||
#ifdef ENABLE_AUDIO_BAR
|
||||
@@ -174,130 +589,174 @@ void SETTINGS_SaveSettings(void)
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if (!gSetting_AM_fix) State[7] &= ~(1u << 5);
|
||||
#endif
|
||||
EEPROM_WriteBuffer(0x0F40, State);
|
||||
}
|
||||
State[7] = (State[7] & ~(3u << 6)) | ((gSetting_backlight_on_tx_rx & 3u) << 6);
|
||||
|
||||
void SETTINGS_LoadChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO)
|
||||
{
|
||||
EEPROM_WriteBuffer(0x0F40, State);
|
||||
}
|
||||
|
||||
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode)
|
||||
{
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOT_NOAA_CHANNEL(Channel))
|
||||
#endif
|
||||
{
|
||||
const uint16_t OffsetMR = Channel * 16;
|
||||
uint16_t OffsetVFO = OffsetMR;
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(Channel))
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (!IS_MR_CHANNEL(Channel))
|
||||
{ // it's a VFO, not a channel
|
||||
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90;
|
||||
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
|
||||
}
|
||||
uint16_t OffsetVFO = Channel * 16;
|
||||
|
||||
if (Mode >= 2 || !IS_MR_CHANNEL(Channel))
|
||||
{ // copy VFO to a channel
|
||||
if (IS_FREQ_CHANNEL(Channel)) { // it's a VFO, not a channel
|
||||
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90;
|
||||
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
|
||||
}
|
||||
|
||||
uint8_t State[8];
|
||||
if (Mode >= 2 || IS_FREQ_CHANNEL(Channel)) { // copy VFO to a channel
|
||||
union {
|
||||
uint8_t _8[8];
|
||||
uint32_t _32[2];
|
||||
} State;
|
||||
|
||||
((uint32_t *)State)[0] = pVFO->freq_config_RX.Frequency;
|
||||
((uint32_t *)State)[1] = pVFO->TX_OFFSET_FREQUENCY;
|
||||
EEPROM_WriteBuffer(OffsetVFO + 0, State);
|
||||
State._32[0] = pVFO->freq_config_RX.Frequency;
|
||||
State._32[1] = pVFO->TX_OFFSET_FREQUENCY;
|
||||
EEPROM_WriteBuffer(OffsetVFO + 0, State._32);
|
||||
|
||||
State[0] = pVFO->freq_config_RX.Code;
|
||||
State[1] = pVFO->freq_config_TX.Code;
|
||||
State[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType;
|
||||
State[3] = ((pVFO->AM_mode & 1u) << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION;
|
||||
State[4] = 0
|
||||
| (pVFO->BUSY_CHANNEL_LOCK << 4)
|
||||
| (pVFO->OUTPUT_POWER << 2)
|
||||
| (pVFO->CHANNEL_BANDWIDTH << 1)
|
||||
| (pVFO->FrequencyReverse << 0);
|
||||
State[5] = (pVFO->DTMF_PTT_ID_TX_MODE << 1) | (pVFO->DTMF_DECODING_ENABLE < 0);
|
||||
State[6] = pVFO->STEP_SETTING;
|
||||
State[7] = pVFO->SCRAMBLING_TYPE;
|
||||
EEPROM_WriteBuffer(OffsetVFO + 8, State);
|
||||
State._8[0] = pVFO->freq_config_RX.Code;
|
||||
State._8[1] = pVFO->freq_config_TX.Code;
|
||||
State._8[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType;
|
||||
State._8[3] = (pVFO->Modulation << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION;
|
||||
State._8[4] = 0
|
||||
| (pVFO->BUSY_CHANNEL_LOCK << 4)
|
||||
| (pVFO->OUTPUT_POWER << 2)
|
||||
| (pVFO->CHANNEL_BANDWIDTH << 1)
|
||||
| (pVFO->FrequencyReverse << 0);
|
||||
State._8[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1)
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
| ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0)
|
||||
#endif
|
||||
;
|
||||
State._8[6] = pVFO->STEP_SETTING;
|
||||
State._8[7] = pVFO->SCRAMBLING_TYPE;
|
||||
EEPROM_WriteBuffer(OffsetVFO + 8, State._8);
|
||||
|
||||
SETTINGS_UpdateChannel(Channel, pVFO, true);
|
||||
SETTINGS_UpdateChannel(Channel, pVFO, true);
|
||||
|
||||
if (IS_MR_CHANNEL(Channel))
|
||||
{
|
||||
#ifndef KEEP_MEM_NAME
|
||||
// clear/reset the channel name
|
||||
//memset(&State, 0xFF, sizeof(State));
|
||||
memset(&State, 0x00, sizeof(State)); // follow the QS way
|
||||
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
|
||||
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
|
||||
#else
|
||||
if (Mode >= 3)
|
||||
{ // save the channel name
|
||||
memmove(State, pVFO->Name + 0, 8);
|
||||
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
|
||||
//memset(State, 0xFF, sizeof(State));
|
||||
memset(State, 0x00, sizeof(State)); // follow the QS way
|
||||
memmove(State, pVFO->Name + 8, 2);
|
||||
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
|
||||
}
|
||||
#endif
|
||||
if (IS_MR_CHANNEL(Channel)) {
|
||||
#ifndef ENABLE_KEEP_MEM_NAME
|
||||
// clear/reset the channel name
|
||||
SETTINGS_SaveChannelName(Channel, "");
|
||||
#else
|
||||
if (Mode >= 3) {
|
||||
SETTINGS_SaveChannelName(Channel, pVFO->Name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
|
||||
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration)
|
||||
{
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOT_NOAA_CHANNEL(Channel))
|
||||
#endif
|
||||
uint16_t buf[4];
|
||||
EEPROM_WriteBuffer(0x1F40, batteryCalibration);
|
||||
EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf));
|
||||
buf[0] = batteryCalibration[4];
|
||||
buf[1] = batteryCalibration[5];
|
||||
EEPROM_WriteBuffer(0x1F48, buf);
|
||||
}
|
||||
|
||||
void SETTINGS_SaveChannelName(uint8_t channel, const char * name)
|
||||
{
|
||||
uint16_t offset = channel * 16;
|
||||
uint8_t buf[16] = {0};
|
||||
memcpy(buf, name, MIN(strlen(name), 10u));
|
||||
EEPROM_WriteBuffer(0x0F50 + offset, buf);
|
||||
EEPROM_WriteBuffer(0x0F58 + offset, buf + 8);
|
||||
}
|
||||
|
||||
void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep)
|
||||
{
|
||||
#ifdef ENABLE_NOAA
|
||||
if (!IS_NOAA_CHANNEL(channel))
|
||||
#endif
|
||||
{
|
||||
uint8_t State[8];
|
||||
uint8_t Attributes = 0xFF; // default attributes
|
||||
#ifdef ENABLE_COMPANDER
|
||||
Attributes &= ~MR_CH_COMPAND; // default to '0' = compander disabled
|
||||
#endif
|
||||
uint16_t Offset = 0x0D60 + (Channel & ~7u);
|
||||
uint8_t state[8];
|
||||
ChannelAttributes_t att = {
|
||||
.band = 0xf,
|
||||
.compander = 0,
|
||||
.scanlist1 = 0,
|
||||
.scanlist2 = 0,
|
||||
}; // default attributes
|
||||
|
||||
EEPROM_ReadBuffer(Offset, State, sizeof(State));
|
||||
uint16_t offset = 0x0D60 + (channel & ~7u);
|
||||
EEPROM_ReadBuffer(offset, state, sizeof(state));
|
||||
|
||||
if (keep)
|
||||
{
|
||||
#ifdef ENABLE_COMPANDER
|
||||
Attributes = (pVFO->SCANLIST1_PARTICIPATION << 7) | (pVFO->SCANLIST2_PARTICIPATION << 6) | (pVFO->Compander << 4) | (pVFO->Band << 0);
|
||||
#else
|
||||
Attributes = (pVFO->SCANLIST1_PARTICIPATION << 7) | (pVFO->SCANLIST2_PARTICIPATION << 6) | (pVFO->Band << 0);
|
||||
#endif
|
||||
if (State[Channel & 7u] == Attributes)
|
||||
if (keep) {
|
||||
att.band = pVFO->Band;
|
||||
att.scanlist1 = pVFO->SCANLIST1_PARTICIPATION;
|
||||
att.scanlist2 = pVFO->SCANLIST2_PARTICIPATION;
|
||||
att.compander = pVFO->Compander;
|
||||
if (state[channel & 7u] == att.__val)
|
||||
return; // no change in the attributes
|
||||
}
|
||||
|
||||
State[Channel & 7u] = Attributes;
|
||||
state[channel & 7u] = att.__val;
|
||||
EEPROM_WriteBuffer(offset, state);
|
||||
|
||||
EEPROM_WriteBuffer(Offset, State);
|
||||
gMR_ChannelAttributes[channel] = att;
|
||||
|
||||
gMR_ChannelAttributes[Channel] = Attributes;
|
||||
|
||||
// #ifndef KEEP_MEM_NAME
|
||||
if (IS_MR_CHANNEL(Channel))
|
||||
{
|
||||
const uint16_t OffsetMR = Channel * 16;
|
||||
if (!keep)
|
||||
{ // clear/reset the channel name
|
||||
//memset(&State, 0xFF, sizeof(State));
|
||||
memset(&State, 0x00, sizeof(State)); // follow the QS way
|
||||
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
|
||||
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
|
||||
}
|
||||
// else
|
||||
// { // update the channel name
|
||||
// memmove(State, pVFO->Name + 0, 8);
|
||||
// EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
|
||||
// //memset(State, 0xFF, sizeof(State));
|
||||
// memset(State, 0x00, sizeof(State)); // follow the QS way
|
||||
// memmove(State, pVFO->Name + 8, 2);
|
||||
// EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
|
||||
// }
|
||||
if (IS_MR_CHANNEL(channel)) { // it's a memory channel
|
||||
if (!keep) {
|
||||
// clear/reset the channel name
|
||||
SETTINGS_SaveChannelName(channel, "");
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SETTINGS_WriteBuildOptions(void)
|
||||
{
|
||||
uint8_t buf[8] = {0};
|
||||
buf[0] = 0
|
||||
#ifdef ENABLE_FMRADIO
|
||||
| (1 << 0)
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
| (1 << 1)
|
||||
#endif
|
||||
#ifdef ENABLE_VOICE
|
||||
| (1 << 2)
|
||||
#endif
|
||||
#ifdef ENABLE_VOX
|
||||
| (1 << 3)
|
||||
#endif
|
||||
#ifdef ENABLE_ALARM
|
||||
| (1 << 4)
|
||||
#endif
|
||||
#ifdef ENABLE_TX1750
|
||||
| (1 << 5)
|
||||
#endif
|
||||
#ifdef ENABLE_PWRON_PASSWORD
|
||||
| (1 << 6)
|
||||
#endif
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
| (1 << 7)
|
||||
#endif
|
||||
;
|
||||
|
||||
buf[1] = 0
|
||||
#ifdef ENABLE_FLASHLIGHT
|
||||
| (1 << 0)
|
||||
#endif
|
||||
#ifdef ENABLE_WIDE_RX
|
||||
| (1 << 1)
|
||||
#endif
|
||||
#ifdef ENABLE_BYP_RAW_DEMODULATORS
|
||||
| (1 << 2)
|
||||
#endif
|
||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||
| (1 << 3)
|
||||
#endif
|
||||
#ifdef ENABLE_AM_FIX
|
||||
| (1 << 4)
|
||||
#endif
|
||||
;
|
||||
EEPROM_WriteBuffer(0x1FF0, buf);
|
||||
}
|
||||
128
settings.h
@@ -20,7 +20,10 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "frequencies.h"
|
||||
#include <helper/battery.h>
|
||||
#include "radio.h"
|
||||
#include <driver/backlight.h>
|
||||
|
||||
enum POWER_OnDisplayMode_t {
|
||||
POWER_ON_DISPLAY_MODE_FULL_SCREEN = 0,
|
||||
@@ -28,16 +31,18 @@ enum POWER_OnDisplayMode_t {
|
||||
POWER_ON_DISPLAY_MODE_VOLTAGE,
|
||||
POWER_ON_DISPLAY_MODE_NONE
|
||||
};
|
||||
|
||||
typedef enum POWER_OnDisplayMode_t POWER_OnDisplayMode_t;
|
||||
|
||||
enum {
|
||||
F_LOCK_OFF = 0,
|
||||
enum TxLockModes_t {
|
||||
F_LOCK_DEF, //all default frequencies + configurable
|
||||
F_LOCK_FCC,
|
||||
F_LOCK_CE,
|
||||
F_LOCK_GB,
|
||||
F_LOCK_430,
|
||||
F_LOCK_438
|
||||
F_LOCK_438,
|
||||
F_LOCK_ALL, // disable TX on all frequencies
|
||||
F_LOCK_NONE, // enable TX on all frequencies
|
||||
F_LOCK_LEN
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -70,7 +75,7 @@ enum {
|
||||
OUTPUT_POWER_HIGH
|
||||
};
|
||||
|
||||
enum {
|
||||
enum ACTION_OPT_t {
|
||||
ACTION_OPT_NONE = 0,
|
||||
ACTION_OPT_FLASHLIGHT,
|
||||
ACTION_OPT_POWER,
|
||||
@@ -80,6 +85,11 @@ enum {
|
||||
ACTION_OPT_ALARM,
|
||||
ACTION_OPT_FM,
|
||||
ACTION_OPT_1750,
|
||||
ACTION_OPT_KEYLOCK,
|
||||
ACTION_OPT_A_B,
|
||||
ACTION_OPT_VFO_MR,
|
||||
ACTION_OPT_SWITCH_DEMODUL,
|
||||
ACTION_OPT_BLMIN_TMP_OFF, //BackLight Minimum Temporay OFF
|
||||
ACTION_OPT_LEN
|
||||
};
|
||||
|
||||
@@ -90,7 +100,6 @@ enum {
|
||||
VOICE_PROMPT_CHINESE,
|
||||
VOICE_PROMPT_ENGLISH
|
||||
};
|
||||
|
||||
typedef enum VOICE_Prompt_t VOICE_Prompt_t;
|
||||
#endif
|
||||
|
||||
@@ -98,7 +107,6 @@ enum ALARM_Mode_t {
|
||||
ALARM_MODE_SITE = 0,
|
||||
ALARM_MODE_TONE
|
||||
};
|
||||
|
||||
typedef enum ALARM_Mode_t ALARM_Mode_t;
|
||||
|
||||
enum ROGER_Mode_t {
|
||||
@@ -106,7 +114,6 @@ enum ROGER_Mode_t {
|
||||
ROGER_MODE_ROGER,
|
||||
ROGER_MODE_MDC
|
||||
};
|
||||
|
||||
typedef enum ROGER_Mode_t ROGER_Mode_t;
|
||||
|
||||
enum CHANNEL_DisplayMode_t {
|
||||
@@ -115,39 +122,52 @@ enum CHANNEL_DisplayMode_t {
|
||||
MDF_NAME,
|
||||
MDF_NAME_FREQ
|
||||
};
|
||||
|
||||
typedef enum CHANNEL_DisplayMode_t CHANNEL_DisplayMode_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t ScreenChannel[2];
|
||||
uint8_t FreqChannel[2];
|
||||
uint8_t MrChannel[2];
|
||||
#ifdef ENABLE_NOAA
|
||||
uint8_t NoaaChannel[2];
|
||||
#endif
|
||||
uint8_t RX_CHANNEL;
|
||||
uint8_t TX_CHANNEL;
|
||||
uint8_t ScreenChannel[2]; // current channels set in the radio (memory or frequency channels)
|
||||
uint8_t FreqChannel[2]; // last frequency channels used
|
||||
uint8_t MrChannel[2]; // last memory channels used
|
||||
#ifdef ENABLE_NOAA
|
||||
uint8_t NoaaChannel[2];
|
||||
#endif
|
||||
|
||||
// The actual VFO index (0-upper/1-lower) that is now used for RX,
|
||||
// It is being alternated by dual watch, and flipped by crossband
|
||||
uint8_t RX_VFO;
|
||||
|
||||
// The main VFO index (0-upper/1-lower) selected by the user
|
||||
//
|
||||
uint8_t TX_VFO;
|
||||
|
||||
uint8_t field7_0xa;
|
||||
uint8_t field8_0xb;
|
||||
|
||||
uint32_t POWER_ON_PASSWORD;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
uint16_t FM_SelectedFrequency;
|
||||
uint8_t FM_SelectedChannel;
|
||||
bool FM_IsMrMode;
|
||||
uint16_t FM_FrequencyPlaying;
|
||||
uint8_t FM_Band : 2;
|
||||
//uint8_t FM_Space : 2;
|
||||
#endif
|
||||
|
||||
uint8_t SQUELCH_LEVEL;
|
||||
uint8_t TX_TIMEOUT_TIMER;
|
||||
bool KEY_LOCK;
|
||||
bool VOX_SWITCH;
|
||||
uint8_t VOX_LEVEL;
|
||||
#ifdef ENABLE_VOICE
|
||||
VOICE_Prompt_t VOICE_PROMPT;
|
||||
#endif
|
||||
#ifdef ENABLE_VOICE
|
||||
VOICE_Prompt_t VOICE_PROMPT;
|
||||
#endif
|
||||
bool BEEP_CONTROL;
|
||||
uint8_t CHANNEL_DISPLAY_MODE;
|
||||
bool TAIL_NOTE_ELIMINATION;
|
||||
bool TAIL_TONE_ELIMINATION;
|
||||
bool VFO_OPEN;
|
||||
uint8_t DUAL_WATCH;
|
||||
uint8_t CROSS_BAND_RX_TX;
|
||||
uint8_t BATTERY_SAVE;
|
||||
uint8_t BACKLIGHT;
|
||||
uint8_t BACKLIGHT_TIME;
|
||||
uint8_t SCAN_RESUME_MODE;
|
||||
uint8_t SCAN_LIST_DEFAULT;
|
||||
bool SCAN_LIST_ENABLED[2];
|
||||
@@ -156,29 +176,14 @@ typedef struct {
|
||||
|
||||
uint8_t field29_0x26;
|
||||
uint8_t field30_0x27;
|
||||
|
||||
uint16_t VOX1_THRESHOLD;
|
||||
uint16_t VOX0_THRESHOLD;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
uint16_t FM_SelectedFrequency;
|
||||
uint8_t FM_SelectedChannel;
|
||||
bool FM_IsMrMode;
|
||||
uint16_t FM_FrequencyPlaying;
|
||||
#endif
|
||||
|
||||
uint8_t field37_0x32;
|
||||
uint8_t field38_0x33;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
uint16_t FM_LowerLimit;
|
||||
uint16_t FM_UpperLimit;
|
||||
#endif
|
||||
|
||||
bool AUTO_KEYPAD_LOCK;
|
||||
#ifdef ENABLE_ALARM
|
||||
ALARM_Mode_t ALARM_MODE;
|
||||
#endif
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
ALARM_Mode_t ALARM_MODE;
|
||||
#endif
|
||||
POWER_OnDisplayMode_t POWER_ON_DISPLAY_MODE;
|
||||
ROGER_Mode_t ROGER;
|
||||
uint8_t REPEATER_TAIL_TONE_ELIMINATION;
|
||||
@@ -189,9 +194,11 @@ typedef struct {
|
||||
uint8_t MIC_SENSITIVITY;
|
||||
uint8_t MIC_SENSITIVITY_TUNING;
|
||||
uint8_t CHAN_1_CALL;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
char ANI_DTMF_ID[8];
|
||||
char KILL_CODE[8];
|
||||
char REVIVE_CODE[8];
|
||||
#endif
|
||||
char DTMF_UP_CODE[16];
|
||||
|
||||
uint8_t field57_0x6c;
|
||||
@@ -202,39 +209,66 @@ typedef struct {
|
||||
uint8_t field60_0x7e;
|
||||
uint8_t field61_0x7f;
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
char DTMF_SEPARATE_CODE;
|
||||
char DTMF_GROUP_CALL_CODE;
|
||||
uint8_t DTMF_DECODE_RESPONSE;
|
||||
uint8_t DTMF_AUTO_RESET_TIME;
|
||||
uint8_t DTMF_auto_reset_time;
|
||||
#endif
|
||||
uint16_t DTMF_PRELOAD_TIME;
|
||||
uint16_t DTMF_FIRST_CODE_PERSIST_TIME;
|
||||
uint16_t DTMF_HASH_CODE_PERSIST_TIME;
|
||||
uint16_t DTMF_CODE_PERSIST_TIME;
|
||||
uint16_t DTMF_CODE_INTERVAL_TIME;
|
||||
bool DTMF_SIDE_TONE;
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
bool PERMIT_REMOTE_KILL;
|
||||
#endif
|
||||
int16_t BK4819_XTAL_FREQ_LOW;
|
||||
#ifdef ENABLE_NOAA
|
||||
bool NOAA_AUTO_SCAN;
|
||||
#endif
|
||||
#ifdef ENABLE_NOAA
|
||||
bool NOAA_AUTO_SCAN;
|
||||
#endif
|
||||
uint8_t VOLUME_GAIN;
|
||||
uint8_t DAC_GAIN;
|
||||
|
||||
VFO_Info_t VfoInfo[2];
|
||||
uint32_t POWER_ON_PASSWORD;
|
||||
uint16_t VOX1_THRESHOLD;
|
||||
uint16_t VOX0_THRESHOLD;
|
||||
|
||||
uint8_t field77_0x95;
|
||||
uint8_t field78_0x96;
|
||||
uint8_t field79_0x97;
|
||||
|
||||
VFO_Info_t VfoInfo[2];
|
||||
uint8_t KEY_M_LONG_PRESS_ACTION;
|
||||
uint8_t BACKLIGHT_MIN;
|
||||
#ifdef ENABLE_BLMIN_TMP_OFF
|
||||
BLMIN_STAT_t BACKLIGHT_MIN_STAT;
|
||||
#endif
|
||||
uint8_t BACKLIGHT_MAX;
|
||||
BATTERY_Type_t BATTERY_TYPE;
|
||||
#ifdef ENABLE_RSSI_BAR
|
||||
uint8_t S0_LEVEL;
|
||||
uint8_t S9_LEVEL;
|
||||
#endif
|
||||
} EEPROM_Config_t;
|
||||
|
||||
extern EEPROM_Config_t gEeprom;
|
||||
|
||||
void SETTINGS_InitEEPROM(void);
|
||||
void SETTINGS_LoadCalibration(void);
|
||||
uint32_t SETTINGS_FetchChannelFrequency(const int channel);
|
||||
void SETTINGS_FetchChannelName(char *s, const int channel);
|
||||
void SETTINGS_FactoryReset(bool bIsAll);
|
||||
#ifdef ENABLE_FMRADIO
|
||||
void SETTINGS_SaveFM(void);
|
||||
#endif
|
||||
void SETTINGS_SaveVfoIndices(void);
|
||||
void SETTINGS_SaveSettings(void);
|
||||
void SETTINGS_SaveChannelName(uint8_t channel, const char * name);
|
||||
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode);
|
||||
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep);
|
||||
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration);
|
||||
void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep);
|
||||
void SETTINGS_WriteBuildOptions(void);
|
||||
|
||||
#endif
|
||||
|
||||
49
ui/aircopy.c
@@ -29,34 +29,41 @@
|
||||
|
||||
void UI_DisplayAircopy(void)
|
||||
{
|
||||
char String[16];
|
||||
char String[16] = { 0 };
|
||||
char *pPrintStr = { 0 };
|
||||
|
||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
||||
UI_DisplayClear();
|
||||
|
||||
if (gAircopyState == AIRCOPY_READY)
|
||||
strcpy(String, "AIR COPY(RDY)");
|
||||
else
|
||||
if (gAircopyState == AIRCOPY_TRANSFER)
|
||||
strcpy(String, "AIR COPY");
|
||||
else
|
||||
strcpy(String, "AIR COPY(CMP)");
|
||||
UI_PrintString(String, 2, 127, 0, 8);
|
||||
|
||||
if (gInputBoxIndex == 0)
|
||||
{
|
||||
NUMBER_ToDigits(gRxVfo->freq_config_RX.Frequency, String);
|
||||
UI_DisplayFrequency(String, 16, 2, 0, 0);
|
||||
UI_DisplaySmallDigits(2, String + 6, 97, 3, true);
|
||||
if (gAircopyState == AIRCOPY_READY) {
|
||||
pPrintStr = "AIR COPY(RDY)";
|
||||
} else if (gAircopyState == AIRCOPY_TRANSFER) {
|
||||
pPrintStr = "AIR COPY";
|
||||
} else {
|
||||
pPrintStr = "AIR COPY(CMP)";
|
||||
}
|
||||
|
||||
UI_PrintString(pPrintStr, 2, 127, 0, 8);
|
||||
|
||||
if (gInputBoxIndex == 0) {
|
||||
uint32_t frequency = gRxVfo->freq_config_RX.Frequency;
|
||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||
// show the remaining 2 small frequency digits
|
||||
UI_PrintStringSmallNormal(String + 7, 97, 0, 3);
|
||||
String[7] = 0;
|
||||
// show the main large frequency digits
|
||||
UI_DisplayFrequency(String, 16, 2, false);
|
||||
} else {
|
||||
const char *ascii = INPUTBOX_GetAscii();
|
||||
sprintf(String, "%.3s.%.3s", ascii, ascii + 3);
|
||||
UI_DisplayFrequency(String, 16, 2, false);
|
||||
}
|
||||
else
|
||||
UI_DisplayFrequency(gInputBox, 16, 2, 1, 0);
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
if (gAirCopyIsSendMode == 0)
|
||||
if (gAirCopyIsSendMode == 0) {
|
||||
sprintf(String, "RCV:%u E:%u", gAirCopyBlockNumber, gErrorsDuringAirCopy);
|
||||
else
|
||||
if (gAirCopyIsSendMode == 1)
|
||||
} else if (gAirCopyIsSendMode == 1) {
|
||||
sprintf(String, "SND:%u", gAirCopyBlockNumber);
|
||||
}
|
||||
UI_PrintString(String, 2, 127, 4, 8);
|
||||
|
||||
ST7565_BlitFullScreen();
|
||||
|
||||
80
ui/battery.c
@@ -21,67 +21,35 @@
|
||||
#include "driver/st7565.h"
|
||||
#include "functions.h"
|
||||
#include "ui/battery.h"
|
||||
#include "../misc.h"
|
||||
|
||||
void UI_DisplayBattery(const uint8_t level, const uint8_t blink)
|
||||
void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink)
|
||||
{
|
||||
// if (gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
{
|
||||
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
|
||||
|
||||
#if 1
|
||||
if (level < 2 && blink == 1) {
|
||||
memset(bitmap, 0, sizeof(BITMAP_BatteryLevel1));
|
||||
return;
|
||||
}
|
||||
|
||||
if (level >= 2)
|
||||
{
|
||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||
uint8_t *pb = bitmap + sizeof(BITMAP_BatteryLevel1);
|
||||
if (level >= 2)
|
||||
memmove(pb - 4, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 5)
|
||||
memmove(pb - 7, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 7)
|
||||
memmove(pb - 10, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 9)
|
||||
memmove(pb - 13, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
#else
|
||||
if (level >= 2)
|
||||
memmove(bitmap + 3, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 5)
|
||||
memmove(bitmap + 6, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 7)
|
||||
memmove(bitmap + 9, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 9)
|
||||
memmove(bitmap + 12, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if (blink == 1)
|
||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
else
|
||||
memset(bitmap, 0, sizeof(bitmap));
|
||||
memcpy(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
|
||||
if (level <= 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t bars = MIN(4, level - 2);
|
||||
|
||||
for (int i = 0; i < bars; i++) {
|
||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||
memcpy(bitmap + sizeof(BITMAP_BatteryLevel1) - 4 - (i * 3), BITMAP_BatteryLevel, 2);
|
||||
#else
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
const uint8_t lev = (level <= 11) ? level : 11;
|
||||
|
||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
|
||||
#ifdef ENABLE_REVERSE_BAT_SYMBOL
|
||||
for (uint8_t i = 0; i < lev; i++)
|
||||
bitmap[3 + i] = (i & 1u) ? 0b01011101 : 0b01011101;
|
||||
#else
|
||||
for (uint8_t i = 0; i < lev; i++)
|
||||
bitmap[sizeof(bitmap) - 3 - i] = (i & 1u) ? 0b01011101 : 0b01011101;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
memset(bitmap, 0, sizeof(bitmap));
|
||||
|
||||
memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2);
|
||||
#endif
|
||||
|
||||
// col lne, siz, bm
|
||||
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
void UI_DisplayBattery(uint8_t level, uint8_t blink)
|
||||
{
|
||||
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
|
||||
UI_DrawBattery(bitmap, level, blink);
|
||||
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, bitmap, sizeof(bitmap));
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#define UI_BATTERY_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void UI_DisplayBattery(const uint8_t Level, const uint8_t blink);
|
||||
void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink);
|
||||
void UI_DisplayBattery(uint8_t Level, uint8_t blink);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
109
ui/fmradio.c
@@ -19,6 +19,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "app/fm.h"
|
||||
#include "driver/bk1080.h"
|
||||
#include "driver/st7565.h"
|
||||
#include "external/printf/printf.h"
|
||||
#include "misc.h"
|
||||
@@ -30,80 +31,70 @@
|
||||
|
||||
void UI_DisplayFM(void)
|
||||
{
|
||||
unsigned int i;
|
||||
char String[16];
|
||||
char String[16] = {0};
|
||||
char *pPrintStr = String;
|
||||
UI_DisplayClear();
|
||||
|
||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
||||
UI_PrintString("FM", 2, 0, 0, 8);
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
strcpy(String, "FM");
|
||||
UI_PrintString(String, 0, 127, 0, 12);
|
||||
sprintf(String, "%d%s-%dM",
|
||||
BK1080_GetFreqLoLimit(gEeprom.FM_Band)/10,
|
||||
gEeprom.FM_Band == 0 ? ".5" : "",
|
||||
BK1080_GetFreqHiLimit(gEeprom.FM_Band)/10
|
||||
);
|
||||
|
||||
UI_PrintStringSmallNormal(String, 1, 0, 6);
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
if (gAskToSave)
|
||||
{
|
||||
strcpy(String, "SAVE?");
|
||||
}
|
||||
else
|
||||
if (gAskToDelete)
|
||||
{
|
||||
strcpy(String, "DEL?");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gFM_ScanState == FM_SCAN_OFF)
|
||||
{
|
||||
if (!gEeprom.FM_IsMrMode)
|
||||
{
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i])
|
||||
{
|
||||
sprintf(String, "VFO(CH%02u)", i + 1);
|
||||
break;
|
||||
}
|
||||
//uint8_t spacings[] = {20,10,5};
|
||||
//sprintf(String, "%d0k", spacings[gEeprom.FM_Space % 3]);
|
||||
//UI_PrintStringSmallNormal(String, 127 - 4*7, 0, 6);
|
||||
|
||||
if (gAskToSave) {
|
||||
pPrintStr = "SAVE?";
|
||||
} else if (gAskToDelete) {
|
||||
pPrintStr = "DEL?";
|
||||
} else if (gFM_ScanState == FM_SCAN_OFF) {
|
||||
if (gEeprom.FM_IsMrMode) {
|
||||
sprintf(String, "MR(CH%02u)", gEeprom.FM_SelectedChannel + 1);
|
||||
pPrintStr = String;
|
||||
} else {
|
||||
pPrintStr = "VFO";
|
||||
for (unsigned int i = 0; i < 20; i++) {
|
||||
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i]) {
|
||||
sprintf(String, "VFO(CH%02u)", i + 1);
|
||||
pPrintStr = String;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 20)
|
||||
strcpy(String, "VFO");
|
||||
}
|
||||
else
|
||||
sprintf(String, "MR(CH%02u)", gEeprom.FM_SelectedChannel + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gFM_AutoScan)
|
||||
strcpy(String, "M-SCAN");
|
||||
else
|
||||
sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1);
|
||||
}
|
||||
} else if (gFM_AutoScan) {
|
||||
sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1);
|
||||
pPrintStr = String;
|
||||
} else {
|
||||
pPrintStr = "M-SCAN";
|
||||
}
|
||||
UI_PrintString(String, 0, 127, 2, 10);
|
||||
|
||||
UI_PrintString(pPrintStr, 0, 127, 3, 10); // memory, vfo, scan
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0))
|
||||
{
|
||||
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0)) {
|
||||
UI_GenerateChannelString(String, gFM_ChannelPosition);
|
||||
}
|
||||
else
|
||||
if (!gAskToDelete)
|
||||
{
|
||||
if (gInputBoxIndex == 0)
|
||||
{
|
||||
NUMBER_ToDigits(gEeprom.FM_FrequencyPlaying * 10000, String);
|
||||
UI_DisplayFrequency(String, 23, 4, false, true);
|
||||
} else if (gAskToDelete) {
|
||||
sprintf(String, "CH-%02u", gEeprom.FM_SelectedChannel + 1);
|
||||
} else {
|
||||
if (gInputBoxIndex == 0) {
|
||||
sprintf(String, "%3d.%d", gEeprom.FM_FrequencyPlaying / 10, gEeprom.FM_FrequencyPlaying % 10);
|
||||
} else {
|
||||
const char * ascii = INPUTBOX_GetAscii();
|
||||
sprintf(String, "%.3s.%.1s",ascii, ascii + 3);
|
||||
}
|
||||
else
|
||||
UI_DisplayFrequency(gInputBox, 23, 4, true, false);
|
||||
|
||||
UI_DisplayFrequency(String, 36, 1, gInputBoxIndex == 0); // frequency
|
||||
ST7565_BlitFullScreen();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(String, "CH-%02u", gEeprom.FM_SelectedChannel + 1);
|
||||
}
|
||||
UI_PrintString(String, 0, 127, 4, 10);
|
||||
|
||||
UI_PrintString(String, 0, 127, 1, 10);
|
||||
|
||||
ST7565_BlitFullScreen();
|
||||
}
|
||||
|
||||
301
ui/helper.c
@@ -21,6 +21,7 @@
|
||||
#include "font.h"
|
||||
#include "ui/helper.h"
|
||||
#include "ui/inputbox.h"
|
||||
#include "misc.h"
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
|
||||
@@ -45,21 +46,36 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel)
|
||||
|
||||
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber)
|
||||
{
|
||||
if (gInputBoxIndex > 0)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < 3; i++)
|
||||
if (gInputBoxIndex > 0) {
|
||||
for (unsigned int i = 0; i < 3; i++) {
|
||||
pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
|
||||
}
|
||||
|
||||
pString[3] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bShowPrefix)
|
||||
if (bShowPrefix) {
|
||||
// BUG here? Prefixed NULLs are allowed
|
||||
sprintf(pString, "CH-%03u", ChannelNumber + 1);
|
||||
else
|
||||
if (ChannelNumber == 0xFF)
|
||||
} else if (ChannelNumber == 0xFF) {
|
||||
strcpy(pString, "NULL");
|
||||
else
|
||||
} else {
|
||||
sprintf(pString, "%03u", ChannelNumber + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void UI_PrintStringBuffer(const char *pString, uint8_t * buffer, uint32_t char_width, const uint8_t *font)
|
||||
{
|
||||
const size_t Length = strlen(pString);
|
||||
const unsigned int char_spacing = char_width + 1;
|
||||
for (size_t i = 0; i < Length; i++) {
|
||||
const unsigned int index = pString[i] - ' ' - 1;
|
||||
if (pString[i] > ' ' && pString[i] < 127) {
|
||||
const uint32_t offset = i * char_spacing + 1;
|
||||
memcpy(buffer + offset, font + index * char_width, char_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width)
|
||||
@@ -72,189 +88,168 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin
|
||||
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
if (pString[i] >= ' ' && pString[i] < 127)
|
||||
const unsigned int ofs = (unsigned int)Start + (i * Width);
|
||||
if (pString[i] > ' ' && pString[i] < 127)
|
||||
{
|
||||
const unsigned int index = pString[i] - ' ';
|
||||
const unsigned int ofs = (unsigned int)Start + (i * Width);
|
||||
memmove(gFrameBuffer[Line + 0] + ofs, &gFontBig[index][0], 8);
|
||||
memmove(gFrameBuffer[Line + 1] + ofs, &gFontBig[index][8], 7);
|
||||
const unsigned int index = pString[i] - ' ' - 1;
|
||||
memcpy(gFrameBuffer[Line + 0] + ofs, &gFontBig[index][0], 7);
|
||||
memcpy(gFrameBuffer[Line + 1] + ofs, &gFontBig[index][7], 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
||||
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t char_width, const uint8_t *font)
|
||||
{
|
||||
const size_t Length = strlen(pString);
|
||||
size_t i;
|
||||
|
||||
if (End > Start)
|
||||
Start += (((End - Start) - (Length * 8)) + 1) / 2;
|
||||
|
||||
const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||
const unsigned int char_spacing = char_width + 1;
|
||||
uint8_t *pFb = gFrameBuffer[Line] + Start;
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
if (pString[i] >= 32)
|
||||
{
|
||||
const unsigned int index = (unsigned int)pString[i] - 32;
|
||||
if (index < ARRAY_SIZE(gFontSmall))
|
||||
memmove(pFb + (i * char_spacing) + 1, &gFontSmall[index], char_width);
|
||||
}
|
||||
|
||||
if (End > Start) {
|
||||
Start += (((End - Start) - Length * char_spacing) + 1) / 2;
|
||||
}
|
||||
|
||||
UI_PrintStringBuffer(pString, gFrameBuffer[Line] + Start, char_width, font);
|
||||
}
|
||||
|
||||
void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
||||
{
|
||||
UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *)gFontSmall);
|
||||
}
|
||||
|
||||
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
||||
{
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
||||
{
|
||||
const size_t Length = strlen(pString);
|
||||
size_t i;
|
||||
|
||||
if (End > Start)
|
||||
Start += (((End - Start) - (Length * 8)) + 1) / 2;
|
||||
|
||||
const unsigned int char_width = ARRAY_SIZE(gFontSmallBold[0]);
|
||||
const unsigned int char_spacing = char_width + 1;
|
||||
uint8_t *pFb = gFrameBuffer[Line] + Start;
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
if (pString[i] >= 32)
|
||||
{
|
||||
const unsigned int index = (unsigned int)pString[i] - 32;
|
||||
if (index < ARRAY_SIZE(gFontSmallBold))
|
||||
memmove(pFb + (i * char_spacing) + 1, &gFontSmallBold[index], char_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
const uint8_t *font = (uint8_t *)gFontSmallBold;
|
||||
const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]);
|
||||
#else
|
||||
const uint8_t *font = (uint8_t *)gFontSmall;
|
||||
const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||
#endif
|
||||
|
||||
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer)
|
||||
{
|
||||
size_t i;
|
||||
const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||
const unsigned int char_spacing = char_width + 1;
|
||||
for (i = 0; i < strlen(pString); i++)
|
||||
{
|
||||
if (pString[i] >= 32)
|
||||
{
|
||||
const unsigned int index = (unsigned int)pString[i] - 32;
|
||||
if (index < ARRAY_SIZE(gFontSmall))
|
||||
memmove(buffer + (i * char_spacing) + 1, &gFontSmall[index], char_width);
|
||||
}
|
||||
}
|
||||
UI_PrintStringSmall(pString, Start, End, Line, char_width, font);
|
||||
}
|
||||
|
||||
void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag)
|
||||
void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t * buffer)
|
||||
{
|
||||
UI_PrintStringBuffer(pString, buffer, ARRAY_SIZE(gFontSmall[0]), (uint8_t *)gFontSmall);
|
||||
}
|
||||
|
||||
void UI_PrintStringSmallBufferBold(const char *pString, uint8_t * buffer)
|
||||
{
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
const uint8_t *font = (uint8_t *)gFontSmallBold;
|
||||
const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]);
|
||||
#else
|
||||
const uint8_t *font = (uint8_t *)gFontSmall;
|
||||
const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||
#endif
|
||||
UI_PrintStringBuffer(pString, buffer, char_width, font);
|
||||
}
|
||||
|
||||
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
|
||||
{
|
||||
const unsigned int char_width = 13;
|
||||
uint8_t *pFb0 = gFrameBuffer[Y] + X;
|
||||
uint8_t *pFb1 = pFb0 + 128;
|
||||
bool bCanDisplay = false;
|
||||
unsigned int i = 0;
|
||||
|
||||
// MHz
|
||||
while (i < 3)
|
||||
{
|
||||
const unsigned int Digit = pDigits[i++];
|
||||
if (bDisplayLeadingZero || bCanDisplay || Digit > 0)
|
||||
|
||||
uint8_t len = strlen(string);
|
||||
for(int i = 0; i < len; i++) {
|
||||
char c = string[i];
|
||||
if(c=='-') c = '9' + 1;
|
||||
if (bCanDisplay || c != ' ')
|
||||
{
|
||||
bCanDisplay = true;
|
||||
memmove(pFb0, gFontBigDigits[Digit], char_width);
|
||||
memmove(pFb1, gFontBigDigits[Digit] + char_width, char_width);
|
||||
if(c>='0' && c<='9' + 1) {
|
||||
memcpy(pFb0 + 2, gFontBigDigits[c-'0'], char_width - 3);
|
||||
memcpy(pFb1 + 2, gFontBigDigits[c-'0'] + char_width - 3, char_width - 3);
|
||||
}
|
||||
else if(c=='.') {
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
if (bFlag)
|
||||
{
|
||||
else if (center) {
|
||||
pFb0 -= 6;
|
||||
pFb1 -= 6;
|
||||
}
|
||||
pFb0 += char_width;
|
||||
pFb1 += char_width;
|
||||
}
|
||||
}
|
||||
|
||||
// decimal point
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
|
||||
// kHz
|
||||
while (i < 6)
|
||||
{
|
||||
const unsigned int Digit = pDigits[i++];
|
||||
memmove(pFb0, gFontBigDigits[Digit], char_width);
|
||||
memmove(pFb1, gFontBigDigits[Digit] + char_width, char_width);
|
||||
pFb0 += char_width;
|
||||
pFb1 += char_width;
|
||||
void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black)
|
||||
{
|
||||
const uint8_t pattern = 1 << (y % 8);
|
||||
if(black)
|
||||
buffer[y/8][x] |= pattern;
|
||||
else
|
||||
buffer[y/8][x] &= ~pattern;
|
||||
}
|
||||
|
||||
static void sort(int16_t *a, int16_t *b)
|
||||
{
|
||||
if(*a > *b) {
|
||||
int16_t t = *a;
|
||||
*a = *b;
|
||||
*b = t;
|
||||
}
|
||||
}
|
||||
|
||||
void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero)
|
||||
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
|
||||
{
|
||||
const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||
const unsigned int spacing = 1 + char_width;
|
||||
uint8_t *pFb = gFrameBuffer[Y] + X;
|
||||
bool bCanDisplay = false;
|
||||
unsigned int i = 0;
|
||||
|
||||
// MHz
|
||||
while (i < 3)
|
||||
{
|
||||
const unsigned int c = pDigits[i++];
|
||||
if (bDisplayLeadingZero || bCanDisplay || c > 0)
|
||||
{
|
||||
#if 0
|
||||
memmove(pFb + 1, gFontSmallDigits[c], char_width);
|
||||
#else
|
||||
const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32;
|
||||
memmove(pFb + 1, gFontSmall[index], char_width);
|
||||
#endif
|
||||
pFb += spacing;
|
||||
bCanDisplay = true;
|
||||
if(x2==x1) {
|
||||
sort(&y1, &y2);
|
||||
for(int16_t i = y1; i <= y2; i++) {
|
||||
UI_DrawPixelBuffer(buffer, x1, i, black);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const int multipl = 1000;
|
||||
int a = (y2-y1)*multipl / (x2-x1);
|
||||
int b = y1 - a * x1 / multipl;
|
||||
|
||||
// decimal point
|
||||
pFb++;
|
||||
pFb++;
|
||||
*pFb++ = 0x60;
|
||||
*pFb++ = 0x60;
|
||||
pFb++;
|
||||
|
||||
// kHz
|
||||
while (i < 8)
|
||||
{
|
||||
const unsigned int c = pDigits[i++];
|
||||
#if 0
|
||||
memmove(pFb + 1, gFontSmallDigits[c], char_width);
|
||||
#else
|
||||
const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32;
|
||||
memmove(pFb + 1, gFontSmall[index], char_width);
|
||||
#endif
|
||||
pFb += spacing;
|
||||
}
|
||||
}
|
||||
|
||||
void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros)
|
||||
{
|
||||
const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||
const unsigned int spacing = 1 + char_width;
|
||||
bool display = display_leading_zeros;
|
||||
unsigned int xx;
|
||||
unsigned int i;
|
||||
for (i = 0, xx = x; i < size; i++)
|
||||
{
|
||||
const unsigned int c = (unsigned int)str[i];
|
||||
if (c > 0)
|
||||
display = true; // non '0'
|
||||
if (display && c < 11)
|
||||
sort(&x1, &x2);
|
||||
for(int i = x1; i<= x2; i++)
|
||||
{
|
||||
#if 0
|
||||
memmove(gFrameBuffer[y] + xx, gFontSmallDigits[c], char_width);
|
||||
#else
|
||||
const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32;
|
||||
memmove(gFrameBuffer[y] + xx + 1, gFontSmall[index], char_width);
|
||||
#endif
|
||||
xx += spacing;
|
||||
UI_DrawPixelBuffer(buffer, i, i*a/multipl +b, black);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
|
||||
{
|
||||
UI_DrawLineBuffer(buffer, x1,y1, x1,y2, black);
|
||||
UI_DrawLineBuffer(buffer, x1,y1, x2,y1, black);
|
||||
UI_DrawLineBuffer(buffer, x2,y1, x2,y2, black);
|
||||
UI_DrawLineBuffer(buffer, x1,y2, x2,y2, black);
|
||||
}
|
||||
|
||||
|
||||
void UI_DisplayPopup(const char *string)
|
||||
{
|
||||
UI_DisplayClear();
|
||||
|
||||
// for(uint8_t i = 1; i < 5; i++) {
|
||||
// memset(gFrameBuffer[i]+8, 0x00, 111);
|
||||
// }
|
||||
|
||||
// for(uint8_t x = 10; x < 118; x++) {
|
||||
// UI_DrawPixelBuffer(x, 10, true);
|
||||
// UI_DrawPixelBuffer(x, 46-9, true);
|
||||
// }
|
||||
|
||||
// for(uint8_t y = 11; y < 37; y++) {
|
||||
// UI_DrawPixelBuffer(10, y, true);
|
||||
// UI_DrawPixelBuffer(117, y, true);
|
||||
// }
|
||||
// DrawRectangle(9,9, 118,38, true);
|
||||
UI_PrintString(string, 9, 118, 2, 8);
|
||||
UI_PrintStringSmallNormal("Press EXIT", 9, 118, 6);
|
||||
}
|
||||
|
||||
void UI_DisplayClear()
|
||||
{
|
||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
||||
}
|
||||
|
||||
22
ui/helper.h
@@ -23,14 +23,18 @@
|
||||
void UI_GenerateChannelString(char *pString, const uint8_t Channel);
|
||||
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber);
|
||||
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width);
|
||||
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||
#endif
|
||||
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer);
|
||||
void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag);
|
||||
void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero);
|
||||
void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros);
|
||||
void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||
void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t *buffer);
|
||||
void UI_PrintStringSmallBufferBold(const char *pString, uint8_t * buffer);
|
||||
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center);
|
||||
|
||||
void UI_DisplayPopup(const char *string);
|
||||
|
||||
void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black);
|
||||
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
|
||||
void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
|
||||
|
||||
void UI_DisplayClear();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||