|
@@ -72,13 +72,17 @@ const bleServerMap = {
|
|
|
},
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+let isOnceTimer = null;
|
|
|
+let isLongClick = false;// 是否为长按
|
|
|
+let isBulbState = false;// 是否处于b门模式下
|
|
|
Page({
|
|
|
data: {
|
|
|
connectStateMap,
|
|
|
bleStateEnum,
|
|
|
isDebug: false,
|
|
|
ble:{
|
|
|
- state: 3,
|
|
|
+ state: 0,
|
|
|
init: false,
|
|
|
},
|
|
|
remoteDev:{
|
|
@@ -102,9 +106,9 @@ Page({
|
|
|
},
|
|
|
async onShow(){
|
|
|
timeClock.setHook((msNum)=>{
|
|
|
- console.log(msNum);
|
|
|
+ // console.log(msNum);
|
|
|
let res = timeClock.parse(msNum)
|
|
|
- console.log(res);
|
|
|
+ // console.log(res);
|
|
|
this.setData({
|
|
|
time_minute:res.minute,
|
|
|
time_second:res.second,
|
|
@@ -141,8 +145,12 @@ Page({
|
|
|
async holdFoucus(){
|
|
|
console.log("发送对焦命令");
|
|
|
},
|
|
|
-
|
|
|
- async devControlShutter(isDown = true){
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {*} isDown 按下或者抬起快门
|
|
|
+ * @param {*} isBulb 是否为b门模式下释放快门
|
|
|
+ */
|
|
|
+ async devControlShutter(isDown = true,isBulb = false){
|
|
|
let cmds,waitTime=10;
|
|
|
let code = bleServerMap.remote.code.hold;
|
|
|
let dev = this.data.bleDevs.find(dev=>this.data.remoteDev.devId===dev.deviceId);
|
|
@@ -155,9 +163,12 @@ Page({
|
|
|
// 发送抬起快门
|
|
|
cmds =[
|
|
|
code.command.shutterUp,
|
|
|
- code.command.shutterDown,
|
|
|
- code.command.shutterUp
|
|
|
]
|
|
|
+ if(isBulb){
|
|
|
+ // b 门模式下需要再次按下快门在进行释放
|
|
|
+ cmds.push(code.command.shutterDown);
|
|
|
+ cmds.push(code.command.shutterUp);
|
|
|
+ }
|
|
|
}else{
|
|
|
console.log('快门按下')
|
|
|
cmds = [code.command.shutterDown]
|
|
@@ -188,6 +199,13 @@ Page({
|
|
|
y1 = touche.clientY;
|
|
|
}
|
|
|
this.data.shutterBtnY1 = y1;
|
|
|
+ isLongClick = false;
|
|
|
+ // 按住700毫秒后视作长按
|
|
|
+ isOnceTimer = setTimeout(()=>{
|
|
|
+ isLongClick = true;
|
|
|
+ isOnceTimer = null;
|
|
|
+ },
|
|
|
+ 700);
|
|
|
if(this.data.isHolder){
|
|
|
// 已经按下,视作已经发送按下快门的操作
|
|
|
return false;
|
|
@@ -200,13 +218,32 @@ Page({
|
|
|
},
|
|
|
async touchEndHandle(e){
|
|
|
console.log("按钮抬起");
|
|
|
-
|
|
|
+ clearTimeout(isOnceTimer);
|
|
|
+ isOnceTimer = null;
|
|
|
if(this.data.isHolder){
|
|
|
// 按住,not do sth
|
|
|
+ isBulbState = true;
|
|
|
}else{
|
|
|
// 抬起按钮
|
|
|
timeClock.stop();
|
|
|
- this.devControlShutter(true);
|
|
|
+ if(isBulbState){
|
|
|
+ // 处于b门模式
|
|
|
+ console.log(`[b门长曝光结束] 曝光时长 ${this.data.time_minute}:${this.data.time_second}:${this.data.time_ms}`);
|
|
|
+ this.devControlShutter(true,true);
|
|
|
+ isBulbState = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(isLongClick){
|
|
|
+ // 长按
|
|
|
+ this.devControlShutter(true);
|
|
|
+ }else{
|
|
|
+ // 短按,等待500ms 后发送抬起的命令
|
|
|
+ setTimeout(()=>{
|
|
|
+ console.log("短按,自动跟发一条抬起快门命令");
|
|
|
+ this.devControlShutter(true);
|
|
|
+ },500)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
async touchMoveHandle(e){
|