|
@@ -104,21 +104,20 @@ export default {
|
|
|
|
|
|
sendToyPower_CheckReconected() {
|
|
|
let that = this;
|
|
|
-
|
|
|
let toy_intv = setInterval(() => {
|
|
|
let $game_status = game_store.getters.getGameStatus();
|
|
|
if ($game_status == 1) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ if (!connect_toy) {
|
|
|
+ wx.showToast({
|
|
|
+ title: `教具已断开`
|
|
|
+ })
|
|
|
+
|
|
|
+ that.SendOrder("09")
|
|
|
+ that.ReconnectToy()
|
|
|
+ clearInterval(toy_intv)
|
|
|
+ } else {
|
|
|
that.SendOrder('8a')
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
}, 3000)
|
|
|
},
|
|
@@ -275,8 +274,6 @@ export default {
|
|
|
} else {
|
|
|
clearInterval($rec)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}, 5000)
|
|
|
|
|
|
},
|
|
@@ -427,23 +424,25 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
if (hexStr.toUpperCase().indexOf("AADD8A") != -1) {
|
|
|
let $_hexStr = hexStr.substr(6);
|
|
|
let $power = parseInt($_hexStr.substr(0, 2), 16)
|
|
|
let $voltage = parseInt($_hexStr.substr(2, 2), 16)
|
|
|
- console.log("电量:" + $power)
|
|
|
- console.log("电压:" + $voltage / 10)
|
|
|
- $this.toy_power = $power;
|
|
|
+
|
|
|
+ $this.toy_power = Math.round(that.CalBLEPower($voltage));
|
|
|
+
|
|
|
|
|
|
+
|
|
|
if ($power != 0) {
|
|
|
connect_toy = true;
|
|
|
}
|
|
|
if (hexStr.toUpperCase().indexOf("FF") != -1) {
|
|
|
connect_toy = false;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
if (current_toy_UUID == "") {
|
|
|
|
|
|
that.SendOrder('84')
|
|
@@ -769,5 +768,19 @@ export default {
|
|
|
connect_toy = false;
|
|
|
current_toy_id = "00";
|
|
|
current_toy_UUID = "";
|
|
|
+ },
|
|
|
+
|
|
|
+ CalBLEPower($voltage) {
|
|
|
+ let $max = 4100;
|
|
|
+ let $min = 3500;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let $_voltage = $voltage * 100;
|
|
|
+
|
|
|
+
|
|
|
+ let $percent = (($_voltage - $min) / ($max - $min)) * 100;
|
|
|
+
|
|
|
+ return $percent;
|
|
|
}
|
|
|
};
|