From 5706041f4348469c64213b948f390905f93f6a12 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Wed, 31 May 2023 23:07:12 +0300 Subject: [PATCH 01/45] Fixed black screen bug on Inmotion V5/8/10 dashboard --- v2/euc/eucInmotionV10/eucInmotionV10.js | 102 ++++++++++++------------ 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index 4f6cb81d..a1302158 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -4,15 +4,15 @@ euc.cmd=function(no,val){ if (ew.is.bt===2) console.log("inmotion: send cmd :",no); let cmd; switch (no) { - case "info" : return [170, 170, 20, 1, 165, 85, 15, 255, 255, 255, 255, 255, 255, 255, 255, 8, 5, 0, 1, 127]; - case "batLevelData":return [170, 170, 20, 1, 165, 85, 15, 0, 0, 0, 21, 0, 0, 0, 0, 8, 5, 0, 1, 156]; + case "info" : return [170, 170, 20, 1, 165, 85, 15, 255, 255, 255, 255, 255, 255, 255, 255, 8, 5, 0, 1, 127]; + case "batLevelData": return [170, 170, 20, 1, 165, 85, 15, 0, 0, 0, 21, 0, 0, 0, 0, 8, 5, 0, 1, 156]; case "live": return [170, 170, 19, 1, 165, 85, 15, 255, 255, 255, 255, 255, 255, 255, 255, 8, 5, 0, 0, 125]; - case "init": return [170, 170, 7, 3, 165, 85, 15, 48, 48, 48, 48, 48, 48, 0, 0, 8, 5, 0, 0, 155]; - case "calibration": return [ 170, 170, 25, 1, 165, 85, 15, 50, 84, 118, 152, 0, 0, 0, 0, 8, 5, 0, 0, 31 ]; - case "horn": return [170, 170, 9, 6, 165, 85, 15, 4, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0, 132]; - case "beep": return [170, 170, 9, 6, 165, 85, 15, 21, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0, 149]; - case "led": return [170, 170, 9, 6, 165, 85, 15, 21, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0, 149]; - case "end": return [85, 85]; + case "init": return [170, 170, 7, 3, 165, 85, 15, 48, 48, 48, 48, 48, 48, 0, 0, 8, 5, 0, 0, 155]; + case "calibration": return [170, 170, 25, 1, 165, 85, 15, 50, 84, 118, 152, 0, 0, 0, 0, 8, 5, 0, 0, 31]; + case "horn": return [170, 170, 9, 6, 165, 85, 15, 4, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0, 132]; + case "beep": return [170, 170, 9, 6, 165, 85, 15, 21, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0, 149]; + case "led": return [170, 170, 9, 6, 165, 85, 15, 21, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0, 149]; + case "end": return [ 85, 85]; case "playSound"://cmd=0-23 cmd = [170, 170, 9, 6, 165, 85, 15, val, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0]; @@ -27,7 +27,7 @@ euc.cmd=function(no,val){ cmd = [170, 170, 13, 1, 165, 85, 15, val, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0]; cmd.push(7+cmd.reduce(checksum)); return cmd; - case "setBrightness": + case "setBrightness": cmd = [170, 170, 20, 3, 96, 43, val]; cmd.push(7+cmd.reduce(checksum)); return cmd; @@ -98,12 +98,12 @@ euc.temp.liveParse= function (inc){ //values //spd euc.dash.live.spd=(lala.getInt32(31, true)+lala.getInt32(35, true))/2000; - + if (euc.dash.trip.topS < euc.dash.live.spd) euc.dash.trip.topS = euc.dash.live.spd; if (euc.dash.live.spd<0) euc.dash.live.spd=-euc.dash.live.spd; - euc.dash.alrt.spd.cc = ( euc.dash.alrt.spd.hapt.hi <= euc.dash.live.spd )? 2 : ( euc.dash.alrt.spd.hapt.low <= euc.dash.live.spd )? 1 : 0 ; - if ( euc.dash.alrt.spd.hapt.en && euc.dash.alrt.spd.cc == 2 ) - euc.is.alert = 1 + Math.round((euc.dash.live.spd-euc.dash.alrt.spd.hapt.hi) / euc.dash.alrt.spd.hapt.step) ; + euc.dash.alrt.spd.cc = ( euc.dash.alrt.spd.hapt.hi <= euc.dash.live.spd )? 2 : ( euc.dash.alrt.spd.hapt.low <= euc.dash.live.spd )? 1 : 0 ; + if ( euc.dash.alrt.spd.hapt.en && euc.dash.alrt.spd.cc == 2 ) + euc.is.alert = 1 + Math.round((euc.dash.live.spd-euc.dash.alrt.spd.hapt.hi) / euc.dash.alrt.spd.hapt.step) ; //volt euc.dash.live.volt=lala.getUint32(43, true)/100; //batt @@ -111,7 +111,7 @@ euc.temp.liveParse= function (inc){ //euc.dash.live.bat = Math.round(((euc.dash.live.volt - 60) * 100) / (84 - 60)); euc.log.batL.unshift(euc.dash.live.bat); if (20 { euc.is.buzz = 0; }, 3000); } //if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} //euc.tout.loop=setTimeout(function(v){ euc.tout.loop=0;euc.temp.live();},50); //euc.temp.live(); -}; +}; euc.temp.alertParse= function (inc){ - //let lala = new DataView(inc); + //let lala = new DataView(inc); euc.dash.alrt.id = inc[6]; euc.dash.alrt.val = (inc[9] * 256) | (inc[8] & 0xFF); euc.dash.alrt.val2 = (inc[13] * 256 * 256 * 256) | ((inc[12] & 0xFF) * 256 * 256) | ((inc[11] & 0xFF) * 256) | (inc[10] & 0xFF); - euc.dash.alrt.spd = Math.abs((euc.dash.alrt.val2 / 3812.0) * 3.6); + euc.dash.alrt.speed = Math.abs((euc.dash.alrt.val2 / 3812.0) * 3.6); switch (euc.dash.alrt.id) { - case 3: euc.dash.alrt.text = ("LIFT");break; + case 3: euc.dash.alrt.text = ("LIFT");break; case 5:euc.dash.alrt.text = ("START"); break; - case 6:euc.dash.alrt.text = ("TILTBACK at speed "+euc.dash.alrt.spd+" at limit "+(euc.dash.alrt.val / 1000.0));break; + case 6:euc.dash.alrt.text = ("TILTBACK at speed "+euc.dash.alrt.speed+" at limit "+(euc.dash.alrt.val / 1000.0));break; case 14:euc.dash.alrt.text = ("HELLO");break; case 25:euc.dash.alrt.text = ("FALL");break; case 29:euc.dash.alrt.text = ("REPAIR: bad battery cell found. At voltage: "+ (euc.dash.alrt.val2 / 100.0));break; case 32:euc.dash.alrt.text = ("LOW BATTEY at voltage :" + (euc.dash.alrt.val2 / 100.0));break; - case 33:euc.dash.alrt.text = ("CUT-OFF at speed :"+euc.dash.alrt.spd);break; - case 38:euc.dash.alrt.text = ("HIGH LOAD at speed :"+euc.dash.alrt.spd+" and current :"+(euc.dash.alrt.val / 1000.0));break; + case 33:euc.dash.alrt.text = ("CUT-OFF at speed :"+euc.dash.alrt.speed);break; + case 38:euc.dash.alrt.text = ("HIGH LOAD at speed :"+euc.dash.alrt.speed+" and current :"+(euc.dash.alrt.val / 1000.0));break; default:euc.dash.alrt.text = ("Unknown Alert: "+ euc.dash.alrt.val+","+euc.dash.alrt.val2); } //euc.emit('alert',euc.dash.alrt.text); @@ -198,7 +198,7 @@ euc.conn=function(mac){ euc.temp.wCha=wc;//write return euc.gatt.getPrimaryService(0xffe0); }).then(function(s) { - euc.temp.serv=s; + euc.temp.serv=s; return euc.temp.serv.getCharacteristic(0xffe4);//read }).then(function(rc) { euc.temp.rCha=rc; @@ -206,21 +206,21 @@ euc.conn=function(mac){ euc.temp.last= []; euc.temp.chk= []; euc.temp.rCha.on('characteristicvaluechanged', function(event) { - if (ew.is.bt===2&&euc.dbg==3) console.log("Inmotion: packet in ",event.target.value.buffer); + if (ew.is.bt===2&&euc.dbg==3) console.log("Inmotion: packet in ",event.target.value.buffer); if (euc.tout.alive) {clearTimeout(euc.tout.alive); euc.tout.alive=0;} if (euc.is.busy) return; //gather package let inc=event.target.value.buffer; euc.temp.tot=E.toUint8Array(euc.temp.last,inc); euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); - //got package - if ( (inc.length==1 && inc[0]==85) || (inc[inc.length - 2]==85 && inc[inc.length - 1]==85) ) { - if (ew.is.bt===2) console.log("Inmotion: in: length:",euc.temp.tot.buffer.length," data :",euc.temp.tot); + //got package + if ( (inc.length==1 && inc[0]==85) || (inc[inc.length - 2]==85 && inc[inc.length - 1]==85) ) { + if (ew.is.bt===2) console.log("Inmotion: in: length:",euc.temp.tot.buffer.length," data :",euc.temp.tot); //live pckg if (euc.temp.tot.buffer[2]===19) { if (euc.temp.tot.length==euc.temp.pckL) { euc.temp.last=[]; - if (ew.is.bt===2) console.log("Inmotion: live in"); + if (ew.is.bt===2) console.log("Inmotion: live in"); euc.temp.liveParse(euc.temp.tot.buffer); euc.temp.last=[]; euc.temp.live(); @@ -234,13 +234,13 @@ euc.conn=function(mac){ euc.temp.chk.set(temp); euc.temp.chk=( euc.temp.chk.reduce(checksum) + 7 == temp[temp.length - 3] )?1:0; if (!euc.temp.chk) { - if (ew.is.bt===2) console.log("Inmotion: problem: length:", temp.length, temp); + if (ew.is.bt===2) console.log("Inmotion: problem: length:", temp.length, temp); euc.temp.live(); //setTimeout(function(){euc.temp.live();},100); euc.temp.last=[]; return; } - if (ew.is.bt===2) console.log("Inmotion: live in fixed : length: :", temp.length); + if (ew.is.bt===2) console.log("Inmotion: live in fixed : length: :", temp.length); euc.temp.pckL=temp.length; euc.temp.last=[]; euc.temp.liveParse(E.toUint8Array(temp).buffer); @@ -251,10 +251,10 @@ euc.conn=function(mac){ //rest }else { if (euc.temp.tot.buffer[2]===1) { - if (ew.is.bt===2) console.log("Inmotion: ALERT in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); + if (ew.is.bt===2) console.log("Inmotion: ALERT in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); euc.temp.alertParse(euc.temp.tot.buffer); }else - if (ew.is.bt===2) console.log("Inmotion: unknown in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); + if (ew.is.bt===2) console.log("Inmotion: unknown in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); } euc.temp.last=[]; return; @@ -264,23 +264,22 @@ euc.conn=function(mac){ euc.gatt.device.on('gattserverdisconnected', euc.off); return rc; }).then(function(c) { - //connected - if (ew.is.bt===2) console.log("EUC InmotionV1: Connected"); + //connected + if (ew.is.bt===2) console.log("EUC InmotionV1: Connected"); euc.state="READY"; //connected buzzer.nav([90,40,150,40,90]); euc.dash.opt.lock.en=0; //write function euc.temp.live= function(){ - if (euc.tout.alive) clearTimeout(euc.tout.alive); + if (euc.tout.alive) clearTimeout(euc.tout.alive); euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); if (euc.is.busy) return; euc.temp.wCha.writeValue([170, 170, 19, 1, 165, 85, 15, 255, 255, 255, 255, 255, 255, 255, 255, 8, 5, 0, 0, 125]).then(function() { return euc.temp.wCha.writeValue([85, 85, 19, 1, 165, 85, 15, 255, 255, 255, 255, 255, 255, 255, 255, 8, 5, 0, 0, 125]); }).catch(function(err) { - if (ew.is.bt===2) console.log("EUC InmotionV1: live write fail"); - //euc.off("writefail"); + if (ew.is.bt===2) console.log("EUC InmotionV1: live write fail"); + //euc.off("writefail"); }); - }; euc.wri=function(cmd,value){ if (euc.tout.alive) {clearTimeout(euc.tout.alive); euc.tout.alive=0;} @@ -294,7 +293,7 @@ euc.conn=function(mac){ //euc.temp.rCha.stopNotifications(); if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} euc.tout.loop=setTimeout(() => {euc.tout.loop=0; - euc.temp.wCha.writeValue(euc.cmd("playSound",euc.dash.opt.horn.mode)).then(function() { + euc.temp.wCha.writeValue(euc.cmd("playSound",euc.dash.opt.horn.mode)).then(function() { return euc.temp.wCha.writeValue(euc.cmd("end")); }).then(function() { euc.tout.loop=0; @@ -303,7 +302,7 @@ euc.conn=function(mac){ }); },150); }else if (cmd==="hornOff") { - euc.is.horn=0; + euc.is.horn=0; return; }else if (euc.state==="OFF"||cmd==="end") { if (euc.gatt && euc.gatt.connected) { @@ -311,9 +310,9 @@ euc.conn=function(mac){ euc.tout.loopEnd=setTimeout(function(){ euc.tout.loopEnd=0; euc.gatt.disconnect(); - },1000); + },1000); if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} - euc.tout.loop=setTimeout(function(){ + euc.tout.loop=setTimeout(function(){ euc.tout.loop=0; if (euc.dash.auto.onD.off||euc.temp.aOff) { euc.temp.wCha.writeValue(euc.cmd("control",5)).then(function() { @@ -322,7 +321,7 @@ euc.conn=function(mac){ euc.off("power off"); }).catch(euc.off); return; - } + } euc.temp.wCha.writeValue(euc.cmd("setLights",(euc.dash.auto.onC.HL)?0:2)).then(function() { return euc.temp.wCha.writeValue(euc.cmd("end")); }).then(function() { @@ -340,7 +339,7 @@ euc.conn=function(mac){ }else if (cmd==="start") { euc.temp.wCha.writeValue(euc.cmd("init")).then(function() { return euc.temp.wCha.writeValue(euc.cmd("end")); - }).then(function() { + }).then(function() { return (euc.dash.auto.onC.HL)?euc.temp.wCha.writeValue(euc.cmd("setLights",(euc.dash.opt.lght.HL)?1:0)):"ok"; }).then(function() { return (euc.dash.auto.onC.HL)?euc.temp.wCha.writeValue(euc.cmd("end")):"ok"; @@ -351,11 +350,10 @@ euc.conn=function(mac){ euc.tout.loop=setTimeout(function(){ euc.tout.loop=0;euc.is.run=1;euc.is.busy=0; return euc.temp.live(); - },350); + },350); }).catch(euc.off); - } else { - //if (euc.is.busy) return; + //if (euc.is.busy) return; if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} euc.tout.loop=setTimeout(function(){ euc.tout.loop=0; @@ -372,9 +370,9 @@ euc.conn=function(mac){ euc.dash.opt.bat.pack=1.25;//84 volts euc.updateDash(require("Storage").readJSON("dash.json",1).slot); ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Mac",euc.mac); - } - //euc.wri("start"); + } + //euc.wri("start"); setTimeout(() => {euc.wri("start");}, 200); //reconnect }).catch(euc.off); -}; \ No newline at end of file +}; From 4a478c3bbd021afb7ce213fa2ffb43bb6ed9c561 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sun, 4 Jun 2023 15:08:02 +0300 Subject: [PATCH 02/45] Fixed a bug with Inmotion V8 survey stopping on the settings screen and after returning from the settings by pressing the button. --- P8-testing/dashInmotionV10/dashInmotionV10.js | 68 +++++++++---------- v2/euc/eucInmotionV10/eucInmotionV10.js | 5 +- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/P8-testing/dashInmotionV10/dashInmotionV10.js b/P8-testing/dashInmotionV10/dashInmotionV10.js index 55ecb842..75389c5c 100644 --- a/P8-testing/dashInmotionV10/dashInmotionV10.js +++ b/P8-testing/dashInmotionV10/dashInmotionV10.js @@ -4,24 +4,24 @@ if (!face.menu) { face.menu.full= function(title,titleSize,value,valueSize,frontColor,backColor,init){ if (!init){ this.g.setColor(0,backColor); - this.g.fillRect(50,50,195,150); + this.g.fillRect(50,50,195,150); this.g.setColor(1,15); this.g.setFont("Vector",valueSize); - this.g.drawString(value,130-(this.g.stringWidth(value)/2),65); + this.g.drawString(value,130-(this.g.stringWidth(value)/2),65); this.g.flip(); }else{ this.g.setColor(0,backColor); this.g.fillRect(0,0,239,195); this.g.setColor(1,15); this.g.setFont("Vector",titleSize); - this.g.drawString(title,120-(this.g.stringWidth(title)/2),10); + this.g.drawString(title,120-(this.g.stringWidth(title)/2),10); this.g.drawImage(require("heatshrink").decompress(atob("oFAwJC/AAs8A41+A43/AwsDA40HA40PA40f/wHFn/8Fw34AwkB//wGw3AGw2AGxk/Gw1/Gw4uFGwPgGxguBGwsfGw4uGv5lFGw4HBGwoHJC4wnHG45HHK45nHO444JGAynHW47HHHBKBHNJ44QA4o4BA4owBA41+A408A4wA6A==")),0,70); this.g.drawImage(require("heatshrink").decompress(atob("oFAwJC/AAU8A41+A43/A4/AA43gA43wA4t//AHFn/8A4sfGA0P/+AA4kDHA0BHCAwGn/+GA4HFg44QGA3/NJ44QA5oXHE443HI4xXHM453HGw6XHU44uGY442Hc473HMo9/Voy9Ifw42FA4IGFgF+A408A4wA9A=")),180,70); - this.g.flip(); + this.g.flip(); this.g.setColor(1,15); this.g.setFont("Vector",valueSize); - this.g.drawString(value,130-(this.g.stringWidth(value)/2),65); - this.g.flip(); + this.g.drawString(value,130-(this.g.stringWidth(value)/2),65); + this.g.flip(); } }; }//face.menu.full("test",20,5,80,"a test",20,"another line",1453,1365); @@ -30,19 +30,17 @@ face[0] = { offms: (ew.def.off[face.appCurr])?ew.def.off[face.appCurr]:5000, g:w.gfx, init: function(){ - if (euc.temp.alive) {clearInterval(euc.temp.alive); euc.temp.alive=0;} - euc.is.busy=1;//stop bt loop-accept commands. if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} this.g.setColor(0,0); this.g.fillRect(0,98,239,99); - this.g.flip(); + this.g.flip(); this.g.fillRect(120,0,121,195); - this.g.flip(); + this.g.flip(); this.g.setColor(0,0); this.g.fillRect(0,205,239,239); this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString("ACTIONS",120-(this.g.stringWidth("ACTIONS")/2),217); + this.g.drawString("ACTIONS",120-(this.g.stringWidth("ACTIONS")/2),217); this.g.flip(); this.g.setColor(0,0); this.g.fillRect(0,196,239,204); @@ -51,17 +49,17 @@ face[0] = { this.g.flip(); this.g.setColor(1,15); this.g.fillRect(75,200,98,204); - this.g.flip(); + this.g.flip(); this.btn(euc.dash.opt.lght.HL,"LIGHT",18,60,20,4,1,0,0,119,97,(euc.dash.opt.lght.HL)?"ON":"OFF",25,60,55); this.btn(euc.dash.opt.snd.vol,"VOLUME",22,185,15,12,13,122,0,239,97,(euc.dash.opt.snd.vol)?euc.dash.opt.snd.vol:"MUTE",30,185,50);//2 let metric={"psi":1,"bar":0.0689475,"kpa":6.89475}; - this.btn(euc.dash.opt.tpms,(euc.dash.opt.tpms)?euc.dash.opt.tpms:"TPMS",18,60,115,(euc.dash.opt.tpms&&tpms.euc[euc.dash.opt.tpms]&&tpms.euc[euc.dash.opt.tpms].time&&(getTime()|0)-tpms.euc[euc.dash.opt.tpms].time<1800)?(tpms.euc[euc.dash.opt.tpms].alrm)?13:4:1,1,0,100,119,195,(euc.dash.opt.tpms)?(tpms.euc[euc.dash.opt.tpms]&&tpms.euc[euc.dash.opt.tpms].psi)?Math.round(tpms.euc[euc.dash.opt.tpms].psi*metric[tpms.def.metric]).toString(1):"WAIT":"OFF",(euc.dash.opt.tpms)?32:28,60,150); //3 + this.btn(euc.dash.opt.tpms,(euc.dash.opt.tpms)?euc.dash.opt.tpms:"TPMS",18,60,115,(euc.dash.opt.tpms&&tpms.euc[euc.dash.opt.tpms]&&tpms.euc[euc.dash.opt.tpms].time&&(getTime()|0)-tpms.euc[euc.dash.opt.tpms].time<1800)?(tpms.euc[euc.dash.opt.tpms].alrm)?13:4:1,1,0,100,119,195,(euc.dash.opt.tpms)?(tpms.euc[euc.dash.opt.tpms]&&tpms.euc[euc.dash.opt.tpms].psi)?Math.round(tpms.euc[euc.dash.opt.tpms].psi*metric[tpms.def.metric]).toString(1):"WAIT":"OFF",(euc.dash.opt.tpms)?32:28,60,150); //3 this.btn(1,"OFF",25,185,136,1,1,122,100,239,195); //4 this.run=true; }, show : function(){ if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} - if (!this.run) return; + if (!this.run) return; this.tid=setTimeout(function(t,o){ t.tid=-1; t.show(); @@ -71,9 +69,9 @@ face[0] = { this.g.setColor(0,(bt)?clr1:clr0); this.g.fillRect(rx1,ry1,rx2,ry2); this.g.setColor(1,15); - this.g.setFont("Vector",size1); - this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); - if (txt2){this.g.setFont("Vector",size2); + this.g.setFont("Vector",size1); + this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); + if (txt2){this.g.setFont("Vector",size2); this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);} this.g.flip(); }, @@ -82,7 +80,7 @@ face[0] = { this.g.fillRect(0,198,239,239); this.g.setColor(1,15); this.g.setFont("Vector",size); - this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); + this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); this.g.flip(); if (this.ntid) clearTimeout(this.ntid); this.ntid=setTimeout(function(t){ @@ -91,7 +89,7 @@ face[0] = { t.g.fillRect(0,205,239,239); t.g.setColor(1,15); t.g.setFont("Vector",20); - t.g.drawString("ACTIONS",122-(t.g.stringWidth("ACTIONS")/2),217); + t.g.drawString("ACTIONS",122-(t.g.stringWidth("ACTIONS")/2),217); t.g.flip(); t.g.setColor(0,0); t.g.fillRect(0,196,239,204); @@ -100,7 +98,7 @@ face[0] = { t.g.flip(); t.g.setColor(1,15); t.g.fillRect(75,200,98,204); - t.g.flip(); + t.g.flip(); },1000,this); }, tid:-1, @@ -130,9 +128,9 @@ face[1] = { clear: function(){ return true; }, -}; +}; //touch -touchHandler[0]=function(e,x,y){ +touchHandler[0]=function(e,x,y){ switch (e) { case 5: //tap event if (face[0].sub) { @@ -157,7 +155,7 @@ touchHandler[0]=function(e,x,y){ } this.timeout(); return; - }else { + }else { if ( x<=120 && y<=100 ) { //lights euc.dash.opt.lght.HL=1-euc.dash.opt.lght.HL; euc.wri("setLights",(euc.dash.opt.lght.HL)?1:0); @@ -170,16 +168,16 @@ touchHandler[0]=function(e,x,y){ face[0].ntfy("SET VOLUME","SET VOLUME",20,4,1); face[0].sub="volume"; }else if ( x<=120 && 100<=y ) { //tpms - buzzer.nav([30,50,30]); - if (!euc.dash.opt.tpms) face[0].ntfy("HOLD-> ON/OFF","",20,4,1); + buzzer.nav([30,50,30]); + if (!euc.dash.opt.tpms) face[0].ntfy("HOLD-> ON/OFF","",20,4,1); else { tpms.def.pos=Object.keys(tpms.def.list).indexOf(euc.dash.opt.tpms); face.go("tpmsFace",0); return; - } + } }else if (120<=x && 100<=y ) { //off face[0].ntfy("HOLD -> POWER OFF","",18,13,1); - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); }else buzzer.nav(40); } this.timeout(); @@ -188,18 +186,18 @@ touchHandler[0]=function(e,x,y){ //face.go("clock",0); setTimeout(function(){euc.is.busy=0;euc.temp.live();},800); face.go(ew.is.dash[ew.def.dash.face],0); - return; + return; case 2: //slide up event - if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. + if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); - }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} + }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} this.timeout(); break; case 3: //slide left event face.go("dashInmotionV1Opt",0); - return; + return; case 4: //slide right event (back action) if (face[0].sub){ face[0].sub=0; @@ -223,13 +221,13 @@ touchHandler[0]=function(e,x,y){ face[0].ntfy("TPMS DISABLED","",20,1,1); return; }else{ - if (global.tpms){ + if (global.tpms){ tpms.scan(); face.go("tpmsFace",0); - }else - face[0].ntfy("NOT INSTALLED","",20,13,1); + }else + face[0].ntfy("NOT INSTALLED","",20,13,1); } - return; + return; }else buzzer.nav(40); this.timeout(); break; diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index a1302158..0aaea5b7 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -361,7 +361,10 @@ euc.conn=function(mac){ return euc.temp.wCha.writeValue(euc.cmd("end")); //}).then(function(err) { //return euc.temp.wCha.writeValue(euc.cmd(cmd,value)); - }).catch(euc.off); + }).then(function() { + euc.tout.loop=0; + euc.tout.loop=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); + }); },250); } }; From 4cc1adeb48cbc626d047dc58b15243742a4fe6c6 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Tue, 6 Jun 2023 23:04:11 +0300 Subject: [PATCH 03/45] Inmotion V5/8/10. Added getting more information. Added receiving: - Serial number - Firmware versions - Production dates - Model names - States of Light - LED states - Volume level --- v2/apps.json | 2 +- v2/euc/eucInmotionV10/eucInmotionV10.js | 208 ++++++++++++++++-------- 2 files changed, 140 insertions(+), 70 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index be664518..cae01aa1 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -801,7 +801,7 @@ { "id": "eucInmotionV10", "name": "Inmotion V5/8/10 module", "icon": "../../v2/euc/eucInmotionV10/icon.png", - "version":"1.94.3", + "version":"1.94.4", "description": "EUC module for Inmotion V5/8/10.", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index 0aaea5b7..222bd29a 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -3,81 +3,71 @@ E.setFlags({ pretokenise: 1 }); euc.cmd=function(no,val){ if (ew.is.bt===2) console.log("inmotion: send cmd :",no); let cmd; - switch (no) { - case "info" : return [170, 170, 20, 1, 165, 85, 15, 255, 255, 255, 255, 255, 255, 255, 255, 8, 5, 0, 1, 127]; - case "batLevelData": return [170, 170, 20, 1, 165, 85, 15, 0, 0, 0, 21, 0, 0, 0, 0, 8, 5, 0, 1, 156]; - case "live": return [170, 170, 19, 1, 165, 85, 15, 255, 255, 255, 255, 255, 255, 255, 255, 8, 5, 0, 0, 125]; - case "init": return [170, 170, 7, 3, 165, 85, 15, 48, 48, 48, 48, 48, 48, 0, 0, 8, 5, 0, 0, 155]; - case "calibration": return [170, 170, 25, 1, 165, 85, 15, 50, 84, 118, 152, 0, 0, 0, 0, 8, 5, 0, 0, 31]; - case "horn": return [170, 170, 9, 6, 165, 85, 15, 4, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0, 132]; - case "beep": return [170, 170, 9, 6, 165, 85, 15, 21, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0, 149]; - case "led": return [170, 170, 9, 6, 165, 85, 15, 21, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0, 149]; - case "end": return [ 85, 85]; + switch (no) { + case "info" : return [0xAA, 0xAA, 0x14, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x01, 0x7F]; + case "batLevelData": return [0xAA, 0xAA, 0x14, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x01, 0x9C]; + case "live": return [0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D]; + case "init": return [0xAA, 0xAA, 0x07, 0x03, 0xA5, 0x55, 0x0F, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x9B]; + case "calibration": return [0xAA, 0xAA, 0x19, 0x01, 0xA5, 0x55, 0x0F, 0x32, 0x54, 0x76, 0x98, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x1F]; + case "horn": return [0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x84]; + case "beep": return [0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x95]; + case "led": return [0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x95]; + case "end": return [0x55, 0x55]; case "playSound"://cmd=0-23 - cmd = [170, 170, 9, 6, 165, 85, 15, val, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; + break; case "setVolume"://cmd=0-100 - cmd = [170, 170, 10, 6, 165, 85, 15, (val * 100) & 0xFF, ((val * 100) / 0x100) & 0xFF, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x0A, 0x06, 0xA5, 0x55, 0x0F, (val * 100) & 0xFF, ((val * 100) / 0x100) & 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; + break; case "setLights"://val=0|1 if (val!=0 && val!=1) return [0]; - cmd = [170, 170, 13, 1, 165, 85, 15, val, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x0D, 0x01, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; + break; case "setBrightness": - cmd = [170, 170, 20, 3, 96, 43, val]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2B, val]; + break; case "setRideMode"://val=0=clasic|1=comfort if (val!=0 && val!=1) return [0]; - cmd = [170, 170, 21, 1, 165, 85, 15, 0, 0, 0, 0, val, 0, 0, 0, 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x00, val, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; + break; case "setPpedalTilt": //val=-80-+80 viw = new DataView(new Int8Array(4).buffer); //to int32 BI. viw.setInt32( 0, val * 65536 / 10 ); - cmd = [170, 170, 21, 1, 165, 85, 15, 0, 0, 0, 0, viw.buffer[3], viw.buffer[2], viw.buffer[1], viw.buffer[0], 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x00, viw.buffer[3], viw.buffer[2], viw.buffer[1], viw.buffer[0], 0x08, 0x05, 0x00, 0x00]; + break; case "setPedalSensitivity": //val=-80-+80 viw = new DataView(new Int8Array(4).buffer); //to int32 BI. viw.setInt32( 0, val * 65536 / 10 ); - cmd = [170, 170, 21, 1, 165, 85, 15, 0, 0, 0, 0, viw.buffer[3], viw.buffer[2], viw.buffer[1], viw.buffer[0], 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x00, viw.buffer[3], viw.buffer[2], viw.buffer[1], viw.buffer[0], 0x08, 0x05, 0x00, 0x00]; + break; case "speedLimit": viw = new DataView(new Int8Array(2).buffer); //to int16 BI. viw.setInt16( 0, val*1000 ); - cmd = [170, 170, 21, 1, 165, 85, 15, 1, 0, 0, 0, viw.buffer[1], viw.buffer[0], 0, 0, 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x01, 0x00, 0x00, 0x00, viw.buffer[1], viw.buffer[0], 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; + break; case "control"://15=ledOn|16=ledOff|5=powerOff|17=beep| - cmd = [170, 170, 22, 1, 165, 85, 15, 178, 0, 0, 0, val, 0, 0, 0, 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x16, 0x01, 0xA5, 0x55, 0x0F, 0xB2, 0x00, 0x00, 0x00, val, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; + break; case "pincode":// - cmd = [170, 170, 7, 3, 165, 85, 15, val, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x07, 0x03, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; + break; case "alert":// - cmd = [170, 170, 1, 1, 165, 85, 15, val, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 0x01, 0x01, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; + break; case "sethandleButton"://val=0|1 if (val!=0 && val!=1) return [0]; - cmd = [170, 170, 46, 1, 165, 85, 15, val, 0, 0, 0, 0, 0, 0, 0, 8, 5, 0, 0]; - cmd.push(7+cmd.reduce(checksum)); - return cmd; + cmd = [0xAA, 0xAA, 46, 0x01, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; + break; } + cmd.push(7+cmd.reduce(checksum)); + return cmd; }; // function checksum(check, val) { return (check + val) & 255; } -//cmd=[[170, 170, 19, 1, 165, 85, 15, -1, -1, -1, -1, -1, -1, -1, -1, 8, 5, 0, 1] +//cmd=[[0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x01] //cmd.push(cmd.reduce(checksum)); function validateChecksum(buffer) { receivedChecksum = buffer[buffer.length - 1]; @@ -86,10 +76,68 @@ function validateChecksum(buffer) { return receivedChecksum == calculatedChecksum; } function appendBuffer(buffer1, buffer2) { - var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength); - tmp.set(new Uint8Array(buffer1), 0); - tmp.set(new Uint8Array(buffer2), buffer1.byteLength); - return tmp.buffer; + var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength); + tmp.set(new Uint8Array(buffer1), 0); + tmp.set(new Uint8Array(buffer2), buffer1.byteLength); + return tmp.buffer; +} + +function getModelName(id) { + switch (id) { + case "50": return "V5"; + case "51": return "V5PLUS"; + case "52": return "V5F"; + case "53": return "V5D"; + case "80": return "V8"; + case "86": return "V8F"; + case "87": return "V8S"; + case "100": return "V10S"; + case "101": return "V10SF"; + case "140": return "V10"; + case "141": return "V10F"; + case "142": return "V10T"; + case "143": return "V10FT"; + } + return "UNKNOWN"; +} + +euc.temp.infoParse= function (inc){ + let lala = new DataView(inc); + //light + euc.dash.opt.lght.HL=lala.getUint8(99); + //led + if(lala.byteLength>149) euc.dash.opt.lght.led=lala.getUint8(149); + //firmware + let v0=lala.getUint8(46); + let v1=lala.getUint8(45); + let v2=((lala.getUint8(44) << 8) | lala.getUint8(43)); + euc.dash.info.get.firm=[v0, v1, v2].join('.'); + //serial + let serial = new String(''); + let tByte; + for (i=26; i > 18; i--) { + tByte=lala.getUint8(i); + if (tByte<0x10) + serial=serial + '0' + tByte.toString(16); + else + serial=serial + tByte.toString(16); + } + euc.dash.info.get.serl=serial.toUpperCase(); + //manufacture date + let year = 2000 + lala.getUint8(26); + let month = ((lala.getUint8(25) & 0xF0) >> 4); + let date = ((lala.getUint8(25) & 0x0F) << 4) + lala.getUint8(24); + euc.dash.info.get.manD=[year.toString(10), month.toString(10), date.toString(10)].join('-'); + //volume + if (lala.byteLength>145) + euc.dash.opt.snd.vol=((lala.getUint8(145) << 8) | lala.getUint8(144)) / 100; + //model + let modelId=lala.getUint8(126).toString(10)+lala.getUint8(123).toString(10) + euc.dash.info.get.modl=getModelName(modelId); + if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Name") || ew.do.fileRead("dash","slot"+"1"+"Name") != euc.dash.info.get.modl) { + ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Name",euc.dash.info.get.modl); + } + return; } euc.temp.liveParse= function (inc){ @@ -214,19 +262,17 @@ euc.conn=function(mac){ euc.temp.tot=E.toUint8Array(euc.temp.last,inc); euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); //got package - if ( (inc.length==1 && inc[0]==85) || (inc[inc.length - 2]==85 && inc[inc.length - 1]==85) ) { - if (ew.is.bt===2) console.log("Inmotion: in: length:",euc.temp.tot.buffer.length," data :",euc.temp.tot); + if ( (inc.length==1 && inc[0]==0x55) || (inc[inc.length - 2]==0x55 && inc[inc.length - 1]==0x55) ) { + if (ew.is.bt===2) console.log("Inmotion: in: length:",euc.temp.tot.buffer.length," data :",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); //live pckg - if (euc.temp.tot.buffer[2]===19) { + if (euc.temp.tot.buffer[2]===0x13) { if (euc.temp.tot.length==euc.temp.pckL) { euc.temp.last=[]; if (ew.is.bt===2) console.log("Inmotion: live in"); euc.temp.liveParse(euc.temp.tot.buffer); euc.temp.last=[]; - euc.temp.live(); - //setTimeout(function(){ euc.temp.live();},100); + euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); return; - //}else if (119 <= euc.temp.tot.length) { }else{ let temp=JSON.parse(JSON.stringify(euc.temp.tot.buffer)); for (let i = 0; i < temp.length; i++){ if (temp[i]===165 && 15<=i) temp.splice(i,1);} @@ -235,8 +281,7 @@ euc.conn=function(mac){ euc.temp.chk=( euc.temp.chk.reduce(checksum) + 7 == temp[temp.length - 3] )?1:0; if (!euc.temp.chk) { if (ew.is.bt===2) console.log("Inmotion: problem: length:", temp.length, temp); - euc.temp.live(); - //setTimeout(function(){euc.temp.live();},100); + euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); euc.temp.last=[]; return; } @@ -244,18 +289,27 @@ euc.conn=function(mac){ euc.temp.pckL=temp.length; euc.temp.last=[]; euc.temp.liveParse(E.toUint8Array(temp).buffer); - euc.temp.live(); - //setTimeout(function(){ euc.temp.live();},100); + euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); return; } + } + //info pckg + if (euc.temp.tot.buffer[2]===0x14) { + if (ew.is.bt===2) console.log("Inmotion: info in"); + euc.temp.infoParse(euc.temp.tot.buffer); + euc.temp.last=[]; + euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); + euc.temp.last=[]; + return; + } //rest - }else { - if (euc.temp.tot.buffer[2]===1) { - if (ew.is.bt===2) console.log("Inmotion: ALERT in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); - euc.temp.alertParse(euc.temp.tot.buffer); - }else - if (ew.is.bt===2) console.log("Inmotion: unknown in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); + if (euc.temp.tot.buffer[2]===1) { + if (ew.is.bt===2) console.log("Inmotion: ALERT in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); + euc.temp.alertParse(euc.temp.tot.buffer); + euc.temp.last=[]; + return; } + if (ew.is.bt===2) console.log("Inmotion: unknown in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); euc.temp.last=[]; return; } @@ -272,15 +326,31 @@ euc.conn=function(mac){ //write function euc.temp.live= function(){ if (euc.tout.alive) clearTimeout(euc.tout.alive); + if (euc.tout.info) clearTimeout(euc.tout.info); euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); if (euc.is.busy) return; - euc.temp.wCha.writeValue([170, 170, 19, 1, 165, 85, 15, 255, 255, 255, 255, 255, 255, 255, 255, 8, 5, 0, 0, 125]).then(function() { - return euc.temp.wCha.writeValue([85, 85, 19, 1, 165, 85, 15, 255, 255, 255, 255, 255, 255, 255, 255, 8, 5, 0, 0, 125]); +// euc.temp.wCha.writeValue([0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D]).then(function() { +// return euc.temp.wCha.writeValue([0x55, 0x55, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D]); + euc.temp.wCha.writeValue(euc.cmd("live")).then(function() { + return euc.temp.wCha.writeValue(euc.cmd("end")); }).catch(function(err) { if (ew.is.bt===2) console.log("EUC InmotionV1: live write fail"); //euc.off("writefail"); }); + euc.tout.info=setTimeout(function(){euc.tout.info=0;euc.temp.info();},100); + }; + euc.temp.info= function(){ + if (euc.tout.alive) clearTimeout(euc.tout.alive); + if (euc.tout.info) clearTimeout(euc.tout.info); + euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); + if (euc.is.busy) return; + euc.temp.wCha.writeValue(euc.cmd("info")).then(function() { + return euc.temp.wCha.writeValue(euc.cmd("end")); + }).catch(function(err) { + if (ew.is.bt===2) console.log("EUC InmotionV1: info write fail"); + }); }; + euc.wri=function(cmd,value){ if (euc.tout.alive) {clearTimeout(euc.tout.alive); euc.tout.alive=0;} euc.is.busy=1; From d5c623bf3b8d5d29ade736458146efaf5e9cf5b1 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Wed, 7 Jun 2023 23:19:19 +0300 Subject: [PATCH 04/45] Inmotion V5/8/10. Fixed manufacturing date calculation. --- v2/apps.json | 2 +- v2/euc/eucInmotionV10/eucInmotionV10.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index cae01aa1..f2892a77 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -801,7 +801,7 @@ { "id": "eucInmotionV10", "name": "Inmotion V5/8/10 module", "icon": "../../v2/euc/eucInmotionV10/icon.png", - "version":"1.94.4", + "version":"1.94.5", "description": "EUC module for Inmotion V5/8/10.", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index 222bd29a..ff834516 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -126,7 +126,7 @@ euc.temp.infoParse= function (inc){ //manufacture date let year = 2000 + lala.getUint8(26); let month = ((lala.getUint8(25) & 0xF0) >> 4); - let date = ((lala.getUint8(25) & 0x0F) << 4) + lala.getUint8(24); + let date = ((lala.getUint8(25) & 0x0F) << 4) | (lala.getUint8(24) & 0x0F); euc.dash.info.get.manD=[year.toString(10), month.toString(10), date.toString(10)].join('-'); //volume if (lala.byteLength>145) From 559558987e30f86b0c5f79abaaf8ab9f2d1a6ccf Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Fri, 21 Jul 2023 00:07:51 +0300 Subject: [PATCH 05/45] Fixed speed display after turning on the screen. When the screen was turned on, the current speed was not immediately displayed, but gradually increased. Removed smooth zoom when turning on the screen. At the same time, while the screen is running, the speed still changes smoothly. --- P8-testing/apps.json | 2 +- P8-testing/dash/dash_digital.js | 137 +++++++++++++++++--------------- v2/apps.json | 2 +- 3 files changed, 73 insertions(+), 68 deletions(-) diff --git a/P8-testing/apps.json b/P8-testing/apps.json index 5b031585..2737d293 100644 --- a/P8-testing/apps.json +++ b/P8-testing/apps.json @@ -166,7 +166,7 @@ { "id": "Dashboard Digital", "name": "EUC digital Dashboard", "icon": "../dash/icon.png", - "version":"1.92.1", + "version":"1.92.2", "description": "EUC simple digital", "tags": "euc", "readme": "README.md", diff --git a/P8-testing/dash/dash_digital.js b/P8-testing/dash/dash_digital.js index cebc046d..a731fb26 100644 --- a/P8-testing/dash/dash_digital.js +++ b/P8-testing/dash/dash_digital.js @@ -9,7 +9,7 @@ face[0] = { if (face.appPrev.startsWith("dash_")) { this.g.setColor(0,0); this.g.fillRect(0,51,239,239); - this.g.flip(); + this.g.flip(); }else this.g.clear(); this.spdC=[0,14,13,13]; this.ampC=[1,9,13,13]; @@ -29,9 +29,10 @@ face[0] = { this.lock=2; this.trpL=-1; this.bar=0; - this.fact=euc.dash.opt.unit.fact.spd*((ew.def.dash.mph)?0.625:1); + this.fact=euc.dash.opt.unit.fact.spd*((ew.def.dash.mph)?0.625:1); this.trpF=euc.dash.opt.unit.fact.dist*((ew.def.dash.mph)?0.625:1); this.run=true; + this.afterScrOff=false; }, show : function(o){ if (!this.run) return; @@ -49,35 +50,37 @@ face[0] = { //tmp/amp block if (!ew.def.dash.amp) { if (this.amp!=Math.round(euc.dash.live.amp)) this.ampF(); - }else + }else if (this.tmp!=Math.round(euc.dash.live.tmp)) this.tmpF(); //alarm block - if (this.buzz!=euc.is.buzz) this.buzF(); + if (this.buzz!=euc.is.buzz) this.buzF(); //spdMspeed block - if (this.topS!=euc.dash.trip.topS.toFixed(1)) this.spMF(); + if (this.topS!=euc.dash.trip.topS.toFixed(1)) this.spMF(); //buzzer/health block if (euc.dash.info.get.makr=="Kingsong"||euc.dash.info.get.makr=="Begode") { if (this.aTlt!=euc.dash.alrt.spd.max) this.limF(); - }else if (this.alrm!=euc.dash.alrt.pwr) this.alrF(); + }else if (this.alrm!=euc.dash.alrt.pwr) this.alrF(); //tmp/amp field if (ew.def.dash.amp){ - //if (this.ampL!=euc.log.ampL) - this.amLF(); + //if (this.ampL!=euc.log.ampL) + this.amLF(); }else if (this.tmp!=euc.dash.live.tmp.toFixed(1)) this.tmFF(); //batery field if (!ew.def.dash.bat){ if (this.volt!=euc.dash.live.volt.toFixed(2)) this.vltF(); }else if (ew.def.dash.bat==1) { if (euc.dash.live.bat!=this.bat) this.batF(); - }else this.baLF();//if (this.batL!=euc.log.batL) this.baLF(); + }else this.baLF();//if (this.batL!=euc.log.batL) this.baLF(); //Mileage if (euc.dash.alrt.warn.txt) this.almTF(); - else if (this.trpL!=euc.dash.trip.last.toFixed(2)) this.mileage(); + else if (this.trpL!=euc.dash.trip.last.toFixed(2)) this.mileage(); + this.afterScrOff=false; //off } else if (euc.state=="OFF") { setTimeout(function(){ face.go("dashOff",0); },250); + this.afterScrOff=false; return; //rest } else { @@ -98,26 +101,27 @@ face[0] = { } } euc.new=0; - //refresh + //refresh this.tid=setTimeout(function(t){ t.tid=-1; t.show(); },20,this); + this.afterScrOff=false; }, spdF: function(){ "ram"; - if ( Math.abs(euc.dash.live.spd-this.spd) <5 ) this.spd =Math.round(euc.dash.live.spd); - else if (euc.dash.live.spd=ew.is.dash.length) - ew.def.dash.face=0; - else + if (ew.def.dash.face+1>=ew.is.dash.length) + ew.def.dash.face=0; + else ew.def.dash.face++; face.go(ew.is.dash[ew.def.dash.face],0); return; @@ -430,4 +435,4 @@ touchHandler[0]=function(e,x,y){ buzzer.nav(40); break; } -}; \ No newline at end of file +}; diff --git a/v2/apps.json b/v2/apps.json index f2892a77..84cad11c 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -280,7 +280,7 @@ { "id": "Dashboard Digital", "name": "EUC digital Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "EUC simple digital", "tags": "euc", "needsFeatures":["V1"], From 705eb91acd0eb5266431880e2e44fce4ad112d05 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Wed, 16 Aug 2023 13:40:58 +0300 Subject: [PATCH 06/45] Allowed control of the accelerometer when the unicycle is connected. --- P8-testing/settings/settings.js | 31 ++++++++++++++++++++----------- v2/apps.json | 18 +++++++++--------- v2/euc/euc.js | 8 +++++--- v2/handler/handler_btn.js | 8 ++++---- 4 files changed, 38 insertions(+), 27 deletions(-) diff --git a/P8-testing/settings/settings.js b/P8-testing/settings/settings.js index f197a0bc..435c5177 100644 --- a/P8-testing/settings/settings.js +++ b/P8-testing/settings/settings.js @@ -1,5 +1,5 @@ E.setFlags({pretokenise:1}); -//settings +//settings face[0] = { offms: (ew.def.off[face.appCurr]) ? ew.def.off[face.appCurr] : 10000, g: w.gfx, @@ -71,7 +71,7 @@ face[0] = { this.g.fillRect(0, 0, 239, 155); this.g.setColor(1, 1); this.g.fillRect(0, 0, 239, 75); - //this.g.fillRect(0,80,239,155); + //this.g.fillRect(0,80,239,155); this.g.flip(); this.g.setColor(0, 15); this.g.setFont("Vector", 35); @@ -94,21 +94,22 @@ face[0] = { } if (ew.def.cli != this.cli) { this.cli = ew.def.cli; - this.btn(this.cli, 160, 0, 239, 75, require("heatshrink").decompress(atob("mEmwIPMggFEj4FEn+AAonAAongAonwDon4Aon8AocP/wFDg//AocD/4wDgP/GAgFFv42RAokPBZQFFEYovFHYhHBJoZTBL4hlEh5xEFxE///4SoQFDFwIFDFwIFCXIQFCYoUP/5KEAA4")), 176, 15, 11, 4, 0, 2); //btn3 + this.btn(this.cli, 160, 0, 239, 75, require("heatshrink").decompress(atob("mEmwIPMggFEj4FEn+AAonAAongAonwDon4Aon8AocP/wFDg//AocD/4wDgP/GAgFFv42RAokPBZQFFEYovFHYhHBJoZTBL4hlEh5xEFxE///4SoQFDFwIFDFwIFCXIQFCYoUP/5KEAA4")), 176, 15, 11, global.euc.state != "OFF" ? 10 : 4, global.euc.state != "OFF" ? 0 : 11, 2); //btn3 } if (ew.def.gb != this.gb) { this.gb = ew.def.gb; - this.btn(this.gb, 0, 80, 75, 155, require("heatshrink").decompress(atob("mEwwIFCg4LEh/AAocfAok/Aol/zAFEnwREvwoD43+FAfw/ngFAX8/vwAoX+vP4DgX/uYFEs4RCv4FB84FDh/vAoP/h0f5+AAoMBn+fAoWOn8/CIXAv9/DoXg/xOCv5HB/g1C+H5HYfwuf6JoX5gf2AoeD8hlC/P75AFC/v5QgUH/v8mAFC///L4UDAoJ9CAosBAoKoCAopaB/5kBAqQdFgfwg41D8ABBAqgdEJpA1FII4A==")), 13, 94, 11, 4, 0, 2); //btn4 + this.btn(this.gb, 0, 80, 75, 155, require("heatshrink").decompress(atob("mEwwIFCg4LEh/AAocfAok/Aol/zAFEnwREvwoD43+FAfw/ngFAX8/vwAoX+vP4DgX/uYFEs4RCv4FB84FDh/vAoP/h0f5+AAoMBn+fAoWOn8/CIXAv9/DoXg/xOCv5HB/g1C+H5HYfwuf6JoX5gf2AoeD8hlC/P75AFC/v5QgUH/v8mAFC///L4UDAoJ9CAosBAoKoCAopaB/5kBAqQdFgfwg41D8ABBAqgdEJpA1FII4A==")), 13, 94, 11, global.euc.state != "OFF" ? 10 : 4, global.euc.state != "OFF" ? 0 : 11, 2); //btn4 } if (ew.def.prxy != this.prxy) { this.prxy = ew.def.prxy; - if (this.prxy) this.btn(1, 80, 80, 155, 155, require("heatshrink").decompress(atob("mEwwMB/4AL/ATBh4FB4AFBCwQgD//+Aod//kDCgU//kfEAUf/E/AoIJB+F/AoP+h4FD/4FBHIcH+H8vgFBw/gAoITBAowRCAoYdDAoovG/A7EI4v8NwXwLIJlDn5rF/+APongAoJ0CN4Q4D/grCAqYdF8EHAofAFwYFGwPBEIUAg5DBLIQFVD4ODEYQvH8AFE+BHEKYoAJA=")), 92, 93, 11, 4, 0, 2); //btn5 + //if (this.prxy) this.btn(1, 80, 80, 155, 155, require("heatshrink").decompress(atob("mEwwMB/4AL/ATBh4FB4AFBCwQgD//+Aod//kDCgU//kfEAUf/E/AoIJB+F/AoP+h4FD/4FBHIcH+H8vgFBw/gAoITBAowRCAoYdDAoovG/A7EI4v8NwXwLIJlDn5rF/+APongAoJ0CN4Q4D/grCAqYdF8EHAofAFwYFGwPBEIUAg5DBLIQFVD4ODEYQvH8AFE+BHEKYoAJA=")), 92, 93, 11, global.euc.state != "OFF" ? 10 : 4, global.euc.state != "OFF" ? 0 : 11, 2); //btn5 //else if (this.prxy == 2) this.btn(1, 80, 80, 155, 155, require("heatshrink").decompress(atob("mUywIQNg//AAP4Aon/4EDAof4gIFD/8AAongv4SEj4DB44CBEgP+FAXDAoQcB+AFDv/+n4FCDgOP/8B/w1B8f/wIWBn/4IwP+/0PDAPw/ED4IYB/E4gF4n/j/0cG4MPDAMOgEB8IYB4eAgE4v+P8PAgEGj/j/FwCQPD/AeCgFwDAOGAoMcn4YBDwIrBDANgDAkYDAmHDAoxBg4xB/hQBgeHJQ/BCQNwMYV4KAJjB/8PwE+j4YB4P8v0HDAKwCZYKVCAIQYB8CuCDAK0D/k/TgLXCY4YFBToIADWALgEh4FD/j5GCQhmBAoaMBDIX8HQIAFA=")), 92, 93, 11, 4, 0, 2); //btn5 - else this.btn(0, 80, 80, 155, 155, require("heatshrink").decompress(atob("mEwwMB/4AL/ATBh4FB4AFBCwQgD//+Aod//kDCgU//kfEAUf/E/AoIJB+F/AoP+h4FD/4FBHIcH+H8vgFBw/gAoITBAowRCAoYdDAoovG/A7EI4v8NwXwLIJlDn5rF/+APongAoJ0CN4Q4D/grCAqYdF8EHAofAFwYFGwPBEIUAg5DBLIQFVD4ODEYQvH8AFE+BHEKYoAJA=")), 95, 94, 11, 4, 0, 2); //btn5 + //else this.btn(0, 80, 80, 155, 155, require("heatshrink").decompress(atob("mEwwMB/4AL/ATBh4FB4AFBCwQgD//+Aod//kDCgU//kfEAUf/E/AoIJB+F/AoP+h4FD/4FBHIcH+H8vgFBw/gAoITBAowRCAoYdDAoovG/A7EI4v8NwXwLIJlDn5rF/+APongAoJ0CN4Q4D/grCAqYdF8EHAofAFwYFGwPBEIUAg5DBLIQFVD4ODEYQvH8AFE+BHEKYoAJA=")), 95, 94, 11, 4, 0, 2); //btn5 + this.btn(this.prxy, 80, 80, 155, 155, require("heatshrink").decompress(atob("mEwwMB/4AL/ATBh4FB4AFBCwQgD//+Aod//kDCgU//kfEAUf/E/AoIJB+F/AoP+h4FD/4FBHIcH+H8vgFBw/gAoITBAowRCAoYdDAoovG/A7EI4v8NwXwLIJlDn5rF/+APongAoJ0CN4Q4D/grCAqYdF8EHAofAFwYFGwPBEIUAg5DBLIQFVD4ODEYQvH8AFE+BHEKYoAJA=")), 92, 93, 11, global.euc.state != "OFF" ? 10 : 4, global.euc.state != "OFF" ? 0 : 11, 2); //btn5 } if (ew.def.hid != this.hid) { this.hid = ew.def.hid; - this.btn(this.hid, 160, 80, 239, 155, require("heatshrink").decompress(atob("mEwwIOLkAEDgPwAocHAok/AocB/4FDh4FEv4FDgf/AocfAogEBAoQhBApnxAomBAof8JoQ/CAohZDgP8AongAuF9AoZ4BAoaJDAoJ+BAoc/ApSbCMgIFCEAQRCEAQFC4AIEwAUEXgRBBP4IFCZAgFF4DlDEAIFEeIcP/wFDgb9EAAoA=")), 176, 94, 11, 4, 0, 2); //btn6 + this.btn(this.hid, 160, 80, 239, 155, require("heatshrink").decompress(atob("mEwwIOLkAEDgPwAocHAok/AocB/4FDh4FEv4FDgf/AocfAogEBAoQhBApnxAomBAof8JoQ/CAohZDgP8AongAuF9AoZ4BAoaJDAoJ+BAoc/ApSbCMgIFCEAQRCEAQFC4AIEwAUEXgRBBP4IFCZAgFF4DlDEAIFEeIcP/wFDgb9EAAoA=")), 176, 94, 11, global.euc.state != "OFF" ? 10 : 4, global.euc.state != "OFF" ? 0 : 11, 2); //btn6 } } else { //settings @@ -122,7 +123,7 @@ face[0] = { this.btn(state, 0, 0, 75, 75, (state) ? require("heatshrink").decompress(atob("mEwwIXUgYFFwAFE4AFE8AFE/AFE/gFE/wFE/4FE74qCgUD54qCg8D44qCh+D4fwAoXDAocD8YRDgPzDocA/YpDgF/Gok/IIkfJokPLIkHFwQFHCIodFFIo1FIIhNFLIplFOIp9FRIqVFUI6tFXIrFFaIrdFdIr/IABY=")) : this.img, 13, 15, 11, 1, 15, 1); this.img = 0; } - //themes + //themes if (this.btn2) { this.btn2 = 0; this.g.setColor(0, 0); @@ -143,12 +144,12 @@ face[0] = { //find my phone if (ew.is.fmp != this.fmp) { this.fmp = ew.is.fmp; - this.btn(this.fmp, 0, 80, 75, 155, require("heatshrink").decompress(atob("mEwwILIv/+AgUD///4AFBg8//HgAoMGj/4sAFCAQIFfgYFD4EPAofghwFDuEcAoc4nAFDjkw4wFBscMuIFDx1hwwFBAYPjAofG8YdD4/HApPjAqIjEAovHsY1D45BFJopZFMopxFPosHAofwSoq/jAo0HAQL1Cgf//40BAAM87wECAAg")), 13, 94, 15, 7, (ew.is.bt == 3) ? 15 : 0, (ew.is.bt == 3) ? 1 : 2); //btn4 + this.btn(this.fmp, 0, 80, 75, 155, require("heatshrink").decompress(atob("mEwwILIv/+AgUD///4AFBg8//HgAoMGj/4sAFCAQIFfgYFD4EPAofghwFDuEcAoc4nAFDjkw4wFBscMuIFDx1hwwFBAYPjAofG8YdD4/HApPjAqIjEAovHsY1D45BFJopZFMopxFPosHAofwSoq/jAo0HAQL1Cgf//40BAAM87wECAAg")), 13, 94, 15, 7, (ew.is.bt == 3) ? 11 : 0, (ew.is.bt == 3) ? 1 : 2); //btn4 } //acc on/off if (ew.def.acc != this.acc) { this.acc = ew.def.acc; - this.btn(this.acc, 80, 80, 155, 155, require("heatshrink").decompress(atob("mEwwJC/AAkPwAECgP//AFCg///4FCj4FBCQU/AoPgAoN/4Ef+AFB/wZBDwMB/gCCgUDBwV+h0HDQU/jkP4AsCvg/Dh/8j5JDAokH/k+Igf4Aoc//E8AoRbBvhhEAoUD//wjAnBwIFBEIRaEn/AgIFDJ4QFIKoQdDAoibDgECbfA=")), 95, 94, 11, global.euc.state != "OFF" ? 12 : 4, 11, global.euc.state != "OFF" ? 12 : 2); + this.btn(this.acc, 80, 80, 155, 155, require("heatshrink").decompress(atob("mEwwJC/AAkPwAECgP//AFCg///4FCj4FBCQU/AoPgAoN/4Ef+AFB/wZBDwMB/gCCgUDBwV+h0HDQU/jkP4AsCvg/Dh/8j5JDAokH/k+Igf4Aoc//E8AoRbBvhhEAoUD//wjAnBwIFBEIRaEn/AgIFDJ4QFIKoQdDAoibDgECbfA=")), 95, 94, 11, 4, 11, 2); } //brightness level if (this.g.bri.lv != this.bri) { @@ -419,8 +420,16 @@ touchHandler[0] = function(e, x, y) { buzzer.nav(40); } else { - if (global.euc.state != "OFF") { buzzer.nav(40); return; } ew.def.acc = 1 - ew.def.acc; + acc.off(); + if (global.euc.state != "OFF") { + if (ew.def.acc) { + setTimeout(() => { ew.def.dash.accE = 1; + acc.on(2); }, 1000); + } + buzzer.nav([30, 50, 30]); + return; + } ew.do.update.acc(); buzzer.nav([30, 50, 30]); } diff --git a/v2/apps.json b/v2/apps.json index 84cad11c..fbdd0dba 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -118,7 +118,7 @@ ] }, - + { "id": "handler", "name": "Handler - V2", "icon": "../../Magic-testing/handler/icon.png", @@ -146,11 +146,11 @@ {"name":"handler_acc_SC7A20","url":"../handler/handler_acc_SC7A20.js"}, {"name":"handler_buzz","url":"../handler/handler_buzz.js"} ] - }, + }, { "id": "handler", "name": "Handler - V1", "icon": "../handler/icon.png", - "version":"1.94.6", + "version":"1.94.7", "description": "P8-P22-Pinetime functions handler", "tags": "core", "needsFeatures":["V1"], @@ -173,7 +173,7 @@ {"name":"handler_buzz","url":"../handler/handler_buzz.js"} ] - }, + }, { "id": "handler_pt", "name": "Handler - Pinetime", "icon": "../../P8-testing/handler_pt/icon.png", @@ -186,7 +186,7 @@ "storage": [ {"name":"handler","url":"../../P8-testing/handler_pt/handler.js"} ] - }, + }, { "id": "clock", "name": "Clock face", "icon": "../../P8-testing/clock/icon.png", @@ -199,11 +199,11 @@ {"name":"clock","url":"../../P8-testing/clock/clock.js"}, {"name":"clockOptions","url":"../../P8-testing/clock/clockOptions.js"} ] - }, + }, { "id": "settings", "name": "Settings", "icon": "../../P8-testing/settings/icon.png", - "version":"1.94.1", + "version":"1.94.3", "description": "Settings face", "tags": "apps", "type":"clock", @@ -733,11 +733,11 @@ {"name":"hid","url":"../../Magic-testing/hid/hid.js"} ] }, - + { "id": "euc", "name": "EUC modules support", "icon": "../../v2/euc/icon.png", - "version":"1.94.4", + "version":"1.94.5", "description": "EUC module switcher, depends on wheel module.", "tags": "euc", "needsFeatures":["EW"], diff --git a/v2/euc/euc.js b/v2/euc/euc.js index d1d9554d..a52c0d23 100644 --- a/v2/euc/euc.js +++ b/v2/euc/euc.js @@ -70,9 +70,11 @@ global.euc = { } if (euc.dash.info.get.makr !== "Kingsong" || euc.dash.info.get.makr !== "inmotionV11") euc.dash.trip.topS = 0; this.conn(this.mac); - if (ew.def.acc) acc.off(); - setTimeout(() => { ew.def.dash.accE = 1; - acc.on(2); }, 1000); + acc.off(); + if (ew.def.acc) { + setTimeout(() => { ew.def.dash.accE = 1; + acc.on(2); }, 1000); + } if (euc.dash.opt.tpms && global.tpms && !tpms.def.int) { tpms.euc = {}; setTimeout(() => { tpms.scan(); }, 10000); } //tpms face.go(ew.is.dash[ew.def.dash.face], 0); diff --git a/v2/handler/handler_btn.js b/v2/handler/handler_btn.js index 58e7da5d..2c94cd75 100644 --- a/v2/handler/handler_btn.js +++ b/v2/handler/handler_btn.js @@ -27,7 +27,7 @@ function btn1(s){ if (face.offid) {clearTimeout(face.offid);face.offid=0;} if (s.state) { this.press=true; - if (global.euc&&euc.state=="READY"&&2<=euc.dash.live.spd&&euc.dash.opt.horn.en) {euc.wri("hornOn");return;} + if (global.euc&&euc.state=="READY"&&2<=euc.dash.live.spd&&euc.dash.opt.horn.en) {euc.wri("hornOn"); if (ew.def.acc) return;} this.t1=setTimeout(() => { this.t1=0; if (global.euc) { @@ -37,7 +37,7 @@ function btn1(s){ }, process.env.BOARD=="BANGLEJS2"?300:800); }else if (this.press && !s.state) { this.press=false; - if (global.euc&&euc.state=="READY"&&euc.is.horn&&euc.dash.opt.horn.en) {euc.wri("hornOff");return;} + if (global.euc&&euc.state=="READY"&&euc.is.horn&&euc.dash.opt.horn.en) {euc.wri("hornOff"); if (ew.def.acc) return;} if (face.pageCurr==-1) { buzzer.nav(buzzer.buzz.on); face.go((global.euc&&euc.state!="OFF")?ew.is.dash[ew.def.dash.face]:face.appCurr,0); @@ -53,7 +53,7 @@ function btn1(s){ else face.go("clock",0); } - }else if (this.press&&global.euc&&euc.state==="READY"&&euc.is.horn&&euc.dash.opt.horn.en) {euc.wri("hornOff");return; + }else if (this.press&&global.euc&&euc.state==="READY"&&euc.is.horn&&euc.dash.opt.horn.en) {euc.wri("hornOff"); if (ew.def.acc) return; }else face.off(); } ew.tid.btn1=setWatch(btn1,BTN1, {repeat:true, debounce:50,edge:0}); @@ -61,4 +61,4 @@ if (process.env.BOARD=="ROCK"){ D46.mode("input_pulldown"); btn2=btn1.bind(); ew.tid.btn2=setWatch(btn2,D46, {repeat:true, debounce:false,edge:0}); -} \ No newline at end of file +} From 9943169772c2f66b99adf0387bc5bb8c861f4fc8 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Thu, 17 Aug 2023 18:46:32 +0300 Subject: [PATCH 07/45] Added proxy for Inmotion V5/8/10 module. Due to limited watch resources and rather large data packets in the Inmotion V5/8/10 protocol, the functionality had to be limited. WheelLog will only receive information from the wheel, but will not be able to control it and change settings in any way. --- P8-testing/dashInmotionV10/dashInmotionV10.js | 3 - .../dashInmotionV10/dashInmotionV10Adv.js | 55 ++--- .../dashInmotionV10AdvCalibrate.js | 55 ++--- .../dashInmotionV10AdvLimits.js | 59 +++-- .../dashInmotionV10/dashInmotionV10AdvPass.js | 96 ++++---- .../dashInmotionV10/dashInmotionV10Opt.js | 49 ++-- .../dashInmotionV10/dashInmotionV10Opt2.js | 47 ++-- v2/apps.json | 15 +- v2/euc/euc.js | 4 + v2/euc/eucInmotionV10/eucInmotionV10.js | 230 +++++++++--------- v2/euc/eucInmotionV10/proxyInmotionV10.js | 128 ++++++++++ 11 files changed, 426 insertions(+), 315 deletions(-) create mode 100644 v2/euc/eucInmotionV10/proxyInmotionV10.js diff --git a/P8-testing/dashInmotionV10/dashInmotionV10.js b/P8-testing/dashInmotionV10/dashInmotionV10.js index 75389c5c..14b377c8 100644 --- a/P8-testing/dashInmotionV10/dashInmotionV10.js +++ b/P8-testing/dashInmotionV10/dashInmotionV10.js @@ -121,7 +121,6 @@ face[1] = { return true; }, show : function(){ - setTimeout(function(){euc.is.busy=0;euc.temp.live();},800); face.go(ew.is.dash[ew.def.dash.face],0); return true; }, @@ -184,7 +183,6 @@ touchHandler[0]=function(e,x,y){ break; case 1: //slide down event //face.go("clock",0); - setTimeout(function(){euc.is.busy=0;euc.temp.live();},800); face.go(ew.is.dash[ew.def.dash.face],0); return; case 2: //slide up event @@ -205,7 +203,6 @@ touchHandler[0]=function(e,x,y){ face[0].init(); return; } - setTimeout(function(){euc.is.busy=0;euc.temp.live();},800); face.go(ew.is.dash[ew.def.dash.face],0); return; case 12: //long press event diff --git a/P8-testing/dashInmotionV10/dashInmotionV10Adv.js b/P8-testing/dashInmotionV10/dashInmotionV10Adv.js index e9c5dd99..63d66841 100644 --- a/P8-testing/dashInmotionV10/dashInmotionV10Adv.js +++ b/P8-testing/dashInmotionV10/dashInmotionV10Adv.js @@ -7,14 +7,14 @@ face[0] = { //if (!face.appPrev.startsWith("dash")) this.g.clear(); this.g.setColor(0,0); this.g.fillRect(0,98,239,99); - this.g.flip(); + this.g.flip(); this.g.fillRect(120,0,121,195); this.g.flip(); this.g.setColor(0,0); this.g.fillRect(0,205,239,239); this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString("ADVANCED",122-(this.g.stringWidth("ADVANCED")/2),217); + this.g.drawString("ADVANCED",122-(this.g.stringWidth("ADVANCED")/2),217); this.g.flip(); this.g.setColor(0,0); this.g.fillRect(0,196,239,204); @@ -23,46 +23,46 @@ face[0] = { this.g.flip(); this.g.setColor(1,15); this.g.fillRect(143,200,165,204); - this.g.flip(); + this.g.flip(); //ride mode this.g.setColor(0,(euc.dash.opt.ride.mode)?4:1); this.g.fillRect(0,0,119,97); this.g.setColor(1,15); - this.g.setFont("Vector",18); - this.g.drawString("MODE",60-(this.g.stringWidth("MODE")/2),15); - this.g.setFont("Vector",23); - this.g.drawString((euc.dash.opt.ride.mode)?"CLASIC":"COMFORT",60-(this.g.stringWidth((euc.dash.opt.ride.mode)?"CLASIC":"COMFORT")/2),55); + this.g.setFont("Vector",18); + this.g.drawString("MODE",60-(this.g.stringWidth("MODE")/2),15); + this.g.setFont("Vector",23); + this.g.drawString((euc.dash.opt.ride.mode)?"CLASIC":"COMFORT",60-(this.g.stringWidth((euc.dash.opt.ride.mode)?"CLASIC":"COMFORT")/2),55); this.g.flip(); //calibrate this.g.setColor(0,12); this.g.fillRect(122,0,239,97); this.g.setColor(1,15); // this.g.drawImage(E.toArrayBuffer(atob("GAiBADAYDHg8HsxmM8xmM8xmI8xmM3g8HjAYDA==")),195,45); - this.g.setFont("Vector",18); - this.g.drawString("CALIBRATE",185-(this.g.stringWidth("CALIBRATE")/2),37); + this.g.setFont("Vector",18); + this.g.drawString("CALIBRATE",185-(this.g.stringWidth("CALIBRATE")/2),37); this.g.flip(); //limits this.g.setColor(0,12); this.g.fillRect(0,100,119,195); this.g.setColor(1,15); - this.g.setFont("Vector",22); - this.g.drawString("WHEEL",60-(this.g.stringWidth("WHEEL")/2),115); + this.g.setFont("Vector",22); + this.g.drawString("WHEEL",60-(this.g.stringWidth("WHEEL")/2),115); // this.g.setFont("Vector",25); - this.g.drawString("ALERTS",60-(this.g.stringWidth("ALERTS")/2),150); -// this.g.drawString(euc.dash.alrt.spd.tilt.val,60-(this.g.stringWidth(euc.dash.alrt.spd.tilt.val)/2),150); + this.g.drawString("ALERTS",60-(this.g.stringWidth("ALERTS")/2),150); +// this.g.drawString(euc.dash.alrt.spd.tilt.val,60-(this.g.stringWidth(euc.dash.alrt.spd.tilt.val)/2),150); this.g.flip(); //pass this.g.setColor(0,12); this.g.fillRect(122,100,239,195); this.g.setColor(1,15); - this.g.setFont("Vector",28); - this.g.drawString("PASS",185-(this.g.stringWidth("PASS")/2),135); + this.g.setFont("Vector",28); + this.g.drawString("PASS",185-(this.g.stringWidth("PASS")/2),135); this.g.flip(); this.run=true; }, show : function(){ if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} - if (!this.run) return; + if (!this.run) return; this.tid=setTimeout(function(t,o){ t.tid=-1; t.show(); @@ -72,10 +72,10 @@ face[0] = { this.g.setColor(0,clr); this.g.fillRect(rx1,ry1,rx2,ry2); this.g.setColor(1,15); - this.g.setFont("Vector",size); - this.g.drawString(txt,x-(this.g.stringWidth(txt)/2),y); + this.g.setFont("Vector",size); + this.g.drawString(txt,x-(this.g.stringWidth(txt)/2),y); if (txt1){ - this.g.setFont("Vector",size1); + this.g.setFont("Vector",size1); this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); } this.g.flip(); @@ -107,16 +107,16 @@ face[1] = { clear: function(){ return true; }, -}; +}; //touch -touchHandler[0]=function(e,x,y){ +touchHandler[0]=function(e,x,y){ switch (e) { case 5:case 12: //tap event if ( x<=120 && y<=100 ) { //ride mode euc.dash.opt.ride.mode=1-euc.dash.opt.ride.mode; face[0].btn("MODE",18,60,20,(euc.dash.opt.ride.mode)?4:1,0,0,119,97,(euc.dash.opt.ride.mode)?"CLASIC":"COMFORT",23,60,55); euc.wri("setRideMode",euc.dash.opt.ride.mode); - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); }else if ( 120<=x && y<=100 ) { //calibrate buzzer.nav([30,50,30]); face.go("dashInmotionV1AdvCalibrate",0); @@ -126,7 +126,7 @@ touchHandler[0]=function(e,x,y){ // face.go("dashInmotionV1AdvLimits",0); // return; //}else if ( 120<=x && 100<=y ) { //pass - // buzzer.nav([30,50,30]); + // buzzer.nav([30,50,30]); // if (euc.dash.opt.lock.pass.length>=4) face.go("dashInmotionV1AdvPass",5); // else face.go("dashInmotionV1AdvPass",0); // return; @@ -134,19 +134,18 @@ touchHandler[0]=function(e,x,y){ this.timeout(); break; case 1: //slide down event - setTimeout(function(){euc.is.busy=0;euc.temp.live();},800); face.go(ew.is.dash[ew.def.dash.face],0); - return; + return; case 2: //slide up event - if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. + if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); - }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} + }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} this.timeout(); break; case 3: //slide left event - buzzer.nav(40); + buzzer.nav(40); this.timeout(); break; case 4: //slide right event (back action) diff --git a/P8-testing/dashInmotionV10/dashInmotionV10AdvCalibrate.js b/P8-testing/dashInmotionV10/dashInmotionV10AdvCalibrate.js index 22a7bf6b..8e272969 100644 --- a/P8-testing/dashInmotionV10/dashInmotionV10AdvCalibrate.js +++ b/P8-testing/dashInmotionV10/dashInmotionV10AdvCalibrate.js @@ -7,59 +7,59 @@ face[0] = { this.g.fillRect(0,0,239,177); this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString("SET PEDAL TILT",120-(this.g.stringWidth("SET PEDAL TILT")/2),10); + this.g.drawString("SET PEDAL TILT",120-(this.g.stringWidth("SET PEDAL TILT")/2),10); // this.g.drawString("MANUALY SET PEDAL TILT",120-(this.g.stringWidth("MANUALY SET PEDAL TILT")/2),5); this.g.drawImage(require("heatshrink").decompress(atob("oFAwJC/AAs8A41+A43/AwsDA40HA40PA40f/wHFn/8Fw34AwkB//wGw3AGw2AGxk/Gw1/Gw4uFGwPgGxguBGwsfGw4uGv5lFGw4HBGwoHJC4wnHG45HHK45nHO444JGAynHW47HHHBKBHNJ44QA4o4BA4owBA41+A408A4wA6A==")),0,70); this.g.drawImage(require("heatshrink").decompress(atob("oFAwJC/AAU8A41+A43/A4/AA43gA43wA4t//AHFn/8A4sfGA0P/+AA4kDHA0BHCAwGn/+GA4HFg44QGA3/NJ44QA5oXHE443HI4xXHM453HGw6XHU44uGY442Hc473HMo9/Voy9Ifw42FA4IGFgF+A408A4wA9A=")),180,70); - this.g.flip(); + this.g.flip(); this.g.setColor(1,15); this.g.setFont("Vector",80); - this.g.drawString(euc.dash.opt.ride.pTlt,130-(this.g.stringWidth(euc.dash.opt.ride.pTlt)/2),65); - this.g.flip(); + this.g.drawString(euc.dash.opt.ride.pTlt,130-(this.g.stringWidth(euc.dash.opt.ride.pTlt)/2),65); + this.g.flip(); this.g.setColor(0,12); this.g.fillRect(0,177,239,239); this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString("START",120-(this.g.stringWidth("START")/2),188); - this.g.drawString("CALIBRATION",120-(this.g.stringWidth("CALIBRATION")/2),216); - this.g.flip(); + this.g.drawString("START",120-(this.g.stringWidth("START")/2),188); + this.g.drawString("CALIBRATION",120-(this.g.stringWidth("CALIBRATION")/2),216); + this.g.flip(); this.calibrate=0; this.run=true; }, show : function(){ if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} - if (!this.run) return; + if (!this.run) return; if (this.calibrate) { this.g.setColor(0,1); - this.g.fillRect(0,0,239,174); + this.g.fillRect(0,0,239,174); this.g.setColor(1,15); this.g.setFont("Vector",17); - this.g.drawString("1. LEVEL WHEEL",25,10); - this.g.drawString("2. HOLD HANDLE",25,37); + this.g.drawString("1. LEVEL WHEEL",25,10); + this.g.drawString("2. HOLD HANDLE",25,37); this.g.drawString("3. PRESS START",25,64); - //this.g.drawString("3. WHEEL BEEPS->OFF",25,91); + //this.g.drawString("3. WHEEL BEEPS->OFF",25,91); this.g.drawString("4. WHEEL BEEPS",25,118); this.g.drawString("5. DONE!",25,145); this.g.flip(); this.g.setColor(0,4); - this.g.fillRect(0,175,120,239); + this.g.fillRect(0,175,120,239); this.g.setColor(1,15); this.g.setFont("Vector",22); - this.g.drawString("START",20,200); + this.g.drawString("START",20,200); this.g.flip(); this.g.setColor(0,12); - this.g.fillRect(121,175,239,239); + this.g.fillRect(121,175,239,239); this.g.setColor(1,15); this.g.setFont("Vector",22); - this.g.drawString("CANCEL",140,200); + this.g.drawString("CANCEL",140,200); this.g.flip(); this.run=false; }else if (this.tilt!=euc.dash.opt.ride.pTlt){ //tilt Set this.g.setColor(0,1); - this.g.fillRect(50,50,190,150); + this.g.fillRect(50,50,190,150); this.g.setColor(1,15); this.g.setFont("Vector",80); - this.g.drawString(euc.dash.opt.ride.pTlt,130-(this.g.stringWidth(euc.dash.opt.ride.pTlt)/2),65); + this.g.drawString(euc.dash.opt.ride.pTlt,130-(this.g.stringWidth(euc.dash.opt.ride.pTlt)/2),65); this.g.flip(); } @@ -72,7 +72,7 @@ face[0] = { t.g.fillRect(0,198,239,239);//6 t.g.setColor(1,15); t.g.setFont("Vector",20); - t.g.drawString("OPTIONS",120-(t.g.stringWidth("OPTIONS")/2),214); + t.g.drawString("OPTIONS",120-(t.g.stringWidth("OPTIONS")/2),214); t.g.flip(); },1000,this); } @@ -109,16 +109,16 @@ face[1] = { w.gfx.flip(); w.gfx.drawLine (120,0,120,195); w.gfx.drawLine (121,0,121,195); - w.gfx.flip(); + w.gfx.flip(); face.go("dashInmotionV1Adv",0); return true; }, clear: function(){ return true; }, -}; +}; //touch -touchHandler[0]=function(e,x,y){ +touchHandler[0]=function(e,x,y){ switch (e) { case 5: //tap event if (!face[0].calibrate){ @@ -142,7 +142,7 @@ touchHandler[0]=function(e,x,y){ w.gfx.flip(); w.gfx.drawLine (120,0,120,195); w.gfx.drawLine (121,0,121,195); - w.gfx.flip(); + w.gfx.flip(); face.go("dashInmotionV1Adv",0);return; }else if (175<=y&&x<=120) { buzzer.nav([30,50,30]); @@ -152,15 +152,14 @@ touchHandler[0]=function(e,x,y){ this.timeout(); break; case 1: //slide down event - setTimeout(function(){euc.is.busy=0;euc.temp.live();},800); face.go(ew.is.dash[ew.def.dash.face],0); - return; + return; case 2: //slide up event - if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. + if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); - }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} + }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} this.timeout(); break; case 3: //slide left event @@ -174,7 +173,7 @@ touchHandler[0]=function(e,x,y){ w.gfx.flip(); w.gfx.drawLine (120,0,120,195); w.gfx.drawLine (121,0,121,195); - w.gfx.flip(); + w.gfx.flip(); face.go("dashInmotionV1Adv",0); return; case 12: //long press event diff --git a/P8-testing/dashInmotionV10/dashInmotionV10AdvLimits.js b/P8-testing/dashInmotionV10/dashInmotionV10AdvLimits.js index 2a43338b..c1c5a2b4 100644 --- a/P8-testing/dashInmotionV10/dashInmotionV10AdvLimits.js +++ b/P8-testing/dashInmotionV10/dashInmotionV10AdvLimits.js @@ -8,12 +8,12 @@ face[0] = { this.g.fillRect(0,196,239,239); this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString("WHEEL ALERTS",120-(this.g.stringWidth("WHEEL ALERTS")/2),214); - this.g.flip(); + this.g.drawString("WHEEL ALERTS",120-(this.g.stringWidth("WHEEL ALERTS")/2),214); + this.g.flip(); this.btn(euc.dash.alrt.spd.one.en,"ALARM 1",18,60,20,12,1,0,0,119,97,(euc.dash.alrt.spd.one.en)?euc.dash.alrt.spd.one.val:"OFF",25,60,55); this.btn(euc.dash.alrt.spd.two.en,"ALARM 2",18,185,20,12,1,122,0,239,97,(euc.dash.alrt.spd.two.en)?euc.dash.alrt.spd.two.val:"OFF",25,185,55); this.btn(1,"ALARM 3",18,60,115,12,0,0,100,119,195,euc.dash.alrt.spd.thre.val,28,60,150); - this.btn(1,"TILTBACK",18,185,115,4,0,122,100,239,195,euc.dash.alrt.spd.tilt.val,28,185,150); + this.btn(1,"TILTBACK",18,185,115,4,0,122,100,239,195,euc.dash.alrt.spd.tilt.val,28,185,150); if (!face.appPrev.startsWith("dashSet")){ this.g.setColor(0,0); this.g.drawLine (0,98,239,98); @@ -22,13 +22,12 @@ face[0] = { this.g.drawLine (120,0,120,195); this.g.drawLine (121,0,121,195); this.g.flip(); - } + } this.run=false; }, show : function(){ if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} - if (!this.run) return; - + if (!this.run) return; this.tid=setTimeout(function(t,o){ t.tid=-1; t.show(); @@ -38,9 +37,9 @@ face[0] = { this.g.setColor(0,(bt)?clr1:clr0); this.g.fillRect(rx1,ry1,rx2,ry2); this.g.setColor(1,15); - this.g.setFont("Vector",size1); - this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); - if (txt2){this.g.setFont("Vector",size2); + this.g.setFont("Vector",size1); + this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); + if (txt2){this.g.setFont("Vector",size2); this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);} this.g.flip(); }, @@ -49,7 +48,7 @@ face[0] = { this.g.fillRect(0,198,239,239); this.g.setColor(1,15); this.g.setFont("Vector",size); - this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); + this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); this.g.flip(); if (this.ntid) clearTimeout(this.ntid); this.ntid=setTimeout(function(t){ @@ -58,7 +57,7 @@ face[0] = { t.g.fillRect(0,198,239,239); t.g.setColor(1,15); t.g.setFont("Vector",20); - t.g.drawString("WHEEL ALERTS",120-(t.g.stringWidth("WHEEL ALERTS")/2),214); + t.g.drawString("WHEEL ALERTS",120-(t.g.stringWidth("WHEEL ALERTS")/2),214); t.g.flip(); },1000,this); }, @@ -69,10 +68,10 @@ face[0] = { this.g.fillRect(0,0,239,195); this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString(txt,120-(this.g.stringWidth(txt)/2),10); + this.g.drawString(txt,120-(this.g.stringWidth(txt)/2),10); this.g.drawImage(require("heatshrink").decompress(atob("oFAwJC/AAs8A41+A43/AwsDA40HA40PA40f/wHFn/8Fw34AwkB//wGw3AGw2AGxk/Gw1/Gw4uFGwPgGxguBGwsfGw4uGv5lFGw4HBGwoHJC4wnHG45HHK45nHO444JGAynHW47HHHBKBHNJ44QA4o4BA4owBA41+A408A4wA6A==")),0,75); this.g.drawImage(require("heatshrink").decompress(atob("oFAwJC/AAU8A41+A43/A4/AA43gA43wA4t//AHFn/8A4sfGA0P/+AA4kDHA0BHCAwGn/+GA4HFg44QGA3/NJ44QA5oXHE443HI4xXHM453HGw6XHU44uGY442Hc473HMo9/Voy9Ifw42FA4IGFgF+A408A4wA9A=")),180,75); - this.g.flip(); + this.g.flip(); this.btn(1,euc.dash.limt[b],100,126,60,12,1,60,40,180,160); euc.dash.limt.en[b]=1; }, @@ -104,7 +103,7 @@ face[1] = { clear: function(){ return true; }, -}; +}; //touch touchHandler[0]=function(e,x,y){ @@ -144,28 +143,28 @@ touchHandler[0]=function(e,x,y){ } }else if (x<=120&&100<=y<=200) { //alarm 3 face[0].ntfy("HOLD -> SET","HOLD -> SET",20,1,1); - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); }else if (120<=x<=239&&100<=y<=200) { //tiltback face[0].ntfy("HOLD -> SET","",20,1,1); - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); }else buzzer.nav([30,50,30]); }else {//set page if (120<=x) { //up - if (face[0].setEb=="spd") + if (face[0].setEb=="spd") if (euc.dash.alrt.spd.two.en) if (euc.dash.alrt.spd.one.val+1200&&x<50) { //toggles full/current brightness on a left down corner swipe up. + if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); - }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} + }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} this.timeout(); break; case 3: //slide left event @@ -214,7 +212,7 @@ touchHandler[0]=function(e,x,y){ break; case 4: //slide right event (back action) if (face[0].setE) { - face[0].setE=0; + face[0].setE=0; w.gfx.clear(); face[0].init(); } else { @@ -237,12 +235,11 @@ touchHandler[0]=function(e,x,y){ }else if (x<=120&&100<=y<=200) { //alarm 3 if (euc.dash.alrt.spd.thre.val>=euc.dash.alrt.spd.tilt.val) euc.dash.alrt.spd.thre.val=euc.dash.alrt.spd.tilt.val; face[0].set("spd2","ALARM 3"); - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); }else if (120<=x<=239&&100<=y<=200) { //tiltback face[0].set("tilt","TITLBACK"); - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); }else buzzer.nav([30,50,30]); - this.timeout(); break; } diff --git a/P8-testing/dashInmotionV10/dashInmotionV10AdvPass.js b/P8-testing/dashInmotionV10/dashInmotionV10AdvPass.js index 86b5cf9a..e5a8e066 100644 --- a/P8-testing/dashInmotionV10/dashInmotionV10AdvPass.js +++ b/P8-testing/dashInmotionV10/dashInmotionV10AdvPass.js @@ -8,16 +8,16 @@ face[0] = { // face[5].ntfy("EMPTY PASSWORD",20,4); // setTimeout(()=>{face.go("dashInmotionV1Opt",0);return;},1000); // return; - //} + //} //status if (euc.dash.opt.lock.pass.length>=4){ this.g.setColor(0,4); this.g.fillRect(0,0,239,97); this.g.setColor(1,15); this.g.setFont("Vector",16); - this.g.drawString("WHEEL IS",120-(this.g.stringWidth("WHEEL IS")/2),18); + this.g.drawString("WHEEL IS",120-(this.g.stringWidth("WHEEL IS")/2),18); this.g.setFont("Vector",26); - this.g.drawString("PASS LOCKED",120-(this.g.stringWidth("PASS LOCKED")/2),50); + this.g.drawString("PASS LOCKED",120-(this.g.stringWidth("PASS LOCKED")/2),50); this.g.flip(); //line this.g.setColor(0,0); @@ -29,18 +29,18 @@ face[0] = { this.g.fillRect(0,100,239,195); this.g.setColor(1,15); this.g.setFont("Vector",16); - this.g.drawString("CHANGE",122-(this.g.stringWidth("CHANGE")/2),118); + this.g.drawString("CHANGE",122-(this.g.stringWidth("CHANGE")/2),118); this.g.setFont("Vector",26); - this.g.drawString("PASS",122-(this.g.stringWidth("PASS")/2),150); + this.g.drawString("PASS",122-(this.g.stringWidth("PASS")/2),150); this.g.flip(); }else { this.g.setColor(0,12); this.g.fillRect(0,0,239,195); this.g.setColor(1,15); this.g.setFont("Vector",18); - this.g.drawString("WHEEL IS",120-(this.g.stringWidth("WHEEL IS")/2),55); + this.g.drawString("WHEEL IS",120-(this.g.stringWidth("WHEEL IS")/2),55); this.g.setFont("Vector",30); - this.g.drawString("PASS FREE",120-(this.g.stringWidth("PASS FREE")/2),90); + this.g.drawString("PASS FREE",120-(this.g.stringWidth("PASS FREE")/2),90); this.g.flip(); } //info @@ -48,13 +48,13 @@ face[0] = { this.g.fillRect(0,195,239,239); this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString("PASS SETTINGS",120-(this.g.stringWidth("PASS SETTINGS")/2),214); - this.g.flip(); + this.g.drawString("PASS SETTINGS",120-(this.g.stringWidth("PASS SETTINGS")/2),214); + this.g.flip(); this.run=false; }, show : function(){ if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} - if (!this.run) return; + if (!this.run) return; this.tid=setTimeout(function(t,o){ t.tid=-1; t.show(); @@ -66,7 +66,7 @@ face[0] = { this.g.fillRect(0,196,239,239); this.g.setColor(1,15); this.g.setFont("Vector",size); - this.g.drawString(txt,122-(this.g.stringWidth(txt)/2),212); + this.g.drawString(txt,122-(this.g.stringWidth(txt)/2),212); this.info=1; this.g.flip(); if (this.ntid) clearTimeout(this.ntid); @@ -76,7 +76,7 @@ face[0] = { t.g.fillRect(0,196,239,239); t.g.setColor(1,15); t.g.setFont("Vector",20); - t.g.drawString("PASS SETTINGS",120-(t.g.stringWidth("PASS SETTINGS")/2),214); + t.g.drawString("PASS SETTINGS",120-(t.g.stringWidth("PASS SETTINGS")/2),214); t.g.flip(); },1000,this); }, @@ -107,7 +107,7 @@ face[1] = { clear: function(){ return true; }, -}; +}; face[5] = { offms: 30000, g:w.gfx, @@ -120,14 +120,14 @@ face[5] = { this.g.drawString(1,34,18);this.g.drawString(2,115,18);this.g.drawString(3,195,18); this.g.drawString(4,34,85);this.g.drawString(5,115,85);this.g.drawString(6,195,85); this.g.drawString(7,34,153);this.g.drawString(8,115,153);this.g.drawString(9,195,153); - this.g.flip(); + this.g.flip(); this.g.setColor(0,0); this.g.drawLine(0,64,239,64); this.g.drawLine(0,65,239,65); - this.g.flip(); + this.g.flip(); this.g.drawLine(0,129,239,129); this.g.drawLine(0,130,239,130); - this.g.flip(); + this.g.flip(); this.g.drawLine(80,0,80,195); this.g.flip(); this.g.drawLine(160,0,160,195); @@ -138,7 +138,7 @@ face[5] = { }, show : function(){ - if (!this.run) return; + if (!this.run) return; if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} this.tid=setTimeout(function(t,o){ t.tid=-1; @@ -151,7 +151,7 @@ face[5] = { this.g.fillRect(0,196,239,239); this.g.setColor(1,15); this.g.setFont("Vector",size); - this.g.drawString(txt,122-(this.g.stringWidth(txt)/2),212); + this.g.drawString(txt,122-(this.g.stringWidth(txt)/2),212); this.info=1; this.g.flip(); if (this.ntid) clearTimeout(this.ntid); @@ -164,7 +164,7 @@ face[5] = { t.g.fillRect(82,198,158,239); t.g.setColor(1,15); t.g.setFont("Vector",30); - t.g.drawString(0,115,207); + t.g.drawString(0,115,207); if (t.pass.length >=4) t.pass=""; t.g.flip(); },1200,this); @@ -174,7 +174,7 @@ face[5] = { this.g.fillRect(x1,y1,x2,y2); this.g.setColor(1,15); this.g.setFont("Vector",30); - this.g.drawString(bt,xb,yb); + this.g.drawString(bt,xb,yb); this.g.flip(); if (this["tid"+bt]) clearTimeout(this["tid"+bt]); this["tid"+bt]=setTimeout(function(t,x1,y1,x2,y2,bt,xb,yb){ @@ -183,7 +183,7 @@ face[5] = { t.g.fillRect(x1,y1,x2,y2); t.g.setColor(1,15); t.g.setFont("Vector",30); - t.g.drawString(bt,xb,yb); + t.g.drawString(bt,xb,yb); t.g.flip(); },500,this,x1,y1,x2,y2,bt,xb,yb); }, @@ -206,7 +206,7 @@ face[5] = { } }; //touch -touchHandler[0]=function(e,x,y){ +touchHandler[0]=function(e,x,y){ switch (e) { case 5: //tap event if (euc.dash.opt.lock.pass.length>=4){ @@ -224,15 +224,14 @@ touchHandler[0]=function(e,x,y){ this.timeout(); break; case 1: //slide down event - setTimeout(function(){euc.is.busy=0;euc.temp.live();},800); face.go(ew.is.dash[ew.def.dash.face],0); - return; + return; case 2: //slide up event - if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. + if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); - }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} + }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} this.timeout(); break; case 3: //slide left event @@ -246,12 +245,12 @@ touchHandler[0]=function(e,x,y){ w.gfx.flip(); w.gfx.drawLine (120,0,120,195); w.gfx.drawLine (121,0,121,195); - w.gfx.flip(); + w.gfx.flip(); face.go("dashInmotionV1Adv",0); return; case 12: //long press event buzzer.nav([30,50,30]); - if (euc.dash.opt.lock.pass.length>=4){ + if (euc.dash.opt.lock.pass.length>=4){ if (y<=100) { //clear euc.wri("passClear"); euc.dash.opt.lock.passOld=""; @@ -262,52 +261,52 @@ touchHandler[0]=function(e,x,y){ }else { //change face.go("dashInmotionV1AdvPass",5); face[0].passSet=1; - return; + return; } }else { //enable euc.dash.opt.lock.pass=""; face.go("dashInmotionV1AdvPass",5); face[0].passSet=1; - } + } this.timeout(); break; } }; -touchHandler[5]=function(e,x,y){ +touchHandler[5]=function(e,x,y){ switch (e) { case 5: //tap event if (face[5].pass.length>=4) {buzzer.nav(40);return;} buzzer.nav([30,50,30]); let i; if (x<=80&&y<=65) {i=1; - face[5].btn(0,0,79,63,i,34,18); + face[5].btn(0,0,79,63,i,34,18); face[5].pass=face[5].pass+i; }else if (80<=x&&x<=160&&y<=65) {i=2; face[5].pass=face[5].pass+i; - face[5].btn(82,0,158,63,i,115,18); + face[5].btn(82,0,158,63,i,115,18); }else if (160<=x&&y<=65) {i=3; - face[5].btn(162,0,239,63,i,195,18); + face[5].btn(162,0,239,63,i,195,18); face[5].pass=face[5].pass+i; }else if (x<=80&&65<=y&&y<=130) {i=4; - face[5].btn(0,66,79,129,i,34,85); - face[5].pass=face[5].pass+i; - }else if (80<=x&&x<=160&&65<=y&&y<=130) {i=5; + face[5].btn(0,66,79,129,i,34,85); + face[5].pass=face[5].pass+i; + }else if (80<=x&&x<=160&&65<=y&&y<=130) {i=5; face[5].pass=face[5].pass+i; - face[5].btn(82,66,158,129,i,115,85); + face[5].btn(82,66,158,129,i,115,85); }else if (160<=x&&65<=y&&y<=130) {i=6; face[5].pass=face[5].pass+i; - i=6;face[5].btn(162,66,239,129,i,195,85); + i=6;face[5].btn(162,66,239,129,i,195,85); }else if (x<=80&&130<=y&&y<=195) {i=7; - face[5].btn(0,131,79,194,i,34,153); + face[5].btn(0,131,79,194,i,34,153); face[5].pass=face[5].pass+i; }else if (80<=x&&x<=160&&130<=y&&y<=195) {i=8; face[5].btn(82,131,158,194,i,115,153); face[5].pass=face[5].pass+i; - }else if (160<=x&&130<=y&&y<=195) {i=9; + }else if (160<=x&&130<=y&&y<=195) {i=9; face[5].pass=face[5].pass+i; - face[5].btn(162,131,239,194,i,195,153); + face[5].btn(162,131,239,194,i,195,153); }else if (195<=y) {i=0; - face[5].btn(82,197,158,239,0,115,207); + face[5].btn(82,197,158,239,0,115,207); i=0;face[5].pass=face[5].pass+0; } if (face[5].pass.length>=4){ @@ -341,24 +340,23 @@ touchHandler[5]=function(e,x,y){ face[5].ntfy("PASSWORD ACCEPTED",20,4); setTimeout(()=>{face.go("dashInmotionV1AdvPass",0);return;},1000); } else { - buzzer.nav(120); face[5].ntfy("WRONG PASSWORD",20,7); } } - } + } this.timeout(); break; case 1: //slide down event //face.go("clock",0); face.go(ew.is.dash[ew.def.dash.face],0); - return; + return; case 2: //slide up event - if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. + if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); - }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} + }else if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} this.timeout(); break; case 3: //slide left event @@ -372,7 +370,7 @@ touchHandler[5]=function(e,x,y){ w.gfx.flip(); w.gfx.drawLine (120,0,120,195); w.gfx.drawLine (121,0,121,195); - w.gfx.flip(); + w.gfx.flip(); face.go("dashInmotionV1Adv",0); return; case 12: //long press event diff --git a/P8-testing/dashInmotionV10/dashInmotionV10Opt.js b/P8-testing/dashInmotionV10/dashInmotionV10Opt.js index 75b54d9d..6227565f 100644 --- a/P8-testing/dashInmotionV10/dashInmotionV10Opt.js +++ b/P8-testing/dashInmotionV10/dashInmotionV10Opt.js @@ -6,15 +6,15 @@ face[0] = { if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} this.g.setColor(0,0); this.g.fillRect(0,98,239,99); - this.g.flip(); + this.g.flip(); this.g.fillRect(120,0,121,195); this.g.flip(); this.g.setColor(0,0); this.g.fillRect(0,205,239,239); this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString("OPTIONS",120-(this.g.stringWidth("OPTIONS")/2),217); - this.g.flip(); + this.g.drawString("OPTIONS",120-(this.g.stringWidth("OPTIONS")/2),217); + this.g.flip(); this.g.setColor(0,0); this.g.fillRect(0,196,239,204); this.g.setColor(1,3); @@ -22,16 +22,16 @@ face[0] = { this.g.flip(); this.g.setColor(1,15); this.g.fillRect(98,200,120,204); - this.g.flip(); + this.g.flip(); this.btn(euc.dash.opt.lght.led,"LED",18,60,20,4,1,0,0,119,97,"RING",25,60,55);//1 - this.btn((euc.dash.alrt.spd.hapt.en||euc.dash.alrt.amp.hapt.en||euc.dash.alrt.tmp.hapt.en||euc.dash.alrt.bat.hapt.en),"WATCH",18,185,20,4,12,122,0,239,97,"ALERTS",22,185,55); + this.btn((euc.dash.alrt.spd.hapt.en||euc.dash.alrt.amp.hapt.en||euc.dash.alrt.tmp.hapt.en||euc.dash.alrt.bat.hapt.en),"WATCH",18,185,20,4,12,122,0,239,97,"ALERTS",22,185,55); this.btn(euc.dash.opt.snsr.lift,"SENSOR",18,60,115,4,1,0,100,119,195,"LIFT",25,60,150); - this.btn(euc.dash.opt.horn.en,"HORN",25,185,136,4,1,122,100,239,195); + this.btn(euc.dash.opt.horn.en,"HORN",25,185,136,4,1,122,100,239,195); this.run=true; }, show : function(){ if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} - if (!this.run) return; + if (!this.run) return; this.tid=setTimeout(function(t,o){ t.tid=-1; t.show(); @@ -41,9 +41,9 @@ face[0] = { this.g.setColor(0,(bt)?clr1:clr0); this.g.fillRect(rx1,ry1,rx2,ry2); this.g.setColor(1,15); - this.g.setFont("Vector",size1); - this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); - if (txt2){this.g.setFont("Vector",size2); + this.g.setFont("Vector",size1); + this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); + if (txt2){this.g.setFont("Vector",size2); this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);} this.g.flip(); }, @@ -52,7 +52,7 @@ face[0] = { this.g.fillRect(0,198,239,239); this.g.setColor(1,15); this.g.setFont("Vector",size); - this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); + this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); this.g.flip(); if (this.ntid) clearTimeout(this.ntid); this.ntid=setTimeout(function(t){ @@ -61,7 +61,7 @@ face[0] = { t.g.fillRect(0,205,239,239); t.g.setColor(1,15); t.g.setFont("Vector",20); - t.g.drawString("OPTIONS",120-(t.g.stringWidth("OPTIONS")/2),217); + t.g.drawString("OPTIONS",120-(t.g.stringWidth("OPTIONS")/2),217); t.g.flip(); t.g.setColor(0,0); t.g.fillRect(0,196,239,204); @@ -70,7 +70,7 @@ face[0] = { t.g.flip(); t.g.setColor(1,15); t.g.fillRect(98,200,120,204); - t.g.flip(); + t.g.flip(); },1000,this); }, tid:-1, @@ -100,9 +100,9 @@ face[1] = { clear: function(){ return true; }, -}; +}; //touch -touchHandler[0]=function(e,x,y){ +touchHandler[0]=function(e,x,y){ switch (e) { case 5: //tap event if (face[0].sub) { @@ -135,12 +135,12 @@ touchHandler[0]=function(e,x,y){ face[0].ntfy("RING LED ON","RING LED OFF",18,(euc.dash.opt.lght.led)?4:1,euc.dash.opt.lght.led); euc.wri("control",(euc.dash.opt.lght.led)?15:16); }else if ( 120<=x && y<=100 ) { //watch alerts - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); face.go("dashAlerts",0); - return; + return; }else if ( x<=120 && 100<=y ) { //lift sensor euc.dash.opt.snsr.lift=1-euc.dash.opt.snsr.lift; - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); face[0].btn(euc.dash.opt.snsr.lift,"SENSOR",18,60,115,4,1,0,100,119,195,"LIFT",25,60,150); face[0].ntfy("LIFT SENSOR ENABLED","LIFT SENSOR DISABLED",16,(euc.dash.opt.snsr.lift)?4:1,euc.dash.opt.snsr.lift); euc.wri("sethandleButton",(euc.dash.opt.snsr.lift)?1:0); @@ -148,22 +148,21 @@ touchHandler[0]=function(e,x,y){ euc.dash.opt.horn.en=1-euc.dash.opt.horn.en; face[0].btn(euc.dash.opt.horn.en,"HORN",25,185,136,4,1,122,100,239,195); face[0].ntfy("BUTTON IS HORN >2KPH","HOLD -> OPTIONS",18,(euc.dash.opt.horn.en)?4:1,euc.dash.opt.horn.en); - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); }else buzzer.nav(40); } this.timeout(); break; case 1: //slide down event - setTimeout(function(){euc.is.busy=0;euc.temp.live();},800); face.go(ew.is.dash[ew.def.dash.face],0); - return; + return; case 2: //slide up event - if ( 200<=y && x<=50) { //toggles full/current brightness on a left down corner swipe up. + if ( 200<=y && x<=50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); }else //if (y>100) { - if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} + if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} //} else {buzzer.nav(40);} this.timeout(); break; @@ -183,14 +182,14 @@ touchHandler[0]=function(e,x,y){ if ( 120<=x && y<=100 ) { //haptic if (euc.dash.alrt.spd.hapt.en||euc.dash.alrt.amp.hapt.en||euc.dash.alrt.tmp.hapt.en||euc.dash.alrt.bat.hapt.en) {euc.dash.alrt.spd.hapt.en=0;euc.dash.alrt.amp.hapt.en=0;euc.dash.alrt.tmp.hapt.en=0;euc.dash.alrt.bat.hapt.en=0;} else {euc.dash.alrt.spd.hapt.en=1;euc.dash.alrt.amp.hapt.en=1;euc.dash.alrt.tmp.hapt.en=1;euc.dash.alrt.bat.hapt.en=1;} - face[0].btn((euc.dash.alrt.spd.hapt.en||euc.dash.alrt.amp.hapt.en||euc.dash.alrt.tmp.hapt.en||euc.dash.alrt.bat.hapt.en),"WATCH",18,185,20,4,12,122,0,239,97,"ALERTS",22,185,55); + face[0].btn((euc.dash.alrt.spd.hapt.en||euc.dash.alrt.amp.hapt.en||euc.dash.alrt.tmp.hapt.en||euc.dash.alrt.bat.hapt.en),"WATCH",18,185,20,4,12,122,0,239,97,"ALERTS",22,185,55); face[0].ntfy("HAPTIC ENABLED","HAPTIC DISABLED",19,1,(euc.dash.alrt.spd.hapt.en||euc.dash.alrt.amp.hapt.en||euc.dash.alrt.tmp.hapt.en||euc.dash.alrt.bat.hapt.en)); buzzer.nav([30,50,30]); }else if (120<=x && 100<=y ) { //horn face.menu.full("SELECT SOUND",20,euc.dash.opt.horn.mode,80,1453,1365,1); face[0].ntfy("SELECT SOUND","",20,4,1); face[0].sub="horn"; - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); }else buzzer.nav(40); this.timeout(); break; diff --git a/P8-testing/dashInmotionV10/dashInmotionV10Opt2.js b/P8-testing/dashInmotionV10/dashInmotionV10Opt2.js index 9c902dfc..639f8733 100644 --- a/P8-testing/dashInmotionV10/dashInmotionV10Opt2.js +++ b/P8-testing/dashInmotionV10/dashInmotionV10Opt2.js @@ -6,15 +6,15 @@ face[0] = { if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} this.g.setColor(0,0); this.g.fillRect(0,98,239,99); - this.g.flip(); + this.g.flip(); this.g.fillRect(120,0,121,195); this.g.flip(); this.g.setColor(0,0); this.g.fillRect(0,205,239,239); this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString("MORE",120-(this.g.stringWidth("MORE")/2),217); - this.g.flip(); + this.g.drawString("MORE",120-(this.g.stringWidth("MORE")/2),217); + this.g.flip(); this.g.setColor(0,0); this.g.fillRect(0,196,239,204); this.g.setColor(1,3); @@ -22,17 +22,17 @@ face[0] = { this.g.flip(); this.g.setColor(1,15); this.g.fillRect(120,200,143,204); - this.g.flip(); + this.g.flip(); this.btn(euc.dash.auto.onC.HL,"AUTO",18,60,20,13,1,0,0,119,97,"LIGHT",25,60,55); - this.btn(0,"",18,185,20,4,1,122,0,239,97,"",22,185,55); + this.btn(0,"",18,185,20,4,1,122,0,239,97,"",22,185,55); this.btn(euc.dash.auto.onD.off,"AUTO",18,60,115,13,1,0,100,119,195,"OFF",25,60,150); this.btn(euc.dash.auto.onC.lift,"",18,185,115,13,1,122,100,239,195); - //this.btn(euc.dash.auto.onC.lift,"AUTO",18,185,115,13,1,122,100,239,195,"LIFT",25,185,155); + //this.btn(euc.dash.auto.onC.lift,"AUTO",18,185,115,13,1,122,100,239,195,"LIFT",25,185,155); this.run=true; }, show : function(){ if (euc.state!=="READY") {face.go(ew.is.dash[ew.def.dash.face],0);return;} - if (!this.run) return; + if (!this.run) return; this.tid=setTimeout(function(t,o){ t.tid=-1; t.show(); @@ -42,9 +42,9 @@ face[0] = { this.g.setColor(0,(bt)?clr1:clr0); this.g.fillRect(rx1,ry1,rx2,ry2); this.g.setColor(1,15); - this.g.setFont("Vector",size1); - this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); - if (txt2){this.g.setFont("Vector",size2); + this.g.setFont("Vector",size1); + this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); + if (txt2){this.g.setFont("Vector",size2); this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);} this.g.flip(); }, @@ -53,7 +53,7 @@ face[0] = { this.g.fillRect(0,198,239,239); this.g.setColor(1,15); this.g.setFont("Vector",size); - this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); + this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); this.g.flip(); if (this.ntid) clearTimeout(this.ntid); this.ntid=setTimeout(function(t){ @@ -62,7 +62,7 @@ face[0] = { t.g.fillRect(0,205,239,239); t.g.setColor(1,15); t.g.setFont("Vector",20); - t.g.drawString("MORE",120-(t.g.stringWidth("MORE")/2),217); + t.g.drawString("MORE",120-(t.g.stringWidth("MORE")/2),217); t.g.flip(); t.g.setColor(0,0); t.g.fillRect(0,196,239,204); @@ -71,7 +71,7 @@ face[0] = { t.g.flip(); t.g.setColor(1,15); t.g.fillRect(120,200,143,204); - t.g.flip(); + t.g.flip(); },1000,this); }, tid:-1, @@ -101,9 +101,9 @@ face[1] = { clear: function(){ return true; }, -}; +}; //touch -touchHandler[0]=function(e,x,y){ +touchHandler[0]=function(e,x,y){ switch (e) { case 5: //tap event if ( x<=120 && y<100 ) { //auto light @@ -112,32 +112,31 @@ touchHandler[0]=function(e,x,y){ face[0].ntfy("AUTO LIGHT ON","AUTO LIGHT OFF",18,1,euc.dash.auto.onC.HL); buzzer.nav([30,50,30]); }else if ( 120<=x && y<=100 ) { //watch alerts - buzzer.nav(40); + buzzer.nav(40); //face.go("dashAlerts",0); }else if ( x<=120 && 100<=y ) { //auto off euc.dash.auto.onD.off=1-euc.dash.auto.onD.off; face[0].btn(euc.dash.auto.onD.off,"AUTO",18,60,115,13,1,0,100,119,195,"OFF",25,60,150); face[0].ntfy("DISCONNECT->POWER OFF","AUTO OFF DISABLED",16,1,euc.dash.auto.onD.off); - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); //}else if (120<=x && 100<=y ) { //auto lift //euc.dash.auto.onC.lift=1-euc.dash.auto.onC.lift; - // face[0].btn(euc.dash.auto.onC.lift,"AUTO",18,185,115,13,1,122,100,239,195,"LIFT",25,185,155); + // face[0].btn(euc.dash.auto.onC.lift,"AUTO",18,185,115,13,1,122,100,239,195,"LIFT",25,185,155); //face[0].ntfy("CONNECT -> LIFT OFF","AUTO LIFT DISABLED",18,1,euc.dash.auto.onC.lift); - //buzzer.nav([30,50,30]); + //buzzer.nav([30,50,30]); }else buzzer.nav(40); this.timeout(); break; case 1: //slide down event - setTimeout(function(){euc.is.busy=0;euc.temp.live();},800); face.go(ew.is.dash[ew.def.dash.face],0); - return; + return; case 2: //slide up event - if ( 200<=y && x<=50) { //toggles full/current brightness on a left down corner swipe up. + if ( 200<=y && x<=50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); }else //if (y>100) { - if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} + if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} //} else {buzzer.nav(40);} this.timeout(); break; @@ -157,7 +156,7 @@ touchHandler[0]=function(e,x,y){ euc.dash.auto.onD.off=1-euc.dash.auto.onD.off; face[0].btn(euc.dash.auto.onD.off,"AUTO",18,60,115,13,1,0,100,119,195,"OFF",25,60,150); face[0].ntfy("DISCONNECT->POWER OFF","AUTO OFF DISABLED",16,1,euc.dash.auto.onD.off); - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); }else buzzer.nav(40); this.timeout(); break; diff --git a/v2/apps.json b/v2/apps.json index fbdd0dba..37a7039c 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -372,11 +372,11 @@ "storage": [ {"name":"dashNinebotS","url":"../../P8-testing/dashNinebotS/dashNinebotS.js"} ] - }, + }, { "id": "dashInmotionV10", "name": "Inmotion V5/8/10 Settings", "icon": "../../P8-testing/dashInmotionV10/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "EUC dashboard, Inmotion V5/8/10 settings gui files.", "tags": "euc", "needsFeatures":["V1"], @@ -388,9 +388,9 @@ {"name":"dashInmotionV10Adv","url":"../../P8-testing/dashInmotionV10/dashInmotionV10Adv.js"}, {"name":"dashInmotionV10AdvCalibrate","url":"../../P8-testing/dashInmotionV10/dashInmotionV10AdvCalibrate.js"}, {"name":"dashInmotionV10AdvLimits","url":"../../P8-testing/dashInmotionV10/dashInmotionV10AdvLimits.js"}, - {"name":"dashInmotionV10AdvPass","url":"../../P8-testing/dashInmotionV10/dashInmotionV10AdvPass.js"} + {"name":"dashInmotionV10AdvPass","url":"../../P8-testing/dashInmotionV10/dashInmotionV10AdvPass.js"} ] - }, + }, { "id": "dashInmotionV11", "name": "Inmotion V11 Settings", "icon": "../../P8-testing/dashInmotionV11/icon.png", @@ -737,7 +737,7 @@ { "id": "euc", "name": "EUC modules support", "icon": "../../v2/euc/icon.png", - "version":"1.94.5", + "version":"1.94.6", "description": "EUC module switcher, depends on wheel module.", "tags": "euc", "needsFeatures":["EW"], @@ -801,13 +801,14 @@ { "id": "eucInmotionV10", "name": "Inmotion V5/8/10 module", "icon": "../../v2/euc/eucInmotionV10/icon.png", - "version":"1.94.5", + "version":"1.94.6", "description": "EUC module for Inmotion V5/8/10.", "tags": "euc", "type": "euc", "needsFeatures":["EW"], "storage": [ - {"name":"eucInmotionV10","url":"../../v2/euc/eucInmotionV10/eucInmotionV10.js"} + {"name":"eucInmotionV10","url":"../../v2/euc/eucInmotionV10/eucInmotionV10.js"}, + {"name":"proxyInmotionV10","url":"../../v2/euc/eucInmotionV10/proxyInmotionV10.js"} ] }, { "id": "eucInmotionV11", diff --git a/v2/euc/euc.js b/v2/euc/euc.js index a52c0d23..a8937b61 100644 --- a/v2/euc/euc.js +++ b/v2/euc/euc.js @@ -23,6 +23,8 @@ global.euc = { euc.tout.alive = 0; } if (euc.tout.busy) { clearTimeout(euc.tout.busy); euc.tout.busy = 0; } + if (euc.tout.intervalLive) { clearInterval(euc.tout.intervalLive); + euc.tout.intervalLive = 0; } if (this.state != "OFF") { buzzer.nav([90, 60, 90]); //log @@ -92,6 +94,8 @@ global.euc = { euc.tout.alive = 0; } if (euc.tout.busy) { clearTimeout(euc.tout.busy); euc.tout.busy = 0; } + if (euc.tout.intervalLive) { clearInterval(euc.tout.intervalLive); + euc.tout.intervalLive = 0; } // if (euc.state != "OFF") { if (euc.dbg) console.log("EUC: Restarting"); diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index ff834516..c855e89b 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -63,7 +63,7 @@ euc.cmd=function(no,val){ cmd.push(7+cmd.reduce(checksum)); return cmd; }; -// + function checksum(check, val) { return (check + val) & 255; } @@ -101,12 +101,17 @@ function getModelName(id) { return "UNKNOWN"; } -euc.temp.infoParse= function (inc){ +euc.temp.infoParse = function (inc){ let lala = new DataView(inc); + euc.is.lastGetInfo = getTime(); //light euc.dash.opt.lght.HL=lala.getUint8(99); //led if(lala.byteLength>149) euc.dash.opt.lght.led=lala.getUint8(149); + //volume + if (lala.byteLength>145) + euc.dash.opt.snd.vol=((lala.getUint8(145) << 8) | lala.getUint8(144)) / 100; + if (euc.temp.infoGet) return; //firmware let v0=lala.getUint8(46); let v1=lala.getUint8(45); @@ -128,21 +133,20 @@ euc.temp.infoParse= function (inc){ let month = ((lala.getUint8(25) & 0xF0) >> 4); let date = ((lala.getUint8(25) & 0x0F) << 4) | (lala.getUint8(24) & 0x0F); euc.dash.info.get.manD=[year.toString(10), month.toString(10), date.toString(10)].join('-'); - //volume - if (lala.byteLength>145) - euc.dash.opt.snd.vol=((lala.getUint8(145) << 8) | lala.getUint8(144)) / 100; //model let modelId=lala.getUint8(126).toString(10)+lala.getUint8(123).toString(10) euc.dash.info.get.modl=getModelName(modelId); if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Name") || ew.do.fileRead("dash","slot"+"1"+"Name") != euc.dash.info.get.modl) { ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Name",euc.dash.info.get.modl); } + euc.temp.infoGet=1; return; } -euc.temp.liveParse= function (inc){ +euc.temp.liveParse = function (inc){ let lala = new DataView(inc); euc.is.alert=0; + euc.is.lastGetLive = getTime(); //values //spd euc.dash.live.spd=(lala.getInt32(31, true)+lala.getInt32(35, true))/2000; @@ -201,9 +205,6 @@ euc.temp.liveParse= function (inc){ buzzer.euc(a); setTimeout(() => { euc.is.buzz = 0; }, 3000); } - //if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} - //euc.tout.loop=setTimeout(function(v){ euc.tout.loop=0;euc.temp.live();},50); - //euc.temp.live(); }; euc.temp.alertParse= function (inc){ @@ -223,10 +224,78 @@ euc.temp.alertParse= function (inc){ case 33:euc.dash.alrt.text = ("CUT-OFF at speed :"+euc.dash.alrt.speed);break; case 38:euc.dash.alrt.text = ("HIGH LOAD at speed :"+euc.dash.alrt.speed+" and current :"+(euc.dash.alrt.val / 1000.0));break; default:euc.dash.alrt.text = ("Unknown Alert: "+ euc.dash.alrt.val+","+euc.dash.alrt.val2); - } + } //euc.emit('alert',euc.dash.alrt.text); }; // +euc.temp.inpk = function(event) { + if (ew.is.bt===2&&euc.dbg==3) console.log("Inmotion: packet in ",event.target.value.buffer); + //gather package + let inc=event.target.value.buffer; + euc.temp.tot=E.toUint8Array(euc.temp.last,inc); + euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); + if (ew.is.bt===5) euc.proxy.w(inc); + //got package + if ( !((inc.length==1 && inc[0]==0x55) || (inc[inc.length - 2]==0x55 && inc[inc.length - 1]==0x55)) ) return; + delete inc; + euc.temp.last = []; + if (ew.is.bt===2) console.log("Inmotion: in: length:",euc.temp.tot.buffer.length," data :",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); + //live pckg + if (euc.temp.tot.buffer[2]===0x13) { + if (euc.temp.tot.length==euc.temp.pckL) { + if (ew.is.bt===2) console.log("Inmotion: live in"); + euc.temp.liveParse(euc.temp.tot.buffer); + return; + }else{ + let temp=JSON.parse(JSON.stringify(euc.temp.tot.buffer)); + for (let i = 0; i < temp.length; i++){ if (temp[i]===165 && 15<=i) temp.splice(i,1);} + euc.temp.chk=new Uint8Array(temp.length -3); + euc.temp.chk.set(temp); + euc.temp.chk=( euc.temp.chk.reduce(checksum) + 7 == temp[temp.length - 3] )?1:0; + if (!euc.temp.chk) { + if (ew.is.bt===2) console.log("Inmotion: problem: length:", temp.length, temp); + return; + } + if (ew.is.bt===2) console.log("Inmotion: live in fixed : length: :", temp.length); + euc.temp.pckL=temp.length; + euc.temp.liveParse(E.toUint8Array(temp).buffer); + return; + } + } + //info pckg + if (euc.temp.tot.buffer[2]===0x14) { + if (ew.is.bt===2) console.log("Inmotion: info in"); + euc.temp.infoParse(euc.temp.tot.buffer); + return; + } + //rest + if (euc.temp.tot.buffer[2]===1) { + if (ew.is.bt===2) console.log("Inmotion: ALERT in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); + euc.temp.alertParse(euc.temp.tot.buffer); + return; + } + if (ew.is.bt===2) console.log("Inmotion: unknown in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); + return; +}; + +euc.temp.live= function(){ + if (getTime() - euc.is.lastGetLive < 0.5) return; + if (euc.tout.busy) return; + euc.tout.busy = 1; + euc.temp.wCha.writeValue([0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D]) + .then(function() { return euc.temp.wCha.writeValue([0x55, 0x55]) + }).then(function() { + if (getTime() - euc.is.lastGetInfo < 1) return; + return euc.temp.wCha.writeValue([0xAA, 0xAA, 0x14, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x01, 0x7F]) + }).then(function() { + if (getTime() - euc.is.lastGetInfo < 1) return; + return euc.temp.wCha.writeValue([0x55, 0x55]) + }).then(function() { return euc.tout.busy = 0 + }).catch(function(err) { + if (ew.is.bt===2) console.log("EUC InmotionV1: live write fail"); + }); +}; +// euc.wri=function(i) {if (ew.is.bt===2) console.log("not connected yet"); if (i=="end") euc.off(); return;}; euc.conn=function(mac){ if (ew.is.bt===2) console.log("EUCInmotionV1 init"); @@ -250,70 +319,10 @@ euc.conn=function(mac){ return euc.temp.serv.getCharacteristic(0xffe4);//read }).then(function(rc) { euc.temp.rCha=rc; + euc.temp.last = []; + euc.temp.chk = []; //read - euc.temp.last= []; - euc.temp.chk= []; - euc.temp.rCha.on('characteristicvaluechanged', function(event) { - if (ew.is.bt===2&&euc.dbg==3) console.log("Inmotion: packet in ",event.target.value.buffer); - if (euc.tout.alive) {clearTimeout(euc.tout.alive); euc.tout.alive=0;} - if (euc.is.busy) return; - //gather package - let inc=event.target.value.buffer; - euc.temp.tot=E.toUint8Array(euc.temp.last,inc); - euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); - //got package - if ( (inc.length==1 && inc[0]==0x55) || (inc[inc.length - 2]==0x55 && inc[inc.length - 1]==0x55) ) { - if (ew.is.bt===2) console.log("Inmotion: in: length:",euc.temp.tot.buffer.length," data :",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); - //live pckg - if (euc.temp.tot.buffer[2]===0x13) { - if (euc.temp.tot.length==euc.temp.pckL) { - euc.temp.last=[]; - if (ew.is.bt===2) console.log("Inmotion: live in"); - euc.temp.liveParse(euc.temp.tot.buffer); - euc.temp.last=[]; - euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); - return; - }else{ - let temp=JSON.parse(JSON.stringify(euc.temp.tot.buffer)); - for (let i = 0; i < temp.length; i++){ if (temp[i]===165 && 15<=i) temp.splice(i,1);} - euc.temp.chk=new Uint8Array(temp.length -3); - euc.temp.chk.set(temp); - euc.temp.chk=( euc.temp.chk.reduce(checksum) + 7 == temp[temp.length - 3] )?1:0; - if (!euc.temp.chk) { - if (ew.is.bt===2) console.log("Inmotion: problem: length:", temp.length, temp); - euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); - euc.temp.last=[]; - return; - } - if (ew.is.bt===2) console.log("Inmotion: live in fixed : length: :", temp.length); - euc.temp.pckL=temp.length; - euc.temp.last=[]; - euc.temp.liveParse(E.toUint8Array(temp).buffer); - euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); - return; - } - } - //info pckg - if (euc.temp.tot.buffer[2]===0x14) { - if (ew.is.bt===2) console.log("Inmotion: info in"); - euc.temp.infoParse(euc.temp.tot.buffer); - euc.temp.last=[]; - euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); - euc.temp.last=[]; - return; - } - //rest - if (euc.temp.tot.buffer[2]===1) { - if (ew.is.bt===2) console.log("Inmotion: ALERT in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); - euc.temp.alertParse(euc.temp.tot.buffer); - euc.temp.last=[]; - return; - } - if (ew.is.bt===2) console.log("Inmotion: unknown in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); - euc.temp.last=[]; - return; - } - }); + euc.temp.rCha.on('characteristicvaluechanged', euc.temp.inpk); //on disconnect euc.gatt.device.on('gattserverdisconnected', euc.off); return rc; @@ -324,36 +333,18 @@ euc.conn=function(mac){ buzzer.nav([90,40,150,40,90]); euc.dash.opt.lock.en=0; //write function - euc.temp.live= function(){ - if (euc.tout.alive) clearTimeout(euc.tout.alive); - if (euc.tout.info) clearTimeout(euc.tout.info); - euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); - if (euc.is.busy) return; -// euc.temp.wCha.writeValue([0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D]).then(function() { -// return euc.temp.wCha.writeValue([0x55, 0x55, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D]); - euc.temp.wCha.writeValue(euc.cmd("live")).then(function() { - return euc.temp.wCha.writeValue(euc.cmd("end")); - }).catch(function(err) { - if (ew.is.bt===2) console.log("EUC InmotionV1: live write fail"); - //euc.off("writefail"); - }); - euc.tout.info=setTimeout(function(){euc.tout.info=0;euc.temp.info();},100); - }; - euc.temp.info= function(){ - if (euc.tout.alive) clearTimeout(euc.tout.alive); - if (euc.tout.info) clearTimeout(euc.tout.info); - euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); - if (euc.is.busy) return; - euc.temp.wCha.writeValue(euc.cmd("info")).then(function() { - return euc.temp.wCha.writeValue(euc.cmd("end")); - }).catch(function(err) { - if (ew.is.bt===2) console.log("EUC InmotionV1: info write fail"); - }); - }; - euc.wri=function(cmd,value){ - if (euc.tout.alive) {clearTimeout(euc.tout.alive); euc.tout.alive=0;} - euc.is.busy=1; + if (euc.tout.eucWrite) { + clearTimeout(euc.tout.eucWrite); + euc.tout.eucWrite=0; + } + if (euc.tout.busy) { + if (cmd!=="proxy") { + euc.tout.eucWrite=setTimeout(function() {euc.wri(cmd,value)},50); + } + return; + } + euc.tout.busy = 1; if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} if (ew.is.bt===2) console.log("Inmotion cmd: ", cmd); //off @@ -367,12 +358,12 @@ euc.conn=function(mac){ return euc.temp.wCha.writeValue(euc.cmd("end")); }).then(function() { euc.tout.loop=0; - if (euc.tout.alive) {clearTimeout(euc.tout.alive); euc.tout.alive=0;} - euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.horn=0;euc.is.busy=0;euc.temp.live();},500); + euc.tout.busy=0; }); },150); }else if (cmd==="hornOff") { euc.is.horn=0; + euc.tout.busy=0; return; }else if (euc.state==="OFF"||cmd==="end") { if (euc.gatt && euc.gatt.connected) { @@ -406,6 +397,7 @@ euc.conn=function(mac){ euc.off("not connected"); return; } + euc.tout.busy=0; }else if (cmd==="start") { euc.temp.wCha.writeValue(euc.cmd("init")).then(function() { return euc.temp.wCha.writeValue(euc.cmd("end")); @@ -418,24 +410,22 @@ euc.conn=function(mac){ }).then(function() { if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} euc.tout.loop=setTimeout(function(){ - euc.tout.loop=0;euc.is.run=1;euc.is.busy=0; - return euc.temp.live(); - },350); + euc.tout.loop=0;euc.is.run=1;euc.tout.busy=0; + euc.tout.intervalLive=setInterval(function(){ + try { + euc.temp.live(); + } catch(e) { return } + },200); + },1000); }).catch(euc.off); + } else if (cmd==="proxy") { + euc.temp.wCha.writeValue(value) + .then(function() { return euc.tout.busy=0}) + .catch(euc.off); } else { - //if (euc.is.busy) return; - if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} - euc.tout.loop=setTimeout(function(){ - euc.tout.loop=0; - euc.temp.wCha.writeValue(euc.cmd(cmd,value)).then(function() { - return euc.temp.wCha.writeValue(euc.cmd("end")); - //}).then(function(err) { - //return euc.temp.wCha.writeValue(euc.cmd(cmd,value)); - }).then(function() { - euc.tout.loop=0; - euc.tout.loop=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); - }); - },250); + euc.temp.wCha.writeValue(euc.cmd(cmd,value)) + .then(function() {return euc.temp.wCha.writeValue(euc.cmd("end"))}) + .then(function() {return euc.tout.busy=0}) } }; if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Mac")) { diff --git a/v2/euc/eucInmotionV10/proxyInmotionV10.js b/v2/euc/eucInmotionV10/proxyInmotionV10.js new file mode 100644 index 00000000..d2d99ad4 --- /dev/null +++ b/v2/euc/eucInmotionV10/proxyInmotionV10.js @@ -0,0 +1,128 @@ +//InmotionV10 Proxy +if (global.euc && !euc.proxy) { + euc.proxy = { + state: 0, + buffer:[], + r: function(o) { + return; +// if (euc.state == "READY") { +// //euc.proxy.buffer.push(o.data) +// euc.wri("proxy",o.data); +// } +// if (ew.dbg && ew.log) { +// ew.log.unshift("Proxy from phone: " + " " + Date() + " " + E.toJS(o.data)); +// if (100 < ew.log.length) ew.log.pop(); +// } + }, + w: function(o) { +// return; + if (ew.is.bt!=5) return; +// if (euc.tout.busy) return; +// if (euc.tout.alive) clearTimeout(euc.tout.alive); +// if (euc.tout.info) clearTimeout(euc.tout.info); +// euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); +// if (euc.is.busy) return; +// euc.is.busy=1; +// NRF.updateServices( {0xffe0: {0xffe4: {value: o, notify:true} }} ).then(function() {euc.is.busy=0}); +// euc.tout.busy=1; + NRF.updateServices( {0xffe0: {0xffe4: {value: o, notify:true} }} ); +// .then(function () { return euc.tout.busy=0 }); + }, + s: function(o) { + NRF.setServices({ + 0xffa0: { + 0xffa1: { + value: [0x01], + maxLen: 20, + writable: true, + onWrite: function(evt) { + ew.emit("ewBtIn",evt); + }, + readable: true, + notify: true, + description: "ew" + }, + 0xffa5: { + value: [0x01], + maxLen: 20, + writable: false, + readable: true, + notify: false, + description: "Inmotion" + } + }, + 0xffe0: { + 0xffe4: { + maxLen: 20, + notify: true, + description: "A CHL(RX,20Byte)" + } + }, + 0xffe5: { + 0xffe9: { + maxLen: 20, + writable: true, + onWrite: function(evt) { + euc.proxy.r(evt); + }, + description: "B CHL(TX,20Byte)" + } + }, + 0xfe00: { + 0xfe01: { + value: [0x00], + readable: true, + notify: false, + writable: true, + description: "RTC Clock" + }, + 0xfe02: { + value: [0x00], + readable: true, + writable: true, + description: "Timing Evt Index" + }, + 0xfe03: { + value: [0x00], + readable: true, + writable: true, + description: "Timing Evt" + }, + 0xfe04: { + value: [0x00], + readable: true, + writable: true, + description: "Timing Port Index" + }, + 0xfe05: { + value: [0x00], + readable: true, + notify: true, + writable: true, + description: "Timing Port" + }, + 0xfe06: { + value: [0x00], + readable: true, + notify: true, + writable: true, + description: "Timing config" + } + } + }, { advertise: ['0xffe0'], uart: false }); + NRF.setAdvertising({}, { name: euc.dash.info.get.modl + "-" + ew.def.name, connectable: true }); + //NRF.setAddress(euc.mac); + NRF.setAddress(NRF.getAddress().substr(0, 15) + "af public"); + NRF.disconnect(); + NRF.restart(); + }, + e: function(o) { + euc.proxy = 0; + ew.do.update.bluetooth(); + NRF.disconnect(); + NRF.restart(); + return; + } + }; + euc.proxy.s(); +} From 4b6019d5b6e0fd4e731ad71dcddeecb8d117e201 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sat, 26 Aug 2023 18:14:51 +0300 Subject: [PATCH 08/45] Optimizations and fixes * Inmotion V5/8/10 module optimization * Added display of the second temperature sensor for Inmotion V5/8/10 * Added support for 58.8 Volt batteries * Removed artifacts due to the inscription "RETRY" after reconnecting with the unicycle --- P8-testing/dash/dashOptions.js | 75 ++-- P8-testing/dash/dash_digital.js | 9 +- v2/apps.json | 55 ++- v2/euc/eucInmotionV10/eucInmotionV10.js | 494 +++++++++++++----------- 4 files changed, 327 insertions(+), 306 deletions(-) diff --git a/P8-testing/dash/dashOptions.js b/P8-testing/dash/dashOptions.js index ab5ebe5f..e34eb7cb 100644 --- a/P8-testing/dash/dashOptions.js +++ b/P8-testing/dash/dashOptions.js @@ -1,6 +1,6 @@ E.setFlags({pretokenise:1}); //dash Options -//dash options +//dash options face[0] = { offms: (ew.def.off[face.appCurr])?ew.def.off[face.appCurr]:15000, g:w.gfx, @@ -12,8 +12,8 @@ face[0] = { this.g.fillRect(0,160,239,239); this.g.setColor(1,15); this.g.setFont("Vector",25); - this.g.drawString("DASH OPTIONS",120-(this.g.stringWidth("DASH OPTIONS")/2),217); - this.g.flip(); + this.g.drawString("DASH OPTIONS",120-(this.g.stringWidth("DASH OPTIONS")/2),217); + this.g.flip(); this.g.setColor(0,0); this.g.fillRect(75,180,165,184); this.g.setColor(1,15); @@ -21,10 +21,10 @@ face[0] = { this.g.flip(); this.g.setColor(1,2); this.g.fillRect(120,180,165,184); - this.g.flip(); + this.g.flip(); this.btn(1,(ew.def.dash.mph)?"MPH":"KPH",30,40,25,4,0,0,0,75,75);//1 this.btn(1,"o",20,100,20,4,0,80,0,155,75,(ew.def.dash.farn)?"F":"C",30,120,25);//2 - //let makr=ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Maker"); + //let makr=ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Maker"); //if (makr) { //if (makr=="Begode"){ //this.btn(1,"EMPTY",15,200,10,1,0,160,0,239,75,euc.dash.opt.bat.low/100,30,200,35); //3 @@ -35,7 +35,7 @@ face[0] = { //this.run=true; }, show : function(){ - if (!this.run) return; + if (!this.run) return; if (euc.state!=="READY"&&face.appPrev!=="dashGarage") {face.go(ew.is.dash[ew.def.dash.face],0);return;} this.tid=setTimeout(function(t,o){ t.tid=-1; @@ -46,9 +46,9 @@ face[0] = { this.g.setColor(0,(bt)?clr1:clr0); this.g.fillRect(rx1,ry1,rx2,ry2); this.g.setColor(1,15); - this.g.setFont("Vector",size1); - this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); - if (txt2){this.g.setFont("Vector",size2); + this.g.setFont("Vector",size1); + this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); + if (txt2){this.g.setFont("Vector",size2); this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);} this.g.flip(); }, @@ -58,10 +58,10 @@ face[0] = { this.g.fillRect(0,160,239,239); this.g.setColor(1,15); this.g.setFont("Vector",18); - this.g.drawString(txt0,120-(this.g.stringWidth(txt0)/2),170); + this.g.drawString(txt0,120-(this.g.stringWidth(txt0)/2),170); if (s) {this.g.setFont("Vector",50);this.g.drawString("<",5,200);this.g.drawString(">",215,200);} this.g.setFont("Vector",size); - this.g.drawString(txt1,120-(this.g.stringWidth(txt1)/2),205); + this.g.drawString(txt1,120-(this.g.stringWidth(txt1)/2),205); this.g.flip(); this.ntid=setTimeout(function(t){ t.ntid=0; @@ -78,7 +78,7 @@ face[0] = { t.g.fillRect(0,156,239,239); t.g.setColor(1,15); t.g.setFont("Vector",25); - t.g.drawString("DASH OPTIONS",120-(t.g.stringWidth("DASH OPTIONS")/2),217); + t.g.drawString("DASH OPTIONS",120-(t.g.stringWidth("DASH OPTIONS")/2),217); t.g.flip(); t.g.setColor(0,0); t.g.fillRect(75,180,165,184); @@ -113,18 +113,18 @@ face[1] = { }, show : function(){ face.go(appRoot[0],0); - return; + return; }, clear: function(){ return true; }, -}; +}; //touch -touchHandler[0]=function(e,x,y){ +touchHandler[0]=function(e,x,y){ this.timeout(); switch (e) { case 5: //tap event - if (face[0].set) { + if (face[0].set) { if (y < 155) { face[0].set=0; if (!face[0].page){ @@ -140,7 +140,7 @@ touchHandler[0]=function(e,x,y){ return; } else{ buzzer.nav([30,50,30]); - if (face[0].set=="spdF") { + if (face[0].set=="spdF") { if (x<120){ //spd euc.dash.opt.unit.fact.spd=(euc.dash.opt.unit.fact.spd - 0.01); if (euc.dash.opt.unit.fact.spd <0.5) euc.dash.opt.unit.fact.spd=0.5; @@ -150,7 +150,7 @@ touchHandler[0]=function(e,x,y){ } face[0].btn(1,"SPEED X",15,40,90,12,0,0,80,75,155,euc.dash.opt.unit.fact.spd,30,40,120); //4 face[0].ntfy("SPEED FACTOR",euc.dash.opt.unit.fact.spd,40,1,12,5000,1); - }else if (face[0].set=="trpF") { + }else if (face[0].set=="trpF") { if (x<120){ //spd euc.dash.opt.unit.fact.dist=(euc.dash.opt.unit.fact.dist - 0.01); if (euc.dash.opt.unit.fact.dist <0.5) euc.dash.opt.unit.fact.dist=0.5; @@ -183,7 +183,7 @@ touchHandler[0]=function(e,x,y){ euc.dash.opt.bat.low++; if (340 <= euc.dash.opt.bat.low) euc.dash.opt.bat.low = 340; } face[0].btn(1,"EMPTY",15,40,90,12,0,0,80,75,155,euc.dash.opt.bat.low/100,30,40,120); //4 - face[0].ntfy("0% WHEN CELL IS AT",euc.dash.opt.bat.low/100 + " Volt",30,1,12,3000,1); + face[0].ntfy("0% WHEN CELL IS AT",euc.dash.opt.bat.low/100 + " Volt",30,1,12,3000,1); }else { buzzer.nav(40); face[0].set=0; @@ -191,7 +191,7 @@ touchHandler[0]=function(e,x,y){ face[0].btn(1,"DIST X",15,120,90,1,4,80,80,155,155,euc.dash.opt.unit.fact.dist,30,120,120); //5 } } - }else if (!face[0].page){ + }else if (!face[0].page){ if (x<75 && y<75) { //1 //face[0].set="mph"; buzzer.nav([30,50,30]); @@ -221,22 +221,22 @@ touchHandler[0]=function(e,x,y){ face[0].set="rtr"; face[0].btn(1,"RETRY",15,200,90,12,0,160,80,239,155,ew.def.dash.rtr,30,200,120); //6 face[0].ntfy("NUMBER OF RETRIES",ew.def.dash.rtr,40,1,12,3000,1); - }else buzzer.nav(40); + }else buzzer.nav(40); }else { if (x<75 && y<75) { //1 - buzzer.nav([30,50,30]); + buzzer.nav([30,50,30]); face[0].set="batF"; face[0].btn(1,"FULL",15,40,10,12,0,0,0,75,75,euc.dash.opt.bat.hi/100,30,40,35); //1 face[0].ntfy("100% WHEN CELL IS AT",euc.dash.opt.bat.hi/100 + " Volt",30,1,12,3000,1); }else if (75<= x && x < 155 && y < 75) { //2 - buzzer.nav(50); + buzzer.nav(50); }else if (155 <= x && y < 75) { //3 euc.dash.opt.unit.ampR=1-euc.dash.opt.unit.ampR; face[0].btn(1,"AMP",15,200,10,4,1,160,0,239,75,(euc.dash.opt.unit.ampR)?"R":"N",30,200,35); //3 face[0].ntfy("AMPERAGE REPORT",(euc.dash.opt.unit.ampR)?"REVERSED":"NORMAL",30,1,4,1500); buzzer.nav([30,50,30]); - }else if (x<75 && 75 200&&x<50) { //toggles full/current brightness on a left down corner swipe up. + if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); @@ -273,7 +274,7 @@ touchHandler[0]=function(e,x,y){ }else { euc.updateDash(require("Storage").readJSON("dash.json",1).slot); face.go("settings",0); - return; + return; } break; case 3: //slide left event @@ -292,8 +293,8 @@ touchHandler[0]=function(e,x,y){ w.gfx.fillRect(0,156,239,239); w.gfx.setColor(1,15); w.gfx.setFont("Vector",25); - w.gfx.drawString("DASH OPTIONS",120-(w.gfx.stringWidth("DASH OPTIONS")/2),217); - w.gfx.flip(); + w.gfx.drawString("DASH OPTIONS",120-(w.gfx.stringWidth("DASH OPTIONS")/2),217); + w.gfx.flip(); } w.gfx.setColor(0,0); w.gfx.fillRect(75,180,165,184); @@ -302,7 +303,7 @@ touchHandler[0]=function(e,x,y){ w.gfx.flip(); w.gfx.setColor(1,15); w.gfx.fillRect(120,180,165,184); - w.gfx.flip(); + w.gfx.flip(); }else buzzer.nav(40); break; @@ -323,8 +324,8 @@ touchHandler[0]=function(e,x,y){ w.gfx.fillRect(0,156,239,239); w.gfx.setColor(1,15); w.gfx.setFont("Vector",25); - w.gfx.drawString("DASH OPTIONS",120-(w.gfx.stringWidth("DASH OPTIONS")/2),217); - w.gfx.flip(); + w.gfx.drawString("DASH OPTIONS",120-(w.gfx.stringWidth("DASH OPTIONS")/2),217); + w.gfx.flip(); } w.gfx.setColor(0,0); w.gfx.fillRect(75,180,165,184); @@ -333,7 +334,7 @@ touchHandler[0]=function(e,x,y){ w.gfx.flip(); w.gfx.setColor(1,2); w.gfx.fillRect(120,180,165,184); - w.gfx.flip(); + w.gfx.flip(); }else { euc.updateDash(require("Storage").readJSON("dash.json",1).slot); face.go(face.appPrev,0); diff --git a/P8-testing/dash/dash_digital.js b/P8-testing/dash/dash_digital.js index a731fb26..2ca585e9 100644 --- a/P8-testing/dash/dash_digital.js +++ b/P8-testing/dash/dash_digital.js @@ -38,6 +38,10 @@ face[0] = { if (!this.run) return; if (euc.state=="READY") { this.g.setColor(0,0); + if(euc.state!=this.conn) { + this.conn=euc.state; + this.g.fillRect(0,0,239,239); + } this.g.flip(); if (this.spd != Math.round(euc.dash.live.spd)) this.spdF(); // alarm events time graph @@ -227,7 +231,7 @@ face[0] = { this.g.setColor(0,this.tmpC[euc.dash.alrt.tmp.cc]); this.g.fillRect(0,0,119,50); this.g.setColor(1,15); - if (euc.dash.info.get.makr=="Kingsong"){ + if (euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="InmotionV10"){ this.g.setFontVector(35); let temp= Math.round(((ew.def.dash.farn)?euc.dash.live.tmp* 1.8+32:this.tmp)); let tempM=Math.round(((ew.def.dash.farn)?euc.dash.live.tmpM*1.8+32:euc.dash.live.tmpM)); @@ -238,7 +242,8 @@ face[0] = { this.g.setFontVector(27); this.g.drawString(tempM,120-this.g.stringWidth(tempM),13); this.g.setFontVector(8); - this.g.drawString("MOSFET MOTOR", 7,40); + if (euc.dash.info.get.makr=="Kingsong") this.g.drawString("MOSFET MOTOR", 7,40); + if (euc.dash.info.get.makr=="InmotionV10") this.g.drawString("MOSFET BATTERY", 7,40); }else{ this.g.setFontVector(50); let temp=((ew.def.dash.farn)?this.tmp*1.8+32:this.tmp).toString().split("."); diff --git a/v2/apps.json b/v2/apps.json index 37a7039c..6da763cb 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -41,9 +41,7 @@ {"name":"eucWatch.img","url":"../init/eucWatch.icon.js"}, {"name":".display","url":"../init/lcd_b2.js"} ] - }, - { "id": "init", "name": "Init - P8/P22", "icon": "../init/icon.png", @@ -84,8 +82,7 @@ "storage": [ {"name":".bootrst","url":"../init/init.js"} ] - }, - + }, { "id": "UI", "name": "UI support", "icon": "../../Magic-testing/UI/icon.png", @@ -98,9 +95,8 @@ "storage": [ {"name":"C:UI","url":"../../Magic-testing/UI/ui.js"}, {"name":"C:icons","url":"../../Magic-testing/UI/icons.js"} - ] - }, + }, { "id": "fonts", "name": "fonts", "icon": "../init/fonts/icon.png", @@ -118,7 +114,6 @@ ] }, - { "id": "handler", "name": "Handler - V2", "icon": "../../Magic-testing/handler/icon.png", @@ -264,7 +259,7 @@ { "id": "dash", "name": "EUC Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "EUC dashboard. Garage, scan and dash faces. Depends on EUC modules.", "tags": "euc", "needsFeatures":["V1"], @@ -280,7 +275,7 @@ { "id": "Dashboard Digital", "name": "EUC digital Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.2", + "version":"1.94.3", "description": "EUC simple digital", "tags": "euc", "needsFeatures":["V1"], @@ -288,7 +283,7 @@ "storage": [ {"name":"dash_digital","url":"../../P8-testing/dash/dash_digital.js"} ] - }, + }, { "id": "Dashboard Simple", "name": "EUC simple Dashboard", "icon": "../../P8-testing/dash/icon.png", @@ -300,7 +295,7 @@ "storage": [ {"name":"dash_simple","url":"../../P8-testing/dash/dash_simple.js"} ] - }, + }, { "id": "Dashboard PWM", "name": "EUC pwm Dashboard", "icon": "../../P8-testing/dash/icon.png", @@ -312,7 +307,7 @@ "storage": [ {"name":"dash_pwm","url":"../../P8-testing/dash/dash_pwm.js"} ] - }, + }, { "id": "dashKingsong", "name": "Kingsong Settings", "icon": "../../P8-testing/dashKingsong/icon.png", @@ -336,7 +331,7 @@ {"name":"dashKingsongAdvPass","url":"../../P8-testing/dashKingsong/dashKingsongAdvPass.js"}, {"name":"dashKingsongCharging","url":"../../P8-testing/dashKingsong/dashKingsongCharging.js"} ] - }, + }, { "id": "dashNinebotE", "name": "Ninebot Settings", "icon": "../../P8-testing/dashNinebotE/icon.png", @@ -348,7 +343,7 @@ "storage": [ {"name":"dashNinebotE","url":"../../P8-testing/dashNinebotE/dashNinebotE.js"} ] - }, + }, { "id": "dashNinebotZ", "name": "NinebotZ Settings", "icon": "../../P8-testing/dashNinebotZ/icon.png", @@ -360,7 +355,7 @@ "storage": [ {"name":"dashNinebotZ","url":"../../P8-testing/dashNinebotZ/dashNinebotZ.js"} ] - }, + }, { "id": "dashNinebotS", "name": "Ninebot S2/A1 Settings", "icon": "../../P8-testing/dashNinebotS/icon.png", @@ -402,7 +397,7 @@ "storage": [ {"name":"dashInmotionV11","url":"../../P8-testing/dashInmotionV11/dashInmotionV11.js"} ] - }, + }, { "id": "dashInmotionV12", "name": "Inmotion V12 Settings", "icon": "../../P8-testing/dashInmotionV12/icon.png", @@ -414,7 +409,7 @@ "storage": [ {"name":"dashInmotionV12","url":"../../P8-testing/dashInmotionV12/dashInmotionV12.js"} ] - }, + }, { "id": "dashVeteran", "name": "Veteran Settings", "icon": "../../P8-testing/dashVeteran/icon.png", @@ -427,7 +422,7 @@ {"name":"dashVeteranOptions","url":"../../P8-testing/dashVeteran/dashVeteranOptions.js"} ] - }, + }, { "id": "dashBegode", "name": "Begode Settings", "icon": "../../P8-testing/dashBegode/icon.png", @@ -470,7 +465,7 @@ "storage": [ {"name":"ledBT","url":"../../P8-testing/ledBT/ledBT.js"} ] - }, + }, { "id": "repellent", "name": "Repellent", "icon": "../../P8-testing/repellent/icon.png", @@ -529,8 +524,6 @@ {"name":"w_testTP","url":"../../P8-testing/w_testTP/w_testTP.js"} ] }, - - { "id": "clock", "name": "Clock", "icon": "../../Magic-testing/clock/icon.png", @@ -542,7 +535,7 @@ "storage": [ {"name":"C:clock","url":"../../Magic-testing/clock/clock.js"} ] - }, + }, { "id": "settings", "name": "Settings", "icon": "../../Magic-testing/settings/icon.png", @@ -578,7 +571,7 @@ {"name":"dashScan","url":"../../Magic-testing/dash/dashScan.js"}, {"name":"C:dashOff","url":"../../Magic-testing/dash/dashOff.js"} ] - }, + }, { "id": "dashKingsong", "name": "Kingsong Settings", "icon": "../../Magic-testing/dashKingsong/icon.png", @@ -602,7 +595,7 @@ {"name":"dashKingsongAdvAlert","url":"../../Magic-testing/dashKingsong/dashKingsongAdvAlert.js"}, {"name":"dashKingsongAdvPass","url":"../../Magic-testing/dashKingsong/dashKingsongAdvPass.js"} ] - }, + }, { "id": "dashNinebotE", "name": "NinebotE Settings", "icon": "../../Magic-testing/dashNinebotE/icon.png", @@ -614,7 +607,7 @@ "storage": [ {"name":"dashNinebotE","url":"../../Magic-testing/dashNinebotE/dashNinebotE.js"} ] - }, + }, { "id": "dashNinebotZ", "name": "NinebotZ Settings", "icon": "../../Magic-testing/dashNinebotZ/icon.png", @@ -626,7 +619,7 @@ "storage": [ {"name":"dashNinebotZ","url":"../../Magic-testing/dashNinebotZ/dashNinebotZ.js"} ] - }, + }, { "id": "dashNinebotS", "name": "Ninebot S2/A1 Settings", "icon": "../../Magic-testing/dashNinebotS/icon.png", @@ -654,9 +647,9 @@ {"name":"dashInmotionV10Adv","url":"../../Magic-testing/dashInmotionV10/dashInmotionV10Adv.js"}, {"name":"dashInmotionV10AdvCalibrate","url":"../../Magic-testing/dashInmotionV10/dashInmotionV10AdvCalibrate.js"}, {"name":"dashInmotionV10AdvLimits","url":"../../Magic-testing/dashInmotionV10/dashInmotionV10AdvLimits.js"}, - {"name":"dashInmotionV10AdvPass","url":"../../Magic-testing/dashInmotionV10/dashInmotionV10AdvPass.js"} + {"name":"dashInmotionV10AdvPass","url":"../../Magic-testing/dashInmotionV10/dashInmotionV10AdvPass.js"} ] - }, + }, { "id": "dashInmotionV11", "name": "Inmotion V11 Settings", "icon": "../../Magic-testing/dashInmotionV11/icon.png", @@ -668,7 +661,7 @@ "storage": [ {"name":"dashInmotionV11","url":"../../Magic-testing/dashInmotionV11/dashInmotionV11.js"} ] - }, + }, { "id": "dashInmotionV12", "name": "Inmotion V12 Settings", "icon": "../../Magic-testing/dashInmotionV12/icon.png", @@ -693,7 +686,7 @@ {"name":"dashVeteranOptions","url":"../../Magic-testing/dashVeteran/dashVeteranOptions.js"} ] - }, + }, { "id": "dashBegode", "name": "Begode Settings", "icon": "../../Magic-testing/dashBegode/icon.png", @@ -801,7 +794,7 @@ { "id": "eucInmotionV10", "name": "Inmotion V5/8/10 module", "icon": "../../v2/euc/eucInmotionV10/icon.png", - "version":"1.94.6", + "version":"1.94.7", "description": "EUC module for Inmotion V5/8/10.", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index c855e89b..fe8888d7 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -1,210 +1,216 @@ -//Inmotion V10 module- code based on freestyl3r'work +//Inmotion V10 module- code based on freestyl3r'wor E.setFlags({ pretokenise: 1 }); euc.cmd=function(no,val){ - if (ew.is.bt===2) console.log("inmotion: send cmd :",no); - let cmd; - switch (no) { - case "info" : return [0xAA, 0xAA, 0x14, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x01, 0x7F]; - case "batLevelData": return [0xAA, 0xAA, 0x14, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x01, 0x9C]; - case "live": return [0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D]; - case "init": return [0xAA, 0xAA, 0x07, 0x03, 0xA5, 0x55, 0x0F, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x9B]; - case "calibration": return [0xAA, 0xAA, 0x19, 0x01, 0xA5, 0x55, 0x0F, 0x32, 0x54, 0x76, 0x98, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x1F]; - case "horn": return [0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x84]; - case "beep": return [0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x95]; - case "led": return [0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x95]; - case "end": return [0x55, 0x55]; + if (ew.is.bt===2) console.log("inmotion: send cmd :",no); + let cmd; + switch (no) { + case "info": return new Uint8Array([0xAA, 0xAA, 0x14, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x01, 0x7F]); + case "batLevelData": return new Uint8Array([0xAA, 0xAA, 0x14, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x01, 0x9C]); + case "live": return new Uint8Array([0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D]); + case "init": return new Uint8Array([0xAA, 0xAA, 0x07, 0x03, 0xA5, 0x55, 0x0F, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x9B]); + case "calibration": return new Uint8Array([0xAA, 0xAA, 0x19, 0x01, 0xA5, 0x55, 0x0F, 0x32, 0x54, 0x76, 0x98, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x1F]); + case "horn": return new Uint8Array([0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x84]); + case "beep": return new Uint8Array([0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x95]); + case "led": return new Uint8Array([0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x95]); + case "end": return new Uint8Array([0x55, 0x55]); - case "playSound"://cmd=0-23 - cmd = [0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; - break; - case "setVolume"://cmd=0-100 - cmd = [0xAA, 0xAA, 0x0A, 0x06, 0xA5, 0x55, 0x0F, (val * 100) & 0xFF, ((val * 100) / 0x100) & 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; - break; - case "setLights"://val=0|1 - if (val!=0 && val!=1) return [0]; - cmd = [0xAA, 0xAA, 0x0D, 0x01, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; - break; - case "setBrightness": - cmd = [0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2B, val]; - break; - case "setRideMode"://val=0=clasic|1=comfort - if (val!=0 && val!=1) return [0]; - cmd = [0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x00, val, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; - break; - case "setPpedalTilt": //val=-80-+80 - viw = new DataView(new Int8Array(4).buffer); //to int32 BI. - viw.setInt32( 0, val * 65536 / 10 ); - cmd = [0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x00, viw.buffer[3], viw.buffer[2], viw.buffer[1], viw.buffer[0], 0x08, 0x05, 0x00, 0x00]; - break; - case "setPedalSensitivity": //val=-80-+80 - viw = new DataView(new Int8Array(4).buffer); //to int32 BI. - viw.setInt32( 0, val * 65536 / 10 ); - cmd = [0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x00, viw.buffer[3], viw.buffer[2], viw.buffer[1], viw.buffer[0], 0x08, 0x05, 0x00, 0x00]; - break; - case "speedLimit": - viw = new DataView(new Int8Array(2).buffer); //to int16 BI. - viw.setInt16( 0, val*1000 ); - cmd = [0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x01, 0x00, 0x00, 0x00, viw.buffer[1], viw.buffer[0], 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; - break; - case "control"://15=ledOn|16=ledOff|5=powerOff|17=beep| - cmd = [0xAA, 0xAA, 0x16, 0x01, 0xA5, 0x55, 0x0F, 0xB2, 0x00, 0x00, 0x00, val, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; - break; - case "pincode":// - cmd = [0xAA, 0xAA, 0x07, 0x03, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; - break; - case "alert":// - cmd = [0xAA, 0xAA, 0x01, 0x01, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; - break; - case "sethandleButton"://val=0|1 - if (val!=0 && val!=1) return [0]; - cmd = [0xAA, 0xAA, 46, 0x01, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00]; - break; - } - cmd.push(7+cmd.reduce(checksum)); - return cmd; + case "playSound"://cmd=0-23 + cmd = new Uint8Array([0xAA, 0xAA, 0x09, 0x06, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "setVolume"://cmd=0-100 + v = val * 100 + cmd = new Uint8Array([0xAA, 0xAA, 0x0A, 0x06, 0xA5, 0x55, 0x0F, v & 0xFF, (v >> 8) & 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "setLights"://val=0|1 + if (val!=0 && val!=1) return new Uint8Array([0]); + cmd = new Uint8Array([0xAA, 0xAA, 0x0D, 0x01, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "setBrightness": + cmd = new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2B, val, 0x00]); + break; + case "setRideMode"://val=0=clasic|1=comfort + if (val!=0 && val!=1) return new Uint8Array([0]); + cmd = new Uint8Array([0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x00, val, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "setPpedalTilt": //val=-80-+80 + viw = new DataView(new Int8Array(4).buffer); //to int32 BI. + viw.setInt32( 0, val * 65536 / 10 ); + cmd = new Uint8Array([0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x00, viw.buffer[3], viw.buffer[2], viw.buffer[1], viw.buffer[0], 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "setPedalSensitivity": //val=-80-+80 + viw = new DataView(new Int8Array(4).buffer); //to int32 BI. + viw.setInt32( 0, val * 65536 / 10 ); + cmd = new Uint8Array([0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x00, 0x00, 0x00, 0x00, viw.buffer[3], viw.buffer[2], viw.buffer[1], viw.buffer[0], 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "speedLimit": + viw = new DataView(new Int8Array(2).buffer); //to int16 BI. + viw.setInt16( 0, val*1000 ); + cmd = new Uint8Array([0xAA, 0xAA, 0x15, 0x01, 0xA5, 0x55, 0x0F, 0x01, 0x00, 0x00, 0x00, viw.buffer[1], viw.buffer[0], 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "control"://15=ledOn|16=ledOff|5=powerOff|17=beep| + cmd = new Uint8Array([0xAA, 0xAA, 0x16, 0x01, 0xA5, 0x55, 0x0F, 0xB2, 0x00, 0x00, 0x00, val, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "pincode":// + cmd = new Uint8Array([0xAA, 0xAA, 0x07, 0x03, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "alert":// + cmd = new Uint8Array([0xAA, 0xAA, 0x01, 0x01, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + case "sethandleButton"://val=0|1 + if (val!=0 && val!=1) return new Uint8Array([0]); + cmd = new Uint8Array([0xAA, 0xAA, 0x2E, 0x01, 0xA5, 0x55, 0x0F, val, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x00]); + break; + } + cmd.set([cmd.reduce(checksumN, 7) & 0xFF], cmd.length - 1); + return cmd; }; function checksum(check, val) { - return (check + val) & 255; + return (check + val) & 255; +} + +function checksumN(check, val) { + return (check + val); } //cmd=[[0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x01] //cmd.push(cmd.reduce(checksum)); function validateChecksum(buffer) { - receivedChecksum = buffer[buffer.length - 1]; - array = new Uint8Array(buffer, 0, buffer.length - 1); - calculatedChecksum = array.reduce(checksum); - return receivedChecksum == calculatedChecksum; + let receivedChecksum = buffer[buffer.length - 3]; + let array = new Uint8Array(buffer.length - 3); + array.set(buffer); + let calculatedChecksum = array.reduce(checksum,7)&0xFF; + return receivedChecksum == calculatedChecksum; } function appendBuffer(buffer1, buffer2) { - var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength); - tmp.set(new Uint8Array(buffer1), 0); - tmp.set(new Uint8Array(buffer2), buffer1.byteLength); - return tmp.buffer; + var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength); + tmp.set(new Uint8Array(buffer1), 0); + tmp.set(new Uint8Array(buffer2), buffer1.byteLength); + return tmp.buffer; } function getModelName(id) { - switch (id) { - case "50": return "V5"; - case "51": return "V5PLUS"; - case "52": return "V5F"; - case "53": return "V5D"; - case "80": return "V8"; - case "86": return "V8F"; - case "87": return "V8S"; - case "100": return "V10S"; - case "101": return "V10SF"; - case "140": return "V10"; - case "141": return "V10F"; - case "142": return "V10T"; - case "143": return "V10FT"; - } - return "UNKNOWN"; + switch (id) { + case "50": return "V5"; + case "51": return "V5PLUS"; + case "52": return "V5F"; + case "53": return "V5D"; + case "80": return "V8"; + case "86": return "V8F"; + case "87": return "V8S"; + case "100": return "V10S"; + case "101": return "V10SF"; + case "140": return "V10"; + case "141": return "V10F"; + case "142": return "V10T"; + case "143": return "V10FT"; + } + return "UNKNOWN"; } euc.temp.infoParse = function (inc){ - let lala = new DataView(inc); - euc.is.lastGetInfo = getTime(); - //light - euc.dash.opt.lght.HL=lala.getUint8(99); - //led - if(lala.byteLength>149) euc.dash.opt.lght.led=lala.getUint8(149); - //volume - if (lala.byteLength>145) - euc.dash.opt.snd.vol=((lala.getUint8(145) << 8) | lala.getUint8(144)) / 100; - if (euc.temp.infoGet) return; - //firmware - let v0=lala.getUint8(46); - let v1=lala.getUint8(45); - let v2=((lala.getUint8(44) << 8) | lala.getUint8(43)); - euc.dash.info.get.firm=[v0, v1, v2].join('.'); - //serial - let serial = new String(''); - let tByte; - for (i=26; i > 18; i--) { - tByte=lala.getUint8(i); - if (tByte<0x10) - serial=serial + '0' + tByte.toString(16); - else - serial=serial + tByte.toString(16); - } - euc.dash.info.get.serl=serial.toUpperCase(); - //manufacture date - let year = 2000 + lala.getUint8(26); - let month = ((lala.getUint8(25) & 0xF0) >> 4); - let date = ((lala.getUint8(25) & 0x0F) << 4) | (lala.getUint8(24) & 0x0F); - euc.dash.info.get.manD=[year.toString(10), month.toString(10), date.toString(10)].join('-'); - //model - let modelId=lala.getUint8(126).toString(10)+lala.getUint8(123).toString(10) - euc.dash.info.get.modl=getModelName(modelId); - if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Name") || ew.do.fileRead("dash","slot"+"1"+"Name") != euc.dash.info.get.modl) { - ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Name",euc.dash.info.get.modl); - } - euc.temp.infoGet=1; - return; + let lala = new DataView(inc); + euc.is.lastGetInfo = getTime(); + //light + euc.dash.opt.lght.HL=lala.getUint8(99); + //led + if(lala.byteLength>149) euc.dash.opt.lght.led=lala.getUint8(149); + //volume + if (lala.byteLength>145) + euc.dash.opt.snd.vol=((lala.getUint8(145) << 8) | lala.getUint8(144)) / 100; + if (euc.temp.infoGet) return; + //firmware + let v0=lala.getUint8(46); + let v1=lala.getUint8(45); + let v2=((lala.getUint8(44) << 8) | lala.getUint8(43)); + euc.dash.info.get.firm=[v0, v1, v2].join('.'); + //serial + let serial = new String(''); + let tByte; + for (i=26; i > 18; i--) { + tByte=lala.getUint8(i); + if (tByte<0x10) + serial=serial + '0' + tByte.toString(16); + else + serial=serial + tByte.toString(16); + } + euc.dash.info.get.serl=serial.toUpperCase(); + //manufacture date + let year = 2000 + lala.getUint8(26); + let month = ((lala.getUint8(25) & 0xF0) >> 4); + let date = ((lala.getUint8(25) & 0x0F) << 4) | (lala.getUint8(24) & 0x0F); + euc.dash.info.get.manD=[year.toString(10), month.toString(10), date.toString(10)].join('-'); + //model + let modelId=lala.getUint8(126).toString(10)+lala.getUint8(123).toString(10) + euc.dash.info.get.modl=getModelName(modelId); + if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Name") || ew.do.fileRead("dash","slot"+"1"+"Name") != euc.dash.info.get.modl) { + ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Name",euc.dash.info.get.modl); + } + euc.temp.infoGet=1; + return; } euc.temp.liveParse = function (inc){ - let lala = new DataView(inc); - euc.is.alert=0; - euc.is.lastGetLive = getTime(); - //values - //spd - euc.dash.live.spd=(lala.getInt32(31, true)+lala.getInt32(35, true))/2000; + let lala = new DataView(inc); + euc.is.alert=0; + euc.is.lastGetLive = getTime(); + //values + //spd + euc.dash.live.spd=(lala.getInt32(31, true)+lala.getInt32(35, true))/2000; - if (euc.dash.trip.topS < euc.dash.live.spd) euc.dash.trip.topS = euc.dash.live.spd; - if (euc.dash.live.spd<0) euc.dash.live.spd=-euc.dash.live.spd; - euc.dash.alrt.spd.cc = ( euc.dash.alrt.spd.hapt.hi <= euc.dash.live.spd )? 2 : ( euc.dash.alrt.spd.hapt.low <= euc.dash.live.spd )? 1 : 0 ; - if ( euc.dash.alrt.spd.hapt.en && euc.dash.alrt.spd.cc == 2 ) - euc.is.alert = 1 + Math.round((euc.dash.live.spd-euc.dash.alrt.spd.hapt.hi) / euc.dash.alrt.spd.hapt.step) ; - //volt - euc.dash.live.volt=lala.getUint32(43, true)/100; - //batt - euc.dash.live.bat=Math.round(100* (euc.dash.live.volt*( 100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); - //euc.dash.live.bat = Math.round(((euc.dash.live.volt - 60) * 100) / (84 - 60)); - euc.log.batL.unshift(euc.dash.live.bat); - if (20 { euc.is.buzz = 0; }, 3000); - } + if (euc.dash.trip.topS < euc.dash.live.spd) euc.dash.trip.topS = euc.dash.live.spd; + if (euc.dash.live.spd<0) euc.dash.live.spd=-euc.dash.live.spd; + euc.dash.alrt.spd.cc = ( euc.dash.alrt.spd.hapt.hi <= euc.dash.live.spd )? 2 : ( euc.dash.alrt.spd.hapt.low <= euc.dash.live.spd )? 1 : 0 ; + if ( euc.dash.alrt.spd.hapt.en && euc.dash.alrt.spd.cc == 2 ) + euc.is.alert = 1 + Math.round((euc.dash.live.spd-euc.dash.alrt.spd.hapt.hi) / euc.dash.alrt.spd.hapt.step) ; + //volt + euc.dash.live.volt=lala.getUint32(43, true)/100; + //batt + euc.dash.live.bat=Math.round(100* (euc.dash.live.volt*( 100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); + //euc.dash.live.bat = Math.round(((euc.dash.live.volt - 60) * 100) / (84 - 60)); + euc.log.batL.unshift(euc.dash.live.bat); + if (20 { euc.is.buzz = 0; }, 3000); + } }; euc.temp.alertParse= function (inc){ @@ -229,67 +235,83 @@ euc.temp.alertParse= function (inc){ }; // euc.temp.inpk = function(event) { - if (ew.is.bt===2&&euc.dbg==3) console.log("Inmotion: packet in ",event.target.value.buffer); - //gather package - let inc=event.target.value.buffer; - euc.temp.tot=E.toUint8Array(euc.temp.last,inc); - euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); - if (ew.is.bt===5) euc.proxy.w(inc); - //got package - if ( !((inc.length==1 && inc[0]==0x55) || (inc[inc.length - 2]==0x55 && inc[inc.length - 1]==0x55)) ) return; - delete inc; - euc.temp.last = []; - if (ew.is.bt===2) console.log("Inmotion: in: length:",euc.temp.tot.buffer.length," data :",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); - //live pckg - if (euc.temp.tot.buffer[2]===0x13) { - if (euc.temp.tot.length==euc.temp.pckL) { - if (ew.is.bt===2) console.log("Inmotion: live in"); - euc.temp.liveParse(euc.temp.tot.buffer); - return; - }else{ - let temp=JSON.parse(JSON.stringify(euc.temp.tot.buffer)); - for (let i = 0; i < temp.length; i++){ if (temp[i]===165 && 15<=i) temp.splice(i,1);} - euc.temp.chk=new Uint8Array(temp.length -3); - euc.temp.chk.set(temp); - euc.temp.chk=( euc.temp.chk.reduce(checksum) + 7 == temp[temp.length - 3] )?1:0; - if (!euc.temp.chk) { - if (ew.is.bt===2) console.log("Inmotion: problem: length:", temp.length, temp); - return; - } - if (ew.is.bt===2) console.log("Inmotion: live in fixed : length: :", temp.length); - euc.temp.pckL=temp.length; - euc.temp.liveParse(E.toUint8Array(temp).buffer); - return; - } - } - //info pckg - if (euc.temp.tot.buffer[2]===0x14) { - if (ew.is.bt===2) console.log("Inmotion: info in"); - euc.temp.infoParse(euc.temp.tot.buffer); - return; - } - //rest - if (euc.temp.tot.buffer[2]===1) { - if (ew.is.bt===2) console.log("Inmotion: ALERT in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); - euc.temp.alertParse(euc.temp.tot.buffer); - return; - } - if (ew.is.bt===2) console.log("Inmotion: unknown in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); - return; + if (ew.is.bt===2&&euc.dbg==3) console.log("Inmotion: packet in ",event.target.value.buffer); + //gather package + let inc=event.target.value.buffer; + euc.temp.tot=E.toUint8Array(euc.temp.last,inc); + euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); + if (ew.is.bt===5) euc.proxy.w(inc); + //got package + if ( !((inc.length==1 && inc[0]==0x55) || (inc[inc.length - 2]==0x55 && inc[inc.length - 1]==0x55)) ) { + delete inc; + return; + } + delete inc; + euc.temp.last = E.toUint8Array(); + if (ew.is.bt===2) console.log("Inmotion: in: length:",euc.temp.tot.buffer.length," data :",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); + //live pckg + if (euc.temp.tot.buffer[2]===0x13) { + if (euc.temp.tot.length==euc.temp.pckL) { + if (ew.is.bt===2) console.log("Inmotion: live in"); + euc.temp.liveParse(euc.temp.tot.buffer); + return; + } else { + let temp=E.toUint8Array(euc.temp.tot.buffer); + let d=0; + for (let i = 15; i < temp.length; i++) { + if (temp[i]===0xA5) { + temp.set(temp.subarray(i+1),i); + d++; + } + } + temp = new Uint8Array(temp.subarray(0, temp.length - d)); + if (!validateChecksum(temp)) { + if (ew.is.bt===2) console.log("Inmotion: problem: length:", temp.length, " data:",[].map.call(temp, x => x.toString(16)).toString()); + return; + } + if (ew.is.bt===2) console.log("Inmotion: live in fixed : length: :", temp.length); + euc.temp.pckL=temp.length; + euc.temp.liveParse(E.toUint8Array(temp).buffer); + return; + } + } + //info pckg + if (euc.temp.tot.buffer[2]===0x14) { + if (euc.temp.tot.length==euc.temp.pckI) { + if (ew.is.bt===2) console.log("Inmotion: info in"); + } else { + if (!validateChecksum(euc.temp.tot.buffer)) { + if (ew.is.bt===2) console.log("Inmotion: info packet error checksum. Skipping"; + return; + } + if (ew.is.bt===2) console.log("Inmotion: info packet checksum PASS"); + euc.temp.pckI=euc.temp.tot.length; + } + euc.temp.infoParse(euc.temp.tot.buffer); + return; + } + //rest + if (euc.temp.tot.buffer[2]===1) { + if (ew.is.bt===2) console.log("Inmotion: ALERT in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); + euc.temp.alertParse(euc.temp.tot.buffer); + return; + } + if (ew.is.bt===2) console.log("Inmotion: unknown in, length :",euc.temp.tot.buffer.length,", check:",euc.temp.chk); + return; }; euc.temp.live= function(){ if (getTime() - euc.is.lastGetLive < 0.5) return; if (euc.tout.busy) return; euc.tout.busy = 1; - euc.temp.wCha.writeValue([0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D]) - .then(function() { return euc.temp.wCha.writeValue([0x55, 0x55]) + euc.temp.wCha.writeValue(new Uint8Array([0xAA, 0xAA, 0x13, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x00, 0x7D])) + .then(function() { return euc.temp.wCha.writeValue(new Uint8Array([0x55, 0x55])) }).then(function() { if (getTime() - euc.is.lastGetInfo < 1) return; - return euc.temp.wCha.writeValue([0xAA, 0xAA, 0x14, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x01, 0x7F]) + return euc.temp.wCha.writeValue(new Uint8Array([0xAA, 0xAA, 0x14, 0x01, 0xA5, 0x55, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x05, 0x00, 0x01, 0x7F])) }).then(function() { if (getTime() - euc.is.lastGetInfo < 1) return; - return euc.temp.wCha.writeValue([0x55, 0x55]) + return euc.temp.wCha.writeValue(new Uint8Array([0x55, 0x55])) }).then(function() { return euc.tout.busy = 0 }).catch(function(err) { if (ew.is.bt===2) console.log("EUC InmotionV1: live write fail"); From a3e0e232913116e8378888fc274a585ae1163eb5 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sun, 27 Aug 2023 01:46:32 +0300 Subject: [PATCH 09/45] Trip on Inmotion V5/8/10 and one fix * Added trip distance on Inmotion V5/8/10 * Fixed random reboot when communication with the unicycle is lost (often manifested on Inmotion V5/8/10) --- v2/apps.json | 4 ++-- v2/euc/euc.js | 3 +++ v2/euc/eucInmotionV10/eucInmotionV10.js | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index 6da763cb..4aa3b2ff 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -730,7 +730,7 @@ { "id": "euc", "name": "EUC modules support", "icon": "../../v2/euc/icon.png", - "version":"1.94.6", + "version":"1.94.7", "description": "EUC module switcher, depends on wheel module.", "tags": "euc", "needsFeatures":["EW"], @@ -794,7 +794,7 @@ { "id": "eucInmotionV10", "name": "Inmotion V5/8/10 module", "icon": "../../v2/euc/eucInmotionV10/icon.png", - "version":"1.94.7", + "version":"1.94.8", "description": "EUC module for Inmotion V5/8/10.", "tags": "euc", "type": "euc", diff --git a/v2/euc/euc.js b/v2/euc/euc.js index a8937b61..4ba97eb6 100644 --- a/v2/euc/euc.js +++ b/v2/euc/euc.js @@ -96,6 +96,9 @@ global.euc = { euc.tout.busy = 0; } if (euc.tout.intervalLive) { clearInterval(euc.tout.intervalLive); euc.tout.intervalLive = 0; } + // Restart watchdog updater + if (wdint) {clearTimeout(wdint); wdint=0}; + wdint = setInterval(KickWd, process.env.BOARD == "DSD6"?1000:3000); // if (euc.state != "OFF") { if (euc.dbg) console.log("EUC: Restarting"); diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index fe8888d7..3ff252ba 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -187,9 +187,11 @@ euc.temp.liveParse = function (inc){ else euc.is.alert = euc.is.alert + 1 + Math.round(-(euc.dash.live.amp - euc.dash.alrt.amp.hapt.low) / euc.dash.alrt.amp.hapt.step) ; } //trip - euc.dash.trip.last=lala.getInt32(67, true)/1000; //print(euc.dash.trip.last); euc.dash.trip.totl=lala.getUint32(63, true)/1000; + if(!euc.dash.trip.startStrip) euc.dash.trip.startStrip=euc.dash.trip.totl; +// euc.dash.trip.last=lala.getInt32(67, true)/1000; + euc.dash.trip.last=euc.dash.trip.totl-euc.dash.trip.startStrip; euc.log.trip.forEach(function(val,pos){ if (!val) euc.log.trip[pos]=euc.dash.trip.totl;}); //mode euc.dash.opt.ride.mode=lala.getInt32(81, true); @@ -321,6 +323,8 @@ euc.temp.live= function(){ euc.wri=function(i) {if (ew.is.bt===2) console.log("not connected yet"); if (i=="end") euc.off(); return;}; euc.conn=function(mac){ if (ew.is.bt===2) console.log("EUCInmotionV1 init"); + euc.temp.infoGet=0; + euc.dash.trip.startStrip=0; if (euc.tout.alive) {clearTimeout(euc.tout.alive); euc.tout.alive=0}; if (euc.gatt && euc.gatt.connected) { return euc.gatt.disconnect(); From d2510d75c8187a15899006274bcde73fff3c4da3 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 28 Aug 2023 20:19:54 +0300 Subject: [PATCH 10/45] Fixed charge percentage calculation for Veteran --- v2/apps.json | 4 ++-- v2/euc/eucVeteran/eucVeteran.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index 4aa3b2ff..45bf9625 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -794,7 +794,7 @@ { "id": "eucInmotionV10", "name": "Inmotion V5/8/10 module", "icon": "../../v2/euc/eucInmotionV10/icon.png", - "version":"1.94.8", + "version":"1.94.7", "description": "EUC module for Inmotion V5/8/10.", "tags": "euc", "type": "euc", @@ -843,7 +843,7 @@ { "id": "eucVeteran", "name": "Veteran module", "icon": "../../v2/euc/eucVeteran/icon.png", - "version":"1.94.3", + "version":"1.94.4", "description": "EUC module for Veteran Sherman", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucVeteran/eucVeteran.js b/v2/euc/eucVeteran/eucVeteran.js index 0bcc5f93..08734b47 100644 --- a/v2/euc/eucVeteran/eucVeteran.js +++ b/v2/euc/eucVeteran/eucVeteran.js @@ -64,7 +64,7 @@ euc.conn=function(mac){ if ( ev[0]===220 && ev[1]===90 && ev[2]===92 ) { //volt-bat euc.dash.live.volt=(ev[4] << 8 | ev[5] )/100; - euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*4.166 - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); + euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); euc.log.batL.unshift(euc.dash.live.bat); if (20 Date: Fri, 8 Sep 2023 18:30:09 +0300 Subject: [PATCH 11/45] Added PWM for Veteran --- P8-testing/dash/dashAlerts.js | 111 +++++++++++++++----------------- P8-testing/dash/dash_digital.js | 2 +- v2/apps.json | 6 +- v2/euc/eucVeteran/eucVeteran.js | 58 +++++++++-------- 4 files changed, 88 insertions(+), 89 deletions(-) diff --git a/P8-testing/dash/dashAlerts.js b/P8-testing/dash/dashAlerts.js index 9c5e44cf..99cfc40f 100644 --- a/P8-testing/dash/dashAlerts.js +++ b/P8-testing/dash/dashAlerts.js @@ -9,23 +9,22 @@ face[0] = { //if (!face.appPrev.startsWith("dash")) this.g.clear(); this.g.setColor(0,0); this.g.fillRect(0,98,239,99); - - this.g.flip(); + this.g.flip(); this.g.fillRect(120,0,121,195); - this.g.flip(); + this.g.flip(); this.g.fillRect(0,196,239,197); - this.g.flip(); + this.g.flip(); if (this.page){ this.btn(euc.dash.alrt.pwm.hapt.en,euc.dash.alrt.pwm.hapt.en?"PWM: "+euc.dash.alrt.pwm.hapt.hi+" %":"PWM DISABLED",25,120,37,4,1,0,0,239,97); this.btn(0,"",25,120,37,4,0,0,100,239,195); - }else{ + }else{ this.btn(euc.dash.alrt.spd.hapt.en,"SPEED",25,60,37,4,1,0,0,119,97); this.btn(euc.dash.alrt.amp.hapt.en,"AMP",25,180,37,4,1,122,0,239,97); this.btn(euc.dash.alrt.tmp.hapt.en,"TEMP",25,60,136,4,1,0,100,119,195); - this.btn(euc.dash.alrt.bat.hapt.en,"BATT",25,180,136,4,1,122,100,239,195); + this.btn(euc.dash.alrt.bat.hapt.en,"BATT",25,180,136,4,1,122,100,239,195); } //if ( euc.dash.info.get.makr=="Kingsong" ||euc.dash.info.get.makr=="Begode" || euc.dash.info.get.makr=="Veteran" ) { - if ( euc.dash.info.get.makr=="Kingsong" ) { + if ( euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran") { this.g.setColor(0,0); this.g.fillRect(0,196,239,204); this.g.setColor(1,3); @@ -34,7 +33,7 @@ face[0] = { this.g.setColor(1,15); if (this.page) this.g.fillRect(120,200,165,204); else this.g.fillRect(75,200,120,204); - this.g.flip(); + this.g.flip(); this.g.setColor(0,0); this.g.fillRect(0,205,239,239); }else { @@ -43,13 +42,13 @@ face[0] = { } this.g.setColor(1,15); this.g.setFont("Vector",20); - this.g.drawString("WATCH ALERTS",120-(this.g.stringWidth("WATCH ALERTS")/2),217); + this.g.drawString("WATCH ALERTS",120-(this.g.stringWidth("WATCH ALERTS")/2),217); this.g.flip(); this.run=true; }, show : function(){ if (euc.state!=="READY"&&face.appPrev!=="dashGarage") {face.go(ew.is.dash[ew.def.dash.face],0);return;} - if (!this.run) return; + if (!this.run) return; this.tid=setTimeout(function(t,o){ t.tid=-1; t.show(); @@ -59,8 +58,8 @@ face[0] = { this.g.setColor(0,(bt)?clr1:clr0); this.g.fillRect(rx1,ry1,rx2,ry2); this.g.setColor(1,15); - this.g.setFont("Vector",size1); - this.g.drawString(txt1,x1+6-(this.g.stringWidth(txt1)/2),y1); + this.g.setFont("Vector",size1); + this.g.drawString(txt1,x1+6-(this.g.stringWidth(txt1)/2),y1); if (txt2){ this.g.setFont("Vector",size2);this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2); if (sele) {this.g.drawString("<",10,y2); this.g.drawString(">",207,y2); } @@ -72,7 +71,7 @@ face[0] = { this.g.fillRect(0,198,239,239); this.g.setColor(1,15); this.g.setFont("Vector",size); - this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); + this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214); this.g.flip(); if (this.ntid) clearTimeout(this.ntid); this.ntid=setTimeout(function(t){ @@ -106,25 +105,24 @@ face[1] = { euc.updateDash(require("Storage").readJSON("dash.json",1).slot); face.go("dashGarage",0); }else face.go(ew.is.dash[ew.def.dash.face],0); - return; + return; }, clear: function(){ return true; }, -}; +}; //touch -touchHandler[0]=function(e,x,y){ +touchHandler[0]=function(e,x,y){ this.timeout(); switch (e) { case 5: //tap event - - if (face[0].set) { + if (face[0].set) { if (face[0].set=="spd") {//spd buzzer.nav([30,50,30]); - if (y<=120){ - if (x<=120){ + if (y<=120){ + if (x<=120){ if (1200&&x<50) { //toggles full/current brightness on a left down corner swipe up. + if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); }else //if (y>100) { face[0].set=0; - if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} + if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;} //} else {buzzer.nav(40);} - break; case 3: //slide left event //if ( !face[0].set &&!face[0].page&& (euc.dash.info.get.makr=="Kingsong" ||euc.dash.info.get.makr=="Begode" || euc.dash.info.get.makr=="Veteran" )) { - if ( !face[0].set &&!face[0].page&& euc.dash.info.get.makr=="Kingsong" ) { + if ( !face[0].set &&!face[0].page&& (euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran")) { face[0].page=1 - face[0].init();return; + face[0].init();return; //face.go("dashAlertsPwm",0); //return; }else buzzer.nav(40); break; case 4: //slide right event (back action) - if (face[0].set) { + if (face[0].set) { face[0].set=0; w.gfx.setColor(0,0); w.gfx.drawLine (0,98,239,98); @@ -364,12 +359,12 @@ touchHandler[0]=function(e,x,y){ w.gfx.flip(); w.gfx.drawLine (120,0,120,195); w.gfx.drawLine (121,0,121,195); - w.gfx.flip(); - face[0].init();return; + w.gfx.flip(); + face[0].init();return; } if (face[0].page) { face[0].page=0; - face[0].init();return; + face[0].init();return; } if (face.appPrev=="dashGarage") { euc.updateDash(require("Storage").readJSON("dash.json",1).slot); @@ -379,9 +374,9 @@ touchHandler[0]=function(e,x,y){ face.go(face.last,0); return; }else face.go(face.appPrev,0); - return; + return; case 12: //hold event - if (face[0].set) { + if (face[0].set) { w.gfx.setColor(0,0); w.gfx.drawLine (0,98,239,98); w.gfx.drawLine (0,99,239,99); @@ -390,9 +385,9 @@ touchHandler[0]=function(e,x,y){ w.gfx.drawLine (121,0,121,195); w.gfx.flip(); face[0].set=0;face[0].init(); - buzzer.nav([30,50,30]); - }else - buzzer.nav(40); + buzzer.nav([30,50,30]); + }else + buzzer.nav(40); break; } }; diff --git a/P8-testing/dash/dash_digital.js b/P8-testing/dash/dash_digital.js index 2ca585e9..6554d5ae 100644 --- a/P8-testing/dash/dash_digital.js +++ b/P8-testing/dash/dash_digital.js @@ -48,7 +48,7 @@ face[0] = { if (euc.log.almL.includes(1)) { this.alF(); this.bar=0; - } else if (5<=this.spd&& euc.dash.info.get.makr=="Kingsong"){ + } else if (5<=this.spd&& euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran"){ if (this.pwm!=euc.dash.live.pwm) {this.pwm=euc.dash.live.pwm; this.pwmF();} } else if (!this.bar) { this.bar=1; this.barF();} //tmp/amp block diff --git a/v2/apps.json b/v2/apps.json index 45bf9625..a946fd30 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -259,7 +259,7 @@ { "id": "dash", "name": "EUC Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.2", + "version":"1.94.3", "description": "EUC dashboard. Garage, scan and dash faces. Depends on EUC modules.", "tags": "euc", "needsFeatures":["V1"], @@ -275,7 +275,7 @@ { "id": "Dashboard Digital", "name": "EUC digital Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.3", + "version":"1.94.4", "description": "EUC simple digital", "tags": "euc", "needsFeatures":["V1"], @@ -843,7 +843,7 @@ { "id": "eucVeteran", "name": "Veteran module", "icon": "../../v2/euc/eucVeteran/icon.png", - "version":"1.94.4", + "version":"1.94.5", "description": "EUC module for Veteran Sherman", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucVeteran/eucVeteran.js b/v2/euc/eucVeteran/eucVeteran.js index 08734b47..0188985b 100644 --- a/v2/euc/eucVeteran/eucVeteran.js +++ b/v2/euc/eucVeteran/eucVeteran.js @@ -2,9 +2,9 @@ E.setFlags({ pretokenise: 1 }); euc.cmd=function(no){ switch (no) { - case "beep":return [98]; - case "rideSoft":return "SETs"; - case "rideMed":return "SETm"; + case "beep":return [98]; + case "rideSoft":return "SETs"; + case "rideMed":return "SETm"; case "rideStrong":return "SETh"; case "setLightOn":return "SetLightON"; case "setLightOff":return "SetLightOFF"; @@ -23,7 +23,7 @@ euc.wri=function(i) {if (ew.def.cli) console.log("not connected yet"); if (i=="e euc.conn=function(mac){ //check if ( euc.gatt!="undefined") { - if (ew.def.cli) print("ble allready connected"); + if (ew.def.cli) print("ble allready connected"); if (euc.gatt.connected) {euc.gatt.disconnect();return;} } //check if proxy @@ -33,8 +33,8 @@ euc.conn=function(mac){ return; } euc.isProxy=0; - euc.pac=[]; - //connect + euc.pac=[]; + //connect NRF.connect(mac,{minInterval:7.5, maxInterval:15}) .then(function(g) { euc.gatt=g; @@ -67,27 +67,27 @@ euc.conn=function(mac){ euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); euc.log.batL.unshift(euc.dash.live.bat); if (20 {euc.is.buzz=0; }, 3000); } }); @@ -120,10 +124,10 @@ euc.conn=function(mac){ return c; //write }).then(function(c) { - console.log("EUC Veteran connected!!"); + console.log("EUC Veteran connected!!"); euc.wri= function(n,v) { //console.log("got :", n); - if (euc.tout.busy) { clearTimeout(euc.tout.busy);euc.tout.busy=setTimeout(()=>{euc.tout.busy=0;},100);return;} + if (euc.tout.busy) { clearTimeout(euc.tout.busy);euc.tout.busy=setTimeout(()=>{euc.tout.busy=0;},100);return;} euc.tout.busy=setTimeout(()=>{euc.tout.busy=0;},200); //end if (n==="proxy") { @@ -133,25 +137,25 @@ euc.conn=function(mac){ }else if (n=="hornOn") { euc.is.horn=1; let md={"1":"SETs","2":"SETm","3":"SETh"}; - c.writeValue(md[euc.dash.opt.ride.mode]).then(function() { + c.writeValue(md[euc.dash.opt.ride.mode]).then(function() { if (!euc.is.busy) {euc.is.busy=1;euc.is.horn=1;c.stopNotifications();} setTimeout(() => { c.writeValue((euc.dash.opt.lght.HL)?"SetLightOFF":"SetLightON").then(function() { - setTimeout(() => { - c.writeValue((euc.dash.opt.lght.HL)?"SetLightON":"SetLightOFF").then(function() { + setTimeout(() => { + c.writeValue((euc.dash.opt.lght.HL)?"SetLightON":"SetLightOFF").then(function() { setTimeout(() => { if (BTN1.read()) { - if (euc.tout.busy) { clearTimeout(euc.tout.busy);euc.tout.busy=0;} + if (euc.tout.busy) { clearTimeout(euc.tout.busy);euc.tout.busy=0;} euc.wri("hornOn"); }else { euc.is.horn=0; euc.is.busy=0; c.startNotifications(); } - },30); + },30); }); },30); - }); + }); },60); }); }else if (n=="hornOff") { @@ -176,7 +180,7 @@ euc.conn=function(mac){ euc.is.run=0; return c.stopNotifications(); }).then(function() { - euc.gatt.disconnect(); + euc.gatt.disconnect(); }).catch(euc.off); }else if (euc.cmd(n)) { c.writeValue(euc.cmd(n)).then(function() { From a5adba6c748d90585adeeedf5f8e2f04acafbbb7 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sat, 9 Sep 2023 16:09:26 +0300 Subject: [PATCH 12/45] Fixed display of PWM at low speed for Veteran --- P8-testing/dash/dash_digital.js | 2 +- v2/apps.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/P8-testing/dash/dash_digital.js b/P8-testing/dash/dash_digital.js index 6554d5ae..326ba1d8 100644 --- a/P8-testing/dash/dash_digital.js +++ b/P8-testing/dash/dash_digital.js @@ -48,7 +48,7 @@ face[0] = { if (euc.log.almL.includes(1)) { this.alF(); this.bar=0; - } else if (5<=this.spd&& euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran"){ + } else if (5<=this.spd && (euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran")){ if (this.pwm!=euc.dash.live.pwm) {this.pwm=euc.dash.live.pwm; this.pwmF();} } else if (!this.bar) { this.bar=1; this.barF();} //tmp/amp block diff --git a/v2/apps.json b/v2/apps.json index a946fd30..02cd755c 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -275,7 +275,7 @@ { "id": "Dashboard Digital", "name": "EUC digital Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.4", + "version":"1.94.5", "description": "EUC simple digital", "tags": "euc", "needsFeatures":["V1"], From 2d877ea23a6e4d468944346d4a968dd7bbf73e2a Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sat, 9 Sep 2023 21:00:29 +0300 Subject: [PATCH 13/45] Support for the new protocol for Veteran --- v2/apps.json | 2 +- v2/euc/eucVeteran/ChangeLog | 1 + v2/euc/eucVeteran/eucVeteran.js | 158 +++++------ v2/euc/eucVeteran/info.txt | 450 +++++++++++++++++++++++++++----- 4 files changed, 466 insertions(+), 145 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index 02cd755c..45c300d7 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -843,7 +843,7 @@ { "id": "eucVeteran", "name": "Veteran module", "icon": "../../v2/euc/eucVeteran/icon.png", - "version":"1.94.5", + "version":"2.0.0", "description": "EUC module for Veteran Sherman", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucVeteran/ChangeLog b/v2/euc/eucVeteran/ChangeLog index 465a951a..dd15543c 100644 --- a/v2/euc/eucVeteran/ChangeLog +++ b/v2/euc/eucVeteran/ChangeLog @@ -1,3 +1,4 @@ +2.00: new protocol support 1.80: rework 1.03: Connection optimization 1.02: DarknessBot/EUC Dash proxy support bug fix diff --git a/v2/euc/eucVeteran/eucVeteran.js b/v2/euc/eucVeteran/eucVeteran.js index 0188985b..290cc129 100644 --- a/v2/euc/eucVeteran/eucVeteran.js +++ b/v2/euc/eucVeteran/eucVeteran.js @@ -18,6 +18,89 @@ euc.cmd=function(no){ } }; euc.isProxy=0; +// +euc.temp.liveParse = function (inc){ + let lala = new DataView(inc); + euc.is.alert=0; + //print(this.ev); + //volt-bat + euc.dash.live.volt=lala.getUint16(4)/100; + euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); + euc.log.batL.unshift(euc.dash.live.bat); + if (20 {euc.is.buzz=0; }, 3000); + } +} +// +euc.temp.inpk = function(event) { + if (euc.is.busy) return; + let inc=event.target.value.buffer; + if (ew.is.bt==5) euc.proxy.w(inc); + + if ( inc.length>4 && inc[0]==0xDC && inc[1]==0x5A && inc[2]==0x5C ) euc.temp.tot=E.toUint8Array(inc); + else if (euc.temp.tot.buffer.length>1) euc.temp.tot=E.toUint8Array(euc.temp.last,inc); + else return; + euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); + + let needBufLen=euc.temp.tot.buffer[3] + 4; + if (euc.temp.tot.buffer.length < needBufLen) return; + + if (euc.temp.tot.buffer.length == needBufLen) { + euc.temp.liveParse(euc.temp.tot.buffer); + if (ew.is.bt===2) console.log("Veteran: in: length:",euc.temp.tot.buffer.length," data :",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); + } else if (ew.is.bt===2) console.log("Packet size error. Dropped."); + + euc.temp.tot=E.toUint8Array([0]); + euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); +} //start euc.wri=function(i) {if (ew.def.cli) console.log("not connected yet"); if (i=="end") euc.off(); return;}; euc.conn=function(mac){ @@ -45,80 +128,7 @@ euc.conn=function(mac){ }).then(function(c) { this.need=0; //this.event=new Uint8Array(event.target.value.buffer); - let ev=new Uint8Array(20); - c.on('characteristicvaluechanged', function(event) { - if (euc.is.busy) return; - if (ew.is.bt==5) euc.proxy.w(event.target.value.buffer); - ev.set(event.target.value.buffer); - euc.is.alert=0; - /*if (euc.temp.CHANGESTRORPACK) { - euc.tot=E.toUint8Array(euc.pac,event.target.value.buffer); - if ( (event.target.value.buffer[event.target.value.buffer.length - 2]== 85 && event.target.value.buffer[event.target.value.buffer.length - 1]==53) ||(event.target.value.buffer[event.target.value.buffer.length - 2]== 80 && event.target.value.buffer[event.target.value.buffer.length - 1]==55)||(event.target.value.buffer[event.target.value.buffer.length - 2]== 70 && event.target.value.buffer[event.target.value.buffer.length - 1]==99) ) { - euc.pac=[]; - print(E.toString(euc.tot)); - } else euc.pac=euc.tot; - return; - } - */ - //print(this.ev); - if ( ev[0]===220 && ev[1]===90 && ev[2]===92 ) { - //volt-bat - euc.dash.live.volt=(ev[4] << 8 | ev[5] )/100; - euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); - euc.log.batL.unshift(euc.dash.live.bat); - if (20 {euc.is.buzz=0; }, 3000); - } - }); + c.on('characteristicvaluechanged', euc.temp.inpk); //on disconnect euc.gatt.device.on('gattserverdisconnected', euc.off); return c; diff --git a/v2/euc/eucVeteran/info.txt b/v2/euc/eucVeteran/info.txt index 5df79005..8ef73097 100644 --- a/v2/euc/eucVeteran/info.txt +++ b/v2/euc/eucVeteran/info.txt @@ -1,70 +1,380 @@ -2v09.119 (c) 2021 G.Williams -Espruino is Open Source. Our work is supported -only by sales of official boards and donations: -http://espruino.com/Donate -EUC Veteran connected!! -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 3, 20, 1]) -new Uint8Array([13, 18, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 150, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 5, 19, 247]) -new Uint8Array([13, 17, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 8, 20, 1]) -new Uint8Array([13, 17, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 2, 20, 1]) -new Uint8Array([13, 17, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 150, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 5, 19, 247]) -new Uint8Array([13, 17, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 150, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 3, 20, 1]) -new Uint8Array([13, 17, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 150, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 4, 20, 1]) -new Uint8Array([13, 16, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 6, 20, 1]) -new Uint8Array([13, 16, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 3, 20, 1]) -new Uint8Array([13, 16, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 150, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 6, 20, 1]) -new Uint8Array([13, 16, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 7, 20, 1]) -new Uint8Array([13, 16, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 150, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 5, 20, 1]) -new Uint8Array([13, 15, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 4, 20, 1]) -new Uint8Array([13, 15, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 150, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 5, 20, 1]) -new Uint8Array([13, 15, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 150, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 5, 19, 247]) -new Uint8Array([13, 15, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 150, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 7, 20, 1]) -new Uint8Array([13, 14, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 6, 19, 247]) -new Uint8Array([13, 14, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 6, 20, 1]) -new Uint8Array([13, 14, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 12, 19, 247]) -new Uint8Array([13, 14, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 148, 0, 0]) -EUC OUT: 22 -EUC Veteran connected!! -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 15, 19, 247]) -new Uint8Array([13, 4, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 147, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 10, 20, 1]) -new Uint8Array([13, 4, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 148, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 12, 20, 1]) -new Uint8Array([13, 4, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 148, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 10, 20, 1]) -new Uint8Array([13, 4, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 148, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 9, 20, 1]) -new Uint8Array([13, 4, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 148, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 8, 19, 247]) -new Uint8Array([13, 3, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 7, 19, 247]) -new Uint8Array([13, 3, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 9, 20, 1]) -new Uint8Array([13, 3, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 148, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 175, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 8, 19, 247]) -new Uint8Array([13, 3, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 7, 19, 247]) -new Uint8Array([13, 3, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 6, 20, 1]) -new Uint8Array([13, 2, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -new Uint8Array([220, 90, 92, 32, 38, 176, 0, 0, 0, 1, 0, 0, 244, 33, 0, 38, 0, 8, 20, 1]) -new Uint8Array([13, 2, 0, 0, 10, 240, 10, 240, 4, 34, 0, 3, 255, 149, 0, 0]) -EUC OUT: 22 \ No newline at end of file +ble allready connected +EUC Veteran connected!! +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,0,11,49 +Veteran: in: length: 20 data : a,d7,0,0,2,46,a,f0,b,c4,0,1,0,6,0,30,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,cd,89,f1,fa +Veteran: in: length: 20 data : dc,5a,5c,35,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4b +Veteran: in: length: 20 data : a,d7,0,0,2,46,a,f0,b,c4,0,1,0,6,0,30,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,56,a0,bb,89 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4b +Veteran: in: length: 20 data : a,d7,0,0,2,46,a,f0,b,c4,0,1,0,6,0,36,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,f3,b1,2c,4 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,2,11,4a +Veteran: in: length: 20 data : a,d7,0,0,2,46,a,f0,b,c4,0,1,0,6,0,3a,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,4e,ff,ff,ff,ff,ff,32,ee,2,19,b +Veteran: in: length: 13 data : 25,11,39,3,53,0,1b,0,0,2e,ea,5b,dd +Veteran: in: length: 20 data : dc,5a,5c,31,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4b +Veteran: in: length: 20 data : a,d6,0,0,2,46,a,f0,b,c4,0,1,0,6,0,38,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,9,a2,25,b,27 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4a +Veteran: in: length: 20 data : a,d6,0,0,2,46,a,f0,b,c4,0,1,0,6,0,34,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,65,60,c4,c5 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,0,11,4b +Veteran: in: length: 20 data : a,d6,0,0,2,46,a,f0,b,c4,0,1,0,6,0,3a,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,fb,e5,72,b +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4b +Veteran: in: length: 20 data : a,d6,0,0,2,46,a,f0,b,c4,0,1,0,6,0,32,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,4f,ff,ff,ff,ff,ff,32,ee,2,19,b +Veteran: in: length: 13 data : 26,11,3b,3,53,0,20,0,0,31,4b,98,5e +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,0,11,4a +Veteran: in: length: 20 data : a,d6,0,0,2,46,a,f0,b,c4,0,1,0,6,0,2c,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,21,58,f0,37 +Veteran: in: length: 20 data : dc,5a,5c,35,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,2,11,4b +Veteran: in: length: 20 data : a,d6,0,0,2,46,a,f0,b,c4,0,1,0,6,0,38,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,64,de,ed,c5 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4c +Veteran: in: length: 20 data : a,d5,0,0,2,46,a,f0,b,c4,0,1,0,6,0,3a,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,36,b6,4b,b1 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,2,11,4b +Veteran: in: length: 20 data : a,d5,0,0,2,46,a,f0,b,c4,0,1,0,6,0,39,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,4f,ff,ff,ff,ff,ff,32,ee,2,19,b +Veteran: in: length: 13 data : 26,11,3c,3,53,0,1a,0,0,b3,2e,2a,dd +Veteran: in: length: 20 data : dc,5a,5c,31,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4a +Veteran: in: length: 20 data : a,d5,0,0,2,46,a,f0,b,c4,0,1,0,6,0,34,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,9,b6,6e,7e,25 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4b +Veteran: in: length: 20 data : a,d5,0,0,2,46,a,f0,b,c4,0,1,0,6,0,36,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,ba,9,23,8f +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4d +Veteran: in: length: 20 data : a,d5,0,0,2,46,a,f0,b,c4,0,1,0,6,0,31,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,41,fc,d6,bb +Veteran: in: length: 20 data : dc,5a,5c,45,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4a +Veteran: in: length: 20 data : a,d4,0,0,2,46,a,f0,b,c4,0,1,0,6,0,34,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,50,ff,ff,ff,ff,ff,32,ee,2,1a,b +Veteran: in: length: 13 data : 26,11,3d,3,53,0,19,0,0,43,ac,24,ea +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,2,11,4b +Veteran: in: length: 20 data : a,d4,0,0,2,46,a,f0,b,c4,0,1,0,6,0,2e,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,a1,5d,1e,ca +Veteran: in: length: 20 data : dc,5a,5c,35,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,49 +Veteran: in: length: 20 data : a,d4,0,0,2,46,a,f0,b,c4,0,1,0,6,0,28,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,5f,5c,65,5a +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4b +Veteran: in: length: 20 data : a,d4,0,0,2,46,a,f0,b,c4,0,1,0,6,0,2d,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,7c,6c,88,e +Veteran: in: length: 20 data : dc,5a,5c,45,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,2,11,4b +Veteran: in: length: 20 data : a,d4,0,0,2,46,a,f0,b,c4,0,1,0,6,0,35,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,51,ff,ff,ff,ff,ff,32,ee,2,1a,b +Veteran: in: length: 13 data : 26,11,3f,3,53,0,1b,0,0,a8,6a,37,a8 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4b +Veteran: in: length: 20 data : a,d3,0,0,2,46,a,f0,b,c4,0,1,0,6,0,35,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,9,12,bd,72,15 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,2,11,4b +Veteran: in: length: 20 data : a,d3,0,0,2,46,a,f0,b,c4,0,1,0,6,0,39,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,f8,f7,54,f8 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4a +Veteran: in: length: 20 data : a,d3,0,0,2,46,a,f0,b,c4,0,1,0,6,0,31,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,ab,65,6a,51 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4b +Veteran: in: length: 20 data : a,d3,0,0,2,46,a,f0,b,c4,0,1,0,6,0,32,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,52,ff,ff,ff,ff,ff,32,ee,2,1a,b +Veteran: in: length: 13 data : 27,11,40,3,53,0,1c,0,0,e1,2d,80,1d +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4c +Veteran: in: length: 20 data : a,d3,0,0,2,46,a,f0,b,c4,0,1,0,6,0,34,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,df,19,b6,3a +Veteran: in: length: 20 data : dc,5a,5c,35,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,0,11,4b +Veteran: in: length: 20 data : a,d2,0,0,2,46,a,f0,b,c4,0,1,0,6,0,39,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,bb,83,68,71 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4a +Veteran: in: length: 20 data : a,d2,0,0,2,46,a,f0,b,c4,0,1,0,6,0,30,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,1,fe,d6,b8 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,2,11,4c +Veteran: in: length: 20 data : a,d2,0,0,2,46,a,f0,b,c4,0,1,0,6,0,30,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,53,ff,ff,ff,ff,ff,32,ee,2,1b,b +Veteran: in: length: 13 data : 27,11,3e,3,53,0,17,0,0,a,66,46,4 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,1,11,4b +Veteran: in: length: 20 data : a,d2,0,0,2,46,a,f0,b,c4,0,1,0,6,0,34,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,9,58,df,c7,50 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,2,11,4b +Veteran: in: length: 20 data : a,d2,0,0,2,46,a,f0,b,c4,0,1,0,6,0,2e,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,98,93,c8,ef +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d4,0,0,aa,7e,0,1,42,18,0,12,0,2,11,4c +Veteran: in: length: 20 data : a,d1,0,0,2,46,a,f0,b,c4,0,1,0,6,0,50,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,9d,8b,b8,7 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,8,11,4b +Veteran: in: length: 20 data : a,d1,0,0,2,46,a,f0,b,c4,0,1,0,8,0,84,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,53,ff,ff,ff,ff,ff,32,ee,1,ed,b +Veteran: in: length: 13 data : 27,11,3e,3,53,0,1b,0,0,fa,68,2e,32 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,7e,0,1,42,18,0,12,0,6,11,4d +Veteran: in: length: 20 data : a,d1,0,0,2,46,a,f0,b,c4,0,1,0,8,0,8d,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,5c,18,9f,85 +Veteran: in: length: 20 data : dc,5a,5c,35,22,d3,0,0,aa,7e,0,1,42,18,0,12,ff,d1,11,4a +Veteran: in: length: 20 data : a,d1,0,0,2,46,a,f0,b,c4,0,1,ff,fe,0,e4,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,da,2f,93,76 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d2,0,0,aa,7e,0,1,42,18,0,12,ff,bf,11,4c +Veteran: in: length: 20 data : a,d1,0,0,2,46,a,f0,b,c4,0,1,ff,f7,1,54,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,2e,31,1,6c +Veteran: in: length: 20 data : dc,5a,5c,45,22,d2,0,2,aa,7e,0,1,42,18,0,12,ff,c7,11,4d +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,ff,f8,1,79,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,54,ff,ff,ff,ff,ff,32,ee,fe,ca,b +Veteran: in: length: 13 data : 27,11,3,3,52,0,4f,0,0,34,e6,5b,be +Veteran: in: length: 20 data : dc,5a,5c,31,22,d2,0,5,aa,7e,0,1,42,18,0,12,ff,f8,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,0,1,42,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,9,20,de,a5,4c +Veteran: in: length: 20 data : dc,5a,5c,32,22,d3,0,8,aa,7e,0,1,42,18,0,12,0,11,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,5,0,2d,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,5b,ab,2c,3f +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,a,aa,7e,0,1,42,18,0,12,0,20,11,4f +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,6,0,56,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,d7,f7,f7,1a +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,b,aa,7e,0,1,42,18,0,12,0,36,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,b,0,e1,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,55,ff,ff,ff,ff,ff,32,ee,fd,fe,b +Veteran: in: length: 13 data : 28,10,f5,3,53,0,47,0,0,6,e,c5,5a +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,6,aa,7e,0,1,42,18,0,12,0,43,11,4f +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,0,12,1,55,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,db,70,8e,ba +Veteran: in: length: 20 data : dc,5a,5c,35,22,d2,ff,fb,aa,7e,0,1,42,18,0,12,0,41,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,13,1,9c,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,85,3e,74,e4 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d2,ff,f9,aa,7e,0,1,42,18,0,12,0,31,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,11,1,c2,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,f1,23,d2,70 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d2,ff,f5,aa,7f,0,1,42,19,0,12,0,23,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,d,2,1,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,56,ff,ff,ff,ff,ff,32,ee,ff,37,b +Veteran: in: length: 13 data : 29,10,db,3,53,0,4a,0,0,c5,9b,45,c8 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d2,ff,ef,aa,7f,0,1,42,19,0,12,0,16,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,d,1,f9,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,a,da,4c,d2,71 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d2,ff,ec,aa,7f,0,1,42,19,0,12,0,13,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,c,2,c,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,65,39,51,47 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d2,ff,e8,aa,7f,0,1,42,19,0,12,0,19,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,e,2,30,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,fa,cd,de,f9 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d2,ff,e5,aa,7f,0,1,42,19,0,12,0,0,11,50 +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,8,1,e2,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,57,ff,ff,ff,ff,ff,32,ee,ff,9a,b +Veteran: in: length: 13 data : 2b,10,f0,3,53,0,43,0,0,38,d3,24,ea +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d2,ff,e7,aa,7f,0,1,42,19,0,12,ff,c7,11,4f +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,1,0,72,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,37,d,aa,cb +Veteran: in: length: 20 data : dc,5a,5c,35,22,d3,ff,e5,aa,7f,0,1,42,19,0,12,ff,c4,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,fe,0,3a,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,c1,17,9a,ff +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,ff,eb,aa,80,0,1,42,1a,0,12,ff,dd,11,50 +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,ff,ff,0,84,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,1d,37,ad,24 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,ff,f2,aa,80,0,1,42,1a,0,12,ff,c5,11,4e +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,ff,fb,1,6,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,57,ff,ff,ff,ff,ff,32,ee,ff,87,b +Veteran: in: length: 13 data : 2e,10,d5,3,53,0,4e,0,0,27,51,b6,f7 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d2,0,7,aa,80,0,1,42,1a,0,12,ff,bd,11,4f +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,ff,f7,1,60,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,b,35,4d,7,48 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d2,0,6,aa,80,0,1,42,1a,0,12,ff,c5,11,4f +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,f7,1,ba,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,f7,a9,ac,cd +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d1,0,b,aa,80,0,1,42,1a,0,12,ff,ce,11,50 +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,f7,2,1,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,9b,c0,c4,44 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d1,0,e,aa,80,0,1,42,1a,0,12,ff,d8,11,50 +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,ff,fa,2,c,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,58,ff,ff,ff,ff,ff,32,ee,ff,55,b +Veteran: in: length: 13 data : 30,10,d7,3,52,0,4f,0,0,bf,51,a8,b7 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d1,0,14,aa,80,0,1,42,1a,0,12,ff,e4,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,fb,2,11,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,90,1a,fc,b2 +Veteran: in: length: 20 data : dc,5a,5c,35,22,d1,0,16,aa,80,0,1,42,1a,0,12,ff,db,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,f9,2,39,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,2c,a5,62,53 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d1,0,19,aa,80,0,1,42,1a,0,12,ff,e3,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,fb,2,39,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,d0,bd,c9,c7 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d2,0,1b,aa,81,0,1,42,1b,0,12,ff,fa,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,fd,1,fa,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,59,ff,ff,ff,ff,ff,32,ee,ff,6b,b +Veteran: in: length: 13 data : 33,10,e9,3,52,0,47,0,0,8,68,41,86 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d2,0,1c,aa,81,0,1,42,1b,0,12,0,27,11,4e +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,0,3,0,61,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,c,3c,7b,ae,c9 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d3,0,1a,aa,81,0,1,42,1b,0,12,0,23,11,4c +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,5,0,32,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,da,1,12,4f +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,14,aa,81,0,1,42,1b,0,12,0,3,11,4c +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,7,0,4d,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,94,b9,4e,7a +Veteran: in: length: 20 data : dc,5a,5c,45,22,d2,0,d,aa,81,0,1,42,1b,0,12,0,2a,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,a,0,fa,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,5a,ff,ff,ff,ff,ff,32,ee,fe,b9,b +Veteran: in: length: 13 data : 35,10,df,3,52,0,4e,0,0,e7,76,cf,8d +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d2,ff,f9,aa,81,0,1,42,1b,0,12,0,38,11,4b +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,f,1,6a,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,12,d5,43,df +Veteran: in: length: 20 data : dc,5a,5c,35,22,d2,ff,f8,aa,81,0,1,42,1b,0,12,0,35,11,4b +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,0,10,1,c4,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,92,61,3f,29 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d1,ff,f4,aa,81,0,1,42,1b,0,12,0,31,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,11,2,15,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,86,c1,11,7 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d1,ff,ef,aa,81,0,1,42,1b,0,12,0,20,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,10,2,41,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,5a,ff,ff,ff,ff,ff,32,ee,ff,8a,b +Veteran: in: length: 13 data : 37,10,e3,3,52,0,46,0,0,3e,7,84,92 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d1,ff,ec,aa,81,0,1,42,1b,0,12,0,c,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,b,2,22,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,c,e9,a9,92,67 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d1,ff,e8,aa,82,0,1,42,1c,0,12,0,12,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,c,2,3a,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,8e,87,49,dd +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d2,ff,e3,aa,82,0,1,42,1c,0,12,ff,ff,11,4f +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,9,1,f9,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,9c,db,a9,84 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d2,ff,e3,aa,82,0,1,42,1c,0,12,ff,db,11,50 +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,2,0,a2,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,5b,ff,ff,ff,ff,ff,32,ee,ff,a3,b +Veteran: in: length: 13 data : 38,11,3,3,53,0,3e,0,0,32,de,5d,b9 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,ff,e5,aa,82,0,1,42,1c,0,12,ff,b1,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,fa,0,11,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,b3,99,8a,4f +Veteran: in: length: 20 data : dc,5a,5c,35,22,d3,ff,e7,aa,82,0,1,42,1c,0,12,ff,e1,11,4f +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,ff,0,55,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,63,aa,fc,7e +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d2,ff,f0,aa,82,0,1,42,1c,0,12,ff,d3,11,4f +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,ff,0,c8,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,b2,57,69,bb +Veteran: in: length: 20 data : dc,5a,5c,45,22,d2,ff,f5,aa,82,0,1,42,1c,0,12,ff,bf,11,4f +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,f7,1,2e,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,5c,ff,ff,ff,ff,ff,32,ee,ff,c1,b +Veteran: in: length: 13 data : 39,10,e6,3,53,0,55,0,0,3d,1a,b0,3c +Veteran: in: length: 20 data : dc,5a,5c,31,22,d2,0,8,aa,82,0,1,42,1c,0,12,ff,b5,11,4e +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,ff,f4,1,a4,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,d,65,19,25,57 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d1,0,a,aa,82,0,1,42,1c,0,12,ff,c3,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,f6,1,e9,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,45,46,24,de +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d1,0,d,aa,82,0,1,42,1c,0,12,ff,d3,11,4f +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,f7,2,9,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,44,58,4f,db +Veteran: in: length: 20 data : dc,5a,5c,45,22,d1,0,f,aa,83,0,1,42,1d,0,12,ff,d4,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,f8,2,18,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,5d,ff,ff,ff,ff,ff,32,ee,ff,ce,b +Veteran: in: length: 13 data : 3a,10,cf,3,53,0,55,0,0,b2,ef,a8,93 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d1,0,13,aa,83,0,1,42,1d,0,12,ff,d1,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,f7,2,2e,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,ca,1,ac,51 +Veteran: in: length: 20 data : dc,5a,5c,35,22,d1,0,18,aa,83,0,1,42,1d,0,12,ff,da,11,4c +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,f9,2,32,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,1a,29,53,4 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d1,0,18,aa,83,0,1,42,1d,0,12,ff,f0,11,4c +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,ff,fc,2,2a,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,e6,2d,9d,ae +Veteran: in: length: 20 data : dc,5a,5c,45,22,d2,0,1a,aa,83,0,1,42,1d,0,12,0,14,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,2,0,bc,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,5e,ff,ff,ff,ff,ff,32,ee,fe,9a,b +Veteran: in: length: 13 data : 3c,10,ef,3,53,0,4e,0,0,96,d5,1d,b4 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d2,0,1c,aa,83,0,1,42,1d,0,12,0,1e,11,4c +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,3,0,38,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,e,48,d,a0,b5 +Veteran: in: length: 20 data : dc,5a,5c,32,22,d3,0,17,aa,83,0,1,42,1d,0,12,0,1d,11,4b +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,5,0,51,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,a0,ae,89,8 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,12,aa,83,0,1,42,1d,0,12,0,2b,11,4b +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,0,8,0,d6,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,6b,6b,3e,b +Veteran: in: length: 20 data : dc,5a,5c,45,22,d2,ff,f4,aa,83,0,1,42,1d,0,12,0,37,11,4a +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,e,1,6a,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,5e,ff,ff,ff,ff,ff,32,ee,fe,c4,b +Veteran: in: length: 13 data : 3f,10,d6,3,53,0,48,0,0,c0,23,9a,9 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d2,ff,f7,aa,83,0,1,42,1d,0,12,0,22,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,d,1,a1,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,d3,d,ea,ef +Veteran: in: length: 20 data : dc,5a,5c,35,22,d2,ff,f4,aa,84,0,1,42,1e,0,12,0,4,11,4c +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,9,1,68,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,20,ee,65,bc +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,ff,f1,aa,84,0,1,42,1e,0,12,ff,e0,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,4,0,30,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,c0,f6,50,be +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,ff,f0,aa,84,0,1,42,1e,0,12,ff,eb,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,6,0,49,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,5f,ff,ff,ff,ff,ff,32,ee,ff,c2,b +Veteran: in: length: 13 data : 40,10,fe,3,53,0,40,0,0,68,f2,ec,b8 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d3,ff,f5,aa,84,0,1,42,1e,0,12,ff,fe,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,8,0,10,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,f,b6,61,94,1c +Veteran: in: length: 20 data : dc,5a,5c,32,22,d3,ff,f7,aa,84,0,1,42,1e,0,12,ff,fc,11,4c +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,7,0,54,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,b1,3f,bf,b4 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,ff,f9,aa,84,0,1,42,1e,0,12,ff,fe,11,4e +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,5,0,62,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,33,a1,5f,a9 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,ff,fc,aa,84,0,1,42,1e,0,12,0,0,11,4d +Veteran: in: length: 20 data : e,10,0,0,2,46,a,f0,b,c4,0,1,0,4,0,3d,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,60,ff,ff,ff,ff,ff,32,ee,1,9c,b +Veteran: in: length: 13 data : 41,11,17,3,53,0,38,0,0,8d,dc,3b,9f +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,ff,fe,aa,84,0,1,42,1e,0,12,0,7,11,4e +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,0,7,0,7d,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,83,97,15,55 +Veteran: in: length: 20 data : dc,5a,5c,35,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,6,11,4f +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,0,8,0,80,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,13,9b,c6,cd +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,4e +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,0,7,0,66,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,13,33,1d,1b +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,2,11,4e +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,0,6,0,44,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,61,ff,ff,ff,ff,ff,32,ee,2,a,b +Veteran: in: length: 13 data : 41,11,2b,3,53,0,31,0,0,df,b1,b4,31 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,6,11,4d +Veteran: in: length: 20 data : e,f,0,0,2,46,a,f0,b,c4,0,1,0,8,0,79,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,f,2e,9e,2a,ae +Veteran: in: length: 20 data : dc,5a,5c,32,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,4d +Veteran: in: length: 20 data : e,e,0,0,2,46,a,f0,b,c4,0,1,0,6,0,5e,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,86,30,3,f0 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,50 +Veteran: in: length: 20 data : e,e,0,0,2,46,a,f0,b,c4,0,1,0,7,0,6d,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,91,9d,ec,ed +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,4f +Veteran: in: length: 20 data : e,e,0,0,2,46,a,f0,b,c4,0,1,0,7,0,79,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,62,ff,ff,ff,ff,ff,32,ee,1,f6,b +Veteran: in: length: 13 data : 40,11,3a,3,53,0,29,0,0,8d,31,6d,e2 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,50 +Veteran: in: length: 20 data : e,e,0,0,2,46,a,f0,b,c4,0,1,0,7,0,74,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,e9,4f,9e,b5 +Veteran: in: length: 20 data : dc,5a,5c,35,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,4e +Veteran: in: length: 20 data : e,e,0,0,2,46,a,f0,b,c4,0,1,0,7,0,72,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,bc,6b,80,c4 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,50 +Veteran: in: length: 20 data : e,d,0,0,2,46,a,f0,b,c4,0,1,0,7,0,76,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,19,2d,8c,fe +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,4,11,4f +Veteran: in: length: 20 data : e,d,0,0,2,46,a,f0,b,c4,0,1,0,7,0,6d,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,62,ff,ff,ff,ff,ff,32,ee,1,e6,b +Veteran: in: length: 13 data : 3f,11,3e,3,53,0,21,0,0,6e,7c,e5,7 +Veteran: in: length: 20 data : dc,5a,5c,31,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,4f +Veteran: in: length: 20 data : e,d,0,0,2,46,a,f0,b,c4,0,1,0,7,0,6e,0,6f,0,0 +Veteran: in: length: 13 data : 0,0,0,0,0,0,1,0,f,11,be,ef,ad +Veteran: in: length: 20 data : dc,5a,5c,32,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,51 +Veteran: in: length: 20 data : e,d,0,0,2,46,a,f0,b,c4,0,1,0,7,0,6a,0,6f,0,0 +Veteran: in: length: 14 data : 0,0,0,0,0,0,2,37,0,0,40,9b,f,b1 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,4f +Veteran: in: length: 20 data : e,d,0,0,2,46,a,f0,b,c4,0,1,0,6,0,74,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,3,7d,8d,fd,65 +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,50 +Veteran: in: length: 20 data : e,c,0,0,2,46,a,f0,b,c4,0,1,0,7,0,6c,0,6f,0,0 +Veteran: in: length: 20 data : 0,0,0,0,0,0,4,0,3,63,ff,ff,ff,ff,ff,32,ee,1,d9,b +Veteran: in: length: 13 data : 3e,11,3f,3,53,0,19,0,0,a5,a9,3,36 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,6,11,50 +Veteran: in: length: 20 data : e,c,0,0,2,46,a,f0,b,c4,0,1,0,7,0,70,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,5,bb,a2,cb,bd +Veteran: in: length: 20 data : dc,5a,5c,35,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,5,11,50 +Veteran: in: length: 20 data : e,c,0,0,2,46,a,f0,b,c4,0,1,0,7,0,75,0,6f,0,0 +Veteran: in: length: 17 data : 0,0,0,0,0,0,6,80,80,80,80,80,80,64,58,f7,53 +Veteran: in: length: 20 data : dc,5a,5c,2f,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,4,11,51 +Veteran: in: length: 20 data : e,c,0,0,2,46,a,f0,b,c4,0,1,0,7,0,75,0,6f,0,0 +Veteran: in: length: 11 data : 0,0,0,0,0,0,7,b4,7b,e6,8c +Veteran: in: length: 20 data : dc,5a,5c,45,22,d3,0,0,aa,84,0,1,42,1e,0,12,0,6,11,50 +Veteran: in: length: 20 data : e,c,0,0,2,46,a,f0,b,c4,0,1,0,7,0,70,0,6f,0,0 +Disconnected from Sherman S +Veteran: in: length: 20 data : 0,0,0,0,0,0,0,0,3,64,ff,ff,ff,ff,ff,32,ee,1,cd,b +Veteran: in: length: 13 data : 3d,11,40,3,53,0,1c,0,0,8d,71,3b,e \ No newline at end of file From f0cc5f0d63b8199dc5c38548afb809b313940cb7 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Wed, 20 Sep 2023 21:34:15 +0300 Subject: [PATCH 14/45] Fixed artifacts on the music control dashboard --- P8-testing/hid/hid.js | 4 ++-- v2/apps.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/P8-testing/hid/hid.js b/P8-testing/hid/hid.js index d32e1c38..6139d688 100644 --- a/P8-testing/hid/hid.js +++ b/P8-testing/hid/hid.js @@ -33,7 +33,7 @@ face[0] = { //header //todo:add music info from gb g.setColor(0, 1); //header_back - g.fillRect(0, 0, 239, 35); + g.fillRect(0, 0, 239, 239); g.setColor(1, 14); //header_txt g.setFont("Vector", 25); g.drawString("MUSIC", 4, 6); @@ -142,7 +142,7 @@ touchHandler[0] = function(e, x, y) { } else { face.go("settings", 0); return; - } + } } else if (e == 3) { buzzer.nav( 40); } else if (e == 4) { diff --git a/v2/apps.json b/v2/apps.json index 45c300d7..32f9fe0c 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -480,7 +480,7 @@ { "id": "hid", "name": "HID BT Music control", "icon": "../../P8-testing/hid/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "Music controls over BLEHID face", "tags": "apps", "needsFeatures":["V1"], From 5bd5b843f4d8d06958d5746c8d51352050d54c56 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Thu, 21 Sep 2023 01:12:40 +0300 Subject: [PATCH 15/45] Fixed notification clearing function. --- P8-testing/notify/notify.js | 50 +++++++++++++++++++++---------------- v2/apps.json | 2 +- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/P8-testing/notify/notify.js b/P8-testing/notify/notify.js index e2aa2baa..7a171072 100644 --- a/P8-testing/notify/notify.js +++ b/P8-testing/notify/notify.js @@ -1,4 +1,4 @@ -//notify +//notify face[0] = { offms: (ew.def.off[face.appCurr])?ew.def.off[face.appCurr]:5000, g:w.gfx, @@ -6,13 +6,13 @@ face[0] = { this.g.setColor(1,0); this.g.fillRect(0,0,239,239);this.g.setColor(0,1);this.g.fillRect(0,0,170,77);this.g.fillRect(175,0,239,77);this.g.fillRect(0,83,170,157);this.g.fillRect(175,83,239,157);this.g.fillRect(0,163,170,238);this.g.fillRect(175,163,239,238); this.g.flip(); - this.g.setColor(1,11); + this.g.setColor(1,11); this.img = require("heatshrink").decompress(atob("lMwwMAv/GBAQEEn/Oh////YhwEC/kOgYEB+12CYUDj9gAgMBw8wj/wgHBnF//0AsEcn//gE4hwZCj4HBAAIrBwBfbn4wBFAxQBw5RB/0B4YEBBoPgKIWAuAUC4E4AgRREmEOEoOAjEHKI8H//AEYQEDACkfKwYoG4JQB/cA8JWCKIN/MAJRGAgRRBEARRBAgPAhkDwf/8EHgJMCagJ6D/7KBAAI=")); this.g.drawImage(this.img,185,17); - this.g.flip(); + this.g.flip(); this.img = require("heatshrink").decompress(atob("mEwwIJGj//AAUAn4FKAAcHAqAAHn4FKAAcGAokPJYuADYnAAod58AjD+HwAoUB8F4BQUD4E8JgfgAocP+AFDj14C4c8ngjDvEfF4fwh/AjwuCg5HCFwJTDBIIPBLoYuEEgJ3CBIPwAoV4EgJtBgFwEgIXCuEHwYFDh6nDuEeAok8AoIjBuF4Aod/+AFBFIN/KYIXCv/Aa6IdCfZQLFAAoA==")); this.g.drawImage(this.img,185,98); - this.g.flip(); + this.g.flip(); this.img = require("heatshrink").decompress(atob("mEwwIROh/wAoc//wFD///wAEBgIFB4AFBgf4h/gAoMH8EDDwUP4EBAoYbB/AFBj4CBvACBjwCBvgFEngCBnwFEAS4dFFIo1FIIpNFLIplBAIJxDj4FCPoqJFgYLEg4FBEYUf+EPF4U/F4P8AoN/AQN+AQIICn4CBIgeATwsBWAfAgZKDWwLCDKwIFCCoMHagfwAocAIgIFFdgYFMAgYAHA==")); this.g.drawImage(this.img,182,177); this.g.flip(); @@ -53,7 +53,7 @@ face[0] = { this.g.setColor(1,(this.nInfo)?12:1); this.g.fillRect(0,163,170,238); this.g.setColor(0,15); - this.g.setFont("Vector",25); + this.g.setFont("Vector",25); this.g.drawString((notify.nInfo)?notify.nInfo+" / "+notify.info.length:(notify.info.length)?notify.info.length+" OLD":"-",100-(this.g.stringWidth((notify.nInfo)?notify.nInfo+" / "+notify.info.length:(notify.info.length)?notify.info.length+" OLD":"-")/2),190); this.img = require("heatshrink").decompress(atob("jEYwIHEv0AgP/wEH//gh//+Ef8/4j/D/E/4/8n///l///+v/nAQPDARM/4YXBAQIgCEwQsCGQQ4CHwQACA==")); this.g.drawImage(this.img,10,187); @@ -93,7 +93,7 @@ face[1] = { clear: function(){ return true; }, -}; +}; //info face face[5] = { offms: 10000, @@ -135,8 +135,8 @@ face[5] = { this.g.setColor(0,0); this.g.fillRect(0,0,239,239); this.g.setColor(1,11); - this.g.setFont("Vector",24); - this.g.drawString("NO ENTRIES",120-(this.g.stringWidth("NO ENTRIES")/2),100); + this.g.setFont("Vector",24); + this.g.drawString("NO ENTRIES",120-(this.g.stringWidth("NO ENTRIES")/2),100); this.at=this.go; } else this.run=true; this.g.flip(); @@ -170,7 +170,7 @@ face[5] = { else if (this.type==="info") this.g.setColor(1,12); this.g.fillRect(0,0,239,30); //if (this.msg.idUnread) {this.g.setColor(0,15);ew.gbSend({t:"notify", id:this.msg.id, n:"dismiss"});} else this.g.setColor(0,3); -// if (this.msg.id) ew.gbSend({t:"notify", id:this.msg.id, n:"dismiss"}); +// if (this.msg.id) ew.gbSend({t:"notify", id:this.msg.id, n:"dismiss"}); this.g.setColor(0,15); this.g.drawString(this.msg.src,3,5); this.g.drawString(this.go+1+"/"+this.list.length,239-(this.g.stringWidth(this.go+1+"/"+this.list.length)),5); @@ -183,7 +183,7 @@ face[5] = { this.g.drawString(this.msg.title+" :",3,35); this.g.setFont("Vector",24); //this.g.drawString(this.msg.body,122-(this.g.stringWidth(this.msg.body)/2),65); - this.g.drawString(this.msg.body.join("\n"),10,65); + this.g.drawString(this.msg.body.join("\n"),10,65); this.g.flip(); this.g.setFont("Vector",24); this.g.setColor(0,1); @@ -214,7 +214,7 @@ face[5] = { return true; } }; -//touch-notify +//touch-notify touchHandler[0]=function(e,x,y){ if (e==5){ if (y<80&&x<170){ @@ -240,7 +240,7 @@ touchHandler[0]=function(e,x,y){ buzzer.nav([30,50,30]); }else { face.go("settings",0);return; - } + } }else if (e==3){ //buzzer.nav(40); face.go("clock",0);return; @@ -250,13 +250,22 @@ touchHandler[0]=function(e,x,y){ }else if (e==12){ if (y<80&&x<170){ buzzer.nav([30,50,80]);notify.call=[];notify.nCall=0;face[0].nCall=-1; - if (!notify.nCall&&!notify.nIm&&!notify.nInfo) {gbSend({t:"notify", n:"dismiss_all"});notify.New=0;} + if (!notify.nCall&&!notify.nIm&&!notify.nInfo) { + if (typeof gbSend !== "undefined") gbSend({t:"notify", n:"dismiss_all"}); + notify.New=0; + } } else if (80<=y&&y<160&x<170){ buzzer.nav([30,50,80]);notify.im=[];notify.nIm=0;face[0].nIm=-1; - if (!notify.nCall&&!notify.nIm&&!notify.nInfo) {gbSend({t:"notify", n:"dismiss_all"});notify.New=0;} + if (!notify.nCall&&!notify.nIm&&!notify.nInfo) { + if (typeof gbSend !== "undefined") gbSend({t:"notify", n:"dismiss_all"}); + notify.New=0; + } } else if (160<=y&&y<239&x<170){ buzzer.nav([30,50,80]);notify.info=[];notify.nInfo=0;face[0].nInfo=-1; - if (!notify.nCall&&!notify.nIm&&!notify.nInfo) {gbSend({t:"notify", n:"dismiss_all"});notify.New=0;} + if (!notify.nCall&&!notify.nIm&&!notify.nInfo) { + if (typeof gbSend !== "undefined") gbSend({t:"notify", n:"dismiss_all"}); + notify.New=0; + } }else buzzer.nav(40); } this.timeout(); @@ -267,9 +276,9 @@ touchHandler[5]=function(e,x,y){ if (notify[face[5].type].length==1) notify[face[5].type]=[]; else notify[face[5].type].splice(face[5].at,1); if (notify[face[5].type].length==0){ - buzzer.nav(80); notify["n"+face[5].type.substr(0,1).toUpperCase()+face[5].type.substr(1)]=0; + buzzer.nav(80); notify["n"+face[5].type.substr(0,1).toUpperCase()+face[5].type.substr(1)]=0; if (!notify.nCall&&!notify.nIm&&!notify.nInfo) {notify.New=0;} - face.go("notify",0);return;} + face.go("notify",0);return;} face[5].go--; } else face[5].at=-1; face[5].del=0; @@ -277,18 +286,18 @@ touchHandler[5]=function(e,x,y){ }else if (e==5){ buzzer.nav(40); }else if (e==1){//slide down - if (face[5].msg&&face[5].msg.id) gbSend({t:"notify", id:face[5].msg.id, n:"dismiss"}); + if (face[5].msg && face[5].msg.id && typeof gbSend !== "undefined") gbSend({t:"notify", id:face[5].msg.id, n:"dismiss"}); face[5].go--; buzzer.nav([30,50,30]); }else if (e==2){ - if (face[5].msg&&face[5].msg.id) gbSend({t:"notify", id:face[5].msg.id, n:"dismiss"}); + if (face[5].msg && face[5].msg.id && typeof gbSend !== "undefined") gbSend({t:"notify", id:face[5].msg.id, n:"dismiss"}); face[5].go++; buzzer.nav([30,50,30]); }else if (e==3){ if (face[5].list.length>0) face[5].del=1; else {face.go("notify",0); return;} }else if (e==4){//slide right event (back action) - if (face[5].msg&&face[5].msg.id) gbSend({t:"notify", id:face[5].msg.id, n:"dismiss"}); + if (face[5].msg && face[5].msg.id && typeof gbSend !== "undefined") gbSend({t:"notify", id:face[5].msg.id, n:"dismiss"}); notify["n"+face[5].type.substr(0,1).toUpperCase()+face[5].type.substr(1)]=0; if (!notify.nInfo&&!notify.nCall&&!notify.nIm) {notify.New=0;} if (face.appPrev=="off") {face.go("clock",-1);return;} @@ -298,4 +307,3 @@ touchHandler[5]=function(e,x,y){ } this.timeout(); }; - diff --git a/v2/apps.json b/v2/apps.json index 32f9fe0c..86fcf918 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -234,7 +234,7 @@ { "id": "notify", "name": "Notifications", "icon": "../../P8-testing/notify/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "Notifications face for system, atc and gadgetbridge", "tags": "apps", "type": "notify", From 976b8057ddc03507355402c415f7f4adef5d3d5a Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sun, 24 Sep 2023 05:42:45 +0300 Subject: [PATCH 16/45] Improvement of the TPMS module * Increased sensors scanning time * Fixed several bugs --- P8-testing/tpms/tpms.js | 224 ++++++----- P8-testing/tpms/tpmsFace.js | 689 +++++++++++++++++---------------- P8-testing/tpms/tpmsOptions.js | 578 +++++++++++++-------------- v2/apps.json | 6 +- v2/handler/handler_notify.js | 4 +- 5 files changed, 751 insertions(+), 750 deletions(-) diff --git a/P8-testing/tpms/tpms.js b/P8-testing/tpms/tpms.js index a2df5d88..3f1989d2 100644 --- a/P8-testing/tpms/tpms.js +++ b/P8-testing/tpms/tpms.js @@ -1,122 +1,120 @@ //tpms sensor support //create settings json if (!require("Storage").read("tpms.json",1) || ( require("Storage").read("tpms.json",1) && require("Storage").readJSON("tpms.json",1).ver!=7) ) { - let def={"ver":7}; - def.dev={}; - def.def={ - wait:10, - try:0, - int:0, - ref:0, - pos:0, - metric:"psi", - list:{}, - allowNew:1 - }; - require("Storage").writeJSON("tpms.json",def); + let def={"ver":7}; + def.dev={}; + def.def={ + wait:60, + try:0, + int:0, + ref:0, + pos:0, + metric:"psi", + list:{}, + allowNew:1 + }; + require("Storage").writeJSON("tpms.json",def); } //tpms module tpms= { - euc:{}, - busy:0, - new:0, - status:"IDLE", - scan:()=>{ - if (tpms.busy) return; - tpms.busy=1; - tpms.new=0; - tpms.try=tpms.def.try; - tpms.cnt=getTime()|0; - tpms.status="SCANNING"; - if (tpms.tid) {clearTimeout(tpms.tid); tpms.tid=0;} - tpms.find(); - }, - find:(rp,sl)=>{ - //if (!this.try && this.status!="SCANNING") this.try=this.def.try - NRF.findDevices(function(devices) { - devices.forEach(function(device) { - if (device != [ ] && device.id ) { - let mac =device.id.split(" ")[0].split(":"); - if (mac[1]+mac[2] == "eaca") { - let id=mac[3]+mac[4]+mac[5]; - if ( tpms.def.allowNew || tpms.def.list[id] ) { - if (!tpms.def.list[id]) { - tpms.def.list[id]={"hiP":50,"lowP":10}; - let got=require("Storage").readJSON("tpms.json",1); - got.def=tpms.def; - require("Storage").writeJSON("tpms.json",got); - got=0; - } - tpms.def.ref=0; - let time=getTime()|0; - let alrm=0; - let dev={}; - dev={ - "id":id, - "pos":mac[0][1], - "kpa":((device.manufacturerData[6]|device.manufacturerData[7]<<8|device.manufacturerData[8]<<16|device.manufacturerData[9]<<24)/1000).toFixed(2), - "bar":((device.manufacturerData[6]|device.manufacturerData[7]<<8|device.manufacturerData[8]<<16|device.manufacturerData[9]<<24)/100000).toFixed(2), - "psi":(((device.manufacturerData[6]|device.manufacturerData[7]<<8|device.manufacturerData[8]<<16|device.manufacturerData[9]<<24)/1000)*0.1450377377).toFixed(2), - "temp":((device.manufacturerData[10]|device.manufacturerData[11]<<8|device.manufacturerData[12]<<16|device.manufacturerData[13]<<24)/100).toFixed(2), - "batt":device.manufacturerData[14], - //"volt":((330-(dev.batt/1.725))/100).toFixed(2), - "alrm":device.manufacturerData[15], - "time":time, - }; - device= [ ]; - tpms.new++; - //tpms.new.time=time; - if (dev.psi{ - tpms.tid=0; - tpms.scan(); - },intT[tpms.def.int]*60000); - } - //}, tpms.def.wait*1000); - }, {timeout : tpms.def.wait*1000, filters : [{services:[ "fbb0" ]}] }); - } + euc:{}, + busy:0, + new:0, + status:"IDLE", + scan:()=>{ + if (tpms.busy) return; + tpms.busy=1; + tpms.new=0; + tpms.try=tpms.def.try; + tpms.cnt=getTime()|0; + tpms.status="SCANNING"; + if (tpms.tid) {clearTimeout(tpms.tid); tpms.tid=0;} + tpms.find(); + }, + find:(rp,sl)=>{ + //if (!this.try && this.status!="SCANNING") this.try=this.def.try + NRF.findDevices(function(devices) { + devices.forEach(function(device) { + if (device != [ ] && device.id ) { + let mac=device.id.split(" ")[0].split(":"); + if (mac[1]+mac[2] == "eaca") { + let id=mac[3]+mac[4]+mac[5]; + if ( tpms.def.allowNew || tpms.def.list[id] ) { + if (!tpms.def.list[id]) { + tpms.def.list[id]={"hiP":50,"lowP":10}; + let got=require("Storage").readJSON("tpms.json",1); + got.def=tpms.def; + require("Storage").writeJSON("tpms.json",got); + got=0; + } + tpms.def.ref=0; + let time=getTime()|0; + let alrm=0; + let dev={}; + dev={ + "id":id, + "pos":mac[0][1], + "kpa":((device.manufacturerData[6]|device.manufacturerData[7]<<8|device.manufacturerData[8]<<16|device.manufacturerData[9]<<24)/1000).toFixed(2), + "bar":((device.manufacturerData[6]|device.manufacturerData[7]<<8|device.manufacturerData[8]<<16|device.manufacturerData[9]<<24)/100000).toFixed(2), + "psi":(((device.manufacturerData[6]|device.manufacturerData[7]<<8|device.manufacturerData[8]<<16|device.manufacturerData[9]<<24)/1000)*0.1450377377).toFixed(2), + "temp":((device.manufacturerData[10]|device.manufacturerData[11]<<8|device.manufacturerData[12]<<16|device.manufacturerData[13]<<24)/100).toFixed(2), + "batt":device.manufacturerData[14], + //"volt":((330-(dev.batt/1.725))/100).toFixed(2), + "alrm":device.manufacturerData[15], + "time":time, + }; + device=[ ]; + tpms.new++; + //tpms.new.time=time; + if (dev.psi{ + tpms.tid=0; + tpms.scan(); + },intT[tpms.def.int]*60000); + } + //}, tpms.def.wait*1000); + }, {timeout : tpms.def.wait*1000, filters : [{services:[ "fbb0" ]}] }); + } }; -//run +//run tpms.def=require("Storage").readJSON("tpms.json",1).def; if (tpms.def.int) tpms.scan(); - - diff --git a/P8-testing/tpms/tpmsFace.js b/P8-testing/tpms/tpmsFace.js index 41d16758..7a5a76a4 100644 --- a/P8-testing/tpms/tpmsFace.js +++ b/P8-testing/tpms/tpmsFace.js @@ -1,358 +1,359 @@ //tpms face face[0] = { - offms: (ew.def.off[face.appCurr])?ew.def.off[face.appCurr]:30000, - g:w.gfx, - spd:[], - init: function(){ - if (euc.state!="OFF"&&face.appPrev.startsWith("dash")) face.faceSave=[face.appPrev,face.pagePrev,face.pageArg]; - //check if log is corrupted - this.tpms=Object.keys(tpms.def.list); - if (require("Storage").read("tpmsLog"+this.tpms[tpms.def.pos]+".json",1) && !require("Storage").readJSON("tpmsLog"+this.tpms[tpms.def.pos]+".json",1)){ - require("Storage").erase("tpmsLog"+this.tpms[tpms.def.pos]+".json",1); - delete tpms.def.list[this.tpms[tpms.def.pos]]; - } - if (!this.tpms.length) {tpms.def.allowNew=1;tpms.def.int=0;} - // - this.log=0; - this.foot="bar"; - this.disp=0; - if (!this.tpms[tpms.def.pos]) tpms.def.pos=0; - //tpms.def.id=this.tpms[tpms.def.pos]; - if (this.tpms.length) { - this.g.setColor(0,0); - this.g.clearRect(0,186,239,195); - this.g.flip(); - this.log=require("Storage").readJSON("tpmsLog"+this.tpms[tpms.def.pos]+".json",1); - this.sc(); - //scale - let tm=(getTime()|0) - this.log[tpms.def.ref].time; - let ago=0; - if (tm < 86400){if(tm<60){ago=tm+"''";}else if(tm<3600){ago=((tm/60)|0)+"'";}else{ago=new Date(tm*1000).toISOString().substr(11,5).split(":");ago=Number(ago[0])+"h "+ago[1]+"'";}}else {ago=(new Date(this.log[tpms.def.ref].time*1000).toString().substr(4,17)).split(" ");ago=ago[0]+" "+ago[1]+" "+ago[3];} - //info - this.sel(this.log[tpms.def.ref][tpms.def.metric] ,ago,(tm < 86400)?"AGO":0); - let cl=((getTime()|0) - this.log[0].time < 1800)?1:0; - //top - this.btn(cl,this.tpms[tpms.def.pos],35,75,13,(this.log[0].psi < tpms.def.list[this.tpms[tpms.def.pos]].lowP || tpms.def.list[this.tpms[tpms.def.pos]].hiP < this.log[0].psi )?13:4,1,0,0,149,50); //device - this.btn(1,tpms.def.pos+1+"/"+this.tpms.length,35,200,7,0,0,150,0,239,50); //more - - if (tpms.status=="SCANNING"||tpms.status.startsWith("RETRY") ) {this.scan();this.ind();}else if (!this.ntid){this.bar();} - this.page=0; - }else { - tpms.def.pos=0; - this.g.setColor(0,0); - this.g.clearRect(0,0,239,239); - this.page="scan"; - this.btn(1,"TPMS SENSOR",25,120,7,0,0,0,0,239,50); - this.btn(1,"TOUCH",30,120,80,1,1,0,50,239,185,"TO SCAN",30,120,130); - if (tpms.status=="SCANNING"||tpms.status.startsWith("RETRY") ) this.scan(); - } - this.ref=tpms.def.ref; - }, - show : function(o){ - if(this.ref!=tpms.def.ref) { - this.ref=tpms.def.ref; - if (this.info){this.sel(this.log[tpms.def.ref].temp,this.log[tpms.def.ref].batt,"%"); - }else {let tm=(getTime()|0) - this.log[tpms.def.ref].time;let ago=0; - if (tm < 86400){if(tm<60){ago=tm+"''";}else if(tm<3600){ago=((tm/60)|0)+"'";}else{ago=new Date(tm*1000).toISOString().substr(11,5).split(":");ago=Number(ago[0])+"h "+ago[1]+"'";}}else {ago=(new Date(this.log[tpms.def.ref].time*1000).toString().substr(4,17)).split(" ");ago=ago[0]+" "+ago[1]+" "+ago[3];}this.sel(this.log[tpms.def.ref][tpms.def.metric],ago,(tm < 86400)?"AGO":0); - } - } - this.tid=setTimeout(function(t){ - t.tid=-1; - t.show(); - },250,this); - }, - sc:function(){ - this.scale=0; - for (let i in this.log) { - if (this.scale < this.log[i][tpms.def.metric]-0 ) this.scale=this.log[i][tpms.def.metric]; - } - this.top=this.scale; - this.scale=40/((this.scale)?this.scale:1); - }, - bar: function(l){ - if (tpms.status=="SCANNING"||tpms.status.startsWith("RETRY") ) {if (this.log ) this.ind(); return;} - this.g.setColor(0,0); - this.g.fillRect(0,190,(this.log)?58:239,239); - this.g.setColor(1,11); - let img = require("heatshrink").decompress(atob("mEwwIcZg/+Aocfx+AAoV4gPgAoQDBuAEBgPAgE4AoQVBjgFBgYCBhgoCAQMGAQUgAolACggFL6AFGGQQFJEZsGsAFEIIhNFLIplFgBxBnwFCPYP/AoU8gf/BwKVB/+/SAUD/kf+CjDh/4V4n8AoYeBAoq1DgIqDAAP/XYcAv4qEn4qEGwsfC4kPEYkHF4Z1DACA=")); - this.g.drawImage(img,5,195); - this.g.flip(); - //this.ind(); - this.g.setColor(0,0); - this.g.fillRect(59,190,239,239); - if (!this.log ) return; - for (let i in this.log) { - //let lim=(this.log[tpms.def.ref].psi String(key)); + if (require("Storage").read("tpmsLog"+this.tpms[tpms.def.pos]+".json",1) && !require("Storage").readJSON("tpmsLog"+this.tpms[tpms.def.pos]+".json",1)){ + require("Storage").erase("tpmsLog"+this.tpms[tpms.def.pos]+".json",1); + delete tpms.def.list[this.tpms[tpms.def.pos]]; + } + if (!this.tpms.length) {tpms.def.allowNew=1;tpms.def.int=0;} + // + this.log=0; + this.foot="bar"; + this.disp=0; + if (!this.tpms[tpms.def.pos]) tpms.def.pos=0; + //tpms.def.id=this.tpms[tpms.def.pos]; + if (this.tpms.length) { + this.g.setColor(0,0); + this.g.clearRect(0,186,239,195); + this.g.flip(); + this.log=require("Storage").readJSON("tpmsLog"+this.tpms[tpms.def.pos]+".json",1); + this.sc(); + //scale + let tm=(getTime()|0) - this.log[tpms.def.ref].time; + let ago=0; + if (tm < 86400){if(tm<60){ago=tm+"''";}else if(tm<3600){ago=((tm/60)|0)+"'";}else{ago=new Date(tm*1000).toISOString().substr(11,5).split(":");ago=Number(ago[0])+"h "+ago[1]+"'";}}else {ago=(new Date(this.log[tpms.def.ref].time*1000).toString().substr(4,17)).split(" ");ago=ago[0]+" "+ago[1]+" "+ago[3];} + //info + this.sel(this.log[tpms.def.ref][tpms.def.metric] ,ago,(tm < 86400)?"AGO":0); + let cl=((getTime()|0) - this.log[0].time < 1800)?1:0; + //top + this.btn(cl,this.tpms[tpms.def.pos],35,75,13,(this.log[0].psi < tpms.def.list[this.tpms[tpms.def.pos]].lowP || tpms.def.list[this.tpms[tpms.def.pos]].hiP < this.log[0].psi )?13:4,1,0,0,149,50); //device + this.btn(1,tpms.def.pos+1+"/"+this.tpms.length,35,200,7,0,0,150,0,239,50); //more - }, - scan: function(){ - this.act=1; - if (tpms.status=="SUCCESS") { - this.page=0; - tpms.def.ref=0; - this.tpms=Object.keys(tpms.def.list); - tpms.def.pos=this.tpms.indexOf(tpms.def.id); - this.log=require("Storage").readJSON("tpmsLog"+this.tpms[tpms.def.pos]+".json",1); - this.sc(); - let cl=((getTime()|0) - this.log[0].time < 1800)?1:0; - this.btn(cl,this.tpms[tpms.def.pos],35,75,7,(this.log[tpms.def.ref].psi=0) clearTimeout(this.stid); - this.stid=setTimeout(function(t){ - t.stid=0; - t.scan(); - },1000,this); - }, - btn: function(bt,txt1,size1,x1,y1,clr1,clr0,rx1,ry1,rx2,ry2,txt2,size2,x2,y2){ - this.g.setColor(0,(bt)?clr1:clr0); - this.g.fillRect(rx1,ry1,rx2,ry2); - this.g.setColor(1,15); - this.g.setFont("Vector",size1); - this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); - if (txt2){this.g.setFont("Vector",size2); - this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);} - this.g.flip(); - }, - sel: function(txt1,txt2,txt3){ - txt1=txt1.split("."); - this.g.setColor(0,1); - this.g.fillRect(0,51,239,120); - this.g.setColor(1,15); - this.g.setFont("Vector",53); - let size=this.g.stringWidth(txt1[0]); - this.g.drawString(txt1[0],((this.info)?100:80)-(size/2),65); - this.g.setFont("Vector",42); - this.g.drawString("."+((this.info)?txt1[1].slice(0,1):txt1[1]),((this.info)?100:80)+(size/2),72); - size=(size/2)+this.g.stringWidth((this.info)?txt1[1].slice(0,1):txt1[1]); - this.g.setFont("Vector",20); - this.g.drawString((this.info)?"°C":tpms.def.metric.toUpperCase(),((this.info)?117:97)+size,89); - this.g.flip(); - this.g.setColor(0,1); - if (txt3){ - this.g.fillRect(0,121,239,185); - this.g.setColor(1,11); - this.g.setFont("Vector",42); - let size=this.g.stringWidth(txt2); - this.g.drawString(txt2,((this.info)?120:110)-(size/2),135); - this.g.setFont("Vector",20); - this.g.drawString(txt3,((this.info)?122:112)+(size/2),152); - }else{ - this.g.fillRect(0,121,239,185); - this.g.setColor(1,15); - this.g.setFont("Vector",30); - this.g.drawString(txt2,120-(this.g.stringWidth(txt2)/2),145); - } - this.g.flip(); - }, - ntfy: function(txt1,txt2,size,clr,bt,tm,s,f,d){ - this.g.setColor(0,clr); - this.g.fillRect(0,190,239,239); - this.g.setColor(1,15); - if (s) {this.g.setFont("Vector",45);this.g.drawString("<",5,197);this.g.drawString(">",215,197);} - this.g.setFont("Vector",size); - this.g.drawString((bt)?txt1:txt2,125-(this.g.stringWidth((bt)?txt1:txt2)/2),205); - this.g.flip(); - if (this.ntid) clearTimeout(this.ntid); - this.ntid=setTimeout(function(t){ - t.ntid=0; - t.act=0; - t[t.foot](); - },tm*1000,this); - }, - tid:-1, - run:false, - clear : function(){ - this.run=false; - if (this.tid) clearTimeout(this.tid); - if (this.stid) clearTimeout(this.stid); - if (this.ntid) clearTimeout(this.ntid); - this.tid=-1; - return true; - }, - off: function(){ - this.g.off(); - this.clear(); - } + if ( tpms.status=="SCANNING"||tpms.status.startsWith("RETRY") ) {this.scan();this.ind();} + else if (!this.ntid){this.bar();} + this.page=0; + } else { + tpms.def.pos=0; + this.g.setColor(0,0); + this.g.clearRect(0,0,239,239); + this.page="scan"; + this.btn(1,"TPMS SENSOR",25,120,7,0,0,0,0,239,50); + this.btn(1,"TOUCH",30,120,80,1,1,0,50,239,185,"TO SCAN",30,120,130); + if ( tpms.status=="SCANNING"||tpms.status.startsWith("RETRY") ) this.scan(); + } + this.ref=tpms.def.ref; + }, + show : function(o){ + if(this.ref!=tpms.def.ref) { + this.ref=tpms.def.ref; + if (this.info){this.sel(this.log[tpms.def.ref].temp,this.log[tpms.def.ref].batt,"%"); + } else { + let tm=(getTime()|0) - this.log[tpms.def.ref].time;let ago=0; + if (tm < 86400){if(tm<60){ago=tm+"''";}else if(tm<3600){ago=((tm/60)|0)+"'";}else{ago=new Date(tm*1000).toISOString().substr(11,5).split(":");ago=Number(ago[0])+"h "+ago[1]+"'";}}else {ago=(new Date(this.log[tpms.def.ref].time*1000).toString().substr(4,17)).split(" ");ago=ago[0]+" "+ago[1]+" "+ago[3];}this.sel(this.log[tpms.def.ref][tpms.def.metric],ago,(tm < 86400)?"AGO":0); + } + } + this.tid=setTimeout(function(t){ + t.tid=-1; + t.show(); + },250,this); + }, + sc:function(){ + this.scale=0; + for (let i in this.log) { + if (this.scale < this.log[i][tpms.def.metric]-0 ) this.scale=this.log[i][tpms.def.metric]; + } + this.top=this.scale; + this.scale=40/((this.scale)?this.scale:1); + }, + bar: function(l){ + if (tpms.status=="SCANNING"||tpms.status.startsWith("RETRY") ) {if (this.log ) this.ind(); return;} + this.g.setColor(0,0); + this.g.fillRect(0,190,(this.log)?58:239,239); + this.g.setColor(1,11); + let img = require("heatshrink").decompress(atob("mEwwIcZg/+Aocfx+AAoV4gPgAoQDBuAEBgPAgE4AoQVBjgFBgYCBhgoCAQMGAQUgAolACggFL6AFGGQQFJEZsGsAFEIIhNFLIplFgBxBnwFCPYP/AoU8gf/BwKVB/+/SAUD/kf+CjDh/4V4n8AoYeBAoq1DgIqDAAP/XYcAv4qEn4qEGwsfC4kPEYkHF4Z1DACA=")); + this.g.drawImage(img,5,195); + this.g.flip(); + //this.ind(); + this.g.setColor(0,0); + this.g.fillRect(59,190,239,239); + if (!this.log ) return; + for (let i in this.log) { + //let lim=(this.log[tpms.def.ref].psi String(key)); + tpms.def.pos=this.tpms.indexOf(tpms.def.id); + this.log=require("Storage").readJSON("tpmsLog"+this.tpms[tpms.def.pos]+".json",1); + this.sc(); + let cl=((getTime()|0) - this.log[0].time < 1800)?1:0; + this.btn(cl,this.tpms[tpms.def.pos],35,75,7,(this.log[tpms.def.ref].psi=0) clearTimeout(this.stid); + this.stid=setTimeout(function(t){ + t.stid=0; + t.scan(); + },1000,this); + }, + btn: function(bt,txt1,size1,x1,y1,clr1,clr0,rx1,ry1,rx2,ry2,txt2,size2,x2,y2){ + this.g.setColor(0,(bt)?clr1:clr0); + this.g.fillRect(rx1,ry1,rx2,ry2); + this.g.setColor(1,15); + this.g.setFont("Vector",size1); + this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); + if (txt2){this.g.setFont("Vector",size2); + this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);} + this.g.flip(); + }, + sel: function(txt1,txt2,txt3){ + txt1=txt1.split("."); + this.g.setColor(0,1); + this.g.fillRect(0,51,239,120); + this.g.setColor(1,15); + this.g.setFont("Vector",53); + let size=this.g.stringWidth(txt1[0]); + this.g.drawString(txt1[0],((this.info)?100:80)-(size/2),65); + this.g.setFont("Vector",42); + this.g.drawString("."+((this.info)?txt1[1].slice(0,1):txt1[1]),((this.info)?100:80)+(size/2),72); + size=(size/2)+this.g.stringWidth((this.info)?txt1[1].slice(0,1):txt1[1]); + this.g.setFont("Vector",20); + this.g.drawString((this.info)?"°C":tpms.def.metric.toUpperCase(),((this.info)?117:97)+size,89); + this.g.flip(); + this.g.setColor(0,1); + if (txt3){ + this.g.fillRect(0,121,239,185); + this.g.setColor(1,11); + this.g.setFont("Vector",42); + let size=this.g.stringWidth(txt2); + this.g.drawString(txt2,((this.info)?120:110)-(size/2),135); + this.g.setFont("Vector",20); + this.g.drawString(txt3,((this.info)?122:112)+(size/2),152); + } else { + this.g.fillRect(0,121,239,185); + this.g.setColor(1,15); + this.g.setFont("Vector",30); + this.g.drawString(txt2,120-(this.g.stringWidth(txt2)/2),145); + } + this.g.flip(); + }, + ntfy: function(txt1,txt2,size,clr,bt,tm,s,f,d){ + this.g.setColor(0,clr); + this.g.fillRect(0,190,239,239); + this.g.setColor(1,15); + if (s) {this.g.setFont("Vector",45);this.g.drawString("<",5,197);this.g.drawString(">",215,197);} + this.g.setFont("Vector",size); + this.g.drawString((bt)?txt1:txt2,125-(this.g.stringWidth((bt)?txt1:txt2)/2),205); + this.g.flip(); + if (this.ntid) clearTimeout(this.ntid); + this.ntid=setTimeout(function(t){ + t.ntid=0; + t.act=0; + t[t.foot](); + },tm*1000,this); + }, + tid:-1, + run:false, + clear : function(){ + this.run=false; + if (this.tid) clearTimeout(this.tid); + if (this.stid) clearTimeout(this.stid); + if (this.ntid) clearTimeout(this.ntid); + this.tid=-1; + return true; + }, + off: function(){ + this.g.off(); + this.clear(); + } }; //loop face face[1] = { - offms:1000, - init: function(){ - return; - }, - show : function(){ - if (global.euc &&euc.state!="OFF"&&face.faceSave[0].startsWith("dash")){ - euc.dash.opt.tpms=face[0].tpms[tpms.def.pos]; - tpms.def.id=face[0].tpms[tpms.def.pos]; - face.go(face.faceSave[0],face.faceSave[1],face.faceSave[2]);face.faceSave=-1; - }else if (global.euc && euc.state!="OFF") - face.go(ew.is.dash[ew.def.dash.face],0); - else - face.go("settings",0,1); - return; - }, - clear: function(){ - return; - }, - off: function(){ - return; - }, -}; + offms:1000, + init: function(){ + return; + }, + show : function(){ + if (global.euc &&euc.state!="OFF"&&face.faceSave[0].startsWith("dash")){ + euc.dash.opt.tpms=face[0].tpms[tpms.def.pos]; + tpms.def.id=face[0].tpms[tpms.def.pos]; + face.go(face.faceSave[0],face.faceSave[1],face.faceSave[2]);face.faceSave=-1; + } else if (global.euc && euc.state!="OFF") + face.go(ew.is.dash[ew.def.dash.face],0); + else + face.go("settings",0,1); + return; + }, + clear: function(){ + return; + }, + off: function(){ + return; + }, +}; //touch-main touchHandler[0]=function(e,x,y){ - this.timeout(); - if (!this.lL) this.lL=getTime(); - switch (e) { - case 5: //tap event - if (face[0].page=="scan"){ - buzzer.nav([30,50,30]); - tpms.scan(); - face[0].scan(); - return; - }else if (190 < y && x < 80 ) { - if (tpms.status!="SCANNING"&&!tpms.status.startsWith("RETRY") ) { - buzzer.nav([30,50,30]); - tpms.scan(); - if (face[0].act && face[0].ntid) { clearTimeout(face[0].ntid);face[0].ntid=0;} - face[0].scan(); - }else buzzer.nav(40); - return; - } - if (50 < y) { - //entry select - if (!face[0].tpms.length ) {buzzer.nav(40);return;} - let last=tpms.def.ref; - buzzer.nav([30,50,30]); - tpms.def.ref=(120160&&x<50) { - buzzer.nav([30,50,30]); - if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} - else w.gfx.bri.set(this.bri); - }else { - face.go("settings",0); - return; - } - break; + if (y>160&&x<50) { + buzzer.nav([30,50,30]); + if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} + else w.gfx.bri.set(this.bri); + } else { + face.go("settings",0); + return; + } + break; case 3: //slide left event - if (!face[0].log) {buzzer.nav(40);return;} - buzzer.nav([30,50,30]); - if (face[0].info) { - face[0].info=0; - let tm=(getTime()|0) - face[0].log[tpms.def.ref].time; - let ago=0; - if (tm < 86400){if(tm<60){ago=tm+"''";}else if(tm<3600){ago=((tm/60)|0)+"'";}else{ago=new Date(tm*1000).toISOString().substr(11,5).split(":");ago=Number(ago[0])+"h "+ago[1]+"'";}}else {ago=(new Date(face[0].log[tpms.def.ref].time*1000).toString().substr(4,17)).split(" ");ago=ago[0]+" "+ago[1]+" "+ago[3];} - face[0].sel(face[0].log[tpms.def.ref][tpms.def.metric],ago,(tm < 86400)?"AGO":0); - return; - }else { - face[0].info=1; - face[0].sel(face[0].log[tpms.def.ref].temp,face[0].log[tpms.def.ref].batt,"%"); - } - return; + if (!face[0].log) {buzzer.nav(40);return;} + buzzer.nav([30,50,30]); + if (face[0].info) { + face[0].info=0; + let tm=(getTime()|0) - face[0].log[tpms.def.ref].time; + let ago=0; + if (tm < 86400){if(tm<60){ago=tm+"''";}else if(tm<3600){ago=((tm/60)|0)+"'";}else{ago=new Date(tm*1000).toISOString().substr(11,5).split(":");ago=Number(ago[0])+"h "+ago[1]+"'";}}else {ago=(new Date(face[0].log[tpms.def.ref].time*1000).toString().substr(4,17)).split(" ");ago=ago[0]+" "+ago[1]+" "+ago[3];} + face[0].sel(face[0].log[tpms.def.ref][tpms.def.metric],ago,(tm < 86400)?"AGO":0); + return; + } else { + face[0].info=1; + face[0].sel(face[0].log[tpms.def.ref].temp,face[0].log[tpms.def.ref].batt,"%"); + } + return; case 4: //slide right event (back action) - if (global.euc && euc.state!="OFF"&&face.faceSave[0].startsWith("dash")){ - euc.dash.opt.tpms=face[0].tpms[tpms.def.pos]; - tpms.def.id=face[0].tpms[tpms.def.pos]; - face.go(face.faceSave[0],face.faceSave[1],face.faceSave[2]);face.faceSave=-1; - }else - face.go("settings",0,1); - return; + if (global.euc && euc.state!="OFF"&&face.faceSave[0].startsWith("dash")){ + euc.dash.opt.tpms=face[0].tpms[tpms.def.pos]; + tpms.def.id=face[0].tpms[tpms.def.pos]; + face.go(face.faceSave[0],face.faceSave[1],face.faceSave[2]);face.faceSave=-1; + }else + face.go("settings",0,1); + return; case 12: //touch and hold(long press) event - buzzer.nav(40); - return; - } -}; \ No newline at end of file + buzzer.nav(40); + return; + } +}; diff --git a/P8-testing/tpms/tpmsOptions.js b/P8-testing/tpms/tpmsOptions.js index 995feb09..bd71e6fd 100644 --- a/P8-testing/tpms/tpmsOptions.js +++ b/P8-testing/tpms/tpmsOptions.js @@ -1,302 +1,304 @@ //tpms face face[0] = { - offms: (ew.def.off[face.appCurr])?ew.def.off[face.appCurr]:30000, - g:w.gfx, - spd:[], - init: function(){ - this.log=0; - this.foot="barS"; - this.page="sett"; - this.disp=0; - this.tpms=Object.keys(tpms.def.list); - if (!this.tpms[tpms.def.pos]) tpms.def.pos=0; - this.log=require("Storage").readJSON("tpmsLog"+this.tpms[tpms.def.pos]+".json",1); - this.sett(); - }, - show : function(o){ - return; - }, - btn: function(bt,txt1,size1,x1,y1,clr1,clr0,rx1,ry1,rx2,ry2,txt2,size2,x2,y2){ - this.g.setColor(0,(bt)?clr1:clr0); - this.g.fillRect(rx1,ry1,rx2,ry2); - this.g.setColor(1,15); - this.g.setFont("Vector",size1); - this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); - if (txt2){this.g.setFont("Vector",size2); - this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);} - this.g.flip(); - }, - sett:function(){ - let tpmsS=["OFF","5 MIN","30 MIN","1 HOUR","6 HOURS"]; - this.barS(); - this.btn(tpms.def.allowNew,(tpms.def.allowNew)?"ALLOW":"BLOCK",25,80,20,4,13,0,0,155,60);//1-2 - this.g.setColor(0,0); - this.g.clearRect(156,0,159,60); - this.g.flip(); - this.btn(1,(tpms.def.metric=="psi")?tpms.def.list[this.tpms[tpms.def.pos]].hiP: (tpms.def.list[this.tpms[tpms.def.pos]].hiP/((tpms.def.metric=="bar")?14.50377377:0.1450377377) ).toFixed((tpms.def.metric=="bar")?2:0),38,205,15,1,0,160,0,239,60); //3 - this.g.setColor(0,0); - this.g.clearRect(0,61,239,64); - this.g.flip(); - this.btn(tpms.def.int,"SCAN",28,80,84,4,(euc.state!="OFF"&&euc.dash.opt.tpms)?12:1,0,65,155,125); //4-5 - this.g.setColor(0,0); - this.g.clearRect(156,65,159,125); - this.g.flip(); - this.btn(1,(tpms.def.metric=="psi")?tpms.def.list[this.tpms[tpms.def.pos]].lowP:(tpms.def.list[this.tpms[tpms.def.pos]].lowP/ ((tpms.def.metric=="bar")?14.50377377:0.1450377377 )).toFixed((tpms.def.metric=="bar")?2:0),38,205,81,1,0,160,65,239,125); //6 - this.g.setColor(0,0); - this.g.clearRect(0,126,239,129); - this.g.flip(); - this.btn(1,"WAIT",18,40,152,1,0,0,130,80,185); //7 - this.g.setColor(0,0); - this.g.clearRect(81,130,84,185); - this.g.flip(); - this.btn(1,"RETRY",18,123,152,1,0,85,130,155,185); //8 - this.g.setColor(0,0); - this.g.clearRect(156,130,159,185); - this.g.flip(); - this.btn(1,tpms.def.metric.toUpperCase(),28,205,150,4,0,160,130,239,185,"",30,205,40); //9 - }, - barS: function(){ - this.g.setColor(0,0); - this.g.clearRect(0,126,239,129); - this.g.flip(); - this.btn(1,"WAIT",18,40,152,1,0,0,130,80,185); //7 - this.g.setColor(0,0); - this.g.clearRect(81,130,84,185); - this.g.flip(); - this.btn(1,"RETRY",18,123,152,1,0,85,130,155,185); //8 - this.g.setColor(0,0); - this.g.clearRect(156,130,159,185); - this.g.flip(); - this.btn(1,tpms.def.metric.toUpperCase(),28,205,150,4,0,160,130,239,185,"",30,205,40); //9 - if (tpms.status=="SCANNING"||tpms.status.startsWith("RETRY")) return; - this.g.setColor(0,0); - this.g.fillRect(0,186,239,239); - this.g.setColor(1,11); - this.g.setFont("Vector",55); - this.g.drawString("<",15,195); - img = require("heatshrink").decompress(atob("mEwwIROv/+AqoAPgf/AAXAg4FD8AFLFSQTCg8AgPwAoMPwAFHkAFE+EPAv4FLsEGL5IFVgH8AoM/AQKnDawQEBbAU/AoIUCj4FB/DkTAAgA=")); - this.g.drawImage(img,177,195); - img=0; - this.g.flip(); - }, - ntfy: function(txt1,txt2,size,clr,bt,tm,s,f,d){ - if (tpms.status=="SCANNING"||tpms.status.startsWith("RETRY") ) return; - if (f && this.ntid) {clearTimeout(this.ntid);this.ntid=0;} - if (!this.ntid){ - this.g.setColor(0,clr); - this.g.fillRect(0,130,239,239); - this.g.setColor(1,15); - if (s) {this.g.setFont("Vector",40);this.g.drawString("<",5,170);this.g.drawString(">",215,170);} - this.g.setFont("Vector",size); - this.g.drawString(txt1,125-(this.g.stringWidth(txt1)/2),150); - //this.g.setFont("Vector",size); - this.g.drawString(txt2,125-(this.g.stringWidth(txt2)/2),205); - this.g.flip(); - } - if (this.ntid) clearTimeout(this.ntid); - this.ntid=setTimeout(function(t){ - t.ntid=0; - t.act=0; - t[t.foot](); - },tm*1000,this); - }, - tid:-1, - run:false, - clear : function(){ - this.run=false; - if (this.tid>=0) clearTimeout(this.tid); - if (this.ntid) clearTimeout(this.ntid); - this.tid=-1; - return true; - }, - off: function(){ - this.g.off(); - this.clear(); - } + offms: (ew.def.off[face.appCurr])?ew.def.off[face.appCurr]:30000, + g:w.gfx, + spd:[], + init: function(){ + this.log=0; + this.foot="barS"; + this.page="sett"; + this.disp=0; + this.tpms=Object.keys(tpms.def.list); + if (!this.tpms[tpms.def.pos]) tpms.def.pos=0; + this.log=require("Storage").readJSON("tpmsLog"+this.tpms[tpms.def.pos]+".json",1); + this.sett(); + }, + show : function(o){ + return; + }, + btn: function(bt,txt1,size1,x1,y1,clr1,clr0,rx1,ry1,rx2,ry2,txt2,size2,x2,y2){ + this.g.setColor(0,(bt)?clr1:clr0); + this.g.fillRect(rx1,ry1,rx2,ry2); + this.g.setColor(1,15); + this.g.setFont("Vector",size1); + this.g.drawString(txt1,x1-(this.g.stringWidth(txt1)/2),y1); + if (txt2){this.g.setFont("Vector",size2); + this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);} + this.g.flip(); + }, + sett:function(){ + let tpmsS=["OFF","5 MIN","30 MIN","1 HOUR","6 HOURS"]; + this.barS(); + this.btn(tpms.def.allowNew,(tpms.def.allowNew)?"ALLOW":"BLOCK",25,80,20,4,13,0,0,155,60);//1-2 + this.g.setColor(0,0); + this.g.clearRect(156,0,159,60); + this.g.flip(); + this.btn(1,(tpms.def.metric=="psi")?tpms.def.list[this.tpms[tpms.def.pos]].hiP: (tpms.def.list[this.tpms[tpms.def.pos]].hiP/((tpms.def.metric=="bar")?14.50377377:0.1450377377) ).toFixed((tpms.def.metric=="bar")?2:0),38,205,15,1,0,160,0,239,60); //3 + this.g.setColor(0,0); + this.g.clearRect(0,61,239,64); + this.g.flip(); + this.btn(tpms.def.int,"SCAN",28,80,84,4,(euc.state!="OFF"&&euc.dash.opt.tpms)?12:1,0,65,155,125); //4-5 + this.g.setColor(0,0); + this.g.clearRect(156,65,159,125); + this.g.flip(); + this.btn(1,(tpms.def.metric=="psi")?tpms.def.list[this.tpms[tpms.def.pos]].lowP:(tpms.def.list[this.tpms[tpms.def.pos]].lowP/ ((tpms.def.metric=="bar")?14.50377377:0.1450377377 )).toFixed((tpms.def.metric=="bar")?2:0),38,205,81,1,0,160,65,239,125); //6 + this.g.setColor(0,0); + this.g.clearRect(0,126,239,129); + this.g.flip(); + this.btn(1,"WAIT",18,40,152,1,0,0,130,80,185); //7 + this.g.setColor(0,0); + this.g.clearRect(81,130,84,185); + this.g.flip(); + this.btn(1,"RETRY",18,123,152,1,0,85,130,155,185); //8 + this.g.setColor(0,0); + this.g.clearRect(156,130,159,185); + this.g.flip(); + this.btn(1,tpms.def.metric.toUpperCase(),28,205,150,4,0,160,130,239,185,"",30,205,40); //9 + }, + barS: function(){ + this.g.setColor(0,0); + this.g.clearRect(0,126,239,129); + this.g.flip(); + this.btn(1,"WAIT",18,40,152,1,0,0,130,80,185); //7 + this.g.setColor(0,0); + this.g.clearRect(81,130,84,185); + this.g.flip(); + this.btn(1,"RETRY",18,123,152,1,0,85,130,155,185); //8 + this.g.setColor(0,0); + this.g.clearRect(156,130,159,185); + this.g.flip(); + this.btn(1,tpms.def.metric.toUpperCase(),28,205,150,4,0,160,130,239,185,"",30,205,40); //9 + if (tpms.status=="SCANNING"||tpms.status.startsWith("RETRY")) return; + this.g.setColor(0,0); + this.g.fillRect(0,186,239,239); + this.g.setColor(1,11); + this.g.setFont("Vector",55); + this.g.drawString("<",15,195); + img = require("heatshrink").decompress(atob("mEwwIROv/+AqoAPgf/AAXAg4FD8AFLFSQTCg8AgPwAoMPwAFHkAFE+EPAv4FLsEGL5IFVgH8AoM/AQKnDawQEBbAU/AoIUCj4FB/DkTAAgA=")); + this.g.drawImage(img,177,195); + img=0; + this.g.flip(); + }, + ntfy: function(txt1,txt2,size,clr,bt,tm,s,f,d){ + if (tpms.status=="SCANNING"||tpms.status.startsWith("RETRY") ) return; + if (f && this.ntid) {clearTimeout(this.ntid);this.ntid=0;} + if (!this.ntid){ + this.g.setColor(0,clr); + this.g.fillRect(0,130,239,239); + this.g.setColor(1,15); + if (s) {this.g.setFont("Vector",40);this.g.drawString("<",5,170);this.g.drawString(">",215,170);} + this.g.setFont("Vector",size); + this.g.drawString(txt1,125-(this.g.stringWidth(txt1)/2),150); + //this.g.setFont("Vector",size); + this.g.drawString(txt2,125-(this.g.stringWidth(txt2)/2),205); + this.g.flip(); + } + if (this.ntid) clearTimeout(this.ntid); + this.ntid=setTimeout(function(t){ + t.ntid=0; + t.act=0; + t[t.foot](); + },tm*1000,this); + }, + tid:-1, + run:false, + clear : function(){ + this.run=false; + if (this.tid>=0) clearTimeout(this.tid); + if (this.ntid) clearTimeout(this.ntid); + this.tid=-1; + return true; + }, + off: function(){ + this.g.off(); + this.clear(); + } }; //loop face face[1] = { - offms:1000, - init: function(){ - return; - }, - show : function(){ - let got=require("Storage").readJSON("tpms.json",1); - got.def=tpms.def; - require("Storage").writeJSON("tpms.json",got); - if (tpms.def.int) tpms.scan(); else if (tpms.tid) {clearTimeout(tpms.tid); tpms.tid=0;} - face.go("tpmsFace",0,1); - return; - }, - clear: function(){ - return; - }, - off: function(){ - return; - }, -}; + offms:1000, + init: function(){ + return; + }, + show : function(){ + let got=require("Storage").readJSON("tpms.json",1); + got.def=tpms.def; + require("Storage").writeJSON("tpms.json",got); + if (tpms.def.int) tpms.scan(); else if (tpms.tid) {clearTimeout(tpms.tid); tpms.tid=0;} + face.go("tpmsFace",0,1); + return; + }, + clear: function(){ + return; + }, + off: function(){ + return; + }, +}; //touch-main touchHandler[0]=function(e,x,y){ - if (tpms.status=="SCANNING"||tpms.status.startsWith("RETRY") ) {face.go("tpmsFace",0);return;} - this.timeout(); - if (!this.lL) this.lL=getTime(); - switch (e) { - case 5: //tap event - if ( 125{face.go("tpmsFace",0);},1000); - return; - }else if (face[0].act=="del"){ - buzzer.nav([30,50,30]); - face[0].ntfy("TAP TO","DELETE",26,13,1,2,0,1,1); - face[0].act="conf"; - }else if (face[0].act=="hi"){ - buzzer.nav([30,50,30]); - let fast=( getTime()-this.lL < 0.2 )?1:0; - if ( x < 120 ) {tpms.def.list[face[0].tpms[tpms.def.pos]].hiP=tpms.def.list[face[0].tpms[tpms.def.pos]].hiP-((fast)?5:1);if(tpms.def.list[face[0].tpms[tpms.def.pos]].hiP-5{face.go("tpmsFace",0);},1000); + return; + } else if (face[0].act=="del") { + buzzer.nav([30,50,30]); + face[0].ntfy("TAP TO","DELETE",26,13,1,2,0,1,1); + face[0].act="conf"; + } else if (face[0].act=="hi") { + buzzer.nav([30,50,30]); + let fast=( getTime()-this.lL < 0.2 )?1:0; + if ( x < 120 ) {tpms.def.list[face[0].tpms[tpms.def.pos]].hiP=tpms.def.list[face[0].tpms[tpms.def.pos]].hiP-((fast)?5:1);if(tpms.def.list[face[0].tpms[tpms.def.pos]].hiP-5160&&x<50) { - if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} - else w.gfx.bri.set(this.bri); - buzzer.nav([30,50,30]); - }else { - let got=require("Storage").readJSON("tpms.json",1); - got.def=tpms.def; - require("Storage").writeJSON("tpms.json",got);got=0; - if (tpms.def.int) tpms.scan(); else if (tpms.tid) {clearTimeout(tpms.tid); tpms.tid=0;} - face.go("settings",0,1); - } - break; + if (y>160&&x<50) { + if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} + else w.gfx.bri.set(this.bri); + buzzer.nav([30,50,30]); + } else { + let got=require("Storage").readJSON("tpms.json",1); + got.def=tpms.def; + require("Storage").writeJSON("tpms.json",got);got=0; + if (tpms.def.int) tpms.scan(); else if (tpms.tid) {clearTimeout(tpms.tid); tpms.tid=0;} + face.go("settings",0,1); + } + break; case 3: //slide left event - buzzer.nav(40); - return; + buzzer.nav(40); + return; case 4: //slide right event (back action) - if (face[0].act) { - face[0].act=0; - if (face[0].ntid) {clearTimeout(face[0].ntid);face[0].ntid=0;} - face[0].barS(); - }else { - let got=require("Storage").readJSON("tpms.json",1); - got.def=tpms.def; - require("Storage").writeJSON("tpms.json",got);got=0; - if (tpms.def.int) tpms.scan(); else if (tpms.tid) {clearTimeout(tpms.tid); tpms.tid=0;} - face.go("tpmsFace",0,1); - return; - } + if (face[0].act) { + face[0].act=0; + if (face[0].ntid) {clearTimeout(face[0].ntid);face[0].ntid=0;} + face[0].barS(); + } else { + let got=require("Storage").readJSON("tpms.json",1); + got.def=tpms.def; + require("Storage").writeJSON("tpms.json",got);got=0; + if (tpms.def.int) tpms.scan(); else if (tpms.tid) {clearTimeout(tpms.tid); tpms.tid=0;} + face.go("tpmsFace",0,1); + return; + } break; case 12: //touch and hold(long press) event - buzzer.nav(40); - return; - } -}; \ No newline at end of file + buzzer.nav(40); + return; + } +}; diff --git a/v2/apps.json b/v2/apps.json index 86fcf918..985e9d30 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -117,7 +117,7 @@ { "id": "handler", "name": "Handler - V2", "icon": "../../Magic-testing/handler/icon.png", - "version":"1.94.3", + "version":"1.94.4", "description": "Magic3-Rock-Bangle functions handler", "tags": "core", "type":"core", @@ -145,7 +145,7 @@ { "id": "handler", "name": "Handler - V1", "icon": "../handler/icon.png", - "version":"1.94.7", + "version":"1.94.8", "description": "P8-P22-Pinetime functions handler", "tags": "core", "needsFeatures":["V1"], @@ -445,7 +445,7 @@ { "id": "tpms", "name": "TPMS Sensor", "icon": "../../P8-testing/tpms/icon.png", - "version":"1.94.2", + "version":"1.94.3", "description": "BLE TPMS Sensors (Tire pressure measuring, TP630 etc)", "tags": "euc", "needsFeatures":["V1"], diff --git a/v2/handler/handler_notify.js b/v2/handler/handler_notify.js index 6688b6c3..2b27346b 100644 --- a/v2/handler/handler_notify.js +++ b/v2/handler/handler_notify.js @@ -10,7 +10,7 @@ function handleInfoEvent(event,discrete) { //"ram"; notify.nInfo++; notify.New++; - + let d=(Date()).toString().split(' '); let ti=(""+d[4]+" "+d[0]+" "+d[2]); notify.info.unshift("{\"src\":\""+event.src+"\",\"title\":\""+event.title+"\",\"body\":\""+event.body+"\",\"time\":\""+ti+"\"}"); @@ -19,7 +19,7 @@ function handleInfoEvent(event,discrete) { face.off(8000); buzzer.nav([80,50,80]); if (face[0].bar){ - UI.btn.ntfy(1,4,0,"_bar",6,event.title,event.body,0,15);w.gfx.flip(); + if (typeof UI !== "undefined") { UI.btn.ntfy(1,4,0,"_bar",6,event.title,event.body,0,15);w.gfx.flip(); } }else if (!discrete){ if (face.appCurr!="clock"||face.pageCurr!=0) { face.go("clock",0); From 8c55cd8be9137a28c82587fdad2c2f4430e0a417 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Wed, 27 Sep 2023 19:44:42 +0300 Subject: [PATCH 17/45] Added checksum for Veteran (Firmware version 3012 and higher) --- v2/apps.json | 2 +- v2/euc/eucVeteran/ChangeLog | 1 + v2/euc/eucVeteran/eucVeteran.js | 23 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index 985e9d30..8dbacee1 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -843,7 +843,7 @@ { "id": "eucVeteran", "name": "Veteran module", "icon": "../../v2/euc/eucVeteran/icon.png", - "version":"2.0.0", + "version":"2.1.0", "description": "EUC module for Veteran Sherman", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucVeteran/ChangeLog b/v2/euc/eucVeteran/ChangeLog index dd15543c..b1d79721 100644 --- a/v2/euc/eucVeteran/ChangeLog +++ b/v2/euc/eucVeteran/ChangeLog @@ -1,3 +1,4 @@ +2.10: add checksum 2.00: new protocol support 1.80: rework 1.03: Connection optimization diff --git a/v2/euc/eucVeteran/eucVeteran.js b/v2/euc/eucVeteran/eucVeteran.js index 290cc129..b9e4ac8f 100644 --- a/v2/euc/eucVeteran/eucVeteran.js +++ b/v2/euc/eucVeteran/eucVeteran.js @@ -17,6 +17,23 @@ euc.cmd=function(no){ default: return []; } }; +// +function checksum(packet) { + // Skip check if old firmware + let FWVer = packet[28]<<8|packet[29]; + if (FWVer < 3012) { + if (ew.is.bt===2) console.log("Firmware does not support checksum. FWVer: ", FWVer); + return 1; + } + + if (ew.is.bt===2) console.log("Checksum verification"); + + let tCRC32View=new DataView(packet, packet.length-4, 4); + let tPckt=new Uint8Array(packet, 0, packet.length-4); + if (E.CRC32(tPckt) == tCRC32View.getUint32(0)) return 1; + else return 0; +} +// euc.isProxy=0; // euc.temp.liveParse = function (inc){ @@ -94,8 +111,12 @@ euc.temp.inpk = function(event) { if (euc.temp.tot.buffer.length < needBufLen) return; if (euc.temp.tot.buffer.length == needBufLen) { - euc.temp.liveParse(euc.temp.tot.buffer); if (ew.is.bt===2) console.log("Veteran: in: length:",euc.temp.tot.buffer.length," data :",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); + if (checksum(euc.temp.tot.buffer)) { + euc.temp.liveParse(euc.temp.tot.buffer); + } else { + if (ew.is.bt===2) console.log("Packet checksum error. Dropped."); + } } else if (ew.is.bt===2) console.log("Packet size error. Dropped."); euc.temp.tot=E.toUint8Array([0]); From b7b7227a01be6eb085ff577576e7c3c71635b516 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sat, 9 Dec 2023 10:41:50 +0300 Subject: [PATCH 18/45] Added Rotate screen app for P22B --- P8-testing/handler/handler_touch_816.js | 38 ++++++++- P8-testing/rotate/ChangeLog | 1 + P8-testing/rotate/README.md | 7 ++ P8-testing/rotate/icon.png | Bin 0 -> 8444 bytes P8-testing/rotate/rotate.js | 107 ++++++++++++++++++++++++ P8-testing/w_apps/w_apps.js | 12 ++- v2/apps.json | 17 +++- v2/init/init.js | 5 ++ v2/init/lcd_P8_16bit_rev.js | 5 +- 9 files changed, 179 insertions(+), 13 deletions(-) create mode 100644 P8-testing/rotate/ChangeLog create mode 100644 P8-testing/rotate/README.md create mode 100644 P8-testing/rotate/icon.png create mode 100644 P8-testing/rotate/rotate.js diff --git a/P8-testing/handler/handler_touch_816.js b/P8-testing/handler/handler_touch_816.js index ff4d54bc..c7d767da 100644 --- a/P8-testing/handler/handler_touch_816.js +++ b/P8-testing/handler/handler_touch_816.js @@ -7,12 +7,42 @@ ew.tid.TP=setWatch(function(s){ if (face.pageCurr>=0) { if (tp[1]== 0 && tp[3]==64) tp[1]=5; else if (ew.def.rstR==0xE5 && tp[1]== 12 ) tp[6]=tp[6]+25; - touchHandler[face.pageCurr](tp[1],tp[4],tp[6]); + let e = tp[1]; + let x = tp[4]; + let y = tp[6]; + switch (scr.rotate) { + case 1: + if (tp[1]==1) e = 4 + else if (tp[1]==2) e = 3; + else if (tp[1]==3||tp[1]==4) e = tp[1] - 2; + x = tp[6]; + y = 240 - tp[4]; + break; + case 2: + if (tp[1]==1||tp[1]==3) e = tp[1] + 1; + else if (tp[1]==2||tp[1]==4) e = tp[1] - 1; + x = 240 - tp[4]; + y = 240 - tp[6]; + break; + case 3: + if (tp[1]==1||tp[1]==2) e = tp[1] + 2; + else if (tp[1]==3) e = 2; + else if (tp[1]==4) e = 1; + x = 240 - tp[6]; + y = tp[4]; + break; + } + if (scr.mirror) { + x = 240 - x; + if (e==3) e = 4; + else if (e==4) e = 3; + } + touchHandler[face.pageCurr](e,x,y); }else if (tp[1]==1) { face.go(face.appCurr,0); }else if (tp[1]==5) { - if ( (getTime()|0) - ew.is.tpT < 1 ) + if ( (getTime()|0) - ew.is.tpT < 1 ) face.go(face.appCurr,0); else ew.is.tpT=getTime()|0; - } -},ew.pin.touch.INT,{repeat:true, edge:"rising"}); + } +},ew.pin.touch.INT,{repeat:true, edge:"rising"}); diff --git a/P8-testing/rotate/ChangeLog b/P8-testing/rotate/ChangeLog new file mode 100644 index 00000000..5560f00b --- /dev/null +++ b/P8-testing/rotate/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/P8-testing/rotate/README.md b/P8-testing/rotate/README.md new file mode 100644 index 00000000..6572232e --- /dev/null +++ b/P8-testing/rotate/README.md @@ -0,0 +1,7 @@ +# App Name + +Describe the app... + +## Usage + +Describe how to use it diff --git a/P8-testing/rotate/icon.png b/P8-testing/rotate/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..86087ebd23ab96ed5b23c6dd2a7e03941fa32a02 GIT binary patch literal 8444 zcmeHLXH-+$whkR>A|L`%LXjedBoInM?=?tOx`Y%6C4?l9fP#ofQRyg1QHmf%nkZ7F zBZ?>@2nYg#h!iV|6dN~y$K!eTymQ|f^#1;6$-QQGrBKAP(=31yVwZSRj^$#{mGeu?m-k z;ExcVuSxssn3rUGr`IP#s%PH;E@OI@E*uN;(!6GsBIF4H7=JsyA+{{>mF6eyyr`-p1RbR%X&IE+@?}O zrl~uL%2dHAd@-dvyN=bu4_G+I=F6QtcTMe*mj*b0d3|i8*A^UgNTe?IENR-D zy>w>>TV?n1omZVR_q5e?;^QAi*d-|*NnEY$_(oc3g}PjZes*)O6PNwuXB!*5#%+B7 z(vVUWs>S$SbdoJpMoX&wsA50fb%I0OabFQbugxLVb3-=n9_3}31w-y^w|w1iq@W)$ z=TcPP`(qF2KJIUq8MI=K+5KKbbm)#-x|@2>Y}x60qP>Q_B3E~b-}5WSmuQH7q1PWQ z0+yXEXNa=CFIv-f>m1xD$ah`vOUkZ1ZfgoH z7nN_|%G735U)PCAXJE`e+^tYmmltfq5puRo4xLw$FvP+uKS$|2a6`45Nz{m|GT|Nb zzB%73b10%v=P%Y@h%d>--MQCD{ zS65`-8;hoVp4WuC?nG(7jp*#j6zQ0^M}VeW6Z|hCp05CIbdMGjVwfd)4AmBKyb&4- zui}opxcuB@1fE?Ss88<76t{4r!>dHPW`22w%eFyjZS zo*Gi-mub&9RC{Zv(Xj?pj`-7IVTN)8Kzk~|@n%%}2|H-^NJAaQ!ayA2%7w+SMM<2j zz3v-6LzNC}$$**6i;NE=gL17FyO(l4vIhyBvFWDh%V#PHm>WG=uXH02b!fhhN~kGM zy$KJ;DR1(#Fy{4{&+a3(?!K-ilGCoYRki&U>PD~HjTDXYX@hSlc$1?K4s(CEO;L*S zEn2thS(RH6n@nUUx78nt4-y-$#l523lWeDjKNwD>x|*=}QpjZ!0m|;4T{9PWEV<6R z?=ow5;I_Lx1ifdIeXIadiz<_1<5%tUV?5sRJTCcxDn`qvqhj5IvjZ}>SkT9EV&vB0 z8j-V4IlY{l0Dhj|uixjQgzt|%9A{5C2ezIbXSyO^4SRSgM6<2OVQ2jcD)y8M@>`UP z{c1^jmT)LC!{^DMpug+g8(FWX{B^MGs`i{`Mb)?*9az)g?usq;cC})U1uP=VSu6;d zAd1G`Z0pY9LuZ}Tyiw!+x2^(XTMAzEFwXbx_J1z6(_`TdTdSLb`}s23@a{I5?iyd4 zX;Rz)LuM{@v4Y{N{%V7gIp*g+sA)6C7sCpXFGH?#o-s za;f0kSDaw-x}{X~grvt}_xaPAgLiORcNx0|_$?32mIW2f5BtBCQ#Xzq|0R8C3j z4VIZu^KrOjc}Ao2{S6tzi;UU=N8`yOdZ7qO;SNJzlLE`(DFYFevLqko9qFSy)9gx( z)eeiuBWC+)?B!M#J9ND-zj<30{XCM5Bbd3~kSmYJ^(tyn$n8CQ=nJh}u^8rVK(?Ts zoEnuY8O8tF-veFM-_-y-u}Tno|A=Ev#^Z?3J^(A%3(s}J{$A4k3Fj`0!?vBb#UjE_ z@MxsmXi2^yPW1L+XilJvHY&BOd)IS{$&G-$*Vxov)EagD?LLpL_jXcw?Sv;(S&+ z_AurV*wD{dFmLb4M`HcS=IHjb$_LIkO9v}tMoIH*1b1-?VuCz6g9ak~n<-a%d`N>DcqR?jl!%+c5#Y+i9 zWA?lTC97|XBroSMg3C%;Hl@{gXeO`VUE$)AVso6bV9H?ARlY$8Z*NnMU@CyGx5-A7 zb9}H_NjOid+hzDJb1%;ID@SJvuYc~!h4V+HwM|cx+mxM@B`M6DS)TW8gFZ0M5c*Zb zIk|-?`ypHmx?UAJGlEJ<^(?|d(V#mOm-)Cmmg1PZKxsyq--S-ebVQnK7jiW1Jx?QBqFu10euatB}a=&U^+cV~?-UoP}Q>=$ARZLmhj_ zfS1FP{bCuzU`U02t%zRuey`5R@}pEKHHTQrj1?!2-A=y{B2Yv%OVkm}1%AFV|2|~E z+#*MNdEe2g@}?^Bi}wN|JMBjg+KSGt*?L{9JbrkCc#22Kv)_Dw-h~AxJ&X9a_SBpO zBmDv+U4>T>_QS-B5z?|@j`zb2nJ}%C=dZ?u-m&(v)Hvs<_#J%_ukm2sZ@Ozhqm!$| zC|V9|>Q*4VKs>>p!rh>=BRtWwY@TWr{<5BH8fbFiD|(D(k0 z+p~6kpKfRljqrYVQybX(?U?n=Vw6{^zy2;%u}ki(E7JBv^zFqHpog3u(}gI$DB$E^ z+lSbxRT%L5)Pxn2<$2y$d=4(Hu{u28C-##`w$*VAUOndk*o0=9t4@Y1$P>e}E$0_I0s1 z&N2_hbYy*6lJhWsZpc5fkTDo5nD6%W!}D`i^3OAR70t&#bhNZeANky~b*)TW8UM6! zX_+U*bYWiXd&*czY3^9ez(B>=$v(+99vqd!9~!1y?$>cB`KFCdK2AJp`LQA2C*$T# z7h>kngx8C{%r`8bc}B|~o~&nZ=U5gz!ofnA@=@?hsvJyy)yCL0_Co&hmsHvE{WxPLjs8=cS zah+RRbIIhqOUt*GutF(NMd74YTn+Zp#3|tlHiJG9Zv5$ep*Ak@d9ci@O?pEX&3Sok z6L3eZo(p`GOGLjC(lgG-ckJ|JwIbIGD((H40YGti;LwmI zHF(ZrwX%^MAT>UeYX;M8bXzWY@Tsm>wHf7jww6f`-1zz3V;$2Zt~ _iB3At~v(^ zFDqmWmhL@15#*6wkjCS!`-(lj@X}Dy=QP5b-X=!am+uLHyh|eAseBhBeAm$9H;umv zb7v)pNy21n>qIoo)Sku5gbkJ2RVmDO=q(@RSS&xH^$C{yB^{MAH(6{2%2gZu7^h=65>}JSZOH*NOWWb7)=M^9Do<|;+0)qNOlcduRs~>D`p`O-h4PE@y zY`?tzz`iP5ei`ZXK;}#RDFcZWn^f+q?5O2p#kC;&~(1vvU(=8HqZnd&ZG%kGH#+8;kyXwyvSu=8udmzA7nPk6TKd5uf}r znbGtPkne%Z8iMlpGzJv&1wqr?cQ<+LGGW(-nPPFmm2wajL*`4%EV~?944cBFL8dmsftm zIW?TIz4S$?#Ih{wb%Sp7xsQV06>iuEM?dU|A%DK7Jc8$zJYjr5KZ>2jG2JF6LFf%a zLC}sOzPhxtF(TfLqrt-Sg_9nO2xesGced7}ezS6Nw=NS!=Z^*DB%$*B_V_#&o%`}6 zNJLKWy>R`2>vs#W%ypUO;ei5Ey=Q8~poxKW?I{wQ5KS3lA5sJaNnT=`d^n$dO>YC# z-~94ZMQGw68xYxSF$rLcZ8JM@Z6thB%=g{XR@DdJzX7!PNhuPRa~lA_&NF!Wn*%4L z6#^X?poGE%dSR7l0Yv(n1pq)xmqtXP{je0E7uFk3(3X1F)G7tUW3;6Xt0Eytq9N7? zZx%+v+J{*?pu_yoaEz3$4u=*EK_>{nQcyrzfIoqZplM5O@gnH=o84e3;1-19r!D1# zv;i6hlCVIS5=;pKGN$1}l%;eyfLbIB4q<0x@`Hlj(w6d}P>2XHm`bH8QB{-zN#0;6 z91aIVl)=i%AUXm>4kb`fG!TI-y-BgnVT2{4Nq8a!A4mXha-zHfgDKilQuJ})4|4h_ z+L%V~{NZ4;y+u!^V8G_|28=!*IsmK;foOmr${=Mp_*Z-SC=&V8nn3=cB3(}~4MhY) zl_21NfInD}DaIkc`}tfz$aH4tAMg}B z?)L@y!+bVJ{w)x?yPy1jK>w!KRxDe(B8&pj!JAIajkKjU<3(Ts(Rd7E>lUUCMXNy7 zVIYh$1PX$Ap)eo~EEWq=RmZ8R!{KTexQ6;KROSRS1w}w(H>v34N_aXCP89>kp*2)N zst_m+1XG2fK^n?%G)Tn@3xlcRU^pyV?H7uJBs{$mQ2xJ0wMm7cQ^8@XDr#QpP!LW7 zrVfIkab6%e1PcMduOzKyxIl(G`!_Z}O66a^PZ3ec9a!V`jN zzYjRz1F-fK)TU@qb%-(qrVLY2RZ)d#z?6Rn9m0~x^d#TpghG^*w?{B&gbAGyMNc+- z0LmK+CK9~2Og5JVL7xm=Skz{1(3!XT>2pCClCUUBAju&x&|h0>Ggjax`=iu;>&O2|8mpqQ7C zK%};p7pMi^+)#g;p4R4;gG3^J6+mlqOG21$W}ba8k?4=dlKv>nZ;A51;C`|Hk(B?* z{8!kvwP7GJlwPzxl!H{lU%LMj;5LI59*rfC1OF=YUm@GF{PNtP$GqJ~f1c4FkKmur z#~*1y7x};W`H^n_O&37mKTiIZzW>Pek6eFCfxiX*C%gWU>u)LWx4{2o*Z-Sb9KWBi zu>|@bJu3bD{50D33H|KNYGdVKO#j{3*eDvkG(o>(@Uk>D0>rV1nb8|Nh-S`Y0DzN! z^UDCp$`PV>vQf;D#%yz3?A(&-UlhH2>0RaKM*0pygV_FNZbm2<%M_JyLFBT385uD!iGwi@G#*h3;F zejjN_9h&X|>Y?Ui@@%^zt*@py)P5AS)_w3kVY2&cLVOl-;oQfBVb&B64F#t#@YMCf zk|*9pOi?GRZwtYoIVY$ocVlOypFK}t^G+-5RC7G1!}RS|^21MGtKPD(RSk^F?(%#_ P4;x@^Y;9C&;2HHV)>XA& literal 0 HcmV?d00001 diff --git a/P8-testing/rotate/rotate.js b/P8-testing/rotate/rotate.js new file mode 100644 index 00000000..906cb0b8 --- /dev/null +++ b/P8-testing/rotate/rotate.js @@ -0,0 +1,107 @@ +//rotate +face[0] = { + offms: 15000, + g:w.gfx, + init: function(){ + // Clear + this.g.setColor(0,0); + this.g.clear(); + this.g.flip(); + // Buttons + this.g.setColor(0,4); + this.g.fillRect(0,40,239,158); + this.g.setColor(1,15); + let img = require("heatshrink").decompress(atob("olUwIGDh//Bwsf///wEAjwPDAAMAgfwgEHA4X+gE/gEBA4X//AQCv4ID8AQBEAILBBAIQBgYHCBAP8CAN//AHBEoPj+EfFwIABGwO/DAJIBJ4fwv/gLAY3Bg4gCEQYQBNIhABgYYEDIPwjgGDNISCFA4JRCDQSCCH4XACAo2BBAIQEn4ICJYIeBLwIICAAYQBNAgQDBAt+E4QIDg/gZgQQDvjVDOIYwBBAP8BAQDCBAJhDIIU/VwaZDn4QCj43DDoUBCAYdDj4/DCAaSCCAIdCc4IuFfALcDCAU+aYYQCNoIQDPwaLDDoQQEFwZ+BCApPDFwiCDg4QHv5DCNocHAgR+ECAR+FCAZtDZgR+FCAR+EZYR+FXwZ+HKgYuDv4ICPwn/Fw0/BAQuE/4ICPwYIDTgkBBAPwVoYID/6LDBAZHDIIQQDIQP+BAQQCE4QICQwMPBAIaCK4QQDDwKSCCAZSFKAcAnEPGIIADg/AEAYAC/whBaYaZB8BLCDAYQCbgZoB4H9GQl//EP44iDj4eB/ipBKIfAh48BBAIHBIAP8QAIACDAIQBj4IDEoKKBv4HCGwIQBOARhDvCxDJ4aCDOIYA==")); + this.g.drawImage(img,27,57); + img = require("heatshrink").decompress(atob("rk0wIMJv//8AKHh///84BY4KB+/ACxP+CxP/+AKGg4LCwBFI+/8IpM/KI8B//x/4WHn//h/4HJHwv5cH/+/gZcHj/z+EfLgwTBn4ZBLg1/4fwg5cGIIIWBLgxaBgfwAYJaG8AWBLgwpBCwIxBLgpABjxICLQpXDLgoRFLgooELgo/FLghWFAoptFDgiEGGYg+FJQiyGAwbJHDoaDGGgb3HJYSxHA4bIGDwbfHGob2HJgRaGLgZaHLgZaGLgZaHJoXhLQxcDLQ5cC/5aHLgRaHLgX/LQ5cCLQs//4AI44KJ/w0BABHnCyvjBRP8A=")) + this.g.drawImage(img,134,73); + this.g.flip(); + // Remove garbage + this.g.setColor(0,0); + this.g.fillRect(0,0,239,39); + this.g.flip(); + this.g.fillRect(0,159,239,239); + this.g.flip(); + this.g.fillRect(119,40,120,158); + this.g.flip(); + // Header + this.g.setColor(1,15); + this.g.setFont("Vector",25); + this.g.drawString("ROTATE MIRROR",3,10); + this.g.flip(); +//side + this.run=true; + this.disp=-1; + this.key=-1; + }, + show : function(){ + if (!this.run) return; + //loop + this.tid=setTimeout(function(t,o){ + t.tid=-1; + t.show(o); + },100,this); + }, + tid:-1, + run:false, + clear : function(o){ + this.run=false; + if (this.tid>=0) clearTimeout(this.tid); + this.tid=-1; + return true; + }, + rotate: function(){ + if (scr.rotate==3) scr.rotate=0; + else scr.rotate++; + w.gfx.setRotation(scr.rotate, scr.mirror); face[0].init(); + }, + mirror: function(){ + if (scr.mirror==true) scr.mirror=false; + else scr.mirror=true; + w.gfx.setRotation(scr.rotate, scr.mirror); face[0].init(); + }, + off: function(o){ + this.g.off(); + this.clear(o); + } +}; +face[1] = { + offms:1000, + init: function(){ + return true; + }, + show : function(){ + face.go("clock",0); + return true; + }, + clear: function(){ + return true; + } +}; +//touch +touchHandler[0]=function(e,x,y){ + // var va; + //short press + if (e==5){ + if (x<119 && 39160&&x<50) { + if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} + else w.gfx.bri.set(this.bri); + buzzer.nav([30,50,30]); + } else + require('Storage').writeJSON('scrorient.json', scr); + face.go("settings",0);return; + } + this.timeout(); +}; diff --git a/P8-testing/w_apps/w_apps.js b/P8-testing/w_apps/w_apps.js index 23de6f9f..a7a4e4c6 100644 --- a/P8-testing/w_apps/w_apps.js +++ b/P8-testing/w_apps/w_apps.js @@ -20,9 +20,13 @@ g.fillRect(80,0,155,75); g.setColor(0,15); if (require("Storage").read("repellent",1)) { this.appDo2="face.go('repellent',0)"; - this.img=E.toArrayBuffer(atob("MDCBAAAAAAAAAAAB//gAAAAH//8AAABH///AAAPP///wAAPP///4AAeOAAf8AAeAAAH+AAeADgB/AAcB/+A/gAwP//wfwAA///4PwAB///8H4AD/4f/D8AH+AD/D8AP8AA/h8APwAAfx+Afgf4Pw+AfB/+H4+A/D//D4/A+H//j4fA+H8/j4fB8PwPj4fB8PgPj4fB8PgPj4fB8fg/j4fB8fA/j4fB8fAfD4fB8fgeH4fB8PgIHw+B8PgAPw+B8PwAfx+B+H4A/h+A+H+D/D8A/D//+D4AfB//8H4Afg//4PwAPwP/gfwAP4B8B/gAH+AAD/AAD/gAf+AAB//P/8AAA////wAAAP///AAAAD//8AAAAA//gAAAAAAAAAAAAAAAAAAA==")); + this.img = E.toArrayBuffer(atob("MDCBAAAAAAAAAAAB//gAAAAH//8AAABH///AAAPP///wAAPP///4AAeOAAf8AAeAAAH+AAeADgB/AAcB/+A/gAwP//wfwAA///4PwAB///8H4AD/4f/D8AH+AD/D8AP8AA/h8APwAAfx+Afgf4Pw+AfB/+H4+A/D//D4/A+H//j4fA+H8/j4fB8PwPj4fB8PgPj4fB8PgPj4fB8fg/j4fB8fA/j4fB8fAfD4fB8fgeH4fB8PgIHw+B8PgAPw+B8PwAfx+B+H4A/h+A+H+D/D8A/D//+D4AfB//8H4Afg//4PwAPwP/gfwAP4B8B/gAH+AAD/AAD/gAf+AAB//P/8AAA////wAAAP///AAAAD//8AAAAA//gAAAAAAAAAAAAAAAAAAA==")); g.drawImage(this.img,94,15); -}else g.drawImage(this.appImgNone,94,15); +} else if (require("Storage").read("rotate",1)) { + this.appDo2="face.go('rotate',0)"; + this.img = E.toArrayBuffer(atob("MDCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAH/gAAAAA//8CAAAD///DAAAP8A/zgAAfgAH7gAA+AAB/gAB4AAAfgAAwAAAPgAAAcAH/gAAA/wD/gAAB/+B/gAAB//4AAAAB///gAAAB4f/wAAAD4B/4AAADwAP4AAADwAD4AAADwADwAAAHgADwAAAHgADwAAAHgAHwAAAPgAHgAAAPAAHwAAAPAAH4AAAPAAP4AAAfAAPwAAAfwAPAAAAf+AfAAAAP/4eAAAAH//+AAAAAf/+AAAH8B/+AAAH+AP8AAAH/AA4AAAHwAAAMAAH4AAAeAAH+AAB8AAHfgAH4AADP8A/wAABD///AAAAA//8AAAAAH/gAAAAAAAAAAAAAAAAAAAAAAAAAAA==")); + g.drawImage(this.img,94,15); +} else g.drawImage(this.appImgNone,94,15); g.flip(); //app3 g.setColor(1,1); @@ -54,7 +58,7 @@ g.fillRect(80,80,155,155); g.setColor(0,15); if (require("Storage").read("ledBT",1)) { this.appDo5="face.go('ledBT',0)"; - img = require("heatshrink").decompress(atob("mU1wIrov/gAodwhwFDmEABgcYgEMAoUIgEBwAFBg0H8AUBgEDgMcggSCwFDCQdgjeAkAFBiEH4AhBgEEgMwgYFBgMAo0AoAGBoEQ4EQDAQpBFYQCCCoI3B/kA//AgEH4Pg+E4BYMQhlgh+AgOCgPggRRBwGAnEBwxJBiB1BoHAmEGgnAkEQJgPDiEYgUGPgOGPgK8BgfgxiMBoEYnE+JAMwj+H/kfwMMhkxgYKBoRsBoHBxBmBwEQmF+BoMj4kMjPBggYBgQKBoMDxlgwOMiFAv0IsF+hhKBNYMAgSXCpjCCS4MaBAPAaQMDXINgCQTfBPgIBB5zjCg4LB8EcfwcPUgIAfA=")); + this.img = require("heatshrink").decompress(atob("mU1wIrov/gAodwhwFDmEABgcYgEMAoUIgEBwAFBg0H8AUBgEDgMcggSCwFDCQdgjeAkAFBiEH4AhBgEEgMwgYFBgMAo0AoAGBoEQ4EQDAQpBFYQCCCoI3B/kA//AgEH4Pg+E4BYMQhlgh+AgOCgPggRRBwGAnEBwxJBiB1BoHAmEGgnAkEQJgPDiEYgUGPgOGPgK8BgfgxiMBoEYnE+JAMwj+H/kfwMMhkxgYKBoRsBoHBxBmBwEQmF+BoMj4kMjPBggYBgQKBoMDxlgwOMiFAv0IsF+hhKBNYMAgSXCpjCCS4MaBAPAaQMDXINgCQTfBPgIBB5zjCg4LB8EcfwcPUgIAfA=")); g.drawImage(this.img,94,94); }else g.drawImage(this.appImgNone,94,94); g.flip(); @@ -70,4 +74,4 @@ if (require("Storage").read("w_testTP",1)) { g.flip(); this.img=0; -this.appImgNone=-1; \ No newline at end of file +this.appImgNone=-1; diff --git a/v2/apps.json b/v2/apps.json index 8dbacee1..3b2b3e60 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -59,7 +59,7 @@ { "id": "init", "name": "Init - P22 B1-D", "icon": "../init/icon.png", - "version":"1.94.4", + "version":"1.94.5", "description": "Screen driver and init functions. For use with the Espruino image build by fanoush. ", "tags": "core", "needsFeatures":["P22B"], @@ -145,7 +145,7 @@ { "id": "handler", "name": "Handler - V1", "icon": "../handler/icon.png", - "version":"1.94.8", + "version":"1.94.9", "description": "P8-P22-Pinetime functions handler", "tags": "core", "needsFeatures":["V1"], @@ -231,6 +231,17 @@ {"name":"calc","url":"../../P8-testing/calc/calc.js"} ] }, + { "id": "rotate", + "name": "Screen rotate", + "icon": "../../P8-testing/rotate/icon.png", + "version":"1.0.0", + "description": "Rotate and mirror screen", + "tags": "apps", + "needsFeatures":["P22B"], + "storage": [ + {"name":"rotate","url":"../../P8-testing/rotate/rotate.js"} + ] + }, { "id": "notify", "name": "Notifications", "icon": "../../P8-testing/notify/icon.png", @@ -491,7 +502,7 @@ { "id": "w_apps", "name": "App Loader", "icon": "../../P8-testing/w_apps/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "Extends settings face with an app drawer.", "tags": "system", "type": "system", diff --git a/v2/init/init.js b/v2/init/init.js index d763f390..0dc62d8e 100644 --- a/v2/init/init.js +++ b/v2/init/init.js @@ -72,6 +72,11 @@ if ((BTN1.read() || require("Storage").read("devmode")) && process.env.BOARD != } else { //working mode var w; + global.scr = require('Storage').readJSON('scrorient.json', 1); + if (typeof scr === 'undefined') { + scr = { "rotate": 0, "mirror": false }; + require('Storage').writeJSON('scrorient.json', scr); + } if (require('Storage').read('.display')) { if (require('Storage').read('.displayM')&&(process.env.BOARD == "MAGIC3"||process.env.BOARD == "ROCK")) eval(require('Storage').read('.displayM')); diff --git a/v2/init/lcd_P8_16bit_rev.js b/v2/init/lcd_P8_16bit_rev.js index b6efa22e..1d395a66 100644 --- a/v2/init/lcd_P8_16bit_rev.js +++ b/v2/init/lcd_P8_16bit_rev.js @@ -22,7 +22,7 @@ var SPI2 = (function(){ // this method would produce code string that can replace bin declaration above with heatshrink compressed variant // however it seems the gain is very small so is not worth it // shrink:function(){return `var bin=E.toString(require("heatshrink").decompress(atob("${btoa(require("heatshrink").compress(bin))}")))`;} -//*/ +// CS=D25;DC=D18;RST=D26;BL=D14; SCK=D2;MOSI=D3; RST.reset(); @@ -94,6 +94,7 @@ function init(){ //var bpp=(require("Storage").read("ew.json") && require("Storage").readJSON("ew.json").bpp)?require("Storage").readJSON("ew.json").bpp:1; var bpp=1; var g=Graphics.createArrayBuffer(240,240,bpp); +g.setRotation(scr.rotate, scr.mirror); var pal; g.sc=g.setColor; // 16bit RGB565 //0=black,1=dgray,2=gray,3=lgray,4=raf,5=raf1,6=raf2,7=red,8=blue,9=purple,10=?,11=green,12=olive,13=yellow,14=lblue,15=white @@ -212,4 +213,4 @@ module.exports = { batt: batt, gfx: g }; -}); \ No newline at end of file +}); From 56c6e21011d800024d60fc82afbcbca036860d5c Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 11 Dec 2023 16:58:19 +0300 Subject: [PATCH 19/45] Added max PWM --- P8-testing/dash/dash_digital.js | 24 ++++++++++++++++++------ v2/apps.json | 6 +++--- v2/euc/eucKingsong/eucKingsong.js | 15 +++++---------- v2/euc/eucVeteran/eucVeteran.js | 1 + 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/P8-testing/dash/dash_digital.js b/P8-testing/dash/dash_digital.js index 326ba1d8..fc4a37e5 100644 --- a/P8-testing/dash/dash_digital.js +++ b/P8-testing/dash/dash_digital.js @@ -18,6 +18,7 @@ face[0] = { this.spd=euc.dash.live.spd-1; this.aTlt=-1; this.topS=-1; + this.topP=-1; this.amp=-10; this.tmp=-1; this.pwm=-1; @@ -48,9 +49,10 @@ face[0] = { if (euc.log.almL.includes(1)) { this.alF(); this.bar=0; - } else if (5<=this.spd && (euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran")){ + } else if (5<=this.spd&& euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran"){ if (this.pwm!=euc.dash.live.pwm) {this.pwm=euc.dash.live.pwm; this.pwmF();} - } else if (!this.bar) { this.bar=1; this.barF();} + if (this.topP!=euc.dash.trip.pwm) {this.topP=euc.dash.trip.pwm; this.pwmMF();} + } else if (!this.bar) { this.topP=-1; this.bar=1; this.barF();} //tmp/amp block if (!ew.def.dash.amp) { if (this.amp!=Math.round(euc.dash.live.amp)) this.ampF(); @@ -126,6 +128,7 @@ face[0] = { this.g.drawString(Math.round(this.spd*this.fact),129-(this.g.stringWidth(Math.round(this.spd*this.fact))/2),(100 <= this.spd)?75:57); this.g.flip(); if (this.spd==0) { + this.topP=-1; this.bar=1; this.barF(); } @@ -142,14 +145,23 @@ face[0] = { pwmF: function(){ "ram"; this.g.setColor(0,euc.dash.alrt.pwm.hapt.hi<=euc.dash.live.pwm?13:1); - this.g.fillRect(0,176,239,200); + this.g.fillRect(0,176,191,200); this.g.setColor(1,50<=euc.dash.live.pwm?14:15); this.g.setFontVector(23); - this.g.drawString(euc.dash.live.pwm,3,175); + this.g.drawString(euc.dash.live.pwm,44-this.g.stringWidth(euc.dash.live.pwm),178); this.g.setFontVector(14); this.g.drawString("%",45,178); - this.g.fillRect(80,180,80+euc.dash.live.pwm*1.6,187); - w.gfx.flip(); + this.g.fillRect(59,180,59+euc.dash.live.pwm*1.32,187); + this.g.flip(); + }, + pwmMF: function(){ + this.g.setColor(0,euc.dash.alrt.pwm.hapt.hi<=euc.dash.trip.pwm?13:1); + this.g.fillRect(192,176,239,200); + this.g.setFontVector(23); + this.g.setColor(1,50<=euc.dash.trip.pwm?14:15); + this.g.setFontVector(23); + this.g.drawString(euc.dash.trip.pwm,239-this.g.stringWidth(euc.dash.trip.pwm),178); + this.g.flip(); }, ampF: function(){ this.amp=Math.round(euc.dash.live.amp); diff --git a/v2/apps.json b/v2/apps.json index 3b2b3e60..c2e99bce 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -286,7 +286,7 @@ { "id": "Dashboard Digital", "name": "EUC digital Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.5", + "version":"1.94.6", "description": "EUC simple digital", "tags": "euc", "needsFeatures":["V1"], @@ -755,7 +755,7 @@ { "id": "eucKingsong", "name": "Kingsong module", "icon": "../../v2/euc/eucKingsong/icon.png", - "version":"1.94.8", + "version":"1.94.9", "description": "EUC module for Kingsong.", "tags": "euc", "type": "euc", @@ -854,7 +854,7 @@ { "id": "eucVeteran", "name": "Veteran module", "icon": "../../v2/euc/eucVeteran/icon.png", - "version":"2.1.0", + "version":"2.1.1", "description": "EUC module for Veteran Sherman", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucKingsong/eucKingsong.js b/v2/euc/eucKingsong/eucKingsong.js index ef1d71ab..a752bf33 100644 --- a/v2/euc/eucKingsong/eucKingsong.js +++ b/v2/euc/eucKingsong/eucKingsong.js @@ -234,7 +234,7 @@ euc.temp.one = function(inpk) { euc.log.trip.forEach(function(val, pos) { if (!val) euc.log.trip[pos] = euc.dash.trip.totl; }); //mode euc.dash.opt.ride.mode = inpk[14]; - //City lights + //City lights if (euc.dash.opt.lght.city && euc.dash.live.spd) { euc.temp.city(); } @@ -432,7 +432,8 @@ euc.conn = function(mac) { euc.gatt.disconnect(); return; } - //connect + //connect + euc.dash.trip.pwm = 0; NRF.connect(mac, { minInterval: 7.5, maxInterval: 15 }) .then(function(g) { euc.gatt=g; @@ -445,26 +446,21 @@ euc.conn = function(mac) { return c; }).then(function(c) { if (euc.dbg) console.log("EUC module Kingsong connected"); - euc.lala= function(n,v){ euc.buff.push([n,v]) }; euc.test=()=>{ - if (euc.buff[0]){ euc.do(euc.buff[0][0],euc.buff[0][1]) euc.buff.shift(); - } + } if (euc.status!="OFF"){ euc.tout.buffer=setTimeout(()=>{ euc.test(); },500); } - }; //euc.test(); - - euc.wri = function(n, v) { if (euc.tout.busy) { clearTimeout(euc.tout.busy); @@ -473,7 +469,7 @@ euc.conn = function(mac) { } euc.tout.busy = setTimeout(() => { euc.tout.busy = 0; }, 100); if (n === "proxy") { - c.writeValue(v).then(function() { + c.writeValue(v).then(function() { }).catch(euc.off); } @@ -527,7 +523,6 @@ euc.conn = function(mac) { } }).then(function() { euc.is.run = 1; - if (2 < euc.dbg) print("EUC module start: passstate:", euc.temp.pass); if (euc.temp.pass) { euc.dash.opt.lock.pass2 = euc.dash.opt.lock.pass; diff --git a/v2/euc/eucVeteran/eucVeteran.js b/v2/euc/eucVeteran/eucVeteran.js index b9e4ac8f..aa4c6cd9 100644 --- a/v2/euc/eucVeteran/eucVeteran.js +++ b/v2/euc/eucVeteran/eucVeteran.js @@ -125,6 +125,7 @@ euc.temp.inpk = function(event) { //start euc.wri=function(i) {if (ew.def.cli) console.log("not connected yet"); if (i=="end") euc.off(); return;}; euc.conn=function(mac){ + euc.dash.trip.pwm=0; //check if ( euc.gatt!="undefined") { if (ew.def.cli) print("ble allready connected"); From 0a9dd178ff3f86bf8fa1a3b2ae3988f2dcc0b40a Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Tue, 2 Jan 2024 15:10:17 +0300 Subject: [PATCH 20/45] Added show all PWM bar if max PWM over 50 --- P8-testing/dash/dash_digital.js | 4 ++-- v2/apps.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/P8-testing/dash/dash_digital.js b/P8-testing/dash/dash_digital.js index fc4a37e5..5b525a5f 100644 --- a/P8-testing/dash/dash_digital.js +++ b/P8-testing/dash/dash_digital.js @@ -49,7 +49,7 @@ face[0] = { if (euc.log.almL.includes(1)) { this.alF(); this.bar=0; - } else if (5<=this.spd&& euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran"){ + } else if ((5<=this.spd || 50<=this.topP) && euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran"){ if (this.pwm!=euc.dash.live.pwm) {this.pwm=euc.dash.live.pwm; this.pwmF();} if (this.topP!=euc.dash.trip.pwm) {this.topP=euc.dash.trip.pwm; this.pwmMF();} } else if (!this.bar) { this.topP=-1; this.bar=1; this.barF();} @@ -127,7 +127,7 @@ face[0] = { else this.g.setFontVector(130); this.g.drawString(Math.round(this.spd*this.fact),129-(this.g.stringWidth(Math.round(this.spd*this.fact))/2),(100 <= this.spd)?75:57); this.g.flip(); - if (this.spd==0) { + if (this.spd==0 && this.topP<50) { this.topP=-1; this.bar=1; this.barF(); diff --git a/v2/apps.json b/v2/apps.json index c2e99bce..462f79a7 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -286,7 +286,7 @@ { "id": "Dashboard Digital", "name": "EUC digital Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.6", + "version":"1.94.7", "description": "EUC simple digital", "tags": "euc", "needsFeatures":["V1"], From 28aa4698b13a5be5b2af3a0e6caf68aeb22d7918 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sat, 20 Jan 2024 14:33:41 +0300 Subject: [PATCH 21/45] Added module for new Inmotion's and unification of calculating the percentage of charge of unicycles * Created a new common module for the new Inmotion unicycles (V11/V12/V13). This is an alpha version for now. Looking for people/unicycles for debugging. * Changed the unicycle battery voltage storage format. Now I store the number of battery cells connected in series. Also, I unified the formula for calculating the percentage of charge. * Fixed temperature display for the latest revisions of Inmotion V8F and V8S --- P8-testing/dash/dashOptions.js | 31 +- P8-testing/dash/dashScan.js | 86 ++-- v2/apps.json | 34 +- v2/euc/eucBegode/eucBegode.js | 83 ++-- v2/euc/eucInmotionV10/eucInmotionV10.js | 14 +- v2/euc/eucInmotionV11/eucInmotionV11.js | 58 ++- v2/euc/eucInmotionV11/eucInmotionV11old.js | 8 +- v2/euc/eucInmotionV12/eucInmotionV12.js | 16 +- v2/euc/eucInmotionV2/ChangeLog | 1 + v2/euc/eucInmotionV2/README.md | 7 + v2/euc/eucInmotionV2/eucInmotionV2.js | 493 +++++++++++++++++++++ v2/euc/eucInmotionV2/icon.png | Bin 0 -> 7940 bytes v2/euc/eucInmotionV2/proxyInmotionV2.js | 86 ++++ v2/euc/eucKingsong/eucKingsong.js | 4 +- v2/euc/eucNinebotE/eucNinebotE.js | 56 +-- v2/euc/eucNinebotS/eucNinebotS.js | 54 +-- v2/euc/eucNinebotZ/eucNinebotZ.js | 48 +- v2/euc/eucVeteran/eucVeteran.js | 4 +- 18 files changed, 846 insertions(+), 237 deletions(-) create mode 100644 v2/euc/eucInmotionV2/ChangeLog create mode 100644 v2/euc/eucInmotionV2/README.md create mode 100644 v2/euc/eucInmotionV2/eucInmotionV2.js create mode 100644 v2/euc/eucInmotionV2/icon.png create mode 100644 v2/euc/eucInmotionV2/proxyInmotionV2.js diff --git a/P8-testing/dash/dashOptions.js b/P8-testing/dash/dashOptions.js index e34eb7cb..88e697a6 100644 --- a/P8-testing/dash/dashOptions.js +++ b/P8-testing/dash/dashOptions.js @@ -53,6 +53,13 @@ face[0] = { this.g.flip(); }, ntfy: function(txt0,txt1,size,bt,clr,tm,s){ + // txt0 - title + // txt1 - value + // size - font size for value + // bt - ??? + // clr - background color + // tm - timeout + // s - show arrows if (this.ntid) {clearTimeout(this.ntid); this.ntid=0;} this.g.setColor(0,clr); this.g.fillRect(0,160,239,239); @@ -87,7 +94,7 @@ face[0] = { t.g.flip(); t.g.setColor(1,(t.page)?15:2); t.g.fillRect(120,180,165,184); - t.g.flip(); + t.g.flip(); },tm,this); }, tid:-1, @@ -184,6 +191,14 @@ touchHandler[0]=function(e,x,y){ } face[0].btn(1,"EMPTY",15,40,90,12,0,0,80,75,155,euc.dash.opt.bat.low/100,30,40,120); //4 face[0].ntfy("0% WHEN CELL IS AT",euc.dash.opt.bat.low/100 + " Volt",30,1,12,3000,1); + }else if (face[0].set=="batP") { //bat + if (x<120){ // + euc.dash.opt.bat.pack--; if (euc.dash.opt.bat.pack < 1) euc.dash.opt.bat.pack = 1; + }else{ //back + euc.dash.opt.bat.pack++; if (99 < euc.dash.opt.bat.pack) euc.dash.opt.bat.pack = 99; + } + face[0].btn(1,"PACK",15,200,90,4,0,160,80,239,155,"S" + euc.dash.opt.bat.pack.toString(10),30,200,120); //6 + face[0].ntfy("BATTERY VOLTAGE",euc.dash.opt.bat.pack*4.2,40,1,4,3000,1); }else { buzzer.nav(40); face[0].set=0; @@ -243,13 +258,9 @@ touchHandler[0]=function(e,x,y){ }else if (75<= x && x < 155 && 75 =0) clearTimeout(this.tid); this.tid=-1; @@ -124,12 +127,11 @@ face[1] = { off: function(){ this.clear(); } -}; -touchHandler[0]=function(e,x,y){ +}; +touchHandler[0]=function(e,x,y){ this.timeout(); switch (e) { case 5: case 12: //tap event//long press event - if(0200&&x<50) { //toggles full/current brightness on a left down corner swipe up. + if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up. if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);} else w.gfx.bri.set(this.bri); buzzer.nav([30,50,30]); - - }else {face.go("settings",0);return;} - + }else {face.go("settings",0);return;} break; case 3: //slide left event - if ( face[0].set < 4 ) { + if ( face[0].set < 5 ) { if (face[0].ntid) clearTimeout(face[0].ntid); face[0].ntid=0; face[0].set ++ ; face[0].page(face[0].set); - }else buzzer.nav(40); - + }else buzzer.nav(40); break; case 4: //slide right event (back action) if ( 1 < face[0].set ) { if (face[0].ntid) clearTimeout(face[0].ntid); face[0].ntid=0; face[0].set -- ; - face[0].page(face[0].set); - + face[0].page(face[0].set); } else { face.go("dashGarage",0); return; @@ -239,5 +245,3 @@ touchHandler[0]=function(e,x,y){ break; } }; - - diff --git a/v2/apps.json b/v2/apps.json index 462f79a7..ca2acf44 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -270,7 +270,7 @@ { "id": "dash", "name": "EUC Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.3", + "version":"1.94.5", "description": "EUC dashboard. Garage, scan and dash faces. Depends on EUC modules.", "tags": "euc", "needsFeatures":["V1"], @@ -755,7 +755,7 @@ { "id": "eucKingsong", "name": "Kingsong module", "icon": "../../v2/euc/eucKingsong/icon.png", - "version":"1.94.9", + "version":"1.94.10", "description": "EUC module for Kingsong.", "tags": "euc", "type": "euc", @@ -768,7 +768,7 @@ { "id": "eucNinebotE", "name": "Ninebot module", "icon": "../../v2/euc/eucNinebotE/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "EUC module for Ninebot C/E/P.", "tags": "euc", "type": "euc", @@ -781,7 +781,7 @@ { "id": "eucNinebotZ", "name": "NinebotZ module", "icon": "../../v2/euc/eucNinebotZ/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "EUC module for Ninebot Z6/Z10", "tags": "euc", "type": "euc", @@ -793,7 +793,7 @@ { "id": "eucNinebotS", "name": "Ninebot S2/A1 module", "icon": "../../v2/euc/eucNinebotS/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "EUC module for Ninebot S2/A1", "tags": "euc", "type": "euc", @@ -805,7 +805,7 @@ { "id": "eucInmotionV10", "name": "Inmotion V5/8/10 module", "icon": "../../v2/euc/eucInmotionV10/icon.png", - "version":"1.94.7", + "version":"1.94.9", "description": "EUC module for Inmotion V5/8/10.", "tags": "euc", "type": "euc", @@ -818,7 +818,7 @@ { "id": "eucInmotionV11", "name": "Inmotion V11 module, V1.4 and later", "icon": "../../v2/euc/eucInmotionV11/icon.png", - "version":"1.94.5", + "version":"1.94.8", "description": "EUC module for Inmotion V11 (fimware version > 1.4).", "tags": "euc", "type": "euc", @@ -830,7 +830,7 @@ { "id": "eucInmotionV11-old", "name": "Inmotion V11 module, old", "icon": "../../v2/euc/eucInmotionV11/icon.png", - "version":"1.94.1", + "version":"1.94.2", "description": "EUC module for *old* Inmotion V11 (fimware version < 1.4).", "tags": "euc", "type": "euc", @@ -842,7 +842,7 @@ { "id": "eucInmotionV12", "name": "Inmotion V12 module", "icon": "../../v2/euc/eucInmotionV12/icon.png", - "version":"1.94.2", + "version":"1.94.3", "description": "EUC module for Inmotion V12.", "tags": "euc", "type": "euc", @@ -851,10 +851,22 @@ {"name":"eucInmotionV12","url":"../../v2/euc/eucInmotionV12/eucInmotionV12.js"} ] }, + { "id": "eucInmotionV2", + "name": "Inmotion V2 (V11/12/13)", + "icon": "../../v2/euc/eucInmotionV2/icon.png", + "version":"0.2", + "description": "EUC module for Inmotion V2. TEST", + "tags": "euc", + "type": "euc", + "needsFeatures":["EW"], + "storage": [ + {"name":"eucInmotionV2","url":"../../v2/euc/eucInmotionV2/eucInmotionV2.js"} + ] + }, { "id": "eucVeteran", "name": "Veteran module", "icon": "../../v2/euc/eucVeteran/icon.png", - "version":"2.1.1", + "version":"2.1.2", "description": "EUC module for Veteran Sherman", "tags": "euc", "type": "euc", @@ -867,7 +879,7 @@ { "id": "eucBegode", "name": "Begode module", "icon": "../../v2/euc/eucBegode/icon.png", - "version":"1.94.6", + "version":"1.94.7", "description": "EUC module for Begode (Gotway)", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucBegode/eucBegode.js b/v2/euc/eucBegode/eucBegode.js index a924a7b8..f8896d3b 100644 --- a/v2/euc/eucBegode/eucBegode.js +++ b/v2/euc/eucBegode/eucBegode.js @@ -1,4 +1,4 @@ -//Begode euc module - based on code from Freetyl3r's euc dash. +//Begode euc module - based on code from Freetyl3r's euc dash. E.setFlags({ pretokenise: 1 }); euc.cmd=function(cmd, param) { if (cmd=='extendedPacket') { @@ -12,14 +12,14 @@ euc.cmd=function(cmd, param) { case 'mainPacket': return [44]; case 'extendedPacket': return [107]; case 'fetchModel': return [78]; - case 'fetchFirmware': return [86]; + case 'fetchFirmware': return [86]; case 'fetchGreet': return [103]; case 'beep': return [98]; case 'lightsOn': return [81]; case 'lightsOff': return [69]; case 'lightsStrobe': return [84]; case 'alertsTwo': return [117]; - case "alertsOneTwo": return [111]; + case "alertsOneTwo": return [111]; case 'alertsOff': return [105]; case 'alertsTiltback': return [73]; case 'pedalSoft': return [115]; @@ -78,7 +78,7 @@ euc.temp.hapt=function(){ //haptic if (euc.dash.alrt.pwm.hapt.en && (euc.dash.alrt.warn.code || euc.dash.alrt.pwm.hapt.hi<=euc.dash.live.pwm)){ buzzer.sys(80); - }else if (!euc.is.buzz && euc.is.alert) { + }else if (!euc.is.buzz && euc.is.alert) { if (!w.gfx.isOn&&(euc.dash.alrt.spd.cc||euc.dash.alrt.amp.cc||euc.dash.alrt.warn.code)) face.go(ew.is.dash[ew.def.dash.face],0); //else face.off(6000); euc.is.buzz=1; @@ -92,13 +92,12 @@ euc.temp.hapt=function(){ for (i = 0; i < euc.is.alert ; i++) { a.push(200,150); } - buzzer.euc(a); + buzzer.euc(a); setTimeout(() => { euc.is.buzz = 0; }, 3000); - } - + } }; euc.temp.line=""; -euc.temp.extd= function(event) { +euc.temp.extd= function(event) { //if (ew.is.bt==5) euc.proxy.w(event.target.value.buffer); if (euc.dbg) console.log("input on ext",event.target.value.buffer); let fragment = E.toString(event.target.value.buffer); @@ -124,12 +123,12 @@ euc.temp.extd= function(event) { //spd let spdIndex = keys.indexOf('M/s'); if (spdIndex != -1) - euc.dash.live.spd = Math.abs((values[spdIndex] * 3.6)/1000); - //volt + euc.dash.live.spd = Math.abs((values[spdIndex] * 3.6)/1000); + //volt let voltIndex = keys.indexOf('Voltage'); if (voltIndex != -1){ - euc.dash.live.volt =Math.abs(values[voltIndex] / 100); - euc.dash.live.bat=Math.round( 100*(euc.dash.live.volt*( 100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); + euc.dash.live.volt =Math.abs(values[voltIndex] / 100); + euc.dash.live.bat=Math.round( 100*(euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); } //keys.forEach((key, i) => print(key+"="+values[i])); euc.temp.line = fragment.slice(lineEnd + 1); @@ -144,24 +143,24 @@ euc.temp.main=function(event){ let endP = part.findIndex((el, idx, arr) => {return arr[idx] == 90 && arr[idx + 1] == 90 && arr[idx + 2] == 90 && arr[idx + 3] == 90;}); //format packet if (startP!=-1) { - if (endP!=-1) - euc.temp.type(new DataView(E.toUint8Array(euc.temp.last,part.slice(0,endP+4)).buffer)); + if (endP!=-1) + euc.temp.type(new DataView(E.toUint8Array(euc.temp.last,part.slice(0,endP+4)).buffer)); euc.temp.last=part.slice(startP,part.length); } else if (endP!=-1) { euc.temp.type(new DataView(E.toUint8Array(euc.temp.last,part.slice(0,endP+4)).buffer)); - euc.temp.last=[]; - } else {// model/firm + euc.temp.last=[]; + } else { // model/firm if (event.target.value.getUint32(0) == 0x4E414D45) { //fetchModel console.log("model fetch responce:",event.target.value.buffer); euc.dash.info.get.modl = E.toString(event.target.value.buffer).slice(5).trim(); if (euc.dash.info.get.modl=="Barton") euc.dash.info.get.modl="RecioWheel"; - if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Model")) + if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Model")) ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Model",euc.dash.info.get.modl); - euc.dash.opt.bat.pack=euc.temp.modelParams(euc.dash.info.get.modl).voltMultiplier; + euc.dash.opt.bat.pack=euc.temp.modelParams(euc.dash.info.get.modl).voltMultiplier * 16; euc.dash.opt.bat.low=euc.temp.modelParams(euc.dash.info.get.modl).minCellVolt*100; } else if (event.target.value.getInt16(0) == 0x4757) { //fetchFirmware euc.dash.info.get.firm = E.toString(event.target.value.buffer).slice(2); - } + } } }; @@ -170,28 +169,28 @@ euc.temp.type=function(data){ euc.is.alert=0; if (data.buffer[18]==0) euc.temp.pck0(data); else if (data.buffer[18]==4) euc.temp.pck4(data); - else if (data.buffer[18]==1) euc.temp.pck1(data); //master + else if (data.buffer[18]==1) euc.temp.pck1(data); //master //haptic euc.temp.hapt(); - } + } }; euc.temp.pck0=function(data) { //volt-battery - euc.dash.live.volt=(data.getUint16(2)*euc.dash.opt.bat.pack)/100; //bms=1 67.2 ,1.25 84, 1.5 100,8 - euc.dash.live.bat=Math.round( 100*(euc.dash.live.volt*( 100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); + euc.dash.live.volt=(data.getUint16(2)*(euc.dash.opt.bat.pack/16))/100; //bms=1 67.2 ,1.25 84, 1.5 100,8 + euc.dash.live.bat=Math.round( 100*(euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); euc.log.batL.unshift(euc.dash.live.bat); if (20{euc.tout.busy=0;},150);return;} - euc.tout.busy=setTimeout(()=>{euc.tout.busy=0;},100); + if (euc.tout.busy) { clearTimeout(euc.tout.busy);euc.tout.busy=setTimeout(()=>{euc.tout.busy=0;},150);return;} + euc.tout.busy=setTimeout(()=>{euc.tout.busy=0;},100); //end if (n==="proxy") { c.writeValue(euc.proxy.buffer[0]).then(function() { @@ -345,7 +344,7 @@ euc.conn=function(mac){ }).then(function() { euc.proxy.buffer.shift(); if (euc.proxy.buffer[0]) return c.writeValue(euc.proxy.buffer[0]) - }).catch(euc.off); + }).catch(euc.off); }else if (euc.state=="OFF"||n=="end") { euc.temp.exit(c); } else if (n==="start") { @@ -368,10 +367,10 @@ euc.conn=function(mac){ if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Mac")) { euc.dash.info.get.mac=euc.mac; ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Mac",euc.mac); - } + } //start wheel init buzzer.nav([90,40,150]); setTimeout(() => {euc.wri("start");}, 500); //reconect }).catch(euc.off); -}; \ No newline at end of file +}; diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index 3ff252ba..a0440a76 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -119,10 +119,10 @@ euc.temp.infoParse = function (inc){ euc.dash.opt.snd.vol=((lala.getUint8(145) << 8) | lala.getUint8(144)) / 100; if (euc.temp.infoGet) return; //firmware - let v0=lala.getUint8(46); + euc.dash.info.get.firmMJ=lala.getUint8(46); let v1=lala.getUint8(45); let v2=((lala.getUint8(44) << 8) | lala.getUint8(43)); - euc.dash.info.get.firm=[v0, v1, v2].join('.'); + euc.dash.info.get.firm=[euc.dash.info.get.firmMJ, v1, v2].join('.'); //serial let serial = new String(''); let tByte; @@ -142,6 +142,7 @@ euc.temp.infoParse = function (inc){ //model let modelId=lala.getUint8(126).toString(10)+lala.getUint8(123).toString(10) euc.dash.info.get.modl=getModelName(modelId); + euc.dash.info.get.makr="InmotionV10"; if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Name") || ew.do.fileRead("dash","slot"+"1"+"Name") != euc.dash.info.get.modl) { ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Name",euc.dash.info.get.modl); } @@ -156,7 +157,6 @@ euc.temp.liveParse = function (inc){ //values //spd euc.dash.live.spd=(lala.getInt32(31, true)+lala.getInt32(35, true))/2000; - if (euc.dash.trip.topS < euc.dash.live.spd) euc.dash.trip.topS = euc.dash.live.spd; if (euc.dash.live.spd<0) euc.dash.live.spd=-euc.dash.live.spd; euc.dash.alrt.spd.cc = ( euc.dash.alrt.spd.hapt.hi <= euc.dash.live.spd )? 2 : ( euc.dash.alrt.spd.hapt.low <= euc.dash.live.spd )? 1 : 0 ; @@ -165,15 +165,15 @@ euc.temp.liveParse = function (inc){ //volt euc.dash.live.volt=lala.getUint32(43, true)/100; //batt - euc.dash.live.bat=Math.round(100* (euc.dash.live.volt*( 100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); - //euc.dash.live.bat = Math.round(((euc.dash.live.volt - 60) * 100) / (84 - 60)); + euc.dash.live.bat=Math.round(100* (euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); euc.log.batL.unshift(euc.dash.live.bat); if (20= 102) euc.dash.live.tmp=lala.getInt8(51); + else euc.dash.live.tmp=lala.getInt8(53); euc.dash.alrt.tmp.cc=(euc.dash.alrt.tmp.hapt.hi - 5 <= euc.dash.live.tmp )? (euc.dash.alrt.tmp.hapt.hi <= euc.dash.live.tmp )?2:1:0; if (euc.dash.alrt.tmp.hapt.en && euc.dash.alrt.tmp.cc==2) euc.is.alert++; //amp diff --git a/v2/euc/eucInmotionV11/eucInmotionV11.js b/v2/euc/eucInmotionV11/eucInmotionV11.js index 0732b52b..4c2aa6a7 100644 --- a/v2/euc/eucInmotionV11/eucInmotionV11.js +++ b/v2/euc/eucInmotionV11/eucInmotionV11.js @@ -67,7 +67,7 @@ euc.cmd=function(no,val){ cmd = [170, 170, 20, 4, 96, 37, val, 100]; cmd.push(cmd.reduce(checksum)); return cmd; - case "setBrightness": + case "setBrightness": cmd = [170, 170, 20, 3, 96, 43, val]; cmd.push(cmd.reduce(checksum)); return cmd; @@ -75,7 +75,7 @@ euc.cmd=function(no,val){ cmd = [170, 170, 20, 3, 96, 38, val]; cmd.push(cmd.reduce(checksum)); return cmd; - case "playSound": + case "playSound": cmd = [170, 170, 20, 4, 96, 81, val, 1]; //cmd = [170, 170, 20, 4, 96, 65, val, 1]; //cmd = [170, 170, 20, 3, 224, 81, 0]; // horn on v11 new firmware 1.4.0 (this is a mistake most probably) @@ -143,27 +143,24 @@ euc.conn=function(mac){ return; } - // masked out temp 031222 // was event.target.value.buffer[3] != 51 - // some packets larger than 74 have valid checksum but drop them for now... if (event.target.value.buffer[3] != 69 || !validateChecksum(event.target.value.buffer) || event.target.value.buffer.length != 74) { if (ew.is.bt===2) print ("packet dropped: ", event.target.value.buffer); - return; + return; } - //print ("packet: ",event.target.value.buffer); - euc.is.alert=0; + euc.is.alert=0; //volt euc.dash.live.volt=event.target.value.getUint16(5, true)/100; //batt - euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*5 - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); + euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); euc.log.batL.unshift(euc.dash.live.bat); if (20 { euc.is.buzz = 0; }, 3000); } }); @@ -226,8 +223,8 @@ euc.conn=function(mac){ euc.gatt.device.on('gattserverdisconnected', euc.off); return rc; }).then(function(c) { - //connected - if (ew.is.bt===2) console.log("EUC: Connected"); + //connected + if (ew.is.bt===2) console.log("EUC: Connected"); euc.state="READY"; //connected buzzer.nav([90,40,150,40,90]); euc.dash.opt.lock.en=0; @@ -237,11 +234,11 @@ euc.conn=function(mac){ euc.is.busy=1; if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} if (euc.gatt && euc.gatt.connected) { - euc.tout.loop=setTimeout(function(){ + euc.tout.loop=setTimeout(function(){ euc.tout.loop=0; if (euc.gatt && !euc.gatt.connected) {euc.off("not connected");return;} euc.temp.wCha.writeValue(euc.cmd("lightsOff")).then(function() { - euc.gatt.disconnect(); + euc.gatt.disconnect(); }).catch(euc.off); },500); }else { @@ -250,44 +247,43 @@ euc.conn=function(mac){ euc.is.busy=0;euc.is.horn=0; return; } - }else if (cmd==="start") { euc.is.busy=0; euc.temp.wCha.writeValue(euc.cmd((euc.dash.opt.lght.HL)?"lightsOn":"lightsOff")).then(function() { - euc.temp.rCha.startNotifications(); + euc.temp.rCha.startNotifications(); if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} - euc.tout.loop=setTimeout(function(){ + euc.tout.loop=setTimeout(function(){ euc.tout.loop=0; euc.is.busy=0; euc.is.run=1; euc.wri("live"); - },300); + },300); }).catch(euc.off); }else if (cmd==="hornOn") { if (euc.is.horn) return; euc.is.busy=1;euc.is.horn=1; if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} euc.tout.loop=setTimeout(function(){ - euc.temp.wCha.writeValue(euc.cmd("playSound",euc.dash.opt.horn.mode)).then(function() { + euc.temp.wCha.writeValue(euc.cmd("playSound",euc.dash.opt.horn.mode)).then(function() { euc.is.horn=0;euc.tout.loop=0; euc.tout.loop=setTimeout(function(){ euc.tout.loop=0; euc.is.busy=0; euc.is.horn=0; - euc.wri("live"); + euc.wri("live"); },250); }); },350); }else if (cmd==="hornOff") { - euc.is.horn=0; + euc.is.horn=0; } else { - //if (euc.is.busy) return; + //if (euc.is.busy) return; euc.temp.wCha.writeValue(euc.cmd(cmd,value)).then(function() { - if (euc.is.busy) return; + if (euc.is.busy) return; if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} euc.tout.loop=setTimeout(function(){ euc.tout.loop=0; - euc.wri("live"); + euc.wri("live"); },125); }).catch(euc.off); } @@ -296,7 +292,7 @@ euc.conn=function(mac){ euc.dash.info.get.mac=euc.mac; euc.dash.opt.bat.hi=420; euc.updateDash(require("Storage").readJSON("dash.json",1).slot); ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Mac",euc.mac); - } + } setTimeout(() => {euc.wri("start");}, 200); //reconnect }).catch(euc.off); diff --git a/v2/euc/eucInmotionV11/eucInmotionV11old.js b/v2/euc/eucInmotionV11/eucInmotionV11old.js index d1f238bb..e0c1dd69 100644 --- a/v2/euc/eucInmotionV11/eucInmotionV11old.js +++ b/v2/euc/eucInmotionV11/eucInmotionV11old.js @@ -141,16 +141,16 @@ euc.conn=function(mac){ return; } //print ("packet: ",event.target.value.buffer); - euc.is.alert=0; + euc.is.alert=0; //volt euc.dash.live.volt=event.target.value.getUint16(5, true)/100; //batt - euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*5 - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); + euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low) ); euc.log.batL.unshift(euc.dash.live.bat); if (20 {euc.wri("start");}, 200); //reconnect }).catch(euc.off); -}; \ No newline at end of file +}; diff --git a/v2/euc/eucInmotionV2/ChangeLog b/v2/euc/eucInmotionV2/ChangeLog new file mode 100644 index 00000000..5cf4bacc --- /dev/null +++ b/v2/euc/eucInmotionV2/ChangeLog @@ -0,0 +1 @@ +0.1: First version diff --git a/v2/euc/eucInmotionV2/README.md b/v2/euc/eucInmotionV2/README.md new file mode 100644 index 00000000..6572232e --- /dev/null +++ b/v2/euc/eucInmotionV2/README.md @@ -0,0 +1,7 @@ +# App Name + +Describe the app... + +## Usage + +Describe how to use it diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js new file mode 100644 index 00000000..5f5faac6 --- /dev/null +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -0,0 +1,493 @@ +//Inmotion V2 module- code based on https://github.com/Wheellog/Wheellog.Android +E.setFlags({ pretokenise: 1 }); +/* + //info type: + NoOp(0), + Version=1, + info=2, + Diagnostic=3, + live=4, + bms=5, + Something1=16, + stats=17, + Settings=32, + control=96; +*/ +euc.cmd=function(no,val){ + let cmd; + euc.temp.last=no; + switch (no) { + case "live": return new Uint8Array([0xAA, 0xAA, 0x14, 0x01, 0x04, 0x11]); + case "stats": return new Uint8Array([0xAA, 0xAA, 0x14, 0x01, 0x11, 0x04]); + case "getSettings": return new Uint8Array([0xAA, 0xAA, 0x14, 0x02, 0x20, 0x20, 0x16]); + case "getVer": return new Uint8Array([0xAA, 0xAA, 0x11, 0x02, 0x02, 0x06, 0x17]); + case "getSN": return new Uint8Array([0xAA, 0xAA, 0x11, 0x02, 0x02, 0x02, 0x13]); + case "getType": return new Uint8Array([0xAA, 0xAA, 0x11, 0x02, 0x02, 0x01, 0x10]); + case "getUseless": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x10, 0x00, 0x01, 0x06]); + case "drlOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2D, 0x01, 0x5B]); + case "drlOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2D, 0x00, 0x5A]); + case "lightsOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x50, 0x01, 0x26]); + case "lightsOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x50, 0x00, 0x27]); + case "fanOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x43, 0x01, 0x35]); + case "fanOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x43, 0x00, 0x34]); + case "fanQuietOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x38, 0x01, 0x4E]); + case "fanQuietOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x38, 0x00, 0x4F]); + case "liftOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2E, 0x01, 0x58]); + case "liftOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2E, 0x00, 0x59]); + case "lock": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x31, 0x01, 0x47]); + case "unlock": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x31, 0x00, 0x46]); + case "transportOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x32, 0x01, 0x44]); + case "transportOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x32, 0x00, 0x45]); + case "rideComfort": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x23, 0x00, 0x54]); + case "rideSport": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x23, 0x01, 0x55]); + case "performanceOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x24, 0x01, 0x52]); + case "performanceOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x24, 0x00, 0x53]); + case "remainderReal": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x3D, 0x01, 0x4B]); + case "remainderEst": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x3D, 0x00, 0x4A]); + case "lowBatLimitOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x37, 0x01, 0x41]); + case "lowBatLimitOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x37, 0x00, 0x40]); + case "usbOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x3C, 0x01, 0x4A]); + case "usbOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x3C, 0x00, 0x4B]); + case "loadDetectOn": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x36, 0x01, 0x40]); + case "loadDetectOff": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x36, 0x00, 0x41]); + case "mute": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2C, 0x00, 0x5B]); + case "unmute": return new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2C, 0x01, 0x5A]); + case "calibration": return new Uint8Array([0xAA, 0xAA, 0x14, 0x05, 0x60, 0x42, 0x01, 0x00, 0x01, 0x33]); + case "speedLimit": + v = val * 100; + cmd = new Uint8Array([0xAA, 0xAA, 0x14, 0x04, 0x60, 0x21, v & 0xFF, (v >> 8) & 0xFF, 0x00]); + break; + case "pedalTilt": + v = val * 100; + cmd = new Uint8Array([0xAA, 0xAA, 0x14, 0x04, 0x60, 0x22, v & 0xFF, (v >> 8) & 0xFF, 0x00]); + break; + case "pedalSensitivity": + cmd = new Uint8Array([0xAA, 0xAA, 0x14, 0x04, 0x60, 0x25, val, 0x64, 0x00]); + break; + case "setBrightness": + cmd = new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x2B, val, 0x00]); + break; + case "setVolume": + cmd = new Uint8Array([0xAA, 0xAA, 0x14, 0x03, 0x60, 0x26, val, 0x00]); + break; + case "playSound": + cmd = new Uint8Array([0xAA, 0xAA, 0x14, 0x04, 0x60, 0x51, val, 0x01, 0x00]); + break; + } + cmd.set([cmd.reduce(checksum, 0) & 0xFF], cmd.length - 1); + return cmd; +}; +// +function checksum(check, val) { + return (check ^ val); +} +// +function validateChecksum(buffer) { + receivedChecksum = buffer[buffer.length - 1]; + array = new Uint8Array(buffer, 0, buffer.length - 1); + let calculatedChecksum = array.reduce(checksum)&0xFF; + return receivedChecksum == calculatedChecksum; +} +function getModelName(id) { + switch (id) { + case 6: euc.temp.parseLive = euc.temp.parseLiveV11v2; return "V11"; + case 7: euc.temp.parseLive = euc.temp.parseLiveV12; return "V12"; + case 8: euc.temp.parseLive = euc.temp.parseLiveV13; return "V13"; + } + return "UNKNOWN"; +} +// +euc.temp.parseMainInfo = function (inc){ + let lala = new DataView(inc); + len dataLen = lala.getUint8(3) + if(inc[5] == 0x01 && dataLen >= 6) { + if (ew.is.bt===2) console.log("Parse main data"); + // 020601010100 -v11 + // 020701010100 -v12 + // 020801010100 -v13 + let series = lala.getUint8(7); + euc.dash.info.get.modl=getModelName(series); + euc.dash.info.get.makr = "Inmotion"; + euc.dash.info.get.mac = euc.mac; + if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Name") || ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Name") != euc.dash.info.get.modl) + ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Name",euc.dash.info.get.modl); + } else if(inc[5] == 0x02 && dataLen >= 17) { + if (ew.is.bt===2) console.log("Parse serial number"); + euc.dash.info.get.serl = ""; + for (let i = 6; i < 22; i++) { + euc.dash.info.get.serl += String.fromCharCode(lala.getUint8(i)); + } + } else if(inc[5] == 0x06 && dataLen >= 24) { + if (ew.is.bt===2) console.log("Parse version"); + euc.temp.protocol = 0; + let motherboard3 = lala.getUint16(16, true); + let motherboard2 = lala.getUint8(18); + let motherboard1 = lala.getUint8(19); + euc.dash.info.get.firm = [motherboard1.toString(10), motherboard2.toString(10), motherboard3.toString(10)].join("."); + if (euc.dash.info.get.modl == "V11") { + if(motherboard1 < 1 && motherboard2 < 4) { + euc.temp.protocol = 1; + euc.temp.parseLive = euc.temp.parseLiveV11v1; + else euc.temp.protocol = 2; + } +} +// +euc.temp.parseSettings = function (inc){ + if (ew.is.bt===2) console.log("Parse main data"); + let lala = new DataView(inc); + len dataLen = lala.getUint8(3) + if (dataLen<8) { + if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); + return; + } + euc.dash.alrt.spd.max = lala.getUint16(6, true)/100; + euc.dash.opt.snd.vol = lala.getUint8(13); +} +// +euc.temp.parseLiveV11v1 = function (inc){ + if (ew.is.bt===2) console.log("Parse realtime data (V11 old)"); + let lala = new DataView(inc); + len dataLen = lala.getUint8(3) + if (dataLen<21) { + if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); + return; + } + //volt + euc.dash.live.volt = lala.getUint16(5, true) / 100; + //amp + euc.dash.live.amp = lala.getInt16(7, true) / 100; + //speed + euc.dash.live.spd = Math.abs(lala.getInt16(9, true) / 100); + //temp + // mosfet temp + euc.dash.live.tmp = lala.getUint8(22) - 176; + // battery temp + euc.dash.live.tmp2 = lala.getUint8(24) - 176; + euc.temp.liveAll(); +} +// +euc.temp.parseLiveV11v2 = function (inc){ + if (ew.is.bt===2) console.log("Parse realtime data (V11)"); + let lala = new DataView(inc); + len dataLen = lala.getUint8(3) + if (dataLen<46) { + if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); + return; + } + //volt + euc.dash.live.volt = lala.getUint16(5, true) / 100; + //amp + euc.dash.live.amp = lala.getInt16(7, true) / 100; + //speed + euc.dash.live.spd = Math.abs(lala.getInt16(9, true) / 100); + //temp + // mosfet temp + euc.dash.live.tmp = lala.getUint8(47) - 176; + // battery temp + euc.dash.live.tmp2 = lala.getUint8(49) - 176; + euc.temp.liveAll(); +} +// +euc.temp.parseLiveV12 = function (inc){ + if (ew.is.bt==2) console.log("Parse realtime data (V12)"); + let lala = new DataView(inc); + len dataLen = lala.getUint8(3) + if (dataLen<44) { + if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); + return; + } + //volt + euc.dash.live.volt = lala.getUint16(5, true) / 100; + //amp + euc.dash.live.amp = lala.getInt16(7, true) / 100; + //speed + euc.dash.live.spd = Math.abs(lala.getInt16(9, true) / 100); + //temp + // mosfet temp + euc.dash.live.tmp = lala.getUint8(45) - 176; + // battery temp + euc.dash.live.tmp2 = lala.getUint8(47) - 176; + euc.temp.liveAll(); +} +// +euc.temp.parseLiveV13 = function (inc){ + if (ew.is.bt==2) console.log("Parse realtime data (V13)"); + let lala = new DataView(inc); + len dataLen = lala.getUint8(3) + if (dataLen<62) { + if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); + return; + } + //volt + euc.dash.live.volt = lala.getUint16(5, true) / 100; + //amp + euc.dash.live.amp = lala.getInt16(7, true) / 100; + //speed + euc.dash.live.spd = Math.abs(lala.getInt16(13, true) / 100); + //temp + // mosfet temp + euc.dash.live.tmp = lala.getUint8(63) - 176; + // battery temp + euc.dash.live.tmp2 = lala.getUint8(65) - 176; + euc.temp.liveAll(); +} +// +euc.temp.liveAll = function (){ + euc.is.lastGetLive = getTime(); + //batt + euc.dash.live.bat = Math.round(100*(euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); + euc.log.batL.unshift(euc.dash.live.bat); + if (20 { euc.is.buzz = 0; }, 3000); + } +} +// +euc.temp.parseStats = function (inc){ + if (ew.is.bt===2) console.log("Parse total stats data"); + euc.is.lastGetStats = getTime(); + let lala = new DataView(inc); + len dataLen = lala.getUint8(3) + if (dataLen<22) { + if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); + return; + } + //trip total + euc.dash.trip.totl=lala.getUint32(5, true)/100; + euc.log.trip.forEach(function(val,pos){ if (!val) euc.log.trip[pos]=euc.dash.trip.totl;}); + //time + euc.dash.timR=(lala.getUint32(17, true)/60)|0; + euc.dash.trip.time=(lala.getUint32(21, true)/60)|0; + //deb + if (24 && inc[0]==0xAA && inc[1]==0xAA ) euc.temp.tot=E.toUint8Array(inc); + else if (euc.temp.tot.buffer.length>1) euc.temp.tot=E.toUint8Array(euc.temp.last,inc); + else return; + euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); + let needBufLen=euc.temp.tot.buffer[3] + 5; + if (euc.temp.tot.buffer.length < needBufLen) return; + if (euc.temp.tot.buffer.length > needBufLen) { + console.log("InmotionV2: Packet size error. Dropped."); + euc.temp.tot=E.toUint8Array([0]); + euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); + return; + } + delete inc; + euc.temp.last = E.toUint8Array(); + if (ew.is.bt===2) console.log("InmotionV2: in: length:",euc.temp.tot.buffer.length," data :",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); + + // Check packet + if ( !validateChecksum(euc.temp.tot.buffer) ) { + if (ew.is.bt===2) console.log("Fail checksum, packet dropped"); + return; + } + if ( euc.temp.tot.buffer[3] == 0 ) { + if (ew.is.bt===2) console.log("No data, packet dropped"); + return; + } + // + if (euc.temp.tot.buffer[2] == 0x11 && euc.temp.tot.buffer[4]&0x7F == 0x02) { + euc.temp.parseMainInfo(euc.temp.tot.buffer); + return; + } + if (euc.temp.tot.buffer[2] == 0x14) { + if (euc.temp.tot.buffer[4]&0x7F == 0x20) { + if (euc.dash.info.get.modl == "V11") euc.temp.parseSettings(euc.temp.tot.buffer); + return; + } + if (euc.temp.tot.buffer[4]&0x7F == 0x11) { + euc.temp.parseStats(euc.temp.tot.buffer); + return; + } + if (euc.temp.tot.buffer[4]&0x7F == 0x04) { + euc.temp.parseLive(euc.temp.tot.buffer); + } + } else return; +} + +euc.temp.keepAlive = function() { + if (getTime() - euc.is.lastGetLive < 0.5) return; + if (euc.tout.busy) return; + euc.tout.busy = 1; + let sendCommand; + if (euc.temp.keepAlive.state == 0) sendCommand = euc.cmd("getType"); + else if(euc.temp.keepAlive.state == 1) sendCommand = euc.cmd("getSN"); + else if(euc.temp.keepAlive.state == 2) sendCommand = euc.cmd("getVer"); + else if(euc.temp.keepAlive.state == 3) sendCommand = euc.cmd("getSettings"); + else if(euc.temp.keepAlive.state == 4) sendCommand = euc.cmd("getUseless"); + else if(euc.temp.keepAlive.state == 5) sendCommand = euc.cmd("stats"); + else if(euc.temp.keepAlive.state == 6) sendCommand = euc.cmd("live"); + euc.temp.wCha.writeValue(sendCommand) + .then(function() { return euc.tout.busy = 0 }) + .catch(function(err) { + if (ew.is.bt===2) console.log("EUC InmotionV2: keepAlive write fail"); + }); + euc.temp.keepAlive.state++; + if(euc.temp.keepAlive.state < 5) return; + if(getTime() - euc.is.lastGetStats < 1) euc.temp.keepAlive.state = 6; + else euc.temp.keepAlive.state = 5; +} + +euc.isProxy=0; +euc.wri=function(i) {if (ew.is.bt===2) console.log("not connected yet"); if (i=="end") euc.off(); return;}; +euc.conn=function(mac){ + if (euc.gatt && euc.gatt.connected) return euc.gatt.disconnect(); + //check if proxy + if (mac.includes("private-resolvable")&&!euc.isProxy ){ + let name=require("Storage").readJSON("dash.json",1)["slot"+require("Storage").readJSON("dash.json",1).slot+"Name"]; + NRF.requestDevice({ timeout:2000, filters: [{ namePrefix: name }] }).then(function(device) { euc.isProxy=1;euc.conn(device.id);} ).catch(function(err) {print ("error "+err);euc.conn(euc.mac); }); + return; + } + euc.isProxy=0; + if (euc.tout.reconnect) {clearTimeout(euc.tout.reconnect); euc.tout.reconnect=0;} + NRF.connect(mac,{minInterval:7.5, maxInterval:15}) + .then(function(g) { + euc.gatt=g; + return g.getPrimaryService("6e400001-b5a3-f393-e0a9-e50e24dcca9e"); + }).then(function(s) { + euc.temp.serv=s; + return euc.temp.serv.getCharacteristic("6e400002-b5a3-f393-e0a9-e50e24dcca9e"); // write + }).then(function(wc) { + euc.temp.wCha=wc; //write + print("write packet: ", wc); + return euc.temp.serv.getCharacteristic("6e400003-b5a3-f393-e0a9-e50e24dcca9e");//read + }).then(function(rc) { + euc.temp.rCha=rc; + //read + euc.temp.rCha.on('characteristicvaluechanged', euc.temp.inpk); + //on disconnect + euc.gatt.device.on('gattserverdisconnected', euc.off); + return rc; + }).then(function(c) { + //connected + if (ew.is.bt===2) console.log("EUC: Connected"); + euc.state="READY"; //connected + buzzer.nav([90,40,150,40,90]); + euc.dash.opt.lock.en=0; + //write function + euc.wri=function(cmd,value){ + if (euc.tout.eucWrite) { + clearTimeout(euc.tout.eucWrite); + euc.tout.eucWrite=0; + } + if (euc.tout.busy) { + if (cmd!=="proxy") euc.tout.eucWrite=setTimeout(function() {euc.wri(cmd,value)},50); + return; + } + euc.tout.busy = 1; + if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} + if (euc.state === "OFF" || cmd === "end") { + if (euc.gatt && euc.gatt.connected) { + if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} + euc.tout.loop = setTimeout(function(){ + euc.tout.loop = 0; + if (euc.gatt && !euc.gatt.connected) {euc.off("not connected"); return;} + euc.gatt.disconnect(); + }).catch(euc.off); + },500); + } else { + euc.state = "OFF"; + euc.off("not connected"); + euc.tout.busy = 0; + euc.is.horn = 0; + return; + } + euc.tout.busy = 0; + } else if (cmd === "start") { + euc.temp.keepAlive.state = 0; + euc.temp.rCha.startNotifications(); + if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} + euc.tout.loop=setTimeout(function(){ + euc.tout.loop=0;euc.tout.busy=0;euc.is.run=1; + euc.tout.intervalKeep=setInterval(function(){ + try euc.temp.keepAlive(); + catch(e) return; + },200); + },200); + } else if (cmd === "hornOn") { + if (euc.is.horn) return; + euc.is.horn=1; + if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} + euc.tout.loop = setTimeout(function(){ + euc.temp.wCha.writeValue(euc.cmd("playSound",euc.dash.opt.horn.mode)).then(function() { + euc.is.horn = 0; + euc.tout.loop = 0; + euc.tout.loop=setTimeout(function(){ + euc.tout.loop = 0; + euc.tout.busy = 0; + euc.is.horn = 0; + },250); + }); + },350); + } else if (cmd==="hornOff") { + euc.is.horn=0; + euc.tout.busy = 0; + } else if (cmd==="proxy") { + euc.temp.wCha.writeValue(value) + .then(function() {return euc.tout.busy = 0;}) + .catch(euc.off); + } else { + euc.temp.wCha.writeValue(euc.cmd(cmd,value)) + .then(function() {return euc.tout.busy = 0;}) + .catch(euc.off); + } + }; + if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Mac")) { + euc.dash.info.get.mac=euc.mac; euc.dash.opt.bat.hi=420; + euc.updateDash(require("Storage").readJSON("dash.json",1).slot); + ew.do.fileWrite("dash","slot"+ew.do.fileRead("dash","slot")+"Mac",euc.mac); + } + setTimeout(() => {euc.wri("start");}, 200); + //reconnect + }).catch(euc.off); +}; diff --git a/v2/euc/eucInmotionV2/icon.png b/v2/euc/eucInmotionV2/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9a45577a93aeaa49e48c669be7ea62432e083348 GIT binary patch literal 7940 zcmWkzWmMEp7yj+C3rk3@fYdJC-Mw^42uLGHE+Q=;D7YX9NDBheNQi$zVrf|xl#nh# z$(2-;?tXbc%*?qTX3m^DbMJlb^Te4L>D(e?A_D;6mY%Mr>CNi+{{bVunU}JH4Vig z&&T&yvwM#h+MDe34akMP_?yNv{A0kB(`L7+1dLF9$n3jGJ>R%Ad6%Cvtf$5C@DzuS zmLpsSb5os1HQy1`pb;7Vg6ibhxuSG+1M=ublbNm4Ym4*W{rOFMc3WMpLEH)osj zaQE)rizw2Fc_k?!!Q?)a-C()dmj7(4rJ~bO?B5f{LJ3Dw;KEq-QfhVbqgi}^f4{|i zv!An?zP`RwaBy&8eZA!9!opSxH60xtqZHZ%b7sN^|Glx%`q7kI;%GQmzFtUPzU8i_ z-JNnx3M;V6)yXpU=8)6X)m6`u)A;4(WwX*%b`a^0ht}#ycJ@woP7x7G0@0UOx5&#% zOQW?cp4r;Y9T9-eMT8$!9EL{%eEpC_MK6 zot>S19ACnAz9flxLLntB4P|0tf;HNkeK1m1es=UPvBL7x!uyk&(!xSQPFGjgHIuym z%E#Q?TuP_NShBv*+#kpty46UYZ+WFh3vT#640~a1tzWvG@wW_N+bOci47=f=NdKY^&zhffF)bpS-Wy(_uA+#MrsLiC#{EK`nfS* z+F54PV)!|t^+cU^zS^oT_VlWAMi5a6Lu$$?xBXK2=o-r#Dh%&NAM`H=qor zzT6A6*O&Bkg}xXX7&uqUFbTXk*+mcSPU6DO^XY0@-o1NQo8o))&zjd@JjCkIOF$NG zFcT0EkUU`1Xq+YXa71!M$?RQzet7Ni@`=c$KK^KPR??_IrQHgD*?w_3IFKny)e*A4 zX5t@es?P~zcFAWH1_>1zh?L&DGYkc_=q$J1#;)t1lfM=29^ig>FM^KO2m&X`RaOrO zsCT|)H=r;RLxl*}gP4!JlU$F9qvPGmmhrM_i1qw^iN?ikLsAwUTA%RSGbtKH1iix8 z+L)P{2^r{;ut-^UPX2TRDFkwAC%|C2_-|>vL^r;BVn;5b9T51fUFyFVR^0bJ+!LI% zQ6+LBKSuHofEa1L~NOzG=>eH7!tWTni=wx6b!0z0Bg zc2F1oYGeJq@eQNu!g6Eucg0QSr?;G4YOl7O4l{12R)fn(9qUy`*EZLcql3PHRxgc0 z2jql^ofvfhhB&|V;XDJnJNW`1MIk91kM4ab^@|f=m)bURyqfB=gAe-|L(GMM>tSW! zZI^r?kWe8YBt)TfIB6Dfzrq5FB@a3iW2^hEv+*B%D&YA=9WWOq27`jSzTPT{YZIxn zYO`&2Gr|y|*kn;)kt7+#_rHJ<`DZUB-G?ERY)XtNwom5hlSO%q^Z!|q?xSGUL!P^d zz;h`uQbZx3J93|d3cY%g6_78v zyAY9;Qc!?kR1N>UulvPdHx1x_(B%6UG*UHGRuvWp3gZRYF;kT*)nR~Y_U<}PtRgpe zx1YwKo`W3?)!!djkWxm(wq+|zd3ALVTg1dx>4`dKu-zcM@d3H_bm>dJc&!8qe3#*m z2B<}wOyb&HluYF}u&{S@$h(0vapIvSf<6M@1n!$;=1*8}Ei2>kJ=yuyaSP0q=iHOP zpXO%KKRHWbhyTSw?S~+a0+BO%b5xr6cn?O31`a;-f^*(J?rk5O7o#*>&kpJg%_EjH`)whRqDQxX2GmCZxZl~h4MXM5QU(CkoH5ly0Gm*h-;lbith z2)Z@#j^wr3Fo2;Z#BON#&T;vfNK1vc1V<86Ox#h{$CxEsic#>Vx9REsOiUCj?H?&J z!5C8=O=Gx6y&;F(#7bR^_$HmHHGjr|IoMS`AgtbYO3a!g{#r<~@|JacUHQAl zp}qWx^rDLCxVZ8cgnq6qDn=w+ncQEKIWOsSf1Nj1Da8M?l#D&H7t8^UC9duUqgELC ziIrCThR+>Lbt~~g-|7%+|MEnY9(F}d+(4ZtElG)ohld|IgdSKF@kdsH+s(ZxJt2o&y+m(*?|U26qygUs6(g2`ipejH2rCv13q{EgF%~VZ z4rJ!ZIy58BXifB_L!{$Wdk@7P;I8!V-5WcKCT9pQXROg%c9BZ@t|_>zXW1jkU8{C^n z$Vgy;NHA)=?kk4mKL<rqcPHhP6e9D>(}+#9 zYSa(8p)p~G2_@J5^tFX;=%!i0Uuxd?*JB~oYwy~^FGC&X>pnpW?e{vDSJ_NUI&F?c z-%&8#DkmEsCXU@cAlU5uZRR+8e~MPT^hHpU;;Bh~-ykijlG0N72nO}RcE2d89?p%l zlJlNy*VOm@_XA&ZZ5QCQVn0D1&ozrb*&%ecfYEONUDV&PaNvCk4|wawk1RW$o}PIz zt}Ze_bYp>H@Gw6$(GCU{ck&#svwzEq%*FA}-uc-0#oX)HuUEEl=OVVp@5)Z!Kvh&v z@WNY@O16jM$|INaOM;;BEyC7(TQB*+77i(sX&&=A5_hJE z(-b5>DF(7jp}c^SO`<0tM8pcvz(7`H-rxdbhXuFYi+t1&voLnSj$(O!i-hKfnzdF! zb@6b%vMu}4QNMslzd%x-x~@UfBaI*V_QxS9?8)HYC!sPf&1`mXm)2fST;ayDCOikPRfp5j z>RaBpZr*A$=MpykW-gYT*~Y}t6m&T2)1iEHIPGxl_4q5q3O$mqtmQtO`woeudx|8E zJ@GNs!NLjDz?W!1L=)ifI*1U%l;$Z&6$HRoltZy*B%}$hxikidx%4eXt9|#6%9epG z*{YV9_1LfGL-E_j=Coq=%vh(E_I%_@(Fs$Oq@-jFEJ3a`dH7h)4}lh8N;r75F(N`l z4Wj!s(^r^}0}uPzPfjFX68+)x(xwO-Y9Ax1Ftax);4I%&`>wdoA);G}Yh;dUYoG^0JWTn?ekloxJofEIZ zQpM`eIAP$Oc^23Q4kuM-ixY*Q)jID;x>1;o#!qlGH0E#bSdBs<8*^O^x6}GOF+^ez z-*+UYq?2d~499^6x;N}jDmAb}tyi#cda@c^ye3y%y#5UA02@70(T;z>M~4t}bOKlx z6ONb}i7O*kiE|Vb-G!W{F|lGKmq@T>6dKqAcG_#+L%KZsrZc550 zn>{^ZocSus0B?VBedPr0eEwE5Qj{LB3a$g1n)SrN)WPi$qy#HaEns5Uw#}7LggB>= ziROq{Op|7l^DXQeI0krd)P>#97iWKX!#OrCD2R82ElHI09h?r!+S7Hxk0~)LEa2Z? z0@x=W%~1dKjPf07u_jwKA){dw6x;|g{ayRi2t(gz`{C=%%nVw16ofc_DVhW)QZl6w z`)UZNGe_4B>M5>U0qbAEz#7ZAumw`4hZcOq$swZs^Cx;U0TFU}IQ`<mPv82L4B~KWgfq_ax@%)&qhsQ9 zy8w`p3=9n1#}d>*Z}Co~k@PHv6x30ng5Dq(Kx57eGbpXIR^&?+Db8f1yo`*-`&c+S z*U$$2R0{jfli=XTldljcU@(PGzE-+DLP~wYF8nx(KCfiyqJhpX!j+?}HkR3Zqqz*A zxAC6Q&pQnSq{I?g`bt^7+!s6B(H}&+F40Cd zKiMKdJSY62l2YOYT0##6UTjC?t&hx5q0@Cie8)86k<`P9EN$9z%jL@|^uI$OYAl6A zeZ9ig%3;XaIMMt<{cgVZTsDnk6qbsidegTY&C7mywNo5HCuPY24k5js_DWYfp56bK1Y|1SY(9 zQBp`1QigKWFASzqFyiFF9|mF$*31D>(LnyBa_ZE@?7}%6V7?@3^zP)FiX5U|MQCSxpwc{TIlRKnYtu^fc zTK9})b1>TV-e8^yx)^cHN$Kk|$DV->7=6{z)DHH3!wD%@Fxa|_KN4KV_8 z*x9I-HJaykwMWHa(q(5nE zZvb#EAY5(B6lfp67SlBx36O|wal1izf{D(Jym;nB$HBlXtcEkpgwfPpMKEKd^d=&u zsyzRUm#UVQmgZ%;&1(->J$8Wl73k=@T+a9WXvjeigAgX)`bVDx6V|eW>ewZ?Rlf#+ zr#?Bnc=qiLcWFPD5xQ3PqjM_Swxn4t0dgEpeoRLE!kT9q-5AC_j?Eo$o*9;Ral924 zHXOsBPge+yQ9WHrlhog=);s^wNZ!plZ!m`fYdTD)9;QM~G>Y<1oCDFy$%XvH3SURv zqNq7*7(I{mZ{lIB?3JqEA`dk-KmYkWzHrWP?sDq`z^4>}SBQxF zmuK?SqQP!7p!dOUlqO;XF@n1Vf;at8mj^>M@BN#bsmkwS*}~=JDeIigD8YvfzwoDk ze#7S|xO`oNqSUB!#J}$zf1tChv=Y~EduUvO!=@aK*Rs@_a0HA&@c{6@Y@s2~MWcFV+9FHgmU50C{)! zl`!roIT2_eThVYjLdce}!0XYGo?2NkCn*_yE~+)p*Eb0*PNC= z!?`!fYkG!_PybvUkhrP5Xkqk6ywLa(t=KdAxHXU%0ZfT!qJb09fctD1& zW3RFX9#X<;Dr25yWh@6hX1P37!Wb*BC-|VzvGSn@=$=~V-aRH}W`l!}jE{ppj~*?J zcn96hk*RukyfuH^)RunJK+)5}sX0rclci;4_x)8C@+Wfs5K(dga$qFJgKJb9A(b8) zpha9rqvimVAni0Tx7R>+v(V)p#*r4Ni|%^_eV4ScHn+y4==}or&4WJ^^3u}M&e&H^ z8t$iOWGoyb-Zq~f?XvA%?2qt%6AC!!9FL)7?f1dV0@2eLp;wWxgz}bv^d<98>C7gP13H*T&z=H|pHZ6*4rc$#K?BD%q<6Jqv`mN(%t$}}s z6%YiKl?d3=Kc$&<|5a36pZ@zY?NNS^*ahEBO?2YRV zJ{|{jd#X$2c7ug51h*TKg`PnZ@!*a+uz9emq77VTG5E6MrE(G8JLeMN4_^ia7~jAS z0;dcjz-*eCq*d#yAx0q!p z#)@2elUPM_6#^d>VPfgB*o74=@Vi{Q>)kbS!b*H5KPlu6F<;~%0L9GfZ$x~K{)URq ze+EWOK}jlrHsVYopYsr{nw(ZEvXw0Oki~(5a7`*!V2#j}Bnj{n#paK6U)I&vD}L{} z{vgj$(N^-eH8L_1;rg-7eEPqJC%B8ffjos5g^686G#D0zC+IAdlZ(sq<4hKLe=b|{ zq0ug0vV^Df@fOU~aM<|LX?-_4K%_+Pbn0A03J1aQE3ez3g ztU5&mvI3lu<(6OacIii3)*cAhr|}rJ3K?D_xT$hhWCm{92Ol?A*TBzv{erAiWUaPr zSwNJiXdL8fYp?M0=g+5m4e_f1k_`ktdP<-jxj#SZA}nW2ZbT=ZR8Jy=0pOTk*U4uQyLN+D}kMUr$v+y0FRT^PGq{@8niic zo#N{4&>q_0{zBudh?p zD);l-RoMRaSO`S~w*d7)9_kk6`@yow=eIULsdcZ2;QME^reP{1h)qq{K;})Js zoREmfm8D+&*5Rm>iYc1{=$LksXSsB2A1*r;hoQ9|GQmrsKQ2{b5CA zV=Co0F}Ma?CZBUNzh%8`wsqBe=>>l~Dm);fXpeDRe=T^!F`z~9OUoWaVqc{eq!AyPO5Uhat(rxHy7^ zkO7)NA`XbjaApV4mq3AEZW>e^aXAlR{07q;)7hV&a#s)}3|yXsF^>B{gdA|6y}DoD zewJ=)sjFcN(9r&<-P0gNfuvsNabgTqf%@Xp03i9F^S;CambK!c(V2$h_Qk{QqDGI2 zGW$o59__71*OV;6P;fMruvLwtyOEL6%SeYTe0T$|uoe4$z3-tiyXZ<>9d)NpRcn_^!T&mbytBP0Bz>c@zX z*N9=jO4<5kWWLk@&6)*pyMr<-mx${SF#g5juj|mllgGU+yXnr>!`umPDWl}a`!!@% zJ9I3}GIWaku>@0t0#9mt*=DnHa%=?%EEBxO>qSfufDJ-W0q6-prjrUnyh)ukLtSwN zg$w{mbkPVpu|Q3^9)4dm-v~LyM-btzjyJ=3Q7TRMvu!dmGkagOdjrTTGWxdrL8VF( z7+?;9nJI=24{-npWJ^z^ud)@?#%E@mvKe+_$I&Nd#f3(vP=zgA@SM;bs@C^ zqM_jfH}&Q?kxjYv`S<_s<4#|=pr|pr$Vc5A{E`9HD3U!h1MLt=9&HehH7 zXl&sY0#ev1$K@p0mVP_a6OqF9f3sPhG&TO88neD3vhxbINOmu+N9UuC$$5=(pRSA+ zX^4`tT&>>TW{%PuaU(zOYymy0CIOj~O~aWrSm`zJ+Q?KH&3$bD_qXI1xBOKX1&-{@ zXRlQmT=u%iMX`Nk`m1kn46zI#rYfyLS6|J6pC-Q^jQZYep8oXjLdJqei<>k)F5rF`co}?xJYN#h%6YX$882 zG>UR03%^b>8>63SeiqFIHNd&AU>=La7T&FaqMbl4Kf*!x>??X2 z_~w;OOik-NPWM)A)9nuhPx>%Cfcy>qG65+DEcYbFH+jukRPJ+>W@cb!hQ-J*~8^KSBotRUgw|3J~Q3n%+DotCD&)&7VoLJWVbi`?lbaQC^V;?SjXqg(@eT1J}H>W-2B11B+x00000 literal 0 HcmV?d00001 diff --git a/v2/euc/eucInmotionV2/proxyInmotionV2.js b/v2/euc/eucInmotionV2/proxyInmotionV2.js new file mode 100644 index 00000000..67e25394 --- /dev/null +++ b/v2/euc/eucInmotionV2/proxyInmotionV2.js @@ -0,0 +1,86 @@ +//InmotionV10 Proxy +if (global.euc && !euc.proxy) { + euc.proxy = { + state: 0, + buffer:[], + r: function(o) { +// "ram"; + return; +// if (euc.state == "READY") { +// //euc.proxy.buffer.push(o.data) +// euc.wri("proxy",o.data); +// } +// if (ew.dbg && ew.log) { +// ew.log.unshift("Proxy from phone: " + " " + Date() + " " + E.toJS(o.data)); +// if (100 < ew.log.length) ew.log.pop(); +// } + }, + w: function(o) { +// return; + if (ew.is.bt!=5) return; +// if (euc.tout.busy) return; +// if (euc.tout.alive) clearTimeout(euc.tout.alive); +// if (euc.tout.info) clearTimeout(euc.tout.info); +// euc.tout.alive=setTimeout(function(){euc.tout.alive=0;euc.is.busy=0;euc.temp.live();},500); +// if (euc.is.busy) return; +// euc.is.busy=1; +// NRF.updateServices( {0xffe0: {0xffe4: {value: o, notify:true} }} ).then(function() {euc.is.busy=0}); +// euc.tout.busy=1; + NRF.updateServices( {"6E400001-B5A3-F393-E0A9-E50E24dCCA9E": {"6E400003-B5A3-F393-E0A9-E50E24DCCA9E": {value: o, notify:true} }} ); +// .then(function () { return euc.tout.busy=0 }); + }, + s: function(o) { + NRF.setServices({ + 0xffa0: { + 0xffa1: { + value: [0x01], + maxLen: 20, + writable: true, + onWrite: function(evt) { + ew.emit("ewBtIn",evt); + }, + readable: true, + notify: true, + description: "ew" + }, + 0xffa6: { + value: [0x01], + maxLen: 20, + writable: false, + readable: true, + notify: false, + description: "Inmotion" + } + }, + "6E400001-B5A3-F393-E0A9-E50E24dCCA9E": { + "6E400002-B5A3-F393-E0A9-E50E24DCCA9E": { + maxLen: 20, + writable: true, + onWrite: function(evt) { + euc.proxy.r(evt); + }, + description: "B CHL(TX,20Byte)" + }, + "6E400003-B5A3-F393-E0A9-E50E24DCCA9E": { + maxLen: 100, + notify: true, + description: "A CHL(RX,20Byte)" + } + } + }, { advertise: ['6E400001-B5A3-F393-E0A9-E50E24DCCA9E'], uart: false }); + NRF.setAdvertising({}, { name: euc.dash.info.get.modl + "-" + ew.def.name, connectable: true }); + //NRF.setAddress(euc.mac); + NRF.setAddress(NRF.getAddress().substr(0, 15) + "a3 public"); + NRF.disconnect(); + NRF.restart(); + }, + e: function(o) { + euc.proxy = 0; + ew.do.update.bluetooth(); + NRF.disconnect(); + NRF.restart(); + return; + } + }; + euc.proxy.s(); +} diff --git a/v2/euc/eucKingsong/eucKingsong.js b/v2/euc/eucKingsong/eucKingsong.js index a752bf33..c5bfd831 100644 --- a/v2/euc/eucKingsong/eucKingsong.js +++ b/v2/euc/eucKingsong/eucKingsong.js @@ -148,7 +148,7 @@ euc.temp.inpk = function(event) { let inpk = JSON.parse(E.toJS(event.target.value.buffer)); if (ew.is.bt == 5) { NRF.updateServices({ 0xffe0: { 0xffe1: { value: inpk, notify: true } } }); - //if (ew.dbg&&ew.log) { + //if (ew.dbg&&ew.log) { // ew.log.unshift("Proxy from wheel: "+" "+Date()+" "+E.toJS(inpk)); // if (100=10) { if (face.appCurr=="dashNinebot") face[0].ntfy("MODE CHANGED","",22,4,1); - buzzer.nav([80,40,80]); + buzzer.nav([80,40,80]); }else euc.dash.opt.ride.mode=this.in16; break; case 112: //lock status @@ -120,7 +120,7 @@ NRF.connect(mac,{minInterval:7.5, maxInterval:15}) break; } //buzz - if (euc.is.alert && !euc.is.buzz) { + if (euc.is.alert && !euc.is.buzz) { if (!w.gfx.isOn&&(euc.dash.alrt.spd.cc||euc.dash.alrt.amp.cc||euc.dash.alrt.pwr)) face.go(ew.is.dash[ew.def.dash.face],0); euc.is.buzz=1; if (20<=euc.is.alert) euc.is.alert=20; @@ -130,17 +130,17 @@ NRF.connect(mac,{minInterval:7.5, maxInterval:15}) euc.is.alert=euc.is.alert-5; } for (let i = 0; i < euc.is.alert ; i++) a.push(150,150); - buzzer.euc(a); + buzzer.euc(a); setTimeout(() => {euc.is.buzz=0; }, 3000); } }); //on disconnect euc.gatt.device.on('gattserverdisconnected', euc.off); - c.startNotifications(); + c.startNotifications(); return c; }).then(function(c) { - //connected - if (ew.is.bt===2) console.log("EUC: Connected"); + //connected + if (ew.is.bt===2) console.log("EUC: Connected"); euc.state="READY"; //connected buzzer.nav([90,40,150,40,90]); euc.dash.opt.lock.en=0; @@ -157,11 +157,11 @@ NRF.connect(mac,{minInterval:7.5, maxInterval:15}) // c.writeValue(v).then(function() { //// if (euc.tout.busy) {clearTimeout(euc.tout.busy);euc.tout.busy=0;} // }).catch(euc.off); - //}else + //}else if ( euc.state==="OFF" || n==="end" ) { euc.is.busy=1; if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} - euc.tout.loop=setTimeout( function(){ + euc.tout.loop=setTimeout( function(){ euc.tout.loop=0; if (!euc.gatt) {euc.off("not connected");return;} c.writeValue(euc.cmd((euc.dash.auto.onD.lock)?21:25)).then(function() { @@ -173,14 +173,14 @@ NRF.connect(mac,{minInterval:7.5, maxInterval:15}) if (euc.tout.busy) {clearTimeout(euc.tout.busy);euc.tout.busy=0;} if (euc.is.busy==1||n=="proxy") return; if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} - euc.tout.loop=setTimeout( function(){ + euc.tout.loop=setTimeout( function(){ euc.tout.loop=0; euc.temp.count++; if (euc.temp.count>=21)euc.temp.count=0; euc.wri(1,euc.temp.count); - },50); + },50); }).catch(euc.off); - } + } }; if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Mac")) { euc.dash.info.get.mac=euc.mac; euc.dash.opt.bat.hi=412; @@ -196,4 +196,4 @@ NRF.connect(mac,{minInterval:7.5, maxInterval:15}) }).catch(function(err) { euc.off(err); }); -}; \ No newline at end of file +}; diff --git a/v2/euc/eucNinebotS/eucNinebotS.js b/v2/euc/eucNinebotS/eucNinebotS.js index dbb20b73..158fd414 100644 --- a/v2/euc/eucNinebotS/eucNinebotS.js +++ b/v2/euc/eucNinebotS/eucNinebotS.js @@ -17,17 +17,17 @@ euc.cmd=function(no){ case 21:return [85,170,3,17,2,112,1,120,255]; //21- lock case 22:return [85,170,3,17,2,112,0,121,255]; //22- unlock case 23:return [85,170,4,9,3,198,0,0,30,255]; //metric khp - case 24:return [85,170,4,9,3,198,1,0,30,255]; //metric mph + case 24:return [85,170,4,9,3,198,1,0,30,255]; //metric mph case 25:return [85,170,4,9,3,198,0,0,41,255]; //ring off case 26:return [85,170,4,9,3,198,1,0,40,255]; //ring cyrcle - case 30:return [85,170,3,17,2,210,0,23,255]; //set Riding Mode 0 + case 30:return [85,170,3,17,2,210,0,23,255]; //set Riding Mode 0 case 31:return [85,170,3,17,2,210,1,22,255]; //set Riding Mode 1 case 32:return [85,170,3,17,2,210,2,21,255]; //set Riding Mode 2 case 33:return [85,170,3,17,2,210,3,20,255]; //set Riding Mode 3 case 34:return [85,170,3,17,2,210,4,19,255]; //set Riding Mode 4 case 35:return [85,170,3,17,2,210,5,18,255]; //set Riding Mode 5 case 36:return [85,170,3,17,2,210,6,17,255]; //set Riding Mode 6 - case 37:return [85,170,3,17,2,210,7,16,255]; //set Riding Mode 7 + case 37:return [85,170,3,17,2,210,7,16,255]; //set Riding Mode 7 case 38:return [85,170,3,17,2,210,8,15,255]; //set Riding Mode 8 case 39:return [85,170,3,17,2,210,9,14,255]; //set Riding Mode 9 } @@ -36,8 +36,8 @@ euc.wri=function(i) {if (ew.is.bt===2) console.log("not connected yet"); if (i== euc.conn=function(mac){ if ( euc.gatt!="undefined") { - if (ew.def.cli) print("ble allready connected"); - if (euc.gatt.connected) + if (ew.def.cli) print("ble allready connected"); + if (euc.gatt.connected) euc.gatt.disconnect(); this.tgl(); return; @@ -66,13 +66,13 @@ euc.conn=function(mac){ case 38://speed euc.dash.live.spd=this.in16/1000; if (euc.dash.trip.topS < euc.dash.live.spd) euc.dash.trip.topS = euc.dash.live.spd; - euc.dash.alrt.spd.cc = ( euc.dash.alrt.spd.hapt.hi <= euc.dash.live.spd )? 2 : ( euc.dash.alrt.spd.hapt.low <= euc.dash.live.spd )? 1 : 0 ; - if ( euc.dash.alrt.spd.hapt.en && euc.dash.alrt.spd.cc == 2 ) - euc.is.alert = 1 + Math.round((euc.dash.live.spd-euc.dash.alrt.spd.hapt.hi) / euc.dash.alrt.spd.hapt.step) ; + euc.dash.alrt.spd.cc = ( euc.dash.alrt.spd.hapt.hi <= euc.dash.live.spd )? 2 : ( euc.dash.alrt.spd.hapt.low <= euc.dash.live.spd )? 1 : 0 ; + if ( euc.dash.alrt.spd.hapt.en && euc.dash.alrt.spd.cc == 2 ) + euc.is.alert = 1 + Math.round((euc.dash.live.spd-euc.dash.alrt.spd.hapt.hi) / euc.dash.alrt.spd.hapt.step) ; break; case 80://amp - if ( 32768 < this.in16 ) - euc.dash.live.amp = (this.in16 - 65536) / 100 ; + if ( 32768 < this.in16 ) + euc.dash.live.amp = (this.in16 - 65536) / 100 ; else euc.dash.live.amp = this.in16 / 100; euc.log.ampL.unshift(Math.round(euc.dash.live.amp)); @@ -84,7 +84,7 @@ euc.conn=function(mac){ } break; case 41://total trip - euc.dash.trip.totl=event.target.value.getUint32(6, true)/1000; + euc.dash.trip.totl=event.target.value.getUint32(6, true)/1000; euc.log.trip.forEach(function(val,pos){ if (!val) euc.log.trip[pos]=euc.dash.trip.totl;}); break; case 185://current trip @@ -92,12 +92,12 @@ euc.conn=function(mac){ break; case 71://battery fixed/voltage euc.dash.live.volt=this.in16/100; - //euc.dash.live.bat=(((this.in16/100)-51.5)*10|0); - euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*6.66 - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); + //euc.dash.live.bat=(((this.in16/100)-51.5)*10|0); + euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); euc.log.batL.unshift(euc.dash.live.bat); if (20=10) { if (face.appCurr=="dashSetNinebot") face[0].ntfy("OK","",22,4,1); - buzzer.nav([80,40,80]); + buzzer.nav([80,40,80]); }else euc.dash.opt.ride.mode=this.in16; break; case 112: //lock status @@ -124,7 +124,7 @@ euc.conn=function(mac){ break; } //buzz - if (euc.is.alert && !euc.is.buzz) { + if (euc.is.alert && !euc.is.buzz) { if (!w.gfx.isOn&&(euc.dash.alrt.spd.cc||euc.dash.alrt.amp.cc||euc.dash.alrt.pwr)) face.go(ew.is.dash[ew.def.dash.face],0); euc.is.buzz=1; if (20<=euc.is.alert) euc.is.alert=20; @@ -134,17 +134,17 @@ euc.conn=function(mac){ euc.is.alert=euc.is.alert-5; } for (let i = 0; i < euc.is.alert ; i++) a.push(150,150); - buzzer.euc(a); + buzzer.euc(a); setTimeout(() => {euc.is.buzz=0; }, 3000); } }); //on disconnect euc.gatt.device.on('gattserverdisconnected', euc.off); - euc.temp.rCha.startNotifications(); + euc.temp.rCha.startNotifications(); return rc; }).then(function(c) { - //connected - if (ew.is.bt===2) console.log("EUC: Connected"); + //connected + if (ew.is.bt===2) console.log("EUC: Connected"); euc.state="READY"; //connected buzzer.nav([90,40,150,40,90]); euc.dash.opt.lock.en=0; @@ -154,7 +154,7 @@ euc.conn=function(mac){ euc.is.busy=1; if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} if (euc.gatt && euc.gatt.connected) { - euc.tout.loop=setTimeout( function(){ + euc.tout.loop=setTimeout( function(){ euc.tout.loop=0; if (!euc.gatt) {euc.off("not connected");return;} euc.temp.wCha.writeValue(euc.cmd((euc.dash.opt.lock.en)?21:25)).then(function() { @@ -168,14 +168,14 @@ euc.conn=function(mac){ }else{ euc.temp.wCha.writeValue(euc.cmd(i)).then(function() { if (euc.is.busy==1) return; - euc.tout.loop=setTimeout( function(){ + euc.tout.loop=setTimeout( function(){ euc.tout.loop=0; euc.temp.count++; if (euc.temp.count>=21)euc.temp.count=0; euc.wri(euc.temp.count); - },50); + },50); }).catch(euc.off); - } + } }; if (!ew.do.fileRead("dash","slot"+ew.do.fileRead("dash","slot")+"Mac")) { euc.dash.info.get.mac=euc.mac; euc.dash.opt.bat.hi=413; @@ -186,4 +186,4 @@ euc.conn=function(mac){ setTimeout(() => {euc.wri((euc.dash.opt.lock.en)?22:26);euc.is.run=1;}, 500); //reconnect }).catch(euc.off); -}; \ No newline at end of file +}; diff --git a/v2/euc/eucNinebotZ/eucNinebotZ.js b/v2/euc/eucNinebotZ/eucNinebotZ.js index fcb343ef..08e72c98 100644 --- a/v2/euc/eucNinebotZ/eucNinebotZ.js +++ b/v2/euc/eucNinebotZ/eucNinebotZ.js @@ -4,18 +4,17 @@ euc.cmd=function(no){ switch (no) { // case "live":return [90,165,1,62,20,01,176,32,219,254]; //Current Amperage with sign if v[80] > 32768 I = v[80] - 65536 else I = v[80] in Amperes * 100 case "live" :return [0x5a,0xa5,0x01,0x3e,0x14,0x01,0xb0,0x20,0xdb,0xfe]; //Current Amperage with sign if v[80] > 32768 I = v[80] - 65536 else I = v[80] in Amperes * 100 - case "live1":return [0x5a,0xa5,0x01,0x3e,0x14,0x01,0x68,0x02,0x41,0xff]; - case "live2":return [0x5a,0xa5,0x01,0x3e,0x14,0x01,0x10,0x0e,0x8d,0xff]; - case "live3":return [0x5a,0xa5,0x01,0x3e,0x14,0x01,0x1a,0x02,0x8f,0xff]; + case "live1":return [0x5a,0xa5,0x01,0x3e,0x14,0x01,0x68,0x02,0x41,0xff]; + case "live2":return [0x5a,0xa5,0x01,0x3e,0x14,0x01,0x10,0x0e,0x8d,0xff]; + case "live3":return [0x5a,0xa5,0x01,0x3e,0x14,0x01,0x1a,0x02,0x8f,0xff]; } }; // euc.wri=function(i) {if (ew.is.bt===2) console.log("not connected yet"); if (i=="end") euc.off(); return;}; euc.conn=function(mac){ - if ( euc.gatt!="undefined") { - if (ew.def.cli) print("ble allready connected"); - if (euc.gatt.connected) + if (ew.def.cli) print("ble allready connected"); + if (euc.gatt.connected) euc.gatt.disconnect(); this.tgl(); return; @@ -41,9 +40,9 @@ euc.conn=function(mac){ //speed euc.dash.live.spd=event.target.value.getUint16(17, true)/100; if (euc.dash.trip.topS < euc.dash.live.spd) euc.dash.trip.topS = euc.dash.live.spd; - euc.dash.alrt.spd.cc = ( euc.dash.alrt.spd.hapt.hi <= euc.dash.live.spd )? 2 : ( euc.dash.alrt.spd.hapt.low <= euc.dash.live.spd )? 1 : 0 ; - if ( euc.dash.alrt.spd.hapt.en && euc.dash.alrt.spd.cc == 2 ) - euc.is.alert = 1 + Math.round((euc.dash.live.spd-euc.dash.alrt.spd.hapt.hi) / euc.dash.alrt.spd.hapt.step) ; + euc.dash.alrt.spd.cc = ( euc.dash.alrt.spd.hapt.hi <= euc.dash.live.spd )? 2 : ( euc.dash.alrt.spd.hapt.low <= euc.dash.live.spd )? 1 : 0 ; + if ( euc.dash.alrt.spd.hapt.en && euc.dash.alrt.spd.cc == 2 ) + euc.is.alert = 1 + Math.round((euc.dash.live.spd-euc.dash.alrt.spd.hapt.hi) / euc.dash.alrt.spd.hapt.step) ; }else if (event.target.value.buffer[1] && event.target.value.buffer.length==20){ //print("l",event.target.value.buffer); euc.dash.trip.totl=event.target.value.getUint32(1, true)/1000; @@ -53,14 +52,14 @@ euc.conn=function(mac){ //temp euc.dash.live.tmp=event.target.value.getUint16(9, true)/10; euc.dash.alrt.tmp.cc=(euc.dash.alrt.tmp.hapt.hi - 5 <= euc.dash.live.tmp )? (euc.dash.alrt.tmp.hapt.hi <= euc.dash.live.tmp )?2:1:0; - if (euc.dash.alrt.tmp.hapt.en && euc.dash.alrt.tmp.cc==2) euc.is.alert++; + if (euc.dash.alrt.tmp.hapt.en && euc.dash.alrt.tmp.cc==2) euc.is.alert++; //volt euc.dash.live.volt=(event.target.value.getUint16(11, true)/100); - euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*7.13 - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); + euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); euc.log.batL.unshift(euc.dash.live.bat); if (20 { euc.is.buzz = 0; }, 3000); } }); //on disconnect euc.gatt.device.on('gattserverdisconnected', euc.off); - euc.temp.rCha.startNotifications(); + euc.temp.rCha.startNotifications(); return rc; }).then(function(c) { - //connected - if (ew.is.bt===2) console.log("EUC: Connected"); + //connected + if (ew.is.bt===2) console.log("EUC: Connected"); euc.state="READY"; //connected buzzer.nav([90,40,150,40,90]); euc.dash.opt.lock.en=0; @@ -122,13 +121,14 @@ euc.conn=function(mac){ }else { euc.state="OFF"; euc.off("not connected"); - return; } + return; + } } else { euc.temp.wCha.writeValue(euc.cmd(cmd)).then(function() { - if (!euc.is.busy) { + if (!euc.is.busy) { euc.tout.loop=setTimeout(function(t,o){ euc.tout.loop=0; - euc.wri("live"); + euc.wri("live"); },50); } }).catch(euc.off); @@ -143,4 +143,4 @@ euc.conn=function(mac){ setTimeout(() => {euc.wri("live");euc.is.run=1;}, 500); //reconnect }).catch(euc.off); -}; \ No newline at end of file +}; diff --git a/v2/euc/eucVeteran/eucVeteran.js b/v2/euc/eucVeteran/eucVeteran.js index aa4c6cd9..7cc4f48e 100644 --- a/v2/euc/eucVeteran/eucVeteran.js +++ b/v2/euc/eucVeteran/eucVeteran.js @@ -1,4 +1,4 @@ -//Vteran euc module +//Vteran euc module E.setFlags({ pretokenise: 1 }); euc.cmd=function(no){ switch (no) { @@ -42,7 +42,7 @@ euc.temp.liveParse = function (inc){ //print(this.ev); //volt-bat euc.dash.live.volt=lala.getUint16(4)/100; - euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/(16*euc.dash.opt.bat.pack)) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); + euc.dash.live.bat=Math.round(100*(euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); euc.log.batL.unshift(euc.dash.live.bat); if (20 Date: Sun, 28 Jan 2024 11:09:48 +0300 Subject: [PATCH 22/45] A couple of small fixes for the InmotionV2 module. --- P8-testing/dash/dashScan.js | 2 +- v2/apps.json | 4 ++-- v2/euc/eucInmotionV2/eucInmotionV2.js | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/P8-testing/dash/dashScan.js b/P8-testing/dash/dashScan.js index 587ed101..51a7e644 100644 --- a/P8-testing/dash/dashScan.js +++ b/P8-testing/dash/dashScan.js @@ -170,7 +170,7 @@ touchHandler[0]=function(e,x,y){ ew.do.fileWrite("dash","slot"+require("Storage").readJSON("dash.json",1).slot+"Name","V2"); euc.dash.info.get.name=0; euc.dash.info.get.makr="InmotionV2"; - face.go('w_scan',0,'ffe0'); + face.go('w_scan',0,'6e400001-b5a3-f393-e0a9-e50e24dcca9e'); return; } }else if(100 Date: Sun, 28 Jan 2024 16:44:05 +0300 Subject: [PATCH 23/45] A couple more syntax fixes for the InmotionV2 module. --- v2/apps.json | 2 +- v2/euc/eucInmotionV2/eucInmotionV2.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index b65c2ed3..9783f4d6 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.3", + "version":"0.4", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index bce329cf..03aa92dd 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -83,7 +83,7 @@ function checksum(check, val) { } // function validateChecksum(buffer) { - receivedChecksum = buffer[buffer.length - 1]; + let receivedChecksum = buffer[buffer.length - 1]; array = new Uint8Array(buffer, 0, buffer.length - 1); let calculatedChecksum = array.reduce(checksum)&0xFF; return receivedChecksum == calculatedChecksum; @@ -99,7 +99,7 @@ function getModelName(id) { // euc.temp.parseMainInfo = function (inc){ let lala = new DataView(inc); - len dataLen = lala.getUint8(3) + let dataLen = lala.getUint8(3); if(inc[5] == 0x01 && dataLen >= 6) { if (ew.is.bt===2) console.log("Parse main data"); // 020601010100 -v11 @@ -128,14 +128,14 @@ euc.temp.parseMainInfo = function (inc){ if(motherboard1 < 1 && motherboard2 < 4) { euc.temp.protocol = 1; euc.temp.parseLive = euc.temp.parseLiveV11v1; - else euc.temp.protocol = 2; + } else euc.temp.protocol = 2; } } // euc.temp.parseSettings = function (inc){ if (ew.is.bt===2) console.log("Parse main data"); let lala = new DataView(inc); - len dataLen = lala.getUint8(3) + let dataLen = lala.getUint8(3) if (dataLen<8) { if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); return; @@ -147,7 +147,7 @@ euc.temp.parseSettings = function (inc){ euc.temp.parseLiveV11v1 = function (inc){ if (ew.is.bt===2) console.log("Parse realtime data (V11 old)"); let lala = new DataView(inc); - len dataLen = lala.getUint8(3) + let dataLen = lala.getUint8(3); if (dataLen<21) { if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); return; @@ -169,7 +169,7 @@ euc.temp.parseLiveV11v1 = function (inc){ euc.temp.parseLiveV11v2 = function (inc){ if (ew.is.bt===2) console.log("Parse realtime data (V11)"); let lala = new DataView(inc); - len dataLen = lala.getUint8(3) + let dataLen = lala.getUint8(3); if (dataLen<46) { if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); return; @@ -191,7 +191,7 @@ euc.temp.parseLiveV11v2 = function (inc){ euc.temp.parseLiveV12 = function (inc){ if (ew.is.bt==2) console.log("Parse realtime data (V12)"); let lala = new DataView(inc); - len dataLen = lala.getUint8(3) + let dataLen = lala.getUint8(3); if (dataLen<44) { if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); return; @@ -213,7 +213,7 @@ euc.temp.parseLiveV12 = function (inc){ euc.temp.parseLiveV13 = function (inc){ if (ew.is.bt==2) console.log("Parse realtime data (V13)"); let lala = new DataView(inc); - len dataLen = lala.getUint8(3) + let dataLen = lala.getUint8(3); if (dataLen<62) { if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); return; @@ -287,7 +287,7 @@ euc.temp.parseStats = function (inc){ if (ew.is.bt===2) console.log("Parse total stats data"); euc.is.lastGetStats = getTime(); let lala = new DataView(inc); - len dataLen = lala.getUint8(3) + let dataLen = lala.getUint8(3); if (dataLen<22) { if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); return; @@ -489,4 +489,4 @@ euc.conn=function(mac){ setTimeout(() => {euc.wri("start");}, 200); //reconnect }).catch(euc.off); -}; +} From 8cb057f67a96962740412a5212edc8f4f36d1674 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 09:08:50 +0300 Subject: [PATCH 24/45] A syntax fix for the InmotionV2 module. --- v2/euc/eucInmotionV2/eucInmotionV2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index 03aa92dd..388ca781 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -449,8 +449,8 @@ euc.conn=function(mac){ euc.tout.loop=setTimeout(function(){ euc.tout.loop=0;euc.tout.busy=0;euc.is.run=1; euc.tout.intervalKeep=setInterval(function(){ - try euc.temp.keepAlive(); - catch(e) return; + try { euc.temp.keepAlive(); + } catch(e) { return; } },200); },200); } else if (cmd === "hornOn") { From f11c08dd7587385be35461c545416288f7fd4795 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 09:58:40 +0300 Subject: [PATCH 25/45] Increased the module version number InmotionV2 --- v2/apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/apps.json b/v2/apps.json index 9783f4d6..eb98b4dc 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4", + "version":"0.4.1", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", From abbb43373d775e20f5b58b659d541924a730eb01 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 10:12:09 +0300 Subject: [PATCH 26/45] Small fix module InmotionV10 --- v2/apps.json | 2 +- v2/euc/eucInmotionV10/eucInmotionV10.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index 9783f4d6..c524189f 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -805,7 +805,7 @@ { "id": "eucInmotionV10", "name": "Inmotion V5/8/10 module", "icon": "../../v2/euc/eucInmotionV10/icon.png", - "version":"1.94.9", + "version":"1.94.10", "description": "EUC module for Inmotion V5/8/10.", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index a0440a76..2547f6cb 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -283,7 +283,7 @@ euc.temp.inpk = function(event) { if (ew.is.bt===2) console.log("Inmotion: info in"); } else { if (!validateChecksum(euc.temp.tot.buffer)) { - if (ew.is.bt===2) console.log("Inmotion: info packet error checksum. Skipping"; + if (ew.is.bt===2) console.log("Inmotion: info packet error checksum. Skipping"); return; } if (ew.is.bt===2) console.log("Inmotion: info packet checksum PASS"); From 48997deb9a6f94692f1ba1aab292eb6b5d40cdf1 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 10:12:09 +0300 Subject: [PATCH 27/45] Small fix module InmotionV10 --- v2/apps.json | 2 +- v2/euc/eucInmotionV10/eucInmotionV10.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index eb98b4dc..d50c2050 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -805,7 +805,7 @@ { "id": "eucInmotionV10", "name": "Inmotion V5/8/10 module", "icon": "../../v2/euc/eucInmotionV10/icon.png", - "version":"1.94.9", + "version":"1.94.10", "description": "EUC module for Inmotion V5/8/10.", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV10/eucInmotionV10.js b/v2/euc/eucInmotionV10/eucInmotionV10.js index a0440a76..2547f6cb 100644 --- a/v2/euc/eucInmotionV10/eucInmotionV10.js +++ b/v2/euc/eucInmotionV10/eucInmotionV10.js @@ -283,7 +283,7 @@ euc.temp.inpk = function(event) { if (ew.is.bt===2) console.log("Inmotion: info in"); } else { if (!validateChecksum(euc.temp.tot.buffer)) { - if (ew.is.bt===2) console.log("Inmotion: info packet error checksum. Skipping"; + if (ew.is.bt===2) console.log("Inmotion: info packet error checksum. Skipping"); return; } if (ew.is.bt===2) console.log("Inmotion: info packet checksum PASS"); From c4cb3b690d41b0fb9e582c4ec0cf014427de1fa7 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 10:45:05 +0300 Subject: [PATCH 28/45] Final syntax fixes for the InmotionV2 module --- v2/euc/eucInmotionV2/eucInmotionV2.js | 49 ++++++++++++++------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index 388ca781..6620c6f3 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -80,14 +80,14 @@ euc.cmd=function(no,val){ // function checksum(check, val) { return (check ^ val); -} +}; // function validateChecksum(buffer) { let receivedChecksum = buffer[buffer.length - 1]; array = new Uint8Array(buffer, 0, buffer.length - 1); let calculatedChecksum = array.reduce(checksum)&0xFF; return receivedChecksum == calculatedChecksum; -} +}; function getModelName(id) { switch (id) { case 6: euc.temp.parseLive = euc.temp.parseLiveV11v2; return "V11"; @@ -95,7 +95,7 @@ function getModelName(id) { case 8: euc.temp.parseLive = euc.temp.parseLiveV13; return "V13"; } return "UNKNOWN"; -} +}; // euc.temp.parseMainInfo = function (inc){ let lala = new DataView(inc); @@ -129,20 +129,21 @@ euc.temp.parseMainInfo = function (inc){ euc.temp.protocol = 1; euc.temp.parseLive = euc.temp.parseLiveV11v1; } else euc.temp.protocol = 2; + } } -} +}; // euc.temp.parseSettings = function (inc){ if (ew.is.bt===2) console.log("Parse main data"); let lala = new DataView(inc); - let dataLen = lala.getUint8(3) + let dataLen = lala.getUint8(3); if (dataLen<8) { if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); return; } euc.dash.alrt.spd.max = lala.getUint16(6, true)/100; euc.dash.opt.snd.vol = lala.getUint8(13); -} +}; // euc.temp.parseLiveV11v1 = function (inc){ if (ew.is.bt===2) console.log("Parse realtime data (V11 old)"); @@ -164,7 +165,7 @@ euc.temp.parseLiveV11v1 = function (inc){ // battery temp euc.dash.live.tmp2 = lala.getUint8(24) - 176; euc.temp.liveAll(); -} +}; // euc.temp.parseLiveV11v2 = function (inc){ if (ew.is.bt===2) console.log("Parse realtime data (V11)"); @@ -186,7 +187,7 @@ euc.temp.parseLiveV11v2 = function (inc){ // battery temp euc.dash.live.tmp2 = lala.getUint8(49) - 176; euc.temp.liveAll(); -} +}; // euc.temp.parseLiveV12 = function (inc){ if (ew.is.bt==2) console.log("Parse realtime data (V12)"); @@ -208,7 +209,7 @@ euc.temp.parseLiveV12 = function (inc){ // battery temp euc.dash.live.tmp2 = lala.getUint8(47) - 176; euc.temp.liveAll(); -} +}; // euc.temp.parseLiveV13 = function (inc){ if (ew.is.bt==2) console.log("Parse realtime data (V13)"); @@ -230,7 +231,7 @@ euc.temp.parseLiveV13 = function (inc){ // battery temp euc.dash.live.tmp2 = lala.getUint8(65) - 176; euc.temp.liveAll(); -} +}; // euc.temp.liveAll = function (){ euc.is.lastGetLive = getTime(); @@ -275,13 +276,13 @@ euc.temp.liveAll = function (){ euc.is.alert = euc.is.alert - 5; } let i; - for (i = 0; i < euc.is.alert ; i++) { + for (i = 0; i < euc.is.alert; i++) { a.push(200,150); } buzzer.euc(a); setTimeout(() => { euc.is.buzz = 0; }, 3000); } -} +}; // euc.temp.parseStats = function (inc){ if (ew.is.bt===2) console.log("Parse total stats data"); @@ -302,7 +303,7 @@ euc.temp.parseStats = function (inc){ if (2 {euc.wri("start");}, 200); //reconnect }).catch(euc.off); -} +}; From e010355961b5ced19c75fdd3af8b02e8cc764b2c Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 12:33:36 +0300 Subject: [PATCH 29/45] Several fixes to the InmotionV2 module --- v2/apps.json | 2 +- v2/euc/eucInmotionV2/eucInmotionV2.js | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index d50c2050..b20d339f 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4.1", + "version":"0.4.2", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index 6620c6f3..a80301a0 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -134,7 +134,7 @@ euc.temp.parseMainInfo = function (inc){ }; // euc.temp.parseSettings = function (inc){ - if (ew.is.bt===2) console.log("Parse main data"); + if (ew.is.bt===2) console.log("Parse settings data"); let lala = new DataView(inc); let dataLen = lala.getUint8(3); if (dataLen<8) { @@ -337,23 +337,19 @@ euc.temp.inpk = function(event) { return; } // - if (euc.temp.tot.buffer[2] == 0x11 && (euc.temp.tot.buffer[4]&0x7F) == 0x02) { + let m = euc.temp.tot.buffer[2]; + let t = euc.temp.tot.buffer[4] & 0x7F; + if (m == 0x11 && t == 0x02) { euc.temp.parseMainInfo(euc.temp.tot.buffer); return; } - if (euc.temp.tot.buffer[2] == 0x14) { - if ((euc.temp.tot.buffer[4]&0x7F) == 0x20) { - if (euc.dash.info.get.modl == "V11") euc.temp.parseSettings(euc.temp.tot.buffer); - return; - } - if ((euc.temp.tot.buffer[4]&0x7F) == 0x11) { - euc.temp.parseStats(euc.temp.tot.buffer); - return; - } - if ((euc.temp.tot.buffer[4]&0x7F) == 0x04) { - euc.temp.parseLive(euc.temp.tot.buffer); - } - } else return; + if (m == 0x14) { + if (t == 0x20) if (euc.dash.info.get.modl == "V11") euc.temp.parseSettings(euc.temp.tot.buffer); + else if (t == 0x11) euc.temp.parseStats(euc.temp.tot.buffer); + else if (t == 0x04) euc.temp.parseLive(euc.temp.tot.buffer); + else console.log("Unknown Info packet. Dropped"); + return; + } else console.log("Unknown packet. Dropped"); }; euc.temp.keepAlive = function() { From baf71439db2e5ab16d0519006b4c20268f8e03b3 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 14:19:45 +0300 Subject: [PATCH 30/45] Added a crutch to correct double bytes with the value 0xA5 --- v2/apps.json | 2 +- v2/euc/eucInmotionV2/eucInmotionV2.js | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index b20d339f..cfae9df5 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4.2", + "version":"0.4.3", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index a80301a0..4183b882 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -305,8 +305,29 @@ euc.temp.parseStats = function (inc){ if (2= len) break; + if (oldByte === 0xA5 && buf[p] === 0xA5) { + p++; + continue; + } + newArr[i] = buf[p]; + oldByte = buf[p]; + p++; + } + if (ew.is.bt===2&&euc.dbg==3) console.log("InmotionV2: in after crutch: length: ", needLen, " data: ",[].map.call(newBuf, x => x.toString(16)).toString()); + return newArr; +}; +// euc.temp.inpk = function(event) { - if (ew.is.bt===2&&euc.dbg==3) console.log("InmotionV2: packet in: ",event.target.value.buffer); + if (ew.is.bt===2&&euc.dbg==3) console.log("InmotionV2: packet in: ",[].map.call(event.target.value, x => x.toString(16)).toString()); //gather package let inc=event.target.value.buffer; if (ew.is.bt==5) euc.proxy.w(inc); @@ -317,6 +338,7 @@ euc.temp.inpk = function(event) { euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); let needBufLen=euc.temp.tot.buffer[3] + 5; if (euc.temp.tot.buffer.length < needBufLen) return; + euc.temp.tot = crutchDoubleA5(euc.temp.tot); if (euc.temp.tot.buffer.length > needBufLen) { console.log("InmotionV2: Packet size error. Dropped."); euc.temp.tot=E.toUint8Array([0]); @@ -325,7 +347,7 @@ euc.temp.inpk = function(event) { } delete inc; euc.temp.last = E.toUint8Array(); - if (ew.is.bt===2) console.log("InmotionV2: in: length:",euc.temp.tot.buffer.length," data :",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); + if (ew.is.bt===2) console.log("InmotionV2: in: length: ",euc.temp.tot.buffer.length," data: ",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); // Check packet if ( !validateChecksum(euc.temp.tot.buffer) ) { From e624b00c8211ee73700b45f5392676d9d5a72ede Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 14:37:56 +0300 Subject: [PATCH 31/45] Small fix InmotionV2 --- v2/euc/eucInmotionV2/eucInmotionV2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index 4183b882..4e9f51cd 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -322,7 +322,7 @@ crutchDoubleA5 = function(buf) { oldByte = buf[p]; p++; } - if (ew.is.bt===2&&euc.dbg==3) console.log("InmotionV2: in after crutch: length: ", needLen, " data: ",[].map.call(newBuf, x => x.toString(16)).toString()); + if (ew.is.bt===2&&euc.dbg==3) console.log("InmotionV2: in after crutch: length: ", needLen, " data: ",[].map.call(newArr, x => x.toString(16)).toString()); return newArr; }; // From 31d963b107077fa84bc7132aef6cda523cc71b25 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 14:41:34 +0300 Subject: [PATCH 32/45] And one more fix InmotionV2 --- v2/apps.json | 2 +- v2/euc/eucInmotionV2/eucInmotionV2.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index cfae9df5..e89bf6fd 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4.3", + "version":"0.4.4", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index 4e9f51cd..645a2700 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -327,7 +327,7 @@ crutchDoubleA5 = function(buf) { }; // euc.temp.inpk = function(event) { - if (ew.is.bt===2&&euc.dbg==3) console.log("InmotionV2: packet in: ",[].map.call(event.target.value, x => x.toString(16)).toString()); + if (ew.is.bt===2&&euc.dbg==3) console.log("InmotionV2: packet in: ",[].map.call(event.target.value.buffer, x => x.toString(16)).toString()); //gather package let inc=event.target.value.buffer; if (ew.is.bt==5) euc.proxy.w(inc); From da17a1094652a967ae96eb5b1e200f4d9997f1af Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 15:36:30 +0300 Subject: [PATCH 33/45] Another fix for the Inmotion V2 module --- v2/apps.json | 2 +- v2/euc/eucInmotionV2/eucInmotionV2.js | 27 +++++++++++---------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index e89bf6fd..652e764d 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4.4", + "version":"0.4.5", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index 645a2700..b20a1423 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -312,14 +312,11 @@ crutchDoubleA5 = function(buf) { let oldByte = 0x00; let p = 0; let newArr = new Uint8Array(needLen); - for (i = 0; i < needLen; i++) { - if (p >= len) break; - if (oldByte === 0xA5 && buf[p] === 0xA5) { - p++; - continue; - } - newArr[i] = buf[p]; - oldByte = buf[p]; + for (i = 0; i < Len; i++) { + if (p >= needlen) break; + if (oldByte === 0xA5 && buf[i] === 0xA5) continue; + newArr[p] = buf[i]; + oldByte = buf[i]; p++; } if (ew.is.bt===2&&euc.dbg==3) console.log("InmotionV2: in after crutch: length: ", needLen, " data: ",[].map.call(newArr, x => x.toString(16)).toString()); @@ -338,24 +335,22 @@ euc.temp.inpk = function(event) { euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); let needBufLen=euc.temp.tot.buffer[3] + 5; if (euc.temp.tot.buffer.length < needBufLen) return; - euc.temp.tot = crutchDoubleA5(euc.temp.tot); + delete inc; + delete euc.temp.last; if (euc.temp.tot.buffer.length > needBufLen) { - console.log("InmotionV2: Packet size error. Dropped."); - euc.temp.tot=E.toUint8Array([0]); - euc.temp.last=E.toUint8Array(euc.temp.tot.buffer); - return; + console.log("InmotionV2: Packet size error. Trying a crutch."); + euc.temp.tot = crutchDoubleA5(euc.temp.tot); } - delete inc; - euc.temp.last = E.toUint8Array(); if (ew.is.bt===2) console.log("InmotionV2: in: length: ",euc.temp.tot.buffer.length," data: ",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); - // Check packet if ( !validateChecksum(euc.temp.tot.buffer) ) { if (ew.is.bt===2) console.log("Fail checksum, packet dropped"); + euc.temp.tot=E.toUint8Array(); return; } if ( euc.temp.tot.buffer[3] == 0 ) { if (ew.is.bt===2) console.log("No data, packet dropped"); + euc.temp.tot=E.toUint8Array(); return; } // From c0aa3dcd6ab3977f24fcdef80e99c6a4fad0c991 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Mon, 29 Jan 2024 17:29:27 +0300 Subject: [PATCH 34/45] Another fix for the InmotionV2 module --- v2/euc/eucInmotionV2/eucInmotionV2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index b20a1423..c6cd2484 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -338,7 +338,7 @@ euc.temp.inpk = function(event) { delete inc; delete euc.temp.last; if (euc.temp.tot.buffer.length > needBufLen) { - console.log("InmotionV2: Packet size error. Trying a crutch."); + if (ew.is.bt===2) console.log("InmotionV2: Packet size error. Trying a crutch."); euc.temp.tot = crutchDoubleA5(euc.temp.tot); } if (ew.is.bt===2) console.log("InmotionV2: in: length: ",euc.temp.tot.buffer.length," data: ",[].map.call(euc.temp.tot, x => x.toString(16)).toString()); From 5c0ad25de394899521851716d77d4ef1caeabeea Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Tue, 30 Jan 2024 09:31:02 +0300 Subject: [PATCH 35/45] Fix for the InmotionV2 module --- v2/apps.json | 2 +- v2/euc/eucInmotionV2/eucInmotionV2.js | 37 +++++++++++++++++---------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index 652e764d..cf80b798 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4.5", + "version":"0.4.6", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index c6cd2484..2fc15b90 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -97,7 +97,7 @@ function getModelName(id) { return "UNKNOWN"; }; // -euc.temp.parseMainInfo = function (inc){ +euc.temp.parseMainInfo = function (inc) { let lala = new DataView(inc); let dataLen = lala.getUint8(3); if(inc[5] == 0x01 && dataLen >= 6) { @@ -133,7 +133,7 @@ euc.temp.parseMainInfo = function (inc){ } }; // -euc.temp.parseSettings = function (inc){ +euc.temp.parseSettings = function (inc) { if (ew.is.bt===2) console.log("Parse settings data"); let lala = new DataView(inc); let dataLen = lala.getUint8(3); @@ -145,7 +145,7 @@ euc.temp.parseSettings = function (inc){ euc.dash.opt.snd.vol = lala.getUint8(13); }; // -euc.temp.parseLiveV11v1 = function (inc){ +euc.temp.parseLiveV11v1 = function (inc) { if (ew.is.bt===2) console.log("Parse realtime data (V11 old)"); let lala = new DataView(inc); let dataLen = lala.getUint8(3); @@ -189,7 +189,7 @@ euc.temp.parseLiveV11v2 = function (inc){ euc.temp.liveAll(); }; // -euc.temp.parseLiveV12 = function (inc){ +euc.temp.parseLiveV12 = function (inc) { if (ew.is.bt==2) console.log("Parse realtime data (V12)"); let lala = new DataView(inc); let dataLen = lala.getUint8(3); @@ -211,7 +211,7 @@ euc.temp.parseLiveV12 = function (inc){ euc.temp.liveAll(); }; // -euc.temp.parseLiveV13 = function (inc){ +euc.temp.parseLiveV13 = function (inc) { if (ew.is.bt==2) console.log("Parse realtime data (V13)"); let lala = new DataView(inc); let dataLen = lala.getUint8(3); @@ -233,7 +233,7 @@ euc.temp.parseLiveV13 = function (inc){ euc.temp.liveAll(); }; // -euc.temp.liveAll = function (){ +euc.temp.liveAll = function () { euc.is.lastGetLive = getTime(); //batt euc.dash.live.bat = Math.round(100*(euc.dash.live.volt*(100/euc.dash.opt.bat.pack) - euc.dash.opt.bat.low ) / (euc.dash.opt.bat.hi-euc.dash.opt.bat.low)); @@ -284,7 +284,7 @@ euc.temp.liveAll = function (){ } }; // -euc.temp.parseStats = function (inc){ +euc.temp.parseStats = function (inc) { if (ew.is.bt===2) console.log("Parse total stats data"); euc.is.lastGetStats = getTime(); let lala = new DataView(inc); @@ -361,12 +361,23 @@ euc.temp.inpk = function(event) { return; } if (m == 0x14) { - if (t == 0x20) if (euc.dash.info.get.modl == "V11") euc.temp.parseSettings(euc.temp.tot.buffer); - else if (t == 0x11) euc.temp.parseStats(euc.temp.tot.buffer); - else if (t == 0x04) euc.temp.parseLive(euc.temp.tot.buffer); - else console.log("Unknown Info packet. Dropped"); - return; - } else console.log("Unknown packet. Dropped"); + switch (t) { + case 0x20: + if (euc.dash.info.get.modl == "V11") euc.temp.parseSettings(euc.temp.tot.buffer); + break; + case 0x11: + euc.temp.parseStats(euc.temp.tot.buffer); + break; + case 0x04: + euc.temp.parseLive(euc.temp.tot.buffer); + break; + default: + if (ew.is.bt===2) console.log("Unknown Info packet. Dropped"); + break; + } + } else { + if (ew.is.bt===2) console.log("Unknown packet. Dropped"); + } }; euc.temp.keepAlive = function() { From e4311874b3b9b8d9b3961f9bcd9c6dba8712c3f4 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Tue, 30 Jan 2024 20:07:05 +0300 Subject: [PATCH 36/45] Added manufacturing date calculation to the InmotionV2 module --- v2/apps.json | 2 +- v2/euc/eucInmotionV2/eucInmotionV2.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/v2/apps.json b/v2/apps.json index cf80b798..f4336e5f 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4.6", + "version":"0.4.7", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index 2fc15b90..0c0c7148 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -117,6 +117,14 @@ euc.temp.parseMainInfo = function (inc) { for (let i = 6; i < 22; i++) { euc.dash.info.get.serl += String.fromCharCode(lala.getUint8(i)); } + //manufacture date + //26 + let year = 2000 + parseInt(euc.dash.info.get.serl.substr(0,2), 16); + //((lala.getUint8(25) & 0xF0) >> 4); + let month = parseInt(euc.dash.info.get.serl.substr(2,1), 16); + //((lala.getUint8(25) & 0x0F) << 4) | (lala.getUint8(24) & 0x0F); + let date = parseInt(euc.dash.info.get.serl.substr(3,1) + euc.dash.info.get.serl.substr(5,1), 16); + euc.dash.info.get.manD=[year.toString(10), month.toString(10), date.toString(10)].join('-'); } else if(inc[5] == 0x06 && dataLen >= 24) { if (ew.is.bt===2) console.log("Parse version"); euc.temp.protocol = 0; From ea23c558e40539e3c88ef3234607d0cddabf0867 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Tue, 30 Jan 2024 20:08:44 +0300 Subject: [PATCH 37/45] Cleaned up --- v2/euc/eucInmotionV2/eucInmotionV2.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index 0c0c7148..32e5f497 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -118,11 +118,8 @@ euc.temp.parseMainInfo = function (inc) { euc.dash.info.get.serl += String.fromCharCode(lala.getUint8(i)); } //manufacture date - //26 let year = 2000 + parseInt(euc.dash.info.get.serl.substr(0,2), 16); - //((lala.getUint8(25) & 0xF0) >> 4); let month = parseInt(euc.dash.info.get.serl.substr(2,1), 16); - //((lala.getUint8(25) & 0x0F) << 4) | (lala.getUint8(24) & 0x0F); let date = parseInt(euc.dash.info.get.serl.substr(3,1) + euc.dash.info.get.serl.substr(5,1), 16); euc.dash.info.get.manD=[year.toString(10), month.toString(10), date.toString(10)].join('-'); } else if(inc[5] == 0x06 && dataLen >= 24) { From efea307b026ee07d633fb5fe0cf52f7c9b110161 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Tue, 30 Jan 2024 22:59:04 +0300 Subject: [PATCH 38/45] Added trip distance in InmotionV2 module --- v2/apps.json | 2 +- v2/euc/eucInmotionV2/eucInmotionV2.js | 51 +++++++++++++++------------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index f4336e5f..4cd20984 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4.7", + "version":"0.4.8", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index 32e5f497..f0a63ee7 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -298,9 +298,11 @@ euc.temp.parseStats = function (inc) { if (ew.is.bt===2) console.log("Short package. dataLen=", dataLen.toString(10)); return; } - //trip total - euc.dash.trip.totl=lala.getUint32(5, true)/100; - euc.log.trip.forEach(function(val,pos){ if (!val) euc.log.trip[pos]=euc.dash.trip.totl;}); + //trip + euc.dash.trip.totl = lala.getUint32(5, true) / 100; + if(!euc.dash.trip.startStrip) euc.dash.trip.startStrip=euc.dash.trip.totl; + euc.dash.trip.last = euc.dash.trip.totl-euc.dash.trip.startStrip; + euc.log.trip.forEach(function(val,pos){ if (!val) euc.log.trip[pos]=euc.dash.trip.totl;}); //time euc.dash.timR=(lala.getUint32(17, true)/60)|0; euc.dash.trip.time=(lala.getUint32(21, true)/60)|0; @@ -367,18 +369,18 @@ euc.temp.inpk = function(event) { } if (m == 0x14) { switch (t) { - case 0x20: - if (euc.dash.info.get.modl == "V11") euc.temp.parseSettings(euc.temp.tot.buffer); - break; - case 0x11: - euc.temp.parseStats(euc.temp.tot.buffer); - break; - case 0x04: - euc.temp.parseLive(euc.temp.tot.buffer); - break; - default: - if (ew.is.bt===2) console.log("Unknown Info packet. Dropped"); - break; + case 0x20: + if (euc.dash.info.get.modl == "V11") euc.temp.parseSettings(euc.temp.tot.buffer); + break; + case 0x11: + euc.temp.parseStats(euc.temp.tot.buffer); + break; + case 0x04: + euc.temp.parseLive(euc.temp.tot.buffer); + break; + default: + if (ew.is.bt===2) console.log("Unknown Info packet. Dropped"); + break; } } else { if (ew.is.bt===2) console.log("Unknown packet. Dropped"); @@ -390,13 +392,15 @@ euc.temp.keepAlive = function() { if (euc.tout.busy) return; euc.tout.busy = 1; let sendCommand; - if (euc.temp.keepAlive.state == 0) sendCommand = euc.cmd("getType"); - else if(euc.temp.keepAlive.state == 1) sendCommand = euc.cmd("getSN"); - else if(euc.temp.keepAlive.state == 2) sendCommand = euc.cmd("getVer"); - else if(euc.temp.keepAlive.state == 3) sendCommand = euc.cmd("getSettings"); - else if(euc.temp.keepAlive.state == 4) sendCommand = euc.cmd("getUseless"); - else if(euc.temp.keepAlive.state == 5) sendCommand = euc.cmd("stats"); - else if(euc.temp.keepAlive.state == 6) sendCommand = euc.cmd("live"); + switch (euc.temp.keepAlive.state) { + case 0: sendCommand = euc.cmd("getType"); break; + case 1: sendCommand = euc.cmd("getSN"); break; + case 2: sendCommand = euc.cmd("getVer"); break; + case 3: sendCommand = euc.cmd("getSettings"); break; + case 4: sendCommand = euc.cmd("getUseless"); break; + case 5: sendCommand = euc.cmd("stats"); break; + case 6: sendCommand = euc.cmd("live"); break; + } euc.temp.wCha.writeValue(sendCommand) .then(function() { return euc.tout.busy = 0 }) .catch(function(err) { @@ -419,6 +423,8 @@ euc.conn=function(mac){ return; } euc.isProxy=0; + euc.dash.trip.startStrip = 0; + euc.temp.keepAlive.state = 0; if (euc.tout.reconnect) {clearTimeout(euc.tout.reconnect); euc.tout.reconnect=0;} NRF.connect(mac,{minInterval:7.5, maxInterval:15}) .then(function(g) { @@ -473,7 +479,6 @@ euc.conn=function(mac){ } euc.tout.busy = 0; } else if (cmd === "start") { - euc.temp.keepAlive.state = 0; euc.temp.rCha.startNotifications(); if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} euc.tout.loop=setTimeout(function(){ From 80d1b4c2060b3d57285523e6f6e9b31f6d8b8d8d Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sun, 24 Mar 2024 11:56:14 +0300 Subject: [PATCH 39/45] Fix module InmotionV2 --- v2/apps.json | 2 +- v2/euc/eucInmotionV2/eucInmotionV2.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index 4cd20984..c0f24efe 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4.8", + "version":"0.4.9", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index f0a63ee7..cfab1495 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -407,7 +407,7 @@ euc.temp.keepAlive = function() { if (ew.is.bt===2) console.log("EUC InmotionV2: keepAlive write fail"); }); euc.temp.keepAlive.state++; - if(euc.temp.keepAlive.state < 5) return; + if(euc.temp.keepAlive.state < 7) return; if(getTime() - euc.is.lastGetStats < 1) euc.temp.keepAlive.state = 6; else euc.temp.keepAlive.state = 5; }; @@ -462,14 +462,19 @@ euc.conn=function(mac){ } euc.tout.busy = 1; if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} + if (ew.is.bt===2) console.log("InmotionV2 cmd: ", cmd); if (euc.state === "OFF" || cmd === "end") { if (euc.gatt && euc.gatt.connected) { - if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} - euc.tout.loop = setTimeout(function(){ - euc.tout.loop = 0; + if (euc.tout.loopEnd) {clearTimeout(euc.tout.loopEnd); euc.tout.loopEnd=0;} + euc.tout.loopEnd = setTimeout(function(){ + euc.tout.loopEnd = 0; if (euc.gatt && !euc.gatt.connected) {euc.off("not connected"); return;} euc.gatt.disconnect().catch(euc.off); },500); + if (euc.tout.loop) {clearTimeout(euc.tout.loop); euc.tout.loop=0;} + if (euc.tout.intervalKeep) {clearInterval(euc.tout.intervalKeep); euc.tout.intervalKeep=0;} + euc.state = "OFF"; + euc.off("end"); } else { euc.state = "OFF"; euc.off("not connected"); From 230830b0a26ac1ab29c0b60eb1b91d9c2b447b27 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sun, 31 Mar 2024 01:36:09 +0300 Subject: [PATCH 40/45] Fixed accelerometer operation when rotating the screen. --- v2/P8.json | 2 +- v2/apps.json | 2 +- v2/handler/handler_acc_SC7A20.js | 21 ++++++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/v2/P8.json b/v2/P8.json index fe669ff0..f255111b 100644 --- a/v2/P8.json +++ b/v2/P8.json @@ -1 +1 @@ -["init","handler","clock","settings","hid","alarm","dash","Dashboard Digital","Dashboard Simple","euc","tpms","w_scan","w_apps","m_gb","notify","calc","eucKingsong","dashKingsong","eucNinebotE","dashNinebotE","eucNinebotS","dashNinebotS","eucNinebotZ","dashNinebotZ","eucInmotionV10","dashInmotionV10","eucInmotionV11","dashInmotionV11","eucInmotionV12","dashInmotionV12","eucBegode","dashBegode","eucVeteran","dashVeteran"] \ No newline at end of file +["init","handler","clock","settings","hid","alarm","dash","Dashboard Digital","Dashboard Simple","euc","tpms","w_scan","w_apps","m_gb","notify","calc","rotate","eucKingsong","dashKingsong","eucNinebotE","dashNinebotE","eucNinebotS","dashNinebotS","eucNinebotZ","dashNinebotZ","eucInmotionV10","dashInmotionV10","eucInmotionV11","dashInmotionV11","eucInmotionV12","dashInmotionV12","eucBegode","dashBegode","eucVeteran","dashVeteran"] \ No newline at end of file diff --git a/v2/apps.json b/v2/apps.json index c0f24efe..a651d49e 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -145,7 +145,7 @@ { "id": "handler", "name": "Handler - V1", "icon": "../handler/icon.png", - "version":"1.94.9", + "version":"1.94.10", "description": "P8-P22-Pinetime functions handler", "tags": "core", "needsFeatures":["V1"], diff --git a/v2/handler/handler_acc_SC7A20.js b/v2/handler/handler_acc_SC7A20.js index 4ec6b506..359cd039 100644 --- a/v2/handler/handler_acc_SC7A20.js +++ b/v2/handler/handler_acc_SC7A20.js @@ -91,7 +91,26 @@ acc={ "ram"; i2c.writeTo(0x18,0xA8); var a =i2c.readFrom(0x18,6); - return {ax:this.conv(a[0],a[1]), ay:this.conv(a[2],a[3]), az:this.conv(a[4],a[5])}; + let x = this.conv(a[0],a[1]); + let y = this.conv(a[2],a[3]); + let z = this.conv(a[4],a[5]); + switch (scr.rotate) { + case 1: + let t = y; + y = x * -1; + x = t; + break; + case 2: + x = x * -1; + y = y * -1; + break; + case 3: + let t = y; + y = x; + x = t * -1; + break; + } + return {ax:x, ay:y, az:z}; }, conv:function(lo,hi){ "ram"; From e3f11f6aaf976679e28aa545d50f98576b5484e1 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sun, 31 Mar 2024 02:11:54 +0300 Subject: [PATCH 41/45] Fixed small bug in handler_acc_SC7A20 --- v2/apps.json | 2 +- v2/handler/handler_acc_SC7A20.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index a651d49e..91bcae9e 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -145,7 +145,7 @@ { "id": "handler", "name": "Handler - V1", "icon": "../handler/icon.png", - "version":"1.94.10", + "version":"1.94.11", "description": "P8-P22-Pinetime functions handler", "tags": "core", "needsFeatures":["V1"], diff --git a/v2/handler/handler_acc_SC7A20.js b/v2/handler/handler_acc_SC7A20.js index 359cd039..5fc98e2c 100644 --- a/v2/handler/handler_acc_SC7A20.js +++ b/v2/handler/handler_acc_SC7A20.js @@ -94,9 +94,10 @@ acc={ let x = this.conv(a[0],a[1]); let y = this.conv(a[2],a[3]); let z = this.conv(a[4],a[5]); + let t; switch (scr.rotate) { case 1: - let t = y; + t = y; y = x * -1; x = t; break; @@ -105,7 +106,7 @@ acc={ y = y * -1; break; case 3: - let t = y; + t = y; y = x; x = t * -1; break; From 43a7e3b7260b1899cb6cbb52afa9e920fb38fe32 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sun, 31 Mar 2024 04:57:35 +0300 Subject: [PATCH 42/45] An attempt to fix the accelerometer in watch mode (via interruption) --- P8-testing/rotate/rotate.js | 1 + v2/apps.json | 4 ++-- v2/handler/handler_acc_SC7A20.js | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/P8-testing/rotate/rotate.js b/P8-testing/rotate/rotate.js index 906cb0b8..a054ba2c 100644 --- a/P8-testing/rotate/rotate.js +++ b/P8-testing/rotate/rotate.js @@ -54,6 +54,7 @@ face[0] = { if (scr.rotate==3) scr.rotate=0; else scr.rotate++; w.gfx.setRotation(scr.rotate, scr.mirror); face[0].init(); + let t = acc.mode; acc.off(); acc.on(t); }, mirror: function(){ if (scr.mirror==true) scr.mirror=false; diff --git a/v2/apps.json b/v2/apps.json index 91bcae9e..fa87f315 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -145,7 +145,7 @@ { "id": "handler", "name": "Handler - V1", "icon": "../handler/icon.png", - "version":"1.94.11", + "version":"1.94.12", "description": "P8-P22-Pinetime functions handler", "tags": "core", "needsFeatures":["V1"], @@ -234,7 +234,7 @@ { "id": "rotate", "name": "Screen rotate", "icon": "../../P8-testing/rotate/icon.png", - "version":"1.0.0", + "version":"1.0.1", "description": "Rotate and mirror screen", "tags": "apps", "needsFeatures":["P22B"], diff --git a/v2/handler/handler_acc_SC7A20.js b/v2/handler/handler_acc_SC7A20.js index 5fc98e2c..bb0faf83 100644 --- a/v2/handler/handler_acc_SC7A20.js +++ b/v2/handler/handler_acc_SC7A20.js @@ -24,7 +24,20 @@ acc={ i2c.writeTo(0x18,0x25,0x00); //no Interrupt2 , no int polatiry i2c.writeTo(0x18,0x32,5); //int1_ths-threshold = 250 milli g's i2c.writeTo(0x18,0x33,15); //duration = 1 * 20ms - i2c.writeTo(0x18,0x30,0x02); //int1 to xh + switch (scr.rotate) { + case 0: + i2c.writeTo(0x18,0x30,0x02); //int1 to xh + break; + case 1: + i2c.writeTo(0x18,0x30,0x08); //int1 to yh + break; + case 2: + i2c.writeTo(0x18,0x30,0x01); //int1 to xl + break; + case 3: + i2c.writeTo(0x18,0x30,0x04); //int1 to yl + break; + } this.mode=(v)?v:0; this.init(v); }, @@ -69,8 +82,8 @@ acc={ i2c.writeTo(0x18,0x32,20); //int1_ths-threshold = 250 milli g's i2c.writeTo(0x18,0x33,1); //duration = 1 * 20ms ew.tid.acc=setWatch(()=>{ - i2c.writeTo(0x18,0x1); - if ( this.chk1()) { + //i2c.writeTo(0x18,0x1); + if ( this.chk2()) { if (!w.gfx.isOn){ if (face.appCurr=="clock") face.go("clock",0); else face.go(face.appCurr,0); From 6843e6f1bf0c82742c8c4c33274298d99bc12305 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Sun, 31 Mar 2024 05:33:43 +0300 Subject: [PATCH 43/45] Second attempt to fix accelerometer interruptions. --- v2/apps.json | 2 +- v2/handler/handler_acc_SC7A20.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/v2/apps.json b/v2/apps.json index fa87f315..be390702 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -145,7 +145,7 @@ { "id": "handler", "name": "Handler - V1", "icon": "../handler/icon.png", - "version":"1.94.12", + "version":"1.94.13", "description": "P8-P22-Pinetime functions handler", "tags": "core", "needsFeatures":["V1"], diff --git a/v2/handler/handler_acc_SC7A20.js b/v2/handler/handler_acc_SC7A20.js index bb0faf83..fc95f88e 100644 --- a/v2/handler/handler_acc_SC7A20.js +++ b/v2/handler/handler_acc_SC7A20.js @@ -26,16 +26,16 @@ acc={ i2c.writeTo(0x18,0x33,15); //duration = 1 * 20ms switch (scr.rotate) { case 0: - i2c.writeTo(0x18,0x30,0x02); //int1 to xh + i2c.writeTo(0x18,0x30,0xc1); //int1 to xh break; case 1: - i2c.writeTo(0x18,0x30,0x08); //int1 to yh + i2c.writeTo(0x18,0x30,0xc4); //int1 to yh break; case 2: - i2c.writeTo(0x18,0x30,0x01); //int1 to xl + i2c.writeTo(0x18,0x30,0xc2); //int1 to xl break; case 3: - i2c.writeTo(0x18,0x30,0x04); //int1 to yl + i2c.writeTo(0x18,0x30,0xc8); //int1 to yl break; } this.mode=(v)?v:0; From 852dbc210e8488e68cc845657a1d70ce83a4d6e3 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Tue, 9 Apr 2024 19:26:12 +0300 Subject: [PATCH 44/45] Two minor fixes --- P8-testing/dash/dashScan.js | 2 +- P8-testing/w_scan/.w_scan.js.swp | Bin 0 -> 1024 bytes v2/apps.json | 4 ++-- v2/euc/eucInmotionV2/eucInmotionV2.js | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 P8-testing/w_scan/.w_scan.js.swp diff --git a/P8-testing/dash/dashScan.js b/P8-testing/dash/dashScan.js index 51a7e644..ff4cbab5 100644 --- a/P8-testing/dash/dashScan.js +++ b/P8-testing/dash/dashScan.js @@ -25,7 +25,7 @@ face[0] = { let s=(n==1)?"INMOTION":(n==2)?"BEGODE":(n==3)?"NINEBOT":(n==4)?"NINEBOT":"INMOTION V2"; this.g.drawString(s,120-(this.g.stringWidth(s)/2),38); this.g.setFont("Vector",14); - let s=(n==1)?"V5/V8/V10":(n==2)?"":(n==3)?"ONE Z10":(n==4)?"ONE S2":"V11/V12/V13 TEST"; + s=(n==1)?"V5/V8/V10":(n==2)?"":(n==3)?"ONE Z10":(n==4)?"ONE S2":"V11/V12/V13 TEST"; this.g.drawString(s,120-(this.g.stringWidth(s)/2),73); this.g.flip(); this.g.setColor(0,0); diff --git a/P8-testing/w_scan/.w_scan.js.swp b/P8-testing/w_scan/.w_scan.js.swp new file mode 100644 index 0000000000000000000000000000000000000000..d07cdac6a32ad72d3a2993b05944d2bc9353b762 GIT binary patch literal 1024 zcmYc?$V<%2S1{ExVL$<&nd}*|%Mz{9=kUamr*j literal 0 HcmV?d00001 diff --git a/v2/apps.json b/v2/apps.json index be390702..4e879d31 100644 --- a/v2/apps.json +++ b/v2/apps.json @@ -270,7 +270,7 @@ { "id": "dash", "name": "EUC Dashboard", "icon": "../../P8-testing/dash/icon.png", - "version":"1.94.6", + "version":"1.94.7", "description": "EUC dashboard. Garage, scan and dash faces. Depends on EUC modules.", "tags": "euc", "needsFeatures":["V1"], @@ -854,7 +854,7 @@ { "id": "eucInmotionV2", "name": "Inmotion V2 (V11/12/13)", "icon": "../../v2/euc/eucInmotionV2/icon.png", - "version":"0.4.9", + "version":"0.4.10", "description": "EUC module for Inmotion V2. TEST", "tags": "euc", "type": "euc", diff --git a/v2/euc/eucInmotionV2/eucInmotionV2.js b/v2/euc/eucInmotionV2/eucInmotionV2.js index cfab1495..b39f4191 100644 --- a/v2/euc/eucInmotionV2/eucInmotionV2.js +++ b/v2/euc/eucInmotionV2/eucInmotionV2.js @@ -390,6 +390,7 @@ euc.temp.inpk = function(event) { euc.temp.keepAlive = function() { if ((getTime() - euc.is.lastGetLive) < 0.5) return; if (euc.tout.busy) return; + if (euc.gatt && !euc.gatt.connected) {euc.off("not connected"); return;} euc.tout.busy = 1; let sendCommand; switch (euc.temp.keepAlive.state) { @@ -405,6 +406,7 @@ euc.temp.keepAlive = function() { .then(function() { return euc.tout.busy = 0 }) .catch(function(err) { if (ew.is.bt===2) console.log("EUC InmotionV2: keepAlive write fail"); + return; }); euc.temp.keepAlive.state++; if(euc.temp.keepAlive.state < 7) return; From 631b971489006c79393d13209713e9cf0c7e4c15 Mon Sep 17 00:00:00 2001 From: Igor Vasilkov Date: Tue, 9 Apr 2024 19:28:58 +0300 Subject: [PATCH 45/45] Deleted temporary file --- P8-testing/w_scan/.w_scan.js.swp | Bin 1024 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 P8-testing/w_scan/.w_scan.js.swp diff --git a/P8-testing/w_scan/.w_scan.js.swp b/P8-testing/w_scan/.w_scan.js.swp deleted file mode 100644 index d07cdac6a32ad72d3a2993b05944d2bc9353b762..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{ExVL$<&nd}*|%Mz{9=kUamr*j