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 97ab6a6dcd..8dd8526f1c 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 @@ -12,6 +12,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.UiThread; import androidx.constraintlayout.widget.ConstraintLayout; import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; @@ -20,7 +21,9 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateList 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.network.utils.Util; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.ThreadUtils; import org.jetbrains.annotations.NotNull; @@ -40,7 +43,8 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS public class SteeringWheelView extends ConstraintLayout { private static final String TAG = "SteeringWheelView"; private ImageView autopilotIV; - private TextView steeringTV; + private TextView steeringTVL; + private TextView steeringTVR; private TapPositionView tapPositionView; private CircularProgressView steeringCircularV; private RotateAnimation rotateAnimation; @@ -62,13 +66,13 @@ public class SteeringWheelView extends ConstraintLayout { private void initView() { autopilotIV = (ImageView) findViewById(R.id.autopilot_iv); - steeringTV = findViewById(R.id.steering_tv); + steeringTVL = findViewById(R.id.steering_tv_left); + steeringTVR = findViewById(R.id.steering_tv_right); tapPositionView = findViewById(R.id.tap_position); steeringCircularV = findViewById(R.id.steering_circular); steeringCircularV.setBackWidth(8); steeringCircularV.setBackColor(R.color.hmi_light_blue_00); steeringCircularV.setProgColor(R.color.hmi_light_blue, R.color.hmi_dark_blue); - steeringCircularV.setProgress(10, 1000); } public SteeringWheelView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { @@ -94,24 +98,30 @@ public class SteeringWheelView extends ConstraintLayout { @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 (autopilotIV != null) { - Log.d(TAG, "autopilotIV != null"); - if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + ThreadUtils.runOnUiThread(new Runnable() { + @Override + public void run() { + if (autopilotStatusInfo == null) return; + int state = autopilotStatusInfo.getState(); + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "state = %s", state); + if (autopilotIV != null) { + Log.d(TAG, "autopilotIV != null"); + if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { - autopilotIV.setImageResource(R.drawable.bg_auto); + 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_ENABLE) { + autopilotIV.setImageResource(R.drawable.bg_auto_nor); - } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { - autopilotIV.setImageResource(R.drawable.bg_auto_nor); + } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { + autopilotIV.setImageResource(R.drawable.bg_auto_nor); + } + } else { + Log.d(TAG, "autopilotIV=null"); + } } - } else { - Log.d(TAG, "autopilotIV=null"); - } + }); + } @Override @@ -139,15 +149,34 @@ public class SteeringWheelView extends ConstraintLayout { Log.d(TAG, "刹车灯:" + String.valueOf(brakeLight)); } + /** + * 方向盘转向角 + * @param steering + */ @Override public void onAutopilotSteeringData(float steering) { - if (steeringTV != null && String.valueOf(steering) != null) { - steeringTV.setText(String.valueOf(steering) + "°"); - steeringCircularV.setProgress((int) steering, 1000); - animationWithSteeringData(steering); - } else { - Log.d(TAG, "steering未呈现"); - } + ThreadUtils.runOnUiThread(new Runnable() { + @Override + public void run() { + Log.d(TAG, "steering" + String.valueOf(steering)); + if (steeringTVL != null && steering < 0) { + steeringTVR.setVisibility(View.INVISIBLE); + steeringTVL.setVisibility(View.VISIBLE); + steeringTVL.setText(String.valueOf((int) steering) + "°"); + steeringCircularV.setProgress((int) steering, 1000); + animationWithSteeringData(steering); + } else if (steeringTVR != null && steering > 0) { + steeringTVL.setVisibility(View.INVISIBLE); + steeringTVR.setVisibility(View.VISIBLE); + steeringTVR.setText(String.valueOf((int) steering) + "°"); + steeringCircularV.setProgress((int) steering, 1000); + animationWithSteeringData(steering); + } else { + Log.d(TAG, "onAutopilotSteeringData error"); + } + } + }); + } /** @@ -156,10 +185,16 @@ public class SteeringWheelView extends ConstraintLayout { */ @Override public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) { - Log.d(TAG, "档位" + gear.toString()); - if (tapPositionView != null) { - tapPositionView.updateWithGear(gear); - } + ThreadUtils.runOnUiThread(new Runnable() { + @Override + public void run() { + Log.d(TAG, "档位" + gear.toString()); + if (tapPositionView != null) { + tapPositionView.updateWithGear(gear); + } + } + }); + } }; diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/monitoring/VehicleMonitoring.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/monitoring/VehicleMonitoring.java index b841092909..bca60eed1e 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/monitoring/VehicleMonitoring.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/monitoring/VehicleMonitoring.java @@ -14,7 +14,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; /** * @author liujing - * @description 车辆监控 + * @description 车辆监控,暂时隐藏该功能 * @since: 8/16/21 */ public class VehicleMonitoring implements Handler.Callback { @@ -34,31 +34,36 @@ public class VehicleMonitoring implements Handler.Callback { } public void vehicleCheck() { - if (AutopilotStatus == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { - CallerLogger.INSTANCE.d(M_HMI + TAG, "自动驾驶中..."); - mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY); - } else { - CallerLogger.INSTANCE.d(M_HMI + TAG, "非自动驾驶状态"); - //非自动驾驶状态只展示一次 - mHandler.sendEmptyMessageDelayed(AutopilotStatus, MANUAL_CHECK_STATUS_DELAY); - } + //暂时隐藏自检功能 + /** + * + if (AutopilotStatus == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + CallerLogger.INSTANCE.d(M_HMI + TAG, "自动驾驶中..."); + mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY); + } else { + CallerLogger.INSTANCE.d(M_HMI + TAG, "非自动驾驶状态"); + //非自动驾驶状态只展示一次 + mHandler.sendEmptyMessageDelayed(AutopilotStatus, MANUAL_CHECK_STATUS_DELAY); + } + + */ } @Override public boolean handleMessage(Message msg) { - AutopilotStatus = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState(); - switch (msg.what) { - case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: - vehicleMonitor(); - mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY); - return true; - case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE: - case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE: - vehicleMonitor(); - mHandler.sendEmptyMessageDelayed(AutopilotStatus, MANUAL_CHECK_STATUS_DELAY); - return true; - default: - } +// AutopilotStatus = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState(); +// switch (msg.what) { +// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: +// vehicleMonitor(); +// mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY); +// return true; +// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE: +// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE: +// vehicleMonitor(); +// mHandler.sendEmptyMessageDelayed(AutopilotStatus, MANUAL_CHECK_STATUS_DELAY); +// return true; +// default: +// } return false; } 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 aa5a02d635..0dc4ac8ab0 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,15 +19,31 @@ app:layout_constraintTop_toTopOf="parent" /> + + 120px 37px 27px + 90px 144px + 186px 300px