From 8b13a991f8d8c993569475710dda5b52551a16ee Mon Sep 17 00:00:00 2001 From: liujing Date: Thu, 7 Apr 2022 20:05:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=A3=E4=BD=8D+=E8=87=AA=E5=8A=A8=E9=A9=BE?= =?UTF-8?q?=E9=A9=B6=E7=8A=B6=E6=80=81=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E7=BC=BA=E5=B0=91=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E6=96=B9=E5=90=91=E7=9B=98=E8=BD=AC=E8=A7=92,=E6=96=B9?= =?UTF-8?q?=E5=90=91=E7=9B=98=E5=8A=A8=E7=94=BB=20=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E5=A4=96=E5=B1=82=E5=9C=86=E5=BD=A2=E8=BF=9B=E5=BA=A6=E6=9D=A1?= =?UTF-8?q?=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmi/ui/widget/SteeringWheelView.java | 84 +++++++++++++++++++ .../hmi/ui/widget/TapPositionView.java | 48 ++++++++++- .../main/res/layout/hmi_steering_wheel.xml | 1 + 3 files changed, 132 insertions(+), 1 deletion(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java index ed6f67ba54..f6f59bfa29 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java @@ -4,12 +4,28 @@ import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; +import android.widget.ImageView; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.ConstraintLayout; +import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener; +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager; import com.mogo.eagle.core.function.hmi.R; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; + +import org.jetbrains.annotations.NotNull; + +import chassis.Chassis; +import mogo.telematics.pad.MessagePad; +import mogo_msg.MogoReportMsg; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; /** * @author Jing @@ -18,10 +34,78 @@ import com.mogo.eagle.core.function.hmi.R; */ public class SteeringWheelView extends ConstraintLayout { private static final String TAG = "SteeringWheelView"; + private ImageView autopilotIV; + private TextView steeringTV; + private TapPositionView tapPositionView; public SteeringWheelView(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); LayoutInflater.from(context).inflate(R.layout.hmi_steering_wheel, this); Log.d(TAG, "2"); + CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener); + CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener); + autopilotIV = findViewById(R.id.autopilot_iv); + steeringTV = findViewById(R.id.steering_tv); + tapPositionView = findViewById(R.id.tap_position); } + + private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener() { + @Override + public void onAutopilotArriveAtStation(@org.jetbrains.annotations.Nullable MessagePad.ArrivalNotification arrivalNotification) { + + } + + @Override + public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) { + + } + + @Override + public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) { + if (autopilotStatusInfo == null) return; + int state = autopilotStatusInfo.getState(); + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "state = %s", state); + if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + autopilotIV.setImageResource(R.drawable.bg_auto); + + } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) { + autopilotIV.setImageResource(R.drawable.bg_auto_nor); + + } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { + autopilotIV.setImageResource(R.drawable.bg_auto_nor); + } + } + + @Override + public void onAutopilotSNRequest() { + + } + }; + + private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() { + @Override + public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) { + + } + + @Override + public void onAutopilotBrakeLightData(boolean brakeLight) { + + } + + @Override + public void onAutopilotSteeringData(float steering) { + steeringTV.setText(String.valueOf(steering) + "°"); + } + + /** + * 档位 + * @param gear + */ + @Override + public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) { + Log.d(TAG, "档位" + gear.toString()); + + } + }; } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TapPositionView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TapPositionView.java index f0717ea872..afb2ce5140 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TapPositionView.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TapPositionView.java @@ -1,6 +1,7 @@ package com.mogo.eagle.core.function.hmi.ui.widget; import android.content.Context; +import android.graphics.Color; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; @@ -12,9 +13,13 @@ import androidx.constraintlayout.widget.ConstraintLayout; import com.mogo.eagle.core.function.hmi.R; +import org.jetbrains.annotations.NotNull; + +import chassis.Chassis; + /** * @author Jing - * @description 档位 + * @description 方向盘下方的档位 * @since: 4/7/22 */ public class TapPositionView extends ConstraintLayout { @@ -28,6 +33,47 @@ public class TapPositionView extends ConstraintLayout { super(context, attrs); Log.d(TAG, "2"); LayoutInflater.from(context).inflate(R.layout.hmi_tap_position, this); + tabP = findViewById(R.id.tap_p); + tabR = findViewById(R.id.tap_r); + tabN = findViewById(R.id.tap_n); + tabD = findViewById(R.id.tap_d); + } + public void updateWithGear(@NotNull Chassis.GearPosition gear) { + + switch (gear) { + case GEAR_NONE: + tabP.setTextColor(Color.parseColor("#6E8EC9")); + tabR.setTextColor(Color.parseColor("#6E8EC9")); + tabN.setTextColor(Color.parseColor("#6E8EC9")); + tabD.setTextColor(Color.parseColor("#6E8EC9")); + break; + case GEAR_P: + tabP.setTextColor(Color.parseColor("#0043FF")); + tabR.setTextColor(Color.parseColor("#6E8EC9")); + tabN.setTextColor(Color.parseColor("#6E8EC9")); + tabD.setTextColor(Color.parseColor("#6E8EC9")); + break; + case GEAR_R: + tabR.setTextColor(Color.parseColor("#0043FF")); + tabP.setTextColor(Color.parseColor("#6E8EC9")); + tabN.setTextColor(Color.parseColor("#6E8EC9")); + tabD.setTextColor(Color.parseColor("#6E8EC9")); + break; + case GEAR_N: + tabN.setTextColor(Color.parseColor("#0043FF")); + tabR.setTextColor(Color.parseColor("#6E8EC9")); + tabP.setTextColor(Color.parseColor("#6E8EC9")); + tabD.setTextColor(Color.parseColor("#6E8EC9")); + break; + case GEAR_D: + tabD.setTextColor(Color.parseColor("#0043FF")); + tabN.setTextColor(Color.parseColor("#6E8EC9")); + tabR.setTextColor(Color.parseColor("#6E8EC9")); + tabP.setTextColor(Color.parseColor("#6E8EC9")); + break; + default: + break; + } } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_steering_wheel.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_steering_wheel.xml index c07bc7e423..016545b117 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_steering_wheel.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_steering_wheel.xml @@ -19,6 +19,7 @@ app:layout_constraintTop_toTopOf="parent" />