Fix: TX Delay not applied until value is changed - #625
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a startup and mode-switch regression where the saved TX Delay (stored as UtcTimer’s manual offset) was being lost when the cycle timer was rebuilt, causing the delay to effectively reset to 0 until the operator edited the value again.
Changes:
- Updated
FT8TransmitSignal.rebuildTimer(...)to rebuild theUtcTimerwhile preserving the prior timer’sgetTime_sec()offset. - Added
FT8TransmitSignal.rebuildTimerPreservingOffset(...)as a package-visible static helper to make the behavior unit-testable and shared between startup/mode-switch paths. - Added unit tests covering both “offset preserved” and “zero stays zero” cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
ft8af/app/src/main/java/com/k1af/ft8af/ft8transmit/FT8TransmitSignal.java |
Preserves TX Delay by carrying UtcTimer’s offset onto the rebuilt timer. |
ft8af/app/src/test/java/com/k1af/ft8af/ft8transmit/FT8TransmitSignalTest.java |
Adds JVM unit tests validating offset preservation across timer rebuilds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+559
to
+575
| @Test | ||
| public void rebuildTimer_carriesOffsetOntoNewTimer() { | ||
| UtcTimer old = new UtcTimer(ModeProfile.FT8.slotMillis, false, NOOP_CALLBACK); | ||
| try { | ||
| old.setTime_sec(1800); // saved TX Delay, in ms | ||
| UtcTimer rebuilt = FT8TransmitSignal.rebuildTimerPreservingOffset( | ||
| old, ModeProfile.FT4, NOOP_CALLBACK); | ||
| try { | ||
| // The core fix: the offset survives the rebuild instead of resetting to 0. | ||
| assertThat(rebuilt.getTime_sec()).isEqualTo(1800); | ||
| } finally { | ||
| rebuilt.delete(); | ||
| } | ||
| } finally { | ||
| old.delete(); | ||
| } | ||
| } |
Comment on lines
+577
to
+592
| @Test | ||
| public void rebuildTimer_zeroOffsetStaysZero() { | ||
| // No TX Delay set: the rebuild must not invent one. | ||
| UtcTimer old = new UtcTimer(ModeProfile.FT8.slotMillis, false, NOOP_CALLBACK); | ||
| try { | ||
| UtcTimer rebuilt = FT8TransmitSignal.rebuildTimerPreservingOffset( | ||
| old, ModeProfile.FT8, NOOP_CALLBACK); | ||
| try { | ||
| assertThat(rebuilt.getTime_sec()).isEqualTo(0); | ||
| } finally { | ||
| rebuilt.delete(); | ||
| } | ||
| } finally { | ||
| old.delete(); | ||
| } | ||
| } |
patrickrb
force-pushed
the
optio/task-5b2d0f79-f7cd-45ca-a6eb-cfa87986b938
branch
from
July 22, 2026 14:28
de13eff to
4c20bad
Compare
TX Delay was not applied until the value was changed after startup. The saved delay is loaded into GeneralVariables.transmitDelay and applied to the current UtcTimer in ComposeMainActivity.initData(), but the very next call — applyLoadedOperatingMode() -> FT8TransmitSignal.rebuildTimer() — threw the timer away and built a fresh one that starts with time_sec = 0, silently discarding the delay until the operator re-edited it. The same reset hit runtime FT8/FT4/FT2 mode switches. Carry the outgoing timer's offset onto the rebuilt one inside a new package-visible static helper (rebuildTimerPreservingOffset) so the fix covers both startup and mode switches, and the carry-over is unit-testable via getTime_sec() without constructing a full FT8TransmitSignal. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
patrickrb
force-pushed
the
optio/task-5b2d0f79-f7cd-45ca-a6eb-cfa87986b938
branch
from
July 22, 2026 14:29
4c20bad to
0ca2f4f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TX Delay isn't applied after startup — the saved value only takes effect once the operator edits it, and it reverts on app exit. It also silently resets on FT8⇄FT4⇄FT2 mode switches.
Root cause
ComposeMainActivity.initData()loads the saved delay intoGeneralVariables.transmitDelayand applies it to the currentUtcTimerviasetTimer_sec(...), but the immediately-followingapplyLoadedOperatingMode()→FT8TransmitSignal.rebuildTimer()throws that timer away and builds a freshUtcTimer, which starts withtime_sec = 0. The delay is discarded until the value is edited again (which callssetTimer_sec()on the now-stable timer). The runtime mode-switch path calls the samerebuildTimer(), so switching mode resets TX Delay to 0 too.Fix
Carry the outgoing timer's offset (
UtcTimer.getTime_sec()) onto the rebuilt timer. The logic is extracted into a package-visible static helperrebuildTimerPreservingOffset(oldTimer, mode, callback)so it covers both startup and mode switches, and — per CLAUDE.md — is unit-testable viagetTime_sec()without constructing a fullFT8TransmitSignalor touching JNI/Android framework.Tests
Added to
FT8TransmitSignalTest:rebuildTimer_carriesOffsetOntoNewTimer— a set offset survives the rebuild (fails on the pre-fix code for the expected reason: offset resets to 0).rebuildTimer_zeroOffsetStaysZero— no offset set → rebuild doesn't invent one../gradlew :app:testDebugUnitTest --tests com.k1af.ft8af.ft8transmit.FT8TransmitSignalTestpasses (54 tests).🤖 Generated with Claude Code