This commit is contained in:
jake 2024-02-08 12:20:22 -05:00
parent 7c7b8eebb4
commit e9edabe3b0
6 changed files with 43 additions and 12 deletions

View File

@ -36,7 +36,7 @@
<ul>
<li><br/><a class="" href="https://jakedowns.github.io/webxr.html">WebXR + WebGPU Demos!</a></li>
<li><br/><a class="" href="https://github.com/jakedowns/xreal-webxr">View Source For This Repo on Github</a></li>
<li><br/><a class="" href="https://gist.github.com/CGamesPlay/b3ea7740ea8715d19e89f5511491519f">HELP! We need your help finishing these FREE, OPEN-SOURCE COMMUNITY-CONTRIBUTED, DRIVERS! Please help us fix the YAW drift!</a></li>
<!-- <li><br/><a class="" href="https://gist.github.com/CGamesPlay/b3ea7740ea8715d19e89f5511491519f">HELP! We need your help finishing these FREE, OPEN-SOURCE COMMUNITY-CONTRIBUTED, DRIVERS! Please help us fix the YAW drift!</a></li> -->
</ul>
</div>

View File

@ -74,6 +74,7 @@
<div id="connect"><button>connect</button></div>
<div id="disconnect" onclick="disconnectDevices()"><button>disconnect</button></div>
<div id="startIMU" style="display: none;" onclick="startIMU()"><button>start headtracking</button></div>
<div id="stopIMU" style="display: none;" onclick="stopIMU()"><button>stop headtracking</button></div>
<div id="hadConnect"></div>
<div id="sn"></div>
<div id="firmwareMcu"></div>
@ -430,7 +431,19 @@
}
window.startIMU = function(){
Manager.startIMU();
Manager.startIMU().then(result=>{
console.warn('Manager.startIMU().then...',{result})
}).catch(err=>{
console.error(err)
});
}
window.stopIMU = function(){
Manager.stopIMU().then(result=>{
console.warn('Manager.stopIMU().then...',{result})
}).catch(err=>{
console.error(err)
});
}
window.disconnectDevices = () => {

View File

@ -392,18 +392,16 @@ export default class Glasses extends EventTarget {
sendReport(msgId, payload) {
const data = new Uint8Array(payload);
const cmd = Protocol.cmd_build(msgId, data);
// console.log({
// msgId,
// payload,
// data,
// cmd
// })
console.warn('js_air:sendReport',{msgId,payload})
console.table([{
id: 'sendReport',
dir: 'OUT',
msgId: [msgId, '0x'+(msgId.toString(16))].join(' '),
key: Protocol.keyForHex(msgId),
payload: data.join(' '),
_input_payload: payload,
cmd: cmd.map(b => b.toString(16).padStart(2, "0")).join(' ')
}])
this._device.sendReport(0x00, cmd);

View File

@ -511,9 +511,9 @@ export async function getSN() {
/** init air IMU tracking mode */
export async function startIMU() {
if(!glasses){
return 'no device connected'
return Promise.reject('no device connected')
}
return glasses.sendReportTimeout(Protocol.MESSAGES.R_INIT_IMU_TRACKING_SESSION)
return glasses.sendReportTimeout(Protocol.MESSAGES.W_TOGGLE_IMU, [1])
.then(report => {
console.warn('startIMU -> report',report);
if (reportSuccess(report)){
@ -524,6 +524,22 @@ export async function startIMU() {
})
}
export async function stopIMU() {
if(!glasses){
return 'no device connected'
}
// arg 2: 0 is what turns "off" the stream
return glasses.sendReportTimeout(Protocol.MESSAGES.W_TOGGLE_IMU, [0])
.then(report => {
console.warn('stopIMU -> report',report);
if (reportSuccess(report)){
return String.fromCharCode.apply(null, report.payload);
}else{
console.error('error w/ report',report)
}
})
}
/** read air glassess Brightness */
export async function getBrightness() {
let glasses = await common.connectDevice();

View File

@ -10,10 +10,10 @@ const RESERVED_OFS = 17;
export const NREAL_VENDOR_ID = 0x3318;
export const BOOT_PRODUCT_ID = 0x0423;
export const IMU_TIMEOUT = 250;
export const MESSAGES = {
W_CANCEL_ACTIVATION: 0x19,
R_MCU_APP_FW_VERSION: 0x26,//MCU APP FW version.
R_GLASSID: 0x15,//MCU APP FW version.
// R_DSP_APP_FW_VERSION: 0x21,//DSP APP FW version.
@ -22,6 +22,9 @@ export const MESSAGES = {
W_ACTIVATION_TIME: 0x2A,//Write activation time
W_SLEEP_TIME: 0x1E,//Write unsleep time
W_TOGGLE_IMU: 0x19,
W_CANCEL_ACTIVATION: 0x19,
// R_IS_NEED_UPGRADE_DSP_FW: 0x49,//Check whether the DSP needs to be upgraded.
// W_FORCE_UPGRADE_DSP_FW: 0x69,//Force upgrade DSP.
R_DSP_VERSION: 0x18,//DSP APP FW version.

View File

@ -32,6 +32,7 @@ export default class Glasses extends EventTarget {
// light connect
sendReport(msgId, payload, option) {
console.warn('js_light:sendReport',{msgId,payload,option})
const data = new Uint8Array(payload);
const cmd = Protocol.cmd_build(msgId, data, option);
this._device.sendReport(0x00, cmd);