[6.4.0][启自驾指引] 加速度值显示优化
This commit is contained in:
@@ -134,7 +134,7 @@ class TestAutoPilotBeforeLaunch {
|
|||||||
CallerChassisGearStateListenerManager.invokeAutopilotGearData(GEAR_R)
|
CallerChassisGearStateListenerManager.invokeAutopilotGearData(GEAR_R)
|
||||||
val current = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
|
val current = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
|
||||||
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(current.also { it.gnssSpeed = Random.nextInt(0 ..20).toFloat(); it.setAcceleration(Random.nextInt(-100, 100).toDouble()) }, DEFAULT)
|
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(current.also { it.gnssSpeed = Random.nextInt(0 ..20).toFloat(); it.setAcceleration(Random.nextInt(-100, 100).toDouble()) }, DEFAULT)
|
||||||
delay(Random.nextInt(10..50).toLong())
|
delay(Random.nextInt(100..500).toLong())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
launch(Dispatchers.IO) {
|
launch(Dispatchers.IO) {
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ interface IAutopilotPreLaunchStatus
|
|||||||
/**
|
/**
|
||||||
* 速度
|
* 速度
|
||||||
*/
|
*/
|
||||||
data class SpeedStatus(val speed: Float, var acc: Float): Status(), IAutopilotPreLaunchStatus {
|
data class SpeedStatus(val speed: Int, var acc: Float): Status(), IAutopilotPreLaunchStatus {
|
||||||
|
|
||||||
override fun isException(): Boolean {
|
override fun isException(): Boolean {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ internal class SpeedImpl(ctx: Context): IFlow<SpeedStatus>(ctx), IMoGoChassisLoc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var lastSpeed: Float? = null
|
private var lastSpeed: Int? = null
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var lastAcc: Float? = null
|
private var lastAcc: Float? = null
|
||||||
@@ -40,16 +40,20 @@ internal class SpeedImpl(ctx: Context): IFlow<SpeedStatus>(ctx), IMoGoChassisLoc
|
|||||||
|
|
||||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||||
var isChanged = false
|
var isChanged = false
|
||||||
if (lastSpeed != mogoLocation?.gnssSpeed) {
|
val speed = mogoLocation?.gnssSpeed?.toInt() ?: 0
|
||||||
|
if (lastSpeed != speed) {
|
||||||
isChanged = true
|
isChanged = true
|
||||||
lastSpeed = mogoLocation?.gnssSpeed
|
lastSpeed = speed
|
||||||
}
|
}
|
||||||
if (!isChanged && lastAcc != mogoLocation?.acceleration) {
|
val acceleration = mogoLocation?.acceleration?.toString()?.format("%.1")?.toFloat() ?: 0f
|
||||||
isChanged = true
|
if (!isChanged) {
|
||||||
lastAcc = mogoLocation?.acceleration
|
if (lastAcc != acceleration) {
|
||||||
|
isChanged = true
|
||||||
|
lastAcc = acceleration
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isChanged) {
|
if (isChanged) {
|
||||||
send(SpeedStatus(mogoLocation?.gnssSpeed ?: 0f, mogoLocation?.acceleration ?: 0f))
|
send(SpeedStatus(speed, acceleration))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ internal class StatusModel : ViewModel() {
|
|||||||
it += DoubleFlashStatus(0)
|
it += DoubleFlashStatus(0)
|
||||||
it += GearStatus(0)
|
it += GearStatus(0)
|
||||||
it += RouteDownloadStatus()
|
it += RouteDownloadStatus()
|
||||||
it += SpeedStatus(0f, 0f)
|
it += SpeedStatus(0, 0f)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,10 @@ import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_bra
|
|||||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_double_flash
|
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_double_flash
|
||||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_steer
|
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_steer
|
||||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.speed
|
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.speed
|
||||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.tv_brake_or_accelerator
|
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.tv_accelerator
|
||||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
import kotlin.text.*
|
||||||
|
|
||||||
class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||||
|
|
||||||
@@ -91,9 +92,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
|||||||
iv_brake_or_accelerator?.isSelected = isError
|
iv_brake_or_accelerator?.isSelected = isError
|
||||||
}
|
}
|
||||||
is BrakeStatus -> {
|
is BrakeStatus -> {
|
||||||
val angle = status.angle
|
|
||||||
iv_brake_or_accelerator?.isSelected = isError
|
iv_brake_or_accelerator?.isSelected = isError
|
||||||
tv_brake_or_accelerator?.text = "a:-${angle.toInt()}"
|
|
||||||
}
|
}
|
||||||
is DoubleFlashStatus -> {
|
is DoubleFlashStatus -> {
|
||||||
iv_double_flash?.isSelected = isError
|
iv_double_flash?.isSelected = isError
|
||||||
@@ -103,7 +102,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
|||||||
}
|
}
|
||||||
is SpeedStatus -> {
|
is SpeedStatus -> {
|
||||||
speed?.text = "${(abs(status.speed) * 3.6f).toInt()}"
|
speed?.text = "${(abs(status.speed) * 3.6f).toInt()}"
|
||||||
tv_brake_or_accelerator?.text = String.format("%.1f", status.acc)
|
tv_accelerator?.text = "a:" + String.format("%-3.1f", status.acc)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
Logger.d(TAG, "other state: $status")
|
Logger.d(TAG, "other state: $status")
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
android:layout_marginEnd="@dimen/dp_14"/>
|
android:layout_marginEnd="@dimen/dp_14"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_brake_or_accelerator"
|
android:id="@+id/tv_accelerator"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/dp_30"
|
android:textSize="@dimen/dp_30"
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
tools:text="a:-100"
|
tools:text="a:-100"
|
||||||
android:text="a:0"/>
|
android:text="a: 0.0"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</merge>
|
</merge>
|
||||||
Reference in New Issue
Block a user