设备方向API中的interval参数不生效,始终是20ms
https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.startDeviceMotionListening.html
wx.startDeviceMotionListening({interval:'ui',
success(e) {
wx.onDeviceMotionChange((res) => {
if (res.alpha) {
let timestamp = Date.now()
console.log("motion时间戳",timestamp)
let motion = res
motion.timestamp = timestamp
let time = new Date().toLocaleTimeString()
motion.time = time
let data = {
type: "device",
tag_id: app.globalData.tagId,
data: {
motion: motion
}
}
// console.log("设备值",res)
let count=that.data.sendCount+1
if(that.data.sendCount%4==0){
sendSocketMessage(data,app.globalData)
}
that.setLocationMakerDirection(res.alpha)
// //console.log("罗盘", res.direction)
that.setData({
angle: res.alpha,
sendCount:count
})
}
// //console.log("设备方向", res.alpha)
})
}
})