Commit graph

153 commits

Author SHA1 Message Date
Ryan Turner
64ec7a1d70 gfx: add gfx_printBufferClipped
Adds gfx_printBufferClipped: a variant of gfx_printBuffer that accepts
an explicit right-edge limit (max_x) and a vertical clip window
[clip_top_y, clip_bot_y].  Word-wrap fires when the next glyph would
exceed max_x.  Pixels outside the clip window are suppressed without
affecting layout, so a negative start.y can be used to implement smooth
text scrolling.

gfx_printBuffer now delegates entirely to gfx_printBufferClipped with
clip_top_y=0 and clip_bot_y=CONFIG_SCREEN_HEIGHT-1.  The old pixel guard
used strict > 0 comparisons, which excluded pixels at row 0 and column 0.
The new implementation renders those pixels; callers that relied on the
old exclusion will see a behaviour change.

Compared to a naive port of gfx_printBuffer, this implementation
addresses several correctness issues:

- Control characters '\n' and '\r' are checked before the glyph array
  is indexed, avoiding undefined behaviour on fonts whose first codepoint
  is at or above 0x20 (e.g. TomThumb, first=0x20), since '\n' (0x0A)
  would produce a negative index.

- get_line_size uses <= instead of < when accumulating glyph widths so
  that a glyph whose xAdvance exactly equals max_width is counted.  The
  render loop uses strict > to trigger wrap, so the old < mismatch caused
  text_size.x to be under-reported by one glyph whenever a line was an
  exact fit, and misplaced CENTER/RIGHT lines in that case.

- For TEXT_ALIGN_LEFT, line_size is recomputed on every '\n' before the
  max_line_size comparison.  Without this, max_line_size was stuck at the
  first-line width for the entire call, so text_size.x was wrong whenever
  a subsequent line was wider.

- saved_start_y is int16_t to match point_t.y, allowing correct
  text_size.y computation when start.y is negative (scroll offset).

- text_size.y is computed as (start.y - saved_start_y) + line_h,
  matching the sign fix introduced for gfx_printBuffer.

- Pixels above row 0 (py < 0) are suppressed before the uint16_t cast
  passed to gfx_setPixel, preventing a silent wrap to a large row index.

- max_line_size tracks the widest line across all line breaks and wraps;
  text_size.x reflects the widest line, not just the last.

Extend tests/unit/gfx_text.cpp with return-value tests covering:
single-line height, two-line height delta equals yAdvance, negative
start.y scroll offset, negative clip_top_y, exact-fit line width
(get_line_size <= boundary), max line width from a wider first line,
max line width from a wider second line (TEXT_ALIGN_LEFT regression),
glyph at clip_bot_y not skipped, and TEXT_ALIGN_RIGHT per-line reset.

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-07-25 21:11:18 +02:00
Ryan Turner
9e472454a1 gfx: add gfx_measureText, accept max_width in get_line_size
Refactor the static helper get_line_size to accept an explicit max_width
parameter instead of the hardcoded CONFIG_SCREEN_WIDTH cap.  All three
call sites in gfx_printBuffer are updated to pass CONFIG_SCREEN_WIDTH,
preserving existing behaviour.

Add gfx_measureText: a pure-computation function that simulates the same
word-wrap pass as gfx_printBufferClipped (to be added next) without
touching the display.  It returns the total pixel height of the laid-out
text block and accepts a char_count limit so callers can compute the
y-coordinate of an arbitrary cursor position for scroll-offset
calculations.

Add tests/unit/gfx_text.cpp and register the gfx_text_test executable in
meson.build.  The test suite covers single-line strings, multi-line
strings via explicit newlines, char_count truncation, and word-wrap
height growth.

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-07-25 21:11:15 +02:00
Jetse Verschuren
7be721f312 core: dsp: add decimator implementation
Co-authored-by: Ryan Turner <ryan@turnrye.com>
2026-04-20 20:21:52 +02:00
Ryan Turner
3139f71e26 tests: add unit test for PacketFrame
Co-authored-by: GitHub Copilot <175728472+github-copilot[bot]@users.noreply.github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-23 22:43:07 +01:00
Ryan Turner
1b8a479390 tests: add end-to-end demodulator lock test
Add a test that generates 10 consecutive RRC-shaped stream frames and
asserts the demodulator stays locked throughout.

Co-authored-by: GitHub Copilot <175728472+github-copilot[bot]@users.noreply.github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-23 22:03:17 +01:00
Morgan Diepart
c782bc34aa test: platform: add tests for stm32 internal flash 2026-03-22 21:29:39 +01:00
Ryan Turner
a006553837 Remove M17 prefix from constants in M17 namespace
Drop the redundant 'M17' prefix from namespace-level constants in
Constants.hpp (SYMBOL_RATE, FRAME_SYMBOLS, SYNCWORD_SYMBOLS,
FRAME_BYTES) and from private class constants in Modulator
(TX_SAMPLE_RATE, SAMPLES_PER_SYMBOL, FRAME_SAMPLES, RRC_GAIN,
RRC_OFFSET). Update all references in Demodulator, Modulator, and
the demodulator test.

Co-authored-by: GitHub Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-21 10:05:33 +01:00
Ryan Turner
e63214e7c0 M17: remove M17 name from namespaced classes
M17 protocol code is already namespaced in M17, so it's redundant to name every class M17*. This change removes the leading M17 from all of the namespaced things.

Co-authored-by: GitHub Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-21 10:05:33 +01:00
Ryan Turner
84c2e9fbdc protocols: M17: add metadata class and reassembly
Add classes oriented around handling metadata in the M17 protocol.
Create a class for reassembling text blocks from metadata in order to
assemble a multi-frame metadata text message.

Co-authored-by: Wojciech Kaczmarski <w.kaczmarski@teletra.pl>
Co-authored-by: Jim Ancona <jim@anconafamily.com>
Co-authored-by: Rick Schnicker <crs026@yahoo.com>
Co-authored-by: GitHub Copilot <noreply@github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-13 21:25:34 +01:00
Ryan Turner
d27cc927b9 test: unit: clean up non-unit test dead code
The unit test directory had a number of manual linux platform tests that aren't really unit tests. They aren't written with assertions and have no documented use. This change deletes these from the testing suite. In the future they could be added back in a different place, or automated tests in the form of true unit or integration tests could be added. But this clarifies that all suites in the unit test folder are actually automated unit tests, and only one unexectued test remains (related to code that is planned to be reintroduced in the future).

Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-04 08:10:40 +01:00
Ryan Turner
7ff4873280 test: unit: port and enable UI standby check test
From the old UI check standby test, update it to be Catch2-based.
Register the test in meson.build and add it to clang_format.sh

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-04 08:10:40 +01:00
Ryan Turner
da132166b3 test: unit: fix and re-enable M17 demodulator test
The previous demodulator test relied on reading a binary test file from
disk and used '#define private public' to access private class members,
both of which were fragile and broke after an M17 refactor.

Rewrite the test to exercise the public Correlator and Synchronizer
classes directly using synthesised input signals, covering:
 * peak correlation for a matching stream syncword
 * DC-signal proportionality
 * syncword detection and sampling index validity
 * no trigger on an above-maximum threshold

Re-enable the test in meson.build and fix the executable definition
ordering (place it after m17_rrc_test).

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-04 08:10:40 +01:00
Ryan Turner
d45aa492c5 test: unit: adopt Catch2 in existing passing tests
Port all currently-enabled unit tests to Catch2: replace the custom
main() / printf error-reporting boilerplate with TEST_CASE and REQUIRE
macros. Add catch2_dep to unit_test_opts now that it is actually used.

Tests ported: M17_callsign, M17_golay, M17_rrc, M17_viterbi, cps,
convert_minmea_coord, linux_inputStream. The M17 demodulator test is
still in its pre-Catch2 form and remains disabled, as it needs
significant rework (not just porting to Catch2).

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-04 08:10:40 +01:00
Ryan Turner
a7dfd83e31 test: unit: rename C test files to C++
Rename cps.c and convert_minmea_coord.c to .cpp so they can be built
with the C++ compiler required for Catch2. File content is unchanged at
this point - the Catch2 port follows in the next commit. Also update the
source references in meson.build and the file list in clang_format.sh.

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-04 08:10:40 +01:00
Ryan Turner
b0493aedae test: format all unit tests
Signed-off-by: Ryan Turner <ryan@turnrye.com
2026-03-04 08:10:40 +01:00
Morgan Diepart
778e5b6d4b NVM: nvm_dump: use nvmem_access api instead of nvmem_device 2026-03-03 18:34:07 +01:00
Silvano Seva
33052fab13 test: calib_read: update partition access indexes
Signed-off-by: Silvano Seva <silseva@fastwebnet.it>
2026-03-03 18:34:07 +01:00
Silvano Seva
83757f422a nvm: removed size field from nvmDevice data structure
Signed-off-by: Silvano Seva <silseva@fastwebnet.it>
2026-03-03 18:34:07 +01:00
Ryan Turner
95fdcd5fe2 copyright-and-license: adopt SPDX-compliant header
This change removes the old copyright header from project sources and
replaces it with a new simplified SPDX-compliant header. Note that files
that were missing the header but reasonably understood to be licensed
according to the root license were not corrected.

Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-01-14 20:10:07 +01:00
Ryan Turner
edbe038329 test: unit: add test for M17 Callsign class 2025-11-17 22:04:27 +01:00
Ryan Turner
d2ddddf478 Fix incorrect include paths for platform-unique header files 2025-10-02 19:43:55 +02:00
Ryan Turner
00a4dbb063 style: resolve ambiguous paths on include macros
Update meson and cmake config to only include openrtx and platform paths.
Update files to use <..> for system and external libraries, ".." for
project files and new relative paths as necessary.

Did not attempt to fix areas where includes that should be <..> were
previously ".."

Inspired by #96, closes #359.

Acked-by: Silvano Seva <silseva@fastwebnet.it>
2025-09-28 17:27:45 +02:00
Silvano Seva
6db558e89c core: dsp: refactor DC block filter implementation
New DC block filter implementation using fixed-point math and guaranteeing
zero DC component on the output signal.

Signed-off-by: Silvano Seva <silseva@fastwebnet.it>
2025-09-28 14:12:20 +02:00
Silvano Seva
12dc81aef2 test: platform: codec2_encode_test: reformat code to new coding style 2025-09-12 16:33:15 +02:00
Silvano Seva
882a7e58ee test: platform: updated codec2 encode test 2025-09-12 16:31:30 +02:00
Silvano Seva
b2e289e6fd test: platform: mic_test: reformat code to new coding style 2025-09-12 16:23:34 +02:00
Silvano Seva
d18905aeb4 test: platform: updated mic test to new audio API 2025-09-12 16:06:55 +02:00
Silvano Seva
219bb4e986 core: gps: added new API for GPS device management 2025-08-15 20:00:20 +02:00
Silvano Seva
498aa309cd tests: platform: added tool for MDx and GDx calibration readout 2025-08-03 12:11:19 +02:00
Silvano Seva
acfffb13a9 tests: platform: added nonvolatile memory dump tool 2025-08-03 12:11:19 +02:00
Silvano Seva
0d249994cf tests: platform: added display test 2025-08-03 12:11:19 +02:00
Silvano Seva
6881c2430b tests: platform: updated keyboard test 2025-08-03 12:11:19 +02:00
Silvano Seva
fa9134e106 tests: platform: updated platform API test 2025-08-03 12:11:19 +02:00
Silvano Seva
7b1ff71907 tests: platform: cleanup deprecated tesuites 2025-08-03 11:42:31 +02:00
Silvano Seva
03d1ae5546 Updated year in copyright headers 2025-04-04 21:15:39 +02:00
Marco
36ef3b310c Added function to convert minmea coordinate to fixed-point integer representation 2024-04-10 08:04:26 +02:00
Niccolò Izzo
ca5519812f Added platform test for validation of NVM devices.
Refactored memory dump test to be compatible with xxd format.

TG-502
2023-12-03 19:00:55 +01:00
Silvano Seva
1011dd1081 Moved audio_stream.h from interfaces to core headers 2023-08-30 18:04:24 +02:00
Ryan Turner
29b6eb08ff chore(test): fix unit tests and explore a github workflow 2023-08-17 12:16:13 +02:00
Silvano Seva
1afd868d64 Renamed "lcd_type" field of hardare info struct to "hw_version" 2023-06-14 21:30:52 +02:00
Silvano Seva
a89a7523cb Updated year in copyright headers 2023-02-08 16:33:02 +01:00
Silvano Seva
49c6cbd7c0 Added implementation of soft-decision Viterbi decoder for M17 protocol, updated version number in meson.build 2022-11-11 22:04:34 +01:00
Silvano Seva
cad026f902 Renamed vp_clearCurrPrompt() to vp_flush(), added a vp_stop() function allowing to stop an in-progress voice prompt but without flushing the data buffer 2022-10-28 08:30:46 +02:00
Silvano Seva
42b262c437 Refactored voicePromptUtils.h and voicePromptUtils.c 2022-10-28 08:30:46 +02:00
Silvano Seva
df5341e103 Refactored voicePrompts.h, aligned function names of voice prompt API to OpenRTX coding style 2022-10-28 08:30:46 +02:00
Niccolò Izzo
8eca684a7d Voice prompts bugfixes:
- added missing initialization of codec2 in voice prompts code
- discarding the voice prompt header as we only support 3200 bit rate
- fixed wrong offset in pick vpQueueStringTableEntry
- fixed bug in vpInit causing voiceprompts to hang
2022-10-28 08:30:46 +02:00
Niccolò Izzo
adbd1f070d Fixed bug in circular buffer management inside linux output stream driver, added unit test for circular buffer mode.
TG-220
2022-10-28 08:30:46 +02:00
Niccolò Izzo
081b19e52c Implemented output audio stream driver for linux.
Implement outputStream backend on linux using Pulseaudio simple API.

TG-250
2022-10-28 08:30:46 +02:00
Jacob McSwain
9a00b4e837 mic_test: Fix DSP arguments 2022-07-25 12:59:17 +02:00
Alain Carlucci
07394cc8a0 Linux input stream driver: bugfixes and completed test 2022-07-10 11:00:49 +02:00