mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-20 14:39:01 +00:00
Compare commits
157 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6dadefe86f | |||
| ea40e3a46d | |||
| 86584feb16 | |||
| 47c94dbf26 | |||
| b048b8f4f1 | |||
| 9067e007b6 | |||
| 367eaf54c0 | |||
| de30cbfe1b | |||
| a4d91f12ef | |||
| c4f32ac436 | |||
| efe214167d | |||
| 483a100100 | |||
| 8561ff32b3 | |||
| 87eb8e5863 | |||
| d11669f711 | |||
| 7513cd46fc | |||
| d671455f79 | |||
| 42122a739c | |||
| 03fe508aae | |||
| e3eafbeb66 | |||
| e3b3fa2fc8 | |||
| 5f0ae22f66 | |||
| f9dd28f31d | |||
| b99cec5111 | |||
| fe2ba80a10 | |||
| b5d84fcc4d | |||
| 7481aefe9f | |||
| 6b641c8a5d | |||
| 2ad34bbc09 | |||
| 9c74a1f392 | |||
| abadf35e06 | |||
| 288e87537a | |||
| d25899de10 | |||
| 8a16ec829c | |||
| f6d6e3be4c | |||
| c16bac24c7 | |||
| 4e6a2cc934 | |||
| cafe62564e | |||
| 960e5b8329 | |||
| f5a5e8e5e8 | |||
| d8a1e2530a | |||
| b84a424875 | |||
| 62d0e598d4 | |||
| a93f2ff583 | |||
| e2586ceb22 | |||
| 5a2b0cdc2a | |||
| f852900cd0 | |||
| 9ab367f2e0 | |||
| c7a0846645 | |||
| 569bcaad22 | |||
| 6b5955e0b5 | |||
| 9042d1c433 | |||
| 378b2808ba | |||
| 5b363b79aa | |||
| 0d51787099 | |||
| 8f5b25b10d | |||
| 4e56d0f420 | |||
| 2bb3b415d1 | |||
| 6e0394fb6b | |||
| da21ea7866 | |||
| 2c434946cd | |||
| f3aee44e3b | |||
| 165c190d92 | |||
| 8f9246c1ea | |||
| f1d52ae78f | |||
| 865bdee9b3 | |||
| 314e910cbc | |||
| ec6c7eff86 | |||
| 95b2e9fbc3 | |||
| 52ff442fcc | |||
| 95d246a020 | |||
| c34a6940ca | |||
| 33330e4c34 | |||
| 66f1835232 | |||
| 4dfbf666d0 | |||
| 245a36459f | |||
| 590f19062b | |||
| f38ef4ebc8 | |||
| 900d2f2482 | |||
| 5aff5ac277 | |||
| cf4d245964 | |||
| c7f7173958 | |||
| 02c0f67a8d | |||
| 2bacbc80a8 | |||
| ab986a0378 | |||
| c9f310f548 | |||
| 1dafdd5a26 | |||
| fc5beb0c09 | |||
| 3f10663bc9 | |||
| 396f8aef41 | |||
| c095a88cb3 | |||
| 900c80549f | |||
| 4dce613172 | |||
| cf44076a34 | |||
| dd006b4830 | |||
| fc18992442 | |||
| ef2ae9874b | |||
| 5deeaed5f0 | |||
| d5f94398ce | |||
| fba15c48e5 | |||
| 888634ce35 | |||
| 03131c8a0c | |||
| 605c9efa0c | |||
| aee54e5b2d | |||
| e33e697cca | |||
| d7d27d99e7 | |||
| 78d3480b68 | |||
| 70b42f4a56 | |||
| 5c719645d6 | |||
| b0eb776bdd | |||
| ce87161f9b | |||
| 8883f2decc | |||
| e06d23ea3e | |||
| 0da90c7c5e | |||
| e7572e5d41 | |||
| 50f1e51d7e | |||
| 55a15958ec | |||
| 395e20d17b | |||
| 9bf1f2175e | |||
| ec57f99a2c | |||
| 5c2d1d3dfb | |||
| 52dd2ea2bb | |||
| b273165a0c | |||
| 5aecd4097e | |||
| 2c2959df30 | |||
| 9a3c2cc6ac | |||
| c91a6db165 | |||
| bf5ea0a004 | |||
| bf166bb2fc | |||
| 52239d320a | |||
| 561143cfb0 | |||
| 678ee2963e | |||
| bae3854d27 | |||
| 0645f1897a | |||
| da0a5c3e73 | |||
| 22932e636d | |||
| 2b7302e659 | |||
| 60ce89021a | |||
| 25556428a7 | |||
| 584587d814 | |||
| a0179117b1 | |||
| ad577a1c66 | |||
| b9958a689b | |||
| 3d8bc308ee | |||
| 9ca36394d0 | |||
| f489d43259 | |||
| 6b663894b0 | |||
| b8ca356ce3 | |||
| 3a54b112ec | |||
| b013e68b17 | |||
| b2bf0f2459 | |||
| 56adca3bf6 | |||
| cd7c412aa4 | |||
| 16c4c28584 | |||
| 10d17fa7ce | |||
| e63f54c0a2 | |||
| b09efb4d3c |
@@ -0,0 +1,91 @@
|
||||
<!--
|
||||
👋 Thank you for your contribution!
|
||||
⚠️ Before you start, please review our Contributing Guidelines:
|
||||
https://github.com/portapack-mayhem/mayhem-firmware/wiki/Contributing-Guidelines
|
||||
-->
|
||||
|
||||
## Brief description of what you did
|
||||
<!--
|
||||
Replace this line with a description of your changes. What problem does this PR solve? What does it add or fix?
|
||||
Don't forget to describe how maintainers can test your modifications!
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Proof that your changes work
|
||||
<!--
|
||||
1. PRs without proof will not be merged. Please provide evidence for every section below that applies to your change.
|
||||
2. Trusted contributors: If you have a track record of merged PRs that were properly tested and documented, maintainers may waive one or more of the proof sections below at their discretion. You are still encouraged to include whatever evidence you have, but sections may be marked `N/A — trusted contributor` with a short note.
|
||||
3. First-time contributors must provide full proof. See the Contributing Guidelines(https://github.com/portapack-mayhem/mayhem-firmware/wiki/Contributing-Guidelines) and Trusted Contributors (https://github.com/portapack-mayhem/mayhem-firmware/wiki/Trusted-Contributors) articles for details.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### 🖥️ Proof it compiles
|
||||
<!--
|
||||
Attach a log snippet showing a successful build from the final firmware size/space summary in the build output. Example: `Space remaining in flash ROM: 19552 bytes ( 1.9 % )`.
|
||||
Paste log below.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### 📱 Proof of testing on a real device
|
||||
<!--
|
||||
Attach photos, screenshots, or a short video of your changes running on actual PortaPack hardware. Emulator or simulator output is not a substitute for real-device testing.
|
||||
Paste photo / video / screenshot below
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### 📡 Proof against a real emitter/receiver (if applicable)
|
||||
<!--
|
||||
1. If your PR involves RX/TX, protocol decoding, signal generation, or any RF-related functionality, you **must** demonstrate it working against a real emitter or receiver. Include photos, videos, logs, or waterfall/spectrum screenshots.
|
||||
2. If this section does not apply to your PR, write `N/A` below and briefly explain why.
|
||||
3. Paste RF evidence, or write N/A with a short justification
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 📚 Wiki documentation commitment
|
||||
<!--
|
||||
By submitting this PR, you acknowledge that once it is merged you are responsible for creating or updating the corresponding page on the project wiki(https://github.com/portapack-mayhem/mayhem-firmware/wiki).
|
||||
Your wiki article should include:
|
||||
- A screenshot of the main app screen (strongly recommended)
|
||||
- A clear description of what the app does
|
||||
- An explanation of the controls and UI elements
|
||||
- Any known limitations, quirks, or caveats
|
||||
- Anything else a user should know to use the app effectively (dependencies, required hardware, file formats, etc.)
|
||||
- If you are modifying an existing app, make sure the wiki page reflects your changes.
|
||||
-->
|
||||
|
||||
|
||||
- [ ] I will (or already) create(d) wiki document for my newly added feature
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] Kept changes minimal and limited to necessary files
|
||||
- [ ] Verified functionality remains intact and code compiles
|
||||
- [ ] Attached proof that the code compiles successfully *(or marked N/A as a trusted contributor)*
|
||||
- [ ] Attached proof of testing on real PortaPack hardware *(or marked N/A as a trusted contributor)*
|
||||
- [ ] Attached proof of testing against a real emitter/receiver (if RF-related), or marked N/A with justification
|
||||
- [ ] I understand that by getting this PR merged, I am implicitly agreeing to create or update the corresponding wiki page (including a main-screen screenshot, description, controls, and limitations)
|
||||
- [ ] I own all rights to this code (i.e., all code contained in this PR), including compliant usage rights for third-party libraries, and I agree that this code is licensed under the license of this project (GPL-3.0).
|
||||
- [ ] If any third-party libraries are used, I confirm that their licenses comply with the requirements for contributing to this repository.
|
||||
- [ ] Reviewed the [Contributing Guidelines](https://github.com/portapack-mayhem/mayhem-firmware/wiki/Contributing-Guidelines)
|
||||
@@ -72,7 +72,7 @@ jobs:
|
||||
unzip world_map.zip -d sdcard/ADSB
|
||||
- name: Prepare Firmware ZIP
|
||||
run: |
|
||||
cp build/hackrf/firmware/hackrf_usb/hackrf_usb.dfu flashing/utils/hackrf_one_usb.dfu && cp build/hackrf/firmware/hackrf_usb/hackrf_usb.bin flashing/utils/hackrf_one_usb.bin
|
||||
mkdir -p flashing/firmware && cp build/hackrf/firmware/hackrf_usb/hackrf_usb.dfu flashing/firmware/hackrf_usb.dfu && cp build/hackrf/firmware/hackrf_usb/hackrf_usb.bin flashing/firmware/hackrf_usb.bin
|
||||
- name: Create Firmware ZIP
|
||||
run: |
|
||||
zip -j firmware.zip build/firmware/portapack-mayhem-firmware.bin && cd flashing && zip -r ../firmware.zip *
|
||||
@@ -103,6 +103,8 @@ jobs:
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Get current date
|
||||
id: date
|
||||
@@ -129,14 +131,42 @@ jobs:
|
||||
echo EOF
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
id: changelog
|
||||
# Combine all 3 device firmware bins into a single zip with device selector bat
|
||||
- name: Create Combined Firmware ZIP
|
||||
run: |
|
||||
mkdir -p firmware_combined
|
||||
unzip artifacts/firmware-default/firmware.zip -d firmware_combined
|
||||
mv firmware_combined/portapack-mayhem-firmware.bin firmware_combined/firmware/firmware_hackrf.bin
|
||||
unzip -j artifacts/firmware-portarf/firmware.zip portapack-mayhem-firmware.bin -d firmware_combined/firmware
|
||||
mv firmware_combined/firmware/portapack-mayhem-firmware.bin firmware_combined/firmware/firmware_portarf.bin
|
||||
unzip -j artifacts/firmware-hpro/firmware.zip portapack-mayhem-firmware.bin -d firmware_combined/firmware
|
||||
mv firmware_combined/firmware/portapack-mayhem-firmware.bin firmware_combined/firmware/firmware_hpro.bin
|
||||
unzip -j artifacts/firmware-hpro/firmware.zip firmware/hackrf_usb.dfu firmware/hackrf_usb.bin -d firmware_combined_hpro
|
||||
mv firmware_combined_hpro/hackrf_usb.dfu firmware_combined/firmware/hackrf_hpro_usb.dfu
|
||||
mv firmware_combined_hpro/hackrf_usb.bin firmware_combined/firmware/hackrf_hpro_usb.bin
|
||||
cd firmware_combined && zip -r ../firmware_all_devices.zip . && cd ..
|
||||
- name: Prepare release assets
|
||||
run: |
|
||||
VER="${{ steps.version_date.outputs.date }}"
|
||||
mkdir -p release_assets
|
||||
# OCI tar assets
|
||||
cp artifacts/oci-tar-default/portapack-mayhem_OCI.ppfw.tar "release_assets/OCI_hackrf_mayhem_nightly_${VER}.ppfw.tar"
|
||||
cp artifacts/oci-tar-portarf/portapack-mayhem_OCI.ppfw.tar "release_assets/OCI_portarf_mayhem_nightly_${VER}.ppfw.tar"
|
||||
cp artifacts/oci-tar-hpro/portapack-mayhem_OCI.ppfw.tar "release_assets/OCI_hpro_mayhem_nightly_${VER}.ppfw.tar"
|
||||
# Combined firmware
|
||||
cp firmware_all_devices.zip "release_assets/FIRMWARE_mayhem_nightly_${VER}.zip"
|
||||
# SD card assets
|
||||
cp artifacts/sdcard-default/sdcard.zip "release_assets/COPY_TO_SDCARD_hackrf_mayhem_nightly_${VER}.zip"
|
||||
cp artifacts/sdcard-no-map-default/sdcard-no-map.zip "release_assets/COPY_TO_SDCARD_hackrf_mayhem_nightly_${VER}-no-world-map.zip"
|
||||
cp artifacts/sdcard-portarf/sdcard.zip "release_assets/COPY_TO_SDCARD_portarf_mayhem_nightly_${VER}.zip"
|
||||
cp artifacts/sdcard-no-map-portarf/sdcard-no-map.zip "release_assets/COPY_TO_SDCARD_portarf_mayhem_nightly_${VER}-no-world-map.zip"
|
||||
cp artifacts/sdcard-hpro/sdcard.zip "release_assets/COPY_TO_SDCARD_hpro_mayhem_nightly_${VER}.zip"
|
||||
cp artifacts/sdcard-no-map-hpro/sdcard-no-map.zip "release_assets/COPY_TO_SDCARD_hpro_mayhem_nightly_${VER}-no-world-map.zip"
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: nightly-tag-${{ steps.date.outputs.date }}
|
||||
release_name: Nightly Release - ${{ steps.date.outputs.date }}
|
||||
name: Nightly Release - ${{ steps.date.outputs.date }}
|
||||
body: |
|
||||
**Nightly release - ${{ steps.date.outputs.date }}**
|
||||
This build is the latest and greatest, although may not be the most stable as this is a nightly release.
|
||||
@@ -145,114 +175,4 @@ jobs:
|
||||
${{ steps.changelog.outputs.content }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
# Default device assets
|
||||
- name: Upload Default Firmware TAR Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/oci-tar-default/portapack-mayhem_OCI.ppfw.tar
|
||||
asset_name: OCI_hackrf_mayhem_nightly_${{ steps.version_date.outputs.date }}.ppfw.tar
|
||||
asset_content_type: application/x-tar
|
||||
- name: Upload Default Firmware Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/firmware-default/firmware.zip
|
||||
asset_name: FIRMWARE_hackrf_mayhem_nightly_${{ steps.version_date.outputs.date }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload Default SD Card Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-default/sdcard.zip
|
||||
asset_name: COPY_TO_SDCARD_hackrf_mayhem_nightly_${{ steps.version_date.outputs.date }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload Default SD Card Asset - No Map
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-no-map-default/sdcard-no-map.zip
|
||||
asset_name: COPY_TO_SDCARD_hackrf_mayhem_nightly_${{ steps.version_date.outputs.date }}-no-world-map.zip
|
||||
asset_content_type: application/zip
|
||||
# PortaRF device assets
|
||||
- name: Upload PortaRF Firmware TAR Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/oci-tar-portarf/portapack-mayhem_OCI.ppfw.tar
|
||||
asset_name: OCI_portarf_mayhem_nightly_${{ steps.version_date.outputs.date }}.ppfw.tar
|
||||
asset_content_type: application/x-tar
|
||||
- name: Upload PortaRF Firmware Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/firmware-portarf/firmware.zip
|
||||
asset_name: FIRMWARE_portarf_mayhem_nightly_${{ steps.version_date.outputs.date }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload PortaRF SD Card Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-portarf/sdcard.zip
|
||||
asset_name: COPY_TO_SDCARD_portarf_mayhem_nightly_${{ steps.version_date.outputs.date }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload PortaRF SD Card Asset - No Map
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-no-map-portarf/sdcard-no-map.zip
|
||||
asset_name: COPY_TO_SDCARD_portarf_mayhem_nightly_${{ steps.version_date.outputs.date }}-no-world-map.zip
|
||||
asset_content_type: application/zip
|
||||
# HPro device assets
|
||||
- name: Upload HPro Firmware TAR Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/oci-tar-hpro/portapack-mayhem_OCI.ppfw.tar
|
||||
asset_name: OCI_hpro_mayhem_nightly_${{ steps.version_date.outputs.date }}.ppfw.tar
|
||||
asset_content_type: application/x-tar
|
||||
- name: Upload HPro Firmware Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/firmware-hpro/firmware.zip
|
||||
asset_name: FIRMWARE_hpro_mayhem_nightly_${{ steps.version_date.outputs.date }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload HPro SD Card Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-hpro/sdcard.zip
|
||||
asset_name: COPY_TO_SDCARD_hpro_mayhem_nightly_${{ steps.version_date.outputs.date }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload HPro SD Card Asset - No Map
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-no-map-hpro/sdcard-no-map.zip
|
||||
asset_name: COPY_TO_SDCARD_hpro_mayhem_nightly_${{ steps.version_date.outputs.date }}-no-world-map.zip
|
||||
asset_content_type: application/zip
|
||||
files: release_assets/*
|
||||
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
unzip world_map.zip -d sdcard/ADSB
|
||||
- name: Prepare Firmware ZIP
|
||||
run: |
|
||||
cp build/hackrf/firmware/hackrf_usb/hackrf_usb.dfu flashing/utils/hackrf_one_usb.dfu && cp build/hackrf/firmware/hackrf_usb/hackrf_usb.bin flashing/utils/hackrf_one_usb.bin
|
||||
mkdir -p flashing/firmware && cp build/hackrf/firmware/hackrf_usb/hackrf_usb.dfu flashing/firmware/hackrf_usb.dfu && cp build/hackrf/firmware/hackrf_usb/hackrf_usb.bin flashing/firmware/hackrf_usb.bin
|
||||
- name: Create Firmware ZIP
|
||||
run: |
|
||||
zip -j firmware.zip build/firmware/portapack-mayhem-firmware.bin && cd flashing && zip -r ../firmware.zip *
|
||||
@@ -86,6 +86,8 @@ jobs:
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Get current date
|
||||
id: date
|
||||
@@ -115,14 +117,42 @@ jobs:
|
||||
echo EOF
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
id: changelog
|
||||
# Combine all 3 device firmware bins into a single zip with device selector bat
|
||||
- name: Create Combined Firmware ZIP
|
||||
run: |
|
||||
mkdir -p firmware_combined
|
||||
unzip artifacts/firmware-default/firmware.zip -d firmware_combined
|
||||
mv firmware_combined/portapack-mayhem-firmware.bin firmware_combined/firmware/firmware_hackrf.bin
|
||||
unzip -j artifacts/firmware-portarf/firmware.zip portapack-mayhem-firmware.bin -d firmware_combined/firmware
|
||||
mv firmware_combined/firmware/portapack-mayhem-firmware.bin firmware_combined/firmware/firmware_portarf.bin
|
||||
unzip -j artifacts/firmware-hpro/firmware.zip portapack-mayhem-firmware.bin -d firmware_combined/firmware
|
||||
mv firmware_combined/firmware/portapack-mayhem-firmware.bin firmware_combined/firmware/firmware_hpro.bin
|
||||
unzip -j artifacts/firmware-hpro/firmware.zip firmware/hackrf_usb.dfu firmware/hackrf_usb.bin -d firmware_combined_hpro
|
||||
mv firmware_combined_hpro/hackrf_usb.dfu firmware_combined/firmware/hackrf_hpro_usb.dfu
|
||||
mv firmware_combined_hpro/hackrf_usb.bin firmware_combined/firmware/hackrf_hpro_usb.bin
|
||||
cd firmware_combined && zip -r ../firmware_all_devices.zip . && cd ..
|
||||
- name: Prepare release assets
|
||||
run: |
|
||||
VER="${{ steps.version.outputs.version }}"
|
||||
mkdir -p release_assets
|
||||
# OCI tar assets
|
||||
cp artifacts/oci-tar-default/portapack-mayhem_OCI.ppfw.tar "release_assets/OCI_hackrf_mayhem_${VER}.ppfw.tar"
|
||||
cp artifacts/oci-tar-portarf/portapack-mayhem_OCI.ppfw.tar "release_assets/OCI_portarf_mayhem_${VER}.ppfw.tar"
|
||||
cp artifacts/oci-tar-hpro/portapack-mayhem_OCI.ppfw.tar "release_assets/OCI_hpro_mayhem_${VER}.ppfw.tar"
|
||||
# Combined firmware
|
||||
cp firmware_all_devices.zip "release_assets/FIRMWARE_mayhem_${VER}.zip"
|
||||
# SD card assets
|
||||
cp artifacts/sdcard-default/sdcard.zip "release_assets/COPY_TO_SDCARD_hackrf_mayhem_${VER}.zip"
|
||||
cp artifacts/sdcard-no-map-default/sdcard-no-map.zip "release_assets/COPY_TO_SDCARD_hackrf_mayhem_${VER}-no-world-map.zip"
|
||||
cp artifacts/sdcard-portarf/sdcard.zip "release_assets/COPY_TO_SDCARD_portarf_mayhem_${VER}.zip"
|
||||
cp artifacts/sdcard-no-map-portarf/sdcard-no-map.zip "release_assets/COPY_TO_SDCARD_portarf_mayhem_${VER}-no-world-map.zip"
|
||||
cp artifacts/sdcard-hpro/sdcard.zip "release_assets/COPY_TO_SDCARD_hpro_mayhem_${VER}.zip"
|
||||
cp artifacts/sdcard-no-map-hpro/sdcard-no-map.zip "release_assets/COPY_TO_SDCARD_hpro_mayhem_${VER}-no-world-map.zip"
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.version }}
|
||||
release_name: Mayhem firmware ${{ steps.version.outputs.version }}
|
||||
name: Mayhem firmware ${{ steps.version.outputs.version }}
|
||||
body: |
|
||||
**Stable release - ${{ steps.version.outputs.version }}**
|
||||
This is a fork of the [Havoc](https://github.com/furrtek/portapack-havoc/) firmware, which itself was a fork of the [PortaPack](https://github.com/sharebrained/portapack-hackrf) firmware, an add-on for the [HackRF](http://greatscottgadgets.com/hackrf/). Please check the [readme](https://github.com/portapack-mayhem/mayhem-firmware/blob/master/README.md) for details.
|
||||
@@ -141,114 +171,4 @@ jobs:
|
||||
For certain functionality, like external apps, the world map, GPS simulator, and others you need to uncompress (using [7-zip](https://www.7-zip.org/download.html)) the files from `mayhem_vX.Y.Z_COPY_TO_SDCARD.zip` to a FAT32 formatted MicroSD card.
|
||||
draft: true
|
||||
prerelease: false
|
||||
# Default device assets
|
||||
- name: Upload Default Firmware TAR Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/oci-tar-default/portapack-mayhem_OCI.ppfw.tar
|
||||
asset_name: OCI_hackrf_mayhem_${{ steps.version.outputs.version }}.ppfw.tar
|
||||
asset_content_type: application/x-tar
|
||||
- name: Upload Default Firmware Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/firmware-default/firmware.zip
|
||||
asset_name: FIRMWARE_hackrf_mayhem_${{ steps.version.outputs.version }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload Default SD Card Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-default/sdcard.zip
|
||||
asset_name: COPY_TO_SDCARD_hackrf_mayhem_${{ steps.version.outputs.version }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload Default SD Card Asset - No Map
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-no-map-default/sdcard-no-map.zip
|
||||
asset_name: COPY_TO_SDCARD_hackrf_mayhem_${{ steps.version.outputs.version }}-no-world-map.zip
|
||||
asset_content_type: application/zip
|
||||
# PortaRF device assets
|
||||
- name: Upload PortaRF Firmware TAR Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/oci-tar-portarf/portapack-mayhem_OCI.ppfw.tar
|
||||
asset_name: OCI_portarf_mayhem_${{ steps.version.outputs.version }}.ppfw.tar
|
||||
asset_content_type: application/x-tar
|
||||
- name: Upload PortaRF Firmware Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/firmware-portarf/firmware.zip
|
||||
asset_name: FIRMWARE_portarf_mayhem_${{ steps.version.outputs.version }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload PortaRF SD Card Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-portarf/sdcard.zip
|
||||
asset_name: COPY_TO_SDCARD_portarf_mayhem_${{ steps.version.outputs.version }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload PortaRF SD Card Asset - No Map
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-no-map-portarf/sdcard-no-map.zip
|
||||
asset_name: COPY_TO_SDCARD_portarf_mayhem_${{ steps.version.outputs.version }}-no-world-map.zip
|
||||
asset_content_type: application/zip
|
||||
# HPro device assets
|
||||
- name: Upload HPro Firmware TAR Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/oci-tar-hpro/portapack-mayhem_OCI.ppfw.tar
|
||||
asset_name: OCI_hpro_mayhem_${{ steps.version.outputs.version }}.ppfw.tar
|
||||
asset_content_type: application/x-tar
|
||||
- name: Upload HPro Firmware Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/firmware-hpro/firmware.zip
|
||||
asset_name: FIRMWARE_hpro_mayhem_${{ steps.version.outputs.version }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload HPro SD Card Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-hpro/sdcard.zip
|
||||
asset_name: COPY_TO_SDCARD_hpro_mayhem_${{ steps.version.outputs.version }}.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload HPro SD Card Asset - No Map
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: artifacts/sdcard-no-map-hpro/sdcard-no-map.zip
|
||||
asset_name: COPY_TO_SDCARD_hpro_mayhem_${{ steps.version.outputs.version }}-no-world-map.zip
|
||||
asset_content_type: application/zip
|
||||
files: release_assets/*
|
||||
|
||||
@@ -1 +1 @@
|
||||
v2.3.1
|
||||
v2.3.2
|
||||
|
||||
@@ -1 +1 @@
|
||||
v2.3.2
|
||||
v2.4.0
|
||||
|
||||
@@ -83,3 +83,4 @@ venv/
|
||||
# generated bitmap arr file
|
||||
# TODO: generate bitmap during build, since we use python during build anyway, lemme know if this is a bad idea @zxkmm
|
||||
/firmware/tools/bitmap.hpp
|
||||
tmp/*
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
# PortaPack Mayhem – Agent Guidelines
|
||||
|
||||
Welcome to the PortaPack Mayhem repository. This document sets mandatory rules and best practices for human developers and AI coding assistants. It exists to prevent unverified, untested code from overwhelming the maintainers, while still enabling AI to accelerate development.
|
||||
|
||||
## 🚫 STRICTLY PROHIBITED
|
||||
|
||||
1. **No Fully Automated Pull Requests**
|
||||
Autonomous agents (bots, crawlers, automated workflows) must **never** open a Pull Request without direct human supervision, review, and explicit approval.
|
||||
|
||||
2. **No “Blind” AI-Generated Submissions**
|
||||
If you cannot explain, debug, or maintain the C++/DSP code an AI produced for you, do **not** submit it. PRs that appear to be untested, AI-only “compile-and-pray” attempts will be closed immediately.
|
||||
|
||||
3. **No Unverified Hardware Interactions**
|
||||
AI cannot test on real hardware. Do **not** submit code that has not been compiled and physically tested on a PortaPack device (or a highly accurate emulator). This includes UI rendering, RF transmission quality, and baseband stability.
|
||||
|
||||
## ✅ ENCOURAGED AI USE CASES
|
||||
|
||||
We strongly encourage using AI assistants (Copilot, ChatGPT, Claude, local LLMs) as pair-programmers. Excellent use cases include:
|
||||
|
||||
- **Bug Triage & Root-Causing:** Analyze crash logs, stack traces, and complex memory issues to identify the root cause of an open issue.
|
||||
- **Code Comprehension:** Map Mayhem’s architecture, understand M0‑M4 IPC, or break down complex DSP algorithms.
|
||||
- **Development Assistance:** Generate boilerplate UI code, write unit tests, optimize math functions, or draft documentation – provided a human reviews and refines the output.
|
||||
- **Targeted Refactoring:** Suggest cleaner, modern C++ for small legacy code segments. **Do not attempt to rewrite the entire codebase.**
|
||||
|
||||
## 📋 MANDATORY RULES FOR AI‑ASSISTED CONTRIBUTIONS
|
||||
|
||||
When submitting AI‑assisted work, you must:
|
||||
|
||||
1. **Take Full Ownership**
|
||||
You are strictly responsible for every line of code you submit, regardless of origin. Be prepared to answer detailed technical questions during review.
|
||||
|
||||
2. **Hardware Verification Required**
|
||||
In your PR, explicitly state: *“I have compiled this code and tested it on physical PortaPack hardware.”* PRs without this statement will be rejected.
|
||||
|
||||
3. **Transparency (Recommended)**
|
||||
If AI significantly helped architect a feature or fix a complex bug, mention it briefly in the PR description (e.g., *“Used an LLM to help optimize the DSP filter loop”*).
|
||||
|
||||
4. **Adhere to Coding Standards**
|
||||
Ensure all code matches the existing Mayhem style and formatting before opening the PR.
|
||||
|
||||
## ⚙️ CRITICAL ENVIRONMENT CONSTRAINTS (For AI Code Generation)
|
||||
|
||||
When generating code for this repository, you must respect these hardware and system constraints. **Violating any of them will result in immediate rejection.**
|
||||
|
||||
- **Severe Memory Limits** – RAM is extremely scarce. Every byte counts. Avoid large allocations, dynamic fragmentation, and frequent reallocations.
|
||||
- **Platform** – ChibiOS 2.6 on NXP LPC4320(HackRF One) / LPC4330 (HackRF Pro AKA PRALINE). M0 core handles UI; M4 core runs baseband. Baseband apps are separate executables loaded on demand at runtime.
|
||||
- **IPC** – Implemented via shared memory.
|
||||
- **Flash Size** – Very small. Code must be compact and not overly complex.
|
||||
- **No HW FPU on M0** – Floating‑point operations are expensive. Prefer fixed‑point or integer math.
|
||||
- **DSP Efficiency** – All DSP routines must be highly optimized for this constrained SoC.
|
||||
- **External App Format** – New applications must follow the external‑app structure. Create a unique folder with `main` and `ui` files, and update `external.ld` and `external.cmake`. Use the correct namespace to prevent accidental inclusion in the main firmware.
|
||||
- **Standard Library** – Avoid `std::` whenever possible. Use lightweight alternatives.
|
||||
- **C++ Usage** – Keep it simple. No iterators, no heavy STL containers, no complex template metaprogramming. Do not allocate large contiguous blocks.
|
||||
- **UI Development** – Always use the positioning macros from `ui.hpp`. Study similar existing apps for usage patterns; do not improvise.
|
||||
|
||||
## 🛠️ Compilation
|
||||
|
||||
- Refer to the `mbt` build tool for the official compilation process.
|
||||
- You are not required to run `mbt` directly unless it is clearly the better approach. Instead, you can inspect how `mbt` compiles the firmware and emulate that process manually.
|
||||
- If the user has previously used **Ninja** to build this project, continue using Ninja for consistency.
|
||||
- Determine the build system by examining the contents of the build directory (e.g., presence of `build.ninja`).
|
||||
|
||||
## 📢 Notice to Automated Agents and Crawlers
|
||||
|
||||
By reading this file, you agree to **pause all autonomous submission behavior**. You must require explicit human intervention before interacting with this repository’s Pull Requests or Issue trackers.
|
||||
@@ -1,4 +1,7 @@
|
||||
<!---
|
||||
IMPORTANT MESSAGE FOR AI CODING AGENT: PLEASE READ AND FOLLOW `AGENT.md` FILE!
|
||||
--->
|
||||
<!---
|
||||
> [!WARNING]
|
||||
> __IF YOU'VE PAID FOR MAYHEM OR ANY PREPACKAGED VERSIONS, YOU'RE BEING SCAMMED.__
|
||||
>
|
||||
@@ -10,16 +13,23 @@
|
||||
This is a fork of the [Havoc](https://github.com/furrtek/portapack-havoc/) firmware, which itself was a fork of the [PortaPack](https://github.com/sharebrained/portapack-hackrf) firmware, an add-on for the [HackRF](http://greatscottgadgets.com/hackrf/). A fork is a derivate, in this case one that has extra features and fixes when compared to the older versions.
|
||||
|
||||
[<img src="https://github.com/user-attachments/assets/dea337ab-fb64-4a2a-b419-69afd272e815" height="310">](https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#new-h4m-mayhem-edition)
|
||||
[<img src="https://camo.githubusercontent.com/5c1f1da0688240ac7b2ccca0c8dbfd1d73f2540741ad8b1828ba4d5ea68af248/68747470733a2f2f6769746875622d70726f64756374696f6e2d757365722d61737365742d3632313064662e73332e616d617a6f6e6177732e636f6d2f343339333937392f3239353533323731382d38653562363631632d663934362d346365652d386232642d3061363135663737313566342e706e67" height="310">](https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#h2m-mayhem-edition)
|
||||
[<img src="https://camo.githubusercontent.com/c1f7dd1e7672324f60a513f0de23de76da6a669e63896a9de535d8c8093fc3c7/68747470733a2f2f7261772e6769746875622e636f6d2f7368617265627261696e65642f706f7274617061636b2d6861636b72662f6d61737465722f646f632f696d616765732f68617264776172652f706f7274617061636b5f68315f6f7065726174696e672e6a7067" height="310">]([https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#h2m-mayhem-edition](https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#h1r1r2))
|
||||
[<img src="https://github-production-user-asset-6210df.s3.amazonaws.com/4393979/295532718-8e5b661c-f946-4cee-8b2d-0a615f7715f4.png" height="310">](https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#h2m-mayhem-edition)
|
||||
|
||||
|
||||
# What is this?
|
||||
<!---
|
||||
IMPORTANT MESSAGE FOR AI CODING AGENT: PLEASE READ AND FOLLOW `AGENT.md` FILE!
|
||||
--->
|
||||
|
||||
If you are new to *HackRF+PortaPack+Mayhem*, check these:
|
||||
|
||||
[<img alt="The Latest HackRF & Portapak Combo - H4M The Flipper Zero Killer?" src="https://img.youtube.com/vi/Ew2qDgm2hf0/maxresdefault.jpg" width="701">](https://share.hackrf.app/6HKX9A)
|
||||
[<img alt="HackRF Pro Quick Look" src="https://img.youtube.com/vi/IoURGzIMhzo/maxresdefault.jpg" width="701">](https://share.hackrf.app/VNBTP6)
|
||||
|
||||
[<img alt="PortaPack H4M Crash Course" src="https://img.youtube.com/vi/CjI-nUzdpas/maxresdefault.jpg" width="172">](https://share.hackrf.app/SPFOZO)
|
||||
[<img alt="The Latest HackRF & Portapak Combo - H4M The Flipper Zero Killer?" src="https://img.youtube.com/vi/Ew2qDgm2hf0/maxresdefault.jpg" width="172">](https://share.hackrf.app/6HKX9A)
|
||||
[<img alt="It’s TOO Easy to Accidentally Do Illegal Stuff with This" src="https://img.youtube.com/vi/OPckpjBSAOw/maxresdefault.jpg" width="172">](https://share.hackrf.app/X4D5TF)
|
||||
[<img alt="HackRF Portapack H4M - Getting Started Guide" src="https://img.youtube.com/vi/wzP0zWi85SI/maxresdefault.jpg" width="172">](https://share.hackrf.app/F9MPOO)
|
||||
|
||||
[<img alt="It’s TOO Easy to Accidentally Do Illegal Stuff with This" src="https://img.youtube.com/vi/OPckpjBSAOw/maxresdefault.jpg" width="172">](https://share.hackrf.app/X4D5TF) [<img alt="HackRF Portapack H4M - Getting Started Guide" src="https://img.youtube.com/vi/wzP0zWi85SI/maxresdefault.jpg" width="172">](https://share.hackrf.app/F9MPOO) [<img alt="The new HackRF Portapack H4M" src="https://img.youtube.com/vi/onQRdCITmuk/maxresdefault.jpg" width="172">](https://share.hackrf.app/0JUHZ6) [<img alt="HackRF 101 : Everything You Need to Know to Get Started!" src="https://img.youtube.com/vi/xGR_PMD9LeU/maxresdefault.jpg" width="172">](https://share.hackrf.app/C0J6ZR)
|
||||
|
||||
# Frequently Asked Questions
|
||||
|
||||
@@ -28,11 +38,11 @@ This repository expands upon the previous work by many people and aims to consta
|
||||
## What to buy?
|
||||
|
||||
<!---not direct to h4m but to opensourcesdrlab https://share.hackrf.app/TUOLYI--->
|
||||
:heavy_check_mark:  The fabulous H4M [complete](https://share.hackrf.app/9UMBN5) or [upgrade](https://share.hackrf.app/30CQ55), featuring numerous improvements and accessories. Sold by our friends at [OpenSourceSDRLab](https://share.hackrf.app/99SAMT). Join their giveaways on discord (check the badge on top). _EU customers_ can purchase via [Lab401](https://share.hackrf.app/0CI2CR).
|
||||
:heavy_check_mark:  The fabulous H4M [complete](https://share.hackrf.app/O4OC90) or [upgrade](https://share.hackrf.app/OCSJYI), featuring numerous improvements and accessories. Sold by our friends at [OpenSourceSDRLab](https://share.hackrf.app/99SAMT). Join their giveaways on discord (check the badge on top). _EU customers_ can purchase via [Lab401](https://share.hackrf.app/0CI2CR).
|
||||
|
||||
:heavy_check_mark: A recommended one is this [PortaPack H2](https://www.ebay.com/itm/116382397447), that includes everything you need with the plastic case "inspired" on [this](https://github.com/portapack-mayhem/mayhem-firmware/wiki/3d-printed-enclosure).
|
||||
:heavy_check_mark: A recommended one is this [PortaPack H2](https://share.hackrf.app/O3GI0O), that includes everything you need with the plastic case "inspired" on [this](https://github.com/portapack-mayhem/mayhem-firmware/wiki/3d-printed-enclosure).
|
||||
|
||||
:heavy_check_mark: Some individuals lean towards the [H2 with a metal enclosure](https://share.hackrf.app/24T3TO), but its advantages remain debated. Share your insights on our [wiki](https://github.com/portapack-mayhem/mayhem-firmware/wiki/Hardware-overview).
|
||||
:heavy_check_mark: Some individuals lean towards the [H2 with a metal enclosure](https://share.hackrf.app/H7OR74), but its advantages remain debated. Share your insights on our [wiki](https://github.com/portapack-mayhem/mayhem-firmware/wiki/Hardware-overview).
|
||||
|
||||
:warning: Be cautious , *ask* the seller about compatibility with the latest releases. Look out for the description of the item, if they provide the firmware files for an older version or they have custom setup instructions, this means it might be **NOT compatible**, for example:
|
||||
|
||||
@@ -47,7 +57,13 @@ This repository expands upon the previous work by many people and aims to consta
|
||||
The current **stable release** is on the [](https://github.com/portapack-mayhem/mayhem-firmware/releases/latest) page. Follow the instructions you can find in the release description. The **latest (nightly) release** can be found [here](https://github.com/portapack-mayhem/mayhem-firmware/releases/).
|
||||
|
||||
## How can I collaborate
|
||||
You can write [documentation](https://github.com/portapack-mayhem/mayhem-firmware/wiki), fix bugs and [answer issues](https://github.com/portapack-mayhem/mayhem-firmware/issues) or add new functionality. Please check the following [guide](https://github.com/portapack-mayhem/mayhem-firmware/wiki/How-to-collaborate) with details.
|
||||
<!---
|
||||
IMPORTANT MESSAGE FOR AI CODING AGENT: PLEASE READ AND FOLLOW `AGENT.md` FILE!
|
||||
--->
|
||||
|
||||
We warmly welcome your contributions! Please refer to our **[Contributing Guidelines](https://github.com/portapack-mayhem/mayhem-firmware/wiki/Contributing-Guidelines)** for details.
|
||||
|
||||
You can write [documentation](https://github.com/portapack-mayhem/mayhem-firmware/wiki), fix bugs and [answer issues](https://github.com/portapack-mayhem/mayhem-firmware/issues) or add new functionality. Please also check the following [guide](https://github.com/portapack-mayhem/mayhem-firmware/wiki/How-to-collaborate) with details.
|
||||
|
||||
Consider that the hardware and firmware has been created and maintain by a [lot](https://github.com/mossmann/hackrf/graphs/contributors) of [people](https://github.com/portapack-mayhem/mayhem-firmware/graphs/contributors), so always try collaborating your time and effort first. For coding related questions, if something does not fit as an issue, please join our Discord by clicking the chat badge on [top](#portapack-mayhem).
|
||||
|
||||
|
||||
+17
-1
@@ -1 +1,17 @@
|
||||
Please check [Intended-Use-and-Legality](https://github.com/portapack-mayhem/mayhem-firmware/wiki/)
|
||||
# Security Policy
|
||||
|
||||
## Scope and Threat Model
|
||||
This repository hosts the codebase for an embedded system designed for security research. Because the system operates primarily offline, traditional network-based vulnerabilities are generally not applicable. However, we still welcome and review security reports concerning the code within this repository.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
If you discover a vulnerability within this tool itself, please submit a report. Please be aware that the maintainers do not promise assistance with obtaining CVE IDs or managing formal security advisories.
|
||||
|
||||
## Out of Scope
|
||||
* **Vulnerabilities found *using* this tool:** Please do not submit reports here for vulnerabilities you have discovered in other systems or targets using this tool. This channel is strictly for reporting vulnerabilities found *in* the tool itself.
|
||||
* **Other Repositories:** For security issues concerning related tools, such as MayhemHub, please submit your reports directly to their respective repositories.
|
||||
|
||||
## Research Attribution
|
||||
If you utilize this tool to successfully discover vulnerabilities in external systems, we would greatly appreciate it if you credit or mention our project in your published research or write-ups.
|
||||
|
||||
## Legal and Security Disclaimer
|
||||
For comprehensive guidelines regarding the legal and secure usage of this tool, as well as our full liability disclaimer, please refer to: [Intended-Use-and-Legality](https://github.com/portapack-mayhem/mayhem-firmware/wiki/). Users are expected to comply with all applicable laws and regulations when using this software and/or hardware.
|
||||
|
||||
@@ -57,6 +57,8 @@ add_subdirectory(baseband)
|
||||
add_subdirectory(standalone)
|
||||
add_subdirectory(test)
|
||||
|
||||
add_dependencies(application.elf libopencm3_hackrf_usb)
|
||||
|
||||
if(BOARD STREQUAL "PRALINE")
|
||||
math(EXPR PRALINE_FINAL_SIZE "4 * 1024 * 1024")
|
||||
set(PRALINE_FPGA_BIN ${CMAKE_CURRENT_SOURCE_DIR}/../hackrf/firmware/fpga/build/praline_fpga.bin)
|
||||
|
||||
@@ -192,6 +192,7 @@ set(CPPSRC
|
||||
${COMMON}/battery.cpp
|
||||
${COMMON}/performance_counter.cpp
|
||||
${COMMON}/bmpfile.cpp
|
||||
${COMMON}/gpio.cpp
|
||||
app_settings.cpp
|
||||
audio.cpp
|
||||
baseband_api.cpp
|
||||
@@ -238,7 +239,6 @@ set(CPPSRC
|
||||
serializer.cpp
|
||||
spectrum_color_lut.cpp
|
||||
string_format.cpp
|
||||
temperature_logger.cpp
|
||||
theme.cpp
|
||||
touch.cpp
|
||||
tone_key.cpp
|
||||
@@ -279,16 +279,12 @@ set(CPPSRC
|
||||
ui/ui_tone_key.cpp
|
||||
ui/ui_transmitter.cpp
|
||||
ui/ui_bmpview.cpp
|
||||
apps/ais_app.cpp
|
||||
apps/analog_audio_app.cpp
|
||||
apps/ble_rx_app.cpp
|
||||
apps/ble_tx_app.cpp
|
||||
apps/capture_app.cpp
|
||||
apps/pocsag_app.cpp
|
||||
apps/ui_about_simple.cpp
|
||||
apps/ui_adsb_rx.cpp
|
||||
apps/ui_aprs_rx.cpp
|
||||
apps/ui_aprs_tx.cpp
|
||||
apps/ui_battinfo.cpp
|
||||
apps/ui_bmp_file_viewer.cpp
|
||||
apps/ui_btle_rx.cpp
|
||||
@@ -493,7 +489,10 @@ add_executable(${PROJECT_NAME}.elf ${CSRC} ${CPPSRC} ${ASMSRC})
|
||||
target_link_options(${PROJECT_NAME}.elf PRIVATE
|
||||
"LINKER:--defsym,LD_FLASH_SIZE=${FLASH_BYTES_LIMIT_SIZE}"
|
||||
)
|
||||
set_target_properties(${PROJECT_NAME}.elf PROPERTIES LINK_DEPENDS ${LDSCRIPT})
|
||||
# NB: LPC43xx_M0.ld does INCLUDE external.ld, so that one has to be listed too -
|
||||
# otherwise editing the external app section rules silently does not relink.
|
||||
set_target_properties(${PROJECT_NAME}.elf PROPERTIES
|
||||
LINK_DEPENDS "${LDSCRIPT};${CMAKE_CURRENT_SOURCE_DIR}/external/external.ld")
|
||||
add_definitions(${DEFS})
|
||||
include_directories(. ${INCDIR})
|
||||
link_directories(${LLIBDIR})
|
||||
@@ -512,3 +511,5 @@ add_custom_target(
|
||||
${PROJECT_NAME}
|
||||
DEPENDS ${PROJECT_NAME}.bin
|
||||
)
|
||||
|
||||
add_dependencies(${PROJECT_NAME} baseband)
|
||||
|
||||
@@ -50,6 +50,9 @@ void BoundSetting::parse(std::string_view value) {
|
||||
case SettingType::I64:
|
||||
parse_int(value, as<int64_t>());
|
||||
break;
|
||||
case SettingType::U64:
|
||||
parse_int(value, as<uint64_t>());
|
||||
break;
|
||||
case SettingType::I32:
|
||||
parse_int(value, as<int32_t>());
|
||||
break;
|
||||
@@ -87,6 +90,9 @@ void BoundSetting::write(File& file) const {
|
||||
case SettingType::I64:
|
||||
file.write(to_string_dec_int(as<int64_t>(), buffer, length), length);
|
||||
break;
|
||||
case SettingType::U64:
|
||||
file.write(to_string_dec_uint(as<uint64_t>(), buffer, length), length);
|
||||
break;
|
||||
case SettingType::I32:
|
||||
file.write(to_string_dec_int(as<int32_t>(), buffer, length), length);
|
||||
break;
|
||||
@@ -97,9 +103,8 @@ void BoundSetting::write(File& file) const {
|
||||
file.write(to_string_dec_uint(as<uint8_t>(), buffer, length), length);
|
||||
break;
|
||||
case SettingType::String: {
|
||||
const auto& str = as<std::string>();
|
||||
file.write(str.data(), str.length());
|
||||
break;
|
||||
file.write_line(as<std::string>());
|
||||
return;
|
||||
}
|
||||
case SettingType::Bool:
|
||||
file.write(as<bool>() ? "1" : "0", 1);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <variant>
|
||||
|
||||
#include "file.hpp"
|
||||
#include "hackrf_hal.hpp"
|
||||
#include "max283x.hpp"
|
||||
#include "string_format.hpp"
|
||||
|
||||
@@ -47,6 +48,7 @@ class BoundSetting {
|
||||
/* The type of bound setting. */
|
||||
enum class SettingType : uint8_t {
|
||||
I64,
|
||||
U64,
|
||||
I32,
|
||||
U32,
|
||||
U8,
|
||||
@@ -59,6 +61,9 @@ class BoundSetting {
|
||||
BoundSetting(std::string_view name, int64_t* target)
|
||||
: name_{name}, target_{target}, type_{SettingType::I64} {}
|
||||
|
||||
BoundSetting(std::string_view name, uint64_t* target)
|
||||
: name_{name}, target_{target}, type_{SettingType::U64} {}
|
||||
|
||||
BoundSetting(std::string_view name, int32_t* target)
|
||||
: name_{name}, target_{target}, type_{SettingType::I32} {}
|
||||
|
||||
@@ -134,7 +139,7 @@ struct AppSettings {
|
||||
uint8_t vga = 32;
|
||||
uint8_t rx_amp = 0;
|
||||
uint8_t tx_amp = 0;
|
||||
uint8_t tx_gain = 35;
|
||||
uint8_t tx_gain = hackrf::one::default_tx_gain_db;
|
||||
uint32_t channel_bandwidth = 1;
|
||||
uint32_t rx_frequency;
|
||||
uint32_t tx_frequency;
|
||||
|
||||
@@ -199,6 +199,55 @@ SPECOptionsView::SPECOptionsView(
|
||||
view->set_spec_iq_phase_calibration_value(view->get_spec_iq_phase_calibration_value()); // initialize iq_phase_calibration in radio
|
||||
}
|
||||
|
||||
/* PralineOptionsView *******************************************************/
|
||||
|
||||
#ifdef PRALINE
|
||||
PralineOptionsView::PralineOptionsView(Rect parent_rect, const Style* style) {
|
||||
set_style(style);
|
||||
set_parent_rect(parent_rect);
|
||||
add_children({&label_sr, &options_sr, &label_dc, &options_dc,
|
||||
&label_qi, &options_qi, &label_qs, &options_qs});
|
||||
|
||||
// READ the current state from hardware
|
||||
fpga_reg_1 = radio::debug::fpga::register_read(1);
|
||||
|
||||
// INITIALIZE UI WIDGETS based on read bits
|
||||
options_dc.set_by_value((fpga_reg_1 & 0x01) ? 1 : 0); // Bit 0
|
||||
options_qi.set_by_value((fpga_reg_1 & 0x02) ? 1 : 0); // Bit 1
|
||||
options_qs.set_by_value((fpga_reg_1 & 0x04) ? 1 : 0); // Bit 2
|
||||
options_sr.set_value(receiver_model.sampling_rate());
|
||||
|
||||
options_sr.on_change = [this](int32_t v) { receiver_model.set_sampling_rate(static_cast<uint32_t>(v)); };
|
||||
options_dc.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
if (v)
|
||||
fpga_reg_1 |= 0x01;
|
||||
else
|
||||
fpga_reg_1 &= ~0x01;
|
||||
update_fpga_ctrl();
|
||||
};
|
||||
|
||||
options_qi.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
if (v)
|
||||
fpga_reg_1 |= 0x02;
|
||||
else
|
||||
fpga_reg_1 &= ~0x02;
|
||||
update_fpga_ctrl();
|
||||
};
|
||||
|
||||
options_qs.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
if (v)
|
||||
fpga_reg_1 |= 0x04;
|
||||
else
|
||||
fpga_reg_1 &= ~0x04;
|
||||
update_fpga_ctrl();
|
||||
};
|
||||
}
|
||||
|
||||
void PralineOptionsView::update_fpga_ctrl() {
|
||||
radio::debug::fpga::register_write(1, fpga_reg_1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* AnalogAudioView *******************************************************/
|
||||
|
||||
AnalogAudioView::AnalogAudioView(
|
||||
@@ -217,7 +266,13 @@ AnalogAudioView::AnalogAudioView(
|
||||
&field_volume,
|
||||
&text_ctcss,
|
||||
&record_view,
|
||||
&waterfall});
|
||||
#ifdef PRALINE
|
||||
&waterfall,
|
||||
&button_pro
|
||||
#else
|
||||
&waterfall
|
||||
#endif
|
||||
});
|
||||
|
||||
// Filename Datetime and Frequency
|
||||
record_view.set_filename_date_frequency(true);
|
||||
@@ -225,6 +280,12 @@ AnalogAudioView::AnalogAudioView(
|
||||
field_frequency.on_show_options = [this]() {
|
||||
this->on_show_options_frequency();
|
||||
};
|
||||
field_frequency.changing = [this](rf::Frequency frequency) {
|
||||
return this->on_frequency_changed(frequency);
|
||||
};
|
||||
field_frequency.entered = [this](rf::Frequency frequency) {
|
||||
this->set_frequency_absolute(frequency);
|
||||
};
|
||||
|
||||
field_lna.on_show_options = [this]() {
|
||||
this->on_show_options_rf_gain();
|
||||
@@ -253,13 +314,20 @@ AnalogAudioView::AnalogAudioView(
|
||||
};
|
||||
|
||||
waterfall.on_select = [this](int32_t offset) {
|
||||
field_frequency.set_value(receiver_model.target_frequency() + offset);
|
||||
field_frequency.set_value(
|
||||
field_frequency.value() + offset * receiver_model.frequency_step());
|
||||
};
|
||||
waterfall.set_live_tuning(true);
|
||||
|
||||
#ifdef PRALINE
|
||||
button_pro.on_select = [this](Button&) { this->on_show_options_praline(); };
|
||||
#endif
|
||||
|
||||
audio::output::start();
|
||||
|
||||
// This call starts the correct baseband image to run
|
||||
// and sets the radio up as necessary for the given modulation.
|
||||
sliding_center_frequency = receiver_model.target_frequency();
|
||||
on_modulation_changed(modulation);
|
||||
}
|
||||
|
||||
@@ -269,7 +337,7 @@ AnalogAudioView::AnalogAudioView(
|
||||
: AnalogAudioView(nav) {
|
||||
// Settings to override when launched from another app (versus from AppSettings .ini file)
|
||||
// TODO: Which other settings make sense to override?
|
||||
field_frequency.set_value(override.frequency_app_override);
|
||||
set_frequency_absolute(override.frequency_app_override);
|
||||
on_frequency_step_changed(override.frequency_step);
|
||||
options_modulation.set_by_value(toUType(override.mode));
|
||||
}
|
||||
@@ -360,10 +428,10 @@ void AnalogAudioView::on_baseband_bandwidth_changed(uint32_t bandwidth_hz) {
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_modulation_changed(ReceiverModel::Mode modulation) {
|
||||
baseband::spectrum_streaming_stop();
|
||||
waterfall.stop();
|
||||
update_modulation(modulation);
|
||||
on_show_options_modulation();
|
||||
baseband::spectrum_streaming_start();
|
||||
waterfall.start();
|
||||
}
|
||||
|
||||
void AnalogAudioView::remove_options_widget() {
|
||||
@@ -514,10 +582,14 @@ void AnalogAudioView::update_modulation(ReceiverModel::Mode modulation) {
|
||||
receiver_model.set_sampling_rate(is_wideband_spectrum_mode ? spec_bw : 3072000);
|
||||
receiver_model.set_baseband_bandwidth(is_wideband_spectrum_mode ? spec_bw / 2 : 1750000);
|
||||
|
||||
receiver_model.set_hidden_offset(modulation == ReceiverModel::Mode::AMAudioFMApt ? -2200 : 0); // wefax needs to be shifted, see wefax rx app.
|
||||
reset_sliding_frequency(modulation);
|
||||
|
||||
receiver_model.enable();
|
||||
|
||||
if (sliding_enabled) {
|
||||
baseband::set_audio_ddc_frequency(0);
|
||||
}
|
||||
|
||||
// TODO: This doesn't belong here! There's a better way.
|
||||
size_t sampling_rate = 0;
|
||||
switch (modulation) {
|
||||
@@ -551,6 +623,70 @@ void AnalogAudioView::handle_coded_squelch(uint32_t value) {
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_freqchg(int64_t freq) {
|
||||
field_frequency.set_value(freq);
|
||||
set_frequency_absolute(freq);
|
||||
}
|
||||
|
||||
void AnalogAudioView::set_frequency_absolute(rf::Frequency frequency) {
|
||||
if (!sliding_enabled) {
|
||||
field_frequency.set_value(frequency);
|
||||
return;
|
||||
}
|
||||
|
||||
sliding_center_frequency = frequency;
|
||||
|
||||
/* set_value() does not call on_change when the displayed frequency is
|
||||
* already equal, so reset the hardware and DDC explicitly in that case. */
|
||||
if (field_frequency.value() == frequency) {
|
||||
receiver_model.set_target_frequency_with_hidden_offset(frequency, 0);
|
||||
baseband::set_audio_ddc_frequency(0);
|
||||
} else {
|
||||
field_frequency.set_value(frequency);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AnalogAudioView::sliding_limit() const {
|
||||
const bool zoom_x2 =
|
||||
receiver_model.modulation() == ReceiverModel::Mode::AMAudio &&
|
||||
previous_zoom != 0;
|
||||
return zoom_x2 ? sliding_limit_zoom_x2 : sliding_limit_zoom_x1;
|
||||
}
|
||||
|
||||
void AnalogAudioView::reset_sliding_frequency(ReceiverModel::Mode modulation) {
|
||||
sliding_enabled =
|
||||
modulation == ReceiverModel::Mode::AMAudio ||
|
||||
modulation == ReceiverModel::Mode::NarrowbandFMAudio;
|
||||
sliding_center_frequency = receiver_model.target_frequency();
|
||||
|
||||
/* AMFM keeps its existing Wefax offset; sliding applies to AM and NFM. */
|
||||
receiver_model.set_hidden_offset(
|
||||
modulation == ReceiverModel::Mode::AMAudioFMApt ? -2200 : 0);
|
||||
}
|
||||
|
||||
bool AnalogAudioView::on_frequency_changed(rf::Frequency frequency) {
|
||||
if (!sliding_enabled)
|
||||
return false;
|
||||
|
||||
const auto limit = sliding_limit();
|
||||
int64_t offset = frequency - sliding_center_frequency;
|
||||
if (offset > limit) {
|
||||
sliding_center_frequency = frequency - limit;
|
||||
offset = limit;
|
||||
} else if (offset < -limit) {
|
||||
sliding_center_frequency = frequency + limit;
|
||||
offset = -limit;
|
||||
}
|
||||
|
||||
/* Store the displayed frequency and retune the hardware centre atomically. */
|
||||
receiver_model.set_target_frequency_with_hidden_offset(
|
||||
frequency, sliding_center_frequency - frequency);
|
||||
baseband::set_audio_ddc_frequency(static_cast<int32_t>(offset));
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef PRALINE
|
||||
void AnalogAudioView::on_show_options_praline() {
|
||||
set_options_widget(std::make_unique<PralineOptionsView>(options_view_rect, Theme::getInstance()->option_active));
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -37,6 +37,38 @@ namespace ui {
|
||||
|
||||
class AnalogAudioView;
|
||||
|
||||
#ifdef PRALINE
|
||||
class PralineOptionsView : public View {
|
||||
public:
|
||||
PralineOptionsView(Rect parent_rect, const Style* style);
|
||||
|
||||
private:
|
||||
// Layout: SR (Sample Rate), DC (DC Block), QI (Q-Invert), QS (Quarter Shift), D (Decim)
|
||||
Text label_sr{{UI_POS_X(0), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)}, "SR"};
|
||||
|
||||
// Parameters: Position, Length (in chars), Range, Step, and default value
|
||||
NumberField options_sr{
|
||||
{UI_POS_X(3), UI_POS_Y(0)},
|
||||
8, // Number of digits to show
|
||||
{0, 40000000}, // Range: 0 to 40,000 kHz
|
||||
100, // Step: 100 Hz
|
||||
' ' // Fix: Single quotes for char
|
||||
};
|
||||
|
||||
Text label_dc{{UI_POS_X(14), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)}, "DC"};
|
||||
OptionsField options_dc{{UI_POS_X(16), UI_POS_Y(0)}, 2, {{"Of", 0}, {"On", 1}}};
|
||||
|
||||
Text label_qi{{UI_POS_X(20), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)}, "QI"};
|
||||
OptionsField options_qi{{UI_POS_X(22), UI_POS_Y(0)}, 2, {{"Of", 0}, {"On", 1}}};
|
||||
|
||||
Text label_qs{{UI_POS_X(26), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)}, "QS"};
|
||||
OptionsField options_qs{{UI_POS_X(28), UI_POS_Y(0)}, 2, {{"Of", 0}, {"On", 1}}};
|
||||
|
||||
uint8_t fpga_reg_1{0x00}; // Tracks DC, QI, QS bits
|
||||
void update_fpga_ctrl();
|
||||
};
|
||||
#endif
|
||||
|
||||
class AMOptionsView : public View {
|
||||
public:
|
||||
AMOptionsView(AnalogAudioView* view, Rect parent_rect, const Style* style);
|
||||
@@ -222,6 +254,11 @@ class AnalogAudioView : public View {
|
||||
uint8_t get_previous_zoom_option();
|
||||
void set_previous_zoom_option(uint8_t zoom);
|
||||
|
||||
#ifdef PRALINE
|
||||
Button button_pro{{UI_POS_X(12), UI_POS_Y(2), UI_POS_WIDTH(3), UI_POS_HEIGHT(1)}, "PRO"};
|
||||
void on_show_options_praline();
|
||||
#endif
|
||||
|
||||
private:
|
||||
static constexpr ui::Dim header_height = 3 * 16;
|
||||
|
||||
@@ -232,6 +269,10 @@ class AnalogAudioView : public View {
|
||||
uint8_t zoom_factor_amfm{0}; // initial zoom factor in AMFM mode
|
||||
uint8_t previous_AM_mode_option{0}; // GUI 5 AM modes : (0..4 ) (DSB9K, DSB6K, USB,LSB, CW). Used to select proper FIR filter (0..11) AM mode + offset 0 (zoom+1) or +6 (if zoom+2)
|
||||
uint8_t previous_zoom{0}; // GUI ZOOM+1, ZOOM+2 , equivalent to two values offset 0 (zoom+1) or +6 (if zoom+2)
|
||||
static constexpr int32_t sliding_limit_zoom_x1 = 50000;
|
||||
static constexpr int32_t sliding_limit_zoom_x2 = 30000;
|
||||
rf::Frequency sliding_center_frequency{0};
|
||||
bool sliding_enabled{false};
|
||||
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_audio",
|
||||
@@ -317,6 +358,10 @@ class AnalogAudioView : public View {
|
||||
void handle_coded_squelch(uint32_t value);
|
||||
|
||||
void on_freqchg(int64_t freq);
|
||||
bool on_frequency_changed(rf::Frequency frequency);
|
||||
void set_frequency_absolute(rf::Frequency frequency);
|
||||
int32_t sliding_limit() const;
|
||||
void reset_sliding_frequency(ReceiverModel::Mode modulation);
|
||||
|
||||
MessageHandlerRegistration message_handler_coded_squelch{
|
||||
Message::ID::CodedSquelch,
|
||||
|
||||
@@ -645,6 +645,20 @@ BLERxView::BLERxView(NavigationView& nav)
|
||||
options_sort.set_selected_index(sort_index, true);
|
||||
options_filter.set_selected_index(filter_index, true);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Handle Max Recent Entries
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
// Max Recent Entries UI widget
|
||||
add_child(&label_max_entries);
|
||||
add_child(&field_max_entries);
|
||||
field_max_entries.set_value(max_recent_entries);
|
||||
|
||||
// Define what happens when the user changes the number
|
||||
field_max_entries.on_change = [this](int32_t v) {
|
||||
max_recent_entries = (size_t)v;
|
||||
};
|
||||
|
||||
// Auto-configure modem for LCR RX (will be removed later)
|
||||
baseband::set_btlerx(channel_number);
|
||||
|
||||
@@ -819,6 +833,10 @@ void BLERxView::on_data(BlePacketData* packet) {
|
||||
recent.push_front(*it);
|
||||
recent.erase(it);
|
||||
} else {
|
||||
// Enforce limit
|
||||
while (recent.size() >= max_recent_entries) {
|
||||
recent.pop_back();
|
||||
}
|
||||
recent.emplace_front(key);
|
||||
truncate_entries(recent);
|
||||
}
|
||||
@@ -887,6 +905,9 @@ void BLERxView::on_filter_change(std::string value) {
|
||||
}
|
||||
|
||||
void BLERxView::on_file_changed(const std::filesystem::path& new_file_path) {
|
||||
// Clear searchList
|
||||
searchList.clear();
|
||||
|
||||
file_path = new_file_path;
|
||||
found_count = 0;
|
||||
total_count = 0;
|
||||
@@ -919,8 +940,10 @@ void BLERxView::on_file_changed(const std::filesystem::path& new_file_path) {
|
||||
break;
|
||||
}
|
||||
|
||||
searchList.push_back(currentLine);
|
||||
total_count++;
|
||||
if (searchList.size() < max_recent_entries) {
|
||||
searchList.push_back(currentLine);
|
||||
total_count++;
|
||||
}
|
||||
|
||||
bytePos += bytesRead;
|
||||
|
||||
@@ -940,6 +963,21 @@ void BLERxView::on_timer() {
|
||||
channel_number = (channel_number < 39) ? channel_number + 1 : 37;
|
||||
}
|
||||
}
|
||||
|
||||
// Debug: Check heap status every ~1 second
|
||||
static int heap_check_counter = 0;
|
||||
if (++heap_check_counter >= 60) {
|
||||
heap_check_counter = 0;
|
||||
size_t heap_free = chCoreStatus();
|
||||
if (heap_free < 4096) { // Less than 4KB free
|
||||
// Emergency: clear old entries
|
||||
while (recent.size() > (max_recent_entries - 1)) {
|
||||
recent.pop_back();
|
||||
}
|
||||
recent_entries_view.set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
if (ble_rx_error != BLE_RX_NO_ERROR) {
|
||||
if (ble_rx_error == BLE_RX_LIST_FILENAME_EMPTY_ERROR) {
|
||||
nav_.display_modal("Error", "List filename is empty !");
|
||||
@@ -1059,7 +1097,6 @@ bool BLERxView::updateEntry(const BlePacketData* packet, BleRecentEntry& entry,
|
||||
entry.dbValue = packet->max_dB - (receiver_model.lna() + receiver_model.vga() + (receiver_model.rf_amp() ? 14 : 0));
|
||||
entry.timestamp = to_string_timestamp(rtc_time::now());
|
||||
entry.dataString = data_string;
|
||||
|
||||
entry.packetData.type = packet->type;
|
||||
entry.packetData.size = packet->size;
|
||||
entry.packetData.dataLen = packet->dataLen;
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
|
||||
#include "recent_entries.hpp"
|
||||
|
||||
// Add for heap debugging
|
||||
// For ChibiOS core functions
|
||||
#include "ch.h"
|
||||
#include "chcore.h"
|
||||
#include "chheap.h"
|
||||
|
||||
class BLELogger {
|
||||
public:
|
||||
Optional<File::Error> append(const std::filesystem::path& filename) {
|
||||
@@ -90,6 +96,7 @@ struct BleRecentEntry {
|
||||
uint64_t uniqueKey;
|
||||
int dbValue;
|
||||
BlePacketData packetData;
|
||||
|
||||
std::string timestamp;
|
||||
std::string dataString;
|
||||
std::string nameString;
|
||||
@@ -315,10 +322,10 @@ class BLERxView : public View {
|
||||
{UI_POS_X(21), UI_POS_Y(0)}};
|
||||
|
||||
RSSI rssi{
|
||||
{UI_POS_X(24), 0, UI_POS_WIDTH_REMAINING(6), 4}};
|
||||
{UI_POS_X(24), 0, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||
|
||||
Channel channel{
|
||||
{UI_POS_X(24), 5, UI_POS_WIDTH_REMAINING(6), 4}};
|
||||
{UI_POS_X(24), 5, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||
|
||||
Labels label_sort{
|
||||
{{UI_POS_X(0), UI_POS_Y(1)}, "Sort:", Theme::getInstance()->fg_light->foreground}};
|
||||
@@ -426,6 +433,20 @@ class BLERxView : public View {
|
||||
[this](const Message* const) {
|
||||
this->on_timer();
|
||||
}};
|
||||
|
||||
// Widget to control the list limit
|
||||
Labels label_max_entries{
|
||||
{{UI_POS_X(22), 10 * 8 - 2}, "List:", Theme::getInstance()->fg_light->foreground}};
|
||||
NumberField field_max_entries{
|
||||
{UI_POS_X(28), 10 * 8 - 2}, // Correct: Position (x, y)
|
||||
2, // Number of digits
|
||||
{5, 64}, // Range (min, max) <- Coincides with max_entries
|
||||
1, // Step size
|
||||
' ' // Filler character
|
||||
};
|
||||
|
||||
// Variable to store the current limit
|
||||
size_t max_recent_entries = 25;
|
||||
}; /* BLERxView */
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -116,7 +116,7 @@ static std::uint64_t get_freq_by_channel_number(uint8_t channel_number) {
|
||||
freq_hz = 2'428'000'000ull + (channel_number - 11) * 2'000'000ull;
|
||||
break;
|
||||
default:
|
||||
freq_hz = UINT64_MAX;
|
||||
freq_hz = 2'402'000'000ull; // Default to channel 37 frequency if invalid channel number
|
||||
}
|
||||
|
||||
return freq_hz;
|
||||
@@ -199,6 +199,7 @@ void BLETxView::send_packet() {
|
||||
generateRandomMacAddress(randomMac);
|
||||
|
||||
char advertisementData[63] = {0};
|
||||
packets[current_packet].advertisementData[62] = '\0';
|
||||
strcpy(advertisementData, packets[current_packet].advertisementData);
|
||||
|
||||
// TODO: Make this a checkbox.
|
||||
@@ -253,7 +254,7 @@ void BLETxView::send_packet() {
|
||||
}
|
||||
|
||||
void BLETxView::start() {
|
||||
if (file_path.empty()) {
|
||||
if (file_path.empty() || num_packets == 0) {
|
||||
file_error();
|
||||
check_loop.set_value(false);
|
||||
return;
|
||||
@@ -265,6 +266,8 @@ void BLETxView::start() {
|
||||
button_play.set_bitmap(&bitmap_stop);
|
||||
is_running = true;
|
||||
|
||||
advCount = 0;
|
||||
|
||||
send_packet();
|
||||
}
|
||||
|
||||
@@ -295,55 +298,61 @@ void BLETxView::on_timer() {
|
||||
void BLETxView::on_tx_progress(const bool done, uint32_t progress) {
|
||||
// TODO: make use of progress variable
|
||||
(void)progress;
|
||||
if (!is_active() || num_packets == 0) {
|
||||
return;
|
||||
}
|
||||
if (done) {
|
||||
if (is_active()) {
|
||||
transmitter_model.disable();
|
||||
|
||||
if (auto_channel) {
|
||||
switch (advCount) {
|
||||
case 0:
|
||||
channel_number = 37;
|
||||
break;
|
||||
case 1:
|
||||
channel_number = 38;
|
||||
break;
|
||||
case 2:
|
||||
channel_number = 39;
|
||||
break;
|
||||
}
|
||||
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
|
||||
advCount++;
|
||||
if (advCount == 3) {
|
||||
channel_number = 37;
|
||||
packet_counter--;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
if (packet_counter > 0) packet_counter--;
|
||||
packetDone = true;
|
||||
advCount = 0;
|
||||
} else {
|
||||
channel_number = 37 + advCount;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
send_packet();
|
||||
}
|
||||
} else if (all_channels) {
|
||||
advCount++;
|
||||
if (advCount == 40) {
|
||||
channel_number = 0;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
if (packet_counter > 0) packet_counter--;
|
||||
packetDone = true;
|
||||
advCount = 0;
|
||||
} else {
|
||||
channel_number = advCount;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
send_packet();
|
||||
advCount++;
|
||||
}
|
||||
} else {
|
||||
packet_counter--;
|
||||
if (packet_counter > 0) packet_counter--;
|
||||
packetDone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reached end of current packet repeats.
|
||||
if (packet_counter == 0) {
|
||||
// Done sending all packets.
|
||||
if (current_packet == (num_packets - 1)) {
|
||||
current_packet = 0;
|
||||
// Reached end of current packet repeats.
|
||||
if (packet_counter == 0) {
|
||||
// Done sending all packets.
|
||||
current_packet++;
|
||||
if (current_packet >= num_packets) {
|
||||
current_packet = 0;
|
||||
|
||||
// If looping, restart from beginning.
|
||||
if (check_loop.value()) {
|
||||
update_current_packet(packets[current_packet], current_packet);
|
||||
} else {
|
||||
stop();
|
||||
}
|
||||
} else {
|
||||
current_packet++;
|
||||
// If looping, restart from beginning.
|
||||
if (check_loop.value()) {
|
||||
update_current_packet(packets[current_packet], current_packet);
|
||||
} else {
|
||||
stop();
|
||||
}
|
||||
} else {
|
||||
update_current_packet(packets[current_packet], current_packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,16 +393,20 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
};
|
||||
|
||||
options_channel.on_change = [this](size_t, int32_t i) {
|
||||
// If we selected Auto don't do anything and Auto will handle changing.
|
||||
if (i == 40) {
|
||||
auto_channel = true;
|
||||
return;
|
||||
auto_channel = (i == BLT_CHAN_AUTO);
|
||||
all_channels = (i == BLT_CHAN_ALL);
|
||||
|
||||
advCount = 0;
|
||||
|
||||
if (auto_channel) {
|
||||
channel_number = 37;
|
||||
} else if (all_channels) {
|
||||
channel_number = 0;
|
||||
} else {
|
||||
auto_channel = false;
|
||||
channel_number = i;
|
||||
}
|
||||
|
||||
field_frequency.set_value(get_freq_by_channel_number(i));
|
||||
channel_number = i;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
};
|
||||
|
||||
options_speed.on_change = [this](size_t, int32_t i) {
|
||||
@@ -402,7 +415,7 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
};
|
||||
|
||||
options_speed.set_selected_index(0);
|
||||
options_channel.set_selected_index(3);
|
||||
options_channel.set_by_value(BLT_CHAN_AUTO);
|
||||
|
||||
check_rand_mac.set_value(false);
|
||||
check_rand_mac.on_select = [this](Checkbox&, bool v) {
|
||||
@@ -412,8 +425,7 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
button_open.on_select = [this](Button&) {
|
||||
auto open_view = nav_.push<FileLoadView>(".TXT");
|
||||
open_view->on_changed = [this](std::filesystem::path new_file_path) {
|
||||
on_file_changed(new_file_path);
|
||||
|
||||
this->on_file_changed(new_file_path);
|
||||
nav_.set_on_pop([this]() { button_play.focus(); });
|
||||
};
|
||||
};
|
||||
@@ -426,7 +438,7 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
64,
|
||||
ENTER_KEYBOARD_MODE_ALPHA,
|
||||
[this](std::string& buffer) {
|
||||
on_save_file(buffer);
|
||||
this->on_save_file(buffer);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -505,10 +517,10 @@ void BLETxView::on_file_changed(const fs::path& new_file_path) {
|
||||
}
|
||||
|
||||
do {
|
||||
readUntil(data_file, packets[num_packets].macAddress, mac_address_size_str, ' ');
|
||||
readUntil(data_file, packets[num_packets].advertisementData, max_packet_size_str, ' ');
|
||||
readUntil(data_file, packets[num_packets].packetType, max_packet_type_str, ' ');
|
||||
readUntil(data_file, packets[num_packets].packetCount, max_packet_repeat_str, '\n');
|
||||
readUntil(data_file, packets[num_packets].macAddress, sizeof(packets[num_packets].macAddress), ' ');
|
||||
readUntil(data_file, packets[num_packets].advertisementData, sizeof(packets[num_packets].advertisementData), ' ');
|
||||
readUntil(data_file, packets[num_packets].packetType, sizeof(packets[num_packets].packetType), ' ');
|
||||
readUntil(data_file, packets[num_packets].packetCount, sizeof(packets[num_packets].packetCount), '\n');
|
||||
|
||||
uint64_t macAddressSize = strlen(packets[num_packets].macAddress);
|
||||
uint64_t advertisementDataSize = strlen(packets[num_packets].advertisementData);
|
||||
@@ -541,10 +553,8 @@ void BLETxView::on_file_changed(const fs::path& new_file_path) {
|
||||
num_packets++;
|
||||
|
||||
} while (num_packets < max_num_packets);
|
||||
|
||||
update_current_packet(packets[0], 0);
|
||||
|
||||
data_file.close();
|
||||
update_current_packet(packets[0], 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,6 +579,9 @@ void BLETxView::update_current_packet(BLETxPacket packet, uint32_t currentIndex)
|
||||
|
||||
std::vector<std::string> strings = splitIntoStrings(packet.advertisementData);
|
||||
|
||||
packet_counter = packet.packet_count;
|
||||
current_packet = currentIndex;
|
||||
|
||||
text_packet_index.set(to_string_dec_uint(current_packet));
|
||||
|
||||
text_packets_sent.set(to_string_dec_uint(packet.packet_count));
|
||||
@@ -577,9 +590,6 @@ void BLETxView::update_current_packet(BLETxPacket packet, uint32_t currentIndex)
|
||||
|
||||
progressbar.set_max(packet.packet_count);
|
||||
|
||||
packet_counter = packet.packet_count;
|
||||
current_packet = currentIndex;
|
||||
|
||||
dataFile.create(dataTempFilePath);
|
||||
|
||||
for (const std::string& str : strings) {
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#define BLT_CHAN_AUTO 40
|
||||
#define BLT_CHAN_ALL 41
|
||||
|
||||
class BLELoggerTx {
|
||||
public:
|
||||
Optional<File::Error> append(const std::filesystem::path& filename) {
|
||||
@@ -94,7 +97,7 @@ struct BLETxPacket {
|
||||
char advertisementData[63];
|
||||
char packetCount[11];
|
||||
char packetType[17];
|
||||
uint32_t packet_count;
|
||||
uint32_t packet_count; // repeat the same packet count times
|
||||
PKT_TYPE pduType;
|
||||
};
|
||||
|
||||
@@ -145,6 +148,7 @@ class BLETxView : public View {
|
||||
std::filesystem::path packet_save_path{bletx_dir / u"BLETX_????.TXT"};
|
||||
uint8_t channel_number = 37;
|
||||
bool auto_channel = false;
|
||||
bool all_channels = false;
|
||||
|
||||
char randomMac[13] = "010203040506";
|
||||
|
||||
@@ -156,10 +160,10 @@ class BLETxView : public View {
|
||||
int16_t auto_channel_period{6};
|
||||
|
||||
bool repeatLoop = false;
|
||||
uint32_t packet_counter{0};
|
||||
uint32_t num_packets{0};
|
||||
uint32_t current_packet{0};
|
||||
uint8_t packetTxCount{0};
|
||||
uint32_t packet_counter{0}; // the counter (decr) of the actual packet as it can be sent multiple times
|
||||
uint32_t num_packets{0}; // how many packets in the file
|
||||
uint32_t current_packet{0}; // the actual packet's num, i'm sending if i have multiple packets
|
||||
uint8_t packetTxCount{0}; // not used
|
||||
bool packetDone = false;
|
||||
bool random_mac = false;
|
||||
bool file_override = false;
|
||||
@@ -241,10 +245,48 @@ class BLETxView : public View {
|
||||
OptionsField options_channel{
|
||||
{11 * 8, 6 * 8},
|
||||
5,
|
||||
{{"Ch.37 ", 37},
|
||||
{{"Ch.0", 0},
|
||||
{"Ch.1", 1},
|
||||
{"Ch.2", 2},
|
||||
{"Ch.3", 3},
|
||||
{"Ch.4", 4},
|
||||
{"Ch.5", 5},
|
||||
{"Ch.6", 6},
|
||||
{"Ch.7", 7},
|
||||
{"Ch.8", 8},
|
||||
{"Ch.9", 9},
|
||||
{"Ch.10", 10},
|
||||
{"Ch.11", 11},
|
||||
{"Ch.12", 12},
|
||||
{"Ch.13", 13},
|
||||
{"Ch.14", 14},
|
||||
{"Ch.15", 15},
|
||||
{"Ch.16", 16},
|
||||
{"Ch.17", 17},
|
||||
{"Ch.18", 18},
|
||||
{"Ch.19", 19},
|
||||
{"Ch.20", 20},
|
||||
{"Ch.21", 21},
|
||||
{"Ch.22", 22},
|
||||
{"Ch.23", 23},
|
||||
{"Ch.24", 24},
|
||||
{"Ch.25", 25},
|
||||
{"Ch.26", 26},
|
||||
{"Ch.27", 27},
|
||||
{"Ch.28", 28},
|
||||
{"Ch.29", 29},
|
||||
{"Ch.30", 30},
|
||||
{"Ch.31", 31},
|
||||
{"Ch.32", 32},
|
||||
{"Ch.33", 33},
|
||||
{"Ch.34", 34},
|
||||
{"Ch.35", 35},
|
||||
{"Ch.36", 36},
|
||||
{"Ch.37", 37},
|
||||
{"Ch.38", 38},
|
||||
{"Ch.39", 39},
|
||||
{"Auto", 40}}};
|
||||
{"Auto", BLT_CHAN_AUTO},
|
||||
{"All", BLT_CHAN_ALL}}};
|
||||
|
||||
OptionsField options_adv_type{
|
||||
{17 * 8, 6 * 8},
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "string_format.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "file_path.hpp"
|
||||
#include "usb_serial_asyncmsg.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
using namespace pocsag;
|
||||
@@ -62,6 +63,7 @@ POCSAGSettingsView::POCSAGSettingsView(
|
||||
&check_small_font,
|
||||
&check_hide_bad,
|
||||
&check_hide_addr_only,
|
||||
&check_numeric_detect,
|
||||
&opt_filter_mode,
|
||||
&field_filter_address,
|
||||
&button_save});
|
||||
@@ -72,6 +74,7 @@ POCSAGSettingsView::POCSAGSettingsView(
|
||||
check_small_font.set_value(settings_.enable_small_font);
|
||||
check_hide_bad.set_value(settings_.hide_bad_data);
|
||||
check_hide_addr_only.set_value(settings_.hide_addr_only);
|
||||
check_numeric_detect.set_value(settings_.enable_numeric_detect);
|
||||
opt_filter_mode.set_by_value(settings_.filter_mode);
|
||||
field_filter_address.set_value(settings_.filter_address);
|
||||
|
||||
@@ -81,6 +84,7 @@ POCSAGSettingsView::POCSAGSettingsView(
|
||||
settings_.enable_small_font = check_small_font.value();
|
||||
settings_.hide_bad_data = check_hide_bad.value();
|
||||
settings_.hide_addr_only = check_hide_addr_only.value();
|
||||
settings_.enable_numeric_detect = check_numeric_detect.value();
|
||||
settings_.filter_mode = opt_filter_mode.selected_index_value();
|
||||
settings_.filter_address = field_filter_address.to_integer();
|
||||
settings_.baud_rate = opt_baud_rate.selected_index_value();
|
||||
@@ -219,12 +223,24 @@ void POCSAGAppView::handle_decoded(Timestamp timestamp, const std::string& prefi
|
||||
return;
|
||||
}
|
||||
|
||||
// Color indicates the message has a lot of decoding errors.
|
||||
std::string color = bad_data ? STR_COLOR_MAGENTA : STR_COLOR_WHITE;
|
||||
// Type indicator with its own color.
|
||||
std::string type_str;
|
||||
bool numeric_detect = settings_.enable_numeric_detect;
|
||||
if (numeric_detect && pocsag_state.detected == pocsag::DET_NUMERIC)
|
||||
type_str = STR_COLOR_GREEN "n";
|
||||
else if (numeric_detect && pocsag_state.detected == pocsag::DET_ALPHA)
|
||||
type_str = STR_COLOR_LIGHT_GREY "a";
|
||||
else if (pocsag_state.out_type == ADDRESS)
|
||||
type_str = STR_COLOR_DARK_YELLOW "t";
|
||||
else
|
||||
type_str = "";
|
||||
|
||||
std::string console_info = "\n" + color + prefix;
|
||||
console_info += " #" + to_string_dec_uint(pocsag_state.address);
|
||||
// Header: timestamp+baud in light grey, capcode+function in white.
|
||||
std::string console_info = "\n" STR_COLOR_LIGHT_GREY + prefix;
|
||||
console_info += STR_COLOR_WHITE " #" + to_string_dec_uint(pocsag_state.address);
|
||||
console_info += " F" + to_string_dec_uint(pocsag_state.function);
|
||||
if (!type_str.empty())
|
||||
console_info += " " + type_str;
|
||||
|
||||
if (pocsag_state.out_type == ADDRESS) {
|
||||
last_address = pocsag_state.address;
|
||||
@@ -240,23 +256,111 @@ void POCSAGAppView::handle_decoded(Timestamp timestamp, const std::string& prefi
|
||||
}
|
||||
}
|
||||
|
||||
/* Serial: tone-only page */
|
||||
if (portapack::usb_serial.serial_connected()) {
|
||||
std::string s = "\r\nPOCSAG " + to_string_dec_uint(current_bitrate) + " " + to_string_dec_uint(pocsag_state.address) + " " + std::string(1, 'A' + pocsag_state.function) + (current_inverted ? " I" : " S") + " tone";
|
||||
UsbSerialAsyncmsg::asyncmsg(s);
|
||||
}
|
||||
|
||||
} else if (pocsag_state.out_type == MESSAGE) {
|
||||
if (pocsag_state.address != last_address) {
|
||||
// New message
|
||||
if (pocsag_state.new_message) {
|
||||
last_address = pocsag_state.address;
|
||||
serial_numeric_sent = 0;
|
||||
console.writeln(console_info);
|
||||
console.write(color + pocsag_state.output);
|
||||
|
||||
// If heuristic chose numeric, show numeric line first (green).
|
||||
if (numeric_detect &&
|
||||
pocsag_state.detected == pocsag::DET_NUMERIC &&
|
||||
pocsag_state.numeric_len > 0) {
|
||||
std::string num_str(pocsag_state.numeric_buf, pocsag_state.numeric_len);
|
||||
console.write(STR_COLOR_GREEN + num_str);
|
||||
console.writeln("");
|
||||
}
|
||||
|
||||
// Alpha decode (already has per-char color escapes from decoder).
|
||||
console.write(pocsag_state.output);
|
||||
|
||||
/* Serial: header + first chunk.
|
||||
* hex field contains rendered alpha as hex bytes (color escapes
|
||||
* stripped). Non-printable chars show as '.' (0x2E),
|
||||
* uncorrectable chars show as '?' (0x3F) — original 7-bit
|
||||
* values are not preserved.
|
||||
* Numeric decode goes in the quoted message field only. */
|
||||
if (portapack::usb_serial.serial_connected()) {
|
||||
/* Build hex representation of decoded alpha characters. */
|
||||
std::string raw;
|
||||
for (size_t i = 0; i < pocsag_state.output.size(); ++i)
|
||||
raw += to_string_hex((uint8_t)pocsag_state.output[i], 2);
|
||||
|
||||
std::string s = "\r\nPOCSAG " + to_string_dec_uint(current_bitrate) + " " + to_string_dec_uint(pocsag_state.address) + " " + std::string(1, 'A' + pocsag_state.function) + (current_inverted ? " I" : " S");
|
||||
|
||||
if (numeric_detect && pocsag_state.detected == pocsag::DET_NUMERIC) {
|
||||
s += " numeric \"";
|
||||
if (pocsag_state.numeric_len > 0)
|
||||
s += std::string(pocsag_state.numeric_buf, pocsag_state.numeric_len);
|
||||
s += "\"";
|
||||
serial_numeric_sent = pocsag_state.numeric_len;
|
||||
} else {
|
||||
/* For alpha, the quoted text is the same chars as raw but as ASCII.
|
||||
* Escape " and \ to avoid breaking the quoted field. */
|
||||
s += " alpha \"";
|
||||
for (size_t i = 0; i < pocsag_state.output.size(); ++i) {
|
||||
if (pocsag_state.output[i] == '"' || pocsag_state.output[i] == '\\') {
|
||||
s += '\\';
|
||||
}
|
||||
s += pocsag_state.output[i];
|
||||
}
|
||||
s += "\"";
|
||||
}
|
||||
s += " hex:" + raw;
|
||||
UsbSerialAsyncmsg::asyncmsg(s);
|
||||
}
|
||||
} else {
|
||||
// Message continues...
|
||||
console.write(color + pocsag_state.output);
|
||||
// Message continues from previous batch.
|
||||
bool is_numeric = numeric_detect && pocsag_state.detected == pocsag::DET_NUMERIC;
|
||||
|
||||
// GUI: show numeric continuation if applicable.
|
||||
if (is_numeric && pocsag_state.numeric_len > serial_numeric_sent) {
|
||||
std::string num_str(pocsag_state.numeric_buf + serial_numeric_sent,
|
||||
pocsag_state.numeric_len - serial_numeric_sent);
|
||||
console.write(STR_COLOR_GREEN + num_str);
|
||||
}
|
||||
console.write(pocsag_state.output);
|
||||
|
||||
/* Serial: continuation chunk with full header.
|
||||
* Type label carries over from first batch (numeric+ or alpha+). */
|
||||
if (portapack::usb_serial.serial_connected()) {
|
||||
std::string raw;
|
||||
std::string decoded;
|
||||
for (size_t i = 0; i < pocsag_state.output.size(); ++i) {
|
||||
if (pocsag_state.output[i] == '"' || pocsag_state.output[i] == '\\')
|
||||
decoded += '\\';
|
||||
decoded += pocsag_state.output[i];
|
||||
raw += to_string_hex((uint8_t)pocsag_state.output[i], 2);
|
||||
}
|
||||
if (!decoded.empty() || pocsag_state.numeric_len > serial_numeric_sent) {
|
||||
std::string s = "\r\nPOCSAG " + to_string_dec_uint(current_bitrate) + " " + to_string_dec_uint(pocsag_state.address) + " " + std::string(1, 'A' + pocsag_state.function) + (current_inverted ? " I" : " S") + (is_numeric ? " numeric+" : " alpha+") + " \"";
|
||||
if (is_numeric && pocsag_state.numeric_len > serial_numeric_sent)
|
||||
s += std::string(pocsag_state.numeric_buf + serial_numeric_sent,
|
||||
pocsag_state.numeric_len - serial_numeric_sent);
|
||||
else
|
||||
s += decoded;
|
||||
s += "\" hex:" + raw;
|
||||
UsbSerialAsyncmsg::asyncmsg(s);
|
||||
}
|
||||
}
|
||||
serial_numeric_sent = pocsag_state.numeric_len;
|
||||
}
|
||||
|
||||
if (logging()) {
|
||||
logger.log_decoded(
|
||||
timestamp,
|
||||
to_string_dec_uint(pocsag_state.address) +
|
||||
" F" + to_string_dec_uint(pocsag_state.function) +
|
||||
" " + pocsag_state.output);
|
||||
std::string log_entry = to_string_dec_uint(pocsag_state.address) +
|
||||
" F" + to_string_dec_uint(pocsag_state.function);
|
||||
if (numeric_detect &&
|
||||
pocsag_state.detected == pocsag::DET_NUMERIC &&
|
||||
pocsag_state.numeric_len > 0)
|
||||
log_entry += " N:" + std::string(pocsag_state.numeric_buf, pocsag_state.numeric_len);
|
||||
log_entry += " " + pocsag_state.output;
|
||||
logger.log_decoded(timestamp, log_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,13 +404,19 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage* message) {
|
||||
image_status.set_foreground(Theme::getInstance()->fg_magenta->foreground);
|
||||
pocsag_state.codeword_index = 0;
|
||||
pocsag_state.errors = 0;
|
||||
current_bitrate = message->packet.bitrate();
|
||||
current_inverted = message->packet.inverted();
|
||||
|
||||
// Handle multiple messages (if any).
|
||||
while (pocsag_decode_batch(message->packet, pocsag_state))
|
||||
handle_decoded(message->packet.timestamp(), prefix);
|
||||
|
||||
// Handle the remainder.
|
||||
handle_decoded(message->packet.timestamp(), prefix);
|
||||
// Handle the remainder. Skip if decoder is still in
|
||||
// STATE_HAVE_ADDRESS — the address was at the end of this
|
||||
// batch and we can't yet tell if it's tone-only or has
|
||||
// message data in the next batch.
|
||||
if (pocsag_state.mode != STATE_HAVE_ADDRESS)
|
||||
handle_decoded(message->packet.timestamp(), prefix);
|
||||
}
|
||||
|
||||
// Set status icon color to indicate state machine state.
|
||||
|
||||
@@ -125,6 +125,7 @@ struct POCSAGSettings {
|
||||
bool enable_raw_log = false;
|
||||
bool hide_bad_data = false;
|
||||
bool hide_addr_only = false;
|
||||
bool enable_numeric_detect = true; /* heuristic alpha/numeric type detection */
|
||||
uint8_t filter_mode = false;
|
||||
int32_t baud_rate = -1;
|
||||
uint32_t filter_address = 0;
|
||||
@@ -150,8 +151,8 @@ class POCSAGSettingsView : public View {
|
||||
|
||||
Labels labels{
|
||||
{{2 * 8, 0 * 16}, "Baud:", Theme::getInstance()->fg_light->foreground},
|
||||
{{2 * 8, 12 * 16}, "Filter Mode:", Theme::getInstance()->fg_light->foreground},
|
||||
{{2 * 8, 13 * 16}, "Filter Addr:", Theme::getInstance()->fg_light->foreground},
|
||||
{{2 * 8, 14 * 16}, "Filter Mode:", Theme::getInstance()->fg_light->foreground},
|
||||
{{2 * 8, 15 * 16}, "Filter Addr:", Theme::getInstance()->fg_light->foreground},
|
||||
};
|
||||
|
||||
Checkbox check_log{
|
||||
@@ -179,21 +180,26 @@ class POCSAGSettingsView : public View {
|
||||
22,
|
||||
"Hide Addr Only"};
|
||||
|
||||
Checkbox check_numeric_detect{
|
||||
{2 * 8, 12 * 16},
|
||||
22,
|
||||
"Detect Numeric"};
|
||||
|
||||
OptionsField opt_filter_mode{
|
||||
{15 * 8, 12 * 16},
|
||||
{15 * 8, 14 * 16},
|
||||
4,
|
||||
{{"None", FILTER_NONE},
|
||||
{"Drop", FILTER_DROP},
|
||||
{"Keep", FILTER_KEEP}}};
|
||||
|
||||
SymField field_filter_address{
|
||||
{15 * 8, 13 * 16},
|
||||
{15 * 8, 15 * 16},
|
||||
7,
|
||||
SymField::Type::Dec,
|
||||
true /*explicit_edit*/};
|
||||
|
||||
Button button_save{
|
||||
{UI_POS_X_CENTER(10), UI_POS_Y(16), 10 * 8, 2 * 16},
|
||||
{UI_POS_X_CENTER(10), UI_POS_Y(17), 10 * 8, 2 * 16},
|
||||
"Save"};
|
||||
};
|
||||
|
||||
@@ -231,6 +237,7 @@ class POCSAGAppView : public View {
|
||||
{"filter_address"sv, &settings_.filter_address},
|
||||
{"hide_bad_data"sv, &settings_.hide_bad_data},
|
||||
{"hide_addr_only"sv, &settings_.hide_addr_only},
|
||||
{"numeric_detect"sv, &settings_.enable_numeric_detect},
|
||||
{"baud_rate"sv, &settings_.baud_rate},
|
||||
}};
|
||||
|
||||
@@ -241,6 +248,10 @@ class POCSAGAppView : public View {
|
||||
void on_stats(const POCSAGStatsMessage* stats);
|
||||
|
||||
uint32_t last_address = 0;
|
||||
uint16_t current_bitrate = 0; /* bitrate of current packet being decoded */
|
||||
bool current_inverted = false; /* polarity of current packet being decoded */
|
||||
uint8_t serial_numeric_sent = 0; /* numeric chars already sent to serial/GUI */
|
||||
|
||||
pocsag::EccContainer ecc{};
|
||||
pocsag::POCSAGState pocsag_state{&ecc};
|
||||
POCSAGLogger logger{};
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "portapack.hpp"
|
||||
#include "battery.hpp"
|
||||
#include <cstring>
|
||||
#include "ui_settings.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
@@ -50,7 +52,6 @@ void BattinfoView::update_result() {
|
||||
text_voltage.set("UNKNOWN");
|
||||
text_current.set("-");
|
||||
text_charge.set("-");
|
||||
// text_cycles.set("-");
|
||||
text_ttef.set("-");
|
||||
text_method.set("-");
|
||||
// text_warn.set("");
|
||||
@@ -58,7 +59,9 @@ void BattinfoView::update_result() {
|
||||
}
|
||||
bool uichg = false;
|
||||
uint8_t valid_mask = 0;
|
||||
battery::BatteryManagement::getBatteryInfo(valid_mask, percent, voltage, current);
|
||||
bool battMayChanged = false;
|
||||
battery::BatteryManagement::getBatteryInfo(valid_mask, percent, voltage, current, battMayChanged);
|
||||
text_state.set((battMayChanged || !persistent_memory::battery_cap_valid()) ? "Needs config." : "ok");
|
||||
// update text fields
|
||||
if (percent <= 100 && (valid_mask & battery::BatteryManagement::BATT_VALID_VOLTAGE) == battery::BatteryManagement::BATT_VALID_VOLTAGE)
|
||||
text_percent.set(to_string_dec_uint(percent) + " %");
|
||||
@@ -74,6 +77,7 @@ void BattinfoView::update_result() {
|
||||
labels_opt.hidden(false);
|
||||
text_current.hidden(false);
|
||||
text_charge.hidden(false);
|
||||
text_state.hidden(false);
|
||||
text_current.set(to_string_dec_int(current) + " mA");
|
||||
if (current >= 25) // when >25mA it is charging in any scenario
|
||||
text_charge.set("Charging");
|
||||
@@ -96,7 +100,7 @@ void BattinfoView::update_result() {
|
||||
labels_opt.hidden(true);
|
||||
text_current.hidden(true);
|
||||
text_charge.hidden(true);
|
||||
// text_cycles.hidden(true);
|
||||
text_state.hidden(true);
|
||||
text_ttef.hidden(true);
|
||||
// text_warn.set("");
|
||||
}
|
||||
@@ -138,14 +142,13 @@ void BattinfoView::update_result() {
|
||||
}
|
||||
if ((valid_mask & battery::BatteryManagement::BATT_VALID_PERCENT) == battery::BatteryManagement::BATT_VALID_PERCENT) {
|
||||
text_method.set("IC");
|
||||
button_mode.set_text("Volt");
|
||||
} else {
|
||||
text_method.set("Voltage");
|
||||
button_mode.set_text("IC");
|
||||
}
|
||||
if (battMayChanged) text_capacity.set_style(Theme::getInstance()->fg_red);
|
||||
if (uichg) set_dirty();
|
||||
// to update status bar too, send message in behalf of batt manager
|
||||
BatteryStateMessage msg{valid_mask, percent, current >= 25, voltage};
|
||||
BatteryStateMessage msg{valid_mask, percent, current >= 25, voltage, battMayChanged};
|
||||
EventDispatcher::send_message(msg);
|
||||
}
|
||||
|
||||
@@ -158,26 +161,21 @@ BattinfoView::BattinfoView(NavigationView& nav)
|
||||
&text_current,
|
||||
&text_charge,
|
||||
&text_method,
|
||||
&button_mode,
|
||||
&button_settings,
|
||||
&button_exit,
|
||||
// &text_cycles,
|
||||
&text_capacity,
|
||||
//&text_state, //disabled for now
|
||||
// &text_warn,
|
||||
&text_ttef});
|
||||
|
||||
button_exit.on_select = [this, &nav](Button&) {
|
||||
nav.pop();
|
||||
};
|
||||
button_mode.on_select = [this, &nav](Button&) {
|
||||
if (button_mode.text() == "IC") {
|
||||
battery::BatteryManagement::set_calc_override(false);
|
||||
persistent_memory::set_ui_override_batt_calc(false);
|
||||
button_mode.set_text("Volt");
|
||||
} else {
|
||||
battery::BatteryManagement::set_calc_override(true);
|
||||
persistent_memory::set_ui_override_batt_calc(true);
|
||||
button_mode.set_text("IC");
|
||||
}
|
||||
button_settings.on_select = [this, &nav](Button&) {
|
||||
nav.replace<SetBatteryView>();
|
||||
};
|
||||
text_capacity.set(to_string_dec_uint(persistent_memory::battery_cap_mah()) + " mAh");
|
||||
if (!persistent_memory::battery_cap_valid()) text_capacity.set_style(Theme::getInstance()->fg_red);
|
||||
update_result();
|
||||
if (thread == nullptr) thread = chThdCreateFromHeap(NULL, 1024, NORMALPRIO + 10, BattinfoView::static_fn, this);
|
||||
}
|
||||
|
||||
@@ -54,48 +54,54 @@ class BattinfoView : public View {
|
||||
int32_t current = 0;
|
||||
|
||||
Labels labels{
|
||||
{{2 * 8, 1 * 16}, "Percent:", Theme::getInstance()->fg_light->foreground},
|
||||
{{2 * 8, 2 * 16}, "Voltage:", Theme::getInstance()->fg_light->foreground},
|
||||
{{2 * 8, 3 * 16}, "Method:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(2), UI_POS_Y(1)}, "Percent:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(2), UI_POS_Y(2)}, "Voltage:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(2), UI_POS_Y(3)}, "Method:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(2), UI_POS_Y(4)}, "Capacity:", Theme::getInstance()->fg_light->foreground},
|
||||
};
|
||||
|
||||
Labels labels_opt{
|
||||
{{2 * 8, 4 * 16}, "Current:", Theme::getInstance()->fg_light->foreground},
|
||||
{{2 * 8, 5 * 16}, "Charge:", Theme::getInstance()->fg_light->foreground},
|
||||
{{2 * 8, 6 * 16}, "TTF/E:", Theme::getInstance()->fg_light->foreground},
|
||||
// {{2 * 8, 7 * 16}, "Cycles:", Theme::getInstance()->fg_light->foreground},
|
||||
{{2 * 8, 10 * 16}, "Change method:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(2), UI_POS_Y(5)}, "Current:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(2), UI_POS_Y(6)}, "Charge:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(2), UI_POS_Y(7)}, "TTF/E:", Theme::getInstance()->fg_light->foreground},
|
||||
//{{UI_POS_X(2), UI_POS_Y(8)}, "State:", Theme::getInstance()->fg_light->foreground}, //for now, this is disabled. see max ic implementation
|
||||
{{UI_POS_X(2), UI_POS_Y(10)}, "Change settings:", Theme::getInstance()->fg_light->foreground},
|
||||
};
|
||||
|
||||
Text text_percent{
|
||||
{13 * 8, 1 * 16, 10 * 16, 16},
|
||||
{UI_POS_X(13), UI_POS_Y(1), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)},
|
||||
"-"};
|
||||
Text text_voltage{
|
||||
{13 * 8, 2 * 16, 10 * 16, 16},
|
||||
{UI_POS_X(13), UI_POS_Y(2), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)},
|
||||
"-"};
|
||||
Text text_method{
|
||||
{13 * 8, 3 * 16, 10 * 16, 16},
|
||||
{UI_POS_X(13), UI_POS_Y(3), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)},
|
||||
"-"};
|
||||
Text text_capacity{
|
||||
{UI_POS_X(13), UI_POS_Y(4), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)},
|
||||
"-"};
|
||||
Text text_current{
|
||||
{13 * 8, 4 * 16, 10 * 16, 16},
|
||||
{UI_POS_X(13), UI_POS_Y(5), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)},
|
||||
"-"};
|
||||
Text text_charge{
|
||||
{13 * 8, 5 * 16, 10 * 16, 16},
|
||||
{UI_POS_X(13), UI_POS_Y(6), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)},
|
||||
"-"};
|
||||
Text text_ttef{
|
||||
{13 * 8, 6 * 16, 10 * 16, 16},
|
||||
"-"};
|
||||
/* Text text_cycles{
|
||||
{13 * 8, 7 * 16, 10 * 16, 16},
|
||||
{UI_POS_X(13), UI_POS_Y(7), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)},
|
||||
"-"};
|
||||
|
||||
Text text_state{
|
||||
{UI_POS_X(13), UI_POS_Y(8), UI_POS_WIDTH_REMAINING(13), UI_POS_HEIGHT(1)},
|
||||
"ok"};
|
||||
/*
|
||||
Text text_warn{
|
||||
{1 * 8, 8 * 16, screen_width, 2 * 16},
|
||||
""}; */
|
||||
{UI_POS_X(1), UI_POS_Y(9), screen_width, UI_POS_HEIGHT(2)},
|
||||
""};
|
||||
*/
|
||||
|
||||
Button button_mode{
|
||||
{2 * 8, 11 * 16 + 5, 5 * 16, 32},
|
||||
"Volt"};
|
||||
Button button_settings{
|
||||
{UI_POS_X(2), UI_POS_Y(11) + 5, UI_POS_WIDTH(10), UI_POS_HEIGHT(2)},
|
||||
"Settings"};
|
||||
|
||||
Button button_exit{
|
||||
{UI_POS_X_CENTER(12), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||
@@ -106,4 +112,4 @@ class BattinfoView : public View {
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif /*__UI_BATTINFO__*/
|
||||
#endif /*__UI_BATTINFO__*/
|
||||
|
||||
@@ -515,6 +515,262 @@ void RadioDiagnosticsView::update_status() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PRALINE
|
||||
PralineRadioDebugView::PralineRadioDebugView(NavigationView& nav) {
|
||||
add_children({&text_title, &text_lbl_lock, &text_lock_status,
|
||||
&text_lbl_clk5, &text_clk5_status,
|
||||
&text_lbl_spi, &text_spi_status, &text_lbl_fpga_ctrl, &text_fpga_ctrl,
|
||||
&text_lbl_vaa, &text_vaa_status, &text_status_msg,
|
||||
&button_refresh, &button_toggle_clk5, &button_done});
|
||||
|
||||
button_refresh.on_select = [this](Button&) { this->refresh(); };
|
||||
button_toggle_clk5.on_select = [this](Button&) { this->toggle_clk5(); };
|
||||
button_done.on_select = [&nav](Button&) { nav.pop(); };
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void PralineRadioDebugView::focus() {
|
||||
button_refresh.focus();
|
||||
}
|
||||
|
||||
void PralineRadioDebugView::toggle_clk5() {
|
||||
// Si5351 Register 3 is the Output Enable mask. Bit 5 = CLK5.
|
||||
// 0 = Enabled, 1 = Disabled.
|
||||
uint8_t reg3 = portapack::clock_manager.si5351_read_register(3);
|
||||
reg3 ^= 0x20; // Toggle Bit 5 (CLK5)
|
||||
portapack::clock_manager.si5351_write_register(3, reg3);
|
||||
refresh();
|
||||
}
|
||||
|
||||
void PralineRadioDebugView::refresh() {
|
||||
// 1. Check Mixer Lock Detect (GPIO6[25] / PD_11) [cite: 16, 17]
|
||||
uint32_t gpio6_state = LPC_GPIO->PIN[6];
|
||||
bool locked = (gpio6_state >> 25) & 1;
|
||||
text_lock_status.set(locked ? "LOCKED (OK)" : "UNLOCKED!");
|
||||
text_lock_status.set_style(locked ? Theme::getInstance()->fg_green : Theme::getInstance()->fg_red);
|
||||
|
||||
// 2. Check Si5351 CLK5 Status (Reg 3, Bit 5) - 0 = ON, 1 = OFF
|
||||
uint8_t si_reg3 = portapack::clock_manager.si5351_read_register(3);
|
||||
bool clk5_on = !(si_reg3 & 0x20);
|
||||
text_clk5_status.set(clk5_on ? "ON (40MHz)" : "OFF");
|
||||
text_clk5_status.set_style(clk5_on ? Theme::getInstance()->fg_green : Theme::getInstance()->fg_red);
|
||||
|
||||
// 3. Check SPI Bit Mode (SSP1 CR0)
|
||||
// DSS (Data Size Select) is Bit 3:0. 0x8 = 9-bit (MAX2831), 0xF = 16-bit (Classic)
|
||||
uint32_t cr0 = LPC_SSP1->CR0;
|
||||
uint8_t dss = cr0 & 0x0F;
|
||||
if (dss == 0x08)
|
||||
text_spi_status.set("9-Bit (Pro)");
|
||||
else
|
||||
text_spi_status.set("Other (Err)");
|
||||
text_spi_status.set_style((dss == 0x08) ? Theme::getInstance()->fg_green : Theme::getInstance()->fg_red);
|
||||
|
||||
// 4. Check FPGA Register 1 (DC Block status) [cite: 12, 13]
|
||||
uint8_t fpga_r1 = radio::debug::fpga::register_read(1);
|
||||
text_fpga_ctrl.set(to_string_hex(fpga_r1, 2));
|
||||
|
||||
// 5. Check VAA RF Power (GPIO4[1] / P8_1) - Active LOW [cite: 16, 17]
|
||||
uint32_t gpio4_state = LPC_GPIO->PIN[4];
|
||||
bool vaa_on = !((gpio4_state >> 1) & 1);
|
||||
text_vaa_status.set(vaa_on ? "ON" : "OFF");
|
||||
text_vaa_status.set_style(vaa_on ? Theme::getInstance()->fg_green : Theme::getInstance()->fg_red);
|
||||
|
||||
// Diagnostic Summary
|
||||
if (!locked && clk5_on && vaa_on) {
|
||||
text_status_msg.set("Clock/Pwr OK. PLL not locked. Check tuning registers.");
|
||||
text_status_msg.set_style(Theme::getInstance()->fg_red);
|
||||
} else if (!clk5_on) {
|
||||
text_status_msg.set("Mixer Clock is OFF. PLL cannot lock.");
|
||||
text_status_msg.set_style(Theme::getInstance()->fg_red);
|
||||
} else {
|
||||
text_status_msg.set("Hardware Link Active.");
|
||||
text_status_msg.set_style(Theme::getInstance()->fg_green);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
/* WFMAudioDebugView *************************************************/
|
||||
|
||||
WFMAudioDebugView::WFMAudioDebugView(NavigationView& nav)
|
||||
: nav_(nav) {
|
||||
add_children({
|
||||
&text_title,
|
||||
&text_lbl_clk0,
|
||||
&text_clk0,
|
||||
&text_lbl_fpga_dec,
|
||||
&text_fpga_dec,
|
||||
&text_lbl_post_fpga,
|
||||
&text_post_fpga,
|
||||
&text_section1,
|
||||
&text_lbl_reg8,
|
||||
&text_reg8,
|
||||
&text_lbl_lpf_bw,
|
||||
&text_lpf_bw,
|
||||
&text_section2,
|
||||
&text_lbl_fpga_r1,
|
||||
&text_fpga_r1,
|
||||
&text_lbl_dc_q,
|
||||
&text_dc_q,
|
||||
&text_section3,
|
||||
&text_lbl_expected,
|
||||
&text_expected,
|
||||
&text_lbl_deemph,
|
||||
&text_deemph,
|
||||
&text_status,
|
||||
&text_status2,
|
||||
&button_refresh,
|
||||
&button_toggle_q,
|
||||
&button_done,
|
||||
});
|
||||
|
||||
text_title.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_section1.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_section2.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_section3.set_style(Theme::getInstance()->fg_yellow);
|
||||
|
||||
button_refresh.on_select = [this](Button&) {
|
||||
refresh();
|
||||
};
|
||||
|
||||
button_toggle_q.on_select = [this](Button&) {
|
||||
uint32_t current = radio::debug::fpga::register_read(1);
|
||||
uint8_t new_val = current ^ 0x02; // Toggle Q_INVERT bit
|
||||
radio::debug::fpga::register_write(1, new_val);
|
||||
radio::invalidate_spi_config();
|
||||
refresh();
|
||||
};
|
||||
|
||||
button_done.on_select = [&nav](Button&) {
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void WFMAudioDebugView::focus() {
|
||||
button_refresh.focus();
|
||||
}
|
||||
|
||||
void WFMAudioDebugView::refresh() {
|
||||
// === Si5351 CLK0 Sample Rate ===
|
||||
// Read MS0 parameters to calculate frequency
|
||||
uint8_t reg44 = portapack::clock_manager.si5351_read_register(44);
|
||||
uint8_t reg45 = portapack::clock_manager.si5351_read_register(45);
|
||||
uint8_t reg46 = portapack::clock_manager.si5351_read_register(46);
|
||||
|
||||
uint8_t r_div_encoded = (reg44 >> 4) & 0x07;
|
||||
uint32_t r_div = 1 << r_div_encoded;
|
||||
uint32_t p1 = ((uint32_t)(reg44 & 0x03) << 16) | ((uint32_t)reg45 << 8) | reg46;
|
||||
uint32_t ms_div = (p1 + 512) / 128;
|
||||
|
||||
// PLL A is 800 MHz
|
||||
uint32_t clk0_khz = 800000 / ms_div / r_div;
|
||||
uint32_t clk0_mhz_int = clk0_khz / 1000;
|
||||
uint32_t clk0_khz_frac = clk0_khz % 1000;
|
||||
|
||||
text_clk0.set(to_string_dec_uint(clk0_mhz_int) + "." +
|
||||
to_string_dec_uint(clk0_khz_frac / 100) +
|
||||
to_string_dec_uint((clk0_khz_frac / 10) % 10) +
|
||||
to_string_dec_uint(clk0_khz_frac % 10) + " MHz");
|
||||
|
||||
if (clk0_khz >= 3000 && clk0_khz <= 3200) {
|
||||
text_clk0.set_style(Theme::getInstance()->fg_green);
|
||||
} else {
|
||||
text_clk0.set_style(Theme::getInstance()->fg_red);
|
||||
}
|
||||
|
||||
// === FPGA Decimation ===
|
||||
uint8_t fpga_decim = radio::debug::fpga::register_read(2);
|
||||
uint32_t fpga_div = 1 << fpga_decim;
|
||||
text_fpga_dec.set("/" + to_string_dec_uint(fpga_div) + " (n=" + to_string_dec_uint(fpga_decim) + ")");
|
||||
|
||||
// === Post-FPGA Rate ===
|
||||
uint32_t post_fpga_khz = clk0_khz / fpga_div;
|
||||
text_post_fpga.set(to_string_dec_uint(post_fpga_khz) + " kHz");
|
||||
|
||||
// For WFM, post-FPGA should be >= 384 kHz for proper audio decimation
|
||||
if (post_fpga_khz >= 384) {
|
||||
text_post_fpga.set_style(Theme::getInstance()->fg_green);
|
||||
} else {
|
||||
text_post_fpga.set_style(Theme::getInstance()->fg_orange);
|
||||
}
|
||||
|
||||
// === MAX2831 LPF ===
|
||||
uint32_t reg8 = radio::debug::second_if::register_read(8);
|
||||
text_reg8.set("0x" + to_string_hex(reg8, 4));
|
||||
|
||||
uint8_t lpf_coarse = reg8 & 0x03;
|
||||
const char* lpf_names[] = {"7.5 MHz", "8.5 MHz", "15 MHz", "18 MHz"};
|
||||
text_lpf_bw.set(lpf_names[lpf_coarse]);
|
||||
|
||||
// 7.5 MHz is minimum, OK for mono WFM but tight for stereo
|
||||
if (lpf_coarse >= 1) {
|
||||
text_lpf_bw.set_style(Theme::getInstance()->fg_green);
|
||||
} else {
|
||||
text_lpf_bw.set_style(Theme::getInstance()->fg_orange);
|
||||
}
|
||||
|
||||
// === FPGA Control Register ===
|
||||
uint32_t fpga_ctrl = radio::debug::fpga::register_read(1);
|
||||
text_fpga_r1.set("0x" + to_string_hex(fpga_ctrl, 2));
|
||||
|
||||
bool dc_block = fpga_ctrl & 0x01;
|
||||
bool q_invert = fpga_ctrl & 0x02;
|
||||
uint8_t quarter_shift = (fpga_ctrl >> 2) & 0x03;
|
||||
|
||||
text_dc_q.set(std::string(dc_block ? "DC:ON" : "DC:OFF") +
|
||||
" Q:" + std::string(q_invert ? "INV" : "NOR") +
|
||||
" QS:" + to_string_dec_uint(quarter_shift));
|
||||
|
||||
if (dc_block) {
|
||||
text_dc_q.set_style(Theme::getInstance()->fg_green);
|
||||
} else {
|
||||
text_dc_q.set_style(Theme::getInstance()->fg_orange);
|
||||
}
|
||||
|
||||
// === Expected Audio Rate ===
|
||||
// WFM typically: 3072 kHz / 64 = 48 kHz audio
|
||||
// Or: 3072 kHz → /8 (channel) → 384 kHz → /8 (audio) → 48 kHz
|
||||
uint32_t expected_audio = post_fpga_khz / 64; // Simplified assumption
|
||||
text_expected.set(to_string_dec_uint(expected_audio) + " kHz (est)");
|
||||
|
||||
if (expected_audio >= 44 && expected_audio <= 50) {
|
||||
text_expected.set_style(Theme::getInstance()->fg_green);
|
||||
} else {
|
||||
text_expected.set_style(Theme::getInstance()->fg_red);
|
||||
}
|
||||
|
||||
// === De-emphasis Status ===
|
||||
// We can't directly read the M4 de-emphasis config, but we can indicate what SHOULD be set
|
||||
// 75µs for USA, 50µs for Europe
|
||||
text_deemph.set("Chk M4 cfg.");
|
||||
text_deemph.set_style(Theme::getInstance()->fg_orange);
|
||||
|
||||
// === Status Summary ===
|
||||
bool sample_rate_ok = (clk0_khz >= 3000 && clk0_khz <= 3200);
|
||||
bool lpf_ok = (lpf_coarse <= 0x0F); // check against the 4-bit max
|
||||
bool dc_ok = dc_block;
|
||||
|
||||
if (sample_rate_ok && lpf_ok && dc_ok) {
|
||||
text_status.set("Hardware config looks OK.");
|
||||
text_status.set_style(Theme::getInstance()->fg_green);
|
||||
text_status2.set("If ringy: Chk d-emph in M4!");
|
||||
text_status2.set_style(Theme::getInstance()->fg_orange);
|
||||
} else {
|
||||
std::string issues = "Issues: ";
|
||||
if (!sample_rate_ok) issues += "SampleRate ";
|
||||
if (!lpf_ok) issues += "LPF ";
|
||||
if (!dc_ok) issues += "DC_Block ";
|
||||
text_status.set(issues);
|
||||
text_status.set_style(Theme::getInstance()->fg_red);
|
||||
text_status2.set("Fix before checking audio.");
|
||||
text_status2.set_style(Theme::getInstance()->fg_red);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* BasebandStatusView ******************************************************/
|
||||
|
||||
BasebandStatusView::BasebandStatusView(NavigationView& nav)
|
||||
@@ -1456,8 +1712,9 @@ void Si5351DebugView::refresh_status() {
|
||||
// Expected for 8 MHz: P1=5888 (0x1700), a=50
|
||||
uint32_t ms_div = (p1 + 512) / 128; // Integer divider value
|
||||
|
||||
// Calculate frequency: f_out = 800 MHz / ms_div / r_div
|
||||
uint32_t freq_khz = 800000 / ms_div / r_div; // Result in kHz
|
||||
// Calculate frequency: f_out = 800 or 800 MHz / ms_div / r_div
|
||||
uint32_t vco_khz = (clk0_ctrl & 0x20) ? 800000 : 800000; // PLLB vs PLLA
|
||||
uint32_t freq_khz = vco_khz / ms_div / r_div; // Result in kHz
|
||||
|
||||
// Show P1 value and R45 for debugging
|
||||
text_clk0_freq_value.set("F:" + to_string_dec_uint(freq_khz / 1000) + "MHz (P1:" + to_string_hex(p1, 4) + ")");
|
||||
@@ -1926,6 +2183,487 @@ void SystemDiagnosticsView::refresh() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
/* Si5351PLLADebugView *******************************************************/
|
||||
|
||||
Si5351PLLADebugView::Si5351PLLADebugView(NavigationView& nav)
|
||||
: nav_(nav) {
|
||||
add_children({&text_title, &text_lbl_raw, &text_r26_27, &text_r28_30, &text_r31_33,
|
||||
&text_lbl_decoded, &text_lbl_p1, &text_p1, &text_lbl_p2, &text_p2,
|
||||
&text_lbl_p3, &text_p3, &text_lbl_calc, &text_lbl_mult, &text_mult,
|
||||
&text_lbl_vco, &text_vco, &text_status, &button_refresh, &button_done});
|
||||
|
||||
text_title.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_lbl_raw.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_lbl_decoded.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_lbl_calc.set_style(Theme::getInstance()->fg_yellow);
|
||||
|
||||
button_refresh.on_select = [this](Button&) { refresh(); };
|
||||
button_done.on_select = [&nav](Button&) { nav.pop(); };
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void Si5351PLLADebugView::focus() {
|
||||
button_refresh.focus();
|
||||
}
|
||||
|
||||
void Si5351PLLADebugView::refresh() {
|
||||
// Read PLL A parameters
|
||||
uint8_t r26 = portapack::clock_manager.si5351_read_register(26);
|
||||
uint8_t r27 = portapack::clock_manager.si5351_read_register(27);
|
||||
uint8_t r28 = portapack::clock_manager.si5351_read_register(28);
|
||||
uint8_t r29 = portapack::clock_manager.si5351_read_register(29);
|
||||
uint8_t r30 = portapack::clock_manager.si5351_read_register(30);
|
||||
uint8_t r31 = portapack::clock_manager.si5351_read_register(31);
|
||||
uint8_t r32 = portapack::clock_manager.si5351_read_register(32);
|
||||
uint8_t r33 = portapack::clock_manager.si5351_read_register(33);
|
||||
|
||||
// Display Raw registers
|
||||
text_r26_27.set("R26-27 (P3 LO): " + to_string_hex(r26, 2) + " " + to_string_hex(r27, 2));
|
||||
text_r28_30.set("R28-30 (P1): " + to_string_hex(r28, 2) + " " + to_string_hex(r29, 2) + " " + to_string_hex(r30, 2));
|
||||
text_r31_33.set("R31-33 (P3H|P2):" + to_string_hex(r31, 2) + " " + to_string_hex(r32, 2) + " " + to_string_hex(r33, 2));
|
||||
|
||||
// Decode parameters
|
||||
uint32_t pll_p1 = ((uint32_t)(r28 & 0x03) << 16) | ((uint32_t)r29 << 8) | r30;
|
||||
uint32_t pll_p2 = ((uint32_t)(r31 & 0x0F) << 16) | ((uint32_t)r32 << 8) | r33;
|
||||
uint32_t pll_p3 = ((uint32_t)(r31 >> 4) << 16) | ((uint32_t)r26 << 8) | r27;
|
||||
|
||||
text_p1.set(to_string_dec_uint(pll_p1) + " (0x" + to_string_hex(pll_p1, 5) + ")");
|
||||
text_p2.set(to_string_dec_uint(pll_p2) + " (0x" + to_string_hex(pll_p2, 5) + ")");
|
||||
text_p3.set(to_string_dec_uint(pll_p3) + " (0x" + to_string_hex(pll_p3, 5) + ")");
|
||||
|
||||
// Calculate Multiplier: M = (128 * P3 + P1 * 128 + 512 + P2) / (128 * P3)
|
||||
// Simplified as: Multiplier = ((P1 + 512) / 128) + (P2 / P3)
|
||||
uint32_t a = (pll_p1 + 512) / 128;
|
||||
|
||||
if (pll_p3 > 0) {
|
||||
text_mult.set(to_string_dec_uint(a) + " + " + to_string_dec_uint(pll_p2) + "/" + to_string_dec_uint(pll_p3));
|
||||
} else {
|
||||
text_mult.set("ERR: P3=0");
|
||||
}
|
||||
|
||||
// Calculate VCO Frequency (f_vco = f_xtal * Multiplier)
|
||||
// The HackRF crystal (f_xtal) is 25 MHz.
|
||||
if (pll_p3 > 0) {
|
||||
uint64_t vco_num = (uint64_t)pll_p2 + (uint64_t)pll_p3 * (pll_p1 + 512);
|
||||
uint64_t vco_den = 128ULL * pll_p3;
|
||||
uint32_t vco_khz = (uint32_t)((25000ULL * vco_num) / vco_den);
|
||||
|
||||
text_vco.set(to_string_dec_uint(vco_khz / 1000) + "." + to_string_dec_uint(vco_khz % 1000, 3) + " MHz");
|
||||
|
||||
// Si5351 VCO range is 600-900 MHz
|
||||
if (vco_khz >= 600000 && vco_khz <= 900000) {
|
||||
text_vco.set_style(Theme::getInstance()->fg_green);
|
||||
text_status.set("VCO within valid range.");
|
||||
} else {
|
||||
text_vco.set_style(Theme::getInstance()->fg_red);
|
||||
text_status.set("VCO OUT OF RANGE (600-900)!");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
Si5351PLLBDebugView::Si5351PLLBDebugView(NavigationView& nav)
|
||||
: nav_(nav) {
|
||||
add_children({&text_title,
|
||||
&text_lbl_raw, &text_r34_35, &text_r36_38, &text_r39_41,
|
||||
&text_lbl_decoded, &text_lbl_p1, &text_p1, &text_lbl_p2, &text_p2, &text_lbl_p3, &text_p3,
|
||||
&text_lbl_calc, &text_lbl_vco, &text_vco,
|
||||
&text_status, &button_refresh, &button_done});
|
||||
|
||||
text_title.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_lbl_raw.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_lbl_decoded.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_lbl_calc.set_style(Theme::getInstance()->fg_yellow);
|
||||
|
||||
button_refresh.on_select = [this](Button&) { refresh(); };
|
||||
button_done.on_select = [&nav](Button&) { nav.pop(); };
|
||||
refresh();
|
||||
}
|
||||
|
||||
void Si5351PLLBDebugView::focus() {
|
||||
button_refresh.focus();
|
||||
}
|
||||
|
||||
void Si5351PLLBDebugView::refresh() {
|
||||
uint8_t r34 = portapack::clock_manager.si5351_read_register(34); // P3[15:8]
|
||||
uint8_t r35 = portapack::clock_manager.si5351_read_register(35); // P3[7:0]
|
||||
uint8_t r36 = portapack::clock_manager.si5351_read_register(36); // P1[17:16]
|
||||
uint8_t r37 = portapack::clock_manager.si5351_read_register(37); // P1[15:8]
|
||||
uint8_t r38 = portapack::clock_manager.si5351_read_register(38); // P1[7:0]
|
||||
uint8_t r39 = portapack::clock_manager.si5351_read_register(39); // P3[19:16] | P2[19:16]
|
||||
uint8_t r40 = portapack::clock_manager.si5351_read_register(40); // P2[15:8]
|
||||
uint8_t r41 = portapack::clock_manager.si5351_read_register(41); // P2[7:0]
|
||||
|
||||
text_r34_35.set("R34-35: " + to_string_hex(r34, 2) + " " + to_string_hex(r35, 2));
|
||||
text_r36_38.set("R36-38: " + to_string_hex(r36, 2) + " " + to_string_hex(r37, 2) + " " + to_string_hex(r38, 2));
|
||||
text_r39_41.set("R39-41: " + to_string_hex(r39, 2) + " " + to_string_hex(r40, 2) + " " + to_string_hex(r41, 2));
|
||||
|
||||
uint32_t p1 = ((uint32_t)(r36 & 0x03) << 16) | ((uint32_t)r37 << 8) | r38;
|
||||
uint32_t p2 = ((uint32_t)(r39 & 0x0F) << 16) | ((uint32_t)r40 << 8) | r41;
|
||||
uint32_t p3 = ((uint32_t)(r39 >> 4) << 16) | ((uint32_t)r34 << 8) | r35;
|
||||
|
||||
text_p1.set(to_string_dec_uint(p1) + " (0x" + to_string_hex(p1, 5) + ")");
|
||||
text_p2.set(to_string_dec_uint(p2) + " (0x" + to_string_hex(p2, 5) + ")");
|
||||
text_p3.set(to_string_dec_uint(p3) + " (0x" + to_string_hex(p3, 5) + ")");
|
||||
|
||||
if (p3 > 0) {
|
||||
uint64_t vco_num = (uint64_t)p2 + (uint64_t)p3 * (p1 + 512);
|
||||
uint64_t vco_den = 128ULL * p3;
|
||||
uint32_t vco_khz = (uint32_t)((25000ULL * vco_num) / vco_den);
|
||||
text_vco.set(to_string_dec_uint(vco_khz / 1000) + "." + to_string_dec_uint(vco_khz % 1000, 3) + " MHz");
|
||||
|
||||
bool ok = (vco_khz >= 600000 && vco_khz <= 900000);
|
||||
text_vco.set_style(ok ? Theme::getInstance()->fg_green : Theme::getInstance()->fg_red);
|
||||
text_status.set(ok ? "PLL B VCO OK" : "VCO OUT OF RANGE!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
/* Si5351MultiSynthDebugView *************************************************/
|
||||
|
||||
Si5351MultiSynthDebugView::Si5351MultiSynthDebugView(NavigationView& nav)
|
||||
: nav_(nav) {
|
||||
add_children({
|
||||
&text_title,
|
||||
&text_lbl_clk_ctrl,
|
||||
&text_clk_ctrl,
|
||||
&text_lbl_ms_int,
|
||||
&text_ms_int,
|
||||
&text_lbl_raw,
|
||||
&text_lbl_r42_43,
|
||||
&text_r42_43,
|
||||
&text_lbl_r44_46,
|
||||
&text_r44_46,
|
||||
&text_lbl_r47_49,
|
||||
&text_r47_49,
|
||||
&text_lbl_decoded,
|
||||
&text_lbl_p1,
|
||||
&text_p1,
|
||||
&text_lbl_p2,
|
||||
&text_p2,
|
||||
&text_lbl_p3,
|
||||
&text_p3,
|
||||
&text_lbl_rdiv,
|
||||
&text_rdiv,
|
||||
&text_lbl_calc,
|
||||
&text_lbl_div,
|
||||
&text_div,
|
||||
&text_lbl_freq,
|
||||
&text_freq,
|
||||
&text_status,
|
||||
&button_refresh,
|
||||
&button_reset,
|
||||
&button_frac,
|
||||
&button_done,
|
||||
});
|
||||
|
||||
text_title.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_lbl_raw.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_lbl_decoded.set_style(Theme::getInstance()->fg_yellow);
|
||||
text_lbl_calc.set_style(Theme::getInstance()->fg_yellow);
|
||||
|
||||
button_refresh.on_select = [this](Button&) {
|
||||
refresh();
|
||||
};
|
||||
|
||||
button_reset.on_select = [this](Button&) {
|
||||
force_pll_reset();
|
||||
};
|
||||
|
||||
button_frac.on_select = [this](Button&) {
|
||||
force_fractional_mode();
|
||||
};
|
||||
|
||||
button_done.on_select = [&nav](Button&) {
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void Si5351MultiSynthDebugView::focus() {
|
||||
button_refresh.focus();
|
||||
}
|
||||
|
||||
void Si5351MultiSynthDebugView::force_pll_reset() {
|
||||
// Reset PLL A (bit 5)
|
||||
portapack::clock_manager.si5351_write_register(177, 0x20);
|
||||
|
||||
// Wait for PLL to settle
|
||||
chThdSleepMilliseconds(10);
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void Si5351MultiSynthDebugView::force_fractional_mode() {
|
||||
// Force CLK0 to fractional mode
|
||||
// Read current control register
|
||||
uint8_t clk0_ctrl = portapack::clock_manager.si5351_read_register(16);
|
||||
|
||||
// Clear MS_INT bit (bit 6) to enable fractional mode
|
||||
clk0_ctrl &= ~0x40;
|
||||
|
||||
// Write back
|
||||
portapack::clock_manager.si5351_write_register(16, clk0_ctrl);
|
||||
|
||||
// Reset PLL to apply
|
||||
portapack::clock_manager.si5351_write_register(177, 0x20);
|
||||
|
||||
chThdSleepMilliseconds(10);
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void Si5351MultiSynthDebugView::refresh() {
|
||||
// === Clock Control Register 16 (CLK0) ===
|
||||
uint8_t clk0_ctrl = portapack::clock_manager.si5351_read_register(16);
|
||||
text_clk_ctrl.set("0x" + to_string_hex(clk0_ctrl, 2) +
|
||||
" (" + to_string_bin(clk0_ctrl, 8) + ")");
|
||||
|
||||
// Decode MS_INT bit (bit 6)
|
||||
bool ms_int = (clk0_ctrl >> 6) & 1;
|
||||
if (ms_int) {
|
||||
text_ms_int.set("1:INT MODE!");
|
||||
text_ms_int.set_style(Theme::getInstance()->fg_red);
|
||||
} else {
|
||||
text_ms_int.set("0:Fract Mode");
|
||||
text_ms_int.set_style(Theme::getInstance()->fg_green);
|
||||
}
|
||||
|
||||
// === Read Raw MS0 Registers (42-49) ===
|
||||
uint8_t r42 = portapack::clock_manager.si5351_read_register(42);
|
||||
uint8_t r43 = portapack::clock_manager.si5351_read_register(43);
|
||||
uint8_t r44 = portapack::clock_manager.si5351_read_register(44);
|
||||
uint8_t r45 = portapack::clock_manager.si5351_read_register(45);
|
||||
uint8_t r46 = portapack::clock_manager.si5351_read_register(46);
|
||||
uint8_t r47 = portapack::clock_manager.si5351_read_register(47);
|
||||
uint8_t r48 = portapack::clock_manager.si5351_read_register(48);
|
||||
uint8_t r49 = portapack::clock_manager.si5351_read_register(49);
|
||||
|
||||
// Display raw registers
|
||||
text_r42_43.set(to_string_hex(r42, 2) + " " + to_string_hex(r43, 2) +
|
||||
" (P3[15:0])");
|
||||
text_r44_46.set(to_string_hex(r44, 2) + " " + to_string_hex(r45, 2) +
|
||||
" " + to_string_hex(r46, 2) + " (R|P1)");
|
||||
text_r47_49.set(to_string_hex(r47, 2) + " " + to_string_hex(r48, 2) +
|
||||
" " + to_string_hex(r49, 2) + " (P3|P2)");
|
||||
|
||||
// === Decode P1, P2, P3 ===
|
||||
// Si5351 MS Register Layout:
|
||||
// Reg 42: P3[15:8]
|
||||
// Reg 43: P3[7:0]
|
||||
// Reg 44: bits 6:4 = R_DIV[2:0], bits 1:0 = P1[17:16]
|
||||
// Reg 45: P1[15:8]
|
||||
// Reg 46: P1[7:0]
|
||||
// Reg 47: bits 7:4 = P3[19:16], bits 3:0 = P2[19:16]
|
||||
// Reg 48: P2[15:8]
|
||||
// Reg 49: P2[7:0]
|
||||
|
||||
// Decode R_DIV
|
||||
uint8_t r_div_encoded = (r44 >> 4) & 0x07;
|
||||
uint32_t r_div = 1 << r_div_encoded;
|
||||
text_rdiv.set("/" + to_string_dec_uint(r_div) + " (enc=" + to_string_dec_uint(r_div_encoded) + ")");
|
||||
|
||||
// Decode P1 (18-bit)
|
||||
uint32_t p1 = ((uint32_t)(r44 & 0x03) << 16) | ((uint32_t)r45 << 8) | r46;
|
||||
text_p1.set(to_string_dec_uint(p1) + " (0x" + to_string_hex(p1, 5) + ")");
|
||||
|
||||
// Decode P2 (20-bit)
|
||||
uint32_t p2 = ((uint32_t)(r47 & 0x0F) << 16) | ((uint32_t)r48 << 8) | r49;
|
||||
text_p2.set(to_string_dec_uint(p2) + " (0x" + to_string_hex(p2, 5) + ")");
|
||||
|
||||
// Decode P3 (20-bit)
|
||||
uint32_t p3 = ((uint32_t)(r47 >> 4) << 16) | ((uint32_t)r42 << 8) | r43;
|
||||
text_p3.set(to_string_dec_uint(p3) + " (0x" + to_string_hex(p3, 5) + ")");
|
||||
|
||||
// Color code P2/P3 based on whether fractional is being used
|
||||
if (p2 == 0 && p3 == 1) {
|
||||
text_p2.set_style(Theme::getInstance()->fg_orange);
|
||||
text_p3.set_style(Theme::getInstance()->fg_orange);
|
||||
} else if (p3 > 1) {
|
||||
text_p2.set_style(Theme::getInstance()->fg_green);
|
||||
text_p3.set_style(Theme::getInstance()->fg_green);
|
||||
} else {
|
||||
// Default/neutral style when P2/P3 don't match known patterns
|
||||
text_p2.set_style(Theme::getInstance()->fg_light);
|
||||
text_p3.set_style(Theme::getInstance()->fg_light);
|
||||
}
|
||||
|
||||
// === Calculate Output Frequency ===
|
||||
|
||||
// === Calculate Multisynth Divider ===
|
||||
// Correct Si5351 formula:
|
||||
// MS_DIV = (P2+P3 × (P1 + 512)) / (128 × P3)
|
||||
// MS_DIV = P2/(128*P3) + P1+512/(128*P3)
|
||||
// x = (P1 + 512) / 128
|
||||
// y = P2/128
|
||||
// z = P3
|
||||
// f_out = f_vco / MS_DIV / R_DIV
|
||||
// a = floor((P1 + 512) / 128)
|
||||
// k = (P1 + 512) - 128*a
|
||||
// b = b = (P2 + c*k) / 128
|
||||
// c = P3
|
||||
// In the case of integer division: b=0, c=1, so MS_DIV = a
|
||||
|
||||
uint64_t ms_div_numerator = (uint64_t)p2 + (uint64_t)p3 * (p1 + 512);
|
||||
uint64_t ms_div_denominator = 128ULL * p3;
|
||||
|
||||
uint32_t x = (p1 + 512) / 128;
|
||||
uint32_t y = p2 / 128;
|
||||
uint32_t z = p3;
|
||||
|
||||
// For display, show the full fractional value
|
||||
// MS_DIV = (a+b)/c
|
||||
if (p3 > 1 && p2 > 0) {
|
||||
std::string div_str = "(" + to_string_dec_uint(x) + "+" + to_string_dec_uint(y) + ")/" + to_string_dec_uint(z);
|
||||
text_div.set(div_str);
|
||||
} else {
|
||||
std::string div_str = to_string_dec_uint(x);
|
||||
text_div.set(div_str);
|
||||
}
|
||||
|
||||
// === Calculate Output Frequency ===
|
||||
|
||||
// f_vco = 800,000,000 (PLL A)
|
||||
// f_out in kHz = 800,000,000 / MS_DIV / r_div / 1000
|
||||
// = 800,000 × ms_div_denominator / ms_div_numerator / r_div
|
||||
|
||||
uint32_t freq_khz = 0;
|
||||
if (ms_div_numerator > 0) {
|
||||
freq_khz = (uint32_t)((800000ULL * ms_div_denominator) / ms_div_numerator / r_div);
|
||||
}
|
||||
|
||||
uint32_t freq_mhz = freq_khz / 1000;
|
||||
uint32_t freq_frac = freq_khz % 1000;
|
||||
|
||||
text_freq.set(to_string_dec_uint(freq_mhz) + "." +
|
||||
to_string_dec_uint(freq_frac / 100) +
|
||||
to_string_dec_uint((freq_frac / 10) % 10) +
|
||||
to_string_dec_uint(freq_frac % 10) + " MHz");
|
||||
|
||||
// Color code based on expected ~24.576 MHz for WFM stereo
|
||||
if (freq_khz >= 24500 && freq_khz <= 24700) {
|
||||
text_freq.set_style(Theme::getInstance()->fg_green);
|
||||
} else if (freq_khz >= 24000 && freq_khz <= 26000) {
|
||||
text_freq.set_style(Theme::getInstance()->fg_orange);
|
||||
} else {
|
||||
text_freq.set_style(Theme::getInstance()->fg_red);
|
||||
}
|
||||
|
||||
// === Status Summary ===
|
||||
// Expected values for 24.576 MHz (3.072 MHz * 8 decimation):
|
||||
// VCO = 800 MHz
|
||||
// Target freq = 49.152 MHz (before R_DIV=/2)
|
||||
// MS_DIV = 800M / 49.152M = 16.276...
|
||||
// a = 16, b = 53, c = 192
|
||||
// P1 = 128*16 + floor(128*53/192) - 512 = 2048 + 35 - 512 = 1571
|
||||
// P2 = 128*53 - 192*35 = 6784 - 6720 = 64
|
||||
// P3 = 192
|
||||
|
||||
if (ms_int) {
|
||||
text_status.set("ERROR: Integer mode! P2/P3 ignored!");
|
||||
text_status.set_style(Theme::getInstance()->fg_red);
|
||||
} else if (p2 == 0 && p3 == 1) {
|
||||
text_status.set("WARN P2:0,P3:1 INT Equiv");
|
||||
text_status.set_style(Theme::getInstance()->fg_orange);
|
||||
} else if (p3 == 192 && p2 == 64) {
|
||||
text_status.set("GOOD Exp 3.072M values!");
|
||||
text_status.set_style(Theme::getInstance()->fg_green);
|
||||
} else if (freq_khz >= 24500 && freq_khz <= 24700) {
|
||||
text_status.set("OK: Freq in range");
|
||||
text_status.set_style(Theme::getInstance()->fg_green);
|
||||
} else {
|
||||
text_status.set("CHECK: P2=" + to_string_dec_uint(p2) +
|
||||
" P3=" + to_string_dec_uint(p3));
|
||||
text_status.set_style(Theme::getInstance()->fg_orange);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
PralineClockDebugView::PralineClockDebugView(NavigationView& nav)
|
||||
: View(),
|
||||
rows{
|
||||
{&t0_id, &t0_ma, &t0_mode, &t0_src, &t0_ph, &t0_st},
|
||||
{&t1_id, &t1_ma, &t1_mode, &t1_src, &t1_ph, &t1_st},
|
||||
{&t2_id, &t2_ma, &t2_mode, &t2_src, &t2_ph, &t2_st},
|
||||
{&t3_id, &t3_ma, &t3_mode, &t3_src, &t3_ph, &t3_st},
|
||||
{&t4_id, &t4_ma, &t4_mode, &t4_src, &t4_ph, &t4_st},
|
||||
{&t5_id, &t5_ma, &t5_mode, &t5_src, &t5_ph, &t5_st},
|
||||
{&t6_id, &t6_ma, &t6_mode, &t6_src, &t6_ph, &t6_st},
|
||||
{&t7_id, &t7_ma, &t7_mode, &t7_src, &t7_ph, &t7_st}} {
|
||||
add_children({&text_title, &text_lbl_pll, &text_pll_status,
|
||||
&text_lbl_afe, &text_afe_rate, &text_lbl_n, &text_n_val,
|
||||
&text_header,
|
||||
&t0_id, &t0_ma, &t0_mode, &t0_src, &t0_ph, &t0_st,
|
||||
&t1_id, &t1_ma, &t1_mode, &t1_src, &t1_ph, &t1_st,
|
||||
&t2_id, &t2_ma, &t2_mode, &t2_src, &t2_ph, &t2_st,
|
||||
&t3_id, &t3_ma, &t3_mode, &t3_src, &t3_ph, &t3_st,
|
||||
&t4_id, &t4_ma, &t4_mode, &t4_src, &t4_ph, &t4_st,
|
||||
&t5_id, &t5_ma, &t5_mode, &t5_src, &t5_ph, &t5_st,
|
||||
&t6_id, &t6_ma, &t6_mode, &t6_src, &t6_ph, &t6_st,
|
||||
&t7_id, &t7_ma, &t7_mode, &t7_src, &t7_ph, &t7_st,
|
||||
&button_refresh, &button_done});
|
||||
|
||||
button_refresh.on_select = [this](Button&) { this->refresh(); };
|
||||
button_done.on_select = [&nav](Button&) { nav.pop(); };
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void PralineClockDebugView::focus() {
|
||||
button_refresh.focus();
|
||||
}
|
||||
|
||||
void PralineClockDebugView::refresh() {
|
||||
// 1. System Status
|
||||
uint8_t status = portapack::clock_manager.si5351_read_status();
|
||||
bool pll_a = !(status & 0x20);
|
||||
bool pll_b = !(status & 0x40);
|
||||
text_pll_status.set(std::string(pll_a ? "A:OK " : "A:ERR ") + (pll_b ? "B:OK" : "B:ERR"));
|
||||
text_pll_status.set_style((pll_a && pll_b) ? Theme::getInstance()->fg_green : Theme::getInstance()->fg_red);
|
||||
|
||||
// 2. AFE & Decimation Info
|
||||
uint32_t base_rate = portapack::clock_manager.get_sampling_frequency();
|
||||
uint8_t n = portapack::clock_manager.get_resampling_n();
|
||||
text_afe_rate.set(to_string_dec_uint(base_rate << n) + " Hz");
|
||||
text_n_val.set(to_string_dec_uint(n));
|
||||
|
||||
// 3. Clock Table Decoding
|
||||
uint8_t output_en = portapack::clock_manager.si5351_read_register(3);
|
||||
const char* ma_lookup[] = {"2m", "4m", "6m", "8m"};
|
||||
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
uint8_t ctrl = portapack::clock_manager.si5351_read_register(16 + i);
|
||||
|
||||
// mA (Bits 1:0)
|
||||
rows[i].ma->set(ma_lookup[ctrl & 0x03]);
|
||||
|
||||
// Mode (Bit 6: 1=Integer, 0=Fractional)
|
||||
rows[i].mode->set((ctrl & 0x40) ? "INT" : "FRAC");
|
||||
rows[i].mode->set_style((ctrl & 0x40) ? Theme::getInstance()->fg_blue : Theme::getInstance()->fg_yellow);
|
||||
|
||||
// PLL Source (Bit 5: 0=PLLA, 1=PLLB)
|
||||
rows[i].src->set((ctrl & 0x20) ? "PLLB" : "PLLA");
|
||||
rows[i].src->set_style((ctrl & 0x20) ? Theme::getInstance()->fg_blue : Theme::getInstance()->fg_green);
|
||||
|
||||
// Phase (Bit 4: 1=Inverted, 0=Normal)
|
||||
// Use 0x10 (Bit 4)
|
||||
rows[i].phase->set((ctrl & 0x10) ? "INVRT" : "NORM ");
|
||||
rows[i].phase->set_style((ctrl & 0x10) ? Theme::getInstance()->fg_orange : Theme::getInstance()->fg_light);
|
||||
|
||||
// Status (Powered On and Output Enabled)
|
||||
bool is_on = !(ctrl & 0x80) && !(output_en & (1 << i));
|
||||
rows[i].stat->set(is_on ? "ON" : "OFF");
|
||||
rows[i].stat->set_style(is_on ? Theme::getInstance()->fg_green : Theme::getInstance()->fg_red);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
/* GPIODebugView *************************************************/
|
||||
GPIODebugView::GPIODebugView(NavigationView& nav) {
|
||||
@@ -2438,9 +3176,9 @@ void RFFC5072StatusView::refresh_status() {
|
||||
|
||||
// Blink LED
|
||||
/*for (int i = 0; i < 3; i++) {
|
||||
hackrf::one::led_rx.on();
|
||||
hackrf::one::led_rx.setActive();
|
||||
chThdSleepMilliseconds(100);
|
||||
hackrf::one::led_rx.off();
|
||||
hackrf::one::led_rx.setInactive();
|
||||
chThdSleepMilliseconds(100);
|
||||
}*/
|
||||
} else {
|
||||
@@ -2740,24 +3478,48 @@ DebugMenuView::DebugMenuView(NavigationView& nav)
|
||||
set_max_rows(2); // allow wider buttons
|
||||
}
|
||||
|
||||
#ifdef PRALINE
|
||||
/* PralineDebugMenuView *************************************************/
|
||||
|
||||
PralineDebugMenuView::PralineDebugMenuView(NavigationView& nav)
|
||||
: nav_(nav) {
|
||||
set_max_rows(2); // Allows wider buttons for descriptive titles
|
||||
}
|
||||
|
||||
void PralineDebugMenuView::on_populate() {
|
||||
if (portapack::persistent_memory::show_gui_return_icon()) {
|
||||
add_items({{"..", ui::Theme::getInstance()->fg_light->foreground, &bitmap_icon_previous, [this]() { nav_.pop(); }}});
|
||||
}
|
||||
add_items({
|
||||
{"WFM Audio", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<WFMAudioDebugView>(); }},
|
||||
{"Clocks", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<ui::PralineClockDebugView>(); }},
|
||||
{"MSynth", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<Si5351MultiSynthDebugView>(); }},
|
||||
{"Radio Diag", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<RadioDiagnosticsView>(); }},
|
||||
{"Radio Debug", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<PralineRadioDebugView>(); }},
|
||||
{"Signal Path", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<SignalPathStatusView>(); }},
|
||||
{"System Diag", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<SystemDiagnosticsView>(); }},
|
||||
{"PLL A", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<Si5351PLLADebugView>(); }},
|
||||
{"PLL B", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<Si5351PLLBDebugView>(); }},
|
||||
{"GPIO", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<GPIODebugView>(); }},
|
||||
{"RFFC Status", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<RFFC5072StatusView>(); }},
|
||||
{"RFFC Tuning", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<RFFCTuningDebugView>(); }},
|
||||
{"MAX2831", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<MAX2831DebugView>(); }},
|
||||
{"Si5351", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<Si5351DebugView>(); }},
|
||||
{"SGPIO Clk", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<SGPIO8ClockDetectorView>(); }},
|
||||
{"Baseband", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<BasebandStatusView>(); }},
|
||||
{"SGPIO Live", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<SGPIOLiveMonitorView>(); }},
|
||||
{"RX Test", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<RadioRxTestView>(); }},
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
void DebugMenuView::on_populate() {
|
||||
if (portapack::persistent_memory::show_gui_return_icon()) {
|
||||
add_items({{"..", ui::Theme::getInstance()->fg_light->foreground, &bitmap_icon_previous, [this]() { nav_.pop(); }}});
|
||||
}
|
||||
add_items({
|
||||
#ifdef PRALINE
|
||||
{"System Diag", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<SystemDiagnosticsView>(); }},
|
||||
{"Radio Diag", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<RadioDiagnosticsView>(); }},
|
||||
{"Signal Path", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<SignalPathStatusView>(); }},
|
||||
{"GPIO Debug", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<GPIODebugView>(); }},
|
||||
{"RFFC Status", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<RFFC5072StatusView>(); }},
|
||||
{"RFFC Tuning", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<RFFCTuningDebugView>(); }},
|
||||
{"MAX2831 Debug", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<MAX2831DebugView>(); }},
|
||||
{"Si5351 Clocks", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<Si5351DebugView>(); }},
|
||||
{"SGPIO8 Clock", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<SGPIO8ClockDetectorView>(); }},
|
||||
{"Baseband Status", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<BasebandStatusView>(); }},
|
||||
{"SGPIO Live", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<SGPIOLiveMonitorView>(); }},
|
||||
{"RX Test", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<RadioRxTestView>(); }},
|
||||
{"Pro Debug", ui::Theme::getInstance()->fg_yellow->foreground, &bitmap_icon_setup, [this]() { nav_.push<PralineDebugMenuView>(); }},
|
||||
#endif
|
||||
{"Buttons Test", ui::Theme::getInstance()->fg_darkcyan->foreground, &bitmap_icon_controls, [this]() { nav_.push<DebugControlsView>(); }},
|
||||
{"M0 Stack Dump", ui::Theme::getInstance()->fg_darkcyan->foreground, &bitmap_icon_memory, [this]() { stack_dump(); }},
|
||||
|
||||
@@ -438,6 +438,123 @@ class RadioDiagnosticsView : public View {
|
||||
"Done"};
|
||||
};
|
||||
|
||||
#ifdef PRALINE
|
||||
class PralineDebugMenuView : public BtnGridView {
|
||||
public:
|
||||
PralineDebugMenuView(NavigationView& nav);
|
||||
std::string title() const override { return "Pro Debug"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
void on_populate() override;
|
||||
};
|
||||
|
||||
/* Praline-Specific Radio Debug View
|
||||
* Monitors Mixer Lock, SPI Bit Depth, and toggles Si5351 CLK5
|
||||
*/
|
||||
class PralineRadioDebugView : public View {
|
||||
public:
|
||||
PralineRadioDebugView(NavigationView& nav);
|
||||
void focus() override;
|
||||
std::string title() const override { return "Pro Radio Debug"; };
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
void toggle_clk5();
|
||||
|
||||
Text text_title{{0, 0, 240, 16}, "=== Pro Radio Debug ==="};
|
||||
|
||||
// Mixer Lock (PD_11 / GPIO6[25])
|
||||
Text text_lbl_lock{{0, 24, 124, 16}, "Mix Lock (LD):"};
|
||||
Text text_lock_status{{126, 24, 114, 16}, "---"};
|
||||
|
||||
// Si5351 CLK5 (Mixer Reference)
|
||||
Text text_lbl_clk5{{0, 40, 124, 16}, "Si5351 CLK5(Mix):"};
|
||||
Text text_clk5_status{{126, 40, 114, 16}, "---"};
|
||||
|
||||
// SPI Bus configuration check
|
||||
Text text_lbl_spi{{0, 56, 124, 16}, "SPI Bit Mode:"};
|
||||
Text text_spi_status{{126, 56, 118, 16}, "---"};
|
||||
|
||||
// FPGA DC Block (Reg 1)
|
||||
Text text_lbl_fpga_ctrl{{0, 72, 124, 16}, "FPGA Reg 1:"};
|
||||
Text text_fpga_ctrl{{126, 72, 118, 16}, "---"};
|
||||
|
||||
// VAA Power Rail (P8_1 / GPIO4[1])
|
||||
Text text_lbl_vaa{{0, 88, 124, 16}, "VAA RF Power:"};
|
||||
Text text_vaa_status{{126, 88, 118, 16}, "---"};
|
||||
|
||||
Text text_status_msg{{0, 110, 240, 48}, ""};
|
||||
|
||||
Button button_refresh{{8, 240, 72, 24}, "Refresh"};
|
||||
Button button_toggle_clk5{{88, 240, 72, 24}, "CLK5_T"};
|
||||
Button button_done{{168, 240, 64, 24}, "Done"};
|
||||
};
|
||||
#endif
|
||||
|
||||
/* WFMAudioDebugView ***************************************************/
|
||||
|
||||
#ifdef PRALINE
|
||||
class WFMAudioDebugView : public View {
|
||||
public:
|
||||
WFMAudioDebugView(NavigationView& nav);
|
||||
void focus() override;
|
||||
std::string title() const override { return "WFM Audio Debug"; }
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
|
||||
NavigationView& nav_;
|
||||
|
||||
Text text_title{{0, 0, 240, 16}, "=== WFM Audio Debug ==="};
|
||||
|
||||
// Sample rates section
|
||||
Text text_lbl_clk0{{0, 20, 140, 16}, "Si5351 CLK0 Rate:"};
|
||||
Text text_clk0{{150, 20, 90, 16}, "---"};
|
||||
|
||||
Text text_lbl_fpga_dec{{0, 36, 140, 16}, "FPGA Decimation:"};
|
||||
Text text_fpga_dec{{150, 36, 90, 16}, "---"};
|
||||
|
||||
Text text_lbl_post_fpga{{0, 52, 140, 16}, "Post-FPGA Rate:"};
|
||||
Text text_post_fpga{{150, 52, 90, 16}, "---"};
|
||||
|
||||
// MAX2831 section
|
||||
Text text_section1{{0, 72, 240, 16}, "--- MAX2831 LPF ---"};
|
||||
|
||||
Text text_lbl_reg8{{0, 88, 140, 16}, "Reg8 (LPF RX):"};
|
||||
Text text_reg8{{150, 88, 90, 16}, "---"};
|
||||
|
||||
Text text_lbl_lpf_bw{{0, 104, 140, 16}, "LPF Bandwidth:"};
|
||||
Text text_lpf_bw{{150, 104, 90, 16}, "---"};
|
||||
|
||||
// FPGA section
|
||||
Text text_section2{{0, 124, 240, 16}, "--- FPGA Control ---"};
|
||||
|
||||
Text text_lbl_fpga_r1{{0, 140, 140, 16}, "Reg1 (Ctrl):"};
|
||||
Text text_fpga_r1{{150, 140, 90, 16}, "---"};
|
||||
|
||||
Text text_lbl_dc_q{{0, 156, 70, 16}, "DC/Q/QS:"};
|
||||
Text text_dc_q{{72, 156, 168, 16}, "---"};
|
||||
|
||||
// Audio section
|
||||
Text text_section3{{0, 176, 240, 16}, "--- Audio Path ---"};
|
||||
|
||||
Text text_lbl_expected{{0, 192, 96, 16}, "Expctd Aud:"};
|
||||
Text text_expected{{98, 192, 142, 16}, "---"};
|
||||
|
||||
Text text_lbl_deemph{{0, 208, 96, 16}, "D-emph Cfg:"};
|
||||
Text text_deemph{{98, 208, 132, 16}, "---"};
|
||||
|
||||
// Status
|
||||
Text text_status{{0, 228, 240, 16}, "---"};
|
||||
Text text_status2{{0, 244, 240, 16}, "---"};
|
||||
|
||||
Button button_refresh{{10, 268, 70, 24}, "Refresh"};
|
||||
Button button_toggle_q{{90, 268, 70, 24}, "Toggle Q"};
|
||||
Button button_done{{170, 268, 60, 24}, "Done"};
|
||||
};
|
||||
#endif
|
||||
|
||||
/* BasebandStatusView ***************************************************/
|
||||
|
||||
class BasebandStatusView : public View {
|
||||
@@ -1018,6 +1135,265 @@ class SystemDiagnosticsView : public View {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
/* Si5351PLLADebugView - Debug fractional parameters for PLL A */
|
||||
class Si5351PLLADebugView : public View {
|
||||
public:
|
||||
Si5351PLLADebugView(NavigationView& nav);
|
||||
void focus() override;
|
||||
std::string title() const override { return "Si5351 PLL A Debug"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
void refresh();
|
||||
|
||||
Text text_title{{0, 0, 240, 16}, "===PLL A Fractional Debug==="};
|
||||
|
||||
// Raw register values
|
||||
Text text_lbl_raw{{0, 24, 240, 16}, "---Raw Registers (26-33)---"};
|
||||
Text text_r26_27{{8, 40, 224, 16}, "---"};
|
||||
Text text_r28_30{{8, 56, 224, 16}, "---"};
|
||||
Text text_r31_33{{8, 72, 224, 16}, "---"};
|
||||
|
||||
// Decoded values
|
||||
Text text_lbl_decoded{{0, 96, 240, 16}, "---Decoded Parameters---"};
|
||||
Text text_lbl_p1{{0, 112, 48, 16}, "P1:"};
|
||||
Text text_p1{{50, 112, 190, 16}, "---"};
|
||||
Text text_lbl_p2{{0, 128, 48, 16}, "P2:"};
|
||||
Text text_p2{{50, 128, 190, 16}, "---"};
|
||||
Text text_lbl_p3{{0, 144, 48, 16}, "P3:"};
|
||||
Text text_p3{{50, 144, 190, 16}, "---"};
|
||||
|
||||
// Calculated VCO
|
||||
Text text_lbl_calc{{0, 168, 240, 16}, "---Calculated VCO---"};
|
||||
Text text_lbl_mult{{0, 184, 80, 16}, "Multiplier:"};
|
||||
Text text_mult{{82, 184, 158, 16}, "---"};
|
||||
Text text_lbl_vco{{0, 200, 80, 16}, "VCO Freq:"};
|
||||
Text text_vco{{82, 200, 158, 16}, "---"};
|
||||
|
||||
Text text_status{{0, 224, 240, 32}, ""};
|
||||
|
||||
Button button_refresh{{8, 280, 100, 24}, "Refresh"};
|
||||
Button button_done{{132, 280, 100, 24}, "Done"};
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
class Si5351PLLBDebugView : public View {
|
||||
public:
|
||||
Si5351PLLBDebugView(NavigationView& nav);
|
||||
void focus() override;
|
||||
std::string title() const override { return "Si5351 PLL B Debug"; };
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
NavigationView& nav_;
|
||||
|
||||
Text text_title{{0, 0, 240, 16}, "=== PLL B Fractional Debug ==="};
|
||||
|
||||
Text text_lbl_raw{{0, 24, 240, 16}, "--- Raw Registers (34-41) ---"};
|
||||
Text text_r34_35{{8, 40, 224, 16}, "---"};
|
||||
Text text_r36_38{{8, 56, 224, 16}, "---"};
|
||||
Text text_r39_41{{8, 72, 224, 16}, "---"};
|
||||
|
||||
Text text_lbl_decoded{{0, 96, 240, 16}, "--- Decoded Parameters ---"};
|
||||
Text text_lbl_p1{{0, 112, 48, 16}, "P1:"};
|
||||
Text text_p1{{50, 112, 190, 16}, "---"};
|
||||
Text text_lbl_p2{{0, 128, 48, 16}, "P2:"};
|
||||
Text text_p2{{50, 128, 190, 16}, "---"};
|
||||
Text text_lbl_p3{{0, 144, 48, 16}, "P3:"};
|
||||
Text text_p3{{50, 144, 190, 16}, "---"};
|
||||
|
||||
Text text_lbl_calc{{0, 168, 240, 16}, "--- Calculated VCO ---"};
|
||||
Text text_lbl_vco{{0, 200, 80, 16}, "VCO Freq:"};
|
||||
Text text_vco{{82, 200, 158, 16}, "---"};
|
||||
|
||||
Text text_status{{0, 224, 240, 32}, ""};
|
||||
Button button_refresh{{8, 280, 100, 24}, "Refresh"};
|
||||
Button button_done{{132, 280, 100, 24}, "Done"};
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
/* Si5351MultiSynthDebugView - Debug fractional register values for MS0 */
|
||||
class Si5351MultiSynthDebugView : public View {
|
||||
public:
|
||||
Si5351MultiSynthDebugView(NavigationView& nav);
|
||||
void focus() override;
|
||||
std::string title() const override { return "Si5351 MS0 Debug"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
void refresh();
|
||||
void force_pll_reset();
|
||||
void force_fractional_mode();
|
||||
|
||||
Text text_title{{0, 0, 240, 16}, "===MS0 Fractional Debug==="};
|
||||
|
||||
// Clock Control Register 16 (CLK0)
|
||||
Text text_lbl_clk_ctrl{{0, 18, 100, 16}, "CLK0 Ctrl:"};
|
||||
Text text_clk_ctrl{{102, 18, 138, 16}, "---"};
|
||||
|
||||
Text text_lbl_ms_int{{0, 34, 100, 16}, "MS_INT bit:"};
|
||||
Text text_ms_int{{102, 34, 138, 16}, "---"};
|
||||
|
||||
// Raw register values
|
||||
Text text_lbl_raw{{0, 54, 240, 16}, "---Raw Registers (42-49)---"};
|
||||
|
||||
Text text_lbl_r42_43{{0, 70, 80, 16}, "R42-43:"};
|
||||
Text text_r42_43{{82, 70, 158, 16}, "---"};
|
||||
|
||||
Text text_lbl_r44_46{{0, 86, 80, 16}, "R44-46:"};
|
||||
Text text_r44_46{{82, 86, 158, 16}, "---"};
|
||||
|
||||
Text text_lbl_r47_49{{0, 102, 80, 16}, "R47-49:"};
|
||||
Text text_r47_49{{82, 102, 158, 16}, "---"};
|
||||
|
||||
// Decoded values
|
||||
Text text_lbl_decoded{{0, 122, 240, 16}, "---Decoded Values---"};
|
||||
|
||||
Text text_lbl_p1{{0, 138, 48, 16}, "P1:"};
|
||||
Text text_p1{{50, 138, 190, 16}, "---"};
|
||||
|
||||
Text text_lbl_p2{{0, 154, 48, 16}, "P2:"};
|
||||
Text text_p2{{50, 154, 190, 16}, "---"};
|
||||
|
||||
Text text_lbl_p3{{0, 170, 48, 16}, "P3:"};
|
||||
Text text_p3{{50, 170, 190, 16}, "---"};
|
||||
|
||||
Text text_lbl_rdiv{{0, 186, 48, 16}, "R_DIV:"};
|
||||
Text text_rdiv{{50, 186, 190, 16}, "---"};
|
||||
|
||||
// Calculated frequency
|
||||
Text text_lbl_calc{{0, 206, 240, 16}, "---Calculated Output---"};
|
||||
|
||||
Text text_lbl_div{{0, 222, 80, 16}, "MS Div:"};
|
||||
Text text_div{{82, 222, 158, 16}, "---"};
|
||||
|
||||
Text text_lbl_freq{{0, 238, 80, 16}, "CLK0 Out:"};
|
||||
Text text_freq{{82, 238, 158, 16}, "---"};
|
||||
|
||||
// Status
|
||||
Text text_status{{0, 258, 240, 16}, ""};
|
||||
|
||||
Button button_refresh{{2, 280, 56, 24}, "Refresh"};
|
||||
Button button_reset{{62, 280, 56, 24}, "PLL Rst"};
|
||||
Button button_frac{{122, 280, 56, 24}, "Frac"};
|
||||
Button button_done{{182, 280, 56, 24}, "Done"};
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PRALINE
|
||||
class PralineClockDebugView : public View {
|
||||
public:
|
||||
PralineClockDebugView(NavigationView& nav);
|
||||
void focus() override;
|
||||
std::string title() const override { return "Pro Clock Status"; };
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
|
||||
Text text_title{{0, 0, 240, 16}, "=== Pro Clock Dashboard ==="};
|
||||
|
||||
// System Status
|
||||
Text text_lbl_pll{{0, 20, 80, 16}, "PLL Lock:"};
|
||||
Text text_pll_status{{88, 20, 152, 16}, "---"};
|
||||
|
||||
Text text_lbl_afe{{0, 36, 80, 16}, "AFE Rate:"};
|
||||
Text text_afe_rate{{88, 36, 152, 16}, "---"};
|
||||
|
||||
Text text_lbl_n{{0, 52, 80, 16}, "Decim (n):"};
|
||||
Text text_n_val{{88, 52, 152, 16}, "-"};
|
||||
|
||||
// Table Header (Width 240px, 30 characters)
|
||||
Text text_header{{0, 72, 240, 16}, "ID mA Mode Src Phase Stat"};
|
||||
|
||||
// Helper structure to group row widgets for CLK0-CLK5
|
||||
struct ClockRow {
|
||||
Text* id;
|
||||
Text* ma;
|
||||
Text* mode;
|
||||
Text* src; // PLL A, or B
|
||||
Text* phase;
|
||||
Text* stat;
|
||||
};
|
||||
std::vector<ClockRow> rows;
|
||||
|
||||
// We define the actual widgets for 6 clocks
|
||||
// Note: Layout uses 16px vertical spacing per row
|
||||
|
||||
// Full list of clock row entries (C0 through C5)
|
||||
// Layout: Y starts at 88, increments by 16 per row.
|
||||
|
||||
// C0: MAX5864 (AFE/Sampling)
|
||||
Text t0_id{{0, 88, 24, 16}, "C0:"}; // Column 0
|
||||
Text t0_ma{{32, 88, 24, 16}, "-"}; // Column 4 (mA)
|
||||
Text t0_mode{{64, 88, 48, 16}, "-"}; // Column 8 (Mode)
|
||||
Text t0_src{{112, 88, 32, 16}, "-"}; // Column 14 (Src)
|
||||
Text t0_ph{{160, 88, 48, 16}, "-"}; // Column 20 (Phase)
|
||||
Text t0_st{{208, 88, 32, 16}, "-"}; // Column 26 (Stat)
|
||||
|
||||
// C1: iCE40 FPGA Timing
|
||||
Text t1_id{{0, 104, 24, 16}, "C1:"};
|
||||
Text t1_ma{{32, 104, 24, 16}, "-"};
|
||||
Text t1_mode{{64, 104, 48, 16}, "-"};
|
||||
Text t1_src{{112, 104, 32, 16}, "-"};
|
||||
Text t1_ph{{160, 104, 48, 16}, "-"};
|
||||
Text t1_st{{208, 104, 32, 16}, "-"};
|
||||
|
||||
// C2: LPC43xx MCU Input
|
||||
Text t2_id{{0, 120, 24, 16}, "C2:"};
|
||||
Text t2_ma{{32, 120, 24, 16}, "-"};
|
||||
Text t2_mode{{64, 120, 48, 16}, "-"};
|
||||
Text t2_src{{112, 120, 32, 16}, "-"};
|
||||
Text t2_ph{{160, 120, 48, 16}, "-"};
|
||||
Text t2_st{{208, 120, 32, 16}, "-"};
|
||||
|
||||
// C3: SG_CLK PORT 1 (Switching Regulator/Logic Sync)
|
||||
Text t3_id{{0, 136, 24, 16}, "C3:"};
|
||||
Text t3_ma{{32, 136, 24, 16}, "-"};
|
||||
Text t3_mode{{64, 136, 48, 16}, "-"};
|
||||
Text t3_src{{112, 136, 32, 16}, "-"};
|
||||
Text t3_ph{{160, 136, 48, 16}, "-"};
|
||||
Text t3_st{{208, 136, 32, 16}, "-"};
|
||||
|
||||
// C4: P_CLK (Peripheral/Expansion Clock)
|
||||
Text t4_id{{0, 152, 24, 16}, "C4:"};
|
||||
Text t4_ma{{32, 152, 24, 16}, "-"};
|
||||
Text t4_mode{{64, 152, 48, 16}, "-"};
|
||||
Text t4_src{{112, 152, 32, 16}, "-"};
|
||||
Text t4_ph{{160, 152, 48, 16}, "-"};
|
||||
Text t4_st{{208, 152, 32, 16}, "-"};
|
||||
|
||||
// C5: AUX_CLK (Auxiliary Reference)
|
||||
Text t5_id{{0, 168, 24, 16}, "C5:"};
|
||||
Text t5_ma{{32, 168, 24, 16}, "-"};
|
||||
Text t5_mode{{64, 168, 48, 16}, "-"};
|
||||
Text t5_src{{112, 168, 32, 16}, "-"};
|
||||
Text t5_ph{{160, 168, 48, 16}, "-"};
|
||||
Text t5_st{{208, 168, 32, 16}, "-"};
|
||||
|
||||
// C6: SG_CLK PORT 2 (Switching Regulator/Logic Sync)
|
||||
Text t6_id{{0, 184, 24, 16}, "C6:"};
|
||||
Text t6_ma{{32, 184, 24, 16}, "-"};
|
||||
Text t6_mode{{64, 184, 48, 16}, "-"};
|
||||
Text t6_src{{112, 184, 32, 16}, "-"};
|
||||
Text t6_ph{{160, 184, 48, 16}, "-"};
|
||||
Text t6_st{{208, 184, 32, 16}, "-"};
|
||||
|
||||
// C7: UNUSED_CLK (Internal Expansion)
|
||||
Text t7_id{{0, 200, 24, 16}, "C7:"};
|
||||
Text t7_ma{{32, 200, 24, 16}, "-"};
|
||||
Text t7_mode{{64, 200, 48, 16}, "-"};
|
||||
Text t7_src{{112, 200, 32, 16}, "-"};
|
||||
Text t7_ph{{160, 200, 48, 16}, "-"};
|
||||
Text t7_st{{208, 200, 32, 16}, "-"};
|
||||
|
||||
Button button_refresh{{8, 260, 100, 24}, "Refresh"};
|
||||
Button button_done{{132, 260, 100, 24}, "Done"};
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
class DebugPeripheralsMenuView : public BtnGridView {
|
||||
|
||||
@@ -103,7 +103,8 @@ DfuMenu2::DfuMenu2(NavigationView& nav)
|
||||
&text_info_line_8,
|
||||
&text_info_line_9,
|
||||
&text_info_line_10,
|
||||
&text_info_line_11});
|
||||
&text_info_line_11,
|
||||
&text_info_line_12});
|
||||
}
|
||||
|
||||
void DfuMenu2::paint(Painter& painter) {
|
||||
@@ -118,9 +119,12 @@ void DfuMenu2::paint(Painter& painter) {
|
||||
text_info_line_9.set(to_string_dec_uint(portapack::transmitter_model.target_frequency(), 10));
|
||||
text_info_line_10.set(to_string_dec_uint(portapack::transmitter_model.baseband_bandwidth(), 10));
|
||||
text_info_line_11.set(to_string_dec_uint(portapack::transmitter_model.sampling_rate(), 10));
|
||||
text_info_line_12.set(std::string("M") + (radio::get_mixer_invert() ? "Y" : "N") +
|
||||
" B" + (radio::get_baseband_invert() ? "Y" : "N") +
|
||||
" IQ" + ((radio::get_mixer_invert() ^ radio::get_baseband_invert()) ? "Y" : "N"));
|
||||
|
||||
constexpr auto margin = 5;
|
||||
constexpr auto lines = 11 + 2;
|
||||
constexpr auto lines = 12 + 2;
|
||||
|
||||
painter.fill_rectangle(
|
||||
{{5 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin},
|
||||
|
||||
@@ -96,6 +96,7 @@ class DfuMenu2 : public View {
|
||||
{{5 * CHARACTER_WIDTH, 13 * LINE_HEIGHT}, "TX Freq:", Theme::getInstance()->fg_darkcyan->foreground},
|
||||
{{5 * CHARACTER_WIDTH, 14 * LINE_HEIGHT}, "TX BW:", Theme::getInstance()->fg_darkcyan->foreground},
|
||||
{{5 * CHARACTER_WIDTH, 15 * LINE_HEIGHT}, "TX SampR:", Theme::getInstance()->fg_darkcyan->foreground},
|
||||
{{5 * CHARACTER_WIDTH, 16 * LINE_HEIGHT}, "IQ Inv:", Theme::getInstance()->fg_darkcyan->foreground},
|
||||
};
|
||||
|
||||
Text text_info_line_1{{14 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
@@ -109,6 +110,7 @@ class DfuMenu2 : public View {
|
||||
Text text_info_line_9{{14 * CHARACTER_WIDTH, 13 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_10{{14 * CHARACTER_WIDTH, 14 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_11{{14 * CHARACTER_WIDTH, 15 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_12{{(14 + 1) * CHARACTER_WIDTH, 16 * LINE_HEIGHT, (10 - 1) * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace ui {
|
||||
static const fs::path txt_ext{u".TXT"};
|
||||
static const fs::path ppl_ext{u".PPL"};
|
||||
static const fs::path c8_ext{u".C8"};
|
||||
static const fs::path cu8_ext{u".CU8"};
|
||||
static const fs::path c16_ext{u".C16"};
|
||||
static const fs::path cxx_ext{u".C*"};
|
||||
static const fs::path png_ext{u".PNG"};
|
||||
@@ -88,8 +89,11 @@ fs::path get_partner_file(fs::path path) {
|
||||
path.replace_extension(txt_ext);
|
||||
else if (path_iequal(ext, txt_ext)) {
|
||||
path.replace_extension(c8_ext);
|
||||
if (!fs::file_exists(path))
|
||||
path.replace_extension(cu8_ext);
|
||||
if (!fs::file_exists(path))
|
||||
path.replace_extension(c16_ext);
|
||||
|
||||
} else
|
||||
return {};
|
||||
|
||||
@@ -386,6 +390,7 @@ std::string get_stem(std::string t) {
|
||||
return t.substr(0, index);
|
||||
}
|
||||
}
|
||||
|
||||
std::string get_filename(std::string _s) {
|
||||
const auto index = _s.find_last_of("/");
|
||||
if (index == _s.npos) {
|
||||
@@ -394,6 +399,7 @@ std::string get_filename(std::string _s) {
|
||||
return _s.substr(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void FileManBaseView::refresh_list() {
|
||||
if (on_refresh_widgets)
|
||||
on_refresh_widgets(false);
|
||||
@@ -404,8 +410,6 @@ void FileManBaseView::refresh_list() {
|
||||
menu_view.clear();
|
||||
|
||||
for (const auto& entry : entry_list) {
|
||||
auto entry_name = std::string{entry.path.length() <= max_filename_length ? entry.path : entry.path.substr(0, max_filename_length)};
|
||||
|
||||
if (entry.is_directory) {
|
||||
std::string size_str{};
|
||||
if (entry.path == str_next || entry.path == str_back) {
|
||||
@@ -414,8 +418,10 @@ void FileManBaseView::refresh_list() {
|
||||
size_str = (entry.path == parent_dir_path.string()) ? "" : to_string_dec_uint(file_count(current_path / entry.path));
|
||||
}
|
||||
|
||||
// CRITICAL: Use "\t" (Tab) to separate the path and the size!
|
||||
// Do not use spaces or padding here. The menu will handle the alignment.
|
||||
menu_view.add_item(
|
||||
{entry_name.substr(0, max_filename_length) + std::string((max_filename_length + 1) - entry_name.length(), ' ') + size_str,
|
||||
{entry.path + "\t" + size_str,
|
||||
Theme::getInstance()->fg_yellow->foreground,
|
||||
&bitmap_icon_dir,
|
||||
[this](KeyEvent key) {
|
||||
@@ -427,8 +433,9 @@ void FileManBaseView::refresh_list() {
|
||||
const auto& assoc = get_assoc(get_extension(entry.path));
|
||||
auto size_str = to_string_file_size(entry.size);
|
||||
|
||||
// CRITICAL: Use "\t" (Tab) to separate the path and the size!
|
||||
menu_view.add_item(
|
||||
{entry_name.substr(0, max_filename_length) + std::string((max_filename_length + 1) - entry_name.length(), ' ') + size_str,
|
||||
{entry.path + "\t" + size_str,
|
||||
assoc.color,
|
||||
assoc.icon,
|
||||
[this](KeyEvent key) {
|
||||
|
||||
@@ -80,6 +80,7 @@ class FileManBaseView : public View {
|
||||
{u".PNG", &bitmap_icon_file_image, ui::Color::green()},
|
||||
{u".BMP", &bitmap_icon_file_image, ui::Color::green()},
|
||||
{u".C8", &bitmap_icon_file_iq, ui::Color::dark_cyan()},
|
||||
{u".CU8", &bitmap_icon_file_iq, ui::Color::dark_cyan()},
|
||||
{u".C16", &bitmap_icon_file_iq, ui::Color::dark_cyan()},
|
||||
{u".WAV", &bitmap_icon_file_wav, ui::Color::dark_magenta()},
|
||||
{u".PPL", &bitmap_icon_file_iq, ui::Color::white()}, // Playlist/Replay
|
||||
|
||||
@@ -32,7 +32,7 @@ static const char* hackrf_magic = "HACKRFFW";
|
||||
#define FIRST_CHECKSUM_NIGHTLY 240125
|
||||
|
||||
Thread* FlashUtilityView::thread{nullptr};
|
||||
static constexpr size_t max_filename_length = 26;
|
||||
static constexpr size_t max_filename_length = 60; // max length of filename
|
||||
|
||||
bool valid_firmware_file(std::filesystem::path::string_type path) {
|
||||
File firmware_file;
|
||||
@@ -134,12 +134,6 @@ bool FlashUtilityView::endsWith(const std::u16string& str, const std::u16string&
|
||||
}
|
||||
}
|
||||
|
||||
void FlashUtilityView::wait_till_loaded() {
|
||||
while (!isLoaded) {
|
||||
chThdSleepMilliseconds(50);
|
||||
}
|
||||
}
|
||||
|
||||
std::filesystem::path FlashUtilityView::extract_tar(std::filesystem::path::string_type path, ui::Painter& painter) {
|
||||
//
|
||||
painter.fill_rectangle(
|
||||
@@ -157,6 +151,7 @@ std::filesystem::path FlashUtilityView::extract_tar(std::filesystem::path::strin
|
||||
|
||||
bool FlashUtilityView::flash_firmware(std::filesystem::path::string_type path) {
|
||||
ui::Painter painter;
|
||||
menu_view.hidden(true);
|
||||
if (endsWith(path, u".tar")) {
|
||||
// extract, then update
|
||||
path = extract_tar(u'/' + path, painter).native();
|
||||
@@ -166,13 +161,14 @@ bool FlashUtilityView::flash_firmware(std::filesystem::path::string_type path) {
|
||||
painter.fill_rectangle({0, 50, portapack::display.width(), 90}, Theme::getInstance()->bg_darkest->background);
|
||||
painter.draw_string({0, 60}, *Theme::getInstance()->fg_red, "BAD FIRMWARE FILE OR W/R ERR");
|
||||
chThdSleepMilliseconds(5000);
|
||||
menu_view.hidden(false);
|
||||
return false;
|
||||
}
|
||||
painter.fill_rectangle(
|
||||
{0, 0, portapack::display.width(), portapack::display.height()},
|
||||
Theme::getInstance()->bg_darkest->background);
|
||||
|
||||
painter.draw_string({12, 24}, this->nav_.style(), "This will take 15 seconds.");
|
||||
painter.draw_string({12, 24}, this->nav_.style(), "This will take 15-45 sec.");
|
||||
painter.draw_string({12, 64}, this->nav_.style(), "Please wait while LED RX");
|
||||
painter.draw_string({12, 84}, this->nav_.style(), "is on and TX is flashing.");
|
||||
painter.draw_string({12, 124}, this->nav_.style(), "Device will then restart.");
|
||||
|
||||
@@ -49,7 +49,6 @@ class FlashUtilityView : public View {
|
||||
|
||||
std::string title() const override { return "Flash Utility"; };
|
||||
bool flash_firmware(std::filesystem::path::string_type path);
|
||||
void wait_till_loaded();
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
@@ -68,14 +67,6 @@ class FlashUtilityView : public View {
|
||||
void firmware_selected(std::filesystem::path::string_type path);
|
||||
|
||||
bool endsWith(const std::u16string& str, const std::u16string& suffix);
|
||||
bool isLoaded = false;
|
||||
uint8_t refreshcnt = 0;
|
||||
MessageHandlerRegistration message_handler_frame_sync{
|
||||
Message::ID::DisplayFrameSync,
|
||||
[this](const Message* const) {
|
||||
refreshcnt++;
|
||||
if (refreshcnt > 5) isLoaded = true;
|
||||
}};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -172,6 +172,7 @@ void IQTrimView::update_range_controls(iq::TrimRange trim_range) {
|
||||
|
||||
void IQTrimView::profile_capture() {
|
||||
power_buckets_.clear();
|
||||
power_buckets_.resize(screen_width);
|
||||
iq::PowerBuckets buckets{
|
||||
.p = power_buckets_.data(),
|
||||
.size = power_buckets_.size()};
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "ui_looking_glass_app.hpp"
|
||||
#include "convert.hpp"
|
||||
#include "file_reader.hpp"
|
||||
#include "file.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "audio.hpp"
|
||||
#include "file_path.hpp"
|
||||
@@ -31,6 +32,7 @@
|
||||
using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
void GlassView::focus() {
|
||||
range_presets.focus();
|
||||
}
|
||||
@@ -44,7 +46,7 @@ GlassView::~GlassView() {
|
||||
|
||||
// Function to map the value from one range to another
|
||||
int32_t GlassView::map(int32_t value, int32_t fromLow, int32_t fromHigh, int32_t toLow, int32_t toHigh) {
|
||||
return toLow + (value - fromLow) * (toHigh - toLow) / (fromHigh - fromLow);
|
||||
return toLow + ((value - fromLow) * (toHigh - toLow) + (fromHigh - fromLow) / 2) / (fromHigh - fromLow);
|
||||
}
|
||||
|
||||
void GlassView::update_display_beep() {
|
||||
@@ -128,8 +130,9 @@ void GlassView::reset_live_view() {
|
||||
max_freq_power = -1000;
|
||||
|
||||
// Clear screen in peak mode.
|
||||
const int spectrum_height = screen_height - spectrum_y;
|
||||
if (live_frequency_view == 2)
|
||||
display.fill_rectangle({{0, 108 + 16}, {screen_width, screen_height - (108 + 16)}}, {0, 0, 0});
|
||||
display.fill_rectangle({{0, spectrum_y}, {screen_width, spectrum_height}}, {0, 0, 0});
|
||||
}
|
||||
|
||||
void GlassView::add_spectrum_pixel(uint8_t power) {
|
||||
@@ -144,11 +147,9 @@ void GlassView::add_spectrum_pixel(uint8_t power) {
|
||||
constexpr float rssi_voltage_min = 0.4;
|
||||
constexpr float rssi_voltage_max = 2.2;
|
||||
constexpr float adc_voltage_max = 3.3;
|
||||
constexpr int raw_min = rssi_sample_range * rssi_voltage_min / adc_voltage_max;
|
||||
constexpr int raw_max = rssi_sample_range * rssi_voltage_max / adc_voltage_max;
|
||||
constexpr int raw_delta = raw_max - raw_min;
|
||||
const range_t<int> y_max_range{0, screen_height - (108 + 16)};
|
||||
|
||||
constexpr int raw_min = 0.5f + rssi_sample_range * rssi_voltage_min / adc_voltage_max;
|
||||
constexpr int raw_max = 0.5f + rssi_sample_range * rssi_voltage_max / adc_voltage_max;
|
||||
const int spectrum_height = screen_height - spectrum_y;
|
||||
// drawing and keeping track of max freq
|
||||
for (uint16_t xpos = 0; xpos < screen_width; xpos++) {
|
||||
// save max powerwull freq
|
||||
@@ -156,17 +157,21 @@ void GlassView::add_spectrum_pixel(uint8_t power) {
|
||||
max_freq_power = spectrum_data[xpos];
|
||||
max_freq_hold = get_freq_from_bin_pos(xpos);
|
||||
}
|
||||
int16_t point = y_max_range.clip(((spectrum_data[xpos] - raw_min) * (screen_height - (108 + 16))) / raw_delta);
|
||||
uint8_t color_gradient = (point * 255) / 212;
|
||||
int16_t point = map(spectrum_data[xpos], 0, 255, 0, spectrum_height);
|
||||
// clear if not in peak view
|
||||
if (live_frequency_view != 2) {
|
||||
display.fill_rectangle({{xpos, 108 + 16}, {1, screen_height - point}}, {0, 0, 0});
|
||||
display.fill_rectangle({{xpos, spectrum_y}, {1, screen_height - point}}, {0, 0, 0});
|
||||
}
|
||||
display.fill_rectangle({{xpos, screen_height - point}, {1, point}}, {color_gradient, 0, uint8_t(255 - color_gradient)});
|
||||
display.fill_rectangle({{xpos, screen_height - point}, {1, point}}, gradient.lut[spectrum_data[xpos]]);
|
||||
}
|
||||
// indicate RSSI min and max power
|
||||
if (show_rssi_guides) {
|
||||
display.fill_rectangle({{0, screen_height - map(raw_min, 0, 255, 0, spectrum_height)}, {screen_width, 1}}, -gradient.lut[raw_min]);
|
||||
display.fill_rectangle({{0, screen_height - map(raw_max, 0, 255, 0, spectrum_height)}, {screen_width, 1}}, -gradient.lut[raw_max]);
|
||||
}
|
||||
if (last_max_freq != max_freq_hold) {
|
||||
last_max_freq = max_freq_hold;
|
||||
freq_stats.set("MAX HOLD: " + to_string_short_freq(max_freq_hold));
|
||||
freq_stats.set("MAX: " + to_string_short_freq(max_freq_hold));
|
||||
}
|
||||
plot_marker(marker_pixel_index);
|
||||
} else {
|
||||
@@ -323,8 +328,8 @@ void GlassView::update_min(int32_t v) {
|
||||
min_size = search_span;
|
||||
if (min_size < 1)
|
||||
min_size = 1;
|
||||
if (v > 7200 - min_size) {
|
||||
v = 7200 - min_size;
|
||||
if (v > LOOKING_GLASS_MAX_FREQ_MHZ - min_size) {
|
||||
v = LOOKING_GLASS_MAX_FREQ_MHZ - min_size;
|
||||
}
|
||||
if (v > (field_frequency_max.value() - min_size))
|
||||
field_frequency_max.set_value(v + min_size, false);
|
||||
@@ -343,6 +348,9 @@ void GlassView::update_max(int32_t v) {
|
||||
if (v < min_size) {
|
||||
v = min_size;
|
||||
}
|
||||
if (v > LOOKING_GLASS_MAX_FREQ_MHZ) {
|
||||
v = LOOKING_GLASS_MAX_FREQ_MHZ;
|
||||
}
|
||||
if (v < (field_frequency_min.value() + min_size))
|
||||
field_frequency_min.set_value(v - min_size, false);
|
||||
if (locked_range)
|
||||
@@ -392,7 +400,8 @@ GlassView::GlassView(
|
||||
&button_marker_plus,
|
||||
&button_jump,
|
||||
&button_rst,
|
||||
&freq_stats});
|
||||
&button_rssi,
|
||||
&freq_stats, &button_play});
|
||||
|
||||
load_presets(); // Load available presets from TXT files (or default).
|
||||
preset_index = clip<uint8_t>(preset_index, 0, presets_db.size());
|
||||
@@ -446,6 +455,7 @@ GlassView::GlassView(
|
||||
freq_stats.hidden(true);
|
||||
button_jump.hidden(true);
|
||||
button_rst.hidden(true);
|
||||
button_rssi.hidden(true);
|
||||
display.scroll_set_area(109, screen_height - 1); // Restart scroll on the correct coordinates.
|
||||
break;
|
||||
|
||||
@@ -456,6 +466,7 @@ GlassView::GlassView(
|
||||
freq_stats.hidden(false);
|
||||
button_jump.hidden(false);
|
||||
button_rst.hidden(false);
|
||||
button_rssi.hidden(false);
|
||||
break;
|
||||
|
||||
case 2: // PEAK
|
||||
@@ -466,6 +477,7 @@ GlassView::GlassView(
|
||||
freq_stats.hidden(false);
|
||||
button_jump.hidden(false);
|
||||
button_rst.hidden(false);
|
||||
button_rssi.hidden(false);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -535,6 +547,31 @@ GlassView::GlassView(
|
||||
reset_live_view();
|
||||
};
|
||||
|
||||
button_rssi.on_select = [this](Button& button) {
|
||||
show_rssi_guides = !show_rssi_guides;
|
||||
if (show_rssi_guides) {
|
||||
button.set_style(Theme::getInstance()->fg_green);
|
||||
} else {
|
||||
button.set_style(Theme::getInstance()->bg_darkest);
|
||||
}
|
||||
reset_live_view();
|
||||
};
|
||||
|
||||
button_play.on_select = [this](ImageButton&) {
|
||||
paused = !paused;
|
||||
if (paused) {
|
||||
button_play.set_foreground(Theme::getInstance()->fg_red->foreground);
|
||||
button_play.set_background(Theme::getInstance()->fg_red->background);
|
||||
baseband::spectrum_streaming_stop();
|
||||
button_play.set_bitmap(&bitmap_play);
|
||||
} else {
|
||||
button_play.set_foreground(Theme::getInstance()->fg_green->foreground);
|
||||
button_play.set_background(Theme::getInstance()->fg_green->background);
|
||||
baseband::spectrum_streaming_start();
|
||||
button_play.set_bitmap(&bitmap_stop);
|
||||
}
|
||||
};
|
||||
|
||||
display.scroll_set_area(109, screen_height - 1); // Restart scroll on the correct coordinates
|
||||
|
||||
// trigger:
|
||||
@@ -585,34 +622,39 @@ void GlassView::on_freqchg(int64_t freq) {
|
||||
}
|
||||
|
||||
void GlassView::load_presets() {
|
||||
File presets_file;
|
||||
auto error = presets_file.open(looking_glass_dir / u"PRESETS.TXT");
|
||||
presets_db.clear();
|
||||
|
||||
// Add the "Manual" entry.
|
||||
presets_db.push_back({0, 0, "Manual"});
|
||||
|
||||
if (!error) {
|
||||
auto reader = FileLineReader(presets_file);
|
||||
for (const auto& line : reader) {
|
||||
if (line.length() == 0 || line[0] == '#')
|
||||
continue;
|
||||
scan_root_files(looking_glass_dir, u"*.TXT", [this](const std::filesystem::path& path) {
|
||||
if (path.empty() || path.native()[0] == u'.')
|
||||
return;
|
||||
|
||||
auto cols = split_string(line, ',');
|
||||
if (cols.size() != 3)
|
||||
continue;
|
||||
File presets_file;
|
||||
auto error = presets_file.open(looking_glass_dir / path);
|
||||
if (!error) {
|
||||
auto reader = FileLineReader(presets_file);
|
||||
for (const auto& line : reader) {
|
||||
if (line.length() == 0 || line[0] == '#')
|
||||
continue;
|
||||
|
||||
preset_entry entry{};
|
||||
parse_int(cols[0], entry.min);
|
||||
parse_int(cols[1], entry.max);
|
||||
entry.label = trimr(cols[2]);
|
||||
auto cols = split_string(line, ',');
|
||||
if (cols.size() != 3)
|
||||
continue;
|
||||
|
||||
if (entry.min == 0 || entry.max == 0 || entry.min >= entry.max)
|
||||
continue; // Invalid line.
|
||||
preset_entry entry{};
|
||||
parse_int(cols[0], entry.min);
|
||||
parse_int(cols[1], entry.max);
|
||||
entry.label = trimr(cols[2]);
|
||||
|
||||
presets_db.emplace_back(std::move(entry));
|
||||
if (entry.max == 0 || entry.min >= entry.max)
|
||||
continue; // Invalid line.
|
||||
|
||||
presets_db.emplace_back(std::move(entry));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
populate_presets();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace ui {
|
||||
#define LOOKING_GLASS_SLICE_WIDTH_MAX 20000000
|
||||
#define LOOKING_GLASS_MAX_SAMPLERATE 20000000
|
||||
#define MHZ_DIV 1000000
|
||||
#define LOOKING_GLASS_MAX_FREQ_MHZ 7250 // HackRF upper tuning limit (band_high top), in MHz
|
||||
|
||||
// blanked DC (16 centered bins ignored ) and top left and right (2 bins ignored on each side )
|
||||
#define LOOKING_GLASS_FASTSCAN 0
|
||||
@@ -104,6 +105,7 @@ class GlassView : public View {
|
||||
};
|
||||
|
||||
void on_freqchg(int64_t freq);
|
||||
// Function to map the value from one range to another
|
||||
int32_t map(int32_t value, int32_t fromLow, int32_t fromHigh, int32_t toLow, int32_t toHigh);
|
||||
std::vector<preset_entry> presets_db{};
|
||||
void manage_beep_audio();
|
||||
@@ -128,6 +130,8 @@ class GlassView : public View {
|
||||
void populate_presets();
|
||||
void launch_audio(rf::Frequency center_freq);
|
||||
|
||||
bool paused{false};
|
||||
|
||||
rf::Frequency search_span{0};
|
||||
rf::Frequency f_center{0};
|
||||
rf::Frequency f_center_ini{0};
|
||||
@@ -163,40 +167,44 @@ class GlassView : public View {
|
||||
uint8_t bin_length = screen_width;
|
||||
uint8_t offset = 0;
|
||||
uint8_t ignore_dc = 0;
|
||||
bool show_rssi_guides = false;
|
||||
|
||||
// start of spectrum area
|
||||
static constexpr int spectrum_y = (108 + 16);
|
||||
|
||||
Labels labels{
|
||||
{{0, UI_POS_Y(0)}, "MIN: MAX: LNA VGA ", Theme::getInstance()->fg_light->foreground},
|
||||
{{0, 1 * 16}, "RANGE: FILTER: AMP:", Theme::getInstance()->fg_light->foreground},
|
||||
{{0, 2 * 16}, "P:", Theme::getInstance()->fg_light->foreground},
|
||||
{{0, 3 * 16}, "MARKER( / ): MHz", Theme::getInstance()->fg_light->foreground},
|
||||
{{0, 4 * 16}, "RES: VOL:", Theme::getInstance()->fg_light->foreground}};
|
||||
{{0, UI_POS_Y(1)}, "RANGE: FILTER: AMP:", Theme::getInstance()->fg_light->foreground},
|
||||
{{0, UI_POS_Y(2)}, "P:", Theme::getInstance()->fg_light->foreground},
|
||||
{{0, UI_POS_Y(3)}, "MARKER( / ): MHz", Theme::getInstance()->fg_light->foreground},
|
||||
{{0, UI_POS_Y(4)}, "RES: VOL:", Theme::getInstance()->fg_light->foreground}};
|
||||
|
||||
NumberField field_frequency_min{
|
||||
{4 * 8, UI_POS_Y(0)},
|
||||
{UI_POS_X(4), UI_POS_Y(0)},
|
||||
4,
|
||||
{0, 7199},
|
||||
{0, LOOKING_GLASS_MAX_FREQ_MHZ - 1},
|
||||
1, // number of steps by encoder delta
|
||||
' '};
|
||||
|
||||
NumberField field_frequency_max{
|
||||
{13 * 8, UI_POS_Y(0)},
|
||||
{UI_POS_X(13), UI_POS_Y(0)},
|
||||
4,
|
||||
{1, 7200},
|
||||
{1, LOOKING_GLASS_MAX_FREQ_MHZ},
|
||||
1, // number of steps by encoder delta
|
||||
' '};
|
||||
|
||||
LNAGainField field_lna{
|
||||
{21 * 8, UI_POS_Y(0)}};
|
||||
{UI_POS_X(21), UI_POS_Y(0)}};
|
||||
|
||||
VGAGainField field_vga{
|
||||
{27 * 8, UI_POS_Y(0)}};
|
||||
{UI_POS_X(27), UI_POS_Y(0)}};
|
||||
|
||||
TextField field_range{
|
||||
{6 * 8, 1 * 16, 6 * 8, 16},
|
||||
{UI_POS_X(6), UI_POS_Y(1), UI_POS_WIDTH(6), UI_POS_HEIGHT(1)},
|
||||
""};
|
||||
|
||||
OptionsField filter_config{
|
||||
{20 * 8, 1 * 16},
|
||||
{UI_POS_X(20), UI_POS_Y(1)},
|
||||
4,
|
||||
{
|
||||
{"OFF ", 0},
|
||||
@@ -205,41 +213,47 @@ class GlassView : public View {
|
||||
}};
|
||||
|
||||
RFAmpField field_rf_amp{
|
||||
{28 * 8, 1 * 16}};
|
||||
{UI_POS_X(28), UI_POS_Y(1)}};
|
||||
|
||||
OptionsField range_presets{
|
||||
{2 * 8, 2 * 16},
|
||||
{UI_POS_X(2), UI_POS_Y(2)},
|
||||
20,
|
||||
{}};
|
||||
|
||||
ButtonWithEncoder button_beep_squelch{
|
||||
{screen_width - 8 * 8, 2 * 16 + 4, 8 * 8, 1 * 8},
|
||||
{UI_POS_X_RIGHT(8), UI_POS_Y(2.25), UI_POS_WIDTH(8), UI_POS_HEIGHT(0.5)},
|
||||
""};
|
||||
|
||||
ImageButton button_play{
|
||||
{UI_POS_X_RIGHT(2), UI_POS_Y(3.25) - 2, UI_POS_WIDTH(2), UI_POS_HEIGHT(0.5)},
|
||||
&bitmap_stop,
|
||||
Theme::getInstance()->fg_green->foreground,
|
||||
Theme::getInstance()->fg_green->background};
|
||||
|
||||
TextField field_marker{
|
||||
{12 * 8, 3 * 16, 9 * 8, 16},
|
||||
{UI_POS_X(12), UI_POS_Y(3), UI_POS_WIDTH(9), UI_POS_HEIGHT(1)},
|
||||
""};
|
||||
|
||||
Button button_marker_minus{
|
||||
{7 * 8, 3 * 16 + 4, 1 * 8, 1 * 8},
|
||||
{UI_POS_X(7), UI_POS_Y(3.25), UI_POS_WIDTH(1), UI_POS_HEIGHT(0.5)},
|
||||
"-"};
|
||||
|
||||
Button button_marker_plus{
|
||||
{9 * 8, 3 * 16 + 4, 1 * 8, 1 * 8},
|
||||
{UI_POS_X(9), UI_POS_Y(3.25), UI_POS_WIDTH(1), UI_POS_HEIGHT(0.5)},
|
||||
"+"};
|
||||
|
||||
NumberField field_trigger{
|
||||
{4 * 8, 4 * 16},
|
||||
{UI_POS_X(4), UI_POS_Y(4)},
|
||||
3,
|
||||
{2, 128},
|
||||
2,
|
||||
' '};
|
||||
|
||||
AudioVolumeField field_volume{
|
||||
{13 * 8, 4 * 16}};
|
||||
{UI_POS_X(13), UI_POS_Y(4)}};
|
||||
|
||||
/*OptionsField steps_config{
|
||||
{13 * 8, 4 * 16},
|
||||
{UI_POS_X(13), UI_POS_Y(4)},
|
||||
3,
|
||||
{
|
||||
{"1", 1},
|
||||
@@ -251,7 +265,7 @@ class GlassView : public View {
|
||||
}};*/
|
||||
|
||||
OptionsField scan_type{
|
||||
{17 * 8, 4 * 16},
|
||||
{UI_POS_X(17), UI_POS_Y(4)},
|
||||
2,
|
||||
{
|
||||
{"F-", LOOKING_GLASS_FASTSCAN},
|
||||
@@ -259,7 +273,7 @@ class GlassView : public View {
|
||||
}};
|
||||
|
||||
OptionsField view_config{
|
||||
{19 * 8, 4 * 16},
|
||||
{UI_POS_X(19), UI_POS_Y(4)},
|
||||
7,
|
||||
{
|
||||
{"SPCTR-V", 0},
|
||||
@@ -268,7 +282,7 @@ class GlassView : public View {
|
||||
}};
|
||||
|
||||
OptionsField level_integration{
|
||||
{27 * 8, 4 * 16},
|
||||
{UI_POS_X(27), UI_POS_Y(4)},
|
||||
2,
|
||||
{
|
||||
{"x0", 0},
|
||||
@@ -284,15 +298,19 @@ class GlassView : public View {
|
||||
}};
|
||||
|
||||
Button button_jump{
|
||||
{screen_width - 4 * 8, 5 * 16, 4 * 8, 16},
|
||||
{UI_POS_X_RIGHT(4), UI_POS_Y(5), UI_POS_WIDTH(4), UI_POS_HEIGHT(1)},
|
||||
"JMP"};
|
||||
|
||||
Button button_rst{
|
||||
{screen_width - 9 * 8, 5 * 16, 4 * 8, 16},
|
||||
{UI_POS_X_RIGHT(9), UI_POS_Y(5), UI_POS_WIDTH(4), UI_POS_HEIGHT(1)},
|
||||
"RST"};
|
||||
|
||||
Button button_rssi{
|
||||
{UI_POS_X_RIGHT(15), UI_POS_Y(5), UI_POS_WIDTH(5), UI_POS_HEIGHT(1)},
|
||||
"RSSI"};
|
||||
|
||||
Text freq_stats{
|
||||
{UI_POS_X(0), 5 * 16, screen_width - 10 * 8, 8},
|
||||
{UI_POS_X(0), UI_POS_Y(5), UI_POS_WIDTH(14), UI_POS_HEIGHT(1)},
|
||||
""};
|
||||
|
||||
MessageHandlerRegistration message_handler_spectrum_config{
|
||||
|
||||
@@ -1261,6 +1261,7 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
|
||||
else
|
||||
v = SPEC_MODULATION;
|
||||
field_mode.set_selected_index(v);
|
||||
return; // Important ! Guru will occur if you don't return when modifying field from within on_change !
|
||||
}
|
||||
last_mode = v;
|
||||
change_mode(v);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2024 Mark Thompson
|
||||
* Copyright (C) 2024 u-foka
|
||||
* Copyright (C) 2024 HTotoo
|
||||
* copyleft 2024 zxkmm AKA zix aka sommermorgentraum
|
||||
* copyleft 2024 zxkmm
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "ui_external_items_menu_loader.hpp"
|
||||
#include "ui_ss_viewer.hpp"
|
||||
#include "ui_fileman.hpp"
|
||||
#include "ui_sd_card_debug.hpp"
|
||||
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
#include "lpc43xx_cpp.hpp"
|
||||
@@ -446,7 +447,11 @@ void SetUIView::focus() {
|
||||
/* SetSDCardView *********************************************/
|
||||
|
||||
SetSDCardView::SetSDCardView(NavigationView& nav) {
|
||||
add_children({&labels,
|
||||
add_children({&status_labels,
|
||||
&text_card_status,
|
||||
&text_filesystem_type,
|
||||
&button_more_info,
|
||||
&labels,
|
||||
&checkbox_sdcard_speed,
|
||||
&button_test_sdcard_high_speed,
|
||||
&text_sdcard_test_status,
|
||||
@@ -455,6 +460,10 @@ SetSDCardView::SetSDCardView(NavigationView& nav) {
|
||||
|
||||
checkbox_sdcard_speed.set_value(pmem::config_sdcard_high_speed_io());
|
||||
|
||||
button_more_info.on_select = [&nav, this](Button&) {
|
||||
nav.push<SDCardDebugView>();
|
||||
};
|
||||
|
||||
button_test_sdcard_high_speed.on_select = [&nav, this](Button&) {
|
||||
pmem::set_config_sdcard_high_speed_io(true, false);
|
||||
text_sdcard_test_status.set("!! HIGH SPEED MODE ON !!");
|
||||
@@ -472,7 +481,79 @@ SetSDCardView::SetSDCardView(NavigationView& nav) {
|
||||
}
|
||||
|
||||
void SetSDCardView::focus() {
|
||||
button_save.focus();
|
||||
button_cancel.focus();
|
||||
}
|
||||
|
||||
void SetSDCardView::on_show() {
|
||||
sd_card_status_signal_token = sd_card::status_signal += [this](const sd_card::Status) {
|
||||
update_sd_card_status();
|
||||
};
|
||||
|
||||
update_sd_card_status();
|
||||
}
|
||||
|
||||
void SetSDCardView::on_hide() {
|
||||
sd_card::status_signal -= sd_card_status_signal_token;
|
||||
}
|
||||
|
||||
void SetSDCardView::update_sd_card_status() {
|
||||
using sd_card::Status;
|
||||
|
||||
const auto status = sd_card::status();
|
||||
|
||||
// Update card status text
|
||||
switch (status) {
|
||||
case Status::NotPresent:
|
||||
text_card_status.set("Not Inserted");
|
||||
text_filesystem_type.set("---");
|
||||
break;
|
||||
case Status::Present:
|
||||
text_card_status.set("Inserted");
|
||||
text_filesystem_type.set("---");
|
||||
break;
|
||||
case Status::Mounted:
|
||||
text_card_status.set("Mounted");
|
||||
// Determine filesystem type
|
||||
{
|
||||
const auto fs_type = sd_card::fs.fs_type;
|
||||
std::string fs_name;
|
||||
switch (fs_type) {
|
||||
case FS_FAT12:
|
||||
fs_name = "FAT12";
|
||||
break;
|
||||
case FS_FAT16:
|
||||
fs_name = "FAT16";
|
||||
break;
|
||||
case FS_FAT32:
|
||||
fs_name = "FAT32";
|
||||
break;
|
||||
case FS_EXFAT:
|
||||
fs_name = "exFAT";
|
||||
break;
|
||||
default:
|
||||
fs_name = "Unknown";
|
||||
break;
|
||||
}
|
||||
text_filesystem_type.set(fs_name);
|
||||
}
|
||||
break;
|
||||
case Status::ConnectError:
|
||||
text_card_status.set("Connect Error");
|
||||
text_filesystem_type.set("---");
|
||||
break;
|
||||
case Status::MountError:
|
||||
text_card_status.set("Mount Error");
|
||||
text_filesystem_type.set("---");
|
||||
break;
|
||||
case Status::IOError:
|
||||
text_card_status.set("I/O Error");
|
||||
text_filesystem_type.set("---");
|
||||
break;
|
||||
default:
|
||||
text_card_status.set("Unknown");
|
||||
text_filesystem_type.set("---");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* SetConverterSettingsView ******************************/
|
||||
@@ -1079,7 +1160,10 @@ SetBatteryView::SetBatteryView(NavigationView& nav) {
|
||||
add_children({&labels,
|
||||
&button_save,
|
||||
&button_cancel,
|
||||
&field_battcap,
|
||||
&button_help_cap,
|
||||
&checkbox_overridebatt,
|
||||
&checkbox_battery_replaceable,
|
||||
&checkbox_battery_charge_hint});
|
||||
|
||||
if (i2cdev::I2CDevManager::get_dev_by_model(I2C_DEVMDL::I2CDEVMDL_MAX17055)) add_children({&button_reset, &labels2});
|
||||
@@ -1087,21 +1171,51 @@ SetBatteryView::SetBatteryView(NavigationView& nav) {
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
pmem::set_ui_override_batt_calc(checkbox_overridebatt.value());
|
||||
pmem::set_ui_battery_charge_hint(checkbox_battery_charge_hint.value());
|
||||
pmem::set_battery_replaceable(checkbox_battery_replaceable.value());
|
||||
battery::BatteryManagement::set_calc_override(checkbox_overridebatt.value());
|
||||
i2cdev::I2cDev_MAX17055* dev = (i2cdev::I2cDev_MAX17055*)i2cdev::I2CDevManager::get_dev_by_model(I2C_DEVMDL::I2CDEVMDL_MAX17055);
|
||||
if (dev) dev->resetChangedFlag();
|
||||
if ((((uint32_t)field_battcap.value() != pmem::battery_cap_mah()) || (!pmem::battery_cap_valid())) || (dev && dev->getIsBattChanged())) {
|
||||
pmem::set_battery_cap_mah(field_battcap.value());
|
||||
if (dev && !dev->reInit()) {
|
||||
nav.display_modal("Error", "Battery gauge re-init failed");
|
||||
return;
|
||||
}
|
||||
if (dev) {
|
||||
dev->resetChangedFlag();
|
||||
dev->update(); // resend the new data
|
||||
}
|
||||
}
|
||||
send_system_refresh();
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
button_reset.on_select = [&nav, this](Button&) {
|
||||
auto dev = (i2cdev::I2cDev_MAX17055*)i2cdev::I2CDevManager::get_dev_by_model(I2C_DEVMDL::I2CDEVMDL_MAX17055);
|
||||
if (dev->reset_learned())
|
||||
if (dev && dev->reset_learned())
|
||||
nav.display_modal("Reset", "Battery parameters reset");
|
||||
else
|
||||
nav.display_modal("Error", "Error parameter reset");
|
||||
};
|
||||
|
||||
button_help_cap.on_select = [&nav, this](Button&) {
|
||||
nav.display_modal("Battery Capacity",
|
||||
"Only change default, if you\n"
|
||||
" changed the battery!\n"
|
||||
"Defaults:\n"
|
||||
"H4 + Hackrf One: 2500\n"
|
||||
"H4 + Hackrf Pro: 2000\n"
|
||||
"H4Pro + Hackrf Pro: custom\n"
|
||||
"PortaRf: 3000\n"
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
checkbox_overridebatt.set_value(pmem::ui_override_batt_calc());
|
||||
checkbox_battery_charge_hint.set_value(pmem::ui_battery_charge_hint());
|
||||
checkbox_battery_replaceable.set_value(pmem::battery_replaceable());
|
||||
|
||||
field_battcap.set_value(pmem::battery_cap_mah());
|
||||
|
||||
button_cancel.on_select = [&nav, this](Button&) {
|
||||
nav.pop();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2023 Kyle Reed
|
||||
* Copyright (C) 2024 Mark Thompson
|
||||
* Copyright (C) 2024 u-foka
|
||||
* copyleft 2024 zxkmm AKA zix aka sommermorgentraum
|
||||
* copyleft 2024 zxkmm
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "ui_navigation.hpp"
|
||||
#include "bitmap.hpp"
|
||||
#include "ff.h"
|
||||
#include "sd_card.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
#include "irq_controls.hpp"
|
||||
|
||||
@@ -424,36 +425,60 @@ class SetSDCardView : public View {
|
||||
public:
|
||||
SetSDCardView(NavigationView& nav);
|
||||
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "SD Card"; };
|
||||
|
||||
private:
|
||||
SignalToken sd_card_status_signal_token{};
|
||||
// Status section (top half)
|
||||
Labels status_labels{
|
||||
{{10, 24}, "Card Status:", Theme::getInstance()->fg_light->foreground},
|
||||
{{10, 48}, "Filesystem:", Theme::getInstance()->fg_light->foreground}};
|
||||
|
||||
Text text_card_status{
|
||||
{120, 24, 110, 16},
|
||||
""};
|
||||
|
||||
Text text_filesystem_type{
|
||||
{120, 48, 110, 16},
|
||||
""};
|
||||
|
||||
Button button_more_info{
|
||||
{UI_POS_X_CENTER(20), 90, UI_POS_WIDTH(20), UI_POS_HEIGHT(2)},
|
||||
"More Info"};
|
||||
|
||||
// Settings section (bottom half)
|
||||
Labels labels{
|
||||
// 01234567890123456789012345678
|
||||
{{UI_POS_X_CENTER(26), 120 - 48}, " HIGH SPEED SDCARD IO ", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X_CENTER(26), 120 - 32}, " May or may not work !! ", Theme::getInstance()->fg_light->foreground}};
|
||||
{{UI_POS_X_CENTER(26), 140}, " HIGH SPEED SDCARD IO ", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X_CENTER(26), 156}, " May or may not work !! ", Theme::getInstance()->fg_light->foreground}};
|
||||
|
||||
Checkbox checkbox_sdcard_speed{
|
||||
{UI_POS_X_CENTER(26), 120},
|
||||
{UI_POS_X_CENTER(26), 180},
|
||||
20,
|
||||
"enable high speed IO"};
|
||||
|
||||
Button button_test_sdcard_high_speed{
|
||||
{UI_POS_X_CENTER(27), 152, UI_POS_WIDTH(27), UI_POS_HEIGHT(2)},
|
||||
{UI_POS_X_CENTER(27), 210, UI_POS_WIDTH(27), UI_POS_HEIGHT(2)},
|
||||
"TEST BUTTON (NO PMEM SAVE)"};
|
||||
|
||||
Text text_sdcard_test_status{
|
||||
{UI_POS_X_CENTER(28), 198, UI_POS_WIDTH(28), UI_POS_HEIGHT(1)},
|
||||
{UI_POS_X_CENTER(28), 256, UI_POS_WIDTH(28), UI_POS_HEIGHT(1)},
|
||||
""};
|
||||
|
||||
Button button_save{
|
||||
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||
"Save"};
|
||||
|
||||
Button button_cancel{
|
||||
{UI_POS_X_CENTER(16) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||
"Cancel"};
|
||||
|
||||
void update_sd_card_status();
|
||||
};
|
||||
|
||||
class SetConverterSettingsView : public View {
|
||||
@@ -1020,35 +1045,55 @@ class SetBatteryView : public View {
|
||||
private:
|
||||
int32_t selected = 0;
|
||||
Labels labels{
|
||||
{{1 * 8, 1 * 16}, "Override batt calculation", Theme::getInstance()->fg_light->foreground},
|
||||
{{1 * 8, 2 * 16}, "method to voltage based", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X_CENTER(26), UI_POS_Y(0)}, "Override batt calculation", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X_CENTER(24), UI_POS_Y(1)}, "method to voltage based", Theme::getInstance()->fg_light->foreground},
|
||||
/**/
|
||||
{{1 * 8, 6 * 16}, "Display a hint to remind you", Theme::getInstance()->fg_light->foreground},
|
||||
{{1 * 8, 7 * 16}, "when you charge", Theme::getInstance()->fg_light->foreground}};
|
||||
{{UI_POS_X_CENTER(29), UI_POS_Y(4)}, "Display a hint to remind you", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X_CENTER(16), UI_POS_Y(5)}, "when you charge", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X_CENTER(17), UI_POS_Y(8)}, "Battery capacity", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(7), UI_POS_Y(9)}, "mAh", Theme::getInstance()->fg_light->foreground}};
|
||||
|
||||
Labels labels2{{{1 * 8, 11 * 16}, "Reset IC's learned params.", Theme::getInstance()->fg_light->foreground}};
|
||||
Labels labels2{{{UI_POS_X(1), UI_POS_Y_BOTTOM(7)}, "Reset IC's learned params.", Theme::getInstance()->fg_light->foreground}};
|
||||
|
||||
NumberField field_battcap{
|
||||
{UI_POS_X(1), UI_POS_Y(9)},
|
||||
5,
|
||||
{BATT_18650_MIN_MAH, BATT_18650_MAX_MAH},
|
||||
100,
|
||||
' ',
|
||||
};
|
||||
|
||||
Button button_help_cap{
|
||||
{UI_POS_X(12), UI_POS_Y(9), UI_POS_WIDTH(5), UI_POS_HEIGHT(1)},
|
||||
"Help",
|
||||
};
|
||||
|
||||
Checkbox checkbox_overridebatt{
|
||||
{2 * 8, 4 * 16},
|
||||
{UI_POS_X(2), UI_POS_Y(2)},
|
||||
23,
|
||||
"Override"};
|
||||
|
||||
Checkbox checkbox_battery_charge_hint{
|
||||
{2 * 8, 9 * 16},
|
||||
{UI_POS_X(2), UI_POS_Y(6)},
|
||||
23,
|
||||
"Charge hint"};
|
||||
|
||||
Checkbox checkbox_battery_replaceable{
|
||||
{UI_POS_X(2), UI_POS_Y(11)},
|
||||
23,
|
||||
"Replaceable battery"};
|
||||
|
||||
Button button_cancel{
|
||||
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||
"Cancel",
|
||||
};
|
||||
|
||||
Button button_save{
|
||||
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||
"Save"};
|
||||
|
||||
Button button_reset{
|
||||
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y(13), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(6), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||
"Reset",
|
||||
};
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
namespace ui {
|
||||
|
||||
void create_thread(int32_t (*fn)(void*), void* arg, size_t stack_size, int priority) {
|
||||
// TODO: collect memory on terminate, once this is used
|
||||
// TODO: collect memory on terminate, once this is used. This is a HUGE TODO! need to call chThdWait on all of them!
|
||||
chThdCreateFromHeap(NULL, stack_size, priority, fn, arg);
|
||||
}
|
||||
|
||||
@@ -186,26 +186,26 @@ void set_dirty() {
|
||||
}
|
||||
|
||||
standalone_application_api_t api = {
|
||||
/* .malloc = */ &alloc,
|
||||
/* .calloc = */ &calloc,
|
||||
/* .realloc = */ &realloc,
|
||||
/* .free = */ &chHeapFree,
|
||||
/* .create_thread = */ &create_thread,
|
||||
/* .fill_rectangle = */ &fill_rectangle,
|
||||
/* .swizzled_switches = */ &swizzled_switches,
|
||||
/* .get_switches_state = */ &get_switches_state_ulong,
|
||||
/* .fixed_5x8_glyph_data = */ ui::font::fixed_5x8.get_data(),
|
||||
/* .fixed_8x16_glyph_data = */ ui::font::fixed_8x16.get_data(),
|
||||
/* .fill_rectangle_unrolled8 = */ &fill_rectangle_unrolled8,
|
||||
/* .draw_bitmap = */ &draw_bitmap,
|
||||
/* .scroll_area_y = */ &scroll_area_y,
|
||||
/* .scroll_set_area = */ &scroll_set_area,
|
||||
/* .scroll_disable = */ &scroll_disable,
|
||||
/* .scroll_set_position = */ &scroll_set_position,
|
||||
/* .scroll = */ &scroll,
|
||||
/* .i2c_read = */ &i2c_read,
|
||||
/* .panic = */ &chDbgPanic,
|
||||
/* .set_dirty = */ &set_dirty,
|
||||
.malloc = &alloc,
|
||||
.calloc = &calloc,
|
||||
.realloc = &realloc,
|
||||
.free = &chHeapFree,
|
||||
.create_thread = &create_thread,
|
||||
.fill_rectangle = &fill_rectangle,
|
||||
.swizzled_switches = &swizzled_switches,
|
||||
.get_switches_state = &get_switches_state_ulong,
|
||||
.fixed_5x8_glyph_data = ui::font::fixed_5x8.get_data(),
|
||||
.fixed_8x16_glyph_data = ui::font::fixed_8x16.get_data(),
|
||||
.fill_rectangle_unrolled8 = &fill_rectangle_unrolled8,
|
||||
.draw_bitmap = &draw_bitmap,
|
||||
.scroll_area_y = &scroll_area_y,
|
||||
.scroll_set_area = &scroll_set_area,
|
||||
.scroll_disable = &scroll_disable,
|
||||
.scroll_set_position = &scroll_set_position,
|
||||
.scroll = &scroll,
|
||||
.i2c_read = &i2c_read,
|
||||
.panic = &chDbgPanic,
|
||||
.set_dirty = &set_dirty,
|
||||
// Version 3
|
||||
.f_open = &ext_f_open,
|
||||
.f_close = &ext_f_close,
|
||||
|
||||
@@ -74,7 +74,7 @@ void SubGhzDRecentEntryDetailView::update_data() {
|
||||
console.writeln("Action: 0x" + to_string_hex(func_code));
|
||||
}
|
||||
|
||||
if (entry_.sensorType == FPS_KEELOQ) {
|
||||
if (entry_.sensorType == FPS_KEELOQ || entry_.sensorType == FPS_SUPERROLLO) {
|
||||
console.writeln("Fix: " + to_string_hex(fix));
|
||||
console.writeln("Encrypted: " + to_string_hex(encrypted));
|
||||
console.writeln("Manufacturer: " + mf_name);
|
||||
@@ -243,6 +243,8 @@ const char* SubGhzDView::getSensorTypeName(FPROTO_SUBGHZD_SENSOR type) {
|
||||
return "Ido 11x";
|
||||
case FPS_INTERTECHNOV3:
|
||||
return "InterTehcno v3";
|
||||
case FPS_SUPERROLLO:
|
||||
return "Superrollo";
|
||||
case FPS_KEELOQ:
|
||||
return "KeeLoq";
|
||||
case FPS_KINGGATESSTYLO4K:
|
||||
@@ -671,7 +673,7 @@ void SubGhzDRecentEntryDetailView::parseProtocol() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry_.sensorType == FPS_KEELOQ) {
|
||||
if (entry_.sensorType == FPS_KEELOQ || entry_.sensorType == FPS_SUPERROLLO) {
|
||||
uint64_t data_rev = FProtoGeneral::subghz_protocol_blocks_reverse_key(entry_.data, 64);
|
||||
|
||||
btn = data_rev >> 60;
|
||||
|
||||
@@ -225,8 +225,15 @@ volume_range_t volume_range() {
|
||||
return audio_codec->headphone_gain_range();
|
||||
}
|
||||
|
||||
void set_volume(const volume_t volume) {
|
||||
audio_codec->set_headphone_volume(volume);
|
||||
bool set_volume(const volume_t volume) {
|
||||
// add retry method
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
if (audio_codec->set_headphone_volume(volume)) {
|
||||
return true;
|
||||
}
|
||||
chThdSleepMilliseconds(2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} /* namespace headphone */
|
||||
|
||||
@@ -49,7 +49,7 @@ class Codec {
|
||||
virtual void headphone_enable() = 0;
|
||||
virtual void headphone_disable() = 0;
|
||||
virtual volume_range_t headphone_gain_range() const = 0;
|
||||
virtual void set_headphone_volume(const volume_t volume) = 0;
|
||||
virtual bool set_headphone_volume(const volume_t volume) = 0;
|
||||
|
||||
virtual void microphone_enable(int8_t alc_mode, bool mic_to_HP_enabled) = 0; // added user-GUI AK4951 ,selected ALC mode.
|
||||
virtual void microphone_disable() = 0;
|
||||
@@ -93,7 +93,7 @@ namespace headphone {
|
||||
|
||||
volume_range_t volume_range();
|
||||
|
||||
void set_volume(const volume_t volume);
|
||||
bool set_volume(const volume_t volume);
|
||||
|
||||
} /* namespace headphone */
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "baseband_api.hpp"
|
||||
#include <cstring>
|
||||
|
||||
#include "audio.hpp"
|
||||
#include "tonesets.hpp"
|
||||
@@ -31,10 +32,6 @@
|
||||
|
||||
#include "core_control.hpp"
|
||||
|
||||
/* Set true to enable additional checks to ensure
|
||||
* M4 and M0 are synchronized before passing messages. */
|
||||
static constexpr bool enforce_core_sync = true;
|
||||
|
||||
/* Set true to enable check for baseband messages getting stuck.
|
||||
* This implies the baseband thread is not dequeuing and has probably stalled.
|
||||
* NB: This check adds a small amout of overhead to the message sending code
|
||||
@@ -334,12 +331,27 @@ void set_rds_data(const uint16_t message_length) {
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_spectrum(const size_t sampling_rate, const size_t trigger) {
|
||||
void set_spectrum(
|
||||
const size_t sampling_rate,
|
||||
const size_t trigger) {
|
||||
const WidebandSpectrumConfigMessage message{
|
||||
sampling_rate, trigger};
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_audio_ddc_frequency(int32_t frequency) {
|
||||
const AudioDDCConfigMessage message{frequency};
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_time_sink(
|
||||
const size_t sampling_rate,
|
||||
const size_t trigger) {
|
||||
const TimeSinkConfigMessage message{
|
||||
sampling_rate, trigger};
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_wefax_config(uint8_t lpm = 120, uint8_t ioc = 0) {
|
||||
const WeFaxRxConfigureMessage message{lpm, ioc};
|
||||
send_message(&message);
|
||||
@@ -350,6 +362,16 @@ void set_noaaapt_config() {
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_vor_config(bool enabled) {
|
||||
const VorRxConfigureMessage message{enabled};
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_vor_tx_config(uint16_t radial_deg, bool ident_enabled, const std::string& ident, bool enabled) {
|
||||
const VorTxConfigureMessage message{radial_deg, ident_enabled, ident.c_str(), enabled};
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_flex_config() {
|
||||
const FlexConfigureMessage message{};
|
||||
send_message(&message);
|
||||
@@ -382,6 +404,11 @@ void set_moreserx_config(uint8_t mode) {
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_tonedetect_config(uint8_t squelch, uint32_t ctcss_freq_x10) {
|
||||
const ToneDetectConfigureMessage message{squelch, ctcss_freq_x10};
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_morsetx_config(uint8_t mode, uint32_t tone, float fm_delta) {
|
||||
const MorseTXConfigureMessage message{mode, tone, fm_delta};
|
||||
send_message(&message);
|
||||
@@ -412,9 +439,38 @@ void set_rtty_config(RTTYDataMessage& message) {
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_epirb_tx_config(EPIRBTXDataMessage& message) {
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_epirb_rx_config(EPIRBRXConfig& message) {
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_p25tx_data(const uint8_t* dibits, uint16_t frame_length) {
|
||||
const size_t max_len = sizeof(shared_memory.bb_data.data);
|
||||
if (frame_length > max_len) frame_length = max_len;
|
||||
memcpy(shared_memory.bb_data.data, dibits, frame_length);
|
||||
P25TxConfigureMessage msg{};
|
||||
msg.frame_length = frame_length;
|
||||
send_message(&msg);
|
||||
}
|
||||
|
||||
void set_hunter_config(uint32_t threshold, uint32_t hangtime_ms, bool start) {
|
||||
HunterConfigMessage message{};
|
||||
message.energy_threshold = threshold;
|
||||
message.hangtime_ms = hangtime_ms;
|
||||
message.start = start;
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
static bool baseband_image_running = false;
|
||||
|
||||
void run_image(const spi_flash::image_tag_t image_tag) {
|
||||
bool is_image_running() {
|
||||
return baseband_image_running;
|
||||
}
|
||||
|
||||
void run_image(const spi_flash::image_tag_t image_tag, bool enforce_core_sync) {
|
||||
if (baseband_image_running) {
|
||||
chDbgPanic("BBRunning");
|
||||
}
|
||||
@@ -427,7 +483,7 @@ void run_image(const spi_flash::image_tag_t image_tag) {
|
||||
|
||||
creg::m4txevent::enable();
|
||||
|
||||
if constexpr (enforce_core_sync) {
|
||||
if (enforce_core_sync) {
|
||||
// Wait up to 3 seconds for baseband to start handling events.
|
||||
auto count = 3'000u;
|
||||
while (!shared_memory.baseband_ready && --count)
|
||||
@@ -438,7 +494,7 @@ void run_image(const spi_flash::image_tag_t image_tag) {
|
||||
}
|
||||
}
|
||||
|
||||
void run_prepared_image(const uint32_t m4_code) {
|
||||
void run_prepared_image(const uint32_t m4_code, bool enforce_core_sync) {
|
||||
if (baseband_image_running) {
|
||||
chDbgPanic("BBRunning");
|
||||
}
|
||||
@@ -451,7 +507,7 @@ void run_prepared_image(const uint32_t m4_code) {
|
||||
|
||||
creg::m4txevent::enable();
|
||||
|
||||
if constexpr (enforce_core_sync) {
|
||||
if (enforce_core_sync) {
|
||||
// Wait up to 3 seconds for baseband to start handling events.
|
||||
auto count = 3'000u;
|
||||
while (!shared_memory.baseband_ready && --count)
|
||||
|
||||
@@ -97,28 +97,42 @@ void set_pocsag(int8_t baud_config = -1);
|
||||
void set_adsb();
|
||||
void set_jammer(const bool run, const jammer::JammerType type, const uint32_t speed);
|
||||
void set_rds_data(const uint16_t message_length);
|
||||
void set_spectrum(const size_t sampling_rate, const size_t trigger);
|
||||
void set_spectrum(
|
||||
const size_t sampling_rate,
|
||||
const size_t trigger);
|
||||
void set_audio_ddc_frequency(int32_t frequency);
|
||||
void set_time_sink(
|
||||
const size_t sampling_rate,
|
||||
const size_t trigger);
|
||||
void set_siggen_tone(const uint32_t tone);
|
||||
void set_siggen_config(const uint32_t bw, const uint32_t shape, const uint32_t duration);
|
||||
void set_spectrum_painter_config(const uint16_t width, const uint16_t height, bool update, int32_t bw);
|
||||
void set_subghzd_config(uint8_t modulation, uint32_t sampling_rate);
|
||||
void set_moreserx_config(uint8_t mode);
|
||||
void set_tonedetect_config(uint8_t squelch, uint32_t ctcss_freq_x10 = 0);
|
||||
void set_morsetx_config(uint8_t mode, uint32_t tone, float fm_delta);
|
||||
void set_morsetx_key(bool key_down);
|
||||
void set_wefax_config(uint8_t lpm, uint8_t ioc);
|
||||
void set_noaaapt_config();
|
||||
void set_vor_config(bool enabled = true);
|
||||
void set_vor_tx_config(uint16_t radial_deg, bool ident_enabled = true, const std::string& ident = "", bool enabled = true);
|
||||
void set_flex_config();
|
||||
void set_bitstream_config(uint32_t deviation, uint8_t mode); // mode 0 for am, 1 for 2fsk
|
||||
void set_rtty_config(uint16_t baud, uint16_t shift, uint8_t* payload = nullptr, uint16_t payload_length = 0); // baud*100
|
||||
void set_rtty_config(RTTYDataMessage& message);
|
||||
void set_epirb_tx_config(EPIRBTXDataMessage& message);
|
||||
void set_epirb_rx_config(EPIRBRXConfig& message);
|
||||
void set_p25tx_data(const uint8_t* dibits, uint16_t frame_length);
|
||||
void set_hunter_config(uint32_t threshold, uint32_t hangtime_ms, bool start);
|
||||
|
||||
void request_roger_beep();
|
||||
void request_rssi_beep();
|
||||
void request_beep_stop();
|
||||
void request_audio_beep(uint32_t freq, uint32_t sample_rate, uint32_t duration_ms);
|
||||
|
||||
void run_image(const portapack::spi_flash::image_tag_t image_tag);
|
||||
void run_prepared_image(const uint32_t m4_code);
|
||||
bool is_image_running();
|
||||
void run_image(const portapack::spi_flash::image_tag_t image_tag, bool enforce_core_sync = true);
|
||||
void run_prepared_image(const uint32_t m4_code, bool enforce_core_sync = true);
|
||||
void shutdown();
|
||||
|
||||
void spectrum_streaming_start();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -77,6 +77,31 @@ class ClockManager {
|
||||
void set_reference_ppb(const int32_t ppb);
|
||||
|
||||
#ifdef PRALINE
|
||||
|
||||
enum class P1_Function {
|
||||
TriggerIn, // CTRL2: L, CTRL1: L, CTRL0: L
|
||||
AuxClk1, // CTRL2: L, CTRL1: L, CTRL0: H
|
||||
ClkIn, // CTRL2: L, CTRL1: H, CTRL0: L
|
||||
TriggerOut, // CTRL2: L, CTRL1: H, CTRL0: H
|
||||
P22_ClkIn, // CTRL2: H, CTRL1: L, CTRL0: L
|
||||
P2_5, // CTRL2: H, CTRL1: L, CTRL0: H
|
||||
NotConnected, // CTRL2: H, CTRL1: H, CTRL0: L (NC)
|
||||
AuxClk2 // CTRL2: H, CTRL1: H, CTRL0: H
|
||||
};
|
||||
|
||||
// Multiplexer 2 (P2) Functions - Based on P2_Control.csv
|
||||
enum class P2_Function {
|
||||
Clk3, // CTRL1: L, CTRL0: X (Don't care)
|
||||
TriggerIn, // CTRL1: H, CTRL0: L
|
||||
TriggerOut // CTRL1: H, CTRL0: H
|
||||
};
|
||||
|
||||
// Function declarations
|
||||
void set_p1_control(P1_Function func);
|
||||
void set_p2_control(P2_Function func);
|
||||
|
||||
uint8_t get_resampling_n() const { return _resampling_n; }
|
||||
|
||||
// Si5351 diagnostic methods
|
||||
uint8_t si5351_read_status() { return clock_generator.device_status(); }
|
||||
uint8_t si5351_read_register(uint8_t reg) { return clock_generator.read_register(reg); }
|
||||
@@ -91,6 +116,9 @@ class ClockManager {
|
||||
|
||||
void enable_clock_output(bool enable);
|
||||
|
||||
void portapack_tcxo_enable();
|
||||
void portapack_tcxo_disable();
|
||||
|
||||
private:
|
||||
I2C& i2c0;
|
||||
si5351::Si5351& clock_generator;
|
||||
@@ -112,6 +140,10 @@ class ClockManager {
|
||||
ReferenceSource detect_reference_source();
|
||||
Reference choose_reference();
|
||||
bool loss_of_signal();
|
||||
|
||||
#ifdef PRALINE
|
||||
uint8_t _resampling_n{0}; // Current decimation factor (log2)
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /*__CLOCK_MANAGER_H__*/
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
#include "hackrf_gpio.hpp"
|
||||
#include "portapack_hal.hpp"
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#include "gpio.hpp"
|
||||
using namespace gpio_control;
|
||||
|
||||
void config_mode_blink_until_dfu();
|
||||
|
||||
void config_mode_set() {
|
||||
@@ -56,7 +61,6 @@ uint32_t blink_patterns[] = {
|
||||
|
||||
void config_mode_run() {
|
||||
configure_pins_portapack();
|
||||
portapack::gpio_dfu.input();
|
||||
portapack::persistent_memory::cache::init();
|
||||
|
||||
if (hackrf_r9) {
|
||||
@@ -75,14 +79,14 @@ void config_mode_run() {
|
||||
config_mode_blink_until_dfu();
|
||||
}
|
||||
|
||||
auto last_dfu_btn = portapack::gpio_dfu.read();
|
||||
auto last_dfu_btn = dfu_button.read();
|
||||
|
||||
int32_t counter = 0;
|
||||
int8_t blink_pattern_value = portapack::persistent_memory::config_cpld() +
|
||||
(portapack::persistent_memory::config_disable_external_tcxo() ? 5 : 0);
|
||||
|
||||
while (true) {
|
||||
auto dfu_btn = portapack::gpio_dfu.read();
|
||||
auto dfu_btn = dfu_button.read();
|
||||
auto dfu_clicked = last_dfu_btn == true && dfu_btn == false;
|
||||
last_dfu_btn = dfu_btn;
|
||||
|
||||
@@ -103,16 +107,16 @@ void config_mode_run() {
|
||||
|
||||
auto tx_value = ((tx_blink_pattern >> ((counter >> 0) & 31)) & 0x1) == 0x1;
|
||||
if (tx_value) {
|
||||
hackrf::one::led_tx.on();
|
||||
led_tx.setActive();
|
||||
} else {
|
||||
hackrf::one::led_tx.off();
|
||||
led_tx.setInactive();
|
||||
}
|
||||
|
||||
auto rx_value = ((rx_blink_pattern >> ((counter >> 0) & 31)) & 0x1) == 0x1;
|
||||
if (rx_value) {
|
||||
hackrf::one::led_rx.on();
|
||||
led_rx.setActive();
|
||||
} else {
|
||||
hackrf::one::led_rx.off();
|
||||
led_rx.setInactive();
|
||||
}
|
||||
|
||||
chThdSleepMilliseconds(100);
|
||||
@@ -122,17 +126,17 @@ void config_mode_run() {
|
||||
|
||||
void config_mode_blink_until_dfu() {
|
||||
while (true) {
|
||||
hackrf::one::led_tx.on();
|
||||
hackrf::one::led_rx.on();
|
||||
hackrf::one::led_usb.on();
|
||||
led_tx.setActive();
|
||||
led_rx.setActive();
|
||||
led_usb.setActive();
|
||||
chThdSleepMilliseconds(10);
|
||||
|
||||
hackrf::one::led_tx.off();
|
||||
hackrf::one::led_rx.off();
|
||||
hackrf::one::led_usb.off();
|
||||
led_tx.setInactive();
|
||||
led_rx.setInactive();
|
||||
led_usb.setInactive();
|
||||
chThdSleepMilliseconds(115);
|
||||
|
||||
auto dfu_btn = portapack::gpio_dfu.read();
|
||||
auto dfu_btn = dfu_button.read();
|
||||
if (dfu_btn)
|
||||
break;
|
||||
}
|
||||
@@ -140,7 +144,7 @@ void config_mode_blink_until_dfu() {
|
||||
while (true) {
|
||||
chThdSleepMilliseconds(10);
|
||||
|
||||
auto dfu_btn = portapack::gpio_dfu.read();
|
||||
auto dfu_btn = dfu_button.read();
|
||||
if (!dfu_btn)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
#include "irq_controls.hpp"
|
||||
#include "file_path.hpp"
|
||||
|
||||
#include "gpio.hpp"
|
||||
using namespace gpio_control;
|
||||
|
||||
using namespace ui;
|
||||
|
||||
#define DEBUG_LOG_FILE "debug_log.txt"
|
||||
@@ -134,9 +137,9 @@ void draw_line(int32_t y_offset, const char* label, regarm_t value) {
|
||||
}
|
||||
|
||||
void runtime_error(uint8_t source) {
|
||||
LED led = (source == CORTEX_M0) ? hackrf::one::led_rx : hackrf::one::led_tx;
|
||||
const auto& led = (source == CORTEX_M0) ? led_rx : led_tx;
|
||||
|
||||
led.off();
|
||||
led.setInactive();
|
||||
|
||||
// wait for DFU button release if pressed, so we don't immediately jump into stack dump
|
||||
while (swizzled_switches() & (1 << (int)Switch::Dfu));
|
||||
|
||||
@@ -37,8 +37,20 @@
|
||||
|
||||
#include "ch.h"
|
||||
|
||||
#include "lpc43xx_cpp.hpp"
|
||||
using namespace lpc43xx;
|
||||
#include "gpio.hpp"
|
||||
using namespace gpio_control;
|
||||
|
||||
#include "irq_rtc.hpp"
|
||||
|
||||
#include "i2c_lld.h"
|
||||
|
||||
#include "i2cdevmanager.hpp"
|
||||
#include "i2cdev_ppmod.hpp"
|
||||
|
||||
#include "lpc43xx.inc"
|
||||
#include "nvic.h"
|
||||
#include "lpc43xx_m0.h"
|
||||
#include "rffc507x_spi.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -134,7 +146,186 @@ void EventDispatcher::set_display_sleep(const bool sleep) {
|
||||
// Let frame sync handler turn on backlight after repaint.
|
||||
}
|
||||
EventDispatcher::display_sleep = sleep;
|
||||
};
|
||||
}
|
||||
|
||||
void EventDispatcher::charge_deep_sleep(const bool sleep) {
|
||||
bool detect = false;
|
||||
uint8_t valid_mask = 0;
|
||||
uint8_t percent = 0;
|
||||
uint16_t voltage = 0;
|
||||
int32_t current = 0;
|
||||
|
||||
constexpr I2CConfig i2c_config_12mhz{
|
||||
.high_count = 15,
|
||||
.low_count = 15,
|
||||
};
|
||||
|
||||
if (sleep) {
|
||||
auto dev = (i2cdev::I2cDev_PPmod*)i2cdev::I2CDevManager::get_dev_by_model(I2C_DEVMDL::I2CDECMDL_PPMOD);
|
||||
if (dev) dev->send_poweroff_command();
|
||||
|
||||
rffc507x::spi::SPI().power_down();
|
||||
portapack::shutdown(false, true);
|
||||
|
||||
// Unmount SD card and stop driver
|
||||
f_mount(nullptr, reinterpret_cast<const TCHAR*>(_T("")), 0);
|
||||
sdcDisconnect(&SDCD1);
|
||||
sdcStop(&SDCD1);
|
||||
|
||||
// Signal application shutdown
|
||||
ShutdownMessage shutdown_message;
|
||||
shared_memory.application_queue.push(shutdown_message);
|
||||
shared_memory.baseband_message = nullptr;
|
||||
|
||||
// Disable core interrupts and system tick
|
||||
nvicDisableVector(DMA_IRQn);
|
||||
nvicDisableVector(M4CORE_IRQn);
|
||||
chSysDisable();
|
||||
systick_stop();
|
||||
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
|
||||
power_control::vaa_power_off();
|
||||
power_control::core_power_off();
|
||||
|
||||
#ifdef PRALINE
|
||||
// Power management and GPIO configuration for Praline hardware
|
||||
LPC_GPIO->DIR[0] &= ~0xFFFF4000;
|
||||
LPC_GPIO->DIR[1] &= ~0xFFFF1000;
|
||||
LPC_GPIO->DIR[2] &= ~((1 << 14) | (1 << 13) | (1 << 12) | (1 << 11) | (1 << 10) | (1 << 6) | (1 << 0));
|
||||
LPC_GPIO->DIR[3] &= ~((1 << 7) | (1 << 5));
|
||||
LPC_GPIO->DIR[5] &= ~(1 << 16);
|
||||
#else
|
||||
// Power management and GPIO configuration for legacy hardware
|
||||
LPC_GPIO->DIR[0] &= ~0xFFFF4000;
|
||||
LPC_GPIO->DIR[1] &= ~0xFFFF1000;
|
||||
LPC_GPIO->DIR[2] &= ~((1 << 14) | (1 << 13) | (1 << 12) | (1 << 11) | (1 << 10) | (1 << 6) | (1 << 0));
|
||||
LPC_GPIO->DIR[3] &= ~((1 << 7) | (1 << 5));
|
||||
LPC_GPIO->DIR[5] &= ~(1 << 16);
|
||||
#endif
|
||||
|
||||
// Power down peripherals (CGU cleanup)
|
||||
LPC_RGU->RESET_CTRL[0] = (1 << 5); // USB0 Reset
|
||||
LPC_CGU->PLL0USB_CTRL.PD = 1;
|
||||
LPC_CGU->BASE_USB0_CLK.PD = 1;
|
||||
LPC_CREG->CREG0 |= (1 << 5);
|
||||
|
||||
LPC_CGU->BASE_USB1_CLK.PD = 1;
|
||||
LPC_CGU->BASE_UART0_CLK.PD = 1;
|
||||
LPC_CGU->BASE_UART1_CLK.PD = 1;
|
||||
LPC_CGU->BASE_UART2_CLK.PD = 1;
|
||||
LPC_CGU->BASE_UART3_CLK.PD = 1;
|
||||
LPC_CGU->BASE_SPI_CLK.PD = 1;
|
||||
LPC_CGU->BASE_PERIPH_CLK.PD = 1;
|
||||
LPC_CGU->BASE_SDIO_CLK.PD = 1;
|
||||
LPC_CGU->BASE_SSP0_CLK.PD = 1;
|
||||
LPC_CGU->BASE_SSP1_CLK.PD = 1;
|
||||
LPC_CGU->BASE_LCD_CLK.PD = 1;
|
||||
LPC_CGU->BASE_OUT_CLK.PD = 1;
|
||||
|
||||
(*(volatile uint32_t*)(&LPC_CGU->PLL0AUDIO_CTRL)) |= (1 << 0);
|
||||
|
||||
LPC_ADC0->CR &= ~(1 << 21);
|
||||
LPC_ADC1->CR &= ~(1 << 21);
|
||||
led_rx.setInactive();
|
||||
led_usb.setInactive();
|
||||
|
||||
rtc_wakeup_init();
|
||||
NVIC_EnableIRQ(I2C0_OR_I2C1_IRQn);
|
||||
|
||||
while (1) {
|
||||
// --- Battery Status Check (I2C) ---
|
||||
detect = battery::BatteryManagement::isDetected();
|
||||
if (detect) {
|
||||
bool dummy;
|
||||
battery::BatteryManagement::getBatteryInfo(valid_mask, percent, voltage, current, dummy);
|
||||
|
||||
bool is_full = (valid_mask == 31 && percent == 100 && current <= 10) ||
|
||||
(valid_mask == 1 && percent == 100);
|
||||
|
||||
if (is_full) {
|
||||
// Case 1: Battery full (All LEDs off)
|
||||
led_rx.setInactive();
|
||||
led_tx.setInactive();
|
||||
} else if ((voltage < 4150 && current < 10) || valid_mask == 0) {
|
||||
// Case 2: Not full but low current draw (<10mA) -> Charging error
|
||||
led_tx.setActive(); // LED indicates error/idle
|
||||
led_rx.setInactive();
|
||||
} else {
|
||||
// Case 3: Actively charging
|
||||
led_rx.setActive(); // LED indicates charging
|
||||
led_tx.setInactive();
|
||||
}
|
||||
} else {
|
||||
// Case 4: Battery IC not detected -> Error or H2 or older, so don't show that as an error.
|
||||
led_tx.setActive();
|
||||
led_rx.setActive();
|
||||
}
|
||||
|
||||
// Shut down I2C and power down the APB bus for sleep
|
||||
portapack::i2c0.stop();
|
||||
LPC_CGU->BASE_APB1_CLK.PD = 1;
|
||||
|
||||
// Save interrupt states before mass disable
|
||||
uint32_t saved_iser0 = NVIC->ISER[0];
|
||||
|
||||
// Disable and clear all pending interrupts
|
||||
NVIC->ICER[0] = 0xFFFFFFFF;
|
||||
|
||||
NVIC->ICPR[0] = 0xFFFFFFFF;
|
||||
|
||||
// Re-enable only necessary wakeup sources
|
||||
NVIC_EnableIRQ(RTC_IRQn);
|
||||
NVIC_EnableIRQ(EVENTROUTER_IRQn);
|
||||
|
||||
// Configure RTC wakeup interval
|
||||
if (valid_mask != 0 || detect) {
|
||||
rtc_wakeup(60);
|
||||
} else {
|
||||
rtc_wakeup(3);
|
||||
}
|
||||
|
||||
LPC_RTC->ILR = 3;
|
||||
LPC_EVENTROUTER->CLR_STAT = 0xFFFFFFFF;
|
||||
NVIC_ClearPendingIRQ(RTC_IRQn);
|
||||
NVIC_ClearPendingIRQ(EVENTROUTER_IRQn);
|
||||
|
||||
__disable_irq();
|
||||
|
||||
// Configure and enter Deep Sleep
|
||||
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
|
||||
|
||||
__DSB();
|
||||
__ISB();
|
||||
|
||||
// CPU enters sleep here
|
||||
__WFI();
|
||||
|
||||
// --- WAKEUP SEQUENCE ---
|
||||
__enable_irq();
|
||||
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
|
||||
|
||||
// Cleanup RTC and restore peripheral clocks
|
||||
LPC_RTC->AMR = 0xFF;
|
||||
LPC_RTC->ILR = 3;
|
||||
LPC_CGU->BASE_APB1_CLK.PD = 0;
|
||||
LPC_RGU->RESET_CTRL[1] = (1 << 16);
|
||||
|
||||
// Short delay for power stability (3V3 rail)
|
||||
for (volatile int d = 0; d < 10000; d++);
|
||||
|
||||
// Restart I2C controller
|
||||
LPC_CGU->BASE_APB1_CLK.PD = 0;
|
||||
portapack::i2c0.start(i2c_config_12mhz);
|
||||
|
||||
// Restore original interrupt enable states
|
||||
NVIC->ISER[0] = saved_iser0;
|
||||
|
||||
} // End of while(1) deep sleep loop
|
||||
} else {
|
||||
portapack::display.wake(true);
|
||||
}
|
||||
}
|
||||
|
||||
eventmask_t EventDispatcher::wait() {
|
||||
return chEvtWaitAny(ALL_EVENTS);
|
||||
@@ -209,8 +400,6 @@ void EventDispatcher::handle_local_queue() {
|
||||
void EventDispatcher::handle_rtc_tick() {
|
||||
sd_card::poll_inserted();
|
||||
|
||||
portapack::temperature_logger.second_tick();
|
||||
|
||||
const auto backlight_timer = portapack::persistent_memory::config_backlight_timer();
|
||||
if (backlight_timer.timeout_enabled()) {
|
||||
if (portapack::bl_tick_counter == backlight_timer.timeout_seconds())
|
||||
|
||||
@@ -63,6 +63,8 @@ class EventDispatcher {
|
||||
|
||||
static void set_display_sleep(const bool sleep);
|
||||
|
||||
static void charge_deep_sleep(const bool sleep);
|
||||
|
||||
static inline void check_fifo_isr() {
|
||||
if (!shared_memory.application_queue.is_empty()) {
|
||||
events_flag_isr(EVT_MASK_APPLICATION);
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2026 PortaPack Mayhem
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_adsb_rx.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "external_app.hpp"
|
||||
|
||||
namespace ui::external_app::adsbrx {
|
||||
|
||||
void initialize_app(ui::NavigationView& nav) {
|
||||
nav.push<ADSBRxView>();
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::adsbrx
|
||||
|
||||
extern "C" {
|
||||
|
||||
__attribute__((section(".external_app.app_adsbrx.application_information"), used)) application_information_t _application_information_adsbrx = {
|
||||
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||
/*.externalAppEntry = */ ui::external_app::adsbrx::initialize_app,
|
||||
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||
/*.app_version = */ VERSION_MD5,
|
||||
|
||||
/*.app_name = */ "ADS-B",
|
||||
/*.bitmap_data = */ {
|
||||
0x80,
|
||||
0x01,
|
||||
0xC0,
|
||||
0x03,
|
||||
0xC0,
|
||||
0x03,
|
||||
0xC0,
|
||||
0x03,
|
||||
0xC0,
|
||||
0x03,
|
||||
0xE0,
|
||||
0x07,
|
||||
0xF8,
|
||||
0x1F,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xC0,
|
||||
0x03,
|
||||
0xC0,
|
||||
0x03,
|
||||
0xC0,
|
||||
0x03,
|
||||
0xE0,
|
||||
0x07,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0xF8,
|
||||
0x1F,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::green().v,
|
||||
/*.menu_location = */ app_location_t::RX,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_adsbrx */ {'P', 'A', 'D', 'R'},
|
||||
/*.m4_app_offset = */ 0x00000000,
|
||||
};
|
||||
|
||||
} // extern "C"
|
||||
Vendored
+27
-6
@@ -38,7 +38,7 @@ using namespace portapack;
|
||||
|
||||
namespace pmem = portapack::persistent_memory;
|
||||
|
||||
namespace ui {
|
||||
namespace ui::external_app::adsbrx {
|
||||
|
||||
static const char speed_type_msg[][6] = {" Spd:", " IAS:", " TAS:"};
|
||||
|
||||
@@ -46,13 +46,19 @@ static std::string get_map_tag(const AircraftRecentEntry& entry) {
|
||||
return trimr(entry.callsign.empty() ? entry.icao_str : entry.callsign);
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::adsbrx
|
||||
|
||||
namespace ui {
|
||||
|
||||
template <>
|
||||
void RecentEntriesTable<AircraftRecentEntries>::draw(
|
||||
void RecentEntriesTable<external_app::adsbrx::AircraftRecentEntries>::draw(
|
||||
const Entry& entry,
|
||||
const Rect& target_rect,
|
||||
Painter& painter,
|
||||
const Style& style,
|
||||
RecentEntriesColumns& columns) {
|
||||
using namespace external_app::adsbrx;
|
||||
|
||||
Color target_color;
|
||||
std::string entry_string;
|
||||
|
||||
@@ -75,7 +81,7 @@ void RecentEntriesTable<AircraftRecentEntries>::draw(
|
||||
uint8_t firstcolwidth = columns.at(0).second;
|
||||
ipc.resize(firstcolwidth, ' '); // Make sure this is always match the first column's width that is dynamic.
|
||||
|
||||
entry_string += ipc + to_string_dec_uint((unsigned int)(entry.pos.altitude / 100), 4);
|
||||
entry_string += ipc + to_string_dec_int((int32_t)(entry.pos.altitude / 100), 4);
|
||||
|
||||
if (entry.velo.type == SPD_IAS && entry.pos.alt_valid) { // IAS can be converted to TAS
|
||||
// It is generally accepted that for every thousand feet of altitude,
|
||||
@@ -107,6 +113,10 @@ void RecentEntriesTable<AircraftRecentEntries>::draw(
|
||||
bitmap_target, target_color, style.background);
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
||||
namespace ui::external_app::adsbrx {
|
||||
|
||||
/* ADSBLogger ********************************************/
|
||||
|
||||
void ADSBLogger::log(const ADSBLogEntry& log_entry) {
|
||||
@@ -532,6 +542,18 @@ ADSBRxView::ADSBRxView(NavigationView& nav) {
|
||||
logger = std::make_unique<ADSBLogger>();
|
||||
logger->append(logs_dir / u"ADSB.TXT");
|
||||
|
||||
/* First run only: start from the configuration that is known to receive
|
||||
* ADS-B on this hardware -- LNA 32, VGA 32, RF amp ON. The first two are
|
||||
* already ReceiverModel's defaults; the amp is not, and running without it
|
||||
* costs about 14 dB, which is the difference between a busy list and an
|
||||
* empty one. Once the user has saved settings for this app their choice
|
||||
* wins, so this only sets the starting point.
|
||||
* Going through the field rather than receiver_model keeps the displayed
|
||||
* value in step: RFAmpField snapshots rf_amp() in its own constructor,
|
||||
* which has already run by the time we get here. */
|
||||
if (!settings_.loaded())
|
||||
field_rf_amp.set_value(1);
|
||||
|
||||
receiver_model.enable();
|
||||
baseband::set_adsb();
|
||||
|
||||
@@ -668,9 +690,8 @@ void ADSBRxView::on_frame(const ADSBFrameMessage* message) {
|
||||
(raw_data[3] & 15);
|
||||
|
||||
// The final altitude is due to the resulting number multiplied by 25, minus 1000.
|
||||
// altitude = 25N - 1000 (ft); minimum is -1000 ft when N=0 (Q=1, M=0 per ICAO Annex 10).
|
||||
altitude = 25 * n - 1000;
|
||||
if (altitude < 0)
|
||||
altitude = 0;
|
||||
} // else N is an 11 bit Gillham coded altitude
|
||||
}
|
||||
|
||||
@@ -817,4 +838,4 @@ void ADSBRxView::remove_expired_entries() {
|
||||
recent.erase(it.base(), recent.end());
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
} // namespace ui::external_app::adsbrx
|
||||
Vendored
+2
-2
@@ -39,7 +39,7 @@
|
||||
|
||||
using namespace adsb;
|
||||
|
||||
namespace ui {
|
||||
namespace ui::external_app::adsbrx {
|
||||
#define AIRCRAFT_ID_L 1 // aircraft ID message type (lowest type id)
|
||||
#define AIRCRAFT_ID_H 4 // aircraft ID message type (highest type id)
|
||||
|
||||
@@ -491,4 +491,4 @@ class ADSBRxView : public View {
|
||||
}};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
} // namespace ui::external_app::adsbrx
|
||||
+37
-29
@@ -35,7 +35,8 @@ using namespace portapack;
|
||||
|
||||
namespace pmem = portapack::persistent_memory;
|
||||
|
||||
namespace ais {
|
||||
namespace ui::external_app::ais_rx {
|
||||
|
||||
namespace format {
|
||||
|
||||
static std::string latlon_abs_normalized(const int32_t normalized, const char suffixes[2]) {
|
||||
@@ -47,7 +48,7 @@ static std::string latlon_abs_normalized(const int32_t normalized, const char su
|
||||
return to_string_dec_uint(degrees) + "." + to_string_dec_uint(fraction, 6, '0') + suffix;
|
||||
}
|
||||
|
||||
static std::string latlon(const Latitude latitude, const Longitude longitude) {
|
||||
static std::string latlon(const ais::Latitude latitude, const ais::Longitude longitude) {
|
||||
if (latitude.is_valid() && longitude.is_valid()) {
|
||||
return latlon_abs_normalized(latitude.normalized(), "SN") + " " + latlon_abs_normalized(longitude.normalized(), "WE");
|
||||
} else if (latitude.is_not_available() && longitude.is_not_available()) {
|
||||
@@ -128,7 +129,7 @@ static std::string navigational_status(const unsigned int value) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::string rate_of_turn(const RateOfTurn value) {
|
||||
static std::string rate_of_turn(const ais::RateOfTurn value) {
|
||||
switch (value) {
|
||||
case -128:
|
||||
return "not available";
|
||||
@@ -149,7 +150,7 @@ static std::string rate_of_turn(const RateOfTurn value) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::string speed_over_ground(const SpeedOverGround value) {
|
||||
static std::string speed_over_ground(const ais::SpeedOverGround value) {
|
||||
if (value == 1023) {
|
||||
return "not available";
|
||||
} else if (value == 1022) {
|
||||
@@ -159,7 +160,7 @@ static std::string speed_over_ground(const SpeedOverGround value) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::string course_over_ground(const CourseOverGround value) {
|
||||
static std::string course_over_ground(const ais::CourseOverGround value) {
|
||||
if (value > 3600) {
|
||||
return "invalid";
|
||||
} else if (value == 3600) {
|
||||
@@ -169,7 +170,7 @@ static std::string course_over_ground(const CourseOverGround value) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::string true_heading(const TrueHeading value) {
|
||||
static std::string true_heading(const ais::TrueHeading value) {
|
||||
if (value == 511) {
|
||||
return "not available";
|
||||
} else if (value > 359) {
|
||||
@@ -180,7 +181,6 @@ static std::string true_heading(const TrueHeading value) {
|
||||
}
|
||||
|
||||
} /* namespace format */
|
||||
} /* namespace ais */
|
||||
|
||||
void AISLogger::on_packet(const ais::Packet& packet) {
|
||||
// TODO: Unstuff here, not in baseband!
|
||||
@@ -265,25 +265,33 @@ void AISRecentEntry::update(const ais::Packet& packet) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::ais_rx
|
||||
|
||||
namespace ui {
|
||||
|
||||
template <>
|
||||
void RecentEntriesTable<AISRecentEntries>::draw(
|
||||
void RecentEntriesTable<external_app::ais_rx::AISRecentEntries>::draw(
|
||||
const Entry& entry,
|
||||
const Rect& target_rect,
|
||||
Painter& painter,
|
||||
const Style& style,
|
||||
RecentEntriesColumns&) {
|
||||
std::string line = ais::format::mmsi(entry.mmsi) + " ";
|
||||
using namespace external_app::ais_rx;
|
||||
|
||||
std::string line = format::mmsi(entry.mmsi) + " ";
|
||||
if (!entry.name.empty()) {
|
||||
line += ais::format::text(entry.name);
|
||||
line += format::text(entry.name);
|
||||
} else {
|
||||
line += ais::format::text(entry.call_sign);
|
||||
line += format::text(entry.call_sign);
|
||||
}
|
||||
line.resize(target_rect.width() / 8, ' ');
|
||||
painter.draw_string(target_rect.location(), style, line);
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
||||
namespace ui::external_app::ais_rx {
|
||||
|
||||
AISRecentEntryDetailView::AISRecentEntryDetailView(NavigationView& nav) {
|
||||
add_children({
|
||||
&button_done,
|
||||
@@ -298,12 +306,12 @@ AISRecentEntryDetailView::AISRecentEntryDetailView(NavigationView& nav) {
|
||||
|
||||
button_see_map.on_select = [this, &nav](Button&) {
|
||||
geomap_view = nav.push<GeoMapView>(
|
||||
ais::format::text(entry_.name),
|
||||
format::text(entry_.name),
|
||||
0,
|
||||
GeoPos::alt_unit::METERS,
|
||||
GeoPos::spd_unit::KNOTS,
|
||||
ais::format::latlon_float(entry_.last_position.latitude.normalized()),
|
||||
ais::format::latlon_float(entry_.last_position.longitude.normalized()),
|
||||
format::latlon_float(entry_.last_position.latitude.normalized()),
|
||||
format::latlon_float(entry_.last_position.longitude.normalized()),
|
||||
entry_.last_position.true_heading,
|
||||
[this]() {
|
||||
send_updates = false;
|
||||
@@ -324,14 +332,14 @@ AISRecentEntryDetailView& AISRecentEntryDetailView::operator=(const AISRecentEnt
|
||||
|
||||
void AISRecentEntryDetailView::update_position() {
|
||||
if (send_updates)
|
||||
geomap_view->update_position(ais::format::latlon_float(entry_.last_position.latitude.normalized()), ais::format::latlon_float(entry_.last_position.longitude.normalized()), (float)entry_.last_position.true_heading, 0, entry_.last_position.speed_over_ground > 1022 ? 0 : entry_.last_position.speed_over_ground / 10);
|
||||
geomap_view->update_position(format::latlon_float(entry_.last_position.latitude.normalized()), format::latlon_float(entry_.last_position.longitude.normalized()), (float)entry_.last_position.true_heading, 0, entry_.last_position.speed_over_ground > 1022 ? 0 : entry_.last_position.speed_over_ground / 10);
|
||||
}
|
||||
|
||||
bool AISRecentEntryDetailView::add_map_marker(const AISRecentEntry& entry) {
|
||||
if (geomap_view && send_updates) {
|
||||
GeoMarker marker{};
|
||||
marker.lon = ais::format::latlon_float(entry.last_position.longitude.normalized());
|
||||
marker.lat = ais::format::latlon_float(entry.last_position.latitude.normalized());
|
||||
marker.lon = format::latlon_float(entry.last_position.longitude.normalized());
|
||||
marker.lat = format::latlon_float(entry.last_position.latitude.normalized());
|
||||
marker.angle = entry.last_position.true_heading;
|
||||
marker.tag = entry.call_sign.empty() ? to_string_dec_uint(entry.mmsi) : entry.call_sign;
|
||||
auto markerStored = geomap_view->store_marker(marker);
|
||||
@@ -377,18 +385,18 @@ void AISRecentEntryDetailView::paint(Painter& painter) {
|
||||
|
||||
auto field_rect = Rect{rect.left(), rect.top() + 16, rect.width(), 16};
|
||||
|
||||
field_rect = draw_field(painter, field_rect, s, "MMSI", ais::format::mmsi(entry_.mmsi));
|
||||
field_rect = draw_field(painter, field_rect, s, "Ctry", ais::format::mid(entry_.mmsi));
|
||||
field_rect = draw_field(painter, field_rect, s, "Name", ais::format::text(entry_.name));
|
||||
field_rect = draw_field(painter, field_rect, s, "Call", ais::format::text(entry_.call_sign));
|
||||
field_rect = draw_field(painter, field_rect, s, "Dest", ais::format::text(entry_.destination));
|
||||
field_rect = draw_field(painter, field_rect, s, "MMSI", format::mmsi(entry_.mmsi));
|
||||
field_rect = draw_field(painter, field_rect, s, "Ctry", format::mid(entry_.mmsi));
|
||||
field_rect = draw_field(painter, field_rect, s, "Name", format::text(entry_.name));
|
||||
field_rect = draw_field(painter, field_rect, s, "Call", format::text(entry_.call_sign));
|
||||
field_rect = draw_field(painter, field_rect, s, "Dest", format::text(entry_.destination));
|
||||
field_rect = draw_field(painter, field_rect, s, "Last", to_string_datetime(entry_.last_position.timestamp));
|
||||
field_rect = draw_field(painter, field_rect, s, "Pos ", ais::format::latlon(entry_.last_position.latitude, entry_.last_position.longitude));
|
||||
field_rect = draw_field(painter, field_rect, s, "Stat", ais::format::navigational_status(entry_.navigational_status));
|
||||
field_rect = draw_field(painter, field_rect, s, "RoT ", ais::format::rate_of_turn(entry_.last_position.rate_of_turn));
|
||||
field_rect = draw_field(painter, field_rect, s, "SoG ", ais::format::speed_over_ground(entry_.last_position.speed_over_ground));
|
||||
field_rect = draw_field(painter, field_rect, s, "CoG ", ais::format::course_over_ground(entry_.last_position.course_over_ground));
|
||||
field_rect = draw_field(painter, field_rect, s, "Head", ais::format::true_heading(entry_.last_position.true_heading));
|
||||
field_rect = draw_field(painter, field_rect, s, "Pos ", format::latlon(entry_.last_position.latitude, entry_.last_position.longitude));
|
||||
field_rect = draw_field(painter, field_rect, s, "Stat", format::navigational_status(entry_.navigational_status));
|
||||
field_rect = draw_field(painter, field_rect, s, "RoT ", format::rate_of_turn(entry_.last_position.rate_of_turn));
|
||||
field_rect = draw_field(painter, field_rect, s, "SoG ", format::speed_over_ground(entry_.last_position.speed_over_ground));
|
||||
field_rect = draw_field(painter, field_rect, s, "CoG ", format::course_over_ground(entry_.last_position.course_over_ground));
|
||||
field_rect = draw_field(painter, field_rect, s, "Head", format::true_heading(entry_.last_position.true_heading));
|
||||
field_rect = draw_field(painter, field_rect, s, "Rx #", to_string_dec_uint(entry_.received_count));
|
||||
}
|
||||
|
||||
@@ -504,4 +512,4 @@ void AISAppView::on_show_detail(const AISRecentEntry& entry) {
|
||||
recent_entry_detail_view.update_map_markers(recent);
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
} // namespace ui::external_app::ais_rx
|
||||
+3
-3
@@ -50,6 +50,8 @@ using namespace lpc43xx;
|
||||
|
||||
#include "recent_entries.hpp"
|
||||
|
||||
namespace ui::external_app::ais_rx {
|
||||
|
||||
struct AISPosition {
|
||||
rtc::RTC timestamp{};
|
||||
ais::Latitude latitude{};
|
||||
@@ -109,8 +111,6 @@ class AISLogger {
|
||||
LogFile log_file{};
|
||||
};
|
||||
|
||||
namespace ui {
|
||||
|
||||
using AISRecentEntriesView = RecentEntriesView<AISRecentEntries>;
|
||||
|
||||
class AISRecentEntryDetailView : public View {
|
||||
@@ -239,6 +239,6 @@ class AISAppView : public View {
|
||||
void on_tick_second();
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
} // namespace ui::external_app::ais_rx
|
||||
|
||||
#endif /*__AIS_APP_H__*/
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2026 PortaPack Mayhem
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ais_app.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "external_app.hpp"
|
||||
|
||||
namespace ui::external_app::ais_rx {
|
||||
|
||||
void initialize_app(ui::NavigationView& nav) {
|
||||
nav.push<AISAppView>();
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::ais_rx
|
||||
|
||||
extern "C" {
|
||||
|
||||
__attribute__((section(".external_app.app_ais_rx.application_information"), used)) application_information_t _application_information_ais_rx = {
|
||||
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||
/*.externalAppEntry = */ ui::external_app::ais_rx::initialize_app,
|
||||
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||
/*.app_version = */ VERSION_MD5,
|
||||
|
||||
/*.app_name = */ "AIS Boats",
|
||||
/*.bitmap_data = */ {
|
||||
0x00,
|
||||
0x01,
|
||||
0x80,
|
||||
0x01,
|
||||
0xC0,
|
||||
0x01,
|
||||
0xC0,
|
||||
0x0D,
|
||||
0xE0,
|
||||
0x3D,
|
||||
0xF0,
|
||||
0x3D,
|
||||
0xF8,
|
||||
0x7D,
|
||||
0xFC,
|
||||
0x7D,
|
||||
0xFC,
|
||||
0x7D,
|
||||
0xFE,
|
||||
0x7D,
|
||||
0xFF,
|
||||
0x7D,
|
||||
0x00,
|
||||
0x00,
|
||||
0xF8,
|
||||
0x7F,
|
||||
0xF8,
|
||||
0x3F,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0x00,
|
||||
0x00,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::green().v,
|
||||
/*.menu_location = */ app_location_t::RX,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_ais */ {'P', 'A', 'I', 'S'},
|
||||
/*.m4_app_offset = */ 0x00000000,
|
||||
};
|
||||
|
||||
} // extern "C"
|
||||
+29
-25
@@ -131,35 +131,39 @@ void TVView::on_channel_spectrum(
|
||||
// I was hoping that by doing this, I can have a longer buffer like 39936, then the frame will looks better vertically
|
||||
// however this is useless until now.
|
||||
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
// video_buffer[i+count*256] = spectrum_rgb4_lut[spectrum.db[i]];
|
||||
video_buffer_int[i + count * 256] = 255 - spectrum.db[i];
|
||||
// Left the original comment, but rewrote the function.
|
||||
|
||||
// Shift the last 128 pixels of the previous packet to the front
|
||||
// This overlap handles an x_correction shift of up to 128 pixels seamlessly.
|
||||
for (size_t i = 0; i < 128; i++) {
|
||||
window_buffer[i] = window_buffer[i + 256];
|
||||
}
|
||||
count = count + 1;
|
||||
if (count == 52 - 1) {
|
||||
ui::Color line_buffer[128];
|
||||
Coord line;
|
||||
uint32_t bmp_px;
|
||||
|
||||
/*for (line = 0; line < 104; line++)
|
||||
{
|
||||
for (bmp_px = 0; bmp_px < 128; bmp_px++)
|
||||
{
|
||||
//line_buffer[bmp_px] = video_buffer[bmp_px+line*128];
|
||||
line_buffer[bmp_px] = spectrum_rgb4_lut[video_buffer_int[bmp_px+line*128 + x_correction]];
|
||||
}
|
||||
// Load the new 256 pixels into the remainder of the buffer
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
window_buffer[i + 128] = 255 - spectrum.db[i];
|
||||
}
|
||||
|
||||
display.render_line({ 0, line + 100 }, 128, line_buffer);
|
||||
}*/
|
||||
for (line = 0; line < 208; line = line + 2) {
|
||||
for (bmp_px = 0; bmp_px < 128; bmp_px++) {
|
||||
// line_buffer[bmp_px] = video_buffer[bmp_px+line*128];
|
||||
line_buffer[bmp_px] = spectrum_rgb4_lut[video_buffer_int[bmp_px + line / 2 * 128 + x_correction]];
|
||||
}
|
||||
ui::Color line_buffer[128];
|
||||
|
||||
display.render_line({0, line + 100}, 128, line_buffer);
|
||||
display.render_line({0, line + 101}, 128, line_buffer);
|
||||
}
|
||||
// Render the first line of this batch (matches original doubled-height behavior)
|
||||
for (size_t bmp_px = 0; bmp_px < 128; bmp_px++) {
|
||||
line_buffer[bmp_px] = spectrum_rgb4_lut[window_buffer[bmp_px + x_correction]];
|
||||
}
|
||||
display.render_line({0, (Coord)(count * 4 + 100)}, 128, line_buffer);
|
||||
display.render_line({0, (Coord)(count * 4 + 101)}, 128, line_buffer);
|
||||
|
||||
// Render the second line of this batch
|
||||
for (size_t bmp_px = 0; bmp_px < 128; bmp_px++) {
|
||||
line_buffer[bmp_px] = spectrum_rgb4_lut[window_buffer[bmp_px + 128 + x_correction]];
|
||||
}
|
||||
display.render_line({0, (Coord)(count * 4 + 102)}, 128, line_buffer);
|
||||
display.render_line({0, (Coord)(count * 4 + 103)}, 128, line_buffer);
|
||||
|
||||
count++;
|
||||
|
||||
// Reset at 52 (52 * 2 lines = 104 lines total)
|
||||
if (count >= 52) {
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -79,8 +79,9 @@ class TVView : public Widget {
|
||||
void paint(Painter& painter) override;
|
||||
void on_channel_spectrum(const ChannelSpectrum& spectrum);
|
||||
void on_adjust_xcorr(uint8_t xcorr);
|
||||
// ui::Color video_buffer[13312];
|
||||
uint8_t video_buffer_int[13312 + 128]{0}; // 128 is for the over length caused by x_correction
|
||||
// 256 samples from current callback + 128 overlap from the previous callback
|
||||
uint8_t window_buffer[384]{0};
|
||||
|
||||
uint32_t count = 0;
|
||||
uint8_t x_correction = 0;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* copyleft 2024 zxkmm AKA zix aka sommermorgentraum
|
||||
* copyleft 2024 zxkmm
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* copyleft 2024 zxkmm AKA zix aka sommermorgentraum
|
||||
* copyleft 2024 zxkmm
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2026 PortaPack Mayhem
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_aprs_rx.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "external_app.hpp"
|
||||
|
||||
namespace ui::external_app::aprs_rx {
|
||||
|
||||
void initialize_app(ui::NavigationView& nav) {
|
||||
nav.push<APRSRXView>();
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::aprs_rx
|
||||
|
||||
extern "C" {
|
||||
|
||||
__attribute__((section(".external_app.app_aprs_rx.application_information"), used)) application_information_t _application_information_aprs_rx = {
|
||||
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||
/*.externalAppEntry = */ ui::external_app::aprs_rx::initialize_app,
|
||||
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||
/*.app_version = */ VERSION_MD5,
|
||||
|
||||
/*.app_name = */ "APRS",
|
||||
/*.bitmap_data = */ {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0x4C,
|
||||
0x32,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0x25,
|
||||
0xA4,
|
||||
0x25,
|
||||
0xA4,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0x25,
|
||||
0xA4,
|
||||
0x25,
|
||||
0xA4,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0x4C,
|
||||
0x32,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::green().v,
|
||||
/*.menu_location = */ app_location_t::RX,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_aprs_rx */ {'P', 'A', 'P', 'R'},
|
||||
/*.m4_app_offset = */ 0x00000000,
|
||||
};
|
||||
|
||||
} // extern "C"
|
||||
Vendored
+12
-2
@@ -31,19 +31,25 @@
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
namespace ui::external_app::aprs_rx {
|
||||
|
||||
void APRSLogger::log_raw_data(const std::string& data) {
|
||||
log_file.write_entry(data);
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::aprs_rx
|
||||
|
||||
namespace ui {
|
||||
|
||||
template <>
|
||||
void RecentEntriesTable<APRSRecentEntries>::draw(
|
||||
void RecentEntriesTable<external_app::aprs_rx::APRSRecentEntries>::draw(
|
||||
const Entry& entry,
|
||||
const Rect& target_rect,
|
||||
Painter& painter,
|
||||
const Style& style,
|
||||
RecentEntriesColumns& columns) {
|
||||
using namespace external_app::aprs_rx;
|
||||
|
||||
Color target_color;
|
||||
// auto entry_age = entry.age;
|
||||
|
||||
@@ -68,6 +74,10 @@ void RecentEntriesTable<APRSRecentEntries>::draw(
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
||||
namespace ui::external_app::aprs_rx {
|
||||
|
||||
void APRSRxView::focus() {
|
||||
options_region.focus();
|
||||
}
|
||||
@@ -402,4 +412,4 @@ void APRSRXView::focus() {
|
||||
|
||||
APRSRXView::~APRSRXView() {
|
||||
}
|
||||
} /* namespace ui */
|
||||
} // namespace ui::external_app::aprs_rx
|
||||
Vendored
+3
-3
@@ -38,6 +38,8 @@
|
||||
#include "utility.hpp"
|
||||
#include "file_path.hpp"
|
||||
|
||||
namespace ui::external_app::aprs_rx {
|
||||
|
||||
class APRSLogger {
|
||||
public:
|
||||
Optional<File::Error> append(const std::filesystem::path& filename) {
|
||||
@@ -50,8 +52,6 @@ class APRSLogger {
|
||||
LogFile log_file{};
|
||||
};
|
||||
|
||||
namespace ui {
|
||||
|
||||
struct APRSRecentEntry {
|
||||
using Key = uint64_t;
|
||||
|
||||
@@ -290,6 +290,6 @@ class APRSRXView : public View {
|
||||
}};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
} // namespace ui::external_app::aprs_rx
|
||||
|
||||
#endif /*__UI_APRS_RX_H__*/
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2026 PortaPack Mayhem
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_aprs_tx.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "external_app.hpp"
|
||||
|
||||
namespace ui::external_app::aprs_tx {
|
||||
|
||||
void initialize_app(ui::NavigationView& nav) {
|
||||
nav.push<APRSTXView>();
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::aprs_tx
|
||||
|
||||
extern "C" {
|
||||
|
||||
__attribute__((section(".external_app.app_aprs_tx.application_information"), used)) application_information_t _application_information_aprs_tx = {
|
||||
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||
/*.externalAppEntry = */ ui::external_app::aprs_tx::initialize_app,
|
||||
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||
/*.app_version = */ VERSION_MD5,
|
||||
|
||||
/*.app_name = */ "APRS TX",
|
||||
/*.bitmap_data = */ {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0x4C,
|
||||
0x32,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0x25,
|
||||
0xA4,
|
||||
0x25,
|
||||
0xA4,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0x25,
|
||||
0xA4,
|
||||
0x25,
|
||||
0xA4,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0x4C,
|
||||
0x32,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::green().v,
|
||||
/*.menu_location = */ app_location_t::TX,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_afsk */ {'P', 'A', 'F', 'T'},
|
||||
/*.m4_app_offset = */ 0x00000000,
|
||||
};
|
||||
|
||||
} // extern "C"
|
||||
Vendored
+3
-2
@@ -37,7 +37,7 @@
|
||||
using namespace aprs;
|
||||
using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
namespace ui::external_app::aprs_tx {
|
||||
|
||||
void APRSTXView::focus() {
|
||||
tx_view.focus();
|
||||
@@ -238,7 +238,8 @@ APRSTXView::APRSTXView(NavigationView& nav) {
|
||||
process_coordinates(lat, lon);
|
||||
});
|
||||
};
|
||||
|
||||
// process_coordinates(last_lat, last_lon); //don't load last, so won't confuse users
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
} // namespace ui::external_app::aprs_tx
|
||||
Vendored
+2
-2
@@ -33,7 +33,7 @@
|
||||
#include "radio_state.hpp"
|
||||
#include "portapack.hpp"
|
||||
|
||||
namespace ui {
|
||||
namespace ui::external_app::aprs_tx {
|
||||
|
||||
class APRSTXView : public View {
|
||||
public:
|
||||
@@ -161,4 +161,4 @@ class APRSTXView : public View {
|
||||
}};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
} // namespace ui::external_app::aprs_tx
|
||||
+1
-1
@@ -45,7 +45,7 @@ __attribute__((section(".external_app.app_battleship.application_information"),
|
||||
0xFF, 0xFF, // ################
|
||||
0xFC, 0x3F, // ..############..
|
||||
},
|
||||
/*.icon_color = */ ui::Color::blue().v,
|
||||
/*.icon_color = */ ui::Color::green().v,
|
||||
/*.menu_location = */ app_location_t::GAMES,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
|
||||
+89
-105
@@ -6,11 +6,9 @@
|
||||
* ------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize("Os")
|
||||
#include "ui_battleship.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "modems.hpp"
|
||||
#include "bch_code.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
using namespace modems;
|
||||
@@ -28,7 +26,6 @@ BattleshipView::BattleshipView(NavigationView& nav)
|
||||
baseband::run_image(portapack::spi_flash::image_tag_pocsag2);
|
||||
|
||||
add_children({&text_title, &text_subtitle,
|
||||
//&rect_radio_settings, &rect_audio_settings, &rect_team_selection,
|
||||
&label_radio, &button_frequency,
|
||||
&label_rf_amp, &checkbox_rf_amp,
|
||||
&label_lna, &field_lna,
|
||||
@@ -151,8 +148,6 @@ BattleshipView::BattleshipView(NavigationView& nav)
|
||||
field_tx_gain.set_parent_rect({185, 118, 32, 16});
|
||||
checkbox_sound.set_parent_rect({17, 187, 80, 24});
|
||||
field_volume.set_parent_rect({165, 187, 32, 16});
|
||||
// button_red_team.set_parent_rect({25, 242, 85, 45});
|
||||
// button_blue_team.set_parent_rect({130, 242, 85, 45});
|
||||
|
||||
// Make menu elements focusable
|
||||
button_frequency.set_focusable(true);
|
||||
@@ -196,34 +191,22 @@ void BattleshipView::init_game() {
|
||||
}
|
||||
|
||||
void BattleshipView::show_hide_menu(bool menu_vis) {
|
||||
text_title.hidden(!menu_vis);
|
||||
text_subtitle.hidden(!menu_vis);
|
||||
// rect_radio_settings.hidden(!menu_vis); rect_audio_settings.hidden(!menu_vis); rect_team_selection.hidden(!menu_vis);
|
||||
label_radio.hidden(!menu_vis);
|
||||
button_frequency.hidden(!menu_vis);
|
||||
label_rf_amp.hidden(!menu_vis);
|
||||
checkbox_rf_amp.hidden(!menu_vis);
|
||||
label_lna.hidden(!menu_vis);
|
||||
field_lna.hidden(!menu_vis);
|
||||
label_vga.hidden(!menu_vis);
|
||||
field_vga.hidden(!menu_vis);
|
||||
label_tx_gain.hidden(!menu_vis);
|
||||
field_tx_gain.hidden(!menu_vis);
|
||||
label_audio.hidden(!menu_vis);
|
||||
checkbox_sound.hidden(!menu_vis);
|
||||
label_volume.hidden(!menu_vis);
|
||||
field_volume.hidden(!menu_vis);
|
||||
label_team.hidden(!menu_vis);
|
||||
button_red_team.hidden(!menu_vis);
|
||||
button_blue_team.hidden(!menu_vis);
|
||||
rssi.hidden(menu_vis);
|
||||
button_rotate.hidden(menu_vis);
|
||||
button_place.hidden(menu_vis);
|
||||
button_menu.hidden(menu_vis);
|
||||
Widget* const menu_widgets[] = {
|
||||
&text_title, &text_subtitle, &label_radio, &button_frequency,
|
||||
&label_rf_amp, &checkbox_rf_amp, &label_lna, &field_lna,
|
||||
&label_vga, &field_vga, &label_tx_gain, &field_tx_gain,
|
||||
&label_audio, &checkbox_sound, &label_volume, &field_volume,
|
||||
&label_team, &button_red_team, &button_blue_team};
|
||||
for (auto* w : menu_widgets) {
|
||||
w->hidden(!menu_vis);
|
||||
}
|
||||
|
||||
Widget* const game_widgets[] = {
|
||||
&rssi, &button_rotate, &button_place, &button_menu};
|
||||
for (auto* w : game_widgets) {
|
||||
w->hidden(menu_vis);
|
||||
}
|
||||
|
||||
// button_rotate.set_focusable(false); //no need, since can't focus on hidden
|
||||
// button_place.set_focusable(false);
|
||||
// button_menu.set_focusable(false);
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
@@ -340,40 +323,23 @@ void BattleshipView::paint(Painter& painter) {
|
||||
if (game_state == GameState::MENU) {
|
||||
draw_menu_screen(painter);
|
||||
|
||||
// Custom paint team buttons
|
||||
if (!button_red_team.hidden()) {
|
||||
Rect r = button_red_team.screen_rect();
|
||||
painter.fill_rectangle(r, Color::dark_red());
|
||||
painter.draw_rectangle(r, Color::red());
|
||||
auto draw_team_btn = [&painter](Button& btn, Color bg, Color border, const char* name) {
|
||||
if (btn.hidden()) return;
|
||||
Rect r = btn.screen_rect();
|
||||
painter.fill_rectangle(r, bg);
|
||||
painter.draw_rectangle(r, border);
|
||||
|
||||
if (button_red_team.has_focus()) {
|
||||
if (btn.has_focus()) {
|
||||
painter.draw_rectangle({r.location().x() - 1, r.location().y() - 1, r.size().width() + 2, r.size().height() + 2}, Color::yellow());
|
||||
}
|
||||
|
||||
auto style_white = Style{
|
||||
.font = ui::font::fixed_8x16,
|
||||
.background = Color::dark_red(),
|
||||
.foreground = Color::white()};
|
||||
painter.draw_string(r.center() - Point(24, 16), style_white, "RED");
|
||||
painter.draw_string(r.center() - Point(24, 0), style_white, "TEAM");
|
||||
}
|
||||
auto style = Style{.font = ui::font::fixed_8x16, .background = bg, .foreground = Color::white()};
|
||||
painter.draw_string(r.center() - Point(24, 16), style, name);
|
||||
painter.draw_string(r.center() - Point(24, 0), style, "TEAM");
|
||||
};
|
||||
|
||||
if (!button_blue_team.hidden()) {
|
||||
Rect r = button_blue_team.screen_rect();
|
||||
painter.fill_rectangle(r, Color::dark_blue());
|
||||
painter.draw_rectangle(r, Color::blue());
|
||||
|
||||
if (button_blue_team.has_focus()) {
|
||||
painter.draw_rectangle({r.location().x() - 1, r.location().y() - 1, r.size().width() + 2, r.size().height() + 2}, Color::yellow());
|
||||
}
|
||||
|
||||
auto style_white = Style{
|
||||
.font = ui::font::fixed_8x16,
|
||||
.background = Color::dark_blue(),
|
||||
.foreground = Color::white()};
|
||||
painter.draw_string(r.center() - Point(24, 16), style_white, "BLUE");
|
||||
painter.draw_string(r.center() - Point(24, 0), style_white, "TEAM");
|
||||
}
|
||||
draw_team_btn(button_red_team, Color::dark_red(), Color::red(), "RED");
|
||||
draw_team_btn(button_blue_team, Color::dark_blue(), Color::blue(), "BLUE");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -417,27 +383,25 @@ void BattleshipView::paint(Painter& painter) {
|
||||
void BattleshipView::draw_menu_screen(Painter& painter) {
|
||||
painter.draw_hline({12, 20 + 16}, screen_width - 24, Color::dark_cyan());
|
||||
|
||||
painter.fill_rectangle({13, 59, screen_width - 26, 116}, Color::dark_grey());
|
||||
painter.draw_hline({12, 58}, screen_width - 24, Color::cyan());
|
||||
painter.draw_hline({12, 157}, screen_width - 24, Color::cyan());
|
||||
const struct {
|
||||
Rect rect;
|
||||
Point line1_pos;
|
||||
Point line2_pos;
|
||||
} boxes[] = {
|
||||
{{13, 59, screen_width - 26, 116}, {12, 58}, {12, 157}},
|
||||
{{13, 165, screen_width - 24, 57}, {12, 164}, {12, 223}},
|
||||
{{13, 232, screen_width - 26, 67}, {12, 232}, {12, 300}}};
|
||||
|
||||
painter.fill_rectangle({13, 165, screen_width - 24, 57}, Color::dark_grey());
|
||||
painter.draw_hline({12, 164}, screen_width - 24, Color::cyan());
|
||||
painter.draw_hline({12, 223}, screen_width - 24, Color::cyan());
|
||||
|
||||
painter.fill_rectangle({13, 232, screen_width - 26, 67}, Color::dark_grey());
|
||||
painter.draw_hline({12, 232}, screen_width - 24, Color::cyan());
|
||||
painter.draw_hline({12, 300}, screen_width - 24, Color::cyan());
|
||||
for (const auto& box : boxes) {
|
||||
painter.fill_rectangle(box.rect, Color::dark_grey());
|
||||
painter.draw_hline(box.line1_pos, screen_width - 24, Color::cyan());
|
||||
painter.draw_hline(box.line2_pos, screen_width - 24, Color::cyan());
|
||||
}
|
||||
|
||||
// Radio status indicator
|
||||
Point indicator_pos{UI_POS_MAXWIDTH - 20, 59};
|
||||
if (is_transmitting) {
|
||||
painter.fill_rectangle({indicator_pos, {6, 6}}, Color::red());
|
||||
painter.draw_rectangle({indicator_pos.x() - 1, indicator_pos.y() - 1, 8, 8}, Color::light_grey());
|
||||
} else {
|
||||
painter.fill_rectangle({indicator_pos, {6, 6}}, Color::green());
|
||||
painter.draw_rectangle({indicator_pos.x() - 1, indicator_pos.y() - 1, 8, 8}, Color::light_grey());
|
||||
}
|
||||
painter.fill_rectangle({indicator_pos, {6, 6}}, is_transmitting ? Color::red() : Color::green());
|
||||
painter.draw_rectangle({indicator_pos.x() - 1, indicator_pos.y() - 1, 8, 8}, Color::light_grey());
|
||||
}
|
||||
|
||||
void BattleshipView::draw_grid(Painter& painter, uint16_t grid_x, uint16_t grid_y, const std::array<std::array<CellState, GRID_SIZE>, GRID_SIZE>& grid, bool show_ships, bool is_offense_grid) {
|
||||
@@ -464,11 +428,14 @@ void BattleshipView::draw_cell(Painter& painter, uint16_t cell_x, uint16_t cell_
|
||||
|
||||
if (game_state == GameState::PLACING_SHIPS && !is_offense_grid && current_ship_index < 5) {
|
||||
uint8_t ship_size = my_ships[current_ship_index].size();
|
||||
uint8_t dx = placing_horizontal ? 1 : 0;
|
||||
uint8_t dy = placing_horizontal ? 0 : 1;
|
||||
uint16_t grid_x = (cell_x - 1) / CELL_SIZE;
|
||||
uint16_t grid_y = (cell_y - GRID_OFFSET_Y - 6) / CELL_SIZE;
|
||||
|
||||
for (uint8_t i = 0; i < ship_size; i++) {
|
||||
uint16_t preview_x = placing_horizontal ? cursor_x + i : cursor_x;
|
||||
uint16_t preview_y = placing_horizontal ? cursor_y : cursor_y + i;
|
||||
uint16_t grid_x = (cell_x - 1) / CELL_SIZE;
|
||||
uint16_t grid_y = (cell_y - GRID_OFFSET_Y - 6) / CELL_SIZE;
|
||||
uint16_t preview_x = cursor_x + (i * dx);
|
||||
uint16_t preview_y = cursor_y + (i * dy);
|
||||
if (grid_x == preview_x && grid_y == preview_y && preview_x < GRID_SIZE && preview_y < GRID_SIZE) {
|
||||
return;
|
||||
}
|
||||
@@ -540,9 +507,12 @@ void BattleshipView::draw_ship_preview(Painter& painter) {
|
||||
uint8_t size = ship.size();
|
||||
bool can_place = can_place_ship(cursor_x, cursor_y, size, placing_horizontal);
|
||||
|
||||
uint8_t dx = placing_horizontal ? 1 : 0;
|
||||
uint8_t dy = placing_horizontal ? 0 : 1;
|
||||
|
||||
for (uint8_t i = 0; i < size; i++) {
|
||||
uint8_t x = placing_horizontal ? cursor_x + i : cursor_x;
|
||||
uint8_t y = placing_horizontal ? cursor_y : cursor_y + i;
|
||||
uint8_t x = cursor_x + (i * dx);
|
||||
uint8_t y = cursor_y + (i * dy);
|
||||
|
||||
if (x < GRID_SIZE && y < GRID_SIZE) {
|
||||
uint16_t cell_x = GRID_OFFSET_X + x * CELL_SIZE + 1;
|
||||
@@ -561,18 +531,21 @@ bool BattleshipView::can_place_ship(uint8_t x, uint8_t y, uint8_t size, bool hor
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t dx = horizontal ? 1 : 0;
|
||||
uint8_t dy = horizontal ? 0 : 1;
|
||||
|
||||
for (uint8_t i = 0; i < size; i++) {
|
||||
uint8_t check_x = horizontal ? x + i : x;
|
||||
uint8_t check_y = horizontal ? y : y + i;
|
||||
uint8_t check_x = x + (i * dx);
|
||||
uint8_t check_y = y + (i * dy);
|
||||
|
||||
if (my_grid[check_y][check_x] != CellState::EMPTY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int dy = -1; dy <= 1; dy++) {
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
int adj_x = check_x + dx;
|
||||
int adj_y = check_y + dy;
|
||||
for (int ddy = -1; ddy <= 1; ddy++) {
|
||||
for (int ddx = -1; ddx <= 1; ddx++) {
|
||||
int adj_x = check_x + ddx;
|
||||
int adj_y = check_y + ddy;
|
||||
|
||||
if (adj_x >= 0 && adj_x < GRID_SIZE &&
|
||||
adj_y >= 0 && adj_y < GRID_SIZE) {
|
||||
@@ -604,10 +577,11 @@ void BattleshipView::place_ship() {
|
||||
ship.horizontal = placing_horizontal;
|
||||
ship.placed = true;
|
||||
|
||||
uint8_t dx = placing_horizontal ? 1 : 0;
|
||||
uint8_t dy = placing_horizontal ? 0 : 1;
|
||||
|
||||
for (uint8_t i = 0; i < size; i++) {
|
||||
uint8_t x = placing_horizontal ? cursor_x + i : cursor_x;
|
||||
uint8_t y = placing_horizontal ? cursor_y : cursor_y + i;
|
||||
my_grid[y][x] = CellState::SHIP;
|
||||
my_grid[cursor_y + (i * dy)][cursor_x + (i * dx)] = CellState::SHIP;
|
||||
}
|
||||
|
||||
current_ship_index++;
|
||||
@@ -644,9 +618,14 @@ void BattleshipView::place_ship() {
|
||||
void BattleshipView::send_message(const GameMessage& msg) {
|
||||
static const char* msg_strings[] = {"READY", "SHOT:", "HIT:", "MISS:", "SUNK:", "WIN"};
|
||||
|
||||
std::string message = msg_strings[static_cast<int>(msg.type)];
|
||||
std::string message;
|
||||
message.reserve(16);
|
||||
message.append(msg_strings[static_cast<int>(msg.type)]);
|
||||
|
||||
if (msg.type != MessageType::READY && msg.type != MessageType::WIN) {
|
||||
message += to_string_dec_uint(msg.x) + "," + to_string_dec_uint(msg.y);
|
||||
message.append(to_string_dec_uint(msg.x));
|
||||
message.append(",");
|
||||
message.append(to_string_dec_uint(msg.y));
|
||||
}
|
||||
|
||||
configure_radio_tx();
|
||||
@@ -836,11 +815,12 @@ void BattleshipView::process_shot(uint8_t x, uint8_t y) {
|
||||
if (!ship.placed) continue;
|
||||
|
||||
bool hit_this_ship = false;
|
||||
for (uint8_t i = 0; i < ship.size(); i++) {
|
||||
uint8_t check_x = ship.horizontal ? ship.x + i : ship.x;
|
||||
uint8_t check_y = ship.horizontal ? ship.y : ship.y + i;
|
||||
|
||||
if (check_x == x && check_y == y) {
|
||||
uint8_t dx = ship.horizontal ? 1 : 0;
|
||||
uint8_t dy = ship.horizontal ? 0 : 1;
|
||||
|
||||
for (uint8_t i = 0; i < ship.size(); i++) {
|
||||
if ((ship.x + i * dx) == x && (ship.y + i * dy) == y) {
|
||||
hit_this_ship = true;
|
||||
ship.hits++;
|
||||
break;
|
||||
@@ -852,9 +832,7 @@ void BattleshipView::process_shot(uint8_t x, uint8_t y) {
|
||||
ships_remaining--;
|
||||
|
||||
for (uint8_t i = 0; i < ship.size(); i++) {
|
||||
uint8_t sunk_x = ship.horizontal ? ship.x + i : ship.x;
|
||||
uint8_t sunk_y = ship.horizontal ? ship.y : ship.y + i;
|
||||
my_grid[sunk_y][sunk_x] = CellState::SUNK;
|
||||
my_grid[ship.y + (i * dy)][ship.x + (i * dx)] = CellState::SUNK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -887,7 +865,12 @@ void BattleshipView::process_shot(uint8_t x, uint8_t y) {
|
||||
}
|
||||
|
||||
void BattleshipView::update_score() {
|
||||
current_score = "W:" + to_string_dec_uint(wins) + " L:" + to_string_dec_uint(losses);
|
||||
current_score.clear();
|
||||
current_score.reserve(16);
|
||||
current_score.append("W:");
|
||||
current_score.append(to_string_dec_uint(wins));
|
||||
current_score.append(" L:");
|
||||
current_score.append(to_string_dec_uint(losses));
|
||||
}
|
||||
|
||||
bool BattleshipView::on_touch(const TouchEvent event) {
|
||||
@@ -980,3 +963,4 @@ bool BattleshipView::on_key(const KeyEvent key) {
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::battleship
|
||||
#pragma GCC pop_options
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
#ifndef __UI_BATTLESHIP_H__
|
||||
#define __UI_BATTLESHIP_H__
|
||||
|
||||
#include "portapack_shared_memory.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "modems.hpp"
|
||||
#include "bch_code.hpp"
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ __attribute__((section(".external_app.app_blackjack.application_information"), u
|
||||
0x80, 0x01, // .......##.......
|
||||
0x00, 0x00, // ................
|
||||
},
|
||||
ui::Color::red().v, // Red color for diamonds
|
||||
ui::Color::green().v, // Red color for diamonds
|
||||
app_location_t::GAMES,
|
||||
-1,
|
||||
|
||||
|
||||
+66
-4
@@ -294,11 +294,11 @@ void BLESpamView::createWindowsPacket() {
|
||||
std::copy(res.begin(), res.end(), advertisementData);
|
||||
}
|
||||
|
||||
void BLESpamView::createNameSpamPacket() {
|
||||
const char* names[] = {"PortaHack", "PwnBt", "iSpam", "GenericFoodVagon", "SignalSnoop", "ByteBandit", "RadioRogue", "RadioRebel", "ByteBlast"};
|
||||
|
||||
const char* name = names[rand() % 9]; //"PortaHack";
|
||||
// Builds a "Complete Local Name" HID advertisement for the given name.
|
||||
// Shared by NameSpam (built-in list) and Custom (SD card list) modes.
|
||||
void BLESpamView::buildNamePacket(const char* name) {
|
||||
uint8_t name_len = strlen(name);
|
||||
if (name_len > 19) name_len = 19; // clamp so the hex string fits advertisementData[63]
|
||||
|
||||
uint8_t size = 12 + name_len;
|
||||
uint8_t i = 0;
|
||||
@@ -327,6 +327,65 @@ void BLESpamView::createNameSpamPacket() {
|
||||
std::copy(res.begin(), res.end(), advertisementData);
|
||||
}
|
||||
|
||||
void BLESpamView::createNameSpamPacket() {
|
||||
const char* names[] = {"PortaHack", "PwnBt", "iSpam", "GenericFoodVagon", "SignalSnoop", "ByteBandit", "RadioRogue", "RadioRebel", "ByteBlast"};
|
||||
buildNamePacket(names[rand() % 9]);
|
||||
}
|
||||
|
||||
// Opens /BLESPAM/NAME.txt once and keeps it open for the session.
|
||||
void BLESpamView::open_custom_file() {
|
||||
custom_loaded_ = true; // attempt only once
|
||||
auto open_error = custom_file_.open(u"/BLESPAM/NAME.txt");
|
||||
custom_file_valid_ = !open_error; // false -> caller falls back to NameSpam
|
||||
}
|
||||
|
||||
// Reads the next line into custom_name_ (clamped to 19 chars), advancing the
|
||||
// file position. At end of file it seeks back to the start to cycle. Returns
|
||||
// false if the file holds no usable name. Only one line is ever held in RAM.
|
||||
bool BLESpamView::read_next_custom_name() {
|
||||
if (!custom_file_valid_) return false;
|
||||
|
||||
custom_name_.clear();
|
||||
bool wrapped = false;
|
||||
char c;
|
||||
|
||||
while (true) {
|
||||
auto read_result = custom_file_.read(&c, 1);
|
||||
if (read_result.is_error()) return false;
|
||||
|
||||
if (read_result.value() == 0) {
|
||||
// end of file
|
||||
if (!custom_name_.empty()) break;
|
||||
// use the final line
|
||||
if (wrapped) return false;
|
||||
// no usable name in file
|
||||
if (custom_file_.seek(0).is_error()) return false;
|
||||
// loop back to the first line
|
||||
wrapped = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '\n' || c == '\r') {
|
||||
if (!custom_name_.empty()) break; // got a complete line
|
||||
continue; // skip blank lines / CRLF pairs
|
||||
}
|
||||
|
||||
if (custom_name_.size() < 19) // clamp; keep scanning rest of long line
|
||||
custom_name_.push_back(c);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BLESpamView::createCustomPacket() {
|
||||
if (!custom_loaded_) open_custom_file();
|
||||
|
||||
if (!read_next_custom_name()) { // no file / unreadable / empty -> fall back
|
||||
createNameSpamPacket();
|
||||
return;
|
||||
}
|
||||
buildNamePacket(custom_name_.c_str());
|
||||
}
|
||||
|
||||
char BLESpamView::randomNameChar() {
|
||||
int randVal = rand() % 62; // 26 uppercase + 26 lowercase + 10 digits
|
||||
if (randVal < 26) {
|
||||
@@ -622,6 +681,9 @@ void BLESpamView::createPacket(ATK_TYPE attackType) {
|
||||
case ATK_NAMERANDOM:
|
||||
createNameRandomPacket();
|
||||
break;
|
||||
case ATK_CUSTOM:
|
||||
createCustomPacket();
|
||||
break;
|
||||
case ATK_ALL_SAFE:
|
||||
createAnyPacket(true);
|
||||
break;
|
||||
|
||||
+14
-2
@@ -39,6 +39,7 @@
|
||||
#include "radio_state.hpp"
|
||||
#include "log_file.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "file.hpp"
|
||||
|
||||
using namespace ui;
|
||||
|
||||
@@ -52,6 +53,7 @@ enum ATK_TYPE {
|
||||
ATK_SAMSUNG,
|
||||
ATK_NAMESPAM,
|
||||
ATK_NAMERANDOM,
|
||||
ATK_CUSTOM,
|
||||
ATK_ALL_SAFE,
|
||||
ATK_ALL
|
||||
};
|
||||
@@ -131,8 +133,9 @@ class BLESpamView : public View {
|
||||
{"Samsung", 4},
|
||||
{"NameSpam", 5},
|
||||
{"NameRandom", 6},
|
||||
{"All-Safe", 7},
|
||||
{"All", 8}}};
|
||||
{"NameCustom", 7},
|
||||
{"All-Safe", 8},
|
||||
{"All", 9}}};
|
||||
|
||||
bool is_running{false};
|
||||
|
||||
@@ -144,6 +147,11 @@ class BLESpamView : public View {
|
||||
bool randomMac{true};
|
||||
bool randomDev{true};
|
||||
|
||||
File custom_file_{}; // kept open while in Custom mode
|
||||
std::string custom_name_{}; // holds only the current name (clamped)
|
||||
bool custom_loaded_{false}; // true once an open attempt has been made
|
||||
bool custom_file_valid_{false}; // true if /BLESPAM/NAME.txt opened successfully
|
||||
|
||||
uint8_t channel_number = 37;
|
||||
char mac[13] = "010203040407";
|
||||
char advertisementData[63] = {"03032CFE06162CFED5A59E020AB4\0"};
|
||||
@@ -156,7 +164,11 @@ class BLESpamView : public View {
|
||||
void createIosPacket(bool crash);
|
||||
void createSamsungPacket();
|
||||
void createWindowsPacket();
|
||||
void buildNamePacket(const char* name); // shared name advertisement builder (NameSpam / Custom)
|
||||
void createNameSpamPacket();
|
||||
void createCustomPacket();
|
||||
void open_custom_file(); // open /BLESPAM/NAME.txt once (one name per line)
|
||||
bool read_next_custom_name(); // read next line into custom_name_, looping at EOF
|
||||
void createNameRandomPacket();
|
||||
void createAnyPacket(bool safe);
|
||||
void createPacket(ATK_TYPE attackType);
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ __attribute__((section(".external_app.app_cvs_spam.application_information"), us
|
||||
|
||||
/*.app_name = */ "CVS Spam",
|
||||
/*.bitmap_data = */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81},
|
||||
/*.icon_color = */ ui::Color::red().v,
|
||||
/*.icon_color = */ ui::Color::yellow().v,
|
||||
/*.menu_location = */ app_location_t::TX,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ __attribute__((section(".external_app.app_detector_rx.application_information"),
|
||||
0x0C,
|
||||
0xF0,
|
||||
0x0F},
|
||||
/*.icon_color = */ ui::Color::orange().v,
|
||||
/*.icon_color = */ ui::Color::yellow().v,
|
||||
/*.menu_location = */ app_location_t::RX,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
|
||||
+177
-46
@@ -26,6 +26,7 @@
|
||||
#include "ui_freqman.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
#include "file.hpp"
|
||||
#include "file_path.hpp"
|
||||
#include "oversample.hpp"
|
||||
#include "ui_font_fixed_8x16.hpp"
|
||||
|
||||
@@ -35,36 +36,112 @@ using portapack::memory::map::backup_ram;
|
||||
|
||||
namespace ui::external_app::detector_rx {
|
||||
|
||||
// Function to map the value from one range to another
|
||||
int32_t DetectorRxView::map(int32_t value, int32_t fromLow, int32_t fromHigh, int32_t toLow, int32_t toHigh) {
|
||||
return toLow + (value - fromLow) * (toHigh - toLow) / (fromHigh - fromLow);
|
||||
}
|
||||
|
||||
void DetectorRxView::focus() {
|
||||
field_lna.focus();
|
||||
button_index.focus();
|
||||
}
|
||||
|
||||
DetectorRxView::~DetectorRxView() {
|
||||
// reset performance counters request to default
|
||||
shared_memory.request_m4_performance_counter = 0;
|
||||
receiver_model.disable();
|
||||
audio::output::stop();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
void DetectorRxView::on_timer() {
|
||||
freq_index++;
|
||||
if (freq_mode == 0 && freq_index >= tetra_uplink_monitoring_frequencies_hz.size()) freq_index = 0; // TETRA UP
|
||||
if (freq_mode == 1 && freq_index >= lora_monitoring_frequencies_hz.size()) freq_index = 0; // Lora
|
||||
if (freq_mode == 2 && freq_index >= remotes_monitoring_frequencies_hz.size()) freq_index = 0; // Remotes
|
||||
std::string DetectorRxView::format_freq_mhz(int64_t freq_hz) {
|
||||
int64_t mhz = freq_hz / 1000000;
|
||||
int64_t khz_frac = (freq_hz % 1000000) / 1000;
|
||||
return "< " + to_string_dec_uint(mhz) + "." + to_string_dec_uint(khz_frac, 3, '0') + " MHz >";
|
||||
}
|
||||
|
||||
if (freq_mode == 2)
|
||||
freq_ = remotes_monitoring_frequencies_hz[freq_index];
|
||||
else if (freq_mode == 1)
|
||||
freq_ = lora_monitoring_frequencies_hz[freq_index];
|
||||
else
|
||||
freq_ = tetra_uplink_monitoring_frequencies_hz[freq_index];
|
||||
receiver_model.set_target_frequency(freq_);
|
||||
void DetectorRxView::load_freqman() {
|
||||
freqman_load_options options{};
|
||||
options.load_freqs = true;
|
||||
options.load_ranges = true;
|
||||
options.load_hamradios = false;
|
||||
options.load_repeaters = false;
|
||||
|
||||
if (!load_freqman_file(freq_file_stem, frequency_list, options) || frequency_list.empty()) {
|
||||
button_file.set_text("No file!");
|
||||
button_index.set_text("");
|
||||
text_entry_desc.set("");
|
||||
button_freq.set_text("");
|
||||
frequency_list.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
current_index = 0;
|
||||
init_current_entry();
|
||||
button_file.set_text(freq_file_stem);
|
||||
}
|
||||
|
||||
void DetectorRxView::init_current_entry() {
|
||||
if (frequency_list.empty()) return;
|
||||
|
||||
auto& entry = *frequency_list[current_index];
|
||||
if (entry.type == freqman_type::Range) {
|
||||
minfreq = entry.frequency_a;
|
||||
maxfreq = entry.frequency_b;
|
||||
current_freq = minfreq;
|
||||
current_step = is_valid(entry.step) ? freqman_entry_get_step_value(entry.step) : DETECTOR_BW;
|
||||
} else {
|
||||
current_freq = entry.frequency_a;
|
||||
minfreq = current_freq;
|
||||
maxfreq = current_freq;
|
||||
current_step = DETECTOR_BW;
|
||||
}
|
||||
|
||||
update_entry_display();
|
||||
update_freq_display();
|
||||
receiver_model.set_target_frequency(current_freq);
|
||||
}
|
||||
|
||||
void DetectorRxView::update_entry_display() {
|
||||
if (frequency_list.empty()) return;
|
||||
|
||||
auto& entry = *frequency_list[current_index];
|
||||
button_index.set_text(
|
||||
to_string_dec_uint(current_index + 1) + "/" +
|
||||
to_string_dec_uint(frequency_list.size()));
|
||||
text_entry_desc.set(entry.description);
|
||||
}
|
||||
|
||||
void DetectorRxView::update_freq_display() {
|
||||
if (auto_scan && (minfreq != maxfreq)) {
|
||||
if (last_update_was_auto_range_type != 1) {
|
||||
button_freq.set_text("RANGE SCAN...");
|
||||
last_update_was_auto_range_type = 1;
|
||||
}
|
||||
} else {
|
||||
button_freq.set_text(format_freq_mhz(current_freq));
|
||||
last_update_was_auto_range_type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DetectorRxView::on_timer() {
|
||||
if (frequency_list.empty() || !auto_scan) return;
|
||||
|
||||
auto& entry = *frequency_list[current_index];
|
||||
if (entry.type == freqman_type::Range) {
|
||||
current_freq += current_step;
|
||||
if (current_freq > maxfreq) {
|
||||
if (auto_advance) {
|
||||
current_index = (current_index + 1) % frequency_list.size();
|
||||
init_current_entry();
|
||||
return;
|
||||
}
|
||||
current_freq = minfreq;
|
||||
}
|
||||
receiver_model.set_target_frequency(current_freq);
|
||||
update_freq_display();
|
||||
} else if (auto_advance) {
|
||||
// Single frequency: advance to next entry
|
||||
current_index = (current_index + 1) % frequency_list.size();
|
||||
init_current_entry();
|
||||
}
|
||||
}
|
||||
|
||||
DetectorRxView::DetectorRxView(NavigationView& nav)
|
||||
@@ -75,21 +152,22 @@ DetectorRxView::DetectorRxView(NavigationView& nav)
|
||||
&field_vga,
|
||||
&field_rf_amp,
|
||||
&field_volume,
|
||||
&text_frequency,
|
||||
&freq_stats_rssi,
|
||||
&freq_stats_db,
|
||||
&button_file,
|
||||
&button_index,
|
||||
&text_entry_desc,
|
||||
&text_beep_squelch,
|
||||
&field_beep_squelch,
|
||||
&freq_stats_db,
|
||||
&freq_stats_rssi,
|
||||
&button_freq,
|
||||
&button_auto_scan,
|
||||
&button_auto_advance,
|
||||
&rssi,
|
||||
&rssi_graph,
|
||||
&field_mode,
|
||||
});
|
||||
|
||||
// activate vertical bar mode
|
||||
rssi.set_vertical_rssi(true);
|
||||
|
||||
freq_ = receiver_model.target_frequency();
|
||||
|
||||
field_beep_squelch.set_value(beep_squelch);
|
||||
field_beep_squelch.on_change = [this](int32_t v) {
|
||||
beep_squelch = v;
|
||||
@@ -97,29 +175,85 @@ DetectorRxView::DetectorRxView(NavigationView& nav)
|
||||
|
||||
rssi_graph.set_nb_columns(256);
|
||||
|
||||
// FILE button opens file picker
|
||||
button_file.on_select = [this](Button&) {
|
||||
auto open_view = nav_.push<FileLoadView>(".TXT");
|
||||
open_view->push_dir(freqman_dir);
|
||||
open_view->on_changed = [this](std::filesystem::path new_file_path) {
|
||||
if (new_file_path.native().find((u"/" / freqman_dir).native()) != 0) {
|
||||
button_file.set_text("Invalid file");
|
||||
return;
|
||||
}
|
||||
freq_file_stem = new_file_path.stem().string();
|
||||
load_freqman();
|
||||
};
|
||||
};
|
||||
|
||||
// Index encoder: rotate to change entry, click does nothing
|
||||
button_index.on_change = [this]() {
|
||||
if (frequency_list.empty()) return;
|
||||
int32_t delta = button_index.get_encoder_delta();
|
||||
button_index.set_encoder_delta(0);
|
||||
if (delta == 0) return;
|
||||
|
||||
// Use signed arithmetic for index wraparound to avoid unsigned promotion issues.
|
||||
const int32_t list_size = static_cast<int32_t>(frequency_list.size());
|
||||
int32_t idx = static_cast<int32_t>(current_index);
|
||||
if (delta > 0) {
|
||||
idx = (idx + 1) % list_size;
|
||||
} else {
|
||||
idx = (idx - 1 + list_size) % list_size;
|
||||
}
|
||||
current_index = static_cast<size_t>(idx);
|
||||
init_current_entry();
|
||||
};
|
||||
|
||||
// Frequency encoder: rotate to step within range
|
||||
button_freq.on_change = [this]() {
|
||||
if (frequency_list.empty()) return;
|
||||
auto& entry = *frequency_list[current_index];
|
||||
if (entry.type != freqman_type::Range) {
|
||||
button_freq.set_encoder_delta(0);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t delta = button_freq.get_encoder_delta();
|
||||
button_freq.set_encoder_delta(0);
|
||||
if (delta == 0) return;
|
||||
|
||||
if (delta > 0) {
|
||||
current_freq += current_step;
|
||||
if (current_freq > maxfreq) current_freq = minfreq;
|
||||
} else {
|
||||
current_freq -= current_step;
|
||||
if (current_freq < minfreq) current_freq = maxfreq;
|
||||
}
|
||||
receiver_model.set_target_frequency(current_freq);
|
||||
update_freq_display();
|
||||
};
|
||||
|
||||
// Auto-scan toggle
|
||||
button_auto_scan.on_select = [this](Button&) {
|
||||
auto_scan = !auto_scan;
|
||||
button_auto_scan.set_text(auto_scan ? "AUTOSCAN" : "NO SCAN");
|
||||
update_freq_display();
|
||||
};
|
||||
button_auto_scan.set_text(auto_scan ? "AUTOSCAN" : "NO SCAN");
|
||||
|
||||
// Auto-advance toggle
|
||||
button_auto_advance.on_select = [this](Button&) {
|
||||
auto_advance = !auto_advance;
|
||||
button_auto_advance.set_text(auto_advance ? "AUTOADV" : "NO ADV");
|
||||
};
|
||||
button_auto_advance.set_text(auto_advance ? "AUTOADV" : "NO ADV");
|
||||
|
||||
change_mode();
|
||||
rssi.set_peak(true, 3000);
|
||||
|
||||
// FILL STEP OPTIONS
|
||||
freq_stats_rssi.set_style(Theme::getInstance()->bg_darkest);
|
||||
freq_stats_db.set_style(Theme::getInstance()->bg_darkest);
|
||||
|
||||
field_mode.on_change = [this](size_t, int32_t value) {
|
||||
freq_mode = value;
|
||||
freq_index = 0;
|
||||
switch (value) {
|
||||
case 1: // Lora
|
||||
text_frequency.set(" 433, 868, 915 Mhz");
|
||||
break;
|
||||
case 2: // Remotes
|
||||
text_frequency.set(" 433, 315 Mhz");
|
||||
break;
|
||||
default:
|
||||
case 0: // TETRA UP
|
||||
text_frequency.set(" 380-390 Mhz");
|
||||
break;
|
||||
}
|
||||
};
|
||||
load_freqman();
|
||||
}
|
||||
|
||||
void DetectorRxView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
@@ -130,25 +264,23 @@ void DetectorRxView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
|
||||
rssi_graph.add_values(rssi.get_min(), rssi.get_avg(), rssi.get_max(), statistics.max_db);
|
||||
|
||||
// refresh db
|
||||
if (last_max_db != statistics.max_db) {
|
||||
last_max_db = statistics.max_db;
|
||||
freq_stats_db.set("Power: " + to_string_dec_int(statistics.max_db) + " db");
|
||||
rssi.set_db(statistics.max_db);
|
||||
}
|
||||
// refresh rssi
|
||||
|
||||
if (last_min_rssi != rssi_graph.get_graph_min() || last_avg_rssi != rssi_graph.get_graph_avg() || last_max_rssi != rssi_graph.get_graph_max()) {
|
||||
last_min_rssi = rssi_graph.get_graph_min();
|
||||
last_avg_rssi = rssi_graph.get_graph_avg();
|
||||
last_max_rssi = rssi_graph.get_graph_max();
|
||||
freq_stats_rssi.set("RSSI: " + to_string_dec_uint(last_min_rssi) + "/" + to_string_dec_uint(last_avg_rssi) + "/" + to_string_dec_uint(last_max_rssi));
|
||||
freq_stats_rssi.set("RSSI:" + to_string_dec_uint(last_min_rssi) + "/" + to_string_dec_uint(last_avg_rssi) + "/" + to_string_dec_uint(last_max_rssi));
|
||||
}
|
||||
|
||||
if (statistics.max_db > beep_squelch) {
|
||||
baseband::request_audio_beep(map(statistics.max_db, -100, 20, 400, 2600), 24000, 150);
|
||||
}
|
||||
|
||||
} /* on_statistic_updates */
|
||||
}
|
||||
|
||||
size_t DetectorRxView::change_mode() {
|
||||
audio::output::stop();
|
||||
@@ -160,14 +292,13 @@ size_t DetectorRxView::change_mode() {
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::Capture);
|
||||
|
||||
baseband::set_sample_rate(DETECTOR_BW, get_oversample_rate(DETECTOR_BW));
|
||||
// The radio needs to know the effective sampling rate.
|
||||
auto actual_sampling_rate = get_actual_sample_rate(DETECTOR_BW);
|
||||
receiver_model.set_sampling_rate(actual_sampling_rate);
|
||||
receiver_model.set_baseband_bandwidth(filter_bandwidth_for_sampling_rate(actual_sampling_rate));
|
||||
|
||||
audio::set_rate(audio_sampling_rate);
|
||||
audio::output::start();
|
||||
receiver_model.set_headphone_volume(receiver_model.headphone_volume()); // WM8731 hack.
|
||||
receiver_model.set_headphone_volume(receiver_model.headphone_volume());
|
||||
|
||||
receiver_model.enable();
|
||||
|
||||
|
||||
+53
-72
@@ -29,6 +29,7 @@
|
||||
#include "audio.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
#include "file.hpp"
|
||||
#include "freqman.hpp"
|
||||
#include "freqman_db.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
#include "radio_state.hpp"
|
||||
@@ -60,20 +61,35 @@ class DetectorRxView : public View {
|
||||
int32_t map(int32_t value, int32_t fromLow, int32_t fromHigh, int32_t toLow, int32_t toHigh);
|
||||
size_t change_mode();
|
||||
void on_statistics_update(const ChannelStatistics& statistics);
|
||||
void set_display_freq(int64_t freq);
|
||||
void on_timer();
|
||||
void load_freqman();
|
||||
void init_current_entry();
|
||||
void update_entry_display();
|
||||
void update_freq_display();
|
||||
std::string format_freq_mhz(int64_t freq_hz);
|
||||
|
||||
freqman_db frequency_list{};
|
||||
size_t current_index{0};
|
||||
int64_t current_freq{0};
|
||||
int64_t minfreq{0};
|
||||
int64_t maxfreq{0};
|
||||
int32_t current_step{DETECTOR_BW};
|
||||
std::string freq_file_stem{"DETECTOR"};
|
||||
bool auto_scan{true};
|
||||
bool auto_advance{false};
|
||||
uint8_t last_update_was_auto_range_type = -1;
|
||||
|
||||
uint8_t freq_index = 0;
|
||||
rf::Frequency freq_ = {433920000};
|
||||
int32_t beep_squelch = 0;
|
||||
audio::Rate audio_sampling_rate = audio::Rate::Hz_48000;
|
||||
uint8_t freq_mode = 0;
|
||||
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_detector",
|
||||
app_settings::Mode::RX,
|
||||
{
|
||||
{"beep_squelch"sv, &beep_squelch},
|
||||
{"freq_file"sv, &freq_file_stem},
|
||||
{"auto_scan"sv, &auto_scan},
|
||||
{"auto_advance"sv, &auto_advance},
|
||||
}};
|
||||
|
||||
Labels labels{
|
||||
@@ -93,41 +109,55 @@ class DetectorRxView : public View {
|
||||
AudioVolumeField field_volume{
|
||||
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||
|
||||
OptionsField field_mode{
|
||||
{UI_POS_X(0), UI_POS_Y(1)},
|
||||
9,
|
||||
{
|
||||
{"TETRA UP", 0},
|
||||
{"Lora", 1},
|
||||
{"Remotes", 2},
|
||||
}};
|
||||
// Row 1: filename + auto advance
|
||||
Button button_file{
|
||||
{UI_POS_X(0), UI_POS_Y(1), UI_POS_WIDTH(20), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
|
||||
Text text_frequency{
|
||||
{UI_POS_X_RIGHT(20), UI_POS_Y(1), UI_POS_WIDTH(20), UI_POS_DEFAULT_HEIGHT},
|
||||
Button button_auto_advance{
|
||||
{UI_POS_X_RIGHT(9), UI_POS_Y(1), UI_POS_WIDTH(9), UI_POS_DEFAULT_HEIGHT},
|
||||
"NO ADV"};
|
||||
|
||||
// Row 2: index encoder + description + auto scan
|
||||
ButtonWithEncoder button_index{
|
||||
{UI_POS_X(0), UI_POS_Y(2), UI_POS_WIDTH(4), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
|
||||
Text text_entry_desc{
|
||||
{UI_POS_X(4), UI_POS_Y(2), UI_POS_WIDTH(17), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
|
||||
Button button_auto_scan{
|
||||
{UI_POS_X_RIGHT(9), UI_POS_Y(2), UI_POS_WIDTH(9), UI_POS_DEFAULT_HEIGHT},
|
||||
"AUTO SCAN"};
|
||||
|
||||
// Row 3: frequency encoder + bip level
|
||||
ButtonWithEncoder button_freq{
|
||||
{UI_POS_X(0), UI_POS_Y(3), UI_POS_WIDTH(20), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
|
||||
Text text_beep_squelch{
|
||||
{UI_POS_X_RIGHT(9), UI_POS_Y(2), UI_POS_WIDTH(4), UI_POS_DEFAULT_HEIGHT},
|
||||
{UI_POS_X_RIGHT(9), UI_POS_Y(3), UI_POS_WIDTH(4), UI_POS_DEFAULT_HEIGHT},
|
||||
"Bip>"};
|
||||
|
||||
NumberField field_beep_squelch{
|
||||
{UI_POS_X_RIGHT(5), UI_POS_Y(2)},
|
||||
{UI_POS_X_RIGHT(5), UI_POS_Y(3)},
|
||||
4,
|
||||
{-100, 20},
|
||||
1,
|
||||
' ',
|
||||
};
|
||||
|
||||
// RSSI: XX/XX/XXX
|
||||
Text freq_stats_rssi{
|
||||
{UI_POS_X(0), UI_POS_Y(2), UI_POS_WIDTH(15), UI_POS_DEFAULT_HEIGHT},
|
||||
};
|
||||
|
||||
// Power: -XXX db
|
||||
// Row 4: Power + RSSI on same line
|
||||
Text freq_stats_db{
|
||||
{UI_POS_X(0), UI_POS_Y(3), UI_POS_WIDTH(15), UI_POS_DEFAULT_HEIGHT},
|
||||
{UI_POS_X(0), UI_POS_Y(4), UI_POS_WIDTH(15), UI_POS_DEFAULT_HEIGHT},
|
||||
};
|
||||
|
||||
Text freq_stats_rssi{
|
||||
{UI_POS_X(15), UI_POS_Y(4), UI_POS_WIDTH(15), UI_POS_DEFAULT_HEIGHT},
|
||||
};
|
||||
|
||||
// Row 5+: RSSI graph + vertical bar
|
||||
RSSIGraph rssi_graph{
|
||||
{UI_POS_X(0), UI_POS_Y(5), UI_POS_WIDTH_REMAINING(5), UI_POS_HEIGHT_REMAINING(6)},
|
||||
};
|
||||
@@ -147,55 +177,6 @@ class DetectorRxView : public View {
|
||||
[this](const Message* const) {
|
||||
this->on_timer();
|
||||
}};
|
||||
|
||||
const std::vector<uint32_t> remotes_monitoring_frequencies_hz = {
|
||||
// Around 315 MHz (common for older remotes, key fobs in some regions)
|
||||
// Window centered on 315 MHz, covers 314.625 - 315.375 MHz
|
||||
315000000,
|
||||
|
||||
// Around 433.92 MHz (very common for remotes, sensors, key fobs globally)
|
||||
// Window centered on 433.92 MHz, covers 433.545 - 434.295 MHz
|
||||
433920000,
|
||||
};
|
||||
const std::vector<uint32_t> lora_monitoring_frequencies_hz = {
|
||||
// EU433 Band (Europe, typically 433.05 MHz to 434.79 MHz)
|
||||
// Scanning the approximate range 433.0 MHz to 434.8 MHz with 750kHz steps
|
||||
433375000, // Covers 433.000 - 433.750 MHz
|
||||
434125000, // Covers 433.750 - 434.500 MHz (includes 433.92 MHz)
|
||||
434875000, // Covers 434.500 - 435.250 MHz (covers up to 434.79 MHz)
|
||||
|
||||
// EU868 Band (Europe, typically 863 MHz to 870 MHz, specific channels around 868 MHz)
|
||||
// Targeting common LoRaWAN channel groups (approx 867.0 - 868.6 MHz) with 750kHz steps
|
||||
867375000, // Covers 867.000 - 867.750 MHz
|
||||
868125000, // Covers 867.750 - 868.500 MHz
|
||||
868875000, // Covers 868.500 - 869.250 MHz (covers up to 868.6 MHz)
|
||||
|
||||
// US915 Band (North America, typically 902 MHz to 928 MHz, specific channels around 915 MHz)
|
||||
// Providing a few sample windows around the 915 MHz area with 750kHz steps.
|
||||
// This band is wide; a full scan would require many more frequencies.
|
||||
914250000, // Covers 913.875 - 914.625 MHz
|
||||
915000000, // Covers 914.625 - 915.375 MHz (Centered on 915 MHz)
|
||||
915750000, // Covers 915.375 - 916.125 MHz
|
||||
};
|
||||
const std::vector<uint32_t> tetra_uplink_monitoring_frequencies_hz = {
|
||||
// Band starts at 380,000,000 Hz, ends at 390,000,000 Hz.
|
||||
// First center: 380,000,000 + 375,000 = 380,375,000 Hz
|
||||
// Last center: 380,375,000 + 13 * 750,000 = 390,125,000 Hz (14 frequencies total for this band)
|
||||
380375000, // Covers 380.000 - 380.750 MHz
|
||||
381125000, // Covers 380.750 - 381.500 MHz
|
||||
381875000, // Covers 381.500 - 382.250 MHz
|
||||
382625000, // Covers 382.250 - 383.000 MHz
|
||||
383375000, // Covers 383.000 - 383.750 MHz
|
||||
384125000, // Covers 383.750 - 384.500 MHz
|
||||
384875000, // Covers 384.500 - 385.250 MHz
|
||||
385625000, // Covers 385.250 - 386.000 MHz
|
||||
386375000, // Covers 386.000 - 386.750 MHz
|
||||
387125000, // Covers 386.750 - 387.500 MHz
|
||||
387875000, // Covers 387.500 - 388.250 MHz
|
||||
388625000, // Covers 388.250 - 389.000 MHz
|
||||
389375000, // Covers 389.000 - 389.750 MHz
|
||||
390125000, // Covers 389.750 - 390.500 MHz
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::detector_rx
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ __attribute__((section(".external_app.app_doom.application_information"), used))
|
||||
0x00,
|
||||
0x00,
|
||||
},
|
||||
ui::Color::red().v,
|
||||
ui::Color::green().v,
|
||||
app_location_t::GAMES,
|
||||
-1,
|
||||
{0, 0, 0, 0},
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "beacon.hpp"
|
||||
#include <cstdio>
|
||||
#include "string_format.hpp"
|
||||
|
||||
// Some but not all methods of beacon class have been externalized in .cpp file
|
||||
// This has been done to try and optimize application size by preventing the compiler to inline methods
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
size_t Beacon::formatSummary(char* buffer, bool with_time) {
|
||||
size_t result = 0;
|
||||
if (with_time) {
|
||||
result += formatTime(buffer);
|
||||
buffer[result++] = '-';
|
||||
}
|
||||
result += sprintf((buffer + result), "%4s-%5s-", shortId().c_str(), getType());
|
||||
if (location.isUnknown()) {
|
||||
result += sprintf((buffer + result), " ");
|
||||
} else {
|
||||
result += location.toString((buffer + result), Location::LocationFormat::MAIDENHEAD_LOCATOR);
|
||||
}
|
||||
result += sprintf((buffer + result), "[%s%s%s]", isFrameValid() ? (bch1Corrected || bch2Corrected) ? STR_COLOR_YELLOW : STR_COLOR_GREEN : STR_COLOR_RED, getSatus().c_str(), STR_COLOR_WHITE);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Beacon::isFrameValid() {
|
||||
return isBch1Valid() && ((!hasBch2) || isBch2Valid()) && (!isEmpty);
|
||||
}
|
||||
|
||||
std::string Beacon::shortId() {
|
||||
std::string result = std::string(hexId);
|
||||
return (result.size() >= 4) ? result.substr(0, 4) : result;
|
||||
}
|
||||
|
||||
size_t Beacon::formatTime(char* buffer) {
|
||||
return sprintf(buffer, "%02d:%02d:%02d", date.hour(), date.minute(), date.second());
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
+856
@@ -0,0 +1,856 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __BEACON_RX_H__
|
||||
#define __BEACON_RX_H__
|
||||
|
||||
#include "country.hpp"
|
||||
#include "location.hpp"
|
||||
#include "rtc_time.hpp"
|
||||
#include "resources.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
// Size for beacon frame buffer
|
||||
#define BEACON_DATA_SIZE 18 // Max 144 bits => 18 bytes
|
||||
|
||||
// Constants for BCH control code calculation
|
||||
#define BCH_21_POLYNOMIAL 0b1001101101100111100011UL
|
||||
#define BCH_21_POLY_LENGTH 22
|
||||
#define BCH_12_POLYNOMIAL 0b1010100111001UL
|
||||
#define BCH_12_POLY_LENGTH 13
|
||||
|
||||
// See content of sdcard/EPIRB/RES/BEACON.RES
|
||||
#define ADDITIONAL_DATA_RESOURCE_START 25
|
||||
#define LONG_ADDITIONAL_DATA_RESOURCE_START 33
|
||||
#define EMERGENCY_RESOURCE_START 39
|
||||
#define EMERGENCY_OTHER_RESOURCE_START 49
|
||||
#define AUX_DEVICE_RESOURCE_START 53
|
||||
|
||||
/**
|
||||
* This is the main class for beaon handling
|
||||
*/
|
||||
class Beacon {
|
||||
public:
|
||||
// Real beacon or test beacon ?
|
||||
enum class FrameMode { NORMAL,
|
||||
SELF_TEST,
|
||||
UNKNOWN };
|
||||
// Type of main location device
|
||||
enum class MainLocatingDevice { UNDEFINED,
|
||||
INTERNAL_NAV,
|
||||
EXTERNAL_NAV };
|
||||
// Type of aux location device
|
||||
enum class AuxLocatingDevice { UNDEFINED,
|
||||
NONE,
|
||||
NONE_OR_OTHER,
|
||||
OTHER,
|
||||
MHZ121_5,
|
||||
SART };
|
||||
|
||||
// Protcol type
|
||||
enum class ProtocolType {
|
||||
UNKNOWN,
|
||||
USER,
|
||||
STANDARD_LOCATION,
|
||||
NATIONAL_LOCATION,
|
||||
RLS_LOCATION,
|
||||
ELT_DT_LOCATION,
|
||||
SPARE
|
||||
};
|
||||
|
||||
// Protocol
|
||||
enum class Protocol {
|
||||
USER_EPIRB_MARITIME,
|
||||
USER_EPIRB_RADIO,
|
||||
USER_ELT,
|
||||
USER_SERIAL,
|
||||
USER_TEST,
|
||||
USER_ORB,
|
||||
USER_NAT,
|
||||
USER_2G,
|
||||
STD_EPIRB,
|
||||
STD_ELT_24,
|
||||
STD_ELT_SERIAL,
|
||||
STD_ELT_AIRCRAFT,
|
||||
STD_EPIRB_SERIAL,
|
||||
STD_PLB_SERIAL,
|
||||
STD_SHIP,
|
||||
STD_TEST,
|
||||
NAT_ELT,
|
||||
NAT_EPIRB,
|
||||
NAT_PLB,
|
||||
NAT_TEST,
|
||||
RLS,
|
||||
ELT_DT,
|
||||
SPARE,
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
#define UNKNOWN_LABEL "Unk."
|
||||
|
||||
// Returns true for User protocol beacons
|
||||
bool protocolIsUser() { return (protocolType == ProtocolType::USER); };
|
||||
// Returns true for National Location protocol beacons
|
||||
bool protocolIsNational() { return (protocolType == ProtocolType::NATIONAL_LOCATION); };
|
||||
// Returns true for Standard Location protocol beacons
|
||||
bool protocolIsStandard() { return (protocolType == ProtocolType::STANDARD_LOCATION); };
|
||||
// Returns true for RLS location protocol beacons
|
||||
bool protocolIsRls() { return (protocolType == ProtocolType::RLS_LOCATION); };
|
||||
// Returns true for RLS or ELT Location protocol beacons
|
||||
bool protocolIsRlsOrElt() { return (protocolType == ProtocolType::RLS_LOCATION || protocolType == ProtocolType::ELT_DT_LOCATION); };
|
||||
// Returns true for unknown protocol beacons
|
||||
bool protocolIsUnknown() { return (protocolType == ProtocolType::UNKNOWN); };
|
||||
|
||||
// Returns the protocol name
|
||||
const char* getProtocolName() {
|
||||
switch (protocolType) {
|
||||
case ProtocolType::STANDARD_LOCATION:
|
||||
return "Standard";
|
||||
case ProtocolType::NATIONAL_LOCATION:
|
||||
return "National";
|
||||
case ProtocolType::RLS_LOCATION:
|
||||
return "RLS";
|
||||
case ProtocolType::ELT_DT_LOCATION:
|
||||
return "ELT(DT)";
|
||||
case ProtocolType::USER:
|
||||
return longFrame ? "User Location" : "User";
|
||||
case ProtocolType::SPARE:
|
||||
return "Spare";
|
||||
default:
|
||||
return UNKNOWN_LABEL;
|
||||
}
|
||||
}
|
||||
|
||||
// Get protocol type for this beacon
|
||||
ProtocolType getProtocolType() {
|
||||
switch (protocol) {
|
||||
case Protocol::USER_EPIRB_MARITIME:
|
||||
case Protocol::USER_EPIRB_RADIO:
|
||||
case Protocol::USER_ELT:
|
||||
case Protocol::USER_SERIAL:
|
||||
case Protocol::USER_TEST:
|
||||
case Protocol::USER_ORB:
|
||||
case Protocol::USER_NAT:
|
||||
case Protocol::USER_2G:
|
||||
return ProtocolType::USER;
|
||||
case Protocol::STD_EPIRB:
|
||||
case Protocol::STD_ELT_24:
|
||||
case Protocol::STD_ELT_SERIAL:
|
||||
case Protocol::STD_ELT_AIRCRAFT:
|
||||
case Protocol::STD_PLB_SERIAL:
|
||||
case Protocol::STD_SHIP:
|
||||
case Protocol::STD_TEST:
|
||||
return ProtocolType::STANDARD_LOCATION;
|
||||
case Protocol::NAT_ELT:
|
||||
case Protocol::NAT_EPIRB:
|
||||
case Protocol::NAT_PLB:
|
||||
case Protocol::NAT_TEST:
|
||||
return ProtocolType::NATIONAL_LOCATION;
|
||||
case Protocol::RLS:
|
||||
return ProtocolType::RLS_LOCATION;
|
||||
case Protocol::ELT_DT:
|
||||
return ProtocolType::ELT_DT_LOCATION;
|
||||
case Protocol::SPARE:
|
||||
return ProtocolType::SPARE;
|
||||
case Protocol::UNKNOWN:
|
||||
default:
|
||||
return ProtocolType::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// True for long frames, fals for short grames
|
||||
bool longFrame{true};
|
||||
// True if protocol flag is set for this frame
|
||||
bool protocolFlag{false};
|
||||
// Frame mode (Test or Real)
|
||||
FrameMode frameMode{FrameMode::UNKNOWN};
|
||||
// Main location device
|
||||
MainLocatingDevice mainLocatingDevice{MainLocatingDevice::UNDEFINED};
|
||||
// Axiliary location device
|
||||
AuxLocatingDevice auxLocatingDevice{AuxLocatingDevice::UNDEFINED};
|
||||
// Protocol code for this beacon
|
||||
long protocolCode{0};
|
||||
// Protocol of this beacon
|
||||
Protocol protocol{Protocol::UNKNOWN};
|
||||
// Protocol type of this beacon
|
||||
ProtocolType protocolType{ProtocolType::UNKNOWN};
|
||||
// Country of this beacon
|
||||
Country country{};
|
||||
// Frame data
|
||||
uint8_t frame[BEACON_DATA_SIZE];
|
||||
// Location of this beacon
|
||||
Location location{};
|
||||
// HexId of this beacon
|
||||
uint64_t identifier{0};
|
||||
// Date of reception of this beacon
|
||||
rtc::RTC date{};
|
||||
// Trus if this beacon has additional data
|
||||
bool hasAdditionalData{false};
|
||||
// The additional data tring
|
||||
char additionalData[48]{0};
|
||||
// True if this beacon has a serial number
|
||||
bool hasSerialNumber{false};
|
||||
// The serial number string
|
||||
char serialNumber[32]{0};
|
||||
// Beacon's Hex ID string
|
||||
char hexId[32]{0};
|
||||
// BCH1 code value
|
||||
uint32_t bch1{};
|
||||
// BCH1 calculated value
|
||||
uint32_t computedBch1{};
|
||||
// True if data has been corrected to match BCH1 code
|
||||
bool bch1Corrected{false};
|
||||
// True if this beacon has a BCH2 correction code
|
||||
bool hasBch2{false};
|
||||
// BCH2 code value
|
||||
uint32_t bch2{};
|
||||
// BCH2 calculated value
|
||||
uint32_t computedBch2{};
|
||||
// True if data has been corrected to match BCH2 code
|
||||
bool bch2Corrected{false};
|
||||
// True if this beacon is empty (not initialized)
|
||||
bool isEmpty{true};
|
||||
// True if thsi beacon contains emergency data
|
||||
bool hasEmergency{false};
|
||||
// True if emenrgency data is automatic for this beacon
|
||||
bool isAutoamticEmergency{false};
|
||||
// True if this beacon is a Maritime beacon
|
||||
bool isMaritime{false};
|
||||
// Emergency type string
|
||||
char emergencyType[32]{0};
|
||||
|
||||
/**
|
||||
* Returns the requested bits in this beacon's frame
|
||||
*/
|
||||
uint64_t getBits(int startBit, int endBit) {
|
||||
uint64_t result = 0;
|
||||
startBit--;
|
||||
int numBits = endBit - startBit;
|
||||
const uint8_t* pData = &(frame[startBit / 8]);
|
||||
uint8_t b = *pData;
|
||||
int bitOffset = 7 - (startBit % 8);
|
||||
for (int i = 0; i < numBits; ++i) {
|
||||
result <<= 1;
|
||||
result |= ((b >> bitOffset) & 0x01);
|
||||
if (--bitOffset < 0) {
|
||||
b = *(++pData);
|
||||
bitOffset = 7;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute a BCH control code for the given bits and poly
|
||||
*/
|
||||
uint64_t computeBCH(int startBit, int endBit, unsigned long poly, int polyLength) {
|
||||
int dataLength = endBit - startBit + 1;
|
||||
int totalLength = dataLength + polyLength - 1;
|
||||
uint64_t result = getBits(startBit, startBit + polyLength - 1);
|
||||
for (int i = polyLength; i <= totalLength; i++) {
|
||||
bool firstBit = result >> (polyLength - 1);
|
||||
if (firstBit) result = result ^ poly;
|
||||
if (i < totalLength) {
|
||||
result = result << 1;
|
||||
if (i < dataLength) result |= getBits(startBit + i, startBit + i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute BCH1 code
|
||||
*/
|
||||
uint64_t computeBCH1() { return computeBCH(25, 85, BCH_21_POLYNOMIAL, BCH_21_POLY_LENGTH); }
|
||||
/**
|
||||
* Compute BCH2 code
|
||||
*/
|
||||
uint64_t computeBCH2() { return computeBCH(107, 132, BCH_12_POLYNOMIAL, BCH_12_POLY_LENGTH); }
|
||||
|
||||
/**
|
||||
* Convert this frame's data to an hex string
|
||||
*/
|
||||
static size_t toHexString(char* buffer, uint8_t* frame, bool withSpace, int start, int end) {
|
||||
size_t result = 0;
|
||||
for (uint8_t i = start; i < end; i++) {
|
||||
if (withSpace && i > start) buffer[result++] = ' ';
|
||||
result += sprintf((buffer + result), "%02X", frame[i]);
|
||||
}
|
||||
buffer[result] = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
Beacon() {}
|
||||
Beacon(const Beacon& other) = delete;
|
||||
Beacon& operator=(const Beacon& other) = delete;
|
||||
|
||||
/**
|
||||
* Set the data for this Beacon and parse it
|
||||
*/
|
||||
void setFrame(const uint8_t* frameBuffer) {
|
||||
frameMode = FrameMode::UNKNOWN;
|
||||
mainLocatingDevice = MainLocatingDevice::UNDEFINED;
|
||||
auxLocatingDevice = AuxLocatingDevice::UNDEFINED;
|
||||
protocolCode = 0;
|
||||
protocol = Protocol::UNKNOWN;
|
||||
protocolType = ProtocolType::UNKNOWN;
|
||||
country.code = 0;
|
||||
country.alphaCode[0] = 0;
|
||||
country.shortName[0] = 0;
|
||||
location.clear();
|
||||
identifier = 0;
|
||||
hasAdditionalData = false;
|
||||
additionalData[0] = 0;
|
||||
hasSerialNumber = false;
|
||||
serialNumber[0] = 0;
|
||||
hexId[0] = 0;
|
||||
bch1 = 0;
|
||||
computedBch1 = 0;
|
||||
hasBch2 = false;
|
||||
bch1Corrected = false;
|
||||
bch2 = 0;
|
||||
computedBch2 = 0;
|
||||
bch2Corrected = false;
|
||||
isEmpty = true;
|
||||
hasEmergency = false;
|
||||
isAutoamticEmergency = false;
|
||||
isMaritime = false;
|
||||
emergencyType[0] = 0;
|
||||
std::memcpy(frame, (const void*)frameBuffer, BEACON_DATA_SIZE);
|
||||
parseFrame();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flip the specified bit in this beacon's data
|
||||
*/
|
||||
void flipBit(int bit) {
|
||||
int byteIdx = (bit - 1) / 8;
|
||||
int bitIdx = 7 - ((bit - 1) % 8);
|
||||
frame[byteIdx] ^= (1 << bitIdx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Single bit error correction to match BCH1 or BCH2 code
|
||||
*/
|
||||
void simpleCorrection(bool isBCH1) {
|
||||
for (int i = (isBCH1 ? 25 : 107); i <= (isBCH1 ? 85 : 132); i++) {
|
||||
flipBit(i);
|
||||
if ((isBCH1 ? (computeBCH1() == bch1) : (computeBCH2() == bch2))) {
|
||||
if (isBCH1) {
|
||||
computedBch1 = bch1;
|
||||
bch1Corrected = true;
|
||||
} else {
|
||||
computedBch2 = bch2;
|
||||
bch2Corrected = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
flipBit(i); // Restore bit value
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string representation of this beacon's type
|
||||
*/
|
||||
const char* getType() {
|
||||
if ((protocol == Protocol::USER_EPIRB_MARITIME) || (protocol == Protocol::USER_EPIRB_RADIO) || (protocol == Protocol::STD_EPIRB) || (protocol == Protocol::STD_EPIRB_SERIAL) || (protocol == Protocol::NAT_EPIRB)) return "EPIRB";
|
||||
if ((protocol == Protocol::USER_ELT) || (protocol == Protocol::STD_ELT_24) || (protocol == Protocol::STD_ELT_SERIAL) || (protocol == Protocol::STD_ELT_AIRCRAFT) || (protocol == Protocol::NAT_ELT) || (protocol == Protocol::ELT_DT)) return "ELT";
|
||||
if ((protocol == Protocol::STD_PLB_SERIAL) || (protocol == Protocol::NAT_PLB)) return "PLB";
|
||||
if ((protocol == Protocol::USER_TEST) || (protocol == Protocol::STD_TEST) || (protocol == Protocol::NAT_TEST)) return "TEST";
|
||||
if (protocol == Protocol::USER_SERIAL) return "SRIAL";
|
||||
if (protocol == Protocol::USER_ORB) return "ORB";
|
||||
if (protocol == Protocol::USER_NAT) return "NAT";
|
||||
if (protocol == Protocol::USER_2G) return "2G";
|
||||
if (protocol == Protocol::STD_SHIP) return "SHIP";
|
||||
if (protocol == Protocol::RLS) return "RLS";
|
||||
if (protocol == Protocol::SPARE) return "SPARE";
|
||||
return UNKNOWN_LABEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this beacon has a main location device
|
||||
*/
|
||||
bool hasMainLocatingDevice() { return (mainLocatingDevice != MainLocatingDevice::UNDEFINED); }
|
||||
|
||||
/**
|
||||
* Returns this beacon's main location device string representation
|
||||
*/
|
||||
const char* getMainLocatingDeviceName() {
|
||||
if (mainLocatingDevice == MainLocatingDevice::EXTERNAL_NAV) return "Exernal";
|
||||
if (mainLocatingDevice == MainLocatingDevice::INTERNAL_NAV) return "Internal";
|
||||
return UNKNOWN_LABEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this beacon has a main location device
|
||||
*/
|
||||
bool hasAuxLocatingDevice() { return (auxLocatingDevice != AuxLocatingDevice::UNDEFINED); }
|
||||
|
||||
/**
|
||||
* Returns true if this beacon has a main location device
|
||||
*/
|
||||
const char* getAuxLocatingDeviceName() {
|
||||
return ResourceManager::get_beacon_resource(AUX_DEVICE_RESOURCE_START + ((int)auxLocatingDevice));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the serial number for this beacon
|
||||
*/
|
||||
void setSerialNumber(uint32_t serial) {
|
||||
sprintf(serialNumber, "%ld (0x%08lX)", serial, serial);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if BCH1 code is valid
|
||||
*/
|
||||
bool isBch1Valid() { return (bch1 == computedBch1); }
|
||||
|
||||
/**
|
||||
* Returns true if BCH2 code is valid
|
||||
*/
|
||||
|
||||
bool isBch2Valid() { return (bch2 == computedBch2); }
|
||||
|
||||
/**
|
||||
* Returns true if frame is valid
|
||||
*/
|
||||
bool isFrameValid();
|
||||
|
||||
/**
|
||||
* Returns true if frame is orbito
|
||||
*/
|
||||
bool isOrbito() { return (protocol == Protocol::USER_ORB); }
|
||||
|
||||
/**
|
||||
* Write the hex preresentation of this frame in the provided buffer
|
||||
*/
|
||||
size_t hexString(char* buffer, bool withHeader) {
|
||||
return toHexString(buffer, frame, false, (withHeader ? 0 : 3), (longFrame ? 18 : 14));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the short ID for this beacon
|
||||
*/
|
||||
std::string shortId();
|
||||
|
||||
/**
|
||||
* Returns the string representation of the status of this frame
|
||||
*/
|
||||
std::string getSatus() {
|
||||
if (isFrameValid())
|
||||
return "OK";
|
||||
else
|
||||
return "KO";
|
||||
}
|
||||
|
||||
/**
|
||||
* Format this beacon's time
|
||||
*/
|
||||
size_t formatTime(char* buffer);
|
||||
|
||||
/**
|
||||
* Format this beacon's summary
|
||||
*/
|
||||
size_t formatSummary(char* buffer, bool with_time);
|
||||
|
||||
private:
|
||||
/* Baudot code matrix */
|
||||
static constexpr char BAUDOT_CODE[64] = {' ', '5', ' ', '9', ' ', ' ', ' ', ' ', ' ', ' ', '4', ' ', '8', '0', ' ', ' ',
|
||||
'3', ' ', ' ', ' ', ' ', '6', ' ', '/', '-', '2', ' ', ' ', '7', '1', ' ', ' ',
|
||||
' ', 'T', ' ', 'O', ' ', 'H', 'N', 'M', ' ', 'L', 'R', 'G', 'I', 'P', 'C', 'V',
|
||||
'E', 'Z', 'D', 'B', 'S', 'Y', 'F', 'X', 'A', 'W', 'J', ' ', 'U', 'Q', 'K', '\0'};
|
||||
|
||||
/**
|
||||
* Parse this beacon's protocol
|
||||
*/
|
||||
void parseProtocol() {
|
||||
protocolFlag = getBits(26, 26);
|
||||
if (protocolFlag)
|
||||
protocolCode = getBits(37, 39);
|
||||
else
|
||||
protocolCode = getBits(37, 40);
|
||||
|
||||
if (!longFrame || protocolFlag == 1) {
|
||||
switch (protocolCode) {
|
||||
case 0b000:
|
||||
protocol = Protocol::USER_ORB;
|
||||
break;
|
||||
case 0b001:
|
||||
protocol = Protocol::USER_ELT;
|
||||
break;
|
||||
case 0b010:
|
||||
protocol = Protocol::USER_EPIRB_MARITIME;
|
||||
isMaritime = true;
|
||||
break;
|
||||
case 0b011:
|
||||
protocol = Protocol::USER_SERIAL;
|
||||
break;
|
||||
case 0b100:
|
||||
protocol = Protocol::USER_NAT;
|
||||
break;
|
||||
case 0b101:
|
||||
protocol = Protocol::USER_2G;
|
||||
break;
|
||||
case 0b110:
|
||||
protocol = Protocol::USER_EPIRB_RADIO;
|
||||
isMaritime = true;
|
||||
break;
|
||||
case 0b111:
|
||||
protocol = Protocol::USER_TEST;
|
||||
break;
|
||||
default:
|
||||
protocol = Protocol::UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
switch (protocolCode) {
|
||||
case 0b0010:
|
||||
protocol = Protocol::STD_EPIRB;
|
||||
break;
|
||||
case 0b0011:
|
||||
protocol = Protocol::STD_ELT_24;
|
||||
break;
|
||||
case 0b0100:
|
||||
protocol = Protocol::STD_ELT_SERIAL;
|
||||
break;
|
||||
case 0b0101:
|
||||
protocol = Protocol::STD_ELT_AIRCRAFT;
|
||||
break;
|
||||
case 0b0110:
|
||||
protocol = Protocol::STD_EPIRB_SERIAL;
|
||||
break;
|
||||
case 0b0111:
|
||||
protocol = Protocol::STD_PLB_SERIAL;
|
||||
break;
|
||||
case 0b1000:
|
||||
protocol = Protocol::NAT_ELT;
|
||||
break;
|
||||
case 0b1001:
|
||||
protocol = Protocol::ELT_DT;
|
||||
break;
|
||||
case 0b1010:
|
||||
protocol = Protocol::NAT_EPIRB;
|
||||
break;
|
||||
case 0b1011:
|
||||
protocol = Protocol::NAT_PLB;
|
||||
break;
|
||||
case 0b1100:
|
||||
protocol = Protocol::STD_SHIP;
|
||||
break;
|
||||
case 0b1101:
|
||||
protocol = Protocol::RLS;
|
||||
break;
|
||||
case 0b1110:
|
||||
protocol = Protocol::STD_TEST;
|
||||
break;
|
||||
case 0b1111:
|
||||
protocol = Protocol::NAT_TEST;
|
||||
break;
|
||||
default:
|
||||
protocol = Protocol::UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse this beacon's additional data
|
||||
*/
|
||||
void parseAdditionalData() {
|
||||
hasAdditionalData = false;
|
||||
hasSerialNumber = false;
|
||||
if (protocolFlag) {
|
||||
if (protocolCode == 0b011) {
|
||||
uint8_t serialUserProtocol = getBits(40, 42);
|
||||
hasAdditionalData = true;
|
||||
switch (serialUserProtocol) {
|
||||
case 0b100:
|
||||
case 0b010:
|
||||
isMaritime = true;
|
||||
// fallthrough
|
||||
case 0b000:
|
||||
case 0b001:
|
||||
case 0b011:
|
||||
case 0b110:
|
||||
strcpy(additionalData, ResourceManager::get_beacon_resource(ADDITIONAL_DATA_RESOURCE_START + serialUserProtocol));
|
||||
break;
|
||||
default:
|
||||
hasAdditionalData = false;
|
||||
}
|
||||
hasSerialNumber = true;
|
||||
setSerialNumber((serialUserProtocol == 0b011) ? getBits(44, 67) : (serialUserProtocol == 0b001) ? getBits(62, 73)
|
||||
: getBits(44, 63));
|
||||
}
|
||||
if (!longFrame) {
|
||||
hasEmergency = getBits(107, 107);
|
||||
if (hasEmergency) {
|
||||
isAutoamticEmergency = getBits(108, 108);
|
||||
if (isMaritime) {
|
||||
uint8_t emmergency = getBits(109, 112);
|
||||
switch (emmergency) {
|
||||
case 0b0001:
|
||||
case 0b0010:
|
||||
case 0b0011:
|
||||
case 0b0100:
|
||||
case 0b0101:
|
||||
case 0b0110:
|
||||
case 0b0111:
|
||||
case 0b1000:
|
||||
strcpy(emergencyType, ResourceManager::get_beacon_resource(EMERGENCY_RESOURCE_START + emmergency));
|
||||
break;
|
||||
default:
|
||||
strcpy(emergencyType, ResourceManager::get_beacon_resource(EMERGENCY_RESOURCE_START));
|
||||
}
|
||||
} else {
|
||||
bool fire = getBits(109, 109);
|
||||
bool med = getBits(110, 110);
|
||||
bool disabled = getBits(111, 111);
|
||||
char* emmergency_pointer = emergencyType;
|
||||
if (fire) emmergency_pointer += sprintf(emmergency_pointer, "%s", ResourceManager::get_beacon_resource(EMERGENCY_OTHER_RESOURCE_START));
|
||||
if (med) {
|
||||
if (fire) emmergency_pointer += sprintf(emmergency_pointer, "%c", '+');
|
||||
emmergency_pointer += sprintf(emmergency_pointer, "%s", ResourceManager::get_beacon_resource(EMERGENCY_OTHER_RESOURCE_START + 1));
|
||||
}
|
||||
if (disabled) {
|
||||
if (fire || med) emmergency_pointer += sprintf(emmergency_pointer, "%c", '+');
|
||||
sprintf(emmergency_pointer, "%s", ResourceManager::get_beacon_resource(EMERGENCY_OTHER_RESOURCE_START + 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (longFrame) {
|
||||
switch (protocolCode) {
|
||||
case 0b0010:
|
||||
hasSerialNumber = true;
|
||||
setSerialNumber(getBits(61, 64));
|
||||
break;
|
||||
case 0b1100: {
|
||||
hasAdditionalData = true;
|
||||
uint32_t mmsi = getBits(41, 60);
|
||||
sprintf(additionalData, ResourceManager::get_beacon_resource(LONG_ADDITIONAL_DATA_RESOURCE_START), mmsi, mmsi);
|
||||
} break;
|
||||
case 0b0011: {
|
||||
hasAdditionalData = true;
|
||||
hasSerialNumber = true;
|
||||
setSerialNumber(getBits(41, 64));
|
||||
strcpy(additionalData, ResourceManager::get_beacon_resource(LONG_ADDITIONAL_DATA_RESOURCE_START + 1));
|
||||
} break;
|
||||
case 0b0100:
|
||||
case 0b0110:
|
||||
case 0b0111: {
|
||||
hasAdditionalData = true;
|
||||
hasSerialNumber = true;
|
||||
uint32_t csTaNumber = getBits(41, 50);
|
||||
sprintf(additionalData, ResourceManager::get_beacon_resource(LONG_ADDITIONAL_DATA_RESOURCE_START + 2), csTaNumber);
|
||||
setSerialNumber(getBits(51, 64));
|
||||
} break;
|
||||
case 0b0101: {
|
||||
hasAdditionalData = true;
|
||||
hasSerialNumber = true;
|
||||
uint32_t data = getBits(41, 45);
|
||||
char char1 = BAUDOT_CODE[data + 32];
|
||||
data = getBits(46, 50);
|
||||
char char2 = BAUDOT_CODE[data + 32];
|
||||
data = getBits(51, 55);
|
||||
char char3 = BAUDOT_CODE[data + 32];
|
||||
sprintf(additionalData, ResourceManager::get_beacon_resource(LONG_ADDITIONAL_DATA_RESOURCE_START + 3), char1, char2, char3);
|
||||
setSerialNumber(getBits(56, 64));
|
||||
} break;
|
||||
case 0b1000:
|
||||
case 0b1010:
|
||||
case 0b1011:
|
||||
case 0b1111: {
|
||||
hasSerialNumber = true;
|
||||
hasAdditionalData = true;
|
||||
setSerialNumber(getBits(41, 58));
|
||||
uint32_t natNum = getBits(127, 132);
|
||||
sprintf(additionalData, ResourceManager::get_beacon_resource(LONG_ADDITIONAL_DATA_RESOURCE_START + 4), natNum);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse this beacon's locating device
|
||||
*/
|
||||
void parseLocatingDevices() {
|
||||
bool mainLoc;
|
||||
if (protocolIsStandard() || protocolIsNational()) {
|
||||
mainLoc = getBits(111, 111);
|
||||
mainLocatingDevice = mainLoc ? MainLocatingDevice::INTERNAL_NAV : MainLocatingDevice::EXTERNAL_NAV;
|
||||
} else if (protocolIsUser() || protocolIsRls()) {
|
||||
mainLoc = getBits(107, 107);
|
||||
mainLocatingDevice = mainLoc ? MainLocatingDevice::INTERNAL_NAV : MainLocatingDevice::EXTERNAL_NAV;
|
||||
}
|
||||
if (protocolIsStandard() || protocolIsNational()) {
|
||||
auxLocatingDevice = getBits(112, 112) ? AuxLocatingDevice::MHZ121_5 : AuxLocatingDevice::NONE_OR_OTHER;
|
||||
} else if (protocolIsRls()) {
|
||||
auxLocatingDevice = getBits(108, 108) ? AuxLocatingDevice::MHZ121_5 : AuxLocatingDevice::NONE_OR_OTHER;
|
||||
} else if (protocolIsUser() && protocolCode != 0b100) {
|
||||
uint8_t aux = getBits(84, 85);
|
||||
if (aux == 0b00)
|
||||
auxLocatingDevice = AuxLocatingDevice::NONE;
|
||||
else if (aux == 0b01)
|
||||
auxLocatingDevice = AuxLocatingDevice::MHZ121_5;
|
||||
else if (aux == 0b10)
|
||||
auxLocatingDevice = AuxLocatingDevice::SART;
|
||||
else
|
||||
auxLocatingDevice = AuxLocatingDevice::OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse this beacon's frame data
|
||||
*/
|
||||
void parseFrame() {
|
||||
long latofmin, latofsec, lonofmin, lonofsec;
|
||||
bool latoffset, lonoffset;
|
||||
|
||||
longFrame = getBits(25, 25);
|
||||
parseProtocol();
|
||||
protocolType = getProtocolType();
|
||||
CountryManager::get_country(getBits(27, 36), country);
|
||||
|
||||
if (frame[2] == 0xD0)
|
||||
frameMode = FrameMode::SELF_TEST;
|
||||
else if (frame[2] == 0x2F)
|
||||
frameMode = FrameMode::NORMAL;
|
||||
else
|
||||
frameMode = FrameMode::UNKNOWN;
|
||||
|
||||
if (longFrame) {
|
||||
if (protocolIsUser() && !isOrbito()) {
|
||||
location.latitude.orientation = (frame[13] & 0x10) >> 4;
|
||||
location.latitude.degrees = ((frame[13] & 0x0F) << 3 | (frame[14] & 0xE0) >> 5);
|
||||
location.latitude.minutes = ((frame[14] & 0x1E) >> 1) * 4;
|
||||
location.longitude.orientation = (frame[14] & 0x01);
|
||||
location.longitude.degrees = (frame[15]);
|
||||
location.longitude.minutes = ((frame[16] & 0xF0) >> 4) * 4;
|
||||
} else if (protocolIsNational()) {
|
||||
latoffset = (frame[14] & 0x80) >> 7;
|
||||
location.latitude.orientation = (frame[7] & 0x20) >> 5;
|
||||
location.latitude.degrees = ((frame[7] & 0x1F) << 2 | (frame[8] & 0xC0) >> 6);
|
||||
location.latitude.minutes = ((frame[8] & 0x3E) >> 1) * 2;
|
||||
latofmin = (frame[14] & 0x60) >> 5;
|
||||
latofsec = ((frame[14] & 0x1E) >> 1) * 4;
|
||||
location.latitude.apply_offset(latoffset, latofmin, latofsec);
|
||||
lonoffset = (frame[14] & 0x01);
|
||||
location.longitude.orientation = (frame[8] & 0x01);
|
||||
location.longitude.degrees = (frame[9]);
|
||||
location.longitude.minutes = ((frame[10] & 0xF8) >> 3) * 2;
|
||||
lonofmin = (frame[15] & 0xC0) >> 6;
|
||||
lonofsec = ((frame[15] & 0x3C) >> 2) * 4;
|
||||
location.longitude.apply_offset(lonoffset, lonofmin, lonofsec);
|
||||
} else if (protocolIsStandard()) {
|
||||
latoffset = (frame[14] & 0x80) >> 7;
|
||||
location.latitude.orientation = (frame[8] & 0x80) >> 7;
|
||||
location.latitude.degrees = (frame[8] & 0x7F);
|
||||
location.latitude.minutes = ((frame[9] & 0xC0) >> 6) * 15;
|
||||
latofmin = (frame[14] & 0x7C) >> 2;
|
||||
latofsec = ((frame[14] & 0x03) << 2 | (frame[15] & 0xC0) >> 6) * 4;
|
||||
location.latitude.apply_offset(latoffset, latofmin, latofsec);
|
||||
lonoffset = (frame[15] & 0x20) >> 5;
|
||||
location.longitude.orientation = (frame[9] & 0x20) >> 5;
|
||||
location.longitude.degrees = ((frame[9] & 0x1F) << 3 | (frame[10] & 0xE0) >> 5);
|
||||
location.longitude.minutes = ((frame[10] & 0x18) >> 3) * 15;
|
||||
lonofmin = (frame[15] & 0x1F);
|
||||
lonofsec = ((frame[16] & 0xF0) >> 4) * 4;
|
||||
location.longitude.apply_offset(lonoffset, lonofmin, lonofsec);
|
||||
} else if (protocolIsRlsOrElt()) {
|
||||
latoffset = (frame[14] & 0x20) >> 5;
|
||||
location.latitude.orientation = (frame[8] & 0x20) >> 5;
|
||||
location.latitude.degrees = ((frame[8] & 0x1F) << 2) | ((frame[9] & 0xC0) >> 6);
|
||||
location.latitude.minutes = ((frame[9] & 0x20) >> 5) * 30;
|
||||
latofmin = (frame[14] & 0x1E) >> 1;
|
||||
latofsec = ((frame[14] & 0x01) << 3 | (frame[15] & 0xE0) >> 5) * 4;
|
||||
location.latitude.apply_offset(latoffset, latofmin, latofsec);
|
||||
lonoffset = (frame[15] & 0x10) >> 4;
|
||||
location.longitude.orientation = (frame[9] & 0x10) >> 4;
|
||||
location.longitude.degrees = ((frame[9] & 0x0F) << 4 | (frame[10] & 0xF0) >> 4);
|
||||
location.longitude.minutes = ((frame[10] & 0x08) >> 3) * 30;
|
||||
lonofmin = (frame[15] & 0x0F);
|
||||
lonofsec = ((frame[16] & 0xF0) >> 4) * 4;
|
||||
location.longitude.apply_offset(lonoffset, lonofmin, lonofsec);
|
||||
}
|
||||
}
|
||||
|
||||
parseAdditionalData();
|
||||
parseLocatingDevices();
|
||||
|
||||
identifier = getBits(26, 85);
|
||||
|
||||
uint32_t hexIdHigh = (uint32_t)(identifier >> 32);
|
||||
uint32_t hexIdLow = (uint32_t)identifier;
|
||||
|
||||
if (protocolIsStandard()) {
|
||||
// default value of bits 65 to 74 = 0 111111111 / default value of bits 75 to 85 = 0 1111111111
|
||||
hexIdLow &= 0b11111111'11100000'00000000'00000000;
|
||||
hexIdLow |= 0b00000000'00001111'11111011'11111111;
|
||||
} else if (protocolIsNational()) {
|
||||
// default value of bits 59 to 71 = 0 1111111 00000 / default value of bits 72 to 85 = 0 11111111 00000
|
||||
hexIdLow &= 0b11111000'00000000'00000000'00000000;
|
||||
hexIdLow |= 0b00000011'11111000'00011111'11100000;
|
||||
} else if (protocolIsRlsOrElt()) {
|
||||
// default value of bits 67 to 75 = 0 11111111 / default value of bits 76 to 85 = 0 111111111
|
||||
hexIdLow &= 0b11111111'11111000'00000000'00000000;
|
||||
hexIdLow |= 0b00000000'00000011'11111101'11111111;
|
||||
}
|
||||
std::sprintf(hexId, "%07lX%08lX", hexIdHigh, hexIdLow);
|
||||
|
||||
if (isOrbito() && !longFrame) {
|
||||
isEmpty = true;
|
||||
for (size_t i = 3; i < BEACON_DATA_SIZE; i++) {
|
||||
if (frame[i] != 0) {
|
||||
isEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
isEmpty = false;
|
||||
|
||||
bch1 = getBits(86, 106);
|
||||
computedBch1 = computeBCH1();
|
||||
// Try and correct single bit error on BCH1 (bits 25-85)
|
||||
if (computedBch1 != bch1) {
|
||||
simpleCorrection(true);
|
||||
}
|
||||
|
||||
hasBch2 = longFrame && !isOrbito();
|
||||
if (hasBch2) {
|
||||
bch2 = getBits(133, 144);
|
||||
computedBch2 = computeBCH2();
|
||||
// Try and correct single bit error on BCH2 (bits 107 - 132)
|
||||
if (computedBch2 != bch2) {
|
||||
simpleCorrection(false);
|
||||
}
|
||||
}
|
||||
static bool isCorrecting = false;
|
||||
// If BCH1 or BCH2 has been corrected, we need to parse frame again to update beacon properties
|
||||
if (!isCorrecting && (bch1Corrected || bch2Corrected)) {
|
||||
// Prevent recursion
|
||||
isCorrecting = true;
|
||||
parseFrame();
|
||||
isCorrecting = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
|
||||
#endif // __BEACON_RX_H__
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "beacon_db.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
/**
|
||||
* Add a beacon to the database.
|
||||
* @return the added beacon reference.
|
||||
*/
|
||||
Beacon& BeaconDB::add_beacon() {
|
||||
Beacon& result = recent_beacons[recent_beacon_pos];
|
||||
recent_beacon_pos = (recent_beacon_pos + 1) % BEACON_HISTORY_SIZE;
|
||||
if (recent_beacon_pos == 0) recent_beacon_full = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the beacon database
|
||||
* @return the size of the beacon database
|
||||
*/
|
||||
size_t BeaconDB::size() {
|
||||
return recent_beacon_full ? BEACON_HISTORY_SIZE : recent_beacon_pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the database is empty
|
||||
* @return true if the database is empty
|
||||
*/
|
||||
bool BeaconDB::empty() {
|
||||
return (!recent_beacon_full && (recent_beacon_pos == 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the beacon at the provided index
|
||||
*/
|
||||
Beacon& BeaconDB::get_beacon(size_t index) {
|
||||
// Start from last beacon et go backward
|
||||
int16_t pos = (int16_t)recent_beacon_pos - 1 - index;
|
||||
while (pos < 0) pos += BEACON_HISTORY_SIZE;
|
||||
return recent_beacons[pos % BEACON_HISTORY_SIZE];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set currently selected beacon
|
||||
* @param index the selected index
|
||||
*/
|
||||
void BeaconDB::set_current_beacon(size_t index) {
|
||||
current_beacon_index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get currently selected index
|
||||
* @return the currently selected index
|
||||
*/
|
||||
size_t BeaconDB::get_current_beacon_index() {
|
||||
return current_beacon_index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently selected beacon
|
||||
* @return the currently selected beacon
|
||||
*/
|
||||
Beacon& BeaconDB::get_current_beacon() {
|
||||
return get_beacon(current_beacon_index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear beacon database
|
||||
*/
|
||||
void BeaconDB::clear() {
|
||||
recent_beacon_pos = 0;
|
||||
recent_beacon_full = false;
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __BEACON_DB_H__
|
||||
#define __BEACON_DB_H__
|
||||
|
||||
#include "beacon.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
// Size of beacon database calculated to match the beacon list component size
|
||||
#define BEACON_HISTORY_SIZE 13
|
||||
|
||||
class BeaconDB {
|
||||
public:
|
||||
Beacon& add_beacon();
|
||||
Beacon& get_beacon(size_t index);
|
||||
Beacon& get_current_beacon();
|
||||
size_t get_current_beacon_index();
|
||||
void set_current_beacon(size_t index);
|
||||
size_t size();
|
||||
bool empty();
|
||||
void clear();
|
||||
|
||||
private:
|
||||
// Actual beacon database array
|
||||
Beacon recent_beacons[BEACON_HISTORY_SIZE];
|
||||
// Position of the insertion pointer
|
||||
int8_t recent_beacon_pos{0};
|
||||
// Beacon selection handling
|
||||
size_t current_beacon_index{0};
|
||||
// True when database is full
|
||||
bool recent_beacon_full{false};
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
|
||||
#endif /* __BEACON_DB_H__ */
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COUNTRY_RX_H__
|
||||
#define __COUNTRY_RX_H__
|
||||
|
||||
#include "string_format.hpp"
|
||||
#include "file_reader.hpp"
|
||||
#include "file_path.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
#define DISABLE_COUNTRY_CACHE
|
||||
|
||||
// Country struct
|
||||
struct Country {
|
||||
int16_t code;
|
||||
char alphaCode[4]; // 3 chars + null
|
||||
char shortName[11]; // 10 chars + null
|
||||
};
|
||||
|
||||
class CountryManager {
|
||||
public:
|
||||
static void get_country(int code, Country& out) {
|
||||
#ifndef DISABLE_COUNTRY_CACHE
|
||||
// Check cache
|
||||
for (int i = 0; i < cache_count; i++) {
|
||||
if (cache[i].code == code) {
|
||||
out = cache[i];
|
||||
if (i > 0) { // Promotion
|
||||
Country tmp = cache[i];
|
||||
for (int j = i; j > 0; j--) cache[j] = cache[j - 1];
|
||||
cache[0] = tmp;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Cache miss => load from file
|
||||
if (load_from_file(code, out)) {
|
||||
#ifndef DISABLE_COUNTRY_CACHE
|
||||
// Insert in cache
|
||||
int limit = (cache_count < 16) ? cache_count : 15;
|
||||
for (int j = limit; j > 0; j--) cache[j] = cache[j - 1];
|
||||
cache[0] = out;
|
||||
if (cache_count < 16) cache_count++;
|
||||
#endif
|
||||
} else {
|
||||
out.code = code;
|
||||
out.alphaCode[0] = '\0';
|
||||
out.shortName[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
#ifndef DISABLE_COUNTRY_CACHE
|
||||
static Country cache[16];
|
||||
static int cache_count;
|
||||
#endif
|
||||
|
||||
static bool load_from_file(int target_code, Country& out) {
|
||||
FIL file;
|
||||
if (f_open(&file, (epirb_dir / u"RES/COUNTRY.RES").tchar(), FA_READ) != FR_OK) return false;
|
||||
|
||||
TCHAR line[48];
|
||||
bool found = false;
|
||||
|
||||
while (f_gets(line, sizeof(line) / sizeof(TCHAR), &file)) {
|
||||
// Light parsing method
|
||||
TCHAR* p = line;
|
||||
|
||||
// Parse CODE
|
||||
int c = 0;
|
||||
while (*p >= '0' && *p <= '9') c = c * 10 + (*p++ - '0');
|
||||
if (c != target_code || *p != ':') continue;
|
||||
p++; // Skip ':'
|
||||
|
||||
out.code = (int16_t)c;
|
||||
|
||||
// Parse ALPHA CODE (3 chars)
|
||||
for (int i = 0; i < 3 && *p != ':'; i++) out.alphaCode[i] = (char)*p++;
|
||||
out.alphaCode[3] = '\0';
|
||||
if (*p != ':') continue;
|
||||
p++; // Skip ':'
|
||||
|
||||
// Parse SHORT NAME
|
||||
int i = 0;
|
||||
while (i < static_cast<int>(sizeof(out.shortName) - 1) && *p != '\r' && *p != '\n' && *p != '\0') {
|
||||
out.shortName[i++] = (char)*p++;
|
||||
}
|
||||
out.shortName[i] = '\0';
|
||||
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
f_close(&file);
|
||||
return found;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
|
||||
#endif // __COUNTRY_RX_H__
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "location.hpp"
|
||||
#include <cstdio>
|
||||
#include "string_format.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
void Location::Angle::clear() {
|
||||
degrees = 255;
|
||||
minutes = 0;
|
||||
seconds = 0;
|
||||
orientation = false;
|
||||
floatValue = 255;
|
||||
}
|
||||
|
||||
float Location::Angle::getFloatValue() {
|
||||
if (floatValue >= 255) {
|
||||
floatValue = (float)degrees;
|
||||
floatValue += ((float)minutes / 60.0f);
|
||||
floatValue += ((float)seconds / 3600.0f);
|
||||
if (orientation) {
|
||||
floatValue = -floatValue;
|
||||
}
|
||||
}
|
||||
return floatValue;
|
||||
}
|
||||
|
||||
void Location::Angle::apply_offset(bool positive, long ofmin, long ofsec) {
|
||||
if (positive) {
|
||||
minutes += ofmin;
|
||||
seconds += ofsec;
|
||||
} else {
|
||||
minutes -= ofmin;
|
||||
if (minutes < 0) {
|
||||
minutes += 60;
|
||||
degrees -= 1;
|
||||
}
|
||||
seconds -= ofsec;
|
||||
if (seconds < 0) {
|
||||
seconds += 60;
|
||||
minutes -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Location::clear() {
|
||||
latitude.clear();
|
||||
longitude.clear();
|
||||
}
|
||||
|
||||
bool Location::isUnknown() {
|
||||
return (latitude.degrees >= 255 || longitude.degrees >= 255);
|
||||
}
|
||||
|
||||
char Location::gps_letterize(int x) {
|
||||
return (char)x + 65;
|
||||
}
|
||||
|
||||
size_t Location::gps_compute_locator(char* buffer, float lat, float lon, int precision) {
|
||||
size_t result = 0;
|
||||
|
||||
lon += 180.0f;
|
||||
lat += 90.0f;
|
||||
|
||||
int A = lon / 20;
|
||||
int B = lat / 10;
|
||||
|
||||
lon -= A * 20;
|
||||
lat -= B * 10;
|
||||
|
||||
int C = lon / 2;
|
||||
int D = lat / 1;
|
||||
|
||||
lon -= C * 2;
|
||||
lat -= D * 1;
|
||||
|
||||
int E = lon / (5.0f / 60.0f);
|
||||
int F = lat / (2.5f / 60.0f);
|
||||
|
||||
lon -= E * (5.0f / 60.0f);
|
||||
lat -= F * (2.5f / 60.0f);
|
||||
|
||||
int G = lon / (5.0f / 600.0f);
|
||||
int H = lat / (2.5f / 600.0f);
|
||||
|
||||
buffer[result++] = char('A' + A);
|
||||
buffer[result++] = char('A' + B);
|
||||
|
||||
if (precision >= 4) {
|
||||
buffer[result++] = char('0' + C);
|
||||
buffer[result++] = char('0' + D);
|
||||
}
|
||||
|
||||
if (precision >= 6) {
|
||||
buffer[result++] = char('a' + E);
|
||||
buffer[result++] = char('a' + F);
|
||||
}
|
||||
|
||||
if (precision >= 8) {
|
||||
buffer[result++] = char('0' + G);
|
||||
buffer[result++] = char('0' + H);
|
||||
}
|
||||
buffer[result] = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t Location::toString(char* buffer, LocationFormat format, int precision) {
|
||||
if (isUnknown()) {
|
||||
return sprintf(buffer, "%s", "GPS not synchronized");
|
||||
}
|
||||
switch (format) {
|
||||
case LocationFormat::SEXAGESIMAL: {
|
||||
return sprintf(buffer, "%ld\xB0%02ld'%02ld\"%c, %ld\xB0%02ld'%02ld\"%c", // 0xB0 is degree ° symbol in our 8x16 font
|
||||
latitude.degrees, latitude.minutes, latitude.seconds, latitude.orientation ? 'S' : 'N',
|
||||
longitude.degrees, longitude.minutes, longitude.seconds, longitude.orientation ? 'W' : 'E');
|
||||
}
|
||||
case LocationFormat::MAIDENHEAD_LOCATOR:
|
||||
return gps_compute_locator(buffer, latitude.getFloatValue(), longitude.getFloatValue(), precision);
|
||||
default:
|
||||
case LocationFormat::DECIMAL:
|
||||
return sprintf(buffer, "%s, %s", to_string_decimal(latitude.getFloatValue(), 5).c_str(), to_string_decimal(longitude.getFloatValue(), 5).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void Location::formatFloatLocation(char* buffer, const char* format) {
|
||||
sprintf(buffer, format, to_string_decimal(latitude.getFloatValue(), 6).c_str(), to_string_decimal(longitude.getFloatValue(), 6).c_str());
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef __LOCATION_RX_H__
|
||||
#define __LOCATION_RX_H__
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
class Location {
|
||||
public:
|
||||
class Angle {
|
||||
public:
|
||||
long degrees = 0;
|
||||
long minutes = 0;
|
||||
long seconds = 0;
|
||||
bool orientation = false; // false = N/E, true = S/W
|
||||
|
||||
Angle() {}
|
||||
Angle(long degrees)
|
||||
: degrees(degrees) {}
|
||||
|
||||
void clear();
|
||||
|
||||
float getFloatValue();
|
||||
|
||||
// Apply an offset (minutes / seconds) with sign-based borrow into minutes/degrees.
|
||||
// Out-of-line to keep parseFrame from inlining the same arithmetic 6 times.
|
||||
void apply_offset(bool positive, long ofmin, long ofsec);
|
||||
|
||||
private:
|
||||
float floatValue = 255.0f;
|
||||
};
|
||||
|
||||
enum class LocationFormat { DECIMAL,
|
||||
SEXAGESIMAL,
|
||||
MAIDENHEAD_LOCATOR };
|
||||
|
||||
Angle latitude = Angle(127);
|
||||
Angle longitude = Angle(255);
|
||||
|
||||
void clear();
|
||||
|
||||
bool isUnknown();
|
||||
|
||||
static char gps_letterize(int x);
|
||||
|
||||
// For code size optimization reasons, string manipulation is performed with char buffers
|
||||
// with no char buffer size check. Caller methods take care of providing large enough buffers
|
||||
static size_t gps_compute_locator(char* buffer, float lat, float lon, int precision = 6);
|
||||
size_t toString(char* buffer, LocationFormat format, int precision = 6);
|
||||
|
||||
void formatFloatLocation(char* buffer, const char* format);
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
|
||||
#endif // __LOCATION_RX_H__
|
||||
+1
-1
@@ -73,7 +73,7 @@ __attribute__((section(".external_app.app_epirb_rx.application_information"), us
|
||||
0x00,
|
||||
0x00,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::red().v,
|
||||
/*.icon_color = */ ui::Color::green().v,
|
||||
/*.menu_location = */ app_location_t::RX,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __RESOUCES_H__
|
||||
#define __RESOUCES_H__
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include "file_reader.hpp"
|
||||
#include "file_path.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
#define UNKNOWN_LABEL "Unk."
|
||||
|
||||
extern std::vector<std::string> beacon_res;
|
||||
extern std::vector<std::string> freq;
|
||||
|
||||
/**
|
||||
* This class is used to load string resources from SD card.
|
||||
* This is done mostly to reduce application size and keep it under the 32kb limit.
|
||||
* It's also used to load frequency values, allowing users to customize frequency list by editing FREQ.TXT file on SD card.
|
||||
*/
|
||||
class ResourceManager {
|
||||
public:
|
||||
// Singleton getter
|
||||
static ResourceManager* getInstance();
|
||||
|
||||
// Singleton instance
|
||||
static ResourceManager* current;
|
||||
// Used from standalone app, to prevent memleak
|
||||
static void destroy();
|
||||
|
||||
// Get a string from BEACON.RES file
|
||||
static const char* get_beacon_resource(uint8_t line) {
|
||||
ResourceManager* rm = getInstance();
|
||||
if (rm->beacon_res.empty()) {
|
||||
load_file((epirb_dir / u"RES/BEACON.RES"), rm->beacon_res);
|
||||
}
|
||||
if (line < rm->beacon_res.size()) {
|
||||
return rm->beacon_res[line].c_str();
|
||||
}
|
||||
return UNKNOWN_LABEL;
|
||||
}
|
||||
|
||||
// Get frequency values
|
||||
static const std::vector<std::string>& get_frequencies() {
|
||||
ResourceManager* rm = getInstance();
|
||||
if (rm->freq.empty()) {
|
||||
load_file((epirb_dir / u"FREQ.TXT"), rm->freq);
|
||||
}
|
||||
return rm->freq;
|
||||
}
|
||||
|
||||
private:
|
||||
// BEACON.RES content
|
||||
std::vector<std::string> beacon_res{};
|
||||
// FREQ.TXT content
|
||||
std::vector<std::string> freq{};
|
||||
|
||||
static void load_file(const std::filesystem::path& path, std::vector<std::string>& vect) {
|
||||
FIL file;
|
||||
if (f_open(&file, path.tchar(), FA_READ) == FR_OK) {
|
||||
TCHAR line_buffer[32];
|
||||
// Read the file line by line
|
||||
while (f_gets(line_buffer, sizeof(line_buffer) / sizeof(TCHAR), &file)) {
|
||||
std::string s;
|
||||
for (int i = 0; line_buffer[i] != '\0' && line_buffer[i] != '\n' && line_buffer[i] != '\r'; i++) {
|
||||
// Convert each TCHAR in char
|
||||
s += (char)line_buffer[i];
|
||||
}
|
||||
vect.push_back(std::move(s));
|
||||
}
|
||||
f_close(&file);
|
||||
}
|
||||
if (vect.empty()) vect.push_back(UNKNOWN_LABEL);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
|
||||
#endif // __RESOUCES_H__
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_beaconlist.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
BeaconUIList::BeaconUIList(Rect parent_rect)
|
||||
: View{parent_rect} {
|
||||
this->set_focusable(true);
|
||||
}
|
||||
|
||||
void BeaconUIList::paint(Painter& painter) {
|
||||
auto rect = screen_rect();
|
||||
// Clear view
|
||||
painter.fill_rectangle(rect, Theme::getInstance()->bg_darkest->background);
|
||||
|
||||
if (!db_ || (db_->empty())) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto base_style = Theme::getInstance()->bg_darkest;
|
||||
|
||||
for (auto offset = 0u; offset < BEACON_HISTORY_SIZE; ++offset) {
|
||||
auto index = start_index_ + offset;
|
||||
|
||||
if (index < db_->size()) {
|
||||
auto line_position = rect.location() + Point{0, 1 + (int)offset * char_height};
|
||||
auto is_selected = (offset == selected_index_);
|
||||
auto style = base_style;
|
||||
|
||||
// Get beacon entry and format it's summary
|
||||
auto& entry = db_->get_beacon(index);
|
||||
char buffer[64];
|
||||
entry.formatSummary(buffer, true);
|
||||
|
||||
if (index == db_->get_current_beacon_index())
|
||||
// If this is the currently displayed beacon change color
|
||||
style = Theme::getInstance()->bg_medium;
|
||||
|
||||
// Draw entry line using stack buffer directly to avoid heap allocation
|
||||
painter.draw_string(
|
||||
line_position, (is_selected ? style->invert() : *style), buffer);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw a bounding rectangle when focused.
|
||||
painter.draw_rectangle(rect, (has_focus() ? Theme::getInstance()->bg_darkest->foreground : Theme::getInstance()->bg_darkest->background));
|
||||
}
|
||||
|
||||
void BeaconUIList::on_show() {
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
bool BeaconUIList::on_key(const KeyEvent key) {
|
||||
if (!db_ || db_->empty())
|
||||
return false;
|
||||
|
||||
if (key == KeyEvent::Select && on_select) {
|
||||
// Select this beacon
|
||||
on_select(get_index());
|
||||
set_dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
auto delta = 0;
|
||||
// Change position in the list
|
||||
if (key == KeyEvent::Up && get_index() > 0)
|
||||
delta = -1;
|
||||
else if (key == KeyEvent::Down && get_index() < db_->size() - 1)
|
||||
delta = 1;
|
||||
else
|
||||
return false;
|
||||
|
||||
adjust_selected_index(delta);
|
||||
set_dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BeaconUIList::on_encoder(EncoderEvent delta) {
|
||||
if (!db_ || db_->empty())
|
||||
return false;
|
||||
// Change position in the list according to encoder
|
||||
adjust_selected_index(delta);
|
||||
set_dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t BeaconUIList::get_index() const {
|
||||
return start_index_ + selected_index_;
|
||||
}
|
||||
|
||||
void BeaconUIList::set_db(BeaconDB& db) {
|
||||
db_ = &db;
|
||||
start_index_ = 0;
|
||||
selected_index_ = 0;
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void BeaconUIList::adjust_selected_index(int delta) {
|
||||
int32_t new_index = selected_index_ + delta;
|
||||
|
||||
// The selection went off the top of the screen, move up.
|
||||
if (new_index < 0) {
|
||||
start_index_ = std::max<int32_t>(start_index_ + new_index, 0);
|
||||
selected_index_ = 0;
|
||||
}
|
||||
|
||||
// Selection is off the bottom of the screen, move down.
|
||||
else if (new_index >= (int32_t)BEACON_HISTORY_SIZE) {
|
||||
start_index_ = std::min<int32_t>(start_index_ + delta, db_->size() - BEACON_HISTORY_SIZE);
|
||||
selected_index_ = BEACON_HISTORY_SIZE - 1;
|
||||
}
|
||||
|
||||
// Otherwise, scroll within the screen, but not past the end.
|
||||
else {
|
||||
selected_index_ = std::min<int32_t>(new_index, db_->size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __UI_BEACONLIST_H__
|
||||
#define __UI_BEACONLIST_H__
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "ui_painter.hpp"
|
||||
#include "ui_widget.hpp"
|
||||
#include "beacon_db.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
/**
|
||||
* Beacon list component
|
||||
*/
|
||||
class BeaconUIList : public View {
|
||||
public:
|
||||
std::function<void(size_t)> on_select{};
|
||||
|
||||
BeaconUIList(Rect parent_rect);
|
||||
BeaconUIList(const BeaconUIList& other) = delete;
|
||||
BeaconUIList& operator=(const BeaconUIList& other) = delete;
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
void on_show() override;
|
||||
bool on_key(const KeyEvent key) override;
|
||||
bool on_encoder(EncoderEvent delta) override;
|
||||
|
||||
size_t get_index() const;
|
||||
void set_db(BeaconDB& db);
|
||||
|
||||
private:
|
||||
void adjust_selected_index(int index);
|
||||
|
||||
BeaconDB* db_{nullptr};
|
||||
size_t start_index_{0};
|
||||
size_t selected_index_{0};
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
|
||||
#endif /*__UI_BEACONLIST_H__*/
|
||||
+637
-707
File diff suppressed because it is too large
Load Diff
+216
-189
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2024 EPIRB Decoder Implementation
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -29,267 +30,293 @@
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_geomap.hpp"
|
||||
|
||||
// Specan is disable to keep application size below the 32k limit
|
||||
// #define SPECAN
|
||||
|
||||
// Comment to disable timout reset on select and save approx 200 bytes of flash
|
||||
#ifndef PRALINE
|
||||
// Application does not fit on Praline with RESET_TIMER enabled
|
||||
#define RESET_TIMER
|
||||
#endif
|
||||
// Comment to disable squelch control
|
||||
#define SQUELCH
|
||||
// Comment to disable beacon selection by encoder on detail tab
|
||||
#define DETAIL_TAB_BEACON_SEL
|
||||
// #define LOGGER
|
||||
|
||||
#ifdef SPECAN
|
||||
#include "ui_spectrum.hpp"
|
||||
#endif
|
||||
|
||||
#include "ui_tabview.hpp"
|
||||
|
||||
#include "ui_qrcode.hpp"
|
||||
|
||||
#include "event_m0.hpp"
|
||||
#include "signal.hpp"
|
||||
#include "message.hpp"
|
||||
#include "log_file.hpp"
|
||||
|
||||
#include "baseband_packet.hpp"
|
||||
|
||||
/* #include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <array> */
|
||||
#include "audio.hpp"
|
||||
|
||||
#include "beacon.hpp"
|
||||
#include "beacon_db.hpp"
|
||||
#include "ui_beaconlist.hpp"
|
||||
#include "resources.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_rx {
|
||||
|
||||
// EPIRB 406 MHz beacon types
|
||||
enum class BeaconType : uint8_t {
|
||||
OrbitingLocationBeacon = 0,
|
||||
PersonalLocatorBeacon = 1,
|
||||
EmergencyLocatorTransmitter = 2,
|
||||
SerialELT = 3,
|
||||
NationalELT = 4,
|
||||
Other = 15
|
||||
};
|
||||
|
||||
// EPIRB distress and emergency types
|
||||
enum class EmergencyType : uint8_t {
|
||||
Fire = 0,
|
||||
Flooding = 1,
|
||||
Collision = 2,
|
||||
Grounding = 3,
|
||||
Sinking = 4,
|
||||
Disabled = 5,
|
||||
Abandoning = 6,
|
||||
Piracy = 7,
|
||||
Man_Overboard = 8,
|
||||
Other = 15
|
||||
};
|
||||
|
||||
struct EPIRBLocation {
|
||||
float latitude; // degrees, -90 to +90
|
||||
float longitude; // degrees, -180 to +180
|
||||
bool valid;
|
||||
|
||||
EPIRBLocation()
|
||||
: latitude(0.0f), longitude(0.0f), valid(false) {}
|
||||
EPIRBLocation(float lat, float lon)
|
||||
: latitude(lat), longitude(lon), valid(true) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Status of a packet
|
||||
*/
|
||||
enum class PacketStatus : uint8_t {
|
||||
Valid = 0,
|
||||
Corrected = 1,
|
||||
Error = 2
|
||||
};
|
||||
|
||||
struct EPIRBBeacon {
|
||||
uint32_t beacon_id;
|
||||
BeaconType beacon_type;
|
||||
EmergencyType emergency_type;
|
||||
EPIRBLocation location;
|
||||
uint32_t country_code;
|
||||
std::string vessel_name;
|
||||
rtc::RTC timestamp;
|
||||
uint32_t sequence_number;
|
||||
PacketStatus packet_status;
|
||||
uint8_t error_count;
|
||||
|
||||
EPIRBBeacon()
|
||||
: beacon_id(0), beacon_type(BeaconType::Other), emergency_type(EmergencyType::Other), location(), country_code(0), vessel_name(), timestamp(), sequence_number(0), packet_status(PacketStatus::Error), error_count(0) {}
|
||||
};
|
||||
|
||||
class EPIRBDecoder {
|
||||
public:
|
||||
static EPIRBBeacon decode_packet(const baseband::Packet& packet);
|
||||
|
||||
private:
|
||||
static EPIRBLocation decode_location(const std::array<uint8_t, 16>& data);
|
||||
static BeaconType decode_beacon_type(uint8_t type_bits);
|
||||
static EmergencyType decode_emergency_type(uint8_t emergency_bits);
|
||||
static uint32_t decode_country_code(const std::array<uint8_t, 16>& data);
|
||||
static std::string decode_vessel_name(const std::array<uint8_t, 16>& data);
|
||||
|
||||
// BCH error correction methods
|
||||
static PacketStatus perform_bch_check(std::array<uint8_t, 16>& data, uint8_t& error_count);
|
||||
static uint32_t calculate_bch_syndrome(const std::array<uint8_t, 16>& data);
|
||||
static bool correct_single_error(std::array<uint8_t, 16>& data, uint32_t syndrome);
|
||||
static uint8_t count_bit_errors(const std::array<uint8_t, 16>& original, const std::array<uint8_t, 16>& corrected);
|
||||
};
|
||||
// Position of tabs in tab view
|
||||
#define EPIRB_TAB_POS_Y (UI_POS_Y(4) + 3 * 8)
|
||||
// Height of tabs in tab view
|
||||
#define EPIRB_TAB_HEIGHT (screen_height - EPIRB_TAB_POS_Y - UI_POS_HEIGHT(1))
|
||||
|
||||
#ifdef LOGGER
|
||||
class EPIRBLogger {
|
||||
public:
|
||||
Optional<File::Error> append(const std::filesystem::path& filename) {
|
||||
return log_file.append(filename);
|
||||
}
|
||||
|
||||
void on_packet(const EPIRBBeacon& beacon);
|
||||
void on_packet(Beacon& beacon);
|
||||
|
||||
private:
|
||||
LogFile log_file{};
|
||||
};
|
||||
#endif
|
||||
|
||||
// Forward declarations of formatting functions
|
||||
std::string format_beacon_type(BeaconType type);
|
||||
std::string format_emergency_type(EmergencyType type);
|
||||
std::string format_packet_status(PacketStatus status);
|
||||
ui::Color get_packet_status_color(PacketStatus status);
|
||||
|
||||
class EPIRBBeaconDetailView : public ui::View {
|
||||
/**
|
||||
* Dedicated TextArea component used to optimize application code size
|
||||
*/
|
||||
class TextArea : public Widget {
|
||||
public:
|
||||
std::function<void(void)> on_close{};
|
||||
TextArea(Rect parent_rect);
|
||||
|
||||
EPIRBBeaconDetailView(ui::NavigationView& nav);
|
||||
EPIRBBeaconDetailView(const EPIRBBeaconDetailView&) = delete;
|
||||
EPIRBBeaconDetailView& operator=(const EPIRBBeaconDetailView&) = delete;
|
||||
#ifdef RESET_TIMER
|
||||
std::function<void(TextArea&)> on_select{};
|
||||
bool on_key(const KeyEvent key) override;
|
||||
#endif
|
||||
|
||||
void set_beacon(const EPIRBBeacon& beacon);
|
||||
const EPIRBBeacon& beacon() const { return beacon_; }
|
||||
|
||||
void focus() override;
|
||||
void paint(ui::Painter&) override;
|
||||
|
||||
ui::GeoMapView* get_geomap_view() { return geomap_view; }
|
||||
void set_content(std::string_view value);
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
private:
|
||||
EPIRBBeacon beacon_{};
|
||||
|
||||
ui::Button button_done{
|
||||
{125, 224, 96, 24},
|
||||
"Done"};
|
||||
ui::Button button_see_map{
|
||||
{19, 224, 96, 24},
|
||||
"See on map"};
|
||||
|
||||
ui::GeoMapView* geomap_view{nullptr};
|
||||
|
||||
ui::Rect draw_field(
|
||||
ui::Painter& painter,
|
||||
const ui::Rect& draw_rect,
|
||||
const ui::Style& style,
|
||||
const std::string& label,
|
||||
const std::string& value);
|
||||
std::string content{};
|
||||
};
|
||||
|
||||
class EPIRBAppView : public ui::View {
|
||||
// Forward declaration
|
||||
class EPIRBAppView;
|
||||
|
||||
/**
|
||||
* View for beacon detail tab
|
||||
*/
|
||||
class EPIRBDetailView : public View {
|
||||
public:
|
||||
EPIRBDetailView(Rect parent_rect, EPIRBAppView& parent);
|
||||
void set_beacon(Beacon& beacon);
|
||||
#ifdef DETAIL_TAB_BEACON_SEL
|
||||
bool on_encoder(EncoderEvent delta) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
TextArea text_beacon{{UI_POS_X(0), UI_POS_Y(0), UI_POS_MAXWIDTH, EPIRB_TAB_HEIGHT}};
|
||||
EPIRBAppView& parent_app;
|
||||
};
|
||||
|
||||
#define EPIRB_RX_DEFAULT_LATITUDE 43.604f
|
||||
#define EPIRB_RX_DEFAULT_LONGITUDE 1.458f
|
||||
|
||||
/**
|
||||
* View for beacon map tab
|
||||
*/
|
||||
class EPIRBMapView : public View {
|
||||
public:
|
||||
EPIRBMapView(Rect parent_rect);
|
||||
void paint(Painter& painter) override;
|
||||
void on_show() override;
|
||||
void set_main_marker(const std::string& label, float lat, float lon);
|
||||
void clear_markers();
|
||||
void add_marker(GeoMarker& marker);
|
||||
void hide_map(bool hide);
|
||||
void repaint();
|
||||
|
||||
private:
|
||||
GeoMap geomap{{0, 0, UI_POS_MAXWIDTH, EPIRB_TAB_HEIGHT}};
|
||||
float lat_{EPIRB_RX_DEFAULT_LATITUDE};
|
||||
float lon_{EPIRB_RX_DEFAULT_LONGITUDE};
|
||||
bool map_hidden{true};
|
||||
};
|
||||
|
||||
#define QR_WIDTH 126
|
||||
#define QR_HEIGHT 127
|
||||
|
||||
/**
|
||||
* Vieaw for Beacon QR tab
|
||||
*/
|
||||
class EPRIBQRView : public View {
|
||||
public:
|
||||
EPRIBQRView(Rect parent_rect);
|
||||
EPRIBQRView(const EPRIBQRView&) = delete;
|
||||
EPRIBQRView& operator=(const EPRIBQRView&) = delete;
|
||||
|
||||
void set_beacon(Beacon* beacon);
|
||||
void update_qr();
|
||||
void update_display();
|
||||
|
||||
private:
|
||||
bool show_map{true};
|
||||
Beacon* current_beacon{nullptr};
|
||||
char qr_url[128];
|
||||
|
||||
OptionsField options_qr{
|
||||
{UI_POS_X(5), UI_POS_Y(1)},
|
||||
6,
|
||||
{{"Map", 0},
|
||||
{"Detail", 1}}};
|
||||
|
||||
QRCodeImage qr_code{
|
||||
{UI_POS_MAXWIDTH - QR_WIDTH - UI_POS_X(1), UI_POS_Y(1), QR_WIDTH, QR_HEIGHT}};
|
||||
|
||||
TextArea text_data{{UI_POS_X(0), UI_POS_Y(1), UI_POS_MAXWIDTH, EPIRB_TAB_HEIGHT - UI_POS_Y(1)}};
|
||||
};
|
||||
|
||||
#ifdef SPECAN
|
||||
class EPIRBRxView : public spectrum::WaterfallView {
|
||||
public:
|
||||
EPIRBRxView(EPIRBAppView& parent, Rect parent_rect);
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
|
||||
private:
|
||||
EPIRBAppView& app_view;
|
||||
};
|
||||
#endif
|
||||
|
||||
class EPIRBAppView final : public ui::View {
|
||||
public:
|
||||
EPIRBAppView(ui::NavigationView& nav);
|
||||
~EPIRBAppView();
|
||||
|
||||
void set_parent_rect(const ui::Rect new_parent_rect) override;
|
||||
void paint(ui::Painter&) override;
|
||||
void focus() override;
|
||||
void refresh();
|
||||
|
||||
// Message to configure rx baseband
|
||||
EPIRBRXConfig epirb_rx_config_message{};
|
||||
void send_config();
|
||||
// Beacons database
|
||||
BeaconDB beacon_db{};
|
||||
// Update display when beacon selection changed0
|
||||
void on_beacon_change();
|
||||
|
||||
std::string title() const override { return "EPIRB RX"; }
|
||||
|
||||
private:
|
||||
uint8_t squelch{50};
|
||||
// The delay between each frame
|
||||
uint32_t countdown{50};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_epirb", app_settings::Mode::RX};
|
||||
"rx_epirb",
|
||||
app_settings::Mode::RX,
|
||||
{
|
||||
{"epirb_squelch"sv, &squelch},
|
||||
{"countdown"sv, &countdown},
|
||||
}};
|
||||
|
||||
ui::NavigationView& nav_;
|
||||
|
||||
std::vector<EPIRBBeacon> recent_beacons{};
|
||||
#ifdef LOGGER
|
||||
std::unique_ptr<EPIRBLogger> logger{};
|
||||
#endif
|
||||
|
||||
EPIRBBeaconDetailView beacon_detail_view{nav_};
|
||||
|
||||
static constexpr auto header_height = 4 * 16;
|
||||
|
||||
ui::Text label_frequency{
|
||||
{UI_POS_X(0), UI_POS_Y(0), 4 * 8, 1 * 16},
|
||||
"Freq"};
|
||||
|
||||
ui::OptionsField options_frequency{
|
||||
{5 * 8, UI_POS_Y(0)},
|
||||
OptionsField options_frequency{
|
||||
{UI_POS_X(0), UI_POS_Y(0)},
|
||||
7,
|
||||
{
|
||||
{"406.028", 406028000},
|
||||
{"406.025", 406025000},
|
||||
{"406.037", 406037000},
|
||||
{"433.025", 433025000},
|
||||
{"144.875", 144875000},
|
||||
}};
|
||||
{}};
|
||||
|
||||
ui::RFAmpField field_rf_amp{
|
||||
{13 * 8, UI_POS_Y(0)}};
|
||||
{UI_POS_X(8), UI_POS_Y(0)}};
|
||||
|
||||
ui::LNAGainField field_lna{
|
||||
{15 * 8, UI_POS_Y(0)}};
|
||||
{UI_POS_X(10), UI_POS_Y(0)}};
|
||||
|
||||
ui::VGAGainField field_vga{
|
||||
{18 * 8, UI_POS_Y(0)}};
|
||||
{UI_POS_X(13), UI_POS_Y(0)}};
|
||||
|
||||
ui::RSSI rssi{
|
||||
{UI_POS_X(21), 0, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||
{UI_POS_X(16), UI_POS_Y(0), UI_POS_WIDTH_REMAINING(22), 4}};
|
||||
|
||||
ui::Channel channel{
|
||||
{UI_POS_X(21), 5, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||
{UI_POS_X(16), UI_POS_Y(0) + 5, UI_POS_WIDTH_REMAINING(22), 4}};
|
||||
|
||||
// ui::Audio audio{
|
||||
// {UI_POS_X(16), UI_POS_Y(0) + 10, UI_POS_WIDTH_REMAINING(22), 4}};
|
||||
|
||||
ui::AudioVolumeField field_volume{
|
||||
{screen_width - 2 * 8, UI_POS_Y(0)}};
|
||||
{UI_POS_WIDTH_REMAINING(2), UI_POS_Y(0)}};
|
||||
|
||||
#ifdef SQUELCH
|
||||
NumberField field_squelch{
|
||||
{UI_POS_WIDTH_REMAINING(5), UI_POS_Y(0)},
|
||||
2,
|
||||
{0, 99},
|
||||
1,
|
||||
' '};
|
||||
#endif
|
||||
|
||||
// Status display
|
||||
ui::Text label_status{
|
||||
{UI_POS_X(0), 1 * 16, 15 * 8, 1 * 16},
|
||||
"Listening..."};
|
||||
|
||||
ui::Text label_beacons_count{
|
||||
{16 * 8, 1 * 16, 14 * 8, 1 * 16},
|
||||
"Beacons: 0"};
|
||||
|
||||
ui::Text label_packet_stats{
|
||||
{UI_POS_X(0), 3 * 16, 29 * 8, 1 * 16},
|
||||
""};
|
||||
|
||||
// Latest beacon info display
|
||||
ui::Text label_latest{
|
||||
{UI_POS_X(0), 2 * 16, 8 * 8, 1 * 16},
|
||||
"Latest:"};
|
||||
|
||||
ui::Text text_latest_info{
|
||||
{8 * 8, 2 * 16, 22 * 8, 1 * 16},
|
||||
""};
|
||||
|
||||
// Beacon list
|
||||
ui::Console console{
|
||||
{0, 4 * 16, 240, 152}};
|
||||
|
||||
ui::Button button_map{
|
||||
{0, 224, 60, 24},
|
||||
"Map"};
|
||||
|
||||
ui::Button button_clear{
|
||||
{64, 224, 60, 24},
|
||||
"Clear"};
|
||||
|
||||
ui::Button button_log{
|
||||
{128, 224, 60, 24},
|
||||
"Log"};
|
||||
|
||||
TextArea text_status{{UI_POS_X(0), UI_POS_Y(1), UI_POS_MAXWIDTH, UI_POS_HEIGHT(3)}};
|
||||
TextArea text_timeout{
|
||||
{UI_POS_X(13), UI_POS_Y(1), UI_POS_WIDTH(3), UI_POS_HEIGHT(1)}};
|
||||
SignalToken signal_token_tick_second{};
|
||||
uint32_t beacons_received = 0;
|
||||
uint32_t packets_valid = 0;
|
||||
uint32_t packets_corrected = 0;
|
||||
uint32_t packets_error = 0;
|
||||
// Timeout string
|
||||
int16_t timeout{0};
|
||||
|
||||
// Tab View
|
||||
Rect view_rect = {0, EPIRB_TAB_POS_Y, UI_POS_MAXWIDTH, EPIRB_TAB_HEIGHT};
|
||||
|
||||
BeaconUIList view_list{view_rect};
|
||||
EPIRBDetailView view_detail{view_rect, (*this)};
|
||||
EPIRBMapView view_map{view_rect};
|
||||
#ifdef SPECAN
|
||||
EPIRBRxView view_rx{*this, view_rect};
|
||||
#endif
|
||||
|
||||
EPRIBQRView view_qr{view_rect};
|
||||
|
||||
TabView tab_view{
|
||||
{"List", Theme::getInstance()->fg_cyan->foreground, &view_list},
|
||||
{"Detail", Theme::getInstance()->fg_green->foreground, &view_detail},
|
||||
{"Map", Theme::getInstance()->fg_yellow->foreground, &view_map},
|
||||
#ifdef SPECAN
|
||||
{"RX", Theme::getInstance()->fg_orange->foreground, &view_rx},
|
||||
#endif
|
||||
{"QR", Theme::getInstance()->fg_orange->foreground, &view_qr}};
|
||||
|
||||
uint16_t beacons_received = 0;
|
||||
uint16_t packets_valid = 0;
|
||||
uint16_t packets_corrected = 0;
|
||||
uint16_t packets_error = 0;
|
||||
|
||||
MessageHandlerRegistration message_handler_packet{
|
||||
Message::ID::EPIRBPacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const EPIRBPacketMessage*>(p);
|
||||
this->on_packet(message->packet);
|
||||
}};
|
||||
[this](Message* const p) { on_packet(p); }};
|
||||
|
||||
void on_packet(const baseband::Packet& packet);
|
||||
void on_beacon_decoded(const EPIRBBeacon& beacon);
|
||||
void on_show_map();
|
||||
void on_clear_beacons();
|
||||
void on_toggle_log();
|
||||
static void decode_packet(const baseband::Packet& packet, Beacon& beacon);
|
||||
void on_packet(Message* const p);
|
||||
void update_map();
|
||||
void on_tick_second();
|
||||
|
||||
void update_display();
|
||||
std::string format_beacon_summary(const EPIRBBeacon& beacon);
|
||||
std::string format_location(const EPIRBLocation& location);
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::epirb_rx
|
||||
|
||||
+530
@@ -0,0 +1,530 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef __BEACON_H__
|
||||
#define __BEACON_H__
|
||||
|
||||
#include "portapack.hpp"
|
||||
#include "ui_epirb_tx.hpp"
|
||||
#include "location.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_tx {
|
||||
|
||||
/**
|
||||
* Get bits frop the provided frame
|
||||
* @param data the frame data
|
||||
* @param startBit the start bit number (one based to match documentation)
|
||||
* @param endBit the end bit number (one based to match documentation)
|
||||
* @return the selected bits (max 64)
|
||||
*/
|
||||
static uint64_t get_bits(uint8_t* data, int startBit, int endBit) {
|
||||
uint64_t result = 0;
|
||||
// 0 bases bit count
|
||||
startBit--;
|
||||
int numBits = endBit - startBit;
|
||||
|
||||
// get a pointer to the starting byte...
|
||||
const uint8_t* pData = &(data[startBit / 8]);
|
||||
uint8_t b = *pData;
|
||||
|
||||
// calculate the starting bit within that byte...
|
||||
int bitOffset = 7 - (startBit % 8);
|
||||
|
||||
// iterate for the desired number of bits...
|
||||
for (int i = 0; i < numBits; ++i) {
|
||||
// make room for the next bit...
|
||||
result <<= 1;
|
||||
// copy the bit...
|
||||
result |= ((b >> bitOffset) & 0x01);
|
||||
// reached the end of the current byte?
|
||||
if (--bitOffset < 0) {
|
||||
b = *(++pData); // go to the next byte...
|
||||
bitOffset = 7; // restart at the first bit in that byte...
|
||||
}
|
||||
}
|
||||
|
||||
// all done...
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute a BCH code
|
||||
* @param frame the frame data
|
||||
* @param startBit the bit to start BCH calculation
|
||||
* @param endBit the bit to stop calculation
|
||||
* @param poly the BCH polynome
|
||||
* @param polyLength the BCH polynome length
|
||||
* @return the BCH code
|
||||
*/
|
||||
static uint64_t compute_bch(uint8_t* frame, int startBit, int endBit, unsigned long poly, int polyLength) { // Length of data to be checked (not including the BCH code)
|
||||
int dataLength = endBit - startBit + 1;
|
||||
// Total lengh (including the BCH code that will be padded to zeros (BCH code length is polyLengh-1))
|
||||
int totalLength = dataLength + polyLength - 1;
|
||||
// Start with the first polyLength bits
|
||||
uint64_t result = get_bits(frame, startBit, startBit + polyLength - 1);
|
||||
for (int i = polyLength; i <= totalLength; i++) { // Iterate on each bit after the first polyLength batch
|
||||
bool firstBit = result >> (polyLength - 1);
|
||||
if (firstBit) { // We have a leading 1 => xor the result with the poly
|
||||
result = result ^ poly;
|
||||
}
|
||||
if (i < totalLength) { // Move to next bit
|
||||
result = result << 1;
|
||||
if (i < dataLength) { // Append next bit
|
||||
result |= get_bits(frame, startBit + i, startBit + i);
|
||||
} // else : 0 padding after data length
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 21 bits BCH polynomial
|
||||
#define BCH_21_POLYNOMIAL 0b1001101101100111100011UL
|
||||
#define BCH_21_POLY_LENGTH 22
|
||||
// 12 bits BCH polynomial
|
||||
#define BCH_12_POLYNOMIAL 0b1010100111001UL
|
||||
#define BCH_12_POLY_LENGTH 13
|
||||
|
||||
/**
|
||||
* Combyte BCH1 code for the provided frame
|
||||
*/
|
||||
static uint64_t compute_bch1(uint8_t* frame) {
|
||||
return compute_bch(frame, 25, 85, BCH_21_POLYNOMIAL, BCH_21_POLY_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Combyte BCH2 code for the provided frame
|
||||
*/
|
||||
static uint64_t compute_bch2(uint8_t* frame) {
|
||||
return compute_bch(frame, 107, 132, BCH_12_POLYNOMIAL, BCH_12_POLY_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a bit in the provided frame
|
||||
* @param buf the frame
|
||||
* @param bit the position of the bit to set (0 based)
|
||||
* @param v the bit value
|
||||
*/
|
||||
static void set_bit(uint8_t* buf, int bit, bool v) {
|
||||
int byte = bit >> 3;
|
||||
int off = 7 - (bit & 7);
|
||||
|
||||
if (v)
|
||||
buf[byte] |= (1 << off);
|
||||
else
|
||||
buf[byte] &= ~(1 << off);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push bits to the provided frame
|
||||
* @param buf the frame
|
||||
* @param pos the current frame possition (in/out, will be incremented during the opreration)
|
||||
* @param v the bits to push (max 64)
|
||||
* @param n the number of bits to push
|
||||
*/
|
||||
static void push_bits(uint8_t* buf, int& pos, uint64_t v, int n) {
|
||||
for (int i = n - 1; i >= 0; i--)
|
||||
set_bit(buf, pos++, (v >> i) & 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a beacon in the provided buffer
|
||||
* @param frame the buffer to generate the frame in
|
||||
* @param params the beacon parameters
|
||||
* @return the size of the generated frame
|
||||
*/
|
||||
size_t generate_beacon(uint8_t* frame, const BeaconParams& params) {
|
||||
// Clear the content of the frame
|
||||
memset(frame, 0, 18);
|
||||
|
||||
int pos = 0;
|
||||
uint32_t deg, min, sec;
|
||||
|
||||
// bit sync
|
||||
for (int i = 0; i < 15; i++)
|
||||
push_bits(frame, pos, 1, 1);
|
||||
|
||||
// frame sync
|
||||
push_bits(frame, pos, params.is_test ? 0b011010000 : 0b000101111, 9);
|
||||
|
||||
// PDF-1 (Protexted Data field 1)
|
||||
int pdf1_start = pos;
|
||||
|
||||
push_bits(frame, pos, 1, 1); // format flag (long)
|
||||
bool is_user = (params.protocol == BeaconProtocol::USER);
|
||||
bool is_standard = (params.protocol == BeaconProtocol::STANDARD);
|
||||
push_bits(frame, pos, is_user, 1); // protocol flag
|
||||
push_bits(frame, pos, params.country, 10); // country code
|
||||
switch (params.type) {
|
||||
case BeaconType::EPIRB:
|
||||
if (is_user)
|
||||
push_bits(frame, pos, 0b010, 3);
|
||||
else if (is_standard)
|
||||
push_bits(frame, pos, 0b0010, 4);
|
||||
else
|
||||
push_bits(frame, pos, 0b1010, 4);
|
||||
break;
|
||||
case BeaconType::PLB:
|
||||
if (is_user)
|
||||
push_bits(frame, pos, 0b011, 3);
|
||||
else if (is_standard)
|
||||
push_bits(frame, pos, 0b0111, 4);
|
||||
else
|
||||
push_bits(frame, pos, 0b1011, 4);
|
||||
break;
|
||||
default:
|
||||
case BeaconType::ELT:
|
||||
if (is_user)
|
||||
push_bits(frame, pos, 0b001, 3);
|
||||
else if (is_standard)
|
||||
push_bits(frame, pos, 0b0011, 4);
|
||||
else
|
||||
push_bits(frame, pos, 0b1000, 4);
|
||||
break;
|
||||
}
|
||||
|
||||
// Fill the rest of PDF 1 with zeros
|
||||
while (pos < pdf1_start + 61)
|
||||
push_bits(frame, pos, 0, 1);
|
||||
|
||||
if (is_user) {
|
||||
// User Location Protocol: no position in PDF1
|
||||
if (params.type == BeaconType::PLB) {
|
||||
// Set bits for PLB
|
||||
set_bit(frame, 40 - 1, 1);
|
||||
set_bit(frame, 41 - 1, 1);
|
||||
set_bit(frame, 42 - 1, 0);
|
||||
}
|
||||
|
||||
set_bit(frame, 85 - 1, params.has_121_5);
|
||||
} else if (is_standard) {
|
||||
// Standard Location Protocol
|
||||
// North / south
|
||||
set_bit(frame, 65 - 1, params.location.south);
|
||||
// E / W
|
||||
set_bit(frame, 75 - 1, params.location.west);
|
||||
pos = 66 - 1;
|
||||
// Latitude 1/4 degrees (9 bits)
|
||||
deg = (params.location.lat_deg << 2) + (params.location.lat_min / 15);
|
||||
push_bits(frame, pos, deg, 9);
|
||||
pos = 76 - 1;
|
||||
// Longitude 1/4 degrees (10 bits)
|
||||
deg = (params.location.long_deg << 2) + (params.location.long_min / 15);
|
||||
push_bits(frame, pos, deg, 10);
|
||||
pos = pdf1_start + 61;
|
||||
} else {
|
||||
// National Location Protocol
|
||||
// North / south
|
||||
set_bit(frame, 59 - 1, params.location.south);
|
||||
// E / W
|
||||
set_bit(frame, 72 - 1, params.location.west);
|
||||
pos = 60 - 1;
|
||||
// Latitude degrees (7 bits)
|
||||
push_bits(frame, pos, params.location.lat_deg, 7);
|
||||
// Latitude min (5 bits, 2 min increment)
|
||||
min = params.location.lat_min / 2;
|
||||
push_bits(frame, pos, min, 5);
|
||||
pos = 73 - 1;
|
||||
// Longitude degrees (8 bits)
|
||||
push_bits(frame, pos, params.location.long_deg, 8);
|
||||
// Longiitude min (5 bits, 2 min increment)
|
||||
min = params.location.long_min / 2;
|
||||
push_bits(frame, pos, min, 5);
|
||||
pos = pdf1_start + 61;
|
||||
}
|
||||
|
||||
// Set BCH1
|
||||
uint64_t bch1 = compute_bch1(frame);
|
||||
push_bits(frame, pos, bch1, 21);
|
||||
|
||||
// PDF-2 (Protexted Data Field 2)
|
||||
int pdf2_start = pos;
|
||||
if (is_user) {
|
||||
// User Location Protocol
|
||||
push_bits(frame, pos, params.is_internal, 1);
|
||||
// Latitude N/S
|
||||
push_bits(frame, pos, params.location.south, 1);
|
||||
// Latitude degrees (7 bits)
|
||||
push_bits(frame, pos, params.location.lat_deg, 7);
|
||||
// Latitude minutes (4 bits, 4 minutes precision)
|
||||
min = params.location.lat_min / 4;
|
||||
push_bits(frame, pos, min, 4);
|
||||
// Longitude E/W
|
||||
push_bits(frame, pos, params.location.west, 1);
|
||||
// Longitude degrees (8 bits)
|
||||
push_bits(frame, pos, params.location.long_deg, 8);
|
||||
// Longitude minutes (4 bits, 4 minutes precision)
|
||||
min = params.location.long_min / 4;
|
||||
push_bits(frame, pos, min, 4);
|
||||
} else if (is_standard) {
|
||||
// Standard Location Protocol
|
||||
push_bits(frame, pos, 0b1101, 4);
|
||||
push_bits(frame, pos, params.is_internal, 1);
|
||||
push_bits(frame, pos, params.has_121_5, 1);
|
||||
// Latiitude
|
||||
// +
|
||||
push_bits(frame, pos, 1, 1);
|
||||
// Min
|
||||
min = params.location.lat_min % 15;
|
||||
push_bits(frame, pos, min, 5);
|
||||
// Sec (4 bits, 4 sec precision)
|
||||
sec = params.location.lat_sec / 4;
|
||||
push_bits(frame, pos, sec, 4);
|
||||
// Longitude
|
||||
// +
|
||||
push_bits(frame, pos, 1, 1);
|
||||
// Min
|
||||
min = params.location.long_min % 15;
|
||||
push_bits(frame, pos, min, 5);
|
||||
// Sec (4 bits, 4 sec precision)
|
||||
sec = params.location.long_sec / 4;
|
||||
push_bits(frame, pos, sec, 4);
|
||||
} else {
|
||||
// National Location Protocol
|
||||
push_bits(frame, pos, 0b1101, 4);
|
||||
push_bits(frame, pos, params.is_internal, 1);
|
||||
push_bits(frame, pos, params.has_121_5, 1);
|
||||
// Lat
|
||||
// +
|
||||
push_bits(frame, pos, 1, 1);
|
||||
// Min
|
||||
push_bits(frame, pos, (params.location.lat_min % 2), 2);
|
||||
// Sec (4 bits, 4 sec precision)
|
||||
sec = params.location.lat_sec / 4;
|
||||
push_bits(frame, pos, sec, 4);
|
||||
// LLon
|
||||
// +
|
||||
push_bits(frame, pos, 1, 1);
|
||||
// Min
|
||||
push_bits(frame, pos, (params.location.long_min % 2), 2);
|
||||
// Sec (4 bits, 4 sec precision)
|
||||
sec = params.location.long_sec / 4;
|
||||
push_bits(frame, pos, sec, 4);
|
||||
}
|
||||
|
||||
while (pos < pdf2_start + 26)
|
||||
push_bits(frame, pos, 0, 1);
|
||||
|
||||
// Compute BCH 2
|
||||
uint64_t bch2 = compute_bch2(frame);
|
||||
push_bits(frame, pos, bch2, 12);
|
||||
return 18;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a beacon hex string representation (generic range)
|
||||
* @param frame the frame data
|
||||
* @param offset_bytes starting byte offset
|
||||
* @param count_bytes number of bytes to convert
|
||||
* @return the hex string representation
|
||||
*/
|
||||
std::string beacon_to_hex_string_range(const uint8_t* frame, int offset_bytes, int count_bytes) {
|
||||
static const char hex[] = "0123456789ABCDEF";
|
||||
std::string out;
|
||||
out.resize(count_bytes * 2);
|
||||
for (int i = 0; i < count_bytes; i++) {
|
||||
uint8_t b = frame[offset_bytes + i];
|
||||
out[i * 2] = hex[b >> 4];
|
||||
out[i * 2 + 1] = hex[b & 0x0F];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SGB (Second Generation Beacon) — T.018 Rev 7, March 2021
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Reference values from T.018 canonical test vector (Appendix B.1)
|
||||
#define SGB_TAC_NUMBER 230 // TAC number (16 bits, 0–65535)
|
||||
#define SGB_SERIAL_NUMBER 573 // Serial number within TAC (14 bits, 0–16383)
|
||||
#define SGB_HOMING_DEVICE 1 // 1 = beacon has 121.5 / 243 MHz homing device
|
||||
#define SGB_RLS_FUNCTION 0 // 0 = no Return Link Service function
|
||||
|
||||
// BCH(250,202) generator polynomial — lower 48 bits (without leading X^48 term)
|
||||
// Full g(x): X^48+X^47+X^46+X^42+X^41+X^40+X^39+X^38+X^37+X^35+X^33+X^32+X^31
|
||||
// +X^26+X^24+X^23+X^22+X^20+X^19+X^18+X^17+X^16+X^13+X^12+X^11+X^10
|
||||
// +X^7+X^4+X^2+X+1
|
||||
// Binary MSB-first: 1110001111110101110000101110111110011110010010111 (T.018 App. B.1)
|
||||
#define SGB_BCH_G_LOWER UINT64_C(0xC7EB85DF3C97)
|
||||
|
||||
/**
|
||||
* Encode latitude for SGB GNSS location protocol (T.018 Appendix C)
|
||||
* Pushes 23 bits: 1-bit N/S flag + 7-bit degrees + 15-bit decimal fraction
|
||||
* @param frame the frame buffer
|
||||
* @param pos current bit position (modified in-place)
|
||||
* @param south true if southern hemisphere
|
||||
* @param lat_mag absolute latitude in decimal degrees (0..90)
|
||||
*/
|
||||
static void push_sgb_latitude(uint8_t* frame, int& pos, bool south, float lat_mag) {
|
||||
push_bits(frame, pos, south ? 1 : 0, 1);
|
||||
uint32_t deg = (uint32_t)lat_mag;
|
||||
if (deg > 90) deg = 90;
|
||||
float frac = lat_mag - (float)deg;
|
||||
uint32_t frac_n = (uint32_t)(frac * 32768.0f + 0.5f);
|
||||
if (frac_n >= 32768) {
|
||||
frac_n = 0;
|
||||
if (deg < 90) deg++;
|
||||
}
|
||||
push_bits(frame, pos, deg, 7);
|
||||
push_bits(frame, pos, frac_n, 15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode longitude for SGB GNSS location protocol (T.018 Appendix C)
|
||||
* Pushes 24 bits: 1-bit E/W flag + 8-bit degrees + 15-bit decimal fraction
|
||||
* @param frame the frame buffer
|
||||
* @param pos current bit position (modified in-place)
|
||||
* @param west true if western hemisphere
|
||||
* @param lon_mag absolute longitude in decimal degrees (0..180)
|
||||
*/
|
||||
static void push_sgb_longitude(uint8_t* frame, int& pos, bool west, float lon_mag) {
|
||||
push_bits(frame, pos, west ? 1 : 0, 1);
|
||||
uint32_t deg = (uint32_t)lon_mag;
|
||||
if (deg > 180) deg = 180;
|
||||
float frac = lon_mag - (float)deg;
|
||||
uint32_t frac_n = (uint32_t)(frac * 32768.0f + 0.5f);
|
||||
if (frac_n >= 32768) {
|
||||
frac_n = 0;
|
||||
if (deg < 180) deg++;
|
||||
}
|
||||
push_bits(frame, pos, deg, 8);
|
||||
push_bits(frame, pos, frac_n, 15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute BCH(250,202) parity using LFSR method (T.018 Appendix B.1)
|
||||
* Reads 202 message bits from buffer positions 6..207 and writes
|
||||
* 48 BCH parity bits to buffer positions 208..255.
|
||||
* @param frame the 32-byte SGB buffer (message already written at bits 6..207)
|
||||
*/
|
||||
static void compute_sgb_bch(uint8_t* frame) {
|
||||
uint64_t reg = 0;
|
||||
for (int i = 0; i < 202; i++) {
|
||||
int bp = i + 6; // buffer bit position (6 = start of message after padding)
|
||||
bool msg_bit = (frame[bp >> 3] >> (7 - (bp & 7))) & 1;
|
||||
bool feedback = ((reg >> 47) & 1) ^ (msg_bit ? 1u : 0u);
|
||||
reg = (reg << 1) & UINT64_C(0xFFFFFFFFFFFF);
|
||||
if (feedback) reg ^= SGB_BCH_G_LOWER;
|
||||
}
|
||||
// Append 48-bit remainder at buffer positions 208..255
|
||||
int pos = 208;
|
||||
push_bits(frame, pos, reg, 48);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map BeaconType to SGB 3-bit beacon type code (T.018 Table 3.1, bits 138-140)
|
||||
* 000=ELT, 001=EPIRB, 010=PLB
|
||||
*/
|
||||
static uint8_t sgb_beacon_type_code(BeaconType t) {
|
||||
switch (t) {
|
||||
case BeaconType::EPIRB:
|
||||
return 0b001;
|
||||
case BeaconType::PLB:
|
||||
return 0b010;
|
||||
default:
|
||||
case BeaconType::ELT:
|
||||
return 0b000;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a Second Generation Beacon (SGB / T.018) frame.
|
||||
* The 250-bit frame is stored in 32 bytes with 6 leading padding bits
|
||||
* (bits 0..4 = 0, bit 5 = 1).
|
||||
* The rotating field is Type 0 — G.008 Objective Requirements (Table 3.3),
|
||||
* with elapsed_hours and time_last_loc_min updated from elapsed_s.
|
||||
* @param frame 32-byte output buffer
|
||||
* @param params beacon parameters
|
||||
* @param elapsed_s seconds elapsed since beacon activation (drives rotating field)
|
||||
* @return 32 (size of the generated frame in bytes)
|
||||
*/
|
||||
size_t generate_sgb_beacon(uint8_t* frame, const BeaconParams& params, uint32_t elapsed_s) {
|
||||
memset(frame, 0, 32);
|
||||
|
||||
// 6 padding bits at start of 32-byte buffer: [0,0,0,0,1,0] (5th bit (1 based index as per specification) = 1 to indicate self-test mode)
|
||||
set_bit(frame, 4, 1);
|
||||
|
||||
// Message bits start at buffer bit position 6 (= SGB message bit 1)
|
||||
int pos = 6;
|
||||
|
||||
// Bits 1-16: TAC number (16 bits) — T.018 Table 3.1
|
||||
push_bits(frame, pos, SGB_TAC_NUMBER, 16);
|
||||
// Bits 17-30: Serial number within TAC (14 bits)
|
||||
push_bits(frame, pos, SGB_SERIAL_NUMBER, 14);
|
||||
// Bits 31-40: Country code (10 bits, ITU MID)
|
||||
push_bits(frame, pos, params.country & 0x3FFU, 10);
|
||||
// Bit 41: Status of homing device (1 = has 121.5/243 MHz homing device)
|
||||
push_bits(frame, pos, params.has_121_5 ? 1 : 0, 1);
|
||||
// Bit 42: RLS function flag (0 = no RLS)
|
||||
push_bits(frame, pos, SGB_RLS_FUNCTION, 1);
|
||||
// Bit 43: Test protocol flag
|
||||
push_bits(frame, pos, params.is_test ? 1 : 0, 1);
|
||||
|
||||
// Bits 44-66: Encoded GNSS latitude (23 bits) — T.018 Appendix C
|
||||
float lat_mag = params.location.latitude < 0.0f ? -params.location.latitude : params.location.latitude;
|
||||
push_sgb_latitude(frame, pos, params.location.south, lat_mag);
|
||||
// Bits 67-90: Encoded GNSS longitude (24 bits)
|
||||
float lon_mag = params.location.longitude < 0.0f ? -params.location.longitude : params.location.longitude;
|
||||
push_sgb_longitude(frame, pos, params.location.west, lon_mag);
|
||||
|
||||
// Bits 91-137: Vessel ID (47 bits = 3-bit type selector + 44-bit body)
|
||||
// Type 000 = No aircraft/maritime identity; body all zeros
|
||||
push_bits(frame, pos, 0, 47);
|
||||
|
||||
// Bits 138-140: Beacon type (3 bits)
|
||||
push_bits(frame, pos, sgb_beacon_type_code(params.type), 3);
|
||||
|
||||
// Bits 141-154: Spare (14 bits, all 1s in normal operation)
|
||||
push_bits(frame, pos, 0x3FFFU, 14);
|
||||
|
||||
// Bits 155-202: Rotating Field Type 0 — G.008 Objective Requirements (Table 3.3)
|
||||
// Bits 155-158: Identifier (4 bits = 0000)
|
||||
push_bits(frame, pos, 0b0000U, 4);
|
||||
// Bits 159-164: Elapsed time since activation (6 bits, 0-63 h, truncated at 63)
|
||||
uint32_t elapsed_h = elapsed_s / 3600;
|
||||
if (elapsed_h > 63) elapsed_h = 63;
|
||||
push_bits(frame, pos, elapsed_h, 6);
|
||||
// Bits 165-175: Time from last encoded location (11 bits, 0-2046 min; 2047 = no fix)
|
||||
uint32_t loc_age_min = elapsed_s / 60;
|
||||
if (loc_age_min > 2046) loc_age_min = 2046;
|
||||
push_bits(frame, pos, loc_age_min, 11);
|
||||
// Bits 176-185: Altitude of encoded location (10 bits; 0x3FF = no altitude)
|
||||
push_bits(frame, pos, 0x3FFU, 10);
|
||||
// Bits 186-193: Dilution of Precision (4-bit HDOP + 4-bit VDOP; 0 = best HDOP, 0 = best VDOP)
|
||||
push_bits(frame, pos, 0b00000000U, 8);
|
||||
// Bits 194-195: Activation notification (00 = manual by user)
|
||||
push_bits(frame, pos, 0b00U, 2);
|
||||
// Bits 196-198: Remaining battery capacity (101 = >75%)
|
||||
push_bits(frame, pos, 0b101U, 3);
|
||||
// Bits 199-200: GNSS status (10 = 3D fix)
|
||||
push_bits(frame, pos, 0b10U, 2);
|
||||
// Bits 201-202: Spare (00)
|
||||
push_bits(frame, pos, 0b00U, 2);
|
||||
|
||||
// pos == 208: 6 padding + 202 message bits consumed
|
||||
|
||||
// Bits 203-250: BCH(250,202) parity (48 bits) computed and written at positions 208-255
|
||||
compute_sgb_bch(frame);
|
||||
|
||||
return 32;
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::epirb_tx
|
||||
|
||||
#endif /*__BEACON_H__*/
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef __LOCATION_H__
|
||||
#define __LOCATION_H__
|
||||
|
||||
#include "portapack.hpp"
|
||||
#include "ui_epirb_tx.hpp"
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
|
||||
namespace ui::external_app::epirb_tx {
|
||||
|
||||
/**
|
||||
* Convert decimal coordinates to sexagesimal coordinates
|
||||
* @param value the decimal value
|
||||
* @param negative output N(false)/S(true) or E(false)/W(true) value
|
||||
* @param deg output degrees value
|
||||
* @param min output minutes value
|
||||
* @param sec output seconds value
|
||||
*/
|
||||
static void decimal_to_dms(float value, bool& negative, int16_t& deg, int8_t& min, int8_t& sec) {
|
||||
negative = value < 0;
|
||||
value = std::fabs(value);
|
||||
|
||||
deg = (int16_t)value;
|
||||
|
||||
float m = (value - deg) * 60.0f;
|
||||
min = (int8_t)m;
|
||||
|
||||
float s = (m - min) * 60.0f;
|
||||
sec = (int8_t)(s + 0.5f);
|
||||
|
||||
if (sec == 60) {
|
||||
sec = 0;
|
||||
min++;
|
||||
}
|
||||
|
||||
if (min == 60) {
|
||||
min = 0;
|
||||
deg++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert sexagesimal coordinates to decimal
|
||||
* @param negative N(false)/S(true) or E(false)/W(true) value
|
||||
* @param deg degrees value
|
||||
* @param min minutes value
|
||||
* @param sec seconds value
|
||||
* @return value the decimal value
|
||||
*/
|
||||
static float dms_to_decimal(bool negative, int16_t deg, int8_t min, int8_t sec) {
|
||||
float v = deg + min / 60.0f + sec / 3600.0f;
|
||||
return negative ? -v : v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert maidenhead locator to decima coordinates
|
||||
* @param loc the locator
|
||||
* @param lat output latitude
|
||||
* @param lon output longitude
|
||||
*/
|
||||
static void maidenhead_to_decimal(const std::string& loc, float& lat, float& lon) {
|
||||
static const float lon_step[] =
|
||||
{
|
||||
20.0f,
|
||||
2.0f,
|
||||
1.0f / 12.0f,
|
||||
1.0f / 120.0f,
|
||||
1.0f / 2880.0f};
|
||||
|
||||
static const float lat_step[] =
|
||||
{
|
||||
10.0f,
|
||||
1.0f,
|
||||
1.0f / 24.0f,
|
||||
1.0f / 240.0f,
|
||||
1.0f / 5760.0f};
|
||||
|
||||
lon = -180.0f;
|
||||
lat = -90.0f;
|
||||
|
||||
int pairs = loc.size() / 2;
|
||||
|
||||
if (pairs > 5)
|
||||
pairs = 5;
|
||||
|
||||
if (pairs > 0) {
|
||||
for (int i = 0; i < pairs; i++) {
|
||||
char c1 = loc[i * 2];
|
||||
char c2 = loc[i * 2 + 1];
|
||||
if (c1 >= 'a' && c1 <= 'z') c1 -= ('a' - 'A');
|
||||
if (c2 >= 'a' && c2 <= 'z') c2 -= ('a' - 'A');
|
||||
|
||||
float lon_size = lon_step[i];
|
||||
float lat_size = lat_step[i];
|
||||
|
||||
int v1, v2;
|
||||
|
||||
if (i % 2 == 0) // letters
|
||||
{
|
||||
v1 = c1 - 'A';
|
||||
v2 = c2 - 'A';
|
||||
} else // digits
|
||||
{
|
||||
v1 = c1 - '0';
|
||||
v2 = c2 - '0';
|
||||
}
|
||||
|
||||
lon += v1 * lon_size;
|
||||
lat += v2 * lat_size;
|
||||
}
|
||||
|
||||
// Cell center
|
||||
lon += lon_step[pairs - 1] / 2.0f;
|
||||
lat += lat_step[pairs - 1] / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert decimal coordinates to maidenhead locator
|
||||
* @param lat the latitude
|
||||
* @param lon the longitude
|
||||
* @param precision (optional, defaults to 8) the number of charater for the maidenhead locator
|
||||
* @return the locator
|
||||
*/
|
||||
static std::string decimal_to_maidenhead(float lat, float lon, int precision = 8) {
|
||||
lon += 180.0f;
|
||||
lat += 90.0f;
|
||||
|
||||
int A = lon / 20;
|
||||
int B = lat / 10;
|
||||
|
||||
lon -= A * 20;
|
||||
lat -= B * 10;
|
||||
|
||||
int C = lon / 2;
|
||||
int D = lat / 1;
|
||||
|
||||
lon -= C * 2;
|
||||
lat -= D * 1;
|
||||
|
||||
int E = lon / (5.0f / 60.0f);
|
||||
int F = lat / (2.5f / 60.0f);
|
||||
|
||||
lon -= E * (5.0f / 60.0f);
|
||||
lat -= F * (2.5f / 60.0f);
|
||||
|
||||
int G = lon / (5.0f / 600.0f);
|
||||
int H = lat / (2.5f / 600.0f);
|
||||
|
||||
std::string locator;
|
||||
|
||||
locator += char('A' + A);
|
||||
locator += char('A' + B);
|
||||
|
||||
if (precision >= 4) {
|
||||
locator += char('0' + C);
|
||||
locator += char('0' + D);
|
||||
}
|
||||
|
||||
if (precision >= 6) {
|
||||
locator += char('a' + E);
|
||||
locator += char('a' + F);
|
||||
}
|
||||
|
||||
if (precision >= 8) {
|
||||
locator += char('0' + G);
|
||||
locator += char('0' + H);
|
||||
}
|
||||
|
||||
return locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the provided Location values from its locator
|
||||
*/
|
||||
void init_from_locator(Location& loc) {
|
||||
maidenhead_to_decimal(loc.locator, loc.latitude, loc.longitude);
|
||||
|
||||
decimal_to_dms(loc.latitude,
|
||||
loc.south,
|
||||
loc.lat_deg,
|
||||
loc.lat_min,
|
||||
loc.lat_sec);
|
||||
|
||||
decimal_to_dms(loc.longitude,
|
||||
loc.west,
|
||||
loc.long_deg,
|
||||
loc.long_min,
|
||||
loc.long_sec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the provided Location values from its decimal coordinates
|
||||
*/
|
||||
void init_from_decimal(Location& loc) {
|
||||
decimal_to_dms(loc.latitude,
|
||||
loc.south,
|
||||
loc.lat_deg,
|
||||
loc.lat_min,
|
||||
loc.lat_sec);
|
||||
|
||||
decimal_to_dms(loc.longitude,
|
||||
loc.west,
|
||||
loc.long_deg,
|
||||
loc.long_min,
|
||||
loc.long_sec);
|
||||
|
||||
loc.locator = decimal_to_maidenhead(loc.latitude, loc.longitude);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the provided Location values from its sexagesimal coordinates
|
||||
*/
|
||||
void init_from_dms(Location& loc) {
|
||||
loc.latitude = dms_to_decimal(
|
||||
loc.south,
|
||||
loc.lat_deg,
|
||||
loc.lat_min,
|
||||
loc.lat_sec);
|
||||
|
||||
loc.longitude = dms_to_decimal(
|
||||
loc.west,
|
||||
loc.long_deg,
|
||||
loc.long_min,
|
||||
loc.long_sec);
|
||||
|
||||
loc.locator = decimal_to_maidenhead(loc.latitude, loc.longitude);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the provided Loaction to it's latitude string (format <xxx°yy'zz"N>)
|
||||
*/
|
||||
std::string to_latitude_string(const Location& location) {
|
||||
char buffer[20];
|
||||
// Format : <xxx°yy'zz"N>
|
||||
sprintf(buffer, "%3d\260%02d'%02d\"%c", location.lat_deg, location.lat_min, location.lat_sec, location.south ? 'S' : 'N');
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the provided Loaction to it's longitude string (format <xxx°yy'zz"W>)
|
||||
*/
|
||||
std::string to_longitude_string(const Location& location) {
|
||||
char buffer[20];
|
||||
// Format : <xxx°yy'zz"W>
|
||||
sprintf(buffer, "%3d\260%02d'%02d\"%c", location.long_deg, location.long_min, location.long_sec, location.west ? 'W' : 'E');
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::epirb_tx
|
||||
|
||||
#endif /*__LOCATION_H__*/
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "ui_epirb_tx.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "external_app.hpp"
|
||||
|
||||
namespace ui::external_app::epirb_tx {
|
||||
void initialize_app(ui::NavigationView& nav) {
|
||||
nav.push<EPIRBTXAppView>();
|
||||
}
|
||||
} // namespace ui::external_app::epirb_tx
|
||||
extern "C" {
|
||||
|
||||
__attribute__((section(".external_app.app_epirb_tx.application_information"), used)) application_information_t _application_information_epirb_tx = {
|
||||
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||
/*.externalAppEntry = */ ui::external_app::epirb_tx::initialize_app,
|
||||
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||
/*.app_version = */ VERSION_MD5,
|
||||
|
||||
/*.app_name = */ "EPIRB TX",
|
||||
/*.bitmap_data = */ {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x7C,
|
||||
0x3E,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xF7,
|
||||
0xEF,
|
||||
0xE3,
|
||||
0xC7,
|
||||
0xE3,
|
||||
0xC7,
|
||||
0xE3,
|
||||
0xC7,
|
||||
0xE3,
|
||||
0xC7,
|
||||
0xF7,
|
||||
0xEF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0x7C,
|
||||
0x3E,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::green().v,
|
||||
/*.menu_location = */ app_location_t::TX,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_epirb_tx */ {'P', 'E', 'P', 'T'},
|
||||
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,709 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_epirb_tx.hpp"
|
||||
|
||||
#include "tonesets.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "file_reader.hpp"
|
||||
#include "file_path.hpp"
|
||||
#include "ui_geomap.hpp"
|
||||
#include "ui_alphanum.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "beacon.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
namespace ui::external_app::epirb_tx {
|
||||
|
||||
void EPIRBTXAppView::focus() {
|
||||
button_tx.focus();
|
||||
}
|
||||
|
||||
EPIRBTXAppView::~EPIRBTXAppView() {
|
||||
// Restore original frequency before leaving
|
||||
transmitter_model.set_target_frequency(original_frequency);
|
||||
transmitter_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion from hex char to half byte
|
||||
*/
|
||||
static uint8_t hexval(char c) {
|
||||
if (c >= '0' && c <= '9') return c - '0';
|
||||
if (c >= 'A' && c <= 'F') return c - 'A' + 10;
|
||||
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from hex chars to uint8_t
|
||||
*/
|
||||
static uint8_t hexToByte(char high, char low) {
|
||||
return (hexval(high) << 4) | hexval(low);
|
||||
}
|
||||
|
||||
std::string EPIRBTXAppView::frame_to_hex_string_range(int offset_bytes, int count_bytes) {
|
||||
return beacon_to_hex_string_range(epirb_tx_message.data, offset_bytes, count_bytes);
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::generate_frame(BeaconParams params) {
|
||||
if (format_sgb) {
|
||||
uint32_t elapsed_s = sgb_start_time > 0 ? (chTimeNow() - sgb_start_time) / 1000 : 0;
|
||||
epirb_tx_message.data_len = generate_sgb_beacon(epirb_tx_message.data, params, elapsed_s);
|
||||
} else {
|
||||
epirb_tx_message.data_len = generate_beacon(epirb_tx_message.data, params);
|
||||
}
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::on_timer() {
|
||||
// Timer is called on display refresh
|
||||
if (loop) {
|
||||
if (loop_enabled) {
|
||||
// chTimeNow() returns milliseconds on our version of ChibiOS / Hardware
|
||||
auto now = chTimeNow();
|
||||
auto elapsed = ((now - last_frame_time) / 1000);
|
||||
std::string timeout = to_string_dec_uint((uint32_t)(delay > elapsed ? delay - elapsed : 0));
|
||||
if (timeout != text_timeout.get()) {
|
||||
// Update timeout text every seconds
|
||||
text_timeout.set(timeout);
|
||||
}
|
||||
if (now > (last_frame_time + (delay * 1000))) {
|
||||
if (mode_file && slideshow_enabled) {
|
||||
// Move on to next frame
|
||||
selected_beacon++;
|
||||
if (selected_beacon >= beacons.size()) selected_beacon = 0;
|
||||
// Update selection
|
||||
file_mode_ui->options_frame.set_selected_index(selected_beacon);
|
||||
}
|
||||
// Send a new frame after the delay
|
||||
start_tx();
|
||||
}
|
||||
} else {
|
||||
// Stop send loop
|
||||
loop = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::update_bpsk_frequency() {
|
||||
bool was_transmitting = false;
|
||||
if (transmitting && (am_enabled || transmitting_bpsk)) {
|
||||
// We need to stop transmission before changing frequency
|
||||
transmitter_model.disable();
|
||||
was_transmitting = true;
|
||||
}
|
||||
transmitter_model.set_target_frequency(bpsk_frequency);
|
||||
// Update displayed frequency
|
||||
tx_view.on_show();
|
||||
if (was_transmitting) {
|
||||
// Start over
|
||||
start_tx();
|
||||
}
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::update_am_transmission() {
|
||||
if (am_enabled && transmitting && !transmitting_bpsk) {
|
||||
// Start am transmission
|
||||
// Restore am frequency
|
||||
epirb_tx_message.mode_406 = false;
|
||||
transmitter_model.set_target_frequency(am_frequency);
|
||||
// Send config to baseband
|
||||
baseband::set_epirb_tx_config(epirb_tx_message);
|
||||
// Start transmitting
|
||||
transmitter_model.enable();
|
||||
} else if (transmitting && !transmitting_bpsk) {
|
||||
// Stop am transmission
|
||||
transmitter_model.disable();
|
||||
tx_view.set_transmitting(false);
|
||||
}
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::update_frame(bool updateConfig) {
|
||||
if (mode_file) {
|
||||
// In file mode, currently selected beacon has changed => load the new one
|
||||
Beacon& beacon = beacons[selected_beacon];
|
||||
// Set desciption
|
||||
file_mode_ui->text_description.set(beacon.description.substr(0, max_text_width_ext));
|
||||
file_mode_ui->text_description_end.set(beacon.description.size() > max_text_width_ext ? "-" + beacon.description.substr(max_text_width_ext, max_text_width_ext + max_text_width_ext - 1) : "");
|
||||
// Udapte frame content on display
|
||||
bool is_fgb = beacon.frame.size() <= BEACON_HEXA_SIZE_FGB;
|
||||
if (is_fgb) {
|
||||
text_frame.set(beacon.frame.substr(0, BEACON_HEXA_SPLIT_FGB));
|
||||
text_frame_end.set(beacon.frame.size() > BEACON_HEXA_SPLIT_FGB ? beacon.frame.substr(BEACON_HEXA_SPLIT_FGB, BEACON_HEXA_SPLIT_FGB) : "");
|
||||
text_frame_sgb_end.set("");
|
||||
} else {
|
||||
text_frame.set(" " + beacon.frame.substr(1, BEACON_HEXA_SPLIT_SGB - 1));
|
||||
text_frame_end.set(beacon.frame.size() > BEACON_HEXA_SPLIT_SGB ? beacon.frame.substr(BEACON_HEXA_SPLIT_SGB, BEACON_HEXA_SPLIT_SGB) : "");
|
||||
text_frame_sgb_end.set(beacon.frame.size() > 2 * BEACON_HEXA_SPLIT_SGB ? beacon.frame.substr(2 * BEACON_HEXA_SPLIT_SGB, BEACON_HEXA_SPLIT_SGB) : "");
|
||||
}
|
||||
// Prepare tx configuration
|
||||
epirb_tx_message.data_len = std::min<size_t>((beacon.frame.size() / 2), BEACON_SIZE_SGB);
|
||||
for (uint8_t i = 0; i < epirb_tx_message.data_len; i++) {
|
||||
epirb_tx_message.data[i] = hexToByte(
|
||||
beacon.frame[2 * i],
|
||||
beacon.frame[2 * i + 1]);
|
||||
}
|
||||
} else {
|
||||
// In manual mode, generate frame content for current beacon params
|
||||
generate_frame(beacon_params);
|
||||
// Update frame content on display
|
||||
if (format_sgb) {
|
||||
// SGB: 32 bytes across 3 lines (BEACON_HEXA_SPLIT_SGB = 22 hex chars = 11 bytes)
|
||||
// Remove first nibble and replace it with a space to match COSPAS hexadecimal representation specification
|
||||
text_frame.set(" " + frame_to_hex_string_range(0, BEACON_HEXA_SPLIT_SGB / 2).substr(1));
|
||||
text_frame_end.set(frame_to_hex_string_range(BEACON_HEXA_SPLIT_SGB / 2, BEACON_HEXA_SPLIT_SGB / 2));
|
||||
text_frame_sgb_end.set(frame_to_hex_string_range(BEACON_HEXA_SPLIT_SGB, (BEACON_HEXA_SPLIT_SGB / 2) - 1));
|
||||
} else {
|
||||
text_frame.set(frame_to_hex_string_range(0, BEACON_HEXA_SPLIT_FGB / 2));
|
||||
text_frame_end.set(frame_to_hex_string_range(BEACON_HEXA_SPLIT_FGB / 2, BEACON_HEXA_SPLIT_FGB / 2));
|
||||
text_frame_sgb_end.set("");
|
||||
}
|
||||
}
|
||||
if (updateConfig && send_on_change && loop) {
|
||||
// Need to update config / send new beacon
|
||||
if (am_enabled) {
|
||||
// Already transmitting => update config
|
||||
last_frame_time = chTimeNow();
|
||||
update_config();
|
||||
} else {
|
||||
// Not yet transmitting => start tx
|
||||
start_tx();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::update_config() {
|
||||
if (!epirb_tx_message.mode_406) {
|
||||
// Previously in AM mode => restore bpsk frequency
|
||||
transmitter_model.set_target_frequency(bpsk_frequency);
|
||||
// Update displayed frequency
|
||||
tx_view.on_show();
|
||||
}
|
||||
// Set mode to bpsk
|
||||
epirb_tx_message.mode_406 = true;
|
||||
transmitting_bpsk = true;
|
||||
// Set pre/post count
|
||||
epirb_tx_message.pre_count = (160 * TONES_SAMPLERATE) / 1000; // 160 ms carrier (COSPAS spec.)
|
||||
epirb_tx_message.post_count = (100 * TONES_SAMPLERATE) / 1000; // 100 ms
|
||||
// Send config to baseband
|
||||
baseband::set_epirb_tx_config(epirb_tx_message);
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::set_tx_button_state(bool active) {
|
||||
button_tx.set_text(active ? "START" : "STOP");
|
||||
button_tx.set_style(active ? &style_tx_start : &style_tx_stop);
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::start_tx() {
|
||||
if (format_sgb && !mode_file) {
|
||||
// Track start time for the SGB rotating field elapsed-time counter
|
||||
if (!transmitting) sgb_start_time = chTimeNow();
|
||||
// update_frame regenerates the SGB frame with current elapsed time and refreshes display
|
||||
update_frame(false);
|
||||
set_dirty();
|
||||
}
|
||||
last_frame_time = chTimeNow();
|
||||
update_config();
|
||||
loop = loop_enabled;
|
||||
transmitter_model.enable();
|
||||
tx_view.set_transmitting(true);
|
||||
set_tx_button_state(false);
|
||||
transmitting = true;
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::stop_tx() {
|
||||
loop = false;
|
||||
transmitter_model.disable();
|
||||
tx_view.set_transmitting(false);
|
||||
set_tx_button_state(true);
|
||||
transmitting = false;
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::on_tx_progress(const uint32_t progress, const bool done) {
|
||||
(void)progress;
|
||||
if (done) {
|
||||
transmitting_bpsk = false;
|
||||
if (am_enabled) {
|
||||
// BPSK frame sent, switch back to 121.5 AM signal
|
||||
epirb_tx_message.mode_406 = false;
|
||||
// Start am transmission
|
||||
update_am_transmission();
|
||||
} else {
|
||||
// End of BPSK frame
|
||||
transmitter_model.disable();
|
||||
tx_view.set_transmitting(false);
|
||||
if (!loop) {
|
||||
// Not looping => update transmission state
|
||||
set_tx_button_state(true);
|
||||
transmitting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::update_location(bool updateLocatorField) {
|
||||
locator = beacon_params.location.locator;
|
||||
if (updateLocatorField) text_field_beacon_locator.set_text(beacon_params.location.locator);
|
||||
text_beacon_latitude_value.set(to_latitude_string(beacon_params.location));
|
||||
text_beacon_longitude_value.set(to_longitude_string(beacon_params.location));
|
||||
}
|
||||
|
||||
void EPIRBTXAppView::update_mode() {
|
||||
// Hide / show widgets for file mode or manual mode
|
||||
using option_t = std::pair<std::string, int32_t>;
|
||||
using options_t = std::vector<option_t>;
|
||||
if (mode_file) {
|
||||
// Load available beacons from BEACONS.TXT files (or default).
|
||||
load_beacons();
|
||||
if (!file_mode_ui) {
|
||||
file_mode_ui = std::make_unique<FileModeWidgets>();
|
||||
// Setup options_frame content with loaded beacons
|
||||
options_t entries;
|
||||
for (const auto& beacon : beacons)
|
||||
entries.emplace_back(beacon.title, entries.size());
|
||||
|
||||
file_mode_ui->options_frame.set_options(entries);
|
||||
if (selected_beacon >= beacons.size())
|
||||
// BEACONS.TXT file has changed since last launch, default index to 0
|
||||
selected_beacon = 0;
|
||||
file_mode_ui->options_frame.set_selected_index(selected_beacon);
|
||||
|
||||
file_mode_ui->options_frame.on_change = [this](size_t index, OptionsField::value_t) {
|
||||
selected_beacon = index;
|
||||
update_frame();
|
||||
set_dirty();
|
||||
};
|
||||
file_mode_ui->text_beacon.set_style(Theme::getInstance()->fg_light);
|
||||
file_mode_ui->text_description_label.set_style(Theme::getInstance()->fg_light);
|
||||
add_child(&file_mode_ui->text_beacon);
|
||||
add_child(&file_mode_ui->options_frame);
|
||||
add_child(&file_mode_ui->text_description_label);
|
||||
add_child(&file_mode_ui->text_description);
|
||||
add_child(&file_mode_ui->text_description_end);
|
||||
add_child(&file_mode_ui->checkbox_slideshow);
|
||||
// Restore settings
|
||||
file_mode_ui->checkbox_slideshow.set_value(slideshow_enabled);
|
||||
// Add callback
|
||||
file_mode_ui->checkbox_slideshow.on_select = [this](Checkbox&, bool v) {
|
||||
slideshow_enabled = v;
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// Clear beacons to save ram for Map display and Locatior editor
|
||||
if (file_mode_ui) {
|
||||
remove_child(&file_mode_ui->text_beacon);
|
||||
remove_child(&file_mode_ui->options_frame);
|
||||
remove_child(&file_mode_ui->text_description_label);
|
||||
remove_child(&file_mode_ui->text_description);
|
||||
remove_child(&file_mode_ui->text_description_end);
|
||||
remove_child(&file_mode_ui->checkbox_slideshow);
|
||||
file_mode_ui.reset();
|
||||
}
|
||||
beacons.clear();
|
||||
beacons.shrink_to_fit();
|
||||
}
|
||||
text_beacon_type.hidden(mode_file);
|
||||
text_beacon_country.hidden(mode_file);
|
||||
checkbox_beacon_internal.hidden(mode_file);
|
||||
text_beacon_locator.hidden(mode_file);
|
||||
text_beacon_latitude.hidden(mode_file);
|
||||
text_beacon_latitude_value.hidden(mode_file);
|
||||
text_beacon_longitude.hidden(mode_file);
|
||||
text_beacon_longitude_value.hidden(mode_file);
|
||||
button_mangps.hidden(mode_file);
|
||||
options_beacon_type.hidden(mode_file);
|
||||
options_beacon_protocol.hidden(mode_file);
|
||||
options_beacon_country.hidden(mode_file);
|
||||
options_format.hidden(mode_file);
|
||||
text_field_beacon_locator.hidden(mode_file);
|
||||
}
|
||||
|
||||
EPIRBTXAppView::EPIRBTXAppView(
|
||||
NavigationView& nav)
|
||||
: nav_{nav} {
|
||||
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
|
||||
|
||||
add_children({&labels,
|
||||
&options_mode,
|
||||
&text_beacon_type,
|
||||
&options_beacon_type,
|
||||
&options_beacon_protocol,
|
||||
&options_format,
|
||||
&text_beacon_country,
|
||||
&options_beacon_country,
|
||||
&checkbox_beacon_internal,
|
||||
&text_beacon_locator,
|
||||
&text_beacon_latitude,
|
||||
&text_beacon_latitude_value,
|
||||
&text_beacon_longitude,
|
||||
&text_beacon_longitude_value,
|
||||
&button_mangps,
|
||||
&text_field_beacon_locator,
|
||||
&text_frame,
|
||||
&text_frame_end,
|
||||
&text_frame_sgb_end,
|
||||
&text_timeout,
|
||||
&checkbox_loop,
|
||||
&field_delay,
|
||||
&button_tx,
|
||||
&checkbox_am,
|
||||
&field_am_frequency,
|
||||
&checkbox_send_on_change,
|
||||
&options_am_channel,
|
||||
&options_bpsk_channel,
|
||||
&tx_view});
|
||||
|
||||
text_beacon_type.set_style(Theme::getInstance()->fg_light);
|
||||
text_beacon_country.set_style(Theme::getInstance()->fg_light);
|
||||
text_beacon_locator.set_style(Theme::getInstance()->fg_light);
|
||||
text_beacon_latitude.set_style(Theme::getInstance()->fg_light);
|
||||
text_beacon_longitude.set_style(Theme::getInstance()->fg_light);
|
||||
|
||||
// Restore settings
|
||||
checkbox_am.set_value(am_enabled);
|
||||
checkbox_loop.set_value(loop_enabled);
|
||||
checkbox_send_on_change.set_value(send_on_change);
|
||||
options_mode.set_by_value(!mode_file);
|
||||
transmitter_model.set_target_frequency(bpsk_frequency);
|
||||
field_am_frequency.set_value(am_frequency);
|
||||
options_am_channel.set_by_value(am_channel);
|
||||
options_am_channel.set_style((am_channel == (uint8_t)AmChannel::REAL) ? Theme::getInstance()->fg_red : Theme::getInstance()->bg_darkest);
|
||||
manual_am_frequency = am_frequency;
|
||||
options_bpsk_channel.set_by_value(bpsk_channel);
|
||||
manual_bpsk_frequency = bpsk_frequency;
|
||||
field_delay.set_value(delay);
|
||||
options_beacon_type.set_by_value(beacon_type);
|
||||
options_beacon_protocol.set_by_value(beacon_protocol);
|
||||
options_beacon_country.set_by_value(beacon_country);
|
||||
checkbox_beacon_internal.set_value(beacon_internal);
|
||||
beacon_params.type = (BeaconType)beacon_type;
|
||||
beacon_params.has_121_5 = am_enabled;
|
||||
beacon_params.location.locator = locator;
|
||||
beacon_params.is_internal = beacon_internal;
|
||||
init_from_locator(beacon_params.location);
|
||||
update_mode();
|
||||
update_location();
|
||||
options_format.set_by_value(format_sgb ? 1 : 0);
|
||||
|
||||
options_mode.on_change = [this](size_t, OptionsField::value_t value) {
|
||||
mode_file = (((BeaconMode)value) == BeaconMode::FILE);
|
||||
update_mode();
|
||||
update_frame();
|
||||
set_dirty();
|
||||
};
|
||||
|
||||
options_beacon_type.on_change = [this](size_t, OptionsField::value_t value) {
|
||||
beacon_params.type = (BeaconType)value;
|
||||
beacon_type = value;
|
||||
update_frame();
|
||||
set_dirty();
|
||||
};
|
||||
|
||||
options_beacon_protocol.on_change = [this](size_t, OptionsField::value_t value) {
|
||||
beacon_params.protocol = (BeaconProtocol)value;
|
||||
beacon_protocol = value;
|
||||
update_frame();
|
||||
set_dirty();
|
||||
};
|
||||
|
||||
options_beacon_country.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
beacon_params.country = v;
|
||||
beacon_country = v;
|
||||
update_frame();
|
||||
set_dirty();
|
||||
};
|
||||
|
||||
options_format.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
format_sgb = (v == 1);
|
||||
sgb_start_time = 0; // reset elapsed counter when format changes
|
||||
update_frame();
|
||||
set_dirty();
|
||||
};
|
||||
|
||||
options_am_channel.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
bool is_real = false;
|
||||
switch ((AmChannel)v) {
|
||||
case AmChannel::REAL:
|
||||
is_real = true;
|
||||
am_frequency = AM_REAL_FREQUENCY;
|
||||
break;
|
||||
case AmChannel::MANUAL:
|
||||
am_frequency = manual_am_frequency;
|
||||
break;
|
||||
default:
|
||||
v = (uint8_t)AmChannel::TEST;
|
||||
// fallthrough
|
||||
case AmChannel::TEST:
|
||||
am_frequency = AM_TEST_FREQUENCY;
|
||||
break;
|
||||
}
|
||||
// Actual frequency change will be done by field_am_frequency.on_change()
|
||||
field_am_frequency.set_value(am_frequency);
|
||||
am_channel = v;
|
||||
options_am_channel.set_style(is_real ? Theme::getInstance()->fg_red : Theme::getInstance()->bg_darkest);
|
||||
set_dirty();
|
||||
};
|
||||
|
||||
options_bpsk_channel.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
switch ((BpskChannel)v) {
|
||||
case BpskChannel::MANUAL:
|
||||
bpsk_frequency = manual_bpsk_frequency;
|
||||
break;
|
||||
case BpskChannel::B:
|
||||
bpsk_frequency = BPSK_FREQUENCY_B;
|
||||
break;
|
||||
case BpskChannel::C:
|
||||
bpsk_frequency = BPSK_FREQUENCY_C;
|
||||
break;
|
||||
case BpskChannel::F:
|
||||
bpsk_frequency = BPSK_FREQUENCY_F;
|
||||
break;
|
||||
case BpskChannel::G:
|
||||
bpsk_frequency = BPSK_FREQUENCY_G;
|
||||
break;
|
||||
case BpskChannel::J:
|
||||
bpsk_frequency = BPSK_FREQUENCY_J;
|
||||
break;
|
||||
case BpskChannel::K:
|
||||
bpsk_frequency = BPSK_FREQUENCY_K;
|
||||
break;
|
||||
case BpskChannel::N:
|
||||
bpsk_frequency = BPSK_FREQUENCY_N;
|
||||
break;
|
||||
case BpskChannel::O:
|
||||
bpsk_frequency = BPSK_FREQUENCY_O;
|
||||
break;
|
||||
case BpskChannel::SGB:
|
||||
bpsk_frequency = BPSK_FREQUENCY_SGB;
|
||||
break;
|
||||
default:
|
||||
v = (uint8_t)BpskChannel::HAM;
|
||||
// fallthrough
|
||||
case BpskChannel::HAM:
|
||||
bpsk_frequency = BPSK_FREQUENCY_HAM;
|
||||
break;
|
||||
}
|
||||
bpsk_channel = v;
|
||||
update_bpsk_frequency();
|
||||
set_dirty();
|
||||
};
|
||||
|
||||
checkbox_beacon_internal.on_select = [this](Checkbox&, bool v) {
|
||||
beacon_internal = v;
|
||||
beacon_params.is_internal = v;
|
||||
update_frame();
|
||||
set_dirty();
|
||||
};
|
||||
|
||||
text_field_beacon_locator.on_select = [this](TextField&) mutable {
|
||||
auto te_view = nav_.push<AlphanumView>(locator, 10, ENTER_KEYBOARD_MODE_ALPHA);
|
||||
te_view->on_changed = [this](std::string& value) {
|
||||
beacon_params.location.locator = value;
|
||||
init_from_locator(beacon_params.location);
|
||||
update_location();
|
||||
update_frame();
|
||||
set_dirty();
|
||||
};
|
||||
};
|
||||
|
||||
button_mangps.on_select = [this](Button&) {
|
||||
nav_.push<GeoMapView>(
|
||||
0,
|
||||
GeoPos::alt_unit::METERS,
|
||||
GeoPos::spd_unit::HIDDEN,
|
||||
beacon_params.location.latitude,
|
||||
beacon_params.location.longitude,
|
||||
[this](int32_t, float lat, float lon, int32_t) {
|
||||
beacon_params.location.latitude = lat;
|
||||
beacon_params.location.longitude = lon;
|
||||
init_from_decimal(beacon_params.location);
|
||||
// Update locator field
|
||||
update_location();
|
||||
update_frame();
|
||||
set_dirty();
|
||||
});
|
||||
};
|
||||
|
||||
field_am_frequency.on_change = [this](rf::Frequency freq) {
|
||||
am_frequency = freq;
|
||||
if (transmitting && !transmitting_bpsk && am_enabled)
|
||||
// Update transmitter frequency
|
||||
transmitter_model.set_target_frequency(am_frequency);
|
||||
};
|
||||
|
||||
// Init frame content / baseband param with currently setup beacon
|
||||
update_frame(false);
|
||||
|
||||
checkbox_loop.on_select = [this](Checkbox&, bool v) {
|
||||
loop_enabled = v;
|
||||
};
|
||||
|
||||
field_delay.on_change = [this](int32_t v) {
|
||||
delay = v;
|
||||
};
|
||||
|
||||
checkbox_am.on_select = [this](Checkbox&, bool v) {
|
||||
beacon_params.has_121_5 = v;
|
||||
am_enabled = v;
|
||||
update_am_transmission();
|
||||
// We update the additional location device data in the frame based on this
|
||||
if (!mode_file) update_frame(false);
|
||||
};
|
||||
|
||||
// AM frequency field edit
|
||||
field_am_frequency.on_edit = [this]() {
|
||||
auto new_view = nav_.push<FrequencyKeypadView>(field_am_frequency.value());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
switch (f) {
|
||||
case AM_REAL_FREQUENCY:
|
||||
am_channel = (uint8_t)AmChannel::REAL;
|
||||
break;
|
||||
case AM_TEST_FREQUENCY:
|
||||
am_channel = (uint8_t)AmChannel::TEST;
|
||||
break;
|
||||
default:
|
||||
manual_am_frequency = f;
|
||||
am_channel = (uint8_t)AmChannel::MANUAL;
|
||||
break;
|
||||
}
|
||||
// Actual frequency change will be done by options_am_channel.on_change()
|
||||
options_am_channel.set_by_value(am_channel);
|
||||
set_dirty();
|
||||
};
|
||||
};
|
||||
|
||||
checkbox_send_on_change.on_select = [this](Checkbox&, bool v) {
|
||||
send_on_change = v;
|
||||
};
|
||||
|
||||
tx_view.on_edit_frequency = [this]() {
|
||||
auto new_view = nav_.push<FrequencyKeypadView>(transmitter_model.target_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
bpsk_frequency = f;
|
||||
switch (f) {
|
||||
case BPSK_FREQUENCY_HAM:
|
||||
bpsk_channel = (uint8_t)BpskChannel::HAM;
|
||||
break;
|
||||
case BPSK_FREQUENCY_B:
|
||||
bpsk_channel = (uint8_t)BpskChannel::B;
|
||||
break;
|
||||
case BPSK_FREQUENCY_C:
|
||||
bpsk_channel = (uint8_t)BpskChannel::C;
|
||||
break;
|
||||
case BPSK_FREQUENCY_F:
|
||||
bpsk_channel = (uint8_t)BpskChannel::F;
|
||||
break;
|
||||
case BPSK_FREQUENCY_G:
|
||||
bpsk_channel = (uint8_t)BpskChannel::G;
|
||||
break;
|
||||
case BPSK_FREQUENCY_J:
|
||||
bpsk_channel = (uint8_t)BpskChannel::J;
|
||||
break;
|
||||
case BPSK_FREQUENCY_K:
|
||||
bpsk_channel = (uint8_t)BpskChannel::K;
|
||||
break;
|
||||
case BPSK_FREQUENCY_N:
|
||||
bpsk_channel = (uint8_t)BpskChannel::N;
|
||||
break;
|
||||
case BPSK_FREQUENCY_O:
|
||||
bpsk_channel = (uint8_t)BpskChannel::O;
|
||||
break;
|
||||
case BPSK_FREQUENCY_SGB:
|
||||
bpsk_channel = (uint8_t)BpskChannel::SGB;
|
||||
break;
|
||||
default:
|
||||
bpsk_channel = (uint8_t)BpskChannel::MANUAL;
|
||||
manual_bpsk_frequency = bpsk_frequency;
|
||||
break;
|
||||
}
|
||||
// Actual frequency change will be done by options_bpsk_channel.on_change()
|
||||
options_bpsk_channel.set_by_value(bpsk_channel);
|
||||
set_dirty();
|
||||
};
|
||||
};
|
||||
|
||||
tx_view.on_start = [this]() {
|
||||
start_tx();
|
||||
};
|
||||
|
||||
tx_view.on_stop = [this]() {
|
||||
stop_tx();
|
||||
};
|
||||
|
||||
button_tx.on_select = [this](Button&) {
|
||||
if (!transmitting)
|
||||
start_tx();
|
||||
else
|
||||
stop_tx();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Load beacons from /EPIRB/BEACONS.TXT file on sd card
|
||||
*/
|
||||
void EPIRBTXAppView::load_beacons() {
|
||||
File beacons_file;
|
||||
auto error = beacons_file.open(epirb_dir / u"BEACONS.TXT");
|
||||
beacons.clear();
|
||||
|
||||
if (!error) {
|
||||
// BEACONS.TXT file exists
|
||||
auto reader = FileLineReader(beacons_file);
|
||||
for (const auto& line : reader) {
|
||||
// Skip comment lines
|
||||
if (line.length() == 0 || line[0] == '#')
|
||||
continue;
|
||||
|
||||
// Split line with ';' separator
|
||||
auto cols = split_string(line, ';');
|
||||
if (cols.size() != 3)
|
||||
continue;
|
||||
|
||||
// Read current beacon
|
||||
Beacon beacon{};
|
||||
beacon.title = trim(cols[0]);
|
||||
beacon.description = trim(cols[1]);
|
||||
// 1G uses up to 36 hex chars, 2G uses 64 hex chars (250 bits rounded to 32 bytes).
|
||||
beacon.frame = trim(cols[2]).substr(0, BEACON_HEXA_SIZE_SGB);
|
||||
size_t size = beacon.frame.size();
|
||||
if (size <= 0)
|
||||
continue; // Invalid line.
|
||||
if ((size % 2) != 0) {
|
||||
beacon.frame = "0" + beacon.frame; // Pad with leading 0 to make it even length
|
||||
}
|
||||
// Beacon is valid, add it to the list
|
||||
beacons.emplace_back(std::move(beacon));
|
||||
}
|
||||
}
|
||||
if (beacons.empty()) {
|
||||
// No beacons file or empty flile: just add default beacon
|
||||
beacons.push_back(default_beacon);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::epirb_tx
|
||||
@@ -0,0 +1,438 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __EPIRB_TX_H__
|
||||
#define __EPIRB_TX_H__
|
||||
|
||||
#include "app_settings.hpp"
|
||||
#include "radio_state.hpp"
|
||||
#include "ui.hpp"
|
||||
#include "ui_widget.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_transmitter.hpp"
|
||||
|
||||
#include "portapack.hpp"
|
||||
#include "message.hpp"
|
||||
#include "tonesets.hpp"
|
||||
|
||||
#define BEACON_SIZE_FGB 18
|
||||
#define BEACON_SIZE_SGB 32
|
||||
#define BEACON_HEXA_SIZE_FGB BEACON_SIZE_FGB * 2
|
||||
#define BEACON_HEXA_SIZE_SGB BEACON_SIZE_SGB * 2
|
||||
#define BEACON_HEXA_SPLIT_FGB 18
|
||||
#define BEACON_HEXA_SPLIT_SGB 22
|
||||
|
||||
#define AM_TEST_FREQUENCY 121375000
|
||||
#define AM_REAL_FREQUENCY 121500000
|
||||
|
||||
#define BPSK_FREQUENCY_HAM 433025000
|
||||
#define BPSK_FREQUENCY_B 406025000
|
||||
#define BPSK_FREQUENCY_C 406028000
|
||||
#define BPSK_FREQUENCY_F 406037000
|
||||
#define BPSK_FREQUENCY_G 406040000
|
||||
#define BPSK_FREQUENCY_J 406049000
|
||||
#define BPSK_FREQUENCY_K 406052000
|
||||
#define BPSK_FREQUENCY_N 406061000
|
||||
#define BPSK_FREQUENCY_O 406064000
|
||||
#define BPSK_FREQUENCY_SGB 406050000
|
||||
|
||||
namespace ui::external_app::epirb_tx {
|
||||
|
||||
enum class BeaconMode {
|
||||
FILE = 0,
|
||||
MODE_MANUAL = 1
|
||||
};
|
||||
|
||||
enum class BeaconType {
|
||||
EPIRB = 0,
|
||||
ELT = 1,
|
||||
PLB = 2
|
||||
};
|
||||
|
||||
enum class BeaconProtocol {
|
||||
USER = 0,
|
||||
STANDARD = 1,
|
||||
NATIONAL = 2
|
||||
};
|
||||
|
||||
enum class AmChannel {
|
||||
TEST = 0,
|
||||
REAL = 1,
|
||||
MANUAL = 2
|
||||
};
|
||||
|
||||
enum class BpskChannel {
|
||||
HAM = 0,
|
||||
B = 1,
|
||||
C = 2,
|
||||
F = 3,
|
||||
G = 4,
|
||||
J = 5,
|
||||
K = 6,
|
||||
N = 7,
|
||||
O = 8,
|
||||
MANUAL = 10,
|
||||
SGB = 100
|
||||
};
|
||||
|
||||
struct Location {
|
||||
std::string locator;
|
||||
bool south;
|
||||
int16_t lat_deg;
|
||||
int8_t lat_min;
|
||||
int8_t lat_sec;
|
||||
float latitude;
|
||||
bool west;
|
||||
int16_t long_deg;
|
||||
int8_t long_min;
|
||||
int8_t long_sec;
|
||||
float longitude;
|
||||
};
|
||||
|
||||
struct BeaconParams {
|
||||
BeaconType type;
|
||||
BeaconProtocol protocol;
|
||||
uint32_t country;
|
||||
bool is_test;
|
||||
bool is_internal;
|
||||
bool has_121_5;
|
||||
Location location;
|
||||
};
|
||||
|
||||
class EPIRBTXAppView : public View {
|
||||
public:
|
||||
EPIRBTXAppView(NavigationView& nav);
|
||||
~EPIRBTXAppView();
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "EPIRB TX"; };
|
||||
|
||||
private:
|
||||
void start_tx();
|
||||
void stop_tx();
|
||||
void update_config();
|
||||
void on_tx_progress(const uint32_t progress, const bool done);
|
||||
void on_timer();
|
||||
void load_beacons();
|
||||
void set_tx_button_state(bool active);
|
||||
std::string frame_to_hex_string_range(int offset_bytes, int count_bytes);
|
||||
void generate_frame(BeaconParams params);
|
||||
void update_frame(bool updateConfig = true);
|
||||
void update_bpsk_frequency();
|
||||
void update_am_transmission();
|
||||
void update_mode();
|
||||
void update_location(bool updateLocatorField = true);
|
||||
|
||||
struct Beacon {
|
||||
std::string title{};
|
||||
std::string description{};
|
||||
std::string frame{};
|
||||
};
|
||||
NavigationView& nav_;
|
||||
|
||||
std::vector<Beacon> beacons{};
|
||||
Beacon default_beacon{"Self test", "Serial User Location Protocol", "FFFED0D6E6202820000C29FF51041775302D"};
|
||||
|
||||
BeaconParams beacon_params{BeaconType::ELT, BeaconProtocol::STANDARD, 227, true, true, true, {"JN03RO", false, 0, 0, 0, 0, false, 0, 0, 0, 0}};
|
||||
|
||||
// Currently selected beacon index (from BEACONS.TXT file / options_frame combo)
|
||||
uint32_t selected_beacon{0};
|
||||
|
||||
// Frequency of the transmitter before starting the app (used to restore frequency when leaving)
|
||||
rf::Frequency original_frequency{0};
|
||||
// Frequency of the AM emergency signal
|
||||
rf::Frequency am_frequency{AM_TEST_FREQUENCY};
|
||||
// Frequency of the 406 MHz BPSK signal
|
||||
rf::Frequency bpsk_frequency{BPSK_FREQUENCY_HAM};
|
||||
// Selected am channel
|
||||
uint8_t am_channel{(uint8_t)AmChannel::TEST};
|
||||
// Selected bpsk channel
|
||||
uint8_t bpsk_channel{(uint8_t)BpskChannel::HAM};
|
||||
// Manual AM frequency value
|
||||
rf::Frequency manual_am_frequency{AM_TEST_FREQUENCY};
|
||||
// Manual BPSK frequency value
|
||||
rf::Frequency manual_bpsk_frequency{BPSK_FREQUENCY_HAM};
|
||||
|
||||
// True when using a beacon from the BEACONS.TXT file
|
||||
bool mode_file{false};
|
||||
// True when slideshow is enabled for file mode (change beacon after every transmission)
|
||||
bool slideshow_enabled{false};
|
||||
// True when looping on sending beacons is enabled
|
||||
bool loop_enabled{true};
|
||||
// True if AM emergency signal transmission is enabled
|
||||
bool am_enabled{true};
|
||||
// True if we want to send a new frame each time the user changes the current beacon
|
||||
bool send_on_change{true};
|
||||
// The current locator string
|
||||
std::string locator{"JN03RO"};
|
||||
// The delay between each frame when on loop mode
|
||||
uint32_t delay{50};
|
||||
uint8_t beacon_type{(uint8_t)BeaconType::EPIRB};
|
||||
// Currently selected beacon protocol
|
||||
uint8_t beacon_protocol{(uint8_t)BeaconProtocol::USER};
|
||||
// Currently selected beacon country
|
||||
uint32_t beacon_country{227};
|
||||
// Current beacon's internal state (true for internal location system)
|
||||
bool beacon_internal{true};
|
||||
|
||||
TxRadioState radio_state_{
|
||||
0 /* frequency */,
|
||||
1750000 /* bandwidth */,
|
||||
TONES_SAMPLERATE /* sampling rate */
|
||||
};
|
||||
app_settings::SettingsManager settings_{
|
||||
"tx_epirb",
|
||||
app_settings::Mode::TX,
|
||||
{
|
||||
{"sbeacon"sv, &selected_beacon},
|
||||
{"amfreq"sv, &am_frequency},
|
||||
{"bpskfreq"sv, &bpsk_frequency},
|
||||
{"amchan"sv, &am_channel},
|
||||
{"bpskchan"sv, &bpsk_channel},
|
||||
{"loop"sv, &loop_enabled},
|
||||
{"delay"sv, &delay},
|
||||
{"file"sv, &mode_file},
|
||||
{"slideshow"sv, &slideshow_enabled},
|
||||
{"am"sv, &am_enabled},
|
||||
{"soc"sv, &send_on_change},
|
||||
{"type"sv, &beacon_type},
|
||||
{"proto"sv, &beacon_protocol},
|
||||
{"country"sv, &beacon_country},
|
||||
{"internal"sv, &beacon_internal},
|
||||
{"locator"sv, &locator},
|
||||
{"sgb"sv, &format_sgb},
|
||||
}};
|
||||
|
||||
// Time of the last sent frame
|
||||
uint32_t last_frame_time{0};
|
||||
// True when transmission is enabled
|
||||
bool transmitting{false};
|
||||
// True when transmitting a BPSK frame
|
||||
bool transmitting_bpsk{false};
|
||||
// True when currently looping on sending beacons
|
||||
bool loop{false};
|
||||
// True when SGB (Second Generation Beacon) format is selected
|
||||
bool format_sgb{false};
|
||||
// System time (ms) when the current SGB transmission session started
|
||||
uint32_t sgb_start_time{0};
|
||||
|
||||
// Current EPIRBTXDataMessage for baseband
|
||||
EPIRBTXDataMessage epirb_tx_message{};
|
||||
|
||||
const size_t max_text_width = UI_POS_WIDTH_REMAINING(6) / UI_POS_DEFAULT_WIDTH;
|
||||
const size_t max_text_width_ext = UI_POS_WIDTH_REMAINING(0) / UI_POS_DEFAULT_WIDTH;
|
||||
|
||||
Labels labels{
|
||||
{{UI_POS_X(0), UI_POS_Y(0)}, "Source:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(6)}, "Frame:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(10)}, "Next frame in s.", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(12)}, "AM frequency: MHz", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(14)}, "AM chan.:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(15)}, "BPSK chan.:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(17), UI_POS_Y(9)}, "s.", Theme::getInstance()->fg_light->foreground}};
|
||||
|
||||
// For file mode
|
||||
struct FileModeWidgets {
|
||||
Text text_beacon{
|
||||
{UI_POS_X(0), UI_POS_Y(1), UI_POS_WIDTH(7), UI_POS_DEFAULT_HEIGHT},
|
||||
"Beacon:"};
|
||||
// Beacon selection from BEACONS.TXT
|
||||
OptionsField options_frame{
|
||||
{UI_POS_X(7), UI_POS_Y(1)},
|
||||
30,
|
||||
{}};
|
||||
Text text_description_label{
|
||||
{UI_POS_X(0), UI_POS_Y(2), UI_POS_WIDTH(12), UI_POS_DEFAULT_HEIGHT},
|
||||
"Description:"};
|
||||
Text text_description{
|
||||
{UI_POS_X(0), UI_POS_Y(3), UI_POS_WIDTH_REMAINING(0), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
Text text_description_end{
|
||||
{UI_POS_X(0), UI_POS_Y(4), UI_POS_WIDTH_REMAINING(0), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
Checkbox checkbox_slideshow{
|
||||
{UI_POS_X(0), UI_POS_Y(5)},
|
||||
9,
|
||||
"Slideshow",
|
||||
true};
|
||||
};
|
||||
std::unique_ptr<FileModeWidgets> file_mode_ui{};
|
||||
|
||||
// For manual mode
|
||||
Text text_beacon_type{
|
||||
{UI_POS_X(0), UI_POS_Y(1), UI_POS_WIDTH(8), UI_POS_DEFAULT_HEIGHT},
|
||||
"Type:"};
|
||||
Text text_beacon_country{
|
||||
{UI_POS_X(0), UI_POS_Y(2), UI_POS_WIDTH(8), UI_POS_DEFAULT_HEIGHT},
|
||||
"Country:"};
|
||||
Checkbox checkbox_beacon_internal{
|
||||
{UI_POS_X_RIGHT(12), UI_POS_Y(2)},
|
||||
12,
|
||||
"Internal",
|
||||
true};
|
||||
Text text_beacon_locator{
|
||||
{UI_POS_X(0), UI_POS_Y(3), UI_POS_WIDTH(8), UI_POS_DEFAULT_HEIGHT},
|
||||
"Locator:"};
|
||||
Text text_beacon_latitude{
|
||||
{UI_POS_X(0), UI_POS_Y(4), UI_POS_WIDTH(8), UI_POS_DEFAULT_HEIGHT},
|
||||
"Lat.:"};
|
||||
Text text_beacon_longitude{
|
||||
{UI_POS_X(0), UI_POS_Y(5), UI_POS_WIDTH(8), UI_POS_DEFAULT_HEIGHT},
|
||||
"Long.:"};
|
||||
Text text_beacon_latitude_value{
|
||||
{UI_POS_X(7), UI_POS_Y(4), UI_POS_WIDTH(12), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
Text text_beacon_longitude_value{
|
||||
{UI_POS_X(7), UI_POS_Y(5), UI_POS_WIDTH(12), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
OptionsField options_beacon_type{
|
||||
{UI_POS_X(9), UI_POS_Y(1)},
|
||||
7,
|
||||
{{"EPIRB", (uint8_t)BeaconType::EPIRB},
|
||||
{"ELT", (uint8_t)BeaconType::ELT},
|
||||
{"PLB", (uint8_t)BeaconType::PLB}}};
|
||||
OptionsField options_beacon_protocol{
|
||||
{UI_POS_X(9 + 7), UI_POS_Y(1)},
|
||||
8,
|
||||
{{"User", (uint8_t)BeaconProtocol::USER},
|
||||
{"Standard", (uint8_t)BeaconProtocol::STANDARD},
|
||||
{"National", (uint8_t)BeaconProtocol::NATIONAL}}};
|
||||
// Format selector (FGB / SGB) — manual mode only, same row as type/protocol
|
||||
OptionsField options_format{
|
||||
{UI_POS_X_RIGHT(4), UI_POS_Y(1)},
|
||||
4,
|
||||
{{"FGB", 0},
|
||||
{"SGB", 1}}};
|
||||
|
||||
OptionsField options_beacon_country{
|
||||
{UI_POS_X(9), UI_POS_Y(2)},
|
||||
7,
|
||||
{{"France", 227},
|
||||
{"USA", 366},
|
||||
{"Germany", 211},
|
||||
{"Russia", 273},
|
||||
{"Spain", 224},
|
||||
{"Japan", 431},
|
||||
{"UK", 232}}};
|
||||
TextField text_field_beacon_locator{
|
||||
{UI_POS_X(9), UI_POS_Y(3), UI_POS_WIDTH(10), UI_POS_DEFAULT_HEIGHT},
|
||||
"JN03RO"};
|
||||
Button button_mangps{
|
||||
{UI_POS_X_RIGHT(9), UI_POS_Y(3), UI_POS_WIDTH(9), UI_POS_HEIGHT(2)},
|
||||
"Set pos."};
|
||||
|
||||
// Mode selection (file/manual)
|
||||
OptionsField options_mode{
|
||||
{UI_POS_X(7), UI_POS_Y(0)},
|
||||
30,
|
||||
{{"File (BEACONS.TXT)", (uint8_t)BeaconMode::FILE},
|
||||
{"Manual (Editor)", (uint8_t)BeaconMode::MODE_MANUAL}}};
|
||||
|
||||
// Frame content
|
||||
Text text_frame{
|
||||
{UI_POS_X(6), UI_POS_Y(6), UI_POS_WIDTH_REMAINING(6), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
Text text_frame_end{
|
||||
{UI_POS_X(6), UI_POS_Y(7), UI_POS_WIDTH_REMAINING(6), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
Text text_frame_sgb_end{
|
||||
{UI_POS_X(6), UI_POS_Y(8), UI_POS_WIDTH_REMAINING(6), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
|
||||
Text text_timeout{
|
||||
{UI_POS_X(14), UI_POS_Y(10), UI_POS_WIDTH(2), UI_POS_DEFAULT_HEIGHT},
|
||||
""};
|
||||
|
||||
// Transmission settings
|
||||
Checkbox checkbox_loop{
|
||||
{UI_POS_X(0), UI_POS_Y(9)},
|
||||
10,
|
||||
"Resend every",
|
||||
true};
|
||||
NumberField field_delay{
|
||||
{UI_POS_X(15), UI_POS_Y(9)},
|
||||
2,
|
||||
{1, 99},
|
||||
1,
|
||||
' '};
|
||||
Checkbox checkbox_am{
|
||||
{UI_POS_X(0), UI_POS_Y(11)},
|
||||
10,
|
||||
"AM signal",
|
||||
true};
|
||||
FrequencyField field_am_frequency{
|
||||
{UI_POS_X(13), UI_POS_Y(12)}};
|
||||
Checkbox checkbox_send_on_change{
|
||||
{UI_POS_X(0), UI_POS_Y(13)},
|
||||
14,
|
||||
"Send on change",
|
||||
true};
|
||||
Button button_tx{
|
||||
{UI_POS_X_RIGHT(9), UI_POS_Y(9), UI_POS_WIDTH(9), UI_POS_HEIGHT(2)},
|
||||
"START"};
|
||||
const Style& style_tx_start = *Theme::getInstance()->fg_green;
|
||||
const Style& style_tx_stop = *Theme::getInstance()->fg_red;
|
||||
OptionsField options_am_channel{
|
||||
{UI_POS_X(11), UI_POS_Y(14)},
|
||||
20,
|
||||
{{"121.375 MHz (Test)", 0},
|
||||
{"121.500 MHz /!\\Real", 1},
|
||||
{"Manual", 2}}};
|
||||
OptionsField options_bpsk_channel{
|
||||
{UI_POS_X(11), UI_POS_Y(15)},
|
||||
20,
|
||||
{{"433.025 MHz (Ham)", (uint8_t)BpskChannel::HAM},
|
||||
{"406.025 MHz (B)", (uint8_t)BpskChannel::B},
|
||||
{"406.028 MHz (C)", (uint8_t)BpskChannel::C},
|
||||
{"406.037 MHz (F)", (uint8_t)BpskChannel::F},
|
||||
{"406.040 MHz (G)", (uint8_t)BpskChannel::G},
|
||||
{"406.049 MHz (J)", (uint8_t)BpskChannel::J},
|
||||
{"406.052 MHz (K)", (uint8_t)BpskChannel::K},
|
||||
{"406.061 MHz (N)", (uint8_t)BpskChannel::N},
|
||||
{"406.064 MHz (O)", (uint8_t)BpskChannel::O},
|
||||
{"406.050 MHz (SGB)", (uint8_t)BpskChannel::SGB},
|
||||
{"Manual", (uint8_t)BpskChannel::MANUAL}}};
|
||||
|
||||
// Transmitter view
|
||||
TransmitterView tx_view{
|
||||
(int16_t)UI_POS_Y_BOTTOM(4),
|
||||
10000,
|
||||
12};
|
||||
|
||||
MessageHandlerRegistration message_handler_tx_progress{
|
||||
Message::ID::TXProgress,
|
||||
[this](const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
|
||||
this->on_tx_progress(message.progress, message.done);
|
||||
}};
|
||||
|
||||
MessageHandlerRegistration message_handler_frame_sync{
|
||||
// Use frame sync for our applcation timer callback
|
||||
Message::ID::DisplayFrameSync,
|
||||
[this](const Message* const) {
|
||||
this->on_timer();
|
||||
}};
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::epirb_tx
|
||||
|
||||
#endif /*__EPIRB_TX_H__*/
|
||||
+1
-1
@@ -100,7 +100,7 @@ namespace ui::external_app::ert_app {
|
||||
|
||||
ERTAppView::ERTAppView(NavigationView& nav)
|
||||
: nav_{nav} {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_ert);
|
||||
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
|
||||
|
||||
add_children({
|
||||
&field_frequency,
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ __attribute__((section(".external_app.app_ert.application_information"), used))
|
||||
/*.menu_location = */ app_location_t::RX,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_none */ {'P', 'E', 'R', 'T'},
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_ert */ {'P', 'E', 'R', 'T'},
|
||||
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
|
||||
};
|
||||
}
|
||||
|
||||
+124
-14
@@ -103,6 +103,14 @@ set(EXTCPPSRC
|
||||
external/sstvtx/main.cpp
|
||||
external/sstvtx/ui_sstvtx.cpp
|
||||
|
||||
#same_tx
|
||||
external/same_tx/main.cpp
|
||||
external/same_tx/ui_same_tx.cpp
|
||||
|
||||
#mdc_tx
|
||||
external/mdc_tx/main.cpp
|
||||
external/mdc_tx/ui_mdc_tx.cpp
|
||||
|
||||
#sstvrx
|
||||
external/sstvrx/main.cpp
|
||||
external/sstvrx/ui_sstvrx.cpp
|
||||
@@ -125,6 +133,14 @@ set(EXTCPPSRC
|
||||
external/noaaapt_rx/main.cpp
|
||||
external/noaaapt_rx/ui_noaaapt_rx.cpp
|
||||
|
||||
#vor_rx
|
||||
external/vor_rx/main.cpp
|
||||
external/vor_rx/ui_vor_rx.cpp
|
||||
|
||||
#vor_tx
|
||||
external/vor_tx/main.cpp
|
||||
external/vor_tx/ui_vor_tx.cpp
|
||||
|
||||
#shoppingcart_lock 272 bytes
|
||||
external/shoppingcart_lock/main.cpp
|
||||
external/shoppingcart_lock/shoppingcart_lock.cpp
|
||||
@@ -153,6 +169,7 @@ set(EXTCPPSRC
|
||||
#mcu_temperature 112
|
||||
external/mcu_temperature/main.cpp
|
||||
external/mcu_temperature/mcu_temperature.cpp
|
||||
external/mcu_temperature/temperature_logger.cpp
|
||||
|
||||
#fmradio 640
|
||||
external/fmradio/main.cpp
|
||||
@@ -255,6 +272,14 @@ set(EXTCPPSRC
|
||||
#epirb_rx 168 byte flash
|
||||
external/epirb_rx/main.cpp
|
||||
external/epirb_rx/ui_epirb_rx.cpp
|
||||
external/epirb_rx/ui_beaconlist.cpp
|
||||
external/epirb_rx/beacon_db.cpp
|
||||
external/epirb_rx/beacon.cpp
|
||||
external/epirb_rx/location.cpp
|
||||
|
||||
#epirb_tx
|
||||
external/epirb_tx/main.cpp
|
||||
external/epirb_tx/ui_epirb_tx.cpp
|
||||
|
||||
#soundboard 272byte - 1236 bytes
|
||||
external/soundboard/main.cpp
|
||||
@@ -297,8 +322,10 @@ set(EXTCPPSRC
|
||||
external/morseradiotx/main.cpp
|
||||
external/morseradiotx/ui_morse_radiotx.cpp
|
||||
|
||||
external/keeloqtx/main.cpp
|
||||
external/keeloqtx/ui_keeloqtx.cpp
|
||||
#keeloqtx
|
||||
external/keeloqtx/main.cpp
|
||||
external/keeloqtx/ui_keeloqtx.cpp
|
||||
|
||||
#rtty_rx
|
||||
external/rtty_rx/main.cpp
|
||||
external/rtty_rx/ui_rtty_rx.cpp
|
||||
@@ -309,9 +336,81 @@ set(EXTCPPSRC
|
||||
external/rtty_tx/ui_rtty_tx.cpp
|
||||
external/rtty_tx/baudot.cpp
|
||||
|
||||
#pocsag_tx
|
||||
#pocsag_tx
|
||||
external/pocsag_tx/main.cpp
|
||||
external/pocsag_tx/ui_pocsag_tx.cpp
|
||||
|
||||
#flex_tx
|
||||
external/flex_tx/main.cpp
|
||||
external/flex_tx/ui_flex_tx.cpp
|
||||
|
||||
#time_sink
|
||||
external/time_sink/main.cpp
|
||||
external/time_sink/ui_time_sink.cpp
|
||||
|
||||
#kiss_tnc
|
||||
external/kiss_tnc/main.cpp
|
||||
external/kiss_tnc/ui_kiss_tnc.cpp
|
||||
|
||||
#fpv_detect
|
||||
external/fpv_detect/main.cpp
|
||||
external/fpv_detect/ui_fpv_detect.cpp
|
||||
|
||||
#p25_tx
|
||||
external/p25_tx/main.cpp
|
||||
external/p25_tx/ui_p25_tx.cpp
|
||||
|
||||
#two_tone_pager
|
||||
external/two_tone_pager/main.cpp
|
||||
external/two_tone_pager/ui_two_tone_pager.cpp
|
||||
|
||||
#two_tone_rx
|
||||
external/two_tone_rx/main.cpp
|
||||
external/two_tone_rx/ui_two_tone_rx.cpp
|
||||
|
||||
#hard_reset
|
||||
external/hard_reset/main.cpp
|
||||
external/hard_reset/ui_hard_reset.cpp
|
||||
|
||||
#secplustx
|
||||
external/secplustx/main.cpp
|
||||
external/secplustx/ui_secplustx.cpp
|
||||
external/secplustx/secplustx.cpp
|
||||
|
||||
#signal_hunter
|
||||
external/signal_hunter/main.cpp
|
||||
external/signal_hunter/ui_signal_hunter.cpp
|
||||
|
||||
|
||||
#tetra rx
|
||||
external/tetra_rx/main.cpp
|
||||
external/tetra_rx/ui_tetra_rx.cpp
|
||||
external/tetra_rx/tetra_crc.cpp
|
||||
external/tetra_rx/tetra_descrambler.cpp
|
||||
external/tetra_rx/tetra_interleave.cpp
|
||||
external/tetra_rx/tetra_rcpc.cpp
|
||||
external/tetra_rx/tetra_viterbi.cpp
|
||||
|
||||
#adsb rx
|
||||
external/adsbrx/main.cpp
|
||||
external/adsbrx/ui_adsb_rx.cpp
|
||||
|
||||
#ais rx
|
||||
external/ais_rx/main.cpp
|
||||
external/ais_rx/ais_app.cpp
|
||||
|
||||
#aprs rx
|
||||
external/aprs_rx/main.cpp
|
||||
external/aprs_rx/ui_aprs_rx.cpp
|
||||
|
||||
#aprs tx
|
||||
external/aprs_tx/main.cpp
|
||||
external/aprs_tx/ui_aprs_tx.cpp
|
||||
|
||||
#sd over usb
|
||||
external/sdusb/main.cpp
|
||||
external/sdusb/ui_sd_over_usb.cpp
|
||||
|
||||
)
|
||||
|
||||
set(EXTAPPLIST
|
||||
@@ -339,11 +438,15 @@ set(EXTAPPLIST
|
||||
adsbtx
|
||||
#morse_tx
|
||||
sstvtx
|
||||
same_tx
|
||||
mdc_tx
|
||||
sstvrx
|
||||
random_password
|
||||
acars_rx
|
||||
wefax_rx
|
||||
noaaapt_rx
|
||||
vor_rx
|
||||
vor_tx
|
||||
shoppingcart_lock
|
||||
ookbrute
|
||||
ook_editor
|
||||
@@ -371,11 +474,13 @@ set(EXTAPPLIST
|
||||
gfxeq
|
||||
waterfall_designer
|
||||
detector_rx
|
||||
fpv_detect
|
||||
spaceinv
|
||||
blackjack
|
||||
battleship
|
||||
ert
|
||||
epirb_rx
|
||||
epirb_tx
|
||||
soundboard
|
||||
game2048
|
||||
bht_tx
|
||||
@@ -386,18 +491,23 @@ set(EXTAPPLIST
|
||||
siggen
|
||||
morse_radio
|
||||
morseradiotx
|
||||
keeloqtx
|
||||
keeloqtx
|
||||
rtty_rx
|
||||
rtty_tx
|
||||
pocsag_tx
|
||||
flex_tx
|
||||
time_sink
|
||||
kiss_tnc
|
||||
p25_tx
|
||||
two_tone_pager
|
||||
two_tone_rx
|
||||
hard_reset
|
||||
secplustx
|
||||
signal_hunter
|
||||
tetra_rx
|
||||
adsbrx
|
||||
ais_rx
|
||||
aprs_rx
|
||||
aprs_tx
|
||||
sdusb
|
||||
)
|
||||
|
||||
# sdusb has type conflicts with PRALINE (HackRF Pro) - add only for non-PRALINE builds
|
||||
if(NOT BOARD STREQUAL "PRALINE")
|
||||
list(APPEND EXTCPPSRC
|
||||
external/sdusb/main.cpp
|
||||
external/sdusb/ui_sd_over_usb.cpp
|
||||
)
|
||||
list(APPEND EXTAPPLIST sdusb)
|
||||
endif()
|
||||
|
||||
|
||||
+316
-175
@@ -23,82 +23,102 @@ MEMORY
|
||||
* Also need to consider processor memory map - reading 0xADxxxxxx generates a fault which may be better than unexpected behavior.
|
||||
* External app address ranges below must match those in python file "external_app_info.py".
|
||||
*/
|
||||
ram_external_app_afsk_rx (rwx) : org = 0xADB10000, len = 32k
|
||||
ram_external_app_calculator (rwx) : org = 0xADB20000, len = 32k
|
||||
ram_external_app_font_viewer(rwx) : org = 0xADB30000, len = 32k
|
||||
ram_external_app_blespam (rwx) : org = 0xADB40000, len = 32k
|
||||
ram_external_app_analogtv (rwx) : org = 0xADB50000, len = 32k
|
||||
ram_external_app_nrf_rx (rwx) : org = 0xADB60000, len = 32k
|
||||
ram_external_app_coasterp (rwx) : org = 0xADB70000, len = 32k
|
||||
ram_external_app_lge (rwx) : org = 0xADB80000, len = 32k
|
||||
ram_external_app_lcr (rwx) : org = 0xADB90000, len = 32k
|
||||
ram_external_app_jammer (rwx) : org = 0xADBA0000, len = 32k
|
||||
ram_external_app_gpssim (rwx) : org = 0xADBB0000, len = 32k
|
||||
ram_external_app_spainter (rwx) : org = 0xADBC0000, len = 32k
|
||||
ram_external_app_keyfob (rwx) : org = 0xADBD0000, len = 32k
|
||||
ram_external_app_tetris (rwx) : org = 0xADBE0000, len = 32k
|
||||
ram_external_app_extsensors (rwx) : org = 0xADBF0000, len = 32k
|
||||
ram_external_app_foxhunt_rx (rwx) : org = 0xADC00000, len = 32k
|
||||
ram_external_app_audio_test (rwx) : org = 0xADC10000, len = 32k
|
||||
ram_external_app_wardrivemap(rwx) : org = 0xADC20000, len = 32k
|
||||
ram_external_app_tpmsrx (rwx) : org = 0xADC30000, len = 32k
|
||||
ram_external_app_protoview (rwx) : org = 0xADC40000, len = 32k
|
||||
ram_external_app_adsbtx (rwx) : org = 0xADC50000, len = 32k
|
||||
ram_external_app_morse_tx (rwx) : org = 0xADC60000, len = 32k
|
||||
ram_external_app_sstvtx (rwx) : org = 0xADC70000, len = 32k
|
||||
ram_external_app_random_password(rwx): org = 0xADC80000, len = 32k
|
||||
ram_external_app_acars_rx (rwx) : org = 0xADC90000, len = 32k
|
||||
ram_external_app_shoppingcart_lock(rwx): org = 0xADCA0000, len = 32k
|
||||
ram_external_app_cvs_spam (rwx) : org = 0xADCB0000, len = 32k
|
||||
ram_external_app_ookbrute (rwx) : org = 0xADCC0000, len = 32k
|
||||
ram_external_app_flippertx (rwx) : org = 0xADCD0000, len = 32k
|
||||
ram_external_app_ook_editor (rwx) : org = 0xADCE0000, len = 32k
|
||||
ram_external_app_remote (rwx) : org = 0xADCF0000, len = 32k
|
||||
ram_external_app_mcu_temperature(rwx): org = 0xADD00000, len = 32k
|
||||
ram_external_app_fmradio (rwx) : org = 0xADD10000, len = 32k
|
||||
ram_external_app_tuner (rwx) : org = 0xADD20000, len = 32k
|
||||
ram_external_app_metronome (rwx) : org = 0xADD30000, len = 32k
|
||||
ram_external_app_app_manager(rwx) : org = 0xADD40000, len = 32k
|
||||
ram_external_app_hopper (rwx) : org = 0xADD50000, len = 32k
|
||||
ram_external_app_antenna_length(rwx): org = 0xADD60000, len = 32k
|
||||
ram_external_app_view_wav (rwx) : org = 0xADD70000, len = 32k
|
||||
ram_external_app_sd_wipe (rwx) : org = 0xADD80000, len = 32k
|
||||
ram_external_app_playlist_editor(rwx): org = 0xADD90000, len = 32k
|
||||
ram_external_app_snake (rwx) : org = 0xADDA0000, len = 32k
|
||||
ram_external_app_stopwatch (rwx) : org = 0xADDB0000, len = 32k
|
||||
ram_external_app_wefax_rx (rwx) : org = 0xADDC0000, len = 32k
|
||||
ram_external_app_breakout (rwx) : org = 0xADDD0000, len = 32k
|
||||
ram_external_app_doom (rwx) : org = 0xADDE0000, len = 32k
|
||||
ram_external_app_debug_pmem (rwx) : org = 0xADDF0000, len = 32k
|
||||
ram_external_app_scanner (rwx) : org = 0xADE00000, len = 32k
|
||||
ram_external_app_level (rwx) : org = 0xADE10000, len = 32k
|
||||
ram_external_app_gfxeq (rwx) : org = 0xADE20000, len = 32k
|
||||
ram_external_app_noaaapt_rx (rwx) : org = 0xADE30000, len = 32k
|
||||
ram_external_app_detector_rx (rwx) : org = 0xADE40000, len = 32k
|
||||
ram_external_app_dinogame (rwx) : org = 0xADE50000, len = 32k
|
||||
ram_external_app_spaceinv (rwx) : org = 0xADE60000, len = 32k
|
||||
ram_external_app_blackjack (rwx) : org = 0xADE70000, len = 32k
|
||||
ram_external_app_battleship (rwx) : org = 0xADE80000, len = 32k
|
||||
ram_external_app_ert (rwx) : org = 0xADE90000, len = 32k
|
||||
ram_external_app_epirb_rx (rwx) : org = 0xADEA0000, len = 32k
|
||||
ram_external_app_soundboard (rwx) : org = 0xADEB0000, len = 32k
|
||||
ram_external_app_game2048 (rwx) : org = 0xADEC0000, len = 32k
|
||||
ram_external_app_bht_tx (rwx) : org = 0xADED0000, len = 32k
|
||||
ram_external_app_morse_practice (rwx) : org = 0xADEE0000, len = 32k
|
||||
ram_external_app_adult_toys_controller (rwx) : org = 0xADEF0000, len = 32k
|
||||
ram_external_app_flex_rx (rwx) : org = 0xADF00000, len = 32k
|
||||
ram_external_app_sstvrx (rwx) : org = 0xADF10000, len = 32k
|
||||
ram_external_app_subcarrx (rwx) : org = 0xADF20000, len = 32k
|
||||
ram_external_app_siggen (rwx) : org = 0xADF30000, len = 32k
|
||||
ram_external_app_sdusb (rwx) : org = 0xADF40000, len = 32k
|
||||
ram_external_app_morse_radio (rwx) : org = 0xADF50000, len = 32k
|
||||
ram_external_app_waterfall_designer (rwx) : org = 0xADF60000, len = 32k
|
||||
ram_external_app_morseradiotx (rwx) : org = 0xADF70000, len = 32k
|
||||
ram_external_app_keeloqtx (rwx) : org = 0xADF80000, len = 32k
|
||||
ram_external_app_rtty_rx (rwx) : org = 0xADF90000, len = 32k
|
||||
ram_external_app_rtty_tx (rwx) : org = 0xADFA0000, len = 32k
|
||||
ram_external_app_tpmstx (rwx) : org = 0xADFB0000, len = 32k
|
||||
ram_external_app_pocsag_tx (rwx) : org = 0xADFC0000, len = 32k
|
||||
ram_external_app_afsk_rx (rwx) : org = 0xADB10000, len = 32k
|
||||
ram_external_app_calculator (rwx) : org = 0xADB20000, len = 32k
|
||||
ram_external_app_font_viewer (rwx) : org = 0xADB30000, len = 32k
|
||||
ram_external_app_blespam (rwx) : org = 0xADB40000, len = 32k
|
||||
ram_external_app_analogtv (rwx) : org = 0xADB50000, len = 32k
|
||||
ram_external_app_nrf_rx (rwx) : org = 0xADB60000, len = 32k
|
||||
ram_external_app_coasterp (rwx) : org = 0xADB70000, len = 32k
|
||||
ram_external_app_lge (rwx) : org = 0xADB80000, len = 32k
|
||||
ram_external_app_lcr (rwx) : org = 0xADB90000, len = 32k
|
||||
ram_external_app_jammer (rwx) : org = 0xADBA0000, len = 32k
|
||||
ram_external_app_gpssim (rwx) : org = 0xADBB0000, len = 32k
|
||||
ram_external_app_spainter (rwx) : org = 0xADBC0000, len = 32k
|
||||
ram_external_app_keyfob (rwx) : org = 0xADBD0000, len = 32k
|
||||
ram_external_app_tetris (rwx) : org = 0xADBE0000, len = 32k
|
||||
ram_external_app_extsensors (rwx) : org = 0xADBF0000, len = 32k
|
||||
ram_external_app_foxhunt_rx (rwx) : org = 0xADC00000, len = 32k
|
||||
ram_external_app_audio_test (rwx) : org = 0xADC10000, len = 32k
|
||||
ram_external_app_wardrivemap (rwx) : org = 0xADC20000, len = 32k
|
||||
ram_external_app_tpmsrx (rwx) : org = 0xADC30000, len = 32k
|
||||
ram_external_app_protoview (rwx) : org = 0xADC40000, len = 32k
|
||||
ram_external_app_adsbtx (rwx) : org = 0xADC50000, len = 32k
|
||||
ram_external_app_morse_tx (rwx) : org = 0xADC60000, len = 32k
|
||||
ram_external_app_sstvtx (rwx) : org = 0xADC70000, len = 32k
|
||||
ram_external_app_random_password (rwx) : org = 0xADC80000, len = 32k
|
||||
ram_external_app_acars_rx (rwx) : org = 0xADC90000, len = 32k
|
||||
ram_external_app_shoppingcart_lock (rwx) : org = 0xADCA0000, len = 32k
|
||||
ram_external_app_cvs_spam (rwx) : org = 0xADCB0000, len = 32k
|
||||
ram_external_app_ookbrute (rwx) : org = 0xADCC0000, len = 32k
|
||||
ram_external_app_flippertx (rwx) : org = 0xADCD0000, len = 32k
|
||||
ram_external_app_ook_editor (rwx) : org = 0xADCE0000, len = 32k
|
||||
ram_external_app_remote (rwx) : org = 0xADCF0000, len = 32k
|
||||
ram_external_app_mcu_temperature (rwx) : org = 0xADD00000, len = 32k
|
||||
ram_external_app_fmradio (rwx) : org = 0xADD10000, len = 32k
|
||||
ram_external_app_tuner (rwx) : org = 0xADD20000, len = 32k
|
||||
ram_external_app_metronome (rwx) : org = 0xADD30000, len = 32k
|
||||
ram_external_app_app_manager (rwx) : org = 0xADD40000, len = 32k
|
||||
ram_external_app_hopper (rwx) : org = 0xADD50000, len = 32k
|
||||
ram_external_app_antenna_length (rwx) : org = 0xADD60000, len = 32k
|
||||
ram_external_app_view_wav (rwx) : org = 0xADD70000, len = 32k
|
||||
ram_external_app_sd_wipe (rwx) : org = 0xADD80000, len = 32k
|
||||
ram_external_app_playlist_editor (rwx) : org = 0xADD90000, len = 32k
|
||||
ram_external_app_snake (rwx) : org = 0xADDA0000, len = 32k
|
||||
ram_external_app_stopwatch (rwx) : org = 0xADDB0000, len = 32k
|
||||
ram_external_app_wefax_rx (rwx) : org = 0xADDC0000, len = 32k
|
||||
ram_external_app_breakout (rwx) : org = 0xADDD0000, len = 32k
|
||||
ram_external_app_doom (rwx) : org = 0xADDE0000, len = 32k
|
||||
ram_external_app_debug_pmem (rwx) : org = 0xADDF0000, len = 32k
|
||||
ram_external_app_scanner (rwx) : org = 0xADE00000, len = 32k
|
||||
ram_external_app_level (rwx) : org = 0xADE10000, len = 32k
|
||||
ram_external_app_gfxeq (rwx) : org = 0xADE20000, len = 32k
|
||||
ram_external_app_noaaapt_rx (rwx) : org = 0xADE30000, len = 32k
|
||||
ram_external_app_detector_rx (rwx) : org = 0xADE40000, len = 32k
|
||||
ram_external_app_dinogame (rwx) : org = 0xADE50000, len = 32k
|
||||
ram_external_app_spaceinv (rwx) : org = 0xADE60000, len = 32k
|
||||
ram_external_app_blackjack (rwx) : org = 0xADE70000, len = 32k
|
||||
ram_external_app_battleship (rwx) : org = 0xADE80000, len = 32k
|
||||
ram_external_app_ert (rwx) : org = 0xADE90000, len = 32k
|
||||
ram_external_app_epirb_rx (rwx) : org = 0xADEA0000, len = 32k
|
||||
ram_external_app_soundboard (rwx) : org = 0xADEB0000, len = 32k
|
||||
ram_external_app_game2048 (rwx) : org = 0xADEC0000, len = 32k
|
||||
ram_external_app_bht_tx (rwx) : org = 0xADED0000, len = 32k
|
||||
ram_external_app_morse_practice (rwx) : org = 0xADEE0000, len = 32k
|
||||
ram_external_app_adult_toys_controller (rwx) : org = 0xADEF0000, len = 32k
|
||||
ram_external_app_flex_rx (rwx) : org = 0xADF00000, len = 32k
|
||||
ram_external_app_sstvrx (rwx) : org = 0xADF10000, len = 32k
|
||||
ram_external_app_subcarrx (rwx) : org = 0xADF20000, len = 32k
|
||||
ram_external_app_siggen (rwx) : org = 0xADF30000, len = 32k
|
||||
ram_external_app_sdusb (rwx) : org = 0xADF40000, len = 32k
|
||||
ram_external_app_morse_radio (rwx) : org = 0xADF50000, len = 32k
|
||||
ram_external_app_waterfall_designer (rwx) : org = 0xADF60000, len = 32k
|
||||
ram_external_app_morseradiotx (rwx) : org = 0xADF70000, len = 32k
|
||||
ram_external_app_keeloqtx (rwx) : org = 0xADF80000, len = 32k
|
||||
ram_external_app_rtty_rx (rwx) : org = 0xADF90000, len = 32k
|
||||
ram_external_app_rtty_tx (rwx) : org = 0xADFA0000, len = 32k
|
||||
ram_external_app_tpmstx (rwx) : org = 0xADFB0000, len = 32k
|
||||
ram_external_app_pocsag_tx (rwx) : org = 0xADFC0000, len = 32k
|
||||
ram_external_app_time_sink (rwx) : org = 0xADFD0000, len = 32k
|
||||
ram_external_app_same_tx (rwx) : org = 0xADFE0000, len = 32k
|
||||
ram_external_app_kiss_tnc (rwx) : org = 0xADFF0000, len = 32k
|
||||
ram_external_app_mdc_tx (rwx) : org = 0xAE000000, len = 32k
|
||||
ram_external_app_epirb_tx (rwx) : org = 0xAE010000, len = 32k
|
||||
ram_external_app_fpv_detect (rwx) : org = 0xAE020000, len = 32k
|
||||
ram_external_app_p25_tx (rwx) : org = 0xAE030000, len = 32k
|
||||
ram_external_app_two_tone_pager (rwx) : org = 0xAE040000, len = 32k
|
||||
ram_external_app_two_tone_rx (rwx) : org = 0xAE050000, len = 32k
|
||||
ram_external_app_flex_tx (rwx) : org = 0xAE060000, len = 32k
|
||||
ram_external_app_hard_reset (rwx) : org = 0xAE070000, len = 32k
|
||||
ram_external_app_secplustx (rwx) : org = 0xAE080000, len = 32k
|
||||
ram_external_app_vor_rx (rwx) : org = 0xAE090000, len = 32k
|
||||
ram_external_app_vor_tx (rwx) : org = 0xAE0A0000, len = 32k
|
||||
ram_external_app_signal_hunter (rwx) : org = 0xAE0B0000, len = 32k
|
||||
ram_external_app_tetra_rx (rwx) : org = 0xAE0C0000, len = 32k
|
||||
ram_external_app_adsbrx (rwx) : org = 0xAE0D0000, len = 32k
|
||||
ram_external_app_ais_rx (rwx) : org = 0xAE0E0000, len = 32k
|
||||
ram_external_app_aprs_rx (rwx) : org = 0xAE0F0000, len = 32k
|
||||
ram_external_app_aprs_tx (rwx) : org = 0xAE100000, len = 32k
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
@@ -106,458 +126,579 @@ SECTIONS
|
||||
.external_app_afsk_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_afsk_rx.application_information));
|
||||
*(*ui*external_app*afsk_rx*);
|
||||
*/external/afsk_rx/*(*ui*external_app*afsk_rx*);
|
||||
} > ram_external_app_afsk_rx
|
||||
|
||||
.external_app_calculator : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_calculator.application_information));
|
||||
*(*ui*external_app*calculator*);
|
||||
*/external/calculator/*(*ui*external_app*calculator*);
|
||||
} > ram_external_app_calculator
|
||||
|
||||
.external_app_font_viewer : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_font_viewer.application_information));
|
||||
*(*ui*external_app*font_viewer*);
|
||||
*/external/font_viewer/*(*ui*external_app*font_viewer*);
|
||||
} > ram_external_app_font_viewer
|
||||
|
||||
.external_app_blespam : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_blespam.application_information));
|
||||
*(*ui*external_app*blespam*);
|
||||
*/external/blespam/*(*ui*external_app*blespam*);
|
||||
} > ram_external_app_blespam
|
||||
|
||||
.external_app_analogtv : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_analogtv.application_information));
|
||||
*(*ui*external_app*analogtv*);
|
||||
*/external/analogtv/*(*ui*external_app*analogtv*);
|
||||
} > ram_external_app_analogtv
|
||||
|
||||
.external_app_nrf_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_nrf_rx.application_information));
|
||||
*(*ui*external_app*nrf_rx*);
|
||||
*/external/nrf_rx/*(*ui*external_app*nrf_rx*);
|
||||
} > ram_external_app_nrf_rx
|
||||
|
||||
.external_app_coasterp : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_coasterp : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_coasterp.application_information));
|
||||
*(*ui*external_app*coasterp*);
|
||||
*/external/coasterp/*(*ui*external_app*coasterp*);
|
||||
} > ram_external_app_coasterp
|
||||
|
||||
.external_app_lge : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_lge.application_information));
|
||||
*(*ui*external_app*lge*);
|
||||
*/external/lge/*(*ui*external_app*lge*);
|
||||
} > ram_external_app_lge
|
||||
|
||||
.external_app_lcr : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_lcr.application_information));
|
||||
*(*ui*external_app*lcr*);
|
||||
*/external/lcr/*(*ui*external_app*lcr*);
|
||||
} > ram_external_app_lcr
|
||||
|
||||
.external_app_jammer : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_jammer.application_information));
|
||||
*(*ui*external_app*jammer*);
|
||||
*/external/jammer/*(*ui*external_app*jammer*);
|
||||
} > ram_external_app_jammer
|
||||
|
||||
.external_app_gpssim : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_gpssim.application_information));
|
||||
*(*ui*external_app*gpssim*);
|
||||
*/external/gpssim/*(*ui*external_app*gpssim*);
|
||||
} > ram_external_app_gpssim
|
||||
|
||||
.external_app_spainter : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_spainter.application_information));
|
||||
*(*ui*external_app*spainter*);
|
||||
*/external/spainter/*(*ui*external_app*spainter*);
|
||||
} > ram_external_app_spainter
|
||||
|
||||
.external_app_keyfob : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_keyfob.application_information));
|
||||
*(*ui*external_app*keyfob*);
|
||||
*/external/keyfob/*(*ui*external_app*keyfob*);
|
||||
} > ram_external_app_keyfob
|
||||
|
||||
.external_app_tetris : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_tetris.application_information));
|
||||
*(*ui*external_app*tetris*);
|
||||
*/external/tetris/*(*ui*external_app*tetris*);
|
||||
} > ram_external_app_tetris
|
||||
|
||||
.external_app_extsensors : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_extsensors : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_extsensors.application_information));
|
||||
*(*ui*external_app*extsensors*);
|
||||
*/external/extsensors/*(*ui*external_app*extsensors*);
|
||||
} > ram_external_app_extsensors
|
||||
|
||||
.external_app_foxhunt_rx : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_foxhunt_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_foxhunt_rx.application_information));
|
||||
*(*ui*external_app*foxhunt_rx*);
|
||||
*/external/foxhunt/*(*ui*external_app*foxhunt_rx*);
|
||||
} > ram_external_app_foxhunt_rx
|
||||
|
||||
.external_app_audio_test : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_audio_test : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_audio_test.application_information));
|
||||
*(*ui*external_app*audio_test*);
|
||||
*/external/audio_test/*(*ui*external_app*audio_test*);
|
||||
} > ram_external_app_audio_test
|
||||
|
||||
.external_app_wardrivemap : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_wardrivemap : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_wardrivemap.application_information));
|
||||
*(*ui*external_app*wardrivemap*);
|
||||
*/external/wardrivemap/*(*ui*external_app*wardrivemap*);
|
||||
} > ram_external_app_wardrivemap
|
||||
|
||||
.external_app_tpmsrx : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_tpmsrx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_tpmsrx.application_information));
|
||||
*(*ui*external_app*tpmsrx*);
|
||||
*/external/tpmsrx/*(*ui*external_app*tpmsrx*);
|
||||
} > ram_external_app_tpmsrx
|
||||
|
||||
.external_app_tpmstx : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_tpmstx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_tpmstx.application_information));
|
||||
*(*ui*external_app*tpmstx*);
|
||||
*/external/tpmstx/*(*ui*external_app*tpmstx*);
|
||||
} > ram_external_app_tpmstx
|
||||
|
||||
.external_app_protoview : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_protoview : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_protoview.application_information));
|
||||
*(*ui*external_app*protoview*);
|
||||
*/external/protoview/*(*ui*external_app*protoview*);
|
||||
} > ram_external_app_protoview
|
||||
|
||||
.external_app_adsbtx : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_adsbtx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_adsbtx.application_information));
|
||||
*(*ui*external_app*adsbtx*);
|
||||
*/external/adsbtx/*(*ui*external_app*adsbtx*);
|
||||
} > ram_external_app_adsbtx
|
||||
|
||||
.external_app_morse_tx : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_morse_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_morse_tx.application_information));
|
||||
*(*ui*external_app*morse_tx*);
|
||||
*/external/morse_tx/*(*ui*external_app*morse_tx*);
|
||||
} > ram_external_app_morse_tx
|
||||
|
||||
.external_app_sstvtx : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_sstvtx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_sstvtx.application_information));
|
||||
*(*ui*external_app*sstvtx*);
|
||||
*/external/sstvtx/*(*ui*external_app*sstvtx*);
|
||||
} > ram_external_app_sstvtx
|
||||
|
||||
.external_app_random_password : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_random_password.application_information));
|
||||
*(*ui*external_app*random_password*);
|
||||
*/external/random_password/*(*ui*external_app*random_password*);
|
||||
} > ram_external_app_random_password
|
||||
|
||||
.external_app_acars_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_acars_rx.application_information));
|
||||
*(*ui*external_app*acars_rx*);
|
||||
*/external/acars_rx/*(*ui*external_app*acars_rx*);
|
||||
} > ram_external_app_acars_rx
|
||||
|
||||
.external_app_shoppingcart_lock : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_shoppingcart_lock : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_shoppingcart_lock.application_information));
|
||||
*(*ui*external_app*shoppingcart_lock*);
|
||||
*/external/shoppingcart_lock/*(*ui*external_app*shoppingcart_lock*);
|
||||
} > ram_external_app_shoppingcart_lock
|
||||
|
||||
.external_app_cvs_spam : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_cvs_spam : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_cvs_spam.application_information));
|
||||
*(*ui*external_app*cvs_spam*);
|
||||
*/external/cvs_spam/*(*ui*external_app*cvs_spam*);
|
||||
} > ram_external_app_cvs_spam
|
||||
|
||||
.external_app_ookbrute : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_ookbrute : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_ookbrute.application_information));
|
||||
*(*ui*external_app*ookbrute*);
|
||||
*/external/ookbrute/*(*ui*external_app*ookbrute*);
|
||||
} > ram_external_app_ookbrute
|
||||
|
||||
.external_app_ook_editor : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_ook_editor.application_information));
|
||||
*(*ui*external_app*ook_editor*);
|
||||
*/external/ook_editor/*(*ui*external_app*ook_editor*);
|
||||
} > ram_external_app_ook_editor
|
||||
|
||||
.external_app_flippertx : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_flippertx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_flippertx.application_information));
|
||||
*(*ui*external_app*flippertx*);
|
||||
*/external/flippertx/*(*ui*external_app*flippertx*);
|
||||
} > ram_external_app_flippertx
|
||||
|
||||
.external_app_remote : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_remote.application_information));
|
||||
*(*ui*external_app*remote*);
|
||||
*/external/remote/*(*ui*external_app*remote*);
|
||||
} > ram_external_app_remote
|
||||
|
||||
.external_app_mcu_temperature : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_mcu_temperature.application_information));
|
||||
*(*ui*external_app*mcu_temperature*);
|
||||
*/external/mcu_temperature/*(*ui*external_app*mcu_temperature*);
|
||||
} > ram_external_app_mcu_temperature
|
||||
|
||||
.external_app_fmradio : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_fmradio.application_information));
|
||||
*(*ui*external_app*fmradio*);
|
||||
*/external/fmradio/*(*ui*external_app*fmradio*);
|
||||
} > ram_external_app_fmradio
|
||||
|
||||
.external_app_tuner : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_tuner.application_information));
|
||||
*(*ui*external_app*tuner*);
|
||||
*/external/tuner/*(*ui*external_app*tuner*);
|
||||
} > ram_external_app_tuner
|
||||
|
||||
.external_app_metronome : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_metronome.application_information));
|
||||
*(*ui*external_app*metronome*);
|
||||
*/external/metronome/*(*ui*external_app*metronome*);
|
||||
} > ram_external_app_metronome
|
||||
|
||||
.external_app_app_manager : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_app_manager.application_information));
|
||||
*(*ui*external_app*app_manager*);
|
||||
*/external/app_manager/*(*ui*external_app*app_manager*);
|
||||
} > ram_external_app_app_manager
|
||||
|
||||
.external_app_hopper : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_hopper.application_information));
|
||||
*(*ui*external_app*hopper*);
|
||||
*/external/hopper/*(*ui*external_app*hopper*);
|
||||
} > ram_external_app_hopper
|
||||
|
||||
.external_app_antenna_length : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_antenna_length.application_information));
|
||||
*(*ui*external_app*antenna_length*);
|
||||
*/external/antenna_length/*(*ui*external_app*antenna_length*);
|
||||
} > ram_external_app_antenna_length
|
||||
|
||||
.external_app_view_wav : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_view_wav.application_information));
|
||||
*(*ui*external_app*view_wav*);
|
||||
*/external/wav_view/*(*ui*external_app*view_wav*);
|
||||
} > ram_external_app_view_wav
|
||||
|
||||
.external_app_sd_wipe : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_sd_wipe.application_information));
|
||||
*(*ui*external_app*sd_wipe*);
|
||||
*/external/sd_wipe/*(*ui*external_app*sd_wipe*);
|
||||
} > ram_external_app_sd_wipe
|
||||
|
||||
.external_app_playlist_editor : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_playlist_editor.application_information));
|
||||
*(*ui*external_app*playlist_editor*);
|
||||
*/external/playlist_editor/*(*ui*external_app*playlist_editor*);
|
||||
} > ram_external_app_playlist_editor
|
||||
|
||||
.external_app_snake : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_snake.application_information));
|
||||
*(*ui*external_app*snake*);
|
||||
*/external/snake/*(*ui*external_app*snake*);
|
||||
} > ram_external_app_snake
|
||||
|
||||
.external_app_stopwatch : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_stopwatch.application_information));
|
||||
*(*ui*external_app*stopwatch*);
|
||||
*/external/stopwatch/*(*ui*external_app*stopwatch*);
|
||||
} > ram_external_app_stopwatch
|
||||
|
||||
.external_app_wefax_rx : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_wefax_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_wefax_rx.application_information));
|
||||
*(*ui*external_app*wefax_rx*);
|
||||
*/external/wefax_rx/*(*ui*external_app*wefax_rx*);
|
||||
} > ram_external_app_wefax_rx
|
||||
|
||||
.external_app_noaaapt_rx : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_noaaapt_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_noaaapt_rx.application_information));
|
||||
*(*ui*external_app*noaaapt_rx*);
|
||||
*/external/noaaapt_rx/*(*ui*external_app*noaaapt_rx*);
|
||||
} > ram_external_app_noaaapt_rx
|
||||
|
||||
.external_app_vor_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_vor_rx.application_information));
|
||||
*/external/vor_rx/*(*ui*external_app*vor_rx*);
|
||||
} > ram_external_app_vor_rx
|
||||
|
||||
.external_app_vor_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_vor_tx.application_information));
|
||||
*/external/vor_tx/*(*ui*external_app*vor_tx*);
|
||||
} > ram_external_app_vor_tx
|
||||
|
||||
.external_app_breakout : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_breakout.application_information));
|
||||
*(*ui*external_app*breakout*);
|
||||
*/external/breakout/*(*ui*external_app*breakout*);
|
||||
} > ram_external_app_breakout
|
||||
|
||||
.external_app_doom : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_doom.application_information));
|
||||
*(*ui*external_app*doom*);
|
||||
*/external/doom/*(*ui*external_app*doom*);
|
||||
} > ram_external_app_doom
|
||||
|
||||
.external_app_debug_pmem : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_debug_pmem.application_information));
|
||||
*(*ui*external_app*debug_pmem*);
|
||||
*/external/debug_pmem/*(*ui*external_app*debug_pmem*);
|
||||
} > ram_external_app_debug_pmem
|
||||
|
||||
.external_app_scanner : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_scanner.application_information));
|
||||
*(*ui*external_app*scanner*);
|
||||
*/external/scanner/*(*ui*external_app*scanner*);
|
||||
} > ram_external_app_scanner
|
||||
|
||||
.external_app_level : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_level.application_information));
|
||||
*(*ui*external_app*level*);
|
||||
*/external/level/*(*ui*external_app*level*);
|
||||
} > ram_external_app_level
|
||||
|
||||
.external_app_gfxeq : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_gfxeq.application_information));
|
||||
*(*ui*external_app*gfxeq*);
|
||||
*/external/gfxeq/*(*ui*external_app*gfxeq*);
|
||||
} > ram_external_app_gfxeq
|
||||
|
||||
.external_app_waterfall_designer : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_waterfall_designer.application_information));
|
||||
*(*ui*external_app*waterfall_designer*);
|
||||
*/external/waterfall_designer/*(*ui*external_app*waterfall_designer*);
|
||||
} > ram_external_app_waterfall_designer
|
||||
|
||||
.external_app_detector_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_detector_rx.application_information));
|
||||
*(*ui*external_app*detector_rx*);
|
||||
*/external/detector_rx/*(*ui*external_app*detector_rx*);
|
||||
} > ram_external_app_detector_rx
|
||||
|
||||
.external_app_dinogame : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_dinogame.application_information));
|
||||
*(*ui*external_app*dinogame*);
|
||||
*/external/dinogame/*(*ui*external_app*dinogame*);
|
||||
} > ram_external_app_dinogame
|
||||
|
||||
.external_app_spaceinv : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_spaceinv.application_information));
|
||||
*(*ui*external_app*spaceinv*);
|
||||
*/external/spaceinv/*(*ui*external_app*spaceinv*);
|
||||
} > ram_external_app_spaceinv
|
||||
|
||||
.external_app_blackjack : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_blackjack.application_information));
|
||||
*(*ui*external_app*blackjack*);
|
||||
*/external/blackjack/*(*ui*external_app*blackjack*);
|
||||
} > ram_external_app_blackjack
|
||||
|
||||
.external_app_battleship : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_battleship.application_information));
|
||||
*(*ui*external_app*battleship*);
|
||||
*/external/battleship/*(*ui*external_app*battleship*);
|
||||
} > ram_external_app_battleship
|
||||
|
||||
.external_app_ert : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_ert.application_information));
|
||||
*(*ui*external_app*ert*);
|
||||
*/external/ert/*(*ui*external_app*ert*);
|
||||
} > ram_external_app_ert
|
||||
|
||||
.external_app_epirb_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_epirb_rx.application_information));
|
||||
*(*ui*external_app*epirb_rx*);
|
||||
*/external/epirb_rx/*(*ui*external_app*epirb_rx*);
|
||||
} > ram_external_app_epirb_rx
|
||||
|
||||
.external_app_soundboard : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_soundboard.application_information));
|
||||
*(*ui*external_app*soundboard*);
|
||||
*/external/soundboard/*(*ui*external_app*soundboard*);
|
||||
} > ram_external_app_soundboard
|
||||
|
||||
.external_app_game2048 : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_game2048.application_information));
|
||||
*(*ui*external_app*game2048*);
|
||||
*/external/game2048/*(*ui*external_app*game2048*);
|
||||
} > ram_external_app_game2048
|
||||
|
||||
|
||||
.external_app_bht_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_bht_tx.application_information));
|
||||
*(*ui*external_app*bht_tx*);
|
||||
*/external/bht_tx/*(*ui*external_app*bht_tx*);
|
||||
} > ram_external_app_bht_tx
|
||||
|
||||
|
||||
.external_app_morse_practice : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_morse_practice.application_information));
|
||||
*(*ui*external_app*morse_practice*);
|
||||
*/external/morse_practice/*(*ui*external_app*morse_practice*);
|
||||
} > ram_external_app_morse_practice
|
||||
|
||||
.external_app_adult_toys_controller : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_adult_toys_controller.application_information));
|
||||
*(*ui*external_app*adult_toys_controller*);
|
||||
*/external/adult_toys_controller/*(*ui*external_app*adult_toys_controller*);
|
||||
} > ram_external_app_adult_toys_controller
|
||||
|
||||
.external_app_flex_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_flex_rx.application_information));
|
||||
*(*ui*external_app*flex_rx*);
|
||||
} > ram_external_app_flex_rx
|
||||
*/external/flex_rx/*(*ui*external_app*flex_rx*);
|
||||
} > ram_external_app_flex_rx
|
||||
|
||||
.external_app_sstvrx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_sstvrx.application_information));
|
||||
*(*ui*external_app*sstvrx*);
|
||||
*/external/sstvrx/*(*ui*external_app*sstvrx*);
|
||||
} > ram_external_app_sstvrx
|
||||
|
||||
.external_app_subcarrx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_subcarrx.application_information));
|
||||
*(*ui*external_app*subcarrx*);
|
||||
*/external/subcarrx/*(*ui*external_app*subcarrx*);
|
||||
} > ram_external_app_subcarrx
|
||||
|
||||
.external_app_siggen : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_siggen.application_information));
|
||||
*(*ui*external_app*siggen*);
|
||||
*/external/siggen/*(*ui*external_app*siggen*);
|
||||
} > ram_external_app_siggen
|
||||
|
||||
.external_app_sdusb : ALIGN(4) SUBALIGN(4)
|
||||
.external_app_sdusb : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_sdusb.application_information));
|
||||
*(*ui*external_app*sdusb*);
|
||||
*/external/sdusb/*(*ui*external_app*sdusb*);
|
||||
} > ram_external_app_sdusb
|
||||
|
||||
|
||||
.external_app_morse_radio : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_morse_radio.application_information));
|
||||
*(*ui*external_app*morse_radio*);
|
||||
*/external/morse_radio/*(*ui*external_app*morse_radio*);
|
||||
} > ram_external_app_morse_radio
|
||||
|
||||
.external_app_morseradiotx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_morseradiotx.application_information));
|
||||
*(*ui*external_app*morseradiotx*);
|
||||
*/external/morseradiotx/*(*ui*external_app*morseradiotx*);
|
||||
} > ram_external_app_morseradiotx
|
||||
|
||||
.external_app_keeloqtx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_keeloqtx.application_information));
|
||||
*(*ui*external_app*keeloqtx*);
|
||||
*/external/keeloqtx/*(*ui*external_app*keeloqtx*);
|
||||
} > ram_external_app_keeloqtx
|
||||
|
||||
.external_app_rtty_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_rtty_rx.application_information));
|
||||
*(*ui*external_app*rtty_rx*);
|
||||
*/external/rtty_rx/*(*ui*external_app*rtty_rx*);
|
||||
} > ram_external_app_rtty_rx
|
||||
|
||||
.external_app_rtty_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_rtty_tx.application_information));
|
||||
*(*ui*external_app*rtty_tx*);
|
||||
*/external/rtty_tx/*(*ui*external_app*rtty_tx*);
|
||||
} > ram_external_app_rtty_tx
|
||||
|
||||
.external_app_pocsag_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_pocsag_tx.application_information));
|
||||
*(*ui*external_app*pocsag_tx*);
|
||||
*/external/pocsag_tx/*(*ui*external_app*pocsag_tx*);
|
||||
} > ram_external_app_pocsag_tx
|
||||
}
|
||||
|
||||
.external_app_time_sink : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_time_sink.application_information));
|
||||
*/external/time_sink/*(*ui*external_app*time_sink*);
|
||||
} > ram_external_app_time_sink
|
||||
|
||||
.external_app_same_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_same_tx.application_information));
|
||||
*/external/same_tx/*(*ui*external_app*same_tx*);
|
||||
} > ram_external_app_same_tx
|
||||
|
||||
.external_app_kiss_tnc : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_kiss_tnc.application_information));
|
||||
*/external/kiss_tnc/*(*ui*external_app*kiss_tnc*);
|
||||
} > ram_external_app_kiss_tnc
|
||||
|
||||
.external_app_mdc_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_mdc_tx.application_information));
|
||||
*/external/mdc_tx/*(*ui*external_app*mdc_tx*);
|
||||
} > ram_external_app_mdc_tx
|
||||
|
||||
.external_app_epirb_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_epirb_tx.application_information));
|
||||
*/external/epirb_tx/*(*ui*external_app*epirb_tx*);
|
||||
} > ram_external_app_epirb_tx
|
||||
|
||||
.external_app_fpv_detect : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_fpv_detect.application_information));
|
||||
*/external/fpv_detect/*(*ui*external_app*fpv_detect*);
|
||||
} > ram_external_app_fpv_detect
|
||||
|
||||
.external_app_p25_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_p25_tx.application_information));
|
||||
*/external/p25_tx/*(*ui*external_app*p25_tx*);
|
||||
} > ram_external_app_p25_tx
|
||||
|
||||
.external_app_two_tone_pager : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_two_tone_pager.application_information));
|
||||
*/external/two_tone_pager/*(*ui*external_app*two_tone_pager*);
|
||||
} > ram_external_app_two_tone_pager
|
||||
|
||||
.external_app_two_tone_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_two_tone_rx.application_information));
|
||||
*/external/two_tone_rx/*(*ui*external_app*two_tone_rx*);
|
||||
} > ram_external_app_two_tone_rx
|
||||
|
||||
.external_app_flex_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_flex_tx.application_information));
|
||||
*/external/flex_tx/*(*ui*external_app*flex_tx*);
|
||||
} > ram_external_app_flex_tx
|
||||
|
||||
.external_app_hard_reset : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_hard_reset.application_information));
|
||||
*/external/hard_reset/*(*ui*external_app*hard_reset*);
|
||||
} > ram_external_app_hard_reset
|
||||
|
||||
.external_app_secplustx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_secplustx.application_information));
|
||||
*/external/secplustx/*(*ui*external_app*secplustx*);
|
||||
} > ram_external_app_secplustx
|
||||
|
||||
.external_app_signal_hunter : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_signal_hunter.application_information));
|
||||
*/external/signal_hunter/*(*ui*external_app*signal_hunter*);
|
||||
} > ram_external_app_signal_hunter
|
||||
|
||||
.external_app_tetra_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_tetra_rx.application_information));
|
||||
*/external/tetra_rx/*(*ui*external_app*tetra_rx*);
|
||||
} > ram_external_app_tetra_rx
|
||||
|
||||
.external_app_adsbrx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_adsbrx.application_information));
|
||||
*(*ui*external_app*adsbrx*);
|
||||
} > ram_external_app_adsbrx
|
||||
|
||||
.external_app_ais_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_ais_rx.application_information));
|
||||
*(*ui*external_app*ais_rx*);
|
||||
} > ram_external_app_ais_rx
|
||||
|
||||
.external_app_aprs_rx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_aprs_rx.application_information));
|
||||
*(*ui*external_app*aprs_rx*);
|
||||
} > ram_external_app_aprs_rx
|
||||
|
||||
.external_app_aprs_tx : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_aprs_tx.application_information));
|
||||
*(*ui*external_app*aprs_tx*);
|
||||
} > ram_external_app_aprs_tx
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ __attribute__((section(".external_app.app_extsensors.application_information"),
|
||||
0xF0,
|
||||
0x0F,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::orange().v,
|
||||
/*.icon_color = */ ui::Color::yellow().v,
|
||||
/*.menu_location = */ app_location_t::DEBUG,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
|
||||
@@ -77,6 +77,10 @@ void ExtSensorsView::on_any() {
|
||||
has_data = true;
|
||||
}
|
||||
|
||||
void ExtSensorsView::on_show() {
|
||||
i2cdev::I2CDevManager::set_autoscan_interval(3);
|
||||
}
|
||||
|
||||
void ExtSensorsView::on_gps(const GPSPosDataMessage* msg) {
|
||||
on_any();
|
||||
std::string tmp = to_string_decimal(msg->lat, 5);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user