File tree Expand file tree Collapse file tree
AudioCoder/src/main/java/org/operatorfoundation/audiocoder Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,6 +177,30 @@ class WSPRTimingCoordinator
177177 )
178178 }
179179
180+ /* *
181+ * Calculates milliseconds until the next even minute boundary.
182+ *
183+ * Used for WSPR transmission timing — transmissions must begin at even minutes.
184+ * Unlike [calculateNextDecodeWindowStartTime], this returns the raw even minute
185+ * boundary with no decode start delay applied.
186+ *
187+ * @return Milliseconds until the next even minute boundary (always > 0)
188+ */
189+ fun getMillisUntilNextEvenMinute (): Long
190+ {
191+ val calendar = Calendar .getInstance()
192+ val currentMinute = calendar.get(Calendar .MINUTE )
193+ val currentSecond = calendar.get(Calendar .SECOND )
194+ val currentMillis = calendar.get(Calendar .MILLISECOND )
195+
196+ val cyclePosition = calculatePositionInCurrentWSPRCycle(currentMinute, currentSecond)
197+
198+ // Time remaining until end of current 2-minute cycle = start of next even minute.
199+ // Subtract currentMillis for sub-second precision.
200+ val secondsRemaining = WSPRTimingConstants .WSPR_CYCLE_DURATION_SECONDS - cyclePosition
201+ return (secondsRemaining * 1000L ) - currentMillis
202+ }
203+
180204 /* *
181205 * Provides real-time information about the current position within the WSPR cycle.
182206 *
You can’t perform that action at this time.
0 commit comments