From bee5ce22228ad1ea5cb8c40896d42be2b8b15b63 Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Thu, 20 Apr 2023 15:11:14 +0800 Subject: [PATCH] =?UTF-8?q?[3.2.0]=20=E5=8F=B8=E6=9C=BA=E7=AB=AF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=AD=94=E6=96=B9=E5=8A=9F=E8=83=BDopt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/DriverMoFangFunctionManager.kt | 79 +++++++++++++++++++ .../module/wigets/DriverMoFangFunctionView.kt | 19 +++++ .../layout/driver_mofang_function_view.xml | 8 ++ 3 files changed, 106 insertions(+) create mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/DriverMoFangFunctionManager.kt create mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/DriverMoFangFunctionView.kt create mode 100644 OCH/mogo-och-common-module/src/main/res/layout/driver_mofang_function_view.xml diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/DriverMoFangFunctionManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/DriverMoFangFunctionManager.kt new file mode 100644 index 0000000000..668332d442 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/DriverMoFangFunctionManager.kt @@ -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) + } + +} + diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/DriverMoFangFunctionView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/DriverMoFangFunctionView.kt new file mode 100644 index 0000000000..d5d236204d --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/DriverMoFangFunctionView.kt @@ -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) + } +} \ No newline at end of file diff --git a/OCH/mogo-och-common-module/src/main/res/layout/driver_mofang_function_view.xml b/OCH/mogo-och-common-module/src/main/res/layout/driver_mofang_function_view.xml new file mode 100644 index 0000000000..4d4560d0ac --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/res/layout/driver_mofang_function_view.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file