瀏覽代碼

正反转bug处理

zhangshenjie 1 月之前
父節點
當前提交
dfc8285601

+ 3 - 2
BusinessCommon/src/main/java/com/develop/common/utils/TuyaUtilsSo.java

@@ -306,7 +306,7 @@ public class TuyaUtilsSo {
                     BaseDevMode modes = info.getMode();
                     if (modes.isMotorDirectionChange()) {
                         //正反转
-                        CofarSDK.cfgMotorDirection((int) boolValue == 0 ? MotorDirections.FORWARD : MotorDirections.REVERSE);
+                        CofarSDK.cfgMotorDirectionNative((int) boolValue == 0 ? MotorDirections.FORWARD : MotorDirections.REVERSE);
                         //按照以前的涂鸦,上面修改转向没有图标没有变动,估在发送一个eventbus
                         tuyaEvent("change_direction");
                     }
@@ -589,7 +589,8 @@ public class TuyaUtilsSo {
 
                 int automatic = getModes(info.getRunningInstId());
 
-
+            Log.v("tuya_iot","CofarSDK.devInfo().getMotorDirection() :"+info.getMotorDirection());
+                Log.v("tuya_iot","CofarSDK.devInfo().getMotorDirectionBuffer() :"+info.getMotorDirectionBuffer());
                 List<DPEvent> dpEvents = new ArrayList<>(Arrays.asList(
                         new DPEvent(TuyaSoDp.ON_OFF, (byte) DPEvent.Type.PROP_BOOL, 1, 0),
                         new DPEvent(TuyaSoDp.START_STOP, (byte) DPEvent.Type.PROP_BOOL, start_stop, 0),

+ 24 - 2
BusinessStep/src/main/java/com/develop/step/ui/ModesDetailActivity.kt

@@ -400,6 +400,9 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         viewModel.stopTurbo()
         viewModel.cancelAnimator()
         hasShowScreenSaver = false
+
+
+
 //        TuyaUtilsSo.getInstance().sendDevReady(1) // 1表示设备不就绪
 
 
@@ -686,6 +689,16 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         }
 
         if ("stop" == event.type) {
+            /**
+             * 测出一个BUG ,在DIY模式中,先是反转运行,1速度,运行后点击暂停,然后换成正转
+             * 然后关闭页面,重新进来会默认是正转然后切换反转会导致反转也可以选择12速度
+             * 估在这,多加一个 CofarSDK.cancel()
+             * 和下面onCancel方法也加上
+             *
+             * 设备上暂停也会出现此问题,估在这多加cancel()
+             * **/
+            CofarSDK.cancel()
+
             stopClick()
         }
 
@@ -1503,6 +1516,14 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
             title = ctx.getString(com.develop.common.R.string.keep_cooking_in_the_background)
             onDialogClickListener = object : CancelConfirmDialog.OnDialogClickListener {
                 override fun onConfirm() {
+                    //先把缓存清了
+                    /**
+                     * 测出一个BUG ,在DIY模式中,先是反转运行,1速度,运行后点击暂停,然后换成正转
+                     * 然后关闭页面,重新进来会默认是正转然后切换反转会导致反转也可以选择12速度
+                     * 估在这,多加一个 CofarSDK.cancel()
+                     * 和下面onCancel方法也加上
+                     * **/
+                    CofarSDK.cancel()
                     if (CofarSDK.devInfo().status == DevStatus.STOP.toInt()) {
                         FloatWindowManager.hideStepFlowWindow()
                         finish()
@@ -1538,6 +1559,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
                 override fun onCancel() {
                     runOnMainThread {
                         FloatWindowManager.hideStepFlowWindow()
+                        CofarSDK.cancel()
                         CofarSDK.stop()
                         finish()
                         TuyaUtilsSo.getInstance().setDpCurrentActivity()
@@ -2904,12 +2926,12 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
             )
 
             if (direction != DirectionView.Direction.RIGHT) {
-                CofarSDK.cfgMotorDirection(MotorDirections.REVERSE);
+                CofarSDK.cfgMotorDirectionNative(MotorDirections.REVERSE);
                 updateMotorDirectionUI(MotorDirections.REVERSE.toInt(), true);
 
 
             } else {
-                CofarSDK.cfgMotorDirection(MotorDirections.FORWARD);
+                CofarSDK.cfgMotorDirectionNative(MotorDirections.FORWARD);
                 updateMotorDirectionUI(MotorDirections.FORWARD.toInt(), true);
 
             }