mirror of
https://github.com/rt-bishop/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Simplified data output code, aligned with HamLib defaults
This commit is contained in:
1 parent
3f981c09d5
commit
868155c532
5 files changed
+66
-36
No files matched your search
@@ -129,7 +129,6 @@ class RadarViewModel(
|
||||
}
|
||||
processRadios(transmitters, satPass.orbitalObject, timeNow)
|
||||
sendPassData(pos)
|
||||
sendPassDataBT(pos)
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
@@ -149,33 +148,35 @@ class RadarViewModel(
|
||||
}
|
||||
|
||||
private fun sendPassData(orbitalPos: OrbitalPos) {
|
||||
viewModelScope.launch {
|
||||
val rc = settingsRepo.rcSettings.value
|
||||
if (rc.rotatorState) {
|
||||
val azimuth = orbitalPos.azimuth.toDegrees().round(2)
|
||||
val elevation = orbitalPos.elevation.toDegrees().round(2)
|
||||
networkReporter.reportRotation(rc.rotatorFormat, azimuth, elevation)
|
||||
}
|
||||
if (rc.frequencyState) {
|
||||
_uiState.value.selectedFrequency?.let { freq ->
|
||||
networkReporter.reportFrequency(rc.frequencyFormat, freq)
|
||||
}
|
||||
}
|
||||
}
|
||||
val rc = settingsRepo.rcSettings.value
|
||||
sendReporterData(
|
||||
networkReporter, orbitalPos,
|
||||
rc.rotatorState, rc.rotatorFormat,
|
||||
rc.frequencyState, rc.frequencyFormat
|
||||
)
|
||||
sendReporterData(
|
||||
bluetoothReporter, orbitalPos,
|
||||
rc.bluetoothRotatorState, rc.bluetoothRotatorFormat,
|
||||
rc.bluetoothFrequencyState, rc.bluetoothFrequencyFormat
|
||||
)
|
||||
}
|
||||
|
||||
private fun sendPassDataBT(orbitalPos: OrbitalPos) {
|
||||
viewModelScope.launch {
|
||||
val rc = settingsRepo.rcSettings.value
|
||||
if (rc.bluetoothRotatorState) {
|
||||
val azimuth = orbitalPos.azimuth.toDegrees().round(0)
|
||||
val elevation = orbitalPos.elevation.toDegrees().round(0)
|
||||
bluetoothReporter.reportRotation(rc.bluetoothRotatorFormat, azimuth, elevation)
|
||||
}
|
||||
if (rc.bluetoothFrequencyState) {
|
||||
_uiState.value.selectedFrequency?.let { freq ->
|
||||
bluetoothReporter.reportFrequency(rc.bluetoothFrequencyFormat, freq)
|
||||
}
|
||||
private fun sendReporterData(
|
||||
reporter: IReporter,
|
||||
orbitalPos: OrbitalPos,
|
||||
rotatorEnabled: Boolean,
|
||||
rotatorFormat: String,
|
||||
frequencyEnabled: Boolean,
|
||||
frequencyFormat: String
|
||||
) {
|
||||
if (rotatorEnabled) {
|
||||
val azimuth = orbitalPos.azimuth.toDegrees().round(2)
|
||||
val elevation = orbitalPos.elevation.toDegrees().round(2)
|
||||
reporter.reportRotation(rotatorFormat, azimuth, elevation)
|
||||
}
|
||||
if (frequencyEnabled) {
|
||||
_uiState.value.selectedFrequency?.let { freq ->
|
||||
reporter.reportFrequency(frequencyFormat, freq)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -216,12 +216,12 @@ fun PreviewNetworkOutputDialog() {
|
||||
frequencyPort = "4532",
|
||||
frequencyFormat = $$"F $FREQ",
|
||||
bluetoothRotatorState = false,
|
||||
bluetoothRotatorFormat = $$"W$AZ $EL",
|
||||
bluetoothRotatorFormat = $$"P $AZ $EL",
|
||||
bluetoothRotatorName = "Default",
|
||||
bluetoothRotatorAddress = "00:0C:BF:13:80:5D",
|
||||
bluetoothFrequencyState = false,
|
||||
bluetoothFrequencyAddress = "00:0C:BF:13:80:5D",
|
||||
bluetoothFrequencyFormat = $$"FA$FREQ"
|
||||
bluetoothFrequencyFormat = $$"F $FREQ"
|
||||
),
|
||||
onDismiss = {},
|
||||
onSave = { _, _, _, _, _, _, _, _ -> }
|
||||
@@ -361,14 +361,14 @@ fun PreviewBluetoothOutputDialog() {
|
||||
frequencyState = false,
|
||||
frequencyAddress = "127.0.0.1",
|
||||
frequencyPort = "4532",
|
||||
frequencyFormat = $$"set_freq $FREQ",
|
||||
frequencyFormat = $$"F $FREQ",
|
||||
bluetoothRotatorState = false,
|
||||
bluetoothRotatorFormat = $$"W$AZ $EL",
|
||||
bluetoothRotatorFormat = $$"P $AZ $EL",
|
||||
bluetoothRotatorName = "Default",
|
||||
bluetoothRotatorAddress = "00:0C:BF:13:80:5D",
|
||||
bluetoothFrequencyState = false,
|
||||
bluetoothFrequencyAddress = "00:0C:BF:13:80:5D",
|
||||
bluetoothFrequencyFormat = $$"FA$FREQ"
|
||||
bluetoothFrequencyFormat = $$"F $FREQ"
|
||||
),
|
||||
onDismiss = {},
|
||||
onSave = { _, _, _, _, _, _ -> }
|
||||
|
||||
Reference in new issue
Block a user