diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt
index 66be06132d..eaa0cc7885 100644
--- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt
+++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt
@@ -16,23 +16,27 @@ import com.mogo.eagle.core.function.hmi.R
* @since: 2022/1/14
*/
class CircularProgressView @JvmOverloads constructor(
- context: Context, attrs: AttributeSet?, defStyleAttr : Int)
- : View(context, attrs, defStyleAttr){
+ context: Context, attrs: AttributeSet?, defStyleAttr: Int)
+ : View(context, attrs, defStyleAttr) {
+
+ val typedArray: TypedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularProgressView)
- val typedArray : TypedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularProgressView)
// 绘制画笔
- private val mBackPaint : Paint = Paint()
- private val mProgPaint : Paint = Paint()
+ private val mBackPaint: Paint = Paint()
+ private val mProgPaint: Paint = Paint()
+
// 绘制区域
- private var mRectF : RectF? = null
+ private var mRectF: RectF? = null
+
// 圆环渐变色
- private var mColorArray : IntArray?=null
+ private var mColorArray: IntArray? = null
+
// 圆环进度(0-100) 初始化进度
- private var mProgress : Int = typedArray.getInteger(R.styleable.CircularProgressView_progress, 0)
+ private var mProgress: Int = typedArray.getInteger(R.styleable.CircularProgressView_progress, 0)
- constructor(context : Context) : this(context,null)
+ constructor(context: Context) : this(context, null)
- constructor(context : Context,attrs : AttributeSet?) :this(context, attrs, 0)
+ constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
init {
// 初始化背景圆环画笔
@@ -52,9 +56,9 @@ class CircularProgressView @JvmOverloads constructor(
// 初始化进度圆环渐变色
val startColor = typedArray.getColor(R.styleable.CircularProgressView_progStartColor, -1)
val firstColor = typedArray.getColor(R.styleable.CircularProgressView_progFirstColor, -1)
- if(startColor != -1 && firstColor != -1){
- mColorArray = intArrayOf(startColor,firstColor)
- }else{
+ if (startColor != -1 && firstColor != -1) {
+ mColorArray = intArrayOf(startColor, firstColor)
+ } else {
mColorArray = null
}
@@ -67,16 +71,16 @@ class CircularProgressView @JvmOverloads constructor(
val viewWide = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
val viewHigh = getMeasuredHeight() - getPaddingTop() - getPaddingBottom();
val mRectLength =
- ((if (viewWide > viewHigh) viewHigh else viewWide) - if (mBackPaint.strokeWidth > mProgPaint.strokeWidth) mBackPaint.strokeWidth else mProgPaint.strokeWidth).toInt()
+ ((if (viewWide > viewHigh) viewHigh else viewWide) - if (mBackPaint.strokeWidth > mProgPaint.strokeWidth) mBackPaint.strokeWidth else mProgPaint.strokeWidth).toInt()
val mRectL = getPaddingLeft() + (viewWide - mRectLength) / 2
val mRectT = getPaddingTop() + (viewHigh - mRectLength) / 2
mRectF = RectF(mRectL.toFloat(), mRectT.toFloat(), (mRectL + mRectLength).toFloat(),
- (mRectT + mRectLength).toFloat())
+ (mRectT + mRectLength).toFloat())
// 设置进度圆环渐变色
mColorArray?.let {
mProgPaint.shader = LinearGradient(
- 0.0f, 0.0f, 0.0f,
- measuredWidth.toFloat(), it, null, Shader.TileMode.MIRROR)
+ 0.0f, 0.0f, 0.0f,
+ measuredWidth.toFloat(), it, null, Shader.TileMode.MIRROR)
}
}
@@ -84,9 +88,11 @@ class CircularProgressView @JvmOverloads constructor(
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
canvas?.let {
- mRectF?.let { it1 -> it.drawArc(it1, 0.0f, 360.0f, false, mBackPaint) }
- mRectF?.let { it1 -> it.drawArc(it1, 275.0f,
- (360 * mProgress / 100).toFloat(), false, mProgPaint) }
+ mRectF?.let { it1 -> it.drawArc(it1, 0.0f, 360.0f, false, mBackPaint) }
+ mRectF?.let { it1 ->
+ it.drawArc(it1, 275.0f,
+ (360 * mProgress / 100).toFloat(), false, mProgPaint)
+ }
}
}
@@ -95,7 +101,7 @@ class CircularProgressView @JvmOverloads constructor(
* 获取当前进度
* @return 当前进度(0-100)
*/
- fun getProgress() : Int{
+ fun getProgress(): Int {
return mProgress
}
@@ -103,7 +109,7 @@ class CircularProgressView @JvmOverloads constructor(
* 设置当前进度
* @param progress 当前进度(0-100)
*/
- fun setProgress(progress : Int){
+ fun setProgress(progress: Int) {
mProgress = progress
invalidate()
}
@@ -113,12 +119,12 @@ class CircularProgressView @JvmOverloads constructor(
* @param progress 当前进度(0-100)
* @param animTime 动画时间(毫秒)
*/
- fun setProgress(progress : Int, animTime : Long){
- if (animTime<=0){
+ fun setProgress(progress: Int, animTime: Long) {
+ if (animTime <= 0) {
setProgress(progress)
- } else{
+ } else {
val animator = ValueAnimator.ofInt(mProgress, progress)
- animator.addUpdateListener{
+ animator.addUpdateListener {
mProgress = it.animatedValue as Int
invalidate()
}
@@ -132,7 +138,7 @@ class CircularProgressView @JvmOverloads constructor(
* 设置背景圆环宽度
* @param width 背景圆环宽度
*/
- fun setBackWidth(width : Int){
+ fun setBackWidth(width: Int) {
mBackPaint.strokeWidth = width.toFloat()
invalidate()
}
@@ -141,8 +147,8 @@ class CircularProgressView @JvmOverloads constructor(
* 设置背景圆环颜色
* @param color 背景圆环颜色
*/
- fun setBackColor(color : Int){
- mBackPaint.color = ContextCompat.getColor(context,color)
+ fun setBackColor(color: Int) {
+ mBackPaint.color = ContextCompat.getColor(context, color)
invalidate()
}
@@ -150,39 +156,49 @@ class CircularProgressView @JvmOverloads constructor(
* 设置进度圆环宽度
* @param width 进度圆环宽度
*/
- fun setProgWidth(width : Int){
+ fun setProgWidth(width: Int) {
mProgPaint.strokeWidth = width.toFloat()
invalidate()
}
/**
- * 设置进度圆环颜色
+ * 设置进度圆环渐变色起始色
* @param color 景圆环颜色
*/
- fun setProgColor(color : Int){
- mProgPaint.color = ContextCompat.getColor(context,color)
+ fun setProgColor(color: Int) {
+ mProgPaint.color = ContextCompat.getColor(context, color)
mProgPaint.shader = null
invalidate()
}
- fun setProgColor(startColor : Int,endColor: Int){
- mColorArray = intArrayOf(ContextCompat.getColor(context,startColor),ContextCompat.getColor(context,endColor))
+
+ /**
+ * 渐变色结束色
+ */
+ fun setProgFirstColor(color: Int) {
+ mProgPaint.color = ContextCompat.getColor(context, color)
+ mProgPaint.shader = null
+ invalidate()
+ }
+
+ fun setProgColor(startColor: Int, endColor: Int) {
+ mColorArray = intArrayOf(ContextCompat.getColor(context, startColor), ContextCompat.getColor(context, endColor))
mColorArray?.let {
mProgPaint.shader = LinearGradient(0f, 0f, 0f,
- getMeasuredWidth().toFloat(), it, null, Shader.TileMode.MIRROR)
+ getMeasuredWidth().toFloat(), it, null, Shader.TileMode.MIRROR)
}
}
- fun setProgColor(colorArray : IntArray){
+ fun setProgColor(colorArray: IntArray) {
colorArray.let {
- if(it.size<2){
+ if (it.size < 2) {
return
}
mColorArray = it.copyOf()
- mColorArray?.let{
+ mColorArray?.let {
mProgPaint.shader = LinearGradient(0f, 0f, 0f,
- getMeasuredWidth().toFloat(), it, null, Shader.TileMode.MIRROR)
+ getMeasuredWidth().toFloat(), it, null, Shader.TileMode.MIRROR)
}
}
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 f6f59bfa29..6adfdd1cca 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
@@ -37,16 +37,23 @@ public class SteeringWheelView extends ConstraintLayout {
private ImageView autopilotIV;
private TextView steeringTV;
private TapPositionView tapPositionView;
+ private CircularProgressView steeringCircularV;
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);
+ steeringCircularV = findViewById(R.id.steering_circular);
+ steeringCircularV.setBackWidth(8);
+ steeringCircularV.setBackColor(R.color.hmi_light_blue_00);
+ steeringCircularV.setProgColor(R.color.hmi_light_blue);
+ steeringCircularV.setProgFirstColor(R.color.hmi_dark_blue);
+ steeringCircularV.setProgress(20, 20);
+ tapPositionView.updateWithGear(Chassis.GearPosition.GEAR_R);
}
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener() {
@@ -65,14 +72,18 @@ public class SteeringWheelView extends ConstraintLayout {
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);
+ if (autopilotIV != null) {
+ Log.d(TAG, "autopilotIV != null");
+ if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
- } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
- autopilotIV.setImageResource(R.drawable.bg_auto_nor);
+ autopilotIV.setImageResource(R.drawable.bg_auto);
- } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
- 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);
+ }
}
}
@@ -83,19 +94,31 @@ public class SteeringWheelView extends ConstraintLayout {
};
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
+ /**
+ * 车辆转向灯
+ * @param lightSwitch
+ */
@Override
public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) {
-
+ Log.d(TAG, "车辆转向灯:" + lightSwitch.toString());
}
+ /**
+ * 刹车灯
+ * @param brakeLight
+ */
@Override
public void onAutopilotBrakeLightData(boolean brakeLight) {
-
+ Log.d(TAG, "刹车灯:" + String.valueOf(brakeLight));
}
@Override
public void onAutopilotSteeringData(float steering) {
- steeringTV.setText(String.valueOf(steering) + "°");
+ if (steeringTV != null && String.valueOf(steering) != null) {
+ steeringTV.setText(String.valueOf(steering) + "°");
+ } else {
+ Log.d(TAG, "steering未呈现");
+ }
}
/**
@@ -105,7 +128,10 @@ public class SteeringWheelView extends ConstraintLayout {
@Override
public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) {
Log.d(TAG, "档位" + gear.toString());
-
+ if (tapPositionView != null) {
+ tapPositionView.updateWithGear(gear);
+ }
}
};
+
}
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/color/taxi_steering_wheel_color_selector.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/color/taxi_steering_wheel_color_selector.xml
deleted file mode 100644
index 0d2bcb88d7..0000000000
--- a/core/function-impl/mogo-core-function-hmi/src/main/res/color/taxi_steering_wheel_color_selector.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
- -
-
-
-
-
-
-
\ No newline at end of file
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 016545b117..5108cbb5d9 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
@@ -31,15 +31,15 @@
app:layout_constraintTop_toTopOf="parent" />
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml
index bd4ed43a04..5bc14b5b52 100644
--- a/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml
+++ b/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml
@@ -53,4 +53,7 @@
#FF006D43
#FFFFE198
#FFFF9B00
+ #45D3FF
+ #1B5BFF
+ #0045D3FF
\ No newline at end of file