Skip to content

Commit 3bc87d9

Browse files
Merge pull request #173 from keenedge1/master
데이터 센서값 수정
2 parents 14fc5cd + 54a2b05 commit 3bc87d9

File tree

2 files changed

+27
-48
lines changed

2 files changed

+27
-48
lines changed

app/modules/truetrue.js

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -227,59 +227,38 @@ Module.prototype.requestLocalData = function() {
227227

228228
Module.prototype.handleLocalData = function(data) {
229229
// Robot data -> EntryHW, save to sensory data
230+
var str = '';
231+
var j = 100;
232+
var sensory = this.sensory;
230233

231-
var str = '';
232234
if (data.length) {
233235
for (var i = 0; i < data.length; i++) {
234236
str = str + this.buf2hex(data[i]);
237+
if( this.buf2hex(data[i]) == '5F' && this.buf2hex(data[i+1]) == '7E' && this.buf2hex(data[i+18]) == '0D' && this.buf2hex(data[i+19]) == '0A' ){
238+
j = i;
239+
sensory.L2 = data[j+2];
240+
sensory.L1 = data[j+3];
241+
sensory.R1 = data[j+4];
242+
sensory.R2 = data[j+5];
243+
sensory.ProxiLeft = data[j+6];
244+
sensory.ProxiRight = data[j+7];
245+
246+
sensory.AccX = data[j+8];
247+
sensory.AccY = data[j+9];
248+
sensory.AccZ = data[j+10];
249+
sensory.AccStatus = data[j+11];
250+
251+
sensory.BColorKey = data[j+14];
252+
sensory.BColorRed = data[j+15];
253+
sensory.BColorGreen = data[j+16];
254+
sensory.BColorBlue = data[j+17];
255+
sensory.FColorLeftKey = data[j+12];
256+
sensory.FColorRightKey = data[j+13];
257+
258+
}
235259
}
236-
//console.log("D:"+str);
237-
//console.log("L:"+data.length);
238260
}
239-
/*
240-
if(data.length != 19) return;
241-
242-
if(data[0] != 0x7E) return; // invalid data
243-
var sensory = this.sensory;
244-
245-
sensory.L2 = data[1];
246-
sensory.L1 = data[2];
247-
sensory.R1 = data[3];
248-
sensory.R2 = data[4];
249-
sensory.ProxiLeft = data[5];
250-
sensory.ProxiRight = data[6];
251-
sensory.AccX = data[7];
252-
sensory.AccY = data[8];
253-
sensory.AccZ = data[9];
254-
sensory.AccStatus = data[10];
255-
sensory.BColorKey = data[13];
256-
sensory.BColorRed = data[14];
257-
sensory.BColorGreen = data[15];
258-
sensory.BColorBlue = data[16];
259-
sensory.FColorLeftKey = data[11];
260-
sensory.FColorRightKey = data[12];
261-
*/
262-
if (data.length != 20) return;
263-
264-
if (data[0] != 0x5f) return; // invalid data
265-
var sensory = this.sensory;
266-
267-
sensory.L2 = data[2];
268-
sensory.L1 = data[3];
269-
sensory.R1 = data[4];
270-
sensory.R2 = data[5];
271-
sensory.ProxiLeft = data[6];
272-
sensory.ProxiRight = data[7];
273-
sensory.AccX = data[8];
274-
sensory.AccY = data[9];
275-
sensory.AccZ = data[10];
276-
sensory.AccStatus = data[11];
277-
sensory.BColorKey = data[14];
278-
sensory.BColorRed = data[15];
279-
sensory.BColorGreen = data[16];
280-
sensory.BColorBlue = data[17];
281-
sensory.FColorLeftKey = data[12];
282-
sensory.FColorRightKey = data[13];
261+
283262
};
284263

285264
//0xff 0x55 0x6 0x0 0x1 0xa 0x9 0x0 0x0 0xa

app/modules/truetrue.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"hardware": {
2424
"type": "bluetooth",
2525
"control": "slave",
26-
"duration": 20,
26+
"duration": 1000,
2727
"vendor": "Microsoft",
2828
"baudRate": 115200
2929
}

0 commit comments

Comments
 (0)