Compare commits

..
233 Commits
Author SHA1 Message Date
Armel FAUVEAU 786318453f Merge pull request #314 from armel/feature_update_v5
Feature update v5
2026-04-28 03:51:29 +02:00
Armel FAUVEAU 61662f3965 Prepare new version v5.4.0 2026-04-28 03:48:04 +02:00
Armel FAUVEAU b3cfda76e5 Merge pull request #313 from mrkusypl/feature_update_v5_2
Code refactoring (68 B)
2026-04-27 22:13:05 +02:00
mrkusypl a20f1ce28e Code refactoring (68 B) 2026-04-27 16:26:49 +02:00
Armel FAUVEAU 8a292755b0 Prepare new version 2026-04-27 15:15:10 +02:00
Armel FAUVEAU 915fc6aa90 SysInf tweak 2026-04-27 15:12:48 +02:00
Armel FAUVEAU cac63f978e Revert "Add UI_PrintStringYOffset to shift big-font"
This reverts commit d5edba1fc2.
2026-04-27 15:03:44 +02:00
Armel FAUVEAU d5edba1fc2 Add UI_PrintStringYOffset to shift big-font 2026-04-27 06:10:44 +02:00
Armel FAUVEAU 2f0852cd03 Add SysInf build details page 2026-04-27 04:12:51 +02:00
Armel FAUVEAU a65f84305e Show firmware version in big font 2026-04-27 04:00:08 +02:00
Armel FAUVEAU 1c0d5ea628 Move SysInf battery data to dedicated page (and patch m lower...) 2026-04-27 03:54:13 +02:00
Armel FAUVEAU a0a5b93408 Merge pull request #312 from mrkusypl/feature_update_v5_2
Code refactoring (12 B)
2026-04-27 02:46:17 +02:00
mrkusypl e8cb32a4ca Code refactoring (12 B) 2026-04-27 02:34:49 +02:00
Armel FAUVEAU 706dea756c Refactor: QR codes only in SysInf menu, drop welcome splash 2026-04-26 23:20:44 +02:00
Armel FAUVEAU 1ea8aba88e Add QR code welcome screen with repo and wiki links 2026-04-26 15:12:24 +02:00
Armel FAUVEAU c2d6a4b751 Fix excluded scan gauge rendering for large channel lists 2026-04-26 04:39:14 +02:00
Armel FAUVEAU db61bce014 Merge pull request #310 from mrkusypl/feature_update_v5_2
Entering text into ChName in a multi-tap system
2026-04-26 03:09:28 +02:00
mrkusypl a3c03f18f0 Fix for string terminator overwriting 2026-04-26 02:24:27 +02:00
mrkusypl 8977a0a112 Entering text into ChName in a multi-tap system 2026-04-26 01:09:57 +02:00
Armel FAUVEAU 09a5e3c1e7 Fix limit bug with scan gauge 2026-04-25 05:09:32 +02:00
Armel FAUVEAU 4fa821e15f Oops ! Preserve scan gauge width calculation, with or without priority labels 2026-04-25 04:50:50 +02:00
Armel FAUVEAU c9a383919a Improve scan progress gauge when priority channels are in use 2026-04-25 04:39:18 +02:00
Armel FAUVEAU e8ba069000 Merge pull request #308 from mrkusypl/feature_update_v5_2
Code refactoring (200 B)
2026-04-25 02:21:18 +02:00
mrkusypl acd2c340ea Code refactoring (200 B) 2026-04-25 02:10:52 +02:00
Armel FAUVEAU 24fd6fd9b1 Improve spectrum trigger line rendering 2026-04-25 00:17:50 +02:00
Armel FAUVEAU 86bb710ca4 Merge pull request #307 from mrkusypl/feature_update_v5_2
Reversing the up/down button functions on the Spectrum
2026-04-24 20:04:32 +02:00
mrkusypl 7148c15f98 Reversing the up/down button functions on the Spectrum 2026-04-24 20:02:05 +02:00
Armel FAUVEAU 2d7093651d Show sweep direction arrow next to A:NORM/WEAK/STRG label 2026-04-24 19:45:20 +02:00
Armel FAUVEAU 874e5aac4b Extract SETTINGS_LoadEepromDtmf to file scope to drop the GCC nested-function extension 2026-04-24 19:35:48 +02:00
Armel FAUVEAU 8051605c16 Guard interlaced sweep code behind SPECTRUM_INTERLACE_LARGE_SWEEPS to silence unused warnings 2026-04-24 19:30:14 +02:00
Armel FAUVEAU 134624825f Merge pull request #306 from mrkusypl/feature_update_v5_2
Code refactoring (232 B)
2026-04-24 18:04:04 +02:00
mrkusypl 7d0fcc8415 Code refactoring (232 B) 2026-04-24 17:51:48 +02:00
Armel FAUVEAU c27b72d6bc Merge pull request #305 from mrkusypl/feature_update_v5_2
Code refactoring (180 B)
2026-04-24 04:49:11 +02:00
Armel FAUVEAU 066c0d0e14 Spectrum experimentation 2026-04-24 04:48:18 +02:00
mrkusypl e77b87f1f2 Another code refactoring (40 B) 2026-04-24 00:09:38 +02:00
mrkusypl 2dd5e1a509 Code refactoring (140 B) 2026-04-23 18:32:39 +02:00
Armel FAUVEAU ab9e97805e Merge pull request #300 from mrkusypl/feature_update_v5_2
Refactoring ScanProgress_DrawGaugeLine
2026-04-23 02:28:38 +02:00
Armel FAUVEAU 65c584ff7d Spectrum/BK4829: interlace large sweeps and cut SPI overhead 2026-04-23 02:27:52 +02:00
mrkusypl 4c76ca1fb4 Refactoring ScanProgress_DrawGaugeLine 2026-04-22 22:33:30 +02:00
Armel FAUVEAU 094896b5f1 UI format progress index with dynamic zero padding based on total digits 2026-04-22 04:00:29 +02:00
Armel FAUVEAU 669dad5b2e Merge pull request #298 from mrkusypl/feature_update_v5_2
Changing the length of the scan progress gauge
2026-04-22 03:31:48 +02:00
Armel FAUVEAU b9902e0c49 UI unify and center top-right menu info badges 2026-04-22 03:30:52 +02:00
mrkusypl 0a955c1f15 Changing the length of the scan progress gauge 2026-04-22 01:54:49 +02:00
Armel FAUVEAU 9f649b5f5b Merge pull request #297 from mrkusypl/feature_update_v5_2
Code refactoring (44 B)
2026-04-21 20:35:33 +02:00
Armel FAUVEAU bb992ca85d Scan progress gauge behind ENABLE_FEAT_F4HWN_SCAN_PROGRESS 2026-04-21 20:34:20 +02:00
mrkusypl 679cf4ea1f Code refactoring (44 B) 2026-04-21 17:26:18 +02:00
Armel FAUVEAU 0004074ffe Fix large-range spectrum stability and manual dB floor behavior 2026-04-21 05:25:28 +02:00
Armel FAUVEAU 35e5d8df90 Fix spectrum manual trigger persistence across scan relaunches 2026-04-21 03:07:23 +02:00
Armel FAUVEAU fa0de5f576 Spectrum: fix and polish manual mode (manualSetFlag) from PR #296 2026-04-21 02:36:32 +02:00
Armel FAUVEAU 4162618473 Merge pull request #296 from mrkusypl/feature_update_v5_2
Code refactoring, improvements in Spectrum
2026-04-21 01:58:39 +02:00
mrkusypl 284af7ca1d Code refactoring, improvements in Spectrum 2026-04-20 23:05:05 +02:00
Armel FAUVEAU c6f1f7b483 Spectrum: align channel name and frequency at x=43 to avoid dBm overlap 2026-04-19 03:21:43 +02:00
Armel FAUVEAU 6cea90d507 Merge pull request #292 from mrkusypl/feature_update_v5_2
Code optimization (80 B), behavior of the EXIT button when editing ChName
2026-04-19 00:29:34 +02:00
Armel FAUVEAU 46608af767 Spectrum refactoring 2026-04-18 18:36:39 +02:00
mrkusypl 24167a7902 Code optimization (80 B), behavior of the EXIT button when editing ChName 2026-04-18 18:30:22 +02:00
Armel FAUVEAU e300c4e7e3 Improve ChName editing with long-press EXIT backspace (issue #281) 2026-04-18 01:09:40 +02:00
Armel FAUVEAU 1a815b315f Update donors 2026-04-18 00:42:49 +02:00
Armel FAUVEAU a7fed2c2d8 Spectrum refactoring 2026-04-18 00:41:24 +02:00
Armel FAUVEAU 9e92037674 Fix build without ENABLE_FMRADIO in APP_TimeSlice500ms 2026-04-15 22:17:05 +02:00
Armel FAUVEAU e536725731 Show homologated CTCSS index in Rx/Tx CTCSS menus 2026-04-15 00:20:13 +02:00
Armel FAUVEAU f59370cee6 Merge pull request #268 from mrkusypl/feature_update_v5_2
Improvements to FM Radio and the UI
2026-04-14 23:11:03 +02:00
mrkusypl bdaf320c08 Fix the channel number display 2026-04-09 10:17:07 +02:00
Armel FAUVEAU fb60d6f7fd Add WIDE/NARROW filter selection for AM RX 2026-04-09 02:44:20 +02:00
Armel FAUVEAU 22295eedcf Update donors 2026-04-08 18:08:50 +02:00
mrkusypl 21c215e9fd Improvements to FM Radio and the UI 2026-04-05 21:01:13 +02:00
Armel FAUVEAU 0061613883 Merge pull request #265 from armel/feature_update_v5
Feature update v5
2026-04-05 06:29:27 +02:00
Armel FAUVEAU aecbcc6409 Update README 2026-04-05 06:27:34 +02:00
Armel FAUVEAU 642dcc9a43 Add support for decoding packed Quansheng stock firmware images 2026-04-03 05:00:38 +02:00
Armel FAUVEAU 2b05990a2c Refactor hidden menu entry to start from first hidden item 2026-04-03 04:28:39 +02:00
Armel FAUVEAU 975084baca Merge pull request #252 from mrkusypl/feature_update_v5_2
Code refactoring (108 B)
2026-04-02 00:06:08 +02:00
mrkusypl 775cd7751a Undo refactoring of AUDIO_Apply(FM/AM)Profile 2026-04-01 13:26:29 +02:00
mrkusypl c5da503cb3 Code refactoring (136 B) 2026-04-01 00:37:44 +02:00
Armel FAUVEAU 5f8a492f4f Merge pull request #251 from armel/feature_update_v5
Update donors
2026-03-31 19:01:33 +02:00
Armel FAUVEAU 8dd5da195e Update donors 2026-03-31 19:00:32 +02:00
Armel FAUVEAU 61aa14cd86 Merge pull request #250 from armel/feature_update_v5
Feature update v5
2026-03-31 18:46:53 +02:00
Armel FAUVEAU 86a6bac145 Prepare new version 2026-03-31 18:45:54 +02:00
Armel FAUVEAU 26616c506e New version 2026-03-31 18:43:44 +02:00
Armel FAUVEAU f8c48ceb8a Merge pull request #249 from mrkusypl/feature_update_v5_2
Code refactoring (64 B)
2026-03-31 18:13:42 +02:00
Armel FAUVEAU 3d739c642e Add Rx audio profiles for AM 2026-03-31 18:13:17 +02:00
mrkusypl 25b96be1a3 Code refactoring (64 B) 2026-03-31 02:57:20 +02:00
Armel FAUVEAU 397ef318f8 Merge pull request #248 from mrkusypl/feature_update_v5_2
Fixed the issue where the squelch level would reset to 1 upon restart (#246)
2026-03-30 16:37:23 +02:00
mrkusypl fbb06fed05 Fixed the issue where the squelch level would reset to 1 upon restart (#246) 2026-03-30 15:20:08 +02:00
Armel FAUVEAU 064a203db0 Merge pull request #243 from armel/feature_update_v5
Feature update v5
2026-03-28 23:23:05 +01:00
Armel FAUVEAU 5987ec7b64 New version 5.3.0 2026-03-28 23:22:00 +01:00
Armel FAUVEAU d72524879b Merge pull request #242 from mrkusypl/feature_update_v5_2
Eliminating high bars in Audio Scope after releasing the DTMF button
2026-03-28 21:03:49 +01:00
mrkusypl db46cea0eb Eliminating high bars in Audio Scope after releasing the DTMF/1750 button 2026-03-28 18:15:20 +01:00
Armel FAUVEAU 8f75d6813b Merge pull request #241 from mrkusypl/feature_update_v5_2
Fix for the Audio Scope in OnePush mode
2026-03-28 01:55:15 +01:00
mrkusypl 1f577ec82e Fix for the Audio Scope in OnePush mode 2026-03-28 01:41:19 +01:00
Armel FAUVEAU 1f801757e9 Merge pull request #239 from mrkusypl/feature_update_v5_2
An even better improvement to Audio Scope
2026-03-27 19:25:52 +01:00
mrkusypl 4588e58af5 An even better improvement to Audio Scope 2026-03-27 17:18:16 +01:00
Armel FAUVEAU 6fe1bec80c Improve Audio Scope 2026-03-27 01:50:16 +01:00
Armel FAUVEAU a2735b1167 Merge pull request #238 from mrkusypl/feature_update_v5_2
Optimizing the Audio Scope code
2026-03-26 18:49:36 +01:00
mrkusypl 249b0b2bb7 Optimizing the Audio Scope code 2026-03-26 17:47:21 +01:00
Armel FAUVEAU 62320f5fbe Update donors 2026-03-26 05:00:43 +01:00
Armel FAUVEAU cebbda72ec Add audio scope feature just for fun 2026-03-26 04:58:49 +01:00
Armel FAUVEAU c51033db77 bk4829: align RX squelch REG_4E with stock firmware 2026-03-26 03:24:17 +01:00
Armel FAUVEAU f863c41d40 Merge pull request #234 from mrkusypl/feature_update_v5_2
Improvements to the FM radio and side buttons
2026-03-26 02:29:21 +01:00
mrkusypl ab7b4ca094 Adding the ‘gRequestSaveSquelch’ flag to the squelch level save 2026-03-25 22:44:20 +01:00
mrkusypl 179c271618 Save the squelch level adjusted using F+UP/DOWN 2026-03-25 21:36:38 +01:00
mrkusypl 2e6dfe3bc7 Revert changes related to RescueOps 2026-03-25 19:22:23 +01:00
Armel FAUVEAU 122cf48d3e Clarify BK4829 REG_43 docs and keep stock AM/W/N behavior coherent 2026-03-24 05:09:57 +01:00
Armel FAUVEAU dea747c628 Fix W/N (issue #233) 2026-03-24 03:49:52 +01:00
mrkusypl bbbc553064 Improvements to the FM radio and side buttons 2026-03-24 00:31:45 +01:00
Armel FAUVEAU 43c40ae9a0 Merge pull request #232 from mrkusypl/feature_update_v5_2
Displaying power bars during TX when using SetPwr; Restore full VFO state on long press of EXIT
2026-03-23 00:32:32 +01:00
Armel FAUVEAU 6fdb17d64a Align BK4829 AGC runtime with stock firmware 2026-03-23 00:31:16 +01:00
mrkusypl aa69d698a7 Code optimization (32 B); Restore full VFO state on long press of EXIT 2026-03-22 20:58:27 +01:00
mrkusypl f4a32b4350 Displaying power bars during TX when using SetPwr 2026-03-22 16:19:08 +01:00
Armel FAUVEAU 688b3a5c77 Merge pull request #229 from mrkusypl/feature_update_v5_2
Minor code refactoring (24 B)
2026-03-22 04:08:24 +01:00
Armel FAUVEAU ff336cd5d9 Retry this... 2026-03-22 03:00:40 +01:00
mrkusypl 85dae05ad3 Minor code refactoring (24 B) 2026-03-21 19:13:51 +01:00
Armel FAUVEAU 2939620066 Update donors 2026-03-21 15:45:18 +01:00
Armel FAUVEAU 0b3a390cb9 Update donors 2026-03-21 00:49:40 +01:00
Armel FAUVEAU 3d4ffd7900 Fix VFO frequency input final digit handling 2026-03-21 00:16:14 +01:00
Armel FAUVEAU 06907f9b67 Merge pull request #226 from mrkusypl/v5_refactor
Enable beeps for Aircopy, minor code refactoring
2026-03-20 23:52:00 +01:00
mrkusypl 7c343a2b3e Enable beeps for Aircopy, minor code refactoring 2026-03-20 18:44:57 +01:00
Armel FAUVEAU b4f66e9bf3 Merge pull request #225 from mrkusypl/v5_refactor
Major code refactoring
2026-03-20 13:52:08 +01:00
mrkusypl 138e078984 Fix for S-meter calculation, AirCopy - removed redundant code 2026-03-20 10:47:50 +01:00
mrkusypl e28177cb9b Major code refactoring 2026-03-19 23:09:39 +01:00
Armel FAUVEAU a1f2f0cdb9 Fix: replace map() with IARU-compliant S-meter thresholds 2026-03-19 03:41:54 +01:00
Armel FAUVEAU e77e558d64 Revert welcome.c and fix default keepAlive to 3 (PR #218) 2026-03-18 01:07:03 +01:00
Armel FAUVEAU 7d5e5b7d97 Merge pull request #218 from mrkusypl/v5_fix
Code refactoring; improvements to K5Viewer and the UI
2026-03-17 00:30:07 +01:00
mrkusypl 315d7a6b59 An even better way to fix a button that keeps getting stuck in K5Viewer 2026-03-16 23:57:17 +01:00
mrkusypl 67231fd326 Replacing 'write_ptr' with 'read_ptr' when deleting old bytes 2026-03-16 15:04:45 +01:00
mrkusypl f4d8abd7d9 Increase the keepAlive value, fix the CHIRP connection while maintaining the fix for the button getting stuck 2026-03-16 14:57:57 +01:00
mrkusypl 9574376d38 Code refactoring; improvements to K5Viewer and the UI 2026-03-16 00:52:28 +01:00
Armel FAUVEAU f2666a6248 Screenshot force full frame on reconnection 2026-03-15 17:35:56 +01:00
Armel FAUVEAU ee5878d641 Merge pull request #216 from mrkusypl/v5_k5viewer_input
K5Viewer: More reliable key handling
2026-03-15 02:02:35 +01:00
mrkusypl 470d1959ba K5Viewer: More reliable key handling 2026-03-15 01:31:53 +01:00
Armel FAUVEAU f5d6f5782b Fix breakout: reliable key handling from K5Viewer (issue #214) 2026-03-14 19:36:33 +01:00
Armel FAUVEAU 5cb6bbdf7a Overlap between Live DTMF and Unlock Keyboard (issue #215) 2026-03-14 17:47:23 +01:00
Armel FAUVEAU 9f0547f6af Fix spectrum: reliable serial key input + USB-C unplug freeze fix (issue #212) 2026-03-14 05:34:17 +01:00
Armel FAUVEAU fcf94e34ce Merge pull request #211 from mrkusypl/v5_backlight_fade
Backlight fading and improved backlight control in spectrum
2026-03-12 02:36:54 +01:00
mrkusypl 5d88fda158 Added backlight fading, improved backlight control in spectrum 2026-03-11 22:52:10 +01:00
Armel FAUVEAU 7b7186e293 Improve one and two-letter scan list names (issue #206) 2026-03-10 04:37:10 +01:00
Armel FAUVEAU d83c6451c8 Fix EX label 2026-03-10 04:20:38 +01:00
Armel FAUVEAU eaa05f107e Improve one and two-letter scan list names (issue #206) 2026-03-10 04:00:43 +01:00
Armel FAUVEAU d0fdca4dc1 BYP and RAW for BK4829 2026-03-10 02:54:25 +01:00
Armel FAUVEAU 37f18972e7 BYP and RAW for BK4829 2026-03-09 05:24:12 +01:00
Armel FAUVEAU 7471ac90c5 Update file 2026-03-09 01:15:38 +01:00
Armel FAUVEAU d826cbd138 Reduce the lag between consecutive RX on both frequencies under DW mode (issue #198) 2026-03-09 01:02:19 +01:00
Armel FAUVEAU 5293a8526d Update donors 2026-03-08 22:14:28 +01:00
Armel FAUVEAU 74aa7b354e SetVol(68/69) keeps the changes despite Exit key is pressed (issue #200) 2026-03-08 22:09:53 +01:00
Armel FAUVEAU ffddf9a9b3 Increase PWM frequency to suppress audio interference (issue #195) 2026-03-08 00:17:33 +01:00
Armel FAUVEAU 77785d14c2 Code refactoring 2026-03-06 05:17:22 +01:00
Armel FAUVEAU f715f776a4 Write dBmCorrTable only if flash zone is erased 2026-03-06 05:14:50 +01:00
Armel FAUVEAU 8a8752f80c Merge pull request #187 from armel/feature_update_v5
New version 5.2.0
2026-03-06 02:02:39 +01:00
Armel FAUVEAU b361b5c3e2 New version 5.2.0 2026-03-06 02:02:12 +01:00
Armel FAUVEAU 98c0552ee3 Merge pull request #186 from armel/feature_update_v5
Feature update v5
2026-03-06 02:00:58 +01:00
Armel FAUVEAU 9a46bdf6bf Add mic gauge 2026-03-05 16:36:01 +01:00
Armel FAUVEAU 3f7d2e56d7 Merge pull request #184 from mrkusypl/v5_refactor
Bug fixes: Receiving the same channel in Dual Watch mode, disabling channel exclusion, changing the scan list, compilation error
2026-03-05 16:22:07 +01:00
mrkusypl 5b638e298e Bug fixes: Receiving the same channel in Dual Watch mode, disabling channel exclusion, changing the scan list, compilation error 2026-03-05 15:19:20 +01:00
kusy 6e232131b9 merge! 2026-03-05 13:52:48 +01:00
Armel FAUVEAU d9eb55fccf FM_CheckFrequencyLock() refactoring 2026-03-05 00:19:11 +01:00
Armel FAUVEAU afb317d12a Merge pull request #182 from mrkusypl/v5_refactor
Major code optimization (456 bytes saved)
2026-03-05 00:11:51 +01:00
kusy 2f90b401cb Restore FM_CheckFrequencyLock() 2026-03-04 18:06:41 +00:00
kusy 28500e1667 Major code optimization (536 bytes saved) 2026-03-04 14:10:02 +00:00
Armel FAUVEAU 4b8f8cf22a Change gDebug type 2026-03-04 01:42:38 +01:00
Armel FAUVEAU 37fb4abd2e Update donors 2026-03-03 17:45:54 +01:00
Armel FAUVEAU ec9bcba781 Increase MIC gain values 2026-02-28 00:13:39 +01:00
Armel FAUVEAU ed0f15959b Fix bug: can't build with Custom #175 2026-02-26 05:41:49 +01:00
Armel FAUVEAU 0c90b7d95c Fix freeze when using K5Viewer and USB-C 2026-02-25 04:49:38 +01:00
Armel FAUVEAU 2248b0cbbe Update donors 2026-02-25 03:16:51 +01:00
Armel FAUVEAU a244a25513 Add long press 2026-02-25 03:08:16 +01:00
Armel FAUVEAU f072b3eb02 Add virtual keyboard 2026-02-25 02:24:39 +01:00
Armel FAUVEAU 6ed0bc3436 Merge pull request #170 from mrkusypl/feature_update_v5
UI improvements, backlight toggle in FM radio, code optimization
2026-02-24 18:08:23 +01:00
kusy 793a44855d modified: App/app/app.c
modified:   App/app/fm.c
	modified:   App/app/generic.c
	modified:   App/app/main.c
2026-02-24 15:50:05 +00:00
Armel FAUVEAU 4937d0baba Improve SMeter Calibration 2026-02-23 02:43:30 +01:00
Armel FAUVEAU 29c0338c61 Fix screenshot and keyboard race 2026-02-21 18:27:13 +01:00
Armel FAUVEAU ed640588c5 Welcome refactoring 2026-02-21 04:31:43 +01:00
Armel FAUVEAU 335e1b5501 Update donors 2026-02-21 00:37:46 +01:00
Armel FAUVEAU d4e29c56a3 Improve channel input 2026-02-21 00:36:28 +01:00
Armel FAUVEAU dc08631274 Update donors 2026-02-19 15:32:33 +01:00
Armel FAUVEAU 0234900baf Add ENABLE_FEAT_F4HWN_MEM 2026-02-19 05:15:20 +01:00
Armel FAUVEAU 30aa3f13a0 Clean code 2026-02-19 02:46:53 +01:00
Armel FAUVEAU 1b170b9ff9 Improve UI 2026-02-19 02:06:20 +01:00
Armel FAUVEAU ed6b98ce46 Add strong signal correction 2026-02-17 03:18:26 +01:00
Armel FAUVEAU f680b3af36 Fix -93dBm on AIR 2026-02-16 23:16:35 +01:00
Armel FAUVEAU 9ef3379ccf Fix -93dBm on VHF 2026-02-16 23:08:39 +01:00
Armel FAUVEAU 9081b01773 Add bidirectional list navigation with UP/DOWN keys (issue #145) 2026-02-15 04:19:57 +01:00
Armel FAUVEAU 706283c16b Fix blink arrow and screenshot 2026-02-15 03:38:01 +01:00
Armel FAUVEAU e51813e1bb Fix Reset All (issue #156) 2026-02-14 23:59:44 +01:00
Armel FAUVEAU 6b4e575d1f Remove stars... 2026-02-14 18:59:20 +01:00
Armel FAUVEAU f0cca71673 Rename function 2026-02-14 18:54:49 +01:00
Armel FAUVEAU aef113eacf Remove BITMAP_Antenna 2026-02-14 18:50:14 +01:00
Armel FAUVEAU 3f8ddb0502 Fix version 2026-02-13 18:21:34 +01:00
Armel FAUVEAU 5b4b8cf2f6 Blink arrow on RX (issue #146) 2026-02-13 02:04:55 +01:00
Armel FAUVEAU ee1d68e7ef Extend Tiny GUI ? 2026-02-12 04:32:12 +01:00
Armel FAUVEAU 261aeb4fb7 Fix issue #153 2026-02-12 00:28:03 +01:00
Armel FAUVEAU 5ccb6cd7ff Fix 4 digits 2026-02-11 19:54:58 +01:00
Armel FAUVEAU fa7537d539 Frequency Band refactoring 2026-02-11 02:52:51 +01:00
Armel FAUVEAU c1a6633302 Shift VFO 2026-02-11 02:14:41 +01:00
Armel FAUVEAU e515d53aaa Improve GUI 2026-02-11 01:20:16 +01:00
Armel FAUVEAU 0ddbb0ad82 Fix issue #40 2026-02-10 05:24:17 +01:00
Armel FAUVEAU c1e5f23d72 Remove N/A 2026-02-10 04:12:59 +01:00
Armel FAUVEAU 8825eb9ac6 Fix Aircopy because of named list 2026-02-10 01:46:31 +01:00
Armel FAUVEAU 7957377388 Add named lists 2026-02-10 01:35:08 +01:00
Armel FAUVEAU 712a984b96 Update donors 2026-02-08 04:29:09 +01:00
Armel FAUVEAU 1236c3863f Restore 10-character channel name limit with MAIN ONLY 2026-02-08 03:56:13 +01:00
Armel FAUVEAU 85f1bfdb7f Fix SCAN_SAVE_CHANNEL and UI_GenerateChannelStringEx 2026-02-08 03:24:25 +01:00
Armel FAUVEAU 086858945b Merge pull request #133 from armel/feature_update_v4
Feature update v4
2026-02-05 23:42:07 +01:00
Armel FAUVEAU df99e6dc1f New version 5.1.0 2026-02-05 23:39:37 +01:00
Armel FAUVEAU 5ee5ec8873 Prepare new version 2026-02-05 23:15:20 +01:00
Armel FAUVEAU 5170170bb1 Fix spectrum RenderStill() 2026-02-05 05:11:00 +01:00
Armel FAUVEAU 76c48044c8 Shift BITMAP_VFO_Lock 2026-02-05 00:24:33 +01:00
Armel FAUVEAU ead079dc5b Update donors 2026-02-04 13:36:50 +01:00
Armel FAUVEAU add6fb17ed Fix SETTINGS_ResetTxLock() 2026-02-04 13:22:59 +01:00
Armel FAUVEAU c4079b1c32 Oops add reset display inversion (SET_INV = 0) 2026-02-04 02:12:45 +01:00
Armel FAUVEAU c4fb7de972 Fix FM_EraseChannels() 2026-02-03 04:08:53 +01:00
Armel FAUVEAU 45ead3125f Fix Lines 1 & 2 evil bug 2026-02-03 02:44:31 +01:00
Armel FAUVEAU 2b40d1216e Fix RO evil bug on new install 2026-02-03 01:57:38 +01:00
Armel FAUVEAU e555b48811 Fix TXLock icon 2026-02-02 22:19:38 +01:00
muzkr d70cc8f59a Refine systick config 2026-02-03 00:51:32 +08:00
Armel FAUVEAU cd79144a25 Add Fusion v5.0.2 public beta 2026-02-01 23:06:17 +01:00
Armel FAUVEAU b7151de126 Add new binary 2026-02-01 23:02:57 +01:00
Armel FAUVEAU 4eea0c7910 Update version 2026-02-01 22:59:20 +01:00
Armel FAUVEAU cd7fcdbf54 Fix MR channel persistence when entered with leading zeros (Thanks @Niteshooter for the bug report) 2026-02-01 17:38:32 +01:00
Armel FAUVEAU 3df48febf0 Update donors 2026-01-31 23:26:50 +01:00
Armel FAUVEAU 7f6594ffb2 Experiment alignment 2026-01-31 04:02:55 +01:00
Armel FAUVEAU 3f3dab7833 Fix ENABLE_LTO to false by default 2026-01-30 23:41:35 +01:00
Armel FAUVEAU 7dbabfe60f Merge pull request #120 from mengzhuo/lto
build: enable LTO by default
2026-01-30 18:46:37 +01:00
Armel FAUVEAU c10ed40a4a Merge pull request #119 from mengzhuo/feature_update_v4
Fix build image once
2026-01-30 18:40:33 +01:00
Armel FAUVEAU 0f7b600516 Merge pull request #121 from mengzhuo/array_size
App: clean up duplicate ARRAY_SIZE macros
2026-01-30 18:35:00 +01:00
Meng Zhuo 7189d09d73 App: clean up duplicate ARRAY_SIZE macros 2026-01-30 11:02:00 +08:00
Meng Zhuo 164a72738a build: enable LTO by default
LTO saves ~4K in Flash and ~300 Bytes in RAM

Disable LTO
```
Memory region         Used Size  Region Size  %age Used
             RAM:       12256 B        16 KB     74.80%
           FLASH:       84304 B       118 KB     69.77%
```

Enable LTO
```
[82/82] Linking C executable f4hwn.fusion.elf
Memory region         Used Size  Region Size  %age Used
             RAM:       11904 B        16 KB     72.66%
           FLASH:       80820 B       118 KB     66.89%
```
2026-01-30 10:26:52 +08:00
Meng Zhuo 9ab8040e4b Fix build image once
Also fix build on Windows message:
```
docker: Error response from daemon: the working directory 'C:/Program Files/Git/src' is invalid, it needs to be an absolute path
```
2026-01-30 09:40:36 +08:00
Armel FAUVEAU d3b985c5ad Fix compilation error if ENABLE_FEAT_F4HWN_AUDIO is false 2026-01-30 02:15:44 +01:00
Armel FAUVEAU 6ba761db1a Fix Dockerfile 2026-01-30 02:06:10 +01:00
Armel FAUVEAU f4826ed46c Merge pull request #107 from mengzhuo/fsk-tx
Fix FSK TX finished mask definition
2026-01-28 03:38:24 +01:00
Armel FAUVEAU 4c41ff7929 Fix scan list + ALL 2026-01-27 23:12:19 +01:00
Armel FAUVEAU 91e2f61099 Revert fix Scan doesn't detect channels with DCS 2026-01-27 19:22:51 +01:00
Armel FAUVEAU 011009b294 Improve SETTINGS_FactoryReset 2026-01-27 19:01:44 +01:00
Meng Zhuo 1865651a5a Fix FSK TX finished mask definition 2026-01-27 16:17:44 +08:00
Armel FAUVEAU 889de45b18 Add Fusion v5.0.1 public beta 2026-01-25 04:38:34 +01:00
94 changed files with 4843 additions and 2411 deletions

No files matched your search

+3 -2
View File
@@ -7,10 +7,11 @@ firmware
.cache
compile_commands.json
.vscode
.claude
/docs
k5_eeprom.raw
/build
/serialtool/__pycache__
__pycache__/
.DS_Store
.DS_Store
+5
View File
@@ -78,6 +78,7 @@ endif()
target_compile_definitions(App INTERFACE
"AUTHOR_STRING=\"${AUTHOR_STRING}\""
"VERSION_STRING=\"${VERSION_STRING}\""
"BUILD_COMMIT=\"${BUILD_COMMIT}\""
)
if(NOT SQL_TONE)
@@ -161,6 +162,7 @@ enable_feature(ENABLE_SQUELCH_MORE_SENSITIVE)
enable_feature(ENABLE_FASTER_CHANNEL_SCAN)
enable_feature(ENABLE_RSSI_BAR)
enable_feature(ENABLE_AUDIO_BAR)
enable_feature(ENABLE_FEAT_F4HWN_AUDIO_SCOPE)
enable_feature(ENABLE_COPY_CHAN_TO_VFO)
enable_feature(ENABLE_REDUCE_LOW_MID_TX_POWER)
enable_feature(ENABLE_BYP_RAW_DEMODULATORS)
@@ -193,6 +195,7 @@ enable_feature(ENABLE_FEAT_F4HWN_RESUME_STATE)
enable_feature(ENABLE_FEAT_F4HWN_NARROWER)
enable_feature(ENABLE_FEAT_F4HWN_INV)
enable_feature(ENABLE_FEAT_F4HWN_CTR)
enable_feature(ENABLE_FEAT_F4HWN_SCAN_PROGRESS)
enable_feature(ENABLE_FEAT_F4HWN_RESCUE_OPS)
enable_feature(ENABLE_FEAT_F4HWN_VOL)
enable_feature(ENABLE_FEAT_F4HWN_AUDIO)
@@ -201,6 +204,8 @@ enable_feature(ENABLE_FEAT_F4HWN_PMR)
enable_feature(ENABLE_FEAT_F4HWN_GMRS_FRS_MURS)
enable_feature(ENABLE_FEAT_F4HWN_CA)
enable_feature(ENABLE_FEAT_F4HWN_DEBUG)
enable_feature(ENABLE_FEAT_F4HWN_MEM)
enable_feature(ENABLE_FEAT_F4HWN_QRCODE)
# ---- DEBUGGING ----
+95 -93
View File
@@ -236,7 +236,7 @@ void ACTION_Scan(bool bRestart)
}
// channel mode. Keep scanning but toggle between scan lists
RADIO_NextValidList();
RADIO_NextValidList(1);
#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE
SETTINGS_WriteCurrentState();
@@ -290,6 +290,8 @@ void ACTION_SwitchDemodul(void)
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
HideFKeyIcon();
if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode){
// entering DTMF code
@@ -319,19 +321,23 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;
}
enum ACTION_OPT_t funcShort = ACTION_OPT_NONE;
enum ACTION_OPT_t funcLong = ACTION_OPT_NONE;
enum ACTION_OPT_t func = ACTION_OPT_NONE;
switch(Key) {
case KEY_SIDE1:
funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION;
funcLong = gEeprom.KEY_1_LONG_PRESS_ACTION;
if (bKeyHeld)
func = gEeprom.KEY_1_LONG_PRESS_ACTION;
else
func = gEeprom.KEY_1_SHORT_PRESS_ACTION;
break;
case KEY_SIDE2:
funcShort = gEeprom.KEY_2_SHORT_PRESS_ACTION;
funcLong = gEeprom.KEY_2_LONG_PRESS_ACTION;
if (bKeyHeld)
func = gEeprom.KEY_2_LONG_PRESS_ACTION;
else
func = gEeprom.KEY_2_SHORT_PRESS_ACTION;
break;
case KEY_MENU:
funcLong = gEeprom.KEY_M_LONG_PRESS_ACTION;
if (bKeyHeld)
func = gEeprom.KEY_M_LONG_PRESS_ACTION;
break;
default:
break;
@@ -347,17 +353,46 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if(!(bKeyHeld && !bKeyPressed)) // don't beep on released after hold
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (bKeyHeld || bKeyPressed) // held
if (bKeyHeld && !bKeyPressed) // button released after hold
{
funcShort = funcLong;
if (!bKeyPressed) //ignore release if held
return;
return;
}
// held or released after short press beyond this point
#ifdef ENABLE_FMRADIO
if (gFmRadioMode) { // do not run these actions in FM radio mode
switch (func) {
case ACTION_OPT_POWER:
case ACTION_OPT_MONITOR:
case ACTION_OPT_A_B:
case ACTION_OPT_VFO_MR:
case ACTION_OPT_SWITCH_DEMODUL:
#ifdef ENABLE_VOX
case ACTION_OPT_VOX:
#endif
#ifdef ENABLE_FEAT_F4HWN
case ACTION_OPT_RXMODE:
case ACTION_OPT_MAINONLY:
case ACTION_OPT_WN:
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case ACTION_OPT_RXA:
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
case ACTION_OPT_POWER_HIGH:
case ACTION_OPT_REMOVE_OFFSET:
#endif
#endif
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
action_opt_table[funcShort]();
default:
break;
}
}
#endif
action_opt_table[func]();
}
@@ -503,17 +538,13 @@ void ACTION_RxMode(void)
{
static bool cycle = 0;
switch(cycle) {
case 0:
gEeprom.DUAL_WATCH = !gEeprom.DUAL_WATCH;
cycle = 1;
break;
case 1:
gEeprom.CROSS_BAND_RX_TX = !gEeprom.CROSS_BAND_RX_TX;
cycle = 0;
break;
if (cycle) {
gEeprom.CROSS_BAND_RX_TX = !gEeprom.CROSS_BAND_RX_TX;
} else {
gEeprom.DUAL_WATCH = !gEeprom.DUAL_WATCH;
}
cycle = !cycle;
ACTION_Update();
}
@@ -523,29 +554,29 @@ void ACTION_MainOnly(void)
static uint8_t dw = 0;
static uint8_t cb = 0;
switch(cycle) {
case 0:
dw = gEeprom.DUAL_WATCH;
cb = gEeprom.CROSS_BAND_RX_TX;
if (cycle) {
gEeprom.DUAL_WATCH = dw;
gEeprom.CROSS_BAND_RX_TX = cb;
} else {
dw = gEeprom.DUAL_WATCH;
cb = gEeprom.CROSS_BAND_RX_TX;
gEeprom.DUAL_WATCH = 0;
gEeprom.CROSS_BAND_RX_TX = 0;
cycle = 1;
break;
case 1:
gEeprom.DUAL_WATCH = dw;
gEeprom.CROSS_BAND_RX_TX = cb;
cycle = 0;
break;
gEeprom.DUAL_WATCH = 0;
gEeprom.CROSS_BAND_RX_TX = 0;
}
cycle = !cycle;
ACTION_Update();
}
#ifdef ENABLE_FEAT_F4HWN_AUDIO
void ACTION_RxA(void)
{
gSetting_set_audio = (gSetting_set_audio + 1) % 5;
if(gRxVfo->Modulation == MODULATION_AM)
gSetting_set_audio_am = (gSetting_set_audio_am + 1) % 3;
else if (gRxVfo->Modulation == MODULATION_FM)
gSetting_set_audio_fm = (gSetting_set_audio_fm + 1) % 5;
RADIO_SetModulation(gRxVfo->Modulation);
}
#endif
@@ -553,64 +584,36 @@ void ACTION_RxA(void)
void ACTION_Ptt(void)
{
gSetting_set_ptt_session = !gSetting_set_ptt_session;
ACTION_Update();
}
void ACTION_Wn(void)
{
if (gRxVfo->Modulation == MODULATION_AM)
const bool isRx = FUNCTION_IsRx();
VFO_Info_t *pVfo = isRx ? gRxVfo : gTxVfo;
pVfo->CHANNEL_BANDWIDTH = !pVfo->CHANNEL_BANDWIDTH;
if (pVfo->Modulation == MODULATION_AM)
{
BK4819_SetFilterBandwidth(BK4819_FILTER_BW_AM, true);
BK4819_SetFilterBandwidth(RADIO_GetAMFilterBandwidth(pVfo), true);
return;
}
uint8_t bw = pVfo->CHANNEL_BANDWIDTH;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
bool narrower = 0;
if (FUNCTION_IsRx())
if (isRx && bw == BANDWIDTH_NARROW && gSetting_set_nfm == 1)
{
gRxVfo->CHANNEL_BANDWIDTH = (gRxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
if(gRxVfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW && gSetting_set_nfm == 1)
{
narrower = 1;
}
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH + narrower, true);
#else
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH + narrower, false);
#endif
bw++;
}
else
{
gTxVfo->CHANNEL_BANDWIDTH = (gTxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
if(gTxVfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW && gSetting_set_nfm == 1)
{
narrower = 1;
}
#endif
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, true);
#else
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, false);
#endif
}
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(bw, true);
#else
if (FUNCTION_IsRx())
{
gRxVfo->CHANNEL_BANDWIDTH = (gRxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH, true);
#else
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH, false);
#endif
}
else
{
gTxVfo->CHANNEL_BANDWIDTH = (gTxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, true);
#else
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, false);
#endif
}
BK4819_SetFilterBandwidth(bw, false);
#endif
}
@@ -657,26 +660,25 @@ void ACTION_Mute(void)
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, gMute ? 0x0A10 : 0x0A1F);
#endif
gEeprom.VOLUME_GAIN = gMute ? 0 : gEeprom.VOLUME_GAIN_BACKUP;
BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
(0u << 10) | // AF Rx Gain-1
(gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
BK4819_SetRxAudioGain();
gUpdateStatus = true;
}
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
void ACTION_ToggleVfoSetting(bool *setting) {
*setting = !(*setting);
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
}
void ACTION_Power_High(void)
{
gPowerHigh = !gPowerHigh;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
ACTION_ToggleVfoSetting(&gPowerHigh);
}
void ACTION_Remove_Offset(void)
{
gRemoveOffset = !gRemoveOffset;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
ACTION_ToggleVfoSetting(&gRemoveOffset);
}
#endif
#endif
#endif
+59 -98
View File
@@ -39,7 +39,7 @@ static const uint16_t Obfuscation[8] = { 0x6C16, 0xE614, 0x912E, 0x400D, 0x3521,
AIRCOPY_State_t gAircopyState;
uint16_t gAirCopyBlockNumber;
uint16_t gErrorsDuringAirCopy;
uint8_t gAirCopyIsSendMode;
bool gAirCopyIsSendMode;
uint16_t g_FSK_Buffer[36];
@@ -88,13 +88,14 @@ DECLARE_AIRCOPY_BANK(1)
// For settings only
static const AIRCOPY_Segment_t AIRCOPY_Segments_Settings[] = {
{ 0xA000, 0xA160, AIRCOPY_WRITE_BYTES },
{ 0xA000, 0xA170, AIRCOPY_WRITE_BYTES },
{ 0x880E, 0x886E, AIRCOPY_WRITE_BYTES },
};
static const AIRCOPY_TransferMap_t AIRCOPY_Map_Settings = {
.segments = AIRCOPY_Segments_Settings,
.num_segments = 1,
.total_blocks = 6
.num_segments = 2,
.total_blocks = 8
};
// Finally
@@ -138,7 +139,7 @@ static void AIRCOPY_clear()
crc[i] = 0;
}
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
getScreenShot(true);
SCREENSHOT_Update(true);
#endif
}
@@ -166,11 +167,18 @@ static inline void AIRCOPY_CheckComplete(void)
{
gAircopyState = AIRCOPY_COMPLETE;
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
getScreenShot(false);
SCREENSHOT_Update(false);
#endif
}
}
static inline void AIRCOPY_Obfuscation(void)
{
for (unsigned int i = 0; i < 34; i++) {
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
}
}
// ============================================================================
// Send/Receive Functions
// ============================================================================
@@ -211,7 +219,7 @@ bool AIRCOPY_SendMessage(void)
if (CurrentSegmentIndex >= map->num_segments) {
gAircopyState = AIRCOPY_COMPLETE;
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
getScreenShot(false);
SCREENSHOT_Update(false);
#endif
return 0;
}
@@ -222,9 +230,7 @@ bool AIRCOPY_SendMessage(void)
g_FSK_Buffer[34] = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
for (unsigned int i = 0; i < 34; i++) {
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
}
AIRCOPY_Obfuscation();
RADIO_SetTxParameters();
@@ -260,9 +266,7 @@ void AIRCOPY_StorePacket(void)
return;
}
for (unsigned int i = 0; i < 34; i++) {
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
}
AIRCOPY_Obfuscation();
uint16_t Crc = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
if (g_FSK_Buffer[34] != Crc) {
@@ -272,25 +276,9 @@ void AIRCOPY_StorePacket(void)
}
uint16_t Offset = g_FSK_Buffer[1];
const AIRCOPY_TransferMap_t *map = AIRCOPY_GetCurrentMap();
// Validate offset is in the map
bool validOffset = false;
for (uint16_t i = 0; i < map->num_segments; i++) {
if (Offset >= map->segments[i].start_offset && Offset < map->segments[i].end_offset) {
validOffset = true;
break;
}
}
if (!validOffset) {
gErrorsDuringAirCopy++;
AIRCOPY_CheckComplete();
return;
}
const AIRCOPY_Segment_t *seg = AIRCOPY_FindSegmentForOffset(Offset);
if (seg == NULL) {
gErrorsDuringAirCopy++;
AIRCOPY_CheckComplete();
@@ -324,20 +312,27 @@ void AIRCOPY_StorePacket(void)
AIRCOPY_CheckComplete();
}
static void AIRCOPY_InitTransfer(bool isSendMode)
{
gAircopyStep = 1;
gFSKWriteIndex = 0;
gAirCopyBlockNumber = 0;
gInputBoxIndex = 0;
gAirCopyIsSendMode = isSendMode;
AIRCOPY_clear();
gAircopyState = AIRCOPY_TRANSFER;
}
// ============================================================================
// Key Processing
// ============================================================================
static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
static void AIRCOPY_Key_DIGITS(KEY_Code_t Key)
{
if (bKeyHeld || !bKeyPressed) {
return;
}
INPUTBOX_Append(Key);
gRequestDisplayScreen = DISPLAY_AIRCOPY;
if (gInputBoxIndex < 6) {
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
@@ -372,62 +367,34 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
BK4819_ResetFSK();
return;
}
gRequestDisplayScreen = DISPLAY_AIRCOPY;
}
static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
static void AIRCOPY_Key_EXIT()
{
if (bKeyHeld || !bKeyPressed) {
return;
}
if (gInputBoxIndex == 0) {
gAircopyStep = 1;
gFSKWriteIndex = 0;
gAirCopyBlockNumber = 0;
gInputBoxIndex = 0;
AIRCOPY_InitTransfer(0); // Mode: Receive
gErrorsDuringAirCopy = lErrorsDuringAirCopy = 0;
gAirCopyIsSendMode = 0;
AIRCOPY_clear();
BK4819_PrepareFSKReceive();
gAircopyState = AIRCOPY_TRANSFER;
} else {
gInputBox[--gInputBoxIndex] = 10;
}
gRequestDisplayScreen = DISPLAY_AIRCOPY;
}
static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld)
static void AIRCOPY_Key_MENU()
{
if (bKeyHeld || !bKeyPressed) {
return;
}
gAircopyStep = 1;
gFSKWriteIndex = 0;
gAirCopyBlockNumber = 0;
gInputBoxIndex = 0;
gAirCopyIsSendMode = 1;
AIRCOPY_InitTransfer(1); // Mode: Send
g_FSK_Buffer[0] = 0xABCD;
g_FSK_Buffer[1] = 0;
g_FSK_Buffer[35] = 0xDCBA;
AIRCOPY_clear();
GUI_DisplayScreen();
gAircopyState = AIRCOPY_TRANSFER;
}
static void AIRCOPY_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
static void AIRCOPY_Key_UP_DOWN(int8_t Direction)
{
if (bKeyHeld || !bKeyPressed) {
return;
if (!gEeprom.SET_NAV) {
Direction = -Direction;
}
switch(Direction)
@@ -439,46 +406,40 @@ static void AIRCOPY_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Directio
gAircopyCurrentMapIndex = (gAircopyCurrentMapIndex + AIRCOPY_NUM_MAPS - 1) % AIRCOPY_NUM_MAPS;
break;
}
gRequestDisplayScreen = DISPLAY_AIRCOPY;
}
void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (bKeyHeld || !bKeyPressed) {
return;
}
if (Key != KEY_PTT) {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
}
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);
case KEY_0...KEY_9:
AIRCOPY_Key_DIGITS(Key);
break;
case KEY_MENU:
AIRCOPY_Key_MENU(bKeyPressed, bKeyHeld);
AIRCOPY_Key_MENU();
break;
case KEY_EXIT:
AIRCOPY_Key_EXIT(bKeyPressed, bKeyHeld);
AIRCOPY_Key_EXIT();
break;
case KEY_UP:
if(gEeprom.SET_NAV == 0)
AIRCOPY_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
else
AIRCOPY_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
break;
case KEY_DOWN:
if(gEeprom.SET_NAV == 0)
AIRCOPY_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
else
AIRCOPY_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
AIRCOPY_Key_UP_DOWN(Key == KEY_UP ? 1 : -1);
break;
case KEY_PTT:
break;
default:
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
}
gRequestDisplayScreen = DISPLAY_AIRCOPY;
}
#endif
+1 -1
View File
@@ -92,7 +92,7 @@ typedef enum {
extern AIRCOPY_State_t gAircopyState;
extern uint16_t gAirCopyBlockNumber;
extern uint16_t gErrorsDuringAirCopy;
extern uint8_t gAirCopyIsSendMode;
extern bool gAirCopyIsSendMode;
extern uint16_t g_FSK_Buffer[36];
+132 -159
View File
@@ -208,7 +208,7 @@ static void HandleIncoming(void)
gFoundCTCSS = false;
}
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_NEGATIVE_CODE
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE
&& (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL))
{
gFoundCDCSS = false;
@@ -273,18 +273,9 @@ static void HandleReceive(void)
break;
case CODE_TYPE_CONTINUOUS_TONE:
if (gFoundCTCSS && gFoundCTCSSCountdown_10ms == 0)
{
gFoundCTCSS = false;
gFoundCDCSS = false;
Mode = END_OF_RX_MODE_END;
goto Skip;
}
break;
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
if (gFoundCDCSS && gFoundCDCSSCountdown_10ms == 0)
if ((gFoundCTCSS && gFoundCTCSSCountdown_10ms == 0) || (gFoundCDCSS && gFoundCDCSSCountdown_10ms == 0))
{
gFoundCTCSS = false;
gFoundCDCSS = false;
@@ -544,7 +535,17 @@ void APP_StartListening(FUNCTION_Type_t function)
gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{ // not scanning, dual watch is enabled
gDualWatchCountdown_10ms = dual_watch_count_after_2_10ms;
//gDualWatchCountdown_10ms = dual_watch_count_after_2_10ms;
const bool isMainTxDualRx =
(gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) &&
(gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF);
// Use a short hold only for MAIN TX DUAL RX, keep legacy hold otherwise
gDualWatchCountdown_10ms = isMainTxDualRx
? dual_watch_count_after_2_10ms / 4 // Short timer = 420 / 4 ...
: dual_watch_count_after_2_10ms;
gScheduleDualWatch = false;
// when crossband is active only the main VFO should be used for TX
@@ -556,11 +557,7 @@ void APP_StartListening(FUNCTION_Type_t function)
gUpdateStatus = true;
}
BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference
( 0u << 10) | // AF Rx Gain-1
(gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
BK4819_SetRxAudioGain();
#ifdef ENABLE_VOICE
if (gVoiceWriteIndex == 0) // AM/FM RX mode will be set when the voice has finished
@@ -815,6 +812,22 @@ void APP_EndTransmission(void)
}
}
void APP_HandleEndTransmission(void) {
if (gFlagEndTransmission) {
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else {
APP_EndTransmission();
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
FUNCTION_Select(FUNCTION_FOREGROUND);
else
gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
}
gFlagEndTransmission = false;
}
#ifdef ENABLE_VOX
static void HandleVox(void)
{
@@ -850,24 +863,10 @@ static void HandleVox(void)
gVOX_NoiseDetected = false;
if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected) {
if (gFlagEndTransmission) {
//if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else {
APP_EndTransmission();
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) {
//if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else
gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
}
APP_HandleEndTransmission();
gUpdateStatus = true;
gUpdateDisplay = true;
gFlagEndTransmission = false;
}
return;
}
@@ -891,6 +890,12 @@ static void HandleVox(void)
void APP_Update(void)
{
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
// Parse incoming packets on every tick so serial keys are never missed,
// regardless of whether the screen needs redrawing.
SCREENSHOT_ParseInput();
#endif
#ifdef ENABLE_VOICE
if (gFlagPlayQueuedVoice) {
AUDIO_PlayQueuedVoice();
@@ -1133,14 +1138,7 @@ void APP_Update(void)
// go back to sleep
#ifdef ENABLE_FEAT_F4HWN_SLEEP
if(gWakeUp)
{
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 200; // deep sleep now indexed on BatSav
}
else
{
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
}
gPowerSave_10ms = gEeprom.BATTERY_SAVE * (gWakeUp ? 200 : 10); // deep sleep now indexed on BatSav
#else
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
#endif
@@ -1165,8 +1163,21 @@ void APP_Update(void)
}
}
void StopTransmitting(void) {
ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
#ifdef ENABLE_FEAT_F4HWN
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
#endif
}
// called every 10ms
static void CheckKeys(void)
void CheckKeys(void)
{
#ifdef ENABLE_DTMF_CALLING
if(gSetting_KILLED){
@@ -1181,75 +1192,63 @@ static void CheckKeys(void)
#endif
// -------------------- PTT ------------------------
const bool serialConfigInProgress = SerialConfigInProgress();
#ifdef ENABLE_FEAT_F4HWN
const bool isPressed = GPIO_IsPttPressed() && !serialConfigInProgress;
#else
const bool isPressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !serialConfigInProgress;
#endif
#ifdef ENABLE_FEAT_F4HWN
if (gSetting_set_ptt_session)
{
if (GPIO_IsPttPressed() && !SerialConfigInProgress() && gPttOnePushCounter == 0)
{ // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting
boot_counter_10ms = 0;
if ((isPressed && (gPttOnePushCounter == 0 || gPttOnePushCounter == 2)) ||
(!isPressed && (gPttOnePushCounter == 1 || gPttOnePushCounter == 3)) ||
serialConfigInProgress)
{
if (++gPttDebounceCounter >= 3 || (serialConfigInProgress && gPttOnePushCounter > 0))
{
gPttDebounceCounter = 0;
gPttIsPressed = true;
gPttOnePushCounter = 1;
ProcessKey(KEY_PTT, true, false);
if (gPttOnePushCounter == 0)
{ // start transmitting
boot_counter_10ms = 0;
gPttIsPressed = true;
gPttOnePushCounter = 1;
ProcessKey(KEY_PTT, true, false);
}
else if (gPttOnePushCounter == 3 || serialConfigInProgress)
{ // stop transmitting
StopTransmitting();
gPttOnePushCounter = 0;
}
else
gPttOnePushCounter++;
}
}
else if ((!GPIO_IsPttPressed() || SerialConfigInProgress()) && gPttOnePushCounter == 1)
{
// PTT released or serial comms config in progress
if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms
{ // stop transmitting
gPttOnePushCounter = 2;
}
}
else if (GPIO_IsPttPressed() && !SerialConfigInProgress() && gPttOnePushCounter == 2)
{ // PTT pressed again
if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms
{ // stop transmitting
gPttOnePushCounter = 3;
}
}
else if ((!GPIO_IsPttPressed() || SerialConfigInProgress()) && gPttOnePushCounter == 3)
{ // PTT released or serial comms config in progress
if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms
{ // stop transmitting
ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
gPttOnePushCounter = 0;
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
}
}
}
else
gPttDebounceCounter = 0;
//gDebug = gPttOnePushCounter;
}
else
}
else
#endif
{
if (gPttIsPressed)
{
if (!GPIO_IsPttPressed() || SerialConfigInProgress())
if (!isPressed)
{ // PTT released or serial comms config in progress
if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms
if (++gPttDebounceCounter >= 3 || serialConfigInProgress) // 30ms
{ // stop transmitting
ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
gPttDebounceCounter = 0;
StopTransmitting();
}
}
else
}
else
gPttDebounceCounter = 0;
}
else if (GPIO_IsPttPressed() && !SerialConfigInProgress())
else if (isPressed)
{ // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting
@@ -1259,38 +1258,9 @@ static void CheckKeys(void)
ProcessKey(KEY_PTT, true, false);
}
}
else
gPttDebounceCounter = 0;
}
#else
if (gPttIsPressed)
{
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || SerialConfigInProgress())
{ // PTT released or serial comms config in progress
if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms
{ // stop transmitting
ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
}
}
else
gPttDebounceCounter = 0;
}
else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !SerialConfigInProgress())
{ // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting
boot_counter_10ms = 0;
gPttDebounceCounter = 0;
gPttIsPressed = true;
ProcessKey(KEY_PTT, true, false);
}
}
else
gPttDebounceCounter = 0;
#endif
// --------------------- OTHER KEYS ----------------------------
@@ -1364,9 +1334,9 @@ void APP_TimeSlice10ms(void)
{
gNextTimeslice = false;
if (gScheduleVfoSave) {
SETTINGS_SaveVfoIndicesFlush();
}
SETTINGS_SaveVfoIndicesFlush();
BACKLIGHT_Update();
gFlashLightBlinkCounter++;
@@ -1392,12 +1362,18 @@ void APP_TimeSlice10ms(void)
if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting
#ifdef ENABLE_AUDIO_BAR
#if defined(ENABLE_AUDIO_BAR) && !defined(ENABLE_FEAT_F4HWN_AUDIO_SCOPE)
if (gSetting_mic_bar && (gFlashLightBlinkCounter % (150 / 10)) == 0) // once every 150ms
UI_DisplayAudioBar();
#endif
}
#ifdef ENABLE_FEAT_F4HWN_AUDIO_SCOPE
if (gSetting_mic_bar && (gFlashLightBlinkCounter % (20 / 10)) == 0) // once every 20ms
// Sample audio amplitude and refresh display during TX only (FM RX has no usable audio register)
UI_DisplayAudioScope();
#endif
bool gUpdateDisplayCurrent = gUpdateDisplay;
bool gUpdateStatusCurrent = gUpdateStatus;
@@ -1412,7 +1388,7 @@ void APP_TimeSlice10ms(void)
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
if (gUpdateDisplayCurrent || gUpdateStatusCurrent) {
getScreenShot(false);
SCREENSHOT_Update(false);
}
#endif
@@ -1459,8 +1435,7 @@ void APP_TimeSlice10ms(void)
if (gAlarmState == ALARM_STATE_TXALARM) {
gAlarmState = ALARM_STATE_SITE_ALARM;
if(gEeprom.TAIL_TONE_ELIMINATION)
RADIO_SendCssTail();
RADIO_SendCssTail();
BK4819_SetupPowerAmplifier(0, 0);
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false);
BK4819_Enable_AfDac_DiscMode_TxDsp();
@@ -1525,18 +1500,16 @@ void cancelUserInputModes(void)
if (gDTMF_InputMode || gDTMF_InputBox_Index > 0)
{
DTMF_clear_input_box();
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
gRequestDisplayScreen = DISPLAY_MAIN;
gUpdateDisplay = true;
}
if (gWasFKeyPressed || gKeyInputCountdown > 0 || gInputBoxIndex > 0)
{
gWasFKeyPressed = false;
HideFKeyIcon();
gInputBoxIndex = 0;
gKeyInputCountdown = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
gUpdateStatus = true;
gUpdateDisplay = true;
}
}
@@ -1558,18 +1531,21 @@ void APP_TimeSlice500ms(void)
if (--gKeyInputCountdown == 0)
{
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE) && (gInputBoxIndex == 1 || gInputBoxIndex == 2))
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE) && (gInputBoxIndex > 0 && gInputBoxIndex < 4)
#ifdef ENABLE_FMRADIO
&& (!gFmRadioMode)
#endif
)
{
channelMoveSwitch();
if (gBeepToPlay == BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL) {
AUDIO_PlayBeep(gBeepToPlay);
}
SETTINGS_SaveVfoIndices();
}
cancelUserInputModes();
gHasVfoBackup = false;
}
}
@@ -1612,9 +1588,11 @@ void APP_TimeSlice500ms(void)
}
#endif
const int m = UI_MENU_GetCurrentMenuId();
if (gBacklightCountdown_500ms > 0 && !gAskToSave && !gCssBackgroundScan
// don't turn off backlight if user is in backlight menu option
&& !(gScreenToDisplay == DISPLAY_MENU && (UI_MENU_GetCurrentMenuId() == MENU_ABR || UI_MENU_GetCurrentMenuId() == MENU_ABR_MAX))
&& !(gScreenToDisplay == DISPLAY_MENU && (m == MENU_ABR || m == MENU_ABR_MAX || m == MENU_ABR_MIN))
&& --gBacklightCountdown_500ms == 0
&& gEeprom.BACKLIGHT_TIME < 61
) {
@@ -1732,8 +1710,10 @@ void APP_TimeSlice500ms(void)
if (exit_menu) {
gMenuCountdown = 0;
if (gEeprom.BACKLIGHT_TIME == 0) {
BACKLIGHT_TurnOff();
const int m = UI_MENU_GetCurrentMenuId();
if (gScreenToDisplay == DISPLAY_MENU && (m == MENU_ABR || m == MENU_ABR_MAX || m == MENU_ABR_MIN)) {
BACKLIGHT_TurnOn();
}
if (gInputBoxIndex > 0 || gDTMF_InputMode) {
@@ -1751,13 +1731,12 @@ void APP_TimeSlice500ms(void)
*/
DTMF_clear_input_box();
gWasFKeyPressed = false;
HideFKeyIcon();
gInputBoxIndex = 0;
gAskToSave = false;
gAskToDelete = false;
gUpdateStatus = true;
gUpdateDisplay = true;
GUI_DisplayType_t disp = DISPLAY_INVALID;
@@ -1936,6 +1915,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
// cancel user input
cancelUserInputModes();
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gMonitor)
ACTION_Monitor(); //turn off the monitor
@@ -1964,12 +1944,10 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN;
#ifdef ENABLE_FEAT_F4HWN // Disable PTT if KEY_LOCK
bool lck_condition = false;
bool lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT;
if(gSetting_set_lck)
lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT;
else
lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT;
if(!gSetting_set_lck)
lck_condition = lck_condition && Key != KEY_PTT;
if (lck_condition)
#else
@@ -2048,8 +2026,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) {
#endif
// cancel the F-key
gWasFKeyPressed = false;
gUpdateStatus = true;
HideFKeyIcon();
}
if (bFlag) {
@@ -2126,18 +2103,14 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
#endif
}
else if (gScreenToDisplay != DISPLAY_INVALID && (
(Key != KEY_SIDE1 && Key != KEY_SIDE2)
#ifdef ENABLE_FEAT_F4HWN // For F + SIDE1 or F + SIDE2
else if (gWasFKeyPressed && (Key == KEY_SIDE1 || Key == KEY_SIDE2)) {
ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld);
}
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) {
ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld);
}
#else
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) {
ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld);
}
|| (gWasFKeyPressed && (Key == KEY_SIDE1 || Key == KEY_SIDE2))
#endif
)) {
ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld);
}
else if (!SCANNER_IsScanning()
#ifdef ENABLE_AIRCOPY
&& gScreenToDisplay != DISPLAY_AIRCOPY
@@ -2192,7 +2165,7 @@ Skip:
}
if (gRequestSaveChannel > 0) { // TODO: remove the gRequestSaveChannel, why use global variable for that??
if ((!bKeyHeld && !bKeyPressed) || (UI_MENU_GetCurrentMenuId() != 0 && gScreenToDisplay == DISPLAY_MENU))
if ((!bKeyHeld && !bKeyPressed) || (UI_MENU_GetCurrentMenuId() != 0 && gScreenToDisplay == DISPLAY_MENU) || gScreenToDisplay == DISPLAY_SCANNER)
{
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gRequestSaveChannel);
+1
View File
@@ -24,6 +24,7 @@
#include "radio.h"
void APP_EndTransmission(void);
void APP_HandleEndTransmission(void);
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);
+32 -43
View File
@@ -401,50 +401,35 @@ static void OnKeyDown(uint8_t key)
}
}
// Key
static KEY_Code_t GetKey()
{
KEY_Code_t btn = KEYBOARD_Poll();
if (btn == KEY_INVALID && GPIO_IsPttPressed())
{
btn = KEY_PTT;
}
return btn;
}
// HandleUserInput
static bool HandleUserInput()
{
// Store previous key state
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
// Parse incoming packets on every tick so serial keys are never missed,
// regardless of whether the screen needs redrawing.
SCREENSHOT_ParseInput();
#endif
kbd.prev = kbd.current;
// Get the current key
kbd.current = GetKey();
// Detect valid key press continuation (same key still pressed)
if (kbd.current != KEY_INVALID && kbd.current == kbd.prev)
{
kbd.counter = 1;
}
else
{
kbd.counter = 0;
}
// Process the key if counter indicates it should be handled
if (kbd.counter == 1)
kbd.current = KEYBOARD_GetKey();
if (kbd.current == KEY_INVALID)
return true;
// Movement keys: dispatch on every tick while held
if (kbd.current == KEY_UP || kbd.current == KEY_DOWN ||
kbd.current == KEY_4 || kbd.current == KEY_0)
{
OnKeyDown(kbd.current);
// Special handling for MENU key
if(kbd.current == KEY_MENU)
{
kbd.counter = 0;
SYSTEM_DelayMs(250);
}
return true;
}
// Action keys (MENU, EXIT): dispatch only on rising edge
if (kbd.current != kbd.prev)
{
OnKeyDown(kbd.current);
}
return true;
}
@@ -452,7 +437,6 @@ static bool HandleUserInput()
static void Tick()
{
HandleUserInput();
HandleUserInput();
}
// APP_RunBreakout
@@ -465,6 +449,9 @@ void APP_RunBreakout(void) {
// Init led
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false);
// Finish the brightness fade if it is in progress
BACKLIGHT_UpdateTickless();
// Init game
UI_DisplayClear();
reset();
@@ -482,11 +469,6 @@ void APP_RunBreakout(void) {
if(swap == 0)
{
blockAnim = (blockAnim + 1) % 4;
// For screenshot
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
getScreenShot(false);
#endif
}
swap = (swap + 1) % 4;
@@ -509,5 +491,12 @@ void APP_RunBreakout(void) {
ST7565_BlitStatusLine(); // Blank status line
ST7565_BlitFullScreen();
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
if(isPaused || swap == 0)
{
SCREENSHOT_Update(false);
}
#endif
}
}
+10 -1
View File
@@ -37,6 +37,15 @@ uint8_t initialCROSS_BAND_RX_TX;
static void NextFreqChannel(void);
static void NextMemChannel(void);
#if defined(ENABLE_FEAT_F4HWN_RESUME_STATE) || defined(ENABLE_SCAN_RANGES)
void CHFRSCANNER_ScanRange(void) {
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency;
if(gScanRangeStart > gScanRangeStop)
SWAP(gScanRangeStart, gScanRangeStop);
}
#endif
void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_direction)
{
if (storeBackupSettings) {
@@ -55,7 +64,7 @@ void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_directi
{
if(!RADIO_CheckValidList(gEeprom.SCAN_LIST_DEFAULT)) {
RADIO_NextValidList();
RADIO_NextValidList(1);
}
// channel mode
+4
View File
@@ -20,6 +20,10 @@ void CHFRSCANNER_Stop(void);
void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_direction);
void CHFRSCANNER_ContinueScanning(void);
#if defined(ENABLE_FEAT_F4HWN_RESUME_STATE) || defined(ENABLE_SCAN_RANGES)
void CHFRSCANNER_ScanRange(void);
#endif
#ifdef ENABLE_FEAT_F4HWN
extern uint32_t lastFoundFrqOrChan;
extern uint32_t lastFoundFrqOrChanOld;
+11
View File
@@ -3,6 +3,7 @@
#include "functions.h"
#include "misc.h"
#include "settings.h"
#include "ui/inputbox.h"
#include "ui/ui.h"
void COMMON_KeypadLockToggle()
@@ -29,6 +30,11 @@ void COMMON_SwitchVFOs()
#endif
gEeprom.TX_VFO ^= 1;
if (gInputBoxIndex > 0) {
gInputBoxIndex = 0;
gHasVfoBackup = false;
}
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)
@@ -49,6 +55,11 @@ void COMMON_SwitchVFOMode()
if (gEeprom.VFO_OPEN)
#endif
{
if (gInputBoxIndex > 0) {
gInputBoxIndex = 0;
gHasVfoBackup = false;
}
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // swap to frequency mode
gEeprom.ScreenChannel[gEeprom.TX_VFO] = gEeprom.FreqChannel[gEeprom.TX_VFO];
+19 -13
View File
@@ -51,20 +51,26 @@ static inline void Flashlight_Toggle(){ GPIO_TogglePin(GPIO_PIN_FLASHLIGHT); }
void ACTION_FlashLight(void)
{
switch (gFlashLightState) {
case FLASHLIGHT_OFF:
gFlashLightState++;
Flashlight_TurnOn();
break;
case FLASHLIGHT_ON:
case FLASHLIGHT_BLINK:
gFlashLightState++;
break;
case FLASHLIGHT_SOS:
default:
gFlashLightState = 0;
Flashlight_TurnOff();
// switch (gFlashLightState) {
// case FLASHLIGHT_OFF:
// Flashlight_TurnOn();
// break;
// case FLASHLIGHT_ON:
// case FLASHLIGHT_BLINK:
// break;
// case FLASHLIGHT_SOS:
// default:
// Flashlight_TurnOff();
// }
if(gFlashLightState == FLASHLIGHT_OFF) {
Flashlight_TurnOn();
}
else if (gFlashLightState == FLASHLIGHT_SOS) {
Flashlight_TurnOff();
}
gFlashLightState = (gFlashLightState + 1) % 4;
}
#else
void ACTION_FlashLight(void)
+103 -82
View File
@@ -32,10 +32,6 @@
#include "ui/inputbox.h"
#include "ui/ui.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
uint16_t gFM_Channels[FM_CHANNELS_MAX];
bool gFmRadioMode;
uint8_t gFmRadioCountdown_500ms;
@@ -44,7 +40,6 @@ volatile int8_t gFM_ScanState;
bool gFM_AutoScan;
uint8_t gFM_ChannelPosition;
bool gFM_FoundFrequency;
bool gFM_AutoScan;
uint16_t gFM_RestoreCountdown_10ms;
@@ -124,10 +119,27 @@ void FM_TurnOff(void)
void FM_EraseChannels(void)
{
PY25Q16_SectorErase(0x003000);
//PY25Q16_SectorErase(0x003000);
uint8_t clearBuf[128];
memset(clearBuf, 0xFF, sizeof(clearBuf));
PY25Q16_WriteBuffer(0x00A028, clearBuf, sizeof(clearBuf), false);
memset(gFM_Channels, 0xFF, sizeof(gFM_Channels));
}
uint16_t FM_WrapFrequency(uint16_t Frequency) {
const uint16_t freqLoLimit = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
const uint16_t freqHiLimit = BK1080_GetFreqHiLimit(gEeprom.FM_Band);
if (Frequency < freqLoLimit)
return freqHiLimit;
else if (Frequency > freqHiLimit)
return freqLoLimit;
return Frequency;
}
void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
{
AUDIO_AudioPathOff();
@@ -144,10 +156,7 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
if (!bFlag) {
Frequency += Step;
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);
Frequency = FM_WrapFrequency(Frequency);
gEeprom.FM_FrequencyPlaying = Frequency;
}
@@ -157,6 +166,12 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
}
void FM_AudioPathOn(void) {
BACKLIGHT_TurnOn();
AUDIO_AudioPathOn();
gEnableSpeaker = true;
}
void FM_PlayAndUpdate(void)
{
gFM_ScanState = FM_SCAN_OFF;
@@ -174,72 +189,50 @@ void FM_PlayAndUpdate(void)
gScheduleFM = false;
gAskToSave = false;
AUDIO_AudioPathOn();
gEnableSpeaker = true;
FM_AudioPathOn();
}
int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
{
int ret = -1;
const uint16_t Test2 = BK1080_ReadRegister(BK1080_REG_07);
// This is supposed to be a signed value, but above function is unsigned
const uint16_t Test2 = BK1080_ReadRegister(BK1080_REG_07);
const uint16_t Deviation = BK1080_REG_07_GET_FREQD(Test2);
if (BK1080_REG_07_GET_SNR(Test2) <= 2) {
BK1080_FrequencyDeviation = Deviation;
BK1080_BaseFrequency = Frequency;
// Helper macro to update globals and return
#define RETURN(val) \
do { \
BK1080_FrequencyDeviation = Deviation; \
BK1080_BaseFrequency = Frequency; \
return (val); \
} while (0)
return ret;
}
if (BK1080_REG_07_GET_SNR(Test2) <= 2)
RETURN(-1);
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)
RETURN(-1);
if ((Status & BK1080_REG_10_MASK_AFCRL) != BK1080_REG_10_AFCRL_NOT_RAILED || BK1080_REG_10_GET_RSSI(Status) < 10) {
BK1080_FrequencyDeviation = Deviation;
BK1080_BaseFrequency = Frequency;
if (Deviation >= 280 && Deviation <= 3815)
RETURN(-1);
return ret;
}
//if (Deviation > -281 && Deviation < 280)
if (Deviation >= 280 && Deviation <= 3815) {
BK1080_FrequencyDeviation = Deviation;
BK1080_BaseFrequency = Frequency;
return ret;
}
// not BLE(less than or equal)
// Scanning upward: previous deviation was negative (bit 11 set) or near zero
if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1) {
if (BK1080_FrequencyDeviation & 0x800 || (BK1080_FrequencyDeviation < 20))
{
BK1080_FrequencyDeviation = Deviation;
BK1080_BaseFrequency = Frequency;
return ret;
}
if (BK1080_FrequencyDeviation & 0x800 || BK1080_FrequencyDeviation < 20)
RETURN(-1);
}
// not BLT(less than)
// Scanning downward: previous deviation was positive or saturated high
if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1) {
if ((BK1080_FrequencyDeviation & 0x800) == 0 || (BK1080_FrequencyDeviation > 4075))
{
BK1080_FrequencyDeviation = Deviation;
BK1080_BaseFrequency = Frequency;
return ret;
}
if ((BK1080_FrequencyDeviation & 0x800) == 0 || BK1080_FrequencyDeviation > 4075)
RETURN(-1);
}
ret = 0;
#undef RETURN
BK1080_FrequencyDeviation = Deviation;
BK1080_BaseFrequency = Frequency;
return ret;
return 0;
}
static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
@@ -267,6 +260,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
}
INPUTBOX_Append(Key);
gKeyInputCountdown = key_input_timeout_500ms;
gRequestDisplayScreen = DISPLAY_FM;
@@ -282,6 +276,8 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
uint32_t Frequency;
gInputBoxIndex = 0;
gKeyInputCountdown = 1;
Frequency = StrToUL(INPUTBOX_GetAscii());
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band) || BK1080_GetFreqHiLimit(gEeprom.FM_Band) < Frequency) {
@@ -304,6 +300,8 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
uint8_t Channel;
gInputBoxIndex = 0;
gKeyInputCountdown = 1;
Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1;
if (State == STATE_MR_MODE) {
@@ -346,8 +344,7 @@ static void Key_FUNC(KEY_Code_t Key, uint8_t state)
bool autoScan = gWasFKeyPressed || (state == BUTTON_EVENT_HELD);
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gWasFKeyPressed = false;
gUpdateStatus = true;
HideFKeyIcon();
gRequestDisplayScreen = DISPLAY_FM;
switch (Key) {
@@ -376,6 +373,14 @@ static void Key_FUNC(KEY_Code_t Key, uint8_t state)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
case KEY_8:
ACTION_BackLightOnDemand();
break;
case KEY_9:
ACTION_BackLight();
break;
case KEY_STAR:
ACTION_Scan(autoScan);
break;
@@ -389,8 +394,14 @@ static void Key_FUNC(KEY_Code_t Key, uint8_t state)
static void Key_EXIT(uint8_t state)
{
if (state != BUTTON_EVENT_SHORT)
return;
if (gInputBoxIndex) {
if (state != BUTTON_EVENT_SHORT)
return;
}
else {
if (state != BUTTON_EVENT_PRESSED)
return;
}
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@@ -406,6 +417,7 @@ static void Key_EXIT(uint8_t state)
}
else {
gInputBox[--gInputBoxIndex] = 10;
gKeyInputCountdown = key_input_timeout_500ms;
if (gInputBoxIndex) {
if (gInputBoxIndex != 1) {
@@ -437,14 +449,25 @@ static void Key_EXIT(uint8_t state)
static void Key_MENU(uint8_t state)
{
if (state != BUTTON_EVENT_SHORT)
if (state == BUTTON_EVENT_HELD) {
ACTION_Handle(KEY_MENU, true, true);
return;
}
else if (state != BUTTON_EVENT_SHORT) {
return;
}
gRequestDisplayScreen = DISPLAY_FM;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
HideFKeyIcon();
if (gFM_ScanState == FM_SCAN_OFF) {
if (gInputBoxIndex) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (!gEeprom.FM_IsMrMode) {
if (gAskToSave) {
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying;
@@ -481,6 +504,8 @@ static void Key_MENU(uint8_t state)
static void Key_UP_DOWN(uint8_t state, int8_t Step)
{
HideFKeyIcon();
if (state == BUTTON_EVENT_PRESSED) {
if (gInputBoxIndex) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@@ -492,6 +517,10 @@ static void Key_UP_DOWN(uint8_t state, int8_t Step)
return;
}
if (!gEeprom.SET_NAV) {
Step = -Step;
}
if (gAskToSave) {
gRequestDisplayScreen = DISPLAY_FM;
gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, FM_CHANNELS_MAX - 1);
@@ -520,10 +549,7 @@ static void Key_UP_DOWN(uint8_t state, int8_t Step)
else {
uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step;
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);
Frequency = FM_WrapFrequency(Frequency);
gEeprom.FM_FrequencyPlaying = Frequency;
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
@@ -552,16 +578,8 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
Key_MENU(state);
break;
case KEY_UP:
if(gEeprom.SET_NAV == 0)
Key_UP_DOWN(state, -1);
else
Key_UP_DOWN(state, 1);
break;
case KEY_DOWN:
if(gEeprom.SET_NAV == 0)
Key_UP_DOWN(state, 1);
else
Key_UP_DOWN(state, -1);
Key_UP_DOWN(state, Key == KEY_UP ? 1 : -1);
break;
case KEY_EXIT:
Key_EXIT(state);
@@ -572,9 +590,14 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case KEY_PTT:
GENERIC_Key_PTT(bKeyPressed);
break;
default:
if (!bKeyHeld && bKeyPressed)
case KEY_SIDE1:
case KEY_SIDE2:
if (state != BUTTON_EVENT_PRESSED) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
HideFKeyIcon();
}
break;
default:
break;
}
}
@@ -589,8 +612,7 @@ void FM_Play(void)
if (!gEeprom.FM_IsMrMode)
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
AUDIO_AudioPathOn();
gEnableSpeaker = true;
FM_AudioPathOn();
GUI_SelectNextDisplay(DISPLAY_FM);
return;
@@ -625,9 +647,8 @@ void FM_Start(void)
// Disable UHF LNA, enable VHF LNA
BK4819_PickRXFilterPathBasedOnFrequency(10320000); // 103.2 MHz < 280 MHz
AUDIO_AudioPathOn();
FM_AudioPathOn();
gEnableSpeaker = true;
gUpdateStatus = true;
#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE
+3 -15
View File
@@ -39,7 +39,7 @@
void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
{
if (gInputBoxIndex > 0) {
if (gInputBoxIndex > 0 || gScreenToDisplay == DISPLAY_MENU) {
if (!bKeyHeld && bKeyPressed) // short pressed
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
@@ -91,7 +91,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
return;
}
#endif
gBeepToPlay = BEEP_440HZ_500MS;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
gPttWasReleased = true;
}
}
@@ -103,20 +103,8 @@ void GENERIC_Key_PTT(bool bKeyPressed)
if (!bKeyPressed || SerialConfigInProgress())
{ // PTT released
if (gCurrentFunction == FUNCTION_TRANSMIT) {
// we are transmitting .. stop
if (gFlagEndTransmission) {
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else {
APP_EndTransmission();
APP_HandleEndTransmission();
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
FUNCTION_Select(FUNCTION_FOREGROUND);
else
gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
}
gFlagEndTransmission = false;
#ifdef ENABLE_VOX
gVOX_NoiseDetected = false;
#endif
+213 -201
View File
@@ -44,9 +44,35 @@
#include "radio.h"
#include "settings.h"
#include "ui/inputbox.h"
#include "ui/main.h"
#include "ui/ui.h"
#include <stdlib.h>
// Full VFO backup for restore on EXIT
static VFO_Info_t gVfoBackup;
static uint16_t gScreenChannelBackup = 0;
static uint16_t gFreqChannelBackup = 0;
static void VFO_RestoreBackup(void) {
if (gHasVfoBackup) {
const uint8_t Vfo = gEeprom.TX_VFO;
// Restore indices
gEeprom.ScreenChannel[Vfo] = gScreenChannelBackup;
gEeprom.FreqChannel[Vfo] = gFreqChannelBackup;
// Restore full VFO
memcpy(gTxVfo, &gVfoBackup, sizeof(VFO_Info_t));
// Save and apply
SETTINGS_SaveVfoIndices();
RADIO_ConfigureSquelchAndOutputPower(gTxVfo);
RADIO_SetupRegisters(true);
gHasVfoBackup = false;
}
}
static void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting
@@ -55,10 +81,7 @@ static void toggle_chan_scanlist(void)
if(!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
#ifdef ENABLE_SCAN_RANGES
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency;
if(gScanRangeStart > gScanRangeStop)
SWAP(gScanRangeStart, gScanRangeStop);
CHFRSCANNER_ScanRange();
#endif
return;
}
@@ -69,20 +92,22 @@ static void toggle_chan_scanlist(void)
if(att->exclude == true)
{
att->exclude = false;
return;
MR_SaveChannelAttributesToFlash(gTxVfo->CHANNEL_SAVE, att);
}
else
{
uint8_t scanlist = gTxVfo->SCANLIST_PARTICIPATION;
scanlist++;
if (scanlist > MR_CHANNELS_LIST + 1)
scanlist = 0;
gTxVfo->SCANLIST_PARTICIPATION = scanlist;
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, true, true);
}
uint8_t scanlist = gTxVfo->SCANLIST_PARTICIPATION;
scanlist++;
if (scanlist > MR_CHANNELS_LIST + 1)
scanlist = 0;
gTxVfo->SCANLIST_PARTICIPATION = scanlist;
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, true, true);
gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true;
}
@@ -91,16 +116,14 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
{
uint8_t Vfo = gEeprom.TX_VFO;
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true) {
if(Key == 2) { // Enable A/B only
gVfoConfigureMode = VFO_CONFIGURE;
COMMON_SwitchVFOs();
if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
}
if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return; // prevent F function if MENU LOCK is true
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true && Key != 2) {
HideFKeyIcon();
return;
}
#endif
@@ -108,8 +131,6 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
switch (Key) {
case KEY_0:
@@ -120,9 +141,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
case KEY_1:
if (!IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
gWasFKeyPressed = false;
gUpdateStatus = true;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
HideFKeyIcon();
#ifdef ENABLE_COPY_CHAN_TO_VFO
if (!gEeprom.VFO_OPEN || gCssBackgroundScan) {
@@ -186,9 +205,6 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
gRequestDisplayScreen = DISPLAY_MAIN;
if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
break;
case KEY_2:
@@ -196,8 +212,6 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
gVfoConfigureMode = VFO_CONFIGURE;
#endif
COMMON_SwitchVFOs();
if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
break;
case KEY_3:
@@ -205,26 +219,21 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
gVfoConfigureMode = VFO_CONFIGURE;
#endif
COMMON_SwitchVFOMode();
if (beep)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
case KEY_4:
gWasFKeyPressed = false;
HideFKeyIcon();
gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
gUpdateStatus = true;
if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
SCANNER_Start(false);
gRequestDisplayScreen = DISPLAY_SCANNER;
break;
case KEY_5:
if(beep) {
if(!beep) {
#ifdef ENABLE_NOAA
if (!IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_VFO];
@@ -285,47 +294,53 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
#ifdef ENABLE_FEAT_F4HWN // Set Squelch F + UP or Down and Step F + SIDE1 or F + SIDE2
case KEY_UP:
gEeprom.SQUELCH_LEVEL = (gEeprom.SQUELCH_LEVEL < 9) ? gEeprom.SQUELCH_LEVEL + 1: 9;
gVfoConfigureMode = VFO_CONFIGURE;
gWasFKeyPressed = false;
break;
case KEY_DOWN:
gEeprom.SQUELCH_LEVEL = (gEeprom.SQUELCH_LEVEL > 0) ? gEeprom.SQUELCH_LEVEL - 1: 0;
gVfoConfigureMode = VFO_CONFIGURE;
gWasFKeyPressed = false;
break;
{
bool isKeyUp = (Key == KEY_UP);
if (gScanStateDir != SCAN_OFF) {
RADIO_NextValidList(isKeyUp ? 1 : -1);
} else {
// Adjust squelch: UP increments, DOWN decrements
if (gSquelchLevelOriginal == 10)
gSquelchLevelOriginal = gEeprom.SQUELCH_LEVEL;
if (isKeyUp) {
if (gEeprom.SQUELCH_LEVEL < 9) gEeprom.SQUELCH_LEVEL++;
} else {
if (gEeprom.SQUELCH_LEVEL > 0) gEeprom.SQUELCH_LEVEL--;
}
gVfoConfigureMode = VFO_CONFIGURE;
}
gWasFKeyPressed = false;
break;
}
case KEY_SIDE1:
uint8_t a = FREQUENCY_GetSortedIdxFromStepIdx(gTxVfo->STEP_SETTING);
if (a < STEP_N_ELEM - 1)
{
gTxVfo->STEP_SETTING = FREQUENCY_GetStepIdxFromSortedIdx(a + 1);
}
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gRequestSaveChannel = 1;
}
gVfoConfigureMode = VFO_CONFIGURE;
gWasFKeyPressed = false;
break;
case KEY_SIDE2:
uint8_t b = FREQUENCY_GetSortedIdxFromStepIdx(gTxVfo->STEP_SETTING);
if (b > 0)
{
gTxVfo->STEP_SETTING = FREQUENCY_GetStepIdxFromSortedIdx(b - 1);
bool isKeySide1 = (Key == KEY_SIDE1);
uint8_t idx = FREQUENCY_GetSortedIdxFromStepIdx(gTxVfo->STEP_SETTING);
if ((isKeySide1 && idx < STEP_N_ELEM - 1) || (!isKeySide1 && idx > 0))
{
gTxVfo->STEP_SETTING = FREQUENCY_GetStepIdxFromSortedIdx(idx + (isKeySide1 ? 1 : -1));
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
gRequestSaveChannel = 1;
}
gVfoConfigureMode = VFO_CONFIGURE;
}
gWasFKeyPressed = false;
break;
}
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gRequestSaveChannel = 1;
}
gVfoConfigureMode = VFO_CONFIGURE;
gWasFKeyPressed = false;
break;
#endif
default:
gUpdateStatus = true;
gWasFKeyPressed = false;
HideFKeyIcon();
if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@@ -362,6 +377,8 @@ void channelMove(uint16_t Channel)
#endif
RADIO_ConfigureChannel(gEeprom.TX_VFO, gVfoConfigureMode);
SETTINGS_SaveVfoIndices();
return;
}
@@ -396,14 +413,10 @@ void channelMoveSwitch(void) {
if (gInputBoxIndex == 4) {
gInputBoxIndex = 0;
gKeyInputCountdown = 1;
channelMove(Channel - 1);
SETTINGS_SaveVfoIndices();
return;
}
channelMove(Channel - 1);
SETTINGS_SaveVfoIndices();
}
}
@@ -417,10 +430,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_MAIN;
}
gWasFKeyPressed = false;
gUpdateStatus = true;
HideFKeyIcon();
processFKeyFunction(Key, false);
processFKeyFunction(Key, true);
}
}
return;
@@ -479,17 +491,14 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
/* 01 .. MR_CHANNELS_LIST */
if (value <= MR_CHANNELS_LIST)
{
if (RADIO_CheckValidList(value))
{
/* Requested scan list is valid */
gEeprom.SCAN_LIST_DEFAULT = value;
}
else
gEeprom.SCAN_LIST_DEFAULT = value;
if (!RADIO_CheckValidList(value))
{
/* Requested scan list is empty or invalid:
jump to the next valid scan list */
gEeprom.SCAN_LIST_DEFAULT = value;
RADIO_NextValidList();
jump to the next valid scan list */
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
RADIO_NextValidList(1);
}
#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE
@@ -497,13 +506,19 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
#endif
}
gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
const uint8_t Vfo = gEeprom.TX_VFO;
// Save full VFO state BEFORE first digit
if (gInputBoxIndex == 0 && IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
memcpy(&gVfoBackup, gTxVfo, sizeof(VFO_Info_t));
gScreenChannelBackup = gEeprom.ScreenChannel[Vfo];
gFreqChannelBackup = gEeprom.FreqChannel[Vfo];
gHasVfoBackup = true;
}
INPUTBOX_Append(Key);
gKeyInputCountdown = key_input_timeout_500ms;
@@ -541,7 +556,13 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;
}
gKeyInputCountdown = (gInputBoxIndex == totalDigits) ? (key_input_timeout_500ms / 16) : (key_input_timeout_500ms / 3);
gKeyInputCountdown = key_input_timeout_500ms / (gInputBoxIndex >= totalDigits ? 16 : 3);
if (gInputBoxIndex > totalDigits) {
gInputBoxIndex = totalDigits;
return;
}
const char *inputStr = INPUTBOX_GetAscii();
uint8_t inputLength = gInputBoxIndex;
@@ -549,11 +570,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
// convert to int
uint32_t inputFreq = StrToUL(inputStr);
// how many zero to add
uint8_t zerosToAdd = totalDigits - inputLength;
// add missing zero
for (uint8_t i = 0; i < zerosToAdd; i++) {
for (uint8_t i = 0; i < totalDigits - inputLength; i++) {
inputFreq *= 10;
}
@@ -610,6 +628,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
gInputBoxIndex = 0;
gHasVfoBackup = false;
uint8_t Channel = (gInputBox[0] * 10) + gInputBox[1];
if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable)) {
@@ -631,8 +650,13 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;
}
gWasFKeyPressed = false;
gUpdateStatus = true;
HideFKeyIcon();
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true && Key != 2) {
return;
}
#endif
if(Key == 8)
{
@@ -647,79 +671,80 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_FEAT_F4HWN_GAME
else if(Key == 7)
{
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true) {
return;
}
#endif
APP_RunBreakout();
return;
}
#endif
processFKeyFunction(Key, true);
processFKeyFunction(Key, false);
}
static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{
if (!bKeyHeld && bKeyPressed) { // exit key pressed
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; // beep when key is pressed
return; // don't use the key till it's released
}
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT)
{ // clear CALL mode being displayed
gDTMF_CallState = DTMF_CALL_STATE_NONE;
gUpdateDisplay = true;
return;
}
#endif
#ifdef ENABLE_FMRADIO
if (!gFmRadioMode)
#endif
{
if (gScanStateDir == SCAN_OFF) {
if (gInputBoxIndex == 0)
return;
gInputBox[--gInputBoxIndex] = 10;
gKeyInputCountdown = key_input_timeout_500ms;
#ifdef ENABLE_VOICE
if (gInputBoxIndex == 0)
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
}
else {
gScanKeepResult = false;
CHFRSCANNER_Stop();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
if (bKeyHeld) { // exit key held down
if (bKeyPressed) {
// Restore full VFO state on long press EXIT
VFO_RestoreBackup();
gRequestDisplayScreen = DISPLAY_MAIN;
return;
}
#ifdef ENABLE_FMRADIO
ACTION_FM();
#endif
return;
}
if (bKeyHeld && bKeyPressed) { // exit key held down
if (gInputBoxIndex > 0 || gDTMF_InputBox_Index > 0 || gDTMF_InputMode)
{ // cancel key input mode (channel/frequency entry)
gDTMF_InputMode = false;
gDTMF_InputBox_Index = 0;
memset(gDTMF_String, 0, sizeof(gDTMF_String));
gInputBoxIndex = 0;
gRequestDisplayScreen = DISPLAY_MAIN;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
}
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT)
{ // clear CALL mode being displayed
gDTMF_CallState = DTMF_CALL_STATE_NONE;
gUpdateDisplay = true;
return;
}
#endif
#ifdef ENABLE_FMRADIO
if (!gFmRadioMode)
#endif
{
if (gScanStateDir == SCAN_OFF) {
if (gInputBoxIndex == 0)
return;
gInputBox[--gInputBoxIndex] = 10;
// Restore full VFO state when back to 0
if (gInputBoxIndex == 0)
VFO_RestoreBackup();
gKeyInputCountdown = key_input_timeout_500ms;
channelMoveSwitch();
#ifdef ENABLE_VOICE
if (gInputBoxIndex == 0)
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
}
else {
gScanKeepResult = false;
gInputBoxIndex = 0;
CHFRSCANNER_Stop();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
gRequestDisplayScreen = DISPLAY_MAIN;
return;
}
#ifdef ENABLE_FMRADIO
ACTION_FM();
#endif
return;
}
static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
@@ -740,6 +765,7 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
att->exclude = true;
MR_SaveChannelAttributesToFlash(lastFoundFrqOrChan, att);
UI_MAIN_NotifyScanProgressDataChanged();
gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true;
@@ -761,7 +787,6 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_MAIN;
}
gWasFKeyPressed = false;
gUpdateStatus = true;
ACTION_Handle(KEY_MENU, bKeyPressed, bKeyHeld);
@@ -772,6 +797,9 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
}
if (!bKeyPressed && !gDTMF_InputMode) { // menu key released
gKeyInputCountdown = 1;
channelMoveSwitch();
const bool bFlag = !gInputBoxIndex;
gInputBoxIndex = 0;
@@ -782,7 +810,11 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
}
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == false) {
if(gEeprom.MENU_LOCK == true) {
HideFKeyIcon();
return;
}
#endif
gFlagRefreshSetting = true;
@@ -790,10 +822,6 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_MENU;
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
}
#endif
}
else {
gRequestDisplayScreen = DISPLAY_MAIN;
@@ -803,13 +831,6 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
{
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true) {
return; // prevent F function if MENU LOCK is true
}
#endif
if (gCurrentFunction == FUNCTION_TRANSMIT)
return;
@@ -819,6 +840,19 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
return;
}
if (!bKeyHeld && bKeyPressed) { // star key pressed
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; // beep when key is pressed
return; // don't use the key till it's released
}
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true) {
HideFKeyIcon();
return; // prevent F function if MENU LOCK is true
}
#endif
if (bKeyHeld && !gWasFKeyPressed){ // long press
if (!bKeyPressed) // released
return;
@@ -841,12 +875,6 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
if (bKeyPressed) { // just pressed
return;
}
// just released
if (!gWasFKeyPressed) // pressed without the F-key
{
@@ -859,7 +887,6 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
#endif
)
{ // start entering a DTMF string
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
memcpy(gDTMF_InputBox, gDTMF_String, MIN(sizeof(gDTMF_InputBox), sizeof(gDTMF_String) - 1));
gDTMF_InputBox_Index = 0;
gDTMF_InputMode = true;
@@ -895,18 +922,13 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
{
if (!gEeprom.SET_NAV) {
Direction = -Direction;
}
#ifdef ENABLE_FEAT_F4HWN // Set Squelch F + UP or Down
if(gWasFKeyPressed) {
switch(Direction)
{
case 1:
processFKeyFunction(KEY_UP, false);
break;
case -1:
processFKeyFunction(KEY_DOWN, false);
break;
}
processFKeyFunction(Direction == 1 ? KEY_UP : KEY_DOWN, true);
return;
}
#endif
@@ -918,10 +940,12 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
uint16_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
if (bKeyHeld || !bKeyPressed) { // key held or released
if (gInputBoxIndex > 0)
return; // leave if input box active
if (gInputBoxIndex > 0) {
gInputBoxIndex = 0;
gHasVfoBackup = false;
}
if (bKeyHeld || !bKeyPressed) { // key held or released
if (!bKeyPressed) {
if (!bKeyHeld || IS_FREQ_CHANNEL(Channel))
return;
@@ -934,10 +958,6 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
}
}
else { // short pressed
if (gInputBoxIndex > 0) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
}
@@ -1038,16 +1058,8 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
MAIN_Key_MENU(bKeyPressed, bKeyHeld);
break;
case KEY_UP:
if(gEeprom.SET_NAV == 0)
MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
else
MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
break;
case KEY_DOWN:
if(gEeprom.SET_NAV == 0)
MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
else
MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, Key == KEY_UP ? 1 : -1);
break;
case KEY_EXIT:
MAIN_Key_EXIT(bKeyPressed, bKeyHeld);
+272 -148
View File
@@ -42,9 +42,6 @@
#include "ui/menu.h"
#include "ui/ui.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
uint8_t gUnlockAllTxConfCnt;
@@ -311,7 +308,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_MIC:
//*pMin = 0;
*pMax = 4;
*pMax = 8;
break;
case MENU_LIST_CH:
@@ -432,7 +429,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case MENU_SET_AUD:
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_AUD) - 1;
if(gTxVfo->Modulation == MODULATION_AM)
*pMax = ARRAY_SIZE(gSubMenu_SET_AUD_AM) - 1;
else if (gTxVfo->Modulation == MODULATION_USB)
*pMax = 0;
else
*pMax = ARRAY_SIZE(gSubMenu_SET_AUD_FM) - 1;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
@@ -455,6 +457,28 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
#endif
#endif
case MENU_VOL: {
// SysInf paginates:
// page 0 = identity,
// page 1 = build date/time,
// page 2 = battery,
// +1 if F4HWN_MEM (Flash/SRAM),
// +2 if F4HWN_QRCODE (Code QR + Wiki QR).
int32_t vol_max = 0;
#ifdef ENABLE_FEAT_F4HWN
vol_max += 2;
#endif
#ifdef ENABLE_FEAT_F4HWN_MEM
vol_max += 1;
#endif
#ifdef ENABLE_FEAT_F4HWN_QRCODE
vol_max += 2;
#endif
if (vol_max == 0) return -1;
*pMax = vol_max;
break;
}
default:
return -1;
}
@@ -483,6 +507,9 @@ void MENU_AcceptSetting(void)
case MENU_SQL:
gEeprom.SQUELCH_LEVEL = gSubMenuSelection;
gVfoConfigureMode = VFO_CONFIGURE;
#ifdef ENABLE_FEAT_F4HWN
gSquelchLevelOriginal = 10;
#endif
break;
case MENU_STEP:
@@ -589,7 +616,7 @@ void MENU_AcceptSetting(void)
case MENU_MEM_NAME:
for (int i = 9; i >= 0; i--) {
if (edit[i] != ' ' && edit[i] != '_' && edit[i] != 0x00 && edit[i] != 0xff)
if (edit[i] != ' ' && edit[i] != 0x00 && edit[i] != 0xff)
break;
edit[i] = ' ';
}
@@ -964,8 +991,12 @@ void MENU_AcceptSetting(void)
break;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case MENU_SET_AUD:
gSetting_set_audio = gSubMenuSelection;
RADIO_SetModulation(gRxVfo->Modulation);
if(gTxVfo->Modulation == MODULATION_AM)
gSetting_set_audio_am = gSubMenuSelection;
else if (gTxVfo->Modulation == MODULATION_FM)
gSetting_set_audio_fm = gSubMenuSelection;
RADIO_SetModulation(gTxVfo->Modulation);
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
@@ -1021,6 +1052,11 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gEeprom.SQUELCH_LEVEL;
break;
case MENU_VOL:
// SysInf is paginated; always start on page 0 (identity).
gSubMenuSelection = 0;
break;
case MENU_STEP:
gSubMenuSelection = FREQUENCY_GetSortedIdxFromStepIdx(gTxVfo->STEP_SETTING);
break;
@@ -1419,7 +1455,12 @@ void MENU_ShowCurrentSetting(void)
break;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case MENU_SET_AUD:
gSubMenuSelection = gSetting_set_audio;
if(gTxVfo->Modulation == MODULATION_AM)
gSubMenuSelection = gSetting_set_audio_am;
else if (gTxVfo->Modulation == MODULATION_USB)
gSubMenuSelection = 0;
else
gSubMenuSelection = gSetting_set_audio_fm;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
@@ -1450,6 +1491,22 @@ void MENU_ShowCurrentSetting(void)
}
}
static KEY_Code_t edit_last_key = 255;
static uint8_t edit_char_index = 0;
static const char* const char_map[10] = {
" 0", // KEY_0
".,-()@/\\+=*#<>[]~1", // KEY_1
"abc2", // KEY_2
"def3", // KEY_3
"ghi4", // KEY_4
"jkl5", // KEY_5
"mno6", // KEY_6
"pqrs7", // KEY_7
"tuv8", // KEY_8
"wxyz9" // KEY_9
};
static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
uint8_t Offset;
@@ -1457,33 +1514,55 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
int32_t Max;
uint16_t Value = 0;
if (bKeyHeld || !bKeyPressed)
if (!bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name
if (edit_index >= 10)
return;
if (edit_index < 10)
uint8_t key_idx = Key - KEY_0;
if (bKeyHeld)
{
if (Key <= KEY_9)
edit[edit_index] = '0' + key_idx;
edit_last_key = 255;
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
if (Key != edit_last_key)
{
edit_last_key = Key;
edit_char_index = 0;
}
else
{
edit_char_index++;
if (char_map[key_idx][edit_char_index] == '\0')
{
edit[edit_index] = '0' + Key - KEY_0;
if (++edit_index >= 10)
{ // exit edit
gFlagAcceptSetting = false;
gAskForConfirmation = 1;
}
gRequestDisplayScreen = DISPLAY_MENU;
edit_char_index = 0;
}
}
char c = char_map[key_idx][edit_char_index];
if (edit_is_uppercase && c >= 'a' && c <= 'z')
{
c -= 32;
}
edit[edit_index] = c;
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
if (bKeyHeld)
return;
INPUTBOX_Append(Key);
gRequestDisplayScreen = DISPLAY_MENU;
@@ -1550,15 +1629,17 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;
}
if (UI_MENU_GetCurrentMenuId() == MENU_MEM_CH ||
UI_MENU_GetCurrentMenuId() == MENU_DEL_CH ||
UI_MENU_GetCurrentMenuId() == MENU_1_CALL ||
UI_MENU_GetCurrentMenuId() == MENU_S_PRI_CH_1 ||
UI_MENU_GetCurrentMenuId() == MENU_S_PRI_CH_2 ||
UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
{ // enter 3-digit channel number
const int m = UI_MENU_GetCurrentMenuId();
if (gInputBoxIndex < 3)
if (m == MENU_MEM_CH ||
m == MENU_DEL_CH ||
m == MENU_1_CALL ||
m == MENU_S_PRI_CH_1 ||
m == MENU_S_PRI_CH_2 ||
m == MENU_MEM_NAME)
{ // enter 4-digit channel number
if (gInputBoxIndex < 4)
{
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
@@ -1569,7 +1650,8 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
//Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
Value = (((gInputBox[0] * 10 + gInputBox[1]) * 10 + gInputBox[2]) * 10 + gInputBox[3]) - 1;
if (IS_MR_CHANNEL(Value))
{
@@ -1626,6 +1708,58 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{
const bool editing_name = !gCssBackgroundScan
&& UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME
&& gIsInSubMenu
&& edit_index >= 0;
if (editing_name)
{
if (!bKeyPressed)
{
if (bKeyHeld)
return; // release after a long press, keep editing
if (edit_index == 0)
goto Skip;
if (edit_index > 0)
{ // step back one character while editing the channel name
edit_index--;
edit_last_key = 255;
gAskForConfirmation = 0;
gRequestDisplayScreen = DISPLAY_MENU;
}
return;
}
if (!bKeyHeld)
{ // wait to see if the user wants a short exit or a long backspace
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
Skip:
/* Backlight related menus set full brightness. Set it back to the configured value,
just in case we are editing from one of them. */
BACKLIGHT_TurnOn();
gAskForConfirmation = 0;
gIsInSubMenu = false;
gInputBoxIndex = 0;
gFlagRefreshSetting = true;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
if (bKeyHeld || !bKeyPressed)
return;
@@ -1633,29 +1767,22 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
if (!gCssBackgroundScan)
{
/* Backlight related menus set full brightness. Set it back to the configured value,
just in case we are exiting from one of them. */
BACKLIGHT_TurnOn();
if (gIsInSubMenu)
{
if (gInputBoxIndex == 0 || UI_MENU_GetCurrentMenuId() != MENU_OFFSET)
{
gAskForConfirmation = 0;
gIsInSubMenu = false;
gInputBoxIndex = 0;
gFlagRefreshSetting = true;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
goto Skip;
}
else
{
/* Backlight related menus set full brightness. Set it back to the configured value,
just in case we are exiting from one of them. */
BACKLIGHT_TurnOn();
gInputBox[--gInputBoxIndex] = 10;
gRequestDisplayScreen = DISPLAY_MENU;
}
// ***********************
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
@@ -1694,19 +1821,21 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (!gIsInSubMenu)
{
const int m = UI_MENU_GetCurrentMenuId();
#ifdef ENABLE_VOICE
if (UI_MENU_GetCurrentMenuId() != MENU_SCR)
if (m != MENU_SCR)
gAnotherVoiceID = MenuList[gMenuCursor].voice_id;
#endif
if (UI_MENU_GetCurrentMenuId() == MENU_UPCODE
|| UI_MENU_GetCurrentMenuId() == MENU_DWCODE
if (m == MENU_UPCODE
|| m == MENU_DWCODE
#ifdef ENABLE_DTMF_CALLING
|| UI_MENU_GetCurrentMenuId() == MENU_ANI_ID
|| m == MENU_ANI_ID
#endif
)
return;
#if 1
if (UI_MENU_GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
if (m == MENU_DEL_CH || m == MENU_MEM_NAME)
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
return; // invalid channel
#endif
@@ -1714,7 +1843,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gAskForConfirmation = 0;
gIsInSubMenu = true;
// if (UI_MENU_GetCurrentMenuId() != MENU_D_LIST)
// if (m != MENU_D_LIST)
{
gInputBoxIndex = 0;
edit_index = -1;
@@ -1732,12 +1861,18 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
SETTINGS_FetchChannelName(edit, gSubMenuSelection);
// pad the channel name out with '_'
edit_index = strlen(edit);
while (edit_index < 10)
edit[edit_index++] = '_';
edit[edit_index] = 0;
// pad the channel name out with ' '
size_t len = strlen(edit);
if (len < 10)
{
memset(edit + len, ' ', 10 - len);
edit[10] = '\0';
}
edit_index = 0; // 'edit_index' is going to be used as the cursor position
edit_last_key = 255;
edit_char_index = 0;
edit_is_uppercase = false;
// make a copy so we can test for change when exiting the menu item
memcpy(edit_original, edit, sizeof(edit_original));
@@ -1747,6 +1882,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
else
if (edit_index >= 0 && edit_index < 10)
{ // editing the channel name characters
edit_last_key = 255;
if (++edit_index < 10)
return; // next char
@@ -1765,10 +1901,12 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (gIsInSubMenu)
{
if (UI_MENU_GetCurrentMenuId() == MENU_RESET ||
UI_MENU_GetCurrentMenuId() == MENU_MEM_CH ||
UI_MENU_GetCurrentMenuId() == MENU_DEL_CH ||
UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
const int m = UI_MENU_GetCurrentMenuId();
if (m == MENU_RESET ||
m == MENU_MEM_CH ||
m == MENU_DEL_CH ||
m == MENU_MEM_NAME)
{
switch (gAskForConfirmation)
{
@@ -1781,7 +1919,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
UI_DisplayMenu();
if (UI_MENU_GetCurrentMenuId() == MENU_RESET)
if (m == MENU_RESET)
{
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
@@ -1823,7 +1961,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
{
if (bKeyHeld || !bKeyPressed)
if (!bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@@ -1833,13 +1971,8 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
if (edit_index < 10)
{
edit[edit_index] = '-';
if (++edit_index >= 10)
{ // exit edit
gFlagAcceptSetting = false;
gAskForConfirmation = 1;
}
edit[edit_index] = !bKeyHeld ? '-' : '*';
edit_last_key = 255;
gRequestDisplayScreen = DISPLAY_MENU;
}
@@ -1847,6 +1980,9 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
return;
}
if (bKeyHeld)
return;
RADIO_SelectVfos();
#ifdef ENABLE_NOAA
@@ -1855,7 +1991,8 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
if (gRxVfo->Modulation == MODULATION_FM)
#endif
{
if ((UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS) && gIsInSubMenu)
const int m = UI_MENU_GetCurrentMenuId();
if ((m == MENU_R_CTCS || m == MENU_R_DCS) && gIsInSubMenu)
{ // scan CTCSS or DCS to find the tone/code of the incoming signal
if (!SCANNER_IsScanning())
MENU_StartCssScan();
@@ -1876,26 +2013,8 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
uint16_t Channel;
bool bCheckScanList;
if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0)
{ // change the character
if (bKeyPressed && edit_index < 10 && Direction != 0)
{
const char unwanted[] = "$%&!\"':;?^`|{}";
char c = edit[edit_index] + Direction;
unsigned int i = 0;
while (i < sizeof(unwanted) && c >= 32 && c <= 126)
{
if (c == unwanted[i++])
{ // choose next character
c += Direction;
i = 0;
}
}
edit[edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c;
gRequestDisplayScreen = DISPLAY_MENU;
}
return;
if (!gEeprom.SET_NAV && gIsInSubMenu) {
Direction = -Direction;
}
if (!bKeyHeld)
@@ -1911,6 +2030,29 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (!bKeyPressed)
return;
if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0)
{ // change the character
if (edit_index < 10 && Direction != 0)
{
const char unwanted[] = "$%&!\"':;?^`|{}_";
char c = edit[edit_index] + Direction;
unsigned int i = 0;
while (i < sizeof(unwanted) && c >= 32 && c <= 126)
{
if (c == unwanted[i++])
{ // choose next character
c += Direction;
i = 0;
}
}
edit[edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c;
edit_last_key = 255;
gRequestDisplayScreen = DISPLAY_MENU;
}
return;
}
if (SCANNER_IsScanning()) {
return;
}
@@ -1923,9 +2065,11 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
gRequestDisplayScreen = DISPLAY_MENU;
if (UI_MENU_GetCurrentMenuId() != MENU_ABR
&& UI_MENU_GetCurrentMenuId() != MENU_ABR_MIN
&& UI_MENU_GetCurrentMenuId() != MENU_ABR_MAX
const int m = UI_MENU_GetCurrentMenuId();
if (m != MENU_ABR
&& m != MENU_ABR_MIN
&& m != MENU_ABR_MAX
&& gEeprom.BACKLIGHT_TIME == 0) // backlight always off and not in the backlight menu
{
BACKLIGHT_TurnOff();
@@ -1951,8 +2095,10 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
}
VFO = 0;
const int m = UI_MENU_GetCurrentMenuId();
switch (UI_MENU_GetCurrentMenuId())
switch (m)
{
case MENU_DEL_CH:
case MENU_1_CALL:
@@ -1968,19 +2114,21 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
return;
}
if(UI_MENU_GetCurrentMenuId() == MENU_S_PRI_CH_1 || UI_MENU_GetCurrentMenuId() == MENU_S_PRI_CH_2)
if(m == MENU_S_PRI_CH_1 || m == MENU_S_PRI_CH_2)
{
static int16_t last;
if(Direction > 0 && gSubMenuSelection == MR_CHANNELS_MAX)
{
gSubMenuSelection = -1;
last = -1;
}
else if(Direction < 0 && gSubMenuSelection == MR_CHANNELS_MAX)
{
gSubMenuSelection = MR_CHANNELS_MAX;
last = MR_CHANNELS_MAX;
if(gSubMenuSelection == MR_CHANNELS_MAX) {
if(Direction > 0)
{
gSubMenuSelection = -1;
last = -1;
}
else if(Direction < 0)
{
gSubMenuSelection = MR_CHANNELS_MAX;
last = MR_CHANNELS_MAX;
}
}
Channel = RADIO_FindNextChannel(gSubMenuSelection + Direction, Direction, bCheckScanList, VFO);
@@ -2016,42 +2164,15 @@ void MENU_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:
case KEY_0...KEY_9:
MENU_Key_0_to_9(Key, bKeyPressed, bKeyHeld);
break;
case KEY_MENU:
MENU_Key_MENU(bKeyPressed, bKeyHeld);
break;
case KEY_UP:
if(gEeprom.SET_NAV == 0) {
if(gIsInSubMenu)
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
else
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
}
else {
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
}
break;
case KEY_DOWN:
if(gEeprom.SET_NAV == 0) {
if(gIsInSubMenu)
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
else
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
}
else {
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
}
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, Key == KEY_UP ? 1 : -1);
break;
case KEY_EXIT:
MENU_Key_EXIT(bKeyPressed, bKeyHeld);
@@ -2062,19 +2183,20 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case KEY_F:
if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name
if (!bKeyHeld && bKeyPressed)
if (!bKeyPressed)
break;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (edit_index < 10)
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (edit_index < 10)
{
edit[edit_index] = ' ';
if (++edit_index >= 10)
{ // exit edit
gFlagAcceptSetting = false;
gAskForConfirmation = 1;
}
gRequestDisplayScreen = DISPLAY_MENU;
}
if (bKeyHeld)
edit[edit_index] = '#';
edit_is_uppercase = !edit_is_uppercase;
edit_last_key = 255;
gRequestDisplayScreen = DISPLAY_MENU;
}
break;
}
@@ -2092,11 +2214,13 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gScreenToDisplay == DISPLAY_MENU)
{
if (UI_MENU_GetCurrentMenuId() == MENU_VOL ||
const int m = UI_MENU_GetCurrentMenuId();
if (m == MENU_VOL ||
#ifdef ENABLE_F_CAL_MENU
UI_MENU_GetCurrentMenuId() == MENU_F_CALI ||
m == MENU_F_CALI ||
#endif
UI_MENU_GetCurrentMenuId() == MENU_BATCAL)
m == MENU_BATCAL)
{
gMenuCountdown = menu_timeout_long_500ms;
}
+14 -11
View File
@@ -32,7 +32,7 @@ DCS_CodeType_t gScanCssResultType;
uint8_t gScanCssResultCode;
bool gScanSingleFrequency; // scan CTCSS/DCS codes for current frequency
SCAN_SaveState_t gScannerSaveState;
uint8_t gScanChannel;
uint16_t gScanChannel;
uint32_t gScanFrequency;
SCAN_CssState_t gScanCssState;
uint8_t gScanProgressIndicator;
@@ -52,7 +52,7 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_SCANNER;
if (gInputBoxIndex < 3) {
if (gInputBoxIndex < 4) {
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
@@ -61,13 +61,14 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
uint16_t chan = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
// uint16_t chan = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
uint16_t chan = (((gInputBox[0] * 10 + gInputBox[1]) * 10 + gInputBox[2]) * 10 + gInputBox[3]) - 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;
gScanChannel = chan;
return;
}
}
@@ -207,7 +208,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
gTxVfo->freq_config_TX.Code = gScanCssResultCode;
}
uint8_t chan;
uint16_t chan;
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
chan = gScanChannel;
gEeprom.MrChannel[gEeprom.TX_VFO] = chan;
@@ -256,6 +257,10 @@ static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Directio
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
}
if (!gEeprom.SET_NAV) {
Direction = -Direction;
}
if (gScannerSaveState == SCAN_SAVE_CHAN_SEL) {
gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, MR_CHANNEL_LAST);
gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0);
@@ -275,10 +280,8 @@ void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
SCANNER_Key_MENU(bKeyPressed, bKeyHeld);
break;
case KEY_UP:
SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
break;
case KEY_DOWN:
SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, Key == KEY_UP ? 1 : -1);
break;
case KEY_EXIT:
SCANNER_Key_EXIT(bKeyPressed, bKeyHeld);
@@ -342,7 +345,7 @@ void SCANNER_Start(bool singleFreq)
gScanFrequency = 0xFFFFFFFF;
BK4819_PickRXFilterPathBasedOnFrequency(gScanFrequency);
BK4819_EnableFrequencyScan();
BK4819_SetFrequencyScan(true);
gUpdateStatus = true;
}
@@ -415,10 +418,10 @@ void SCANNER_TimeSlice10ms(void)
else
scanHitCount = 0;
BK4819_DisableFrequencyScan();
BK4819_SetFrequencyScan(false);
if (scanHitCount < 3) {
BK4819_EnableFrequencyScan();
BK4819_SetFrequencyScan(true);
}
else {
BK4819_SetScanFrequency(gScanFrequency);
+1 -1
View File
@@ -40,7 +40,7 @@ extern DCS_CodeType_t gScanCssResultType;
extern uint8_t gScanCssResultCode;
extern bool gScanSingleFrequency;
extern SCAN_SaveState_t gScannerSaveState;
extern uint8_t gScanChannel;
extern uint16_t gScanChannel;
extern uint32_t gScanFrequency;
extern SCAN_CssState_t gScanCssState;
extern uint8_t gScanProgressIndicator;
+1091 -340
View File
File diff suppressed because it is too large. Load diff
+20 -13
View File
@@ -42,7 +42,8 @@
#include <stdint.h>
#include <string.h>
static const uint8_t DrawingEndY = 40;
static const uint8_t DrawingEndY = 40;
static const uint8_t DrawingTopY = 8; // Reserve top 8px for frequency display (gFrameBuffer[0])
static const uint8_t U8RssiMap[] = {
121,
@@ -78,29 +79,35 @@ static const uint16_t scanStepValues[] = {
static const uint16_t scanStepBWRegValues[] = {
// RX RXw TX BW
// 0b0 000 000 001 01 1000
// 1
// 1 (S_STEP_0_01kHz, index 0)
0b0000000001011000, // 6.25
// 10
// 10 (S_STEP_0_1kHz, index 1)
0b0000000001011000, // 6.25
// 50
// 50 (S_STEP_0_5kHz, index 2)
0b0000000001011000, // 6.25
// 100
// 100 (S_STEP_1_0kHz, index 3)
0b0000000001011000, // 6.25
// 250
// 250 (S_STEP_2_5kHz, index 4)
0b0000000001011000, // 6.25
// 500
// 500 (S_STEP_5_0kHz, index 5)
0b0010010001011000, // 6.25
// 625
// 625 (S_STEP_6_25kHz, index 6)
0b0100100001011000, // 6.25
// 833
// 833 (S_STEP_8_33kHz, index 7)
0b0110110001001000, // 6.25
// 1000
// 1000 (S_STEP_10_0kHz, index 8)
0b0110110001001000, // 6.25
// 1250
// 1250 (S_STEP_12_5kHz, index 9)
0b0111111100001000, // 6.25
// 2500
// 1500 (S_STEP_15_0kHz, index 10)
0b0011011000101000, // 25
// 10000
// 2000 (S_STEP_20_0kHz, index 11)
0b0011011000101000, // 25
// 2500 (S_STEP_25_0kHz, index 12)
0b0011011000101000, // 25
// 5000 (S_STEP_50_0kHz, index 13)
0b0011011000101000, // 25
// 10000 (S_STEP_100_0kHz, index 14)
0b0011011000101000, // 25
};
+5 -5
View File
@@ -347,9 +347,9 @@ static void CMD_0514(uint32_t Port, const uint8_t *pBuffer)
#endif
gSerialConfigCountDown_500ms = 12; // 6 sec
// turn the LCD backlight off
BACKLIGHT_TurnOff();
if (gEeprom.BACKLIGHT_TIME < 61) // backlight is set to be always on
BACKLIGHT_TurnOff(); // turn the LCD backlight off
SendVersion(Port);
}
@@ -593,8 +593,8 @@ static void CMD_052F(uint32_t Port, const uint8_t *pBuffer)
}
#endif
// turn the LCD backlight off
BACKLIGHT_TurnOff();
if (gEeprom.BACKLIGHT_TIME < 61) // backlight is set to be always on
BACKLIGHT_TurnOff(); // turn the LCD backlight off
SendVersion(Port);
}
+21 -20
View File
@@ -36,12 +36,18 @@
BEEP_Type_t gBeepToPlay = BEEP_NONE;
static void AUDIO_PlayBeepPulse(void) {
BK4819_ExitTxMute();
SYSTEM_DelayMs(60);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);
}
void AUDIO_PlayBeep(BEEP_Type_t Beep)
{
if (Beep != BEEP_880HZ_60MS_DOUBLE_BEEP &&
Beep != BEEP_500HZ_60MS_DOUBLE_BEEP &&
Beep != BEEP_440HZ_500MS &&
#ifdef ENABLE_DTMF_CALLING
Beep != BEEP_880HZ_200MS &&
Beep != BEEP_880HZ_500MS &&
@@ -53,12 +59,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
#endif
!gEeprom.BEEP_CONTROL)
return;
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay == DISPLAY_AIRCOPY)
return;
#endif
if (gCurrentFunction == FUNCTION_RECEIVE)
return;
@@ -93,9 +94,6 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
case BEEP_500HZ_60MS_DOUBLE_BEEP:
ToneFrequency = 500;
break;
case BEEP_440HZ_500MS:
ToneFrequency = 440;
break;
case BEEP_880HZ_60MS_DOUBLE_BEEP:
#ifndef ENABLE_FEAT_F4HWN
case BEEP_880HZ_200MS:
@@ -116,10 +114,12 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
#endif
}
#ifdef ENABLE_FEAT_F4HWN
if(Beep == BEEP_400HZ_30MS || Beep == BEEP_500HZ_30MS || Beep == BEEP_600HZ_30MS)
{
BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_ENABLE_TONE1 | ((1 & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
}
#endif
BK4819_PlayTone(ToneFrequency, true);
@@ -133,17 +133,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
switch (Beep)
{
case BEEP_880HZ_60MS_DOUBLE_BEEP:
BK4819_ExitTxMute();
SYSTEM_DelayMs(60);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);
AUDIO_PlayBeepPulse();
[[fallthrough]];
case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL:
case BEEP_500HZ_60MS_DOUBLE_BEEP:
BK4819_ExitTxMute();
SYSTEM_DelayMs(60);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);
AUDIO_PlayBeepPulse();
[[fallthrough]];
case BEEP_1KHZ_60MS_OPTIONAL:
BK4819_ExitTxMute();
@@ -157,7 +151,6 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
Duration = 30;
break;
#endif
case BEEP_440HZ_500MS:
#ifndef ENABLE_FEAT_F4HWN
case BEEP_880HZ_200MS:
BK4819_ExitTxMute();
@@ -182,11 +175,19 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
SYSTEM_DelayMs(5);
BK4819_WriteRegister(BK4819_REG_71, ToneConfig);
#ifdef ENABLE_FMRADIO
const bool isFmRadio = gFmRadioMode;
if (isFmRadio)
SYSTEM_DelayMs(10);
#endif
if (gEnableSpeaker)
AUDIO_AudioPathOn();
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
if (isFmRadio)
BK1080_Mute(false);
#endif
-1
View File
@@ -27,7 +27,6 @@ enum BEEP_Type_t
BEEP_NONE = 0,
BEEP_1KHZ_60MS_OPTIONAL,
BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL,
BEEP_440HZ_500MS,
#ifdef ENABLE_DTMF_CALLING
BEEP_880HZ_200MS,
BEEP_880HZ_500MS,
+44 -16
View File
@@ -157,26 +157,18 @@ const uint8_t BITMAP_USB_C[9] =
};
#endif
const uint8_t BITMAP_Antenna[5] =
{
0b00000011,
0b00000101,
0b01111111,
0b00000101,
0b00000011
};
const uint8_t BITMAP_VFO_Lock[7] =
{
0b01111100,
0b01000110,
0b01000101,
0b01000101,
0b01000101,
0b01000110,
0b01111100,
0b00111100,
0b00100110,
0b00100101,
0b00100101,
0b00100101,
0b00100110,
0b00111100,
};
/*
const uint8_t BITMAP_VFO_Default[7] =
{
0b01111111,
@@ -198,6 +190,42 @@ const uint8_t BITMAP_VFO_NotDefault[7] =
0b00010100,
0b00001000
};
*/
// Compact arrow
const uint8_t BITMAP_VFO_Default[7] =
{
0b00111110,
0b00111110,
0b00011100,
0b00011100,
0b00001000,
0b00001000,
0b00000000
};
// Compact empty arrow
const uint8_t BITMAP_VFO_NotDefault[7] =
{
0b00100010,
0b00100010,
0b00010100,
0b00010100,
0b00001000,
0b00001000,
0b00000000
};
const uint8_t BITMAP_VFO_Empty[7] =
{
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
const uint8_t BITMAP_compand[6] =
{
+1 -1
View File
@@ -35,9 +35,9 @@ extern const uint8_t BITMAP_NotReady[7];
extern const uint8_t gFontVox[2][6];
#endif
extern const uint8_t BITMAP_Antenna[5];
extern const uint8_t BITMAP_VFO_Default[7];
extern const uint8_t BITMAP_VFO_NotDefault[7];
extern const uint8_t BITMAP_VFO_Empty[7];
extern const uint8_t BITMAP_VFO_Lock[7];
extern const uint8_t BITMAP_PowerUser[3];
extern const uint8_t BITMAP_compand[6];
+34 -4
View File
@@ -15,10 +15,7 @@
*/
#include "dcs.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#include "misc.h"
// CTCSS Hz * 10
const uint16_t CTCSS_Options[50] = {
@@ -29,6 +26,12 @@ const uint16_t CTCSS_Options[50] = {
2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541
};
// Indices in CTCSS_Options for the 12 non-homologated tones.
static const uint8_t CTCSS_ExtraIdx[12] = {
1, 26, 28, 30, 32, 34, 36, 38, 39, 41,
45, 49
};
const uint16_t DCS_Options[104] = {
0x0013, 0x0015, 0x0016, 0x0019, 0x001A, 0x001E, 0x0023, 0x0027,
0x0029, 0x002B, 0x002C, 0x0035, 0x0039, 0x003A, 0x003B, 0x003C,
@@ -111,3 +114,30 @@ uint8_t DCS_GetCtcssCode(int Code)
return Result;
}
uint8_t DCS_GetCtcssApprovedIndex(uint8_t Option)
{
unsigned int i;
unsigned int extra_pos = 0;
uint8_t approved_index = 0;
if (Option >= ARRAY_SIZE(CTCSS_Options))
return 0xFF;
for (i = 0; i < ARRAY_SIZE(CTCSS_Options); i++) {
const bool is_extra = extra_pos < ARRAY_SIZE(CTCSS_ExtraIdx) &&
i == CTCSS_ExtraIdx[extra_pos];
if (is_extra) {
extra_pos++;
continue;
}
if (i == Option)
return approved_index;
approved_index++;
}
return 0xFF;
}
+1 -1
View File
@@ -40,6 +40,6 @@ 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(int Code);
uint8_t DCS_GetCtcssApprovedIndex(uint8_t Option);
#endif
+67 -32
View File
@@ -31,7 +31,7 @@
#include "misc.h"
#endif
#define PWM_FREQ 320
#define PWM_FREQ 4000
#define DUTY_CYCLE_LEVELS 64
#define DUTY_CYCLE_ON_VALUE GPIO_PIN_MASK(GPIO_PIN_BACKLIGHT)
@@ -44,8 +44,14 @@ static uint32_t dutyCycle[DUTY_CYCLE_LEVELS];
// this is decremented once every 500ms
uint16_t gBacklightCountdown_500ms = 0;
bool gUpdateBacklight = false;
bool backlightOn;
static uint8_t currentIndex = 0;
static int16_t currentBrightness = 0;
static int16_t targetBrightness = 0;
static int16_t fadeStep = 0;
#ifdef ENABLE_FEAT_F4HWN
const uint8_t value[] = {
0, // 0 off
@@ -110,6 +116,12 @@ static void BACKLIGHT_Sound(void)
gK5startup = false;
}
void BACKLIGHT_UpdateTickless(void) {
while(gUpdateBacklight) {
BACKLIGHT_Update();
SYSTEM_DelayMs(10);
}
}
void BACKLIGHT_TurnOn(void)
{
@@ -134,27 +146,23 @@ void BACKLIGHT_TurnOn(void)
backlightOn = true;
#ifdef ENABLE_FEAT_F4HWN
if(gK5startup == true) {
#if defined(ENABLE_FMRADIO) && defined(ENABLE_SPECTRUM)
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MAX);
#else
for(uint8_t i = 0; i <= gEeprom.BACKLIGHT_MAX; i++)
{
BACKLIGHT_SetBrightness(i);
SYSTEM_DelayMs(50);
}
#endif
BACKLIGHT_Sound();
}
else
{
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MAX);
}
#else
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MAX);
#ifdef ENABLE_FEAT_F4HWN
if(gK5startup == true)
#else
static bool startup = true;
if(startup)
#endif
{
BACKLIGHT_UpdateTickless();
#ifdef ENABLE_FEAT_F4HWN
BACKLIGHT_Sound();
#else
startup = false;
#endif
}
switch (gEeprom.BACKLIGHT_TIME) {
default:
@@ -190,18 +198,11 @@ bool BACKLIGHT_IsOn()
return backlightOn;
}
static uint8_t currentBrightness = 0;
void BACKLIGHT_SetBrightness(uint8_t brigtness)
static void BACKLIGHT_SetHardwareBrightness(uint8_t brightness)
{
// printf("BL: %d\n", brigtness);
if (currentBrightness == brigtness)
{
return;
}
if (0 == brigtness)
if (0 == brightness)
{
LL_TIM_DisableCounter(TIMx);
LL_DMA_DisableChannel(DMA1, DMA_CHANNEL);
@@ -210,7 +211,7 @@ void BACKLIGHT_SetBrightness(uint8_t brigtness)
}
else
{
const uint32_t level = (uint32_t)(value[brigtness]) * DUTY_CYCLE_LEVELS / 255;
const uint32_t level = (uint32_t)(brightness) * DUTY_CYCLE_LEVELS / 255;
if (level >= DUTY_CYCLE_LEVELS)
{
LL_TIM_DisableCounter(TIMx);
@@ -231,11 +232,45 @@ void BACKLIGHT_SetBrightness(uint8_t brigtness)
}
}
}
}
currentBrightness = brigtness;
void BACKLIGHT_Update(void)
{
if (gUpdateBacklight) {
currentBrightness += fadeStep;
if ((fadeStep > 0 && currentBrightness >= targetBrightness) ||
(fadeStep < 0 && currentBrightness <= targetBrightness)) {
currentBrightness = targetBrightness;
gUpdateBacklight = false;
}
BACKLIGHT_SetHardwareBrightness((uint8_t)currentBrightness);
}
}
void BACKLIGHT_SetBrightness(uint8_t targetIndex)
{
if (currentIndex == targetIndex) {
return;
}
currentIndex = targetIndex;
targetBrightness = value[targetIndex];
int16_t diff = targetBrightness - currentBrightness;
if (diff == 0) {
gUpdateBacklight = false;
return;
}
fadeStep = diff > 0 ? -(-diff >> 4) : diff >> 4;
gUpdateBacklight = true;
}
uint8_t BACKLIGHT_GetBrightness(void)
{
return currentBrightness;
return currentIndex;
}
+2
View File
@@ -40,10 +40,12 @@ typedef enum {
#endif
void BACKLIGHT_InitHardware();
void BACKLIGHT_UpdateTickless(void);
void BACKLIGHT_TurnOn();
void BACKLIGHT_TurnOff();
bool BACKLIGHT_IsOn();
void BACKLIGHT_SetBrightness(uint8_t brigtness);
void BACKLIGHT_Update(void);
uint8_t BACKLIGHT_GetBrightness(void);
#endif
-4
View File
@@ -20,10 +20,6 @@
#include "driver/system.h"
#include "misc.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#endif
static const uint16_t BK1080_RegisterTable[] =
{
0x0008, 0x1080, 0x0201, 0x0000, 0x40C0, 0x0A1F, 0x002E, 0x02FF,
+1 -1
View File
@@ -163,7 +163,7 @@ typedef enum BK4819_GPIO_PIN_t BK4819_GPIO_PIN_t;
#define BK4819_REG_02_SHIFT_SQUELCH_LOST 2
#define BK4819_REG_02_SHIFT_FSK_RX_SYNC 1
#define BK4819_REG_02_MASK_FSK_TX_FINISHED (1U << BK4819_REG_02_SHIFT_FSK_TX)
#define BK4819_REG_02_MASK_FSK_TX_FINISHED (1U << BK4819_REG_02_SHIFT_FSK_TX_FINISHED)
#define BK4819_REG_02_MASK_FSK_FIFO_ALMOST_EMPTY (1U << BK4819_REG_02_SHIFT_FSK_FIFO_ALMOST_EMPTY)
#define BK4819_REG_02_MASK_FSK_RX_FINISHED (1U << BK4819_REG_02_SHIFT_FSK_RX_FINISHED)
#define BK4819_REG_02_MASK_FSK_FIFO_ALMOST_FULL (1U << BK4819_REG_02_SHIFT_FSK_FIFO_ALMOST_FULL)
+1 -4
View File
@@ -19,6 +19,7 @@
#include <stdio.h>
#include "settings.h"
#include "misc.h"
#include "audio.h"
@@ -28,10 +29,6 @@
#include "driver/systick.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#define PIN_CSN GPIO_MAKE_PIN(GPIOF, LL_GPIO_PIN_9)
#define PIN_SCL GPIO_MAKE_PIN(GPIOB, LL_GPIO_PIN_8)
#define PIN_SDA GPIO_MAKE_PIN(GPIOB, LL_GPIO_PIN_9)
+6 -2
View File
@@ -116,6 +116,10 @@ void BK4819_TurnsOffTones_TurnsOnRX(void);
#endif
void BK4819_ResetFSK(void);
void BK4819_Idle(void);
#ifdef ENABLE_BYP_RAW_DEMODULATORS
void BK4819_EnterBypass(void);
void BK4819_EnterRaw(void);
#endif
void BK4819_ExitBypass(void);
void BK4819_PrepareTransmit(void);
void BK4819_TxOn_Beep(void);
@@ -143,11 +147,11 @@ uint8_t BK4819_GetGlitchIndicator(void);
uint8_t BK4819_GetExNoiceIndicator(void);
uint16_t BK4819_GetVoiceAmplitudeOut(void);
uint8_t BK4819_GetAfTxRx(void);
void BK4819_SetRxAudioGain(void);
bool BK4819_GetFrequencyScanResult(uint32_t *pFrequency);
BK4819_CssScanResult_t BK4819_GetCxCSSScanResult(uint32_t *pCdcssFreq, uint16_t *pCtcssFreq);
void BK4819_DisableFrequencyScan(void);
void BK4819_EnableFrequencyScan(void);
void BK4819_SetFrequencyScan(bool enable);
void BK4819_SetScanFrequency(uint32_t Frequency);
void BK4819_Disable(void);
+203 -220
View File
@@ -19,6 +19,7 @@
#include <stdio.h>
#include "settings.h"
#include "misc.h"
#include "audio.h"
@@ -27,11 +28,6 @@
#include "driver/system.h"
#include "driver/systick.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#define PIN_CSN GPIO_MAKE_PIN(GPIOF, LL_GPIO_PIN_9)
#define PIN_SCL GPIO_MAKE_PIN(GPIOB, LL_GPIO_PIN_8)
#define PIN_SDA GPIO_MAKE_PIN(GPIOB, LL_GPIO_PIN_9)
@@ -43,6 +39,16 @@ static const uint16_t FSK_RogerTable[7] = {0xF1A2, 0x7446, 0x61A4, 0x6544, 0x4E8
static uint16_t gBK4819_GpioOutState;
#define SHORT_DELAY() \
__asm volatile("nop\n nop\n nop\n nop\n nop\n" \
"nop\n nop\n nop\n nop\n nop\n" \
"nop\n nop\n nop\n nop\n nop\n" \
"nop\n nop\n nop\n nop\n nop\n" \
"nop\n nop\n nop\n nop\n nop\n" \
"nop\n nop\n nop\n nop\n nop\n" \
"nop\n nop\n nop\n nop\n nop\n" \
"nop\n nop\n nop\n nop\n nop\n")
bool gRxIdleMode;
static inline void CS_Assert()
@@ -201,63 +207,78 @@ static uint16_t BK4819_ReadU16(void)
uint16_t Value;
SDA_SetDir(false);
SYSTICK_DelayUs(1);
SHORT_DELAY();
Value = 0;
for (i = 0; i < 16; i++)
{
Value <<= 1;
Value |= SDA_ReadInput();
SCL_Set();
SYSTICK_DelayUs(1);
SHORT_DELAY();
SCL_Reset();
SYSTICK_DelayUs(1);
SHORT_DELAY();
}
SDA_SetDir(true);
return Value;
}
static uint16_t reg_30_cache = 0xFFFF;
static uint16_t reg_47_cache = 0xFFFF;
uint16_t BK4819_ReadRegister(BK4819_REGISTER_t Register)
{
uint16_t Value;
CS_Release();
SCL_Reset();
SYSTICK_DelayUs(1);
SHORT_DELAY();
CS_Assert();
BK4819_WriteU8(Register | 0x80);
Value = BK4819_ReadU16();
CS_Release();
SYSTICK_DelayUs(1);
SHORT_DELAY();
SCL_Set();
SDA_Set();
if (Register == BK4819_REG_30)
reg_30_cache = Value;
else if (Register == BK4819_REG_47)
reg_47_cache = Value;
return Value;
}
void BK4819_WriteRegister(BK4819_REGISTER_t Register, uint16_t Data)
{
if (Register == BK4819_REG_30)
{
if (Data == reg_30_cache)
return;
reg_30_cache = Data;
}
else if (Register == BK4819_REG_47)
{
if (Data == reg_47_cache)
return;
reg_47_cache = Data;
}
CS_Release();
SCL_Reset();
SYSTICK_DelayUs(1);
SHORT_DELAY();
CS_Assert();
BK4819_WriteU8(Register);
SYSTICK_DelayUs(1);
SHORT_DELAY();
BK4819_WriteU16(Data);
SYSTICK_DelayUs(1);
SHORT_DELAY();
CS_Release();
SYSTICK_DelayUs(1);
SHORT_DELAY();
SCL_Set();
SDA_Set();
@@ -275,14 +296,14 @@ void BK4819_WriteU8(uint8_t Data)
else
SDA_Set();
SYSTICK_DelayUs(1);
SHORT_DELAY();
SCL_Set();
SYSTICK_DelayUs(1);
SHORT_DELAY();
Data <<= 1;
SCL_Reset();
SYSTICK_DelayUs(1);
SHORT_DELAY();
}
}
@@ -298,14 +319,14 @@ void BK4819_WriteU16(uint16_t Data)
else
SDA_Set();
SYSTICK_DelayUs(1);
SHORT_DELAY();
SCL_Set();
Data <<= 1;
SYSTICK_DelayUs(1);
SHORT_DELAY();
SCL_Reset();
SYSTICK_DelayUs(1);
SHORT_DELAY();
}
}
@@ -338,45 +359,9 @@ void BK4819_SetAGC(bool enable)
void BK4819_InitAGC(bool amModulation)
{
// REG_10, REG_11, REG_12 REG_13, REG_14
//
// Rx AGC Gain Table[]. (Index Max->Min is 3,2,1,0,-1)
//
// <15:10> ???
//
// <9:8> LNA Gain Short
// 3 = 0dB <<< 1o11 read from spectrum reference manual
// 2 = -24dB -19 -11
// 1 = -30dB -24 -16
// 0 = -33dB -28 -19
//
// <7:5> LNA Gain
// 7 = 0dB
// 6 = -2dB
// 5 = -4dB
// 4 = -6dB
// 3 = -9dB
// 2 = -14dB <<<
// 1 = -19dB
// 0 = -24dB
//
// <4:3> MIXER Gain
// 3 = 0dB <<<
// 2 = -3dB
// 1 = -6dB
// 0 = -8dB
//
// <2:0> PGA Gain
// 7 = 0dB
// 6 = -3dB <<<
// 5 = -6dB
// 4 = -9dB
// 3 = -15dB
// 2 = -21dB
// 1 = -27dB
// 0 = -33dB
//
/*
// Old strategy
BK4819_WriteRegister(BK4819_REG_13, 0x03BE); // 0x03BE / 000000 11 101 11 110 / -7dB
BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 0x037B / 000000 11 011 11 011 / -24dB
BK4819_WriteRegister(BK4819_REG_11, 0x027B); // 0x027B / 000000 10 011 11 011 / -43dB
@@ -391,7 +376,21 @@ void BK4819_InitAGC(bool amModulation)
}
BK4819_WriteRegister(BK4819_REG_7B, 0x8420);
*/
// New strategy
// Keep the runtime AGC profile aligned with the stock BK4829 firmware
// until modulation-specific AGC changes are proven on hardware.
(void)amModulation;
BK4819_WriteRegister(BK4819_REG_10, 0x0318);
BK4819_WriteRegister(BK4819_REG_11, 0x033A);
BK4819_WriteRegister(BK4819_REG_12, 0x03DB);
BK4819_WriteRegister(BK4819_REG_13, 0x03DF);
BK4819_WriteRegister(BK4819_REG_14, 0x0210);
BK4819_WriteRegister(BK4819_REG_49, 0x2AB2);
BK4819_WriteRegister(BK4819_REG_7B, 0x73DC);
}
int8_t BK4819_GetRxGain_dB(void)
@@ -629,100 +628,91 @@ void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold)
void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const bool weak_no_different)
{
// REG_43
// <15> 0 ???
(void)weak_no_different;
// REG_43 on BK4829, per BK4829 Registers Table.
//
// <14:12> 4 RF filter bandwidth
// 0 = 1.7 kHz
// 1 = 2.0 kHz
// 2 = 2.5 kHz
// 3 = 3.0 kHz
// 4 = 3.75 kHz
// 5 = 4.0 kHz
// 6 = 4.25 kHz
// 7 = 4.5 kHz
// if <5> == 1, RF filter bandwidth * 2
// <14:12> RF filter bandwidth (Apass = 0.1dB)
// 000 = 2.0 kHz
// 001 = 2.5 kHz
// 010 = 3.0 kHz
// 011 = 3.5 kHz
// 100 = 4.0 kHz
// 101 = 4.5 kHz
// 110 = 5.0 kHz
// 111 = 5.5 kHz
// if REG_43<5> == 1, RF filter bandwidth *= 2
//
// <11:9> 0 RF filter bandwidth when signal is weak
// 0 = 1.7 kHz
// 1 = 2.0 kHz
// 2 = 2.5 kHz
// 3 = 3.0 kHz
// 4 = 3.75 kHz
// 5 = 4.0 kHz
// 6 = 4.25 kHz
// 7 = 4.5 kHz
// if <5> == 1, RF filter bandwidth * 2
// <11:9> RF filter bandwidth when signal is weak (Apass = 0.1dB)
// 000 = 2.0 kHz
// 001 = 2.5 kHz
// 010 = 3.0 kHz
// 011 = 3.5 kHz
// 100 = 4.0 kHz
// 101 = 4.5 kHz
// 110 = 5.0 kHz
// 111 = 5.5 kHz
// if REG_43<5> == 1, RF filter bandwidth *= 2
//
// <8:6> 1 AFTxLPF2 filter Band Width
// 1 = 2.5 kHz (for 12.5k channel space)
// 2 = 2.75 kHz
// 0 = 3.0 kHz (for 25k channel space)
// 3 = 3.5 kHz
// 4 = 4.5 kHz
// 5 = 4.25 kHz
// 6 = 4.0 kHz
// 7 = 3.75 kHz
// <8:6> AF Tx LPF2 filter bandwidth (Apass = 1dB)
// 100 = 5.5 kHz
// 101 = 5.0 kHz
// 110 = 4.5 kHz
// 111 = 4.0 kHz
// 000 = 3.0 kHz
// 001 = 2.5 kHz
// 010 = 2.75 kHz
// 011 = 3.5 kHz
//
// <5:4> 0 BW Mode Selection
// 0 = 12.5k
// 1 = 6.25k
// 2 = 25k/20k
// <5:4> BW mode selection
// 00 = 12.5k
// 01 = 6.25k
// 10 = 25k/20k
//
// <3> 1 ???
// <2> gain after FM demodulation
// 0 = 0 dB
// 1 = 6 dB
//
// <2> 0 Gain after FM Demodulation
// 0 = 0dB
// 1 = 6dB
//
// <1:0> 0 ???
// <3> and <1:0> remain undocumented here.
uint16_t val = 0;
switch (Bandwidth)
{
case BK4819_FILTER_BW_WIDE: // 25kHz
// if (weak_no_different) {
// // make the RX bandwidth the same with weak signals
// val = 0x3628; // Old value 0x49a8 < v3.6
// } else {
// // with weak RX signals the RX bandwidth is reduced
// val = 0x3428; // Old value 0x45a8 < v3.6
// }
// 0x3028 = (0b011 << 12) | (0b000 << 9) | (0b000 << 6) |
// (0b10 << 4) | (1 << 3)
// = RF 3.5 kHz and weak-RF 2.0 kHz, both doubled because
// bit<5> is set in 25k/20k mode => RF 7.0 kHz, weak-RF
// 4.0 kHz, AF Tx LPF2 3.0 kHz, FM gain 0 dB.
val = 0x3028;
break;
case BK4819_FILTER_BW_NARROW: // 12.5kHz
// if (weak_no_different) {
// // make the RX bandwidth the same with weak signals
// val = 0x3648; // Old value 0x4808 < v3.6
// } else {
// // with weak RX signals the RX bandwidth is reduced
// val = 0x3448; // Old value 0x4408 < v3.6
// }
// 0x4048 = (0b100 << 12) | (0b000 << 9) | (0b001 << 6) |
// (0b00 << 4) | (1 << 3)
// = RF 4.0 kHz, weak-RF 2.0 kHz, AF Tx LPF2 2.5 kHz,
// 12.5k mode, FM gain 0 dB.
val = 0x4048;
break;
case BK4819_FILTER_BW_NARROWER: // 6.25kHz
// if (weak_no_different) {
// // make the RX bandwidth the same with weak signals
// val = 0x1348; // Old value 0x3658 < v3.6
// } else {
// // with weak RX signals the RX bandwidth is reduced
// val = 0x1148; // Old value 0x3658 < v3.6
// }
// 0x205C = (0b010 << 12) | (0b000 << 9) | (0b001 << 6) |
// (0b01 << 4) | (1 << 3) | (1 << 2)
// = RF 3.0 kHz, weak-RF 2.0 kHz, AF Tx LPF2 2.5 kHz,
// 6.25k mode, FM gain +6 dB.
val = 0x205C;
break;
case BK4819_FILTER_BW_AM: // 8.33kHz
// if (weak_no_different) {
// // make the RX bandwidth the same with weak signals
// val = 0x4858;
// } else {
// // with weak RX signals the RX bandwidth is reduced
// val = 0x4458;
// }
case BK4819_FILTER_BW_AM: // Stock AM preset
// 0x345C = (0b011 << 12) | (0b010 << 9) | (0b001 << 6) |
// (0b01 << 4) | (1 << 3) | (1 << 2)
// = RF 3.5 kHz, weak-RF 3.0 kHz, AF Tx LPF2 2.5 kHz,
// 6.25k mode, bit<2> set. The "8.33kHz AM" label used in
// the codebase is functional/empirical; it does not come
// directly from the BW mode bits of REG_43.
val = 0x345C;
break;
default:
val = 0x5C;
break;
@@ -801,21 +791,20 @@ void BK4819_SetupSquelch(
// <13:11> 5 Squelch = open Delay Setting
// 0 ~ 7
//
// <10:9> 7 Squelch = close Delay Setting
// <10:9> 3 Squelch = close Delay Setting
// 0 ~ 3
//
// <8> 0 ???
// <8> 1 ???
//
// <7:0> 8 Glitch threshold for Squelch = open
// 0 ~ 255
//
BK4819_WriteRegister(BK4819_REG_4E, // 01 101 11 1 00000000
// original (*)
(1u << 14) | // 1 ???
(5u << 11) | // *5 squelch = open delay .. 0 ~ 7
(6u << 9) | // *3 squelch = close delay .. 0 ~ 3
SquelchOpenGlitchThresh); // 0 ~ 255
BK4819_WriteRegister(BK4819_REG_4E,
(1u << 14) | // 1 ???
(5u << 11) | // 5 squelch = open delay .. 0 ~ 7
(3u << 9) | // 3 squelch = close delay .. 0 ~ 3
(1u << 8) | // 1 ??? (matches stock BK4829)
SquelchOpenGlitchThresh); // 0 ~ 255
// REG_4F
@@ -1158,45 +1147,62 @@ void BK4819_Idle(void)
BK4819_WriteRegister(BK4819_REG_30, 0x0000);
}
#ifdef ENABLE_BYP_RAW_DEMODULATORS
void BK4819_EnterBypass(void)
{
// Keep AF output on normal path (REG_47 mode 0x1 is documented on BK4829).
BK4819_SetAF(BK4819_AF_FM);
// Bypass all AF filters (Rx + Tx) as recommended for digital bypass mode.
// REG_2B:
// bit10: Disable AF Rx HPF300
// bit 9: Disable AF Rx LPF3K
// bit 8: Disable AF Rx de-emphasis
// bit 2: Disable AF Tx HPF300
// bit 1: Disable AF Tx LPF1
// bit 0: Disable AF Tx pre-emphasis
uint16_t reg2b = BK4819_ReadRegister(BK4819_REG_2B);
reg2b |= (1u << 10) | (1u << 9) | (1u << 8) | (1u << 2) | (1u << 1) | (1u << 0);
BK4819_WriteRegister(BK4819_REG_2B, reg2b);
// Keep AGC/AFC behavior aligned with FM-like bypass experiments.
BK4819_SetRegValue(afcDisableRegSpec, false);
}
void BK4819_EnterRaw(void)
{
// Keep AF output on a documented mode.
BK4819_SetAF(BK4819_AF_FM);
// RAW profile: bypass RX AF filters only, keep TX filter path unchanged.
// REG_2B:
// bit10: Disable AF Rx HPF300
// bit 9: Disable AF Rx LPF3K
// bit 8: Disable AF Rx de-emphasis
uint16_t reg2b = BK4819_ReadRegister(BK4819_REG_2B);
reg2b |= (1u << 10) | (1u << 9) | (1u << 8);
reg2b &= ~((1u << 2) | (1u << 1) | (1u << 0));
BK4819_WriteRegister(BK4819_REG_2B, reg2b);
// RAW profile keeps AFC disabled to preserve discriminator-like behavior.
BK4819_SetRegValue(afcDisableRegSpec, true);
}
#endif
void BK4819_ExitBypass(void)
{
BK4819_SetAF(BK4819_AF_MUTE);
// REG_7E
//
// <15> 0 AGC fix mode
// 1 = fix
// 0 = auto
//
// <14:12> 3 AGC fix index
// 3 ( 3) = max
// 2 ( 2)
// 1 ( 1)
// 0 ( 0)
// 7 (-1)
// 6 (-2)
// 5 (-3)
// 4 (-4) = min
//
// <11:6> 0 ???
//
// <5:3> 5 DC filter band width for Tx (MIC In)
// 0 ~ 7
// 0 = bypass DC filter
//
// <2:0> 6 DC filter band width for Rx (I.F In)
// 0 ~ 7
// 0 = bypass DC filter
//
#ifdef ENABLE_BYP_RAW_DEMODULATORS
// Restore normal AF filters.
uint16_t reg2b = BK4819_ReadRegister(BK4819_REG_2B);
reg2b &= ~((1u << 10) | (1u << 9) | (1u << 8) | (1u << 2) | (1u << 1) | (1u << 0));
BK4819_WriteRegister(BK4819_REG_2B, reg2b);
#endif
// Keep existing REG_7E logic from your current implementation.
uint16_t regVal = BK4819_ReadRegister(BK4819_REG_7E);
// 0x302E / 0 011 000000 101 110
BK4819_WriteRegister(BK4819_REG_7E, (regVal & ~(0b111 << 3))
| (5u << 3) // 5 DC Filter band width for Tx (MIC In)
);
BK4819_WriteRegister(BK4819_REG_7E, (regVal & ~(0b111 << 3)) | (5u << 3));
}
void BK4819_PrepareTransmit(void)
@@ -1451,24 +1457,15 @@ void BK4819_GenTail(uint8_t Tail)
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz)*20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
switch (Tail)
{
case 0: // 134.4Hz CTCSS Tail
BK4819_WriteRegister(BK4819_REG_52, 0x828F); // 1 00 0 001010 001111
break;
case 1: // 120° phase shift
BK4819_WriteRegister(BK4819_REG_52, 0xA28F); // 1 01 0 001010 001111
break;
case 2: // 180° phase shift
BK4819_WriteRegister(BK4819_REG_52, 0xC28F); // 1 10 0 001010 001111
break;
case 3: // 240° phase shift
BK4819_WriteRegister(BK4819_REG_52, 0xE28F); // 1 11 0 001010 001111
break;
case 4: // 55Hz tone freq
BK4819_WriteRegister(BK4819_REG_07, 0x046f); // 0 00 0 010001 101111
break;
}
if (Tail <= 3)
// 0: 134.4Hz CTCSS Tail
// 1: 120° phase shift
// 2: 180° phase shift
// 3: 240° phase shift
BK4819_WriteRegister(BK4819_REG_52, 0x028F | (Tail << 13));
else if (Tail == 4)
// 4: 55Hz tone freq
BK4819_WriteRegister(BK4819_REG_07, 0x046F);
}
void BK4819_PlayCDCSSTail(void)
@@ -1550,6 +1547,14 @@ uint8_t BK4819_GetAfTxRx(void)
return BK4819_ReadRegister(BK4819_REG_6F) & 0x003F;
}
void BK4819_SetRxAudioGain(void) {
BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
( 0u << 10) | // AF Rx Gain-1
(gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
}
bool BK4819_GetFrequencyScanResult(uint32_t *pFrequency)
{
const uint16_t High = BK4819_ReadRegister(BK4819_REG_0D);
@@ -1585,7 +1590,7 @@ BK4819_CssScanResult_t BK4819_GetCxCSSScanResult(uint32_t *pCdcssFreq, uint16_t
return BK4819_CSS_RESULT_NOT_FOUND;
}
void BK4819_DisableFrequencyScan(void)
void BK4819_SetFrequencyScan(bool enable)
{
// REG_32
//
@@ -1601,32 +1606,10 @@ void BK4819_DisableFrequencyScan(void)
// 1 = enable
// 0 = disable
//
BK4819_WriteRegister(BK4819_REG_32, // 0x0244); // 00 0000100100010 0
BK4819_WriteRegister(BK4819_REG_32,
( 0u << 14) | // 0 frequency scan Time
(290u << 1) | // ???
( 0u << 0)); // 0 frequency scan enable
}
void BK4819_EnableFrequencyScan(void)
{
// REG_32
//
// <15:14> 0 frequency scan time
// 0 = 0.2 sec
// 1 = 0.4 sec
// 2 = 0.8 sec
// 3 = 1.6 sec
//
// <13:1> ???
//
// <0> 0 frequency scan enable
// 1 = enable
// 0 = disable
//
BK4819_WriteRegister(BK4819_REG_32, // 0x0245); // 00 0000100100010 1
( 0u << 14) | // 0 frequency scan time
(290u << 1) | // ???
( 1u << 0)); // 1 frequency scan enable
(enable ? 1u : 0u)); // frequency scan (1: enable | 0: disable)
}
void BK4819_SetScanFrequency(uint32_t Frequency)
@@ -1690,7 +1673,7 @@ void BK4819_Disable(void)
void BK4819_StopScan(void)
{
BK4819_DisableFrequencyScan();
BK4819_SetFrequencyScan(false);
BK4819_Disable();
}
+4 -2
View File
@@ -48,11 +48,12 @@ static const AddrMapping_t ADDR_MAPPINGS[] = {
_MK_MAPPING(0x006000, 0x006000, 0x007000), // 256 MR Name * 16 Bytes
_MK_MAPPING(0x007000, 0x007000, 0x008000), // 256 MR Name * 16 Bytes
_MK_MAPPING(0x008000, 0x008000, 0x00880E), // 1024 MR + 7 VFO Attributes * 2 Bytes (ex 0x002000)
_MK_MAPPING(0x008000, 0x008000, 0x00886E), // 1024 MR + 7 VFO Attributes * 2 Bytes (ex 0x002000) 0x008000 -> 0x00880E
// List name * 4 Bytes 0x00880E -> 0x00886E
_MK_MAPPING(0x009000, 0x009000, 0x0090D6), // 14 VFO * 16 Bytes (ex 0x001000)
_MK_MAPPING(0x00A000, 0x00A000, 0x00A160), // Settings * 16 Bytes (ex 0x004000) 0x00A000 -> 0x00A010
_MK_MAPPING(0x00A000, 0x00A000, 0x00A170), // Settings * 16 Bytes (ex 0x004000) 0x00A000 -> 0x00A010
// Settings * 16 Bytes (ex 0x005000) 0x00A010 -> 0x00A020
// Settings FM * 8 Bytes (0x006000) 0x00A020 -> 0x00A028
// MR FM * 128 Bytes (0x003000) 0x00A028 -> 0x00A0A8
@@ -62,6 +63,7 @@ static const AddrMapping_t ADDR_MAPPINGS[] = {
// Settings AES * 16 Bytes (0x00A000) 0x00A140 -> 0x00A150
// Settings * 8 Bytes (0x00B000) 0x00A150 -> 0x00A158
// Settings F4HWN * 8 Bytes (0x00C000) 0x00A158 -> 0x00A160
// Settings Version * 16 Bytes 0x00A160 -> 0x00A170
_MK_MAPPING(0x010000, 0x00B000, 0x00B200), // Calibration 512 Bytes!!!
};
+112
View File
@@ -27,6 +27,84 @@ KEY_Code_t gKeyReading1 = KEY_INVALID;
uint16_t gDebounceCounter = 0;
bool gWasFKeyPressed = false;
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
// Short press: hold key for SERIAL_KEY_SHORT_POLLS calls.
// Must exceed key_debounce_10ms (2) to trigger ProcessKey(key, true, false).
#define SERIAL_KEY_SHORT_POLLS 5
// Long press: hold key for SERIAL_KEY_LONG_POLLS calls.
// Must exceed key_repeat_delay_10ms (40) to trigger ProcessKey(key, true, true).
#define SERIAL_KEY_LONG_POLLS 45
// Packet types for serial key injection (K5Viewer → radio)
#define SERIAL_KEY_TYPE 0x03
#define SERIAL_KEY_TYPE_LONG 0x04
volatile KEY_Code_t gKeyFromSerial = KEY_INVALID;
static uint8_t gSerialKeyHoldCount = 0;
static uint8_t gSerialKeyLong = 0; // 0 = short press, 1 = long press
// Inject a short or long press from serial (UART or VCP).
// KEY_PTT is explicitly blocked — PTT release cannot be guaranteed over serial.
static inline void KEYBOARD_InjectKey(uint8_t keyCode, bool keyLong)
{
if (keyCode < KEY_INVALID && keyCode != KEY_PTT) {
gKeyFromSerial = (KEY_Code_t)keyCode;
gSerialKeyHoldCount = 0;
gSerialKeyLong = keyLong;
}
}
bool KEYBOARD_ProcessProtocolByte(ParseState_t *state, uint8_t b)
{
bool connected = false;
switch (*state)
{
case STATE_IDLE:
if (b == 0x55) *state = STATE_KA_1;
else if (b == 0xAA) *state = STATE_KEY_1;
break;
case STATE_KA_1:
*state = (b == 0xAA) ? STATE_KA_2 : STATE_IDLE;
break;
case STATE_KA_2:
*state = (b == 0x00) ? STATE_KA_3 : STATE_IDLE;
break;
case STATE_KA_3:
if (b == 0x00) connected = true;
*state = STATE_IDLE;
break;
case STATE_KEY_1:
*state = (b == 0x55) ? STATE_KEY_2 : STATE_IDLE;
break;
case STATE_KEY_2:
if (b == SERIAL_KEY_TYPE) *state = STATE_KEY_3;
else if (b == SERIAL_KEY_TYPE_LONG) *state = STATE_KEY_3L;
else *state = STATE_IDLE;
break;
case STATE_KEY_3:
case STATE_KEY_3L:
KEYBOARD_InjectKey(b, *state == STATE_KEY_3L);
connected = true;
*state = STATE_IDLE;
break;
default:
*state = STATE_IDLE;
break;
}
return connected;
}
#endif
#define GPIOx GPIOB
#define PIN_MASK_COLS (LL_GPIO_PIN_6 | LL_GPIO_PIN_5 | LL_GPIO_PIN_4 | LL_GPIO_PIN_3)
#define PIN_COLS GPIO_MAKE_PIN(GPIOx, PIN_MASK_COLS)
@@ -78,6 +156,25 @@ static const KEY_Code_t keyboard[5][4] = {
KEY_Code_t KEYBOARD_Poll(void)
{
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
// Serial-injected key: hold it for SHORT or LONG polls depending on press type,
// so the debounce counter in app.c reaches the right threshold:
// - Short: key_debounce_10ms (2) → ProcessKey(key, true, false)
// - Long: key_repeat_delay_10ms (40) → ProcessKey(key, true, true)
// Once the hold count is exhausted we clear it — next call returns KEY_INVALID,
// which triggers the release path in app.c naturally.
if (gKeyFromSerial != KEY_INVALID) {
KEY_Code_t injected = gKeyFromSerial;
uint8_t threshold = gSerialKeyLong ? SERIAL_KEY_LONG_POLLS : SERIAL_KEY_SHORT_POLLS;
if (++gSerialKeyHoldCount >= threshold) {
gKeyFromSerial = KEY_INVALID;
gSerialKeyHoldCount = 0;
gSerialKeyLong = 0;
}
return injected;
}
#endif
KEY_Code_t Key = KEY_INVALID;
// Scan all 5 columns - never break early to avoid GPIO state issues
@@ -153,4 +250,19 @@ KEY_Code_t KEYBOARD_Poll(void)
GPIO_SetOutputPin(PIN_COLS);
return Key;
}
KEY_Code_t KEYBOARD_GetKey(void)
{
KEY_Code_t btn = KEYBOARD_Poll();
if (btn == KEY_INVALID && GPIO_IsPttPressed())
{
btn = KEY_PTT;
}
return btn;
}
void HideFKeyIcon(void) {
gWasFKeyPressed = false;
gUpdateStatus = true;
}
+21 -1
View File
@@ -45,12 +45,32 @@ enum KEY_Code_e {
};
typedef enum KEY_Code_e KEY_Code_t;
typedef enum {
STATE_IDLE = 0,
STATE_KA_1,
STATE_KA_2,
STATE_KA_3,
STATE_KEY_1,
STATE_KEY_2,
STATE_KEY_3,
STATE_KEY_3L,
} ParseState_t;
extern KEY_Code_t gKeyReading0;
extern KEY_Code_t gKeyReading1;
extern uint16_t gDebounceCounter;
extern bool gWasFKeyPressed;
KEY_Code_t KEYBOARD_Poll(void);
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
// Serial-injected key (written by UART/VCP parser, consumed by KEYBOARD_Poll).
extern volatile KEY_Code_t gKeyFromSerial;
bool KEYBOARD_ProcessProtocolByte(ParseState_t *state, uint8_t b);
#endif
KEY_Code_t KEYBOARD_Poll(void);
KEY_Code_t KEYBOARD_GetKey(void);
void HideFKeyIcon(void);
#endif
+4 -4
View File
@@ -40,7 +40,7 @@
static uint32_t SectorCacheAddr = 0x1000000;
static uint8_t SectorCache[SECTOR_SIZE];
static uint8_t BlackHole[1];
static uint8_t BlackHole[4] __attribute__((aligned(4)));
static volatile bool TC_Flag;
static inline void CS_Assert()
@@ -256,9 +256,9 @@ void PY25Q16_WriteBuffer(uint32_t Address, const void *pBuffer, uint32_t Size, b
printf("spi flash write: %06x %ld %d\n", Address, Size, Append);
#endif
#ifdef ENABLE_FEAT_F4HWN_DEBUG
gDebug++;
#endif
//#ifdef ENABLE_FEAT_F4HWN_DEBUG
// gDebug++;
//#endif
uint32_t SecIndex = Address / SECTOR_SIZE;
uint32_t SecAddr = SecIndex * SECTOR_SIZE;
+4
View File
@@ -24,6 +24,7 @@
#include "driver/st7565.h"
#include "driver/system.h"
#include "misc.h"
#include "screenshot.h"
#define SPIx SPI1
@@ -163,6 +164,9 @@ void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const u
void ST7565_BlitLine(unsigned line)
{
ST7565_BlitScreen(line + 1);
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
SCREENSHOT_Update(true); // Force immediate capture
#endif
}
void ST7565_BlitStatusLine(void)
+3 -2
View File
@@ -20,8 +20,9 @@
static uint32_t gTickMultiplier;
void SYSTICK_Init(void)
{
SysTick_Config(480000);
gTickMultiplier = 48;
SysTick_Config(SystemCoreClock / 100); // 10 ms (1/100 sec) systick interrupt
gTickMultiplier = SystemCoreClock / 1000000;
NVIC_SetPriority(SysTick_IRQn, 0);
}
void SYSTICK_DelayUs(uint32_t Delay)
+24 -7
View File
@@ -22,7 +22,10 @@
#include "py32f071_ll_dma.h"
#include "py32f071_ll_gpio.h"
#include "py32f071_ll_usart.h"
#include "driver/uart.h"
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
#include "driver/keyboard.h"
#endif
#define USARTx USART1
#define DMA_CHANNEL LL_DMA_CHANNEL_2
@@ -149,12 +152,26 @@ void UART_LogSend(const void *pBuffer, uint32_t Size)
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
bool UART_IsCableConnected(void) {
for (size_t i = 0; i < sizeof(UART_DMA_Buffer); i++) {
if (UART_DMA_Buffer[i] == 0x55) {
UART_DMA_Buffer[i] = 0x00; // Clear only the matched byte
return true;
}
static uint8_t read_ptr = 0;
static ParseState_t state = STATE_IDLE;
bool connected = false;
// DMA write position: NbData counts DOWN from 256
uint8_t write_ptr = (uint8_t)(sizeof(UART_DMA_Buffer) -
LL_DMA_GetDataLength(DMA1, DMA_CHANNEL));
uint8_t processed = 0;
while (read_ptr != write_ptr && processed < sizeof(UART_DMA_Buffer))
{
uint8_t b = UART_DMA_Buffer[read_ptr++];
// read_ptr wraps naturally at 256 since it's uint8_t
processed++;
if(KEYBOARD_ProcessProtocolByte(&state, b))
connected = true;
}
return false;
return connected;
}
#endif
+39 -8
View File
@@ -18,6 +18,10 @@
#include "usb_config.h"
#include "py32f071_ll_bus.h"
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
#include "driver/keyboard.h"
#endif
uint8_t VCP_RxBuf[VCP_RX_BUF_SIZE];
volatile uint32_t VCP_RxBufPointer = 0;
@@ -38,24 +42,51 @@ void VCP_Init()
NVIC_EnableIRQ(USBD_IRQn);
}
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
bool VCP_ScreenshotPing(void)
{
static uint32_t read_ptr = 0;
// State machine for parsing incoming packets:
// Keepalive: 0x55 0xAA 0x00 0x00 → viewer alive
// Short key press: 0xAA 0x55 0x03 <key> → inject short press
// Long key press: 0xAA 0x55 0x04 <key> → inject long press
//
// State transitions:
// IDLE → 0x55 → KA_1
// KA_1 → 0xAA → KA_2 (else IDLE)
// KA_2 → 0x00 → KA_3 (else IDLE)
// KA_3 → 0x00 → keepalive OK, IDLE
//
// IDLE → 0xAA → KEY_1
// KEY_1 → 0x55 → KEY_2 (else IDLE)
// KEY_2 → 0x03 → KEY_3 (short press, else check long)
// KEY_2 → 0x04 → KEY_3L (long press, else IDLE)
// KEY_3 → <b> → KEYBOARD_InjectKey(b, false), IDLE
// KEY_3L → <b> → KEYBOARD_InjectKey(b, true), IDLE
uint32_t write_ptr = VCP_RxBufPointer;
static uint8_t read_ptr = 0;
static ParseState_t state = STATE_IDLE;
while (read_ptr != write_ptr)
bool connected = false;
uint8_t write_ptr = VCP_RxBufPointer; // snapshot once — ISR may update concurrently
// Cap bytes processed per call to VCP_RX_BUF_SIZE.
// Prevents unbounded loop if the ISR write pointer laps read_ptr
// (buffer overflow / corrupted state), which would freeze the firmware.
uint32_t processed = 0;
while (read_ptr != write_ptr && processed < VCP_RX_BUF_SIZE)
{
uint8_t b = VCP_RxBuf[read_ptr];
read_ptr++;
if (read_ptr >= VCP_RX_BUF_SIZE)
read_ptr = 0;
processed++;
if (b == 0x55)
{
return true;
}
if(KEYBOARD_ProcessProtocolByte(&state, b))
connected = true;
}
return false;
return connected;
}
#endif // ENABLE_FEAT_F4HWN_SCREENSHOT
+3
View File
@@ -28,7 +28,10 @@ extern uint8_t VCP_RxBuf[VCP_RX_BUF_SIZE];
extern volatile uint32_t VCP_RxBufPointer;
void VCP_Init();
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
bool VCP_ScreenshotPing(void);
#endif
static inline void VCP_Send(const uint8_t *Buf, uint32_t Size)
{
+2 -2
View File
@@ -362,7 +362,7 @@ const uint8_t gFontSmall[95-1][6] =
{0x20, 0x40, 0x40, 0x3D, 0x00, 0x00}, // 'j'
{0x00, 0x7F, 0x10, 0x28, 0x44, 0x00}, // 'k'
{0x00, 0x00, 0x3F, 0x40, 0x00, 0x00}, // 'l'
{0x7C, 0x08, 0x10, 0x10, 0x08, 0x7C}, // 'm'
{0x7C, 0x04, 0x7C, 0x04, 0x78, 0x00}, // 'm'
{0x7C, 0x04, 0x04, 0x04, 0x78, 0x00}, // 'n'
{0x38, 0x44, 0x44, 0x44, 0x38, 0x00}, // 'o'
{0x7C, 0x14, 0x14, 0x14, 0x08, 0x00}, // 'p'
@@ -491,7 +491,7 @@ const uint8_t gFontSmall[95-1][6] =
{0x03, 0x00, 0x03}, // 34 - quotedbl
{0x1f, 0x0a, 0x1f}, // 35 - numbersign
{0x0a, 0x1f, 0x05}, // 36 - dollar
{0x09, 0x04, 0x12}, // 37 - percent
{0x19, 0x04, 0x13}, // 37 - percent
{0x0f, 0x17, 0x1c}, // 38 - ampersand
{0x00, 0x03, 0x00}, // 39 - quotesingle
{0x00, 0x0e, 0x11}, // 40 - parenleft
+5 -8
View File
@@ -163,11 +163,8 @@ int32_t TX_freq_check(const uint32_t Frequency)
{ // return '0' if TX frequency is allowed
// otherwise 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
if (RX_freq_check(Frequency))
return -1;
switch (gSetting_F_LOCK)
{
@@ -280,10 +277,10 @@ int32_t RX_freq_check(const uint32_t Frequency)
// otherwise return '-1'
if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper)
return -1;
return -1; // not allowed outside this range
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
return -1;
return -1; // BX chip does not work in this range
return 0; // OK frequency
return 0; // OK frequency
}
+1 -8
View File
@@ -118,14 +118,7 @@ void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction)
void FUNCTION_PowerSave() {
#ifdef ENABLE_FEAT_F4HWN_SLEEP
if(gWakeUp)
{
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 200; // deep sleep now indexed on BatSav
}
else
{
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
}
gPowerSave_10ms = gEeprom.BATTERY_SAVE * (gWakeUp ? 200 : 10); // deep sleep now indexed on BatSav
#else
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
#endif
+26 -69
View File
@@ -157,11 +157,7 @@ void Main(void)
#ifdef ENABLE_FEAT_F4HWN
gEeprom.KEY_LOCK = 0;
SETTINGS_SaveSettings();
gMenuCursor = MENU_ITEMS;
#ifdef ENABLE_NOAA
gMenuCursor += 1; // move to hidden section, fix me if change... !!!
#endif
gMenuCursor = UI_MENU_GetMenuIdx(FIRST_HIDDEN_MENU_ITEM);
gSubMenuSelection = gSetting_F_LOCK;
#endif
}
@@ -277,77 +273,38 @@ void Main(void)
#endif
}
/*
#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE
if(gEeprom.CURRENT_STATE == 2 || gEeprom.CURRENT_STATE == 5)
{
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency;
if(gScanRangeStart > gScanRangeStop)
{
SWAP(gScanRangeStart, gScanRangeStop);
}
}
switch (gEeprom.CURRENT_STATE) {
case 1:
gEeprom.SCAN_LIST_DEFAULT = gEeprom.CURRENT_LIST;
CHFRSCANNER_Start(true, SCAN_FWD);
break;
if (gEeprom.CURRENT_STATE == 2 || gEeprom.CURRENT_STATE == 5)
CHFRSCANNER_ScanRange();
case 2:
CHFRSCANNER_Start(true, SCAN_FWD);
break;
switch (gEeprom.CURRENT_STATE) {
case 1:
gEeprom.SCAN_LIST_DEFAULT = gEeprom.CURRENT_LIST;
CHFRSCANNER_Start(true, SCAN_FWD);
break;
#ifdef ENABLE_FMRADIO
case 3:
ACTION_FM();
GUI_SelectNextDisplay(gRequestDisplayScreen);
break;
#endif
case 2:
CHFRSCANNER_Start(true, SCAN_FWD);
break;
#ifdef ENABLE_SPECTRUM
case 4:
APP_RunSpectrum();
break;
case 5:
APP_RunSpectrum();
break;
#endif
#ifdef ENABLE_FMRADIO
case 3:
ACTION_FM();
GUI_SelectNextDisplay(gRequestDisplayScreen);
break;
#endif
default:
// No action for CURRENT_STATE == 0 or other unexpected values
break;
}
#endif
*/
#ifdef ENABLE_SPECTRUM
case 4:
case 5:
APP_RunSpectrum();
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE
if (gEeprom.CURRENT_STATE == 2 || gEeprom.CURRENT_STATE == 5) {
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency;
if (gScanRangeStart > gScanRangeStop) {
SWAP(gScanRangeStart, gScanRangeStop);
}
default:
// No action for CURRENT_STATE == 0 or other unexpected values
break;
}
if (gEeprom.CURRENT_STATE == 1) {
gEeprom.SCAN_LIST_DEFAULT = gEeprom.CURRENT_LIST;
}
if (gEeprom.CURRENT_STATE == 1 || gEeprom.CURRENT_STATE == 2) {
CHFRSCANNER_Start(true, SCAN_FWD);
}
#ifdef ENABLE_FMRADIO
else if (gEeprom.CURRENT_STATE == 3) {
ACTION_FM();
GUI_SelectNextDisplay(gRequestDisplayScreen);
}
#endif
#ifdef ENABLE_SPECTRUM
else if (gEeprom.CURRENT_STATE == 4 || gEeprom.CURRENT_STATE == 5) {
APP_RunSpectrum();
}
#endif
#endif
while (true) {
+21 -4
View File
@@ -87,7 +87,7 @@ const uint16_t NOAA_countdown_3_10ms = 200 / 10; // 200ms
const uint32_t gDefaultAesKey[4] = {0x4AA5CC60, 0x0312CC5F, 0xFFD2DABB, 0x6BBA7F92};
const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31};
const uint8_t gMicGain_dB2[9] = {3, 8, 16, 24, 32, 40, 48, 56, 63}; // BK4819 {3, 8, 16, 24, 31};
#ifndef ENABLE_FEAT_F4HWN
bool gSetting_350TX;
@@ -127,7 +127,8 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
bool gSetting_set_met = 0;
bool gSetting_set_gui = 0;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
uint8_t gSetting_set_audio = 0;
uint8_t gSetting_set_audio_fm = 0;
uint8_t gSetting_set_audio_am = 0;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
bool gSetting_set_nfm = 0;
@@ -135,7 +136,7 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
bool gSetting_set_tmr = 0;
bool gSetting_set_ptt_session;
#ifdef ENABLE_FEAT_F4HWN_DEBUG
uint16_t gDebug;
int16_t gDebug;
#endif
uint8_t gDW = 0;
uint8_t gCB = 0;
@@ -149,6 +150,7 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
bool gPowerHigh = false;
bool gRemoveOffset = false;
#endif
int8_t dBmCorrTable[7] = {-15, -16, -10, -4, -7, -6, -1};
#endif
#ifdef ENABLE_AUDIO_BAR
@@ -241,6 +243,7 @@ volatile uint16_t gScanPauseDelayIn_10ms;
uint16_t gMenuCountdown;
bool gPttWasReleased;
bool gPttWasPressed;
bool gHasVfoBackup;
uint8_t gKeypadLocked;
bool gFlagReconfigureVfos;
uint8_t gVfoConfigureMode;
@@ -292,7 +295,7 @@ uint8_t gFSKWriteIndex;
#ifdef ENABLE_NOAA
bool gIsNoaaMode;
uint16_t gNoaaChannel;
uint8_t gNoaaChannel;
#endif
bool gUpdateDisplay;
@@ -328,12 +331,14 @@ uint8_t gIsLocked = 0xFF;
bool gMute = false;
uint8_t gBacklightTimeOriginal;
uint8_t gBacklightBrightnessOld;
uint8_t gSquelchLevelOriginal = 10;
uint8_t gPttOnePushCounter = 0;
uint32_t gBlinkCounter = 0;
uint16_t gVfoSaveCountdown_10ms = 0;
bool gScheduleVfoSave = false;
bool gVfoStateChanged = false;
char gListName[MR_CHANNELS_LIST][4];
#endif
inline void FUNCTION_NOP() { ; }
@@ -632,4 +637,16 @@ void MR_PrintCacheStats(void)
// cache_hits, cache_misses, MR_GetCacheHitRate());
}
#endif
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
bool SCREENSHOT_IsLocked(void)
{
if (gUART_LockScreenshot > 0) {
gUART_LockScreenshot--;
return true;
}
return false;
}
#endif
+12 -6
View File
@@ -39,8 +39,6 @@
#define FM_CHANNELS_MAX 48
#define MR_CHANNELS_MAX 1024
#define MR_CHANNELS_LIST 24
#define MENU_ITEMS 69
// CACHE-BASED OPTIMIZATION: Only keep active channels in RAM
// Full array stays in EEPROM, cache holds ~10 most-used channels
#define MR_CHANNELS_CACHE_SIZE 10
@@ -148,7 +146,7 @@ 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 const uint8_t gMicGain_dB2[9];
#ifndef ENABLE_FEAT_F4HWN
extern bool gSetting_350TX;
@@ -189,7 +187,8 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
extern bool gSetting_set_met;
extern bool gSetting_set_gui;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
extern uint8_t gSetting_set_audio;
extern uint8_t gSetting_set_audio_fm;
extern uint8_t gSetting_set_audio_am;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
extern bool gSetting_set_nfm;
@@ -197,7 +196,7 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
extern bool gSetting_set_tmr;
extern bool gSetting_set_ptt_session;
#ifdef ENABLE_FEAT_F4HWN_DEBUG
extern uint16_t gDebug;
extern int16_t gDebug;
#endif
extern uint8_t gDW;
extern uint8_t gCB;
@@ -211,6 +210,7 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
extern bool gPowerHigh;
extern bool gRemoveOffset;
#endif
extern int8_t dBmCorrTable[7];
#endif
#ifdef ENABLE_AUDIO_BAR
@@ -322,6 +322,8 @@ extern volatile bool gTxTimeoutReached;
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
extern volatile uint8_t gUART_LockScreenshot; // lock screenshot if Chirp is used
extern bool gUSB_ScreenshotEnabled;
bool SCREENSHOT_IsLocked(void);
#endif
#endif
@@ -365,6 +367,7 @@ extern AlarmState_t gAlarmState;
extern uint16_t gMenuCountdown;
extern bool gPttWasReleased;
extern bool gPttWasPressed;
extern bool gHasVfoBackup;
extern bool gFlagReconfigureVfos;
extern uint8_t gVfoConfigureMode;
extern bool gFlagResetVfos;
@@ -449,12 +452,15 @@ extern volatile uint8_t boot_counter_10ms;
extern bool gMute;
extern uint8_t gBacklightTimeOriginal;
extern uint8_t gBacklightBrightnessOld;
extern uint8_t gSquelchLevelOriginal;
extern uint8_t gPttOnePushCounter;
extern uint32_t gBlinkCounter;
extern uint16_t gVfoSaveCountdown_10ms;
extern bool gScheduleVfoSave;
extern bool gVfoStateChanged;
extern char gListName[MR_CHANNELS_LIST][4];
#endif
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
@@ -464,4 +470,4 @@ void FUNCTION_NOP();
static inline bool SerialConfigInProgress() { return gSerialConfigCountDown_500ms != 0; }
#endif
#endif
+209 -189
View File
@@ -54,36 +54,67 @@ const char gModulationStr[MODULATION_UKNOWN][4] = {
};
#ifdef ENABLE_FEAT_F4HWN_AUDIO
static void AUDIO_ApplyProfile(uint8_t profile)
// About BK4819_WriteRegister(0x2b, val) experimentation...
//
// 0x000: 300 Hz high-pass filter enabled, 3 kHz low-pass filter enabled, de-emphasis enabled.
// Audio impression: the most "classic radio" tuning, more filtered and smoother.
//
// 0x300: 300 Hz high-pass filter enabled, 3 kHz low-pass filter disabled, de-emphasis disabled.
// Audio impression: clearer, brighter, and more open, while still cutting low frequencies.
//
// 0x400: 300 Hz high-pass filter disabled, 3 kHz low-pass filter enabled, de-emphasis enabled.
// Audio impression: fuller low end, but still softened by de-emphasis and upper-frequency limiting.
//
// 0x500: 300 Hz high-pass filter disabled, 3 kHz low-pass filter enabled, de-emphasis disabled.
// Audio impression: fuller bass, more direct sound, while still keeping the 3 kHz top-end limit.
static void AUDIO_ApplyFMProfile(uint8_t profile)
{ // | 0x54 || 0x55 |
static const uint16_t fm_profiles[][2] = {
{0x9009, 0x3200}, // 0: FLAT
{0x9009, 0x33A9}, // 1: CLEAN
{0x9009, 0x3600}, // 2: MID
{0x8546, 0x3AF0}, // 3: BOOST
{0x8566, 0x3D00} // 4: MAX
};
if (profile >= ARRAY_SIZE(fm_profiles))
profile = 0;
BK4819_WriteRegister(0x54, fm_profiles[profile][0]);
BK4819_WriteRegister(0x55, fm_profiles[profile][1]);
}
static void AUDIO_ApplyAMProfile(uint8_t profile)
{ // | 0x2b || 0x2f || 0x54 || 0x55 |
static const uint16_t am_profiles[][4] = {
// SHARP (ALPHA test profile) - Narrow IF filter (REG54 bits[14:8]=0, bits[7:0]=9), low IF gain (REG55 bits[11:8]=1, ref=169)
// Selective and crisp, best adjacent channel rejection, may sound harsh on strong signals
{0x0300, 0x9990, 0x9009, 0x31A9},
// STOCK - Narrow IF filter (REG54 bits[14:8]=0, bits[7:0]=9), moderate IF gain (REG55 bits[11:8]=4, ref=180)
// Selective filter with balanced gain, punchy and detailed, good compromise between rejection and sensitivity
{0x0500, 0x9990, 0x9009, 0x31A9},
// OPEN (BRAVO test profile) - Medium-wide IF filter (REG54 bits[14:8]=8, bits[7:0]=70), high IF gain (REG55 bits[11:8]=8, ref=192)
// Wide and pleasant, better sensitivity on weak signals, may struggle with adjacent channel interference
{0x0300, 0x9990, 0x8846, 0x38C0}
};
if (profile >= ARRAY_SIZE(am_profiles))
profile = 0;
BK4819_WriteRegister(0x2b, am_profiles[profile][0]);
BK4819_WriteRegister(0x2f, am_profiles[profile][1]);
BK4819_WriteRegister(0x54, am_profiles[profile][2]);
BK4819_WriteRegister(0x55, am_profiles[profile][3]);
}
static void AUDIO_ApplyUSBProfile(void)
{
switch (profile)
{
default:
case 0: // FLAT
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x3200);
break;
case 1: // CLEAN
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x33A9);
break;
case 2: // MID
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x3600);
break;
case 3: // BOOST
BK4819_WriteRegister(0x54, 0x8546);
BK4819_WriteRegister(0x55, 0x3AF0);
break;
case 4: // MAX
BK4819_WriteRegister(0x54, 0x8566);
BK4819_WriteRegister(0x55, 0x3D00);
break;
}
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31A9);
}
#endif
@@ -102,28 +133,30 @@ bool RADIO_CheckValidList(uint8_t scanList)
return false;
}
void RADIO_NextValidList(void)
void RADIO_NextValidList(int8_t direction)
{
uint8_t startList = gEeprom.SCAN_LIST_DEFAULT;
uint8_t attempts = 0;
const uint8_t MAX_LISTS = MR_CHANNELS_LIST + 2; // 1-25, includes ALL
const uint8_t MAX_VALUE = MR_CHANNELS_LIST + 1; // 25 (1-24 lists + ALL)
do {
// Move to next scan list, wrapping around from 25 to 1
gEeprom.SCAN_LIST_DEFAULT = ((gEeprom.SCAN_LIST_DEFAULT + 1) % MAX_LISTS) ?: 1;
if (direction > 0) {
// Forward: 1 → 2 → ... → 25 → 1
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT % MAX_VALUE) + 1;
} else {
// Backward: 25 → 24 → ... → 1 → 25
gEeprom.SCAN_LIST_DEFAULT = ((gEeprom.SCAN_LIST_DEFAULT - 2 + MAX_VALUE) % MAX_VALUE) + 1;
}
attempts++;
// Check if current list has valid channels
if (RADIO_CheckValidList(gEeprom.SCAN_LIST_DEFAULT))
return;
// Stop if we've cycled through all lists or made too many attempts
} while (gEeprom.SCAN_LIST_DEFAULT != startList && attempts < MAX_LISTS);
} while (gEeprom.SCAN_LIST_DEFAULT != startList && attempts < MAX_VALUE);
// Safety fallback: if no valid list found, switch to ALL mode
// This prevents infinite loops and ensures scanning can continue
// Safety fallback: switch to ALL mode
if (!RADIO_CheckValidList(gEeprom.SCAN_LIST_DEFAULT)) {
gEeprom.SCAN_LIST_DEFAULT = MR_CHANNELS_LIST + 1; // ALL
gEeprom.SCAN_LIST_DEFAULT = MAX_VALUE; // ALL (25)
}
}
@@ -138,7 +171,7 @@ bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanL
return false;
if (att->band > BAND7_470MHz)
return false;
if (!checkScanList || (scanList > MR_CHANNELS_LIST && att->scanlist != 0))
if (!checkScanList || (scanList > MR_CHANNELS_LIST && att->scanlist != 0) || (scanList > 0 && att->scanlist == MR_CHANNELS_LIST + 1))
return true;
if ((scanList == 0) || (scanList != att->scanlist)) {
return false;
@@ -200,6 +233,24 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint16_t ChannelSave, const uint32_
RADIO_ConfigureSquelchAndOutputPower(pInfo);
}
void RADIO_ValidateAndSetCode(FREQ_Config_t *pFreq_Config, uint8_t tmp) {
switch (pFreq_Config->CodeType) {
default:
case CODE_TYPE_OFF:
pFreq_Config->CodeType = CODE_TYPE_OFF;
tmp = 0;
break;
case CODE_TYPE_CONTINUOUS_TONE:
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
if (tmp > ((pFreq_Config->CodeType == CODE_TYPE_CONTINUOUS_TONE ? ARRAY_SIZE(CTCSS_Options) : ARRAY_SIZE(DCS_Options)) - 1))
tmp = 0;
break;
}
pFreq_Config->Code = tmp;
}
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure)
{
VFO_Info_t *pVfo = &gEeprom.VfoInfo[VFO];
@@ -273,7 +324,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
}
pVfo->Band = band;
pVfo->SCANLIST_PARTICIPATION = bParticipation;
pVfo->SCANLIST_PARTICIPATION = bParticipation;
pVfo->CHANNEL_SAVE = channel;
uint32_t base;
@@ -318,49 +369,8 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
pVfo->freq_config_RX.CodeType = (data[2] >> 0) & 0x0F;
pVfo->freq_config_TX.CodeType = (data[2] >> 4) & 0x0F;
tmp = data[0];
switch (pVfo->freq_config_RX.CodeType)
{
default:
case CODE_TYPE_OFF:
pVfo->freq_config_RX.CodeType = CODE_TYPE_OFF;
tmp = 0;
break;
case CODE_TYPE_CONTINUOUS_TONE:
if (tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
tmp = 0;
break;
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
if (tmp > (ARRAY_SIZE(DCS_Options) - 1))
tmp = 0;
break;
}
pVfo->freq_config_RX.Code = tmp;
tmp = data[1];
switch (pVfo->freq_config_TX.CodeType)
{
default:
case CODE_TYPE_OFF:
pVfo->freq_config_TX.CodeType = CODE_TYPE_OFF;
tmp = 0;
break;
case CODE_TYPE_CONTINUOUS_TONE:
if (tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
tmp = 0;
break;
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
if (tmp > (ARRAY_SIZE(DCS_Options) - 1))
tmp = 0;
break;
}
pVfo->freq_config_TX.Code = tmp;
RADIO_ValidateAndSetCode(&pVfo->freq_config_RX, data[0]);
RADIO_ValidateAndSetCode(&pVfo->freq_config_TX, data[1]);
if (data[4] == 0xFF)
{
@@ -572,30 +582,15 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
uint8_t Op = 0; // Low eeprom calibration data
uint8_t currentPower = pInfo->OUTPUT_POWER;
if(currentPower == OUTPUT_POWER_USER)
{
if(gSetting_set_pwr == 5)
{
Op = 1; // Mid eeprom calibration data
}
else if(gSetting_set_pwr == 6)
{
Op = 2; // High eeprom calibration data
}
if (currentPower == OUTPUT_POWER_USER)
currentPower = gSetting_set_pwr;
}
else
{
if (currentPower == OUTPUT_POWER_MID)
{
Op = 1; // Mid eeprom calibration data
}
else if(currentPower == OUTPUT_POWER_HIGH)
{
Op = 2; // High eeprom calibration data
}
currentPower--;
}
if (currentPower == 5)
Op = 1; // Mid eeprom calibration data
else if (currentPower == 6)
Op = 2; // High eeprom calibration data
PY25Q16_ReadBuffer(0x100D0 + (Band * 16) + (Op * 3), Txp, 3);
@@ -738,6 +733,12 @@ void RADIO_SelectVfos(void)
RADIO_SelectCurrentVfo();
}
BK4819_FilterBandwidth_t RADIO_GetAMFilterBandwidth(const VFO_Info_t *pVfo)
{
// On BK4829, AM "wide" intentionally reuses the wider RF filter preset.
return (pVfo->CHANNEL_BANDWIDTH == BANDWIDTH_WIDE) ? BK4819_FILTER_BW_WIDE : BK4819_FILTER_BW_AM;
}
void RADIO_SetupRegisters(bool switchToForeground)
{
BK4819_FilterBandwidth_t Bandwidth = gRxVfo->CHANNEL_BANDWIDTH;
@@ -756,7 +757,7 @@ void RADIO_SetupRegisters(bool switchToForeground)
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false);
if (gRxVfo->Modulation == MODULATION_AM)
BK4819_SetFilterBandwidth(BK4819_FILTER_BW_AM, true);
BK4819_SetFilterBandwidth(RADIO_GetAMFilterBandwidth(gRxVfo), true);
else
{
switch (Bandwidth)
@@ -794,8 +795,8 @@ void RADIO_SetupRegisters(bool switchToForeground)
}
BK4819_WriteRegister(BK4819_REG_3F, 0);
// mic gain 0.5dB/step 0 to 31
BK4819_WriteRegister(BK4819_REG_7D, 0xE940 | (gEeprom.MIC_SENSITIVITY_TUNING & 0x1f));
// mic gain 0.5dB/step 0 to 63
BK4819_WriteRegister(BK4819_REG_7D, 0xE940 | (gEeprom.MIC_SENSITIVITY_TUNING & 0x3f));
uint32_t Frequency;
#ifdef ENABLE_NOAA
@@ -820,12 +821,7 @@ void RADIO_SetupRegisters(bool switchToForeground)
// AF RX Gain and DAC
//BK4819_WriteRegister(BK4819_REG_48, 0xB3A8); // 1011 00 111010 1000
BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
( 0u << 10) | // AF Rx Gain-1
(gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
BK4819_SetRxAudioGain();
uint16_t InterruptMask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
@@ -924,8 +920,8 @@ void RADIO_SetupRegisters(bool switchToForeground)
BK4819_EnableDTMF();
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
//RADIO_SetupAGC(gRxVfo->Modulation == MODULATION_AM, false);
RADIO_SetupAGC(false, false);
RADIO_SetupAGC(gRxVfo->Modulation == MODULATION_AM, false);
//RADIO_SetupAGC(false, false);
// enable/disable BK4819 selected interrupts
BK4819_WriteRegister(BK4819_REG_3F, InterruptMask);
@@ -1054,6 +1050,30 @@ void RADIO_SetTxParameters(void)
void RADIO_SetModulation(ModulationMode_t modulation)
{
#ifdef ENABLE_BYP_RAW_DEMODULATORS
if (modulation == MODULATION_BYP || modulation == MODULATION_RAW) {
uint16_t reg_3d_val = 0x0000;
if (modulation == MODULATION_BYP) {
// BYP on BK4829 uses full audio bypass profile.
BK4819_EnterBypass();
reg_3d_val = 0x2AAB;
} else {
// RAW on BK4829 uses RX-only filter bypass profile.
BK4819_EnterRaw();
// reg_3d_val = 0x0000;
}
BK4819_SetRegValue(afDacGainRegSpec, 0xF);
BK4819_WriteRegister(BK4819_REG_3D, reg_3d_val);
RADIO_SetupAGC(false, false);
return;
}
// Ensure we always leave bypass / raw mode before applying normal modulation settings.
BK4819_ExitBypass();
#endif
BK4819_AF_Type_t mod;
switch(modulation) {
default:
@@ -1067,93 +1087,87 @@ void RADIO_SetModulation(ModulationMode_t modulation)
mod = BK4819_AF_BASEBAND2;
break;
#ifdef ENABLE_BYP_RAW_DEMODULATORS
case MODULATION_BYP:
mod = BK4819_AF_UNKNOWN3;
break;
case MODULATION_RAW:
mod = BK4819_AF_BASEBAND1;
break;
#endif
}
BK4819_SetAF(mod);
// HACK, FIXME:
//
// What follows is a direct copy of the AM enable/disable code from
// the original UV-K1 firmware. It is not clear why these specific register
// values are used for AM all of a sudden instead of the AF setting like on
// the BK4819, nor what exactly they do.
// So for now we just keep it as is to maintain compatibility.
//
if (modulation != MODULATION_AM)
{
uint16_t uVar1 = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31,uVar1 & 0xfffffffe);
BK4819_WriteRegister(0x42,0x6b5a);
BK4819_WriteRegister(0x2a,0x7400);
BK4819_WriteRegister(0x2b,0);
BK4819_WriteRegister(0x2f,0x9890);
//BK4819_WriteRegister(0x54, 0x9009);
//BK4819_WriteRegister(0x55, 0x31a9);
#ifdef ENABLE_FEAT_F4HWN_AUDIO
AUDIO_ApplyProfile(gSetting_set_audio);
#else
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31a9);
#endif
}
else
{
uint16_t uVar1 = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31,uVar1 | 1);
BK4819_WriteRegister(0x42,0x6f5c);
BK4819_WriteRegister(0x2a,0x7434);
BK4819_WriteRegister(0x2b,0x300);
BK4819_WriteRegister(0x2f,0x9990);
//BK4819_WriteRegister(0x54, 0x9775);
//BK4819_WriteRegister(0x55, 0x32c6);
BK4819_WriteRegister(0x54, 0x8846);
BK4819_WriteRegister(0x55, 0x38C0);
switch (modulation)
{
case MODULATION_AM:
{
uint16_t uVar1 = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31, uVar1 | 1); // AM Demodulation Enable
BK4819_WriteRegister(0x42, 0x6f5c);
BK4819_WriteRegister(0x2a, 0x7434);
BK4819_SetFilterBandwidth(BK4819_FILTER_BW_AM, true);
#ifdef ENABLE_FEAT_F4HWN_AUDIO
AUDIO_ApplyAMProfile(gSetting_set_audio_am);
#else
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31a9);
#endif
BK4819_SetFilterBandwidth(RADIO_GetAMFilterBandwidth(gCurrentVfo), true);
break;
}
case MODULATION_USB:
case MODULATION_FM:
default:
{
uint16_t uVar1 = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31, uVar1 & 0xfffe); // AM Demodulation Disable
BK4819_WriteRegister(0x42, 0x6b5a);
BK4819_WriteRegister(0x2a, 0x7400);
BK4819_WriteRegister(0x2b, 0x0000);
BK4819_WriteRegister(0x2f, 0x9890);
#ifdef ENABLE_FEAT_F4HWN_AUDIO
if (modulation == MODULATION_USB)
AUDIO_ApplyUSBProfile();
else
AUDIO_ApplyFMProfile(gSetting_set_audio_fm);
#else
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31a9);
#endif
break;
}
}
BK4819_SetRegValue(afDacGainRegSpec, 0xF);
BK4819_WriteRegister(BK4819_REG_3D, modulation == MODULATION_USB ? 0 : 0x2AAB);
BK4819_SetRegValue(afcDisableRegSpec, modulation != MODULATION_FM);
//RADIO_SetupAGC(modulation == MODULATION_AM, false);
RADIO_SetupAGC(false, false);
RADIO_SetupAGC(modulation == MODULATION_AM, false);
}
void RADIO_SetupAGC(bool listeningAM, bool disable)
{
static uint8_t lastSettings;
static uint8_t lastSettings = 0xFF;
uint8_t newSettings = (listeningAM << 1) | disable;
if(lastSettings == newSettings)
if (lastSettings == newSettings)
return;
lastSettings = newSettings;
if(!listeningAM) { // if not actively listening AM we don't need any AM specific regulation
BK4819_SetAGC(!disable);
BK4819_InitAGC(false);
}
else {
#ifdef ENABLE_AM_FIX
if(gSetting_AM_fix) { // if AM fix active lock AGC so AM-fix can do it's job
BK4819_SetAGC(0);
AM_fix_enable(!disable);
}
else
#endif
{
BK4819_SetAGC(!disable);
BK4819_InitAGC(true);
}
if (listeningAM && gSetting_AM_fix) {
BK4819_SetAGC(0);
AM_fix_enable(!disable);
return;
}
#endif
BK4819_SetAGC(!disable);
BK4819_InitAGC(listeningAM);
}
void RADIO_SetVfoState(VfoState_t State)
@@ -1227,6 +1241,12 @@ void RADIO_PrepareTX(void)
// over voltage .. this is being a pain
State = VFO_STATE_VOLTAGE_HIGH;
}
#ifdef ENABLE_BYP_RAW_DEMODULATORS
else if (gCurrentVfo->Modulation == MODULATION_BYP || gCurrentVfo->Modulation == MODULATION_RAW) {
// BYP/RAW are receive-only modes.
State = VFO_STATE_TX_DISABLE;
}
#endif
#ifndef ENABLE_TX_WHEN_AM
else if (gCurrentVfo->Modulation != MODULATION_FM) {
// not allowed to TX if in AM mode
@@ -1306,17 +1326,19 @@ void RADIO_PrepareTX(void)
void RADIO_SendCssTail(void)
{
switch (gCurrentVfo->pTX->CodeType) {
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
BK4819_PlayCDCSSTail();
break;
default:
BK4819_PlayCTCSSTail();
break;
}
if (gEeprom.TAIL_TONE_ELIMINATION) {
switch (gCurrentVfo->pTX->CodeType) {
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
BK4819_PlayCDCSSTail();
break;
default:
BK4819_PlayCTCSSTail();
break;
}
SYSTEM_DelayMs(200);
SYSTEM_DelayMs(200);
}
}
void RADIO_SendEndOfTransmission(void)
@@ -1325,8 +1347,7 @@ void RADIO_SendEndOfTransmission(void)
DTMF_SendEndOfTransmission();
// send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
if(gEeprom.TAIL_TONE_ELIMINATION)
RADIO_SendCssTail();
RADIO_SendCssTail();
RADIO_SetupRegisters(false);
}
@@ -1336,7 +1357,6 @@ void RADIO_PrepareCssTX(void)
SYSTEM_DelayMs(200);
if(gEeprom.TAIL_TONE_ELIMINATION)
RADIO_SendCssTail();
RADIO_SendCssTail();
RADIO_SetupRegisters(true);
}
+3 -1
View File
@@ -21,6 +21,7 @@
#include <stdint.h>
#include "dcs.h"
#include "driver/bk4819.h"
#include "frequencies.h"
enum {
@@ -149,7 +150,7 @@ extern DCS_CodeType_t gCurrentCodeType;
extern VfoState_t VfoState[2];
bool RADIO_CheckValidList(uint8_t scanList);
void RADIO_NextValidList(void);
void RADIO_NextValidList(int8_t direction);
bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanList);
uint16_t RADIO_FindNextChannel(uint16_t ChNum, int8_t Direction, bool bCheckScanList, uint8_t RadioNum);
void RADIO_InitInfo(VFO_Info_t *pInfo, const uint16_t ChannelSave, const uint32_t Frequency);
@@ -161,6 +162,7 @@ void RADIO_SetupRegisters(bool switchToForeground);
#ifdef ENABLE_NOAA
void RADIO_ConfigureNOAA(void);
#endif
BK4819_FilterBandwidth_t RADIO_GetAMFilterBandwidth(const VFO_Info_t *pVfo);
void RADIO_SetTxParameters(void);
void RADIO_SetupAGC(bool listeningAM, bool disable);
void RADIO_SetModulation(ModulationMode_t modulation);
+60 -48
View File
@@ -19,8 +19,31 @@
#include "screenshot.h"
#include "misc.h"
#include "driver/vcp.h"
#include "driver/keyboard.h"
static void Screenshot_Send(const uint8_t *buf, uint16_t len)
// SRAM optimization: minimize static allocations
// - previousFrame: 1024 bytes (REQUIRED - need to compare for delta)
// - No currentFrame or deltaFrame static buffers
static uint8_t previousFrame[1024] = {0};
static uint8_t forcedBlock = 0;
static uint8_t keepAlive = 3;
void SCREENSHOT_ParseInput(void)
{
if (SCREENSHOT_IsLocked())
return;
if (UART_IsCableConnected()) {
keepAlive = 15;
gUSB_ScreenshotEnabled = false;
}
else if (VCP_ScreenshotPing()) {
keepAlive = 15;
gUSB_ScreenshotEnabled = true;
}
}
static void SCREENSHOT_Send(const uint8_t *buf, uint16_t len)
{
if (gUSB_ScreenshotEnabled) {
cdc_acm_data_send_with_dtr(buf, len);
@@ -29,14 +52,19 @@ static void Screenshot_Send(const uint8_t *buf, uint16_t len)
}
}
// SRAM optimization: minimize static allocations
// - previousFrame: 1024 bytes (REQUIRED - need to compare for delta)
// - No currentFrame or deltaFrame static buffers
static uint8_t previousFrame[1024] = {0};
static uint8_t forcedBlock = 0;
static uint8_t keepAlive = 10;
void SCREENSHOT_Line(uint8_t *src, uint8_t *dest, uint16_t *idx) {
for (uint8_t b = 0; b < 8; b++) {
for (uint8_t i = 0; i < 128; i += 8) {
uint8_t acc = 0;
for (uint8_t k = 0; k < 8; k++) {
if (src[i + k] & (1 << b)) acc |= (1 << k);
}
dest[(*idx)++] = gSetting_set_inv ? ~acc : acc;
}
}
}
void getScreenShot(bool force)
void SCREENSHOT_Update(bool force)
{
// Build frame in a temporary stack buffer
// This is 1024 bytes but it's temporary and gets freed after the function
@@ -44,55 +72,34 @@ void getScreenShot(bool force)
uint16_t index = 0;
uint8_t acc = 0;
uint8_t bitCount = 0;
static bool wasConnected = false;
if (gUART_LockScreenshot > 0) {
gUART_LockScreenshot--;
if (SCREENSHOT_IsLocked())
return;
}
if (UART_IsCableConnected()) {
keepAlive = 10;
gUSB_ScreenshotEnabled = false;
}
if (VCP_ScreenshotPing()) {
keepAlive = 10;
gUSB_ScreenshotEnabled = true;
}
if (keepAlive > 0) {
if (--keepAlive == 0) return;
if (--keepAlive == 0) {
// Connection just lost → reset state for next reconnection
wasConnected = false;
return;
}
} else {
return;
}
// Connection is alive — detect reconnection and force full frame
if (!wasConnected) {
force = true;
wasConnected = true;
}
// ==== BUILD FRAME ONCE ====
// Status line: 8 bit layers × 128 columns
for (uint8_t b = 0; b < 8; b++) {
for (uint8_t i = 0; i < 128; i++) {
uint8_t bit = (gStatusLine[i] >> b) & 0x01;
acc |= (bit << bitCount++);
if (bitCount == 8) {
frameBuffer[index++] = acc;
acc = 0;
bitCount = 0;
}
}
}
SCREENSHOT_Line(gStatusLine, frameBuffer, &index);
// Frame buffer: 7 lines × 8 bit layers × 128 columns
for (uint8_t l = 0; l < 7; l++) {
for (uint8_t b = 0; b < 8; b++) {
for (uint8_t i = 0; i < 128; i++) {
uint8_t bit = (gFrameBuffer[l][i] >> b) & 0x01;
acc |= (bit << bitCount++);
if (bitCount == 8) {
frameBuffer[index++] = acc;
acc = 0;
bitCount = 0;
}
}
}
SCREENSHOT_Line(gFrameBuffer[l], frameBuffer, &index);
}
if (bitCount > 0)
@@ -125,11 +132,16 @@ void getScreenShot(bool force)
if (deltaLen == 0)
return;
// Skip transmission if a key is currently pressed
// UART_Send is blocking - would freeze the main loop and lose keypresses
if (gKeyReading0 != KEY_INVALID)
return;
// ==== Send version marker (for backward compatibility detection) ====
// New format: sends 0xFF before header
// Old format: doesn't exist, so viewers can differentiate
uint8_t versionMarker = 0xFF;
Screenshot_Send(&versionMarker, 1);
SCREENSHOT_Send(&versionMarker, 1);
// ==== Send header ====
uint8_t header[5] = {
@@ -138,7 +150,7 @@ void getScreenShot(bool force)
(uint8_t)(deltaLen & 0xFF)
};
Screenshot_Send(header, 5);
SCREENSHOT_Send(header, 5);
// ==== SECOND PASS: Send only changed chunks ====
uint8_t chunk[9];
@@ -151,12 +163,12 @@ void getScreenShot(bool force)
chunk[0] = chunkIdx;
memcpy(&chunk[1], cur, 8);
Screenshot_Send(chunk, 9);
SCREENSHOT_Send(chunk, 9);
// Update previousFrame for next comparison
memcpy(prev, cur, 8);
}
uint8_t end = 0x0A;
Screenshot_Send(&end, 1);
SCREENSHOT_Send(&end, 1);
}
+2 -1
View File
@@ -17,6 +17,7 @@
#ifndef SCREENSHOT_H
#define SCREENSHOT_H
void getScreenShot(bool force);
void SCREENSHOT_Update(bool force);
void SCREENSHOT_ParseInput(void);
#endif
+163 -60
View File
@@ -30,13 +30,116 @@
EEPROM_Config_t gEeprom = { 0 };
// Load a DTMF code from EEPROM, falling back to default_val if invalid.
static void SETTINGS_LoadEepromDtmf(uint32_t addr, char *dest, size_t size, const char *default_val)
{
uint8_t buf[16];
if (size > sizeof(buf))
size = sizeof(buf);
PY25Q16_ReadBuffer(addr, buf, size);
if (DTMF_ValidateCodes((char *)buf, size)) {
memcpy(dest, buf, size);
} else {
strcpy(dest, default_val);
}
}
void SETTINGS_InitEEPROM(void)
{
uint8_t Data[16] = {0};
//
// Version check
// Read stored version from EEPROM and compare with VERSION_STRING_2
//
{
char storedVersion[16] = {0};
PY25Q16_ReadBuffer(0x00A160, storedVersion, sizeof(storedVersion));
// Compare with current version
if (strncmp(storedVersion, VERSION_STRING_2, sizeof(storedVersion)) != 0)
{
// Different version: new install or firmware update
// 1. Write new version to EEPROM
char newVersion[16] = {0};
strncpy(newVersion, VERSION_STRING_2, sizeof(newVersion));
PY25Q16_WriteBuffer(0x00A160, newVersion, sizeof(newVersion), false);
// 2. Reset sensitive parameters (MENU_LOCK, etc.)
uint8_t configByte[8] = {0};
PY25Q16_ReadBuffer(0x00A000, configByte, sizeof(configByte));
configByte[4] &= (uint8_t)~0x01; // KEY_LOCK = 0
configByte[4] &= (uint8_t)~0x02; // MENU_LOCK = 0
configByte[4] &= (uint8_t)~0x3C; // SET_KEY = 0
//configByte[4] &= (uint8_t)~0x40; // SET_NAV = 0
PY25Q16_WriteBuffer(0x00A000, configByte, sizeof(configByte), false);
// 3. Reset display inversion (SET_INV = 0)
uint8_t displayByte[8] = {0};
PY25Q16_ReadBuffer(0x00A158, displayByte, sizeof(displayByte));
displayByte[5] &= (uint8_t)~0x10; // Clear bit 4 (SET_INV)
PY25Q16_WriteBuffer(0x00A158, displayByte, sizeof(displayByte), false);
// 4. Reset logo lines (clear to null for strlen() == 0)
char logoLines[32];
PY25Q16_ReadBuffer(0x00A0C8, logoLines, sizeof(logoLines));
bool needsWrite = false;
for (int line = 0; line < 2; line++) {
int offset = line * 16;
for (int i = 0; i < 16; i++) {
char c = logoLines[offset + i];
if (c == 0) {
break;
}
if (c < 0x20 || c > 0x7E) {
memset(logoLines + offset, 0, 16);
needsWrite = true;
break;
}
}
}
if (needsWrite) {
PY25Q16_WriteBuffer(0x00A0C8, logoLines, sizeof(logoLines), false);
}
// 5. Reset dBmCorrTable
int8_t buf[7];
PY25Q16_ReadBuffer(0x00A0B9, (uint8_t *)buf, 7);
needsWrite = true;
for (uint8_t i = 0; i < 7; i++) {
if ((uint8_t)buf[i] != 0xFF) {
needsWrite = false;
break;
}
}
if (needsWrite) {
for (uint8_t i = 0; i < 7; i++)
buf[i] = dBmCorrTable[i];
PY25Q16_WriteBuffer(0x00A0B9, buf, 7, false);
}
}
}
// 0E70..0E77
PY25Q16_ReadBuffer(0x00A000, Data, 8);
#ifdef ENABLE_FEAT_F4HWN_AUDIO
gSetting_set_audio = (Data[0] < 5) ? Data[0] : 0;
gSetting_set_audio_fm = ((Data[0] & 0x0F) < 5) ? (Data[0] & 0x0F) : 0;
gSetting_set_audio_am = (((Data[0] >> 4) & 0x0F) < 3) ? ((Data[0] >> 4) & 0x0F) : 0;
#endif
gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1;
gEeprom.TX_TIMEOUT_TIMER = (Data[2] > 4 && Data[2] < 180) ? Data[2] : 11;
@@ -55,7 +158,7 @@ void SETTINGS_InitEEPROM(void)
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;
gEeprom.MIC_SENSITIVITY = (Data[7] < 9) ? Data[7] : 4;
// 0E78..0E7F
PY25Q16_ReadBuffer(0x00A008, Data, 8);
@@ -132,9 +235,12 @@ gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data16[5]) ? Data16[5] : (FREQ_CHANNE
gEeprom.FM_Band = fmCfg.band;
//gEeprom.FM_Space = fmCfg.space;
uint16_t freqLoLimit = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
gEeprom.FM_SelectedFrequency =
(fmCfg.selFreq >= BK1080_GetFreqLoLimit(gEeprom.FM_Band) && fmCfg.selFreq <= BK1080_GetFreqHiLimit(gEeprom.FM_Band)) ?
fmCfg.selFreq : BK1080_GetFreqLoLimit(gEeprom.FM_Band);
(fmCfg.selFreq >= freqLoLimit && fmCfg.selFreq <= BK1080_GetFreqHiLimit(gEeprom.FM_Band)) ?
fmCfg.selFreq : freqLoLimit;
gEeprom.FM_SelectedChannel = fmCfg.selChn;
gEeprom.FM_IsMrMode = fmCfg.isMrMode;
@@ -173,13 +279,10 @@ gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data16[5]) ? Data16[5] : (FREQ_CHANNE
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;
for (uint8_t i = 0; i < 7; i++) {
int8_t val = (int8_t)Data[i + 1];
if (val >= -64 && val <= 64)
dBmCorrTable[i] = val;
}
#endif
@@ -211,51 +314,25 @@ gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data16[5]) ? Data16[5] : (FREQ_CHANNE
PY25Q16_ReadBuffer(0x00A0A8 + 0x48, 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
PY25Q16_ReadBuffer(0x00A0F8, 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");
}
SETTINGS_LoadEepromDtmf(0x00A0F8, gEeprom.ANI_DTMF_ID, sizeof(gEeprom.ANI_DTMF_ID), "123");
// 0EE8..0EEF
PY25Q16_ReadBuffer(0x00A0F8 + 0x8, 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");
}
SETTINGS_LoadEepromDtmf(0x00A0F8 + 0x08, gEeprom.KILL_CODE, sizeof(gEeprom.KILL_CODE), "ABCD9");
// 0EF0..0EF7
PY25Q16_ReadBuffer(0x00A0F8 + 0x10, 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");
}
SETTINGS_LoadEepromDtmf(0x00A0F8 + 0x10, gEeprom.REVIVE_CODE, sizeof(gEeprom.REVIVE_CODE), "9DCBA");
#endif
// 0EF8..0F07
PY25Q16_ReadBuffer(0x00A0F8 + 0x18, 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");
}
SETTINGS_LoadEepromDtmf(0x00A0F8 + 0x18, gEeprom.DTMF_UP_CODE, sizeof(gEeprom.DTMF_UP_CODE), "12345");
// 0F08..0F17
PY25Q16_ReadBuffer(0x00A0F8 + 0x28, 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");
}
SETTINGS_LoadEepromDtmf(0x00A0F8 + 0x28, gEeprom.DTMF_DOWN_CODE, sizeof(gEeprom.DTMF_DOWN_CODE), "54321");
// 0F18..0F1F
PY25Q16_ReadBuffer(0x00A130, Data, 8);
@@ -336,6 +413,9 @@ gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data16[5]) ? Data16[5] : (FREQ_CHANNE
}
*/
// Init list name
PY25Q16_ReadBuffer(0x00880E, gListName, sizeof(gListName));
// Init attr cache
MR_InitChannelAttributesCache();
@@ -532,15 +612,20 @@ void SETTINGS_FetchChannelName(char *s, const uint16_t channel)
void SETTINGS_FactoryReset(bool bIsAll)
{
PY25Q16_SectorErase(0x000000);
PY25Q16_SectorErase(0x001000);
PY25Q16_SectorErase(0x003000);
PY25Q16_SectorErase(0x004000);
PY25Q16_SectorErase(0x005000);
PY25Q16_SectorErase(0x006000);
PY25Q16_SectorErase(0x007000);
PY25Q16_SectorErase(0x008000);
PY25Q16_SectorErase(0x009000);
// PY25Q16_SectorErase(0x000000);
// PY25Q16_SectorErase(0x001000);
// PY25Q16_SectorErase(0x002000);
// PY25Q16_SectorErase(0x003000);
// PY25Q16_SectorErase(0x004000);
// PY25Q16_SectorErase(0x005000);
// PY25Q16_SectorErase(0x006000);
// PY25Q16_SectorErase(0x007000);
// PY25Q16_SectorErase(0x008000);
// PY25Q16_SectorErase(0x009000);
for (uint32_t addr = 0x000000; addr <= 0x009000; addr += 0x1000) {
PY25Q16_SectorErase(addr);
}
// 0d60 - 0e30
if (bIsAll)
@@ -558,6 +643,13 @@ void SETTINGS_FactoryReset(bool bIsAll)
Data8[4] &= (uint8_t)~0x01;
Data8[4] &= (uint8_t)~0x02;
// SET_KEY to 0
Data8[4] &= (uint8_t)~0x3C; // Clear bits 2-5 (SET_KEY)
// SET_NAV to false
Data8[4] &= (uint8_t)~0x40; // Clear bit 6 (SET_NAV) for UV-K1 by default
#ifdef ENABLE_FEAT_F4HWN_RESET_VFO
Data8[7] = (1 & 0x01);
#endif
@@ -580,9 +672,12 @@ void SETTINGS_FactoryReset(bool bIsAll)
gEeprom.FreqChannel[0] = FREQ_CHANNEL_FIRST + BAND3_137MHz;
gEeprom.FreqChannel[1] = FREQ_CHANNEL_FIRST + BAND6_400MHz;
SETTINGS_SaveVfoIndices();
SETTINGS_SaveChannel(FREQ_CHANNEL_FIRST + BAND3_137MHz, 0, &gEeprom.VfoInfo[0], 2);
SETTINGS_SaveChannel(FREQ_CHANNEL_FIRST + BAND6_400MHz, 1, &gEeprom.VfoInfo[1], 2);
gVfoStateChanged = true;
gScheduleVfoSave = true;
SETTINGS_SaveVfoIndicesFlush();
#endif
}
@@ -664,9 +759,14 @@ void SETTINGS_SaveSettings(void)
// 0x0E70
State = SecBuf;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
State[0] = gSetting_set_audio;
State[0] = (gSetting_set_audio_fm & 0x0F) | ((gSetting_set_audio_am & 0x0F) << 4);
#endif
State[1] = gEeprom.SQUELCH_LEVEL;
#ifdef ENABLE_FEAT_F4HWN
if (gSquelchLevelOriginal < 10)
State[1] = gSquelchLevelOriginal;
else
#endif
State[1] = gEeprom.SQUELCH_LEVEL;
State[2] = gEeprom.TX_TIMEOUT_TIMER;
#ifdef ENABLE_NOAA
State[3] = gEeprom.NOAA_AUTO_SCAN;
@@ -1028,7 +1128,7 @@ void SETTINGS_UpdateChannel(uint16_t channel, const VFO_Info_t *pVFO, bool keep,
}; // default attributes
// 0x0D60
PY25Q16_ReadBuffer(0x008000 + channel, &state, 1);
PY25Q16_ReadBuffer(0x008000 + (channel * 2), &state, 2);
if (keep) {
att.band = pVFO->Band;
@@ -1176,12 +1276,12 @@ void SETTINGS_ResetTxLock(void)
// This is an expensive operation: full scan of all MR channels
#define CHANNEL_SIZE 16
#define TXLOCK_BYTE_OFFSET 4
#define TXLOCK_BYTE_OFFSET 12
#define TXLOCK_BIT 6
#define SETTINGS_ResetTxLock_BATCH 16
#define SETTINGS_ResetTxLock_BATCH 32
const uint32_t TotalBytes = MR_CHANNELS_MAX * CHANNEL_SIZE; // 512 * 16 = 8192
const uint32_t BatchSize = TotalBytes / SETTINGS_ResetTxLock_BATCH; // 8192 / 16 = 512
const uint32_t TotalBytes = MR_CHANNELS_MAX * CHANNEL_SIZE; // 1024 * 16 = 16 384
const uint32_t BatchSize = TotalBytes / SETTINGS_ResetTxLock_BATCH; // 16 384 / 32 = 512
const uint32_t BatchChCnt = BatchSize / CHANNEL_SIZE; // 32 channels per batch
uint8_t Buf[BatchSize];
@@ -1201,6 +1301,9 @@ void SETTINGS_ResetTxLock(void)
PY25Q16_WriteBuffer(Offset, Buf, BatchSize, false);
}
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
#undef SETTINGS_ResetTxLock_BATCH
#undef CHANNEL_SIZE
#undef TXLOCK_BYTE_OFFSET
+1 -3
View File
@@ -118,9 +118,7 @@ enum ACTION_OPT_t {
ACTION_OPT_WN,
ACTION_OPT_BACKLIGHT,
ACTION_OPT_MUTE,
#ifdef ENABLE_FEAT_F4HWN_AUDIO
ACTION_OPT_RXA,
#endif
ACTION_OPT_RXA,
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
ACTION_OPT_POWER_HIGH,
ACTION_OPT_REMOVE_OFFSET,
+4
View File
@@ -35,6 +35,10 @@ void UI_DisplayFM(void)
char *pPrintStr = String;
UI_DisplayClear();
#ifdef ENABLE_FEAT_F4HWN
UI_DisplayUnlockKeyboard(5);
#endif
UI_PrintString("FM", 2, 0, 0, 8);
sprintf(String, "%d%s-%dM",
+38 -37
View File
@@ -22,10 +22,8 @@
#include "ui/helper.h"
#include "ui/inputbox.h"
#include "misc.h"
#include "settings.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
#endif
void UI_GenerateChannelString(char *pString, const uint16_t Channel)
{
@@ -47,23 +45,23 @@ void UI_GenerateChannelString(char *pString, const uint16_t Channel)
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint16_t ChannelNumber)
{
if (gInputBoxIndex > 0) {
for (unsigned int i = 0; i < 3; i++) {
for (unsigned int i = 0; i < 4; i++) {
pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
}
pString[3] = 0;
pString[4] = 0;
return;
}
if (bShowPrefix) {
// BUG here? Prefixed NULLs are allowed
sprintf(pString, "CH-%03u", ChannelNumber + 1);
sprintf(pString, "CH-%04u", ChannelNumber + 1);
} else if (ChannelNumber == MR_CHANNEL_LAST + 1) {
strcpy(pString, "None");
} else if (ChannelNumber == 0xFFFF) {
strcpy(pString, "NULL");
} else {
sprintf(pString, "%03u", ChannelNumber + 1);
sprintf(pString, "%04u", ChannelNumber + 1);
}
}
@@ -133,17 +131,17 @@ void UI_PrintStringSmallNormalInverse(const char *pString, uint8_t Start, uint8_
if (End != 0 && x_end > End)
x_end = End;
gFrameBuffer[Line][x_start - 3] ^= 0x3E;
gFrameBuffer[Line][x_start - 2] ^= 0x7F;
gFrameBuffer[Line][x_start - 1] ^= 0xFF;
//gFrameBuffer[Line][x_start - 2] ^= 0x3E;
gFrameBuffer[Line][x_start - 1] ^= 0x7F;
//gFrameBuffer[Line][x_start - 1] ^= 0xFF;
for (uint8_t x = x_start; x < x_end; x++)
{
gFrameBuffer[Line][x] ^= 0xFF;
gFrameBuffer[Line - 1][x] ^= 0x80;
}
gFrameBuffer[Line][x_end + 0] ^= 0xFF;
gFrameBuffer[Line][x_end + 1] ^= 0x7F;
gFrameBuffer[Line][x_end + 2] ^= 0x3E;
//gFrameBuffer[Line][x_end + 0] ^= 0xFF;
gFrameBuffer[Line][x_end + 0] ^= 0x7F;
//gFrameBuffer[Line][x_end + 1] ^= 0x3E;
}
@@ -160,30 +158,6 @@ void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, ui
UI_PrintStringSmall(pString, Start, End, Line, char_width, font);
}
void UI_PrintStringSmallBoldInverse(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
{
// First draw the string normally
UI_PrintStringSmallBold(pString, Start, End, Line);
// Now invert the framebuffer bits for the rendered area
uint8_t len = strlen(pString);
uint8_t char_width = 7; // small font is typically 6px wide
uint8_t x_start = Start;
uint8_t x_end = Start + (len * char_width);
if (End != 0 && x_end > End)
x_end = End;
gFrameBuffer[Line][x_start] ^= 0x7F;
for (uint8_t x = x_start + 1; x < x_end; x++)
{
gFrameBuffer[Line][x] ^= 0x41;
}
gFrameBuffer[Line][x_end + 1] ^= 0x7F;
}
void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t * buffer)
{
UI_PrintStringBuffer(pString, buffer, ARRAY_SIZE(gFontSmall[0]), (uint8_t *)gFontSmall);
@@ -348,6 +322,33 @@ static void sort(int16_t *a, int16_t *b)
x += 4;
}
}
void UI_DisplayUnlockKeyboard(uint8_t shift) {
if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
{ // tell user how to unlock the keyboard
//memcpy(gFrameBuffer[shift] + 2, gFontKeyLock, sizeof(gFontKeyLock));
UI_PrintStringSmallBold("UNLOCK KEYBOARD", 12, 0, shift);
//memcpy(gFrameBuffer[shift] + 120, gFontKeyLock, sizeof(gFontKeyLock));
/*
for (uint8_t i = 12; i < 116; i++)
{
gFrameBuffer[shift][i] ^= 0xFF;
}
*/
}
}
bool IsEmptyName(const char *name, uint8_t len) {
if (name[0] == '\0' || name[0] == '\xff')
return true;
for (uint8_t i = 0; i < len; i++) {
if (name[i] != ' ' && name[i] != '\xff' && name[i] != '\0')
return false;
}
return true;
}
#endif
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
+2 -1
View File
@@ -26,7 +26,6 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin
void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
void UI_PrintStringSmallNormalInverse(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_PrintStringSmallBoldInverse(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);
@@ -39,6 +38,8 @@ void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black
void PutPixel(uint8_t x, uint8_t y, bool fill);
void PutPixelStatus(uint8_t x, uint8_t y, bool fill);
void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, bool statusbar, bool fill);
void UI_DisplayUnlockKeyboard(uint8_t shift);
bool IsEmptyName(const char *name, uint8_t len);
#endif
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);
+15
View File
@@ -41,4 +41,19 @@ const char* INPUTBOX_GetAscii()
inputBoxAscii[i] = (c==10)? '-' : '0' + c;
}
return inputBoxAscii;
}
const char* INPUTBOX_GetAsciiAlignRight() {
int targetPos = 7;
for (int i = 7; i >= 0; i--) {
if (gInputBox[i] != 10) {
inputBoxAscii[targetPos--] = '0' + gInputBox[i];
}
}
while(targetPos >= 0)
inputBoxAscii[targetPos--] = '-';
return inputBoxAscii;
}
+2
View File
@@ -25,7 +25,9 @@ extern char gInputBox[8];
extern uint8_t gInputBoxIndex;
void INPUTBOX_Append(const KEY_Code_t Digit);
const char* INPUTBOX_GetAscii();
const char* INPUTBOX_GetAsciiAlignRight();
#endif
+804 -161
View File
File diff suppressed because it is too large. Load diff
+15 -1
View File
@@ -17,10 +17,14 @@
#ifndef UI_MAIN_H
#define UI_MAIN_H
#include <stdint.h>
enum center_line_t {
CENTER_LINE_NONE = 0,
CENTER_LINE_IN_USE,
CENTER_LINE_SCAN_PROGRESS,
CENTER_LINE_AUDIO_BAR,
CENTER_LINE_AUDIO_SCOPE,
CENTER_LINE_RSSI,
CENTER_LINE_AM_FIX_DATA,
CENTER_LINE_DTMF_DEC,
@@ -36,12 +40,22 @@ enum Vfo_txtr_mode{
typedef enum center_line_t center_line_t;
extern center_line_t center_line;
extern const int8_t dBmCorrTable[7];
#ifdef ENABLE_AUDIO_BAR
void UI_DisplayAudioBar(void);
#endif
#ifdef ENABLE_FEAT_F4HWN_AUDIO_SCOPE
void UI_DisplayAudioScope(void);
#endif
void UI_MAIN_TimeSlice500ms(void);
void UI_DisplayMain(void);
#ifdef ENABLE_FEAT_F4HWN_SCAN_PROGRESS
void UI_MAIN_NotifyScanProgressDataChanged(void);
#else
static inline void UI_MAIN_NotifyScanProgressDataChanged(void) {}
#endif
#ifdef ENABLE_AGC_SHOW_DATA
void UI_MAIN_PrintAGC(bool force);
#endif
+233 -55
View File
@@ -27,6 +27,7 @@
#include "../driver/eeprom.h"
#include "../driver/st7565.h"
#include "../external/printf/printf.h"
#include "../font.h"
#include "../frequencies.h"
#include "../helper/battery.h"
#include "../misc.h"
@@ -40,6 +41,7 @@
#include "inputbox.h"
#include "menu.h"
#include "ui.h"
#include "welcome.h"
const t_menu_item MenuList[] =
@@ -413,7 +415,7 @@ const char gSubMenu_SCRAMBLER[][7] =
};
#ifdef ENABLE_FEAT_F4HWN_AUDIO
const char gSubMenu_SET_AUD[][6] =
const char gSubMenu_SET_AUD_FM[][6] =
{
"FLAT",
"CLEAN",
@@ -421,6 +423,13 @@ const char gSubMenu_SCRAMBLER[][7] =
"BOOST",
"MAX"
};
const char gSubMenu_SET_AUD_AM[][6] =
{
"SHARP",
"STOCK",
"OPEN"
};
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
@@ -516,6 +525,64 @@ int32_t gSubMenuSelection;
char edit_original[17]; // a copy of the text before editing so that we can easily test for changes/difference
char edit[17];
int edit_index;
bool edit_is_uppercase = false;
static void UI_MENU_DrawTopRightRoundedBadge(const char *text, const uint8_t line, const bool center_in_area, const uint8_t area_x1, const uint8_t area_x2)
{
const size_t length = strlen(text);
const size_t char_pitch = ARRAY_SIZE(gFontSmall[0]) + 1u;
const size_t text_width = length * char_pitch;
const size_t capsule_span = text_width + 1u; // matches UI_PrintStringSmallNormalInverse x_end computation
uint8_t text_x;
if (length == 0 || line == 0 || line >= FRAME_LINES) {
return;
}
if (center_in_area && area_x2 > area_x1 + 2u) {
const uint8_t min_x = area_x1 + 1u;
uint8_t max_x;
const uint8_t area_width = area_x2 - area_x1 + 1u;
if (capsule_span >= area_width) {
text_x = min_x;
} else {
text_x = (uint8_t)(area_x1 + ((area_width - capsule_span) / 2u));
}
if (area_x2 > capsule_span) {
max_x = (uint8_t)(area_x2 - capsule_span);
} else {
max_x = min_x;
}
if (max_x < min_x) {
max_x = min_x;
}
if (text_x < min_x) {
text_x = min_x;
} else if (text_x > max_x) {
text_x = max_x;
}
} else {
if (capsule_span >= (LCD_WIDTH - 3u)) {
text_x = 1u;
} else {
const uint8_t global_shift_right = 1u;
const uint8_t base_text_x = (uint8_t)(LCD_WIDTH - capsule_span - 3u);
const uint8_t max_text_x = (uint8_t)(LCD_WIDTH - capsule_span - 1u);
const uint16_t shifted_x = (uint16_t)base_text_x + global_shift_right;
if (shifted_x > max_text_x) {
text_x = max_text_x;
} else {
text_x = (uint8_t)shifted_x;
}
}
}
UI_PrintStringSmallNormalInverse(text, text_x, 0, line);
}
void UI_DisplayMenu(void)
{
@@ -524,6 +591,7 @@ void UI_DisplayMenu(void)
const unsigned int menu_item_x2 = LCD_WIDTH - 1;
unsigned int i;
char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char)
char top_right_badge[16];
#ifdef ENABLE_DTMF_CALLING
char Contact[16];
@@ -622,6 +690,7 @@ void UI_DisplayMenu(void)
// **************
memset(String, 0, sizeof(String));
memset(top_right_badge, 0, sizeof(top_right_badge));
bool already_printed = false;
@@ -646,7 +715,11 @@ void UI_DisplayMenu(void)
case MENU_MIC:
{ // display the mic gain in actual dB rather than just an index number
const uint8_t mic = gMicGain_dB2[gSubMenuSelection];
sprintf(String, "+%u.%01udB", mic / 2, mic % 2);
sprintf(String, "+%u.%udB", mic / 2, (mic % 2) * 5);
gaugeLine = 4;
gaugeMin = 0;
gaugeMax = 8;
}
break;
@@ -703,15 +776,14 @@ void UI_DisplayMenu(void)
if (!gIsInSubMenu || gInputBoxIndex == 0)
{
sprintf(String, "%3d.%05u", gSubMenuSelection / 100000, abs(gSubMenuSelection) % 100000);
UI_PrintString(String, menu_item_x1, menu_item_x2, 1, 8);
}
else
{
const char * ascii = INPUTBOX_GetAscii();
sprintf(String, "%.3s.%.3s ",ascii, ascii + 3);
UI_PrintString(String, menu_item_x1, menu_item_x2, 1, 8);
}
UI_PrintString(String, menu_item_x1, menu_item_x2, 1, 8);
UI_PrintString("MHz", menu_item_x1, menu_item_x2, 3, 8);
already_printed = true;
@@ -855,7 +927,7 @@ void UI_DisplayMenu(void)
{ // show the frequency so that the user knows the channels frequency
const uint32_t frequency = SETTINGS_FetchChannelFrequency(gSubMenuSelection);
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000);
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);
}
SETTINGS_FetchChannelName(String, gSubMenuSelection);
@@ -889,15 +961,34 @@ void UI_DisplayMenu(void)
{ // show the channel name being edited
//UI_PrintString(edit, menu_item_x1, 0, 2, 8);
UI_PrintString(edit, menu_item_x1, menu_item_x2, 2, 8);
if (edit_index < 10)
//UI_PrintString("^", menu_item_x1 + (8 * edit_index), 0, 4, 8); // show the cursor
UI_PrintString("^", menu_item_x1 - 1 + (8 * edit_index),0, 4, 8); // show the cursor
if (edit_index < 10) {
// UI_PrintString("^", menu_item_x1 - 1 + (8 * edit_index),0, 4, 8); // show the cursor
uint8_t x = menu_item_x1 - 1;
for (uint8_t i = 0; i < 10; i++)
{
if (i != edit_index)
{
if (edit[i] != 'g' && edit[i] != 'j')
{
UI_DrawLineBuffer(gFrameBuffer, x, 29, x + 6, 29, 1);
}
}
else
{
UI_DrawLineBuffer(gFrameBuffer, x + 2, 30, x + 4, 30, 1);
UI_DrawPixelBuffer(gFrameBuffer, x + 3, 29, 1);
}
x += 8;
}
UI_PrintStringSmallNormal(edit_is_uppercase ? "ABC" : "abc", 77, 0, 4);
}
}
if (!gAskForConfirmation)
{ // show the frequency so that the user knows the channels frequency
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000);
UI_PrintString(String, menu_item_x1, menu_item_x2, 4 + (gIsInSubMenu && edit_index >= 0), 8);
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);
}
}
@@ -965,21 +1056,22 @@ void UI_DisplayMenu(void)
break;
case MENU_LIST_CH:
if (gSubMenuSelection == MR_CHANNELS_LIST + 1)
strcpy(String, "ALL");
else if (gSubMenuSelection == 0)
strcpy(String, "OFF");
else
sprintf(String, "%u", gSubMenuSelection);
break;
case MENU_S_LIST:
if (gSubMenuSelection == MR_CHANNELS_LIST + 1)
strcpy(String, "ALL");
else
sprintf(String, "%u", gSubMenuSelection);
else if (gSubMenuSelection == 0 && UI_MENU_GetCurrentMenuId() == MENU_LIST_CH)
strcpy(String, "OFF");
else {
const char *name = gListName[gSubMenuSelection - 1];
// If first character is empty/invalid, display "N/A"
if (IsEmptyName(name, sizeof(gListName[0])))
sprintf(String, "%02u", gSubMenuSelection);
else
sprintf(String, "%02u (%.3s)", gSubMenuSelection, name);
}
break;
#ifdef ENABLE_ALARM
case MENU_AL_MOD:
sprintf(String, gSubMenu_AL_MOD[gSubMenuSelection]);
@@ -1038,18 +1130,98 @@ void UI_DisplayMenu(void)
strcpy(String, gSubMenu_ROGER[gSubMenuSelection]);
break;
case MENU_VOL:
case MENU_VOL: {
// SysInf is paginated. Pages appear in this order, only when their
// feature flag is enabled:
// 0 -> identity
// next -> Build date/time (ENABLE_FEAT_F4HWN)
// next -> Battery (ENABLE_FEAT_F4HWN)
// next -> Flash / SRAM usage (ENABLE_FEAT_F4HWN_MEM)
// next, +1 -> CODE / WIKI QR codes (ENABLE_FEAT_F4HWN_QRCODE)
// In non-F4HWN builds, page 0 keeps the old battery-voltage display.
const uint8_t page = (uint8_t)gSubMenuSelection;
uint8_t p = 0;
if (page == p++) {
// Page 0: firmware identity.
#ifdef ENABLE_FEAT_F4HWN
sprintf(String, "%s\n%s",
AUTHOR_STRING_2,
VERSION_STRING_2
);
sprintf(String, "%s\n%s", AUTHOR_STRING_2, VERSION_STRING_2);
UI_PrintStringSmallNormal(Edition, menu_item_x1 - 1, menu_item_x2, 6);
#else
sprintf(String, "%u.%02uV\n%u%%",
gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100,
BATTERY_VoltsToPercent(gBatteryVoltageAverage));
sprintf(String, "%u.%02uV\n%u%%",
gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100,
BATTERY_VoltsToPercent(gBatteryVoltageAverage));
#endif
break;
}
#ifdef ENABLE_FEAT_F4HWN
if (page == p++) {
strcpy(top_right_badge, "BUILD");
UI_PrintStringSmallNormal(BuildDate, menu_item_x1 - 1, menu_item_x2, 3);
UI_PrintStringSmallNormal(BuildTime, menu_item_x1 - 1, menu_item_x2, 4);
UI_PrintStringSmallNormal(BuildCommit, menu_item_x1 - 1, menu_item_x2, 6);
already_printed = true;
break;
}
if (page == p++) {
char val[16];
strcpy(top_right_badge, "BATTERY");
sprintf(val, "%u.%02uV %u%%",
gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100,
BATTERY_VoltsToPercent(gBatteryVoltageAverage));
UI_PrintStringSmallNormal(val, menu_item_x1 - 1, menu_item_x2, 3);
UI_PrintStringSmallNormal(gSubMenu_BATTYP[gEeprom.BATTERY_TYPE], menu_item_x1 - 1, menu_item_x2, 5);
already_printed = true;
break;
}
#endif
#ifdef ENABLE_FEAT_F4HWN_MEM
if (page == p++) {
uint16_t flash_pct = 0;
uint16_t ram_pct = 0;
UI_GetMemPercents(&flash_pct, &ram_pct);
char val[16];
// MEMORY title capsule centered in right zone, fb line 1.
strcpy(top_right_badge, "MEMORY");
// Flash + SRAM values stacked below, normal small font, with a fb-line of breathing space.
sprintf(val, "FLASH %u.%u%%",
(unsigned)(flash_pct / 100), (unsigned)((flash_pct / 10) % 10));
UI_PrintStringSmallNormal(val, menu_item_x1 - 1, menu_item_x2, 3);
sprintf(val, "SRAM %u.%u%%",
(unsigned)(ram_pct / 100), (unsigned)((ram_pct / 10) % 10));
UI_PrintStringSmallNormal(val, menu_item_x1 - 1, menu_item_x2, 5);
already_printed = true;
break;
}
#endif
#ifdef ENABLE_FEAT_F4HWN_QRCODE
// Right zone: x=49..127 (79 px). QR centered at x=72..104.
// Capsule label above QR (small-font Inverse style at fb line 1).
if (page == p || page == p + 1) {
const bool is_wiki = (page == (p + 1));
strcpy(top_right_badge, is_wiki ? "WIKI" : "CODE");
UI_DrawQRCode(is_wiki, 72, 28);
already_printed = true;
break;
}
p += 2;
#endif
break;
}
case MENU_RESET:
strcpy(String, gSubMenu_RESET[gSubMenuSelection]);
@@ -1178,7 +1350,18 @@ void UI_DisplayMenu(void)
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case MENU_SET_AUD:
strcpy(String, gSubMenu_SET_AUD[gSubMenuSelection]);
if(gTxVfo->Modulation == MODULATION_AM) {
strcpy(String, gSubMenu_SET_AUD_AM[gSubMenuSelection]);
strcpy(top_right_badge, "AM");
}
else if (gTxVfo->Modulation == MODULATION_USB) {
strcpy(String, "USB");
strcpy(top_right_badge, "USB");
}
else {
strcpy(String, gSubMenu_SET_AUD_FM[gSubMenuSelection]);
strcpy(top_right_badge, "FM");
}
break;
#endif
@@ -1204,12 +1387,8 @@ void UI_DisplayMenu(void)
gaugeMax = 63;
//#endif
}
gEeprom.VOLUME_GAIN = gSubMenuSelection;
BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
( 0u << 10) | // AF Rx Gain-1
(gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
// gEeprom.VOLUME_GAIN = gSubMenuSelection;
BK4819_SetRxAudioGain();
break;
#endif
@@ -1266,23 +1445,6 @@ void UI_DisplayMenu(void)
y = (small ? 3 : 2) - (lines / 2);
// only for SysInf
if(UI_MENU_GetCurrentMenuId() == MENU_VOL)
{
sprintf(edit, "%u.%02uV %u%%",
gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100,
BATTERY_VoltsToPercent(gBatteryVoltageAverage)
);
UI_PrintStringSmallNormal(edit, 54, 127, 1);
#ifdef ENABLE_FEAT_F4HWN
UI_PrintStringSmallNormal(Edition, 54, 127, 6);
#endif
y = 2;
}
// draw the text lines
for (i = 0; i < len && lines > 0; lines--)
{
@@ -1329,8 +1491,24 @@ void UI_DisplayMenu(void)
|| UI_MENU_GetCurrentMenuId() == MENU_D_LIST
#endif
) {
sprintf(String, "%2d", gSubMenuSelection);
UI_PrintStringSmallNormal(String, 105, 0, 0);
if (UI_MENU_GetCurrentMenuId() == MENU_R_CTCS ||
UI_MENU_GetCurrentMenuId() == MENU_T_CTCS) {
const uint8_t approved_index =
(gSubMenuSelection > 0) ? DCS_GetCtcssApprovedIndex(gSubMenuSelection - 1) : 0xFF;
if (gSubMenuSelection == 0)
sprintf(top_right_badge, "00/00");
else if (approved_index != 0xFF)
sprintf(top_right_badge, "%02u/%02u", (unsigned)gSubMenuSelection, approved_index + 1);
else
sprintf(top_right_badge, "%02u/--", (unsigned)gSubMenuSelection);
} else {
sprintf(top_right_badge, "%03d", gSubMenuSelection);
}
}
if (top_right_badge[0] != '\0') {
UI_MENU_DrawTopRightRoundedBadge(top_right_badge, 1, true, menu_item_x1, menu_item_x2);
}
if ((UI_MENU_GetCurrentMenuId() == MENU_RESET ||
@@ -1343,4 +1521,4 @@ void UI_DisplayMenu(void)
}
ST7565_BlitFullScreen();
}
}
+3 -1
View File
@@ -198,7 +198,8 @@ extern const char gSubMenu_D_RSP[4][11];
extern const char gSubMenu_SET_KEY[][9];
#endif
#ifdef ENABLE_FEAT_F4HWN_AUDIO
extern const char gSubMenu_SET_AUD[5][6];
extern const char gSubMenu_SET_AUD_FM[5][6];
extern const char gSubMenu_SET_AUD_AM[3][6];
#endif
#endif
@@ -232,6 +233,7 @@ extern int32_t gSubMenuSelection;
extern char edit_original[17];
extern char edit[17];
extern int edit_index;
extern bool edit_is_uppercase;
void UI_DisplayMenu(void);
int UI_MENU_GetCurrentMenuId();
+50 -52
View File
@@ -99,33 +99,32 @@ void UI_DisplayStatus()
if(gEeprom.SCAN_LIST_DEFAULT == MR_CHANNELS_LIST + 1)
{
if(gEeprom.SCAN_LIST_ENABLED==1) {
sprintf(str, "%s+", "ALL");
end = 19;
}
else
{
sprintf(str, "%s", "ALL");
end = 15;
}
sprintf(str, gEeprom.SCAN_LIST_ENABLED ? "%s+" : "%s", "ALL");
end = gEeprom.SCAN_LIST_ENABLED ? 18 : 14;
}
else
{
if(gEeprom.SCAN_LIST_ENABLED==1) {
sprintf(str, "%02d+", gEeprom.SCAN_LIST_DEFAULT);
end = 15;
}
const char *name = gListName[gEeprom.SCAN_LIST_DEFAULT - 1];
// Check if name is valid
if (!IsEmptyName(name, sizeof(gListName[0]))) {
sprintf(str, "%.3s%s", name, gEeprom.SCAN_LIST_ENABLED ? "+" : "");
end = gEeprom.SCAN_LIST_ENABLED ? 18 : 14;
}
else {
sprintf(str, "%02d", gEeprom.SCAN_LIST_DEFAULT);
end = 11;
sprintf(str, "%02d%s", gEeprom.SCAN_LIST_DEFAULT, gEeprom.SCAN_LIST_ENABLED ? "+" : "");
end = gEeprom.SCAN_LIST_ENABLED ? 14 : 10;
}
}
GUI_DisplaySmallest(str, 2, 1, true, true);
for (uint8_t x = 0; x < end; x++)
gStatusLine[0] ^= 0x3E;
for (uint8_t x = 1; x < end; x++)
{
gStatusLine[x] ^= 0x7F;
}
gStatusLine[end] ^= 0x3E;
}
else { // frequency mode
memcpy(line + x + 1, gFontS, sizeof(gFontS));
@@ -156,42 +155,48 @@ void UI_DisplayStatus()
if(!SCANNER_IsScanning()) {
#ifdef ENABLE_FEAT_F4HWN_RX_TX_TIMER
if(gCurrentFunction == FUNCTION_TRANSMIT && gSetting_set_tmr == true)
{
convertTime(line, 0);
}
else if(FUNCTION_IsRx() && gSetting_set_tmr == true)
{
convertTime(line, 1);
bool isTransmit = gCurrentFunction == FUNCTION_TRANSMIT;
if (gSetting_set_tmr && (isTransmit || FUNCTION_IsRx())) {
convertTime(line, !isTransmit);
}
else
#endif
{
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true) {
memcpy(line + x + 2, gFontRO, sizeof(gFontRO));
}
else
{
#endif
uint8_t dw = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2;
if(dw == 1 || dw == 3) { // DWR - dual watch + respond
if(gDualWatchActive)
memcpy(line + x + (dw==1?0:2), gFontDWR, sizeof(gFontDWR) - (dw==1?0:5));
else
memcpy(line + x + 3, gFontHold, sizeof(gFontHold));
}
else if(dw == 2) { // XB - crossband
memcpy(line + x + 2, gFontXB, sizeof(gFontXB));
}
else
if(!gAirCopyBootMode) {
const void *src = NULL; // Pointer to the font/bitmap to copy
size_t sSize = 0; // Size of the font/bitmap
uint8_t sOff = 2; // Offset relative to the reference position
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if (gEeprom.MENU_LOCK) {
src = gFontRO;
sSize = sizeof(gFontRO);
} else
#endif
{
if(!gAirCopyBootMode)
memcpy(line + x + 2, gFontMO, sizeof(gFontMO));
uint8_t xb = (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF);
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) {
if (gDualWatchActive) { // DWR - dual watch + respond
src = gFontDWR;
sOff = xb ? 2 : 0;
sSize = sizeof(gFontDWR) - (xb ? 5 : 0);
} else {
src = gFontHold;
sOff = 3;
sSize = sizeof(gFontHold);
}
} else {
src = xb ? gFontXB : gFontMO; // XB - crossband
sSize = xb ? sizeof(gFontXB) : sizeof(gFontMO); // MO - main only
}
}
// Perform the memcpy if a source was selected
if (src) {
memcpy(line + x + sOff, src, sSize);
}
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
}
#endif
}
}
x += sizeof(gFontDWR) + 3;
@@ -233,15 +238,8 @@ void UI_DisplayStatus()
size = sizeof(gFontKeyLock);
}
else if (gWasFKeyPressed) {
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if (!gEeprom.MENU_LOCK) {
src = gFontF;
size = sizeof(gFontF);
}
#else
src = gFontF;
size = sizeof(gFontF);
#endif
}
#ifdef ENABLE_FEAT_F4HWN
else if (gMute) {
+1 -2
View File
@@ -94,9 +94,8 @@ void GUI_SelectNextDisplay(GUI_DisplayType_t Display)
gAskForConfirmation = 0;
gAskToSave = false;
gAskToDelete = false;
gWasFKeyPressed = false;
gUpdateStatus = true;
HideFKeyIcon();
}
gScreenToDisplay = Display;
+184 -69
View File
@@ -15,6 +15,7 @@
*/
#include <string.h>
#include <stdint.h>
#include "driver/py25q16.h"
#include "driver/st7565.h"
@@ -32,6 +33,160 @@
#include "screenshot.h"
#endif
#ifdef ENABLE_FEAT_F4HWN_QRCODE
// QR code (version 4, 33x33 modules, EC level L) encoding:
// https://github.com/armel/uv-k1-k5v3-firmware-custom
// Stored in framebuffer column-major format: 5 fb-lines x 33 columns.
// Each byte packs 8 vertical pixels (bit 0 = top). Last fb-line uses
// only bit 0 (row 32); bits 1..7 are always 0.
//
// static const uint8_t BITMAP_QR_GitHub[5][33] = {
// { 0x7F, 0x41, 0x5D, 0x5D, 0x5D, 0x41, 0x7F, 0x00, 0x6A, 0xB8, 0xCB, 0xA0, 0x6D, 0x07, 0xCB, 0x1F, 0xD2, 0x18, 0x59, 0x15, 0x79, 0x86, 0xCE, 0x15, 0x43, 0x00, 0x7F, 0x41, 0x5D, 0x5D, 0x5D, 0x41, 0x7F },
// { 0x87, 0xA3, 0x69, 0xC3, 0x19, 0x0E, 0x55, 0x1F, 0x43, 0x11, 0x16, 0xC1, 0x5A, 0x0E, 0x96, 0x3E, 0xA5, 0x15, 0x06, 0x2A, 0xFE, 0xCE, 0xCA, 0x3A, 0x70, 0xD9, 0xEA, 0xF5, 0x5C, 0x15, 0x8A, 0x67, 0x22 },
// { 0xE0, 0x0B, 0x1D, 0x28, 0xF5, 0x87, 0x55, 0xEB, 0xA8, 0x11, 0xA3, 0xC1, 0x5A, 0x0E, 0x96, 0x3E, 0xA5, 0x15, 0x84, 0x2B, 0x72, 0xE8, 0xE9, 0x23, 0x11, 0xCD, 0xE6, 0xC1, 0x91, 0xE6, 0x88, 0x77, 0x22 },
// { 0xFD, 0x04, 0x75, 0x75, 0x75, 0x04, 0xFD, 0x01, 0xF7, 0xE0, 0xD6, 0xC1, 0x5A, 0x0E, 0x96, 0x3E, 0xA5, 0x37, 0x22, 0x2B, 0xEA, 0xAA, 0xA7, 0x8D, 0x5F, 0x31, 0x55, 0xB1, 0x3F, 0xCE, 0xCA, 0x2C, 0x2B },
// { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 }
// };
static const uint8_t BITMAP_QR_GitHub_Compressed[137] = {
0x7F, 0x41, 0x5D, 0x5D, 0x5D, 0x41, 0x7F, 0x00, 0x6A, 0xB8, 0xCB, 0xA0, 0x6D, 0x07, 0xCB, 0x1F, 0xD2, 0x18, 0x59, 0x15, 0x79, 0x86, 0xCE, 0x15, 0x43, 0x00, 0x7F, 0x41, 0x5D, 0x5D, 0x5D, 0x41, 0x7F,
0x87, 0xA3, 0x69, 0xC3, 0x19, 0x0E, 0x55, 0x1F, 0x43, 0x11, 0x16, 0xC1, 0x5A, 0x0E, 0x96, 0x3E, 0xA5, 0x15, 0x06, 0x2A, 0xFE, 0xCE, 0xCA, 0x3A, 0x70, 0xD9, 0xEA, 0xF5, 0x5C, 0x15, 0x8A, 0x67, 0x22,
0xE0, 0x0B, 0x1D, 0x28, 0xF5, 0x87, 0x55, 0xEB, 0xA8, 0x11, 0xA3, 0xC1, 0x5A, 0x0E, 0x96, 0x3E, 0xA5, 0x15, 0x84, 0x2B, 0x72, 0xE8, 0xE9, 0x23, 0x11, 0xCD, 0xE6, 0xC1, 0x91, 0xE6, 0x88, 0x77, 0x22,
0xFD, 0x04, 0x75, 0x75, 0x75, 0x04, 0xFD, 0x01, 0xF7, 0xE0, 0xD6, 0xC1, 0x5A, 0x0E, 0x96, 0x3E, 0xA5, 0x37, 0x22, 0x2B, 0xEA, 0xAA, 0xA7, 0x8D, 0x5F, 0x31, 0x55, 0xB1, 0x3F, 0xCE, 0xCA, 0x2C, 0x2B,
0x7F, 0x09, 0x8C, 0xA3, 0x00
};
// QR code (version 4, 33x33 modules, EC level L) encoding:
// https://github.com/armel/uv-k1-k5v3-firmware-custom/wiki
// Stored in framebuffer column-major format: 5 fb-lines x 33 columns.
// Last fb-line uses only bit 0 (row 32); bits 1..7 are always 0.
//
// static const uint8_t BITMAP_QR_GitHub_Wiki[5][33] = {
// { 0x7F, 0x41, 0x5D, 0x5D, 0x5D, 0x41, 0x7F, 0x00, 0x6A, 0x0F, 0x74, 0x0E, 0xD2, 0xB0, 0x74, 0xB1, 0x6D, 0x18, 0x59, 0x15, 0x79, 0x86, 0xCE, 0x15, 0x43, 0x00, 0x7F, 0x41, 0x5D, 0x5D, 0x5D, 0x41, 0x7F },
// { 0xCD, 0x5D, 0x83, 0x65, 0xE7, 0xC6, 0x55, 0xBD, 0x6B, 0x3F, 0xA9, 0x1C, 0xA5, 0xE0, 0x69, 0xE3, 0x4A, 0x15, 0x06, 0x2A, 0xFE, 0xCE, 0xCA, 0x3A, 0x70, 0xD9, 0xEA, 0xF5, 0x5C, 0x15, 0x8A, 0x67, 0x22 },
// { 0xFF, 0x25, 0xAE, 0xB6, 0x30, 0xF8, 0x55, 0xDD, 0x07, 0xB6, 0xC2, 0x1C, 0xA5, 0xE0, 0x69, 0xC4, 0x66, 0x15, 0x84, 0x2B, 0x72, 0xE8, 0xE9, 0x23, 0x11, 0xCD, 0xE6, 0xC1, 0x91, 0xE6, 0x88, 0x77, 0x22 },
// { 0xFD, 0x04, 0x74, 0x74, 0x74, 0x05, 0xFD, 0x01, 0xF7, 0xAE, 0x81, 0x1C, 0xA5, 0xE0, 0x69, 0x54, 0xFE, 0x37, 0x22, 0x2B, 0xEA, 0xAA, 0xA7, 0x8D, 0x5F, 0x31, 0x55, 0xB1, 0x3F, 0xCE, 0xCA, 0x24, 0x33 },
// { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 }
// };
static const uint8_t BITMAP_QR_GitHub_Wiki_Compressed[137] = {
0x7F, 0x41, 0x5D, 0x5D, 0x5D, 0x41, 0x7F, 0x00, 0x6A, 0x0F, 0x74, 0x0E, 0xD2, 0xB0, 0x74, 0xB1, 0x6D, 0x18, 0x59, 0x15, 0x79, 0x86, 0xCE, 0x15, 0x43, 0x00, 0x7F, 0x41, 0x5D, 0x5D, 0x5D, 0x41, 0x7F,
0xCD, 0x5D, 0x83, 0x65, 0xE7, 0xC6, 0x55, 0xBD, 0x6B, 0x3F, 0xA9, 0x1C, 0xA5, 0xE0, 0x69, 0xE3, 0x4A, 0x15, 0x06, 0x2A, 0xFE, 0xCE, 0xCA, 0x3A, 0x70, 0xD9, 0xEA, 0xF5, 0x5C, 0x15, 0x8A, 0x67, 0x22,
0xFF, 0x25, 0xAE, 0xB6, 0x30, 0xF8, 0x55, 0xDD, 0x07, 0xB6, 0xC2, 0x1C, 0xA5, 0xE0, 0x69, 0xC4, 0x66, 0x15, 0x84, 0x2B, 0x72, 0xE8, 0xE9, 0x23, 0x11, 0xCD, 0xE6, 0xC1, 0x91, 0xE6, 0x88, 0x77, 0x22,
0xFD, 0x04, 0x74, 0x74, 0x74, 0x05, 0xFD, 0x01, 0xF7, 0xAE, 0x81, 0x1C, 0xA5, 0xE0, 0x69, 0x54, 0xFE, 0x37, 0x22, 0x2B, 0xEA, 0xAA, 0xA7, 0x8D, 0x5F, 0x31, 0x55, 0xB1, 0x3F, 0xCE, 0xCA, 0x24, 0x33,
0x7F, 0x53, 0x8E, 0xA3, 0x00
};
#endif
#ifdef ENABLE_FEAT_F4HWN_MEM
// Linker symbols (provided by the linker script)
extern uint8_t _sdata; // Start of .data in RAM
extern uint8_t _edata; // End of .data in RAM
extern uint8_t _sbss; // Start of .bss in RAM
extern uint8_t _ebss; // End of .bss in RAM
// _eflash_used must be defined in the linker script immediately after the last
// section with a FLASH load address (after .noncacheable). Example:
//
// .noncacheable : {
// ...
// } > RAM AT> FLASH
// _eflash_used = LOADADDR(.noncacheable) + SIZEOF(.noncacheable);
//
// This gives the exact byte count that the linker reports as FLASH used.
extern uint8_t _eflash_used;
// Absolute symbols: their *address* IS the numeric size value (ARM/CMSIS convention).
// RAM = .data + gap + .bss + heap_reserve + stack_reserve
extern uint8_t _Min_Heap_Size;
extern uint8_t _Min_Stack_Size;
// Region sizes (must match your linker MEMORY regions)
#define RAM_SIZE_BYTES (16u * 1024u)
#define FLASH_SIZE_BYTES (118u * 1024u)
// Base address of FLASH — must match ORIGIN(FLASH) in your linker script
#define FLASH_BASE (0x08002800u)
static inline uint32_t span(const void* a, const void* b)
{
return (uint32_t)((uintptr_t)b - (uintptr_t)a);
}
static void build_usage(uint32_t* ram_used, uint32_t* flash_used)
{
// RAM: span from start of .data to end of .bss covers .data + alignment gap + .bss.
// Then add heap and stack reservations (absolute linker symbols: address = size).
// Proof: (0x20002A60 - 0x20000000) + 0x200 + 0x400 = 10848 + 512 + 1024 = 12384 B ✓
const uint32_t heap_size = (uint32_t)(uintptr_t)&_Min_Heap_Size;
const uint32_t stack_size = (uint32_t)(uintptr_t)&_Min_Stack_Size;
*ram_used = span(&_sdata, &_ebss) + heap_size + stack_size;
// FLASH: _eflash_used is placed by the linker script right after the last
// section copied to FLASH (.data LMA + .noncacheable LMA).
// Note: _etext is NOT usable here because this linker script places .rodata
// sections AFTER _etext, making it an unreliable end-of-flash marker.
*flash_used = span((void*)FLASH_BASE, &_eflash_used);
}
static inline uint16_t pct_x100(uint32_t used, uint32_t total)
{
return (uint16_t)((used * 10000u) / total); // 7559 => 75.59%
}
void UI_GetMemPercents(uint16_t *flash_pct_x100, uint16_t *ram_pct_x100)
{
uint32_t ram_used = 0;
uint32_t flash_used = 0;
build_usage(&ram_used, &flash_used);
if (flash_pct_x100) *flash_pct_x100 = pct_x100(flash_used, FLASH_SIZE_BYTES);
if (ram_pct_x100) *ram_pct_x100 = pct_x100(ram_used, RAM_SIZE_BYTES);
}
#endif
#ifdef ENABLE_FEAT_F4HWN_QRCODE
// Set a single pixel at LCD-physical (x, y). y=0..7 maps to gStatusLine,
// y=8..63 maps to gFrameBuffer (line = (y-8)/8, bit = (y-8)%8).
static void QR_SetPixel(uint8_t x, uint8_t y)
{
if (x >= 128 || y >= 64) return;
if (y < 8) {
gStatusLine[x] |= (uint8_t)(1u << y);
} else {
const uint8_t fb_y = (uint8_t)(y - 8u);
gFrameBuffer[fb_y >> 3][x] |= (uint8_t)(1u << (fb_y & 7u));
}
}
// Render a square QR bitmap stored in framebuffer column-major format
// (size cols × ceil(size/8) fb-lines, row-major in memory).
static void QR_Draw(const uint8_t *bitmap, uint8_t size, uint8_t origin_x, uint8_t origin_y)
{
for (uint8_t qy = 0; qy < size; qy++) {
for (uint8_t qx = 0; qx < size; qx++) {
// const uint16_t idx = (uint16_t)(qy >> 3) * (uint16_t)size + (uint16_t)qx;
// if ((bitmap[idx] >> (qy & 7u)) & 1u) {
if (qy < 32 ?
((bitmap[(uint16_t)(qy >> 3) * (uint16_t)size + (uint16_t)qx] >> (qy & 7u)) & 1u) :
((bitmap[132 + (qx >> 3)] >> (qx & 7u)) & 1u)) {
QR_SetPixel((uint8_t)(origin_x + qx),
(uint8_t)(origin_y + qy));
}
}
}
}
void UI_DrawQRCode(bool wiki, uint8_t origin_x, uint8_t origin_y)
{
// QR_Draw(wiki ? (const uint8_t *)BITMAP_QR_GitHub_Wiki
// : (const uint8_t *)BITMAP_QR_GitHub,
QR_Draw(wiki ? (const uint8_t *)BITMAP_QR_GitHub_Wiki_Compressed
: (const uint8_t *)BITMAP_QR_GitHub_Compressed,
33, origin_x, origin_y);
}
#endif
void UI_DisplayReleaseKeys(void)
{
memset(gStatusLine, 0, sizeof(gStatusLine));
@@ -52,7 +207,7 @@ void UI_DisplayWelcome(void)
char WelcomeString0[16];
char WelcomeString1[16];
char WelcomeString2[16];
char WelcomeString3[20];
char WelcomeString3[32];
memset(gStatusLine, 0, sizeof(gStatusLine));
@@ -125,79 +280,39 @@ void UI_DisplayWelcome(void)
#ifdef ENABLE_FEAT_F4HWN
UI_PrintStringSmallNormal(Version, 0, 128, 4);
UI_DrawLineBuffer(gFrameBuffer, 0, 31, 127, 31, 1); // Be ware, status zone = 8 lines, the rest = 56 ->total 64
for (uint8_t i = 18; i < 110; i++)
UI_DrawLineBuffer(gFrameBuffer, 0, 35, 18, 35, 1);
gFrameBuffer[4][19] ^= 0x7F;
for (uint8_t x = 20; x < 108; x++)
{
gFrameBuffer[4][i] ^= 0xFF;
gFrameBuffer[4][x] ^= 0xFF;
gFrameBuffer[3][x] ^= 0x80;
}
gFrameBuffer[4][108] ^= 0x7F;
UI_DrawLineBuffer(gFrameBuffer, 109, 35, 127, 35, 1);
/*
#ifdef ENABLE_FEAT_F4HWN_MEM
uint32_t ram_used = 0;
uint32_t flash_used = 0;
build_usage(&ram_used, &flash_used);
const uint16_t ram_pct = pct_x100(ram_used, RAM_SIZE_BYTES);
const uint16_t flash_pct = pct_x100(flash_used, FLASH_SIZE_BYTES);
// No floats: 7559 => 75.59%
sprintf(WelcomeString3,
"FLASH %u.%02u %% - SRAM %u.%02u %%",
(unsigned)(flash_pct / 100), (unsigned)(flash_pct % 100),
(unsigned)(ram_pct / 100), (unsigned)(ram_pct % 100));
GUI_DisplaySmallest(WelcomeString3, 5, 1, true, true);
ST7565_BlitStatusLine();
#endif
*/
sprintf(WelcomeString3, "%s Edition", Edition);
UI_PrintStringSmallNormal(WelcomeString3, 0, 127, 6);
/*
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
#if ENABLE_FEAT_F4HWN_RESCUE_OPS > 1
UI_PrintStringSmallNormal(Edition, 18, 0, 6);
if(gEeprom.MENU_LOCK == true) {
memcpy(gFrameBuffer[6] + 103, BITMAP_Ready, sizeof(BITMAP_Ready));
}
else
{
memcpy(gFrameBuffer[6] + 103, BITMAP_NotReady, sizeof(BITMAP_NotReady));
}
#else
UI_PrintStringSmallNormal(Edition, 18, 0, 5);
memcpy(gFrameBuffer[5] + 103, BITMAP_Ready, sizeof(BITMAP_Ready));
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
UI_PrintStringSmallNormal("RescueOps", 18, 0, 6);
if(gEeprom.MENU_LOCK == true) {
memcpy(gFrameBuffer[6] + 103, BITMAP_Ready, sizeof(BITMAP_Ready));
}
else
{
memcpy(gFrameBuffer[6] + 103, BITMAP_NotReady, sizeof(BITMAP_NotReady));
}
#endif
#endif
#else
UI_PrintStringSmallNormal(Edition, 18, 0, 6);
memcpy(gFrameBuffer[6] + 103, BITMAP_Ready, sizeof(BITMAP_Ready));
#endif
*/
/*
#ifdef ENABLE_SPECTRUM
#ifdef ENABLE_FMRADIO
UI_PrintStringSmallNormal(Based, 0, 127, 5);
UI_PrintStringSmallNormal(Credits, 0, 127, 6);
#else
UI_PrintStringSmallNormal("Bandscope ", 0, 127, 5);
memcpy(gFrameBuffer[5] + 95, BITMAP_Ready, sizeof(BITMAP_Ready));
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
UI_PrintStringSmallNormal("RescueOps ", 0, 127, 6);
if(gEeprom.MENU_LOCK == true) {
memcpy(gFrameBuffer[6] + 95, BITMAP_Ready, sizeof(BITMAP_Ready));
}
#else
UI_PrintStringSmallNormal("Broadcast ", 0, 127, 6);
#endif
#endif
#else
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
UI_PrintStringSmallNormal("RescueOps ", 0, 127, 5);
if(gEeprom.MENU_LOCK == true) {
memcpy(gFrameBuffer[5] + 95, BITMAP_Ready, sizeof(BITMAP_Ready));
}
#else
UI_PrintStringSmallNormal("Bandscope ", 0, 127, 5);
#endif
UI_PrintStringSmallNormal("Broadcast ", 0, 127, 6);
memcpy(gFrameBuffer[6] + 95, BITMAP_Ready, sizeof(BITMAP_Ready));
#endif
*/
#else
UI_PrintStringSmallNormal(Version, 0, 127, 6);
#endif
@@ -206,7 +321,7 @@ void UI_DisplayWelcome(void)
ST7565_BlitFullScreen();
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
getScreenShot(true);
SCREENSHOT_Update(true);
#endif
}
}
+14
View File
@@ -17,8 +17,22 @@
#ifndef UI_WELCOME_H
#define UI_WELCOME_H
#include <stdbool.h>
#include <stdint.h>
void UI_DisplayReleaseKeys(void);
void UI_DisplayWelcome(void);
#ifdef ENABLE_FEAT_F4HWN_QRCODE
// Draw the embedded GitHub QR code (V4, 33x33) at (origin_x, origin_y).
// `wiki` selects the wiki URL bitmap, otherwise the repo URL bitmap.
void UI_DrawQRCode(bool wiki, uint8_t origin_x, uint8_t origin_y);
#endif
#ifdef ENABLE_FEAT_F4HWN_MEM
// Compute current FLASH and SRAM usage as percentages × 100 (e.g. 7559 = 75.59%).
void UI_GetMemPercents(uint16_t *flash_pct_x100, uint16_t *ram_pct_x100);
#endif
#endif
+6 -1
View File
@@ -190,8 +190,13 @@ void cdc_acm_data_send_with_dtr(const uint8_t *buf, uint32_t size)
{
ep_tx_busy_flag = true;
usbd_ep_start_write(CDC_IN_EP, buf, size);
while (ep_tx_busy_flag)
uint32_t timeout = 100000;
while (ep_tx_busy_flag && --timeout)
;
if (!timeout) {
ep_tx_busy_flag = false;
dtr_enable = 0; // Consider USB disconnected
}
}
}
+3
View File
@@ -8,6 +8,9 @@
#ifdef ENABLE_FEAT_F4HWN
const char Version[] = AUTHOR_STRING_2 " " VERSION_STRING_2;
const char Edition[] = EDITION_STRING;
const char BuildDate[] = __DATE__;
const char BuildTime[] = __TIME__;
const char BuildCommit[] = BUILD_COMMIT;
#else
const char Version[] = AUTHOR_STRING VER;
#endif
+3
View File
@@ -24,4 +24,7 @@ extern const char UART_Version[];
#ifdef ENABLE_FEAT_F4HWN
extern const char Edition[];
extern const char BuildDate[];
extern const char BuildTime[];
extern const char BuildCommit[];
#endif
+19
View File
@@ -19,6 +19,21 @@ message("Build type: " ${CMAKE_BUILD_TYPE})
enable_language(C ASM)
find_package(Git QUIET)
set(BUILD_COMMIT "unknown")
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE BUILD_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(NOT BUILD_COMMIT)
set(BUILD_COMMIT "unknown")
endif()
endif()
if(ENABLE_FEAT_F4HWN)
if(NOT AUTHOR_STRING_1)
set(AUTHOR_STRING_1 "EGZUMER")
@@ -70,6 +85,10 @@ target_link_libraries(${EXE_NAME} Core App)
target_compile_definitions(${EXE_NAME} PRIVATE $<$<CONFIG:Debug>:DEBUG>)
target_link_libraries(${EXE_NAME} ${TOOLCHAIN_LINK_LIBRARIES})
if(ENABLE_LTO)
target_compile_options(${EXE_NAME} PRIVATE -flto=auto)
endif()
# Generate map file
target_link_options(${EXE_NAME} PRIVATE "-Wl,-Map=${EXE_NAME}.map")
+10 -1
View File
@@ -9,6 +9,7 @@
"toolchainFile": "${sourceDir}/cmake/gcc-arm-none-eabi.cmake",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"ENABLE_LTO": false,
"ENABLE_FMRADIO": false,
"ENABLE_UART": true,
"ENABLE_USB": true,
@@ -59,16 +60,20 @@
"ENABLE_FEAT_F4HWN_RESCUE_OPS": false,
"ENABLE_FEAT_F4HWN_VOL": false,
"ENABLE_FEAT_F4HWN_AUDIO": false,
"ENABLE_FEAT_F4HWN_AUDIO_SCOPE": false,
"ENABLE_FEAT_F4HWN_RESET_VFO": true,
"ENABLE_FEAT_F4HWN_PMR": false,
"ENABLE_FEAT_F4HWN_GMRS_FRS_MURS": false,
"ENABLE_FEAT_F4HWN_CA": true,
"ENABLE_FEAT_F4HWN_DEBUG": false,
"ENABLE_FEAT_F4HWN_QRCODE": false,
"ENABLE_FEAT_F4HWN_MEM": false,
"ENABLE_FEAT_F4HWN_SCAN_PROGRESS": false,
"ENABLE_AGC_SHOW_DATA": false,
"ENABLE_UART_RW_BK_REGS": false,
"ENABLE_SWD": false,
"VERSION_STRING_1": "v0.22",
"VERSION_STRING_2": "v5.0.1"
"VERSION_STRING_2": "v5.4.0"
}
},
{
@@ -187,6 +192,10 @@
"ENABLE_FEAT_F4HWN_RESCUE_OPS": true,
"ENABLE_FEAT_F4HWN_VOL": true,
"ENABLE_FEAT_F4HWN_AUDIO": true,
"ENABLE_FEAT_F4HWN_AUDIO_SCOPE": true,
"ENABLE_FEAT_F4HWN_SCAN_PROGRESS": true,
"ENABLE_FEAT_F4HWN_QRCODE": true,
"ENABLE_FEAT_F4HWN_MEM": true,
"ENABLE_SWD": true,
"EDITION_STRING": "Fusion",
"TARGET": "f4hwn.fusion"
+9
View File
@@ -145,6 +145,15 @@ SECTIONS
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
/* Explicit placement of .noncacheable (CherryUSB) + end-of-FLASH symbol */
.noncacheable :
{
. = ALIGN(4);
*(.noncacheable)
*(.noncacheable*)
. = ALIGN(4);
} >RAM AT> FLASH
_eflash_used = LOADADDR(.noncacheable) + SIZEOF(.noncacheable);
/* Uninitialized data section */
. = ALIGN(4);
+2 -1
View File
@@ -3,7 +3,8 @@ FROM mcr.microsoft.com/devcontainers/python:3.10-bookworm
# ---------------------------------------------
# Base build tools
# ---------------------------------------------
RUN apt-get update && apt-get install -y --no-install-recommends \
RUN rm -f /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake ninja-build python3 curl xz-utils ca-certificates \
&& rm -rf /var/lib/apt/lists/*
+2 -1
View File
@@ -3,7 +3,8 @@ FROM mcr.microsoft.com/devcontainers/python:3.10-bookworm
# ---------------------------------------------
# Base build tools
# ---------------------------------------------
RUN apt-get update && apt-get install -y --no-install-recommends \
RUN rm -f /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake ninja-build python3 curl xz-utils ca-certificates \
&& rm -rf /var/lib/apt/lists/*
+54 -61
View File
@@ -31,9 +31,9 @@ Anyway, have fun.
> _FR - CE FIRMWARE N'A PAS DE VÉRITABLE CERVEAU. VEUILLEZ UTILISER LE VÔTRE. Utilisez ce firmware à vos risques et périls. Il n'y a absolument aucune garantie qu'il fonctionnera d'une manière ou d'une autre sur votre (vos) radio(s), il peut même bousiller votre (vos) radio(s), dans ce cas, vous devrez acheter une autre radio. Quoi qu'il en soit, amusez-vous bien._
> [!NOTE]
> EN - About Chirp, as many others firmwares, you need to use a dedicated driver available on [this repository](https://github.com/armel/uv-k5-chirp-driver).
> EN - About CHIRP, as with many other firmwares, you need to use a dedicated driver. The matching CHIRP driver is now bundled with each release of this repository, so you can download the firmware and its driver together from the [Releases page](https://github.com/armel/uv-k1-k5v3-firmware-custom/releases).
>
> _FR - A propos de Chirp, comme beaucoup d'autres firmwares, vous devez utiliser un pilote dédié disponible sur [ce dépôt](https://github.com/armel/uv-k5-chirp-driver)._
> _FR - A propos de CHIRP, comme pour beaucoup d'autres firmwares, vous devez utiliser un pilote dédié. Le driver CHIRP correspondant est désormais fourni avec chaque release de ce dépôt, ce qui permet de récupérer ensemble le firmware et son pilote depuis la page des [Releases](https://github.com/armel/uv-k1-k5v3-firmware-custom/releases)._
> [!CAUTION]
> EN - I recommend to backup your calibration data with [uvtools2](https://armel.github.io/uvtools2/) just after flashing this firmware. It's a good reflex to have.
@@ -42,7 +42,7 @@ Anyway, have fun.
# Donations
Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Olivier 14RC206, Frédéric F4ESO, Stéphane F5LGW (2 times), Jorge Ornelas (4 times), Laurent F4AXK, Christophe Morel, Clayton W0LED, Pierre Antoine F6FWB, Jean-Claude 14FRS3306, Thierry F4GVO, Eric F1NOU, PricelessToolkit, Ady M6NYJ, Tom McGovern (4 times), Joseph Roth, Pierre-Yves Colin, Frank DJ7FG, Marcel Testaz, Brian Frobisher, Yannick F4JFO, Paolo Bussola, Dirk DL8DF, Levente Szőke (2 times), Bernard-Michel Herrera, Jérôme Saintespes, Paul Davies, RS (3 times), Johan F4WAT, Robert Wörle, Rafael Sundorf, Paul Harker, Peter Fintl, Pascal F4ICR (2 times), Mike DL2MF (3 times), Eric KI1C (2 times), Phil G0ELM, Jérôme Lambert, Eliot Vedel, Alfonso EA7KDF, Jean-François F1EVM, Robert DC1RDB (2 times), Ian KE2CHJ, Daryl VK3AWA, Roberto Brunelli, Robert Boardman, Stephen Oliver, Nicolas F4INE, William Bruno, Daniel OK2VLK, Tayler Chew, Peter DL7RFP, Philippe Kopp, Rune LA6YMA, Jeremy Luna and Steef Wagenaar for their [donations](https://www.paypal.com/paypalme/F4HWN). That’s so kind of them. Thanks so much 🙏🏻
Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Olivier 14RC206, Frédéric F4ESO, Stéphane F5LGW (2 times), Jorge Ornelas (4 times), Laurent F4AXK, Christophe Morel, Clayton W0LED, Pierre Antoine F6FWB, Jean-Claude 14FRS3306, Thierry F4GVO, Eric F1NOU, PricelessToolkit, Ady M6NYJ, Tom McGovern (4 times), Joseph Roth, Pierre-Yves Colin, Frank DJ7FG, Marcel Testaz, Brian Frobisher, Yannick F4JFO, Paolo Bussola, Dirk DL8DF, Levente Szőke (2 times), Bernard-Michel Herrera, Jérôme Saintespes, Paul Davies, RS (3 times), Johan F4WAT, Robert Wörle, Rafael Sundorf, Paul Harker, Peter Fintl, Pascal F4ICR (2 times), Mike DL2MF (3 times), Eric KI1C (2 times), Phil G0ELM, Jérôme Lambert, Eliot Vedel, Alfonso EA7KDF, Jean-François F1EVM, Robert DC1RDB (2 times), Ian KE2CHJ, Daryl VK3AWA, Roberto Brunelli, Robert Boardman, Stephen Oliver, Nicolas F4INE, William Bruno, Daniel OK2VLK, Tayler Chew, Peter DL7RFP, Philippe Kopp, Rune LA6YMA, Jeremy Luna, Steef Wagenaar (2 times), Zhuo BG7SGA, Jamie M0JLB, Antoine LIBERT, Vince K0DKR, Julia DF7JA, Ken 2E0UMK, Victor TI2SYS, Tobi DG9LAY, Deaglan K4DFQ, Catherine PALMER, Brian WA6JFK, Stéphane Hintzy, Roger F1HCN and Marcin Kusaj for their [donations](https://www.paypal.com/paypalme/F4HWN). That’s so kind of them. Thanks so much 🙏🏻
## Table of Contents
@@ -57,12 +57,15 @@ Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Ol
## Main features and improvements from F4HWN:
* several firmware versions:
* Bandscope (with spectrum analyzer made by Fagci),
* Broadcast (with commercial FM radio support),
* Basic (with spectrum analyzer and commercial FM radios support, but without certain functions such as Vox, Aircopy, etc.),
* RescueOps (specifically designed for first responders: firefighters, sea rescue, mountain rescue),
* Game (with a small breakout game),
* Fusion is now the reference edition of the project:
* all-in-one firmware for UV-K1 and UV-K5 V3,
* spectrum analyzer made by Fagci,
* commercial FM radio support,
* Vox and Aircopy support,
* screenshots and K5Viewer support,
* advanced RX audio profiles and Audio Scope,
* first-responder oriented options,
* small breakout game,
* improve default power settings level:
* Low1 to Low5 (<~20mW, ~125mW, ~250mW, ~500mW, ~1W),
* Mid ~2W,
@@ -92,6 +95,8 @@ Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Ol
* improve keyboard frequency input,
* add percent and gauge to Air Copy,
* improve audio bar,
* add backlight fading,
* add Audio Scope on TX,
* and more...
* new menu entries and changes:
* add SetPwr menu to set User power (<20mW, 125mW, 250mW, 500mW, 1W, 2W or 5W),
@@ -103,10 +108,12 @@ Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Ol
* add SetMet menu to set s-meter style (Classic or Tiny),
* add SetLck menu to set what is locked (Keys or Keys + PTT),
* add SetGUI menu to set font size on the VFO baseline (Classic or Tiny),
* add SetRxA menu to select RX audio profiles,
* add TXLock menu to open TX on channel,
* add SetTmr menu to set RX and TX timers (Off or On),
* add SetOff menu to set the delay before the transceiver goes into deep sleep (Off or 1 minute to 2 hours),
* add SetNFM menu to set Narrow width (12.5kHz or 6.25kHz),
* add SetVol menu to adjust RX audio volume,
* rename BatVol menu (52/63) to SysInf, which displays the firmware version in addition to the battery status,
* improve PonMsg menu,
* improve BackLt menu,
@@ -116,6 +123,7 @@ Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Ol
* add HAM CA F Lock band (for Canadian zone),
* add PMR 446 F Lock band,
* add FRS/GMRS/MURS F Lock band,
* add SetNav hidden menu to select the navigation layout according to the radio model,
* remove blink and SOS functionality,
* remove AM Fix menu (AM Fix is ENABLED by default),
* add support of 3500mAh battery,
@@ -124,18 +132,16 @@ Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Ol
* change font and bitmaps,
* move USB icon to left of battery information,
* add RX and TX timers,
* improve lists and scan lists options:
* add new list 3,
* add new list 0 (channel without list...),
* add new scan lists options,
* scan list 0 (all channels without list),
* scan list 1,
* scan list 2,
* scan list 3,
* scan lists [1, 2, 3],
* scan all (all channels with or without list),
* add scan list shortcuts,
* add resume mode on startup (scan, bandscope and broadcast FM),
* improve channel scanning:
* support up to 24 scan lists,
* each memory channel can be assigned to `OFF`, to one list (`01` to `24`), or to `ALL`,
* `ALL` scans every channel except those set to `OFF`,
* named scan lists are shown in the UI and status bar when available,
* if the selected scan list is empty or invalid, the firmware automatically jumps to the next valid one,
* add resume mode on startup (scan, spectrum analyzer and FM radio),
* improve VFO persistence and restore behavior:
* save the Squelch level adjusted with F + UP or F + DOWN,
* restore the full VFO state on long press of EXIT,
* new actions:
* RX MODE,
* MAIN ONLY,
@@ -143,23 +149,25 @@ Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Ol
* WIDE NARROW,
* 1750Hz,
* MUTE,
* POWER HIGH (RescueOps),
* REMOVE OFFSET (RescueOps),
* POWER HIGH,
* REMOVE OFFSET,
* new key combinations:
* add the F + UP or F + DOWN key combination to dynamically change the Squelch level,
* add the F + F1 or F + F2 key combination to dynamically change the Step,
* add F + 8 to quickly switch backlight between BLMin and BLMax on demand (this bypass BackLt strategy),
* add F + 9 to return to BackLt strategy,
* add long press on MENU, in * SCAN mode, to temporarily exclude a memory channel,
* add short press on [0, 1, 2, 3, 4 or 5], in * SCAN mode, to dynamically change scan list.
* add long press on MENU, in * SCAN mode, to exclude the current memory channel,
* add direct scan list selection while scanning with two digits (`00` = `ALL`, `01` to `24` = scan list).
* many fix:
* squelch,
* s-meter,
* DTMF overlaying,
* scan list 2 ignored,
* scan range limit,
* clean display on startup,
* no more PWM noise,
* K5Viewer/serial key handling,
* spectrum freeze on USB-C unplug,
* Audio Scope behavior in OnePush mode and after DTMF/1750,
* and more...
* enabled AIR COPY
* disabled ENABLE_DTMF_CALLING,
@@ -167,7 +175,7 @@ Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Ol
* remove 200Tx, 350Tx and 500Tx,
* unlock TX on all bands needs only to be repeat 3 times,
* code refactoring and many memory optimization,
* displays the live screen of the Quansheng K5 on your computer via a USB-to-Serial cable,
* stream the live screen of the Quansheng K5 to K5Viewer and capture screenshots over a USB-to-Serial cable,
* and more...
## Main features from Egzumer:
@@ -203,7 +211,7 @@ Special thanks to Jean-Cyrille F6IWW (3 times), Fabrice 14RC123, David F4BPP, Ol
## Manual
Up to date manual is available in the [Wiki section](https://github.com/armel/uv-k5-firmware-custom/wiki)
Up to date manual is available in the [Wiki section](https://github.com/armel/uv-k1-k5v3-firmware-custom/wiki)
## Radio performance
@@ -211,21 +219,21 @@ Please note that the Quansheng UV-Kx radios are not professional quality transce
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.
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.
Using the radio in high intensity RF environments will most likely make reception difficult,
especially in AM mode. The receiver simply does not have a great dynamic range, so stronger
signals can easily cause distortion, desensitization and poor AM audio.
This is fundamentally a hardware limitation: firmware can improve behavior at the margins, but
it cannot overcome the front-end design of the radio.
In practice, AM reception will degrade first and most severely, while FM reception is generally
more tolerant and should remain more usable.
But, they are nice toys for the price, fun to play with.
## Compiling and Building from Docker
This project provides a Docker-based build system to compile all firmware editions for the UV-K1 and UV-K5 V3. Everything is handled through the `compile-with-docker.sh` helper script.
This project provides a Docker-based build system to compile the Fusion firmware for the UV-K1 and UV-K5 V3. Everything is handled through the `compile-with-docker.sh` helper script.
All build outputs are generated inside the `build/<Preset>` directory, according to the CMake presets defined in `CMakePresets.json`.
The documented build output is generated inside `build/Fusion`, using the CMake presets defined in `CMakePresets.json`.
### Prerequisites
@@ -238,40 +246,25 @@ The script `compile-with-docker.sh` performs the following actions:
1. Builds the Docker image (`uvk1-uvk5v3`) if it does not already exist.
2. Removes any previous `build` directory to ensure a clean configuration.
3. Runs CMake using the selected preset inside the Docker container.
4. Builds the firmware and outputs `.elf`, `.bin` and `.hex` files for the chosen edition.
3. Runs CMake using the `Fusion` preset inside the Docker container.
4. Builds the firmware and outputs `.elf`, `.bin` and `.hex` files.
### Usage
```bash
./compile-with-docker.sh <Preset> [extra CMake options]
./compile-with-docker.sh Fusion [extra CMake options]
```
### Available Presets
### Documented Preset
- **Custom**
- **Bandscope**
- **Broadcast**
- **Basic**
- **RescueOps**
- **Game**
- **Fusion**
- **All** (builds all editions sequentially)
### Examples
Build a single edition:
Build Fusion:
```bash
./compile-with-docker.sh Fusion
./compile-with-docker.sh Bandscope
./compile-with-docker.sh Broadcast
```
Build everything:
```bash
./compile-with-docker.sh All
```
### Passing Additional CMake Options
@@ -282,15 +275,14 @@ These are forwarded directly to `cmake --preset` inside the container.
Examples:
```bash
./compile-with-docker.sh Bandscope -DENABLE_SPECTRUM=ON
./compile-with-docker.sh Broadcast -DENABLE_FEAT_F4HWN_GAME=ON -DENABLE_NOAA=ON
./compile-with-docker.sh Bandscope -DSQL_TONE=600
./compile-with-docker.sh Fusion -DENABLE_SPECTRUM=ON
./compile-with-docker.sh Fusion -DENABLE_FEAT_F4HWN_GAME=ON -DENABLE_NOAA=ON
./compile-with-docker.sh Fusion -DSQL_TONE=600
```
### Notes
- The first run may take a few minutes while Docker builds the base image.
- Running with `All` will build every firmware variant in sequence.
- Each build runs inside Docker, so your host environment remains clean.
## Flashing the Firmware with UVTools2
@@ -342,6 +334,7 @@ Click `Restore Calibration Data` and wait until the process fully completes.
Many thanks to various people:
* [Muzkr](https://github.com/muzkr)
* [Mrkusypl](https://github.com/mrkusypl)
* [Andrej](https://github.com/Tunas1337)
* [Egzumer](https://github.com/egzumer)
* [OneOfEleven](https://github.com/OneOfEleven)
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5 -2
View File
@@ -31,13 +31,16 @@ fi
# ---------------------------------------------
# Build the Docker image (only needed once)
# ---------------------------------------------
docker build -t "$IMAGE" .
if [[ "$(docker images -q $IMAGE)" == "" ]]; then
echo "Building Docker image..."
docker build -t "$IMAGE" .
fi
# ---------------------------------------------
# Clean existing CMake cache to ensure toolchain reload
# ---------------------------------------------
rm -rf build
export MSYS_NO_PATHCONV=1
# ---------------------------------------------
# Function to build one preset
# ---------------------------------------------
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env python3
# Copyright (c) 2026
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at the root of this repository.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from binascii import crc_hqx
from itertools import cycle
# Quansheng stock updater pack format:
# - raw firmware split at 0x2000
# - 16-byte ASCII version field inserted there
# - XOR obfuscation with the table below
# - CRC16/XMODEM appended at the end
OBFUSCATION = bytes(
[
0x47, 0x22, 0xC0, 0x52, 0x5D, 0x57, 0x48, 0x94, 0xB1, 0x60, 0x60, 0xDB, 0x6F, 0xE3, 0x4C, 0x7C,
0xD8, 0x4A, 0xD6, 0x8B, 0x30, 0xEC, 0x25, 0xE0, 0x4C, 0xD9, 0x00, 0x7F, 0xBF, 0xE3, 0x54, 0x05,
0xE9, 0x3A, 0x97, 0x6B, 0xB0, 0x6E, 0x0C, 0xFB, 0xB1, 0x1A, 0xE2, 0xC9, 0xC1, 0x56, 0x47, 0xE9,
0xBA, 0xF1, 0x42, 0xB6, 0x67, 0x5F, 0x0F, 0x96, 0xF7, 0xC9, 0x3C, 0x84, 0x1B, 0x26, 0xE1, 0x4E,
0x3B, 0x6F, 0x66, 0xE6, 0xA0, 0x6A, 0xB0, 0xBF, 0xC6, 0xA5, 0x70, 0x3A, 0xBA, 0x18, 0x9E, 0x27,
0x1A, 0x53, 0x5B, 0x71, 0xB1, 0x94, 0x1E, 0x18, 0xF2, 0xD6, 0x81, 0x02, 0x22, 0xFD, 0x5A, 0x28,
0x91, 0xDB, 0xBA, 0x5D, 0x64, 0xC6, 0xFE, 0x86, 0x83, 0x9C, 0x50, 0x1C, 0x73, 0x03, 0x11, 0xD6,
0xAF, 0x30, 0xF4, 0x2C, 0x77, 0xB2, 0x7D, 0xBB, 0x3F, 0x29, 0x28, 0x57, 0x22, 0xD6, 0x92, 0x8B,
]
)
VERSION_OFFSET = 0x2000
VERSION_SIZE = 16
CRC_SIZE = 2
def _vector_table_looks_valid(image: bytes) -> bool:
if len(image) < 8:
return False
stack_pointer = int.from_bytes(image[0:4], "little")
reset_vector = int.from_bytes(image[4:8], "little")
return (stack_pointer & 0xFFF00000) == 0x20000000 and (reset_vector & 0xFFF00000) == 0x08000000
def is_raw_image(image: bytes) -> bool:
return _vector_table_looks_valid(image)
def has_valid_vendor_crc(image: bytes) -> bool:
if len(image) < CRC_SIZE:
return False
expected_crc = crc_hqx(image[:-CRC_SIZE], 0)
actual_crc = int.from_bytes(image[-CRC_SIZE:], "little")
return expected_crc == actual_crc
def is_packed_image(image: bytes) -> bool:
if len(image) <= VERSION_OFFSET + VERSION_SIZE + CRC_SIZE:
return False
if is_raw_image(image):
return False
return has_valid_vendor_crc(image)
def decode_packed_image(image: bytes) -> tuple[bytes, str]:
if not is_packed_image(image):
raise ValueError("not a packed Quansheng firmware image")
decoded = bytes(a ^ b for a, b in zip(image[:-CRC_SIZE], cycle(OBFUSCATION)))
version_bytes = decoded[VERSION_OFFSET:VERSION_OFFSET + VERSION_SIZE]
version = version_bytes.split(b"\x00", 1)[0].decode("ascii", errors="replace")
raw = decoded[:VERSION_OFFSET] + decoded[VERSION_OFFSET + VERSION_SIZE:]
if not is_raw_image(raw):
raise ValueError("decoded firmware does not look like a raw MCU image")
return raw, version
+80 -8
View File
@@ -17,14 +17,11 @@
import argparse
import serial
import signal
from time import sleep
import os
import _prog as pp
import _dump as dd
import _restore as rr
import _fwcodec as fc
def load_image(file: str) -> bytes:
@@ -42,7 +39,9 @@ def load_image(file: str) -> bytes:
return a
def main_dump(args, ser: serial.Serial):
def main_dump(args, ser):
import _dump as dd
dump_file: str = args.file
@@ -73,7 +72,10 @@ def main_dump(args, ser: serial.Serial):
sleep(0)
def main_restore(args, ser: serial.Serial):
def main_restore(args, ser):
import _dump as dd
import _restore as rr
dump_file: str = args.file
@@ -105,7 +107,9 @@ def main_restore(args, ser: serial.Serial):
sleep(0)
def main_flash(args, ser: serial.Serial):
def main_flash(args, ser):
import _prog as pp
bl_ver: str = args.bl_ver
fw_file: str = args.file
@@ -139,6 +143,56 @@ def main_flash(args, ser: serial.Serial):
sleep(0)
def get_raw_output_path(file: str) -> str:
root, ext = os.path.splitext(file)
if ext:
file_name = "{}.raw{}".format(os.path.basename(root), ext)
candidate = "{}.raw{}".format(root, ext)
else:
file_name = os.path.basename(file) + ".raw.bin"
candidate = file + ".raw.bin"
out_dir = os.path.dirname(candidate) or "."
if os.access(out_dir, os.W_OK):
return candidate
return os.path.join(os.getcwd(), file_name)
def main_decode(args):
fw_file: str = args.file
out_file: str = args.output or get_raw_output_path(fw_file)
try:
fw_image = load_image(fw_file)
if 0 == len(fw_image):
print("Invalid firmware image: {}: empty file".format(fw_file))
return
except Exception as e:
print("Cannot load firmware image '{}': {}".format(fw_file, e))
return
if fc.is_raw_image(fw_image):
print("Firmware image already looks raw")
raw_image = fw_image
version = None
else:
try:
raw_image, version = fc.decode_packed_image(fw_image)
except Exception as e:
print("Cannot decode firmware image '{}': {}".format(fw_file, e))
return
with open(out_file, "wb") as fd:
fd.write(raw_image)
print("Raw firmware image written: {}, size = {}".format(out_file, len(raw_image)))
if version:
print("Packed version field: {}".format(version))
def main():
# Usage:
@@ -146,6 +200,7 @@ def main():
# serialtool.py .. flash [--bl-ver <ver>] <file>
# serialtool.py .. dump {--config | --calib [| --all]} file
# serialtool.py .. restore {--config | --calib [| --all]} file
# serialtool.py decode <packed.bin> [raw.bin]
ap = argparse.ArgumentParser(description="UV-K5 V2 serial tool")
# TODO: have to add option to each of subcommands ??
@@ -198,14 +253,31 @@ def main():
)
ap_restore.add_argument("file", help="input dump file")
ap_decode = sp.add_parser(
"decode", help="decode a packed Quansheng stock firmware into a raw image"
)
ap_decode.add_argument("file", help="input firmware image file")
ap_decode.add_argument(
"output",
nargs="?",
help="output raw firmware image file (default: <input>.raw.bin)",
)
args = ap.parse_args()
port: str = args.port
sub_name: str = args.subcommand
print(ap.description)
# print("Press Ctrl-C to quit")
if "decode" == sub_name:
main_decode(args)
return
port: str = args.port
try:
import serial
ser = serial.Serial(port, baudrate=38400, timeout=0.0001, write_timeout=None)
except Exception as e:
print("Cannot open port '{}': {}".format(port, e))
+2 -2
View File
@@ -2,11 +2,11 @@
<img width="2016" height="1512" alt="pcbite" src="https://github.com/user-attachments/assets/b3086bf2-c14c-47da-b68b-a6867268ae78" />
Restoring a UV-K5 V1 accidentally flashed with the F4HWN 4.3 Fusion 🔥 Edition firmware, using OpenOCD and a ST-LINK programmer.
Restoring a UV-K5 V1 accidentally flashed with the F4HWN Fusion 🔥 Edition firmware, using OpenOCD and a ST-LINK programmer.
## Introduction
Some users have accidentally flashed a UV-K5 V1 with the F4HWN 4.3 Fusion 🔥 Edition firmware. This edition **is only** compatible with:
Some users have accidentally flashed a UV-K5 V1 with the F4HWN Fusion 🔥 Edition firmware. This edition **is only** compatible with:
- UV-K5 V3
- UV-K1