[6.4.0][启自驾指引] 加速度值显示优化
This commit is contained in:
@@ -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 {
|
||||
return false
|
||||
|
||||
@@ -24,7 +24,7 @@ internal class SpeedImpl(ctx: Context): IFlow<SpeedStatus>(ctx), IMoGoChassisLoc
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var lastSpeed: Float? = null
|
||||
private var lastSpeed: Int? = null
|
||||
|
||||
@Volatile
|
||||
private var lastAcc: Float? = null
|
||||
@@ -40,16 +40,20 @@ internal class SpeedImpl(ctx: Context): IFlow<SpeedStatus>(ctx), IMoGoChassisLoc
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
var isChanged = false
|
||||
if (lastSpeed != mogoLocation?.gnssSpeed) {
|
||||
val speed = mogoLocation?.gnssSpeed?.toInt() ?: 0
|
||||
if (lastSpeed != speed) {
|
||||
isChanged = true
|
||||
lastSpeed = mogoLocation?.gnssSpeed
|
||||
lastSpeed = speed
|
||||
}
|
||||
if (!isChanged && lastAcc != mogoLocation?.acceleration) {
|
||||
isChanged = true
|
||||
lastAcc = mogoLocation?.acceleration
|
||||
val acceleration = mogoLocation?.acceleration?.toString()?.format("%.1")?.toFloat() ?: 0f
|
||||
if (!isChanged) {
|
||||
if (lastAcc != acceleration) {
|
||||
isChanged = true
|
||||
lastAcc = acceleration
|
||||
}
|
||||
}
|
||||
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 += GearStatus(0)
|
||||
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_steer
|
||||
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 kotlin.math.abs
|
||||
import kotlin.text.*
|
||||
|
||||
class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||
|
||||
@@ -91,9 +92,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||
iv_brake_or_accelerator?.isSelected = isError
|
||||
}
|
||||
is BrakeStatus -> {
|
||||
val angle = status.angle
|
||||
iv_brake_or_accelerator?.isSelected = isError
|
||||
tv_brake_or_accelerator?.text = "a:-${angle.toInt()}"
|
||||
}
|
||||
is DoubleFlashStatus -> {
|
||||
iv_double_flash?.isSelected = isError
|
||||
@@ -103,7 +102,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||
}
|
||||
is SpeedStatus -> {
|
||||
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 -> {
|
||||
Logger.d(TAG, "other state: $status")
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
android:layout_marginEnd="@dimen/dp_14"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_brake_or_accelerator"
|
||||
android:id="@+id/tv_accelerator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/dp_30"
|
||||
@@ -141,7 +141,7 @@
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/white"
|
||||
tools:text="a:-100"
|
||||
android:text="a:0"/>
|
||||
android:text="a: 0.0"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
Reference in New Issue
Block a user