Fixed antenna rotator control issue #69

This commit is contained in:
Arty Bishop committed 2021-10-27 21:47:02 +01:00
1 parent 55a827330f
commit db8fe3ce8d
3 files changed
+45 -58

No files matched your search

@@ -83,10 +83,6 @@ class PreferencesSource @Inject constructor(
const val keyPositionQTH = "setPositionQTH"
}
fun positionToQTH(lat: Double, lon: Double): String? {
return QthConverter.positionToQTH(lat, lon)
}
fun loadStationPosition(): GeoPos {
val defaultSP = "0.0"
val latitude = preferences.getString(keyLatitude, null) ?: defaultSP
@@ -185,11 +181,9 @@ class PreferencesSource @Inject constructor(
return preferences.getBoolean(keyRotator, false)
}
fun getRotatorServer(): Pair<String, Int>? {
return if (isRotatorEnabled()) {
val address = preferences.getString(keyRotatorAddress, null) ?: "127.0.0.1"
val port = preferences.getString(keyRotatorPort, null) ?: "4533"
Pair(address, port.toInt())
} else null
fun getRotatorServer(): Pair<String, Int> {
val address = preferences.getString(keyRotatorAddress, null) ?: "127.0.0.1"
val port = preferences.getString(keyRotatorPort, null) ?: "4533"
return Pair(address, port.toInt())
}
}
@@ -78,10 +78,6 @@ class RadarViewModel @Inject constructor(
private fun sendPassData(satPass: SatPass) {
viewModelScope.launch {
var satTrack: List<SatPos> = emptyList()
val rotatorPrefs = preferences.getRotatorServer()
if (rotatorPrefs != null) {
dataReporter.setupRotatorSocket(rotatorPrefs.first, rotatorPrefs.second)
}
if (!satPass.isDeepSpace) {
val startDate = Date(satPass.aosTime)
val endDate = Date(satPass.losTime)
@@ -89,9 +85,13 @@ class RadarViewModel @Inject constructor(
}
while (isActive) {
val satPos = predictor.getSatPos(satPass.satellite, stationPos, Date())
val azimuth = Math.toDegrees(satPos.azimuth).round(1)
val elevation = Math.toDegrees(satPos.elevation).round(1)
dataReporter.reportRotation(azimuth, elevation)
if (preferences.isRotatorEnabled()) {
val server = preferences.getRotatorServer().first
val port = preferences.getRotatorServer().second
val azimuth = Math.toDegrees(satPos.azimuth).round(1)
val elevation = Math.toDegrees(satPos.elevation).round(1)
dataReporter.reportRotation(server, port, azimuth, elevation)
}
_passData.postValue(RadarData(satPos, satTrack))
delay(1000)
}