Compare commits

..

66 Commits

Author SHA1 Message Date
Erwin Ried bf166bb2fc Update main video 2026-03-08 21:32:39 +01:00
stafur 52239d320a Next praline clean up (#3077)
* Cleaned up #ifndef PRALINE and updated logic to being with #ifdef PRALINE entries where possible to make logic flow for PRALINE code execution pipeline clearer. Cleaned up compiletime warnings for PRALINE related codebase updates.

* Addressed comments provided by copilot during PR review. Combed through frequency definitions for consistency between PLL A and PLL B register definitions for CLKs 0-7. Ensured CLK3/LK6 <- SMA PORTs and CLK7 <- not utiliized are disabled during core development phase to support root cause analysis of any spectral artifacts. Updated MCU frequency to 40MHz to ensure audio harmonics are outside FM radio band range (< 80 MHz, >120MHz) and added comments clarifying choice of 40 over 10 MHz for potential future root cause analysis in other bands where audio may be expected as needed. Added CLK6 and CLK7 to Clocks Status View Debug display. Moved CLK defintions and PLL instantiations for components that are most RF sensitive to PLL A. Left others in PLL B. That is move FPGA CLK1 to PLL B, while moving CLK2, CLK4, and CLK5 to PLL A.

* Cleaned up PLL A and B XTAL reference checks relative to 800 MHz.
2026-03-08 13:39:53 +13:00
E.T. 561143cfb0 Improve SD Card Status Display and Error Handling (#3079)
Summary:
Fixed SD card mount error detection by enabling immediate mounting, made the status icon clickable to access settings, and added real-time status display (including filesystem type) in the SD card settings page.

Changes:
- Changed f_mount() to immediate mounting for error detection
- Made SD card status icon clickable, linking to an enhanced sd card settings page that now includes live display of card status and filesystem type
- Removed "SDCard Error" menu item
2026-03-06 20:05:44 +01:00
jLynx 678ee2963e PortaRF & Windows tool update (#3075)
* Remove outdated DLL files and update HackRF submodule to latest commit

* Remove outdated msvcp120.dll and msvcr120.dll files
2026-03-06 09:41:56 +13:00
Sarah Rose bae3854d27 Add SAME TX external app (#3069)
* Add SAME TX external app

Adds a Specific Area Message Encoding (SAME/EAS) transmitter as an
external app (.ppma) for HackRF PortaPack.

SAME is the digital protocol used by NOAA Weather Radio and the
Emergency Alert System in the US and Canada for broadcasting
emergency alerts (tornado warnings, flash floods, EAN, etc.)
on 162.400-162.550 MHz and AM/FM broadcast stations.

Features:
- Originator code selector (WXR, EAS, CIV, PEP)
- Event code selector: 26 standard SAME event codes
  (RWT, TOR, SVR, FFW, EAN, etc.) with live name display
- FIPS location code entry (state 00-99 + county 000-999)
- Purge time entry (hours + minutes)
- Live message preview showing the encoded header
- AFSK encoding: mark=2083Hz, space=1563Hz, 520.833 baud
- FM deviation: 5 kHz, repeated 3x per SAME spec
- Default frequency: 162.550 MHz (WX channel 7)

Protocol details:
- 16-byte 0xAB preamble (bit-reversed for LSB-first AFSK)
- Header: ZCZC-ORG-EVT-SSPCCC+HHMM-JJJHHMM-STATION-
- Uses existing PAFT (proc_afsk) baseband image

* Apply clang-format via format-code.sh

* Add GPL license headers, guard re-entry, call set_transmitting(true)

- Add standard PortaPack GPL-2.0 license header to ui_same_tx.cpp and .hpp
- Guard start_tx() with tx_active_ to prevent re-entrant calls
- Call tx_view.set_transmitting(true) after starting TX so the
  TransmitterView button switches to stop mode
2026-03-05 19:49:17 +13:00
jLynx 0645f1897a Flashing: overhaul mayhem_flasher.bat with serial fallback and improved UX (#3074)
* Refactor mayhem_flasher.bat to streamline firmware flashing process and add serial fallback for device connection

* Improve COM port selection logic in mayhem_flasher.bat for better user input handling

* Enhance error handling in firmware flashing process for improved user feedback
2026-03-05 16:20:41 +13:00
jLynx da0a5c3e73 Fix on-device flash utility hanging on HackRF Pro (Praline) (#3073)
* Add support for W25Q32JV device ID in wait_for_device function

* Enhance mayhem_flasher.bat: Add DFU unbrick option and update firmware links
2026-03-05 14:49:32 +13:00
jLynx 22932e636d Switched build to use ninja by default (#3072)
* Initial plan

* Enable Ninja parallel builds for nightly and stable release pipelines

Co-authored-by: jLynx <4393979+jLynx@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-03-05 13:25:39 +13:00
E.T. 2b7302e659 rename Widget::visible to Widget::drawn (#3066)
* rename Widget::visible to Widget::drawn

* Update firmware/standalone/common/ui/ui_widget.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update firmware/standalone/common/ui/ui_widget.hpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix fm_radio usage of drawn()

---------

Co-authored-by: gullradriel <3157857+gullradriel@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-04 21:30:43 +01:00
jLynx 60ce89021a Combine per-device firmware ZIPs into a single unified flasher (#3070)
* Add combined firmware ZIP creation and update flashing script for device selection

* Refactor firmware flashing scripts and update README for improved device selection and actions

* Remove outdated flash script for PortaPack Mayhem

* Add write permissions to release jobs in nightly and stable release workflows

* Rename HackRF firmware files for consistency in nightly and stable release workflows

* Refactor release workflows to streamline asset preparation and upload process

* Fix file paths for HackRF firmware in nightly and stable release workflows

* Updated labels

* Refactor mayhem_flasher.bat for improved clarity

* Added reset after flash

Updated the flashing script to include error handling and improved user prompts.

* Remove --reset from DFU as it is known to cause issues
2026-03-05 08:40:39 +13:00
jLynx 25556428a7 Update HackRF flashing utilities for Windows (#3067)
* Update flasher for windows

* Updated scripts

* Fix echo statement formatting in flash script

* Fix echo statement formatting in flash script
2026-03-04 07:22:19 +00:00
stafur 584587d814 Resolve "crackling" sounds in analog_audio_app (#3068)
* Updated PRALINE audio processing methods to account for potential slip in 25MHz reference clock. Moved all clocks to PLLB except for CLK0 to isolate the ADC from potential EMI and clock spills from the other clocks to CLK0. Added PLL reference to Clock ui_debug display and added debug view for PLLA and PLLB. Updated PRO menu in analog_audio_app to allow for 100Hz resolution in sample rate for finer control of samplerate debugging of crackling noise artifacts. Updated ppb method and set it for account for a potential 49 Hz shift in the PRALINE crystal. Started instatiating methods for synchronized DMA transfers for the spectrogram since the FFT calculations and the LCD data updates appear to be related to the crackling noise.

* Added firmware/flash.h to .gitignore.

* Changed reference clock for start_audio_pll to 40MHz instead of ~12MHz xtal. Moved clocks around to reflect best audio quality in analog_audio_app at 3.072 MHz sample frequency.

* Ran format-code.sh.

* Removed ppb in set_sampling_frequency since it created aliasing in analog_audio_app.

* Expanded baseband_bandwidth back to 1750000 after testing since audio quality was retained.

* Updated comments to address copilot recommendations where acceptable.

* Removed firmware/flashsize.h from .gitignore as coordinated with @gullradriel.
2026-03-04 02:11:19 -05:00
Erwin Ried a0179117b1 Update README
Broken photo and links updated
2026-03-04 00:48:17 +01:00
gullradriel ad577a1c66 Delete firmware/flashsize.h (#3063)
Remove uneeded file
2026-03-02 23:43:23 +01:00
E.T. b9958a689b Btngrid better paging (#3061)
* improved paging for ui_btngrid

* move pgup and down to their own funcs in btngrid

* one line minus (format code)

* visible check before focus
2026-03-02 23:33:09 +01:00
E.T. 3d8bc308ee add checks to prevent crashes when showing an empty menu (#3060)
* add checks to prevent crashes when showing an empty menu

* Update firmware/application/ui/ui_btngrid.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-02 21:04:35 +01:00
zxkmm 9ca36394d0 add oscilloscope (time sink) app (#3059)
* POC

* submodule

* seperate bb

* seperate bb

* seperate bb

* seperate bb

* seperate bb

* sadly have to reduce history

* icon

* bring it back

* bring it back

* bb

* format and move bb outside
2026-03-02 19:17:02 +01:00
E.T. f489d43259 Auto update ext apps (#3046)
* first naive impl

* Unregister sdcard notification

* btngrid reload_items fixed

* format-code

* Avoid some unnecessary updates

* clear empty space after removing items

* Fix displaying sdcard error after inserting card while running

* format code

* Eliminate multiple update_items() calls from on_populate()
And call it only once after on_populate()

* update_items() only once when showing btngrid

* normalize offset when menu item count decreases
2026-03-02 12:35:45 +01:00
stafur 6b663894b0 Addresses comments from PR #3057 (#3058)
* Addressed clock inversion and fractiona/interger states. Created ui_debug display that checks expected clock frequencies for expected 3.072 MHz sampling frequency commonly utilizaed in portapack apps.

* Ran format-code.sh

* Addressed comments from PR. Ran format-code.sh. Updated definition of a, b, and c in comments and introduced x, y, and z for debug display. Changed default color for P2/P3 conditional debub display for MS_DIV. Removed implied recalibration since this did not address crackling sound.
2026-03-01 21:51:28 +01:00
stafur b8ca356ce3 Addressed clock inversion and fractional/interger states for 3.072 MHz sampling rate (#3057)
* Addressed clock inversion and fractiona/interger states. Created ui_debug display that checks expected clock frequencies for expected 3.072 MHz sampling frequency commonly utilizaed in portapack apps.

* Ran format-code.sh
2026-03-01 21:28:36 +01:00
stafur 3a54b112ec Imrpoved sound quality in analog_audio_app, and added Nyquist protection option to BBW filter for praline. (#3054) 2026-02-28 23:36:01 +01:00
stafur b013e68b17 Sampling frequency and Receiver Model tweaks. (#3053) 2026-02-28 10:11:04 +01:00
stafur b2bf0f2459 Legacy Initialization, Analog Audio App, and Aliasing fixes. (#3052)
* Added PRO button to analog_audio.cpp for debugging metallic ringing sounds in Audio app. Ensured consitency to 4MHz in analog_audio.cpp

* Restored blutooth after loss.

* Added several sampling rates to analog_audio for testing.

* Ran format-code.sh

* Fixed 0x03 mode for DC/Q-INV/Q-SHFT being set at every tuning and sample rate change. This was the root cause for loss of bluetooth before. Sample rate, and frequency can now be changed without need for manually resetting DC/Q-INV/Q-SHIFT settings. Updated method for setting frequncies in praline so that we have more testing options.

* Ran format-code.sh and cleaned up stale comments.

* Addressed comments, and removed commented line, opting for higher register values, 5E and 5D. Added WFM Debug View to support testing demodulation ringing.

* Addressed comments in PR conversation to clean comments and ensure consistency at initializtion accross updated methods and displays.

* Ran format-code.sh

* Set initial legacy state. Improved readability of clocking initialization settings. Updated set_sampling_frequency, and udpate_bandwidth to set decimation values in the fpga_registers to avoid aliasing in low band frequencies.

* Updated clock_manager to use correct clock and clock parameters for audio pll. Ran format-code.sh.
2026-02-27 23:43:19 -05:00
stafur 56adca3bf6 Resolved root cause for loss of bluetooth functionality and added more testing options (#3049)
* Added PRO button to analog_audio.cpp for debugging metallic ringing sounds in Audio app. Ensured consitency to 4MHz in analog_audio.cpp

* Restored blutooth after loss.

* Added several sampling rates to analog_audio for testing.

* Ran format-code.sh

* Fixed 0x03 mode for DC/Q-INV/Q-SHFT being set at every tuning and sample rate change. This was the root cause for loss of bluetooth before. Sample rate, and frequency can now be changed without need for manually resetting DC/Q-INV/Q-SHIFT settings. Updated method for setting frequncies in praline so that we have more testing options.

* Ran format-code.sh and cleaned up stale comments.

* Addressed comments, and removed commented line, opting for higher register values, 5E and 5D. Added WFM Debug View to support testing demodulation ringing.

* Addressed comments in PR conversation to clean comments and ensure consistency at initializtion accross updated methods and displays.

* Ran format-code.sh
2026-02-26 11:16:07 -05:00
stafur cd7c412aa4 Improve low band signal reception (FM Radio Station Audio tests) (#3048)
* Added PRO button to analog_audio.cpp for debugging metallic ringing sounds in Audio app. Ensured consitency to 4MHz in analog_audio.cpp

* Restored blutooth after loss.

* Added several sampling rates to analog_audio for testing.

* Ran format-code.sh
2026-02-25 03:29:21 -05:00
gullradriel 16c4c28584 fix guru in level / scanner / recon app (#3047)
* fix guru
* fix potential guru
* added information for the sudden return
2026-02-25 01:28:16 +01:00
Totoo 10d17fa7ce Fix device locking in grid item selection callback (#3044) 2026-02-24 16:32:05 +01:00
Totoo e63f54c0a2 Fixes (#3032) 2026-02-24 11:23:41 +01:00
stafur b09efb4d3c Mixer lock:: update clocks and move fpga_bridge_init to portapack.cpp (#3039)
* Updated harckrf_gpio methods to more closely reflect hackrf_usb. Added some ui debug updates to RFFC5072 Status View.

* Updated tuning tables for tuning.cpp. Remnoved 15MHz lower limit in max2831.cpp since lower bandwidths don't seem to be causing lower band issues. Added more opportunities for clocks to stabalize at startup in board.cpp. Added/amended UI to help with addresssing low band tuning issues. Cleaned up stale comments in radio.cpp.

* Ran format-code.sh

* Updated to remove commented lines as part of clean up addressing review comments.

* Fixed clock_manager.cpp configruation for praline. Praline hackrf pro should have: CLK4: 6mA, Invert RFFC5072 40MHz ref and CLK5: 4mA, Invert MAX2831 40MHz ref. Improvements should be visible in the watefall at 2.4GHz, and between 2.311 and 2.599GHz.

* After reviewin clock config, updated values to reflect: CLK0 MAX5864 (ADC) 40 MHz 4mA Normal Integer Minimizes sampling jitter for SNR. CLK1 iCE40 FPGA 40 MHz 6mA Normal Integer Stable timing for the SPI bridge. CLK2 LPC43xx MCU 40 MHz 4mA Normal Integer Standard reference for MCU PLL. CLK3 SMA Port P1 10 MHz 8mA Normal Integer Cleanest square wave for Ext Ref. CLK4 RFFC5072 (Mixer) 40 MHz 6mA Inverted Integer Crucial for PLL Lock stability. CLK5 MAX2831 (TRX) 40 MHz 4mA Inverted Integer Reduces phase noise in the 2.4GHz LO. CLK6 SMA Port P2 10 MHz 8mA Normal Integer Sync output for external gear. CLK7 Reserved Off N/A N/A N/A Disabled to save power/reduce EMI.

* Ran format-code.sh

* Moved fpga_brdige_init to portapack.cpp. This more closely resembles how hackrf_usb starts initializes the fpga, and allows time for the clocks to stabilize and facilitate locking to support low band tuning.

* Ran format-code.sh

* Added ProRadio Debug display to check for / debug locking.

* Moved fpga_bridge_init before radio_init in portapack.cpp

* Low band can now see signals. Updated clock_manager, rffc507 and portapack.cpp to ensure fpga intialized correctly. Ensures rffc507x.cpp has correct 40MHz reference frequency, prescaler, and synth configuration.

* Updated radio to add q-invert on, dc-block on, and deimation=3 (8x, for 20 -> 2.5 MHz decimation for testing cleaner low band signals.

* Ran format-code.sh
2026-02-24 03:36:55 -05:00
gullradriel bfbbacd43c Update hackrf submodule (#3034)
* fix warnings

* update hackrf submodule
2026-02-24 00:41:59 +01:00
Sandbox 065d01b591 Move POCSAG Tx to Ext. (#3033)
* Disable POCSAG TX in menu

Comment out POCSAG TX related code in ui_navigation.cpp

* Comment out ui_pocsag_tx.cpp in CMakeLists

Comment out the ui_pocsag_tx.cpp file in CMakeLists.

* Move POCSAG Tx to Ext.

* Update external.cmake

* Delete firmware/application/apps/ui_pocsag_tx.hpp

* Delete firmware/application/apps/ui_pocsag_tx.cpp

* Update main.cpp

* Update main.cpp

* Update external.ld

* fix namespace

* deleted commented out entry

* delete commented entries

* fix: correct baseband for pocsag tx

* run prepared

---------

Co-authored-by: gullradriel <gullradriel@users.noreply.github.com>
2026-02-23 21:37:03 +01:00
stafur b197a4b1de Update to CLK4 and CLK5 configuration for PRALINE. (#3031)
* Updated harckrf_gpio methods to more closely reflect hackrf_usb. Added some ui debug updates to RFFC5072 Status View.

* Updated tuning tables for tuning.cpp. Remnoved 15MHz lower limit in max2831.cpp since lower bandwidths don't seem to be causing lower band issues. Added more opportunities for clocks to stabalize at startup in board.cpp. Added/amended UI to help with addresssing low band tuning issues. Cleaned up stale comments in radio.cpp.

* Ran format-code.sh

* Updated to remove commented lines as part of clean up addressing review comments.

* Fixed clock_manager.cpp configruation for praline. Praline hackrf pro should have: CLK4: 6mA, Invert RFFC5072 40MHz ref and CLK5: 4mA, Invert MAX2831 40MHz ref. Improvements should be visible in the watefall at 2.4GHz, and between 2.311 and 2.599GHz.

* After reviewin clock config, updated values to reflect: CLK0 MAX5864 (ADC) 40 MHz 4mA Normal Integer Minimizes sampling jitter for SNR. CLK1 iCE40 FPGA 40 MHz 6mA Normal Integer Stable timing for the SPI bridge. CLK2 LPC43xx MCU 40 MHz 4mA Normal Integer Standard reference for MCU PLL. CLK3 SMA Port P1 10 MHz 8mA Normal Integer Cleanest square wave for Ext Ref. CLK4 RFFC5072 (Mixer) 40 MHz 6mA Inverted Integer Crucial for PLL Lock stability. CLK5 MAX2831 (TRX) 40 MHz 4mA Inverted Integer Reduces phase noise in the 2.4GHz LO. CLK6 SMA Port P2 10 MHz 8mA Normal Integer Sync output for external gear. CLK7 Reserved Off N/A N/A N/A Disabled to save power/reduce EMI.

* Ran format-code.sh
2026-02-22 21:31:46 -05:00
stafur 85eaa9d800 Updated praline low and high band tuning (#3030)
* Updated harckrf_gpio methods to more closely reflect hackrf_usb. Added some ui debug updates to RFFC5072 Status View.

* Updated tuning tables for tuning.cpp. Remnoved 15MHz lower limit in max2831.cpp since lower bandwidths don't seem to be causing lower band issues. Added more opportunities for clocks to stabalize at startup in board.cpp. Added/amended UI to help with addresssing low band tuning issues. Cleaned up stale comments in radio.cpp.

* Ran format-code.sh

* Updated to remove commented lines as part of clean up addressing review comments.
2026-02-23 13:40:49 +13:00
Sandbox 1ad092f341 ACARS Rx App using libacars (#3029)
* Using same decode as libacrars
* Enable ACARS RX
* indent + fix warning
* fixed CRC calculations, length validation, message print
Co-authored-by: gullradriel <gullradriel@users.noreply.github.com>
2026-02-22 21:29:20 +01:00
E.T. 0fe51fa7e3 Move flashsize.h to build directory to avoid conflicts when switching between different builds (#3021)
* Move flashsize.h to build directory to avoid conflicts when switching builds

plus small fix in praline image generation

* Update hackrf submodule to latest next

* fix fpga append comments

* Update firmware/CMakeLists.txt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update firmware/CMakeLists.txt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* remove ls dependency from build

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: gullradriel <gullradriel@users.noreply.github.com>
2026-02-22 21:21:03 +01:00
Sandbox 4cc2ba690b Add 12k5 RXBW to NFM Mode (#3023)
* Add 12k5 option to NFM
* Updated freqman_db
* Add 12k5 RXBW to NFM
* Add 12k5 RXBW
* formating
2026-02-22 20:53:26 +01:00
gullradriel abee022000 update submodule, revert lz4 bufs M0/M4 allocation (#3022) 2026-02-21 19:54:48 +01:00
Totoo 430c8e5e79 Enhance ADSB details view with map trail functionality and update gro… (#3020)
* Enhance ADSB details view with map trail functionality and update ground speed calculation
2026-02-21 14:32:20 +01:00
stafur 7ea3eec016 Update to additional gpio definitions for praline (#3018)
* Initial commit and pr for HackRF Pro (praline) arch-port to mayhem-firmware. Please see https://github.com/portapack-mayhem/mayhem-firmware/issues/2957. Added flash specifics for -DBOARD=PRALINE. This firmware only builds with toolchain v9.2.1 if hackrf codebase has -B arm in firmware/hackrf_usb/CMakeLists.txt.

* Updated CMakeLists.txt per coordination with @HtoToo. For -DBOARD=PRALINE FLASH_MB_SIZE and FLASH_MB_LIMIT_SIZE are now 4. Removed praline specific variable for FLASH limits.

* Updated chibios-portapack's board.cpp to support initialization of the HachRF-Pro (praline) FPGA. Added append_fpga_bitstream.py tool to ensure that praline_fgpa.bin bitstream can be appended to -DBOARD=PRALINE produced firmware. In order to ensure successful execution of append_fpga_bitstream.py to append the fpga bitstream we should expect that the bistsream will be located at 0x180000 in flash. This requires that FLASH_MB_LIMIT_SIZE must be 1.5, and FLASH_BYTES_LIMIT_SIZE must be 1535 * 1024. If we want to allow more or less space for the base firmware image sans the fpga bitstream the location of the bistream must be moved to a location other than 0x180000.

* Updated location of praline_fpga.bin bitstream to 0x380000 to allow more room for firmware. Firmware now has 3.5MB, or 2MB more available than before as coordinated with @HTotoo.

* Expanded #ifndef PRALINE to include og and r9 gpio and pin setup as coordinated with @HTotoo.

* Added note for PRALINE FLASH_MB_LIMIT_SIZE and FLASH_BYTES_LIMIT_SIZE to explain why we are using the 3.5 and 3584 values respectively as coordinated with @HTotoo.

* Next round of modifications derived heavily, if not entirely  from work done by @banandana at https://github.com/Banandana/mayhem-firmware. This commit should power on the HackRF Pro (praline) display, power on the fpga, and enable gpio, and provide debug utilties. There is still a lot of work to be done to fully enable the new praline board with this build and firmware architectural porting effort. However, hackrf-one boards do not seem to be adversely impacted by the #ifdef PRALINE statements, and CMakeLists updates, as far as I have been able to test.

* Ran format-code.sh. Updates for this commit are only due to formatting. Tested builds and they seem to work as exptected.

* Addressed fixes in firmware/application and firmware/baseband. Stream now flows to capture and looking glass. Issues were related to thread management. Issues were originally addressed by @banandana.

* Ran format-code.sh to allow for consistency with autoamted clang checks.

* Update hackrf ref repo to mayhem-portapack-hackrf next from https://github.com/portapack-mayhem/hackrf

* Addressed format edits necessary to pass clang-format check.

* Starting addressing Si5351 Clocks for radio sampling. These updates correctly set the Si5351 clock at start up. There appears to be an issue during runtime when testing with RX Test Init, Capture and Looking glass.

* Updated clock_manager.cpp to restore correct function introduced by @banandana when testing with Rx Test Init.

* Switched to using decimation for setting the sample rate without changing the Si5351 clock. This assumes that for the praline board Si5351 CLK0 runs at fixed 8 MHz (constant) and the FPGA decimates to get the desired sample rate. For example, for a 1 MHz sample rate -> Si5351 outputs 8 MHz, FPGA decimates by 8. There is still more work needed here, and potential verification that this is the correct way to operate with this new archteitecture.

* After deliberating on hackrf_usb hackrf_core.c and radio.c, and reviewing firmware/application/hw/si5351.cpp the original approach of using the aproach detailed in hackrf_core.c sample_rate_frac_set() lines 580-582, via the implementation in firmware/application/hw/si5351.cpp seems like the best place to continue testing efforts.

* Tested at ~2.4GHz (2.3 - 2.5) with lookgin glass and was able to receive signals. Added a Signal Path debug app to test gains, and readio mode (receive/transmit).

* Added two debug apps for the RFFC507x. Status View and Tuning View. This helped debug some of the potential issues with tuning.

* update submodule

* format code

* Small touch up merging latest next and ensuring build for HackRF One.

* Fix ui addition of max2831 debug display.

* Reverted edits to re: firmware/baseband/sd_over_usb/scsi.c and firmware/application/portapack.cpp. Source now builds, had to pull latest hackrf submodule.

* Skipped detect hardware for praline board to avoid backscreen in HackRF Pro praline board.

* Added UI debug display for max2831 like the rffc507x. Added Filter Band display and Mixer status to Signal Path Status debug display.

* Added ability to set Q: INV, or Q:NOR in Signal Path Status Debug view for testing. Also added display entries for the FGPA Ctrl register fir debugging.

* Added System Diagnostics which allows testing sample rate, q-inv, and dc blk

* Corrected LP - GPIO4[8], and GPIO4[9] issue which was preventing RF Amp, and LPF from chaning state. HackRF Pro (praline) now correctly changes state of LPF and RF Amp as expected.

* Corrected LP - GPIO4[8], and GPIO4[9] issue which was preventing RF Amp, and LPF from chaning state. HackRF Pro (praline) now correctly changes state of LPF and RF Amp as expected.

* Added consistency for testing.

* Added ui to debug whether rffc5072 is locking correctly. Also addressed rf_amp fixed in on state, such that it may now be able to be toggled in HackRF Pro praline setups.

* Updated format to support automated tests.

* format code

* Updated rffc5072 status view in ui_debug to help with debugging. Made updated recommendtions for merge from PR comments. Made updates to ensure resetx isn't reconfigured for output in rffc507x.cpp.

* Ran ./format-code.sh

* Added reference comment that addresses debugging in PRALINE to detail that when the capture app was requesting 15 MHz, it matched 15100000 which resulted in the 8.5M setting. To get the actual 15M setting (22.6 MHz bandwidth), I had to force a request at least 22 MHz while debugging.

* Debugging tunning ENX and frequency locking in low band.

* Addressed pin differences between HackRF One and HackRF Pro (praline), resolved ENX configuration.

* Cirrected pins, and debugging tuning for low band. High band now goes past 2.7GHz into 3.3 GHz.

* Updated ui_debug to track ENX updates and support tracing which calls may be changing ENX.

* Removed clkin reference in ui_debug.cpp to allow space for more information about CLK0, CLK1, CLK4, and CLK5.

* Removed clkin reference in ui_debug.cpp to allow space for more information about CLK0, CLK1, CLK4, and CLK5.

* Ran format-code.sh

* Updated rffc507xx.cpp, and ensured hackrf submodule at f1dcd554.

---------

Co-authored-by: gullradriel <gullradriel@users.noreply.github.com>
2026-02-21 16:48:23 +13:00
Totoo eb524f7110 fix dino hiscore position (#3017) 2026-02-20 22:09:55 +01:00
Totoo 3413d71bb3 Refactor marker addition logic in ADSBRxView to eliminate shadow markers and optimize RAM usage (#3013) 2026-02-20 15:18:15 +01:00
E.T. c64dddf5cc Dockerize docu update (#3014) 2026-02-20 14:49:35 +01:00
Totoo 3d56bccd49 Fix sd_over_usb serial command (#3015) 2026-02-20 14:43:20 +01:00
gullradriel 705e4f125f Update submodule, fix warnings for PRALINE (#3012)
* update submodule
* remove pragma, remove unused variable
* fix bad external decl, signed vs unsigned comparison
* fix unused: display computed flags
* fix max2881 info mess
* code format
* fix gui positions
* use constexpr for min and max lo_frequencies
2026-02-20 11:08:41 +00:00
qwer123 363b27efe8 fix RX AUDIO baseband async error for PRALINE (#3010) 2026-02-20 10:35:19 +01:00
E.T. f8ed7489c9 update docker entrypoint to support setting build directory via -B or --workdir arguments (#3011) 2026-02-20 10:29:22 +01:00
Totoo 0685fb7a9f Add altitude-based color coding for map markers in adsb (#3004)
* Add altitude-based color coding for map markers in adsb
2026-02-19 20:50:49 +01:00
Totoo 6498f5a1b2 Notifications (#3002) 2026-02-19 14:33:01 +01:00
jLynx 77f747aab2 Add HackRF Pro (PRALINE) Board Detection and Info Display (#3006) 2026-02-19 08:56:22 +01:00
Jeff Laflamme 819b4d0fed Add restaurant pager (EV1527-variant) to SubGhzD (#2998)
* Add restaurant pager protocol to SubGhzD receiver

EV1527-variant 25-bit OOK PWM decoder for restaurant pager
systems (JianTao JT-913 and similar). Decodes system ID,
pager address, and function code (buzz/sync).

* Show friendly pager details in SubGhzD view
2026-02-18 07:47:41 +01:00
jLynx 15df51f976 TPMS TX Application with Enhanced RX Integration (#3001)
* Add TPMS transmit application with editable fields and update linker script

* Fix formatting in application information structure for TPMS TX

* Implement TPMS recent entry detail view and enhance TPMS TX encoding logic

* Refactor TPMS TX UI layout and streamline packet display updates

* Fix formatting by removing unnecessary blank line in TPMSTXView constructor

* Enhance TPMS transmission logic with signal type handling and update UI components

* Add advanced mode toggle and auto-select signal type based on packet type

* Enhance packet display and encoding logic with protocol-specific notes for temperature and ID handling

* Implement baseband switching logic for TPMS transmission based on signal type

* Implement application-level FSK repeat handling and initialize repeat counter

* Add FSK termination function and improve transmission handling

* Remove unused kill_fsk function and clean up whitespace in TPMS transmission logic

* Add pressure and temperature unit conversion functionality in TPMSTXView

* Add temperature and function field visibility handling in TPMSTXView

* Add signal type handling and improve data loading in TPMSTXView

* Fix formatting of pressure unit string in TPMSRecentEntryDetailView

* Add pressure overflow checks and enhance transponder ID handling in TPMSTXView

* Update application information and change icon color to green in TPMS TX

* Update desired menu position for TPMS TX application
2026-02-17 22:02:27 -08:00
zxkmm e9e78609b7 init (#3000) 2026-02-17 16:06:38 +08:00
Totoo 785bd06938 fix random splash file selection logic in SplashScreenView (#2999) 2026-02-17 20:52:08 +13:00
zxkmm 300a4b03c6 fix the FLASH ERR warn on hackrf pro plus PP H1/2/3/4 (#2997)
* init

* remove mbt
2026-02-17 12:31:03 +08:00
jLynx eaa07f8369 Fix HackRF Pro firmware compatibility check failure (#2996)
* fix: update SUPPORTED_PLATFORM definition to align with official HackRF firmware logic

* fix: align SUPPORTED_PLATFORM macro formatting with coding standards
2026-02-17 11:35:12 +08:00
stafur c31a978e6f Next pralinetcv9.2.1 archport (#2991)
* Initial commit and pr for HackRF Pro (praline) arch-port to mayhem-firmware. Please see https://github.com/portapack-mayhem/mayhem-firmware/issues/2957. Added flash specifics for -DBOARD=PRALINE. This firmware only builds with toolchain v9.2.1 if hackrf codebase has -B arm in firmware/hackrf_usb/CMakeLists.txt.

* Updated CMakeLists.txt per coordination with @HtoToo. For -DBOARD=PRALINE FLASH_MB_SIZE and FLASH_MB_LIMIT_SIZE are now 4. Removed praline specific variable for FLASH limits.

* Updated chibios-portapack's board.cpp to support initialization of the HachRF-Pro (praline) FPGA. Added append_fpga_bitstream.py tool to ensure that praline_fgpa.bin bitstream can be appended to -DBOARD=PRALINE produced firmware. In order to ensure successful execution of append_fpga_bitstream.py to append the fpga bitstream we should expect that the bistsream will be located at 0x180000 in flash. This requires that FLASH_MB_LIMIT_SIZE must be 1.5, and FLASH_BYTES_LIMIT_SIZE must be 1535 * 1024. If we want to allow more or less space for the base firmware image sans the fpga bitstream the location of the bistream must be moved to a location other than 0x180000.

* Updated location of praline_fpga.bin bitstream to 0x380000 to allow more room for firmware. Firmware now has 3.5MB, or 2MB more available than before as coordinated with @HTotoo.

* Expanded #ifndef PRALINE to include og and r9 gpio and pin setup as coordinated with @HTotoo.

* Added note for PRALINE FLASH_MB_LIMIT_SIZE and FLASH_BYTES_LIMIT_SIZE to explain why we are using the 3.5 and 3584 values respectively as coordinated with @HTotoo.

* Next round of modifications derived heavily, if not entirely  from work done by @banandana at https://github.com/Banandana/mayhem-firmware. This commit should power on the HackRF Pro (praline) display, power on the fpga, and enable gpio, and provide debug utilties. There is still a lot of work to be done to fully enable the new praline board with this build and firmware architectural porting effort. However, hackrf-one boards do not seem to be adversely impacted by the #ifdef PRALINE statements, and CMakeLists updates, as far as I have been able to test.

* Ran format-code.sh. Updates for this commit are only due to formatting. Tested builds and they seem to work as exptected.

* Addressed fixes in firmware/application and firmware/baseband. Stream now flows to capture and looking glass. Issues were related to thread management. Issues were originally addressed by @banandana.

* Ran format-code.sh to allow for consistency with autoamted clang checks.

* Update hackrf ref repo to mayhem-portapack-hackrf next from https://github.com/portapack-mayhem/hackrf

* Addressed format edits necessary to pass clang-format check.

* Starting addressing Si5351 Clocks for radio sampling. These updates correctly set the Si5351 clock at start up. There appears to be an issue during runtime when testing with RX Test Init, Capture and Looking glass.

* Updated clock_manager.cpp to restore correct function introduced by @banandana when testing with Rx Test Init.

* Switched to using decimation for setting the sample rate without changing the Si5351 clock. This assumes that for the praline board Si5351 CLK0 runs at fixed 8 MHz (constant) and the FPGA decimates to get the desired sample rate. For example, for a 1 MHz sample rate -> Si5351 outputs 8 MHz, FPGA decimates by 8. There is still more work needed here, and potential verification that this is the correct way to operate with this new archteitecture.

* After deliberating on hackrf_usb hackrf_core.c and radio.c, and reviewing firmware/application/hw/si5351.cpp the original approach of using the aproach detailed in hackrf_core.c sample_rate_frac_set() lines 580-582, via the implementation in firmware/application/hw/si5351.cpp seems like the best place to continue testing efforts.

* Tested at ~2.4GHz (2.3 - 2.5) with lookgin glass and was able to receive signals. Added a Signal Path debug app to test gains, and readio mode (receive/transmit).

* Added two debug apps for the RFFC507x. Status View and Tuning View. This helped debug some of the potential issues with tuning.

* update submodule

* format code

* Small touch up merging latest next and ensuring build for HackRF One.

* Fix ui addition of max2831 debug display.

* Reverted edits to re: firmware/baseband/sd_over_usb/scsi.c and firmware/application/portapack.cpp. Source now builds, had to pull latest hackrf submodule.

* Skipped detect hardware for praline board to avoid backscreen in HackRF Pro praline board.

* Added UI debug display for max2831 like the rffc507x. Added Filter Band display and Mixer status to Signal Path Status debug display.

* Added ability to set Q: INV, or Q:NOR in Signal Path Status Debug view for testing. Also added display entries for the FGPA Ctrl register fir debugging.

* Added System Diagnostics which allows testing sample rate, q-inv, and dc blk

* Corrected LP - GPIO4[8], and GPIO4[9] issue which was preventing RF Amp, and LPF from chaning state. HackRF Pro (praline) now correctly changes state of LPF and RF Amp as expected.

* Corrected LP - GPIO4[8], and GPIO4[9] issue which was preventing RF Amp, and LPF from chaning state. HackRF Pro (praline) now correctly changes state of LPF and RF Amp as expected.

* Added consistency for testing.

* Added ui to debug whether rffc5072 is locking correctly. Also addressed rf_amp fixed in on state, such that it may now be able to be toggled in HackRF Pro praline setups.

* Updated format to support automated tests.

* format code

* Updated rffc5072 status view in ui_debug to help with debugging. Made updated recommendtions for merge from PR comments. Made updates to ensure resetx isn't reconfigured for output in rffc507x.cpp.

* Ran ./format-code.sh

* Added reference comment that addresses debugging in PRALINE to detail that when the capture app was requesting 15 MHz, it matched 15100000 which resulted in the 8.5M setting. To get the actual 15M setting (22.6 MHz bandwidth), I had to force a request at least 22 MHz while debugging.

---------

Co-authored-by: gullradriel <gullradriel@users.noreply.github.com>
2026-02-17 15:27:29 +13:00
Pezsma 266db4b158 Random splash on boot (#2961) 2026-02-16 17:52:47 +01:00
gullradriel 290bf543a1 fix restore settings (#2995) 2026-02-16 17:06:57 +01:00
gullradriel e17f4c4ab4 Fix units tpms not compiling (#2994)
* add defines for unit types
* fix compilation, units usage and variables names
2026-02-16 15:50:27 +01:00
lifegame1lu111 83a4580353 Refactor KeeLoq crypto functions and add new KeeLoq TX app (#2990) 2026-02-16 15:19:50 +01:00
Hoite Prins 00f40bf171 feat: add BAR unit support to TPMS RX app (#2988)
- Add bar() conversion method to Pressure class
- Convert pressure units system from boolean to enum (kPa, PSI, BAR)
- Add BAR option to pressure unit selector in UI
- Update settings manager to persist pressure unit preference
- Use ternary operators for compact pressure formatting
2026-02-16 14:55:12 +01:00
Totoo 794daf5257 Rtty tx and rx (#2977) 2026-02-16 14:34:55 +01:00
gullradriel 95eafeb812 fix clang format workflow, update hackrf submodule, fix subghzd compilation warning, remove flashsize.h (#2992)
* trying to fix clang format workflow
* try without docker repo, classic apt install
* find what installed clang format 18 version is
* removed auto generated flashsize
* comment on flashsize.h
* modified to use repo owned clang-format binaries
* code format for windows hosts
* add clang-format binaries for linux x86_64/arm64, macos-arm64, windows x86_64
* add helper script to download specific llvm clang-format version
* add helper to download missing libraries (use docker)
* use custom clang-format
* fix ui_subghzd.cpp:85:29: warning: narrowing conversion of 'this->ui::SubGhzDRecentEntryDetailView::cnt' from 'uint32_t' {aka 'long unsigned int'} to 'uint16_t' {aka 'short unsigned int'} [-Wnarrowing]
* remove auto generated file
* Update tools/clang-format.sh
* removed fallback
* updated hackrf submodule
2026-02-15 21:29:26 +00:00
gullradriel 94d46036f8 up to latest (#2984) 2026-02-12 12:00:22 +00:00
Totoo 68000f0b94 fix compile (#2983) 2026-02-12 12:41:12 +01:00
lifegame1lu111 eff68693ad Add support for decrypting and saving KeeLoq signals for SubGhzD (#2982) 2026-02-12 10:41:56 +01:00
207 changed files with 11219 additions and 1449 deletions
+18 -10
View File
@@ -3,7 +3,7 @@ name: Check formatting
on: [pull_request]
jobs:
check_date:
check_format:
runs-on: ubuntu-latest
name: Check formatting
strategy:
@@ -13,12 +13,20 @@ jobs:
- "firmware/application"
- "firmware/baseband"
steps:
- uses: actions/checkout@v2
- name: print latest_commit
run: echo ${{ github.sha }}
- name: clang-format Check
uses: jidicula/clang-format-action@v4.11.0
with:
clang-format-version: '18'
check-path: ${{ matrix.path }}
fallback-style: Chromium
- uses: actions/checkout@v4
- name: clang-format check (repo pinned)
run: |
set -euo pipefail
CF="./tools/clang-format.sh"
chmod +x "$CF" || true
"$CF" --version
ROOT="${{ matrix.path }}"
find "$ROOT" -type f \( \
-name '*.c' -o -name '*.cpp' -o \
-name '*.h' -o -name '*.hpp' \
\) -print0 \
| xargs -0 -r "$CF" --dry-run --Werror --style=file
+38 -118
View File
@@ -60,7 +60,7 @@ jobs:
- name: Make build folder
run: mkdir ${{ github.workspace }}/build
- name: Run the Docker image
run: docker run -e VERSION_STRING=${{ steps.version_date.outputs.date }} -i -v ${{ github.workspace }}:/havoc portapack-dev ${{ matrix.cmake_args }}
run: docker run -e VERSION_STRING=${{ steps.version_date.outputs.date }} -i -v ${{ github.workspace }}:/havoc portapack-dev ninja ${{ matrix.cmake_args }}
- name: Create Small SD Card ZIP - No World Map
run: |
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-mayhem-firmware.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version_date.outputs.date }}.bin && cp build/firmware/portapack-mayhem_OCI.ppfw.tar sdcard/FIRMWARE/mayhem_nightly_${{ steps.version_date.outputs.date }}${{ matrix.artifact_suffix }}_OCI.ppfw.tar && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && cp build/firmware/standalone/*/*.ppmp sdcard/APPS && cd sdcard && zip -r ../sdcard-no-map.zip . && cd ..
@@ -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/*
+38 -118
View File
@@ -43,7 +43,7 @@ jobs:
- name: Make build folder
run: mkdir ${{ github.workspace }}/build
- name: Run the Docker image
run: docker run -e VERSION_STRING=${{ steps.version.outputs.version }} -i -v ${{ github.workspace }}:/havoc portapack-dev ${{ matrix.cmake_args }}
run: docker run -e VERSION_STRING=${{ steps.version.outputs.version }} -i -v ${{ github.workspace }}:/havoc portapack-dev ninja ${{ matrix.cmake_args }}
- name: Create Small SD Card ZIP - No World Map
run: |
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-mayhem-firmware.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version.outputs.version }}.bin && cp build/firmware/portapack-mayhem_OCI.ppfw.tar sdcard/FIRMWARE/mayhem_${{ steps.version.outputs.version }}${{ matrix.artifact_suffix }}_OCI.ppfw.tar && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && cp build/firmware/standalone/*/*.ppmp sdcard/APPS && cd sdcard && zip -r ../sdcard-no-map.zip . && cd ..
@@ -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
View File
@@ -83,4 +83,3 @@ 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
firmware/flashsize.h
+1 -4
View File
@@ -43,7 +43,7 @@ if(NOT DEFINED FLASH_MB_LIMIT_SIZE)
set(FLASH_MB_LIMIT_SIZE 3.5) #PRALINE 4 MB = 3.5 firmware + 0.5 MB fpga bitstream.
else()
set(FLASH_MB_LIMIT_SIZE 1) #TODO: should be ${FLASH_MB_SIZE} remove once we got a stable build for all devices we support with bigger than 1 mb flash
endif()
endif()
endif()
message("Configuring for FLASH_MB_LIMIT_SIZE=${FLASH_MB_LIMIT_SIZE}MB")
@@ -58,9 +58,6 @@ else()
math(EXPR FLASH_BYTES_LIMIT_SIZE "${FLASH_MB_LIMIT_SIZE} * 1024 * 1024")
endif()
#generate h files
configure_file(flashsize.h.in ${CMAKE_CURRENT_SOURCE_DIR}/firmware/flashsize.h)
option(USE_CCACHE "Enable ccache, please keep an eye on this because sometimes it's not quite stable and generated unusable binary" OFF)
project(portapack-h1)
+10 -6
View File
@@ -10,16 +10,20 @@
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?
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="PortaPack H4M Crash Course" src="https://img.youtube.com/vi/CjI-nUzdpas/maxresdefault.jpg" width="701">](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="Its 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="Its 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,9 +32,9 @@ 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: ![Static Badge](https://img.shields.io/badge/NEW-yellow) 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: ![Static Badge](https://img.shields.io/badge/NEW-yellow) The fabulous H4M [complete](https://share.hackrf.app/DF2BZS) 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/QT5JMB), 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).
+2 -2
View File
@@ -29,5 +29,5 @@ RUN mkdir /opt/build \
ADD firmware/tools/docker-entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# replace make with ninja temporarily while building your image if you prefer to use that by default
CMD ["make"]
# replace ninja with make if you prefer to use that by default
CMD ["ninja"]
+5 -2
View File
@@ -15,8 +15,11 @@
# - Get a shell inside the build image to
# inspect problems: ./dockerize.sh shell
# - Give additional parameters to the container:
# ./dockerize.sh -j10
# ./dockerize.sh ninja -j10
# Additional parameters to make: ./dockerize.sh -j10
# Use ninja instead of make: ./dockerize.sh ninja -j10
# Addotopnal CMake parameters: ./dockerize.sh -DBOARD=PRALINE
# Change the default build directory: ./dockerize.sh -B build-alt
# (Alternatively --workdir works as well)
# - Use a different dockerfile:
# ./dockerize.sh build dockerfile-other
# - Use a different cpu architecture:
+33 -26
View File
@@ -48,43 +48,50 @@ if(NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL ${EXPECTED_GCC_VERSION})
set(GCC_VERSION_MISMATCH 1)
endif()
#generate h files
configure_file(flashsize.h.in flashsize.h)
add_compile_options(-include ${CMAKE_CURRENT_BINARY_DIR}/flashsize.h)
add_subdirectory(application)
add_subdirectory(baseband)
add_subdirectory(standalone)
add_subdirectory(test)
# NOTE: Dependencies break if the .bin files aren't included in DEPENDS. WTF, CMake?
add_custom_command(
OUTPUT ${FIRMWARE_FILENAME}
COMMAND ${MAKE_SPI_IMAGE} ${application_BINARY_DIR}/application.bin ${baseband_BINARY_DIR}/baseband.img ${FIRMWARE_FILENAME} ${FLASH_BYTES_LIMIT_SIZE}
DEPENDS baseband application ${MAKE_SPI_IMAGE}
${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin
VERBATIM
)
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)
set(APPEND_FPGA_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/tools/append_fpga_bitstream.py)
# NOTE: Dependencies break if the .bin files aren't included in DEPENDS. WTF, CMake?
add_custom_command(
OUTPUT ${FIRMWARE_FILENAME}
COMMAND ${MAKE_SPI_IMAGE} ${application_BINARY_DIR}/application.bin ${baseband_BINARY_DIR}/baseband.img ${FIRMWARE_FILENAME} ${FLASH_BYTES_LIMIT_SIZE}
# PRALINE: Append FPGA bitstream to firmware at offset 0x380000
# The base firmware is 3.5MB, FPGA bitstream gets appended at the end of it, final size is 4MB
COMMAND ${CMAKE_COMMAND} -E echo "Appending PRALINE FPGA bitstream to firmware..."
COMMAND python3 ${APPEND_FPGA_SCRIPT} ${FIRMWARE_FILENAME} ${PRALINE_FPGA_BIN} ${FIRMWARE_FILENAME}.tmp ${PRALINE_FINAL_SIZE}
COMMAND ${CMAKE_COMMAND} -E rename ${FIRMWARE_FILENAME}.tmp ${FIRMWARE_FILENAME}
DEPENDS baseband application ${MAKE_SPI_IMAGE}
${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin
${PRALINE_FPGA_BIN} ${APPEND_FPGA_SCRIPT}
VERBATIM
)
else() # Sadly this part had to be duplicated (or at least I couldn't find a better way to do it)
# NOTE: Dependencies break if the .bin files aren't included in DEPENDS. WTF, CMake?
add_custom_command(
OUTPUT ${FIRMWARE_FILENAME}
COMMAND ${MAKE_SPI_IMAGE} ${application_BINARY_DIR}/application.bin ${baseband_BINARY_DIR}/baseband.img ${FIRMWARE_FILENAME} ${FLASH_BYTES_LIMIT_SIZE}
DEPENDS baseband application ${MAKE_SPI_IMAGE}
${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin
VERBATIM
)
endif()
add_custom_target(
firmware
DEPENDS ${FIRMWARE_FILENAME} ${HACKRF_FIRMWARE_DFU_FILENAME} ${HACKRF_FIRMWARE_FILENAME}
)
# PRALINE: Append FPGA bitstream to firmware at offset 0x180000
# The base firmware is 1MB, FPGA goes at 1MB offset, final size is 2MB
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)
set(APPEND_FPGA_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/tools/append_fpga_bitstream.py)
add_custom_command(
TARGET firmware POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Appending PRALINE FPGA bitstream to firmware..."
COMMAND python3 ${APPEND_FPGA_SCRIPT} ${FIRMWARE_FILENAME} ${PRALINE_FPGA_BIN} ${FIRMWARE_FILENAME}.tmp ${PRALINE_FINAL_SIZE}
COMMAND ${CMAKE_COMMAND} -E rename ${FIRMWARE_FILENAME}.tmp ${FIRMWARE_FILENAME}
COMMAND ${CMAKE_COMMAND} -E echo "PRALINE firmware with FPGA bitstream created:"
COMMAND ls -la ${FIRMWARE_FILENAME}
COMMENT "Appending PRALINE FPGA bitstream"
VERBATIM
)
endif()
if(${GCC_VERSION_MISMATCH})
set(COMPILER_MISMATCH_MESSAGE "WARNING: Compiler version mismatch, please use the official compiler version ${EXPECTED_GCC_VERSION} when sharing builds! Current compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
message(${COMPILER_MISMATCH_MESSAGE})
+4 -1
View File
@@ -213,6 +213,9 @@ set(CPPSRC
irq_controls.cpp
irq_lcd_frame.cpp
irq_rtc.cpp
keeloq_common.cpp
keeloq_file.cpp
keeloq_keystore.cpp
log_file.cpp
metadata_file.cpp
flipper_subfile.cpp
@@ -255,6 +258,7 @@ set(CPPSRC
ook_file.cpp
ui_baseband_stats_view.cpp
ui_navigation.cpp
ui_notifications.cpp
ui_record_view.cpp
ui_sd_card_status_view.cpp
ui/ui_alphanum.cpp
@@ -301,7 +305,6 @@ set(CPPSRC
apps/ui_mictx.cpp
apps/ui_modemsetup.cpp
apps/ui_playlist.cpp
apps/ui_pocsag_tx.cpp
apps/ui_rds.cpp
apps/ui_recon_settings.cpp
apps/ui_recon.cpp
+67 -1
View File
@@ -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);
@@ -256,6 +311,10 @@ AnalogAudioView::AnalogAudioView(
field_frequency.set_value(receiver_model.target_frequency() + offset);
};
#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
@@ -553,4 +612,11 @@ void AnalogAudioView::handle_coded_squelch(uint32_t value) {
void AnalogAudioView::on_freqchg(int64_t freq) {
field_frequency.set_value(freq);
}
#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;
+2 -1
View File
@@ -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.
@@ -225,7 +226,7 @@ void BLETxView::send_packet() {
uint8_t min = 0x00;
uint8_t max = 0x0F;
hexDigit = min + std::rand() % (max - min + 1);
hexDigit = min + rand() % (max - min + 1);
} break;
default:
hexDigit = 0;
+112 -9
View File
@@ -271,10 +271,17 @@ ADSBRxDetailsView::ADSBRxDetailsView(
&text_frame_pos_even,
&text_frame_pos_odd,
&button_aircraft_details,
&button_see_map});
&button_see_map,
&opt_map_list});
text_icao_address.set(entry_.icao_str);
opt_map_list.on_change = [this](size_t, uint32_t mf) {
map_filter = mf;
clear_map_markers(); // reset them
pos_history.clear(); // erase the trail
};
button_aircraft_details.on_select = [this, &nav](Button&) {
aircraft_details_view_ = nav.push<ADSBRxAircraftDetailsView>(entry_);
nav.set_on_pop([this]() {
@@ -288,7 +295,7 @@ ADSBRxDetailsView::ADSBRxDetailsView(
get_map_tag(entry_),
entry_.pos.altitude,
GeoPos::alt_unit::FEET,
GeoPos::spd_unit::HIDDEN,
GeoPos::spd_unit::KNOTS,
entry_.pos.latitude,
entry_.pos.longitude,
entry_.velo.heading);
@@ -312,17 +319,107 @@ void ADSBRxDetailsView::update(const AircraftRecentEntry& entry) {
// AC Details view is showing, nothing to update.
} else if (geomap_view_) {
// Map is showing, update the current item.
if (map_filter == 1) {
// add to map trail history
add_map_trail(entry);
}
geomap_view_->update_tag(get_map_tag(entry_));
geomap_view_->update_position(entry.pos.latitude, entry.pos.longitude, entry.velo.heading, entry.pos.altitude, entry.velo.speed);
geomap_view_->update_position(entry.pos.latitude, entry.pos.longitude, entry.velo.heading, entry.pos.altitude, entry.get_ground_speed());
} else {
// Details is showing, update details.
refresh_ui();
}
}
void ADSBRxDetailsView::get_altitude_color(int32_t alt_ft, uint8_t* r, uint8_t* g, uint8_t* b) {
static const struct {
int32_t alt;
uint8_t r, g, b;
} stops[] = {
{0, 220, 220, 220}, // 0 ft: White/Grey (Ground)
{2000, 255, 255, 0}, // 2k ft: Yellow
{10000, 0, 255, 0}, // 10k ft: Green
{20000, 0, 255, 255}, // 20k ft: Cyan
{30000, 60, 60, 255}, // 30k ft: Blue (Lightened for visibility on Black)
{40000, 255, 0, 255} // 40k+ ft: Magenta
};
if (alt_ft <= stops[0].alt) {
*r = stops[0].r;
*g = stops[0].g;
*b = stops[0].b;
return;
}
const int count = sizeof(stops) / sizeof(stops[0]);
if (alt_ft >= stops[count - 1].alt) {
*r = stops[count - 1].r;
*g = stops[count - 1].g;
*b = stops[count - 1].b;
return;
}
for (int i = 0; i < count - 1; i++) {
if (alt_ft < stops[i + 1].alt) {
float t = (float)(alt_ft - stops[i].alt) / (stops[i + 1].alt - stops[i].alt);
*r = (uint8_t)(stops[i].r + (stops[i + 1].r - stops[i].r) * t);
*g = (uint8_t)(stops[i].g + (stops[i + 1].g - stops[i].g) * t);
*b = (uint8_t)(stops[i].b + (stops[i + 1].b - stops[i].b) * t);
return;
}
}
// Fallback: in case no interval matched, default to ground color.
*r = stops[0].r;
*g = stops[0].g;
*b = stops[0].b;
}
void ADSBRxDetailsView::clear_map_markers() {
if (geomap_view_)
geomap_view_->clear_markers();
if (map_filter == 1)
refresh_trail_markers(); // re add trail
}
void ADSBRxDetailsView::refresh_trail_markers() {
if (!geomap_view_)
return;
geomap_view_->clear_markers();
for (const auto& pos : pos_history) {
GeoMarker marker{};
marker.lon = pos.lon;
marker.lat = pos.lat;
marker.angle = pos.heading;
marker.tag = ""; // No tag for trail points
uint8_t r, g, b;
get_altitude_color(pos.altitude, &r, &g, &b);
marker.color = Color(r, g, b);
geomap_view_->store_marker(marker);
}
}
void ADSBRxDetailsView::add_map_trail(const AircraftRecentEntry& entry) {
if (!geomap_view_)
return;
if (entry.pos.pos_valid == false)
return;
if (!pos_history.empty()) {
const auto& last_pos = pos_history.back();
const float THRESH_DEG = 0.009f;
const float THRESH_SQ = THRESH_DEG * THRESH_DEG; // 0.00002025f
float d_lat = entry.pos.latitude - last_pos.lat;
float d_lon = entry.pos.longitude - last_pos.lon;
if ((d_lat * d_lat) + (d_lon * d_lon) < THRESH_SQ) {
return; // Moved less than ~1000m, skip (rough estimate, varies with latitude but good enough for our purposes). This prevents adding too many points when the plane is circling or taxiing.
}
}
// Only keep the last 30 positions in the trail.
if (pos_history.size() >= 30)
pos_history.erase(pos_history.begin());
pos_history.push_back({entry.pos.latitude, entry.pos.longitude, entry.velo.heading, entry.pos.altitude});
refresh_trail_markers();
}
bool ADSBRxDetailsView::add_map_marker(const AircraftRecentEntry& entry) {
@@ -330,11 +427,16 @@ bool ADSBRxDetailsView::add_map_marker(const AircraftRecentEntry& entry) {
if (!geomap_view_)
return false;
if (map_filter == 1) return false; // this is the 'only me' option, so skip all others
GeoMarker marker{};
marker.lon = entry.pos.longitude;
marker.lat = entry.pos.latitude;
marker.angle = entry.velo.heading;
marker.tag = get_map_tag(entry);
uint8_t r, g, b;
get_altitude_color(entry.pos.altitude, &r, &g, &b);
marker.color = Color(r, g, b);
auto markerStored = geomap_view_->store_marker(marker);
return markerStored == MARKER_STORED;
@@ -651,14 +753,15 @@ void ADSBRxView::refresh_ui() {
// Process the entries list.
for (const auto& entry : recent) {
// Found the entry being shown in details view. Update it.
if (entry.key() == detail_key) {
if (entry.key() == detail_key) { // we don't add it to the markers, since this is the currently selected and shown in the middle one. This eliminates the "shadow" marker, and saves ram
details_view->update(entry);
current_updated = true;
}
// NB: current entry also gets a marker so it shows up if map is panned.
if (map_needs_update && entry.pos.pos_valid && entry.state <= ADSBAgeState::Recent) {
map_needs_update = details_view->add_map_marker(entry);
} else {
// Add others only
// NB: current entry also gets a marker so it shows up if map is panned.
if (map_needs_update && entry.pos.pos_valid && entry.state <= ADSBAgeState::Recent) {
map_needs_update = details_view->add_map_marker(entry);
}
}
// Any work left to do?
+70 -39
View File
@@ -64,9 +64,9 @@ namespace ui {
#define VEL_AIR_SUBSONIC 3
#define VEL_AIR_SUPERSONIC 4
#define O_E_FRAME_TIMEOUT 20 // timeout between odd and even frames
#define MARKER_UPDATE_SECONDS_OSM 10 // "other" map marker redraw interval for osm
#define MARKER_UPDATE_SECONDS_BIN 5 // "other" map marker redraw interval for bin map
#define O_E_FRAME_TIMEOUT 20 // timeout between odd and even frames
#define MARKER_UPDATE_SECONDS_OSM 8 // "other" map marker redraw interval for osm
#define MARKER_UPDATE_SECONDS_BIN 5 // "other" map marker redraw interval for bin map
/* Thresholds (in seconds) that define the transition between ages. */
struct ADSBAgeLimit {
@@ -150,6 +150,19 @@ struct AircraftRecentEntry {
age = 0;
}
int32_t get_ground_speed() const {
if (velo.valid == false) return 0;
if (velo.type == SPD_GND)
return velo.speed;
else if (velo.type == SPD_IAS) {
if (!pos.alt_valid) return velo.speed; // can't correct without altitude, so just return IAS
return (int32_t)(velo.speed * (1.0f + (0.02f * (pos.altitude / 1000.0f))));
} else if (velo.type == SPD_TAS)
return velo.speed; // We don't know the wind speed
else
return 0;
}
void inc_age(int delta) {
age += delta;
@@ -208,50 +221,50 @@ class ADSBRxAircraftDetailsView : public View {
private:
Labels labels{
{{UI_POS_X(0), 1 * 16}, "ICAO:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 2 * 16}, "Registration:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 3 * 16}, "Manufacturer:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 5 * 16}, "Model:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 7 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 8 * 16}, "Number of engines:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 9 * 16}, "Engine type:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 11 * 16}, "Owner:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 13 * 16}, "Operator:", Theme::getInstance()->fg_light->foreground}};
{{UI_POS_X(0), UI_POS_Y(1)}, "ICAO:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(2)}, "Registration:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(3)}, "Manufacturer:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(5)}, "Model:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(7)}, "Type:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(8)}, "Number of engines:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(9)}, "Engine type:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(11)}, "Owner:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(13)}, "Operator:", Theme::getInstance()->fg_light->foreground}};
Text text_icao_address{
{5 * 8, 1 * 16, 6 * 8, UI_POS_HEIGHT(1)},
{UI_POS_X(5), UI_POS_Y(1), 6 * 8, UI_POS_HEIGHT(1)},
"-"};
Text text_registration{
{13 * 8, 2 * 16, 8 * 8, UI_POS_HEIGHT(1)},
{UI_POS_X(13), UI_POS_Y(2), 8 * 8, UI_POS_HEIGHT(1)},
"-"};
Text text_manufacturer{
{UI_POS_X(0), 4 * 16, 19 * 8, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(4), 19 * 8, UI_POS_HEIGHT(1)},
"-"};
Text text_model{
{UI_POS_X(0), 6 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(6), screen_width, UI_POS_HEIGHT(1)},
"-"};
Text text_type{
{5 * 8, 7 * 16, 22 * 8, UI_POS_HEIGHT(1)},
{UI_POS_X(5), UI_POS_Y(7), 22 * 8, UI_POS_HEIGHT(1)},
"-"};
Text text_number_of_engines{
{18 * 8, 8 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(18), UI_POS_Y(8), screen_width, UI_POS_HEIGHT(1)},
"-"};
Text text_engine_type{
{UI_POS_X(0), 10 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(10), screen_width, UI_POS_HEIGHT(1)},
"-"};
Text text_owner{
{UI_POS_X(0), 12 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(12), screen_width, UI_POS_HEIGHT(1)},
"-"};
Text text_operator{
{UI_POS_X(0), 14 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(14), screen_width, UI_POS_HEIGHT(1)},
"-"};
Button button_close{
@@ -270,11 +283,14 @@ class ADSBRxDetailsView : public View {
void focus() override;
void update(const AircraftRecentEntry& entry);
void get_altitude_color(int32_t alt_ft, uint8_t* r, uint8_t* g, uint8_t* b);
/* Calls forwarded to map view if shown. */
bool map_active() const { return geomap_view_; }
void clear_map_markers();
/* Adds a marker for the entry to the map. Returns true on success. */
bool add_map_marker(const AircraftRecentEntry& entry);
void add_map_trail(const AircraftRecentEntry& entry);
void refresh_trail_markers();
std::string title() const override { return "Details"; }
@@ -297,57 +313,72 @@ class ADSBRxDetailsView : public View {
// if removed from the recent entries list.
AircraftRecentEntry entry_{AircraftRecentEntry::invalid_key};
bool airline_checked{false};
uint8_t map_filter{0}; // 0: all, 1: only this, set by opt_map_list.
struct PosHistory {
float lat;
float lon;
uint16_t heading;
int32_t altitude;
};
std::vector<PosHistory> pos_history{};
Labels labels{
{{UI_POS_X(0), 1 * 16}, "ICAO:", Theme::getInstance()->fg_light->foreground},
{{13 * 8, 1 * 16}, "Callsign:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 2 * 16}, "Last seen:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 3 * 16}, "Airline:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 5 * 16}, "Country:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 13 * 16}, "Even position frame:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), 15 * 16}, "Odd position frame:", Theme::getInstance()->fg_light->foreground}};
{{UI_POS_X(0), UI_POS_Y(0)}, "ICAO:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(13), UI_POS_Y(0)}, "Callsign:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(1)}, "Last seen:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(2)}, "Airline:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(4)}, "Country:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(7)}, "Map filter:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(13)}, "Even position frame:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(15)}, "Odd position frame:", Theme::getInstance()->fg_light->foreground}};
Text text_icao_address{
{5 * 8, 1 * 16, 6 * 8, UI_POS_HEIGHT(1)},
{UI_POS_X(5), UI_POS_Y(0), 6 * 8, UI_POS_HEIGHT(1)},
"-"};
Text text_callsign{
{22 * 8, 1 * 16, 8 * 8, UI_POS_HEIGHT(1)},
{UI_POS_X(22), UI_POS_Y(0), 8 * 8, UI_POS_HEIGHT(1)},
"-"};
Text text_last_seen{
{11 * 8, 2 * 16, 19 * 8, UI_POS_HEIGHT(1)},
{UI_POS_X(11), UI_POS_Y(1), 19 * 8, UI_POS_HEIGHT(1)},
"-"};
Text text_airline{
{UI_POS_X(0), 4 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(3), screen_width, UI_POS_HEIGHT(1)},
"-"};
Text text_country{
{8 * 8, 5 * 16, 22 * 8, UI_POS_HEIGHT(1)},
{UI_POS_X(8), UI_POS_Y(4), 22 * 8, UI_POS_HEIGHT(1)},
"-"};
Text text_infos{
{UI_POS_X(0), 6 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(5), screen_width, UI_POS_HEIGHT(1)},
"-"};
Text text_info2{
{UI_POS_X(0), 7 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(6), screen_width, UI_POS_HEIGHT(1)},
"-"};
Text text_frame_pos_even{
{UI_POS_X(0), 14 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(14), screen_width, UI_POS_HEIGHT(1)},
"-"};
Text text_frame_pos_odd{
{UI_POS_X(0), 16 * 16, screen_width, UI_POS_HEIGHT(1)},
{UI_POS_X(0), UI_POS_Y(16), screen_width, UI_POS_HEIGHT(1)},
"-"};
Button button_aircraft_details{
{UI_POS_X_CENTER(12) - UI_POS_X(8), UI_POS_Y(9), UI_POS_WIDTH(12), UI_POS_HEIGHT(3)},
{UI_POS_X_CENTER(12) - UI_POS_X(8), UI_POS_Y(8), UI_POS_WIDTH(12), UI_POS_HEIGHT(3)},
"A/C details"};
OptionsField opt_map_list{
{UI_POS_X_CENTER(12) + UI_POS_X(8), UI_POS_Y(7)},
12,
{{"All", 0},
{"Only this", 1}}};
Button button_see_map{
{UI_POS_X_CENTER(12) + UI_POS_X(8), UI_POS_Y(9), UI_POS_WIDTH(12), UI_POS_HEIGHT(3)},
{UI_POS_X_CENTER(12) + UI_POS_X(8), UI_POS_Y(8), UI_POS_WIDTH(12), UI_POS_HEIGHT(3)},
"See on map"};
MessageHandlerRegistration message_handler_gps{
File diff suppressed because it is too large Load Diff
+610 -54
View File
@@ -438,6 +438,113 @@ class RadioDiagnosticsView : public View {
"Done"};
};
#ifdef PRALINE
/* 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 {
@@ -643,34 +750,36 @@ class Si5351DebugView : public View {
private:
NavigationView& nav_;
Text text_title{{8, 16, 200, 16}, "Si5351 Clock Generator"};
Text text_title{{0, 0, 200, 16}, "Si5351 Clock Generator"};
Text text_status_label{{8, 40, 80, 16}, "Status Reg:"};
Text text_status_value{{96, 40, 144, 16}, ""};
Text text_status_label{{0, 16, 80, 16}, "Status Reg:"};
Text text_status_value{{96, 16, 144, 16}, ""};
Text text_pll_a_label{{8, 60, 80, 16}, "PLL A:"};
Text text_pll_a_status{{96, 60, 144, 16}, ""};
Text text_pll_a_label{{0, 32, 80, 16}, "PLL A:"};
Text text_pll_a_status{{96, 32, 144, 16}, ""};
Text text_pll_b_label{{8, 80, 80, 16}, "PLL B:"};
Text text_pll_b_status{{96, 80, 144, 16}, ""};
Text text_pll_b_label{{0, 48, 80, 16}, "PLL B:"};
Text text_pll_b_status{{96, 48, 144, 16}, ""};
Text text_sys_init_label{{8, 100, 80, 16}, "SYS_INIT:"};
Text text_sys_init_status{{96, 100, 144, 16}, ""};
Text text_sys_init_label{{0, 64, 80, 16}, "SYS_INIT:"};
Text text_sys_init_status{{96, 64, 144, 16}, ""};
Text text_xtal_cap_label{{8, 120, 80, 16}, "XTAL Cap:"};
Text text_xtal_cap_value{{96, 120, 144, 16}, ""};
Text text_xtal_cap_label{{0, 80, 80, 16}, "XTAL Cap:"};
Text text_xtal_cap_value{{96, 80, 144, 16}, ""};
Text text_clk0_label{{8, 150, 72, 16}, "CLK0:"};
Text text_clk0_status{{88, 150, 152, 16}, ""};
Text text_clk0_label{{0, 96, 48, 16}, "CLK0:"};
Text text_clk0_status{{50, 96, 28, 16}, ""};
Text text_clk0_freq_value{{80, 96, 160, 16}, ""};
Text text_clk0_div_value{{50, 112, 190, 16}, ""};
Text text_clk0_freq_label{{8, 170, 72, 16}, " Freq:"};
Text text_clk0_freq_value{{88, 170, 152, 16}, ""};
Text text_clk1_label{{0, 128, 96, 16}, "CLK1 (SCT):"};
Text text_clk1_status{{112, 128, 128, 16}, ""};
Text text_clk0_div_label{{8, 190, 72, 16}, " Div:"};
Text text_clk0_div_value{{88, 190, 152, 16}, ""};
Text text_clk4_label{{0, 144, 96, 16}, "CLK4 (MAX):"};
Text text_clk4_status{{112, 144, 128, 16}, ""};
Text text_clk1_label{{8, 210, 96, 16}, "CLK1 (SCT):"};
Text text_clk1_status{{112, 210, 128, 16}, ""};
Text text_clk5_label{{0, 160, 96, 16}, "CLK5 (RFFC):"};
Text text_clk5_status{{112, 160, 128, 16}, ""};
Button button_refresh{{8, 240, 72, 24}, "Refresh"};
Button button_reset_pll{{88, 240, 72, 24}, "Reset PLL"};
@@ -694,7 +803,7 @@ class SignalPathStatusView : public View {
Text text_title{{0, 0, 240, 16}, "=== Signal Path Status ==="};
Text text_lbl_max_enable{{0, 20, 1114, 16}, "MAX2831:"};
Text text_lbl_max_enable{{0, 20, 114, 16}, "MAX2831:"};
Text text_max_enable{{116, 20, 124, 16}, "---"};
Text text_lbl_max_mode{{0, 36, 114, 16}, "RX Mode:"};
@@ -703,20 +812,88 @@ class SignalPathStatusView : public View {
Text text_lbl_rf_path{{0, 52, 114, 16}, "RF Path:"};
Text text_rf_path{{116, 52, 124, 16}, "---"};
Text text_lbl_rf_amp{{0, 68, 114, 16}, "RF Amp:"};
Text text_rf_amp{{116, 68, 124, 16}, "---"};
Text text_lbl_filter{{0, 68, 114, 16}, "Filter Band:"};
Text text_filter{{116, 68, 124, 16}, "---"};
Text text_lbl_lna{{0, 84, 114, 16}, "LNA Gain:"};
Text text_lna{{116, 84, 124, 16}, "---"};
Text text_lbl_mixer{{0, 84, 114, 16}, "Mixer Enable:"};
Text text_mixer{{116, 84, 124, 16}, "---"};
Text text_lbl_vga{{0, 100, 114, 16}, "VGA Gain:"};
Text text_vga{{116, 100, 124, 16}, "---"};
Text text_lbl_rf_amp{{0, 100, 114, 16}, "RF Amp:"};
Text text_rf_amp{{116, 100, 124, 16}, "---"};
Text text_lbl_fpga_decim{{0, 116, 114, 16}, "FPGA Decim:"};
Text text_fpga_decim{{116, 116, 124, 16}, "---"};
Text text_lbl_lna{{0, 116, 114, 16}, "LNA Gain:"};
Text text_lna{{116, 116, 124, 16}, "---"};
Text text_status{{0, 140, 240, 32}, ""};
Text text_lbl_vga{{0, 132, 114, 16}, "VGA Gain:"};
Text text_vga{{116, 132, 124, 16}, "---"};
Text text_lbl_fpga_decim{{0, 148, 114, 16}, "FPGA Decim:"};
Text text_fpga_decim{{116, 148, 124, 16}, "---"};
Text text_lbl_fpga_ctrl_dc_q{{0, 164, 114, 16}, "FPGA Ctrl:"};
Text text_fpga_ctrl_dc_q{{116, 164, 124, 16}, "---"};
Text text_lbl_fpga_ctrl_qs{{0, 180, 114, 16}, ""};
Text text_fpga_ctrl_qs{{116, 180, 124, 16}, "---"};
Text text_status{{0, 200, 240, 32}, ""};
Button button_refresh{{0, 280, 72, 24}, "Refresh"};
Button button_toggle_q{{88, 280, 72, 24}, "Q Inv"};
Button button_done{{176, 280, 64, 24}, "Done"};
};
#endif
#ifdef PRALINE
class GPIODebugView : public View {
public:
GPIODebugView(NavigationView& nav);
void focus() override;
std::string title() const override { return "GPIO Debug"; };
private:
void refresh();
// GPIO4 (LPF and RF Amp)
Text text_lbl_gpio4{{0, 0, 240, 16}, "Pin Diag: GPIO4 (LPF|Amp|Mix)"};
Text text_lbl_mixr1{{0, 18, 56, 16}, "MixR1:"};
Text text_mixr1{{58, 18, 180, 16}, "---"};
Text text_lbl_pin4{{0, 36, 114, 16}, "PIN[4] (read):"};
Text text_pin4{{116, 36, 124, 16}, "---"};
Text text_lbl_set4{{0, 54, 114, 16}, "SET[4] (write):"};
Text text_set4{{116, 54, 124, 16}, "---"};
// Bit 8 (LPF)
Text text_lbl_lpf_bit{{0, 78, 240, 16}, "Bit 8 (LPF - GPIO4[8]):"};
Text text_lpf_dir{{0, 96, 80, 16}, "DIR: ?"};
Text text_lpf_pin{{82, 96, 78, 16}, "PIN: ?"};
Text text_lpf_set{{162, 96, 78, 16}, "SET: ?"};
Button button_lpf_toggle{{8, 114, 110, 24}, "Toggle LPF"};
Button button_lpf_on{{122, 114, 50, 24}, "ON"};
Button button_lpf_off{{176, 114, 50, 24}, "OFF"};
// Bit 9 (RF Amp)
Text text_lbl_amp_bit{{0, 146, 240, 16}, "Bit 9 (Amp - GPIO4[9]):"};
Text text_amp_dir{{0, 164, 80, 16}, "DIR: ?"};
Text text_amp_pin{{82, 164, 78, 16}, "PIN: ?"};
Text text_amp_set{{162, 164, 78, 16}, "SET: ?"};
Button button_amp_toggle{{8, 182, 110, 24}, "Toggle Amp"};
Button button_amp_on{{122, 182, 50, 24}, "ON"};
Button button_amp_off{{176, 182, 50, 24}, "OFF"};
// GPIO3 (Mixer)
Text text_lbl_gpio3{{0, 214, 240, 16}, "--- GPIO3 (Mixer) ---"};
Text text_lbl_mix_bit{{0, 232, 240, 16}, "Bit 2 (MIX - GPIO3[2]):"};
Text text_mix_dir{{0, 250, 80, 16}, "DIR: ?"};
Text text_mix_pin{{82, 250, 78, 16}, "PIN: ?"};
Text text_mix_set{{162, 250, 78, 16}, "SET: ?"};
// Controls
Button button_refresh{{8, 280, 72, 24}, "Refresh"};
Button button_done{{168, 280, 64, 24}, "Done"};
};
@@ -734,44 +911,50 @@ class RFFC5072StatusView : public View {
NavigationView& nav_;
void refresh_status();
Text text_title{{0, 0, 240, 16}, "=== RFFC5072 (1st IF) ==="};
Text text_status{{0, 0, 240, 16}, "---"};
Text text_lbl_enabled{{0, 20, 114, 16}, "Status:"};
Text text_enabled{{116, 20, 124, 16}, "---"};
Text text_gpio4{{0, 16, 240, 16}, "---"};
Text text_lbl_freq{{0, 36, 114, 16}, "LO Freq:"};
Text text_freq{{116, 36, 124, 16}, "---"};
Text text_ctrl{{0, 32, 240, 16}, "---"};
Text text_lbl_path{{0, 52, 114, 16}, "Path:"};
Text text_path{{116, 52, 124, 16}, "---"};
Text text_lbl_enabled{{0, 48, 114, 16}, "Status:"};
Text text_enabled{{116, 48, 124, 16}, "---"};
Text text_lbl_mixer{{0, 68, 114, 16}, "Mixer:"};
Text text_mixer{{116, 68, 124, 16}, "---"};
Text text_lbl_freq{{0, 64, 114, 16}, "LO Freq:"};
Text text_freq{{116, 64, 124, 16}, "---"};
Text text_lbl_r0{{0, 92, 114, 16}, "Reg 0:"};
Text text_r0{{116, 92, 124, 16}, "---"};
Text text_lbl_path{{0, 80, 114, 16}, "Path:"};
Text text_path{{116, 80, 124, 16}, "---"};
Text text_lbl_r1{{0, 108, 114, 16}, "Reg 1 (N):"};
Text text_r1{{116, 108, 124, 16}, "---"};
Text text_lbl_mixer{{0, 96, 114, 16}, "Mixer:"};
Text text_mixer{{116, 96, 124, 16}, "---"};
Text text_lbl_r2{{0, 124, 114, 16}, "Reg 2:"};
Text text_r2{{116, 124, 124, 16}, "---"};
Text text_lbl_r0{{0, 112, 114, 16}, "Reg 0:"};
Text text_r0{{116, 112, 124, 16}, "---"};
Text text_lbl_decode{{0, 148, 240, 16}, "--- Decoded Values ---"};
Text text_lbl_r1{{0, 128, 114, 16}, "Reg 1 (N):"};
Text text_r1{{116, 128, 124, 16}, "---"};
Text text_lbl_n{{0, 168, 114, 16}, "N divider:"};
Text text_n{{116, 168, 124, 16}, "---"};
Text text_lbl_r2{{0, 144, 114, 16}, "Reg 2:"};
Text text_r2{{116, 144, 124, 16}, "---"};
Text text_lbl_lodiv{{0, 184, 114, 16}, "LO divider:"};
Text text_lodiv{{116, 184, 124, 16}, "---"};
Text text_lbl_n{{0, 160, 114, 16}, "N divider:"};
Text text_n{{116, 160, 124, 16}, "---"};
Text text_lbl_calc{{0, 200, 114, 16}, "Calc freq:"};
Text text_calc{{116, 200, 124, 16}, "---"};
Text text_lbl_lodiv{{0, 176, 114, 16}, "LO divider:"};
Text text_lodiv{{116, 176, 124, 16}, "---"};
Text text_status{{0, 224, 240, 32}, ""};
Text text_lbl_calc{{0, 192, 114, 16}, "Calc freq:"};
Text text_calc{{116, 192, 124, 16}, "---"};
Button button_refresh{{8, 280, 72, 24}, "Refresh"};
Button button_done{{168, 280, 64, 24}, "Done"};
Text text_regs_status{{0, 208, 240, 16}, "---"};
Text text_status2{{0, 224, 240, 16}, ""};
Text text_status3{{0, 240, 240, 16}, ""};
Button button_refresh{{2, 280, 72, 24}, "Refresh"};
Button button_force{{98, 280, 60, 24}, "SPI"};
Button button_done{{182, 280, 56, 24}, "Done"};
};
#ifdef PRALINE
@@ -828,6 +1011,379 @@ class RFFCTuningDebugView : public View {
#endif
#ifdef PRALINE
/* MAX2831DebugView *************************************************/
class MAX2831DebugView : public View {
public:
MAX2831DebugView(NavigationView& nav);
void focus() override;
std::string title() const override { return "MAX2831 Debug"; };
private:
void refresh();
Text text_title{{0, 0, 240, 16}, "MAX2831 (2nd IF) Debug"};
Text text_lbl_called{{0, 24, 120, 16}, "Freq Set:"};
Text text_called{{122, 24, 118, 16}, "NO"};
Text text_lbl_valid{{0, 42, 120, 16}, "In Range:"};
Text text_valid{{122, 42, 118, 16}, "---"};
Text text_lbl_req{{0, 60, 120, 16}, "Requested:"};
Text text_req{{122, 60, 118, 16}, "---"};
Text text_lbl_calc_n{{0, 78, 120, 16}, "Calc N:"};
Text text_calc_n{{122, 78, 118, 16}, "---"};
Text text_lbl_calc_frac{{0, 96, 120, 16}, "Calc Frac:"};
Text text_calc_frac{{122, 96, 118, 16}, "---"};
Text text_spacer{{0, 114, 240, 16}, "--- Hardware Regs ---"};
Text text_lbl_r3{{0, 132, 120, 16}, "Reg 3:"};
Text text_r3{{122, 132, 118, 16}, "---"};
Text text_lbl_r4{{0, 150, 120, 16}, "Reg 4:"};
Text text_r4{{122, 150, 118, 16}, "---"};
Text text_lbl_act_n{{0, 168, 120, 16}, "Actual N:"};
Text text_act_n{{122, 168, 118, 16}, "---"};
Text text_lbl_act_frac{{0, 186, 120, 16}, "Actual Frac:"};
Text text_act_frac{{122, 186, 118, 16}, "---"};
Text text_lbl_calc_freq{{0, 204, 120, 16}, "Calc Freq:"};
Text text_calc_freq{{122, 204, 118, 16}, "---"};
Text text_status{{0, 228, 240, 44}, ""};
Button button_refresh{{8, 280, 72, 24}, "Refresh"};
Button button_done{{168, 280, 64, 24}, "Done"};
};
#endif
#ifdef PRALINE
class SystemDiagnosticsView : public View {
public:
SystemDiagnosticsView(NavigationView& nav);
void focus() override;
std::string title() const override { return "System Diagnostics"; };
private:
void refresh();
void read_gpio_states();
void set_sample_rate(uint32_t rate);
Text text_title{{0, 0, 240, 16}, "System Diagnostics"};
// Sample Rate Section
Text text_lbl_sample{{0, 24, 42, 16}, "Rate:"};
Text text_sample_rate{{44, 24, 50, 16}, "---"};
Text text_lbl_fpga_decode{{96, 24, 144, 16}, "DC:? Q:? QS:?"};
Button button_sample_2m{{2, 44, 56, 24}, "2 MSPS"};
Button button_sample_4m{{62, 44, 56, 24}, "4 MSPS"};
Button button_sample_8m{{122, 44, 56, 24}, "8 MSPS"};
Button button_sample_20m{{182, 44, 56, 24}, "20 MSPS"};
// Baseband Filter Section
Text text_lbl_bb_filter{{0, 76, 114, 16}, "BB Filter BW:"};
Text text_bb_filter{{116, 76, 124, 16}, "---"};
Text text_lbl_reg8{{0, 94, 114, 16}, "MAX2831 R8:"};
Text text_reg8{{116, 94, 124, 16}, "---"};
// GPIO States Section
Text text_lbl_gpio{{0, 118, 240, 16}, "--- GPIO Pin States ---"};
Text text_lbl_lpf{{0, 136, 56, 16}, "LPF:"};
Text text_gpio_lpf{{58, 136, 181, 16}, "---"};
Text text_lbl_mix{{0, 154, 56, 16}, "Mixer:"};
Text text_gpio_mix{{58, 154, 181, 16}, "---"};
Text text_lbl_amp{{0, 172, 56, 16}, "RF Amp:"};
Text text_gpio_amp{{58, 172, 181, 16}, "---"};
// FPGA Control Section
Text text_lbl_fpga{{0, 196, 240, 16}, "--- FPGA Control ---"};
Text text_lbl_fpga_ctrl{{0, 214, 114, 16}, "FPGA Reg 1:"};
Text text_fpga_ctrl{{116, 214, 124, 16}, "---"};
Text text_lbl_band{{0, 232, 48, 16}, "Band:"};
Text text_band{{50, 232, 190, 16}, "---"};
Button button_toggle_q{{2, 252, 110, 24}, "Toggle Q Inv"};
Button button_toggle_dc{{122, 252, 110, 24}, "Toggle DC Blk"};
// Control Buttons
Button button_refresh{{2, 280, 72, 24}, "Refresh"};
Button button_done{{168, 280, 64, 24}, "Done"};
};
#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 {
@@ -46,11 +46,10 @@ bool valid_firmware_file(std::filesystem::path::string_type path) {
auto result = firmware_file.open(path.c_str());
if (!result.is_valid()) {
uint64_t file_size = firmware_file.size();
if (portapack::device_type == portapack::DeviceType::DEV_PORTAPACK && file_size > 1 * 1024 * 1024) {
// Portapack firmware files must not be larger than 1MB
if (file_size > FLASH_ROM_SIZE) {
// Firmware file is larger than the flash size for this device
return false;
}
// May need to add a check to portarf and portarf pro too.
checksum = 0;
for (uint64_t offset = 0; offset < FLASH_ROM_SIZE && offset < file_size; offset += sizeof(read_buffer)) {
auto readResult = firmware_file.read(&read_buffer, sizeof(read_buffer));
@@ -32,8 +32,6 @@
#include "untar.hpp"
#include <cstdint>
#include "../../flashsize.h"
#define FLASH_ROM_SIZE (FLASH_SIZE_MB * 1024 * 1024)
#define FLASH_STARTING_ADDRESS 0x00000000
#define FLASH_EXPECTED_CHECKSUM 0x00000000
+2 -1
View File
@@ -304,7 +304,8 @@ class MicTXView : public View {
{
{" 8k5 ", 0}, // Initial dynamic values when we start Mic App.
{" 11k ", 1},
{" 16k ", 2},
{" 12k5 ", 2},
{" 16k ", 3},
}};
NumberField field_squelch{
+1
View File
@@ -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);
+126 -5
View File
@@ -33,6 +33,9 @@
#include "ui_touch_calibration.hpp"
#include "ui_text_editor.hpp"
#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"
@@ -348,7 +351,6 @@ SetUIView::SetUIView(NavigationView& nav) {
add_children({&checkbox_disable_touchscreen,
&checkbox_bloff,
&options_bloff,
&checkbox_showsplash,
&checkbox_showclock,
&options_clockformat,
&checkbox_guireturnflag,
@@ -375,7 +377,6 @@ SetUIView::SetUIView(NavigationView& nav) {
}
checkbox_disable_touchscreen.set_value(pmem::disable_touchscreen());
checkbox_showsplash.set_value(pmem::config_splash());
checkbox_showclock.set_value(!pmem::hide_clock());
checkbox_guireturnflag.set_value(pmem::show_gui_return_icon());
@@ -414,7 +415,6 @@ SetUIView::SetUIView(NavigationView& nav) {
pmem::set_clock_with_date(false);
}
pmem::set_config_splash(checkbox_showsplash.value());
pmem::set_clock_hidden(!checkbox_showclock.value());
pmem::set_gui_return_icon(checkbox_guireturnflag.value());
pmem::set_disable_touchscreen(checkbox_disable_touchscreen.value());
@@ -447,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,
@@ -456,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 !!");
@@ -473,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 ******************************/
@@ -1113,6 +1193,46 @@ void SetBatteryView::focus() {
button_cancel.focus();
}
/* SetSlpash *********************************************/
SetSplash::SetSplash(NavigationView& nav) {
add_children({&checkbox_showsplash,
&checkbox_randomsplash,
&message,
&button_picture_select,
&button_save,
&button_cancel});
checkbox_showsplash.set_value(pmem::config_splash());
splash_bmp_exists = file_exists(splash_dot_bmp);
checkbox_randomsplash.set_value(!splash_bmp_exists);
message.hidden(splash_bmp_exists);
checkbox_randomsplash.on_select = [this](Checkbox&, bool v) {
random_enabled = v;
};
button_picture_select.on_select = [this, &nav](Button&) {
auto ret = nav.push<FileManagerView>();
ret->push_dir(splash_dir);
};
button_save.on_select = [&nav, this](Button&) {
if (random_enabled == true) delete_file(splash_dot_bmp);
pmem::set_config_splash(checkbox_showsplash.value());
send_system_refresh();
nav.pop();
};
button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
};
}
void SetSplash::focus() {
button_save.focus();
}
/* SettingsMenuView **************************************/
SettingsMenuView::SettingsMenuView(NavigationView& nav)
@@ -1146,6 +1266,7 @@ void SettingsMenuView::on_populate() {
{"Display", ui::Color::dark_cyan(), &bitmap_icon_brightness, [this]() { nav_.push<SetDisplayView>(); }},
{"Menu Color", ui::Color::dark_cyan(), &bitmap_icon_brightness, [this]() { nav_.push<SetMenuColorView>(); }},
{"Theme", ui::Color::dark_cyan(), &bitmap_icon_setup, [this]() { nav_.push<SetThemeView>(); }},
{"Splash settings", ui::Color::dark_cyan(), &bitmap_icon_file_image, [this]() { nav_.push<SetSplash>(); }},
});
if (battery::BatteryManagement::isDetected()) add_item({"Battery", ui::Color::dark_cyan(), &bitmap_icon_batt_icon, [this]() { nav_.push<SetBatteryView>(); }});
+85 -28
View File
@@ -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"
@@ -343,77 +344,72 @@ class SetUIView : public View {
{"1 hour", backlight_timeout_t::Timeout3600Sec},
}};
Checkbox checkbox_showsplash{
{3 * 8, 6 * 16},
20,
"Show splash"};
Checkbox checkbox_showclock{
{3 * 8, 8 * 16},
{3 * 8, 6 * 16},
20,
"Show clock with:"};
OptionsField options_clockformat{
{60, 9 * 16 + 8},
{60, 7 * 16 + 8},
20,
{{"time only", 0},
{"time and date", 1}}};
Checkbox checkbox_guireturnflag{
{3 * 8, 11 * 16},
{3 * 8, 9 * 16},
20,
"Back button in menu"};
Labels labels{
{{3 * 8, 13 * 16}, "Show/Hide Status Icons", Theme::getInstance()->fg_light->foreground},
{{3 * 8, 11 * 16}, "Show/Hide Status Icons", Theme::getInstance()->fg_light->foreground},
};
ImageToggle toggle_camera{
{2 * 8, 14 * 16 + 2, 16, 16},
{2 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_camera};
ImageToggle toggle_sleep{
{4 * 8, 14 * 16 + 2, 16, 16},
{4 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_sleep};
ImageToggle toggle_stealth{
{6 * 8, 14 * 16 + 2, 16, 16},
{6 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_stealth};
ImageToggle toggle_converter{
{8 * 8, 14 * 16 + 2, 16, 16},
{8 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_upconvert};
ImageToggle toggle_bias_tee{
{10 * 8, 14 * 16 + 2, 16, 16},
{10 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_biast_off};
ImageToggle toggle_clock{
{12 * 8, 14 * 16 + 2, 8, 16},
{12 * 8, 12 * 16 + 2, 8, 16},
&bitmap_icon_clk_ext};
ImageToggle toggle_mute{
{13 * 8, 14 * 16 + 2, 16, 16},
{13 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_speaker_and_headphones_mute};
ImageToggle toggle_speaker{
{15 * 8, 14 * 16 + 2, 16, 16},
{15 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_speaker_mute};
ImageToggle toggle_battery_icon{
{17 * 8, 14 * 16 + 2, 16, 16},
{17 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_batt_icon};
ImageToggle toggle_battery_text{
{19 * 8, 14 * 16 + 2, 16, 16},
{19 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_batt_text};
ImageToggle toggle_fake_brightness{
{21 * 8, 14 * 16 + 2, 16, 16},
{21 * 8, 12 * 16 + 2, 16, 16},
&bitmap_icon_brightness};
ImageToggle toggle_sd_card{
{23 * 8, 14 * 16 + 2, 16, 16},
{23 * 8, 12 * 16 + 2, 16, 16},
&bitmap_sd_card_ok};
Button button_save{
@@ -429,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 {
@@ -1069,6 +1089,43 @@ class SettingsMenuView : public BtnGridView {
void on_populate() override;
};
class SetSplash : public View {
public:
SetSplash(NavigationView& nav);
void focus() override;
std::string title() const override { return "Splash"; };
private:
bool splash_bmp_exists = false;
bool random_enabled = false;
Checkbox checkbox_showsplash{
{3 * 8, 1 * 16},
20,
"Show splash"};
Checkbox checkbox_randomsplash{
{3 * 8, 3 * 16},
20,
"Random splash on boot"};
Text message{{UI_POS_X(1), UI_POS_Y(6), UI_POS_WIDTH(26), UI_POS_HEIGHT(1)}, "Pick image to stop random."};
Button button_picture_select{
{UI_POS_X_CENTER(8) - UI_POS_WIDTH(4), UI_POS_Y_BOTTOM(7), UI_POS_WIDTH(13), UI_POS_HEIGHT(2)},
"Select pict."};
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)},
"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)},
"Cancel"};
};
} /* namespace ui */
#endif /*__UI_SETTINGS_H__*/
@@ -27,8 +27,6 @@ namespace fs = std::filesystem;
namespace ui {
const std::filesystem::path splash_dot_bmp{u"/splash.bmp"};
ScreenshotViewer::ScreenshotViewer(
NavigationView& nav,
const std::filesystem::path& path)
@@ -44,7 +42,6 @@ bool ScreenshotViewer::on_key(KeyEvent) {
void ScreenshotViewer::paint(Painter& painter) {
File file{};
painter.fill_rectangle({0, 0, screen_width, screen_height}, Color::black());
auto show_invalid = [&]() {
+1 -3
View File
@@ -28,11 +28,10 @@
#include "ui_painter.hpp"
#include "ui_widget.hpp"
#include "file.hpp"
#include "file_path.hpp"
namespace ui {
extern const std::filesystem::path splash_dot_bmp;
class ScreenshotViewer : public View {
public:
ScreenshotViewer(NavigationView& nav, const std::filesystem::path& path);
@@ -49,7 +48,6 @@ class SplashViewer : public View {
SplashViewer(NavigationView& nav, const std::filesystem::path& path);
bool on_key(KeyEvent key) override;
void paint(Painter& painter) override;
void update_ss(void);
private:
NavigationView& nav_;
@@ -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);
}
+140 -2
View File
@@ -25,6 +25,10 @@
#include "baseband_api.hpp"
#include "string_format.hpp"
#include "file_path.hpp"
#include "ui_textentry.hpp"
#include "../keeloq_keystore.hpp"
#include "../keeloq_file.hpp"
#include "../keeloq_common.hpp"
#include "portapack_persistent_memory.hpp"
using namespace portapack;
@@ -56,6 +60,51 @@ void SubGhzDRecentEntryDetailView::update_data() {
if (cnt != SD_NO_CNT) console.writeln("Cnt: " + to_string_dec_uint(cnt));
if (entry_.data != 0) console.writeln("Data: " + to_string_hex(entry_.data));
if (entry_.sensorType == FPS_RESTAURANT_PAGER) {
uint8_t pager_addr = (entry_.data >> 5) & 0x0F;
uint8_t func_code = (entry_.data >> 1) & 0x0F;
console.writeln("Station: 0x" + to_string_hex(serial) + " (" + to_string_dec_uint(serial) + ")");
console.writeln("Pager: " + to_string_dec_uint(pager_addr));
if (func_code == 0x0D)
console.writeln("Action: Buzz");
else if (func_code == 0x0F)
console.writeln("Action: Sync");
else
console.writeln("Action: 0x" + to_string_hex(func_code));
}
if (entry_.sensorType == FPS_KEELOQ) {
console.writeln("Fix: " + to_string_hex(fix));
console.writeln("Encrypted: " + to_string_hex(encrypted));
console.writeln("Manufacturer: " + mf_name);
if (hop != SD_NO_HOP) {
console.writeln("Hop: " + to_string_hex(hop));
add_children({&button_save});
button_save.on_select = [this](const Button&) {
keeloq_file_buffer.clear();
text_prompt(
nav_,
keeloq_file_buffer,
64,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& buffer) {
KeeloqData params{
mf_name,
serial,
(uint16_t)cnt,
btn};
ensure_directory(keeloq_remotes_dir);
write_keeloq_file(keeloq_remotes_dir / buffer + ".KEELOQ", params);
});
};
}
}
}
SubGhzDRecentEntryDetailView::SubGhzDRecentEntryDetailView(NavigationView& nav, const SubGhzDRecentEntry& entry)
@@ -244,6 +293,8 @@ const char* SubGhzDView::getSensorTypeName(FPROTO_SUBGHZD_SENSOR type) {
return "Marantec24";
case FPS_HOLTEKHT6P20B:
return "Holtek HT6P20B";
case FPS_RESTAURANT_PAGER:
return "Rest. Pager";
case FPS_Invalid:
default:
return "Unknown";
@@ -270,7 +321,14 @@ void RecentEntriesTable<ui::SubGhzDRecentEntries>::draw(
line.reserve(30);
line = SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry.sensorType);
line = line + " " + to_string_hex(entry.data << 32);
if (entry.sensorType == FPS_RESTAURANT_PAGER) {
uint8_t pgr = (entry.data >> 5) & 0x0F;
uint8_t func = (entry.data >> 1) & 0x0F;
line += " P:" + to_string_dec_uint(pgr) + (func == 0x0D ? " Buzz" : func == 0x0F ? " Sync"
: "");
} else {
line = line + " " + to_string_hex(entry.data << 32);
}
line.resize(columns.at(0).second, ' ');
std::string ageStr = to_string_dec_uint(entry.age);
std::string bitsStr = to_string_dec_uint(entry.bits);
@@ -303,6 +361,29 @@ void atomo_decrypt(uint8_t* buff) {
}
}
bool SubGhzDRecentEntryDetailView::keeloq_check_decrypt(uint32_t decrypt) {
uint16_t end_serial = serial & 0xFF;
if ((decrypt >> 28 == btn) && (((((uint16_t)(decrypt >> 16)) & 0xFF) == end_serial) ||
((((uint16_t)(decrypt >> 16)) & 0xFF) == 0))) {
cnt = decrypt & 0xFFFF;
return true;
}
return false;
}
bool SubGhzDRecentEntryDetailView::keeloq_check_decrypt_centurion(uint32_t decrypt) {
if ((decrypt >> 28 == btn) && ((((uint16_t)(decrypt >> 16)) & 0x3FF) == 0x1CE)) {
cnt = decrypt & 0xFFFF;
return true;
}
return false;
}
const uint32_t came_twee_magic_numbers_xor[15] = {
0x0E0E0E00,
0x1D1D1D11,
@@ -591,7 +672,57 @@ void SubGhzDRecentEntryDetailView::parseProtocol() {
}
if (entry_.sensorType == FPS_KEELOQ) {
// too many sub protocol versions, skipping. maybe in future when we'll have much more fw space
uint64_t data_rev = FProtoGeneral::subghz_protocol_blocks_reverse_key(entry_.data, 64);
btn = data_rev >> 60;
serial = (data_rev >> 32) & 0xFFFFFFF;
fix = data_rev >> 32;
encrypted = data_rev & 0xFFFFFFFF;
KeeloqKeystore keystore{};
const auto& keys = keystore.get_keys();
if (keys.empty()) {
return;
}
for (const auto& key : keys) {
switch (key.type) {
case KEELOQ_SIMPLE_LEARNING: {
uint32_t decrypted = keeloq_decrypt(encrypted, key.key);
if (keeloq_check_decrypt(decrypted)) {
mf_name = key.mf_name;
hop = decrypted;
return;
}
break;
}
case KEELOQ_NORMAL_LEARNING: {
uint64_t man = keeloq_normal_learning(fix, key.key);
uint32_t decrypted = keeloq_decrypt(encrypted, man);
if (key.mf_name == "Centurion" && keeloq_check_decrypt_centurion(decrypted)) {
mf_name = "Centurion";
hop = decrypted;
return;
} else if (keeloq_check_decrypt(decrypted)) {
mf_name = key.mf_name;
hop = decrypted;
return;
}
break;
}
}
}
return;
}
@@ -764,5 +895,12 @@ void SubGhzDRecentEntryDetailView::parseProtocol() {
btn = (entry_.data >> 4) & 0xF;
return;
}
if (entry_.sensorType == FPS_RESTAURANT_PAGER) {
// 25-bit EV1527-variant: [sysid:16][pager:4][func:4][stop:1]
serial = (entry_.data >> 9) & 0xFFFF; // System ID
// btn/cnt left as SD_NO values; friendly output in update_data()
return;
}
}
} // namespace ui
+22 -1
View File
@@ -25,7 +25,11 @@
#define SD_NO_SERIAL 0xFFFFFFFF
#define SD_NO_BTN 0xFF
#define SD_NO_CNT 0xFF
#define SD_NO_CNT 0xFFFFFFFF
#define SD_NO_HOP 0xFFFFFFFF
#define SD_NO_FIX 0xFFFFFFFF
#define SD_NO_ENCRYPTED 0xFFFFFFFF
#include "ui.hpp"
#include "ui_navigation.hpp"
@@ -191,6 +195,19 @@ class SubGhzDRecentEntryDetailView : public View {
uint32_t cnt = SD_NO_CNT;
uint32_t seed = 0;
// keeloq specific
std::string keeloq_file_buffer{};
uint32_t hop = SD_NO_HOP;
uint32_t fix = SD_NO_FIX;
uint32_t encrypted = SD_NO_ENCRYPTED;
std::string mf_name = "Unknown";
bool keeloq_check_decrypt(uint32_t decrypt);
bool keeloq_check_decrypt_centurion(uint32_t decrypt);
// end keeloq specific
Text text_type{{UI_POS_X(0), 1 * 16, 15 * 8, 16}, "?"};
Text text_id{{6 * 8, 2 * 16, 10 * 8, 16}, "?"};
@@ -207,6 +224,10 @@ class SubGhzDRecentEntryDetailView : public View {
{screen_width - 96 - 4, screen_height - 32 - 12, 96, 32},
"Done"};
Button button_save{
{4, screen_height - 32 - 12, 96, 32},
"Save"};
void parseProtocol();
};
+32 -2
View File
@@ -334,12 +334,22 @@ 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_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);
@@ -397,6 +407,21 @@ void set_bitstream_config(uint32_t deviation, uint8_t mode) {
send_message(&message);
}
void set_rtty_config(uint16_t baud, uint16_t shift, uint8_t* payload, uint16_t payload_length) {
RTTYDataMessage message{baud, shift};
if (payload && payload_length > 0) {
message.data_len = payload_length > message.max_len ? message.max_len : payload_length;
for (size_t i = 0; i < message.data_len; ++i) {
message.data[i] = payload[i];
}
}
send_message(&message);
}
void set_rtty_config(RTTYDataMessage& message) {
send_message(&message);
}
static bool baseband_image_running = false;
void run_image(const spi_flash::image_tag_t image_tag) {
@@ -458,7 +483,12 @@ void shutdown() {
send_message(&message);
shared_memory.application_queue.reset();
// Allow time for the shutdown message to be processed and for the baseband
// core to stop before starting another image. Otherwise, the M4 may still be
// running and cause a crash when the next image is started.
#ifdef PRALINE
chThdSleepMilliseconds(20);
#endif
baseband_image_running = false;
}
+9 -2
View File
@@ -97,7 +97,12 @@ 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_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);
@@ -108,7 +113,9 @@ void set_morsetx_key(bool key_down);
void set_wefax_config(uint8_t lpm, uint8_t ioc);
void set_noaaapt_config();
void set_flex_config();
void set_bitstream_config(uint32_t deviation, uint8_t mode); // mode 0 for am, 1 for 2fsk
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 request_roger_beep();
void request_rssi_beep();
+389 -133
View File
@@ -35,12 +35,16 @@ using namespace lpc43xx;
extern "C" {
#include "fpga_bridge.h"
}
// Need access to ssp1_arbiter from radio namespace
// Need access to ssp1_arbiter from radio namespace for FPGA related radio method dependencies.
#include "radio.hpp"
#endif
constexpr uint32_t si5351_vco_f = 800000000;
#ifdef PRALINE
constexpr uint32_t si5351_vco_afe_f = 800000000; // If necessary may be changed to 768 MHz for optimal for 3.072 MHz sample frequencies commonly used by apps
#endif
constexpr si5351::Inputs si5351_inputs{
.f_xtal = si5351_xtal_f,
.f_clkin = si5351_clkin_f,
@@ -62,8 +66,44 @@ constexpr si5351::PLL si5351_pll_xtal_25m{
.b = 0,
.c = 1,
};
constexpr auto si5351_pll_a_xtal_reg = si5351_pll_xtal_25m.reg(0);
#ifdef PRALINE
// Define pll_a from 25MHz clock for stable PLL A, and AFE locked reference
// PLL A: 800 MHz VCO (32x Multiplier for jitter-free 3.072 MHz sampling)
constexpr si5351::PLL si5351_pll_a_afe_800m{
.f_in = si5351_inputs.f_xtal, // 25,000,000 Hz
.a = 32, // Multiplier: 25 * 32 = 800
.b = 0,
.c = 1,
};
// PLL A: registers (Base 34) 800 MHz VCO (For jitter-free AFE sampling frequencies)
constexpr auto si5351_pll_a_800_reg = si5351_pll_a_afe_800m.reg(0); // Base 26
static_assert(si5351_pll_a_afe_800m.f_vco() == si5351_vco_f, "PLL A XTAL frequency wrong");
static_assert(si5351_pll_a_afe_800m.p1() == 3584, "PLL A XTAL P1 wrong");
static_assert(si5351_pll_a_afe_800m.p2() == 0, "PLL A XTAL P2 wrong");
static_assert(si5351_pll_a_afe_800m.p3() == 1, "PLL A XTAL P3 wrong");
// Define pll_b 25MHz clock for stable PLL B
// PLL B: 800 MHz VCO (32x Multiplier for (For stable Digital/SGPIO bus)
constexpr si5351::PLL si5351_pll_b_800m{
.f_in = si5351_inputs.f_xtal, // 25,000,000 Hz
.a = 32, // Multiplier: 25 * 32 = 800
.b = 0,
.c = 1,
};
// PLL B: registers (Base 34) 800 MHz VCO (For stable Digital/SGPIO bus)
constexpr auto si5351_pll_b_800_reg = si5351_pll_b_800m.reg(1); // Base 34
static_assert(si5351_pll_b_800m.f_vco() == si5351_vco_f, "PLL B XTAL frequency wrong");
static_assert(si5351_pll_b_800m.p1() == 3584, "PLL B XTAL P1 wrong");
static_assert(si5351_pll_b_800m.p2() == 0, "PLL B XTAL P2 wrong");
static_assert(si5351_pll_b_800m.p3() == 1, "PLL B XTAL P3 wrong");
#else
// PLL A registers (Base 26)
constexpr auto si5351_pll_a_xtal_reg = si5351_pll_xtal_25m.reg(0);
static_assert(si5351_pll_xtal_25m.f_vco() == si5351_vco_f, "PLL XTAL frequency wrong");
static_assert(si5351_pll_xtal_25m.p1() == 3584, "PLL XTAL P1 wrong");
static_assert(si5351_pll_xtal_25m.p2() == 0, "PLL XTAL P2 wrong");
@@ -79,13 +119,6 @@ constexpr si5351::PLL si5351_pll_clkin_10m{
constexpr auto si5351c_pll_b_clkin_reg = si5351_pll_clkin_10m.reg(1);
constexpr auto si5351a_pll_a_clkin_reg = si5351_pll_clkin_10m.reg(0);
#ifndef PRALINE
static_assert(si5351_pll_xtal_25m.f_vco() == si5351_vco_f, "PLL XTAL frequency wrong");
static_assert(si5351_pll_xtal_25m.p1() == 3584, "PLL XTAL P1 wrong");
static_assert(si5351_pll_xtal_25m.p2() == 0, "PLL XTAL P2 wrong");
static_assert(si5351_pll_xtal_25m.p3() == 1, "PLL XTAL P3 wrong");
#endif
static_assert(si5351_pll_clkin_10m.f_vco() == si5351_vco_f, "PLL CLKIN frequency wrong");
static_assert(si5351_pll_clkin_10m.p1() == 9728, "PLL CLKIN P1 wrong");
static_assert(si5351_pll_clkin_10m.p2() == 0, "PLL CLKIN P2 wrong");
@@ -99,16 +132,16 @@ constexpr si5351::MultisynthFractional si5351_ms_18m432 {
.r_div = 1,
};
*/
/*
constexpr si5351::MultisynthFractional si5351_ms_0_20m {
.f_src = si5351_vco_f,
.a = 20,
.b = 0,
.c = 1,
.r_div = 1,
// constexpr auto si5351_ms_0_20m_reg = si5351_ms_0_20m.reg(0);
constexpr si5351::MultisynthFractional si5351_ms_0_4m{
.f_src = si5351_vco_f, // 800,000,000 Hz
.a = 100, // Integer divider 100
.b = 0,
.c = 1,
.r_div = 1 // Final R-divider: 2^1 = 2
};
constexpr auto si5351_ms_0_20m_reg = si5351_ms_0_20m.reg(0);
*/
constexpr si5351::MultisynthFractional si5351_ms_0_8m{
.f_src = si5351_vco_f,
.a = 50,
@@ -116,6 +149,73 @@ constexpr si5351::MultisynthFractional si5351_ms_0_8m{
.c = 1,
.r_div = 1,
};
#ifdef PRALINE
// (initial 4 MHz from 800 MHz VCO: 800 / 200 = 4)
constexpr si5351::MultisynthFractional si5351_ms_afe_4m{
.f_src = si5351_vco_afe_f, // 800 MHz
.a = 200,
.b = 0,
.c = 1,
.r_div = 0};
// (10 MHz from 800 MHz VCO: 800 / 80 = 10)
constexpr si5351::MultisynthFractional si5351_ms_afe_10m{
.f_src = si5351_vco_afe_f, // 800 MHz
.a = 80,
.b = 0,
.c = 1,
.r_div = 0};
// (20 MHz from 800 MHz VCO: 800 / 40 = 20)
constexpr si5351::MultisynthFractional si5351_ms_afe_20m{
.f_src = si5351_vco_afe_f,
.a = 40,
.b = 0,
.c = 1,
.r_div = 0,
};
// (25 MHz from 800 MHz VCO: 800 / 32 = 25)
// Define xtal MultiSynth 25MHz clock for stable PLL A, and AFE locked XTAL reference
constexpr si5351::MultisynthFractional si5351_ms_afe_25m{
.f_src = si5351_vco_afe_f, // 800,000,000 Hz
.a = 32, // 800 / 32 = 25 MHz
.b = 0,
.c = 1,
.r_div = 0 // No final bit-shifting
};
// (40 MHz from 800 MHz VCO: 800 / 20 = 40)
constexpr si5351::MultisynthFractional si5351_ms_afe_40m{
.f_src = si5351_vco_afe_f, // 800 MHz
.a = 20,
.b = 0,
.c = 1,
.r_div = 0};
// (20 MHz from 800 MHz VCO: 800 / 40 = 20)
constexpr si5351::MultisynthFractional si5351_ms_20m{
.f_src = si5351_vco_f,
.a = 40,
.b = 0,
.c = 1,
.r_div = 0,
};
// constexpr auto si5351_ms_20m_reg = si5351_ms_20m.reg(0);
// (25 MHz from 800 MHz VCO: 800 / 32 = 25)
// Define xtal MultiSynth 25MHz clock for stable PLL B, and XTAL reference
constexpr si5351::MultisynthFractional si5351_ms_25m{
.f_src = si5351_vco_f, // 800,000,000 Hz
.a = 32, // 800 / 32 = 25 MHz
.b = 0,
.c = 1,
.r_div = 0 // No final bit-shifting
};
#endif
constexpr auto si5351c_ms_0_8m_reg = si5351_ms_0_8m.reg(clock_generator_output_og_codec);
#ifdef PRALINE
@@ -237,19 +337,40 @@ constexpr ClockControls si5351c_clock_control_common{{
}};
constexpr ClockControls si5351a_clock_control_common{{
#ifndef PRALINE
{ClockControl::ClockCurrentDrive::_6mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
#ifdef PRALINE
// CLK0: MAX5864 (ADC) - 4mA, Normal PLLA Integer
{ClockControl::ClockCurrentDrive::_4mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_On},
// CLK1: SCT_CLK (iCE40 FPGA) - 4mA, Normal PLLB Integer
{ClockControl::ClockCurrentDrive::_4mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLB, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_On},
// CLK2: LPC43xx MCU - 2mA, Normal PLLA (Must be Integer for MCU stability)
{ClockControl::ClockCurrentDrive::_2mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_On},
// CLK3: CLKOUT SMA Port P1 - 2mA, Normal PLLB Integer Power_Off
{ClockControl::ClockCurrentDrive::_2mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLB, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
// CLK4: MAX2831 reference (40 MHz) - 4mA, Invert PLLA Integer (Required for mixer lock)
{ClockControl::ClockCurrentDrive::_4mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Invert, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_On},
// CLK5: RFFC5072 reference (40 MHz) - 4mA, Invert PLLA Integer (Required for mixer lock)
{ClockControl::ClockCurrentDrive::_4mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Invert, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_On},
// CLK6: Not used (disabled) 2mA, Normal PLLB Integer, Power_Off
{ClockControl::ClockCurrentDrive::_2mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLB, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
// CLK7: Not used (disabled) 2mA, Normal PLLB Integer, Power_Off
{ClockControl::ClockCurrentDrive::_2mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLB, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
#else
{ClockControl::ClockCurrentDrive::_6mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Fractional, ClockControl::ClockPowerDown::Power_Off}, // CLK0: MUST be Fractional for 8 MHz!
#endif
{ClockControl::ClockCurrentDrive::_6mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
{ClockControl::ClockCurrentDrive::_4mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Fractional, ClockControl::ClockPowerDown::Power_Off},
{ClockControl::ClockCurrentDrive::_8mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
{ClockControl::ClockCurrentDrive::_2mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
// CLK4: HackRF r9 - not inverted
{ClockControl::ClockCurrentDrive::_2mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
// CLK5: HackRF r9 - not used
{ClockControl::ClockCurrentDrive::_2mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
// CLK6: Not used
{ClockControl::ClockCurrentDrive::_2mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
// CLK7: Not used
{ClockControl::ClockCurrentDrive::_2mA, ClockControl::ClockSource::MS_Self, ClockControl::ClockInvert::Normal, ClockControl::MultiSynthSource::PLLA, ClockControl::MultiSynthMode::Integer, ClockControl::ClockPowerDown::Power_Off},
#endif
}};
ClockManager::Reference ClockManager::get_reference() const {
return reference;
}
@@ -377,58 +498,86 @@ void ClockManager::init_clock_generator() {
#endif
#ifdef PRALINE
/* PRALINE uses Si5351A with:
* CLK0 = AFE_CLK (codec/FPGA sample clock)
* CLK1 = SCT_CLK (FPGA timing clock at 2x sample rate)
* CLK4 = first IF (RFFC5072)
* CLK5 = second IF (MAX2831)
* Uses PLLA on XTAL only (no CLKIN support).
/* * Praline HackRF Pro Clock Assignments (800 MHz VCO Configuration)
* VCO Frequency: 800,000,000 Hz (Master Reference)
* * CLK0: AFE_CLK (MAX5864 Codec & FPGA ADC Interface)
* - Note: Defines hardware sample rate. Essential for WFM purity.
* * CLK1: SCT_CLK (iCE40 FPGA System/Timing Clock)
* - Note: Timing for SGPIO data bus; scales to 2x SR in wideband modes.
* * CLK2: MCU_CLKIN (LPC43xx MCU External Clock Input)
* - Note: Synchronizes MCU processing to the RF clock tree.
* * CLK3: SG_CLK (Switching Regulator/Internal Logic Sync) SMA Port 1
* - Note: Used for internal FPGA logic/gateware synchronization.
* * CLK4: P_CLK (MAX2831 Peripheral/Expansion Clock)
* - Note: Routed to expansion headers for external hardware sync.
* * CLK5: AUX_CLK (RFFC5371 Auxiliary reference for secondary logic)
* - Note: Provides additional timing flexibility for the iCE40 FPGA.
* * CLK6: SG_CLK (Switching Regulator/Internal Logic Sync) SMA Port 2
* - Note: Used for internal FPGA logic/gateware synchronization.
* * CLK7: Unused / Power-Down
* - State: Disabled (si5351a_ms6_7_off_reg)
* - Note: Kept OFF to reduce EMI/RFI near the RF front-end.
* * CLKOUT: Optional external clock output on the header.
*/
/* Step 1: Write PLL A configuration (800 MHz VCO from 25 MHz XTAL) */
/* Use single-byte writes to debug I2C issues */
/* Write PLL A (800 MHz based on 25 MHz xtal for RF) and
* PLL B (800 MHZ based on 25 MHz xtalfor Digital)
* Use single-byte writes to debug I2C issues
*/
{
const auto& pll_regs = si5351_pll_a_xtal_reg;
const uint8_t base_reg = pll_regs[0];
for (size_t i = 1; i < pll_regs.size(); i++) {
clock_generator.write_register(base_reg + i - 1, pll_regs[i]);
// Write PLLA (Registers 26-33)
/* Write PLL A configuration (Base 26) */
const auto& pll_a = si5351_pll_a_800_reg;
for (size_t i = 1; i < pll_a.size(); i++) {
clock_generator.write_register(pll_a[0] + i - 1, pll_a[i]);
}
// Write PLLB (Registers 34-41)
/* Write PLL B configuration (Base 34) */
const auto& pll_b = si5351_pll_b_800_reg;
for (size_t i = 1; i < pll_b.size(); i++) {
clock_generator.write_register(pll_b[0] + i - 1, pll_b[i]);
}
}
/* Step 2: Write multisynth configurations using single-byte writes */
clock_generator.write_ms_single_byte(0, si5351_ms_0_8m); // MS0 = divider 50, r_div=1 for 8 MHz
clock_generator.write_ms_single_byte(1, si5351_ms_16m); // MS1 = divider 50, r_div=0 for 16 MHz
/* Write multisynth configurations using single-byte writes */
// These cover all active channels on the Praline board
clock_generator.write_ms_single_byte(0, si5351_ms_afe_4m); // CLK0: PLL A AFE Codec (4 MHz)
clock_generator.write_ms_single_byte(1, si5351_ms_10m); // CLK1: PLL B SGPIO/FPGA Timing (10 MHz)
clock_generator.write_ms_single_byte(2, si5351_ms_afe_40m); // CLK2: PLL A Audio and MCU Input (40 MHz)
clock_generator.write_ms_single_byte(3, si5351_ms_0_4m); // CLK3: PLL B SMA Port 1 Logic Sync (4 MHz or 10 MHz)
clock_generator.write_ms_single_byte(4, si5351_ms_afe_40m); // CLK4: PLL A MAX2831 Second IF (40 MHz)
clock_generator.write_ms_single_byte(5, si5351_ms_afe_40m); // CLK5: PLL A RFFC5071First IF (40 MHz)
clock_generator.write_ms_single_byte(6, si5351_ms_0_4m); // CLK6: PLL B SMA Port 2 Logic Sync (4 MHz or 10 MHz)
clock_generator.write_ms_single_byte(7, si5351_ms_0_4m); // CLK7: PLL B Unused (4 MHz)
/* CLK4 and CLK5 - use single-byte writes too */
{
const auto& ms4_regs = si5351c_ms_4_reg;
const uint8_t base_reg = ms4_regs[0];
for (size_t i = 1; i < ms4_regs.size(); i++) {
clock_generator.write_register(base_reg + i - 1, ms4_regs[i]);
}
}
{
const auto& ms5_regs = si5351c_ms_5_reg;
const uint8_t base_reg = ms5_regs[0];
for (size_t i = 1; i < ms5_regs.size(); i++) {
clock_generator.write_register(base_reg + i - 1, ms5_regs[i]);
}
}
clock_generator.write(si5351a_ms6_7_off_reg); // MS6/7 off - short write is OK
/* Step 3: NOW set clock control registers (AFTER multisynths per HackRF reference) */
const auto ref_pll = ClockControl::MultiSynthSource::PLLA;
/* NOW set clock control registers (AFTER multisynths per HackRF reference) */
const auto ref_pll_a = ClockControl::MultiSynthSource::PLLA;
const auto ref_pll_b = ClockControl::MultiSynthSource::PLLB;
const ClockControls si5351_clock_control = ClockControls{{
si5351a_clock_control_common[0].ms_src(ref_pll),
si5351a_clock_control_common[1].ms_src(ref_pll),
si5351a_clock_control_common[2].ms_src(ref_pll),
si5351a_clock_control_common[3].ms_src(ref_pll),
si5351a_clock_control_common[4].ms_src(ref_pll),
si5351a_clock_control_common[5].ms_src(ref_pll),
si5351a_clock_control_common[6].ms_src(ref_pll),
si5351a_clock_control_common[7].ms_src(ref_pll),
si5351a_clock_control_common[0].ms_src(ref_pll_a),
si5351a_clock_control_common[1].ms_src(ref_pll_b),
si5351a_clock_control_common[2].ms_src(ref_pll_a),
si5351a_clock_control_common[3].ms_src(ref_pll_b),
si5351a_clock_control_common[4].ms_src(ref_pll_a),
si5351a_clock_control_common[5].ms_src(ref_pll_a),
si5351a_clock_control_common[6].ms_src(ref_pll_b),
si5351a_clock_control_common[7].ms_src(ref_pll_b),
}};
clock_generator.set_clock_control(si5351_clock_control);
// clock_generator.set_clock_control(si5351_clock_control);
// Use single-byte writes instead of multi-byte
clock_generator.set_clock_control_single_byte(si5351_clock_control);
// Don't write CLKS 3, 6, and 7 multisynth
// Ensure CLK3 clock control has Power_Off
// Verify output is disabled
clock_generator.disable_output(3);
clock_generator.disable_clock(3);
clock_generator.disable_output(6);
clock_generator.disable_clock(6);
clock_generator.disable_output(7);
clock_generator.disable_clock(7);
#else
if (hackrf_r9) {
const PLLReg pll_reg = (reference.source == ReferenceSource::Xtal)
@@ -456,8 +605,8 @@ void ClockManager::init_clock_generator() {
// Wait for PLL(s) to lock.
#ifdef PRALINE
// PRALINE: Wait for PLLA to lock (0x20 = LOL_A bit)
uint8_t device_status_mask = 0x20;
// PRALINE: Wait for 0x60 (0x20 | 0x40), PLLA and PLLB to lock (0x20 = LOL_A bit, 0x40 = LOL_B bit)
uint8_t device_status_mask = 0x60;
uint32_t pll_timeout = 100000;
while ((clock_generator.device_status() & device_status_mask) != 0 && pll_timeout > 0) {
pll_timeout--;
@@ -466,8 +615,6 @@ void ClockManager::init_clock_generator() {
static volatile uint32_t pll_lock_timeout = pll_timeout;
(void)pll_lock_timeout;
// CRITICAL: Add delay to ensure Si5351 writes complete before I2C bus stops
chThdSleepMilliseconds(100);
#else
// Wait for PLL(s) to lock - with timeout to prevent hang
uint8_t device_status_mask = hackrf_r9
@@ -475,14 +622,8 @@ void ClockManager::init_clock_generator() {
: (ref_pll == ClockControl::MultiSynthSource::PLLB)
? 0x40
: 0x20;
#ifndef PRALINE
while ((clock_generator.device_status() & device_status_mask) != 0);
#else
uint32_t pll_timeout = 100000;
while ((clock_generator.device_status() & device_status_mask) != 0 && pll_timeout > 0) {
pll_timeout--;
}
#endif
clock_generator.set_clock_control(
clock_generator_output_mcu_clkin,
@@ -558,11 +699,11 @@ void ClockManager::enable_codec_clocks() {
#ifdef PRALINE
/* PRALINE: CLK0 (AFE_CLK) for codec/FPGA, CLK1 (SCT_CLK) for FPGA timing.
* Reference hackrf_core.c shows PRALINE needs both CLK0 and CLK1. */
clock_generator.enable_clock(clock_generator_output_og_codec); /* CLK0 */
clock_generator.enable_clock(clock_generator_output_og_cpld); /* CLK1 */
clock_generator.enable_clock(clock_generator_output_og_codec); /* CLK0 MAX5864*/
clock_generator.enable_clock(clock_generator_output_og_cpld); /* CLK1 iCE40 FPGA*/
clock_generator.enable_clock(clock_generator_output_og_sgpio); /* CLK2 LPC43xx*/
clock_generator.enable_output_mask(
(1U << clock_generator_output_og_codec) |
(1U << clock_generator_output_og_cpld));
(1U << clock_generator_output_og_codec) | (1U << clock_generator_output_og_cpld) | (1U << clock_generator_output_og_sgpio));
#else
if (hackrf_r9) {
clock_generator.enable_clock(clock_generator_output_r9_sgpio);
@@ -590,12 +731,12 @@ void ClockManager::disable_codec_clocks() {
* CLKx_DISABLE_STATE.
*/
#ifdef PRALINE
/* PRALINE: CLK0 (AFE_CLK) and CLK1 (SCT_CLK) used for codec/FPGA */
/* PRALINE: CLK0 (AFE_CLK), CLK1 (SCT_CLK), and CLK2 MCU used for codec/FPGA */
clock_generator.disable_output_mask(
(1U << clock_generator_output_og_codec) |
(1U << clock_generator_output_og_cpld));
(1U << clock_generator_output_og_codec) | (1U << clock_generator_output_og_cpld) | (1U << clock_generator_output_og_sgpio));
clock_generator.disable_clock(clock_generator_output_og_codec);
clock_generator.disable_clock(clock_generator_output_og_cpld);
clock_generator.disable_clock(clock_generator_output_og_sgpio);
#else
if (hackrf_r9) {
clock_generator.disable_output_mask(1U << clock_generator_output_r9_sgpio);
@@ -612,7 +753,7 @@ void ClockManager::disable_codec_clocks() {
void ClockManager::enable_if_clocks() {
#ifdef PRALINE
/* PRALINE uses CLK4 (first IF) and CLK5 (second IF) like original HackRF One */
/* PRALINE uses CLK5 (first IF) and CLK4 (second IF) */
clock_generator.enable_clock(clock_generator_output_og_first_if);
clock_generator.enable_output_mask(1U << clock_generator_output_og_first_if);
clock_generator.enable_clock(clock_generator_output_og_second_if);
@@ -651,21 +792,57 @@ void ClockManager::disable_if_clocks() {
void ClockManager::set_sampling_frequency(const uint32_t frequency) {
#ifdef PRALINE
/* PRALINE: CLK0=AFE_CLK runs at sample rate (VCO/divider/2)
* CLK1=SCT_CLK runs at 2x sample rate (VCO/divider/1)
* Reference: hackrf_core.c sample_rate_frac_set() lines 580-582
/*
* PRALINE sample rate strategy:
* 1. Maximize AFE rate to push Nyquist above MAX2831's 11.6 MHz LPF minimum
* 2. Use FPGA decimation to achieve desired output rate
* 3. Ensure AFE rate is achievable by Si5351 (clean division from 800 MHz VCO)
*/
/* PRALINE: Match HackRF USB sample_rate_frac_set()
* Reference: hackrf_usb radio.c lines 29-91, hackrf_core.c lines 501-685 */
constexpr uint32_t MAX_AFE_RATE = 40000000; // Use 40 MHz per GSG reference
constexpr uint8_t MAX_N = 5;
// Set FPGA decimation to 0 (no decimation) for direct passthrough
fpga_debug_register_write(2, 0);
_base_band_frequency = frequency;
uint8_t n = 0;
uint32_t afe_rate = frequency;
// Find the largest n where AFE rate stays within limit
// Start at n=0 and work up
while (n < MAX_N) {
uint32_t next_rate = afe_rate << 1;
if (next_rate > MAX_AFE_RATE) break;
afe_rate = next_rate;
n++;
}
_resampling_n = n;
// === Stop FPGA processing and flush filters ===
fpga_debug_register_write(1, 0x00); // Disable FPGA filters (resets CIC accumulators)
// Set FPGA RX decimation register
fpga_debug_register_write(2, n);
radio::invalidate_spi_config();
// The following was originally from @kitty. Adopting for testing radio.
clock_generator.set_ms_frequency(0, frequency * 2, si5351_vco_f, 1); // CLK0: r_div=1 (÷2)
clock_generator.set_ms_frequency(1, frequency * 2, si5351_vco_f, 0); // CLK1: r_div=0 (÷1)
// Configure Si5351 clocks
// CLK0: AFE_CLK (with r_div=1 for ÷2)
// CLK1: SCT_CLK (with r_div=0 for ÷1, runs at 2× AFE for FPGA timing)
// Configure Si5351 clocks using the correct AFE VCO
clock_generator.set_ms_frequency(0, afe_rate * 2, si5351_vco_afe_f, 1);
clock_generator.set_ms_frequency(1, afe_rate * 2, si5351_vco_afe_f, 0);
// === Reset PLL A for phase alignment ===
clock_generator.write_register(si5351::Register::PLLReset, 0x20);
// Brief delay for PLL lock and clock stability ===
// ~1ms at 96MHz = ~96000 cycles, use 10ms for safety
volatile uint32_t delay = 240000; // ~2.5ms
while (delay--);
// Re-enable FPGA processing with clean state ===
fpga_debug_register_write(1, 0x01);
#else
/* Codec clock is at sampling frequency, CPLD and SGPIO clocks are at
* twice the frequency, and derived from the MS0 synth. So it's only
@@ -689,7 +866,18 @@ void ClockManager::set_reference_ppb(const int32_t ppb) {
if (hackrf_r9 && reference.source != ReferenceSource::Xtal) {
return;
}
#ifdef PRALINE
// On Praline, only apply if we aren't locked to a superior external 10MHz source
// (Assuming you have a way to detect the 10MHz presence on Praline)
if (reference.source == ReferenceSource::External) {
return;
}
constexpr uint32_t pll_multiplier = si5351_pll_a_afe_800m.a;
#else
constexpr uint32_t pll_multiplier = si5351_pll_xtal_25m.a;
#endif
constexpr uint32_t denominator = 1000000 / pll_multiplier;
const uint32_t new_a = (ppb >= 0) ? pll_multiplier : (pll_multiplier - 1);
const uint32_t new_b = (ppb >= 0) ? (ppb / 1000) : (denominator + (ppb / 1000));
@@ -701,8 +889,14 @@ void ClockManager::set_reference_ppb(const int32_t ppb) {
.b = new_b,
.c = new_c,
};
#ifdef PRALINE
clock_generator.write_pll_single_byte(0, pll);
clock_generator.reset_plls();
#else
const auto pll_a_reg = pll.reg(0);
clock_generator.write(pll_a_reg);
#endif
}
void ClockManager::start_frequency_monitor_measurement(const cgu::CLK_SEL clk_sel) {
@@ -717,15 +911,15 @@ void ClockManager::start_frequency_monitor_measurement(const cgu::CLK_SEL clk_se
}
void ClockManager::wait_For_frequency_monitor_measurement_done() {
// FREQ_MON mechanism fails to finish if there's no clock present on selected input?!
#ifndef PRALINE
while (LPC_CGU->FREQ_MON.MEAS == 1);
#else
// FREQ_MON mechanism fails to finish if there's no clock present on selected input?!
#ifdef PRALINE
// PRALINE FIX: Add timeout to prevent infinite hang
uint32_t timeout = 100000;
while (LPC_CGU->FREQ_MON.MEAS == 1 && timeout > 0) {
timeout--;
}
#else
while (LPC_CGU->FREQ_MON.MEAS == 1);
#endif
}
@@ -738,33 +932,89 @@ uint32_t ClockManager::get_frequency_monitor_measurement_in_hertz() {
void ClockManager::start_audio_pll() {
#ifdef PRALINE
/* PRALINE: Use 12MHz XTAL for audio PLL
* For 12MHz XTAL input, 48kHz audio rate, 256Fs MCLK:
* Fout=12.288MHz, Fcco=491.52MHz
* 12MHz * 1024 / 25 = 491.52MHz
* MSEL=1024, NSEL=25, PSEL=20
*/
// Control Block
cgu::pll0audio::ctrl({
.pd = 1,
.bypass = 0,
.directi = 0,
.directo = 0,
.clken = 0,
.frm = 0,
.autoblock = 1,
.pllfract_req = 0,
.sel_ext = 1,
.mod_pd = 1,
.clk_sel = cgu::CLK_SEL::XTAL,
.pd = 1, // Start powered down
.bypass = 0, // Use the PLL
.directi = 0, // Enable N-divider
.directo = 0, // Enable P-divider
.clken = 0, // Disable output initially
.frm = 0, // Normal mode
.autoblock = 1, // Glitchless switching
.pllfract_req = 1, // Integer, Disabled
.sel_ext = 1, // Use GP_CLKIN (CLK2)
.mod_pd = 0, // Modulator OFF
.clk_sel = cgu::CLK_SEL::GP_CLKIN,
});
cgu::pll0audio::mdiv({
.mdec = 22625UL, // MDEC for MSEL=1024
});
/*
* Audio PLL Configuration for 48 kHz audio with 256Fs MCLK
* Target output: Fout = 12.288 MHz
*
* Formulas:
* Fout = Fin × MSEL / (NSEL × PSEL)
* FCO = 2 × Fin × MSEL / NSEL (must be 275-550 MHz)
*/
/*
*
* 10 MHz INPUT (HackRF r9 compatible but interfere with fm band)
*
* MSEL=3072, NSEL=125, PSEL=20
* Fout = 10 × 3072 / (125 × 20) = 30720 / 2500 = 12.288 MHz
* FCO = 2 × 10 × 3072 / 125 = 61440 / 125 = 491.52 MHz
*
* Encoded values: MDEC=8308, NDEC=45, PDEC=31
* CLK2 harmonics: 90, 100, 110 MHz (interfere with FM band!)
*
*/
/*
// Math: (10 MHz * 3072) / (125 * 20) * 2 = 12.288MHz
cgu::pll0audio::mdiv({.mdec = 8308UL}); // MSEL = 3072
cgu::pll0audio::np_div({
.pdec = 31, // PSEL=20
.ndec = 69, // NDEC for NSEL=25
.pdec = 31, // PSEL = 20 for 10 MHz
.ndec = 45 // NSEL = 125 for 10 MHz
});
*/
/*
*
* 40 MHz INPUT (Recommended - avoids FM band harmonics)
*
* MSEL=768, NSEL=125, PSEL=20
* Fout = 40 × 768 / (125 × 20) = 30720 / 2500 = 12.288 MHz
* FCO = 2 × 40 × 768 / 125 = 61440 / 125 = 491.52 MHz
*
* Encoded values: MDEC=30542, NDEC=45, PDEC=31
* CLK2 harmonics: 80, 120, 160 MHz (none in FM 88-108 MHz band)
*
*/
// 40 MHz input → 12.288 MHz output (same as HackRF OG)
// Math: (40MHz * 768) / (125 * 20) * 2 = 12.288MHz
cgu::pll0audio::mdiv({.mdec = 30542UL}); // MSEL = 768
cgu::pll0audio::np_div({.pdec = 31,
.ndec = 45});
cgu::pll0audio::frac({.pllfract_ctrl = 0});
cgu::pll0audio::power_up();
// Lock and Routing (Keep as is)
{
uint32_t timeout = 100000;
while (!cgu::pll0audio::is_locked() && timeout > 0) {
timeout--;
}
}
cgu::pll0audio::clock_enable();
set_base_audio_clock_divider(1);
LPC_CGU->BASE_AUDIO_CLK.AUTOBLOCK = 1;
LPC_CGU->BASE_AUDIO_CLK.CLK_SEL = toUType(cgu::CLK_SEL::IDIVD);
#else
cgu::pll0audio::ctrl({
.pd = 1,
@@ -794,30 +1044,21 @@ void ClockManager::start_audio_pll() {
.pdec = 31,
.ndec = 45,
});
#endif
cgu::pll0audio::frac({
.pllfract_ctrl = 0,
});
cgu::pll0audio::power_up();
#ifndef PRALINE
while (!cgu::pll0audio::is_locked());
#else
// PRALINE FIX: Add timeout to prevent infinite hang if GP_CLKIN not present
{
uint32_t timeout = 100000;
while (!cgu::pll0audio::is_locked() && timeout > 0) {
timeout--;
}
}
#endif
cgu::pll0audio::clock_enable();
while (!cgu::pll0audio::is_locked());
cgu::pll0audio::clock_enable();
set_base_audio_clock_divider(1);
LPC_CGU->BASE_AUDIO_CLK.AUTOBLOCK = 1;
LPC_CGU->BASE_AUDIO_CLK.CLK_SEL = toUType(cgu::CLK_SEL::IDIVD);
#endif
}
void ClockManager::set_base_audio_clock_divider(const size_t divisor) {
@@ -826,9 +1067,24 @@ void ClockManager::set_base_audio_clock_divider(const size_t divisor) {
}
void ClockManager::stop_audio_pll() {
#ifdef PRALINE
/* PRALINE: Gracefully switch audio peripherals away from the PLL branch */
LPC_CGU->BASE_AUDIO_CLK.PD = 1; // Power down the branch first
LPC_CGU->BASE_AUDIO_CLK.CLK_SEL = toUType(cgu::CLK_SEL::IRC); // Reset to safe IRC source
#endif
cgu::pll0audio::clock_disable();
cgu::pll0audio::power_down();
#ifdef PRALINE
/* PRALINE: Add a safety timeout to the unlock check to prevent potential hangs */
uint32_t timeout = 100000;
while (cgu::pll0audio::is_locked() && timeout > 0) {
timeout--;
}
#else
while (cgu::pll0audio::is_locked());
#endif
}
void ClockManager::enable_clock_output(bool enable) {
+12
View File
@@ -70,9 +70,15 @@ class ClockManager {
void set_sampling_frequency(const uint32_t frequency);
uint32_t get_sampling_frequency() const {
return _base_band_frequency;
};
void set_reference_ppb(const int32_t ppb);
#ifdef PRALINE
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); }
@@ -92,6 +98,8 @@ class ClockManager {
si5351::Si5351& clock_generator;
Reference reference;
uint32_t _base_band_frequency{20000000};
void set_gp_clkin_to_clkin_direct();
void start_frequency_monitor_measurement(const cgu::CLK_SEL clk_sel);
@@ -106,6 +114,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__*/
+3 -1
View File
@@ -256,7 +256,9 @@ ui::Widget* EventDispatcher::touch_widget(ui::Widget* const w, ui::TouchEvent ev
if (!w->hidden()) {
// To achieve reverse depth ordering (last object drawn is
// considered "top"), descend first.
for (const auto child : w->children()) {
auto& children = w->children();
for (auto it = children.rbegin(); it != children.rend(); ++it) { // reverse, bc the lastly added will be "top" if overlaps
const auto& child = *it;
const auto touched_widget = touch_widget(child, event);
if (touched_widget) {
return touched_widget;
+73 -4
View File
@@ -33,6 +33,76 @@ using namespace portapack;
namespace ui::external_app::acars_rx {
// ACARS frame field layout (0-based byte offsets):
// [0] SOH framing byte (skipped)
// [1..7] Aircraft registration (7 chars)
// [8] STX framing byte (skipped)
// [9..10] Label (2 chars)
// [11] Block ID (1 char)
// [12..14] Message number (3 chars)
// [15..20] Flight ID (6 chars)
// [21..N-3] Free-text payload (variable)
// [N-2..N-1] CRC-16/CCITT (2 bytes, MSB first, NOT part of payload)
//
// Minimum valid frame: 21-byte fixed header + 2 CRC bytes = 23 bytes.
// (A zero-length payload is legal per spec; we require at least 23 bytes.)
static constexpr std::string::size_type kAcarsCrcLen = 2;
static constexpr std::string::size_type kAcarsHeaderLen = 21;
static constexpr std::string::size_type kAcarsMinLen = kAcarsHeaderLen + kAcarsCrcLen;
// CRC-16/CCITT: poly 0x1021, init 0x0000, no reflection, no final XOR.
// This is the variant used by ACARS (same as XMODEM CRC).
static uint16_t acars_crc16(const std::string& data, std::string::size_type len) {
uint16_t crc = 0x0000;
for (std::string::size_type i = 0; i < len; ++i) {
crc ^= static_cast<uint16_t>(static_cast<uint8_t>(data[i])) << 8;
for (int bit = 0; bit < 8; ++bit) {
if (crc & 0x8000)
crc = static_cast<uint16_t>((crc << 1) ^ 0x1021);
else
crc = static_cast<uint16_t>(crc << 1);
}
}
return crc;
}
AcarsDecoded acars_decode(const std::string& raw) {
AcarsDecoded result;
if (raw.size() < kAcarsMinLen) {
result.txt = "ACARS message too short (" + std::to_string(raw.size()) +
" bytes, need " + std::to_string(kAcarsMinLen) + ")";
return result;
}
// Verify CRC: computed over everything except the last 2 bytes,
// then compared against those 2 bytes (MSB first).
const std::string::size_type payload_len = raw.size() - kAcarsCrcLen;
const uint16_t computed = acars_crc16(raw, payload_len);
const uint16_t received = (static_cast<uint16_t>(static_cast<uint8_t>(raw[raw.size() - 2])) << 8) |
static_cast<uint16_t>(static_cast<uint8_t>(raw[raw.size() - 1]));
result.crc_ok = (computed == received);
result.reg = raw.substr(1, 7);
result.label = raw.substr(9, 2);
result.block_id = raw[11];
result.msg_num = raw.substr(12, 3);
result.flight_id = raw.substr(15, 6);
// Payload sits between end of fixed header and the 2 trailing CRC bytes.
if (payload_len > kAcarsHeaderLen)
result.txt = raw.substr(kAcarsHeaderLen, payload_len - kAcarsHeaderLen);
return result;
}
std::string acars_format(const AcarsDecoded& msg) {
return std::string("ACARS Decoded Result\nCRC: ") + (msg.crc_ok ? "OK" : "FAIL") +
"\nRegistration: " + msg.reg +
"\nLabel: " + msg.label +
"\nBlockID: " + msg.block_id +
"\nMsgNum: " + msg.msg_num +
"\nFlightID: " + msg.flight_id +
"\nMessage: " + msg.txt;
}
void ACARSLogger::log_str(std::string msg) {
log_file.write_entry(msg);
}
@@ -77,17 +147,16 @@ void ACARSAppView::focus() {
void ACARSAppView::on_packet(const ACARSPacketMessage* packet) {
std::string console_info;
if (packet->state == 255) {
// got a packet, parse it, and display
rtc::RTC datetime;
rtc_time::now(datetime);
// todo parity error recovery
console_info = to_string_datetime(datetime, HMS);
console_info += ": ";
console_info += packet->message;
std::string message{packet->message, packet->message + packet->msg_len};
AcarsDecoded decoded = acars_decode(message);
console_info += acars_format(decoded);
console.writeln(console_info);
// Log raw data whatever it contains
if (logger && logging)
logger->log_str(console_info);
} else {
+21 -1
View File
@@ -33,6 +33,26 @@
namespace ui::external_app::acars_rx {
// Decoded ACARS message fields extracted from a raw frame.
// CRC-16/CCITT (poly 0x1021, init 0x0000) is verified against the two
// trailing bytes of the raw frame; crc_ok reflects that result.
struct AcarsDecoded {
bool crc_ok{false};
std::string reg{};
std::string label{};
std::string flight_id{};
std::string msg_num{};
char block_id{'\0'};
std::string txt{};
};
// Decode a raw ACARS frame: verify CRC-16/CCITT and extract fixed-offset fields.
// Returns a partially-filled AcarsDecoded (txt error only) if the frame is too short.
AcarsDecoded acars_decode(const std::string& raw);
// Format a decoded ACARS message for display or logging.
std::string acars_format(const AcarsDecoded& msg);
class ACARSLogger {
public:
Optional<File::Error> append(const std::filesystem::path& filename) {
@@ -106,4 +126,4 @@ class ACARSAppView : public View {
} // namespace ui::external_app::acars_rx
#endif /*__ACARS_APP_H__*/
#endif /*__ACARS_APP_H__*/
+83 -83
View File
@@ -1,83 +1,83 @@
/*
* Copyright (C) 2023 Bernd Herzog
*
* 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 "acars_app.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::acars_rx {
void initialize_app(ui::NavigationView& nav) {
nav.push<ACARSAppView>();
}
} // namespace ui::external_app::acars_rx
extern "C" {
__attribute__((section(".external_app.app_acars_rx.application_information"), used)) application_information_t _application_information_acars_rx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::acars_rx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "ACARS",
/*.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::orange().v,
/*.menu_location = */ app_location_t::RX,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_acars */ {'P', 'A', 'C', 'A'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
/*
* Copyright (C) 2023 Bernd Herzog
*
* 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 "acars_app.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::acars_rx {
void initialize_app(ui::NavigationView& nav) {
nav.push<ACARSAppView>();
}
} // namespace ui::external_app::acars_rx
extern "C" {
__attribute__((section(".external_app.app_acars_rx.application_information"), used)) application_information_t _application_information_acars_rx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::acars_rx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "ACARS",
/*.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::orange().v,
/*.menu_location = */ app_location_t::RX,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_acars */ {'P', 'A', 'C', 'A'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
@@ -339,7 +339,7 @@ void AdultToysView::randomizeMac() {
}
void AdultToysView::randomChn() {
channel_number = 37 + std::rand() % (39 - 37 + 1);
channel_number = 37 + rand() % (39 - 37 + 1);
field_frequency.set_value(get_freq_by_channel_number(channel_number));
}
+1 -1
View File
@@ -72,7 +72,7 @@ void BlackjackView::paint(Painter& painter) {
if (!initialized) {
initialized = true;
std::srand(LPC_RTC->CTIME0);
srand(LPC_RTC->CTIME0);
init_deck();
}
}
+1 -1
View File
@@ -132,7 +132,7 @@ void BLESpamView::reset() {
}
void BLESpamView::randomChn() {
channel_number = 37 + std::rand() % (39 - 37 + 1);
channel_number = 37 + rand() % (39 - 37 + 1);
field_frequency.set_value(get_freq_by_channel_number(channel_number));
}
+1 -1
View File
@@ -655,7 +655,7 @@ void BreakoutView::paint(Painter& painter) {
if (!initialized) {
initialized = true;
std::srand(LPC_RTC->CTIME0);
srand(LPC_RTC->CTIME0);
init_game();
}
}
+3 -3
View File
@@ -125,7 +125,7 @@ void DinoGameView::paint(Painter& painter) {
if (!initialized) {
initialized = true;
std::srand(LPC_RTC->CTIME0);
srand(LPC_RTC->CTIME0);
init_game();
}
}
@@ -789,8 +789,8 @@ void DinoGameView::draw_current_score() {
void DinoGameView::draw_high_score() {
auto style = *ui::Theme::getInstance()->fg_light;
painter.fill_rectangle({UI_POS_X_RIGHT(90), 28, 90, 18}, Color::black());
painter.draw_string({UI_POS_X_RIGHT(90), 30}, style, "HI " + score_to_string(highScore));
painter.fill_rectangle({UI_POS_X_RIGHT(10), 28, 90, 18}, Color::black());
painter.draw_string({UI_POS_X_RIGHT(10), 30}, style, "HI " + score_to_string(highScore));
}
void DinoGameView::jump() {
+15 -15
View File
@@ -204,11 +204,11 @@ void spawn_entity(uint8_t type, uint8_t x, uint8_t y) {
void spawn_random_entity(uint8_t type) {
if (num_entities >= MAX_ENTITIES) return;
std::srand(LPC_RTC->CTIME0);
srand(LPC_RTC->CTIME0);
uint8_t spawn_x, spawn_y;
do {
spawn_x = std::rand() % LEVEL_WIDTH;
spawn_y = std::rand() % LEVEL_HEIGHT;
spawn_x = rand() % LEVEL_WIDTH;
spawn_y = rand() % LEVEL_HEIGHT;
} while (get_block_at(spawn_x, spawn_y) == 0xF ||
(spawn_x == (uint8_t)player.pos.x && spawn_y == (uint8_t)player.pos.y));
@@ -227,9 +227,9 @@ void remove_entity(uint8_t index) {
bool spawned = false;
while (!spawned && attempts < 50) {
std::srand(LPC_RTC->CTIME0 + attempts);
uint8_t spawn_x = std::rand() % LEVEL_WIDTH;
uint8_t spawn_y = std::rand() % LEVEL_HEIGHT;
srand(LPC_RTC->CTIME0 + attempts);
uint8_t spawn_x = rand() % LEVEL_WIDTH;
uint8_t spawn_y = rand() % LEVEL_HEIGHT;
int16_t dx = (int16_t)spawn_x - (int16_t)player.pos.x;
int16_t dy = (int16_t)spawn_y - (int16_t)player.pos.y;
@@ -270,9 +270,9 @@ void initialize_level() {
uint8_t attempts = 0;
while (initial_enemies < 2 && num_entities < MAX_ENTITIES && attempts < 50) {
std::srand(LPC_RTC->CTIME0 + attempts);
int8_t offset_x = (std::rand() % 11) - 5;
int8_t offset_y = (std::rand() % 11) - 5;
srand(LPC_RTC->CTIME0 + attempts);
int8_t offset_x = (rand() % 11) - 5;
int8_t offset_y = (rand() % 11) - 5;
if (abs(offset_x) < 3 && abs(offset_y) < 3) {
attempts++;
@@ -307,10 +307,10 @@ void initialize_level() {
attempts = 0;
while (num_entities < MIN_ENTITIES && attempts < 100) {
std::srand(LPC_RTC->CTIME0 + attempts + 100);
srand(LPC_RTC->CTIME0 + attempts + 100);
uint8_t spawn_x = std::rand() % LEVEL_WIDTH;
uint8_t spawn_y = std::rand() % LEVEL_HEIGHT;
uint8_t spawn_x = rand() % LEVEL_WIDTH;
uint8_t spawn_y = rand() % LEVEL_HEIGHT;
int16_t dx = (int16_t)spawn_x - (int16_t)player.pos.x;
int16_t dy = (int16_t)spawn_y - (int16_t)player.pos.y;
@@ -1045,7 +1045,7 @@ void DoomView::on_show() {
void DoomView::paint(Painter& painter) {
if (!initialized) {
initialized = true;
std::srand(LPC_RTC->CTIME0);
srand(LPC_RTC->CTIME0);
scene = 0;
up = down = left = right = fired = false;
jogging = view_height = 0;
@@ -1081,7 +1081,7 @@ void DoomView::paint(Painter& painter) {
int hud_y = RENDER_HEIGHT + 5;
painter.draw_string({5, hud_y}, style_yellow, "Health: " + std::to_string(player.health));
painter.draw_string({UI_POS_X_CENTER(15), hud_y}, style_red, "Kills: " + std::to_string(kills));
painter.draw_string({UI_POS_X_RIGHT(80), hud_y}, style_blue, "Ammo: " + std::to_string(player.ammo));
painter.draw_string({UI_POS_X_RIGHT(10), hud_y}, style_blue, "Ammo: " + std::to_string(player.ammo));
prev_velocity_moving = (player.velocity != 0);
needs_redraw = false;
@@ -1113,7 +1113,7 @@ void DoomView::paint(Painter& painter) {
int hud_y = RENDER_HEIGHT + 5;
painter.draw_string({5, hud_y}, style_yellow, "Health: " + std::to_string(player.health));
painter.draw_string({UI_POS_X_CENTER(15), hud_y}, style_red, "Kills: " + std::to_string(kills));
painter.draw_string({UI_POS_X_RIGHT(80), hud_y}, style_blue, "Ammo: " + std::to_string(player.ammo));
painter.draw_string({UI_POS_X_RIGHT(10), hud_y}, style_blue, "Ammo: " + std::to_string(player.ammo));
needs_gun_redraw = false;
}
+38 -3
View File
@@ -83,6 +83,10 @@ set(EXTCPPSRC
external/tpmsrx/main.cpp
external/tpmsrx/tpms_app.cpp
#tpmstx 800 bytes - TPMS transmit with editable fields
external/tpmstx/main.cpp
external/tpmstx/tpms_tx_app.cpp
#protoview 8 byte
external/protoview/main.cpp
external/protoview/ui_protoview.cpp
@@ -99,6 +103,10 @@ 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
#sstvrx
external/sstvrx/main.cpp
external/sstvrx/ui_sstvrx.cpp
@@ -109,8 +117,8 @@ set(EXTCPPSRC
external/random_password/sha512.cpp
#acars
#external/acars_rx/main.cpp
#external/acars_rx/acars_app.cpp
external/acars_rx/main.cpp
external/acars_rx/acars_app.cpp
#wefax_rx 192 bytes
external/wefax_rx/main.cpp
@@ -292,6 +300,26 @@ set(EXTCPPSRC
#morseradiotx
external/morseradiotx/main.cpp
external/morseradiotx/ui_morse_radiotx.cpp
external/keeloqtx/main.cpp
external/keeloqtx/ui_keeloqtx.cpp
#rtty_rx
external/rtty_rx/main.cpp
external/rtty_rx/ui_rtty_rx.cpp
external/rtty_rx/baudot.cpp
#rtty_tx
external/rtty_tx/main.cpp
external/rtty_tx/ui_rtty_tx.cpp
external/rtty_tx/baudot.cpp
#pocsag_tx
external/pocsag_tx/main.cpp
external/pocsag_tx/ui_pocsag_tx.cpp
#time_sink
external/time_sink/main.cpp
external/time_sink/ui_time_sink.cpp
)
set(EXTAPPLIST
@@ -314,13 +342,15 @@ set(EXTAPPLIST
audio_test
wardrivemap
tpmsrx
tpmstx
protoview
adsbtx
#morse_tx
sstvtx
same_tx
sstvrx
random_password
# acars_rx --not working
acars_rx
wefax_rx
noaaapt_rx
shoppingcart_lock
@@ -365,6 +395,11 @@ set(EXTAPPLIST
siggen
morse_radio
morseradiotx
keeloqtx
rtty_rx
rtty_tx
pocsag_tx
time_sink
)
# sdusb has type conflicts with PRALINE (HackRF Pro) - add only for non-PRALINE builds
+48
View File
@@ -94,6 +94,14 @@ MEMORY
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
}
SECTIONS
@@ -212,6 +220,12 @@ SECTIONS
*(*ui*external_app*tpmsrx*);
} > ram_external_app_tpmsrx
.external_app_tpmstx : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_tpmstx.application_information));
*(*ui*external_app*tpmstx*);
} > ram_external_app_tpmstx
.external_app_protoview : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_protoview.application_information));
@@ -526,5 +540,39 @@ SECTIONS
*(*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*);
} > 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*);
} > 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*);
} > 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*);
} > ram_external_app_pocsag_tx
.external_app_time_sink : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_time_sink.application_information));
*(*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));
*(*ui*external_app*same_tx*);
} > ram_external_app_same_tx
}
+5 -5
View File
@@ -165,7 +165,7 @@ FmRadioView::FmRadioView(NavigationView& nav)
&gr});
txt_save_help.set_focusable(false);
txt_save_help.visible(false);
txt_save_help.hidden(true);
for (uint8_t i = 0; i < 12; ++i) {
if (freq_fav_list[i].frequency == 0) {
freq_fav_list[i].frequency = 87000000;
@@ -195,7 +195,7 @@ FmRadioView::FmRadioView(NavigationView& nav)
btn_fav_save.on_select = [this](Button&) {
save_fav = !save_fav;
txt_save_help.set_text(save_fav ? "Select slot" : "");
txt_save_help.visible(save_fav);
txt_save_help.hidden(!save_fav);
txt_save_help.set_dirty();
};
@@ -229,9 +229,9 @@ void FmRadioView::on_btn_clicked(uint8_t i) {
freq_fav_list[i].modulation = field_modulation.selected_index_value();
freq_fav_list[i].bandwidth = radio_bw;
update_fav_btn_texts();
txt_save_help.visible(save_fav);
txt_save_help.hidden(true);
txt_save_help.set_text("");
txt_save_help.set_dirty();
set_dirty();
return;
}
field_frequency.set_value(freq_fav_list[i].frequency);
@@ -266,7 +266,7 @@ FmRadioView::~FmRadioView() {
}
void FmRadioView::on_audio_spectrum() {
if (gr.visible() && audio_spectrum_data) gr.update_audio_spectrum(*audio_spectrum_data);
if (gr.drawn() && audio_spectrum_data) gr.update_audio_spectrum(*audio_spectrum_data);
if (audio_spectrum_data && audio_spectrum_data->db.size() <= 128) {
for (size_t i = 0; i < audio_spectrum_data->db.size(); ++i) {
audio_spectrum[i] = ((int16_t)audio_spectrum_data->db[i] - 127) * 256;
+1 -1
View File
@@ -33,7 +33,7 @@ Game2048View::Game2048View(NavigationView& nav)
void Game2048View::on_show() {
if (!initialized) {
std::srand(LPC_RTC->CTIME0);
srand(LPC_RTC->CTIME0);
reset_game();
initialized = true;
}
+81
View File
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2026 lifegame1lu111
*
* 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_navigation.hpp"
#include "ui_keeloqtx.hpp"
#include "external_app.hpp"
namespace ui::external_app::ui_keeloqtx {
void initialize_app(ui::NavigationView& nav) {
nav.push<KeeloqTXView>();
}
} // namespace ui::external_app::ui_keeloqtx
extern "C" {
__attribute__((section(".external_app.app_keeloqtx.application_information"), used)) application_information_t _application_information_keeloqtx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::ui_keeloqtx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "KeeLoq TX",
/*.bitmap_data = */ {
0x20,
0x00,
0x20,
0x00,
0x20,
0x00,
0x20,
0x00,
0xE0,
0x07,
0xF0,
0x0F,
0x30,
0x0C,
0x30,
0x0C,
0xF0,
0x0F,
0xF0,
0x0F,
0x70,
0x0D,
0xB0,
0x0E,
0x70,
0x0D,
0xB0,
0x0E,
0xF0,
0x0F,
0xE0,
0x07,
},
/*.icon_color = */ ui::Color::yellow().v,
/*.menu_location = */ app_location_t::TX,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_ook */ {'P', 'O', 'O', 'K'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
+248
View File
@@ -0,0 +1,248 @@
#include "ui_keeloqtx.hpp"
#include "ui_fileman.hpp"
#include "baseband_api.hpp"
#include "../../keeloq_common.hpp"
#include "../../baseband/fprotos/fprotogeneral.hpp"
using namespace portapack;
using namespace ui;
namespace fs = std::filesystem;
namespace ui::external_app::ui_keeloqtx {
void KeeloqTXView::focus() {
button_open.focus();
}
void KeeloqTXView::update_hop() {
hop = data.btn << 28 | (data.serial & 0x3FF) << 16 | data.counter;
if (data.mf_name == "Aprimatic") {
uint32_t apri_serial = data.serial;
uint8_t apr1 = 0;
for (uint16_t i = 1; i != 0b10000000000; i <<= 1) {
if (apri_serial & i) apr1++;
}
apri_serial &= 0b00001111111111;
if (apr1 % 2 == 0) {
apri_serial |= 0b110000000000;
}
hop = data.btn << 28 | (apri_serial & 0xFFF) << 16 | data.counter;
} else if (
data.mf_name == "DTM_Neo" || data.mf_name == "FAAC_RC,XT" || data.mf_name == "Mutanco_Mutancode" || data.mf_name == "Came_Space" || data.mf_name == "Genius_Bravo" || data.mf_name == "GSN" || data.mf_name == "Rosh" || data.mf_name == "Rossi" || data.mf_name == "Peccinin" || data.mf_name == "Steelmate" || data.mf_name == "Cardin_S449") {
hop = data.btn << 28 | (data.serial & 0xFFF) << 16 | data.counter;
} else if (
data.mf_name == "NICE_Smilo" || data.mf_name == "NICE_MHOUSE" || data.mf_name == "JCM_Tech") {
hop = data.btn << 28 | (data.serial & 0xFF) << 16 | data.counter;
} else if (data.mf_name == "Merlin") {
hop = data.btn << 28 | (0x000) << 16 | data.counter;
} else if (data.mf_name == "Centurion") {
hop = data.btn << 28 | (0x1CE) << 16 | data.counter;
} else if (data.mf_name == "Monarch") {
hop = data.btn << 28 | (0x100) << 16 | data.counter;
} else if (data.mf_name == "Dea_Mio") {
uint8_t first_disc_num = (data.serial >> 8) & 0xF;
uint8_t result_disc = (0xC + (first_disc_num % 4));
uint32_t dea_serial = (data.serial & 0xFF) | (((uint32_t)result_disc) << 8);
hop = data.btn << 28 | (dea_serial & 0xFFF) << 16 | data.counter;
}
text_hop.set(to_string_hex(hop));
}
void KeeloqTXView::update_payload() {
uint64_t encrypt = 0;
switch (current_key.type) {
case KEELOQ_SIMPLE_LEARNING: {
encrypt = keeloq_encrypt(hop, current_key.key);
break;
}
case KEELOQ_NORMAL_LEARNING: {
uint64_t man = keeloq_normal_learning(fix, current_key.key);
encrypt = keeloq_encrypt(hop, man);
break;
}
}
payload = (uint64_t)fix << 32 | encrypt;
uint64_t preview_payload = FProtoGeneral::subghz_protocol_blocks_reverse_key(payload, 64);
text_payload.set(to_string_hex(preview_payload));
encode_data();
}
void KeeloqTXView::encode_data() {
std::string fragments{};
for (uint32_t i = 0; i < 64; ++i) {
fragments += keeloq_fragments[bit(payload, i)];
}
encoded_data = KEELOQ_HEADER + fragments + "1001";
if (data.mf_name == "Sommer") {
pause_duration = 28;
} else {
pause_duration = 39;
}
}
KeeloqTXView::KeeloqTXView(NavigationView& nav)
: nav_{nav} {
baseband::run_image(portapack::spi_flash::image_tag_ook);
add_children({&labels,
&text_mf_name,
&text_serial,
&text_fix,
&text_hop,
&field_counter,
&field_button,
&field_repeat,
&text_payload,
&button_open,
&text_status,
&progressbar,
&tx_view});
field_counter.on_change = [this](uint32_t value) {
data.counter = (uint16_t)value;
update_hop();
update_payload();
};
field_button.on_change = [this](uint32_t value) {
data.btn = (uint8_t)value;
fix &= 0xFFFFFFF;
fix |= data.btn << 28;
text_fix.set(to_string_hex(fix));
update_hop();
update_payload();
};
field_repeat.on_change = [this](uint32_t value) {
repeat = value;
};
field_repeat.set_value(4, true);
tx_view.on_edit_frequency = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.target_frequency());
new_view->on_changed = [this](rf::Frequency f) {
transmitter_model.set_target_frequency(f);
};
};
tx_view.on_start = [this]() {
start_tx();
};
tx_view.on_stop = [this]() {
baseband::kill_ook();
stop_tx();
};
button_open.on_select = [this](const Button&) {
auto open_view = nav_.push<FileLoadView>(".KEELOQ");
ensure_directory(keeloq_remotes_dir);
open_view->push_dir(keeloq_remotes_dir);
open_view->on_changed = [this](fs::path path) {
nav_.set_on_pop([this, path]() {
if (!read_keeloq_file(path, data)) {
return;
}
file_path = path;
for (const auto& key : keystore.get_keys()) {
if (key.mf_name == data.mf_name) {
current_key = key;
break;
}
}
fix = data.btn << 28 | data.serial;
update_hop();
text_mf_name.set(data.mf_name);
text_serial.set(to_string_hex(data.serial));
text_fix.set(to_string_hex(fix));
field_counter.set_value(data.counter, false);
field_button.set_value(data.btn, false);
update_payload();
field_counter.focus();
});
};
};
}
void KeeloqTXView::start_tx() {
size_t bitstream_length = encoders::make_bitstream(encoded_data);
progressbar.set_max(repeat);
tx_view.set_transmitting(true);
transmitter_model.enable();
baseband::set_ook_data(
bitstream_length,
OOK_SAMPLERATE * (400.0 / 1000000.0),
repeat,
pause_duration);
}
void KeeloqTXView::stop_tx() {
transmitter_model.disable();
text_status.set("Ready");
progressbar.set_value(0);
tx_view.set_transmitting(false);
data.counter += 1;
field_counter.set_value(data.counter, false);
update_hop();
update_payload();
write_keeloq_file(file_path, data);
}
void KeeloqTXView::on_tx_progress(uint32_t progress, bool done) {
if (!done) {
text_status.set(to_string_dec_uint(progress + 1) + "/" + to_string_dec_uint(repeat));
progressbar.set_value(progress + 1);
} else {
chThdSleepMilliseconds(10);
stop_tx();
}
}
KeeloqTXView::~KeeloqTXView() {
transmitter_model.disable();
baseband::shutdown();
}
} // namespace ui::external_app::ui_keeloqtx
+129
View File
@@ -0,0 +1,129 @@
#ifndef __KEELOQTX__
#define __KEELOQTX__
#include "ui.hpp"
#include "ui_transmitter.hpp"
#include "transmitter_model.hpp"
#include "file_path.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "encoders.hpp"
#include "string_format.hpp"
#include "../../keeloq_file.hpp"
#include "../../keeloq_keystore.hpp"
#define KEELOQ_HEADER "101010101010101010101010000000000"
namespace ui::external_app::ui_keeloqtx {
class KeeloqTXView : public View {
public:
KeeloqTXView(NavigationView& nav);
~KeeloqTXView();
void focus() override;
std::string title() const override {
return "KeeLoqTX";
}
private:
const std::string keeloq_fragments[2] = {"110", "100"};
NavigationView& nav_;
TxRadioState radio_state_{
433920000,
1750000,
OOK_SAMPLERATE};
app_settings::SettingsManager settings_{
"tx_keeloq", app_settings::Mode::TX};
std::filesystem::path file_path{};
KeeloqKeystore keystore{};
KeeloqKey current_key{};
KeeloqData data{};
uint32_t fix = 0;
uint32_t hop = 0;
uint64_t payload = 0;
void update_hop();
Labels labels{
{{UI_POS_X(1), UI_POS_Y(0)}, "Manufacturer:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(1), UI_POS_Y(1)}, "Serial:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(1), UI_POS_Y(2)}, "Fix:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(1), UI_POS_Y(3)}, "Hop:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(1), UI_POS_Y(4)}, "Counter:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(1), UI_POS_Y(5)}, "Button:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(1), UI_POS_Y(6)}, "Repeat:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(2), UI_POS_Y(8)}, "Payload:", Theme::getInstance()->fg_light->foreground},
};
Text text_mf_name{{UI_POS_X(15), UI_POS_Y(0), 128, 16}, ""};
Text text_serial{{UI_POS_X(9), UI_POS_Y(1), 64, 16}, "00000000"};
Text text_fix{{UI_POS_X(6), UI_POS_Y(2), 64, 16}, "00000000"};
Text text_hop{{UI_POS_X(6), UI_POS_Y(3), 64, 16}, "00000000"};
NumberField field_counter{
{UI_POS_X(10), UI_POS_Y(4)},
5,
{0, 65535},
1,
' '};
NumberField field_button{
{UI_POS_X(9), UI_POS_Y(5)},
2,
{0, 15},
1,
' '};
NumberField field_repeat{
{UI_POS_X(10), UI_POS_Y(6)},
3,
{0, 100},
1,
' '};
Text text_payload{{UI_POS_X(2), UI_POS_Y(9), 128, 16}, "0000000000000000"};
void update_payload();
Button button_open{{UI_POS_X(0), UI_POS_Y(11), screen_width, 32}, "Open file"};
Text text_status{{UI_POS_X(2), UI_POS_Y_BOTTOM(7), 128, 16}, "Ready"};
ProgressBar progressbar{
{UI_POS_X(2), UI_POS_Y_BOTTOM(7) + 20, UI_POS_WIDTH_REMAINING(4), 16}};
TransmitterView tx_view{
(int16_t)UI_POS_Y_BOTTOM(4),
50000,
9};
std::string encoded_data{};
void encode_data();
uint32_t repeat = 4;
uint32_t pause_duration = 0;
void start_tx();
void stop_tx();
void update_progress();
void on_tx_progress(uint32_t progress, bool done);
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);
}};
};
} // namespace ui::external_app::ui_keeloqtx
#endif
+1
View File
@@ -137,6 +137,7 @@ LevelView::LevelView(NavigationView& nav)
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);
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2023 Bernd Herzog
*
* 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_pocsag_tx.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::pocsag_tx {
void initialize_app(ui::NavigationView& nav) {
nav.push<POCSAGTXView>();
}
} // namespace ui::external_app::pocsag_tx
extern "C" {
__attribute__((section(".external_app.app_pocsag_tx.application_information"), used)) application_information_t _application_information_pocsag_tx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::pocsag_tx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "POCSG TX",
/*.bitmap_data = */ {
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0xFC,
0x3F,
0xFE,
0x7F,
0x02,
0x40,
0xBA,
0x45,
0x02,
0x40,
0xFE,
0x7F,
0xFE,
0x7F,
0x92,
0x7C,
0x92,
0x7C,
0xFC,
0x3F,
0x00,
0x00,
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_fsktx */ {'P', 'F', 'S', 'K'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
@@ -31,7 +31,7 @@
using namespace portapack;
using namespace pocsag;
namespace ui {
namespace ui::external_app::pocsag_tx {
#define MAX_POCSAG_LENGTH 80
@@ -159,7 +159,7 @@ void POCSAGTXView::on_set_text(NavigationView& nav) {
POCSAGTXView::POCSAGTXView(
NavigationView& nav)
: nav_(nav) {
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
add_children({&labels,
&options_bitrate,
@@ -205,4 +205,4 @@ POCSAGTXView::POCSAGTXView(
};
}
} /* namespace ui */
} /* namespace ui::external_app::pocsag_tx */
@@ -37,7 +37,7 @@
using namespace pocsag;
namespace ui {
namespace ui::external_app::pocsag_tx {
class POCSAGTXView : public View {
public:
@@ -155,6 +155,6 @@ class POCSAGTXView : public View {
}};
};
} /* namespace ui */
} /* namespace ui::external_app::pocsag_tx */
#endif /*__POCSAG_TX_H__*/
@@ -239,10 +239,10 @@ void RandomPasswordView::on_freqchg(int64_t freq) {
}
void RandomPasswordView::set_random_freq() {
std::srand(LPC_RTC->CTIME0);
srand(LPC_RTC->CTIME0);
// this is only for seed to visit random freq, the radio is still real random
auto random_freq = 100000000 + (std::rand() % 900000000); // 100mhz to 1ghz
auto random_freq = 100000000 + (rand() % 900000000); // 100mhz to 1ghz
receiver_model.set_target_frequency(random_freq);
field_frequency.set_value(random_freq);
}
@@ -297,12 +297,12 @@ void RandomPasswordView::new_password() {
/// roll worker
for (int i = 0; i < password_length * 2; i += 2) {
unsigned int seed = seeds_deque[i];
std::srand(seed);
srand(seed);
uint8_t rollnum = (uint8_t)(seeds_deque[i + 1] % 128);
uint8_t nu = 0;
for (uint8_t o = 0; o < rollnum; ++o) nu = std::rand();
for (uint8_t o = 0; o < rollnum; ++o) nu = rand();
nu++;
char c = charset[std::rand() % charset.length()];
char c = charset[rand() % charset.length()];
initial_password += c;
}
+104
View File
@@ -0,0 +1,104 @@
#include "baudot.hpp"
#include <cctype>
namespace ui::external_app::rtty_rx {
constexpr uint8_t CODE_FIGS = 0x1B;
constexpr uint8_t CODE_LTRS = 0x1F;
constexpr uint8_t CODE_SPACE = 0x04;
char BaudotCoder::get_char_mapping(bool is_figures, uint8_t index) const {
if (index >= 32) return 0; // Safety check
if (is_figures) {
// ITA2 FIGURES Table
const char figures[32] = {
0, '3', '\n', '-', ' ', '\'', '8', '7',
'\r', '$', '4', '\a', ',', '!', ':', '(',
'5', '+', ')', '2', '#', '6', '0', '1',
'9', '?', '&', 0, '.', '/', '=', 0};
return figures[index];
} else {
// ITA2 LETTERS Table
const char letters[32] = {
0, 'E', '\n', 'A', ' ', 'S', 'I', 'U',
'\r', 'D', 'R', 'J', 'N', 'F', 'C', 'K',
'T', 'Z', 'L', 'W', 'H', 'Y', 'P', 'Q',
'O', 'B', 'G', 0, 'M', 'X', 'V', 0};
return letters[index];
}
}
// --- DECODE ---
char BaudotCoder::decode(uint8_t baudotCode) {
uint8_t code = baudotCode & 0x1F;
if (code == CODE_FIGS) {
shiftState = FIGURES;
return 0;
}
if (code == CODE_LTRS) {
shiftState = LETTERS;
return 0;
}
if (usos_enabled && shiftState == FIGURES && code == CODE_SPACE) {
shiftState = LETTERS;
return ' ';
}
return get_char_mapping((shiftState == FIGURES), code);
}
void BaudotCoder::encode(const std::string& src, uint8_t* dest, uint16_t* dest_length, uint16_t dest_max_size) {
uint16_t idx = 0;
for (char c : src) {
if (idx >= dest_max_size) break;
char upper_c = std::toupper(c);
uint8_t code = 0;
bool found = false;
bool target_is_figures = false;
if (upper_c == ' ') {
code = CODE_SPACE;
found = true;
} else {
for (int i = 1; i < 32; i++) {
if (get_char_mapping(false, i) == upper_c) {
code = i;
found = true;
target_is_figures = false;
break;
}
}
if (!found) {
for (int i = 1; i < 32; i++) {
if (get_char_mapping(true, i) == upper_c) {
code = i;
found = true;
target_is_figures = true;
break;
}
}
}
}
if (found) {
if (target_is_figures && shiftState != FIGURES) {
if (idx + 1 >= dest_max_size) break;
dest[idx++] = CODE_FIGS;
shiftState = FIGURES;
} else if (!target_is_figures && shiftState != LETTERS && code != CODE_SPACE) {
if (idx + 1 >= dest_max_size) break;
dest[idx++] = CODE_LTRS;
shiftState = LETTERS;
}
dest[idx++] = code;
}
}
if (dest_length) {
*dest_length = idx;
}
}
} // namespace ui::external_app::rtty_rx
+28
View File
@@ -0,0 +1,28 @@
#ifndef BAUDOT_HPP
#define BAUDOT_HPP
#include <cstdint>
#include <string>
namespace ui::external_app::rtty_rx {
class BaudotCoder {
public:
enum ShiftState { LETTERS,
FIGURES };
BaudotCoder()
: shiftState(LETTERS) {}
char decode(uint8_t baudotCode);
void encode(const std::string& src, uint8_t* dest, uint16_t* dest_length, uint16_t dest_max_size);
void set_usos(bool enable) { usos_enabled = enable; } // shift == set to letters too
private:
ShiftState shiftState;
bool usos_enabled = true;
char get_char_mapping(bool is_figures, uint8_t index) const;
};
} // namespace ui::external_app::rtty_rx
#endif // BAUDOT_HPP
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2026 HTotoo
*
* 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_rtty_rx.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::rtty_rx {
void initialize_app(ui::NavigationView& nav) {
nav.push<RttyRxView>();
}
} // namespace ui::external_app::rtty_rx
extern "C" {
__attribute__((section(".external_app.app_rtty_rx.application_information"), used)) application_information_t _application_information_rtty_rx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::rtty_rx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "RTTY",
/*.bitmap_data = */ {
0x00,
0x00,
0xFE,
0x1F,
0xFE,
0x3F,
0x0E,
0x78,
0x0E,
0x70,
0x0E,
0x70,
0x0E,
0x70,
0x0E,
0x78,
0xFE,
0x3F,
0xFE,
0x1F,
0x8E,
0x07,
0x0E,
0x0F,
0x0E,
0x1E,
0x0E,
0x3C,
0x0E,
0x78,
0x00,
0x00,
},
/*.icon_color = */ ui::Color::orange().v,
/*.menu_location = */ app_location_t::RX,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_rttyrx */ {'P', 'R', 'T', 'R'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
+96
View File
@@ -0,0 +1,96 @@
/*
* Copyright (C) 2026 HTotoo
*
* 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_rtty_rx.hpp"
#include "audio.hpp"
#include "rtc_time.hpp"
#include "baseband_api.hpp"
#include "string_format.hpp"
#include "portapack_persistent_memory.hpp"
using namespace portapack;
using namespace ui;
// todo add timeout, so add newline and time when new data arrives after a time.
namespace ui::external_app::rtty_rx {
void RttyRxView::focus() {
field_frequency.focus();
}
RttyRxView::RttyRxView(NavigationView& nav)
: nav_{nav} {
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
add_children({
&rssi,
&field_rf_amp,
&field_lna,
&field_vga,
&field_volume,
&field_frequency,
&labels,
&options_baud,
&console,
});
field_frequency.set_step(100);
audio::set_rate(audio::Rate::Hz_24000);
audio::output::start();
receiver_model.set_hidden_offset(0);
receiver_model.set_sampling_rate(3072000); // set the needed baseband SR.
receiver_model.set_baseband_bandwidth(1750000); // set the front-end RF BW filter.
receiver_model.enable();
console.enable_scrolling(false);
options_baud.on_change = [this](size_t, int32_t value) {
baseband::set_rtty_config(value, 170);
baud_conf = value;
};
options_baud.set_by_value(baud_conf);
if (baud_conf == 0) { // to trigger it when not changed
baseband::set_rtty_config(0, 170);
}
}
void RttyRxView::got_message(std::string msg) {
console.write(msg);
}
RttyRxView::~RttyRxView() {
receiver_model.set_hidden_offset(0);
receiver_model.disable();
baseband::shutdown();
audio::output::stop();
}
void RttyRxView::on_data(const RTTYDataMessage* message) {
std::string msg = "";
for (size_t i = 0; i < message->data_len; i++) {
const auto c = baudot_decoder.decode(message->data[i]);
if (c != 0)
msg += c;
}
got_message(msg);
}
} // namespace ui::external_app::rtty_rx
+109
View File
@@ -0,0 +1,109 @@
/*
* Copyright (C) 2026 HTotoo
*
* 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_RTTY_RX_H__
#define __UI_RTTY_RX_H__
#include "ui.hpp"
#include "ui_language.hpp"
#include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "ui_freq_field.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "log_file.hpp"
#include "utility.hpp"
#include "ui_fileman.hpp"
#include "file_path.hpp"
#include "baudot.hpp"
using namespace ui;
namespace ui::external_app::rtty_rx {
class RttyRxView : public View {
public:
RttyRxView(NavigationView& nav);
~RttyRxView();
void focus() override;
std::string title() const override { return "RTTY"; };
private:
NavigationView& nav_;
RxRadioState radio_state_{};
uint32_t baud_conf = 0;
app_settings::SettingsManager settings_{
"rx_rtty",
app_settings::Mode::RX,
{
{"baud_conf"sv, &baud_conf},
}};
RxFrequencyField field_frequency{
{UI_POS_X(0), UI_POS_Y(0)},
nav_};
RFAmpField field_rf_amp{
{UI_POS_X(13), UI_POS_Y(0)}};
LNAGainField field_lna{
{UI_POS_X(15), UI_POS_Y(0)}};
VGAGainField field_vga{
{UI_POS_X(18), UI_POS_Y(0)}};
RSSI rssi{
{UI_POS_X(21), UI_POS_Y(0), UI_POS_WIDTH_REMAINING(24), 4}};
AudioVolumeField field_volume{{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
Labels labels{
{{UI_POS_X(0), UI_POS_Y(1)}, "Baud:", Theme::getInstance()->fg_light->foreground}};
OptionsField options_baud{
{UI_POS_X(7), UI_POS_Y(1)},
5,
{{"Auto", 0},
{"45", 4500},
{"45.45", 4545},
{"50", 5000},
{"75", 7500},
{"100", 10000},
{"110", 11000},
{"150", 15000},
{"200", 20000}}};
Console console{
{UI_POS_X(0), UI_POS_Y(2), UI_POS_MAXWIDTH, UI_POS_HEIGHT_REMAINING(3)}};
BaudotCoder baudot_decoder{};
void on_data(const RTTYDataMessage* message);
void got_message(std::string msg);
MessageHandlerRegistration message_handler_data{
Message::ID::RTTYData,
[this](Message* const p) {
const auto message = static_cast<const RTTYDataMessage*>(p);
this->on_data(message);
}};
};
} // namespace ui::external_app::rtty_rx
#endif /*__UI_RTTY_RX_H__*/
+104
View File
@@ -0,0 +1,104 @@
#include "baudot.hpp"
#include <cctype>
namespace ui::external_app::rtty_tx {
constexpr uint8_t CODE_FIGS = 0x1B;
constexpr uint8_t CODE_LTRS = 0x1F;
constexpr uint8_t CODE_SPACE = 0x04;
char BaudotCoder::get_char_mapping(bool is_figures, uint8_t index) const {
if (index >= 32) return 0; // Safety check
if (is_figures) {
// ITA2 FIGURES Table
const char figures[32] = {
0, '3', '\n', '-', ' ', '\'', '8', '7',
'\r', '$', '4', '\a', ',', '!', ':', '(',
'5', '+', ')', '2', '#', '6', '0', '1',
'9', '?', '&', 0, '.', '/', '=', 0};
return figures[index];
} else {
// ITA2 LETTERS Table
const char letters[32] = {
0, 'E', '\n', 'A', ' ', 'S', 'I', 'U',
'\r', 'D', 'R', 'J', 'N', 'F', 'C', 'K',
'T', 'Z', 'L', 'W', 'H', 'Y', 'P', 'Q',
'O', 'B', 'G', 0, 'M', 'X', 'V', 0};
return letters[index];
}
}
// --- DECODE ---
char BaudotCoder::decode(uint8_t baudotCode) {
uint8_t code = baudotCode & 0x1F;
if (code == CODE_FIGS) {
shiftState = FIGURES;
return 0;
}
if (code == CODE_LTRS) {
shiftState = LETTERS;
return 0;
}
if (usos_enabled && shiftState == FIGURES && code == CODE_SPACE) {
shiftState = LETTERS;
return ' ';
}
return get_char_mapping((shiftState == FIGURES), code);
}
void BaudotCoder::encode(const std::string& src, uint8_t* dest, uint16_t* dest_length, uint16_t dest_max_size) {
uint16_t idx = 0;
for (char c : src) {
if (idx >= dest_max_size) break;
char upper_c = std::toupper(c);
uint8_t code = 0;
bool found = false;
bool target_is_figures = false;
if (upper_c == ' ') {
code = CODE_SPACE;
found = true;
} else {
for (int i = 1; i < 32; i++) {
if (get_char_mapping(false, i) == upper_c) {
code = i;
found = true;
target_is_figures = false;
break;
}
}
if (!found) {
for (int i = 1; i < 32; i++) {
if (get_char_mapping(true, i) == upper_c) {
code = i;
found = true;
target_is_figures = true;
break;
}
}
}
}
if (found) {
if (target_is_figures && shiftState != FIGURES) {
if (idx + 1 >= dest_max_size) break;
dest[idx++] = CODE_FIGS;
shiftState = FIGURES;
} else if (!target_is_figures && shiftState != LETTERS && code != CODE_SPACE) {
if (idx + 1 >= dest_max_size) break;
dest[idx++] = CODE_LTRS;
shiftState = LETTERS;
}
dest[idx++] = code;
}
}
if (dest_length) {
*dest_length = idx;
}
}
} // namespace ui::external_app::rtty_tx
+28
View File
@@ -0,0 +1,28 @@
#ifndef BAUDOT_HPP
#define BAUDOT_HPP
#include <cstdint>
#include <string>
namespace ui::external_app::rtty_tx {
class BaudotCoder {
public:
enum ShiftState { LETTERS,
FIGURES };
BaudotCoder()
: shiftState(LETTERS) {}
char decode(uint8_t baudotCode);
void encode(const std::string& src, uint8_t* dest, uint16_t* dest_length, uint16_t dest_max_size);
void set_usos(bool enable) { usos_enabled = enable; } // shift == set to letters too
private:
ShiftState shiftState;
bool usos_enabled = true;
char get_char_mapping(bool is_figures, uint8_t index) const;
};
} // namespace ui::external_app::rtty_tx
#endif // BAUDOT_HPP
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2026 HTotoo
*
* 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_rtty_tx.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::rtty_tx {
void initialize_app(ui::NavigationView& nav) {
nav.push<RttyTxView>();
}
} // namespace ui::external_app::rtty_tx
extern "C" {
__attribute__((section(".external_app.app_rtty_tx.application_information"), used)) application_information_t _application_information_rtty_tx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::rtty_tx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "RTTY",
/*.bitmap_data = */ {
0x00,
0x00,
0xFE,
0x1F,
0xFE,
0x3F,
0x0E,
0x78,
0x0E,
0x70,
0x0E,
0x70,
0x0E,
0x70,
0x0E,
0x78,
0xFE,
0x3F,
0xFE,
0x1F,
0x8E,
0x07,
0x0E,
0x0F,
0x0E,
0x1E,
0x0E,
0x3C,
0x0E,
0x78,
0x00,
0x00,
},
/*.icon_color = */ ui::Color::orange().v,
/*.menu_location = */ app_location_t::TX,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_rttytx */ {'P', 'R', 'T', 'T'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
+154
View File
@@ -0,0 +1,154 @@
/*
* Copyright (C) 2026 HTotoo
*
* 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_rtty_tx.hpp"
#include "audio.hpp"
#include "rtc_time.hpp"
#include "baseband_api.hpp"
#include "string_format.hpp"
#include "portapack_persistent_memory.hpp"
using namespace portapack;
using namespace ui;
namespace ui::external_app::rtty_tx {
void RttyTxView::focus() {
options_baud.focus();
}
RttyTxView::RttyTxView(NavigationView& nav)
: nav_{nav} {
add_children({&tx_view,
&labels,
&options_baud,
&options_shift,
&btn_message,
&text_message,
&check_inverted,
&options_tone,
&text_tones});
options_baud.on_change = [this](size_t, int32_t value) {
baud_conf = value;
};
options_baud.set_by_value(baud_conf);
options_shift.on_change = [this](size_t, int32_t value) {
shift = value;
refresh_tones();
};
options_shift.set_by_value(shift);
btn_message.on_select = [this](Button&) {
text_prompt(nav_, message, 64, ENTER_KEYBOARD_MODE_ALPHA, [this](std::string& new_message) {
message = new_message;
text_message.set(message); // maybe replace to console
});
};
text_message.set(message);
options_tone.set_by_value(mark_tone);
options_tone.on_change = [this](size_t, int32_t value) {
mark_tone = value;
refresh_tones();
};
check_inverted.on_select = [this](Checkbox&, bool) {
refresh_tones();
};
tx_view.on_edit_frequency = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.target_frequency());
new_view->on_changed = [this](rf::Frequency f) {
transmitter_model.set_target_frequency(f);
};
};
tx_view.on_start = [this]() {
if (message.empty()) {
nav_.display_modal("Error", "Message is empty. Please set a message to transmit.");
return;
}
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
transmitter_model.set_baseband_bandwidth(2048000);
baseband::set_sample_rate(2048000, OversampleRate::None);
transmitter_model.set_sampling_rate(2048000);
transmitter_model.set_baseband_bandwidth(2048000);
transmitter_model.enable();
rtty_message.baud = baud_conf;
rtty_message.shift = shift;
rtty_message.inverted = false; // check_inverted.value(); //i already invert it with the mark and space calculation
rtty_message.mark_tone = mark;
rtty_message.space_tone = space;
rtty_message.stopbits = stop_bits;
baudot_encoder.set_usos(false); // to be compatible with all
baudot_encoder.encode(message, rtty_message.data, &rtty_message.data_len, rtty_message.max_len);
baseband::set_rtty_config(rtty_message);
tx_view.set_transmitting(true);
};
tx_view.on_stop = [this]() {
stop();
};
refresh_tones();
}
void RttyTxView::refresh_tones() {
std::string tones_str = "";
int16_t shift = options_shift.selected_index_value();
if (mark_tone == -32000) {
mark = -shift / 2;
space = shift / 2;
} else {
if (mark_tone < 0) {
space = -(shift + abs(mark_tone));
} else {
space = shift + mark_tone;
}
mark = mark_tone;
}
if (check_inverted.value()) {
int16_t tmp = mark;
mark = space;
space = tmp;
}
tones_str = "Mark:" + to_string_dec_int(mark) + " Hz, Space:" + to_string_dec_int(space) + " Hz";
text_tones.set(tones_str);
}
void RttyTxView::on_tx_progress(bool done) {
if (done) stop();
}
void RttyTxView::stop() {
tx_view.set_transmitting(false);
transmitter_model.disable();
baseband::shutdown();
}
RttyTxView::~RttyTxView() {
stop();
}
} // namespace ui::external_app::rtty_tx
+145
View File
@@ -0,0 +1,145 @@
/*
* Copyright (C) 2026 HTotoo
*
* 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_RTTY_TX_H__
#define __UI_RTTY_TX_H__
#include "ui.hpp"
#include "ui_language.hpp"
#include "ui_navigation.hpp"
#include "ui_transmitter.hpp"
#include "ui_freq_field.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "log_file.hpp"
#include "utility.hpp"
#include "ui_fileman.hpp"
#include "file_path.hpp"
#include "baudot.hpp"
using namespace ui;
namespace ui::external_app::rtty_tx {
class RttyTxView : public View {
public:
RttyTxView(NavigationView& nav);
~RttyTxView();
void focus() override;
std::string title() const override { return "RTTY"; };
private:
void on_tx_progress(bool done);
void stop();
void refresh_tones();
NavigationView& nav_;
RxRadioState radio_state_{};
uint32_t baud_conf = 4545; // default to 45.45 baud, which is common for RTTY.
uint32_t shift = 170; // 170 hz
std::string message = "PORTAPACK";
int32_t mark_tone = 0; // for option
int16_t mark = 0, space = 170;
uint8_t stop_bits = 3; // 2=1.0, 3=1.5, 4=2.0
app_settings::SettingsManager settings_{
"tx_rtty",
app_settings::Mode::TX,
{
{"baud_conf"sv, &baud_conf},
{"shift"sv, &shift},
{"message"sv, &message},
{"mark_tone"sv, &mark_tone},
}};
Labels labels{
{{UI_POS_X(0), UI_POS_Y(0)}, "Baud:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(14), UI_POS_Y(0)}, "Shift:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(15), UI_POS_Y(1)}, "Mark t:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(3)}, "Message:", Theme::getInstance()->fg_light->foreground}};
OptionsField options_baud{
{UI_POS_X(7), UI_POS_Y(0)},
5,
{{"45", 4500},
{"45.45", 4545},
{"50", 5000},
{"75", 7500},
{"100", 10000},
{"110", 11000},
{"150", 15000},
{"200", 20000}}};
OptionsField options_shift{
{UI_POS_X(21), UI_POS_Y(0)},
5,
{{"170", 170},
{"85", 85},
{"200", 200},
{"450", 450},
{"850", 850}}};
Checkbox check_inverted{
{UI_POS_X(0), UI_POS_Y(1)},
10,
"Inverted",
true};
OptionsField options_tone{
{UI_POS_X(25), UI_POS_Y(1)},
5,
{{"CNT", -32000},
{"0", 0},
{"2125", 2125},
{"-2125", -2125},
{"1275", 1275},
{"-1275", -1275}}};
Text text_tones{
{UI_POS_X(0), UI_POS_Y(2), UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)},
"-"};
Button btn_message{
{UI_POS_X(0), UI_POS_Y(3), UI_POS_WIDTH(15), UI_POS_HEIGHT(2)},
"Set message"};
Text text_message{
{UI_POS_X(0), UI_POS_Y(5), UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)},
""};
TransmitterView tx_view{
(int16_t)UI_POS_Y_BOTTOM(4),
1000,
0};
RTTYDataMessage rtty_message{};
BaudotCoder baudot_encoder{};
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.done);
}};
};
} // namespace ui::external_app::rtty_tx
#endif /*__UI_RTTY_TX_H__*/
+79
View File
@@ -0,0 +1,79 @@
/*
* SAME TX - Specific Area Message Encoding Transmitter
*
* 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.
*/
#include "ui.hpp"
#include "ui_same_tx.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::same_tx {
void initialize_app(ui::NavigationView& nav) {
nav.push<SameTxView>();
}
} // namespace ui::external_app::same_tx
extern "C" {
__attribute__((section(".external_app.app_same_tx.application_information"), used)) application_information_t _application_information_same_tx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::same_tx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "SAME TX",
/*.bitmap_data = */ {
// 16x16 icon - simple "!" alert symbol
0x00,
0x00,
0x18,
0x00,
0x3C,
0x00,
0x3C,
0x00,
0x3C,
0x00,
0x3C,
0x00,
0x18,
0x00,
0x18,
0x00,
0x00,
0x00,
0x18,
0x00,
0x3C,
0x00,
0x3C,
0x00,
0x18,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
},
/*.icon_color = */ ui::Color::orange().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,
};
}
+239
View File
@@ -0,0 +1,239 @@
/*
* Copyright (C) 2024 HTotoo
*
* 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_same_tx.hpp"
#include "theme.hpp"
#include "baseband_api.hpp"
#include "portapack.hpp"
#include "portapack_shared_memory.hpp"
#include "transmitter_model.hpp"
using namespace portapack;
namespace ui::external_app::same_tx {
static constexpr uint32_t SAME_SAMPLES_PER_BIT = 2949;
static constexpr uint32_t SAME_MARK_FREQ = 2083;
static constexpr uint32_t SAME_SPACE_FREQ = 1563;
static constexpr uint32_t SAME_FM_DEVIATION = 5000;
static constexpr uint8_t SAME_REPEAT = 3;
static constexpr char SAME_ORG_CODES[][4] = {"WXR", "EAS", "CIV", "PEP"};
static constexpr char SAME_EVT_CODES[][4] = {
"RWT",
"RMT",
"NPT",
"NST",
"NMT",
"EAN",
"EAT",
"NIC",
"ADR",
"AVA",
"AVW",
"BZW",
"CFW",
"CFS",
"DSW",
"EQW",
"EVI",
"FFW",
"FFS",
"FFH",
"FRW",
"HLS",
"HUW",
"HUH",
"SVR",
"TOR",
};
static uint8_t bitrev8(uint8_t b) {
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
return b;
}
static void fmt2d(char* buf, int v) {
buf[0] = '0' + v / 10;
buf[1] = '0' + v % 10;
}
static void fmt3d(char* buf, int v) {
buf[0] = '0' + v / 100;
buf[1] = '0' + (v / 10) % 10;
buf[2] = '0' + v % 10;
}
void SameTxView::update_msg_preview() {
const char* org = SAME_ORG_CODES[field_org.selected_index()];
const char* evt = SAME_EVT_CODES[field_event_idx.value()];
int ss = field_fips_state.value();
int ccc = field_fips_county.value();
int dh = field_dur_h.value();
int dm = field_dur_m.value();
char buf[48];
char* p = buf;
// "WXR-RWT-SS0CCC+HHmm" (preview, no ZCZC header)
for (const char* s = org; *s; s++) *p++ = *s;
*p++ = '-';
for (const char* s = evt; *s; s++) *p++ = *s;
*p++ = '-';
fmt2d(p, ss);
p += 2;
*p++ = '0';
fmt3d(p, ccc);
p += 3;
*p++ = '+';
fmt2d(p, dh);
p += 2;
fmt2d(p, dm);
p += 2;
*p = '\0';
text_msg.set(buf);
}
void SameTxView::start_tx() {
const char* org = SAME_ORG_CODES[field_org.selected_index()];
const char* evt = SAME_EVT_CODES[field_event_idx.value()];
int ss = field_fips_state.value();
int ccc = field_fips_county.value();
int dh = field_dur_h.value();
int dm = field_dur_m.value();
// Build full SAME message: "ZCZC-ORG-EVT-SS0CCC+HHMM-0010000-STATION-"
char msg[64];
char* p = msg;
const char* hdr = "ZCZC-";
for (const char* s = hdr; *s; s++) *p++ = *s;
for (const char* s = org; *s; s++) *p++ = *s;
*p++ = '-';
for (const char* s = evt; *s; s++) *p++ = *s;
*p++ = '-';
fmt2d(p, ss);
p += 2;
*p++ = '0';
fmt3d(p, ccc);
p += 3;
*p++ = '+';
fmt2d(p, dh);
p += 2;
fmt2d(p, dm);
p += 2;
*p++ = '-';
// Issue time: fixed 0010000 (placeholder), station: SAME-TX
const char* tail = "0010000-SAMETX--";
for (const char* s = tail; *s; s++) *p++ = *s;
*p = '\0';
auto* words = reinterpret_cast<uint16_t*>(shared_memory.bb_data.data);
size_t idx = 0;
for (uint8_t i = 0; i < 16; i++)
words[idx++] = bitrev8(0xAB);
for (const char* c = msg; *c; c++)
words[idx++] = bitrev8(static_cast<uint8_t>(*c));
words[idx] = 0;
tx_active_ = true;
text_status.set("Transmitting...");
transmitter_model.enable();
baseband::set_afsk_data(
SAME_SAMPLES_PER_BIT,
SAME_MARK_FREQ,
SAME_SPACE_FREQ,
SAME_REPEAT,
SAME_FM_DEVIATION,
8);
}
void SameTxView::stop_tx() {
baseband::kill_afsk();
transmitter_model.disable();
tx_active_ = false;
text_status.set("Ready");
tx_view.set_transmitting(false);
}
void SameTxView::on_tx_progress(const uint32_t progress, const bool done) {
if (done) {
stop_tx();
text_status.set("Done!");
} else {
(void)progress;
text_status.set("TX...");
}
}
void SameTxView::focus() {
field_org.focus();
}
SameTxView::SameTxView(NavigationView& nav)
: nav_{nav} {
baseband::run_image(portapack::spi_flash::image_tag_afsk);
add_children({
&labels,
&field_org,
&field_event_idx,
&text_evt,
&field_fips_state,
&field_fips_county,
&field_dur_h,
&field_dur_m,
&text_msg,
&text_status,
&tx_view,
});
// Defaults: Ohio, county 007 (Ashtabula), 30 min
field_fips_state.set_value(39);
field_fips_county.set_value(7);
field_dur_h.set_value(0);
field_dur_m.set_value(30);
auto refresh = [this](int32_t) {
text_evt.set(SAME_EVT_CODES[field_event_idx.value()]);
update_msg_preview();
};
field_event_idx.on_change = refresh;
field_org.on_change = [this](size_t, int32_t) { update_msg_preview(); };
field_fips_state.on_change = [this](int32_t) { update_msg_preview(); };
field_fips_county.on_change = [this](int32_t) { update_msg_preview(); };
field_dur_h.on_change = [this](int32_t) { update_msg_preview(); };
field_dur_m.on_change = [this](int32_t) { update_msg_preview(); };
update_msg_preview();
tx_view.on_start = [this]() {
if (!tx_active_) {
start_tx();
tx_view.set_transmitting(true);
}
};
tx_view.on_stop = [this]() { stop_tx(); };
}
SameTxView::~SameTxView() {
transmitter_model.disable();
baseband::shutdown();
}
} // namespace ui::external_app::same_tx
+84
View File
@@ -0,0 +1,84 @@
#ifndef __UI_SAME_TX_H__
#define __UI_SAME_TX_H__
/*
* Copyright (C) 2024 HTotoo
*
* 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_widget.hpp"
#include "ui_navigation.hpp"
#include "ui_transmitter.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "message.hpp"
#include "modems.hpp"
namespace ui::external_app::same_tx {
class SameTxView : public View {
public:
SameTxView(NavigationView& nav);
~SameTxView();
SameTxView(const SameTxView&) = delete;
SameTxView& operator=(const SameTxView&) = delete;
void focus() override;
std::string title() const override { return "SAME TX"; }
private:
NavigationView& nav_;
bool tx_active_{false};
void start_tx();
void stop_tx();
void on_tx_progress(const uint32_t progress, const bool done);
void update_msg_preview();
TxRadioState radio_state_{162550000, 1750000, AFSK_TX_SAMPLERATE};
app_settings::SettingsManager settings_{"tx_same", app_settings::Mode::TX};
Labels labels{{
{{0 * 8, 0 * 16}, "Org:", ui::Theme::getInstance()->fg_light->foreground},
{{8 * 8, 0 * 16}, "Evt:", ui::Theme::getInstance()->fg_light->foreground},
{{0 * 8, 1 * 16}, "FIPS:", ui::Theme::getInstance()->fg_light->foreground},
{{16 * 8, 1 * 16}, "Dur:", ui::Theme::getInstance()->fg_light->foreground},
}};
OptionsField field_org{
{4 * 8, 0 * 16},
3,
{{"WXR", 0}, {"EAS", 1}, {"CIV", 2}, {"PEP", 3}}};
NumberField field_event_idx{{12 * 8, 0 * 16}, 2, {0, 25}, 1, '0', true};
Text text_evt{{15 * 8, 0 * 16, 3 * 8, 16}, "RWT"};
NumberField field_fips_state{{5 * 8, 1 * 16}, 2, {0, 99}, 1, '0'};
NumberField field_fips_county{{7 * 8 + 4, 1 * 16}, 3, {0, 999}, 1, '0'};
NumberField field_dur_h{{20 * 8, 1 * 16}, 2, {0, 99}, 1, '0'};
NumberField field_dur_m{{22 * 8, 1 * 16}, 2, {0, 59}, 1, '0'};
Text text_msg{{0, 2 * 16, 240, 16}, ""};
Text text_status{{0, 3 * 16, 240, 16}, "Ready"};
TransmitterView tx_view{(int16_t)UI_POS_Y_BOTTOM(4), 1000, 0};
MessageHandlerRegistration message_handler_tx_progress{
Message::ID::TXProgress,
[this](const Message* const p) {
const auto msg = *reinterpret_cast<const TXProgressMessage*>(p);
this->on_tx_progress(msg.progress, msg.done);
}};
};
} // namespace ui::external_app::same_tx
#endif
+1
View File
@@ -461,6 +461,7 @@ ScannerView::ScannerView(
else
v = WFM_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;
receiver_model.disable();
+4 -1
View File
@@ -36,8 +36,11 @@ WipeSDView::WipeSDView(NavigationView& nav)
}
WipeSDView::~WipeSDView() {
if (thread)
if (thread) {
chThdTerminate(thread);
chThdWait(thread);
thread = nullptr;
}
}
void WipeSDView::focus() {
+1 -1
View File
@@ -221,7 +221,7 @@ void SnakeView::paint(Painter& painter) {
(void)painter;
if (!initialized) {
initialized = true;
std::srand(LPC_RTC->CTIME0);
srand(LPC_RTC->CTIME0);
init_game();
}
}
+1 -1
View File
@@ -605,7 +605,7 @@ void pause_game() {
}
int main() {
std::srand(GenerateRandomSeed());
srand(GenerateRandomSeed());
Init();
ShowLevelMenu();
joystick.attach(&ReadJoystickForLevel, 0.3);
+82
View File
@@ -0,0 +1,82 @@
/*
* Copyright (C) 2025 Bernd Herzog
*
* 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_time_sink.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::time_sink {
void initialize_app(ui::NavigationView& nav) {
nav.push<TimeSinkView>();
}
} // namespace ui::external_app::time_sink
extern "C" {
__attribute__((section(".external_app.app_time_sink.application_information"), used)) application_information_t _application_information_time_sink = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::time_sink::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "Time Sink",
/*.bitmap_data = */ {
0x18,
0x00,
0x24,
0x00,
0x42,
0x00,
0x42,
0x00,
0x42,
0x00,
0x42,
0x00,
0x81,
0x00,
0xAB,
0x6A,
0x80,
0x40,
0x00,
0x21,
0x00,
0x21,
0x00,
0x21,
0x00,
0x21,
0x00,
0x12,
0x00,
0x0C,
0x00,
0x00,
},
/*.icon_color = */ ui::Color::cyan().v,
/*.menu_location = */ app_location_t::RX,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_none */ {'P', 'T', 'S', 'K'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
+352
View File
@@ -0,0 +1,352 @@
/*
* Copyleft zxkmm (>) 2026
*
* 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_time_sink.hpp"
#include "baseband_api.hpp"
#include "portapack.hpp"
#include "ui_spectrum.hpp"
#include <algorithm>
using namespace portapack;
namespace ui::external_app::time_sink {
TimeSinkWaveformWidget::TimeSinkWaveformWidget(
Rect parent_rect,
const int16_t* data,
size_t length,
Color color)
: Widget{parent_rect},
data_{data},
length_{length},
color_{color} {
reset_cache();
}
void TimeSinkWaveformWidget::set_parent_rect(const Rect new_parent_rect) {
Widget::set_parent_rect(new_parent_rect);
reset_cache();
}
void TimeSinkWaveformWidget::on_show() {
reset_cache();
set_dirty();
}
void TimeSinkWaveformWidget::reset_cache() {
history_count_ = 0;
history_head_ = 0;
needs_clear_ = true;
}
void TimeSinkWaveformWidget::set_persistence_frames(uint8_t frames) {
const auto clamped = static_cast<uint8_t>(std::clamp<size_t>(
frames,
1,
max_persistence_frames));
if (clamped != persistence_frames_) {
persistence_frames_ = clamped;
reset_cache();
set_dirty();
}
}
Coord TimeSinkWaveformWidget::sample_to_y(const Rect& r, int16_t sample) const {
const int32_t y_center = r.top() + (r.height() / 2);
const int32_t y_span = std::max<int32_t>(1, r.height() - 1);
const int32_t y = y_center - (static_cast<int32_t>(sample) * y_span) / 65536;
return static_cast<Coord>(std::clamp<int32_t>(y, r.top(), r.bottom() - 1));
}
void TimeSinkWaveformWidget::paint(Painter& painter) {
const auto r = screen_rect();
const auto background = Theme::getInstance()->bg_darkest->background;
if (!r || !data_ || !length_) {
if (needs_clear_) {
painter.fill_rectangle_unrolled8(r, background);
needs_clear_ = false;
}
history_count_ = 0;
history_head_ = 0;
return;
}
const size_t columns = std::min<size_t>({
length_,
max_columns,
static_cast<size_t>(r.width()),
});
if (!columns) {
history_count_ = 0;
history_head_ = 0;
return;
}
if (needs_clear_) {
painter.fill_rectangle_unrolled8(r, background);
needs_clear_ = false;
history_count_ = 0;
history_head_ = 0;
}
for (size_t x = 0; x < columns; ++x) {
const size_t src_index = (x * length_) / columns;
current_y_[x] = sample_to_y(r, data_[src_index]);
}
// Draw first, then erase stale pixels so the trace never disappears mid-refresh.
for (size_t x = 0; x < columns; ++x) {
display.draw_pixel(
{static_cast<Coord>(r.left() + x), current_y_[x]},
color_);
}
if (history_count_ >= persistence_frames_) {
const size_t expired_slot = history_head_;
for (size_t x = 0; x < columns; ++x) {
const auto expired_y = history_y_[expired_slot][x];
bool keep = (expired_y == current_y_[x]);
if (!keep) {
for (size_t i = 1; i < history_count_; ++i) {
const size_t slot = (history_head_ + i) % max_persistence_frames;
if (history_y_[slot][x] == expired_y) {
keep = true;
break;
}
}
}
if (!keep) {
display.draw_pixel(
{static_cast<Coord>(r.left() + x), expired_y},
background);
}
}
history_head_ = (history_head_ + 1) % max_persistence_frames;
--history_count_;
}
const size_t tail_slot = (history_head_ + history_count_) % max_persistence_frames;
std::copy_n(current_y_.begin(), columns, history_y_[tail_slot].begin());
++history_count_;
}
TimeSinkView::TimeSinkView(NavigationView& nav)
: nav_(nav) {
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
add_children({
&labels,
&field_frequency,
&field_frequency_step,
&field_rf_amp,
&field_lna,
&field_vga,
&options_sample_rate,
&field_trigger,
&options_persistence,
&options_trigger_mode,
&field_trigger_level,
&waveform,
});
field_frequency_step.set_by_value(receiver_model.frequency_step());
field_frequency_step.on_change = [this](size_t, OptionsField::value_t v) {
receiver_model.set_frequency_step(v);
field_frequency.set_step(v);
};
options_sample_rate.set_by_nearest_value(sampling_rate);
sampling_rate = options_sample_rate.selected_index_value();
options_sample_rate.on_change = [this](size_t, OptionsField::value_t v) {
sampling_rate = v;
apply_spectrum_config();
};
field_trigger.set_value(trigger);
field_trigger.on_change = [this](int32_t v) {
trigger = static_cast<uint8_t>(v);
apply_spectrum_config();
};
options_persistence.set_by_nearest_value(persistence_frames);
persistence_frames = options_persistence.selected_index_value();
waveform.set_persistence_frames(persistence_frames);
options_persistence.on_change = [this](size_t, OptionsField::value_t v) {
persistence_frames = static_cast<uint8_t>(v);
waveform.set_persistence_frames(persistence_frames);
};
options_trigger_mode.set_by_nearest_value(trigger_mode);
trigger_mode = static_cast<uint8_t>(options_trigger_mode.selected_index_value());
options_trigger_mode.on_change = [this](size_t, OptionsField::value_t v) {
trigger_mode = static_cast<uint8_t>(v);
trigger_lock_valid = false;
};
field_trigger_level.set_value(trigger_level);
field_trigger_level.on_change = [this](int32_t v) {
trigger_level = v;
trigger_lock_valid = false;
};
receiver_model.set_squelch_level(0);
receiver_model.enable();
apply_spectrum_config();
}
TimeSinkView::~TimeSinkView() {
receiver_model.disable();
baseband::shutdown();
}
void TimeSinkView::focus() {
field_frequency.focus();
}
void TimeSinkView::on_show() {
baseband::spectrum_streaming_start();
}
void TimeSinkView::on_hide() {
baseband::spectrum_streaming_stop();
}
void TimeSinkView::set_parent_rect(const Rect new_parent_rect) {
View::set_parent_rect(new_parent_rect);
waveform.set_parent_rect({0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height});
}
void TimeSinkView::apply_spectrum_config() {
receiver_model.set_sampling_rate(sampling_rate);
receiver_model.set_baseband_bandwidth(filter_bandwidth_for_sampling_rate(sampling_rate));
baseband::set_time_sink(
sampling_rate,
trigger);
}
size_t TimeSinkView::find_stable_trigger_index(const ChannelSpectrum& spectrum) {
if (spectrum.db.size() < 2) {
return 0;
}
TriggerMode mode = TriggerMode::Rising;
switch (trigger_mode) {
case static_cast<uint8_t>(TriggerMode::Off):
mode = TriggerMode::Off;
break;
case static_cast<uint8_t>(TriggerMode::Rising):
mode = TriggerMode::Rising;
break;
case static_cast<uint8_t>(TriggerMode::Falling):
mode = TriggerMode::Falling;
break;
default:
break;
}
if (mode == TriggerMode::Off) {
trigger_lock_valid = false;
return 0;
}
constexpr int32_t hysteresis = 2;
const int32_t threshold = std::clamp<int32_t>(
128 + trigger_level,
hysteresis,
255 - hysteresis);
const size_t center = spectrum.db.size() / 2;
const size_t reference_index = trigger_lock_valid ? trigger_lock_index : center;
bool found = false;
size_t best_index = 0;
size_t best_distance = spectrum.db.size();
const auto circular_distance = [count = spectrum.db.size()](size_t a, size_t b) -> size_t {
const size_t linear =
(a > b) ? (a - b) : (b - a);
return std::min(linear, count - linear);
};
for (size_t i = 1; i < spectrum.db.size(); ++i) {
const int32_t prev = spectrum.db[i - 1];
const int32_t curr = spectrum.db[i];
bool crossing = false;
if (mode == TriggerMode::Rising) {
crossing =
(prev <= (threshold - hysteresis)) &&
(curr >= (threshold + hysteresis));
} else {
crossing =
(prev >= (threshold + hysteresis)) &&
(curr <= (threshold - hysteresis));
}
if (!crossing) {
continue;
}
const size_t distance = circular_distance(i, reference_index);
if (!found || (distance < best_distance)) {
found = true;
best_index = i;
best_distance = distance;
}
}
if (found) {
trigger_lock_index = best_index;
trigger_lock_valid = true;
return best_index;
}
return trigger_lock_valid ? trigger_lock_index : 0;
}
void TimeSinkView::on_channel_spectrum(const ChannelSpectrum& spectrum) {
const size_t trigger_index = find_stable_trigger_index(spectrum);
const size_t source_count = spectrum.db.size();
const size_t window_size = source_count;
for (size_t x = 0; x < waveform_points; x++) {
const size_t offset = (x * window_size) / waveform_points;
const size_t src_index =
(trigger_index + offset) % source_count;
const int32_t centered = static_cast<int32_t>(spectrum.db[src_index]) - 128;
const int32_t scaled = centered * 256;
waveform_buffer[x] = static_cast<int16_t>(std::clamp<int32_t>(scaled, -32768, 32767));
}
waveform.set_dirty();
}
void TimeSinkView::on_freqchg(int64_t freq) {
field_frequency.set_value(freq);
}
} // namespace ui::external_app::time_sink
+238
View File
@@ -0,0 +1,238 @@
/*
* Copyleft zxkmm (>) 2026
*
* 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_TIME_SINK_APP_H__
#define __UI_TIME_SINK_APP_H__
#include "app_settings.hpp"
#include "baseband_api.hpp"
#include "message.hpp"
#include "radio_state.hpp"
#include "ui.hpp"
#include "ui_freq_field.hpp"
#include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "ui_widget.hpp"
#include <array>
namespace ui::external_app::time_sink {
constexpr size_t time_sink_waveform_points = 240;
class TimeSinkWaveformWidget : public Widget {
public:
TimeSinkWaveformWidget(Rect parent_rect, const int16_t* data, size_t length, Color color);
TimeSinkWaveformWidget(const TimeSinkWaveformWidget&) = delete;
TimeSinkWaveformWidget(TimeSinkWaveformWidget&&) = delete;
TimeSinkWaveformWidget& operator=(const TimeSinkWaveformWidget&) = delete;
TimeSinkWaveformWidget& operator=(TimeSinkWaveformWidget&&) = delete;
void set_parent_rect(const Rect new_parent_rect) override;
void on_show() override;
void paint(Painter& painter) override;
void set_persistence_frames(uint8_t frames);
private:
static constexpr size_t max_columns = time_sink_waveform_points;
static constexpr size_t max_persistence_frames = 16; // this is sad that we cant have 32 histories in ext app due to memory constraints
void reset_cache();
Coord sample_to_y(const Rect& r, int16_t sample) const;
const int16_t* data_;
size_t length_;
Color color_;
std::array<Coord, max_columns> current_y_{};
std::array<std::array<Coord, max_columns>, max_persistence_frames> history_y_{};
size_t history_count_{0};
size_t history_head_{0};
uint8_t persistence_frames_{1};
bool needs_clear_{true};
};
class TimeSinkView : public View {
public:
TimeSinkView(NavigationView& nav);
~TimeSinkView();
TimeSinkView(const TimeSinkView&) = delete;
TimeSinkView(TimeSinkView&&) = delete;
TimeSinkView& operator=(const TimeSinkView&) = delete;
TimeSinkView& operator=(TimeSinkView&&) = delete;
std::string title() const override { return "Time Sink"; };
void focus() override;
void on_show() override;
void on_hide() override;
void set_parent_rect(const Rect new_parent_rect) override;
private:
enum class TriggerMode : uint8_t {
Off = 0,
Rising = 1,
Falling = 2,
};
static constexpr Dim header_height = 3 * 16;
static constexpr size_t waveform_points = time_sink_waveform_points;
NavigationView& nav_;
RxRadioState radio_state_{
433'920'000,
1'750'000,
2'000'000,
ReceiverModel::Mode::SpectrumAnalysis};
uint32_t sampling_rate{2'000'000};
uint8_t trigger{0};
uint8_t persistence_frames{1};
uint8_t trigger_mode{static_cast<uint8_t>(TriggerMode::Rising)};
int32_t trigger_level{0};
size_t trigger_lock_index{0};
bool trigger_lock_valid{false};
app_settings::SettingsManager settings_{
"rx_time_sink"sv,
app_settings::Mode::RX,
{
{"sampling_rate"sv, &sampling_rate},
{"trigger"sv, &trigger},
{"persistence_frames"sv, &persistence_frames},
{"trigger_mode"sv, &trigger_mode},
{"trigger_level"sv, &trigger_level},
}};
int16_t waveform_buffer[waveform_points]{0};
ChannelSpectrumFIFO* fifo = nullptr;
Labels labels{
{{UI_POS_X(0), UI_POS_Y(1)}, "SR:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(11), UI_POS_Y(1)}, "DEC:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(0), UI_POS_Y(2)}, "PST:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(9), UI_POS_Y(2)}, "TRM:", Theme::getInstance()->fg_light->foreground},
{{UI_POS_X(19), UI_POS_Y(2)}, "LVL:", Theme::getInstance()->fg_light->foreground},
};
RxFrequencyField field_frequency{
{UI_POS_X(0), UI_POS_Y(0)},
nav_};
FrequencyStepView field_frequency_step{
{10 * 8, UI_POS_Y(0)}};
RFAmpField field_rf_amp{
{16 * 8, UI_POS_Y(0)}};
LNAGainField field_lna{
{18 * 8, UI_POS_Y(0)}};
VGAGainField field_vga{
{21 * 8, UI_POS_Y(0)}};
OptionsField options_sample_rate{
{UI_POS_X(3), UI_POS_Y(1)},
6,
{
{"1.0M ", 1'000'000},
{"2.0M ", 2'000'000},
{"5.0M ", 5'000'000},
{"10.0M ", 10'000'000},
{"20.0M ", 20'000'000},
}};
NumberField field_trigger{
{UI_POS_X(17), UI_POS_Y(1)},
3,
{0, 128},
1,
' '};
OptionsField options_persistence{
{UI_POS_X(3), UI_POS_Y(2)},
3,
{
{"1 ", 1},
{"2 ", 2},
{"4 ", 4},
{"8 ", 8},
{"16 ", 16},
}};
OptionsField options_trigger_mode{
{UI_POS_X(13), UI_POS_Y(2)},
4,
{
{"Off ", static_cast<int32_t>(TriggerMode::Off)},
{"Rise", static_cast<int32_t>(TriggerMode::Rising)},
{"Fall", static_cast<int32_t>(TriggerMode::Falling)},
}};
NumberField field_trigger_level{
{UI_POS_X(23), UI_POS_Y(2)},
4,
{-127, 127},
1,
' '};
TimeSinkWaveformWidget waveform{
{0, header_height, screen_width, screen_height - header_height},
waveform_buffer,
waveform_points,
Theme::getInstance()->fg_light->foreground};
MessageHandlerRegistration message_handler_spectrum_config{
Message::ID::ChannelSpectrumConfig,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const ChannelSpectrumConfigMessage*>(p);
this->fifo = message.fifo;
}};
MessageHandlerRegistration message_handler_frame_sync{
Message::ID::DisplayFrameSync,
[this](const Message* const) {
if (this->fifo) {
ChannelSpectrum spectrum{};
bool has_spectrum = false;
while (fifo->out(spectrum)) {
has_spectrum = true;
}
if (has_spectrum) {
this->on_channel_spectrum(spectrum);
}
}
}};
MessageHandlerRegistration message_handler_freqchg{
Message::ID::FreqChangeCommand,
[this](Message* const p) {
const auto message = static_cast<const FreqChangeCommandMessage*>(p);
this->on_freqchg(message->freq);
}};
void apply_spectrum_config();
size_t find_stable_trigger_index(const ChannelSpectrum& spectrum);
void on_channel_spectrum(const ChannelSpectrum& spectrum);
void on_freqchg(int64_t freq);
};
} // namespace ui::external_app::time_sink
#endif // __UI_TIME_SINK_APP_H__
+1 -1
View File
@@ -75,7 +75,7 @@ __attribute__((section(".external_app.app_tpmsrx.application_information"), used
},
/*.icon_color = */ ui::Color::green().v,
/*.menu_location = */ app_location_t::RX,
/*.desired_menu_position = */ -1,
/*.desired_menu_position = */ 7,
/*.m4_app_tag = portapack::spi_flash::image_tag_tpms */ {'P', 'T', 'P', 'M'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
+146 -8
View File
@@ -42,16 +42,37 @@ std::string type(tpms::Reading::Type type) {
return to_string_dec_uint(toUType(type), 2);
}
std::string type_name(tpms::Reading::Type type) {
switch (type) {
case tpms::Reading::Type::None:
return "None";
case tpms::Reading::Type::FLM_64:
return "FLM_64";
case tpms::Reading::Type::FLM_72:
return "FLM_72";
case tpms::Reading::Type::FLM_80:
return "FLM_80";
case tpms::Reading::Type::Schrader:
return "Schrader";
case tpms::Reading::Type::GMC_96:
return "GMC_96";
default:
return "Unknown";
}
}
std::string id(tpms::TransponderID id) {
return to_string_hex(id.value(), 8);
}
std::string pressure(Pressure pressure) {
return to_string_dec_int(units_psi ? pressure.psi() : pressure.kilopascal(), 3);
return to_string_dec_int(pressure_unit == PRESSURE_UNIT_PSI ? pressure.psi() : pressure_unit == PRESSURE_UNIT_BAR ? pressure.bar()
: pressure.kilopascal(),
3);
}
std::string temperature(Temperature temperature) {
return to_string_dec_int(units_fahr ? temperature.fahrenheit() : temperature.celsius(), 3);
return to_string_dec_int(temp_unit == TEMP_UNIT_CELSIUS ? temperature.celsius() : temperature.fahrenheit(), 3);
}
std::string flags(tpms::Flags flags) {
@@ -99,7 +120,8 @@ void TPMSRecentEntry::update(const tpms::Reading& reading) {
}
}
TPMSAppView::TPMSAppView(NavigationView&) {
TPMSAppView::TPMSAppView(NavigationView& nav)
: nav_{nav} {
// baseband::run_image(portapack::spi_flash::image_tag_tpms);
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
@@ -122,16 +144,21 @@ TPMSAppView::TPMSAppView(NavigationView&) {
options_band.set_by_value(receiver_model.target_frequency());
options_pressure.on_change = [this](size_t, int32_t i) {
format::units_psi = (bool)i;
format::pressure_unit = (uint8_t)i;
update_view();
};
options_pressure.set_selected_index(format::units_psi, true);
options_pressure.set_by_value(format::pressure_unit);
options_temperature.on_change = [this](size_t, int32_t i) {
format::units_fahr = (bool)i;
format::temp_unit = (uint8_t)i;
update_view();
};
options_temperature.set_selected_index(format::units_fahr, true);
options_temperature.set_by_value(format::temp_unit);
// Add on_select handler for entries
recent_entries_view.on_select = [this](const TPMSRecentEntry& entry) {
on_show_detail(entry);
};
logger = std::make_unique<TPMSLogger>();
if (logger) {
@@ -176,6 +203,7 @@ void TPMSAppView::on_packet(const tpms::Packet& packet) {
const auto reading = reading_opt.value();
auto& entry = ::on_packet(recent, TPMSRecentEntry::Key{reading.type(), reading.id()});
entry.update(reading);
entry.signal_type = packet.signal_type();
recent_entries_view.set_dirty();
}
@@ -189,6 +217,116 @@ void TPMSAppView::on_show_list() {
recent_entries_view.focus();
}
void TPMSAppView::on_show_detail(const TPMSRecentEntry& entry) {
nav_.push<TPMSRecentEntryDetailView>(entry);
}
// Detail view implementation
TPMSRecentEntryDetailView::TPMSRecentEntryDetailView(NavigationView& nav, const TPMSRecentEntry& entry)
: nav_{nav},
entry_{entry} {
add_children({&labels,
&text_type,
&text_id,
&text_pressure,
&text_temperature,
&text_flags,
&text_count,
&button_done,
&button_save});
// Display entry data
text_type.set(format::type_name(entry.type));
text_id.set(to_string_hex(entry.id.value(), 8));
if (entry.last_pressure.is_valid()) {
std::string pressure_str = format::pressure(entry.last_pressure.value());
std::string unit_str = format::pressure_unit == PRESSURE_UNIT_PSI ? " PSI" : format::pressure_unit == PRESSURE_UNIT_BAR ? " BAR"
: " kPa";
text_pressure.set(pressure_str + unit_str);
} else {
text_pressure.set("---");
}
if (entry.last_temperature.is_valid()) {
text_temperature.set(to_string_dec_int(entry.last_temperature.value().celsius(), 3) + " C");
} else {
text_temperature.set("---");
}
if (entry.last_flags.is_valid()) {
text_flags.set(to_string_hex(entry.last_flags.value(), 2));
} else {
text_flags.set("--");
}
text_count.set(to_string_dec_uint(entry.received_count, 4));
button_done.on_select = [&nav](Button&) {
nav.pop();
};
button_save.on_select = [this](Button&) {
on_save();
};
}
void TPMSRecentEntryDetailView::focus() {
button_done.focus();
}
void TPMSRecentEntryDetailView::set_entry(const TPMSRecentEntry& entry) {
entry_ = entry;
}
void TPMSRecentEntryDetailView::on_save() {
auto timestamp = to_string_timestamp(rtc_time::now());
std::string file_name = "TPMS_" + timestamp + ".TXT";
ensure_directory(tpms_dir);
auto file_path = tpms_dir / file_name;
if (save_file(file_path)) {
nav_.display_modal("Saved", "Packet saved to:\n" + file_name);
} else {
nav_.display_modal("Error", "Failed to save\npacket");
}
}
bool TPMSRecentEntryDetailView::save_file(const std::filesystem::path& path) {
File f;
auto error = f.create(path);
if (error.is_valid())
return false;
// Save in format compatible with TX app
std::string content = "Type=" + to_string_dec_uint(toUType(entry_.type), 1) + "\n";
content += "ID=" + to_string_hex(entry_.id.value(), 8) + "\n";
if (entry_.last_pressure.is_valid()) {
content += "Pressure=" + to_string_dec_int(entry_.last_pressure.value().kilopascal(), 1) + "\n";
} else {
content += "Pressure=240\n"; // Default value
}
if (entry_.last_temperature.is_valid()) {
content += "Temperature=" + to_string_dec_int(entry_.last_temperature.value().celsius(), 1) + "\n";
} else {
content += "Temperature=25\n"; // Default value
}
if (entry_.last_flags.is_valid()) {
content += "Flags=" + to_string_hex(entry_.last_flags.value(), 2) + "\n";
} else {
content += "Flags=00\n";
}
// Save signal type for proper retransmission
content += "SignalType=" + to_string_dec_uint(toUType(entry_.signal_type), 1) + "\n";
f.write(content.c_str(), content.length());
return true;
}
} // namespace ui::external_app::tpmsrx
namespace ui {
@@ -239,4 +377,4 @@ void RecentEntriesTable<ui::external_app::tpmsrx::TPMSRecentEntries>::draw(
painter.draw_string(target_rect.location(), style, line);
}
} // namespace ui
} // namespace ui
+73 -11
View File
@@ -42,10 +42,9 @@ namespace ui::external_app::tpmsrx {
namespace format {
static bool units_psi{false};
static bool units_fahr{false};
} /* namespace format */
static uint8_t pressure_unit{PRESSURE_UNIT_KPA};
static uint8_t temp_unit{TEMP_UNIT_CELSIUS};
} // namespace format
struct TPMSRecentEntry {
using Key = std::pair<tpms::Reading::Type, tpms::TransponderID>;
@@ -54,6 +53,7 @@ struct TPMSRecentEntry {
tpms::Reading::Type type{invalid_key.first};
tpms::TransponderID id{invalid_key.second};
tpms::SignalType signal_type{tpms::SignalType::OOK_8k192_Schrader};
size_t received_count{0};
@@ -90,6 +90,64 @@ class TPMSLogger {
using TPMSRecentEntriesView = RecentEntriesView<TPMSRecentEntries>;
class TPMSRecentEntryDetailView : public View {
public:
TPMSRecentEntryDetailView(NavigationView& nav, const TPMSRecentEntry& entry);
void set_entry(const TPMSRecentEntry& entry);
const TPMSRecentEntry& entry() const { return entry_; }
void focus() override;
private:
NavigationView& nav_;
TPMSRecentEntry entry_;
void on_save();
bool save_file(const std::filesystem::path& path);
Labels labels{
{{0 * 8, 1 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 3 * 16}, "ID:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 5 * 16}, "Pressure:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 7 * 16}, "Temperature:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 9 * 16}, "Flags:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 11 * 16}, "Count:", Theme::getInstance()->fg_light->foreground},
};
Text text_type{
{8 * 8, 1 * 16, 20 * 8, 16},
""};
Text text_id{
{8 * 8, 3 * 16, 20 * 8, 16},
""};
Text text_pressure{
{12 * 8, 5 * 16, 16 * 8, 16},
""};
Text text_temperature{
{14 * 8, 7 * 16, 14 * 8, 16},
""};
Text text_flags{
{8 * 8, 9 * 16, 20 * 8, 16},
""};
Text text_count{
{8 * 8, 11 * 16, 20 * 8, 16},
""};
Button button_save{
{0 * 8, 13 * 16, 14 * 8, 32},
"Save"};
Button button_done{
{16 * 8, 13 * 16, 14 * 8, 32},
"Done"};
};
class TPMSAppView : public View {
public:
TPMSAppView(NavigationView& nav);
@@ -106,6 +164,8 @@ class TPMSAppView : public View {
std::string title() const override { return "TPMS RX"; };
private:
NavigationView& nav_;
RxRadioState radio_state_{
314900000 /* frequency*/
,
@@ -117,8 +177,8 @@ class TPMSAppView : public View {
"rx_tpms",
app_settings::Mode::RX,
{
{"units_psi"sv, &format::units_psi},
{"units_fahr"sv, &format::units_fahr},
{"pressure_unit"sv, &format::pressure_unit},
{"temp_unit"sv, &format::temp_unit},
}};
MessageHandlerRegistration message_handler_packet{
@@ -154,15 +214,16 @@ class TPMSAppView : public View {
OptionsField options_pressure{
{6 * 8, UI_POS_Y(0)},
3,
{{"kPa", 0},
{"PSI", 1}}};
4,
{{"kPa", PRESSURE_UNIT_KPA},
{"PSI", PRESSURE_UNIT_PSI},
{"BAR", PRESSURE_UNIT_BAR}}};
OptionsField options_temperature{
{10 * 8, UI_POS_Y(0)},
2,
{{STR_DEGREES_C, 0},
{STR_DEGREES_F, 1}}};
{{STR_DEGREES_C, TEMP_UNIT_CELSIUS},
{STR_DEGREES_F, TEMP_UNIT_FAHRENHEIT}}};
RFAmpField field_rf_amp{
{13 * 8, UI_POS_Y(0)}};
@@ -188,6 +249,7 @@ class TPMSAppView : public View {
void on_packet(const tpms::Packet& packet);
void on_show_list();
void on_show_detail(const TPMSRecentEntry& entry);
void update_view();
};
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2026
*
* 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 "tpms_tx_app.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::tpmstx {
void initialize_app(ui::NavigationView& nav) {
nav.push<TPMSTXView>();
}
} // namespace ui::external_app::tpmstx
extern "C" {
__attribute__((section(".external_app.app_tpmstx.application_information"), used)) application_information_t _application_information_tpmstx = {
/*.memory_location = */ (uint8_t*)0x00000000, // will be filled at compile time
/*.externalAppEntry = */ ui::external_app::tpmstx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "TPMS TX",
/*.bitmap_data = */ {
0xC0,
0x03,
0xF0,
0x0F,
0x18,
0x18,
0xEC,
0x37,
0x36,
0x6D,
0x3A,
0x59,
0x4B,
0xD5,
0x8B,
0xD3,
0xCB,
0xD1,
0xAB,
0xD2,
0x9A,
0x5C,
0xB6,
0x6C,
0xEC,
0x37,
0x18,
0x18,
0xF0,
0x0F,
0xC0,
0x03,
},
/*.icon_color = */ ui::Color::green().v,
/*.menu_location = */ app_location_t::TX,
/*.desired_menu_position = */ 6,
/*.m4_app_tag = portapack::spi_flash::image_tag_ook */ {'P', 'O', 'O', 'K'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
+812
View File
@@ -0,0 +1,812 @@
/*
* Copyright (C) 2026
*
* 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 "tpms_tx_app.hpp"
#include "baseband_api.hpp"
#include "portapack.hpp"
#include "spi_image.hpp"
#include "ui_fileman.hpp"
#include "ui_freqman.hpp"
#include "manchester.hpp"
#include "rtc_time.hpp"
#include "file_path.hpp"
#include "encoders.hpp"
#include "crc.hpp"
using namespace portapack;
using namespace tpms;
namespace ui::external_app::tpmstx {
void TPMSTXView::focus() {
options_packet_type.focus();
}
void TPMSTXView::update_signal_type_from_packet() {
// Auto-select signal type based on packet type
switch (packet_type_) {
case tpms::Reading::Type::Schrader:
signal_type_ = tpms::SignalType::OOK_8k192_Schrader;
break;
case tpms::Reading::Type::FLM_64:
case tpms::Reading::Type::FLM_72:
case tpms::Reading::Type::FLM_80:
signal_type_ = tpms::SignalType::FSK_19k2_Schrader;
break;
case tpms::Reading::Type::GMC_96:
signal_type_ = tpms::SignalType::OOK_8k4_Schrader;
break;
default:
signal_type_ = tpms::SignalType::OOK_8k192_Schrader;
break;
}
// Note: Don't call switch_baseband() here - it's called when needed
}
void TPMSTXView::switch_baseband() {
// Switch baseband image based on signal type
// Must shutdown first to avoid BBRunning error
baseband::shutdown();
chThdSleepMilliseconds(100);
if (signal_type_ == tpms::SignalType::FSK_19k2_Schrader) {
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
} else {
baseband::run_image(portapack::spi_flash::image_tag_ook);
}
chThdSleepMilliseconds(100);
}
void TPMSTXView::update_packet_display() {
// Only update status text - field values are already set by user interaction
// or by explicit set_value calls when loading from file
std::string status = "ID:" + to_string_hex(transponder_id_, 8);
// Note protocol-specific limitations
if (packet_type_ == tpms::Reading::Type::Schrader) {
status = "ID:" + to_string_hex(transponder_id_ & 0x00FFFFFF, 6) + " (24bit)";
}
status += " " + to_string_dec_uint(pressure_kpa_) + "kPa";
// Check for pressure overflow and warn user
if (packet_type_ == tpms::Reading::Type::GMC_96) {
if (pressure_kpa_ > 701) {
status += " !MAX"; // GMC_96 max is 701 kPa (101.7 PSI)
}
} else {
if (pressure_kpa_ > 340) {
status += " !MAX"; // Schrader/FLM max is 340 kPa (49.3 PSI)
}
}
// Temperature note for protocols that support it
if (packet_type_ == tpms::Reading::Type::GMC_96 ||
packet_type_ == tpms::Reading::Type::FLM_64 ||
packet_type_ == tpms::Reading::Type::FLM_72 ||
packet_type_ == tpms::Reading::Type::FLM_80) {
status += " " + to_string_dec_int(temperature_c_) + "C";
} else {
status += " (no temp)";
}
text_status.set(status);
}
void TPMSTXView::update_field_visibility() {
// Schrader: Show Func, Hide Temp (no temperature support)
// GMC_96, FLM_xx: Hide Func, Show Temp (temperature supported, no func field)
if (packet_type_ == tpms::Reading::Type::Schrader) {
// Show Func field and label
label_flags.hidden(false);
field_flags.hidden(false);
// Hide Temp field, label, and unit selector
label_temperature.hidden(true);
field_temperature.hidden(true);
options_temperature.hidden(true);
// Show 24-bit ID field, hide 32-bit ID field
field_transponder_id_24.hidden(false);
field_transponder_id_32.hidden(true);
} else {
// Hide Func field and label
label_flags.hidden(true);
field_flags.hidden(true);
// Show Temp field, label, and unit selector
label_temperature.hidden(false);
field_temperature.hidden(false);
options_temperature.hidden(false);
// Show 32-bit ID field, hide 24-bit ID field
field_transponder_id_24.hidden(true);
field_transponder_id_32.hidden(false);
}
// Force screen refresh to clear hidden widgets
set_dirty();
}
void TPMSTXView::on_pressure_unit_change() {
// Convert displayed pressure to new unit and update field
units::Pressure pressure(pressure_kpa_);
int display_value = 0;
if (format::pressure_unit == PRESSURE_UNIT_PSI) {
display_value = pressure.psi();
} else if (format::pressure_unit == PRESSURE_UNIT_BAR) {
display_value = pressure.bar();
} else {
display_value = pressure.kilopascal();
}
field_pressure.set_value(display_value);
}
void TPMSTXView::on_temperature_unit_change() {
// Convert displayed temperature to new unit and update field
units::Temperature temperature(temperature_c_);
int display_value = 0;
if (format::temp_unit == TEMP_UNIT_FAHRENHEIT) {
display_value = temperature.fahrenheit();
} else {
display_value = temperature.celsius();
}
field_temperature.set_value(display_value);
}
void TPMSTXView::encode_and_transmit() {
if (!is_transmitting_) return;
// Build TPMS packet based on signal type
std::string binary_string;
uint32_t symbol_rate;
uint32_t sample_rate;
// Set sample rate based on signal type to match transmitter config
if (signal_type_ == tpms::SignalType::FSK_19k2_Schrader) {
sample_rate = 2280000; // 2.28 MHz for FSK (matches transmitter_model config)
} else {
sample_rate = 2000000; // 2 MHz for OOK
}
if (signal_type_ == tpms::SignalType::OOK_8k192_Schrader) {
// Schrader OOK 8k192 format (Type = Schrader)
// Preamble: 11*2, 01*14, 11, 10
// Data: 3 bits function code, 24 bits ID, 8 bits pressure, 2 bits checksum
// Total: 37 Manchester symbols (74 bits after encoding)
// NOTE: This protocol does NOT support temperature transmission
// NOTE: Only lower 24 bits of ID are transmitted
// NOTE: Function code (flags_) is stored as 3-bit value (0-7)
// RX will display it combined with checksum in upper nibble
symbol_rate = 8192;
// Preamble as expected by RX decoder
binary_string = "1111"; // 11*2
for (int i = 0; i < 14; i++) {
binary_string += "01";
}
binary_string += "1110"; // 11, 10
// Build data bits (pre-Manchester)
uint64_t data = 0;
// 3-bit flags (0-7, stored directly)
uint8_t flags_3bit = flags_ & 0x07;
data |= ((uint64_t)flags_3bit << 34);
// 24-bit ID (only use lower 24 bits - protocol limitation)
uint32_t id_24bit = transponder_id_ & 0x00FFFFFF;
data |= ((uint64_t)id_24bit << 10);
// 8-bit pressure (convert kPa to raw: kPa * 3/4)
// Clamp to prevent overflow: max raw = 255, max kPa = 255 * 4/3 = 340 (49.3 PSI)
uint16_t pressure_clamped = (pressure_kpa_ > 340) ? 340 : pressure_kpa_;
uint8_t pressure_raw = (pressure_clamped * 3 / 4);
data |= ((uint64_t)pressure_raw << 2);
// Calculate 2-bit checksum: sum all 2-bit pairs, result & 3 must equal 3
uint32_t checksum_calc = (data >> 36) & 1; // First bit
for (size_t i = 1; i < 37; i += 2) {
checksum_calc += (data >> (37 - i - 2)) & 3;
}
uint8_t checksum_2bit = (3 - (checksum_calc & 3)) & 3;
data |= checksum_2bit;
// Manchester encode the 37 data bits
for (int i = 36; i >= 0; i--) {
if ((data >> i) & 1) {
binary_string += "10"; // '1' = 10 in Manchester
} else {
binary_string += "01"; // '0' = 01 in Manchester
}
}
} else if (signal_type_ == tpms::SignalType::OOK_8k4_Schrader) {
// GMC_96 OOK 8k4 format
symbol_rate = 8400;
// Preamble: 01*40
for (int i = 0; i < 40; i++) {
binary_string += "01";
}
// First nibble of System ID (0x4) - part of preamble pattern match
// RX looks for pattern ending with: 01010101...01100101
// The "01100101" = Manchester for 0x4, and is consumed by pattern matcher
binary_string += "01"; // 0
binary_string += "10"; // 1
binary_string += "01"; // 0
binary_string += "01"; // 0 (0100 = 0x4)
// Remaining 20 bits of system ID (padding with zeros)
// These are the first 20 bits of the 76-bit payload
for (int i = 0; i < 20; i++) {
binary_string += "01"; // All zeros for padding
}
// 32-bit ID (Manchester encoded)
for (int i = 31; i >= 0; i--) {
if ((transponder_id_ >> i) & 1) {
binary_string += "10";
} else {
binary_string += "01";
}
}
// Pressure: kPa * 4/11
// Clamp to prevent overflow: max raw = 255, max kPa = 255 * 11/4 = 701.25 (101.7 PSI)
uint16_t pressure_clamped = (pressure_kpa_ > 701) ? 701 : pressure_kpa_;
uint8_t pressure_gmc = (pressure_clamped * 4 / 11);
for (int i = 7; i >= 0; i--) {
if ((pressure_gmc >> i) & 1) {
binary_string += "10";
} else {
binary_string += "01";
}
}
// Temperature: temp + 61
uint8_t temp_gmc = (temperature_c_ + 61) & 0xFF;
for (int i = 7; i >= 0; i--) {
if ((temp_gmc >> i) & 1) {
binary_string += "10";
} else {
binary_string += "01";
}
}
// Checksum: sum of all data bytes (system ID + ID + pressure + temp)
// System ID byte 0: (0x4 << 4) | 0x0 = 0x40
// System ID byte 1: 0x00
// System ID byte 2: 0x00
uint8_t checksum = 0x40; // First byte of system ID
checksum += 0x00; // Second byte of system ID
checksum += 0x00; // Third byte of system ID
// Add all 4 bytes of the ID
checksum += (transponder_id_ >> 24) & 0xFF;
checksum += (transponder_id_ >> 16) & 0xFF;
checksum += (transponder_id_ >> 8) & 0xFF;
checksum += transponder_id_ & 0xFF;
// Add pressure and temperature
checksum += pressure_gmc;
checksum += temp_gmc;
for (int i = 7; i >= 0; i--) {
if ((checksum >> i) & 1) {
binary_string += "10";
} else {
binary_string += "01";
}
}
} else if (signal_type_ == tpms::SignalType::FSK_19k2_Schrader) {
// FSK 19.2k for FLM variants
// Data is Manchester encoded: each data bit becomes two FSK symbols
// Preamble: 14 x '01' + '10' = 30 bits (matches RX pattern exactly)
// Payload: 160 Manchester-encoded bits (80 data bits max)
symbol_rate = 19200;
// Build preamble: 14 pairs of "01" followed by "10"
for (int i = 0; i < 14; i++) {
binary_string += "01";
}
binary_string += "10";
std::array<uint8_t, 20> data_bytes = {0}; // 160 bits = 20 bytes max
size_t num_data_bits = 0;
if (packet_type_ == tpms::Reading::Type::FLM_64) {
// FLM_64: 64 bits (8 bytes)
// Bytes 0-3: ID (32 bits)
// Byte 4: Pressure (8 bits)
// Byte 5: Temperature (8 bits, LSB 7 bits used)
// Byte 6: Padding
// Byte 7: Sum checksum of bytes 0-6 (low 8 bits)
num_data_bits = 64;
data_bytes[0] = (transponder_id_ >> 24) & 0xFF;
data_bytes[1] = (transponder_id_ >> 16) & 0xFF;
data_bytes[2] = (transponder_id_ >> 8) & 0xFF;
data_bytes[3] = transponder_id_ & 0xFF;
// Clamp pressure to prevent overflow: max 340 kPa (49.3 PSI)
uint16_t pressure_clamped_flm64 = (pressure_kpa_ > 340) ? 340 : pressure_kpa_;
data_bytes[4] = (pressure_clamped_flm64 * 3 / 4);
data_bytes[5] = ((temperature_c_ + 56) & 0x7F); // LSB 7 bits only
data_bytes[6] = 0x00; // Padding
// Addition checksum over bytes 0-6
uint32_t checksum = 0;
for (int i = 0; i < 7; i++) {
checksum += data_bytes[i];
}
data_bytes[7] = checksum & 0xFF;
} else if (packet_type_ == tpms::Reading::Type::FLM_72) {
// FLM_72: 72 bits (9 bytes)
// Bytes 0-3: ID (32 bits)
// Byte 4: Padding
// Byte 5: Pressure (8 bits)
// Byte 6: Temperature (8 bits)
// Bytes 7-8: CRC field - RX processes ALL 9 bytes and expects CRC result = 0
num_data_bits = 72;
data_bytes[0] = (transponder_id_ >> 24) & 0xFF;
data_bytes[1] = (transponder_id_ >> 16) & 0xFF;
data_bytes[2] = (transponder_id_ >> 8) & 0xFF;
data_bytes[3] = transponder_id_ & 0xFF;
data_bytes[4] = 0x00; // Padding
// Clamp pressure to prevent overflow: max 340 kPa (49.3 PSI)
uint16_t pressure_clamped_flm = (pressure_kpa_ > 340) ? 340 : pressure_kpa_;
data_bytes[5] = (pressure_clamped_flm * 3 / 4);
data_bytes[6] = (temperature_c_ + 56) & 0xFF;
data_bytes[7] = 0x00; // Set to 0 initially
// Calculate CRC over bytes 0-7, place result in byte 8
// When RX calculates CRC over bytes 0-8, it should get residual 0
CRC<8> crc{0x01, 0x00};
for (int i = 0; i < 8; i++) {
crc.process_byte(data_bytes[i]);
}
data_bytes[8] = crc.checksum() & 0xFF;
} else if (packet_type_ == tpms::Reading::Type::FLM_80) {
// FLM_80: 80 bits (10 bytes)
// Byte 0: Padding
// Bytes 1-4: ID (32 bits)
// Byte 5: Padding
// Byte 6: Pressure (8 bits)
// Byte 7: Temperature (8 bits)
// Bytes 8-9: CRC field - RX processes bytes 1-9 and expects CRC result = 0
num_data_bits = 80;
data_bytes[0] = 0x00; // Padding (not included in CRC)
data_bytes[1] = (transponder_id_ >> 24) & 0xFF;
data_bytes[2] = (transponder_id_ >> 16) & 0xFF;
data_bytes[3] = (transponder_id_ >> 8) & 0xFF;
data_bytes[4] = transponder_id_ & 0xFF;
data_bytes[5] = 0x00; // Padding
// Clamp pressure to prevent overflow: max 340 kPa (49.3 PSI)
uint16_t pressure_clamped_flm80 = (pressure_kpa_ > 340) ? 340 : pressure_kpa_;
data_bytes[6] = (pressure_clamped_flm80 * 3 / 4);
data_bytes[7] = (temperature_c_ + 56) & 0xFF;
data_bytes[8] = 0x00; // Padding/Reserved
data_bytes[9] = 0x00; // CRC byte
// Calculate CRC over bytes 1-8 (all bytes except 0 and 9)
// When RX calculates CRC over bytes 1-9, it should get residual 0
CRC<8> crc{0x01, 0x00};
for (int i = 1; i <= 8; i++) {
crc.process_byte(data_bytes[i]);
}
data_bytes[9] = crc.checksum() & 0xFF;
}
// Manchester-encode data bits for FSK
// RX ManchesterDecoder with sense=0: '1' = "10", '0' = "01"
size_t num_bytes = num_data_bits / 8;
for (size_t byte_idx = 0; byte_idx < num_bytes; byte_idx++) {
uint8_t byte_val = data_bytes[byte_idx];
for (int bit_idx = 7; bit_idx >= 0; bit_idx--) {
if ((byte_val >> bit_idx) & 1) {
binary_string += "10"; // Manchester '1'
} else {
binary_string += "01"; // Manchester '0'
}
}
}
// Pad payload to 160 bits with valid Manchester pairs ("01" = 0)
// Using proper Manchester encoding maintains clock recovery sync
while (binary_string.length() < 190) { // 30 preamble + 160 payload
binary_string += "01"; // Manchester-encoded zero
}
} else {
text_status.set("Unknown signal type");
stop_tx();
return;
}
// Convert binary string to bitstream
size_t bitstream_length = encoders::make_bitstream(binary_string);
// Calculate samples per bit (round to nearest for best timing accuracy)
uint32_t samples_per_bit = (sample_rate + symbol_rate / 2) / symbol_rate;
// Update status to show we're sending
text_status.set("TX: " + to_string_dec_uint(binary_string.length()) + " bits");
// Send via appropriate baseband (OOK or FSK)
if (signal_type_ == tpms::SignalType::FSK_19k2_Schrader) {
// FSK mode: 19.2 kbaud, 38.4 kHz shift
baseband::set_fsk_data(
bitstream_length,
samples_per_bit,
38400, // 38.4 kHz shift
256); // Progress notice interval
} else {
// OOK mode
baseband::set_ook_data(
bitstream_length,
samples_per_bit,
repeat_count_,
pause_duration_);
}
}
void TPMSTXView::handle_tx_complete() {
// For FSK (FLM packets), handle repeats at application level
// OOK repeats are handled by the baseband processor
if (signal_type_ == tpms::SignalType::FSK_19k2_Schrader) {
fsk_repeat_counter_++;
if (fsk_repeat_counter_ < repeat_count_) {
// More repeats needed - send the next one
// Update progress bar
progressbar.set_value(fsk_repeat_counter_);
// Wait for FSK processor to fully complete and reset
// This allows the shared memory bitstream to be safely rewritten
chThdSleepMilliseconds(50);
encode_and_transmit();
} else {
// All FSK repeats complete
stop_tx();
}
} else {
// OOK repeats are handled by baseband, just stop here
stop_tx();
}
}
void TPMSTXView::start_tx() {
if (is_transmitting_)
return;
is_transmitting_ = true;
progressbar.set_max(repeat_count_);
progressbar.set_value(0);
button_transmit.set_text("STOP TX");
text_status.set("Transmitting...");
// Initialize FSK repeat counter for application-level repeat handling
fsk_repeat_counter_ = 0;
// Switch to appropriate baseband before transmission
switch_baseband();
// Configure transmitter based on modulation type
if (signal_type_ == tpms::SignalType::FSK_19k2_Schrader) {
// FSK configuration
transmitter_model.set_sampling_rate(2280000); // 2.28 MHz for FSK
transmitter_model.set_baseband_bandwidth(1750000);
} else {
// OOK configuration
transmitter_model.set_sampling_rate(2000000); // 2 MHz for OOK
transmitter_model.set_baseband_bandwidth(1750000);
}
transmitter_model.enable();
// Start transmission
encode_and_transmit();
}
void TPMSTXView::stop_tx() {
if (!is_transmitting_)
return;
is_transmitting_ = false;
transmitter_model.disable();
button_transmit.set_text("START TX");
text_status.set("Transmission complete");
progressbar.set_value(0);
}
TPMSTXView::TPMSTXView(NavigationView& nav)
: nav_{nav} {
// Start with OOK baseband (will switch if needed)
baseband::run_image(portapack::spi_flash::image_tag_ook);
add_children({&labels,
&label_temperature,
&label_flags,
&options_frequency,
&options_packet_type,
&field_transponder_id_24,
&field_transponder_id_32,
&field_pressure,
&options_pressure,
&field_temperature,
&options_temperature,
&field_flags,
&field_repeat,
&button_load,
&button_save,
&tx_view,
&button_transmit,
&text_status,
&progressbar});
// Set label styles to match other labels (light grey)
label_temperature.set_style(Theme::getInstance()->fg_light);
label_flags.set_style(Theme::getInstance()->fg_light);
// Initialize values
options_frequency.set_by_value(transmitter_model.target_frequency());
options_packet_type.set_selected_index(0);
field_repeat.set_value(repeat_count_);
// Set initial signal type based on packet type
update_signal_type_from_packet();
// Initialize unit selection
options_pressure.set_by_value(format::pressure_unit);
options_temperature.set_by_value(format::temp_unit);
// Initialize field values from default member variables
// For pressure and temperature, use unit conversion to display in selected units
field_transponder_id_24.set_value(transponder_id_ & 0x00FFFFFF);
field_transponder_id_32.set_value(transponder_id_);
on_pressure_unit_change();
on_temperature_unit_change();
field_flags.set_value(flags_);
update_field_visibility();
update_packet_display();
// Event handlers
options_frequency.on_change = [this](size_t, OptionsField::value_t v) {
transmitter_model.set_target_frequency(v);
};
options_packet_type.on_change = [this](size_t, int32_t value) {
packet_type_ = static_cast<tpms::Reading::Type>(value);
update_signal_type_from_packet();
// Sync field values when switching packet types
if (packet_type_ == tpms::Reading::Type::Schrader) {
// Switching to Schrader: copy from 32-bit field to 24-bit field (masked)
transponder_id_ = field_transponder_id_32.to_integer() & 0x00FFFFFF;
field_transponder_id_24.set_value(transponder_id_);
} else {
// Switching from Schrader: copy from 24-bit field to 32-bit field
transponder_id_ = field_transponder_id_24.to_integer();
field_transponder_id_32.set_value(transponder_id_);
}
update_field_visibility();
update_packet_display();
};
options_pressure.on_change = [this](size_t, int32_t i) {
format::pressure_unit = (uint8_t)i;
on_pressure_unit_change();
};
options_temperature.on_change = [this](size_t, int32_t i) {
format::temp_unit = (uint8_t)i;
on_temperature_unit_change();
};
field_transponder_id_24.on_change = [this](SymField&) {
transponder_id_ = field_transponder_id_24.to_integer() & 0x00FFFFFF;
update_packet_display();
};
field_transponder_id_32.on_change = [this](SymField&) {
transponder_id_ = field_transponder_id_32.to_integer();
update_packet_display();
};
field_pressure.on_change = [this](int32_t value) {
// Convert from displayed unit to kPa for internal storage
if (format::pressure_unit == PRESSURE_UNIT_PSI) {
pressure_kpa_ = value * 6895 / 1000;
} else if (format::pressure_unit == PRESSURE_UNIT_BAR) {
pressure_kpa_ = value * 100;
} else {
pressure_kpa_ = value;
}
update_packet_display();
};
field_temperature.on_change = [this](int32_t value) {
// Convert from displayed unit to Celsius for internal storage
if (format::temp_unit == TEMP_UNIT_FAHRENHEIT) {
temperature_c_ = (value - 32) * 5 / 9;
} else {
temperature_c_ = value;
}
update_packet_display();
};
field_flags.on_change = [this](int32_t value) {
flags_ = value & 0x07;
update_packet_display();
};
field_repeat.on_change = [this](int32_t value) {
repeat_count_ = value;
};
button_transmit.on_select = [this](Button&) {
if (is_transmitting_) {
stop_tx();
} else {
start_tx();
}
};
button_load.on_select = [this, &nav](Button&) {
auto open_view = nav.push<FileLoadView>(".TXT");
open_view->on_changed = [this](std::filesystem::path file_path) {
// Load TPMS packet from file
File f;
auto error = f.open(file_path);
if (!error.is_valid()) {
char buffer[512];
auto result = f.read(buffer, sizeof(buffer) - 1);
if (result.is_ok()) {
buffer[result.value()] = 0;
// Parse the file format (key=value format, one per line)
std::string content(buffer);
size_t pos = 0;
auto parse_line = [&content, &pos](const std::string& key) -> std::string {
size_t key_pos = content.find(key + "=", pos);
if (key_pos != std::string::npos) {
size_t value_start = key_pos + key.length() + 1;
size_t value_end = content.find('\n', value_start);
if (value_end == std::string::npos) value_end = content.length();
return content.substr(value_start, value_end - value_start);
}
return "";
};
std::string type_str = parse_line("Type");
std::string id_str = parse_line("ID");
std::string pressure_str = parse_line("Pressure");
std::string temp_str = parse_line("Temperature");
std::string flags_str = parse_line("Flags");
std::string signal_type_str = parse_line("SignalType");
if (!type_str.empty()) {
int type = std::stoi(type_str);
if (type >= static_cast<int>(tpms::Reading::Type::FLM_64) &&
type <= static_cast<int>(tpms::Reading::Type::GMC_96)) {
packet_type_ = static_cast<tpms::Reading::Type>(type);
options_packet_type.set_by_value(type);
}
}
if (!id_str.empty()) {
transponder_id_ = std::stoul(id_str, nullptr, 16);
field_transponder_id_24.set_value(transponder_id_ & 0x00FFFFFF);
field_transponder_id_32.set_value(transponder_id_);
}
if (!pressure_str.empty()) {
pressure_kpa_ = std::stoi(pressure_str);
on_pressure_unit_change();
}
if (!temp_str.empty()) {
temperature_c_ = std::stoi(temp_str);
field_temperature.set_value(temperature_c_);
}
if (!flags_str.empty()) {
uint8_t loaded_flags = std::stoul(flags_str, nullptr, 16);
// Handle old format files: extract bits 6-4 if value > 7
flags_ = (loaded_flags > 7) ? ((loaded_flags >> 4) & 0x07) : (loaded_flags & 0x07);
field_flags.set_value(flags_);
}
// Load signal type if available, otherwise auto-select based on packet type
if (!signal_type_str.empty()) {
int signal_type = std::stoi(signal_type_str);
if (signal_type >= 1 && signal_type <= 3) {
signal_type_ = static_cast<tpms::SignalType>(signal_type);
} else {
// Fall back to auto-detect
update_signal_type_from_packet();
}
} else {
// Fall back to auto-detect for backwards compatibility
update_signal_type_from_packet();
}
update_packet_display();
update_field_visibility();
text_status.set("Loaded: " + file_path.filename().string());
} else {
text_status.set("Error reading file");
}
} else {
text_status.set("Error opening file");
}
};
};
button_save.on_select = [this](Button&) {
// Save current TPMS packet to file
auto timestamp = to_string_timestamp(rtc_time::now());
std::string file_name = "TPMS_" + timestamp + ".TXT";
ensure_directory(tpms_dir);
auto file_path = tpms_dir / file_name;
File f;
auto error = f.create(file_path);
if (!error.is_valid()) {
std::string content = "Type=" + to_string_dec_uint(toUType(packet_type_), 1) + "\n";
content += "ID=" + to_string_hex(transponder_id_, 8) + "\n";
content += "Pressure=" + to_string_dec_uint(pressure_kpa_) + "\n";
content += "Temperature=" + to_string_dec_int(temperature_c_) + "\n";
content += "Flags=" + to_string_hex(flags_ & 0x07, 1) + "\n";
f.write(content.c_str(), content.length());
text_status.set("Saved: " + file_name);
} else {
text_status.set("Error saving file");
}
};
}
TPMSTXView::~TPMSTXView() {
stop_tx();
transmitter_model.disable();
baseband::shutdown();
}
} // namespace ui::external_app::tpmstx
+226
View File
@@ -0,0 +1,226 @@
/*
* Copyright (C) 2026
*
* 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 __TPMS_TX_APP_H__
#define __TPMS_TX_APP_H__
#include "ui_widget.hpp"
#include "ui_navigation.hpp"
#include "ui_transmitter.hpp"
#include "transmitter_model.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "portapack.hpp"
#include "message.hpp"
#include "tpms_packet.hpp"
#include "file_path.hpp"
#include "string_format.hpp"
#include "units.hpp"
namespace ui::external_app::tpmstx {
namespace format {
static uint8_t pressure_unit{PRESSURE_UNIT_PSI};
static uint8_t temp_unit{TEMP_UNIT_CELSIUS};
} // namespace format
class TPMSTXView : public View {
public:
TPMSTXView(NavigationView& nav);
~TPMSTXView();
void focus() override;
std::string title() const override { return "TPMS TX"; };
private:
NavigationView& nav_;
TxRadioState radio_state_{
314900000, /* frequency */
1750000, /* bandwidth */
2457600 /* sampling rate */
};
app_settings::SettingsManager settings_{
"tx_tpms",
app_settings::Mode::TX,
{
{"pressure_unit"sv, &format::pressure_unit},
{"temp_unit"sv, &format::temp_unit},
}};
// TPMS packet data
tpms::Reading::Type packet_type_{tpms::Reading::Type::Schrader};
uint32_t transponder_id_{0x12345678};
uint16_t pressure_kpa_{240}; // Default ~35 PSI
int16_t temperature_c_{25}; // Default 25°C
uint8_t flags_{0x00}; // 3-bit function code (0-7), checksum is auto-calculated
tpms::SignalType signal_type_{tpms::SignalType::FSK_19k2_Schrader};
uint8_t repeat_count_{5};
uint32_t pause_duration_{50}; // ms between repeats
bool is_transmitting_{false};
// FSK-specific repeat tracking (OOK repeats are handled by baseband)
uint8_t fsk_repeat_counter_{0};
uint32_t fsk_repeat_timer_id_{0};
void update_signal_type_from_packet();
void switch_baseband();
void start_tx();
void stop_tx();
void send_packet();
void encode_and_transmit();
void update_packet_display();
void on_pressure_unit_change();
void on_temperature_unit_change();
void update_field_visibility();
MessageHandlerRegistration message_handler_tx_progress{
Message::ID::TXProgress,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
progressbar.set_value(message.progress);
if (message.done) {
handle_tx_complete();
}
}};
void handle_tx_complete();
Labels labels{
{{0 * 8, 0 * 16}, "Freq:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 1 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 2 * 16}, "ID:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 3 * 16}, "Pres:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 5 * 16}, "Rpt:", Theme::getInstance()->fg_light->foreground},
};
Text label_temperature{
{0 * 8, 4 * 16, 5 * 8, 16},
"Temp:"};
Text label_flags{
{0 * 8, 4 * 16, 5 * 8, 16},
"Func:"};
OptionsField options_frequency{
{6 * 8, 0 * 16},
5,
{
{"314.9", 314900000},
{"315.0", 315000000},
{"433.9", 433920000},
}};
OptionsField options_packet_type{
{6 * 8, 1 * 16},
10,
{
{"Schrader", (int32_t)tpms::Reading::Type::Schrader},
{"FLM_64", (int32_t)tpms::Reading::Type::FLM_64},
{"FLM_72", (int32_t)tpms::Reading::Type::FLM_72},
{"FLM_80", (int32_t)tpms::Reading::Type::FLM_80},
{"GMC_96", (int32_t)tpms::Reading::Type::GMC_96},
}};
OptionsField options_pressure{
{11 * 8, 3 * 16},
4,
{{"kPa", PRESSURE_UNIT_KPA},
{"PSI", PRESSURE_UNIT_PSI},
{"BAR", PRESSURE_UNIT_BAR}}};
OptionsField options_temperature{
{11 * 8, 4 * 16},
2,
{{STR_DEGREES_C, TEMP_UNIT_CELSIUS},
{STR_DEGREES_F, TEMP_UNIT_FAHRENHEIT}}};
SymField field_transponder_id_24{
{6 * 8, 2 * 16},
6,
SymField::Type::Hex};
SymField field_transponder_id_32{
{6 * 8, 2 * 16},
8,
SymField::Type::Hex};
NumberField field_pressure{
{6 * 8, 3 * 16},
4,
{0, 9999},
1,
' '};
NumberField field_temperature{
{6 * 8, 4 * 16},
4,
{-99, 999},
1,
' '};
NumberField field_flags{
{6 * 8, 4 * 16},
1,
{0, 7},
1,
' '};
NumberField field_repeat{
{6 * 8, 5 * 16},
3,
{1, 100},
1,
' '};
Button button_load{
{0 * 8, 8 * 16 + 4, 7 * 8, 24},
"Load"};
Button button_save{
{8 * 8, 8 * 16 + 4, 7 * 8, 24},
"Save"};
TransmitterView2 tx_view{
{16 * 8, 0 * 16},
true // Short UI format
};
Button button_transmit{
{0 * 8, 11 * 16, 15 * 8, 32},
"START TX"};
Text text_status{
{0 * 8, 13 * 16 + 4, 30 * 8, 16},
"Ready"};
ProgressBar progressbar{
{0 * 8, 14 * 16 + 8, 30 * 8, 16}};
};
} // namespace ui::external_app::tpmstx
#endif /*__TPMS_TX_APP_H__*/
+3 -2
View File
@@ -161,7 +161,7 @@ Optional<File::Error> File::sync() {
File::Result<std::string> File::read_file(const std::filesystem::path& filename) {
constexpr size_t buffer_size = 0x80;
char* buffer[buffer_size];
char buffer[buffer_size];
File f;
auto error = f.open(filename);
@@ -205,6 +205,7 @@ static std::filesystem::path find_last_ordinal_match(
const std::filesystem::path& pattern,
pattern_range range) {
auto last_match = std::filesystem::path();
if (range.start == std::string::npos || range.end == std::string::npos || range.start > range.end) return last_match;
auto can_increment = [range](const auto& path) {
for (auto i = range.start; i <= range.end; ++i)
if (!isdigit(path.native()[i]))
@@ -230,7 +231,7 @@ static std::filesystem::path increment_filename_ordinal(
const std::filesystem::path& path,
pattern_range range) {
auto name = path.filename().native();
if (range.start == std::string::npos || range.end == std::string::npos || range.start > range.end) return {name};
for (auto i = range.end; i >= range.start; --i) {
auto& c = name[i];
+4
View File
@@ -51,5 +51,9 @@ const std::filesystem::path whipcalc_dir = u"WHIPCALC";
const std::filesystem::path ook_editor_dir = u"OOKFILES";
const std::filesystem::path hopper_dir = u"HOPPER";
const std::filesystem::path subghz_dir = u"SUBGHZ";
const std::filesystem::path tpms_dir = u"TPMS";
const std::filesystem::path waterfalls_dir = u"WATERFALLS";
const std::filesystem::path macaddress_dir = u"MACADDRESS";
const std::filesystem::path splash_dot_bmp = u"/splash.bmp";
const std::filesystem::path keeloq_keys_dir = u"KEELOQKEYS";
const std::filesystem::path keeloq_remotes_dir = u"KEELOQREMOTES";
+5
View File
@@ -53,7 +53,12 @@ extern const std::filesystem::path whipcalc_dir;
extern const std::filesystem::path ook_editor_dir;
extern const std::filesystem::path hopper_dir;
extern const std::filesystem::path subghz_dir;
extern const std::filesystem::path tpms_dir;
extern const std::filesystem::path waterfalls_dir;
extern const std::filesystem::path macaddress_dir;
extern const std::filesystem::path keeloq_keys_dir;
extern const std::filesystem::path keeloq_remotes_dir;
extern const std::filesystem::path splash_dot_bmp;
#endif /* __FILE_PATH_H__ */
+1 -1
View File
@@ -117,7 +117,7 @@ class BufferLineReader {
std::strncpy(&it.line_data_[offset], buf, len);
offset += len;
if (len < buf_size)
if (len < buf_size || buf[len - 1] == '\n')
break;
}
+12
View File
@@ -1,7 +1,19 @@
#include "../../hackrf/firmware/common/firmware_info.h"
#include "../../hackrf/firmware/common/platform_detect.h"
// Use the same logic as official HackRF firmware
#ifdef JAWBREAKER
#define SUPPORTED_PLATFORM PLATFORM_JAWBREAKER
#elif HACKRF_ONE
#define SUPPORTED_PLATFORM (PLATFORM_HACKRF1_OG | PLATFORM_HACKRF1_R9)
#elif RAD1O
#define SUPPORTED_PLATFORM PLATFORM_RAD1O
#elif PRALINE
#define SUPPORTED_PLATFORM PLATFORM_PRALINE
#else
#define SUPPORTED_PLATFORM 0
#endif
#define DFU_MODE_VALUE 0
__attribute__((section(".firmware_info"))) const struct firmware_info_t firmware_info = {
+2 -1
View File
@@ -66,7 +66,8 @@ options_t freqman_bandwidths[6] = {
// NFM
{"8k5", 0},
{"11k", 1},
{"16k", 2},
{"12k5", 2},
{"16k", 3},
},
{
// WFM
+1 -2
View File
@@ -84,8 +84,7 @@ void Gradient::step(int16_t index, int16_t r, int16_t g, int16_t b) {
int16_t new_r = prev_r * y + r * x;
int16_t new_g = prev_g * y + g * x;
int16_t new_b = prev_b * y + b * x;
lut[i] = ui::Color(new_r, new_g, new_b);
if (i <= 255) lut[i] = ui::Color(new_r, new_g, new_b);
}
prev_index = index;
+40 -2
View File
@@ -42,6 +42,17 @@ namespace max2831 {
using namespace max283x;
static MAX2831Info max2831_info = {0, 0, 0, false, false};
MAX2831Info get_max2831_info() {
return {
max2831_info.requested_freq_mhz,
max2831_info.calculated_n,
max2831_info.calculated_frac,
max2831_info.set_frequency_called,
max2831_info.frequency_valid};
}
/*
* MAX2831 uses 9-bit SPI transfers.
* An 18-bit word is sent as two 9-bit transfers:
@@ -120,7 +131,8 @@ void MAX2831::init() {
// set_reg_field(11, REG11_RXVGA_GAIN_MASK, 0x1F); // 62 dB VGA = MAX
/* Configure baseband filter for 8 MHz TX - matches GSG reference */
set_reg_field(8, REG8_LPF_COARSE_MASK, REG8_RX_LPF_7_5M);
// set_reg_field(8, REG8_LPF_COARSE_MASK, REG8_RX_LPF_7_5M);
set_reg_field(8, REG8_LPF_COARSE_MASK, REG8_RX_LPF_15M);
set_reg_field(7, REG7_RX_LPF_FINE_MASK, REG7_RX_LPF_FINE_100);
set_reg_field(7, REG7_TX_LPF_FINE_MASK, REG7_TX_LPF_FINE_100);
@@ -329,9 +341,18 @@ uint32_t MAX2831::set_lpf_bandwidth_internal(const uint32_t bandwidth_hz) {
void MAX2831::set_lpf_rf_bandwidth_rx(const uint32_t bandwidth_minimum) {
_desired_lpf_bw = bandwidth_minimum;
#ifdef PRALINE
uint32_t actual_bw = bandwidth_minimum;
_desired_lpf_bw = actual_bw;
if (_mode == Mode::Receive || _mode == Mode::Rx_Calibration) {
set_lpf_bandwidth_internal(actual_bw);
}
#else
if (_mode == Mode::Receive || _mode == Mode::Rx_Calibration) {
set_lpf_bandwidth_internal(bandwidth_minimum);
}
#endif
}
void MAX2831::set_lpf_rf_bandwidth_tx(const uint32_t bandwidth_minimum) {
@@ -355,7 +376,20 @@ bool MAX2831::set_frequency(const rf::Frequency lo_frequency) {
*/
/* MAX2831 supports 2.3-2.6 GHz */
if (lo_frequency < 2300000000ULL || lo_frequency > 2600000000ULL) {
// if (lo_frequency < MAX2831_MIN_LO_FREQUENCY_HZ || lo_frequency > MAX2831_MAX_LO_FREQUENCY_HZ) {
// return false;
// }
bool valid = (lo_frequency >= MAX2831_MIN_LO_FREQUENCY_HZ && lo_frequency <= MAX2831_MAX_LO_FREQUENCY_HZ);
// TRACK REQUEST IMMEDIATELY
max2831_info.requested_freq_mhz = lo_frequency / 1000000;
max2831_info.set_frequency_called = true;
max2831_info.frequency_valid = valid;
if (!valid) {
max2831_info.calculated_n = 0;
max2831_info.calculated_frac = 0;
return false;
}
@@ -377,6 +411,10 @@ bool MAX2831::set_frequency(const rf::Frequency lo_frequency) {
}
}
// TRACK CALCULATED VALUES
max2831_info.calculated_n = div_int;
max2831_info.calculated_frac = div_frac;
/* Write order matters - matches GSG reference */
/* REG 3: SYN_INT (bits 7:0) and SYN_FRAC_LO (bits 13:8) */
uint16_t reg3_val = (div_int & 0xFF) | ((div_frac & 0x3F) << 8);
+15
View File
@@ -38,6 +38,21 @@ namespace max2831 {
using namespace max283x;
// Global debug tracking for MAX2831
struct MAX2831Info {
uint32_t requested_freq_mhz;
uint32_t calculated_n;
uint32_t calculated_frac;
bool set_frequency_called;
bool frequency_valid;
};
MAX2831Info get_max2831_info();
/* minumum and maximum lo_frequencies supported by max2831 */
constexpr rf::Frequency MAX2831_MIN_LO_FREQUENCY_HZ = 2300000000LL;
constexpr rf::Frequency MAX2831_MAX_LO_FREQUENCY_HZ = 2600000000LL;
/* MAX2831 has 16 registers, each containing 14 bits of data */
constexpr size_t reg_count = 16;
+5 -26
View File
@@ -65,7 +65,11 @@ constexpr halrtcnt_t ticks_during_reset = (base_m4_clk_f * seconds_during_reset
constexpr float seconds_after_reset = 5.0e-6;
constexpr halrtcnt_t ticks_after_reset = (base_m4_clk_f * seconds_after_reset + 1);
#ifdef PRALINE
constexpr rf::Frequency reference_frequency = 40000000ULL;
#else
constexpr auto reference_frequency = rffc5072_reference_f;
#endif
namespace vco {
@@ -114,31 +118,9 @@ constexpr size_t divider_min = 1U << divider_log2_min;
constexpr size_t divider_max = 1U << divider_log2_max;
constexpr size_t divider_log2(const rf::Frequency vco_frequency) {
#ifdef PRALINE
// PRALINE FIX: Avoid N register overflow (9-bit max = 511)
// With 40 MHz reference:
// - For VCO=5400 MHz, presc=÷2: N = (5400×2)/40 = 270 ✓
// - For VCO=5400 MHz, presc=÷4: N = (5400×4)/40 = 540 ✗ OVERFLOW!
//
// Maximum safe VCO for ÷4 prescaler:
// N_max = 511, so VCO_max = (511 × 40) / 4 = 5110 MHz
//
// Use ÷4 only if VCO < 5110 MHz AND VCO > 3200 MHz
// Use ÷2 for VCO >= 5110 MHz to avoid overflow
constexpr rf::Frequency overflow_threshold = 5110000000ULL; // Max VCO for ÷4
constexpr rf::Frequency min_presc4_freq = 3200000000ULL; // Min VCO for ÷4
if ((vco_frequency > min_presc4_freq) && (vco_frequency < overflow_threshold)) {
return divider_log2_max; // ÷4 prescaler
} else {
return divider_log2_min; // ÷2 prescaler
}
#else
return (vco_frequency > (prescaler::divider_min * prescaler::max_frequency))
? prescaler::divider_log2_max
: prescaler::divider_log2_min;
#endif
}
} /* namespace prescaler */
@@ -161,11 +143,7 @@ struct SynthConfig {
const size_t prescaler_divider_log2 = prescaler::divider_log2(vco_frequency);
#ifndef PRALINE
const uint64_t prescaled_lo_q24 = vco_frequency << (24 - prescaler_divider_log2);
#else
const uint64_t prescaled_lo_q24 = vco_frequency << (24 + prescaler_divider_log2);
#endif
const uint64_t n_divider_q24 = prescaled_lo_q24 / reference_frequency;
#ifdef PRALINE
@@ -287,6 +265,7 @@ void RFFC507x::set_frequency(const rf::Frequency lo_frequency) {
const SynthConfig synth_config = SynthConfig::calculate(lo_frequency);
#ifdef PRALINE
// Calculate VCO frequency from LO frequency and divider
const size_t lo_divider = 1U << synth_config.lo_divider_log2; // 2^lodiv_log2
const rf::Frequency vco_freq = lo_frequency * lo_divider;
+31 -7
View File
@@ -361,18 +361,31 @@ class Si5351 {
}
void wait_for_device_ready() {
#ifndef PRALINE
while (device_status() & 0x80);
#else
#ifdef PRALINE
// Add timeout to prevent infinite loop if I2C communication fails
// (e.g., on PRALINE hardware with different configuration)
uint32_t timeout = 100000;
while ((device_status() & 0x80) && (timeout > 0)) {
timeout--;
if (timeout == 0) {
chDbgAssert(false, "si5351: wait_for_device_ready timeout", nullptr);
}
}
#else
while (device_status() & 0x80);
#endif
}
#ifdef PRALINE
void set_clock_control_single_byte(const ClockControls& clock_control) {
_clock_control = clock_control;
// Use single-byte writes for PRALINE (multi-byte I2C fails)
for (size_t i = 0; i < 8; i++) {
write_register(Register::CLKControl_Base + i, _clock_control[i]);
}
}
#endif
bool plla_loss_of_signal() {
return (device_status() >> 5) & 1;
}
@@ -386,13 +399,14 @@ class Si5351 {
}
void reset_plls() {
#ifndef PRALINE
// Datasheet recommends value 0xac, though the low nibble bits are not defined in AN619.
write_register(Register::PLLReset, 0xac);
#else
#ifdef PRALINE
// Reset both PLLA and PLLB. Use 0xA0 to match HackRF reference firmware.
// The low nibble bits are reserved/undefined in AN619.
write_register(Register::PLLReset, 0xa0);
#else
// Datasheet recommends value 0xac, though the low nibble bits are not defined in AN619.
write_register(Register::PLLReset, 0xac);
#endif
}
regvalue_t read_register(const uint8_t reg);
@@ -413,6 +427,7 @@ class Si5351 {
#ifdef PRALINE
/* Write multisynth config using single-byte writes for debugging */
void write_ms_single_byte(const size_t ms_number, const MultisynthFractional& config) {
const auto regs = config.reg(ms_number);
// regs[0] is the base register address, regs[1-8] are the data bytes
@@ -421,6 +436,15 @@ class Si5351 {
write_register(base_reg + i - 1, regs[i]);
}
}
void write_pll_single_byte(const uint8_t pll_n, const PLL& pll_config) {
const auto regs = pll_config.reg(pll_n);
// regs[0] is base register address, regs[1-8] are data
const uint8_t base_reg = regs[0];
for (size_t i = 1; i < regs.size(); i++) {
write_register(base_reg + i - 1, regs[i]);
}
}
#endif
void set_ms_frequency(
+2 -1
View File
@@ -81,7 +81,8 @@ struct header_t {
struct tags_t {
constexpr tags_t(
const std::string& title_str) {
strcpy(title, title_str.c_str());
strncpy(title, title_str.c_str(), sizeof(title) - 1);
title[sizeof(title) - 1] = '\0';
cksize = sizeof(tags_t) - 8;
}
+36
View File
@@ -0,0 +1,36 @@
#include "keeloq_common.hpp"
uint32_t keeloq_encrypt(const uint32_t data, const uint64_t key) {
uint32_t x = data, r;
for (r = 0; r < 528; r++)
x = (x >> 1) ^ ((bit(x, 0) ^ bit(x, 16) ^ (uint32_t)bit(key, r & 63) ^
bit(KEELOQ_NLF, g5(x, 1, 9, 20, 26, 31)))
<< 31);
return x;
}
uint32_t keeloq_decrypt(const uint32_t data, const uint64_t key) {
uint32_t x = data, r;
for (r = 0; r < 528; r++)
x = (x << 1) ^ bit(x, 31) ^ bit(x, 15) ^ (uint32_t)bit(key, (15 - r) & 63) ^
bit(KEELOQ_NLF, g5(x, 0, 8, 19, 25, 30));
return x;
}
uint64_t keeloq_normal_learning(uint32_t data, const uint64_t key) {
uint32_t k1, k2;
data &= 0x0FFFFFFF;
data |= 0x20000000;
k1 = keeloq_decrypt(data, key);
data &= 0x0FFFFFFF;
data |= 0x60000000;
k2 = keeloq_decrypt(data, key);
return ((uint64_t)k2 << 32) | k1;
}
+16
View File
@@ -0,0 +1,16 @@
#ifndef __KEELOQ_COMMON__
#define __KEELOQ_COMMON__
#include <cstdint>
#define bit(x, n) (((x) >> (n)) & 1)
#define g5(x, a, b, c, d, e) \
(bit(x, a) + bit(x, b) * 2 + bit(x, c) * 4 + bit(x, d) * 8 + bit(x, e) * 16)
#define KEELOQ_NLF 0x3A5C742E
uint32_t keeloq_encrypt(const uint32_t data, const uint64_t key);
uint32_t keeloq_decrypt(const uint32_t data, const uint64_t key);
uint64_t keeloq_normal_learning(uint32_t data, const uint64_t key);
#endif
+72
View File
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2026 lifegame1lu111
*
* 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 "keeloq_file.hpp"
namespace fs = std::filesystem;
bool read_keeloq_file(const fs::path& path, KeeloqData& data) {
File file{};
auto result = file.open(path);
if (result) {
return false;
}
FileLineReader reader{file};
std::string raw = *reader.begin();
auto chunks = split_string(raw, ';');
if (chunks.size() != 4) {
return false;
}
data.mf_name = std::string{chunks[0]};
data.serial = std::strtoul(chunks[1].data(), NULL, 16);
data.counter = (uint16_t)std::atoi(chunks[2].data());
data.btn = (uint8_t)std::atoi(chunks[3].data());
return true;
}
bool write_keeloq_file(const fs::path& path, const KeeloqData& data) {
delete_file(path);
File file{};
auto result = file.open(path, false, true);
if (result) {
return false;
}
std::string formatted = data.mf_name + ";" +
to_string_hex(data.serial) + ";" +
to_string_dec_uint(data.counter) + ";" +
to_string_dec_uint(data.btn);
file.write_line(formatted);
file.close();
return true;
}
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2026 lifegame1lu111
*
* 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 __KEELOQ_FILE__
#define __KEELOQ_FILE__
#include "portapack.hpp"
#include "file_reader.hpp"
#include "string_format.hpp"
#include <string_view>
struct KeeloqData {
std::string mf_name{};
uint32_t serial = 0;
uint16_t counter = 0;
uint8_t btn = 0;
};
bool read_keeloq_file(const std::filesystem::path&, KeeloqData&);
bool write_keeloq_file(const std::filesystem::path&, const KeeloqData&);
#endif
+53
View File
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2026 lifegame1lu111
*
* 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 "keeloq_keystore.hpp"
KeeloqKeystore::KeeloqKeystore() {
ensure_directory(keeloq_keys_dir);
File keeloq_keys_file{};
if (keeloq_keys_file.open(keeloq_keys_dir / "MFCODES")) {
return;
}
FileLineReader reader{keeloq_keys_file};
for (const std::string& line : reader) {
auto cols = split_string(line, ';');
if (cols.size() != 3) {
return;
}
KeeloqKey key{
std::string{cols[0]},
std::strtoull(cols[1].data(), NULL, 16),
(uint8_t)std::atoi(cols[2].data())};
keys.push_back(key);
}
}
const std::vector<KeeloqKey>& KeeloqKeystore::get_keys() {
return keys;
}
+49
View File
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2026 lifegame1lu111
*
* 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 __KEELOQ_KEYSTORE__
#define __KEELOQ_KEYSTORE__
#include "file_reader.hpp"
#include "file_path.hpp"
#include "string_format.hpp"
#include <string_view>
#define KEELOQ_SIMPLE_LEARNING 1
#define KEELOQ_NORMAL_LEARNING 2
struct KeeloqKey {
std::string mf_name{};
uint64_t key = 0;
uint8_t type = 0;
};
class KeeloqKeystore {
public:
KeeloqKeystore();
const std::vector<KeeloqKey>& get_keys();
private:
std::vector<KeeloqKey> keys{};
};
#endif
Executable → Regular
+18 -1
View File
@@ -91,7 +91,7 @@ Continuous (Fox-oring)
// TODO: ADS-B draw trajectory + GPS coordinates + scale, and playback
// TODO: RDS multiple groups (sequence)
// TODO: Use ModalMessageView confirmation for TX ?
// TODO: Use msgpack for settings, lists... on sd card
// TODO: Use msgpack for settings, lists... on sd card. and make it safe, since now it has a lot of oob potentials
// Multimon-style stuff:
// TODO: DMR detector
@@ -145,6 +145,21 @@ Continuous (Fox-oring)
rffc507x::RFFC507x first_if;
ui::SystemView* system_view_ptr;
static uint32_t random_seed_state = 123456789;
extern "C" int rand(void) {
random_seed_state ^= random_seed_state << 13;
random_seed_state ^= random_seed_state >> 17;
random_seed_state ^= random_seed_state << 5;
return (int)(random_seed_state & 0x7FFFFFFF);
}
extern "C" void srand(unsigned int seed) {
if (seed == 0) {
random_seed_state = 123456789;
} else {
random_seed_state = seed;
}
}
static void event_loop() {
static ui::Context context;
static ui::SystemView system_view{
@@ -166,7 +181,9 @@ static void event_loop() {
}
int main(void) {
#ifndef PRALINE // Do not perform quick set up of GP01_RFF507X = 1 for PRALINE
first_if.init(); /* To avoid initial short Ant_DC_Bias pulse ,we need quick set up GP01_RFF507X =1 */
#endif
if (config_mode_should_enter()) {
config_mode_clear();
+45 -18
View File
@@ -56,11 +56,13 @@ using asahi_kasei::ak4951::AK4951;
#include "i2cdevmanager.hpp"
#include "battery.hpp"
#ifndef PRALINE
extern "C" {
#include "platform_detect.h"
}
#ifdef PRALINE
#include "fpga_bridge.h"
#endif
}
namespace portapack {
@@ -390,18 +392,8 @@ static void set_cpu_clock_speed() {
#endif
cgu::pll1::enable();
#ifndef PRALINE
while (!cgu::pll1::is_locked());
set_clock_config(clock_config_pll1_step);
/* Delay >50us at 90-110MHz clock speed */
volatile uint32_t delay = 1400;
while (delay--);
set_clock_config(clock_config_pll1);
/* Remove /2P divider from PLL1 output to achieve full speed */
cgu::pll1::direct();
#else
#ifdef PRALINE
// Wait for PLL1 to lock with timeout
{
uint32_t timeout = 100000;
@@ -421,6 +413,18 @@ static void set_cpu_clock_speed() {
/* Remove /2P divider from PLL1 output to achieve full speed */
cgu::pll1::direct();
}
#else
while (!cgu::pll1::is_locked());
set_clock_config(clock_config_pll1_step);
/* Delay >50us at 90-110MHz clock speed */
volatile uint32_t delay = 1400;
while (delay--);
set_clock_config(clock_config_pll1);
/* Remove /2P divider from PLL1 output to achieve full speed */
cgu::pll1::direct();
#endif
}
@@ -549,18 +553,22 @@ static void initialize_boot_splash_screen() {
*/
init_status_t init() {
#ifdef PRALINE
/* 1. HOLD FPGA IN RESET (Active Low) */
// P5_2 is GPIO2[11] (FPGA CRESET)
palClearPad(GPIO2, 11);
#endif
set_idivc_base_clocks(cgu::CLK_SEL::IDIVC);
i2c0.start(i2c_config_boot_clock);
chThdSleepMilliseconds(100);
#ifndef PRALINE
detect_hardware_platform();
finalize_detect_hardware_platform();
chThdSleepMilliseconds(100);
#endif
configure_pins_portapack();
@@ -622,6 +630,27 @@ init_status_t init() {
clock_manager.enable_if_clocks();
clock_manager.enable_codec_clocks();
#ifdef PRALINE
chThdSleepMilliseconds(20);
// This function returns LD_SUCCESS (0) if the FPGA confirms the bitstream
// Call fpga_bridge_init and continue boot regardless of result
// (Watchdog was resetting device when we halted with while(1))
int load_result = fpga_bridge_init();
(void)load_result; // Ignore result for now, just let boot continue
/* RELEASE FPGA RESET */
// FPGA wakes up and latches the stable 40MHz CLK1
// P5_2 is GPIO2[11] (FPGA CRESET)
palSetPad(GPIO2, 11);
// Allow FPGA and related logic a brief stabilization period without busy-waiting
chThdSleepMilliseconds(10);
// Keep LEDs off after FPGA load
LPC_GPIO->SET[2] = (1 << 1) | (1 << 2) | (1 << 8);
#endif
radio::init();
sdcStart(&SDCD1, nullptr);
@@ -633,6 +662,7 @@ init_status_t init() {
draw_splash_screen_icon(2, ui::bitmap_icon_sd);
init_status_t return_code = init_status_t::INIT_SUCCESS;
#ifndef PRALINE
// HackRF One uses CPLD - load it via JTAG
if (!hackrf::cpld::load_sram()) {
@@ -641,9 +671,6 @@ init_status_t init() {
return_code = init_status_t::INIT_HACKRF_CPLD_FAILED;
}
#else
// HackRF Pro (PRALINE) uses FPGA - already loaded in board.cpp __early_init()
// via fpga_bridge_init(), so nothing to do here
#endif
if (lcd_fast_setup)

Some files were not shown because too many files have changed in this diff Show More