[3.2.0] 司机端增加魔方功能opt
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package com.mogo.och.common.module.manager
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendOperatorSetAcceleratedSpeed
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendOperatorSetHorn
|
||||
import java.util.*
|
||||
|
||||
|
||||
/**
|
||||
* 魔方连接状态和设备管理
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
class DriverMoFangFunctionManager private constructor() {
|
||||
|
||||
companion object {
|
||||
val driverMoFangFunctionManager: DriverMoFangFunctionManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
DriverMoFangFunctionManager()
|
||||
}
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
private val TAG = "DriverMoFangFunctionManager"
|
||||
private var startPressTime: Long = 0 //开始按键时间
|
||||
private var isPressEnd = false //按键是否结束
|
||||
|
||||
private var timerHorn: Timer? = null
|
||||
private var timerAcc: Timer? = null
|
||||
|
||||
|
||||
fun init(context: Context) {
|
||||
mContext = context
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送加速和减速,复位的时候,isSend为false,其他都是true,acc就是具体的值
|
||||
*/
|
||||
@Synchronized
|
||||
fun sendAcc(isSend: Boolean, acc: Double) {
|
||||
if (isSend) {
|
||||
if (timerAcc == null) {
|
||||
timerAcc = Timer()
|
||||
timerAcc!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
sendOperatorSetAcceleratedSpeed(acc)
|
||||
}
|
||||
}, 0, 500)
|
||||
}
|
||||
} else {
|
||||
if (timerAcc != null) {
|
||||
timerAcc!!.cancel()
|
||||
timerAcc = null
|
||||
}
|
||||
sendOperatorSetAcceleratedSpeed(acc)
|
||||
}
|
||||
}
|
||||
|
||||
fun reset(){
|
||||
sendAcc(false,0.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* 鸣笛,鸣笛需要手动结束
|
||||
*/
|
||||
fun sendOperatorSetHornByDriver(){
|
||||
sendOperatorSetHorn(1.0)
|
||||
if (timerHorn == null) {
|
||||
timerHorn = Timer()
|
||||
}
|
||||
timerHorn!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
sendOperatorSetHorn(2.0)
|
||||
timerHorn = null
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mogo.och.common.module.wigets
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.och.common.module.R
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/4/20
|
||||
*/
|
||||
class DriverMoFangFunctionView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : ConstraintLayout(context, attrs) {
|
||||
init {
|
||||
// LayoutInflater.from(context).inflate(R.layout.driver_mofang_function_view)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user