fix(radar): 修复 offset slider 拖动时多普勒计算用旧值
问题:onValueChange 回调里 offsetHz 是派生状态的旧快照,拖动时计算的频率滞后一帧。 修复:在回调内立即从 newVal 计算 newOffsetHz,传给多普勒计算器。 影响:拖动 offset 时频率显示实时正确。
This commit is contained in:
1 parent
cf93ca9f71
commit
e69d6dee4a
1 file changed
+3
-2
@@ -593,13 +593,14 @@ private fun DopplerFrequencyCalculator(
|
||||
value = offsetKHz,
|
||||
onValueChange = { newVal ->
|
||||
offsetKHz = newVal
|
||||
val newOffsetHz = newVal.toDoubleOrNull()?.let { it * 1000 }?.toLong() ?: 0L
|
||||
// Trigger recompute based on last edited field
|
||||
if (lastEditedBy == EditedField.TX) {
|
||||
val txMHz = txInputMHz.toDoubleOrNull()
|
||||
if (txMHz != null && txMHz > 0) {
|
||||
val txHz = (txMHz * 1_000_000).toLong()
|
||||
val rxHz = DopplerFrequencyCalculator.computeDownlinkFromUplinkWithOffset(
|
||||
txHz, transponder, orbitalPos, offsetHz
|
||||
txHz, transponder, orbitalPos, newOffsetHz
|
||||
)
|
||||
rxInputMHz = if (rxHz != null) String.format(Locale.ENGLISH, "%.6f", rxHz / 1_000_000.0) else ""
|
||||
}
|
||||
@@ -608,7 +609,7 @@ private fun DopplerFrequencyCalculator(
|
||||
if (rxMHz != null && rxMHz > 0) {
|
||||
val rxHz = (rxMHz * 1_000_000).toLong()
|
||||
val txHz = DopplerFrequencyCalculator.computeUplinkFromDownlinkWithOffset(
|
||||
rxHz, transponder, orbitalPos, offsetHz
|
||||
rxHz, transponder, orbitalPos, newOffsetHz
|
||||
)
|
||||
txInputMHz = if (txHz != null) String.format(Locale.ENGLISH, "%.6f", txHz / 1_000_000.0) else ""
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user