Skip to content

Fix: TX Delay not applied until value is changed - #625

Merged
patrickrb merged 1 commit into
devfrom
optio/task-5b2d0f79-f7cd-45ca-a6eb-cfa87986b938
Jul 22, 2026
Merged

Fix: TX Delay not applied until value is changed#625
patrickrb merged 1 commit into
devfrom
optio/task-5b2d0f79-f7cd-45ca-a6eb-cfa87986b938

Conversation

@patrickrb

Copy link
Copy Markdown
Owner

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 into GeneralVariables.transmitDelay and applies it to the current UtcTimer via setTimer_sec(...), but the immediately-following applyLoadedOperatingMode()FT8TransmitSignal.rebuildTimer() throws that timer away and builds a fresh UtcTimer, which starts with time_sec = 0. The delay is discarded until the value is edited again (which calls setTimer_sec() on the now-stable timer). The runtime mode-switch path calls the same rebuildTimer(), 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 helper rebuildTimerPreservingOffset(oldTimer, mode, callback) so it covers both startup and mode switches, and — per CLAUDE.md — is unit-testable via getTime_sec() without constructing a full FT8TransmitSignal or 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.FT8TransmitSignalTest passes (54 tests).

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the UtcTimer while preserving the prior timer’s getTime_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
patrickrb force-pushed the optio/task-5b2d0f79-f7cd-45ca-a6eb-cfa87986b938 branch from de13eff to 4c20bad Compare July 22, 2026 14:28
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
patrickrb force-pushed the optio/task-5b2d0f79-f7cd-45ca-a6eb-cfa87986b938 branch from 4c20bad to 0ca2f4f Compare July 22, 2026 14:29
@patrickrb
patrickrb merged commit b7f8eac into dev Jul 22, 2026
15 checks passed
@patrickrb
patrickrb deleted the optio/task-5b2d0f79-f7cd-45ca-a6eb-cfa87986b938 branch July 22, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants