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" />